diff mbox series

[RFC,25/30] NFSD: Clean up "open file" case in nfsd_file_acquire()

Message ID 165590733080.75778.16386422015870544314.stgit@manet.1015granger.net (mailing list archive)
State Superseded
Headers show
Series Overhaul NFSD filecache | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Chuck Lever III June 22, 2022, 2:15 p.m. UTC
Refactor a little to prepare for changes to nfsd_file_find_locked().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/filecache.c |   27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index ae813e6f645f..8b8d765a0df0 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -1003,23 +1003,22 @@  nfsd_do_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	rcu_read_lock();
 	nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
 	rcu_read_unlock();
-	if (nf)
-		goto wait_for_construction;
+	if (nf == NULL) {
+		new = nfsd_file_alloc(inode, may_flags, net);
+		if (!new) {
+			status = nfserr_jukebox;
+			goto out_status;
+		}
 
-	new = nfsd_file_alloc(inode, may_flags, net);
-	if (!new) {
-		status = nfserr_jukebox;
-		goto out_status;
-	}
+		spin_lock(&nfsd_file_hashtbl[hashval].nfb_lock);
+		nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
+		if (nf == NULL)
+			goto open_file;
+		spin_unlock(&nfsd_file_hashtbl[hashval].nfb_lock);
 
-	spin_lock(&nfsd_file_hashtbl[hashval].nfb_lock);
-	nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
-	if (nf == NULL)
-		goto open_file;
-	spin_unlock(&nfsd_file_hashtbl[hashval].nfb_lock);
-	nfsd_file_slab_free(&new->nf_rcu);
+		nfsd_file_slab_free(&new->nf_rcu);
+	}
 
-wait_for_construction:
 	wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE);
 
 	/* Did construction of this file fail? */