linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] exfat: call sync_filesystem for read-only remount
@ 2020-06-16  5:34 ` Hyunchul Lee
  2020-06-17  8:10   ` Sungjong Seo
  0 siblings, 1 reply; 3+ messages in thread
From: Hyunchul Lee @ 2020-06-16  5:34 UTC (permalink / raw)
  To: Namjae Jeon, Sungjong Seo
  Cc: Hyunchul Lee, linux-fsdevel, linux-kernel, kernel-team

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.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
---
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(+)

diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index e650e65536f8..253a92460d52 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v2] exfat: call sync_filesystem for read-only remount
  2020-06-16  5:34 ` [PATCH v2] exfat: call sync_filesystem for read-only remount Hyunchul Lee
@ 2020-06-17  8:10   ` Sungjong Seo
  2020-06-17  8:40     ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Sungjong Seo @ 2020-06-17  8:10 UTC (permalink / raw)
  To: 'Hyunchul Lee', 'Namjae Jeon'; +Cc: linux-fsdevel, linux-kernel

> 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.
> 
> Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>

Acked-by: Sungjong Seo <sj1557.seo@samsung.com>

> ---
> 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(+)
> 
> diff --git a/fs/exfat/super.c b/fs/exfat/super.c index
> e650e65536f8..253a92460d52 100644
> --- a/fs/exfat/super.c
> +++ b/fs/exfat/super.c
> @@ -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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v2] exfat: call sync_filesystem for read-only remount
  2020-06-17  8:10   ` Sungjong Seo
@ 2020-06-17  8:40     ` Namjae Jeon
  0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2020-06-17  8:40 UTC (permalink / raw)
  To: 'Sungjong Seo', 'Hyunchul Lee'
  Cc: linux-fsdevel, linux-kernel

> > 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.
> >
> > Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
> 
> Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
Applied. Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-17  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200616053459epcas1p4e7a4908eda3785d6f5cbb71150cbe50b@epcas1p4.samsung.com>
2020-06-16  5:34 ` [PATCH v2] exfat: call sync_filesystem for read-only remount Hyunchul Lee
2020-06-17  8:10   ` Sungjong Seo
2020-06-17  8:40     ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).