Skip to contentSkip to conversation

afs: Add barriers by using clear_and_wake_up_bit()

PATCH Superseded Arnaud Bonnet 1 participant 1 message Jul 8 Afs filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 afs: Add barriers by using clear_and_wake_up_bit()

Insert the required barrier between clear_bit_unlock() and wake_up_bit() as per the wake_up_bit() documentation:
* In order for this to function properly there must be a full memory
* barrier after the bit is cleared and before this function is called.

Use the clear_and_wake_up_bit() helper which is a wrapper for the common clear_bit_unlock() -> smp_mb__after_atomic() -> wake_up_bit() sequence.

Fixes 3bf0fb6f33dd5 ("afs: Probe multiple fileservers simultaneously")
Fixes d2ddc776a4581 ("afs: Overhaul volume and server record caching and fileserver rotation")

---
Note on testing: although the change builds and feels rather uncontroversial, I couldn't get the changed code paths to trigger on my setup when loading the module and could use assistance with this.

 fs/afs/server.c   | 3 +--
 fs/afs/vl_probe.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/afs/server.c +1 -2
index 0fe162ea2a36..8cbe0f7425a4 100644
@@ -605,8 +605,7 @@ bool afs_check_server_record(struct afs_operation *op, struct afs_server *server
 	if (!test_and_set_bit_lock(AFS_SERVER_FL_UPDATING, &server->flags)) {
 		clear_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags);
 		success = afs_update_server_record(op, server, key);
-		clear_bit_unlock(AFS_SERVER_FL_UPDATING, &server->flags);
-		wake_up_bit(&server->flags, AFS_SERVER_FL_UPDATING);
+		clear_and_wake_up_bit(AFS_SERVER_FL_UPDATING, &server->flags);
 		_leave(" = %d", success);
 		return success;
 	}
fs/afs/vl_probe.c +1 -2
index 3d2e0c925460..9850e028c44b 100644
@@ -22,8 +22,7 @@ static void afs_finished_vl_probe(struct afs_vlserver *server)
 		clear_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags);
 	}
 
-	clear_bit_unlock(AFS_VLSERVER_FL_PROBING, &server->flags);
-	wake_up_bit(&server->flags, AFS_VLSERVER_FL_PROBING);
+	clear_and_wake_up_bit(AFS_VLSERVER_FL_PROBING, &server->flags);
 }
 
 /*
Signature · 1 line
2.53.0