mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ext4: Convert ext4 to new truncate calling convention
Trivial conversion. Fixup one error handling case calling vmtruncate() and remove ->truncate callback. We also fix a bug that IS_IMMUTABLE and IS_APPEND files could not be truncated during failed writes. In fact, the test can be completely removed as upper layers do necessary permission checks for truncate in do_sys_[f]truncate() and may_open() anyway. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
		
							parent
							
								
									556b27abf7
								
							
						
					
					
						commit
						ae24f28d39
					
				
					 2 changed files with 1 additions and 4 deletions
				
			
		| 
						 | 
					@ -272,7 +272,6 @@ const struct file_operations ext4_file_operations = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct inode_operations ext4_file_inode_operations = {
 | 
					const struct inode_operations ext4_file_inode_operations = {
 | 
				
			||||||
	.truncate	= ext4_truncate,
 | 
					 | 
				
			||||||
	.setattr	= ext4_setattr,
 | 
						.setattr	= ext4_setattr,
 | 
				
			||||||
	.getattr	= ext4_getattr,
 | 
						.getattr	= ext4_getattr,
 | 
				
			||||||
#ifdef CONFIG_EXT4_FS_XATTR
 | 
					#ifdef CONFIG_EXT4_FS_XATTR
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3511,7 +3511,7 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
 | 
				
			||||||
			loff_t end = offset + iov_length(iov, nr_segs);
 | 
								loff_t end = offset + iov_length(iov, nr_segs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (end > isize)
 | 
								if (end > isize)
 | 
				
			||||||
				vmtruncate(inode, isize);
 | 
									ext4_truncate_failed_write(inode);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
 | 
						if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
 | 
				
			||||||
| 
						 | 
					@ -4407,8 +4407,6 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ext4_can_truncate(struct inode *inode)
 | 
					int ext4_can_truncate(struct inode *inode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	if (S_ISREG(inode->i_mode))
 | 
						if (S_ISREG(inode->i_mode))
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
	if (S_ISDIR(inode->i_mode))
 | 
						if (S_ISDIR(inode->i_mode))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue