Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jan Kara and committed by
Theodore Ts'o
ae24f28d 556b27ab

+1 -4
-1
fs/ext4/file.c
··· 272 272 }; 273 273 274 274 const struct inode_operations ext4_file_inode_operations = { 275 - .truncate = ext4_truncate, 276 275 .setattr = ext4_setattr, 277 276 .getattr = ext4_getattr, 278 277 #ifdef CONFIG_EXT4_FS_XATTR
+1 -3
fs/ext4/inode.c
··· 3511 3511 loff_t end = offset + iov_length(iov, nr_segs); 3512 3512 3513 3513 if (end > isize) 3514 - vmtruncate(inode, isize); 3514 + ext4_truncate_failed_write(inode); 3515 3515 } 3516 3516 } 3517 3517 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) ··· 4407 4407 4408 4408 int ext4_can_truncate(struct inode *inode) 4409 4409 { 4410 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) 4411 - return 0; 4412 4410 if (S_ISREG(inode->i_mode)) 4413 4411 return 1; 4414 4412 if (S_ISDIR(inode->i_mode))