Skip to content

Commit ba1e563

Browse files
Chandan RajendraMiklos Szeredi
authored andcommitted
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>
1 parent 2a9c6d0 commit ba1e563

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/overlayfs/inode.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#include <linux/ratelimit.h>
1616
#include "overlayfs.h"
1717

18+
19+
static dev_t ovl_get_pseudo_dev(struct dentry *dentry)
20+
{
21+
struct ovl_entry *oe = dentry->d_fsdata;
22+
23+
return oe->lowerstack[0].layer->pseudo_dev;
24+
}
25+
1826
int ovl_setattr(struct dentry *dentry, struct iattr *attr)
1927
{
2028
int err;
@@ -121,6 +129,13 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
121129
*/
122130
stat->dev = dentry->d_sb->s_dev;
123131
stat->ino = dentry->d_inode->i_ino;
132+
} else if (!OVL_TYPE_UPPER(type)) {
133+
/*
134+
* For non-samefs setup, to make sure that st_dev/st_ino pair
135+
* is unique across the system, we use a unique anonymous
136+
* st_dev for lower layer inode.
137+
*/
138+
stat->dev = ovl_get_pseudo_dev(dentry);
124139
}
125140

126141
/*

0 commit comments

Comments
 (0)