fs: pass the request_mask to generic_fillattr
authorJeff Layton <jlayton@kernel.org>
Mon, 7 Aug 2023 19:38:33 +0000 (15:38 -0400)
committerChristian Brauner <brauner@kernel.org>
Wed, 9 Aug 2023 06:56:36 +0000 (08:56 +0200)
generic_fillattr just fills in the entire stat struct indiscriminately
today, copying data from the inode. There is at least one attribute
(STATX_CHANGE_COOKIE) that can have side effects when it is reported,
and we're looking at adding more with the addition of multigrain
timestamps.

Add a request_mask argument to generic_fillattr and have most callers
just pass in the value that is passed to getattr. Have other callers
(e.g. ksmbd) just pass in STATX_BASIC_STATS. Also move the setting of
STATX_CHANGE_COOKIE into generic_fillattr.

Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: "Paulo Alcantara (SUSE)" <pc@manguebit.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Message-Id: <20230807-mgctime-v7-2-d1dec143a704@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
40 files changed:
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
fs/afs/inode.c
fs/btrfs/inode.c
fs/ceph/inode.c
fs/coda/inode.c
fs/ecryptfs/inode.c
fs/erofs/inode.c
fs/exfat/file.c
fs/ext2/inode.c
fs/ext4/inode.c
fs/f2fs/file.c
fs/fat/file.c
fs/fuse/dir.c
fs/gfs2/inode.c
fs/hfsplus/inode.c
fs/kernfs/inode.c
fs/libfs.c
fs/minix/inode.c
fs/nfs/inode.c
fs/nfs/namespace.c
fs/ntfs3/file.c
fs/ocfs2/file.c
fs/orangefs/inode.c
fs/proc/base.c
fs/proc/fd.c
fs/proc/generic.c
fs/proc/proc_net.c
fs/proc/proc_sysctl.c
fs/proc/root.c
fs/smb/client/inode.c
fs/smb/server/smb2pdu.c
fs/smb/server/vfs.c
fs/stat.c
fs/sysv/itree.c
fs/ubifs/dir.c
fs/udf/symlink.c
fs/vboxsf/utils.c
include/linux/fs.h
mm/shmem.c

