[PATCH 10/11] nfs: use atomic_dec_and_wake_up()

NeilBrown
2024-12-06T02:20:01Z

In two places nfs uses wake_up_var() after atomic_dec_and_test() on the
same var. This is correct as no extra barriers are needed in this case.
This can be made more clear by using the atomic_dec_and_wake_up()
interface.

Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/nfs/pagelist.c | 3 +--
fs/nfs/write.c | 6 +-----
2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 7f3914064cee..a1b4c77cbc68 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -557,8 +557,7 @@ static void nfs_clear_request(struct nfs_page *req)
req->wb_page = NULL;
}
if (l_ctx != NULL) {
- if (atomic_dec_and_test(&l_ctx->io_count)) {
- wake_up_var(&l_ctx->io_count);
+ if (atomic_dec_and_wake_up(&l_ctx->io_count)) {
ctx = l_ctx->open_context;
if (test_bit(NFS_CONTEXT_UNLOCK, &ctx->flags))
rpc_wake_up(&NFS_SERVER(d_inode(ctx->dentry))->uoc_rpcwaitq);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 50fa539611f5..3b709cfff0da 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1658,11 +1658,7 @@ void nfs_commit_begin(struct nfs_mds_commit_info *cinfo)

bool nfs_commit_end(struct nfs_mds_commit_info *cinfo)
{
- if (atomic_dec_and_test(&cinfo->rpcs_out)) {
- wake_up_var(&cinfo->rpcs_out);
- return true;
- }
- return false;
+ return atomic_dec_and_wake_up(&cinfo->rpcs_out);
}

void nfs_commitdata_release(struct nfs_commit_data *data)
--
2.47.0