From 520c2959244ee366444dbc0b0d82bc05f4f9f5d6 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 15 May 2018 13:29:27 -0400 Subject: [PATCH] LU-8130 ldlm: store name directly in namespace. Rather than storing the name of a namespace in the hash table, store it directly in the namespace. This will allow the hashtable to be changed to use rhashtable. Linux-commit: 648ae363628c84faa8d8861e3246e096b8c0a392 Change-Id: Ie5bb8092c9e1831fbc38beade46be6d35f3256dc Signed-off-by: NeilBrown Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/32408 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Reviewed-by: Mike Pershin Reviewed-by: John L. Hammond --- lustre/include/lustre_dlm.h | 5 ++++- lustre/ldlm/ldlm_resource.c | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index ac3ec39..5015648 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -378,6 +378,9 @@ struct ldlm_namespace { /** Flag indicating if namespace is on client instead of server */ enum ldlm_side ns_client; + /** name of this namespace */ + char *ns_name; + /** Resource hash table for namespace. */ struct cfs_hash *ns_rs_hash; @@ -1046,7 +1049,7 @@ static inline bool ldlm_has_dom(struct ldlm_lock *lock) static inline char * ldlm_ns_name(struct ldlm_namespace *ns) { - return ns->ns_rs_hash->hs_name; + return ns->ns_name; } static inline struct ldlm_namespace * diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index cbbb074..49e5a0d 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -968,9 +968,12 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, nsb->nsb_reclaim_start = 0; } - ns->ns_obd = obd; - ns->ns_appetite = apt; - ns->ns_client = client; + ns->ns_obd = obd; + ns->ns_appetite = apt; + ns->ns_client = client; + ns->ns_name = kstrdup(name, GFP_KERNEL); + if (!ns->ns_name) + goto out_hash; INIT_LIST_HEAD(&ns->ns_list_chain); INIT_LIST_HEAD(&ns->ns_unused_list); @@ -1022,7 +1025,8 @@ out_sysfs: ldlm_namespace_sysfs_unregister(ns); ldlm_namespace_cleanup(ns, 0); out_hash: - cfs_hash_putref(ns->ns_rs_hash); + kfree(ns->ns_name); + cfs_hash_putref(ns->ns_rs_hash); out_ns: OBD_FREE_PTR(ns); out_ref: @@ -1286,9 +1290,11 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) ldlm_namespace_debugfs_unregister(ns); ldlm_namespace_sysfs_unregister(ns); cfs_hash_putref(ns->ns_rs_hash); + kfree(ns->ns_name); /* Namespace \a ns should be not on list at this time, otherwise * this will cause issues related to using freed \a ns in poold - * thread. */ + * thread. + */ LASSERT(list_empty(&ns->ns_list_chain)); OBD_FREE_PTR(ns); ldlm_put_ref(); -- 1.8.3.1