提交 1eff1a1d 编写于 作者: A Amir Goldstein 提交者: Miklos Szeredi

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: NAmir Goldstein <amir73il@gmail.com>
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
上级 2e1a5328
...@@ -291,17 +291,15 @@ static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, ...@@ -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, static int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
struct ovl_path *lower, unsigned int numlower, struct dentry *upperdentry,
struct ovl_path **stackp) struct ovl_path **stackp)
{ {
struct vfsmount *mnt;
struct dentry *origin = NULL; struct dentry *origin = NULL;
int i; int i;
for (i = 0; i < numlower; i++) { for (i = 0; i < ofs->numlower; i++) {
mnt = lower[i].layer->mnt; origin = ovl_decode_fh(fh, ofs->lower_layers[i].mnt);
origin = ovl_decode_fh(fh, mnt);
if (origin) if (origin)
break; break;
} }
...@@ -321,7 +319,10 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry, ...@@ -321,7 +319,10 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry,
dput(origin); dput(origin);
return -ENOMEM; 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; return 0;
...@@ -333,8 +334,7 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry, ...@@ -333,8 +334,7 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry,
return -EIO; return -EIO;
} }
static int ovl_check_origin(struct dentry *upperdentry, static int ovl_check_origin(struct ovl_fs *ofs, struct dentry *upperdentry,
struct ovl_path *lower, unsigned int numlower,
struct ovl_path **stackp, unsigned int *ctrp) struct ovl_path **stackp, unsigned int *ctrp)
{ {
struct ovl_fh *fh = ovl_get_origin_fh(upperdentry); struct ovl_fh *fh = ovl_get_origin_fh(upperdentry);
...@@ -343,7 +343,7 @@ static int ovl_check_origin(struct dentry *upperdentry, ...@@ -343,7 +343,7 @@ static int ovl_check_origin(struct dentry *upperdentry,
if (IS_ERR_OR_NULL(fh)) if (IS_ERR_OR_NULL(fh))
return PTR_ERR(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); kfree(fh);
if (err) { if (err) {
...@@ -423,8 +423,7 @@ int ovl_verify_origin(struct dentry *dentry, struct dentry *origin, ...@@ -423,8 +423,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. * 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. * Return 0 on match, -ESTALE on mismatch or stale origin, < 0 on error.
*/ */
int ovl_verify_index(struct dentry *index, struct ovl_path *lower, int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
unsigned int numlower)
{ {
struct ovl_fh *fh = NULL; struct ovl_fh *fh = NULL;
size_t len; size_t len;
...@@ -471,7 +470,7 @@ int ovl_verify_index(struct dentry *index, struct ovl_path *lower, ...@@ -471,7 +470,7 @@ int ovl_verify_index(struct dentry *index, struct ovl_path *lower,
if (err) if (err)
goto fail; goto fail;
err = ovl_check_origin_fh(fh, index, lower, numlower, &stack); err = ovl_check_origin_fh(ofs, fh, index, &stack);
if (err) if (err)
goto fail; goto fail;
...@@ -689,8 +688,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, ...@@ -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 * number - it's the same as if we held a reference
* to a dentry in lower layer that was moved under us. * to a dentry in lower layer that was moved under us.
*/ */
err = ovl_check_origin(upperdentry, roe->lowerstack, err = ovl_check_origin(ofs, upperdentry, &stack, &ctr);
roe->numlower, &stack, &ctr);
if (err) if (err)
goto out_put_upper; goto out_put_upper;
} }
......
...@@ -251,11 +251,11 @@ static inline bool ovl_is_impuredir(struct dentry *dentry) ...@@ -251,11 +251,11 @@ static inline bool ovl_is_impuredir(struct dentry *dentry)
/* namei.c */ /* namei.c */
int ovl_verify_origin(struct dentry *dentry, struct dentry *origin, int ovl_verify_origin(struct dentry *dentry, struct dentry *origin,
bool is_upper, bool set); bool is_upper, bool set);
int ovl_verify_index(struct dentry *index, struct ovl_path *lower, int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
unsigned int numlower);
int ovl_get_index_name(struct dentry *origin, struct qstr *name); int ovl_get_index_name(struct dentry *origin, struct qstr *name);
int ovl_path_next(int idx, struct dentry *dentry, struct path *path); 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); bool ovl_lower_positive(struct dentry *dentry);
/* readdir.c */ /* readdir.c */
...@@ -267,8 +267,7 @@ void ovl_dir_cache_free(struct inode *inode); ...@@ -267,8 +267,7 @@ void ovl_dir_cache_free(struct inode *inode);
int ovl_check_d_type_supported(struct path *realpath); int ovl_check_d_type_supported(struct path *realpath);
void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
struct dentry *dentry, int level); struct dentry *dentry, int level);
int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, int ovl_indexdir_cleanup(struct ovl_fs *ofs);
struct ovl_path *lower, unsigned int numlower);
/* inode.c */ /* inode.c */
int ovl_set_nlink_upper(struct dentry *dentry); int ovl_set_nlink_upper(struct dentry *dentry);
......
...@@ -1030,13 +1030,13 @@ void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, ...@@ -1030,13 +1030,13 @@ void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
} }
} }
int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, int ovl_indexdir_cleanup(struct ovl_fs *ofs)
struct ovl_path *lower, unsigned int numlower)
{ {
int err; int err;
struct dentry *indexdir = ofs->indexdir;
struct dentry *index = NULL; struct dentry *index = NULL;
struct inode *dir = dentry->d_inode; struct inode *dir = indexdir->d_inode;
struct path path = { .mnt = mnt, .dentry = dentry }; struct path path = { .mnt = ofs->upper_mnt, .dentry = indexdir };
LIST_HEAD(list); LIST_HEAD(list);
struct rb_root root = RB_ROOT; struct rb_root root = RB_ROOT;
struct ovl_cache_entry *p; struct ovl_cache_entry *p;
...@@ -1060,13 +1060,13 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1060,13 +1060,13 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
if (p->len == 2 && p->name[1] == '.') if (p->len == 2 && p->name[1] == '.')
continue; continue;
} }
index = lookup_one_len(p->name, dentry, p->len); index = lookup_one_len(p->name, indexdir, p->len);
if (IS_ERR(index)) { if (IS_ERR(index)) {
err = PTR_ERR(index); err = PTR_ERR(index);
index = NULL; index = NULL;
break; break;
} }
err = ovl_verify_index(index, lower, numlower); err = ovl_verify_index(ofs, index);
/* Cleanup stale and orphan index entries */ /* Cleanup stale and orphan index entries */
if (err && (err == -ESTALE || err == -ENOENT)) if (err && (err == -ESTALE || err == -ENOENT))
err = ovl_cleanup(dir, index); err = ovl_cleanup(dir, index);
......
...@@ -1057,10 +1057,7 @@ static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe, ...@@ -1057,10 +1057,7 @@ static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe,
/* Cleanup bad/stale/orphan index entries */ /* Cleanup bad/stale/orphan index entries */
if (!err) if (!err)
err = ovl_indexdir_cleanup(ofs->indexdir, err = ovl_indexdir_cleanup(ofs);
ofs->upper_mnt,
oe->lowerstack,
oe->numlower);
} }
if (err || !ofs->indexdir) if (err || !ofs->indexdir)
pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n"); pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册