]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: don't write inode when inactivation fails
authorDarrick J. Wong <djwong@kernel.org>
Wed, 13 Aug 2025 18:00:49 +0000 (11:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 21 Aug 2025 00:00:54 +0000 (17:00 -0700)
remove_inode has this weird behavior where it writes the inode to disk
even if the attempts to inactivate it (remove xattrs, truncate data)
fail.  Worse yet, it doesn't even return the original error code, so it
masks failures.  Fix this too.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
misc/fuse2fs.c

index a7f7e7f1595344f183a1b85c42afb8bf914141c3..2648b55893d5e73a25c5539d08347f718a712e00 100644 (file)
@@ -1577,10 +1577,9 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino)
        int ret = 0;
 
        err = fuse2fs_read_inode(fs, ino, &inode);
-       if (err) {
-               ret = translate_error(fs, ino, err);
-               goto out;
-       }
+       if (err)
+               return translate_error(fs, ino, err);
+
        dbg_printf(ff, "%s: put ino=%d links=%d\n", __func__, ino,
                   inode.i_links_count);
 
@@ -1597,7 +1596,7 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino)
 
        ret = update_ctime(fs, ino, &inode);
        if (ret)
-               goto out;
+               return ret;
 
        if (inode.i_links_count)
                goto write_out;
@@ -1605,21 +1604,19 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino)
        if (ext2fs_has_feature_ea_inode(fs->super)) {
                ret = remove_ea_inodes(ff, ino, &inode);
                if (ret)
-                       goto write_out;
+                       return ret;
        }
 
        /* Nobody holds this file; free its blocks! */
        err = ext2fs_free_ext_attr(fs, ino, &inode);
        if (err)
-               goto write_out;
+               return translate_error(fs, ino, err);
 
        if (ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(&inode))) {
                err = ext2fs_punch(fs, ino, EXT2_INODE(&inode), NULL,
                                   0, ~0ULL);
-               if (err) {
-                       ret = translate_error(fs, ino, err);
-                       goto write_out;
-               }
+               if (err)
+                       return translate_error(fs, ino, err);
        }
 
        ext2fs_inode_alloc_stats2(fs, ino, -1,
@@ -1627,12 +1624,10 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino)
 
 write_out:
        err = fuse2fs_write_inode(fs, ino, &inode);
-       if (err) {
-               ret = translate_error(fs, ino, err);
-               goto out;
-       }
-out:
-       return ret;
+       if (err)
+               return translate_error(fs, ino, err);
+
+       return 0;
 }
 
 static int __op_unlink(struct fuse2fs *ff, const char *path)