From patchwork Tue Jul 31 15:07:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10550893 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 656EE14E2 for ; Tue, 31 Jul 2018 15:08:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54F9F2B04F for ; Tue, 31 Jul 2018 15:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4986F2B055; Tue, 31 Jul 2018 15:08:29 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00E82B04D for ; Tue, 31 Jul 2018 15:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732442AbeGaQtM (ORCPT ); Tue, 31 Jul 2018 12:49:12 -0400 Received: from mout.gmx.net ([212.227.15.18]:52297 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727397AbeGaQtM (ORCPT ); Tue, 31 Jul 2018 12:49:12 -0400 Received: from localhost.localdomain ([113.116.159.60]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LfSeH-1gHrw71ijh-00p3zs; Tue, 31 Jul 2018 17:08:23 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 4/4] libceph: introudce a variable to avoid calling refcount_read() twice Date: Tue, 31 Jul 2018 23:07:47 +0800 Message-Id: <20180731150747.27745-4-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180731150747.27745-1-cgxu519@gmx.com> References: <20180731150747.27745-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:mVsvZMFPEgj3XQRWjvKkkBuEPdU6LZ74K/StH7lE/ZJt62tY+45 3hHKCBbU3UAmVc2Z4S1IWuieke3DfrhDDJ/obPD+ydBYRisKzWEkyS4pTPXmVCLjZ9cxPc+ NzjOCUZidQXB/IvY2yB08DIzVAensRvNDPgUJrw/wyLm/dlcbq0RJzBZ7ZI2jksBWG2jmh9 wrjEXn8R+1mA4LnEOAotQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:JYADTb+NNb0=:cbjZicRfKE76jQ4YK5fAk3 RzYOQC1B03RXpSMYvuQq0BiTm9aH1iNaBDpx9xfkZ5p1T80h5eURt+Hn+j9YIyonexrXfOq0u VbqTIxlWDj6ZLN4vpsnmtjH8C1AWsXOfX9uppwZnjVWPwvVIQR0pTRkv7WTwIBZy42uI5due0 FgVGKHcUlizzWNqbhshzrXx9OTaN9FGz4ofMskBtnpiOkkjRiE1y2wQGlWvPNvRrPawfrXisU Dd3GGh/bs46cSweJitUQfZBWg1eSVl97V3+F5K6zI1QCle5M6fvMENpEJN7wUWdiah3CvIziP UswogKwNuddV9/bQMFQWjgXxGtlFmgjPn2BG+aZl6Fth0Obqe9T8PdwNhrSNwqnrXqMOHby+l vyAHr8KAvPuG4XATiEuBAhlrOMI+dItc4EJH/F+nnBGt0ARp5H3kH2OGO/jY9jDkZruFMw/OK d5Jo9N5/0xR2AXplMfzPTyABRYwzHANPNy5YKKvr4prRmPWoGlJQjKZM4iBxgwUQftRlEWcut qH8s4dHUkf/f3TJinGoNGo31hrvht19PU8ly7NcsEAgOCdhoDLpECRw0ygYwMODgvlFTtBlr7 IZB4WvGB1ek90obwUeFuT3ti/9UhLmmOuv7b1LbNax/R+PEgV9EhddVCdLVN1D+Rqb3ApeuSV LXYhImdC75FUJiRPVKPzUZ6wXY0r2sBvyYgqIUUUilp9LN6MLUHdpVeYCTedPfkX1dxDf3q9y p+ZsHl029M1QkdKDng4YVBNqz6Miz1CAO6ZWSG1tvumft7Ol3Z90uZdjFcs= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Calling refcount_read() twice may return different value each time, so introduce a variable to avoid it. Signed-off-by: Chengguang Xu --- net/ceph/osd_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 8002b8e9ce24..ee8eb99a06ae 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1155,8 +1155,8 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum) static struct ceph_osd *get_osd(struct ceph_osd *osd) { if (refcount_inc_not_zero(&osd->o_ref)) { - dout("get_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref)-1, - refcount_read(&osd->o_ref)); + unsigned int refcnt = refcount_read(&osd->o_ref); + dout("get_osd %p %d -> %d\n", osd, refcnt - 1, refcnt); return osd; } else { dout("get_osd %p FAIL\n", osd); @@ -1166,8 +1166,8 @@ static struct ceph_osd *get_osd(struct ceph_osd *osd) static void put_osd(struct ceph_osd *osd) { - dout("put_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref), - refcount_read(&osd->o_ref) - 1); + unsigned int refcnt = refcount_read(&osd->o_ref); + dout("put_osd %p %d -> %d\n", osd, refcnt, refcnt - 1); if (refcount_dec_and_test(&osd->o_ref)) { osd_cleanup(osd); kfree(osd);