From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B818F43E48B for ; Wed, 12 Aug 2026 12:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786537249; cv=none; b=svSJB93eu7WrChrtBibWJR4Gnj0T110fgCeIdRlP8Rw6z2CzinU9tCFSo2rEdUvVERfIsgwVLeyiSwnlL6pmAkb3IRV9EqEU59Fp+3aXAxW4+wZaPuXIeWU6ChXSjOOA6rA5MH+cUCwNALc517HmmqXoWGkj3EiH68wDoo3eYSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786537249; c=relaxed/simple; bh=ExqDWbwAUJ/rgJMxlOxYUtmWMBKaK+kML8JI5YnKLak=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cz3YVKZuwowtyfJInqoRK4aeRupAihWrHxnhvNpOYPobR5PlOgv35iXkcFlFLHDHt4sqWZKTb8EBoSc+oBkTvrn+k4El3wpQxXPzVLj6BPDJdnJq6JYcllb/eFCsYc/IDy6f35X0kpHYnQwNuUcu6aJYSU+NvvR6gxcNcwN56iQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nq70MJ2Q; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nq70MJ2Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 799EE1F000E9; Wed, 12 Aug 2026 12:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786537247; bh=kZg03mGGOq81u4B61Lg/APAIsg+87Ay12C/WV1nBv3o=; h=From:To:Cc:Subject:Date; b=nq70MJ2QRHC6tQhybaj0SVjKCObIv6jr0Iydr3bCWznrFVark8dUMKpN/2J2LkOhY 70u/uDh3/IqzdOao0eeJgHKZNa6+IaORH9CkC22StBVSqsmCm8iK1a83pLKHyMbzB3 v27VWU6HG/LE3hEjwzrn55rkPx8JmS4kX75yT8C3zchnsuHG4GRiEG3fTmtA9Kx7DU alE7DuUfDkc379IkGrtzJ9reBBIgJv2CFkkgTsu94F8V15zu9mATWZMg2Ycyy3KeuY Af60ZhqAFxWFU/80obAsMkAGXqNTdYOeTGh0Ws5R8ZeWzv9l1nYj5/0We3u8m8YANf CWWpgmkkTYClA== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: fix to propagate error from f2fs_sync_fs() Date: Wed, 12 Aug 2026 12:20:43 +0000 Message-ID: <20260812122043.282195-1-chao@kernel.org> X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit So that caller can detect any failure from f2fs_sync_fs(). Signed-off-by: Chao Yu --- fs/f2fs/namei.c | 51 ++++++++++++++++++++++++++++++++++--------------- fs/f2fs/super.c | 4 +++- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index f67864417455..37897f4321c0 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -402,8 +402,11 @@ static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir, d_instantiate_new(dentry, inode); - if (IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return err; + } f2fs_balance_fs(sbi, true); return 0; @@ -455,8 +458,11 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, d_instantiate(dentry, inode); - if (IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return err; + } return 0; out: clear_inode_flag(inode, FI_INC_LINK); @@ -624,8 +630,11 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) d_invalidate(dentry); - if (IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + goto out; + } goto out; corrupted: @@ -717,7 +726,7 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir, disk_link.len - 1); if (!err && IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + err = f2fs_sync_fs(sbi->sb, 1); } if (err) @@ -769,8 +778,11 @@ static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir, d_instantiate_new(dentry, inode); - if (IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return ERR_PTR(err); + } f2fs_balance_fs(sbi, true); return NULL; @@ -824,8 +836,11 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir, d_instantiate_new(dentry, inode); - if (IS_DIRSYNC(dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return err; + } f2fs_balance_fs(sbi, true); return 0; @@ -1122,8 +1137,11 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, f2fs_unlock_op(sbi, &lc); - if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return err; + } f2fs_update_time(sbi, REQ_TIME); return 0; @@ -1289,8 +1307,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_unlock_op(sbi, &lc); - if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) - f2fs_sync_fs(sbi->sb, 1); + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) { + err = f2fs_sync_fs(sbi->sb, 1); + if (err) + return err; + } f2fs_update_time(sbi, REQ_TIME); return 0; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 0c8f60b7242f..3bdb0f891c35 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2960,7 +2960,9 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) set_sbi_flag(sbi, SBI_IS_DIRTY); set_sbi_flag(sbi, SBI_IS_CLOSE); - f2fs_sync_fs(sb, 1); + err = f2fs_sync_fs(sb, 1); + if (err) + goto restore_gc; clear_sbi_flag(sbi, SBI_IS_CLOSE); } -- 2.49.0