index 16d85e6..d24d1f2 100644 (file)
@@ -1016,7 +1016,7 @@ v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path,
        p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
        v9ses = v9fs_dentry2v9ses(dentry);
        if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) {
-               generic_fillattr(&nop_mnt_idmap, inode, stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
                return 0;
        } else if (v9ses->cache & CACHE_WRITEBACK) {
                if (S_ISREG(inode->i_mode)) {
@@ -1037,7 +1037,7 @@ v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path,
                return PTR_ERR(st);
 
        v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb, 0);
-       generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(dentry), stat);
 
        p9stat_free(st);
        kfree(st);
index 464ea73..8e8d5d2 100644 (file)
@@ -451,7 +451,7 @@ v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap,
        p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
        v9ses = v9fs_dentry2v9ses(dentry);
        if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) {
-               generic_fillattr(&nop_mnt_idmap, inode, stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
                return 0;
        } else if (v9ses->cache) {
                if (S_ISREG(inode->i_mode)) {
@@ -476,7 +476,7 @@ v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap,
                return PTR_ERR(st);
 
        v9fs_stat2inode_dotl(st, d_inode(dentry), 0);
-       generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(dentry), stat);
        /* Change block size to what the server returned */
        stat->blksize = st->st_blksize;
 
index 6b636f4..1c794a1 100644 (file)
@@ -773,7 +773,7 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
 
        do {
                read_seqbegin_or_lock(&vnode->cb_lock, &seq);
-               generic_fillattr(&nop_mnt_idmap, inode, stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
                if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) &&
                    stat->nlink > 0)
                        stat->nlink -= 1;
index ceac62c..29a20f8 100644 (file)
@@ -8746,7 +8746,7 @@ static int btrfs_getattr(struct mnt_idmap *idmap,
                                  STATX_ATTR_IMMUTABLE |
                                  STATX_ATTR_NODUMP);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
        stat->dev = BTRFS_I(inode)->root->anon_dev;
 
        spin_lock(&BTRFS_I(inode)->lock);
index 5f6e937..fd05d68 100644 (file)
@@ -2467,7 +2467,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path,
                        return err;
        }
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        stat->ino = ceph_present_inode(inode);
 
        /*
index 3e64679..0c7c252 100644 (file)
@@ -256,7 +256,8 @@ int coda_getattr(struct mnt_idmap *idmap, const struct path *path,
 {
        int err = coda_revalidate_inode(d_inode(path->dentry));
        if (!err)
-               generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask,
+                                d_inode(path->dentry), stat);
        return err;
 }
 
index b491bb2..992d9c7 100644 (file)
@@ -982,7 +982,7 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
 
        mount_crypt_stat = &ecryptfs_superblock_to_private(
                                                dentry->d_sb)->mount_crypt_stat;
-       generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(dentry), stat);
        if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
                char *target;
                size_t targetsiz;
@@ -1011,7 +1011,8 @@ static int ecryptfs_getattr(struct mnt_idmap *idmap,
        if (!rc) {
                fsstack_copy_attr_all(d_inode(dentry),
                                      ecryptfs_inode_to_lower(d_inode(dentry)));
-               generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask,
+                                d_inode(dentry), stat);
                stat->blocks = lower_stat.blocks;
        }
        return rc;
index 567c0d3..f3053f0 100644 (file)
@@ -368,7 +368,7 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
        stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
                                  STATX_ATTR_IMMUTABLE);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
        return 0;
 }
 
index f40ecfe..32395ef 100644 (file)
@@ -232,7 +232,7 @@ int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
        struct inode *inode = d_backing_inode(path->dentry);
        struct exfat_inode_info *ei = EXFAT_I(inode);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        exfat_truncate_atime(&stat->atime);
        stat->result_mask |= STATX_BTIME;
        stat->btime.tv_sec = ei->i_crtime.tv_sec;
index 1259995..acbab27 100644 (file)
@@ -1628,7 +1628,7 @@ int ext2_getattr(struct mnt_idmap *idmap, const struct path *path,
                        STATX_ATTR_IMMUTABLE |
                        STATX_ATTR_NODUMP);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        return 0;
 }
 
index 86696b4..6683076 100644 (file)
@@ -5535,7 +5535,7 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
                                  STATX_ATTR_NODUMP |
                                  STATX_ATTR_VERITY);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
        return 0;
 }
 
index b018800..35886a5 100644 (file)
@@ -882,7 +882,7 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
                                  STATX_ATTR_NODUMP |
                                  STATX_ATTR_VERITY);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
 
        /* we need to show initial sectors used for inline_data/dentries */
        if ((S_ISREG(inode->i_mode) && f2fs_has_inline_data(inode)) ||
index 4564779..e887e9a 100644 (file)
@@ -401,7 +401,7 @@ int fat_getattr(struct mnt_idmap *idmap, const struct path *path,
        struct inode *inode = d_inode(path->dentry);
        struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
        stat->blksize = sbi->cluster_size;
 
        if (sbi->options.nfs == FAT_NFS_NOSTALE_RO) {
index a210c23..645fae4 100644 (file)
@@ -1224,7 +1224,7 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,
                forget_all_cached_acls(inode);
                err = fuse_do_getattr(inode, stat, file);
        } else if (stat) {
-               generic_fillattr(&nop_mnt_idmap, inode, stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
                stat->mode = fi->orig_i_mode;
                stat->ino = fi->orig_ino;
        }
index 2ded6c8..200cabf 100644 (file)
@@ -2071,7 +2071,7 @@ static int gfs2_getattr(struct mnt_idmap *idmap,
                                  STATX_ATTR_IMMUTABLE |
                                  STATX_ATTR_NODUMP);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
        if (gfs2_holder_initialized(&gh))
                gfs2_glock_dq_uninit(&gh);
index 40c61ab..c65c8c4 100644 (file)
@@ -298,7 +298,7 @@ int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
        stat->attributes_mask |= STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE |
                                 STATX_ATTR_NODUMP;
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        return 0;
 }
 
index 89a9b4d..af37be6 100644 (file)
@@ -190,7 +190,7 @@ int kernfs_iop_getattr(struct mnt_idmap *idmap,
 
        down_read(&root->kernfs_iattr_rwsem);
        kernfs_refresh_inode(kn, inode);
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        up_read(&root->kernfs_iattr_rwsem);
 
        return 0;
index 1f5245e..a618784 100644 (file)
@@ -33,7 +33,7 @@ int simple_getattr(struct mnt_idmap *idmap, const struct path *path,
                   unsigned int query_flags)
 {
        struct inode *inode = d_inode(path->dentry);
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        stat->blocks = inode->i_mapping->nrpages << (PAGE_SHIFT - 9);
        return 0;
 }
@@ -1334,7 +1334,7 @@ static int empty_dir_getattr(struct mnt_idmap *idmap,
                             u32 request_mask, unsigned int query_flags)
 {
        struct inode *inode = d_inode(path->dentry);
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        return 0;
 }
 
index 8a4fc94..df57547 100644 (file)
@@ -656,7 +656,7 @@ int minix_getattr(struct mnt_idmap *idmap, const struct path *path,
        struct super_block *sb = path->dentry->d_sb;
        struct inode *inode = d_inode(path->dentry);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        if (INODE_VERSION(inode) == MINIX_V1)
                stat->blocks = (BLOCK_SIZE / 512) * V1_minix_blocks(stat->size, sb);
        else
index 1283fdf..e21c073 100644 (file)
@@ -912,7 +912,7 @@ out_no_revalidate:
        /* Only return attributes that were revalidated. */
        stat->result_mask = nfs_get_valid_attrmask(inode) | request_mask;
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode));
        stat->change_cookie = inode_peek_iversion_raw(inode);
        stat->attributes_mask |= STATX_ATTR_CHANGE_MONOTONIC;
index 19d51eb..e7494cd 100644 (file)
@@ -215,7 +215,8 @@ nfs_namespace_getattr(struct mnt_idmap *idmap,
        if (NFS_FH(d_inode(path->dentry))->size != 0)
                return nfs_getattr(idmap, path, stat, request_mask,
                                   query_flags);
-       generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(path->dentry),
+                        stat);
        return 0;
 }
 
index 1278860..962f12c 100644 (file)
@@ -85,7 +85,7 @@ int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
 
        stat->attributes_mask |= STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED;
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
 
        stat->result_mask |= STATX_BTIME;
        stat->btime = ni->i_crtime;
index 1b337eb..8184499 100644 (file)
@@ -1319,7 +1319,7 @@ int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
                goto bail;
        }
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        /*
         * If there is inline data in the inode, the inode will normally not
         * have data blocks allocated (it may have an external xattr block).
index 9014bbc..a52c30e 100644 (file)
@@ -871,7 +871,7 @@ int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
        ret = orangefs_inode_getattr(inode,
            request_mask & STATX_SIZE ? ORANGEFS_GETATTR_SIZE : 0);
        if (ret == 0) {
-               generic_fillattr(&nop_mnt_idmap, inode, stat);
+               generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
                /* override block size reported to stat */
                if (!(request_mask & STATX_SIZE))
index 3c644a8..2fcb393 100644 (file)
@@ -1966,7 +1966,7 @@ int pid_getattr(struct mnt_idmap *idmap, const struct path *path,
        struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
        struct task_struct *task;
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
        stat->uid = GLOBAL_ROOT_UID;
        stat->gid = GLOBAL_ROOT_GID;
@@ -3899,7 +3899,7 @@ static int proc_task_getattr(struct mnt_idmap *idmap,
 {
        struct inode *inode = d_inode(path->dentry);
        struct task_struct *p = get_proc_task(inode);
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
        if (p) {
                stat->nlink += get_nr_threads(p);
index b3140de..6276b39 100644 (file)
@@ -352,7 +352,7 @@ static int proc_fd_getattr(struct mnt_idmap *idmap,
        struct inode *inode = d_inode(path->dentry);
        int rv = 0;
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
        /* If it's a directory, put the number of open fds there */
        if (S_ISDIR(inode->i_mode)) {
index 42ae38f..775ce0b 100644 (file)
@@ -146,7 +146,7 @@ static int proc_getattr(struct mnt_idmap *idmap,
                }
        }
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        return 0;
 }
 
index a0c0419..75f35f1 100644 (file)
@@ -308,7 +308,7 @@ static int proc_tgid_net_getattr(struct mnt_idmap *idmap,
 
        net = get_proc_task_net(inode);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
        if (net != NULL) {
                stat->nlink = net->proc_net->nlink;
index 6bc10e7..bf06344 100644 (file)
@@ -849,7 +849,7 @@ static int proc_sys_getattr(struct mnt_idmap *idmap,
        if (IS_ERR(head))
                return PTR_ERR(head);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        if (table)
                stat->mode = (stat->mode & S_IFMT) | table->mode;
 
index a86e65a..9191248 100644 (file)
@@ -314,7 +314,8 @@ static int proc_root_getattr(struct mnt_idmap *idmap,
                             const struct path *path, struct kstat *stat,
                             u32 request_mask, unsigned int query_flags)
 {
-       generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(path->dentry),
+                        stat);
        stat->nlink = proc_root.nlink + nr_processes();
        return 0;
 }
index 218f03d..93fe437 100644 (file)
@@ -2540,7 +2540,7 @@ int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
                        return rc;
        }
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        stat->blksize = cifs_sb->ctx->bsize;
        stat->ino = CIFS_I(inode)->uniqueid;
 
index f909983..2a084d3 100644 (file)
@@ -4391,8 +4391,8 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,
        }
 
        basic_info = (struct smb2_file_basic_info *)rsp->Buffer;
-       generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp),
-                        &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS,
+                        file_inode(fp->filp), &stat);
        basic_info->CreationTime = cpu_to_le64(fp->create_time);
        time = ksmbd_UnixTimeToNT(stat.atime);
        basic_info->LastAccessTime = cpu_to_le64(time);
@@ -4417,7 +4417,7 @@ static void get_file_standard_info(struct smb2_query_info_rsp *rsp,
        struct kstat stat;
 
        inode = file_inode(fp->filp);
-       generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS, inode, &stat);
 
        sinfo = (struct smb2_file_standard_info *)rsp->Buffer;
        delete_pending = ksmbd_inode_pending_delete(fp);
@@ -4471,7 +4471,7 @@ static int get_file_all_info(struct ksmbd_work *work,
                return PTR_ERR(filename);
 
        inode = file_inode(fp->filp);
-       generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS, inode, &stat);
 
        ksmbd_debug(SMB, "filename = %s\n", filename);
        delete_pending = ksmbd_inode_pending_delete(fp);
@@ -4548,8 +4548,8 @@ static void get_file_stream_info(struct ksmbd_work *work,
        int buf_free_len;
        struct smb2_query_info_req *req = ksmbd_req_buf_next(work);
 
-       generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp),
-                        &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS,
+                        file_inode(fp->filp), &stat);
        file_info = (struct smb2_file_stream_info *)rsp->Buffer;
 
        buf_free_len =
@@ -4639,8 +4639,8 @@ static void get_file_internal_info(struct smb2_query_info_rsp *rsp,
        struct smb2_file_internal_info *file_info;
        struct kstat stat;
 
-       generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp),
-                        &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS,
+                        file_inode(fp->filp), &stat);
        file_info = (struct smb2_file_internal_info *)rsp->Buffer;
        file_info->IndexNumber = cpu_to_le64(stat.ino);
        rsp->OutputBufferLength =
@@ -4665,7 +4665,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
        file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer;
 
        inode = file_inode(fp->filp);
-       generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS, inode, &stat);
 
        file_info->CreationTime = cpu_to_le64(fp->create_time);
        time = ksmbd_UnixTimeToNT(stat.atime);
