From: NeilBrown Date: Thu, 27 Jun 2019 21:55:26 +0000 (-0400) Subject: LU-8066 obd_type: use typ_kobj.name as typ_name X-Git-Tag: 2.12.56~16 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d9d48aab9e3d4e00037598be5427dd196cccaad7 LU-8066 obd_type: use typ_kobj.name as typ_name 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 Reviewed-on: https://review.whamcloud.com/34717 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis --- diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 9c50743..29a1fb1 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -543,7 +543,7 @@ struct ptlrpc_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 */ @@ -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_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, diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 233f4f0..4d2f08c 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -107,12 +107,12 @@ struct obd_type { #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; }; +#define typ_name typ_kobj.name struct brw_page { u64 off; diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index d906f77..695ef46 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -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, - 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); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 982d6d4..268f77a 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -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; - 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, diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 883e9a4..4923838 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -176,13 +176,10 @@ static void class_sysfs_release(struct kobject *kobj) list_del(&type->typ_chain); spin_unlock(&obd_types_lock); - if (type->typ_name) { #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 - 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) @@ -289,18 +286,15 @@ dir_exist: #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 || - 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; - strcpy(type->typ_name, name); 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) { - 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)) { @@ -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, - const char * typ_name, + const char *type_name, 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 ((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, @@ -2134,14 +2128,14 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max) __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; - 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) { diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index b9b73cc..b02e9a3 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -70,7 +70,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async); /** * 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; diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index dba6352..f0e7e1f 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -1796,7 +1796,7 @@ static int sepol_helper(struct obd_import *imp) 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 &&