From patchwork Wed Sep 5 19:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10589335 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 3757B15E9 for ; Wed, 5 Sep 2018 19:25:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 232DE2A626 for ; Wed, 5 Sep 2018 19:25:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 177D82A9A2; Wed, 5 Sep 2018 19:25:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A7DE22A626 for ; Wed, 5 Sep 2018 19:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbeIEX4v (ORCPT ); Wed, 5 Sep 2018 19:56:51 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:54567 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbeIEX4v (ORCPT ); Wed, 5 Sep 2018 19:56:51 -0400 Received: by mail-it0-f67.google.com with SMTP id f14-v6so11501826ita.4 for ; Wed, 05 Sep 2018 12:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mdtfbl5MSVkgeBG96X2x4bFlLROOnugXJQ7c0WsVoAI=; b=UA0fk0+9hdYE/CKHyn+k4FYBKin2GpgBQTrK5qRRR0xqho49aioQ5bpF/YSkCBMfYd nOSl8I8qOXsnQ3T/ZG5tGwnJnZYq+gtJIh2VX18sQw3fdM4HSQftrQRT+96xneh+Jrj+ QAXmtrES5pM+WSWRwqJWbVwC23Q1NkRfjhQ0WsmztaejQJR7Fs78MQWIWo1oiqqKh0bc zuHu17YqalzP7MrrEDzLnXpvGvUikupvvwi3R/4XF6blo5zJ7dW/G20MmHhwMfMe0rFg MQhn/pc/6/09/8j17Me87F740wlY28JMedDqUjVjlXpnEPDPM3Tsud5YOB+G68JFKqq7 oIzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mdtfbl5MSVkgeBG96X2x4bFlLROOnugXJQ7c0WsVoAI=; b=o+AqktP1/LzPtUGxE4PT1IjuWo0E/yYPTLM677LJ6WbZ8pM4IajSfebmaD4uTGovx4 MeLmxDDDJI3OIIleaqpcXD+JwRM85CIN4IpSewpBqf5EyerpmaUXfMxj68bBT4/xQwji 69or3rcm+6uvk4nINLPu0UshWgjm5ujZKSrujxBRv6iD9AmlecEgLEJInz5VeJcnTIqO OuLTUzaaIaHhDovbEFN0wTbxnYOghbvEvDbu2zNJSWyAePOtZgvm+b6o1S0Mq6cdr16x c2ez4WxAscfhkEhwJ9jJlcPEHKlMKq1HBCwkm8avLlqcfP4pNBQsVzKdL7+nNHsYsRrG k81w== X-Gm-Message-State: APzg51DEZCWrnXN+bt3T8LXMaKP3aPWPpg9J8b5WnTGkG5+lXDGAHdoV JYzkr29K65TbDh0n+iLBayyplrg= X-Google-Smtp-Source: ANB0VdaQsFvP/YqkpKn1nOqmuATcb4uAvo87mH677mYe41A9BClWIU9RVlALMCy/3HLw/IE5kop2hw== X-Received: by 2002:a02:1a89:: with SMTP id 131-v6mr27406335jai.58.1536175515594; Wed, 05 Sep 2018 12:25:15 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id x198-v6sm1459928ite.19.2018.09.05.12.25.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 12:25:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 7/7] NFSv4: Convert struct nfs4_state to use refcount_t Date: Wed, 5 Sep 2018 15:24:00 -0400 Message-Id: <20180905192400.107485-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180905192400.107485-7-trond.myklebust@hammerspace.com> References: <20180905192400.107485-1-trond.myklebust@hammerspace.com> <20180905192400.107485-2-trond.myklebust@hammerspace.com> <20180905192400.107485-3-trond.myklebust@hammerspace.com> <20180905192400.107485-4-trond.myklebust@hammerspace.com> <20180905192400.107485-5-trond.myklebust@hammerspace.com> <20180905192400.107485-6-trond.myklebust@hammerspace.com> <20180905192400.107485-7-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4proc.c | 8 ++++---- fs/nfs/nfs4state.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 1b4737f4cac4..8d59c9655ec4 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -188,7 +188,7 @@ struct nfs4_state { unsigned int n_wronly; /* Number of write-only references */ unsigned int n_rdwr; /* Number of read/write references */ fmode_t state; /* State on the server (R,W, or RW) */ - atomic_t count; + refcount_t count; wait_queue_head_t waitq; struct rcu_head rcu_head; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 10c20a5b075d..4da59bd53f98 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1777,7 +1777,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) out: return ERR_PTR(ret); out_return_state: - atomic_inc(&state->count); + refcount_inc(&state->count); return state; } @@ -1849,7 +1849,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) update: update_open_stateid(state, &data->o_res.stateid, NULL, data->o_arg.fmode); - atomic_inc(&state->count); + refcount_inc(&state->count); return state; } @@ -1887,7 +1887,7 @@ nfs4_opendata_find_nfs4_state(struct nfs4_opendata *data) return ERR_CAST(inode); if (data->state != NULL && data->state->inode == inode) { state = data->state; - atomic_inc(&state->count); + refcount_inc(&state->count); } else state = nfs4_get_open_state(inode, data->owner); iput(inode); @@ -1978,7 +1978,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context if (opendata == NULL) return ERR_PTR(-ENOMEM); opendata->state = state; - atomic_inc(&state->count); + refcount_inc(&state->count); return opendata; } diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 7feac365038c..6ca3bd076073 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -655,7 +655,7 @@ nfs4_alloc_open_state(void) state = kzalloc(sizeof(*state), GFP_NOFS); if (!state) return NULL; - atomic_set(&state->count, 1); + refcount_set(&state->count, 1); INIT_LIST_HEAD(&state->lock_states); spin_lock_init(&state->state_lock); seqlock_init(&state->seqlock); @@ -689,7 +689,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner) continue; if (!nfs4_valid_open_stateid(state)) continue; - if (atomic_inc_not_zero(&state->count)) + if (refcount_inc_not_zero(&state->count)) return state; } return NULL; @@ -743,7 +743,7 @@ void nfs4_put_open_state(struct nfs4_state *state) struct inode *inode = state->inode; struct nfs4_state_owner *owner = state->owner; - if (!atomic_dec_and_lock(&state->count, &owner->so_lock)) + if (!refcount_dec_and_lock(&state->count, &owner->so_lock)) return; spin_lock(&inode->i_lock); list_del_rcu(&state->inode_states); @@ -1573,7 +1573,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs continue; if (state->state == 0) continue; - atomic_inc(&state->count); + refcount_inc(&state->count); spin_unlock(&sp->so_lock); status = ops->recover_open(sp, state); if (status >= 0) {