From patchwork Thu Aug 2 13:32:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10553641 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 A6CB713BB for ; Thu, 2 Aug 2018 13:32:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 986AD20182 for ; Thu, 2 Aug 2018 13:32:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AC8E205F7; Thu, 2 Aug 2018 13:32:48 +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 1574320182 for ; Thu, 2 Aug 2018 13:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387470AbeHBPYA (ORCPT ); Thu, 2 Aug 2018 11:24:00 -0400 Received: from mout.gmx.net ([212.227.15.19]:51235 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387438AbeHBPYA (ORCPT ); Thu, 2 Aug 2018 11:24:00 -0400 Received: from localhost.localdomain ([113.116.49.58]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0McEkx-1fTxPz0jR9-00JbLp; Thu, 02 Aug 2018 15:32:40 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH v2 1/2] ceph: introudce a variable to avoid calling atomic_read() twice Date: Thu, 2 Aug 2018 21:32:21 +0800 Message-Id: <20180802133222.3692-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:ShdeP5hyWvQI9VHdhrc4Hv9ZEjfq/C7TyUD/WAFM63a0x2JJr5a oezdzrpWdmlNFUtsrKSraXDlJsxYNyUOkyvaj+CX8IfiCYg46WNsR2l1hSJxYKz7pisLZTM U7TMvqBrsMTaZFCslBBA0nbmbEq11RcHKYwNqb2/anlnc7thzhObt8zzKNS8zV0uJD+yh3i FPv5NuehOF9X+JLn5Y7IA== X-UI-Out-Filterresults: notjunk:1;V01:K0:2AqKttqX47s=:Ni0NPTGiIgDpj/OtGWGhn9 6WjsND5V8Wh+kOw5u9Tor173o1RsLhDWTZzCXlyXRNe2AkrUPecUiffWV7Ox6bfR/sErgY2TQ 6vlBC9UnRIukZJExA8vDqNumdzdg8IXGSXSKv/bJWuY8lZtr6Nh4VvJ57GVOoAknRkUGIlp4I BsXzdFfbILNbLs/WlR9nZd8TZeSv8UKX2cy/HtuLSLL0TOKXMCXKYXBd3HNo0qi/RIIXbJzSN oB+NxUCuUIMw6frgw7JS/CG/lPCxQKhcAsEtOcxo9mzklJw5TD1o1PC9ray/WOJ+j+p/OMCn3 a7o/4+p3mxXWhdxB2rBqsFXH/qkWtE9buOT7YyaXn9mgFAYEwF9096I4bWIOyrOHt74KYIjB6 vjX9nuNWlYJI9f+Kstxz07+gfsRYx8dhjsbb0/EdctVLgi92hCP6QpmPBnWN0J8QIMAbrwe8F ldRp1RYl6DH+yyDydRssj4nccMu2BMTicmovJKepkZBIneFokRTbRzqBRzO82ARsJLukpo6Yv whtVNPyXkaUqTyMmthTvFGxYkLXGnwrNeBO82g0E8W03bHWwPpnWjyYlA7TKurMXRDXwDsE6i CFz5lrcpFFu3T/0jVLvZxQTfeRevKHirEDBA2ecm5Rxwz3UsV7+RCtJMp6JxethilYFB7XvO7 lKNN0aFjpod6s2FuGbea3KluSJ7dY9U58IW+VJBS3ATbq1PvUq3t7/zmVmGOUSysqAApS64jz pbNSpD1uLUsCWT3BK5QRTGhZk2nylNrfhtu7QN41poccC8CuHFQwksdEl/c= 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 atomic_read() twice in a debug message may return different value each time, so introduce a variable to avoid it. Signed-off-by: Chengguang Xu --- v1->v2: - Keep atomic_t type as it is and only fix the problem of calling atomic_read() twice in a debug message. fs/ceph/snap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index 01b0144c0b73..4f8228e58d73 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c @@ -63,8 +63,8 @@ void ceph_get_snap_realm(struct ceph_mds_client *mdsc, struct ceph_snap_realm *realm) { - dout("get_realm %p %d -> %d\n", realm, - atomic_read(&realm->nref), atomic_read(&realm->nref)+1); + int nref = atomic_read(&realm->nref); + dout("get_realm %p %d -> %d\n", realm, nref, nref + 1); /* * since we _only_ increment realm refs or empty the empty * list with snap_rwsem held, adjusting the empty list here is @@ -193,8 +193,9 @@ static void __destroy_snap_realm(struct ceph_mds_client *mdsc, static void __put_snap_realm(struct ceph_mds_client *mdsc, struct ceph_snap_realm *realm) { + int nref = atomic_read(&realm->nref); dout("__put_snap_realm %llx %p %d -> %d\n", realm->ino, realm, - atomic_read(&realm->nref), atomic_read(&realm->nref)-1); + nref, nref - 1); if (atomic_dec_and_test(&realm->nref)) __destroy_snap_realm(mdsc, realm); } @@ -205,8 +206,9 @@ static void __put_snap_realm(struct ceph_mds_client *mdsc, void ceph_put_snap_realm(struct ceph_mds_client *mdsc, struct ceph_snap_realm *realm) { + int nref = atomic_read(&realm->nref); dout("put_snap_realm %llx %p %d -> %d\n", realm->ino, realm, - atomic_read(&realm->nref), atomic_read(&realm->nref)-1); + nref, nref - 1); if (!atomic_dec_and_test(&realm->nref)) return;