Skip to contentSkip to conversation

fscache: Fix if condition in fscache_wait_on_volume_collision()

PATCH Gao Xiang 3 participants 3 messages May 26, 2022 – Jul 5, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Gao Xiang

author Reviewed-by
#1 lore raw
Quoted 8 lines · Yue Hu

After waiting for the volume to complete the acquisition with timeout, the if condition under which potential volume collision occurs should be acquire the volume is still pending rather than not pending so that we will continue to wait until the pending flag is cleared. Also, use the existing test pending wrapper directly instead of test_bit().

---

Looks good to me,

Thanks,
Gao Xiang

Quoted 31 lines
 fs/fscache/volume.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fscache/volume.c +2 -2
index 71d3a6d6d72c..f2009cc22002 100644
@@ -143,7 +143,7 @@ static void fscache_wait_on_volume_collision(struct fscache_volume *candidate,
 {
 	wait_var_event_timeout(&candidate->flags,
 			       !fscache_is_acquire_pending(candidate), 20 * HZ);
-	if (!fscache_is_acquire_pending(candidate)) {
+	if (fscache_is_acquire_pending(candidate)) {
 		pr_notice("Potential volume collision new=%08x old=%08x",
 			  candidate->debug_id, collidee_debug_id);
 		fscache_stat(&fscache_n_volumes_collision);
@@ -182,7 +182,7 @@ static bool fscache_hash_volume(struct fscache_volume *candidate)
 	hlist_bl_add_head(&candidate->hash_link, h);
 	hlist_bl_unlock(h);
 
-	if (test_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &candidate->flags))
+	if (fscache_is_acquire_pending(candidate))
 		fscache_wait_on_volume_collision(candidate, collidee_debug_id);
 	return true;
 
Signature · 5 lines
2.17.1
--
Linux-cachefs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/linux-cachefs
Reviewed-by
#2 lore raw
In reply to a message not in the archive
Quoted 16 lines · Yue Hu

After waiting for the volume to complete the acquisition with timeout, the if condition under which potential volume collision occurs should be acquire the volume is still pending rather than not pending so that we will continue to wait until the pending flag is cleared. Also, use the existing test pending wrapper directly instead of test_bit().

---
 fs/fscache/volume.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fscache/volume.c +0 -0
index 71d3a6d6d72c..f2009cc22002 100644

fs/fscache/volume.c static void fscache_wait_on_volume_collision(struct fscache_volume *candidate, · line 149

Quoted 8 lines
fs/fscache/volume.c +1 -1
@@ -143,7 +143,7 @@ static void fscache_wait_on_volume_collision(struct fscache_volume *candidate,
 {
 	wait_var_event_timeout(&candidate->flags,
 			       !fscache_is_acquire_pending(candidate), 20 * HZ);
-	if (!fscache_is_acquire_pending(candidate)) {
+	if (fscache_is_acquire_pending(candidate)) {
 		pr_notice("Potential volume collision new=%08x old=%08x",
 			  candidate->debug_id, collidee_debug_id);
 		fscache_stat(&fscache_n_volumes_collision);

Yeah, I also noticed that before.

fs/fscache/volume.c static bool fscache_hash_volume(struct fscache_volume *candidate) · line 188

Quoted 9 lines
fs/fscache/volume.c +1 -1
@@ -182,7 +182,7 @@ static bool fscache_hash_volume(struct fscache_volume *candidate)
 	hlist_bl_add_head(&candidate->hash_link, h);
 	hlist_bl_unlock(h);
 
-	if (test_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &candidate->flags))
+	if (fscache_is_acquire_pending(candidate))
 		fscache_wait_on_volume_collision(candidate, collidee_debug_id);
 	return true;
 

LGTM.

Signature · 2 lines
Thanks,
Jeffle
Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 25 lines · Yue Hu

After waiting for the volume to complete the acquisition with timeout, the if condition under which potential volume collision occurs should be acquire the volume is still pending rather than not pending so that we will continue to wait until the pending flag is cleared. Also, use the existing test pending wrapper directly instead of test_bit().

---
 fs/fscache/volume.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fscache/volume.c +1 -1
index 71d3a6d6d72c..f2009cc22002 100644
@@ -143,7 +143,7 @@ static void fscache_wait_on_volume_collision(struct fscache_volume *candidate,
 {
 	wait_var_event_timeout(&candidate->flags,
 			       !fscache_is_acquire_pending(candidate), 20 * HZ);
-	if (!fscache_is_acquire_pending(candidate)) {
+	if (fscache_is_acquire_pending(candidate)) {
 		pr_notice("Potential volume collision new=%08x old=%08x",
 			  candidate->debug_id, collidee_debug_id);
 		fscache_stat(&fscache_n_volumes_collision);

fs/fscache/volume.c static bool fscache_hash_volume(struct fscache_volume *candidate) · line 188

Quoted 8 lines
fs/fscache/volume.c +1 -1
@@ -182,7 +182,7 @@ static bool fscache_hash_volume(struct fscache_volume *candidate)
 	hlist_bl_add_head(&candidate->hash_link, h);
 	hlist_bl_unlock(h);
 
-	if (test_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &candidate->flags))
+	if (fscache_is_acquire_pending(candidate))
 		fscache_wait_on_volume_collision(candidate, collidee_debug_id);
 	return true;
 

Nice catch: