Re: [PATCH 2/3] ovl: prepare to copy up without workdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 10, 2020 at 10:25 AM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> With index=on, we copy up lower hardlinks to work dir and move them
> into index dir. Fix locking to allow work dir and index dir to be the
> same directory.
>
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> ---
>  fs/overlayfs/copy_up.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> index 9709cf22cab3..e523e63f604f 100644
> --- a/fs/overlayfs/copy_up.c
> +++ b/fs/overlayfs/copy_up.c
> @@ -576,7 +576,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
>         struct inode *udir = d_inode(c->destdir), *wdir = d_inode(c->workdir);
>         struct dentry *temp, *upper;
>         struct ovl_cu_creds cc;
> -       int err;
> +       int err = 0;
>         struct ovl_cattr cattr = {
>                 /* Can't properly set mode on creation because of the umask */
>                 .mode = c->stat.mode & S_IFMT,
> @@ -584,7 +584,11 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
>                 .link = c->link
>         };
>
> -       err = ovl_lock_rename_workdir(c->workdir, c->destdir);
> +       /* Are we copying up to indexdir which is also workdir? */
> +       if (c->indexed && c->workdir == c->destdir)
> +               inode_lock_nested(wdir, I_MUTEX_PARENT);
> +       else
> +               err = ovl_lock_rename_workdir(c->workdir, c->destdir);

This is confusing.  What about just

if (!lock_rename(c->workdir, c->destdir))
    return -EIO;

?

Thanks,
Miklos



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux