Whamcloud - gitweb
LU-6142 lustre: Make dev/body/type operations const 98/39398/7
authorMr NeilBrown <neilb@suse.de>
Thu, 16 Jul 2020 04:14:10 +0000 (14:14 +1000)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Mar 2021 18:33:20 +0000 (18:33 +0000)
Many of
  struct md_device_operations
  struct dt_body_operations
  struct dt_object_operations
  struct dt_device_operations
  struct dt_index_operations
  struct lu_object_operations
  struct lu_device_operations
  struct lu_device_type_operations
are already const.  This patch makes the remainder 'const',
and changes a few to 'static'.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ife82c870a27a9e68e57208d49f51983a552e86ec
Reviewed-on: https://review.whamcloud.com/39398
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
22 files changed:
lustre/lod/lod_dev.c
lustre/lod/lod_internal.h
lustre/lod/lod_object.c
lustre/mdd/mdd_device.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_mds.c
lustre/mgs/mgs_handler.c
lustre/obdclass/local_storage.c
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_dev.c
lustre/osd-zfs/osd_handler.c
lustre/osd-zfs/osd_index.c
lustre/osd-zfs/osd_internal.h
lustre/osd-zfs/osd_io.c
lustre/osd-zfs/osd_object.c
lustre/osp/lwp_dev.c
lustre/osp/osp_dev.c
lustre/osp/osp_internal.h
lustre/osp/osp_md_object.c
lustre/osp/osp_object.c
lustre/quota/qmt_dev.c

index 1593a64..d64a604 100644 (file)
@@ -2048,17 +2048,17 @@ LU_CONTEXT_KEY_DEFINE(lod, LCT_MD_THREAD);
 
 LU_TYPE_INIT_FINI(lod, &lod_thread_key);
 
