From a3478c074752610814f894375c3d947ece4938fe Mon Sep 17 00:00:00 2001 From: Olaf Faaland Date: Mon, 20 Mar 2017 17:51:16 -0700 Subject: Linux 4.11 compat: iops.getattr and friends In torvalds/linux@a528d35, there are changes to the getattr family of functions, struct kstat, and the interface of inode_operations .getattr. The inode_operations .getattr and simple_getattr() interface changed to: int (*getattr) (const struct path *, struct dentry *, struct kstat *, u32 request_mask, unsigned int query_flags) The request_mask argument indicates which field(s) the caller intends to use. Fields the caller has not specified via request_mask may be set in the returned struct anyway, but their values may be approximate. The query_flags argument indicates whether the filesystem must update the attributes from the backing store. Currently both fields are ignored. It is possible that getattr-related functions within zfs could be optimized based on the request_mask. struct kstat includes new fields: u32 result_mask; /* What fields the user got */ u64 attributes; /* See STATX_ATTR_* flags */ struct timespec btime; /* File creation time */ Fields attribute and btime are cleared; the result_mask reflects this. These appear to be optional based on simple_getattr() and vfs_getattr() within the kernel, which take the same approach. Reviewed-by: Chunwei Chen Reviewed-by: Brian Behlendorf Signed-off-by: Olaf Faaland Closes #5875 --- module/zfs/zpl_ctldir.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'module/zfs/zpl_ctldir.c') diff --git a/module/zfs/zpl_ctldir.c b/module/zfs/zpl_ctldir.c index b6a3b669d..bd8af3928 100644 --- a/module/zfs/zpl_ctldir.c +++ b/module/zfs/zpl_ctldir.c @@ -100,16 +100,15 @@ zpl_root_readdir(struct file *filp, void *dirent, filldir_t filldir) */ /* ARGSUSED */ static int -zpl_root_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) +zpl_root_getattr_impl(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) { - int error; - - error = simple_getattr(mnt, dentry, stat); + generic_fillattr(path->dentry->d_inode, stat); stat->atime = CURRENT_TIME; - return (error); + return (0); } +ZPL_GETATTR_WRAPPER(zpl_root_getattr); static struct dentry * #ifdef HAVE_LOOKUP_NAMEIDATA @@ -375,21 +374,22 @@ zpl_snapdir_mkdir(struct inode *dip, struct dentry *dentry, zpl_umode_t mode) */ /* ARGSUSED */ static int -zpl_snapdir_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) +zpl_snapdir_getattr_impl(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) { - zfsvfs_t *zfsvfs = ITOZSB(dentry->d_inode); - int error; + zfsvfs_t *zfsvfs = ITOZSB(path->dentry->d_inode); ZFS_ENTER(zfsvfs); - error = simple_getattr(mnt, dentry, stat); + generic_fillattr(path->dentry->d_inode, stat); + stat->nlink = stat->size = 2; stat->ctime = stat->mtime = dmu_objset_snap_cmtime(zfsvfs->z_os); stat->atime = CURRENT_TIME; ZFS_EXIT(zfsvfs); - return (error); + return (0); } +ZPL_GETATTR_WRAPPER(zpl_snapdir_getattr); /* * The '.zfs/snapshot' directory file operations. These mainly control @@ -509,10 +509,10 @@ zpl_shares_readdir(struct file *filp, void *dirent, filldir_t filldir) /* ARGSUSED */ static int -zpl_shares_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) +zpl_shares_getattr_impl(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) { - struct inode *ip = dentry->d_inode; + struct inode *ip = path->dentry->d_inode; zfsvfs_t *zfsvfs = ITOZSB(ip); znode_t *dzp; int error; @@ -520,11 +520,11 @@ zpl_shares_getattr(struct vfsmount *mnt, struct dentry *dentry, ZFS_ENTER(zfsvfs); if (zfsvfs->z_shares_dir == 0) { - error = simple_getattr(mnt, dentry, stat); + generic_fillattr(path->dentry->d_inode, stat); stat->nlink = stat->size = 2; stat->atime = CURRENT_TIME; ZFS_EXIT(zfsvfs); - return (error); + return (0); } error = -zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp); @@ -538,6 +538,7 @@ zpl_shares_getattr(struct vfsmount *mnt, struct dentry *dentry, return (error); } +ZPL_GETATTR_WRAPPER(zpl_shares_getattr); /* * The '.zfs/shares' directory file operations. -- cgit v1.2.3