Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] ext2: Simplify error handling of IO error when adding xattr
@ 2026-07-28 15:47 Jan Kara
  0 siblings, 0 replies; only message in thread
From: Jan Kara @ 2026-07-28 15:47 UTC (permalink / raw)
  To: linux-ext4; +Cc: Jan Kara

When we fail to write out inode when adding new xattr block, we backed
out some changes (like quota modifications) but left others (like block
allocation or inode xattr block modification). Just leave the inode
intact in this case because we can hardly reach a consistent state and
defer fixing to e2fsck. Also remove outdated comment and special data
handling since sync_inode_metadata() does not write out any data.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext2/xattr.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

The inconsistency was notice by unrelated Sashiko review. I plan to merge this
through my tree.

diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index e55d16abf422..5f49ec4afc36 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -779,16 +779,12 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
 	inode_set_ctime_current(inode);
 	if (IS_SYNC(inode)) {
 		error = sync_inode_metadata(inode, 1);
-		/* In case sync failed due to ENOSPC the inode was actually
-		 * written (only some dirty data were not) so we just proceed
-		 * as if nothing happened and cleanup the unused block */
-		if (error && error != -ENOSPC) {
-			if (new_bh && new_bh != old_bh) {
-				dquot_free_block_nodirty(inode, 1);
-				mark_inode_dirty(inode);
-			}
+		/*
+		 * Inode writeout failed. Backing everything out is complex so
+		 * let's just leave it for e2fsck to cleanup the mess.
+		 */
+		if (error)
 			goto cleanup;
-		}
 	} else
 		mark_inode_dirty(inode);
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-28 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 15:47 [PATCH] ext2: Simplify error handling of IO error when adding xattr Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox