From: NeilBrown Date: Fri, 20 Dec 2019 14:37:48 +0000 (-0500) Subject: LU-12542 handle: rename ops to owner X-Git-Tag: 2.13.51~14 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1a9aafbf6317a9b8b026f69faad11e1801e1b92a LU-12542 handle: rename ops to owner Now that portals_handle_ops contains only a char*, it is functioning primarily to identify the owner of each handle. So change the name to h_owner, and the type to const char*. Note: this h_owner is now quite different from the similar h_owner in the server code. When server code it merged the "med" pointer should be stored in the "mfd" and validated separately. Change-Id: Ie2e9134ea22c4929683c84bf45c41b96b348d0a2 Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/35798 Reviewed-by: Shaun Tancheff Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_handles.h b/lustre/include/lustre_handles.h index 511a2f6..41670d5 100644 --- a/lustre/include/lustre_handles.h +++ b/lustre/include/lustre_handles.h @@ -47,11 +47,6 @@ #include #include -struct portals_handle_ops { - /* hop_type is used for some debugging messages */ - char *hop_type; -}; - /* These handles are most easily used by having them appear at the very top of * whatever object that you want to make handles for. ie: * @@ -66,7 +61,7 @@ struct portals_handle_ops { struct portals_handle { struct list_head h_link; __u64 h_cookie; - const struct portals_handle_ops *h_ops; + const char *h_owner; refcount_t h_ref; /* newly added fields to handle the RCU issue. -jxiong */ @@ -78,10 +73,9 @@ struct portals_handle { /* handles.c */ /* Add a handle to the hash table */ -void class_handle_hash(struct portals_handle *, - const struct portals_handle_ops *ops); +void class_handle_hash(struct portals_handle *, const char *h_owner); void class_handle_unhash(struct portals_handle *); -void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops); +void *class_handle2object(u64 cookie, const char *h_owner); int class_handle_init(void); void class_handle_cleanup(void); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 8af3366..c2fd190 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -447,9 +447,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) EXIT; } -static struct portals_handle_ops lock_handle_ops = { - .hop_type = "ldlm", -}; +static const char lock_handle_owner[] = "ldlm"; /** * @@ -492,7 +490,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats, LDLM_NSS_LOCKS); INIT_LIST_HEAD_RCU(&lock->l_handle.h_link); - class_handle_hash(&lock->l_handle, &lock_handle_ops); + class_handle_hash(&lock->l_handle, lock_handle_owner); lu_ref_init(&lock->l_reference); lu_ref_add(&lock->l_reference, "hash", lock); @@ -605,8 +603,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, if (!lustre_handle_is_used(handle)) RETURN(NULL); - lock = class_handle2object(handle->cookie, &lock_handle_ops); - + lock = class_handle2object(handle->cookie, lock_handle_owner); if (lock == NULL) RETURN(NULL); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index c364925..8baaa48 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -44,9 +44,7 @@ #include "mdt_internal.h" #include -static const struct portals_handle_ops mfd_open_handle_ops = { - .hop_type = "mdt", -}; +static const char mfd_open_handle_owner[] = "mdt"; /* Create a new mdt_file_data struct, initialize it, * and insert it to global hash table */ @@ -61,7 +59,7 @@ struct mdt_file_data *mdt_mfd_new(const struct mdt_export_data *med) INIT_LIST_HEAD_RCU(&mfd->mfd_open_handle.h_link); mfd->mfd_owner = med; INIT_LIST_HEAD(&mfd->mfd_list); - class_handle_hash(&mfd->mfd_open_handle, &mfd_open_handle_ops); + class_handle_hash(&mfd->mfd_open_handle, mfd_open_handle_owner); } RETURN(mfd); @@ -81,7 +79,7 @@ struct mdt_file_data *mdt_open_handle2mfd(struct mdt_export_data *med, ENTRY; LASSERT(open_handle != NULL); - mfd = class_handle2object(open_handle->cookie, &mfd_open_handle_ops); + mfd = class_handle2object(open_handle->cookie, mfd_open_handle_owner); if (mfd) refcount_dec(&mfd->mfd_open_handle.h_ref); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 0d670da..1fa7197 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -899,7 +899,7 @@ out: RETURN(rc); } -static struct portals_handle_ops export_handle_ops; +static const char export_handle_owner[] = "export"; /* map connection to client */ struct obd_export *class_conn2export(struct lustre_handle *conn) @@ -918,7 +918,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) } CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie); - export = class_handle2object(conn->cookie, &export_handle_ops); + export = class_handle2object(conn->cookie, export_handle_owner); RETURN(export); } EXPORT_SYMBOL(class_conn2export); @@ -971,10 +971,6 @@ static void class_export_destroy(struct obd_export *exp) EXIT; } -static struct portals_handle_ops export_handle_ops = { - .hop_type = "export", -}; - struct obd_export *class_export_get(struct obd_export *exp) { refcount_inc(&exp->exp_handle.h_ref); @@ -1063,7 +1059,7 @@ struct obd_export *__class_new_export(struct obd_device *obd, INIT_LIST_HEAD_RCU(&export->exp_handle.h_link); INIT_LIST_HEAD(&export->exp_hp_rpcs); INIT_LIST_HEAD(&export->exp_reg_rpcs); - class_handle_hash(&export->exp_handle, &export_handle_ops); + class_handle_hash(&export->exp_handle, export_handle_owner); export->exp_last_request_time = ktime_get_real_seconds(); spin_lock_init(&export->exp_lock); spin_lock_init(&export->exp_rpc_lock); diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c index 40d69186..7931442 100644 --- a/lustre/obdclass/lustre_handles.c +++ b/lustre/obdclass/lustre_handles.c @@ -59,8 +59,7 @@ static struct handle_bucket { * Generate a unique 64bit cookie (hash) for a handle and insert it into * global (per-node) hash-table. */ -void class_handle_hash(struct portals_handle *h, - const struct portals_handle_ops *ops) +void class_handle_hash(struct portals_handle *h, const char *owner) { struct handle_bucket *bucket; @@ -88,7 +87,7 @@ void class_handle_hash(struct portals_handle *h, h->h_cookie = handle_base; spin_unlock(&handle_base_lock); - h->h_ops = ops; + h->h_owner = owner; spin_lock_init(&h->h_lock); bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK]; @@ -135,7 +134,7 @@ void class_handle_unhash(struct portals_handle *h) } EXPORT_SYMBOL(class_handle_unhash); -void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) +void *class_handle2object(u64 cookie, const char *owner) { struct handle_bucket *bucket; struct portals_handle *h; @@ -153,14 +152,14 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) rcu_read_lock(); list_for_each_entry_rcu(h, &bucket->head, h_link) { - if (h->h_cookie != cookie || h->h_ops != ops) + if (h->h_cookie != cookie || h->h_owner != owner) continue; spin_lock(&h->h_lock); if (likely(h->h_in != 0)) { refcount_inc(&h->h_ref); CDEBUG(D_INFO, "GET %s %p refcount=%d\n", - h->h_ops->hop_type, h, + h->h_owner, h, refcount_read(&h->h_ref)); retval = h; } @@ -205,8 +204,8 @@ static int cleanup_all_handles(void) spin_lock(&handle_hash[i].lock); list_for_each_entry_rcu(h, &(handle_hash[i].head), h_link) { - CERROR("force clean handle %#llx addr %p ops %p\n", - h->h_cookie, h, h->h_ops); + CERROR("force clean handle %#llx addr %p owner %p\n", + h->h_cookie, h, h->h_owner); class_handle_unhash_nolock(h); rc++;