diff options
author | Amir Goldstein <amir73il@gmail.com> | 2017-12-12 15:40:46 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-01-24 04:19:46 -0500 |
commit | 1eff1a1deec727bacead79ec64554c1df190f43c (patch) | |
tree | eaae28170f3fb13a4c3463fd3e9c0a923ec83003 /fs/overlayfs/namei.c | |
parent | 2e1a532883cf77f01031bef4b83d864a46c1bed0 (diff) |
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>
Diffstat (limited to 'fs/overlayfs/namei.c')
-rw-r--r-- | fs/overlayfs/namei.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index a6b9bd2afca1..27f25a61f6e4 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c | |||
@@ -291,17 +291,15 @@ static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, | |||
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry, | 294 | static int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, |
295 | struct ovl_path *lower, unsigned int numlower, | 295 | struct dentry *upperdentry, |
296 | struct ovl_path **stackp) | 296 | struct ovl_path **stackp) |
297 | { | 297 | { |
298 | struct vfsmount *mnt; | ||
299 | struct dentry *origin = NULL; | 298 | struct dentry *origin = NULL; |
300 | int i; | 299 | int i; |
301 | 300 | ||
302 | for (i = 0; i < numlower; i++) { | 301 | for (i = 0; i < ofs->numlower; i++) { |
303 | mnt = lower[i].layer->mnt; | 302 | origin = ovl_decode_fh(fh, ofs->lower_layers[i].mnt); |
304 | origin = ovl_decode_fh(fh, mnt); | ||
305 | if (origin) | 303 | if (origin) |
306 | break; | 304 | break; |
307 | } | 305 | } |
@@ -321,7 +319,10 @@ static int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry, | |||
321 | dput(origin); | 319 | dput(origin); |
322 | return -ENOMEM; | 320 | return -ENOMEM; |
323 | } | 321 | } |
324 | **stackp = (struct ovl_path){.dentry = origin, .layer = lower[i].layer}; | 322 | **stackp = (struct ovl_path){ |
323 | .dentry = origin, | ||
324 | .layer = &ofs->lower_layers[i] | ||
325 | }; | ||
325 | 326 | ||
326 | return 0; | 327 | return 0; |
327 | 328 | ||
@@ -333,8 +334,7 @@ invalid: | |||
333 | return -EIO; | 334 | return -EIO; |
334 | } | 335 | } |
335 | 336 | ||
336 | static int ovl_check_origin(struct dentry *upperdentry, | 337 | static int ovl_check_origin(struct ovl_fs *ofs, struct dentry *upperdentry, |
337 | struct ovl_path *lower, unsigned int numlower, | ||
338 | struct ovl_path **stackp, unsigned int *ctrp) | 338 | struct ovl_path **stackp, unsigned int *ctrp) |
339 | { | 339 | { |
340 | struct ovl_fh *fh = ovl_get_origin_fh(upperdentry); | 340 | struct ovl_fh *fh = ovl_get_origin_fh(upperdentry); |
@@ -343,7 +343,7 @@ static int ovl_check_origin(struct dentry *upperdentry, | |||
343 | if (IS_ERR_OR_NULL(fh)) | 343 | if (IS_ERR_OR_NULL(fh)) |
344 | return PTR_ERR(fh); | 344 | return PTR_ERR(fh); |
345 | 345 | ||
346 | err = ovl_check_origin_fh(fh, upperdentry, lower, numlower, stackp); | 346 | err = ovl_check_origin_fh(ofs, fh, upperdentry, stackp); |
347 | kfree(fh); | 347 | kfree(fh); |
348 | 348 | ||
349 | if (err) { | 349 | if (err) { |
@@ -423,8 +423,7 @@ fail: | |||
423 | * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path. | 423 | * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path. |
424 | * Return 0 on match, -ESTALE on mismatch or stale origin, < 0 on error. | 424 | * Return 0 on match, -ESTALE on mismatch or stale origin, < 0 on error. |
425 | */ | 425 | */ |
426 | int ovl_verify_index(struct dentry *index, struct ovl_path *lower, | 426 | int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index) |
427 | unsigned int numlower) | ||
428 | { | 427 | { |
429 | struct ovl_fh *fh = NULL; | 428 | struct ovl_fh *fh = NULL; |
430 | size_t len; | 429 | size_t len; |
@@ -471,7 +470,7 @@ int ovl_verify_index(struct dentry *index, struct ovl_path *lower, | |||
471 | if (err) | 470 | if (err) |
472 | goto fail; | 471 | goto fail; |
473 | 472 | ||
474 | err = ovl_check_origin_fh(fh, index, lower, numlower, &stack); | 473 | err = ovl_check_origin_fh(ofs, fh, index, &stack); |
475 | if (err) | 474 | if (err) |
476 | goto fail; | 475 | goto fail; |
477 | 476 | ||
@@ -689,8 +688,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, | |||
689 | * number - it's the same as if we held a reference | 688 | * number - it's the same as if we held a reference |
690 | * to a dentry in lower layer that was moved under us. | 689 | * to a dentry in lower layer that was moved under us. |
691 | */ | 690 | */ |
692 | err = ovl_check_origin(upperdentry, roe->lowerstack, | 691 | err = ovl_check_origin(ofs, upperdentry, &stack, &ctr); |
693 | roe->numlower, &stack, &ctr); | ||
694 | if (err) | 692 | if (err) |
695 | goto out_put_upper; | 693 | goto out_put_upper; |
696 | } | 694 | } |