All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>
To: "linkinjeon@kernel.org" <linkinjeon@kernel.org>,
	"sj1557.seo@samsung.com" <sj1557.seo@samsung.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] exfat: do not clear VolumeDirty in writeback
Date: Tue, 8 Feb 2022 05:18:57 +0000	[thread overview]
Message-ID: <HK2PR04MB38914869B1FEE326CFE11779812D9@HK2PR04MB3891.apcprd04.prod.outlook.com> (raw)

Before this commit, VolumeDirty will be cleared first in
writeback if 'dirsync' or 'sync' is not enabled. If the power
is suddenly cut off after cleaning VolumeDirty but other
updates are not written, the exFAT filesystem will not be able
to detect the power failure in the next mount.

And VolumeDirty will be set again when updating the parent
directory. It means that BootSector will be written twice in each
writeback, that will shorten the life of the device.

Reviewed-by: Andy.Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama, Wataru <wataru.aoyama@sony.com>
Signed-off-by: Yuezhang.Mo <Yuezhang.Mo@sony.com>
---
 fs/exfat/super.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 8c9fb7dcec16..f4906c17475e 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -25,6 +25,8 @@
 static char exfat_default_iocharset[] = CONFIG_EXFAT_DEFAULT_IOCHARSET;
 static struct kmem_cache *exfat_inode_cachep;
 
+static int __exfat_clear_volume_dirty(struct super_block *sb);
+
 static void exfat_free_iocharset(struct exfat_sb_info *sbi)
 {
 	if (sbi->options.iocharset != exfat_default_iocharset)
@@ -64,7 +66,7 @@ static int exfat_sync_fs(struct super_block *sb, int wait)
 	/* If there are some dirty buffers in the bdev inode */
 	mutex_lock(&sbi->s_lock);
 	sync_blockdev(sb->s_bdev);
-	if (exfat_clear_volume_dirty(sb))
+	if (__exfat_clear_volume_dirty(sb))
 		err = -EIO;
 	mutex_unlock(&sbi->s_lock);
 	return err;
@@ -139,13 +141,21 @@ int exfat_set_volume_dirty(struct super_block *sb)
 	return exfat_set_vol_flags(sb, sbi->vol_flags | VOLUME_DIRTY);
 }
 
-int exfat_clear_volume_dirty(struct super_block *sb)
+static int __exfat_clear_volume_dirty(struct super_block *sb)
 {
 	struct exfat_sb_info *sbi = EXFAT_SB(sb);
 
 	return exfat_set_vol_flags(sb, sbi->vol_flags & ~VOLUME_DIRTY);
 }
 
+int exfat_clear_volume_dirty(struct super_block *sb)
+{
+	if (sb->s_flags & (SB_SYNCHRONOUS | SB_DIRSYNC))
+		return __exfat_clear_volume_dirty(sb);
+
+	return 0;
+}
+
 static int exfat_show_options(struct seq_file *m, struct dentry *root)
 {
 	struct super_block *sb = root->d_sb;
-- 
2.25.1

             reply	other threads:[~2022-02-08  6:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  5:18 Yuezhang.Mo [this message]
2022-02-08  6:43 ` [PATCH] exfat: do not clear VolumeDirty in writeback Yuezhang.Mo
2022-02-28  3:24   ` Yuezhang.Mo
2022-03-01  9:19     ` Namjae Jeon
2022-02-28  7:11 ` Kohada.Tetsuhiro
2022-02-28 10:51   ` Yuezhang.Mo
2022-03-02  9:29     ` Kohada.Tetsuhiro
2022-03-03  7:08       ` Yuezhang.Mo
2022-03-07  5:34         ` Kohada.Tetsuhiro
2022-03-05  6:03 ` Namjae Jeon
2022-03-08 10:55   ` Yuezhang.Mo
2022-03-09 11:14     ` Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HK2PR04MB38914869B1FEE326CFE11779812D9@HK2PR04MB3891.apcprd04.prod.outlook.com \
    --to=yuezhang.mo@sony.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.