diff options
author | Chandan Rajendra <chandan@linux.vnet.ibm.com> | 2017-07-24 09:57:54 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-09 12:23:27 +0300 |
commit | ba1e563cdc6b07f2d5d9eee854fb3cdf3596470f (patch) | |
tree | 6a68fdb6a0b6dfca8f1962ab327b85ea6cdbc14b /fs/overlayfs | |
parent | 2a9c6d066e98c1fe51a735b1439929f2f2afd891 (diff) | |
download | linux-ba1e563cdc6b07f2d5d9eee854fb3cdf3596470f.tar.xz |
ovl: return anonymous st_dev for lower inodes
For non-samefs setup, to make sure that st_dev/st_ino pair is unique
across the system, we return a unique anonymous st_dev for stat(2)
of lower layer inode.
A following patch is going to fix constant st_dev/st_ino across copy up
by returning origin st_dev/st_ino for copied up objects.
If the st_dev/st_ino for copied up object would have been the same as
that of the real underlying lower file, running diff on underlying lower
file and overlay copied up file would result in diff reporting that the
2 files are equal when in fact, they may have different content.
[amir: simplify ovl_get_pseudo_dev()
split from allocate anonymous bdev patch]
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r-- | fs/overlayfs/inode.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 52aaa8530710..b599059d6f78 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -15,6 +15,14 @@ #include <linux/ratelimit.h> #include "overlayfs.h" + +static dev_t ovl_get_pseudo_dev(struct dentry *dentry) +{ + struct ovl_entry *oe = dentry->d_fsdata; + + return oe->lowerstack[0].layer->pseudo_dev; +} + int ovl_setattr(struct dentry *dentry, struct iattr *attr) { int err; @@ -121,6 +129,13 @@ int ovl_getattr(const struct path *path, struct kstat *stat, */ stat->dev = dentry->d_sb->s_dev; stat->ino = dentry->d_inode->i_ino; + } else if (!OVL_TYPE_UPPER(type)) { + /* + * For non-samefs setup, to make sure that st_dev/st_ino pair + * is unique across the system, we use a unique anonymous + * st_dev for lower layer inode. + */ + stat->dev = ovl_get_pseudo_dev(dentry); } /* |