From patchwork Wed Jan 9 06:24:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753447 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 A25956C2 for ; Wed, 9 Jan 2019 06:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 913DF28E16 for ; Wed, 9 Jan 2019 06:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8517928E19; Wed, 9 Jan 2019 06:25:09 +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 1DB5228E16 for ; Wed, 9 Jan 2019 06:25:08 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 9896821FE58; Tue, 8 Jan 2019 22:25:08 -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 A1FDA21FDD9 for ; Tue, 8 Jan 2019 22:25:06 -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 E2732AF0F; Wed, 9 Jan 2019 06:25:05 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:00 +1100 Message-ID: <154701504072.26726.12597270089564992131.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 01/29] lustre: osc_cache: discard oe_intree 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 An rbnode knows if it is in the tree or not, using RB_EMPTY_NODE(). There is no need for an extra flag. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 15 +++++++-------- .../staging/lustre/lustre/osc/osc_cl_internal.h | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 93330cb77e94..fbf16547003d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -74,7 +74,7 @@ static inline char *ext_flags(struct osc_extent *ext, char *flags) { char *buf = flags; *buf++ = ext->oe_rw ? 'r' : 'w'; - if (ext->oe_intree) + if (!RB_EMPTY_NODE(&ext->oe_node)) *buf++ = 'i'; if (ext->oe_sync) *buf++ = 'S'; @@ -154,7 +154,7 @@ static inline struct osc_extent *next_extent(struct osc_extent *ext) if (!ext) return NULL; - LASSERT(ext->oe_intree); + LASSERT(!RB_EMPTY_NODE(&ext->oe_node)); return rb_extent(rb_next(&ext->oe_node)); } @@ -163,7 +163,7 @@ static inline struct osc_extent *prev_extent(struct osc_extent *ext) if (!ext) return NULL; - LASSERT(ext->oe_intree); + LASSERT(!RB_EMPTY_NODE(&ext->oe_node)); return rb_extent(rb_prev(&ext->oe_node)); } @@ -393,7 +393,7 @@ static void osc_extent_put(const struct lu_env *env, struct osc_extent *ext) LASSERT(list_empty(&ext->oe_link)); LASSERT(atomic_read(&ext->oe_users) == 0); LASSERT(ext->oe_state == OES_INV); - LASSERT(!ext->oe_intree); + LASSERT(RB_EMPTY_NODE(&ext->oe_node)); if (ext->oe_dlmlock) { lu_ref_add(&ext->oe_dlmlock->l_reference, @@ -465,7 +465,7 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) struct rb_node *parent = NULL; struct osc_extent *tmp; - LASSERT(ext->oe_intree == 0); + LASSERT(RB_EMPTY_NODE(&ext->oe_node)); LASSERT(ext->oe_obj == obj); LASSERT(osc_object_is_locked(obj)); while (*n) { @@ -482,7 +482,6 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) rb_link_node(&ext->oe_node, parent, n); rb_insert_color(&ext->oe_node, &obj->oo_root); osc_extent_get(ext); - ext->oe_intree = 1; } /* caller must have held object lock. */ @@ -491,9 +490,9 @@ static void osc_extent_erase(struct osc_extent *ext) struct osc_object *obj = ext->oe_obj; LASSERT(osc_object_is_locked(obj)); - if (ext->oe_intree) { + if (!RB_EMPTY_NODE(&ext->oe_node)) { rb_erase(&ext->oe_node, &obj->oo_root); - ext->oe_intree = 0; + RB_CLEAR_NODE(&ext->oe_node); /* rbtree held a refcount */ osc_extent_put_trust(ext); } diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 077a2b183634..b78deef3963a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -598,9 +598,8 @@ struct osc_extent { /* state of this extent */ enum osc_extent_state oe_state; /* flags for this extent. */ - unsigned int oe_intree:1, /* 0 is write, 1 is read */ - oe_rw:1, + unsigned int oe_rw:1, /* sync extent, queued by osc_queue_sync_pages() */ oe_sync:1, /* set if this extent has partial, sync pages. 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. 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: 10753451 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 7F9AC17D2 for ; Wed, 9 Jan 2019 06:25:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1AC28E16 for ; Wed, 9 Jan 2019 06:25:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62ACA28E19; Wed, 9 Jan 2019 06:25:21 +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 0BA6128E16 for ; Wed, 9 Jan 2019 06:25:21 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5357021FDD9; Tue, 8 Jan 2019 22:25:20 -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 8C95721FDB2 for ; Tue, 8 Jan 2019 22:25:18 -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 C5CA4AF0B; Wed, 9 Jan 2019 06:25:17 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504111.26726.7861020038366907898.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 03/29] lustre: osc: simplify osc_extent_wait() 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 Taking a spinlock to check the current value of the state is unnecessary. The wake_up() and wait_event() calls have sufficient barriers to ensure that the value will be seen and the wait will abort properly. In most cases, osc_extent_wait() is followed by osc_object_lock() before any shared data is touched - in those cases there is no need for osc_extent_wait() to wait for the spinlock to be released. The one case where osc_object_lock() does not immediately follow is in osc_cache_truncate_start(). The extra locking was introduced in a patch which fixed a problem with truncation, so it is likely that this is the call that was thought to be relevant. In that case, following osc_extent_wait(), an extent that had been detached from the per-object list (oe_link linkage) and proceeds to work on it without any locking. In this case the code is waiting for OES_TRUNC, so any changes that happen after the osc_extent_state_set(ext, OES_TRUNC) and when the lock is dropped, might not be seen by the woken code. The only thing changed is ->oe_trunc_pending, and the woken code doesn't look at that. The only remaining possible need for extra synchronization is if some other value was changed before the wakeup and is needed after the wait. According to memory-barriers.txt, a barrier might be needed to ensure that is visible. Such a barrier is most clearly presented by used smp_store_release() to set the state before wakeup, and smp_load_acquire() to view it after waiting. Also use a simple wake_up() instead of wake_up_all() - the latter is only needed when exclusive waiting is being used. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 1ce9f673f1bf..00056dffceb9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -345,8 +345,8 @@ static void osc_extent_state_set(struct osc_extent *ext, int state) /* LASSERT(sanity_check_nolock(ext) == 0); */ /* TODO: validate the state machine */ - ext->oe_state = state; - wake_up_all(&ext->oe_waitq); + smp_store_release(&ext->oe_state, state); + wake_up(&ext->oe_waitq); } static struct osc_extent *osc_extent_alloc(struct osc_object *obj) @@ -948,17 +948,6 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, return 0; } -static int extent_wait_cb(struct osc_extent *ext, enum osc_extent_state state) -{ - int ret; - - osc_object_lock(ext->oe_obj); - ret = ext->oe_state == state; - osc_object_unlock(ext->oe_obj); - - return ret; -} - /** * Wait for the extent's state to become @state. */ @@ -989,13 +978,16 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, /* wait for the extent until its state becomes @state */ rc = wait_event_idle_timeout(ext->oe_waitq, - extent_wait_cb(ext, state), 600 * HZ); + smp_load_acquire(&ext->oe_state) == state, + 600 * HZ); if (rc == 0) { OSC_EXTENT_DUMP(D_ERROR, ext, "%s: wait ext to %u timedout, recovery in progress?\n", cli_name(osc_cli(obj)), state); - wait_event_idle(ext->oe_waitq, extent_wait_cb(ext, state)); + wait_event_idle(ext->oe_waitq, + smp_load_acquire(&ext->oe_state) == state); + } if (ext->oe_rc < 0) rc = ext->oe_rc; 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: 10753453 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 167676C2 for ; Wed, 9 Jan 2019 06:25:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0468C28E16 for ; Wed, 9 Jan 2019 06:25:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED0F828E19; Wed, 9 Jan 2019 06:25:27 +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 AD62828E16 for ; Wed, 9 Jan 2019 06:25:27 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 522D421FE58; Tue, 8 Jan 2019 22:25: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 833CA21FDD3 for ; Tue, 8 Jan 2019 22:25:25 -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 BAA3AAF0B; Wed, 9 Jan 2019 06:25:24 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504121.26726.13780223132597872019.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 04/29] lustre: osc: simplify list manipulation 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 when A is empty, list_move_tail(&A, &B); is identical to list_add_tail(&A, &B); so always use list_move_tail() - it is easier to understand. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 00056dffceb9..6771675dd520 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2885,10 +2885,7 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, } /* This extent could be on the full extents list, that's OK */ EASSERT(!ext->oe_hp && !ext->oe_urgent, ext); - if (!list_empty(&ext->oe_link)) - list_move_tail(&ext->oe_link, &list); - else - list_add_tail(&ext->oe_link, &list); + list_move_tail(&ext->oe_link, &list); ext = next_extent(ext); } 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: 10753455 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 C11996C2 for ; Wed, 9 Jan 2019 06:25:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF8C828E16 for ; Wed, 9 Jan 2019 06:25:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A32A128E19; Wed, 9 Jan 2019 06:25:33 +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 318E828E16 for ; Wed, 9 Jan 2019 06:25:33 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D876021FF94; Tue, 8 Jan 2019 22:25:32 -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 6F216681A8F for ; Tue, 8 Jan 2019 22:25:30 -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 864B9AF0B; Wed, 9 Jan 2019 06:25:29 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504126.26726.9018865558337243745.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 05/29] lustre: osc: convert oe_refc and oe_users to kref and refcount_ 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 oe_refc is used like a kref, so make it one. oe_users isn't quite, as it is initialised to 0, so make it a refcount_t. As cl_object_put() needs an 'env', we cannot quite use kref_put() as intended. Maybe that can be fixed one day. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 73 ++++++++++++-------- .../staging/lustre/lustre/osc/osc_cl_internal.h | 4 + 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 6771675dd520..cab1a4f99cc2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -114,8 +114,8 @@ static const char *oes_strings[] = { /* ----- extent part 0 ----- */ \ __ext, EXTPARA(__ext), \ /* ----- part 1 ----- */ \ - atomic_read(&__ext->oe_refc), \ - atomic_read(&__ext->oe_users), \ + kref_read(&__ext->oe_refc), \ + refcount_read(&__ext->oe_users), \ list_empty_marker(&__ext->oe_link), \ oes_strings[__ext->oe_state], ext_flags(__ext, __buf), \ __ext->oe_obj, \ @@ -188,12 +188,12 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, goto out; } - if (atomic_read(&ext->oe_refc) <= 0) { + if (kref_read(&ext->oe_refc) <= 0) { rc = 20; goto out; } - if (atomic_read(&ext->oe_refc) < atomic_read(&ext->oe_users)) { + if (kref_read(&ext->oe_refc) < refcount_read(&ext->oe_users)) { rc = 30; goto out; } @@ -206,7 +206,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, rc = 0; goto out; case OES_ACTIVE: - if (atomic_read(&ext->oe_users) == 0) { + if (refcount_read(&ext->oe_users) == 0) { rc = 40; goto out; } @@ -230,7 +230,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, } /* fall through */ default: - if (atomic_read(&ext->oe_users) > 0) { + if (refcount_read(&ext->oe_users) > 0) { rc = 70; goto out; } @@ -360,8 +360,8 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj) RB_CLEAR_NODE(&ext->oe_node); ext->oe_obj = obj; cl_object_get(osc2cl(obj)); - atomic_set(&ext->oe_refc, 1); - atomic_set(&ext->oe_users, 0); + kref_init(&ext->oe_refc); + refcount_set(&ext->oe_users, 0); INIT_LIST_HEAD(&ext->oe_link); ext->oe_state = OES_INV; INIT_LIST_HEAD(&ext->oe_pages); @@ -371,35 +371,48 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj) return ext; } -static void osc_extent_free(struct osc_extent *ext) +static void osc_extent_free(struct kref *kref) { + struct osc_extent *ext = container_of(kref, struct osc_extent, + oe_refc); + + LASSERT(list_empty(&ext->oe_link)); + LASSERT(refcount_read(&ext->oe_users) == 0); + LASSERT(ext->oe_state == OES_INV); + LASSERT(RB_EMPTY_NODE(&ext->oe_node)); + + if (ext->oe_dlmlock) { + lu_ref_add(&ext->oe_dlmlock->l_reference, + "osc_extent", ext); + LDLM_LOCK_PUT(ext->oe_dlmlock); + ext->oe_dlmlock = NULL; + } +#if 0 + // When cl_object_put drop the need for 'env', + // this code can be enabled. + cl_object_put(osc2cl(ext->oe_obj)); + kmem_cache_free(osc_extent_kmem, ext); +#endif } static struct osc_extent *osc_extent_get(struct osc_extent *ext) { - LASSERT(atomic_read(&ext->oe_refc) >= 0); - atomic_inc(&ext->oe_refc); + LASSERT(kref_read(&ext->oe_refc) >= 0); + kref_get(&ext->oe_refc); return ext; } static void osc_extent_put(const struct lu_env *env, struct osc_extent *ext) { - LASSERT(atomic_read(&ext->oe_refc) > 0); - if (atomic_dec_and_test(&ext->oe_refc)) { - LASSERT(list_empty(&ext->oe_link)); - LASSERT(atomic_read(&ext->oe_users) == 0); - LASSERT(ext->oe_state == OES_INV); - LASSERT(RB_EMPTY_NODE(&ext->oe_node)); - - if (ext->oe_dlmlock) { - lu_ref_add(&ext->oe_dlmlock->l_reference, - "osc_extent", ext); - LDLM_LOCK_PUT(ext->oe_dlmlock); - ext->oe_dlmlock = NULL; - } + LASSERT(kref_read(&ext->oe_refc) > 0); + if (kref_put(&ext->oe_refc, osc_extent_free)) { + /* This should be in osc_extent_free(), but + * while we need to pass 'env' it cannot be. + */ cl_object_put(env, osc2cl(ext->oe_obj)); - osc_extent_free(ext); + + kmem_cache_free(osc_extent_kmem, ext); } } @@ -410,9 +423,9 @@ 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(kref_read(&ext->oe_refc) > 1); assert_osc_object_is_locked(ext->oe_obj); - atomic_dec(&ext->oe_refc); + osc_extent_put(NULL, ext); } /** @@ -505,7 +518,7 @@ static struct osc_extent *osc_extent_hold(struct osc_extent *ext) osc_extent_state_set(ext, OES_ACTIVE); osc_update_pending(obj, OBD_BRW_WRITE, -ext->oe_nr_pages); } - atomic_inc(&ext->oe_users); + refcount_inc(&ext->oe_users); list_del_init(&ext->oe_link); return osc_extent_get(ext); } @@ -599,11 +612,11 @@ void osc_extent_release(const struct lu_env *env, struct osc_extent *ext) struct osc_object *obj = ext->oe_obj; struct client_obd *cli = osc_cli(obj); - LASSERT(atomic_read(&ext->oe_users) > 0); + LASSERT(refcount_read(&ext->oe_users) > 0); LASSERT(sanity_check(ext) == 0); LASSERT(ext->oe_grants > 0); - if (atomic_dec_and_lock(&ext->oe_users, &obj->oo_lock)) { + if (refcount_dec_and_lock(&ext->oe_users, &obj->oo_lock)) { LASSERT(ext->oe_state == OES_ACTIVE); if (ext->oe_trunc_pending) { /* a truncate process is waiting for this extent. diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index aa1b753fc88d..b1a1d241cc6c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -579,9 +579,9 @@ struct osc_extent { /* osc_object of this extent */ struct osc_object *oe_obj; /* refcount, removed from red-black tree if reaches zero. */ - atomic_t oe_refc; + struct kref oe_refc; /* busy if non-zero */ - atomic_t oe_users; + refcount_t oe_users; /* link list of osc_object's oo_{hp|urgent|locking}_exts. */ struct list_head oe_link; /* state of this extent */ 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: 10753457 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 A4D8717D2 for ; Wed, 9 Jan 2019 06:25:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9378128E16 for ; Wed, 9 Jan 2019 06:25:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8800628E19; Wed, 9 Jan 2019 06:25:38 +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 4B71B28E16 for ; Wed, 9 Jan 2019 06:25:38 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id EFAE221FFE3; Tue, 8 Jan 2019 22:25:37 -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 76BCE21FF10 for ; Tue, 8 Jan 2019 22:25:36 -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 6B070AF0B; Wed, 9 Jan 2019 06:25:35 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504133.26726.5055625028157924201.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 06/29] lustre: osc: use overlapped() consistently. 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 osc_extent_is_overlapped() open-codes exactly the test that overlapped() performs. So use overlapped() instead, to make the code more obviously consistent. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index cab1a4f99cc2..dd3c87124aa5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -313,6 +313,11 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, __res; \ }) +static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) +{ + return !(ex1->oe_end < ex2->oe_start || ex2->oe_end < ex1->oe_start); +} + /** * sanity check - to make sure there is no overlapped extent in the tree. */ @@ -329,8 +334,7 @@ static int osc_extent_is_overlapped(struct osc_object *obj, for (tmp = first_extent(obj); tmp; tmp = next_extent(tmp)) { if (tmp == ext) continue; - if (tmp->oe_end >= ext->oe_start && - tmp->oe_start <= ext->oe_end) + if (overlapped(tmp, ext)) return 1; } return 0; @@ -655,11 +659,6 @@ void osc_extent_release(const struct lu_env *env, struct osc_extent *ext) osc_extent_put(env, ext); } -static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) -{ - return !(ex1->oe_end < ex2->oe_start || ex2->oe_end < ex1->oe_start); -} - /** * Find or create an extent which includes @index, core function to manage * extent tree. 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: 10753459 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 B16B317D2 for ; Wed, 9 Jan 2019 06:25:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FE6228E16 for ; Wed, 9 Jan 2019 06:25:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9415028E19; Wed, 9 Jan 2019 06:25:44 +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 4910D28E16 for ; Wed, 9 Jan 2019 06:25:44 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1B6A8681B37; Tue, 8 Jan 2019 22:25:44 -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 32EBE681C06 for ; Tue, 8 Jan 2019 22:25:42 -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 63649AF0B; Wed, 9 Jan 2019 06:25:41 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504139.26726.16752476949923033869.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 07/29] lustre: osc: convert a while loop to for 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 This loop uses 'continue' in several places, and each one is proceeded by ext = next_extent(ext) which also appears at the end. This is exactly the pattern that a 'for' loop simplifies. So change to a for loop. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index dd3c87124aa5..eb8de1503386 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -737,7 +737,7 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, ext = osc_extent_search(obj, cur->oe_start); if (!ext) ext = first_extent(obj); - while (ext) { + for (; ext; ext = next_extent(ext)) { pgoff_t ext_chk_start = ext->oe_start >> ppc_bits; pgoff_t ext_chk_end = ext->oe_end >> ppc_bits; @@ -750,15 +750,12 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, EASSERTF(!overlapped(ext, cur), ext, EXTSTR "\n", EXTPARA(cur)); - ext = next_extent(ext); continue; } /* discontiguous chunks? */ - if (chunk + 1 < ext_chk_start) { - ext = next_extent(ext); + if (chunk + 1 < ext_chk_start) continue; - } /* ok, from now on, ext and cur have these attrs: * 1. covered by the same lock @@ -786,33 +783,27 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, } /* non-overlapped extent */ - if (ext->oe_state != OES_CACHE || ext->oe_fsync_wait) { + if (ext->oe_state != OES_CACHE || ext->oe_fsync_wait) /* we can't do anything for a non OES_CACHE extent, or * if there is someone waiting for this extent to be * flushed, try next one. */ - ext = next_extent(ext); continue; - } /* check if they belong to the same rpc slot before trying to * merge. the extents are not overlapped and contiguous at * chunk level to get here. */ - if (ext->oe_max_end != max_end) { + if (ext->oe_max_end != max_end) /* if they don't belong to the same RPC slot or * max_pages_per_rpc has ever changed, do not merge. */ - ext = next_extent(ext); continue; - } /* check whether maximum extent size will be hit */ if ((ext_chk_end - ext_chk_start + 1) << ppc_bits > - cli->cl_max_extent_pages) { - ext = next_extent(ext); + cli->cl_max_extent_pages) continue; - } /* it's required that an extent must be contiguous at chunk * level so that we know the whole extent is covered by grant @@ -851,8 +842,6 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, } if (found) break; - - ext = next_extent(ext); } osc_extent_tree_dump(D_CACHE, obj); 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: 10753461 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 D29506C2 for ; Wed, 9 Jan 2019 06:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C158F28E16 for ; Wed, 9 Jan 2019 06:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5EB628E19; Wed, 9 Jan 2019 06:25:50 +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 6419A28E16 for ; Wed, 9 Jan 2019 06:25:50 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 32AF8681B28; Tue, 8 Jan 2019 22:25:50 -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 269CA21FD99 for ; Tue, 8 Jan 2019 22:25:48 -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 4D3FAAF0B; Wed, 9 Jan 2019 06:25:47 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504144.26726.6306839878824560964.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 08/29] lustre: osc: simplify osc_extent_find() 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 osc_extent_find() contains some code with the same functionality as osc_extent_merge(). So replace that code with a call to osc_extent_merge(). This requires that we: - set cur->oe_grants earlier, as osc_extent_merge() needs that - take an extra temporary ref to cur, as osc_extent_merge() will drop the ref we have on success. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 50 ++++++------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index eb8de1503386..848e440ae2a9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -718,7 +718,8 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, cur->oe_start = descr->cld_start; if (cur->oe_end > max_end) cur->oe_end = max_end; - cur->oe_grants = 0; + LASSERT(*grants >= chunksize); + cur->oe_grants = chunksize; cur->oe_mppr = max_pages; if (olck->ols_dlmlock) { LASSERT(olck->ols_hold); @@ -790,58 +791,31 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, */ continue; - /* check if they belong to the same rpc slot before trying to - * merge. the extents are not overlapped and contiguous at - * chunk level to get here. - */ - if (ext->oe_max_end != max_end) - /* if they don't belong to the same RPC slot or - * max_pages_per_rpc has ever changed, do not merge. - */ - continue; - - /* check whether maximum extent size will be hit */ - if ((ext_chk_end - ext_chk_start + 1) << ppc_bits > - cli->cl_max_extent_pages) - continue; - /* it's required that an extent must be contiguous at chunk * level so that we know the whole extent is covered by grant * (the pages in the extent are NOT required to be contiguous). * Otherwise, it will be too much difficult to know which * chunks have grants allocated. */ - - /* try to do front merge - extend ext's start */ - if (chunk + 1 == ext_chk_start) { - /* ext must be chunk size aligned */ - EASSERT((ext->oe_start & ~chunk_mask) == 0, ext); - - /* pull ext's start back to cover cur */ - ext->oe_start = cur->oe_start; - ext->oe_grants += chunksize; - LASSERT(*grants >= chunksize); + /* On success, osc_extent_merge() will put cur, + * so we take an extra reference + */ + osc_extent_get(cur); + if (osc_extent_merge(env, ext, cur) == 0) { *grants -= chunksize; - found = osc_extent_hold(ext); - } else if (chunk == ext_chk_end + 1) { - /* rear merge */ - ext->oe_end = cur->oe_end; - ext->oe_grants += chunksize; - LASSERT(*grants >= chunksize); - *grants -= chunksize; - /* try to merge with the next one because we just fill - * in a gap + /* + * Try to merge with the next one too because we + * might have just filled in a gap. */ if (osc_extent_merge(env, ext, next_extent(ext)) == 0) /* we can save extent tax from next extent */ *grants += cli->cl_grant_extent_tax; - found = osc_extent_hold(ext); - } - if (found) break; + } + osc_extent_put(env, cur); } osc_extent_tree_dump(D_CACHE, obj); 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: 10753463 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 252B56C2 for ; Wed, 9 Jan 2019 06:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1281228E16 for ; Wed, 9 Jan 2019 06:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0752D28E19; Wed, 9 Jan 2019 06:25:56 +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 BB02C28E16 for ; Wed, 9 Jan 2019 06:25:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 705CE681C39; Tue, 8 Jan 2019 22:25:55 -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 E4E0221FFA8 for ; Tue, 8 Jan 2019 22:25:53 -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 23897AF0B; Wed, 9 Jan 2019 06:25:53 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504152.26726.5389367058165286948.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 09/29] lustre: osc: remove test on 'found' being an error. 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 Found cannot be IS_ERR() at this point in the code, as it is only ever assigned a value from osc_extent_hold() (or NULL). So discard the test. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 848e440ae2a9..e65d917336b9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -821,11 +821,9 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, osc_extent_tree_dump(D_CACHE, obj); if (found) { LASSERT(!conflict); - if (!IS_ERR(found)) { - LASSERT(found->oe_dlmlock == cur->oe_dlmlock); - OSC_EXTENT_DUMP(D_CACHE, found, - "found caching ext for %lu.\n", index); - } + LASSERT(found->oe_dlmlock == cur->oe_dlmlock); + OSC_EXTENT_DUMP(D_CACHE, found, + "found caching ext for %lu.\n", index); } else if (!conflict) { /* create a new extent */ EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur); 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: 10753465 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 2033917D2 for ; Wed, 9 Jan 2019 06:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D80328E16 for ; Wed, 9 Jan 2019 06:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01D2E28E19; Wed, 9 Jan 2019 06:26:01 +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 99A2628E16 for ; Wed, 9 Jan 2019 06:26:01 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1CFEA681C33; Tue, 8 Jan 2019 22:26:01 -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 D7912681C0F for ; Tue, 8 Jan 2019 22:25:59 -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 1CA9BAF0B; Wed, 9 Jan 2019 06:25:59 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504159.26726.15747465883750837429.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 10/29] lustre: osc_cache: avoid list_for_each_entry_safe when clearing list. 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 When removing some items from a list, list_for_each_entry_safe() is a good choice. When removing all items, it is clearer to use a while loop that repeatedly removes the first element, until there are none left. This makes it obvious that the list ends up empty. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index e65d917336b9..5cd3732101e7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -869,7 +869,6 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, { struct client_obd *cli = osc_cli(ext->oe_obj); struct osc_async_page *oap; - struct osc_async_page *tmp; int nr_pages = ext->oe_nr_pages; int lost_grant = 0; int blocksize = cli->cl_import->imp_obd->obd_osfs.os_bsize ? : 4096; @@ -882,7 +881,9 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, EASSERT(ergo(rc == 0, ext->oe_state == OES_RPC), ext); osc_lru_add_batch(cli, &ext->oe_pages); - list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) { + while ((oap = list_first_entry_or_null(&ext->oe_pages, + struct osc_async_page, + oap_pending_item))) { list_del_init(&oap->oap_rpc_item); list_del_init(&oap->oap_pending_item); if (last_off <= oap->oap_obj_off) { @@ -1686,11 +1687,11 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, /* caller must hold loi_list_lock */ void osc_wake_cache_waiters(struct client_obd *cli) { - struct list_head *l, *tmp; struct osc_cache_waiter *ocw; - list_for_each_safe(l, tmp, &cli->cl_cache_waiters) { - ocw = list_entry(l, struct osc_cache_waiter, ocw_entry); + while ((ocw = list_first_entry_or_null(&cli->cl_cache_waiters, + struct osc_cache_waiter, + ocw_entry))) { list_del_init(&ocw->ocw_entry); ocw->ocw_rc = -EDQUOT; @@ -2739,7 +2740,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, { struct client_obd *cli = osc_cli(obj); struct osc_extent *ext; - struct osc_async_page *oap, *tmp; + struct osc_async_page *oap; int page_count = 0; int mppr = cli->cl_max_pages_per_rpc; bool can_merge = true; @@ -2763,7 +2764,9 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, ext = osc_extent_alloc(obj); if (!ext) { - list_for_each_entry_safe(oap, tmp, list, oap_pending_item) { + while ((oap = list_first_entry_or_null(&oap->oap_pending_item, + struct osc_async_page, + oap_pending_item))) { list_del_init(&oap->oap_pending_item); osc_ap_completion(env, cli, oap, 0, -ENOMEM); } @@ -3093,11 +3096,12 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, LASSERT(ergo(!discard, list_empty(&discard_list))); if (!list_empty(&discard_list)) { - struct osc_extent *tmp; int rc; osc_list_maint(osc_cli(obj), obj); - list_for_each_entry_safe(ext, tmp, &discard_list, oe_link) { + while ((ext = list_first_entry_or_null(&discard_list, + struct osc_extent, + oe_link))) { list_del_init(&ext->oe_link); EASSERT(ext->oe_state == OES_LOCKING, ext); 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: 10753467 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 C5ADF17D2 for ; Wed, 9 Jan 2019 06:26:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B371328E16 for ; Wed, 9 Jan 2019 06:26:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7EC028E19; Wed, 9 Jan 2019 06:26:08 +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 690F428E16 for ; Wed, 9 Jan 2019 06:26:08 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3B06E681C72; Tue, 8 Jan 2019 22:26:08 -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 2929221FE54 for ; Tue, 8 Jan 2019 22:26:06 -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 328C7AF0B; Wed, 9 Jan 2019 06:26:05 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504164.26726.1429367185304894591.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 11/29] lustre: osc_cache: simplify osc_wake_cache_waiters() 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 osc_wake_cache_waiters() performs a test, then possibly calls osc_enter_cache_try() which performs the same test. We don't benefit from this duplication except that it allows an extra debug message. I'm not certain that message is worth the complexity. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 5cd3732101e7..0c78b95e45a3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1694,20 +1694,11 @@ void osc_wake_cache_waiters(struct client_obd *cli) ocw_entry))) { list_del_init(&ocw->ocw_entry); - ocw->ocw_rc = -EDQUOT; - /* we can't dirty more */ - if ((cli->cl_dirty_pages > cli->cl_dirty_max_pages) || - (atomic_long_read(&obd_dirty_pages) + 1 > - obd_max_dirty_pages)) { - CDEBUG(D_CACHE, "no dirty room: dirty: %ld osc max %ld, sys max %ld\n", - cli->cl_dirty_pages, cli->cl_dirty_max_pages, - obd_max_dirty_pages); - goto wakeup; - } - if (osc_enter_cache_try(cli, ocw->ocw_oap, ocw->ocw_grant, 0)) ocw->ocw_rc = 0; -wakeup: + else + ocw->ocw_rc = -EDQUOT; + CDEBUG(D_CACHE, "wake up %p for oap %p, avail grant %ld, %d\n", ocw, ocw->ocw_oap, cli->cl_avail_grant, ocw->ocw_rc); 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: 10753469 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 83DFD6C2 for ; Wed, 9 Jan 2019 06:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7182828E16 for ; Wed, 9 Jan 2019 06:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6612628E19; Wed, 9 Jan 2019 06:26: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 2534A28E16 for ; Wed, 9 Jan 2019 06:26:14 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C8331681CDD; Tue, 8 Jan 2019 22:26: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 DEE0921FE54 for ; Tue, 8 Jan 2019 22:26:11 -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 26E77AF0B; Wed, 9 Jan 2019 06:26:11 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504179.26726.1340537377320556999.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 12/29] lustre: osc_cache: avoid confusing variable reuse. 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 In osc_extent_wait(), the 'rc' variable use used for three very different purposes. This makes the code a bit harder to read. For one of the purposes, introduce a boolean 'need_release'. For another, use a conditional expression instead. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 0c78b95e45a3..5a295799f177 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -929,7 +929,8 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, enum osc_extent_state state) { struct osc_object *obj = ext->oe_obj; - int rc = 0; + bool need_release = false; + int rc; osc_object_lock(obj); LASSERT(sanity_check_nolock(ext) == 0); @@ -943,11 +944,11 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, } else if (ext->oe_state == OES_CACHE) { ext->oe_urgent = 1; osc_extent_hold(ext); - rc = 1; + need_release = true; } } osc_object_unlock(obj); - if (rc == 1) + if (need_release) osc_extent_release(env, ext); /* wait for the extent until its state becomes @state */ @@ -963,11 +964,7 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, smp_load_acquire(&ext->oe_state) == state); } - if (ext->oe_rc < 0) - rc = ext->oe_rc; - else - rc = 0; - return rc; + return ext->oe_rc < 0 ? ext->oe_rc : 0; } /** 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: 10753471 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 7DBFB17D2 for ; Wed, 9 Jan 2019 06:26:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF3328E17 for ; Wed, 9 Jan 2019 06:26:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60BF628E1A; Wed, 9 Jan 2019 06:26:22 +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 18ED828E17 for ; Wed, 9 Jan 2019 06:26:22 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E241421EBD2; Tue, 8 Jan 2019 22:26:20 -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 08F0A200DB0 for ; Tue, 8 Jan 2019 22:26:17 -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 0B1E9AF0B; Wed, 9 Jan 2019 06:26:17 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:01 +1100 Message-ID: <154701504186.26726.10969814573194089501.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 13/29] lustre: osc_cache: change osc_enter_cache_try to return bool. 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 'bool' is the natural type for this, so make that obvious. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 26 +++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 5a295799f177..e9987c187ecd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1533,17 +1533,14 @@ static void osc_exit_cache(struct client_obd *cli, struct osc_async_page *oap) * Non-blocking version of osc_enter_cache() that consumes grant only when it * is available. */ -static int osc_enter_cache_try(struct client_obd *cli, - struct osc_async_page *oap, - int bytes, int transient) +static bool osc_enter_cache_try(struct client_obd *cli, + struct osc_async_page *oap, + int bytes, int transient) { - int rc; - OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes); - rc = osc_reserve_grant(cli, bytes); - if (rc < 0) - return 0; + if (osc_reserve_grant(cli, bytes) < 0) + return false; if (cli->cl_dirty_pages < cli->cl_dirty_max_pages && atomic_long_read(&obd_dirty_pages) + 1 <= obd_max_dirty_pages) { @@ -1553,12 +1550,11 @@ static int osc_enter_cache_try(struct client_obd *cli, atomic_long_inc(&obd_dirty_transit_pages); oap->oap_brw_flags |= OBD_BRW_NOCACHE; } - rc = 1; + return true; } else { __osc_unreserve_grant(cli, bytes, bytes); - rc = 0; + return false; } - return rc; } static int ocw_granted(struct client_obd *cli, struct osc_cache_waiter *ocw) @@ -2457,12 +2453,12 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* it doesn't need any grant to dirty this page */ spin_lock(&cli->cl_loi_list_lock); - rc = osc_enter_cache_try(cli, oap, grants, 0); - spin_unlock(&cli->cl_loi_list_lock); - if (rc == 0) { /* try failed */ + if (!osc_enter_cache_try(cli, oap, grants, 0)) { grants = 0; need_release = 1; - } else if (ext->oe_end < index) { + } + spin_unlock(&cli->cl_loi_list_lock); + if (!need_release && ext->oe_end < index) { tmp = grants; /* try to expand this extent */ rc = osc_extent_expand(ext, index, &tmp); From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753473 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 D72D017E1 for ; Wed, 9 Jan 2019 06:26:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C8F28E17 for ; Wed, 9 Jan 2019 06:26:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B13B328E1A; Wed, 9 Jan 2019 06:26:43 +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 0921428E17 for ; Wed, 9 Jan 2019 06:26:43 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A6B2B21F596; Tue, 8 Jan 2019 22:26:25 -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 D946921F45C for ; Tue, 8 Jan 2019 22:26:23 -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 E4047AF0B; Wed, 9 Jan 2019 06:26:22 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504196.26726.10177553592840024331.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 14/29] lustre: osc_cache: convert cl_cache_waiters to a wait_queue. 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 cli->cl_cache_waiters is a list of tasks that need to be woken when grant-space becomes available. This means it is acting much like a wait queue. So let's change it to really be a wait queue. The current implementation adds new waiters to the end of the list, and calls osc_enter_cache_try() on each in order. We can provide the same behaviour by using an exclusive wait, and having each waiter wake the next task when it succeeds. If a waiter notices that success has become impossible, it wakes all other waiters. If a waiter times out, it doesn't wake other - just leaves them to time out themselves. Note that the old code handled -EINTR from the wait function. That is not a possible return value when wait_event_idle* is used, so that case is discarded. For all this to work, we need a wait_event_idle_exclusive_timeout_cmd() macro. This fits the pattern of other macros in wait.h, and can be moved to wait.h when this code lands in mainline. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 2 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 drivers/staging/lustre/lustre/osc/osc_cache.c | 145 ++++++++-------------- drivers/staging/lustre/lustre/osc/osc_internal.h | 12 +- drivers/staging/lustre/lustre/osc/osc_page.c | 2 5 files changed, 57 insertions(+), 106 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index d6a968ceb274..bb6f3e1fce6e 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -209,7 +209,7 @@ struct client_obd { * See osc_{reserve|unreserve}_grant for details. */ long cl_reserved_grant; - struct list_head cl_cache_waiters; /* waiting for cache/grant */ + wait_queue_head_t cl_cache_waiters; /* waiting for cache/grant */ unsigned long cl_next_shrink_grant; /* jiffies */ struct list_head cl_grant_shrink_list; /* Timeout event list */ int cl_grant_shrink_interval; /* seconds */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 732ef3a64c72..609b9d04eb40 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -323,7 +323,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) * ptlrpc_connect_interpret(). */ client_adjust_max_dirty(cli); - INIT_LIST_HEAD(&cli->cl_cache_waiters); + init_waitqueue_head(&cli->cl_cache_waiters); INIT_LIST_HEAD(&cli->cl_loi_ready_list); INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list); INIT_LIST_HEAD(&cli->cl_loi_write_list); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index e9987c187ecd..ddfb61502f30 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1557,15 +1557,22 @@ static bool osc_enter_cache_try(struct client_obd *cli, } } -static int ocw_granted(struct client_obd *cli, struct osc_cache_waiter *ocw) -{ - int rc; - - spin_lock(&cli->cl_loi_list_lock); - rc = list_empty(&ocw->ocw_entry); - spin_unlock(&cli->cl_loi_list_lock); - return rc; -} +#define __wait_event_idle_exclusive_timeout_cmd(wq_head, condition, \ + timeout, cmd1, cmd2) \ + ___wait_event(wq_head, ___wait_cond_timeout(condition), \ + TASK_IDLE, 1, timeout, \ + cmd1; __ret = schedule_timeout(__ret); cmd2) + +#define wait_event_idle_exclusive_timeout_cmd(wq_head, condition, timeout,\ + cmd1, cmd2) \ +({ \ + long __ret = timeout; \ + might_sleep(); \ + if (!___wait_cond_timeout(condition)) \ + __ret = __wait_event_idle_exclusive_timeout_cmd( \ + wq_head, condition, timeout, cmd1, cmd2); \ + __ret; \ +}) /** * The main entry to reserve dirty page accounting. Usually the grant reserved @@ -1579,9 +1586,10 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, { struct osc_object *osc = oap->oap_obj; struct lov_oinfo *loi = osc->oo_oinfo; - struct osc_cache_waiter ocw; unsigned long timeout = (AT_OFF ? obd_timeout : at_max) * HZ; int rc = -EDQUOT; + int remain; + bool entered = false; OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes); @@ -1598,107 +1606,54 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, goto out; } - /* Hopefully normal case - cache space and write credits available */ - if (osc_enter_cache_try(cli, oap, bytes, 0)) { - OSC_DUMP_GRANT(D_CACHE, cli, "granted from cache\n"); - rc = 0; - goto out; - } - - /* We can get here for two reasons: too many dirty pages in cache, or + /* + * We can wait here for two reasons: too many dirty pages in cache, or * run out of grants. In both cases we should write dirty pages out. * Adding a cache waiter will trigger urgent write-out no matter what * RPC size will be. - * The exiting condition is no avail grants and no dirty pages caching, - * that really means there is no space on the OST. + * The exiting condition (other then success) is no avail grants + * and no dirty pages caching, that really means there is no space + * on the OST. */ - init_waitqueue_head(&ocw.ocw_waitq); - ocw.ocw_oap = oap; - ocw.ocw_grant = bytes; - while (cli->cl_dirty_pages > 0 || cli->cl_w_in_flight > 0) { - list_add_tail(&ocw.ocw_entry, &cli->cl_cache_waiters); - ocw.ocw_rc = 0; - spin_unlock(&cli->cl_loi_list_lock); + remain = wait_event_idle_exclusive_timeout_cmd( + cli->cl_cache_waiters, + (entered = osc_enter_cache_try( + cli, oap, bytes, 0)) || + (cli->cl_dirty_pages == 0 && + cli->cl_w_in_flight == 0), + timeout, + spin_unlock(&cli->cl_loi_list_lock); osc_io_unplug_async(env, cli, NULL); - - CDEBUG(D_CACHE, "%s: sleeping for cache space @ %p for %p\n", - cli_name(cli), &ocw, oap); - - rc = wait_event_idle_timeout(ocw.ocw_waitq, - ocw_granted(cli, &ocw), timeout); - - spin_lock(&cli->cl_loi_list_lock); - - if (rc == 0) { - /* wait_event is interrupted by signal, or timed out */ - list_del_init(&ocw.ocw_entry); - rc = -ETIMEDOUT; - break; - } - LASSERT(list_empty(&ocw.ocw_entry)); - rc = ocw.ocw_rc; - - if (rc != -EDQUOT) - break; - if (osc_enter_cache_try(cli, oap, bytes, 0)) { - rc = 0; - break; - } - } - - switch (rc) { - case 0: - OSC_DUMP_GRANT(D_CACHE, cli, "finally got grant space\n"); - break; - case -ETIMEDOUT: + CDEBUG(D_CACHE, + "%s: sleeping for cache space for %p\n", + cli_name(cli), oap); + , + spin_lock(&cli->cl_loi_list_lock)); + + if (entered) { + if (remain == timeout) + OSC_DUMP_GRANT(D_CACHE, cli, "granted from cache\n"); + else + OSC_DUMP_GRANT(D_CACHE, cli, + "finally got grant space\n"); + wake_up(&cli->cl_cache_waiters); + rc = 0; + } else if (remain == 0) { OSC_DUMP_GRANT(D_CACHE, cli, "timeout, fall back to sync i/o\n"); osc_extent_tree_dump(D_CACHE, osc); /* fall back to synchronous I/O */ - rc = -EDQUOT; - break; - case -EINTR: - /* Ensures restartability - LU-3581 */ - OSC_DUMP_GRANT(D_CACHE, cli, "interrupted\n"); - rc = -ERESTARTSYS; - break; - case -EDQUOT: + } else { OSC_DUMP_GRANT(D_CACHE, cli, "no grant space, fall back to sync i/o\n"); - break; - default: - CDEBUG(D_CACHE, "%s: event for cache space @ %p never arrived due to %d, fall back to sync i/o\n", - cli_name(cli), &ocw, rc); - break; + wake_up_all(&cli->cl_cache_waiters); } out: spin_unlock(&cli->cl_loi_list_lock); return rc; } -/* caller must hold loi_list_lock */ -void osc_wake_cache_waiters(struct client_obd *cli) -{ - struct osc_cache_waiter *ocw; - - while ((ocw = list_first_entry_or_null(&cli->cl_cache_waiters, - struct osc_cache_waiter, - ocw_entry))) { - list_del_init(&ocw->ocw_entry); - - if (osc_enter_cache_try(cli, ocw->ocw_oap, ocw->ocw_grant, 0)) - ocw->ocw_rc = 0; - else - ocw->ocw_rc = -EDQUOT; - - CDEBUG(D_CACHE, "wake up %p for oap %p, avail grant %ld, %d\n", - ocw, ocw->ocw_oap, cli->cl_avail_grant, ocw->ocw_rc); - - wake_up(&ocw->ocw_waitq); - } -} - static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) { int hprpc = !!list_empty(&osc->oo_hp_exts); @@ -1742,7 +1697,7 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, * waiting for space. as they're waiting, they're not going to * create more pages to coalesce with what's waiting.. */ - if (!list_empty(&cli->cl_cache_waiters)) { + if (waitqueue_active(&cli->cl_cache_waiters)) { CDEBUG(D_CACHE, "cache waiters forcing RPC\n"); return 1; } @@ -2219,7 +2174,7 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) * have filled up the cache and not been fired into rpcs because * they don't pass the nr_pending/object threshold */ - if (!list_empty(&cli->cl_cache_waiters) && + if (waitqueue_active(&cli->cl_cache_waiters) && !list_empty(&cli->cl_loi_write_list)) return list_to_obj(&cli->cl_loi_write_list, write_item); diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 0de8a3ee826d..0354272fe192 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -87,15 +87,11 @@ static inline struct osc_async_page *brw_page2oap(struct brw_page *pga) return container_of(pga, struct osc_async_page, oap_brw_page); } -struct osc_cache_waiter { - struct list_head ocw_entry; - wait_queue_head_t ocw_waitq; - struct osc_async_page *ocw_oap; - int ocw_grant; - int ocw_rc; -}; +static inline void osc_wake_cache_waiters(struct client_obd *cli) +{ + wake_up(&cli->cl_cache_waiters); +} -void osc_wake_cache_waiters(struct client_obd *cli); int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes); void osc_update_next_shrink(struct client_obd *cli); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index ada1eda24614..28b12729d7e9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -155,7 +155,7 @@ static int osc_page_print(const struct lu_env *env, cli->cl_r_in_flight, cli->cl_w_in_flight, cli->cl_max_rpcs_in_flight, cli->cl_avail_grant, - osc_list(&cli->cl_cache_waiters), + waitqueue_active(&cli->cl_cache_waiters) ? "+" : "-", osc_list(&cli->cl_loi_ready_list), osc_list(&cli->cl_loi_hp_ready_list), osc_list(&cli->cl_loi_write_list), From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753475 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 404116C2 for ; Wed, 9 Jan 2019 06:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D66928E17 for ; Wed, 9 Jan 2019 06:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2146E28E1A; Wed, 9 Jan 2019 06:26:52 +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.3 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,URG_BIZ 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 CA85D28E17 for ; Wed, 9 Jan 2019 06:26:51 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id EA73121FD40; Tue, 8 Jan 2019 22:26:31 -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 C830421FBA4 for ; Tue, 8 Jan 2019 22:26:29 -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 09BD2AF0B; Wed, 9 Jan 2019 06:26:29 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504202.26726.9471170836147674405.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 15/29] lustre: osc_cache: change osc_make_rpc() to return bool. 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 'bool' more accurately reflects the nature of this function. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 28 +++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index ddfb61502f30..9b78562d3366 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1665,10 +1665,10 @@ static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) * (lop). This is used by osc_check_rpcs->osc_next_obj() and osc_list_maint() * to quickly find objects that are ready to send an RPC. */ -static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, - int cmd) +static bool osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, + int cmd) { - int invalid_import = 0; + bool invalid_import = false; /* if we have an invalid import we want to drain the queued pages * by forcing them through rpcs that immediately fail and complete @@ -1676,22 +1676,22 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, * before canceling the locks and evicting down the llite pages */ if (!cli->cl_import || cli->cl_import->imp_invalid) - invalid_import = 1; + invalid_import = true; if (cmd & OBD_BRW_WRITE) { if (atomic_read(&osc->oo_nr_writes) == 0) - return 0; + return false; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - return 1; + return true; } if (!list_empty(&osc->oo_hp_exts)) { CDEBUG(D_CACHE, "high prio request forcing RPC\n"); - return 1; + return true; } if (!list_empty(&osc->oo_urgent_exts)) { CDEBUG(D_CACHE, "urgent request forcing RPC\n"); - return 1; + return true; } /* trigger a write rpc stream as long as there are dirtiers * waiting for space. as they're waiting, they're not going to @@ -1699,25 +1699,25 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, */ if (waitqueue_active(&cli->cl_cache_waiters)) { CDEBUG(D_CACHE, "cache waiters forcing RPC\n"); - return 1; + return true; } if (!list_empty(&osc->oo_full_exts)) { CDEBUG(D_CACHE, "full extent ready, make an RPC\n"); - return 1; + return true; } } else { if (atomic_read(&osc->oo_nr_reads) == 0) - return 0; + return false; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - return 1; + return true; } /* all read are urgent. */ if (!list_empty(&osc->oo_reading_exts)) - return 1; + return true; } - return 0; + return false; } static void osc_update_pending(struct osc_object *obj, int cmd, int delta) From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753477 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 3C8876C2 for ; Wed, 9 Jan 2019 06:26:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B38328E17 for ; Wed, 9 Jan 2019 06:26:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E9F528E1A; Wed, 9 Jan 2019 06:26:57 +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 D1B1528E17 for ; Wed, 9 Jan 2019 06:26:56 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 63569681E65; Tue, 8 Jan 2019 22:26:37 -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 9F8B9681E44 for ; Tue, 8 Jan 2019 22:26:35 -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 C38A9AF0B; Wed, 9 Jan 2019 06:26:34 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504207.26726.261002093793293176.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 16/29] lustre: osc_cache: use osc_makes_hprpc() more consistently. 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 We have a function "osc_makes_hprpc()", and a few places that could use it, but instead open-code the content. Move the function earlier, and use it more broadly. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 9b78562d3366..d2d5867156ad 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1654,9 +1654,14 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, return rc; } +static int osc_makes_hprpc(struct osc_object *obj) +{ + return !list_empty(&obj->oo_hp_exts); +} + static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) { - int hprpc = !!list_empty(&osc->oo_hp_exts); + int hprpc = !osc_makes_hprpc(osc); return rpcs_in_flight(cli) >= cli->cl_max_rpcs_in_flight + hprpc; } @@ -1685,7 +1690,7 @@ static bool osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, CDEBUG(D_CACHE, "invalid import forcing RPC\n"); return true; } - if (!list_empty(&osc->oo_hp_exts)) { + if (osc_makes_hprpc(osc)) { CDEBUG(D_CACHE, "high prio request forcing RPC\n"); return true; } @@ -1736,11 +1741,6 @@ static void osc_update_pending(struct osc_object *obj, int cmd, int delta) OSC_IO_DEBUG(obj, "update pending cmd %d delta %d.\n", cmd, delta); } -static int osc_makes_hprpc(struct osc_object *obj) -{ - return !list_empty(&obj->oo_hp_exts); -} - static void on_list(struct list_head *item, struct list_head *list, int should_be_on) { if (list_empty(item) && should_be_on) From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753479 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 C684417D2 for ; Wed, 9 Jan 2019 06:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B564C28E17 for ; Wed, 9 Jan 2019 06:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A989828E1A; Wed, 9 Jan 2019 06:27:00 +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 6416928E17 for ; Wed, 9 Jan 2019 06:27:00 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5ABE3681F0D; Tue, 8 Jan 2019 22:26:42 -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 7635E21F3AC for ; Tue, 8 Jan 2019 22:26:41 -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 A6DCCAF0B; Wed, 9 Jan 2019 06:26:40 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504211.26726.81439906958866826.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 17/29] lustre: osc_cache: simplify list walk in get_write_extents(). 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 This iteration is exactly what list_first_entry_or_null() is for. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index d2d5867156ad..14e6efb4b80b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1982,9 +1982,9 @@ static unsigned int get_write_extents(struct osc_object *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); + while ((ext = list_first_entry_or_null(&obj->oo_hp_exts, + struct osc_extent, + oe_link))) { LASSERT(ext->oe_state == OES_CACHE); if (!try_to_add_extent_for_io(cli, ext, &data)) return data.erd_page_count; From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753481 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 78A6317D2 for ; Wed, 9 Jan 2019 06:27:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67BFE28E17 for ; Wed, 9 Jan 2019 06:27:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C0CE28E1A; Wed, 9 Jan 2019 06:27:04 +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 1D5FF28E17 for ; Wed, 9 Jan 2019 06:27:04 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3A37B682047; Tue, 8 Jan 2019 22:26:49 -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 7601121F596 for ; Tue, 8 Jan 2019 22:26:47 -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 92AA9AF0B; Wed, 9 Jan 2019 06:26:46 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504226.26726.13771066469284363266.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 18/29] lustre: osc_cache: avoid unnecessary tests. 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 These tests (have we reached page limit) are not necessary, as the next call to try_to_add_extent_for_io() will perform the same test, and fail if necessary. Having the tests don't add any clarity to the code, and are unlikely to help performance as they are likely to fail more often than they succeed. So discard them. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 14e6efb4b80b..5666f384ac6c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1990,8 +1990,6 @@ static unsigned int get_write_extents(struct osc_object *obj, return data.erd_page_count; EASSERT(ext->oe_nr_pages <= data.erd_max_pages, ext); } - if (data.erd_page_count == data.erd_max_pages) - return data.erd_page_count; while (!list_empty(&obj->oo_urgent_exts)) { ext = list_entry(obj->oo_urgent_exts.next, @@ -1999,8 +1997,6 @@ static unsigned int get_write_extents(struct osc_object *obj, if (!try_to_add_extent_for_io(cli, ext, &data)) return data.erd_page_count; } - if (data.erd_page_count == data.erd_max_pages) - return data.erd_page_count; /* * One key difference between full extents and other extents: full @@ -2015,8 +2011,6 @@ static unsigned int get_write_extents(struct osc_object *obj, if (!try_to_add_extent_for_io(cli, ext, &data)) break; } - if (data.erd_page_count == data.erd_max_pages) - return data.erd_page_count; ext = first_extent(obj); while (ext) { From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753483 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 6A4166C2 for ; Wed, 9 Jan 2019 06:27:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58DD228E17 for ; Wed, 9 Jan 2019 06:27:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D2A128E1A; Wed, 9 Jan 2019 06:27:07 +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 1331728E17 for ; Wed, 9 Jan 2019 06:27:07 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 317276820B0; Tue, 8 Jan 2019 22:26:55 -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 BCE65682096 for ; Tue, 8 Jan 2019 22:26:53 -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 DC361AF0B; Wed, 9 Jan 2019 06:26:52 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504232.26726.5168102908572630267.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 19/29] lustre: osc_cache: convert while to for in get_write_extents() 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 This 'while' loop is really a 'for' loop in disguise. So change it to 'for'. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 5666f384ac6c..db28cc4d5ae8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2012,19 +2012,16 @@ static unsigned int get_write_extents(struct osc_object *obj, break; } - ext = first_extent(obj); - while (ext) { + for (ext = first_extent(obj); + ext; + ext = next_extent(ext)) { if ((ext->oe_state != OES_CACHE) || /* this extent may be already in current rpclist */ - (!list_empty(&ext->oe_link) && ext->oe_owner)) { - ext = next_extent(ext); + (!list_empty(&ext->oe_link) && ext->oe_owner)) continue; - } if (!try_to_add_extent_for_io(cli, ext, &data)) return data.erd_page_count; - - ext = next_extent(ext); } return data.erd_page_count; } From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753485 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 BE65417D2 for ; Wed, 9 Jan 2019 06:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA3128E17 for ; Wed, 9 Jan 2019 06:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A02D628E1A; Wed, 9 Jan 2019 06:27:10 +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 3AE2C28E17 for ; Wed, 9 Jan 2019 06:27:10 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A4279681E65; Tue, 8 Jan 2019 22:27:01 -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 ABBC9681E2D for ; Tue, 8 Jan 2019 22:26:59 -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 D543AAF0B; Wed, 9 Jan 2019 06:26:58 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504236.26726.14318399777937714593.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 20/29] lustre: osc_cache: don't drop a lock we didn't take. 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 Dropping a lock in a function which didn't take the lock is best avoided as it makes it difficult to understand the code. Sometimes it is unavoidable, but not in this case. There is very little code in the (only) calling function which is also locked, so we can move that code into the called function, and then just take the lock inside the called function - the same function which drops it. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 78 ++++++++++++------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index db28cc4d5ae8..863884cac028 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2029,7 +2029,6 @@ static unsigned int get_write_extents(struct osc_object *obj, static int osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, struct osc_object *osc) - __must_hold(osc) { LIST_HEAD(rpclist); struct osc_extent *ext; @@ -2039,13 +2038,16 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, int srvlock = 0; int rc = 0; - assert_osc_object_is_locked(osc); + osc_object_lock(osc); + if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) + page_count = get_write_extents(osc, &rpclist); - page_count = get_write_extents(osc, &rpclist); LASSERT(equi(page_count == 0, list_empty(&rpclist))); - if (list_empty(&rpclist)) + if (list_empty(&rpclist)) { + osc_object_unlock(osc); return 0; + } osc_update_pending(osc, OBD_BRW_WRITE, -page_count); @@ -2086,7 +2088,6 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, LASSERT(list_empty(&rpclist)); } - osc_object_lock(osc); return rc; } @@ -2103,7 +2104,6 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, static int osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, struct osc_object *osc) - __must_hold(osc) { struct osc_extent *ext; struct osc_extent *next; @@ -2117,7 +2117,12 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, }; int rc = 0; - assert_osc_object_is_locked(osc); + osc_object_lock(osc); + if (!osc_makes_rpc(cli, osc, OBD_BRW_READ)) { + osc_object_unlock(osc); + return rc; + } + 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)) @@ -2129,13 +2134,12 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, osc_update_pending(osc, OBD_BRW_READ, -data.erd_page_count); + osc_object_unlock(osc); if (!list_empty(&rpclist)) { - osc_object_unlock(osc); rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ); LASSERT(list_empty(&rpclist)); - osc_object_lock(osc); } return rc; } @@ -2210,38 +2214,32 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) * partial read pending queue when we're given this object to * do io on writes while there are cache waiters */ - osc_object_lock(osc); - if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) { - rc = osc_send_write_rpc(env, cli, osc); - if (rc < 0) { - CERROR("Write request failed with %d\n", rc); - - /* osc_send_write_rpc failed, mostly because of - * memory pressure. - * - * It can't break here, because if: - * - a page was submitted by osc_io_submit, so - * page locked; - * - no request in flight - * - no subsequent request - * The system will be in live-lock state, - * because there is no chance to call - * osc_io_unplug() and osc_check_rpcs() any - * more. pdflush can't help in this case, - * because it might be blocked at grabbing - * the page lock as we mentioned. - * - * Anyway, continue to drain pages. - */ - /* break; */ - } - } - if (osc_makes_rpc(cli, osc, OBD_BRW_READ)) { - rc = osc_send_read_rpc(env, cli, osc); - if (rc < 0) - CERROR("Read request failed with %d\n", rc); + rc = osc_send_write_rpc(env, cli, osc); + if (rc < 0) { + CERROR("Write request failed with %d\n", rc); + + /* osc_send_write_rpc failed, mostly because of + * memory pressure. + * + * It can't break here, because if: + * - a page was submitted by osc_io_submit, so + * page locked; + * - no request in flight + * - no subsequent request + * The system will be in live-lock state, + * because there is no chance to call + * osc_io_unplug() and osc_check_rpcs() any + * more. pdflush can't help in this case, + * because it might be blocked at grabbing + * the page lock as we mentioned. + * + * Anyway, continue to drain pages. + */ + /* break; */ } - osc_object_unlock(osc); + rc = osc_send_read_rpc(env, cli, osc); + if (rc < 0) + CERROR("Read request failed with %d\n", rc); osc_list_maint(cli, osc); lu_object_ref_del_at(&obj->co_lu, &link, "check", current); From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753487 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 ADD9E17D2 for ; Wed, 9 Jan 2019 06:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C6B628E17 for ; Wed, 9 Jan 2019 06:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 910EA28E1A; Wed, 9 Jan 2019 06:27:13 +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 4CA4028E17 for ; Wed, 9 Jan 2019 06:27:13 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DBBC1681F33; Tue, 8 Jan 2019 22:27:08 -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 E999421F24D for ; Tue, 8 Jan 2019 22:27:06 -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 EAEC8AF0B; Wed, 9 Jan 2019 06:27:05 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504241.26726.16825256312797481549.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 21/29] lustre: osc_cache: don't drop a lock we didn't take - two 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 osc_check_rpcs() drops a lock that it was called with, which can make it harder to understand the code. It is only called from one place, and that places takes the lock just to all this function. So instead, take the lock at the start of the function, and drop it at the end. This makes the code easier to follow. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 863884cac028..b2ad6a15014e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2187,11 +2187,11 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) /* called with the loi list lock held */ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) - __must_hold(&cli->cl_loi_list_lock) { struct osc_object *osc; int rc = 0; + spin_lock(&cli->cl_loi_list_lock); while ((osc = osc_next_obj(cli)) != NULL) { struct cl_object *obj = osc2cl(osc); struct lu_ref_link link; @@ -2247,6 +2247,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) spin_lock(&cli->cl_loi_list_lock); } + spin_unlock(&cli->cl_loi_list_lock); } static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, @@ -2258,9 +2259,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, return 0; if (!async) { - spin_lock(&cli->cl_loi_list_lock); osc_check_rpcs(env, cli); - spin_unlock(&cli->cl_loi_list_lock); } else { CDEBUG(D_CACHE, "Queue writeback work for client %p.\n", cli); LASSERT(cli->cl_writeback_work); From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753489 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 9CF4F6C2 for ; Wed, 9 Jan 2019 06:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C20B28E17 for ; Wed, 9 Jan 2019 06:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80B1828E1A; Wed, 9 Jan 2019 06:27:16 +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 4552028E17 for ; Wed, 9 Jan 2019 06:27:16 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 415876820FA; Tue, 8 Jan 2019 22:27: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 A50AC6820B0 for ; Tue, 8 Jan 2019 22:27:11 -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 D08E5AF0B; Wed, 9 Jan 2019 06:27:10 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504248.26726.14014358069894794630.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 22/29] lustre: osc_cache: osc_prep_async_page() has meaningless return 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 osc_prep_async_page() is only called by osc_page_init(), which immediately returns any non-zero return value. osc_page_init is a ->coo_page_init() function, only called by cl_page_alloc(), which treats any non-zero return as a negative error number. So osc_prep_async_page() must return 0 or a negative error. Currently it can return cfs_size_round(sizeof(*oap)) which is either of those. Presumably this condition never happens, so the return value is irrelevant. We could make it an LASSERT(), but it is safer to just return an generic error. So make it return -EIO; Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b2ad6a15014e..8a68d3eb9314 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2287,7 +2287,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, struct osc_async_page *oap = &ops->ops_oap; if (!page) - return cfs_size_round(sizeof(*oap)); + return -EIO; oap->oap_magic = OAP_MAGIC; oap->oap_cli = &exp->exp_obd->u.cli; From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753491 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 A94A06C2 for ; Wed, 9 Jan 2019 06:27:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 946FD28E17 for ; Wed, 9 Jan 2019 06:27:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85C3F28E1A; Wed, 9 Jan 2019 06:27:20 +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 41FBC28E17 for ; Wed, 9 Jan 2019 06:27:20 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id F094E21F3A4; Tue, 8 Jan 2019 22:27:19 -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 992A1681D44 for ; Tue, 8 Jan 2019 22:27:17 -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 BDCCBAF0B; Wed, 9 Jan 2019 06:27:16 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504254.26726.7702205638412400024.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 23/29] lustre: osc_cache: remove 'transient' arg from osc_enter_cache_try 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 This arg is always '0', so remove it. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Reviewed-by: Andreas Dilger Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 8a68d3eb9314..b4bb36926046 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1535,7 +1535,7 @@ static void osc_exit_cache(struct client_obd *cli, struct osc_async_page *oap) */ static bool osc_enter_cache_try(struct client_obd *cli, struct osc_async_page *oap, - int bytes, int transient) + int bytes) { OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes); @@ -1545,11 +1545,6 @@ static bool osc_enter_cache_try(struct client_obd *cli, if (cli->cl_dirty_pages < cli->cl_dirty_max_pages && atomic_long_read(&obd_dirty_pages) + 1 <= obd_max_dirty_pages) { osc_consume_write_grant(cli, &oap->oap_brw_page); - if (transient) { - cli->cl_dirty_transit++; - atomic_long_inc(&obd_dirty_transit_pages); - oap->oap_brw_flags |= OBD_BRW_NOCACHE; - } return true; } else { __osc_unreserve_grant(cli, bytes, bytes); @@ -1618,7 +1613,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, remain = wait_event_idle_exclusive_timeout_cmd( cli->cl_cache_waiters, (entered = osc_enter_cache_try( - cli, oap, bytes, 0)) || + cli, oap, bytes)) || (cli->cl_dirty_pages == 0 && cli->cl_w_in_flight == 0), timeout, @@ -2396,7 +2391,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* it doesn't need any grant to dirty this page */ spin_lock(&cli->cl_loi_list_lock); - if (!osc_enter_cache_try(cli, oap, grants, 0)) { + if (!osc_enter_cache_try(cli, oap, grants)) { grants = 0; need_release = 1; } From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753493 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 C90BC17D2 for ; Wed, 9 Jan 2019 06:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B816228E17 for ; Wed, 9 Jan 2019 06:27:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABDA428E1A; Wed, 9 Jan 2019 06:27:25 +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 AFA5228E17 for ; Wed, 9 Jan 2019 06:27:24 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 735FA2006E1; Tue, 8 Jan 2019 22:27:24 -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 81D4021F9AE for ; Tue, 8 Jan 2019 22:27:23 -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 BB131AF0F; Wed, 9 Jan 2019 06:27:22 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504259.26726.10938592737685333082.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 24/29] lustre: osc_cache: change need_release to bool 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 This variable is used like a bool, so declare it as one. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/osc/osc_cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b4bb36926046..1476f84e6156 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2316,7 +2316,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, unsigned int grants = 0, tmp; int brw_flags = OBD_BRW_ASYNC; int cmd = OBD_BRW_WRITE; - int need_release = 0; + bool need_release = false; int rc = 0; if (oap->oap_magic != OAP_MAGIC) @@ -2393,7 +2393,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, spin_lock(&cli->cl_loi_list_lock); if (!osc_enter_cache_try(cli, oap, grants)) { grants = 0; - need_release = 1; + need_release = true; } spin_unlock(&cli->cl_loi_list_lock); if (!need_release && ext->oe_end < index) { @@ -2401,7 +2401,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* try to expand this extent */ rc = osc_extent_expand(ext, index, &tmp); if (rc < 0) { - need_release = 1; + need_release = true; /* don't free reserved grant */ } else { OSC_EXTENT_DUMP(D_CACHE, ext, @@ -2413,7 +2413,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, rc = 0; } else if (ext) { /* index is located outside of active extent */ - need_release = 1; + need_release = true; } if (need_release) { osc_extent_release(env, ext); From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753495 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 528D017D2 for ; Wed, 9 Jan 2019 06:27:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F75B28E17 for ; Wed, 9 Jan 2019 06:27:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3418D28E1A; Wed, 9 Jan 2019 06:27:33 +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 6E1AC28E17 for ; Wed, 9 Jan 2019 06:27:32 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1B2A1682271; Tue, 8 Jan 2019 22:27:32 -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 6645821F3A4 for ; Tue, 8 Jan 2019 22:27:29 -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 96D7DAF0B; Wed, 9 Jan 2019 06:27:28 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504264.26726.17608454548660581136.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 25/29] lustre: remove cl_page_cancel() 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 cl_page_cancel() is never used, so remove it and various other things that it is the only user of. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/include/cl_object.h | 18 ----- drivers/staging/lustre/lustre/include/lustre_net.h | 1 drivers/staging/lustre/lustre/obdclass/cl_page.c | 20 ------ drivers/staging/lustre/lustre/osc/osc_cache.c | 67 -------------------- .../staging/lustre/lustre/osc/osc_cl_internal.h | 1 drivers/staging/lustre/lustre/osc/osc_internal.h | 1 drivers/staging/lustre/lustre/osc/osc_page.c | 20 ------ drivers/staging/lustre/lustre/osc/osc_request.c | 9 --- drivers/staging/lustre/lustre/ptlrpc/client.c | 15 +--- 9 files changed, 4 insertions(+), 148 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index a1e07f8b5eda..de5d68879740 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -969,23 +969,6 @@ struct cl_page_operations { void (*cpo_clip)(const struct lu_env *env, const struct cl_page_slice *slice, int from, int to); - /** - * \pre the page was queued for transferring. - * \post page is removed from client's pending list, or -EBUSY - * is returned if it has already been in transferring. - * - * This is one of seldom page operation which is: - * 0. called from top level; - * 1. don't have vmpage locked; - * 2. every layer should synchronize execution of its ->cpo_cancel() - * with completion handlers. Osc uses client obd lock for this - * purpose. Based on there is no vvp_page_cancel and - * lov_page_cancel(), cpo_cancel is defacto protected by client lock. - * - * \see osc_page_cancel(). - */ - int (*cpo_cancel)(const struct lu_env *env, - const struct cl_page_slice *slice); /** * Write out a page by kernel. This is only called by ll_writepage * right now. @@ -2159,7 +2142,6 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, struct cl_page *pg, enum cl_req_type crt); void cl_page_clip(const struct lu_env *env, struct cl_page *pg, int from, int to); -int cl_page_cancel(const struct lu_env *env, struct cl_page *page); int cl_page_flush(const struct lu_env *env, struct cl_io *io, struct cl_page *pg); diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 468a03edefd9..6d328b48a96b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1830,7 +1830,6 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func, void *arg); int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set); int ptlrpc_set_wait(struct ptlrpc_request_set *); -void ptlrpc_mark_interrupted(struct ptlrpc_request *req); void ptlrpc_set_destroy(struct ptlrpc_request_set *); void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 00df94b87606..217a5ebe1691 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -932,26 +932,6 @@ void cl_page_print(const struct lu_env *env, void *cookie, } EXPORT_SYMBOL(cl_page_print); -/** - * Cancel a page which is still in a transfer. - */ -int cl_page_cancel(const struct lu_env *env, struct cl_page *page) -{ - const struct cl_page_slice *slice; - int result = 0; - - list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { - if (slice->cpl_ops->cpo_cancel) - result = (*slice->cpl_ops->cpo_cancel)(env, slice); - if (result != 0) - break; - } - if (result > 0) - result = 0; - - return result; -} - /** * Converts a byte offset within object \a obj into a page index. */ diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 1476f84e6156..79bcaa212339 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1822,7 +1822,6 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, spin_lock(&oap->oap_lock); oap->oap_async_flags = 0; spin_unlock(&oap->oap_lock); - oap->oap_interrupted = 0; if (oap->oap_cmd & OBD_BRW_WRITE && xid > 0) { spin_lock(&cli->cl_loi_list_lock); @@ -2591,72 +2590,6 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, return rc; } -/** - * this is called when a sync waiter receives an interruption. Its job is to - * get the caller woken as soon as possible. If its page hasn't been put in an - * rpc yet it can dequeue immediately. Otherwise it has to mark the rpc as - * desiring interruption which will forcefully complete the rpc once the rpc - * has timed out. - */ -int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) -{ - struct osc_async_page *oap = &ops->ops_oap; - struct osc_object *obj = oap->oap_obj; - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; - struct osc_extent *found = NULL; - struct list_head *plist; - pgoff_t index = osc_index(ops); - int rc = -EBUSY; - int cmd; - - LASSERT(!oap->oap_interrupted); - oap->oap_interrupted = 1; - - /* Find out the caching extent */ - osc_object_lock(obj); - if (oap->oap_cmd & OBD_BRW_WRITE) { - plist = &obj->oo_urgent_exts; - cmd = OBD_BRW_WRITE; - } else { - plist = &obj->oo_reading_exts; - cmd = OBD_BRW_READ; - } - list_for_each_entry(ext, plist, oe_link) { - if (ext->oe_start <= index && ext->oe_end >= index) { - LASSERT(ext->oe_state == OES_LOCK_DONE); - /* For OES_LOCK_DONE state extent, it has already held - * a refcount for RPC. - */ - found = osc_extent_get(ext); - break; - } - } - if (found) { - list_del_init(&found->oe_link); - osc_update_pending(obj, cmd, -found->oe_nr_pages); - osc_object_unlock(obj); - - osc_extent_finish(env, found, 0, -EINTR); - osc_extent_put(env, found); - rc = 0; - } else { - osc_object_unlock(obj); - /* ok, it's been put in an rpc. only one oap gets a request - * reference - */ - if (oap->oap_request) { - ptlrpc_mark_interrupted(oap->oap_request); - ptlrpcd_wake(oap->oap_request); - ptlrpc_req_finished(oap->oap_request); - oap->oap_request = NULL; - } - } - - osc_list_maint(cli, obj); - return rc; -} - int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, struct list_head *list, int cmd, int brw_flags) { diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index b1a1d241cc6c..3af096e0dbdd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -380,7 +380,6 @@ int osc_lvb_print(const struct lu_env *env, void *cookie, void osc_lru_add_batch(struct client_obd *cli, struct list_head *list); void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags); -int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops); int osc_set_async_flags(struct osc_object *obj, struct osc_page *opg, u32 async_flags); int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 0354272fe192..586f0dfe3790 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -60,7 +60,6 @@ enum async_flags { struct osc_async_page { int oap_magic; unsigned short oap_cmd; - unsigned short oap_interrupted:1; struct list_head oap_pending_item; struct list_head oap_rpc_item; diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 28b12729d7e9..e0187fafcc37 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -137,11 +137,10 @@ static int osc_page_print(const struct lu_env *env, struct osc_object *obj = cl2osc(slice->cpl_obj); struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; - return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p %lu: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", + return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p %lu: 1< %#x %d %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", opg, osc_index(opg), /* 1 */ oap->oap_magic, oap->oap_cmd, - oap->oap_interrupted, osc_list(&oap->oap_pending_item), osc_list(&oap->oap_rpc_item), /* 2 */ @@ -216,22 +215,6 @@ static void osc_page_clip(const struct lu_env *env, spin_unlock(&oap->oap_lock); } -static int osc_page_cancel(const struct lu_env *env, - const struct cl_page_slice *slice) -{ - struct osc_page *opg = cl2osc_page(slice); - int rc = 0; - - /* Check if the transferring against this page - * is completed, or not even queued. - */ - if (opg->ops_transfer_pinned) - /* FIXME: may not be interrupted.. */ - rc = osc_cancel_async_page(env, opg); - LASSERT(ergo(rc == 0, opg->ops_transfer_pinned == 0)); - return rc; -} - static int osc_page_flush(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *io) @@ -247,7 +230,6 @@ static const struct cl_page_operations osc_page_ops = { .cpo_print = osc_page_print, .cpo_delete = osc_page_delete, .cpo_clip = osc_page_clip, - .cpo_cancel = osc_page_cancel, .cpo_flush = osc_page_flush }; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index b28fbacbcfbf..ccc491efa982 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1635,10 +1635,6 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, LASSERTF(request == oap->oap_request, "request %p != oap_request %p\n", request, oap->oap_request); - if (oap->oap_interrupted) { - ptlrpc_req_finished(new_req); - return -EINTR; - } } } /* New request takes over pga and oaps from old request. @@ -1879,7 +1875,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int mem_tight = 0; int page_count = 0; bool soft_sync = false; - bool interrupted = false; int grant = 0; int i; int rc; @@ -1937,8 +1932,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, else LASSERT(oap->oap_page_off + oap->oap_count == PAGE_SIZE); - if (oap->oap_interrupted) - interrupted = true; } } @@ -1968,8 +1961,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, req->rq_memalloc = mem_tight != 0; oap->oap_request = ptlrpc_request_addref(req); - if (interrupted && !req->rq_intr) - ptlrpc_mark_interrupted(req); /* Need to update the timestamps after the request is built in case * we race with setattr (locally or in queue at OST). If OST gets diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 8fafc8dc3f57..f90a3eef5daf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -2148,17 +2148,6 @@ void ptlrpc_expired_set(struct ptlrpc_request_set *set) } } -/** - * Sets rq_intr flag in \a req under spinlock. - */ -void ptlrpc_mark_interrupted(struct ptlrpc_request *req) -{ - spin_lock(&req->rq_lock); - req->rq_intr = 1; - spin_unlock(&req->rq_lock); -} -EXPORT_SYMBOL(ptlrpc_mark_interrupted); - /** * Interrupts (sets interrupted flag) all uncompleted requests in * a set \a data. Called when l_wait_event_abortable_timeout receives signal. @@ -2174,7 +2163,9 @@ static void ptlrpc_interrupted_set(struct ptlrpc_request_set *set) req->rq_phase != RQ_PHASE_UNREG_RPC) continue; - ptlrpc_mark_interrupted(req); + spin_lock(&req->rq_lock); + req->rq_intr = 1; + spin_unlock(&req->rq_lock); } } From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753497 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 210476C2 for ; Wed, 9 Jan 2019 06:27:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D72928E17 for ; Wed, 9 Jan 2019 06:27:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0118A28E1A; Wed, 9 Jan 2019 06:27:38 +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 5377928E17 for ; Wed, 9 Jan 2019 06:27:38 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id F3B026822D0; Tue, 8 Jan 2019 22:27:37 -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 7834E681E50 for ; Tue, 8 Jan 2019 22:27:35 -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 905EFAF0B; Wed, 9 Jan 2019 06:27:34 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504269.26726.8061168646539306509.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 26/29] lustre: osc_cache: simplify osc_page_gang_lookup() 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 osc_page_gang_lookup() has 4 values that it can receive from a callback, and that it can return to the caller: CLP_GANG_OKAY, CLP_GANG_RESCHED, CLP_GANG_AGAIN, CLP_GANG_ABORT "AGAIN" is never used. "RESCHED" is not needed as a cond_resched() can safely be called at the point this is returned, rather than returning it. That leaves "OKAY" and "ABORT" which can simply by "true" and "false" boolean values. Internalizing the RESCHED case means the callers don't need to loop themselves. This simplify calling patterns. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Reviewed-by: Andreas Dilger Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 7 ---- drivers/staging/lustre/lustre/osc/osc_cache.c | 40 ++++++++------------ .../staging/lustre/lustre/osc/osc_cl_internal.h | 10 +++-- drivers/staging/lustre/lustre/osc/osc_io.c | 4 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 27 ++++++-------- 5 files changed, 33 insertions(+), 55 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index de5d68879740..57d8fe676995 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2076,14 +2076,7 @@ static inline int cl_object_refc(struct cl_object *clob) /** \defgroup cl_page cl_page * @{ */ -enum { - CLP_GANG_OKAY = 0, - CLP_GANG_RESCHED, - CLP_GANG_AGAIN, - CLP_GANG_ABORT -}; -/* callback of cl_page_gang_lookup() */ struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *obj, pgoff_t idx, struct page *vmpage, enum cl_page_type type); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 79bcaa212339..e01f3815978c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2994,18 +2994,14 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, /** * Returns a list of pages by a given [start, end] of \a obj. * - * \param resched If not NULL, then we give up before hogging CPU for too - * long and set *resched = 1, in that case caller should implement a retry - * logic. - * * Gang tree lookup (radix_tree_gang_lookup()) optimization is absolutely * crucial in the face of [offset, EOF] locks. * * Return at least one page in @queue unless there is no covered page. */ -int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, - struct osc_object *osc, pgoff_t start, pgoff_t end, - osc_page_gang_cbt cb, void *cbdata) +bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, + struct osc_object *osc, pgoff_t start, pgoff_t end, + osc_page_gang_cbt cb, void *cbdata) { struct osc_page *ops; void **pvec; @@ -3013,7 +3009,7 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, unsigned int nr; unsigned int i; unsigned int j; - int res = CLP_GANG_OKAY; + bool res = true; bool tree_lock = true; idx = start; @@ -3059,7 +3055,7 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, for (i = 0; i < j; ++i) { ops = pvec[i]; - if (res == CLP_GANG_OKAY) + if (res) res = (*cb)(env, io, ops, cbdata); page = ops->ops_cl.cpl_page; @@ -3069,10 +3065,10 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, if (nr < OTI_PVEC_SIZE || end_of_region) break; - if (res == CLP_GANG_OKAY && need_resched()) - res = CLP_GANG_RESCHED; - if (res != CLP_GANG_OKAY) + if (!res) break; + if (need_resched()) + cond_resched(); spin_lock(&osc->oo_tree_lock); tree_lock = true; @@ -3085,7 +3081,7 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, /** * Check if page @page is covered by an extra lock or discard it. */ -static int check_and_discard_cb(const struct lu_env *env, struct cl_io *io, +static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io, struct osc_page *ops, void *cbdata) { struct osc_thread_info *info = osc_env_info(env); @@ -3121,10 +3117,10 @@ static int check_and_discard_cb(const struct lu_env *env, struct cl_io *io, } info->oti_next_index = index + 1; - return CLP_GANG_OKAY; + return true; } -static int discard_cb(const struct lu_env *env, struct cl_io *io, +static bool discard_cb(const struct lu_env *env, struct cl_io *io, struct osc_page *ops, void *cbdata) { struct osc_thread_info *info = osc_env_info(env); @@ -3145,7 +3141,7 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, LASSERT(page->cp_state == CPS_FREEING); } - return CLP_GANG_OKAY; + return true; } /** @@ -3162,7 +3158,7 @@ int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc, struct osc_thread_info *info = osc_env_info(env); struct cl_io *io = &info->oti_io; osc_page_gang_cbt cb; - int res; + bool res; int result; io->ci_obj = cl_object_top(osc2cl(osc)); @@ -3174,15 +3170,9 @@ int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc, cb = discard ? discard_cb : check_and_discard_cb; info->oti_fn_index = start; info->oti_next_index = start; - do { - res = osc_page_gang_lookup(env, io, osc, - info->oti_next_index, end, cb, osc); - if (info->oti_next_index > end) - break; - if (res == CLP_GANG_RESCHED) - cond_resched(); - } while (res != CLP_GANG_OKAY); + res = osc_page_gang_lookup(env, io, osc, + info->oti_next_index, end, cb, osc); out: cl_io_fini(env, io); return result; diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 3af096e0dbdd..c0f58f41513f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -660,11 +660,11 @@ void osc_extent_release(const struct lu_env *env, struct osc_extent *ext); int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc, pgoff_t start, pgoff_t end, bool discard_pages); -typedef int (*osc_page_gang_cbt)(const struct lu_env *, struct cl_io *, - struct osc_page *, void *); -int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, - struct osc_object *osc, pgoff_t start, pgoff_t end, - osc_page_gang_cbt cb, void *cbdata); +typedef bool (*osc_page_gang_cbt)(const struct lu_env *, struct cl_io *, + struct osc_page *, void *); +bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, + struct osc_object *osc, pgoff_t start, pgoff_t end, + osc_page_gang_cbt cb, void *cbdata); /* @} osc */ #endif /* OSC_CL_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index dabdf6da8b38..b95e0358d7ff 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -449,7 +449,7 @@ static int osc_async_upcall(void *a, int rc) /** * Checks that there are no pages being written in the extent being truncated. */ -static int trunc_check_cb(const struct lu_env *env, struct cl_io *io, +static bool trunc_check_cb(const struct lu_env *env, struct cl_io *io, struct osc_page *ops, void *cbdata) { struct cl_page *page = ops->ops_cl.cpl_page; @@ -466,7 +466,7 @@ static int trunc_check_cb(const struct lu_env *env, struct cl_io *io, CDEBUG(D_CACHE, "page %p index %lu locked for %d.\n", ops, osc_index(ops), oap->oap_cmd & OBD_BRW_RWMASK); - return CLP_GANG_OKAY; + return true; } static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 4cc813d192d9..1eab61d720e2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -630,18 +630,18 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) return result; } -static int weigh_cb(const struct lu_env *env, struct cl_io *io, - struct osc_page *ops, void *cbdata) +static bool weigh_cb(const struct lu_env *env, struct cl_io *io, + struct osc_page *ops, void *cbdata) { struct cl_page *page = ops->ops_cl.cpl_page; if (cl_page_is_vmlocked(env, page) || PageDirty(page->cp_vmpage) || PageWriteback(page->cp_vmpage) ) - return CLP_GANG_ABORT; + return false; *(pgoff_t *)cbdata = osc_index(ops) + 1; - return CLP_GANG_OKAY; + return true; } static unsigned long osc_lock_weight(const struct lu_env *env, @@ -651,7 +651,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, struct cl_io *io = &osc_env_info(env)->oti_io; struct cl_object *obj = cl_object_top(&oscobj->oo_cl); pgoff_t page_index; - int result; + bool result; io->ci_obj = obj; io->ci_ignore_layout = 1; @@ -660,19 +660,14 @@ static unsigned long osc_lock_weight(const struct lu_env *env, return result; page_index = cl_index(obj, extent->start); - do { - result = osc_page_gang_lookup(env, io, oscobj, - page_index, - cl_index(obj, extent->end), - weigh_cb, (void *)&page_index); - if (result == CLP_GANG_ABORT) - break; - if (result == CLP_GANG_RESCHED) - cond_resched(); - } while (result != CLP_GANG_OKAY); + + result = osc_page_gang_lookup(env, io, oscobj, + page_index, + cl_index(obj, extent->end), + weigh_cb, (void *)&page_index); cl_io_fini(env, io); - return result == CLP_GANG_ABORT ? 1 : 0; + return result ? 1 : 0; } /** From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753499 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 9631C17D2 for ; Wed, 9 Jan 2019 06:27:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83D6728E17 for ; Wed, 9 Jan 2019 06:27:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 785EE28E1A; Wed, 9 Jan 2019 06:27:44 +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 0C8A028E17 for ; Wed, 9 Jan 2019 06:27:44 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id AE99D6823AA; Tue, 8 Jan 2019 22:27:43 -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 4CB526823A2 for ; Tue, 8 Jan 2019 22:27:41 -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 75AFFAF0B; Wed, 9 Jan 2019 06:27:40 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504274.26726.6932313520085605572.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 27/29] lustre: osc_cache: white-space and other checkpatch fixes. 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 Assorted minor checkpatch issues fixed. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Reviewed-by: Andreas Dilger Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_cache.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index e01f3815978c..019854b78277 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -101,7 +101,7 @@ static inline char list_empty_marker(struct list_head *list) #define EXTSTR "[%lu -> %lu/%lu]" #define EXTPARA(ext) (ext)->oe_start, (ext)->oe_end, (ext)->oe_max_end -static const char *oes_strings[] = { +static const char * const oes_strings[] = { "inv", "active", "cache", "locking", "lockdone", "rpc", "trunc", NULL }; #define OSC_EXTENT_DUMP(lvl, extent, fmt, ...) do { \ @@ -668,7 +668,7 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, unsigned int *grants) { struct client_obd *cli = osc_cli(obj); - struct osc_lock *olck; + struct osc_lock *olck; struct cl_lock_descr *descr; struct osc_extent *cur; struct osc_extent *ext; @@ -962,7 +962,6 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, wait_event_idle(ext->oe_waitq, smp_load_acquire(&ext->oe_state) == state); - } return ext->oe_rc < 0 ? ext->oe_rc : 0; } @@ -1020,7 +1019,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, if (index < trunc_index || (index == trunc_index && partial)) { /* accounting how many pages remaining in the chunk - * so that we can calculate grants correctly. */ + * so that we can calculate grants correctly. + */ if (index >> ppc_bits == trunc_chunk) ++pages_in_chunk; continue; @@ -1141,7 +1141,8 @@ static int osc_extent_make_ready(const struct lu_env *env, * the size of file. */ if (!(last->oap_async_flags & ASYNC_COUNT_STABLE)) { - int last_oap_count = osc_refresh_count(env, last, OBD_BRW_WRITE); + int last_oap_count = osc_refresh_count(env, last, + OBD_BRW_WRITE); LASSERT(last_oap_count > 0); LASSERT(last->oap_page_off + last_oap_count <= PAGE_SIZE); @@ -1337,7 +1338,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, int cmd, int rc) { struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = oap2cl_page(oap); + struct cl_page *page = oap2cl_page(oap); enum cl_req_type crt; int srvlock; @@ -1736,7 +1737,8 @@ static void osc_update_pending(struct osc_object *obj, int cmd, int delta) OSC_IO_DEBUG(obj, "update pending cmd %d delta %d.\n", cmd, delta); } -static void on_list(struct list_head *item, struct list_head *list, int should_be_on) +static void on_list(struct list_head *item, struct list_head *list, + int should_be_on) { if (list_empty(item) && should_be_on) list_add_tail(item, list); @@ -1898,7 +1900,8 @@ static int try_to_add_extent_for_io(struct client_obd *cli, oap_pending_item); EASSERT(tmp->oe_owner == current, tmp); if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) { - CDEBUG(D_CACHE, "Do not permit different type of IO in one RPC\n"); + CDEBUG(D_CACHE, + "Do not permit different type of IO in one RPC\n"); return 0; } @@ -2130,10 +2133,8 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, osc_object_unlock(osc); if (!list_empty(&rpclist)) { - rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ); LASSERT(list_empty(&rpclist)); - } return rc; } @@ -3082,7 +3083,7 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, * Check if page @page is covered by an extra lock or discard it. */ static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io, - struct osc_page *ops, void *cbdata) + struct osc_page *ops, void *cbdata) { struct osc_thread_info *info = osc_env_info(env); struct osc_object *osc = cbdata; @@ -3121,7 +3122,7 @@ static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io, } static bool discard_cb(const struct lu_env *env, struct cl_io *io, - struct osc_page *ops, void *cbdata) + struct osc_page *ops, void *cbdata) { struct osc_thread_info *info = osc_env_info(env); struct cl_page *page = ops->ops_cl.cpl_page; From patchwork Wed Jan 9 06:24:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753501 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 A89AC17D2 for ; Wed, 9 Jan 2019 06:27:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962A428E17 for ; Wed, 9 Jan 2019 06:27:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A6DC28E1A; Wed, 9 Jan 2019 06:27:49 +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 C74FF28E17 for ; Wed, 9 Jan 2019 06:27:48 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5EFA36822F3; Tue, 8 Jan 2019 22:27:48 -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 248CA6822CF for ; Tue, 8 Jan 2019 22:27:47 -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 6095DAF0B; Wed, 9 Jan 2019 06:27:46 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:02 +1100 Message-ID: <154701504282.26726.12048576544354457365.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 28/29] lustre: osc_request: assorted white-space and check-patch fixes. 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 Just misc formatting fixes. Some minot code change where an 'else' after 'return' was discarded. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/osc/osc_request.c | 163 +++++++++++++---------- 1 file changed, 89 insertions(+), 74 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index ccc491efa982..c2239c99a7b2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -63,37 +63,37 @@ static unsigned int osc_reqpool_mem_max = 5; module_param(osc_reqpool_mem_max, uint, 0444); struct osc_brw_async_args { - struct obdo *aa_oa; - int aa_requested_nob; - int aa_nio_count; - u32 aa_page_count; - int aa_resends; - struct brw_page **aa_ppga; - struct client_obd *aa_cli; - struct list_head aa_oaps; - struct list_head aa_exts; + struct obdo *aa_oa; + int aa_requested_nob; + int aa_nio_count; + u32 aa_page_count; + int aa_resends; + struct brw_page **aa_ppga; + struct client_obd *aa_cli; + struct list_head aa_oaps; + struct list_head aa_exts; }; struct osc_async_args { - struct obd_info *aa_oi; + struct obd_info *aa_oi; }; struct osc_setattr_args { - struct obdo *sa_oa; - obd_enqueue_update_f sa_upcall; - void *sa_cookie; + struct obdo *sa_oa; + obd_enqueue_update_f sa_upcall; + void *sa_cookie; }; struct osc_fsync_args { struct osc_object *fa_obj; struct obdo *fa_oa; - obd_enqueue_update_f fa_upcall; - void *fa_cookie; + obd_enqueue_update_f fa_upcall; + void *fa_cookie; }; struct osc_ladvise_args { struct obdo *la_oa; - obd_enqueue_update_f la_upcall; + obd_enqueue_update_f la_upcall; void *la_cookie; }; @@ -101,12 +101,12 @@ struct osc_enqueue_args { struct obd_export *oa_exp; enum ldlm_type oa_type; enum ldlm_mode oa_mode; - __u64 *oa_flags; + __u64 *oa_flags; osc_enqueue_upcall_f oa_upcall; - void *oa_cookie; - struct ost_lvb *oa_lvb; + void *oa_cookie; + struct ost_lvb *oa_lvb; struct lustre_handle oa_lockh; - unsigned int oa_agl:1; + unsigned int oa_agl:1; }; static void osc_release_ppga(struct brw_page **ppga, u32 count); @@ -331,8 +331,7 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa, body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, - oa); + lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa); req_ladvise_hdr = req_capsule_client_get(&req->rq_pill, &RMF_OST_LADVISE_HDR); @@ -652,8 +651,8 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, * Wait until the number of on-going destroy RPCs drops * under max_rpc_in_flight */ - rc = l_wait_event_abortable_exclusive(cli->cl_destroy_waitq, - osc_can_send_destroy(cli)); + rc = l_wait_event_abortable_exclusive( + cli->cl_destroy_waitq, osc_can_send_destroy(cli)); if (rc) { ptlrpc_req_finished(req); return rc; @@ -716,7 +715,8 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, * take extent tax into account when asking for more * grant space */ - nrextents = DIV_ROUND_UP(nrpages, cli->cl_max_extent_pages); + nrextents = DIV_ROUND_UP(nrpages, + cli->cl_max_extent_pages); oa->o_undirty += nrextents * cli->cl_grant_extent_tax; } } @@ -930,7 +930,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) if (OCD_HAS_FLAG(ocd, GRANT_PARAM)) cli->cl_avail_grant -= cli->cl_dirty_grant; else - cli->cl_avail_grant -= cli->cl_dirty_pages << PAGE_SHIFT; + cli->cl_avail_grant -= + cli->cl_dirty_pages << PAGE_SHIFT; } if (OCD_HAS_FLAG(ocd, GRANT_PARAM)) { @@ -1181,11 +1182,12 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, */ req->rq_no_retry_einprogress = 1; - desc = ptlrpc_prep_bulk_imp(req, page_count, + desc = ptlrpc_prep_bulk_imp( + req, page_count, cli->cl_import->imp_connect_data.ocd_brw_size >> LNET_MTU_BITS, (opc == OST_WRITE ? PTLRPC_BULK_GET_SOURCE : PTLRPC_BULK_PUT_SINK) | PTLRPC_BULK_BUF_KIOV, OST_BULK_PORTAL, - &ptlrpc_bulk_kiov_pin_ops); + &ptlrpc_bulk_kiov_pin_ops); if (!desc) { rc = -ENOMEM; @@ -1252,7 +1254,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, "want %p - real %p\n", req_capsule_client_get(&req->rq_pill, &RMF_NIOBUF_REMOTE), (void *)(niobuf - niocount)); - osc_announce_cached(cli, &body->oa, opc == OST_WRITE ? requested_nob:0); + osc_announce_cached(cli, &body->oa, + opc == OST_WRITE ? requested_nob : 0); if (resend) { if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) { body->oa.o_valid |= OBD_MD_FLFLAGS; @@ -1436,18 +1439,21 @@ static int check_write_checksum(struct obdo *oa, msg = "changed in transit AND doesn't match the original - likely false positive due to mmap IO (bug 11742)" ; - LCONSOLE_ERROR_MSG(0x132, - "%s: BAD WRITE CHECKSUM: %s: from %s inode " DFID " object " DOSTID " extent [%llu-%llu], original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", - aa->aa_cli->cl_import->imp_obd->obd_name, - msg, libcfs_nid2str(peer->nid), - oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (u64)0, - oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, - oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, - POSTID(&oa->o_oi), aa->aa_ppga[0]->off, - aa->aa_ppga[aa->aa_page_count - 1]->off + - aa->aa_ppga[aa->aa_page_count - 1]->count - 1, - client_cksum, cksum_type_unpack(aa->aa_oa->o_flags), - server_cksum, cksum_type, new_cksum); + LCONSOLE_ERROR_MSG( + 0x132, + "%s: BAD WRITE CHECKSUM: %s: from %s inode " DFID + " object " DOSTID + " extent [%llu-%llu], original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", + aa->aa_cli->cl_import->imp_obd->obd_name, + msg, libcfs_nid2str(peer->nid), + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (u64)0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, + POSTID(&oa->o_oi), aa->aa_ppga[0]->off, + aa->aa_ppga[aa->aa_page_count - 1]->off + + aa->aa_ppga[aa->aa_page_count - 1]->count - 1, + client_cksum, cksum_type_unpack(aa->aa_oa->o_flags), + server_cksum, cksum_type, new_cksum); return 1; } @@ -1480,7 +1486,8 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) unsigned int qid[MAXQUOTAS] = { body->oa.o_uid, body->oa.o_gid, body->oa.o_projid }; - CDEBUG(D_QUOTA, "setdq for [%u %u %u] with valid %#llx, flags %x\n", + CDEBUG(D_QUOTA, + "setdq for [%u %u %u] with valid %#llx, flags %x\n", body->oa.o_uid, body->oa.o_gid, body->oa.o_projid, body->oa.o_valid, body->oa.o_flags); osc_quota_setdq(cli, qid, body->oa.o_valid, body->oa.o_flags); @@ -1569,23 +1576,26 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) aa->aa_ppga, server_cksum, client_cksum); - LCONSOLE_ERROR_MSG(0x133, - "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu], client %x, server %x, cksum_type %x\n", - req->rq_import->imp_obd->obd_name, - libcfs_nid2str(peer->nid), - via, router, - clbody->oa.o_valid & OBD_MD_FLFID ? - clbody->oa.o_parent_seq : (u64)0, - clbody->oa.o_valid & OBD_MD_FLFID ? - clbody->oa.o_parent_oid : 0, - clbody->oa.o_valid & OBD_MD_FLFID ? - clbody->oa.o_parent_ver : 0, - POSTID(&body->oa.o_oi), - aa->aa_ppga[0]->off, - aa->aa_ppga[page_count - 1]->off + - aa->aa_ppga[page_count - 1]->count - 1, - client_cksum, server_cksum, - cksum_type); + LCONSOLE_ERROR_MSG( + 0x133, + "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID + " object " DOSTID + " extent [%llu-%llu], client %x, server %x, cksum_type %x\n", + req->rq_import->imp_obd->obd_name, + libcfs_nid2str(peer->nid), + via, router, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_seq : (u64)0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_oid : 0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_ver : 0, + POSTID(&body->oa.o_oi), + aa->aa_ppga[0]->off, + aa->aa_ppga[page_count - 1]->off + + aa->aa_ppga[page_count - 1]->count - 1, + client_cksum, server_cksum, + cksum_type); cksum_counter = 0; aa->aa_oa->o_cksum = client_cksum; rc = -EAGAIN; @@ -1622,8 +1632,8 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, DEBUG_REQ(rc == -EINPROGRESS ? D_RPCTRACE : D_ERROR, request, "redo for recoverable error %d", rc); - rc = osc_brw_prep_request(lustre_msg_get_opc(request->rq_reqmsg) == - OST_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ, + rc = osc_brw_prep_request((lustre_msg_get_opc(request->rq_reqmsg) == + OST_WRITE) ? OBD_BRW_WRITE : OBD_BRW_READ, aa->aa_cli, aa->aa_oa, aa->aa_page_count, aa->aa_ppga, &new_req, 0, 1); @@ -1648,7 +1658,8 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, * what ptlrpc does (see after_reply()) */ if (aa->aa_resends > new_req->rq_timeout) - new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout; + new_req->rq_sent = (ktime_get_real_seconds() + + new_req->rq_timeout); else new_req->rq_sent = ktime_get_real_seconds() + aa->aa_resends; new_req->rq_generation_set = 1; @@ -1702,7 +1713,8 @@ static void sort_brw_pages(struct brw_page **array, int num) for (i = stride ; i < num ; i++) { tmp = array[i]; j = i; - while (j >= stride && array[j - stride]->off > tmp->off) { + while (j >= stride && + array[j - stride]->off > tmp->off) { array[j] = array[j - stride]; j -= stride; } @@ -1733,7 +1745,9 @@ static int brw_interpret(const struct lu_env *env, if (osc_recoverable_error(rc)) { if (req->rq_import_generation != req->rq_import->imp_generation) { - CDEBUG(D_HA, "%s: resend cross eviction for object: " DOSTID ", rc = %d.\n", + CDEBUG(D_HA, + "%s: resend cross eviction for object: " DOSTID + ", rc = %d.\n", req->rq_import->imp_obd->obd_name, POSTID(&aa->aa_oa->o_oi), rc); } else if (rc == -EINPROGRESS || @@ -2093,7 +2107,6 @@ static int osc_enqueue_interpret(const struct lu_env *env, __u32 lvb_len = sizeof(*lvb); __u64 flags = 0; - /* ldlm_cli_enqueue is holding a reference on the lock, so it must * be valid. */ @@ -2212,7 +2225,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(&lockh, mode); LDLM_LOCK_PUT(matched); return -ECANCELED; - } else if (osc_set_lock_data(matched, einfo->ei_cbdata)) { + } + if (osc_set_lock_data(matched, einfo->ei_cbdata)) { *flags |= LDLM_FL_LVB_READY; /* We already have a lock, and it's referenced. */ (*upcall)(cookie, &lockh, ELDLM_LOCK_MATCHED); @@ -2220,10 +2234,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(&lockh, mode); LDLM_LOCK_PUT(matched); return ELDLM_OK; - } else { - ldlm_lock_decref(&lockh, mode); - LDLM_LOCK_PUT(matched); } + ldlm_lock_decref(&lockh, mode); + LDLM_LOCK_PUT(matched); } no_match: @@ -2269,9 +2282,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, aa->oa_lvb = lvb; } else { /* AGL is essentially to enqueue an DLM lock - * in advance, so we don't care about the - * result of AGL enqueue. - */ + * in advance, so we don't care about the + * result of AGL enqueue. + */ aa->oa_lvb = NULL; aa->oa_flags = NULL; } @@ -2663,7 +2676,8 @@ static int osc_reconnect(const struct lu_env *env, cli->cl_lost_grant = 0; spin_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d, lost: %ld.\n", + CDEBUG(D_RPCTRACE, + "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d, lost: %ld.\n", data->ocd_connect_flags, data->ocd_version, data->ocd_grant, lost_grant); } @@ -2788,7 +2802,8 @@ static int osc_import_event(struct obd_device *obd, /* See bug 7198 */ if (ocd->ocd_connect_flags & OBD_CONNECT_REQPORTAL) - imp->imp_client->cli_request_portal = OST_REQUEST_PORTAL; + imp->imp_client->cli_request_portal = + OST_REQUEST_PORTAL; rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD); break; From patchwork Wed Jan 9 06:24:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10753503 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 65BC76C2 for ; Wed, 9 Jan 2019 06:27:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543A628E17 for ; Wed, 9 Jan 2019 06:27:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4864928E1A; Wed, 9 Jan 2019 06:27:56 +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 DCAA728E17 for ; Wed, 9 Jan 2019 06:27:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6AA826823C4; Tue, 8 Jan 2019 22:27:55 -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 13B1B6822FB for ; Tue, 8 Jan 2019 22:27:53 -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 4CD2CAF0B; Wed, 9 Jan 2019 06:27:52 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Wed, 09 Jan 2019 17:24:03 +1100 Message-ID: <154701504291.26726.3018163382085938859.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 29/29] lustre: centralize handling of PTLRPCD_SET 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 Various places test if a given rqset is PTLRPCD_SET and call either ptlrpcd_add_req() or ptlrpc_set_add_req() depending on the result. This can be unified by putting the test of PTLRPCD_SET in ptlrpc_set_add_req(), and always calling that function. This results in the being only one place that tests PTLRPCD_SET. Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/include/lustre_net.h | 1 + drivers/staging/lustre/lustre/osc/osc_internal.h | 2 - drivers/staging/lustre/lustre/osc/osc_request.c | 27 ++++---------------- drivers/staging/lustre/lustre/ptlrpc/client.c | 5 ++++ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 6d328b48a96b..e665f70e54a8 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1832,6 +1832,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set); int ptlrpc_set_wait(struct ptlrpc_request_set *); void ptlrpc_set_destroy(struct ptlrpc_request_set *); void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *); +#define PTLRPCD_SET ((struct ptlrpc_request_set*)1) void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool); int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq); diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 586f0dfe3790..c61ef894177b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -99,8 +99,6 @@ void osc_update_next_shrink(struct client_obd *cli); */ #include -extern struct ptlrpc_request_set *PTLRPCD_SET; - typedef int (*osc_enqueue_upcall_f)(void *cookie, struct lustre_handle *lockh, int rc); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index c2239c99a7b2..87cc8c72f6e6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -266,10 +266,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa, sa->sa_upcall = upcall; sa->sa_cookie = cookie; - if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req); - else - ptlrpc_set_add_req(rqset, req); + ptlrpc_set_add_req(rqset, req); } return 0; @@ -354,10 +351,7 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa, la->la_upcall = upcall; la->la_cookie = cookie; - if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req); - else - ptlrpc_set_add_req(rqset, req); + ptlrpc_set_add_req(rqset, req); return 0; } @@ -450,10 +444,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa, sa->sa_oa = oa; sa->sa_upcall = upcall; sa->sa_cookie = cookie; - if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req); - else - ptlrpc_set_add_req(rqset, req); + ptlrpc_set_add_req(rqset, req); return 0; } @@ -533,10 +524,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa, fa->fa_upcall = upcall; fa->fa_cookie = cookie; - if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req); - else - ptlrpc_set_add_req(rqset, req); + ptlrpc_set_add_req(rqset, req); return 0; } @@ -2148,8 +2136,6 @@ static int osc_enqueue_interpret(const struct lu_env *env, return rc; } -struct ptlrpc_request_set *PTLRPCD_SET = (void *)1; - /* When enqueuing asynchronously, locks are not ordered, we can obtain a lock * from the 2nd OSC before a lock from the 1st one. This does not deadlock with * other synchronous requests, however keeping some locks and trying to obtain @@ -2291,10 +2277,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_enqueue_interpret; - if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req); - else - ptlrpc_set_add_req(rqset, req); + ptlrpc_set_add_req(rqset, req); } else if (intent) { ptlrpc_req_finished(req); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index f90a3eef5daf..110bb5d8f767 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -1048,6 +1048,11 @@ EXPORT_SYMBOL(ptlrpc_set_destroy); void ptlrpc_set_add_req(struct ptlrpc_request_set *set, struct ptlrpc_request *req) { + if (set == PTLRPCD_SET) { + ptlrpcd_add_req(req); + return; + } + LASSERT(list_empty(&req->rq_set_chain)); /* The set takes over the caller's request reference */