From patchwork Wed Jan 9 06:24:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753449 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 B8CE417D2 for ; Wed, 9 Jan 2019 06:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5C9728E16 for ; Wed, 9 Jan 2019 06:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A1F928E19; Wed, 9 Jan 2019 06:25:14 +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 3341A28E16 for ; Wed, 9 Jan 2019 06:25:14 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DD53821FDB2; Tue, 8 Jan 2019 22:25:13 -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 8723421F656 for ; Tue, 8 Jan 2019 22:25:12 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BD232AF0B; Wed, 9 Jan 2019 06:25:11 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504098.26726.7180667249484886220.stgit@noble> In-Reply-To: <154701488711.26726.17363928508883972338.stgit@noble> References: <154701488711.26726.17363928508883972338.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 02/29] lustre: osc_cache: use assert_spin_locked() 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 assert_spin_locked() is preferred to spin_is_locked() for affirming that a spinlock is locked. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 29 +++++++++----------- .../staging/lustre/lustre/osc/osc_cl_internal.h | 15 +--------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index fbf16547003d..1ce9f673f1bf 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -181,10 +181,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, size_t page_count; int rc = 0; - if (!osc_object_is_locked(obj)) { - rc = 9; - goto out; - } + assert_osc_object_is_locked(obj); if (ext->oe_state >= OES_STATE_MAX) { rc = 10; @@ -324,7 +321,7 @@ static int osc_extent_is_overlapped(struct osc_object *obj, { struct osc_extent *tmp; - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); if (!extent_debug) return 0; @@ -341,7 +338,7 @@ static int osc_extent_is_overlapped(struct osc_object *obj, static void osc_extent_state_set(struct osc_extent *ext, int state) { - LASSERT(osc_object_is_locked(ext->oe_obj)); + assert_osc_object_is_locked(ext->oe_obj); LASSERT(state >= OES_INV && state < OES_STATE_MAX); /* Never try to sanity check a state changing extent :-) */ @@ -414,7 +411,7 @@ static void osc_extent_put(const struct lu_env *env, struct osc_extent *ext) static void osc_extent_put_trust(struct osc_extent *ext) { LASSERT(atomic_read(&ext->oe_refc) > 1); - LASSERT(osc_object_is_locked(ext->oe_obj)); + assert_osc_object_is_locked(ext->oe_obj); atomic_dec(&ext->oe_refc); } @@ -428,7 +425,7 @@ static struct osc_extent *osc_extent_search(struct osc_object *obj, struct rb_node *n = obj->oo_root.rb_node; struct osc_extent *tmp, *p = NULL; - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); while (n) { tmp = rb_extent(n); if (index < tmp->oe_start) { @@ -467,7 +464,7 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) LASSERT(RB_EMPTY_NODE(&ext->oe_node)); LASSERT(ext->oe_obj == obj); - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); while (*n) { tmp = rb_extent(*n); parent = *n; @@ -489,7 +486,7 @@ static void osc_extent_erase(struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); if (!RB_EMPTY_NODE(&ext->oe_node)) { rb_erase(&ext->oe_node, &obj->oo_root); RB_CLEAR_NODE(&ext->oe_node); @@ -502,7 +499,7 @@ static struct osc_extent *osc_extent_hold(struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); LASSERT(ext->oe_state == OES_ACTIVE || ext->oe_state == OES_CACHE); if (ext->oe_state == OES_CACHE) { osc_extent_state_set(ext, OES_ACTIVE); @@ -515,7 +512,7 @@ static struct osc_extent *osc_extent_hold(struct osc_extent *ext) static void __osc_extent_remove(struct osc_extent *ext) { - LASSERT(osc_object_is_locked(ext->oe_obj)); + assert_osc_object_is_locked(ext->oe_obj); LASSERT(list_empty(&ext->oe_pages)); osc_extent_erase(ext); list_del_init(&ext->oe_link); @@ -546,7 +543,7 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, int ppc_bits; LASSERT(cur->oe_state == OES_CACHE); - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); if (!victim) return -EINVAL; @@ -2079,7 +2076,7 @@ static unsigned int get_write_extents(struct osc_object *obj, .erd_max_extents = 256, }; - LASSERT(osc_object_is_locked(obj)); + assert_osc_object_is_locked(obj); while (!list_empty(&obj->oo_hp_exts)) { ext = list_entry(obj->oo_hp_exts.next, struct osc_extent, oe_link); @@ -2146,7 +2143,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, int srvlock = 0; int rc = 0; - LASSERT(osc_object_is_locked(osc)); + assert_osc_object_is_locked(osc); page_count = get_write_extents(osc, &rpclist); LASSERT(equi(page_count == 0, list_empty(&rpclist))); @@ -2224,7 +2221,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, }; int rc = 0; - LASSERT(osc_object_is_locked(osc)); + assert_osc_object_is_locked(osc); list_for_each_entry_safe(ext, next, &osc->oo_reading_exts, oe_link) { EASSERT(ext->oe_state == OES_LOCK_DONE, ext); if (!try_to_add_extent_for_io(cli, ext, &data)) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index b78deef3963a..aa1b753fc88d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -183,19 +183,8 @@ static inline void osc_object_unlock(struct osc_object *obj) spin_unlock(&obj->oo_lock); } -static inline int osc_object_is_locked(struct osc_object *obj) -{ -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) - return spin_is_locked(&obj->oo_lock); -#else - /* - * It is not perfect to return true all the time. - * But since this function is only used for assertion - * and checking, it seems OK. - */ - return 1; -#endif -} +#define assert_osc_object_is_locked(obj) \ + assert_spin_locked(&obj->oo_lock) /* * Lock "micro-states" for osc layer.