Whamcloud - gitweb
LU-8066 obd_type: use typ_kobj.name as typ_name 17/34717/7
authorNeilBrown <neilb@suse.com>
Thu, 27 Jun 2019 21:55:26 +0000 (17:55 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 12 Jul 2019 05:21:49 +0000 (05:21 +0000)
As the kobject has a name (after kobject_add has been called),
we don't need to also store it in typ_name.
So use typ_kobj.name instead of typ_name.

This requires changing some "char *" to "const char *" as
typ.kobj.name is const.

Change-Id: Iaf0ef192e91ba1b4bd1c1b124dc1068de632d341
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/34717
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
lustre/include/lustre_net.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/ldlm/ldlm_lib.c
lustre/obdclass/genops.c
lustre/ptlrpc/client.c
lustre/ptlrpc/sec.c

index 9c50743..29a1fb1 100644 (file)
@@ -543,7 +543,7 @@ struct ptlrpc_client {
         /** What portal do we expect replies on */
         __u32                   cli_reply_portal;
         /** Name of the client */
         /** What portal do we expect replies on */
         __u32                   cli_reply_portal;
         /** Name of the client */
-        char                   *cli_name;
+       const char              *cli_name;
 };
 
 /** state flags of requests */
 };
 
 /** state flags of requests */
@@ -2118,7 +2118,7 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd);
  */
 void ptlrpc_request_committed(struct ptlrpc_request *req, int force);
 
  */
 void ptlrpc_request_committed(struct ptlrpc_request *req, int force);
 
-void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
+void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
                         struct ptlrpc_client *);
 void ptlrpc_cleanup_client(struct obd_import *imp);
 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid,
                         struct ptlrpc_client *);
 void ptlrpc_cleanup_client(struct obd_import *imp);
 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid,
index 233f4f0..4d2f08c 100644 (file)
@@ -107,12 +107,12 @@ struct obd_type {
 #ifdef HAVE_SERVER_SUPPORT
        bool                     typ_sym_filter;
 #endif
 #ifdef HAVE_SERVER_SUPPORT
        bool                     typ_sym_filter;
 #endif
-       char                    *typ_name;
        int                      typ_refcnt;
        struct lu_device_type   *typ_lu;
        spinlock_t               obd_type_lock;
        struct kobject           typ_kobj;
 };
        int                      typ_refcnt;
        struct lu_device_type   *typ_lu;
        spinlock_t               obd_type_lock;
        struct kobject           typ_kobj;
 };
+#define typ_name typ_kobj.name
 
 struct brw_page {
        u64              off;
 
 struct brw_page {
        u64              off;
index d906f77..695ef46 100644 (file)
@@ -86,7 +86,7 @@ int class_uuid2dev(struct obd_uuid *uuid);
 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
 void class_obd_list(void);
 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
 void class_obd_list(void);
 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
-                                          const char * typ_name,
+                                         const char *type_name,
                                           struct obd_uuid *grp_uuid);
 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
                                            int *next);
                                           struct obd_uuid *grp_uuid);
 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
                                            int *next);
index 982d6d4..268f77a 100644 (file)
@@ -278,7 +278,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
        struct obd_import *imp;
        struct obd_uuid server_uuid;
        int rq_portal, rp_portal, connect_op;
        struct obd_import *imp;
        struct obd_uuid server_uuid;
        int rq_portal, rp_portal, connect_op;
