Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09db6a2e authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: fix to truncate blocks past EOF in ->setattr



By using FALLOC_FL_KEEP_SIZE in ->fallocate of f2fs, we can fallocate block past
EOF without changing i_size of inode. These blocks past EOF will not be
truncated in ->setattr as we truncate them only when change the file size.

We should give a chance to truncate blocks out of filesize in setattr().

Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 976e4c50
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -560,15 +560,22 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
	if (err)
	if (err)
		return err;
		return err;


	if ((attr->ia_valid & ATTR_SIZE) &&
	if (attr->ia_valid & ATTR_SIZE) {
			attr->ia_size != i_size_read(inode)) {
		err = f2fs_convert_inline_data(inode, attr->ia_size, NULL);
		err = f2fs_convert_inline_data(inode, attr->ia_size, NULL);
		if (err)
		if (err)
			return err;
			return err;


		if (attr->ia_size != i_size_read(inode)) {
			truncate_setsize(inode, attr->ia_size);
			truncate_setsize(inode, attr->ia_size);
			f2fs_truncate(inode);
			f2fs_truncate(inode);
			f2fs_balance_fs(F2FS_I_SB(inode));
			f2fs_balance_fs(F2FS_I_SB(inode));
		} else {
			/*
			 * giving a chance to truncate blocks past EOF which
			 * are fallocated with FALLOC_FL_KEEP_SIZE.
			 */
			f2fs_truncate(inode);
		}
	}
	}


	__setattr_copy(inode, attr);
	__setattr_copy(inode, attr);