ovl: simplify arguments to ovl_check_origin_fh()

Pass the fs instance with lower_layers array instead of the dentry
lowerstack array to ovl_check_origin_fh(), because the dentry members
of lowerstack play no role in this helper.

This change simplifies the argument list of ovl_check_origin(),
ovl_cleanup_index() and ovl_verify_index().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Amir Goldstein
2017-12-12 22:40:46 +02:00
committed by Miklos Szeredi
parent 2e1a532883
commit 1eff1a1dee
4 changed files with 24 additions and 30 deletions

View File

@@ -291,17 +291,15 @@ 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,
static int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
struct dentry *upperdentry,
struct ovl_path **stackp)
{
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 < ofs->numlower; i++) {
origin = ovl_decode_fh(fh, ofs->lower_layers[i].mnt);
if (origin)
break;
}
@@ -321,7 +319,10 @@ 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 = &ofs->lower_layers[i]
};
return 0;
@@ -333,8 +334,7 @@ invalid:
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 +343,7 @@ 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(ofs, fh, upperdentry, stackp);
kfree(fh);
if (err) {
@@ -423,8 +423,7 @@ fail:
* 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 +470,7 @@ 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(ofs, fh, index, &stack);
if (err)
goto fail;
@@ -689,8 +688,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;
}