-       char *name = obddev->obd_type->typ_name;
+       const char *name = obddev->obd_type->typ_name;
        enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN;
        char *cli_name = lustre_cfg_buf(lcfg, 0);
        struct ptlrpc_connection fake_conn = { .c_self = 0,
        enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN;
        char *cli_name = lustre_cfg_buf(lcfg, 0);
        struct ptlrpc_connection fake_conn = { .c_self = 0,
index 883e9a4..4923838 100644 (file)
@@ -176,13 +176,10 @@ static void class_sysfs_release(struct kobject *kobj)
        list_del(&type->typ_chain);
        spin_unlock(&obd_types_lock);
 
        list_del(&type->typ_chain);
        spin_unlock(&obd_types_lock);
 
-       if (type->typ_name) {
 #ifdef CONFIG_PROC_FS
 #ifdef CONFIG_PROC_FS
-               if (type->typ_procroot)
-                       remove_proc_subtree(type->typ_name, proc_lustre_root);
+       if (type->typ_name && type->typ_procroot)
+               remove_proc_subtree(type->typ_name, proc_lustre_root);
 #endif
 #endif
-               OBD_FREE(type->typ_name, strlen(type->typ_name) + 1);
-       }
        if (type->typ_md_ops)
                OBD_FREE_PTR(type->typ_md_ops);
        if (type->typ_dt_ops)
        if (type->typ_md_ops)
                OBD_FREE_PTR(type->typ_md_ops);
        if (type->typ_dt_ops)
@@ -289,18 +286,15 @@ dir_exist:
 #endif /* HAVE_SERVER_SUPPORT */
         OBD_ALLOC_PTR(type->typ_dt_ops);
         OBD_ALLOC_PTR(type->typ_md_ops);
 #endif /* HAVE_SERVER_SUPPORT */
         OBD_ALLOC_PTR(type->typ_dt_ops);
         OBD_ALLOC_PTR(type->typ_md_ops);
-        OBD_ALLOC(type->typ_name, strlen(name) + 1);
 
         if (type->typ_dt_ops == NULL ||
 
         if (type->typ_dt_ops == NULL ||
-            type->typ_md_ops == NULL ||
-            type->typ_name == NULL)
+           type->typ_md_ops == NULL)
                GOTO (failed, rc = -ENOMEM);
 
         *(type->typ_dt_ops) = *dt_ops;
         /* md_ops is optional */
         if (md_ops)
                 *(type->typ_md_ops) = *md_ops;
                GOTO (failed, rc = -ENOMEM);
 
         *(type->typ_dt_ops) = *dt_ops;
         /* md_ops is optional */
         if (md_ops)
                 *(type->typ_md_ops) = *md_ops;
-        strcpy(type->typ_name, name);
        spin_lock_init(&type->obd_type_lock);
 
 #ifdef HAVE_SERVER_SUPPORT
        spin_lock_init(&type->obd_type_lock);
 
 #ifdef HAVE_SERVER_SUPPORT
@@ -309,7 +303,7 @@ dir_exist:
 #endif
 #ifdef CONFIG_PROC_FS
        if (enable_proc && !type->typ_procroot) {
 #endif
 #ifdef CONFIG_PROC_FS
        if (enable_proc && !type->typ_procroot) {
-               type->typ_procroot = lprocfs_register(type->typ_name,
+               type->typ_procroot = lprocfs_register(name,
                                                      proc_lustre_root,
                                                      NULL, type);
                if (IS_ERR(type->typ_procroot)) {
                                                      proc_lustre_root,
                                                      NULL, type);
                if (IS_ERR(type->typ_procroot)) {
@@ -795,7 +789,7 @@ void class_obd_list(void)
    specified, then only the client with that uuid is returned,
    otherwise any client connected to the tgt is returned. */
 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
    specified, then only the client with that uuid is returned,
    otherwise any client connected to the tgt is returned. */
 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
-                                          const char * typ_name,
+                                         const char *type_name,
                                           struct obd_uuid *grp_uuid)
 {
         int i;
                                           struct obd_uuid *grp_uuid)
 {
         int i;
@@ -806,8 +800,8 @@ struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
 
                 if (obd == NULL)
                         continue;
 
                 if (obd == NULL)
                         continue;
-                if ((strncmp(obd->obd_type->typ_name, typ_name,
-                             strlen(typ_name)) == 0)) {
+               if ((strncmp(obd->obd_type->typ_name, type_name,
+                            strlen(type_name)) == 0)) {
                         if (obd_uuid_equals(tgt_uuid,
                                             &obd->u.cli.cl_target_uuid) &&
                             ((grp_uuid)? obd_uuid_equals(grp_uuid,
                         if (obd_uuid_equals(tgt_uuid,
                                             &obd->u.cli.cl_target_uuid) &&
                             ((grp_uuid)? obd_uuid_equals(grp_uuid,
@@ -2134,14 +2128,14 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max)
        __u32                           old;
        int                             diff;
        int                             i;
        __u32                           old;
        int                             diff;
        int                             i;
-       char                            *typ_name;
+       const char *type_name;
        int                             rc;
 
        if (max > OBD_MAX_RIF_MAX || max < 1)
                return -ERANGE;
 
        int                             rc;
 
        if (max > OBD_MAX_RIF_MAX || max < 1)
                return -ERANGE;
 
-       typ_name = cli->cl_import->imp_obd->obd_type->typ_name;
-       if (strcmp(typ_name, LUSTRE_MDC_NAME) == 0) {
+       type_name = cli->cl_import->imp_obd->obd_type->typ_name;
+       if (strcmp(type_name, LUSTRE_MDC_NAME) == 0) {
                /* adjust max_mod_rpcs_in_flight to ensure it is always
                 * strictly lower that max_rpcs_in_flight */
                if (max < 2) {
                /* adjust max_mod_rpcs_in_flight to ensure it is always
                 * strictly lower that max_rpcs_in_flight */
                if (max < 2) {
index b9b73cc..b02e9a3 100644 (file)
@@ -70,7 +70,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async);
 /**
  * Initialize passed in client structure \a cl.
  */
 /**
  * Initialize passed in client structure \a cl.
  */
-void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
+void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
                        struct ptlrpc_client *cl)
 {
        cl->cli_request_portal = req_portal;
                        struct ptlrpc_client *cl)
 {
        cl->cli_request_portal = req_portal;
index dba6352..f0e7e1f 100644 (file)
@@ -1796,7 +1796,7 @@ static int sepol_helper(struct obd_import *imp)
            imp->imp_obd->obd_type == NULL) {
                rc = -EINVAL;
        } else {
            imp->imp_obd->obd_type == NULL) {
                rc = -EINVAL;
        } else {
-               argv[2] = imp->imp_obd->obd_type->typ_name;
+               argv[2] = (char *)imp->imp_obd->obd_type->typ_name;
                argv[4] = imp->imp_obd->obd_name;
                spin_lock(&imp->imp_sec->ps_lock);
                if (imp->imp_sec->ps_sepol_mtime == 0 &&
                argv[4] = imp->imp_obd->obd_name;
                spin_lock(&imp->imp_sec->ps_lock);
                if (imp->imp_sec->ps_sepol_mtime == 0 &&