[PATCH 20/8] fuse2fs: fix punching post-EOF blocks during truncate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

ext2fs_punch() can update the inode that's passed in, so we need to
write it back.  This should fix some fstests failures where the test
file system ends up with inodes where all extent records fit within the
inode but inexplicably have extents beyond EOF.  While we're at it, add
the fuse2fs prefix to the two helper functions.

Cc: <linux-ext4@xxxxxxxxxxxxxxx> # v1.47.3
Fixes: 4581ac60eb53ec ("fuse2fs: fix post-EOF preallocation clearing on truncation")
Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
---
 misc/fuse2fs.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 18d8f426a5eb43..c6b1684f53e2e4 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -2461,7 +2461,8 @@ static int op_chown(const char *path, uid_t owner, gid_t group
 	return ret;
 }
 
-static int punch_posteof(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)
+static int fuse2fs_punch_posteof(struct fuse2fs *ff, ext2_ino_t ino,
+				 off_t new_size)
 {
 	ext2_filsys fs = ff->fs;
 	struct ext2_inode_large inode;
@@ -2477,10 +2478,14 @@ static int punch_posteof(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)
 	if (err)
 		return translate_error(fs, ino, err);
 
+	err = fuse2fs_write_inode(fs, ino, &inode);
+	if (err)
+		return translate_error(fs, ino, err);
+
 	return 0;
 }
 
-static int truncate_helper(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)
+static int fuse2fs_truncate(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)
 {
 	ext2_filsys fs = ff->fs;
 	ext2_file_t file;
@@ -2523,7 +2528,7 @@ static int truncate_helper(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)
 	 * we should clear out post-EOF preallocations.
 	 */
 	if (new_size == old_isize)
-		return punch_posteof(ff, ino, new_size);
+		return fuse2fs_punch_posteof(ff, ino, new_size);
 
 	return 0;
 }
@@ -2559,7 +2564,7 @@ static int op_truncate(const char *path, off_t len
 	if (ret)
 		goto out;
 
-	ret = truncate_helper(ff, ino, len);
+	ret = fuse2fs_truncate(ff, ino, len);
 	if (ret)
 		goto out;
 
@@ -2659,7 +2664,7 @@ static int __op_open(struct fuse2fs *ff, const char *path,
 	}
 
 	if (fp->flags & O_TRUNC) {
-		ret = truncate_helper(ff, file->ino, 0);
+		ret = fuse2fs_truncate(ff, file->ino, 0);
 		if (ret)
 			goto out;
 	}




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux