Commit f7d3daca authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

ovl: relax same fs constrain for ovl_check_origin()

For the case of all layers not on the same fs, try to decode the copy up
origin file handle on any of the lower layers.
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 2cac0c00
...@@ -272,28 +272,24 @@ static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, ...@@ -272,28 +272,24 @@ static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d,
static int ovl_check_origin(struct dentry *dentry, struct dentry *upperdentry, static int ovl_check_origin(struct dentry *dentry, struct dentry *upperdentry,
struct path **stackp, unsigned int *ctrp) struct path **stackp, unsigned int *ctrp)
{ {
struct super_block *same_sb = ovl_same_sb(dentry->d_sb);
struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata; struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata;
struct vfsmount *mnt; struct vfsmount *mnt;
struct dentry *origin; struct dentry *origin = NULL;
int i;
if (!same_sb || !roe->numlower)
return 0;
/* for (i = 0; i < roe->numlower; i++) {
* Since all layers are on the same fs, we use the first layer for mnt = roe->lowerstack[i].mnt;
* decoding the file handle. We may get a disconnected dentry, origin = ovl_get_origin(upperdentry, mnt);
* which is fine, because we only need to hold the origin inode in if (IS_ERR(origin))
* cache and use its inode number. We may even get a connected dentry, return PTR_ERR(origin);
* that is not under the first layer's root. That is also fine for
* using it's inode number - it's the same as if we held a reference if (origin)
* to a dentry in first layer that was moved under us. break;
*/ }
mnt = roe->lowerstack[0].mnt;
if (!origin)
origin = ovl_get_origin(upperdentry, mnt); return 0;
if (IS_ERR_OR_NULL(origin))
return PTR_ERR(origin);
BUG_ON(*stackp || *ctrp); BUG_ON(*stackp || *ctrp);
*stackp = kmalloc(sizeof(struct path), GFP_TEMPORARY); *stackp = kmalloc(sizeof(struct path), GFP_TEMPORARY);
...@@ -371,6 +367,16 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, ...@@ -371,6 +367,16 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
} }
if (upperdentry && !d.is_dir) { if (upperdentry && !d.is_dir) {
BUG_ON(!d.stop || d.redirect); BUG_ON(!d.stop || d.redirect);
/*
* Lookup copy up origin by decoding origin file handle.
* We may get a disconnected dentry, which is fine,
* because we only need to hold the origin inode in
* cache and use its inode number. We may even get a
* connected dentry, that is not under any of the lower
* layers root. That is also fine for using it's inode
* 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(dentry, upperdentry, err = ovl_check_origin(dentry, upperdentry,
&stack, &ctr); &stack, &ctr);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment