Whamcloud - gitweb
LU-6142 lustre: change various operations structs to const 00/39400/3
authorMr NeilBrown <neilb@suse.de>
Thu, 16 Jul 2020 04:56:38 +0000 (14:56 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 21:42:20 +0000 (21:42 +0000)
Nearly all of
  struct cl_io_operations
  struct cl_lock_operations
  struct iam_operations
  struct iam_leaf_operations
  struct llog_operations
  struct lquota_entry_operations
  struct md_dir_operations

are now const.  The one exception is changelog_orig_logops.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I91dc9528b62a77f6bcedc80d6066a74a8eeaa3fa
Reviewed-on: https://review.whamcloud.com/39400
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
18 files changed:
lustre/include/lustre_log.h
lustre/include/lustre_net.h
lustre/mdc/mdc_dev.c
lustre/mdd/mdd_device.c
lustre/obdclass/llog.c
lustre/obdclass/llog_obd.c
lustre/obdclass/llog_osd.c
lustre/obdecho/echo_client.c
lustre/osd-ldiskfs/osd_iam.h
lustre/osd-ldiskfs/osd_iam_lfix.c
lustre/osd-ldiskfs/osd_iam_lvar.c
lustre/ptlrpc/llog_client.c
lustre/quota/lquota_entry.c
lustre/quota/lquota_internal.h
lustre/quota/qmt_entry.c
lustre/quota/qmt_internal.h
lustre/quota/qsd_entry.c
lustre/quota/qsd_internal.h

index d58ddd8..bde44be 100644 (file)
@@ -172,7 +172,7 @@ int llog_cat_reverse_process(const struct lu_env *env,
 /* llog_obd.c */
 int llog_setup(const struct lu_env *env, struct obd_device *obd,
               struct obd_llog_group *olg, int index,
-              struct obd_device *disk_obd, struct llog_operations *op);
+              struct obd_device *disk_obd, const struct llog_operations *op);
 int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt);
 int llog_cleanup(const struct lu_env *env, struct llog_ctxt *);
 int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags);
@@ -282,7 +282,7 @@ struct llog_handle {
        } u;
        char                    *lgh_name;
        void                    *private_data;
-       struct llog_operations  *lgh_logops;
+       const struct llog_operations    *lgh_logops;
        refcount_t               lgh_refcount;
 
        int                     lgh_max_size;
@@ -290,8 +290,8 @@ struct llog_handle {
 };
 
 /* llog_osd.c */
-extern struct llog_operations llog_osd_ops;
-extern struct llog_operations llog_common_cat_ops;
+extern const struct llog_operations llog_osd_ops;
+extern const struct llog_operations llog_common_cat_ops;
 int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d,
                          int idx, int count, struct llog_catid *idarray,
                          const struct lu_fid *fid);