@@ -4726,8 +4726,8 @@ static void get_file_compression_info(struct smb2_query_info_rsp *rsp,
        struct smb2_file_comp_info *file_info;
        struct kstat stat;
 
-       generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp),
-                        &stat);
+       generic_fillattr(file_mnt_idmap(fp->filp), STATX_BASIC_STATS,
+                        file_inode(fp->filp), &stat);
 
        file_info = (struct smb2_file_comp_info *)rsp->Buffer;
        file_info->CompressedFileSize = cpu_to_le64(stat.blocks << 9);
index e359144..d0e94b7 100644 (file)
@@ -1650,7 +1650,8 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
        u64 time;
        int rc;
 
-       generic_fillattr(idmap, d_inode(dentry), ksmbd_kstat->kstat);
+       generic_fillattr(idmap, STATX_BASIC_STATS, d_inode(dentry),
+                        ksmbd_kstat->kstat);
 
        time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime);
        ksmbd_kstat->create_time = time;
index 8c2b30a..7644e59 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
 
 /**
  * generic_fillattr - Fill in the basic attributes from the inode struct
- * @idmap:     idmap of the mount the inode was found from
- * @inode:     Inode to use as the source
- * @stat:      Where to fill in the attributes
+ * @idmap:             idmap of the mount the inode was found from
+ * @request_mask:      statx request_mask
+ * @inode:             Inode to use as the source
+ * @stat:              Where to fill in the attributes
  *
  * Fill in the basic attributes in the kstat structure from data that's to be
  * found on the VFS inode structure.  This is the default if no getattr inode
@@ -42,8 +43,8 @@
  * uid and gid filds. On non-idmapped mounts or if permission checking is to be
  * performed on the raw inode simply passs @nop_mnt_idmap.
  */
