Skip to contentSkip to conversation

exfat: call sync_filesystem for read-only remount

PATCH Applied Hyunchul Lee 3 participants 3 messages Jun 16, 2020 – Jun 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 exfat: call sync_filesystem for read-only remount

We need to commit dirty metadata and pages to disk before remounting exfat as read-only.

This fixes a failure in xfstests generic/452

generic/452 does the following:
cp something <exfat>/
mount -o remount,ro <exfat>

the <exfat>/something is corrupted. because while exfat is remounted as read-only, exfat doesn't have a chance to commit metadata and
vfs invalidates page caches in a block device.

---
Changes from v1:
- Does not check the return value of sync_filesystem to allow to change from "rw" to "ro" even when this function fails.
- Add the detailed explanation why generic/452 fails

 fs/exfat/super.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/exfat/super.c +10 -0
index e650e65536f8..253a92460d52 100644
@@ -693,10 +693,20 @@ static void exfat_free(struct fs_context *fc)
 	}
 }
 
+static int exfat_reconfigure(struct fs_context *fc)
+{
+	fc->sb_flags |= SB_NODIRATIME;
+
+	/* volume flag will be updated in exfat_sync_fs */
+	sync_filesystem(fc->root->d_sb);
+	return 0;
+}
+
 static const struct fs_context_operations exfat_context_ops = {
 	.parse_param	= exfat_parse_param,
 	.get_tree	= exfat_get_tree,
 	.free		= exfat_free,
+	.reconfigure	= exfat_reconfigure,
 };
 
 static int exfat_init_fs_context(struct fs_context *fc)
Signature · 1 line
2.17.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines

We need to commit dirty metadata and pages to disk before remounting exfat as read-only.

This fixes a failure in xfstests generic/452

generic/452 does the following:
cp something <exfat>/
mount -o remount,ro <exfat>

Quoted 5 lines

the <exfat>/something is corrupted. because while exfat is remounted as read-only, exfat doesn't have a chance to commit metadata and vfs invalidates page caches in a block device.

Quoted 36 lines

---
Changes from v1:
- Does not check the return value of sync_filesystem to allow to change from "rw" to "ro" even when this function fails.
- Add the detailed explanation why generic/452 fails

 fs/exfat/super.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/exfat/super.c index renamed from fs/exfat/super.c +0 -0

e650e65536f8..253a92460d52 100644

fs/exfat/super.c +9 -1
@@ -693,10 +693,20 @@ static void exfat_free(struct fs_context *fc)
 	}
 }
 
+static int exfat_reconfigure(struct fs_context *fc) {
+	fc->sb_flags |= SB_NODIRATIME;
+
+	/* volume flag will be updated in exfat_sync_fs */
+	sync_filesystem(fc->root->d_sb);
+	return 0;
+}
+
 static const struct fs_context_operations exfat_context_ops = {
 	.parse_param	= exfat_parse_param,
 	.get_tree	= exfat_get_tree,
 	.free		= exfat_free,
+	.reconfigure	= exfat_reconfigure,
 };
 
 static int exfat_init_fs_context(struct fs_context *fc)
--

2.17.1

Applied
#2 lore raw
Quoted 9 lines
Quoted 9 lines

We need to commit dirty metadata and pages to disk before remounting exfat as read-only.

This fixes a failure in xfstests generic/452

generic/452 does the following:
cp something <exfat>/
mount -o remount,ro <exfat>

Quoted 7 lines
Quoted 5 lines

the <exfat>/something is corrupted. because while exfat is remounted as read-only, exfat doesn't have a chance to commit metadata and vfs invalidates page caches in a block device.

Applied. Thanks!