* [PATCH] ovl: sync dirty data when remounting to ro mode
@ 2020-04-22 4:28 Chengguang Xu
2020-04-22 7:29 ` Miklos Szeredi
0 siblings, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2020-04-22 4:28 UTC (permalink / raw)
To: miklos; +Cc: linux-unionfs, Chengguang Xu
sync_filesystem() does not sync dirty data for readonly
filesystem during umount, so before changing to readonly
filesystem we should sync dirty data for data integrity.
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
fs/overlayfs/super.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index f57aa348dcd6..1bab326342bc 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -364,11 +364,20 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
static int ovl_remount(struct super_block *sb, int *flags, char *data)
{
struct ovl_fs *ofs = sb->s_fs_info;
+ struct super_block *upper_sb;
+ int ret = 0;
if (!(*flags & SB_RDONLY) && ovl_force_readonly(ofs))
return -EROFS;
- return 0;
+ if (*flags & SB_RDONLY && !sb_rdonly(sb)) {
+ upper_sb = ofs->upper_mnt->mnt_sb;
+ down_read(&upper_sb->s_umount);
+ ret = sync_filesystem(upper_sb);
+ up_read(&upper_sb->s_umount);
+ }
+
+ return ret;
}
static const struct super_operations ovl_super_operations = {
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ovl: sync dirty data when remounting to ro mode
2020-04-22 4:28 [PATCH] ovl: sync dirty data when remounting to ro mode Chengguang Xu
@ 2020-04-22 7:29 ` Miklos Szeredi
2020-04-22 8:13 ` Chengguang Xu
0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2020-04-22 7:29 UTC (permalink / raw)
To: Chengguang Xu; +Cc: overlayfs
On Wed, Apr 22, 2020 at 6:29 AM Chengguang Xu <cgxu519@mykernel.net> wrote:
>
> sync_filesystem() does not sync dirty data for readonly
> filesystem during umount, so before changing to readonly
> filesystem we should sync dirty data for data integrity.
Isn't the same true for ->put_super()?
Thanks,
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ovl: sync dirty data when remounting to ro mode
2020-04-22 7:29 ` Miklos Szeredi
@ 2020-04-22 8:13 ` Chengguang Xu
2020-04-22 8:26 ` Miklos Szeredi
0 siblings, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2020-04-22 8:13 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: overlayfs
---- 在 星期三, 2020-04-22 15:29:33 Miklos Szeredi <miklos@szeredi.hu> 撰写 ----
> On Wed, Apr 22, 2020 at 6:29 AM Chengguang Xu <cgxu519@mykernel.net> wrote:
> >
> > sync_filesystem() does not sync dirty data for readonly
> > filesystem during umount, so before changing to readonly
> > filesystem we should sync dirty data for data integrity.
>
> Isn't the same true for ->put_super()?
>
Before getting into ->put_super(), dirty data have been synced through below functions,
so I think we don't have to worry about ->put_super().
kill_anon_super()
generic_shutdown_super()
sync_filesystem()
Thanks,
cgxu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ovl: sync dirty data when remounting to ro mode
2020-04-22 8:13 ` Chengguang Xu
@ 2020-04-22 8:26 ` Miklos Szeredi
0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2020-04-22 8:26 UTC (permalink / raw)
To: Chengguang Xu; +Cc: overlayfs
On Wed, Apr 22, 2020 at 10:13 AM Chengguang Xu <cgxu519@mykernel.net> wrote:
>
> ---- 在 星期三, 2020-04-22 15:29:33 Miklos Szeredi <miklos@szeredi.hu> 撰写 ----
> > On Wed, Apr 22, 2020 at 6:29 AM Chengguang Xu <cgxu519@mykernel.net> wrote:
> > >
> > > sync_filesystem() does not sync dirty data for readonly
> > > filesystem during umount, so before changing to readonly
> > > filesystem we should sync dirty data for data integrity.
> >
> > Isn't the same true for ->put_super()?
> >
>
> Before getting into ->put_super(), dirty data have been synced through below functions,
> so I think we don't have to worry about ->put_super().
>
> kill_anon_super()
> generic_shutdown_super()
> sync_filesystem()
Okay, makes sense.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-22 8:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 4:28 [PATCH] ovl: sync dirty data when remounting to ro mode Chengguang Xu
2020-04-22 7:29 ` Miklos Szeredi
2020-04-22 8:13 ` Chengguang Xu
2020-04-22 8:26 ` Miklos Szeredi
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.