From: NeilBrown <neilb@suse.de>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 03/11] nfs: use clear_and_wake_up_bit().
Date: Fri, 6 Dec 2024 13:15:29 +1100 [thread overview]
Message-ID: <20241206021830.3526922-4-neilb@suse.de> (raw)
In-Reply-To: <20241206021830.3526922-1-neilb@suse.de>
In three places nfs clears a bit and then sends a wake_up_bit().
Using clear_and_wake_up_bit() makes this code cleaner and avoids the
need for explicit barriers.
In 2 cases the wake_up is conditional on a "congested" flag. For these
we use the flag to select between clear_bit and clear_and_wake_up_bit.
Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/nfs/inode.c | 4 +---
fs/nfs/pagelist.c | 14 ++++++--------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 596f35170137..4c4c3ab57fcd 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1451,9 +1451,7 @@ int nfs_clear_invalid_mapping(struct address_space *mapping)
ret = nfs_invalidate_mapping(inode, mapping);
trace_nfs_invalidate_mapping_exit(inode, ret);
- clear_bit_unlock(NFS_INO_INVALIDATING, bitlock);
- smp_mb__after_atomic();
- wake_up_bit(bitlock, NFS_INO_INVALIDATING);
+ clear_and_wake_up_bit(NFS_INO_INVALIDATING, bitlock);
out:
return ret;
}
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index e27c07bd8929..7f3914064cee 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -214,11 +214,10 @@ nfs_page_set_headlock(struct nfs_page *req)
void
nfs_page_clear_headlock(struct nfs_page *req)
{
- clear_bit_unlock(PG_HEADLOCK, &req->wb_flags);
- smp_mb__after_atomic();
if (!test_bit(PG_CONTENDED1, &req->wb_flags))
- return;
- wake_up_bit(&req->wb_flags, PG_HEADLOCK);
+ clear_bit_unlock(PG_HEADLOCK, &req->wb_flags);
+ else
+ clear_and_wake_up_bit(PG_HEADLOCK, &req->wb_flags);
}
/*
@@ -519,11 +518,10 @@ nfs_create_subreq(struct nfs_page *req,
*/
void nfs_unlock_request(struct nfs_page *req)
{
- clear_bit_unlock(PG_BUSY, &req->wb_flags);
- smp_mb__after_atomic();
if (!test_bit(PG_CONTENDED2, &req->wb_flags))
- return;
- wake_up_bit(&req->wb_flags, PG_BUSY);
+ clear_bit_unlock(PG_BUSY, &req->wb_flags);
+ else
+ clear_and_wake_up_bit(PG_BUSY, &req->wb_flags);
}
/**
--
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 ` NeilBrown [this message]
2024-12-06 2:15 ` [PATCH 04/11] nfs: combine NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK NeilBrown
2025-01-22 20:45 ` 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-4-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