linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Chandan Rajendra <chandan@linux.vnet.ibm.com>,
	linux-unionfs@vger.kernel.org
Subject: Re: [PATCH v6 3/9] ovl: allocate anonymous devs for lowerdirs
Date: Thu, 2 Nov 2017 08:28:34 -0400	[thread overview]
Message-ID: <20171102122834.GB16677@redhat.com> (raw)
In-Reply-To: <1509567773-25590-4-git-send-email-amir73il@gmail.com>

On Wed, Nov 01, 2017 at 10:22:47PM +0200, Amir Goldstein wrote:
> From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> 
> Generate unique values of st_dev per lower layer for non-samefs
> overlay mount. The unique values are obtained by allocating anonymous
> bdevs for each of the lowerdirs in the overlayfs instance.

Still not sure that why are we allocating anonymous bdev only for
lower and not upper. Until and unless we have a good reason not not
do so, treating them in same way will make it atleast easier to
understand?

Vivek

> 
> The anonymous bdev is going to be returned by stat(2) for lowerdir
> non-dir entries in non-samefs case.
> 
> [amir: split from ovl_getattr() and re-structure patches]
> 
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  fs/overlayfs/ovl_entry.h |  1 +
>  fs/overlayfs/super.c     | 18 ++++++++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
> index 1e28329b5db8..93eb6a044dd2 100644
> --- a/fs/overlayfs/ovl_entry.h
> +++ b/fs/overlayfs/ovl_entry.h
> @@ -19,6 +19,7 @@ struct ovl_config {
>  
>  struct ovl_layer {
>  	struct vfsmount *mnt;
> +	dev_t pseudo_dev;
>  };
>  
>  struct ovl_path {
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index e6e13d9588d1..323dfd7a0236 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -219,8 +219,10 @@ static void ovl_put_super(struct super_block *sb)
>  	if (ufs->upper_mnt && ufs->upperdir_locked)
>  		ovl_inuse_unlock(ufs->upper_mnt->mnt_root);
>  	mntput(ufs->upper_mnt);
> -	for (i = 0; i < ufs->numlower; i++)
> +	for (i = 0; i < ufs->numlower; i++) {
>  		mntput(ufs->lower_layers[i].mnt);
> +		free_anon_bdev(ufs->lower_layers[i].pseudo_dev);
> +	}
>  	kfree(ufs->lower_layers);
>  
>  	kfree(ufs->config.lowerdir);
> @@ -1032,11 +1034,19 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
>  		goto out_put_workdir;
>  	for (i = 0; i < numlower; i++) {
>  		struct vfsmount *mnt;
> +		dev_t dev;
> +
> +		err = get_anon_bdev(&dev);
> +		if (err) {
> +			pr_err("overlayfs: failed to get anonymous bdev for lowerpath\n");
> +			goto out_put_lower_layers;
> +		}
>  
>  		mnt = clone_private_mount(&stack[i]);
>  		err = PTR_ERR(mnt);
>  		if (IS_ERR(mnt)) {
>  			pr_err("overlayfs: failed to clone lowerpath\n");
> +			free_anon_bdev(dev);
>  			goto out_put_lower_layers;
>  		}
>  		/*
> @@ -1046,6 +1056,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
>  		mnt->mnt_flags |= MNT_READONLY | MNT_NOATIME;
>  
>  		ufs->lower_layers[ufs->numlower].mnt = mnt;
> +		ufs->lower_layers[ufs->numlower].pseudo_dev = dev;
>  		ufs->numlower++;
>  
>  		/* Check if all lower layers are on same sb */
> @@ -1160,8 +1171,11 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
>  out_free_oe:
>  	kfree(oe);
>  out_put_lower_layers:
> -	for (i = 0; i < ufs->numlower; i++)
> +	for (i = 0; i < ufs->numlower; i++) {
> +		if (ufs->lower_layers[i].mnt)
> +			free_anon_bdev(ufs->lower_layers[i].pseudo_dev);
>  		mntput(ufs->lower_layers[i].mnt);
> +	}
>  	kfree(ufs->lower_layers);
>  out_put_workdir:
>  	dput(ufs->workdir);
> -- 
> 2.7.4

  reply	other threads:[~2017-11-02 12:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 20:22 [PATCH v6 0/9] Overlayfs: constant st_ino/d_ino for non-samefs Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 1/9] ovl: move include of ovl_entry.h into overlayfs.h Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 2/9] ovl: re-structure overlay lower layers in-memory Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 3/9] ovl: allocate anonymous devs for lowerdirs Amir Goldstein
2017-11-02 12:28   ` Vivek Goyal [this message]
2017-11-02 13:05     ` Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 4/9] ovl: return anonymous st_dev for lower inodes Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 5/9] ovl: relax same fs constraint for constant st_ino Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 6/9] ovl: fix d_ino of current pure upper in non-samefs case Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 7/9] ovl: update cache version of impure parent on rename Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 8/9] ovl: update merge dir cache for non-samefs case Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 9/9] ovl: update non-merge " Amir Goldstein
2017-11-02 16:33 ` [PATCH v6 0/9] Overlayfs: constant st_ino/d_ino for non-samefs Miklos Szeredi
2017-11-02 18:06   ` 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=20171102122834.GB16677@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=amir73il@gmail.com \
    --cc=chandan@linux.vnet.ibm.com \
    --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 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).