From patchwork Tue Feb 19 00:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10819089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 867EC13BF for ; Tue, 19 Feb 2019 00:14:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC442B65E for ; Tue, 19 Feb 2019 00:14:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 620B12BDE4; Tue, 19 Feb 2019 00:14:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F14782B65E for ; Tue, 19 Feb 2019 00:14:27 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C30314E30AC; Mon, 18 Feb 2019 16:14:27 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 447E94E30EB for ; Mon, 18 Feb 2019 16:14:25 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7D02BACC1; Tue, 19 Feb 2019 00:14:24 +0000 (UTC) From: NeilBrown To: James Simmons , Andreas Dilger , Oleg Drokin Date: Tue, 19 Feb 2019 11:09:06 +1100 Message-ID: <155053494646.24125.10155576042684274174.stgit@noble.brown> In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP lustre_handles assigned a 64bit unique identifier (a 'cookie') to objects of various types and stored them in a hash table, allowing them to be accessed by the cookie. The is a facility for type checking by recording an 'owner' for each object, and checking the owner on lookup. Unfortunately this is not used - owner is always zero. Eahc object also contains an h_ops pointer which can be used to reliably identify an owner. So discard h_owner, pass and 'ops' pointer to class_handle2object(), and only return objects for which the h_ops matches. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 7 +++---- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 3 ++- .../lustre/lustre/obdclass/lustre_handles.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 683680891e4c..9a4b1a821e7b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -65,8 +65,7 @@ struct portals_handle_ops { struct portals_handle { struct list_head h_link; u64 h_cookie; - const void *h_owner; - struct portals_handle_ops *h_ops; + const struct portals_handle_ops *h_ops; /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; @@ -79,9 +78,9 @@ struct portals_handle { /* Add a handle to the hash table */ void class_handle_hash(struct portals_handle *, - struct portals_handle_ops *ops); + const struct portals_handle_ops *ops); void class_handle_unhash(struct portals_handle *); -void *class_handle2object(u64 cookie, const void *owner); +void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops); void class_handle_free_cb(struct rcu_head *rcu); int class_handle_init(void); void class_handle_cleanup(void); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 60a6ec2f7136..248331153c68 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -503,7 +503,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(handle); - lock = class_handle2object(handle->cookie, NULL); + lock = class_handle2object(handle->cookie, &lock_handle_ops); if (!lock) return NULL; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index fc7985a2922c..b5fce96e43f7 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -674,6 +674,7 @@ int obd_init_caches(void) return -ENOMEM; } +static struct portals_handle_ops export_handle_ops; /* map connection to client */ struct obd_export *class_conn2export(struct lustre_handle *conn) { @@ -690,7 +691,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, NULL); + export = class_handle2object(conn->cookie, &export_handle_ops); return export; } EXPORT_SYMBOL(class_conn2export); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 0674afb0059f..32b70d613f71 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -59,7 +59,7 @@ static struct handle_bucket { * global (per-node) hash-table. */ void class_handle_hash(struct portals_handle *h, - struct portals_handle_ops *ops) + const struct portals_handle_ops *ops) { struct handle_bucket *bucket; @@ -132,7 +132,7 @@ void class_handle_unhash(struct portals_handle *h) } EXPORT_SYMBOL(class_handle_unhash); -void *class_handle2object(u64 cookie, const void *owner) +void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) { struct handle_bucket *bucket; struct portals_handle *h; @@ -147,7 +147,7 @@ void *class_handle2object(u64 cookie, const void *owner) rcu_read_lock(); list_for_each_entry_rcu(h, &bucket->head, h_link) { - if (h->h_cookie != cookie || h->h_owner != owner) + if (h->h_cookie != cookie || h->h_ops != ops) continue; spin_lock(&h->h_lock);