From: NeilBrown <neilb@suse.de>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 04/11] nfs: combine NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK
Date: Fri, 6 Dec 2024 13:15:30 +1100 [thread overview]
Message-ID: <20241206021830.3526922-5-neilb@suse.de> (raw)
In-Reply-To: <20241206021830.3526922-1-neilb@suse.de>
The flags NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK are effectively
identical.
The only time either are cleared is in pnfs_clear_layoutreturn_waitbit(),
and there both are cleared.
The only time NFS_LAYOUT_RETURN is set is in pnfs_prepare_layoutreturn()
immediately after NFS_LAYOUT_RETURN_LOCK was set.
The only other time that NFS_LAYOUT_RETURN_LOCK is set is in
pnfs_mark_layout_stateid_invalid() if NFS_LAYOUT_RETURN was set but
NFS_LAYOUT_RETURN_LOCK was not set - but that is an impossible
combination given that else where the flags are set or cleared together.
So we only need one of these flags. This patch discards
NFS_LAYOUT_RETURN_LOCK and does the test_and_set needed for exclusion with
NFS_LAYOUT_RETURN.
Also the wake_up_bit in pnfs_clear_layoutreturn_waitbit() is changed to
clear_and_wake_up_bit() which includes all needed barriers internally.
Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/nfs/pnfs.c | 15 ++++-----------
fs/nfs/pnfs.h | 1 -
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 0d16b383a452..5963c0440e23 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -386,10 +386,7 @@ pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo)
static void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo)
{
- clear_bit_unlock(NFS_LAYOUT_RETURN, &lo->plh_flags);
- clear_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags);
- smp_mb__after_atomic();
- wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN);
+ clear_and_wake_up_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq);
}
@@ -471,9 +468,6 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo,
pnfs_clear_layoutreturn_info(lo);
pnfs_free_returned_lsegs(lo, lseg_list, &range, 0);
set_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags);
- if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags) &&
- !test_and_set_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags))
- pnfs_clear_layoutreturn_waitbit(lo);
return !list_empty(&lo->plh_segs);
}
@@ -1310,9 +1304,8 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo,
/* Serialise LAYOUTGET/LAYOUTRETURN */
if (atomic_read(&lo->plh_outstanding) != 0)
return false;
- if (test_and_set_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags))
+ if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
return false;
- set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
pnfs_get_layout_hdr(lo);
nfs4_stateid_copy(stateid, &lo->plh_stateid);
*cred = get_cred(lo->plh_lc_cred);
@@ -1454,7 +1447,7 @@ _pnfs_return_layout(struct inode *ino)
/* Reference matched in nfs4_layoutreturn_release */
pnfs_get_layout_hdr(lo);
/* Is there an outstanding layoutreturn ? */
- if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) {
+ if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
spin_unlock(&ino->i_lock);
if (wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN,
TASK_UNINTERRUPTIBLE))
@@ -1564,7 +1557,7 @@ bool pnfs_roc(struct inode *ino,
goto out_noroc;
}
pnfs_get_layout_hdr(lo);
- if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) {
+ if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
spin_unlock(&ino->i_lock);
rcu_read_unlock();
wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN,
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 30d2613e912b..df914f17b927 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -100,7 +100,6 @@ enum {
NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */
NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */
NFS_LAYOUT_RETURN, /* layoutreturn in progress */
- NFS_LAYOUT_RETURN_LOCK, /* Serialise layoutreturn */
NFS_LAYOUT_RETURN_REQUESTED, /* Return this layout ASAP */
NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */
NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */
--
2.47.0
next prev parent reply other threads:[~2024-12-06 2:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 2:15 [PATCH 00/11] nfs: improve use of wake_up_bit and wake_up_var NeilBrown
2024-12-06 2:15 ` [PATCH 01/11] sunrpc: remove explicit barrier from rpc_make_runnable() NeilBrown
2024-12-06 2:15 ` [PATCH 02/11] sunrpc: use clear_and_wake_up_bit() for XPRT_LOCKED NeilBrown
2024-12-06 2:15 ` [PATCH 03/11] nfs: use clear_and_wake_up_bit() NeilBrown
2024-12-06 2:15 ` NeilBrown [this message]
2025-01-22 20:45 ` [PATCH 04/11] nfs: combine NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK Mike Snitzer
2025-01-22 21:25 ` NeilBrown
2024-12-06 2:15 ` [PATCH 05/11] nfs: use clear_and_wake_up_bit() in pnfs code NeilBrown
2024-12-06 2:15 ` [PATCH 06/11] nfs: use store_release_wake_up() for clearing d_fsdata NeilBrown
2024-12-06 2:15 ` [PATCH 07/11] sunrpc: discard rpc_wait_bit_killable() NeilBrown
2024-12-06 2:15 ` [PATCH 08/11] nfs: discard nfs_wait_bit_killable() NeilBrown
2024-12-06 2:15 ` [PATCH 09/11] nfs: add memory barrier before calling wake_up_var on cl_state NeilBrown
2024-12-06 2:15 ` [PATCH 10/11] nfs: use atomic_dec_and_wake_up() NeilBrown
2024-12-06 2:15 ` [PATCH 11/11] nfs: use wait_var_event_spinlock() to wait for nfsi->layout to change NeilBrown
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=20241206021830.3526922-5-neilb@suse.de \
--to=neilb@suse.de \
--cc=anna@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@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