Received: by 10.213.65.68 with SMTP id h4csp618005imn; Fri, 30 Mar 2018 12:00:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+nYVNry6eY+VGyfr2tvVVfUavvXmOhKr8Ld7GrprsUod/QrBwLNx4mhaqKs/ZmsZbR8Yvk X-Received: by 2002:a17:902:2862:: with SMTP id e89-v6mr186365plb.348.1522436433147; Fri, 30 Mar 2018 12:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522436433; cv=none; d=google.com; s=arc-20160816; b=gOJU/HNj1ERUx4mgsfnmHLU8zOgLKtds0qn7CmF6PMyW+P5sxwrD99TaHt4Y/Asdyd IK1jOQmldvmWkxsD3+Rqy04KKl1V0Oz4o3M7UqIF+psC9qi+jevANHJ1XBdhAo1798fT kCwo8mr3p1ePGk+Cemg/DucZyCKE4feoM5824oFyWk4Nh7WmkoTaNzmH35ZxqRQ62IC9 7COTz9k/nDAXIEKvmKyrkrc3hfZrsCfqh0IZHyL3JxGNhhALYtAJmjNMFtVz1+c6zikB +xidYIzrqB5ImpKwoQZbKzUdOakdxFe6GMok/fWtpiOmDJ5YAI3U9oUIzC0p5DIiGSLa 3MWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=kiQp4N5lJ5fkGUqdABL1y2dWLEcBUfNEBuKlr/lcaj8=; b=wmcTL79RxexRP03hZ5YEVkdqtyFpyIZeWWS+CK+lD0B+7he6lTsF9pKvkp9lpF5kl/ rpz9Npsv9jhGSCYsBg/IqbB3Riy0E9pqFhCRQIHxw8BhDwXHQjKsKlnPyrGtC2zSwnG0 gAoHBCmbCM47XgwH42zajqRYNbpJf3GqGnNFy6uefsnQxDgeyp/dtzQAHe6ckbU0AAKA buolKPb2MB7+I5ZO14m42KQMTzczGl6S5Pc0OaFiectUt1skwFsb76HlPbaNv1L8uS76 lzVElAqAIScZQL9tL6OLl86wYPe5l9aKu+EH/pgk2+85x3cc//q3NkyIXKEAe8gAAFGB IMkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=YMLz5ugK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6-v6si4594615pll.417.2018.03.30.12.00.19; Fri, 30 Mar 2018 12:00:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=YMLz5ugK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbeC3S6m (ORCPT + 99 others); Fri, 30 Mar 2018 14:58:42 -0400 Received: from casper.infradead.org ([85.118.1.10]:46166 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbeC3S6k (ORCPT ); Fri, 30 Mar 2018 14:58:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Message-ID:In-Reply-To:Subject:cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kiQp4N5lJ5fkGUqdABL1y2dWLEcBUfNEBuKlr/lcaj8=; b=YMLz5ugK5wMfGnKOxtloNXu2U uFWat+m9+is39ByCWaY7ar/mWDo05W9AhzsBk9BT7OBOVZUmeqOmJDebuV1+kkNWGzA88xlyMth8I uyWcnEHq6ZRElQFlSjW33L3SKtG2fUwbh/ThpqjpicxqFF5RAC1YR6r9uE6hPKx/kBnGIaXol7gtZ PpcNgHavqn0DQQaKc+Vop2cTc3B5BvTxoyCb6tFVwCJob369Z9aM1QuKHyShXYEYYf0hVcaj004Cy MHAAdZ5Mq1vFm8mxcZrulJ3+Rdrlm9ZkB0L5hZ8NogcgZ6HFefOEJ8WqwtKZu3u0XKvyzW/95zLZF DqVwzDKeQ==; Received: from jsimmons (helo=localhost) by casper.infradead.org with local-esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1zER-0002dR-4b; Fri, 30 Mar 2018 18:58:36 +0000 Date: Fri, 30 Mar 2018 19:58:35 +0100 (BST) From: James Simmons To: NeilBrown cc: Oleg Drokin , Greg Kroah-Hartman , Andreas Dilger , Linux Kernel Mailing List , Lustre Development List Subject: Re: [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref() In-Reply-To: <152229760841.27689.15144924642603768840.stgit@noble> Message-ID: References: <152229732768.27689.4800156943561963977.stgit@noble> <152229760841.27689.15144924642603768840.stgit@noble> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180330_195835_171996_67BEC6C7 X-CRM114-Status: GOOD ( 20.01 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 NO_RELAYS Informational: message was not relayed via SMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 1/ the return value of ldlm_resource_putref() is never > used, so change it to return 'void'. > 2/ Move all of the code to run on the last putref to > __ldlm_resource_putref_final(). This means a lock > is taken in one function and dropped in another, but > that isn't too uncommon, and will disappear in a future > patch. > Now that the code it together, it becomes apparent that > we are dropping a ref on the namespace *before* the last > use. So keep the ref until after. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 21 +++++++++----------- > 2 files changed, 10 insertions(+), 13 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h > index 5a355fbab401..d668d86423a4 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h > +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h > @@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, > struct ldlm_resource *parent, > const struct ldlm_res_id *, > enum ldlm_type type, int create); > -int ldlm_resource_putref(struct ldlm_resource *res); > +void ldlm_resource_putref(struct ldlm_resource *res); > void ldlm_resource_add_lock(struct ldlm_resource *res, > struct list_head *head, > struct ldlm_lock *lock); > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index 4c44603ab6f9..8841a1bb2c0a 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, > struct ldlm_resource *res) > { > struct ldlm_ns_bucket *nsb = res->lr_ns_bucket; > + struct ldlm_namespace *ns = nsb->nsb_namespace; > > if (!list_empty(&res->lr_granted)) { > ldlm_resource_dump(D_ERROR, res); > @@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, > LBUG(); > } > > - cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash, > + cfs_hash_bd_del_locked(ns->ns_rs_hash, > bd, &res->lr_hash); > lu_ref_fini(&res->lr_reference); > + cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1); > + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) > + ns->ns_lvbo->lvbo_free(res); > if (cfs_hash_bd_count_get(bd) == 0) > - ldlm_namespace_put(nsb->nsb_namespace); > + ldlm_namespace_put(ns); > + kmem_cache_free(ldlm_resource_slab, res); > } > > -/* Returns 1 if the resource was freed, 0 if it remains. */ > -int ldlm_resource_putref(struct ldlm_resource *res) > +void ldlm_resource_putref(struct ldlm_resource *res) > { > struct ldlm_namespace *ns = ldlm_res_to_ns(res); > struct cfs_hash_bd bd; > @@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res) > res, atomic_read(&res->lr_refcount) - 1); > > cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd); > - if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) { > + if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) > __ldlm_resource_putref_final(&bd, res); > - cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); > - if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) > - ns->ns_lvbo->lvbo_free(res); > - kmem_cache_free(ldlm_resource_slab, res); > - return 1; > - } > - return 0; > } > EXPORT_SYMBOL(ldlm_resource_putref); > > > >