[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175573318765.4130038.17584770605415835679.stgit@frogsfrogsfrogs>
Date: Wed, 20 Aug 2025 16:43:13 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH 09/12] fuse2fs: don't write inode when inactivation fails
From: Darrick J. Wong <djwong@...nel.org>
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@...r.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index a7f7e7f1595344..2648b55893d5e7 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -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)
Powered by blists - more mailing lists