[RFC][PATCH 11/13] ovl: fix du --one-file-system on overlay mount

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Overlay directory inodes report overlay bdev and overlay ino to stat(2).
Overlay regular file inodes report real bdev and real ino to stat(2).

This results in wrong results from command du -x on an overlay mount,
because the regular files are not accounted for the overlay bdev usage.

The reasons for this inconsistecy is:
1. The overlay ino is not persistent, so real ino is used
2. The tupple overlay bdev and real ino is not unique, so real bdev is
   used

In case all overlay layers are on the same underlying fs, the tupple
from reason 2 above is unique, so use this tupple for regular files and
symlinks to produce the correct result from du -x.

Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 fs/overlayfs/inode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 42fa243..1951865 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -69,6 +69,17 @@ static int ovl_getattr(const struct path *path, struct kstat *stat,
 	old_cred = ovl_override_creds(dentry->d_sb);
 	err = vfs_getattr(&realpath, stat, request_mask, flags);
 	revert_creds(old_cred);
+	if (err)
+		return err;
+
+	/*
+	 * When all layers are on same fs, the tupple overlay bdev
+	 * and real inode ino is unique, so it is preferred to expose
+	 * overlay bdev for overlay inodes for things like du -x.
+	 */
+	if (ovl_same_sb(dentry->d_sb))
+		stat->dev = dentry->d_sb->s_dev;
+
 	return err;
 }
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux