@@ -96,11 +96,14 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
WARN_ON_ONCE(stat->dev != lowerstat.dev);
/*
- * Lower hardlinks are broken on copy up to different
+ * Lower hardlinks may be broken on copy up to different
* upper files, so we cannot use the lower origin st_ino
* for those different files, even for the same fs case.
+ * Indexed upper inodes are safe and non-hardlinked
+ * origin inodes are safe.
*/
- if (is_dir || lowerstat.nlink == 1)
+ if (is_dir || lowerstat.nlink == 1 ||
+ OVL_TYPE_INDEX(type))
stat->ino = lowerstat.ino;
}
stat->dev = dentry->d_sb->s_dev;
When inodes index feature is enabled, it is safe to return the copy up origin st_ino for indexed upper hardlinks, because all indexed upper hardlinks are represented by the same overlay inode as the copy up origin. Signed-off-by: Amir Goldstein <amir73il@gmail.com> --- fs/overlayfs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)