From: Vivek Goyal <vgoyal@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>, zhangyi <yi.zhang@huawei.com>,
linux-unionfs@vger.kernel.org
Subject: Re: [PATCH v2 05/23] ovl: pass ovl_layer array to ovl_check_origin_fh()
Date: Thu, 4 Jan 2018 17:35:25 -0500 [thread overview]
Message-ID: <20180104223525.GC2808@redhat.com> (raw)
In-Reply-To: <1515084018-25134-6-git-send-email-amir73il@gmail.com>
On Thu, Jan 04, 2018 at 06:40:00PM +0200, Amir Goldstein wrote:
> Pass the fs instance lower_layer array instead of lowerstack array to
> ovl_check_origin_fh(), because the dentry member of ovl_path plays no
> part in this helper.
>
> This change simplifies the argument list of ovl_check_origin(),
> ovl_cleanup_index() and ovl_verify_index().
>
> We pass lower_layer array and numlower and not struct ovl_fs to
> ovl_check_origin_fh(), because we are going to use this helper for
> decoding upper layer file handles for NFS export support.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> fs/overlayfs/namei.c | 25 +++++++++++--------------
> fs/overlayfs/overlayfs.h | 9 ++++-----
> fs/overlayfs/readdir.c | 12 ++++++------
> fs/overlayfs/super.c | 5 +----
> 4 files changed, 22 insertions(+), 29 deletions(-)
>
> diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
> index 4cc8fb64c879..46a3e31b0225 100644
> --- a/fs/overlayfs/namei.c
> +++ b/fs/overlayfs/namei.c
> @@ -292,16 +292,14 @@ static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d,
>
>
> static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry,
> - struct ovl_path *lower, unsigned int numlower,
> + struct ovl_layer *layers, unsigned int numlayers,
> struct ovl_path **stackp)
I was thinking if this will lead to decoding in all lower layers (as opposed
to only some depending on how many lower layers ovl_entry has stored). But
looks like we already do decoding in all the lower layers of fs (both for
origin and index). So this is not a concern.
Vivek
> {
> - struct vfsmount *mnt;
> struct dentry *origin = NULL;
> int i;
>
> - for (i = 0; i < numlower; i++) {
> - mnt = lower[i].layer->mnt;
> - origin = ovl_decode_fh(fh, mnt);
> + for (i = 0; i < numlayers; i++) {
> + origin = ovl_decode_fh(fh, layers[i].mnt);
> if (origin)
> break;
> }
> @@ -321,7 +319,7 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry,
> dput(origin);
> return -ENOMEM;
> }
> - **stackp = (struct ovl_path){.dentry = origin, .layer = lower[i].layer};
> + **stackp = (struct ovl_path){.dentry = origin, .layer = &layers[i]};
>
> return 0;
>
> @@ -333,8 +331,7 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry,
> return -EIO;
> }
>
> -static int ovl_check_origin(struct dentry *upperdentry,
> - struct ovl_path *lower, unsigned int numlower,
> +static int ovl_check_origin(struct ovl_fs *ofs, struct dentry *upperdentry,
> struct ovl_path **stackp, unsigned int *ctrp)
> {
> struct ovl_fh *fh = ovl_get_origin_fh(upperdentry);
> @@ -343,7 +340,8 @@ static int ovl_check_origin(struct dentry *upperdentry,
> if (IS_ERR_OR_NULL(fh))
> return PTR_ERR(fh);
>
> - err = ovl_check_origin_fh(fh, upperdentry, lower, numlower, stackp);
> + err = ovl_check_origin_fh(fh, upperdentry, ofs->lower_layers,
> + ofs->numlower, stackp);
> kfree(fh);
>
> if (err) {
> @@ -423,8 +421,7 @@ int ovl_verify_origin(struct dentry *dentry, struct dentry *origin,
> * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path.
> * Return 0 on match, -ESTALE on mismatch or stale origin, < 0 on error.
> */
> -int ovl_verify_index(struct dentry *index, struct ovl_path *lower,
> - unsigned int numlower)
> +int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
> {
> struct ovl_fh *fh = NULL;
> size_t len;
> @@ -471,7 +468,8 @@ int ovl_verify_index(struct dentry *index, struct ovl_path *lower,
> if (err)
> goto fail;
>
> - err = ovl_check_origin_fh(fh, index, lower, numlower, &stack);
> + err = ovl_check_origin_fh(fh, index, ofs->lower_layers,
> + ofs->numlower, &stack);
> if (err)
> goto fail;
>
> @@ -689,8 +687,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> * number - it's the same as if we held a reference
> * to a dentry in lower layer that was moved under us.
> */
> - err = ovl_check_origin(upperdentry, roe->lowerstack,
> - roe->numlower, &stack, &ctr);
> + err = ovl_check_origin(ofs, upperdentry, &stack, &ctr);
> if (err)
> goto out_put_upper;
> }
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index d1cfa69c98b5..d55afb6646b0 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -251,11 +251,11 @@ static inline bool ovl_is_impuredir(struct dentry *dentry)
> /* namei.c */
> int ovl_verify_origin(struct dentry *dentry, struct dentry *origin,
> bool is_upper, bool set);
> -int ovl_verify_index(struct dentry *index, struct ovl_path *lower,
> - unsigned int numlower);
> +int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
> int ovl_get_index_name(struct dentry *origin, struct qstr *name);
> int ovl_path_next(int idx, struct dentry *dentry, struct path *path);
> -struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags);
> +struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> + unsigned int flags);
> bool ovl_lower_positive(struct dentry *dentry);
>
> /* readdir.c */
> @@ -267,8 +267,7 @@ void ovl_dir_cache_free(struct inode *inode);
> int ovl_check_d_type_supported(struct path *realpath);
> void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
> struct dentry *dentry, int level);
> -int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
> - struct ovl_path *lower, unsigned int numlower);
> +int ovl_indexdir_cleanup(struct ovl_fs *ofs);
>
> /* inode.c */
> int ovl_set_nlink_upper(struct dentry *dentry);
> diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> index 001c79297bc5..0cdd1ad0b4f6 100644
> --- a/fs/overlayfs/readdir.c
> +++ b/fs/overlayfs/readdir.c
> @@ -1023,13 +1023,13 @@ void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
> }
> }
>
> -int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
> - struct ovl_path *lower, unsigned int numlower)
> +int ovl_indexdir_cleanup(struct ovl_fs *ofs)
> {
> int err;
> + struct dentry *indexdir = ofs->indexdir;
> struct dentry *index = NULL;
> - struct inode *dir = dentry->d_inode;
> - struct path path = { .mnt = mnt, .dentry = dentry };
> + struct inode *dir = indexdir->d_inode;
> + struct path path = { .mnt = ofs->upper_mnt, .dentry = indexdir };
> LIST_HEAD(list);
> struct rb_root root = RB_ROOT;
> struct ovl_cache_entry *p;
> @@ -1053,13 +1053,13 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
> if (p->len == 2 && p->name[1] == '.')
> continue;
> }
> - index = lookup_one_len(p->name, dentry, p->len);
> + index = lookup_one_len(p->name, indexdir, p->len);
> if (IS_ERR(index)) {
> err = PTR_ERR(index);
> index = NULL;
> break;
> }
> - err = ovl_verify_index(index, lower, numlower);
> + err = ovl_verify_index(ofs, index);
> /* Cleanup stale and orphan index entries */
> if (err && (err == -ESTALE || err == -ENOENT))
> err = ovl_cleanup(dir, index);
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index 2b58620eedf0..994d35628acf 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -1062,10 +1062,7 @@ static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe,
>
> /* Cleanup bad/stale/orphan index entries */
> if (!err)
> - err = ovl_indexdir_cleanup(ofs->indexdir,
> - ofs->upper_mnt,
> - oe->lowerstack,
> - oe->numlower);
> + err = ovl_indexdir_cleanup(ofs);
> }
> if (err || !ofs->indexdir)
> pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n");
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-01-04 22:35 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-04 16:39 [PATCH v2 00/23] Overlayfs consistency verification with full index Amir Goldstein
2018-01-04 16:39 ` [PATCH v2 01/23] ovl: disable index when no xattr support Amir Goldstein
2018-01-04 16:39 ` [PATCH v2 02/23] ovl: ignore index mount option when no upper layer Amir Goldstein
2018-01-04 18:42 ` Vivek Goyal
2018-01-04 19:39 ` Amir Goldstein
2018-01-04 20:05 ` Vivek Goyal
2018-01-04 16:39 ` [PATCH v2 03/23] ovl: store layer index in ovl_layer Amir Goldstein
2018-01-04 21:00 ` Vivek Goyal
2018-01-05 5:05 ` Amir Goldstein
2018-01-05 11:22 ` Amir Goldstein
2018-01-05 15:00 ` Vivek Goyal
2018-01-05 17:51 ` Amir Goldstein
2018-01-09 8:36 ` Miklos Szeredi
2018-01-05 14:57 ` Vivek Goyal
2018-01-04 16:39 ` [PATCH v2 04/23] ovl: factor out ovl_check_origin_fh() Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 05/23] ovl: pass ovl_layer array to ovl_check_origin_fh() Amir Goldstein
2018-01-04 22:35 ` Vivek Goyal [this message]
2018-01-05 5:26 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 06/23] ovl: add support for "verify" feature Amir Goldstein
2018-01-05 15:43 ` Vivek Goyal
2018-01-05 15:47 ` Amir Goldstein
2018-01-05 15:48 ` Amir Goldstein
2018-01-05 16:39 ` Vivek Goyal
2018-01-05 17:07 ` Amir Goldstein
2018-01-05 19:07 ` Vivek Goyal
2018-01-05 20:20 ` Amir Goldstein
2018-01-05 20:37 ` Amir Goldstein
2018-01-09 9:16 ` Miklos Szeredi
2018-01-09 9:54 ` Amir Goldstein
2018-01-09 10:07 ` Miklos Szeredi
2018-01-09 10:44 ` Amir Goldstein
2018-01-09 10:50 ` Miklos Szeredi
2018-01-04 16:40 ` [PATCH v2 07/23] ovl: verify stored origin fh matches lower dir Amir Goldstein
2018-01-05 16:04 ` Vivek Goyal
2018-01-05 16:26 ` Amir Goldstein
2018-01-05 16:35 ` Vivek Goyal
2018-01-05 16:42 ` Amir Goldstein
2018-01-05 18:33 ` Vivek Goyal
2018-01-05 19:00 ` Amir Goldstein
2018-01-09 9:52 ` Miklos Szeredi
2018-01-09 10:04 ` Amir Goldstein
2018-01-09 10:17 ` Miklos Szeredi
2018-01-04 16:40 ` [PATCH v2 08/23] ovl: unbless lower st_ino of files under unverified redirected dir Amir Goldstein
2018-01-09 13:31 ` Miklos Szeredi
2018-01-09 14:24 ` Amir Goldstein
2018-01-09 14:28 ` Miklos Szeredi
2018-01-04 16:40 ` [PATCH v2 09/23] ovl: lookup index for directories Amir Goldstein
2018-01-09 14:49 ` Miklos Szeredi
2018-01-09 16:07 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 10/23] ovl: verify whiteout index entries on mount Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 11/23] ovl: verify directory " Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 12/23] ovl: cleanup temp index entries Amir Goldstein
2018-01-09 15:25 ` Miklos Szeredi
2018-01-09 16:08 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 13/23] ovl: create ovl_need_index() helper Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 14/23] ovl: index all files on copy up with 'verify=on' Amir Goldstein
2018-01-09 16:45 ` Vivek Goyal
2018-01-09 16:50 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 15/23] ovl: index directories " Amir Goldstein
2018-01-09 16:08 ` Miklos Szeredi
2018-01-09 16:31 ` Amir Goldstein
2018-01-09 16:35 ` Miklos Szeredi
2018-01-09 16:48 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 16/23] ovl: cleanup dir index when dir nlink drops to zero Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 17/23] ovl: whiteout index when union " Amir Goldstein
2018-01-09 16:28 ` Miklos Szeredi
2018-01-09 16:41 ` Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 18/23] ovl: whiteout orphan index entries on mount Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 19/23] ovl: factor out ovl_get_index_fh() helper Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 20/23] ovl: do not pass overlay dentry to ovl_get_inode() Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 21/23] ovl: grab i_count reference of lower inode Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 22/23] ovl: use d_splice_alias() in place of d_add() in lookup Amir Goldstein
2018-01-04 16:40 ` [PATCH v2 23/23] ovl: copy up of disconnected dentries Amir Goldstein
2018-01-11 14:47 ` Miklos Szeredi
2018-01-11 15:28 ` Amir Goldstein
2018-01-11 16:55 ` [PATCH v2 00/23] Overlayfs consistency verification with full index 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=20180104223525.GC2808@redhat.com \
--to=vgoyal@redhat.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=yi.zhang@huawei.com \
/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