From patchwork Thu Aug 2 13:32:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10553643 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 1777C15A6 for ; Thu, 2 Aug 2018 13:32:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08A4A20182 for ; Thu, 2 Aug 2018 13:32:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F13E7205F7; Thu, 2 Aug 2018 13:32:54 +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 9715720182 for ; Thu, 2 Aug 2018 13:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387499AbeHBPYH (ORCPT ); Thu, 2 Aug 2018 11:24:07 -0400 Received: from mout.gmx.net ([212.227.15.15]:36323 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387438AbeHBPYH (ORCPT ); Thu, 2 Aug 2018 11:24:07 -0400 Received: from localhost.localdomain ([113.116.49.58]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MQzIE-1fNg0m0mi6-00ULng; Thu, 02 Aug 2018 15:32:47 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH v2 2/2] libceph: introudce a variable to avoid calling refcount_read() twice Date: Thu, 2 Aug 2018 21:32:22 +0800 Message-Id: <20180802133222.3692-2-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802133222.3692-1-cgxu519@gmx.com> References: <20180802133222.3692-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:Ia1TyXHyz55tyYJkQklUlp0/M6KdCUmjNoQX9JRFVRvpYO6MDXr 1ULuGOUp9tCb+Py9O0adZ12A5kkX9e/2p00cZvLfiNOf8TWL8AhkCiJ/Hrc0VyAASR10Y4L zxCpqgTr7wiDk15NROIJVv7doxvluPPVbkJi3PFdw3sd3t3zrx+Be1ehSdjhPkAvXiM/fkJ XJ7PvfG5rBNL7e1SevKhw== X-UI-Out-Filterresults: notjunk:1;V01:K0:QdzAjpH19xE=:8t5OvU+3Ir8ZjdScks/r3D ZSPLE5if2Jf1/OP8YldEtku3t4Hsajgoy4PH5hihUAV5+/kQOexjfZUNsP8WDAlGF3ibxAXr/ oc2/uWUCJcmpo8fhRLt8a8BuU5YlxioVO2+1oTslV0YfY6sRj3pwWpQBBS4FiSuV1Ebr6hjSR cVlye0i9i3OgiQXNtzMTDi6z/oUrE545PZSwSLdK458kiNHaasGYdv/Ui4RshmVh3aBomGxj+ y9lm8eNuqmnc/7rBzDhUMxUIATiqUDf8EU1cJpC6sxl9IMi4qeYr16zqAHaP2DX/CPXU0506Z +FhC9wSiPF7qngWQG9bwlHFIXzUQs66iCVjCvkqVXSJ1NxePP1GK38qzNjWx3IkMpglnE8WmS OPvMtszXXwISOKstsFYunDVQaXBO4bN2DE7llxMBIxmGElDAbM8LOaGPN2RCdZimTiYoZ8dT+ ms8yz54jkwsZvugShIZ6Vs83H6hhHFqxB4uWtMwhzaOwZACaz2JEyhe7pRPBFpdZ5CFLZUKtL aLlc1bPC2WFFte5taWuDs3j7YZYo6LVoHMR/GP483GhHOYA8p5wJCXeedm2e9kH7+QkMCtutl CJsnPW6TxXLJOC9LgEmPAMjCaNq95KMNaa4fPuygY3E0PNuhgMqX1VqkvVcwGR3AoeorndWO+ tK/CAG5VSibtu2VNpyDHe0qu5nIxLYitnPdpv7hSfb5iTc0YldTMCJ1gqySgp+0KrVzg+hqnq BT++tlEEYU2Uj2LFLnmHbiw3pmghHH0Hfs1GyNY/IHfYe7EixFbYI0fa/IE= 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 in a debug message 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);