All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Chengguang Xu <cgxu519@mykernel.net>,
	overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: [PATCH v4] ovl: whiteout inode sharing
Date: Tue, 28 Apr 2020 16:15:51 +0300	[thread overview]
Message-ID: <CAOQ4uxh4ZVqOHtiytk4fHB5otNd8VRM-Z_8ZYpW1qMjzAsmkZw@mail.gmail.com> (raw)
In-Reply-To: <20200428122104.GA13131@miu.piliscsaba.redhat.com>

On Tue, Apr 28, 2020 at 3:21 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> On Fri, Apr 24, 2020 at 05:49:00PM +0300, Amir Goldstein wrote:
>
> > I didn't mean we need to check if link_max  is valid range for upper fs.
> > We anyway use minimum of user requested value and upper fs max.
> >
> > Frankly, I think there are only two sane options for system wide configuration:
> > 1. disable whiteout link
> > 2. enable whiteout link with ofs->workdir->d_sb->s_max_links
>
> And that one doesn't work, see for example ext4, which defines EXT4_LINK_MAX but
> doesn't set s_max_links.  This could be fixed, but using EMLINK to detect the
> max-link condition is simpler and more reliable.
>
> And I don't really see a reason to disable whiteout hard links.  What scenario
> would that be useful in?

I have a vague memory of e2fsck excessive memory consumption
in face of many hardlinks created by rsync backups.
Now I suppose it was a function of number of files with nlink > 1 and not
a function of nlink itself and could be a non issue for a long time, but I am
just being careful about introducing non-standard setups which may end up
exposing filesystem corner case bugs (near the edge of s_max_links).
Yeh that is very defensive, so I don't mind ignoring that concern and addressing
it in case somebody shouts.

>
> Updated patch below.  Changes from v5:
>
>  - fix a missing dput on shutdown
>  - don't poass workdir to ovl_cleanup_and_whiteout/ovl_whiteout
>  - flatten out retry loop in ovl_whiteout
>  - use EMLINK to distinguish max-links from misc failure
>
> Thanks,
> Miklos
>
> ---
> From: Chengguang Xu <cgxu519@mykernel.net>
> Subject: ovl: whiteout inode sharing
> Date: Fri, 24 Apr 2020 10:55:17 +0800
>
> Share inode with different whiteout files for saving inode and speeding up
> delete operation.
>
> If EMLINK is encountered when linking a shared whiteout, create a new one.
> In case of any other error, disable sharing for this super block.
>
> Note: ofs->whiteout is protected by inode lock on workdir.
>
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
>  fs/overlayfs/dir.c       |   49 +++++++++++++++++++++++++++++++++++------------
>  fs/overlayfs/overlayfs.h |    2 -
>  fs/overlayfs/ovl_entry.h |    3 ++
>  fs/overlayfs/readdir.c   |    2 -
>  fs/overlayfs/super.c     |    4 +++
>  fs/overlayfs/util.c      |    3 +-
>  6 files changed, 48 insertions(+), 15 deletions(-)
>
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -62,35 +62,59 @@ struct dentry *ovl_lookup_temp(struct de
>  }
>
>  /* caller holds i_mutex on workdir */
> -static struct dentry *ovl_whiteout(struct dentry *workdir)
> +static struct dentry *ovl_whiteout(struct ovl_fs *ofs)
>  {
>         int err;
>         struct dentry *whiteout;
> +       struct dentry *workdir = ofs->workdir;
>         struct inode *wdir = workdir->d_inode;
>
> -       whiteout = ovl_lookup_temp(workdir);
> -       if (IS_ERR(whiteout))
> -               return whiteout;
> +       if (!ofs->whiteout) {
> +               whiteout = ovl_lookup_temp(workdir);
> +               if (IS_ERR(whiteout))
> +                       return whiteout;
> +
> +               err = ovl_do_whiteout(wdir, whiteout);
> +               if (err) {
> +                       dput(whiteout);
> +                       return ERR_PTR(err);
> +               }
> +               ofs->whiteout = whiteout;
> +       }
>
> -       err = ovl_do_whiteout(wdir, whiteout);
> -       if (err) {
> +       if (ofs->share_whiteout) {
> +               whiteout = ovl_lookup_temp(workdir);
> +               if (IS_ERR(whiteout))
> +                       goto fallback;
> +
> +               err = ovl_do_link(ofs->whiteout, wdir, whiteout);
> +               if (!err)
> +                       goto success;
> +
> +               if (err != -EMLINK) {
> +                       pr_warn("Failed to link whiteout - disabling whiteout inode sharing(nlink=%u, err=%i)\n",
> +                               ofs->whiteout->d_inode->i_nlink, err);
> +                       ofs->share_whiteout = false;
> +               }
>                 dput(whiteout);
> -               whiteout = ERR_PTR(err);
>         }
> -
> +fallback:
> +       whiteout = ofs->whiteout;
> +       ofs->whiteout = NULL;
> +success:

This label is a bit strange, but fine.

>         return whiteout;
>  }
>

Thanks,
Amir.

  reply	other threads:[~2020-04-28 13:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 10:27 [PATCH v4] ovl: whiteout inode sharing Chengguang Xu
2020-04-22 11:50 ` Amir Goldstein
2020-04-23  1:17   ` Chengguang Xu
2020-04-24  6:02     ` Amir Goldstein
2020-04-24  6:26       ` Chengguang Xu
2020-04-24 14:49         ` Amir Goldstein
2020-04-28 12:21           ` Miklos Szeredi
2020-04-28 13:15             ` Amir Goldstein [this message]
2020-04-28 13:32               ` Miklos Szeredi
2020-04-28 15:15                 ` Amir Goldstein

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=CAOQ4uxh4ZVqOHtiytk4fHB5otNd8VRM-Z_8ZYpW1qMjzAsmkZw@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=cgxu519@mykernel.net \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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.