2021-11-22 03:16:53

by Chengguang Xu

[permalink] [raw]
Subject: [RFC PATCH V6 7/7] ovl: implement containerized syncfs for overlayfs

From: Chengguang Xu <[email protected]>

Now overlayfs can only sync own dirty inodes during syncfs,
so remove unnecessary sync_filesystem() on upper file system.

Signed-off-by: Chengguang Xu <[email protected]>
---
fs/overlayfs/super.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index ccffcd96491d..213b795a6a86 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -292,18 +292,14 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
/*
* Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC).
* All the super blocks will be iterated, including upper_sb.
- *
- * If this is a syncfs(2) call, then we do need to call
- * sync_filesystem() on upper_sb, but enough if we do it when being
- * called with wait == 1.
*/
- if (!wait)
- return 0;
-
upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
-
down_read(&upper_sb->s_umount);
- ret = sync_filesystem(upper_sb);
+ if (wait)
+ wait_sb_inodes(upper_sb);
+ if (upper_sb->s_op->sync_fs)
+ upper_sb->s_op->sync_fs(upper_sb, wait);
+ ret = ovl_sync_upper_blockdev(upper_sb, wait);
up_read(&upper_sb->s_umount);

return ret;
--
2.27.0




2021-11-22 07:41:30

by Amir Goldstein

[permalink] [raw]
Subject: Re: [RFC PATCH V6 7/7] ovl: implement containerized syncfs for overlayfs

On Mon, Nov 22, 2021 at 5:01 AM Chengguang Xu <[email protected]> wrote:
>
> From: Chengguang Xu <[email protected]>
>
> Now overlayfs can only sync own dirty inodes during syncfs,
> so remove unnecessary sync_filesystem() on upper file system.
>
> Signed-off-by: Chengguang Xu <[email protected]>
> ---
> fs/overlayfs/super.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index ccffcd96491d..213b795a6a86 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -292,18 +292,14 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
> /*
> * Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC).
> * All the super blocks will be iterated, including upper_sb.
> - *
> - * If this is a syncfs(2) call, then we do need to call
> - * sync_filesystem() on upper_sb, but enough if we do it when being
> - * called with wait == 1.
> */
> - if (!wait)
> - return 0;
> -
> upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
> -
> down_read(&upper_sb->s_umount);
> - ret = sync_filesystem(upper_sb);
> + if (wait)
> + wait_sb_inodes(upper_sb);
> + if (upper_sb->s_op->sync_fs)
> + upper_sb->s_op->sync_fs(upper_sb, wait);
> + ret = ovl_sync_upper_blockdev(upper_sb, wait);

I think it will be cleaner to use a helper ovl_sync_upper_filesystem()
with everything from upper_sb = ... and a comment to explain that
this is a variant of __sync_filesystem() where all the dirty inodes write
have already been started.

Thanks,
Amir.

P.S. I like this "stoopid proof" v6 because I can understand it ;-)

2021-11-26 05:06:06

by Chengguang Xu

[permalink] [raw]
Subject: Re: [RFC PATCH V6 7/7] ovl: implement containerized syncfs for overlayfs

---- 在 星期一, 2021-11-22 15:40:59 Amir Goldstein <[email protected]> 撰写 ----
> On Mon, Nov 22, 2021 at 5:01 AM Chengguang Xu <[email protected]> wrote:
> >
> > From: Chengguang Xu <[email protected]>
> >
> > Now overlayfs can only sync own dirty inodes during syncfs,
> > so remove unnecessary sync_filesystem() on upper file system.
> >
> > Signed-off-by: Chengguang Xu <[email protected]>
> > ---
> > fs/overlayfs/super.c | 14 +++++---------
> > 1 file changed, 5 insertions(+), 9 deletions(-)
> >
> > diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> > index ccffcd96491d..213b795a6a86 100644
> > --- a/fs/overlayfs/super.c
> > +++ b/fs/overlayfs/super.c
> > @@ -292,18 +292,14 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
> > /*
> > * Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC).
> > * All the super blocks will be iterated, including upper_sb.
> > - *
> > - * If this is a syncfs(2) call, then we do need to call
> > - * sync_filesystem() on upper_sb, but enough if we do it when being
> > - * called with wait == 1.
> > */
> > - if (!wait)
> > - return 0;
> > -
> > upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
> > -
> > down_read(&upper_sb->s_umount);
> > - ret = sync_filesystem(upper_sb);
> > + if (wait)
> > + wait_sb_inodes(upper_sb);
> > + if (upper_sb->s_op->sync_fs)
> > + upper_sb->s_op->sync_fs(upper_sb, wait);
> > + ret = ovl_sync_upper_blockdev(upper_sb, wait);
>
> I think it will be cleaner to use a helper ovl_sync_upper_filesystem()
> with everything from upper_sb = ... and a comment to explain that
> this is a variant of __sync_filesystem() where all the dirty inodes write
> have already been started.
>

I agree with you.

Thanks,
Chengguang

2021-11-26 09:27:11

by Jan Kara

[permalink] [raw]
Subject: Re: [RFC PATCH V6 7/7] ovl: implement containerized syncfs for overlayfs

On Mon 22-11-21 11:00:38, Chengguang Xu wrote:
> From: Chengguang Xu <[email protected]>
>
> Now overlayfs can only sync own dirty inodes during syncfs,
> so remove unnecessary sync_filesystem() on upper file system.
>
> Signed-off-by: Chengguang Xu <[email protected]>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> fs/overlayfs/super.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index ccffcd96491d..213b795a6a86 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -292,18 +292,14 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
> /*
> * Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC).
> * All the super blocks will be iterated, including upper_sb.
> - *
> - * If this is a syncfs(2) call, then we do need to call
> - * sync_filesystem() on upper_sb, but enough if we do it when being
> - * called with wait == 1.
> */
> - if (!wait)
> - return 0;
> -
> upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
> -
> down_read(&upper_sb->s_umount);
> - ret = sync_filesystem(upper_sb);
> + if (wait)
> + wait_sb_inodes(upper_sb);
> + if (upper_sb->s_op->sync_fs)
> + upper_sb->s_op->sync_fs(upper_sb, wait);
> + ret = ovl_sync_upper_blockdev(upper_sb, wait);
> up_read(&upper_sb->s_umount);
>
> return ret;
> --
> 2.27.0
>
>
--
Jan Kara <[email protected]>
SUSE Labs, CR