@@ -307,17 +307,17 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d,
 #define LLOG_CTXT_FLAG_NORMAL_FID       0x00000004
 
 struct llog_ctxt {
-        int                      loc_idx; /* my index the obd array of ctxt's */
-        struct obd_device       *loc_obd; /* points back to the containing obd*/
-        struct obd_llog_group   *loc_olg; /* group containing that ctxt */
-        struct obd_export       *loc_exp; /* parent "disk" export (e.g. MDS) */
-        struct obd_import       *loc_imp; /* to use in RPC's: can be backward
-                                             pointing import */
-       struct llog_operations  *loc_logops;
-       struct llog_handle      *loc_handle;
+       int                      loc_idx; /* my index the obd array of ctxt's */
+       struct obd_device       *loc_obd; /* points back to the containing obd*/
+       struct obd_llog_group   *loc_olg; /* group containing that ctxt */
+       struct obd_export       *loc_exp; /* parent "disk" export (e.g. MDS) */
+       struct obd_import       *loc_imp; /* to use in RPC's: can be backward
+                                          * pointing import */
+       const struct llog_operations  *loc_logops;
+       struct llog_handle      *loc_handle;
        struct mutex             loc_mutex; /* protect loc_imp */
-       atomic_t                 loc_refcount;
-       long                     loc_flags; /* flags, see above defines */
+       atomic_t                 loc_refcount;
+       long                     loc_flags; /* flags, see above defines */
        struct dt_object        *loc_dir;
        struct local_oid_storage *loc_los_nameless;
        struct local_oid_storage *loc_los_named;
@@ -331,20 +331,20 @@ struct llog_ctxt {
 #define LLOG_DEL_PLAIN  0x0003
 
 static inline int llog_obd2ops(struct llog_ctxt *ctxt,
-                               struct llog_operations **lop)
+                              const struct llog_operations **lop)
 {
-        if (ctxt == NULL)
-                return -ENOTCONN;
+       if (ctxt == NULL)
+               return -ENOTCONN;
 
-        *lop = ctxt->loc_logops;
-        if (*lop == NULL)
-                return -EOPNOTSUPP;
+       *lop = ctxt->loc_logops;
+       if (*lop == NULL)
+               return -EOPNOTSUPP;
 
-        return 0;
+       return 0;
 }
 
 static inline int llog_handle2ops(struct llog_handle *loghandle,
-                                  struct llog_operations **lop)
+                                 const struct llog_operations **lop)
 {
        if (loghandle == NULL || loghandle->lgh_logops == NULL)
                return -EINVAL;
@@ -355,7 +355,7 @@ static inline int llog_handle2ops(struct llog_handle *loghandle,
 
 static inline int llog_data_len(int len)
 {
-        return cfs_size_round(len);
+       return cfs_size_round(len);
 }
 
 static inline int llog_get_size(struct llog_handle *loghandle)
@@ -449,7 +449,7 @@ static inline int llog_next_block(const struct lu_env *env,
                                  int next_idx, __u64 *cur_offset, void *buf,
                                  int len)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -469,7 +469,7 @@ static inline int llog_prev_block(const struct lu_env *env,
                                  struct llog_handle *loghandle,
                                  int prev_idx, void *buf, int len)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -488,8 +488,8 @@ static inline int llog_connect(struct llog_ctxt *ctxt,
                               struct llog_logid *logid, struct llog_gen *gen,
                               struct obd_uuid *uuid)
 {
-       struct llog_operations  *lop;
-       int                      rc;
+       const struct llog_operations *lop;
+       int rc;
 
        ENTRY;
 
index f34a272..e732457 100644 (file)
@@ -2727,7 +2727,7 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req);
 int llog_origin_handle_read_header(struct ptlrpc_request *req);
 
 /* ptlrpc/llog_client.c */
-extern struct llog_operations llog_client_ops;
+extern const struct llog_operations llog_client_ops;
 /** @} net */
 
 #endif
index 24f3a27..f179e6f 100644 (file)
@@ -1314,7 +1314,7 @@ static void mdc_io_data_version_end(const struct lu_env *env,
        EXIT;
 }
 
-static struct cl_io_operations mdc_io_ops = {
+static const struct cl_io_operations mdc_io_ops = {
        .op = {
                [CIT_READ] = {
                        .cio_iter_init = osc_io_rw_iter_init,
index 1a258e1..de4c04b 100644 (file)
@@ -845,7 +845,7 @@ static int mdd_obf_create(const struct lu_env *env, struct md_object *pobj,
        RETURN(-EPERM);
 }
 
-static struct md_dir_operations mdd_obf_dir_ops = {
+static const struct md_dir_operations mdd_obf_dir_ops = {
        .mdo_lookup = obf_lookup,
        .mdo_create = mdd_obf_create,
        .mdo_rename = mdd_dummy_rename,
@@ -853,7 +853,7 @@ static struct md_dir_operations mdd_obf_dir_ops = {
        .mdo_unlink = mdd_dummy_unlink
 };
 
-static struct md_dir_operations mdd_lpf_dir_ops = {
+static const struct md_dir_operations mdd_lpf_dir_ops = {
        .mdo_lookup = mdd_lookup,
        .mdo_create = mdd_dummy_create,
        .mdo_rename = mdd_dummy_rename,
index 4ac4d20..b2b5feb 100644 (file)
@@ -104,7 +104,7 @@ int llog_handle_put(const struct lu_env *env, struct llog_handle *loghandle)
        int rc = 0;
 
        if (refcount_dec_and_test(&loghandle->lgh_refcount)) {
-               struct llog_operations *lop;
+               const struct llog_operations *lop;
 
                rc = llog_handle2ops(loghandle, &lop);
                if (!rc) {
@@ -122,7 +122,7 @@ static int llog_declare_destroy(const struct lu_env *env,
                                struct llog_handle *handle,
                                struct thandle *th)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -141,7 +141,7 @@ static int llog_declare_destroy(const struct lu_env *env,
 int llog_trans_destroy(const struct lu_env *env, struct llog_handle *handle,
                       struct thandle *th)
 {
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
        ENTRY;
 
@@ -162,9 +162,9 @@ int llog_trans_destroy(const struct lu_env *env, struct llog_handle *handle,
 
 int llog_destroy(const struct lu_env *env, struct llog_handle *handle)
 {
-       struct llog_operations  *lop;
-       struct dt_device        *dt;
-       struct thandle          *th;
+       const struct llog_operations *lop;
+       struct dt_device *dt;
+       struct thandle *th;
        int rc;
 
        ENTRY;
@@ -339,7 +339,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle,
 int llog_read_header(const struct lu_env *env, struct llog_handle *handle,
                     const struct obd_uuid *uuid)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
        ENTRY;
 
@@ -1024,8 +1024,8 @@ EXPORT_SYMBOL(llog_reverse_process);
  */
 int llog_exist(struct llog_handle *loghandle)
 {
-       struct llog_operations  *lop;
-       int                      rc;
+       const struct llog_operations *lop;
+       int rc;
 
        ENTRY;
 
@@ -1044,7 +1044,7 @@ int llog_declare_create(const struct lu_env *env,
                        struct llog_handle *loghandle, struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1065,7 +1065,7 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle,
                struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1088,7 +1088,7 @@ int llog_declare_write_rec(const struct lu_env *env,
                           struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1111,7 +1111,7 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle,
                   int idx, struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc, buflen;
 
        ENTRY;
index b0eddf9..492682a 100644 (file)
@@ -143,7 +143,7 @@ EXPORT_SYMBOL(llog_cleanup);
 
 int llog_setup(const struct lu_env *env, struct obd_device *obd,
               struct obd_llog_group *olg, int index,
-              struct obd_device *disk_obd, struct llog_operations *op)
+              struct obd_device *disk_obd, const struct llog_operations *op)
 {
        struct llog_ctxt *ctxt;
        int rc = 0;
index 92d7186..092e374 100644 (file)
@@ -1949,7 +1949,7 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
        return 0;
 }
 
-struct llog_operations llog_osd_ops = {
+const struct llog_operations llog_osd_ops = {
        .lop_next_block         = llog_osd_next_block,
        .lop_prev_block         = llog_osd_prev_block,
        .lop_read_header        = llog_osd_read_header,
@@ -1967,7 +1967,7 @@ struct llog_operations llog_osd_ops = {
 };
 EXPORT_SYMBOL(llog_osd_ops);
 
-struct llog_operations llog_common_cat_ops = {
+const struct llog_operations llog_common_cat_ops = {
        .lop_next_block         = llog_osd_next_block,
        .lop_prev_block         = llog_osd_prev_block,
        .lop_read_header        = llog_osd_read_header,
index a5bfd7a..a8f487c 100644 (file)
@@ -400,8 +400,8 @@ static void echo_lock_fini(const struct lu_env *env,
        OBD_SLAB_FREE_PTR(ecl, echo_lock_kmem);
 }
 
-static struct cl_lock_operations echo_lock_ops = {
-       .clo_fini      = echo_lock_fini,
+static const struct cl_lock_operations echo_lock_ops = {
+       .clo_fini       = echo_lock_fini,
 };
 
 /** @} echo_lock */
index 15d3ede..bd1fcd5 100644 (file)
@@ -410,36 +410,36 @@ struct iam_leaf_operations {
  * Parameters, describing a flavor of iam container.
  */
 struct iam_descr {
-        /*
-         * Size of a key in this container, in bytes.
-         */
-         size_t       id_key_size;
-        /*
-         * Size of a key in index nodes, in bytes.
-         */
-         size_t       id_ikey_size;
-        /*
-         * Size of a pointer to the next level (stored in index nodes), in
-         * bytes.
-         */
-        size_t       id_ptr_size;
-        /*
-         * Size of a record (stored in leaf nodes), in bytes.
-         */
-        size_t       id_rec_size;
-        /*
-         * Size of unused (by iam) space at the beginning of every non-root
-         * node, in bytes. Used for compatibility with ldiskfs.
-         */
-        size_t       id_node_gap;
-        /*
-         * Size of unused (by iam) space at the beginning of root node, in
-         * bytes. Used for compatibility with ldiskfs.
-         */
-        size_t       id_root_gap;
+       /*
+        * Size of a key in this container, in bytes.
+        */
+       size_t       id_key_size;
+       /*
+        * Size of a key in index nodes, in bytes.
+        */
+       size_t       id_ikey_size;
+       /*
+        * Size of a pointer to the next level (stored in index nodes), in
+        * bytes.
+        */
+       size_t       id_ptr_size;
+       /*
+        * Size of a record (stored in leaf nodes), in bytes.
+        */
+       size_t       id_rec_size;
+       /*
+        * Size of unused (by iam) space at the beginning of every non-root
+        * node, in bytes. Used for compatibility with ldiskfs.
+        */
+       size_t       id_node_gap;
+       /*
+        * Size of unused (by iam) space at the beginning of root node, in
+        * bytes. Used for compatibility with ldiskfs.
+        */
+       size_t       id_root_gap;
 
-        struct iam_operations           *id_ops;
-        struct iam_leaf_operations      *id_leaf_ops;
+       const struct iam_operations           *id_ops;
+       const struct iam_leaf_operations      *id_leaf_ops;
 };
 
 enum {
@@ -792,10 +792,10 @@ static inline struct iam_descr *iam_leaf_descr(const struct iam_leaf *leaf)
         return iam_leaf_container(leaf)->ic_descr;
 }
 
-static inline struct iam_leaf_operations *
+static inline const struct iam_leaf_operations *
 iam_leaf_ops(const struct iam_leaf *leaf)
 {
-        return iam_leaf_descr(leaf)->id_leaf_ops;
+       return iam_leaf_descr(leaf)->id_leaf_ops;
 }
 
 static inline void iam_reccpy(const struct iam_leaf *leaf,
@@ -1063,7 +1063,7 @@ int iam_leaf_can_add(const struct iam_leaf *l,
 struct iam_path *iam_leaf_path(const struct iam_leaf *leaf);
 struct iam_container *iam_leaf_container(const struct iam_leaf *leaf);
 struct iam_descr *iam_leaf_descr(const struct iam_leaf *leaf);
-struct iam_leaf_operations *iam_leaf_ops(const struct iam_leaf *leaf);
+const struct iam_leaf_operations *iam_leaf_ops(const struct iam_leaf *leaf);
 
 
 int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
index c6a73cf..14ae6ff 100644 (file)
@@ -512,7 +512,7 @@ static int iam_lfix_leaf_empty(struct iam_leaf *leaf)
        return lentry_count_get(leaf) == 0;
 }
 
-static struct iam_leaf_operations iam_lfix_leaf_ops = {
+static const struct iam_leaf_operations iam_lfix_leaf_ops = {
        .init           = iam_lfix_init,
        .init_new       = iam_lfix_init_new,
        .fini           = iam_lfix_fini,
@@ -659,7 +659,7 @@ static struct iam_path_descr *iam_lfix_ipd_alloc(const struct iam_container *c,
        return iam_ipd_alloc(area, c->ic_descr->id_ikey_size);
 }
 
-static struct iam_operations iam_lfix_ops = {
+static const struct iam_operations iam_lfix_ops = {
        .id_root_ptr    = iam_lfix_root_ptr,
        .id_node_read   = iam_node_read,
        .id_node_init   = iam_lfix_node_init,
index 2636934..f8947c5 100644 (file)
@@ -770,7 +770,7 @@ static int lvar_leaf_empty(struct iam_leaf *leaf)
        return h_used(n_head(leaf)) == sizeof(struct lvar_leaf_header);
 }
 
-static struct iam_leaf_operations lvar_leaf_ops = {
+static const struct iam_leaf_operations lvar_leaf_ops = {
        .init           = lvar_init,
        .init_new       = lvar_init_new,
        .fini           = lvar_fini,
@@ -1044,7 +1044,7 @@ out:
        return result;
 }
 
-static struct iam_operations lvar_ops = {
+static const struct iam_operations lvar_ops = {
        .id_root_ptr    = lvar_root_ptr,
        .id_node_read   = iam_node_read,
        .id_node_init   = lvar_node_init,
index fa9782e..ac25e7e 100644 (file)
@@ -343,7 +343,7 @@ static int llog_client_close(const struct lu_env *env,
        return 0;
 }
 
-struct llog_operations llog_client_ops = {
+const struct llog_operations llog_client_ops = {
        .lop_next_block         = llog_client_next_block,
        .lop_prev_block         = llog_client_prev_block,
        .lop_read_header        = llog_client_read_header,
index ae495d8..7e2b62b 100644 (file)
@@ -199,7 +199,7 @@ retry:
  */
 struct lquota_site *lquota_site_alloc(const struct lu_env *env, void *parent,
                                      bool is_master, short qtype,
-                                     struct lquota_entry_operations *ops)
+                                     const struct lquota_entry_operations *ops)
 {
        struct lquota_site      *site;
        char                     hashname[15];
index 2629882..43bcb4b 100644 (file)
@@ -228,7 +228,7 @@ struct lquota_site {
 
        /* Vector of operations which can be done on lquota entry belonging to
         * this quota site */
-       struct lquota_entry_operations  *lqs_ops;
+       const struct lquota_entry_operations    *lqs_ops;
 
        /* Backpointer to parent structure, either QMT pool info for master or
         * QSD for slave */
@@ -445,8 +445,9 @@ const struct dt_index_features *glb_idx_feature(struct lu_fid *);
 
 /* lquota_entry.c */
 /* site create/destroy */
-struct lquota_site *lquota_site_alloc(const struct lu_env *, void *, bool,
-                                     short, struct lquota_entry_operations *);
+struct lquota_site *lquota_site_alloc(const struct lu_env *env, void *parent,
+                                     bool master, short qtype,
+                                     const struct lquota_entry_operations *op);
 void lquota_site_free(const struct lu_env *, struct lquota_site *);
 /* quota entry operations */
 #define lqe_locate(env, site, id) lqe_locate_find(env, site, id, false)
index 8b452b4..f5b74de 100644 (file)
@@ -186,7 +186,7 @@ static void qmt_lqe_debug(struct lquota_entry *lqe, void *arg,
 /*
  * Vector of quota entry operations supported on the master
  */
-struct lquota_entry_operations qmt_lqe_ops = {
+const struct lquota_entry_operations qmt_lqe_ops = {
        .lqe_init       = qmt_lqe_init,
        .lqe_read       = qmt_lqe_read,
        .lqe_debug      = qmt_lqe_debug,
index f9045b6..3ccd4d4 100644 (file)
@@ -462,7 +462,7 @@ int qmt_sarr_get_idx(struct qmt_pool_info *qpi, int arr_idx);
 unsigned int qmt_sarr_count(struct qmt_pool_info *qpi);
 
 /* qmt_entry.c */
-extern struct lquota_entry_operations qmt_lqe_ops;
+extern const struct lquota_entry_operations qmt_lqe_ops;
 int qmt_lqe_set_default(const struct lu_env *env, struct qmt_pool_info *pool,
                        struct lquota_entry *lqe, bool create_record);
 struct thandle *qmt_trans_start_with_slv(const struct lu_env *,
index 5ecf8fe..c3a434f 100644 (file)
@@ -184,7 +184,7 @@ static void qsd_lqe_debug(struct lquota_entry *lqe, void *arg,
 /*
  * Vector of quota entry operations supported on the slave
  */
-struct lquota_entry_operations qsd_lqe_ops = {
+const struct lquota_entry_operations qsd_lqe_ops = {
        .lqe_init               = qsd_lqe_init,
        .lqe_read               = qsd_lqe_read,
        .lqe_debug              = qsd_lqe_debug,
index 4dc3418..7144e2e 100644 (file)
@@ -333,7 +333,7 @@ static inline int qsd_wait_timeout(struct qsd_instance *qsd)
 }
 
 /* qsd_entry.c */
-extern struct lquota_entry_operations qsd_lqe_ops;
+extern const struct lquota_entry_operations qsd_lqe_ops;
 int qsd_refresh_usage(const struct lu_env *, struct lquota_entry *);
 int qsd_update_index(const struct lu_env *, struct qsd_qtype_info *,
                     union lquota_id *, bool, __u64, void *);