-void generic_fillattr(struct mnt_idmap *idmap, struct inode *inode,
-                     struct kstat *stat)
+void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask,
+                     struct inode *inode, struct kstat *stat)
 {
        vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
        vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
@@ -61,6 +62,12 @@ void generic_fillattr(struct mnt_idmap *idmap, struct inode *inode,
        stat->ctime = inode_get_ctime(inode);
        stat->blksize = i_blocksize(inode);
        stat->blocks = inode->i_blocks;
+
+       if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) {
+               stat->result_mask |= STATX_CHANGE_COOKIE;
+               stat->change_cookie = inode_query_iversion(inode);
+       }
+
 }
 EXPORT_SYMBOL(generic_fillattr);
 
@@ -123,17 +130,12 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
        stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT |
                                  STATX_ATTR_DAX);
 
-       if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) {
-               stat->result_mask |= STATX_CHANGE_COOKIE;
-               stat->change_cookie = inode_query_iversion(inode);
-       }
-
        idmap = mnt_idmap(path->mnt);
        if (inode->i_op->getattr)
                return inode->i_op->getattr(idmap, path, stat,
                                            request_mask, query_flags);
 
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
        return 0;
 }
 EXPORT_SYMBOL(vfs_getattr_nosec);
index dba6a2e..edb94e5 100644 (file)
@@ -449,7 +449,8 @@ int sysv_getattr(struct mnt_idmap *idmap, const struct path *path,
                 struct kstat *stat, u32 request_mask, unsigned int flags)
 {
        struct super_block *s = path->dentry->d_sb;
-       generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(path->dentry),
+                        stat);
        stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size);
        stat->blksize = s->s_blocksize;
        return 0;
