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: 10819093 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 A096A13BF for ; Tue, 19 Feb 2019 00:14:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BAA52B65E for ; Tue, 19 Feb 2019 00:14:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FFDD2BDE4; Tue, 19 Feb 2019 00:14:39 +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 128F02B65E for ; Tue, 19 Feb 2019 00:14:39 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id AD1B64E30CE; Mon, 18 Feb 2019 16:14:38 -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 416B94E3030 for ; Mon, 18 Feb 2019 16:14:37 -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 70F4CACC1; Tue, 19 Feb 2019 00:14:36 +0000 (UTC) From: NeilBrown To: James Simmons , Andreas Dilger , Oleg Drokin Date: Tue, 19 Feb 2019 11:09:06 +1100 Message-ID: <155053494660.24125.14350673827307393026.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 31/37] lustre: discard OBD_FREE_RCU 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 OBD_FREE_RCU and the hop_free call-back together form an overly complex mechanism equivalent to kfree_rcu() or call_rcu(...). Discard them and use the simpler approach. This removes the only use for the field h_size, so discard that too. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 3 --- .../staging/lustre/lustre/include/obd_support.h | 10 ---------- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 16 ++++++++-------- drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++---- .../lustre/lustre/obdclass/lustre_handles.c | 15 --------------- 5 files changed, 10 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 7e868aecff0e..7079982ffd31 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -46,7 +46,6 @@ #include struct portals_handle_ops { - void (*hop_free)(void *object, int size); }; /* These handles are most easily used by having them appear at the very top of @@ -70,7 +69,6 @@ struct portals_handle { /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; spinlock_t h_lock; - unsigned int h_size:31; unsigned int h_in:1; }; @@ -81,7 +79,6 @@ void class_handle_hash(struct portals_handle *, const struct portals_handle_ops *ops); void class_handle_unhash(struct portals_handle *); 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/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 3e15cac04ac5..91d6a862fa92 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -503,16 +503,6 @@ extern char obd_jobid_var[]; #define POISON_PAGE(page, val) do { } while (0) #endif -#define OBD_FREE_RCU(ptr, size, handle) \ -do { \ - struct portals_handle *__h = (handle); \ - \ - __h->h_cookie = (unsigned long)(ptr); \ - __h->h_size = (size); \ - call_rcu(&__h->h_rcu, class_handle_free_cb); \ - POISON_PTR(ptr); \ -} while (0) - #define KEY_IS(str) \ (keylen >= (sizeof(str) - 1) && \ memcmp(key, str, (sizeof(str) - 1)) == 0) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 7864f9a7ef90..010285b226e6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -153,6 +153,13 @@ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock) } EXPORT_SYMBOL(ldlm_lock_get); +static void lock_handle_free(struct rcu_head *rcu) +{ + struct ldlm_lock *lock = container_of(rcu, struct ldlm_lock, + l_handle.h_rcu); + kmem_cache_free(ldlm_lock_slab, lock); +} + /** * Release lock reference. * @@ -184,7 +191,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) kfree(lock->l_lvb_data); - OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); + call_rcu(&lock->l_handle.h_rcu, lock_handle_free); } } EXPORT_SYMBOL(ldlm_lock_put); @@ -349,14 +356,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) LDLM_LOCK_RELEASE(lock); } -static void lock_handle_free(void *lock, int size) -{ - LASSERT(size == sizeof(struct ldlm_lock)); - kmem_cache_free(ldlm_lock_slab, lock); -} - static struct portals_handle_ops lock_handle_ops = { - .hop_free = lock_handle_free, }; /** diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 4b1e14957a66..156541ead12e 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -740,11 +740,10 @@ static void class_export_destroy(struct obd_export *exp) if (exp != obd->obd_self_export) class_decref(obd); - OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); + kfree_rcu(exp, exp_handle.h_rcu); } static struct portals_handle_ops export_handle_ops = { - .hop_free = NULL, }; struct obd_export *class_export_get(struct obd_export *exp) @@ -930,11 +929,10 @@ static void class_import_destroy(struct obd_import *imp) LASSERT(!imp->imp_sec); class_decref(imp->imp_obd); - OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); + kfree_rcu(imp, imp_handle.h_rcu); } static struct portals_handle_ops import_handle_ops = { - .hop_free = NULL, }; struct obd_import *class_import_get(struct obd_import *import) diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 5c722d336c21..f4599ec5b0f0 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -164,21 +164,6 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) } EXPORT_SYMBOL(class_handle2object); -void class_handle_free_cb(struct rcu_head *rcu) -{ - struct portals_handle *h; - void *ptr; - - h = container_of(rcu, struct portals_handle, h_rcu); - ptr = (void *)(unsigned long)h->h_cookie; - - if (h->h_ops->hop_free) - h->h_ops->hop_free(ptr, h->h_size); - else - kfree(ptr); -} -EXPORT_SYMBOL(class_handle_free_cb); - int class_handle_init(void) { struct handle_bucket *bucket;