[Devel] [PATCH RHEL7 COMMIT] docker: Revert "vfs: take stat's dev from mnt->sb"

Vladimir Davydov vdavydov at virtuozzo.com
Wed Aug 24 09:19:01 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.28.2.vz7.17.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.28.2.vz7.17.3
------>
commit 11a02aff96d8a6140b5ca71eacaa6e9b995db7d5
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Wed Aug 24 20:19:01 2016 +0400

    docker: Revert "vfs: take stat's dev from mnt->sb"
    
    This reverts commit ecfa1b0f7ba985e200e807941b5838943b266cb3.
    
    All non-directory objects on overlayfs should report an st_dev from
    lower or upper filesystem that is providing the object then call
    stat(2) on it(Documentation/filesystems/overlayfs.txt). But in our
    case file on overlayfs reports st_dev from overlayfs itself:
    
    e.g.: on VZ7 host device is 57 but should be 64768:
    mkdir /lower /upper /merged /work
    mount -t overlay overlay -olowerdir=/lower,upperdir=/upper,\
    workdir=/work /merged
    touch /merged/file
    stat /merged/file | grep Device | awk '{print $1$2}'
      Device:39h/57d
    cat /proc/self/mountinfo
      63 1 253:0 / / rw,relatime shared:1 - ext4
    /dev/mapper/virtuozzo_pcs7-root rw,data=ordered
      149 63 0:57 / /merged rw,relatime shared:81 - overlay overlay
    rw,lowerdir=/lower,upperdir=/upper,workdir=/work
    
    Reason is in sys_stat->vfs_stat->vfs_fstatat->vfs_getattr:
    1) Call ovl_getattr()->ovl_path_real() - find real object's path
    2) Call ovl_getattr()->vfs_getattr() - find real object's s_dev
    3) Replace it with overlay's s_dev, which is wrong.
    
    We do not have simfs - remove step (3) and stat will be fine again.
    
    *note: we need it for docker - when stat and fstat give different
    s_dev ldconfig in glibc breaks, and thus docker-ui tests break.
    
    https://jira.sw.ru/browse/PSBM-51255
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/stat.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/fs/stat.c b/fs/stat.c
index a423f6351e27..d0ea7ef75e26 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -14,7 +14,6 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/pagemap.h>
-#include <linux/mount.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -48,14 +47,10 @@ int vfs_getattr(struct path *path, struct kstat *stat)
 		return retval;
 
 	if (inode->i_op->getattr)
-		retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
-	else
-		generic_fillattr(inode, stat);
+		return inode->i_op->getattr(path->mnt, path->dentry, stat);
 
-	if (!retval)
-		stat->dev = path->mnt->mnt_sb->s_dev;
-
-	return retval;
+	generic_fillattr(inode, stat);
+	return 0;
 }
 
 EXPORT_SYMBOL(vfs_getattr);


More information about the Devel mailing list