linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
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	[thread overview]
Message-ID: <20180905192400.107485-8-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20180905192400.107485-7-trond.myklebust@hammerspace.com>

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 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) {
-- 
2.17.1

  reply	other threads:[~2018-09-05 23:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 19:23 [PATCH 0/7] Misc NFS + pNFS performance enhancements Trond Myklebust
2018-09-05 19:23 ` [PATCH 1/7] pNFS: Don't zero out the array in nfs4_alloc_pages() Trond Myklebust
2018-09-05 19:23   ` [PATCH 2/7] pNFS: Don't allocate more pages than we need to fit a layoutget response Trond Myklebust
2018-09-05 19:23     ` [PATCH 3/7] NFS: Convert lookups of the lock context to RCU Trond Myklebust
2018-09-05 19:23       ` [PATCH 4/7] NFS: Simplify internal check for whether file is open for write Trond Myklebust
2018-09-05 19:23         ` [PATCH 5/7] NFS: Convert lookups of the open context to RCU Trond Myklebust
2018-09-05 19:23           ` [PATCH 6/7] NFSv4: Convert open state lookup to use RCU Trond Myklebust
2018-09-05 19:24             ` Trond Myklebust [this message]
2018-09-28 16:34           ` [PATCH 5/7] NFS: Convert lookups of the open context to RCU Olga Kornievskaia
2018-09-28 16:54             ` Olga Kornievskaia
2018-09-28 17:49               ` Trond Myklebust
2018-09-28 18:31                 ` Olga Kornievskaia
2018-09-28 18:53                   ` Trond Myklebust
2018-09-28 19:10                     ` Olga Kornievskaia
2018-09-28 19:55                       ` Olga Kornievskaia
2018-09-28 20:07                         ` Trond Myklebust
2018-09-28 20:19                           ` Olga Kornievskaia
2018-09-28 20:38                             ` Trond Myklebust
2018-10-03 18:38                               ` Olga Kornievskaia
2018-10-04 15:22                                 ` Trond Myklebust
2018-10-04 15:49                                   ` Olga Kornievskaia
2018-10-04 16:13                                     ` Trond Myklebust
2018-10-04 16:31                                       ` Olga Kornievskaia
2018-10-04 16:42                                         ` Trond Myklebust
2018-10-04 18:51                                           ` Olga Kornievskaia
2018-10-03 22:05     ` [PATCH 2/7] pNFS: Don't allocate more pages than we need to fit a layoutget response NeilBrown
2018-09-05 19:33 ` [PATCH 0/7] Misc NFS + pNFS performance enhancements Chuck Lever
2018-09-05 20:36   ` Trond Myklebust
2018-09-07 15:44     ` Chuck Lever
2018-09-10  1:35       ` Trond Myklebust
2018-09-10 16:14         ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905192400.107485-8-trond.myklebust@hammerspace.com \
    --to=trondmy@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).