Commit 7a92deaa authored by Andreas Gruenbacher's avatar Andreas Gruenbacher
Browse files

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: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent 9642c8c4
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ int gfs2_instantiate(struct gfs2_holder *gh)
	 * Since we unlock the lockref lock, we set a flag to indicate
	 * instantiate is in progress.
	 */
	if (test_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags)) {
	if (test_and_set_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags)) {
		wait_on_bit(&gl->gl_flags, GLF_INSTANTIATE_IN_PROG,
			    TASK_UNINTERRUPTIBLE);
		/*
@@ -509,14 +509,10 @@ int gfs2_instantiate(struct gfs2_holder *gh)
		goto again;
	}

	set_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);

	ret = glops->go_instantiate(gh);
	if (!ret)
		clear_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags);
	clear_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
	smp_mb__after_atomic();
	wake_up_bit(&gl->gl_flags, GLF_INSTANTIATE_IN_PROG);
	clear_and_wake_up_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
	return ret;
}