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 6/7] NFSv4: Convert open state lookup to use RCU
Date: Wed,  5 Sep 2018 15:23:59 -0400	[thread overview]
Message-ID: <20180905192400.107485-7-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20180905192400.107485-6-trond.myklebust@hammerspace.com>

Further reduce contention on the inode->i_lock.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4_fs.h   |  1 +
 fs/nfs/nfs4state.c | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 3a6904173214..1b4737f4cac4 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -191,6 +191,7 @@ struct nfs4_state {
 	atomic_t count;
 
 	wait_queue_head_t waitq;
+	struct rcu_head rcu_head;
 };
 
 
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index be92ce4259e9..7feac365038c 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -684,7 +684,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
 	struct nfs_inode *nfsi = NFS_I(inode);
 	struct nfs4_state *state;
 
-	list_for_each_entry(state, &nfsi->open_states, inode_states) {
+	list_for_each_entry_rcu(state, &nfsi->open_states, inode_states) {
 		if (state->owner != owner)
 			continue;
 		if (!nfs4_valid_open_stateid(state))
@@ -698,7 +698,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
 static void
 nfs4_free_open_state(struct nfs4_state *state)
 {
-	kfree(state);
+	kfree_rcu(state, rcu_head);
 }
 
 struct nfs4_state *
@@ -707,9 +707,9 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
 	struct nfs4_state *state, *new;
 	struct nfs_inode *nfsi = NFS_I(inode);
 
-	spin_lock(&inode->i_lock);
+	rcu_read_lock();
 	state = __nfs4_find_state_byowner(inode, owner);
-	spin_unlock(&inode->i_lock);
+	rcu_read_unlock();
 	if (state)
 		goto out;
 	new = nfs4_alloc_open_state();
@@ -720,7 +720,7 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
 		state = new;
 		state->owner = owner;
 		atomic_inc(&owner->so_count);
-		list_add(&state->inode_states, &nfsi->open_states);
+		list_add_rcu(&state->inode_states, &nfsi->open_states);
 		ihold(inode);
 		state->inode = inode;
 		spin_unlock(&inode->i_lock);
@@ -746,7 +746,7 @@ void nfs4_put_open_state(struct nfs4_state *state)
 	if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
 		return;
 	spin_lock(&inode->i_lock);
-	list_del(&state->inode_states);
+	list_del_rcu(&state->inode_states);
 	list_del(&state->open_states);
 	spin_unlock(&inode->i_lock);
 	spin_unlock(&owner->so_lock);
-- 
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           ` Trond Myklebust [this message]
2018-09-05 19:24             ` [PATCH 7/7] NFSv4: Convert struct nfs4_state to use refcount_t Trond Myklebust
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-7-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).