-static struct lu_device_type_operations lod_device_type_ops = {
-       .ldto_init           = lod_type_init,
-       .ldto_fini           = lod_type_fini,
+static const struct lu_device_type_operations lod_device_type_ops = {
+       .ldto_init              = lod_type_init,
+       .ldto_fini              = lod_type_fini,
 
-       .ldto_start          = lod_type_start,
-       .ldto_stop           = lod_type_stop,
+       .ldto_start             = lod_type_start,
+       .ldto_stop              = lod_type_stop,
 
-       .ldto_device_alloc   = lod_device_alloc,
-       .ldto_device_free    = lod_device_free,
+       .ldto_device_alloc      = lod_device_alloc,
+       .ldto_device_free       = lod_device_free,
 
-       .ldto_device_fini    = lod_device_fini
+       .ldto_device_fini       = lod_device_fini
 };
 
 static struct lu_device_type lod_device_type = {
index 3ab3e3f..e6a819d 100644 (file)
@@ -701,8 +701,8 @@ int lod_procfs_init(struct lod_device *lod);
 void lod_procfs_fini(struct lod_device *lod);
 
 /* lod_object.c */
-extern struct dt_object_operations lod_obj_ops;
-extern struct lu_object_operations lod_lu_obj_ops;
+extern const struct dt_object_operations lod_obj_ops;
+extern const struct lu_object_operations lod_lu_obj_ops;
 
 int lod_load_lmv_shards(const struct lu_env *env, struct lod_object *lo,
                        struct lu_buf *buf, bool resize);
index 32bb2b7..caa32fb 100644 (file)
@@ -344,7 +344,7 @@ static int lod_it_key_rec(const struct lu_env *env, const struct dt_it *di,
                                                         key_rec);
 }
 
-static struct dt_index_operations lod_index_ops = {
+static const struct dt_index_operations lod_index_ops = {
        .dio_lookup             = lod_lookup,
        .dio_declare_insert     = lod_declare_insert,
        .dio_insert             = lod_insert,
@@ -787,7 +787,7 @@ static int lod_striped_it_load(const struct lu_env *env,
        return next->do_index_ops->dio_it.load(env, it->lit_it, hash);
 }
 
-static struct dt_index_operations lod_striped_index_ops = {
+static const struct dt_index_operations lod_striped_index_ops = {
        .dio_lookup             = lod_striped_lookup,
        .dio_declare_insert     = lod_declare_insert,
        .dio_insert             = lod_insert,
@@ -8368,7 +8368,7 @@ static int lod_layout_change(const struct lu_env *env, struct dt_object *dt,
        RETURN(rc);
 }
 
-struct dt_object_operations lod_obj_ops = {
+const struct dt_object_operations lod_obj_ops = {
        .do_read_lock           = lod_read_lock,
        .do_write_lock          = lod_write_lock,
        .do_read_unlock         = lod_read_unlock,
@@ -8469,7 +8469,7 @@ static int lod_punch(const struct lu_env *env, struct dt_object *dt,
  * body_ops themselves will check file type inside, see lod_read/write/punch for
  * details.
  */
-const struct dt_body_operations lod_body_ops = {
+static const struct dt_body_operations lod_body_ops = {
        .dbo_read               = lod_read,
        .dbo_declare_write      = lod_declare_write,
        .dbo_write              = lod_write,
@@ -8707,7 +8707,7 @@ static int lod_object_print(const struct lu_env *env, void *cookie,
        return (*p)(env, cookie, LUSTRE_LOD_NAME"-object@%p", o);
 }
 
-struct lu_object_operations lod_lu_obj_ops = {
+const struct lu_object_operations lod_lu_obj_ops = {
        .loo_object_init        = lod_object_init,
        .loo_object_free        = lod_object_free,
        .loo_object_release     = lod_object_release,
index de4c04b..800df0e 100644 (file)
@@ -1943,17 +1943,17 @@ static const struct md_device_operations mdd_ops = {
        .mdo_dtconf_get     = mdd_dtconf_get,
 };
 
-static struct lu_device_type_operations mdd_device_type_ops = {
-        .ldto_init = mdd_type_init,
-        .ldto_fini = mdd_type_fini,
+static const struct lu_device_type_operations mdd_device_type_ops = {
+       .ldto_init              = mdd_type_init,
+       .ldto_fini              = mdd_type_fini,
 
-        .ldto_start = mdd_type_start,
-        .ldto_stop  = mdd_type_stop,
+       .ldto_start             = mdd_type_start,
+       .ldto_stop              = mdd_type_stop,
 
-        .ldto_device_alloc = mdd_device_alloc,
-        .ldto_device_free  = mdd_device_free,
+       .ldto_device_alloc      = mdd_device_alloc,
+       .ldto_device_free       = mdd_device_free,
 
-        .ldto_device_fini    = mdd_device_fini
+       .ldto_device_fini       = mdd_device_fini
 };
 
 static struct lu_device_type mdd_device_type = {
index 462d522..e953635 100644 (file)
@@ -7386,10 +7386,10 @@ int mdt_cos_is_enabled(struct mdt_device *mdt)
         return mdt->mdt_opts.mo_cos != 0;
 }
 
-static struct lu_device_type_operations mdt_device_type_ops = {
-        .ldto_device_alloc = mdt_device_alloc,
-        .ldto_device_free  = mdt_device_free,
-        .ldto_device_fini  = mdt_device_fini
+static const struct lu_device_type_operations mdt_device_type_ops = {
+       .ldto_device_alloc = mdt_device_alloc,
+       .ldto_device_free  = mdt_device_free,
+       .ldto_device_fini  = mdt_device_fini
 };
 
 static struct lu_device_type mdt_device_type = {
index 025c0da..9311d72 100644 (file)
@@ -638,7 +638,7 @@ static struct lu_device *mds_device_alloc(const struct lu_env *env,
 /* type constructor/destructor: mdt_type_init, mdt_type_fini */
 LU_TYPE_INIT_FINI(mds, &mdt_thread_key);
 
-static struct lu_device_type_operations mds_device_type_ops = {
+static const struct lu_device_type_operations mds_device_type_ops = {
        .ldto_init = mds_type_init,
        .ldto_fini = mds_type_fini,
 
index 26af684..5323663 100644 (file)
@@ -1482,7 +1482,7 @@ static int mgs_object_print(const struct lu_env *env, void *cookie,
        return (*p)(env, cookie, LUSTRE_MGS_NAME"-object@%p", o);
 }
 
-static struct lu_object_operations mgs_lu_obj_ops = {
+static const struct lu_object_operations mgs_lu_obj_ops = {
        .loo_object_init        = mgs_object_init,
        .loo_object_free        = mgs_object_free,
        .loo_object_print       = mgs_object_print,
@@ -1602,7 +1602,7 @@ LU_TYPE_INIT_FINI(mgs, &mgs_thread_key);
 
 LU_CONTEXT_KEY_DEFINE(mgs, LCT_MG_THREAD);
 
-static struct lu_device_type_operations mgs_device_type_ops = {
+static const struct lu_device_type_operations mgs_device_type_ops = {
        .ldto_init              = mgs_type_init,
        .ldto_fini              = mgs_type_fini,
 
index 5227545..2e2a0c4 100644 (file)
@@ -69,7 +69,7 @@ static void ls_object_free(const struct lu_env *env, struct lu_object *o)
        kfree_rcu(obj, ls_header.loh_rcu);
 }
 
-static struct lu_object_operations ls_lu_obj_ops = {
+static const struct lu_object_operations ls_lu_obj_ops = {
        .loo_object_init  = ls_object_init,
        .loo_object_free  = ls_object_free,
 };
@@ -101,7 +101,7 @@ static struct lu_object *ls_object_alloc(const struct lu_env *env,
        }
 }
 
-static struct lu_device_operations ls_lu_dev_ops = {
+static const struct lu_device_operations ls_lu_dev_ops = {
        .ldo_object_alloc =     ls_object_alloc
 };
 
@@ -130,7 +130,7 @@ struct ls_device *ls_find_dev(struct dt_device *dev)
        return ls;
 }
 
-static struct lu_device_type_operations ls_device_type_ops = {
+static const struct lu_device_type_operations ls_device_type_ops = {
        .ldto_start = NULL,
        .ldto_stop  = NULL,
 };
index 08c72b2..39b62ce 100644 (file)
@@ -713,7 +713,7 @@ static struct tgt_opc_slice esd_common_slice[] = {
  * this device is just serving incoming requests immediately
  * without building a stack of lu_devices.
  */
-static struct lu_device_operations echo_srv_lu_ops = { 0 };
+static const struct lu_device_operations echo_srv_lu_ops = { 0 };
 
 /**
  * Initialize Echo Server device with parameters in the config log \a cfg.
index a8f487c..92c923d 100644 (file)
@@ -618,7 +618,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env,
        RETURN(obj);
 }
 
-static struct lu_device_operations echo_device_lu_ops = {
+static const struct lu_device_operations echo_device_lu_ops = {
        .ldo_object_alloc   = echo_object_alloc,
 };
 
index bc3aa83..644148c 100644 (file)
@@ -507,7 +507,7 @@ static int ofd_object_print(const struct lu_env *env, void *cookie,
        return (*p)(env, cookie, LUSTRE_OST_NAME"-object@%p", o);
 }
 
-static struct lu_object_operations ofd_obj_ops = {
+static const struct lu_object_operations ofd_obj_ops = {
        .loo_object_init        = ofd_object_init,
        .loo_object_free        = ofd_object_free,
        .loo_object_print       = ofd_object_print
@@ -703,7 +703,7 @@ static int ofd_recovery_complete(const struct lu_env *env,
 /**
  * lu_device_operations matrix for OFD device.
  */
-static struct lu_device_operations ofd_lu_ops = {
+static const struct lu_device_operations ofd_lu_ops = {
        .ldo_object_alloc       = ofd_object_alloc,
        .ldo_process_config     = ofd_process_config,
        .ldo_recovery_complete  = ofd_recovery_complete,
@@ -3225,7 +3225,7 @@ static struct lu_device *ofd_device_alloc(const struct lu_env *env,
 /* type constructor/destructor: ofd_type_init(), ofd_type_fini() */
 LU_TYPE_INIT_FINI(ofd, &ofd_thread_key);
 
-static struct lu_device_type_operations ofd_device_type_ops = {
+static const struct lu_device_type_operations ofd_device_type_ops = {
        .ldto_init              = ofd_type_init,
        .ldto_fini              = ofd_type_fini,
 
index 94dec9d..30ec13e 100644 (file)
@@ -699,7 +699,7 @@ static int osd_ro(const struct lu_env *env, struct dt_device *d)
        RETURN(0);
 }
 
-static struct dt_device_operations osd_dt_ops = {
+static const struct dt_device_operations osd_dt_ops = {
        .dt_root_get            = osd_root_get,
        .dt_statfs              = osd_statfs,
        .dt_trans_create        = osd_trans_create,
@@ -1581,7 +1581,7 @@ static int osd_fid_alloc(const struct lu_env *env, struct lu_device *d,
        return seq_client_alloc_fid(env, osd->od_cl_seq, fid);
 }
 
-struct lu_device_operations osd_lu_ops = {
+const struct lu_device_operations osd_lu_ops = {
        .ldo_object_alloc       = osd_object_alloc,
        .ldo_process_config     = osd_process_config,
        .ldo_recovery_complete  = osd_recovery_complete,
@@ -1597,7 +1597,7 @@ static void osd_type_stop(struct lu_device_type *t)
 {
 }
 
-static struct lu_device_type_operations osd_device_type_ops = {
+static const struct lu_device_type_operations osd_device_type_ops = {
        .ldto_init              = osd_type_init,
        .ldto_fini              = osd_type_fini,
 
index 765099a..75cbec8 100644 (file)
@@ -1700,7 +1700,7 @@ static int osd_dir_it_load(const struct lu_env *env,
        RETURN(rc);
 }
 
-struct dt_index_operations osd_dir_ops = {
+const struct dt_index_operations osd_dir_ops = {
        .dio_lookup         = osd_dir_lookup,
        .dio_declare_insert = osd_declare_dir_insert,
        .dio_insert         = osd_dir_insert,
@@ -1997,7 +1997,7 @@ static int osd_index_it_load(const struct lu_env *env, const struct dt_it *di,
        RETURN(rc);
 }
 
-static struct dt_index_operations osd_index_ops = {
+static const struct dt_index_operations osd_index_ops = {
        .dio_lookup             = osd_index_lookup,
        .dio_declare_insert     = osd_declare_index_insert,
        .dio_insert             = osd_index_insert,
index 4e818c2..cd50e1d 100644 (file)
 #define zfs_refcount_add       refcount_add
 #endif
 
-extern struct dt_body_operations osd_body_scrub_ops;
-extern struct dt_body_operations osd_body_ops;
+extern const struct dt_body_operations osd_body_scrub_ops;
+extern const struct dt_body_operations osd_body_ops;
 extern struct kmem_cache *osd_object_kmem;
 
 /**
@@ -471,8 +471,8 @@ struct osd_object {
 int osd_statfs(const struct lu_env *, struct dt_device *, struct obd_statfs *,
               struct obd_statfs_info *);
 extern const struct dt_index_operations osd_acct_index_ops;
-extern struct lu_device_operations  osd_lu_ops;
-extern struct dt_index_operations osd_dir_ops;
+extern const struct lu_device_operations  osd_lu_ops;
+extern const struct dt_index_operations osd_dir_ops;
 int osd_declare_quota(const struct lu_env *env, struct osd_device *osd,
                      qid_t uid, qid_t gid, qid_t projid, long long space,
                      struct osd_thandle *oh,
index dd26c0a..74d5775 100644 (file)
@@ -1219,7 +1219,7 @@ static loff_t osd_lseek(const struct lu_env *env, struct dt_object *dt,
        RETURN(result);
 }
 
-struct dt_body_operations osd_body_ops = {
+const struct dt_body_operations osd_body_ops = {
        .dbo_read                       = osd_read,
        .dbo_declare_write              = osd_declare_write,
        .dbo_write                      = osd_write,
@@ -1237,7 +1237,7 @@ struct dt_body_operations osd_body_ops = {
        .dbo_lseek                      = osd_lseek,
 };
 
-struct dt_body_operations osd_body_scrub_ops = {
+const struct dt_body_operations osd_body_scrub_ops = {
        .dbo_read                       = osd_read_no_record,
        .dbo_declare_write              = osd_declare_write,
        .dbo_write                      = osd_write,
index 338a47e..7df429e 100644 (file)
@@ -64,9 +64,9 @@
 char *osd_obj_tag = "osd_object";
 static int osd_object_sync_delay_us = -1;
 
-static struct dt_object_operations osd_obj_ops;
-static struct lu_object_operations osd_lu_obj_ops;
-static struct dt_object_operations osd_obj_otable_it_ops;
+static const struct dt_object_operations osd_obj_ops;
+static const struct lu_object_operations osd_lu_obj_ops;
+static const struct dt_object_operations osd_obj_otable_it_ops;
 
 static void
 osd_object_sa_fini(struct osd_object *obj)
@@ -2151,7 +2151,7 @@ static bool osd_check_stale(struct dt_object *dt)
        return false;
 }
 
-static struct dt_object_operations osd_obj_ops = {
+static const struct dt_object_operations osd_obj_ops = {
        .do_read_lock           = osd_read_lock,
        .do_write_lock          = osd_write_lock,
        .do_read_unlock         = osd_read_unlock,
@@ -2181,7 +2181,7 @@ static struct dt_object_operations osd_obj_ops = {
        .do_check_stale         = osd_check_stale,
 };
 
-static struct lu_object_operations osd_lu_obj_ops = {
+static const struct lu_object_operations osd_lu_obj_ops = {
        .loo_object_init        = osd_object_init,
        .loo_object_delete      = osd_object_delete,
        .loo_object_release     = osd_object_release,
@@ -2198,7 +2198,7 @@ static int osd_otable_it_attr_get(const struct lu_env *env,
        return 0;
 }
 
-static struct dt_object_operations osd_obj_otable_it_ops = {
+static const struct dt_object_operations osd_obj_otable_it_ops = {
        .do_attr_get            = osd_otable_it_attr_get,
        .do_index_try           = osd_index_try,
 };
index c26968a..31ac7d0 100644 (file)
@@ -392,10 +392,10 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env,
        RETURN(NULL);
 }
 
-static struct lu_device_type_operations lwp_device_type_ops = {
-       .ldto_device_alloc   = lwp_device_alloc,
-       .ldto_device_free    = lwp_device_free,
-       .ldto_device_fini    = lwp_device_fini
+static const struct lu_device_type_operations lwp_device_type_ops = {
+       .ldto_device_alloc      = lwp_device_alloc,
+       .ldto_device_free       = lwp_device_free,
+       .ldto_device_fini       = lwp_device_fini
 };
 
 struct lu_device_type lwp_device_type = {
index 4f520b7..0cb080f 100644 (file)
@@ -934,7 +934,7 @@ out:
        RETURN(rc);
 }
 
-const struct dt_device_operations osp_dt_ops = {
+static const struct dt_device_operations osp_dt_ops = {
        .dt_statfs       = osp_statfs,
        .dt_sync         = osp_sync,
        .dt_trans_create = osp_trans_create,
@@ -1843,7 +1843,7 @@ struct lu_context_key osp_txn_key = {
 };
 LU_TYPE_INIT_FINI(osp, &osp_thread_key, &osp_txn_key);
 
-static struct lu_device_type_operations osp_device_type_ops = {
+static const struct lu_device_type_operations osp_device_type_ops = {
        .ldto_init           = osp_type_init,
        .ldto_fini           = osp_type_fini,
 
index 6d66ceb..f4d3681 100644 (file)
@@ -326,10 +326,9 @@ struct osp_object {
        struct rw_semaphore     opo_invalidate_sem;
 };
 
-extern struct lu_object_operations osp_lu_obj_ops;
-extern const struct dt_device_operations osp_dt_ops;
-extern struct dt_object_operations osp_md_obj_ops;
-extern struct dt_body_operations osp_md_body_ops;
+extern const struct lu_object_operations osp_lu_obj_ops;
+extern const struct dt_object_operations osp_md_obj_ops;
+extern const struct dt_body_operations osp_md_body_ops;
 
 struct osp_thread_info {
        struct lu_buf            osi_lb;
index a90d5f5..f01682c 100644 (file)
@@ -1061,7 +1061,7 @@ int osp_md_destroy(const struct lu_env *env, struct dt_object *dt,
        RETURN(rc);
 }
 
-struct dt_object_operations osp_md_obj_ops = {
+const struct dt_object_operations osp_md_obj_ops = {
        .do_read_lock         = osp_md_read_lock,
        .do_write_lock        = osp_md_write_lock,
        .do_read_unlock       = osp_md_read_unlock,
@@ -1317,7 +1317,7 @@ out_update:
 }
 
 /* These body operation will be used to write symlinks during migration etc */
-struct dt_body_operations osp_md_body_ops = {
+const struct dt_body_operations osp_md_body_ops = {
        .dbo_declare_write      = osp_md_declare_write,
        .dbo_write              = osp_md_write,
        .dbo_read               = osp_md_read,
index 77bd82f..554f74a 100644 (file)
@@ -2213,7 +2213,7 @@ static int osp_index_try(const struct lu_env *env,
        return 0;
 }
 
-static struct dt_object_operations osp_obj_ops = {
+static const struct dt_object_operations osp_obj_ops = {
        .do_declare_attr_get    = osp_declare_attr_get,
        .do_attr_get            = osp_attr_get,
        .do_declare_attr_set    = osp_declare_attr_set,
@@ -2389,7 +2389,7 @@ static int osp_object_invariant(const struct lu_object *o)
        LBUG();
 }
 
-struct lu_object_operations osp_lu_obj_ops = {
+const struct lu_object_operations osp_lu_obj_ops = {
        .loo_object_init        = osp_object_init,
        .loo_object_free        = osp_object_free,
        .loo_object_release     = osp_object_release,
index c810e83..763baec 100644 (file)
@@ -355,7 +355,7 @@ LU_CONTEXT_KEY_DEFINE(qmt, LCT_MD_THREAD);
 /*
  * lu device type operations associated with the master target.
  */
-static struct lu_device_type_operations qmt_device_type_ops = {
+static const struct lu_device_type_operations qmt_device_type_ops = {
        .ldto_init              = qmt_type_init,
        .ldto_fini              = qmt_type_fini,