index 3a1ba8b..2f48c58 100644 (file)
@@ -1654,7 +1654,7 @@ int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path,
                                STATX_ATTR_ENCRYPTED |
                                STATX_ATTR_IMMUTABLE);
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        stat->blksize = UBIFS_BLOCK_SIZE;
        stat->size = ui->ui_size;
 
index 779b5c2..f7eaf7b 100644 (file)
@@ -149,7 +149,7 @@ static int udf_symlink_getattr(struct mnt_idmap *idmap,
        struct inode *inode = d_backing_inode(dentry);
        struct page *page;
 
-       generic_fillattr(&nop_mnt_idmap, inode, stat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
        page = read_mapping_page(inode->i_mapping, 0, NULL);
        if (IS_ERR(page))
                return PTR_ERR(page);
index 576b91d..83f20dd 100644 (file)
@@ -252,7 +252,7 @@ int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
        if (err)
                return err;
 
-       generic_fillattr(&nop_mnt_idmap, d_inode(dentry), kstat);
+       generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(dentry), kstat);
        return 0;
 }
 
index 61f2701..85977cd 100644 (file)
@@ -2917,7 +2917,7 @@ extern void page_put_link(void *);
 extern int page_symlink(struct inode *inode, const char *symname, int len);
 extern const struct inode_operations page_symlink_inode_operations;
 extern void kfree_link(void *);
-void generic_fillattr(struct mnt_idmap *, struct inode *, struct kstat *);
+void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *);
 void generic_fill_statx_attr(struct inode *inode, struct kstat *stat);
 extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int);
 extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int);
index 72129c1..142ead7 100644 (file)
@@ -1073,7 +1073,7 @@ static int shmem_getattr(struct mnt_idmap *idmap,
        stat->attributes_mask |= (STATX_ATTR_APPEND |
                        STATX_ATTR_IMMUTABLE |
                        STATX_ATTR_NODUMP);
-       generic_fillattr(idmap, inode, stat);
+       generic_fillattr(idmap, request_mask, inode, stat);
 
        if (shmem_is_huge(inode, 0, false, NULL, 0))
                stat->blksize = HPAGE_PMD_SIZE;