diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2017-05-05 11:38:58 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-05-05 11:38:58 +0200 |
commit | 5b712091a3a3904b0ae8311e18e6b540a070d464 (patch) | |
tree | 5322c5ac759d7cf3d3884adb9c0778f0377745f8 /fs/overlayfs/dir.c | |
parent | 72b608f08528458334218a809d66ea94d924c378 (diff) |
ovl: merge getattr for dir and nondir
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/dir.c')
-rw-r--r-- | fs/overlayfs/dir.c | 61 |
1 files changed, 1 insertions, 60 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 0c5e79966957..f4cf2928cf8e 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -138,65 +138,6 @@ static int ovl_set_opaque(struct dentry *dentry, struct dentry *upperdentry) return err; } -static int ovl_dir_getattr(const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int flags) -{ - struct dentry *dentry = path->dentry; - int err; - enum ovl_path_type type; - struct path realpath; - const struct cred *old_cred; - - type = ovl_path_real(dentry, &realpath); - old_cred = ovl_override_creds(dentry->d_sb); - err = vfs_getattr(&realpath, stat, request_mask, flags); - if (err) - goto out; - - /* - * When all layers are on the same fs, use the copy-up-origin st_ino, - * which is persistent, unique and constant across copy up. - * - * Otherwise the pair {real st_ino; overlay st_dev} is not unique, so - * use the non persistent overlay st_ino. - */ - if (ovl_same_sb(dentry->d_sb)) { - if (OVL_TYPE_ORIGIN(type)) { - struct kstat lowerstat; - - ovl_path_lower(dentry, &realpath); - err = vfs_getattr(&realpath, &lowerstat, - STATX_INO, flags); - if (err) - goto out; - - WARN_ON_ONCE(stat->dev != lowerstat.dev); - stat->ino = lowerstat.ino; - } - } else { - stat->ino = dentry->d_inode->i_ino; - } - - /* - * Always use the overlay st_dev for directories, so 'find -xdev' will - * scan the entire overlay mount and won't cross the overlay mount - * boundaries. - */ - stat->dev = dentry->d_sb->s_dev; - - /* - * It's probably not worth it to count subdirs to get the - * correct link count. nlink=1 seems to pacify 'find' and - * other utilities. - */ - if (OVL_TYPE_MERGE(type)) - stat->nlink = 1; -out: - revert_creds(old_cred); - - return err; -} - /* Common operations required to be done after creation of file on upper */ static void ovl_instantiate(struct dentry *dentry, struct inode *inode, struct dentry *newdentry, bool hardlink) @@ -1099,7 +1040,7 @@ const struct inode_operations ovl_dir_inode_operations = { .create = ovl_create, .mknod = ovl_mknod, .permission = ovl_permission, - .getattr = ovl_dir_getattr, + .getattr = ovl_getattr, .listxattr = ovl_listxattr, .get_acl = ovl_get_acl, .update_time = ovl_update_time, |