[PATCH 03/11] nfs: use clear_and_wake_up_bit().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux