Skip to content

Commit 7a92dea

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix atomic bug in gfs2_instantiate
Replace test_bit() + set_bit() with test_and_set_bit() where we need an atomic operation. Use clear_and_wake_up_bit() instead of open coding it. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 9642c8c commit 7a92dea

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

fs/gfs2/glock.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ int gfs2_instantiate(struct gfs2_holder *gh)
496496
* Since we unlock the lockref lock, we set a flag to indicate
497497
* instantiate is in progress.
498498
*/
499-
if (test_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags)) {
499+
if (test_and_set_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags)) {
500500
wait_on_bit(&gl->gl_flags, GLF_INSTANTIATE_IN_PROG,
501501
TASK_UNINTERRUPTIBLE);
502502
/*
@@ -509,14 +509,10 @@ int gfs2_instantiate(struct gfs2_holder *gh)
509509
goto again;
510510
}
511511

512-
set_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
513-
514512
ret = glops->go_instantiate(gh);
515513
if (!ret)
516514
clear_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags);
517-
clear_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
518-
smp_mb__after_atomic();
519-
wake_up_bit(&gl->gl_flags, GLF_INSTANTIATE_IN_PROG);
515+
clear_and_wake_up_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
520516
return ret;
521517
}
522518

0 commit comments

Comments
 (0)