Whamcloud - gitweb
LU-16049 llite: struct cleanup and option ordering 15/58515/3
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 21 Mar 2025 23:09:03 +0000 (17:09 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 10 Apr 2025 06:58:48 +0000 (06:58 +0000)
Reorder some fields in struct ll_file_data and ll_inode_info to
remove holes to save space in these commonly-used structures.
Rename struct ll_file_data ll_lock_no_expand->lfd_lock_no_expand.

Alphabetize LL_SBI_ enum to be in alphabetical order (by option
type) so that it is easier to find options, and to deconflict
future field insertions so that they are not always at the end.
These values are only used in memory on the client.

Partly alphabetize the llite_attrs table to make it easier to
find entries, and deconflict future field insertions.  Not fully
ordered to avoid conflicts with in-flight patches.

There should not be any functional changes in this patch.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I8b58e59bc7e5d4ab7422303edcac0036c82540e5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58515
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c

index 29258e0..549cbf6 100644 (file)
@@ -1824,7 +1824,7 @@ void ll_io_init(struct cl_io *io, struct file *file, enum cl_io_type iot,
        int flags = vvp_io_args_flags(file, args);
 
        io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
-       io->ci_lock_no_expand = lfd->ll_lock_no_expand;
+       io->ci_lock_no_expand = lfd->lfd_lock_no_expand;
 
        if (iot == CIT_WRITE) {
                io->u.ci_wr.wr_append = iocb_ki_flags_check(flags, APPEND);
@@ -4206,7 +4206,7 @@ static int ll_lock_noexpand(struct file *file, int flags)
 {
        struct ll_file_data *lfd = file->private_data;
 
-       lfd->ll_lock_no_expand = !(flags & LF_UNSET);
+       lfd->lfd_lock_no_expand = !(flags & LF_UNSET);
 
        return 0;
 }
index 7789b5a..ff10cb5 100644 (file)
@@ -139,6 +139,8 @@ struct ll_inode_info {
        __u32                           lli_inode_magic;
        rwlock_t                        lli_lock;
 
+       __u32                           lli_projid;   /* project id */
+
        volatile unsigned long          lli_flags;
        struct posix_acl                *lli_posix_acl;
 
@@ -255,10 +257,10 @@ struct ll_inode_info {
                        /* for writepage() only to communicate to fsync */
                        int                     lli_async_rc;
 
+                       __u32                   lli_heat_flags;
                        /* protect the file heat fields */
-                       spinlock_t                      lli_heat_lock;
-                       __u32                           lli_heat_flags;
-                       struct obd_heat_instance        lli_heat_instances[OBD_HEAT_COUNT];
+                       spinlock_t              lli_heat_lock;
+                       struct obd_heat_instance lli_heat_instances[OBD_HEAT_COUNT];
 
                        /*
                         * Whenever a process try to read/write the file, the
@@ -272,9 +274,9 @@ struct ll_inode_info {
                        seqlock_t               lli_jobinfo_seqlock;
                        struct job_info         lli_jobinfo;
 
-                       struct mutex             lli_pcc_lock;
-                       enum lu_pcc_state_flags  lli_pcc_state;
-                       atomic_t                 lli_pcc_mapcnt;
+                       struct mutex            lli_pcc_lock;
+                       enum lu_pcc_state_flags lli_pcc_state;
+                       atomic_t                lli_pcc_mapcnt;
                        /*
                         * I/O for a file previously opened before attach into
                         * PCC or once opened while in ATTACHING state will
@@ -286,6 +288,7 @@ struct ll_inode_info {
                         * Lustre file when mmaped a file.
                         */
                        atomic_t                 lli_pcc_mapneg;
+                       enum pcc_dataset_flags   lli_pcc_dsflags;
                        /*
                         * @lli_pcc_generation saves the gobal PCC generation
                         * when the file was successfully attached into PCC.
@@ -300,7 +303,6 @@ struct ll_inode_info {
                         * safely.
                         */
                        __u64                    lli_pcc_generation;
-                       enum pcc_dataset_flags   lli_pcc_dsflags;
                        struct pcc_inode        *lli_pcc_inode;
 
                        struct mutex             lli_group_mutex;
@@ -332,8 +334,6 @@ struct ll_inode_info {
        __u32                           lli_layout_gen;
        spinlock_t                      lli_layout_lock;
 
-       __u32                           lli_projid;   /* project id */
-
        struct rw_semaphore             lli_xattrs_list_rwsem;
        struct mutex                    lli_xattrs_enq_lock;
        struct list_head                lli_xattrs; /* ll_xattr_entry->xe_list*/
@@ -834,38 +834,38 @@ enum stats_track_type {
 
 /* flags for sbi->ll_flags */
 enum ll_sbi_flags {
-       LL_SBI_NOLCK,                   /* DLM locking disabled directio-only */
-       LL_SBI_CHECKSUM,                /* checksum each page as it's written */
-       LL_SBI_LOCALFLOCK,              /* local flocks instead of fs-wide */
-       LL_SBI_FLOCK,                   /* flock enabled */
-       LL_SBI_USER_XATTR,              /* support user xattr */
-       LL_SBI_LRU_RESIZE,              /* lru resize support */
-       LL_SBI_LAZYSTATFS,              /* lazystatfs mount option */
        LL_SBI_32BIT_API,               /* generate 32 bit inodes. */
-       LL_SBI_USER_FID2PATH,           /* fid2path by unprivileged users */
-       LL_SBI_VERBOSE,                 /* verbose mount/umount */
        LL_SBI_ALWAYS_PING,             /* ping even if server suppress_pings */
-       LL_SBI_TEST_DUMMY_ENCRYPTION,   /* test dummy encryption */
+       LL_SBI_CHECKSUM,                /* checksum each page as it's written */
        LL_SBI_ENCRYPT,                 /* client side encryption */
+       LL_SBI_FLOCK,                   /* flock enabled */
+       LL_SBI_LOCALFLOCK,              /* local flocks instead of fs-wide */
        LL_SBI_FOREIGN_SYMLINK,         /* foreign fake-symlink support */
        LL_SBI_FOREIGN_SYMLINK_UPCALL,  /* foreign fake-symlink upcall set */
+       LL_SBI_LAZYSTATFS,              /* lazystatfs mount option */
+       LL_SBI_LRU_RESIZE,              /* lru resize support */
+       LL_SBI_NOLCK,                   /* DLM locking disabled directio-only */
        LL_SBI_STATFS_PROJECT,          /* statfs returns project quota */
+       LL_SBI_TEST_DUMMY_ENCRYPTION,   /* test dummy encryption */
+       LL_SBI_USER_FID2PATH,           /* fid2path by unprivileged users */
+       LL_SBI_USER_XATTR,              /* support user xattr */
+       LL_SBI_VERBOSE,                 /* verbose mount/umount */
        LL_SBI_NUM_MOUNT_OPT,
 
+       LL_SBI_64BIT_HASH,              /* support 64-bits dir hash/offset */
        LL_SBI_ACL,                     /* support ACL */
        LL_SBI_AGL_ENABLED,             /* enable agl */
-       LL_SBI_64BIT_HASH,              /* support 64-bits dir hash/offset */
-       LL_SBI_LAYOUT_LOCK,             /* layout lock support */
-       LL_SBI_XATTR_CACHE,             /* support for xattr cache */
-       LL_SBI_NOROOTSQUASH,            /* do not apply root squash */
+       LL_SBI_ENCRYPT_NAME,            /* name encryption */
        LL_SBI_FAST_READ,               /* fast read support */
-       LL_SBI_FILE_SECCTX,             /* file security context at create */
-       LL_SBI_TINY_WRITE,              /* tiny write support */
        LL_SBI_FILE_HEAT,               /* file heat support */
+       LL_SBI_FILE_SECCTX,             /* file security context at create */
+       LL_SBI_HYBRID_IO,               /* allow BIO as DIO */
+       LL_SBI_LAYOUT_LOCK,             /* layout lock support */
+       LL_SBI_NOROOTSQUASH,            /* do not apply root squash */
        LL_SBI_PARALLEL_DIO,            /* parallel (async) O_DIRECT RPCs */
-       LL_SBI_ENCRYPT_NAME,            /* name encryption */
+       LL_SBI_TINY_WRITE,              /* tiny write support */
        LL_SBI_UNALIGNED_DIO,           /* unaligned DIO */
-       LL_SBI_HYBRID_IO,               /* allow BIO as DIO */
+       LL_SBI_XATTR_CACHE,             /* support for xattr cache */
        LL_SBI_NUM_FLAGS
 };
 
@@ -905,15 +905,15 @@ struct ll_sb_info {
 
        DECLARE_BITMAP(ll_flags, LL_SBI_NUM_FLAGS); /* enum ll_sbi_flags */
        gid_t                    ll_enable_setstripe_gid; /*  */
-       unsigned int             ll_xattr_cache_enabled:1,
-                                ll_xattr_cache_set:1, /* already set to 0/1 */
+       unsigned int             ll_checksum_set:1,
                                 ll_client_common_fill_super_succeeded:1,
-                                ll_checksum_set:1,
-                                ll_inode_cache_enabled:1,
+                                ll_dir_open_read:1,
                                 ll_enable_statahead_fname:1,
+                                ll_inode_cache_enabled:1,
                                 ll_intent_mkdir_enabled:1,
-                                ll_dir_open_read:1;
-
+                                ll_sync_on_close:1,
+                                ll_xattr_cache_enabled:1,
+                                ll_xattr_cache_set:1; /* already set to 0/1 */
 
        struct lustre_client_ocd ll_lco;
 
@@ -1144,38 +1144,38 @@ struct ll_readahead_work {
 extern struct kmem_cache *ll_file_data_slab;
 struct lustre_handle;
 struct ll_file_data {
-       struct ll_readahead_state fd_ras;
-       struct ll_grouplock fd_grouplock;
-       __u64 lfd_pos;
-       __u32 fd_flags;
-       enum mds_open_flags fd_open_mode;
+       struct file                     *fd_file;
+       __u64                           lfd_pos;
        /* openhandle if lease exists for this file.
         * Borrow lli->lli_och_mutex to protect assignment
         */
-       struct obd_client_handle *fd_lease_och;
-       struct obd_client_handle *fd_och;
-       struct file *fd_file;
+       struct obd_client_handle        *fd_lease_och;
+       struct obd_client_handle        *fd_och;
+       struct ll_readahead_state       fd_ras;
        /* Indicate whether need to report failure when close.
         * true: failure is known, not report again.
         * false: unknown failure, should report.
         */
-       bool fd_write_failed;
-       bool ll_lock_no_expand;
+       bool                            fd_write_failed;
+       unsigned int                    lfd_lock_no_expand:1;
+       __u32                           fd_flags;
+       enum mds_open_flags             fd_open_mode;
+       /* striped directory may read partially if some stripe inaccessible,
+        * -errno is saved here, and will return to user in close().
+        */
+       int                             fd_partial_readdir_rc;
        /* Used by mirrored file to lead IOs to a specific mirror, usually
         * for mirror resync. 0 means default.
         */
-       __u32 fd_designated_mirror;
+       __u32                           fd_designated_mirror;
        /* The layout version when resync starts. Resync I/O should carry this
         * layout version for verification to OST objects
         */
-       __u32 fd_layout_version;
-       struct pcc_file fd_pcc_file;
-       /* striped directory may read partially if some stripe inaccessible,
-        * -errno is saved here, and will return to user in close().
-        */
-       int fd_partial_readdir_rc;
+       __u32                           fd_layout_version;
+       struct ll_grouplock             fd_grouplock;
+       struct pcc_file                 fd_pcc_file;
        /* mdtest unique/shared dir stat mode: per process statahead struct. */
-       struct ll_statahead_info *fd_sai;
+       struct ll_statahead_info        *fd_sai;
 };
 
 void llite_tunables_unregister(void);
index 32d13f4..56dff93 100644 (file)
@@ -973,47 +973,47 @@ void ll_kill_super(struct super_block *sb)
  * for the sbi_flags.
  */
 static const match_table_t ll_sbi_flags_name = {
-       {LL_SBI_NOLCK,                  "nolock"},
+       {LL_SBI_32BIT_API,              "32bitapi"},
        {LL_SBI_CHECKSUM,               "checksum"},
        {LL_SBI_CHECKSUM,               "nochecksum"},
-       {LL_SBI_LOCALFLOCK,             "localflock"},
+       {LL_SBI_ENCRYPT,                "encrypt"},
+       {LL_SBI_ENCRYPT,                "noencrypt"},
        {LL_SBI_FLOCK,                  "flock"},
        {LL_SBI_FLOCK,                  "noflock"},
-       {LL_SBI_USER_XATTR,             "user_xattr"},
-       {LL_SBI_USER_XATTR,             "nouser_xattr"},
-       {LL_SBI_LRU_RESIZE,             "lruresize"},
-       {LL_SBI_LRU_RESIZE,             "nolruresize"},
+       {LL_SBI_LOCALFLOCK,             "localflock"},
+       {LL_SBI_FOREIGN_SYMLINK,        "foreign_symlink=%s"},
        {LL_SBI_LAZYSTATFS,             "lazystatfs"},
        {LL_SBI_LAZYSTATFS,             "nolazystatfs"},
-       {LL_SBI_32BIT_API,              "32bitapi"},
+       {LL_SBI_LRU_RESIZE,             "lruresize"},
+       {LL_SBI_LRU_RESIZE,             "nolruresize"},
+       {LL_SBI_NOLCK,                  "nolock"},
+       {LL_SBI_STATFS_PROJECT,         "statfs_project"},
+       {LL_SBI_STATFS_PROJECT,         "nostatfs_project"},
+       {LL_SBI_TEST_DUMMY_ENCRYPTION,  "test_dummy_encryption=%s"},
+       {LL_SBI_TEST_DUMMY_ENCRYPTION,  "test_dummy_encryption"},
        {LL_SBI_USER_FID2PATH,          "user_fid2path"},
        {LL_SBI_USER_FID2PATH,          "nouser_fid2path"},
+       {LL_SBI_USER_XATTR,             "user_xattr"},
+       {LL_SBI_USER_XATTR,             "nouser_xattr"},
        {LL_SBI_VERBOSE,                "verbose"},
        {LL_SBI_VERBOSE,                "noverbose"},
        {LL_SBI_ALWAYS_PING,            "always_ping"},
-       {LL_SBI_TEST_DUMMY_ENCRYPTION,  "test_dummy_encryption=%s"},
-       {LL_SBI_TEST_DUMMY_ENCRYPTION,  "test_dummy_encryption"},
-       {LL_SBI_ENCRYPT,                "encrypt"},
-       {LL_SBI_ENCRYPT,                "noencrypt"},
-       {LL_SBI_FOREIGN_SYMLINK,        "foreign_symlink=%s"},
-       {LL_SBI_STATFS_PROJECT,         "statfs_project"},
-       {LL_SBI_STATFS_PROJECT,         "nostatfs_project"},
        {LL_SBI_NUM_MOUNT_OPT,          NULL},
 
+       {LL_SBI_64BIT_HASH,             "64bit_hash"},
        {LL_SBI_ACL,                    "acl"},
        {LL_SBI_AGL_ENABLED,            "agl"},
-       {LL_SBI_64BIT_HASH,             "64bit_hash"},
-       {LL_SBI_LAYOUT_LOCK,            "layout"},
-       {LL_SBI_XATTR_CACHE,            "xattr_cache"},
-       {LL_SBI_NOROOTSQUASH,           "norootsquash"},
+       {LL_SBI_ENCRYPT_NAME,           "name_encrypt"},
        {LL_SBI_FAST_READ,              "fast_read"},
-       {LL_SBI_FILE_SECCTX,            "file_secctx"},
-       {LL_SBI_TINY_WRITE,             "tiny_write"},
        {LL_SBI_FILE_HEAT,              "file_heat"},
-       {LL_SBI_PARALLEL_DIO,           "parallel_dio"},
+       {LL_SBI_FILE_SECCTX,            "file_secctx"},
        {LL_SBI_HYBRID_IO,              "hybrid_io"},
-       {LL_SBI_ENCRYPT_NAME,           "name_encrypt"},
+       {LL_SBI_LAYOUT_LOCK,            "layout"},
+       {LL_SBI_NOROOTSQUASH,           "norootsquash"},
+       {LL_SBI_PARALLEL_DIO,           "parallel_dio"},
+       {LL_SBI_TINY_WRITE,             "tiny_write"},
        {LL_SBI_UNALIGNED_DIO,          "unaligned_dio"},
+       {LL_SBI_XATTR_CACHE,            "xattr_cache"},
 };
 
 int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
@@ -1092,10 +1092,10 @@ static int ll_options(char *options, struct super_block *sb)
                }
 
                switch (token) {
-               case LL_SBI_NOLCK:
                case LL_SBI_32BIT_API:
                case LL_SBI_64BIT_HASH:
                case LL_SBI_ALWAYS_PING:
+               case LL_SBI_NOLCK:
                        set_bit(token, sbi->ll_flags);
                        break;
 
@@ -1207,7 +1207,7 @@ static int ll_options(char *options, struct super_block *sb)
                        } else {
                                LCONSOLE_ERROR("invalid %s option\n", s1);
                        }
-               fallthrough;
+                       break;
                default:
                        break;
                }
index 4b3d8de..17a41f7 100644 (file)
@@ -2498,7 +2498,12 @@ static struct attribute *llite_attrs[] = {
        &lustre_attr_foreign_symlink_upcall.attr,
        &lustre_attr_foreign_symlink_upcall_info.attr,
        &lustre_attr_fstype.attr,
-       &lustre_attr_uuid.attr,
+       &lustre_attr_heat_decay_percentage.attr,
+       &lustre_attr_heat_period_second.attr,
+       &lustre_attr_hybrid_io.attr,
+       &lustre_attr_hybrid_io_write_threshold_bytes.attr,
+       &lustre_attr_hybrid_io_read_threshold_bytes.attr,
+       &lustre_attr_inode_cache.attr,
        &lustre_attr_checksums.attr,
        &lustre_attr_checksum_pages.attr,
        &lustre_attr_max_easize.attr,
@@ -2508,6 +2513,13 @@ static struct attribute *llite_attrs[] = {
        &lustre_attr_max_read_ahead_async_active.attr,
        &lustre_attr_maxbytes.attr,
        &lustre_attr_namelen_max.attr,
+       &lustre_attr_opencache_threshold_count.attr,
+       &lustre_attr_opencache_threshold_ms.attr,
+       &lustre_attr_opencache_max_ms.attr,
+       &lustre_attr_parallel_dio.attr,
+       &lustre_attr_pcc_async_threshold.attr,
+       &lustre_attr_pcc_mode.attr,
+       &lustre_attr_pcc_async_affinity.attr,
        &lustre_attr_read_ahead_async_file_threshold_mb.attr,
        &lustre_attr_read_ahead_range_kb.attr,
        &lustre_attr_stat_blocksize.attr,
@@ -2532,28 +2544,16 @@ static struct attribute *llite_attrs[] = {
        &lustre_attr_intent_mkdir.attr,
        &lustre_attr_fast_read.attr,
        &lustre_attr_tiny_write.attr,
-       &lustre_attr_parallel_dio.attr,
        &lustre_attr_unaligned_dio.attr,
-       &lustre_attr_hybrid_io.attr,
        &lustre_attr_enable_setstripe_gid.attr,
        &lustre_attr_file_heat.attr,
-       &lustre_attr_heat_decay_percentage.attr,
-       &lustre_attr_heat_period_second.attr,
-       &lustre_attr_opencache_threshold_count.attr,
-       &lustre_attr_opencache_threshold_ms.attr,
-       &lustre_attr_opencache_max_ms.attr,
-       &lustre_attr_inode_cache.attr,
-       &lustre_attr_hybrid_io_write_threshold_bytes.attr,
-       &lustre_attr_hybrid_io_read_threshold_bytes.attr,
 #ifdef CONFIG_LL_ENCRYPTION
        &lustre_attr_enable_filename_encryption.attr,
 #endif
 #if defined(CONFIG_LL_ENCRYPTION) || defined(HAVE_LUSTRE_CRYPTO)
        &lustre_attr_filename_enc_use_old_base64.attr,
 #endif
-       &lustre_attr_pcc_async_threshold.attr,
-       &lustre_attr_pcc_mode.attr,
-       &lustre_attr_pcc_async_affinity.attr,
+       &lustre_attr_uuid.attr,
        &lustre_attr_dir_read_on_open.attr,
        NULL,
 };