mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
GFS2: Fix potential race in glock code
We need to be careful of the ordering between clearing the GLF_LOCK bit and scheduling the workqueue. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
parent
22763c5cf3
commit
7e71c55ee7
1 changed files with 8 additions and 2 deletions
|
@ -672,12 +672,17 @@ __acquires(&gl->gl_spin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out_sched:
|
out_sched:
|
||||||
|
clear_bit(GLF_LOCK, &gl->gl_flags);
|
||||||
|
smp_mb__after_clear_bit();
|
||||||
gfs2_glock_hold(gl);
|
gfs2_glock_hold(gl);
|
||||||
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
|
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
|
||||||
gfs2_glock_put_nolock(gl);
|
gfs2_glock_put_nolock(gl);
|
||||||
|
return;
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
clear_bit(GLF_LOCK, &gl->gl_flags);
|
clear_bit(GLF_LOCK, &gl->gl_flags);
|
||||||
goto out;
|
smp_mb__after_clear_bit();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_work_func(struct work_struct *work)
|
static void delete_work_func(struct work_struct *work)
|
||||||
|
@ -1375,10 +1380,11 @@ static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask)
|
||||||
handle_callback(gl, LM_ST_UNLOCKED, 0);
|
handle_callback(gl, LM_ST_UNLOCKED, 0);
|
||||||
nr--;
|
nr--;
|
||||||
}
|
}
|
||||||
|
clear_bit(GLF_LOCK, &gl->gl_flags);
|
||||||
|
smp_mb__after_clear_bit();
|
||||||
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
|
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
|
||||||
gfs2_glock_put_nolock(gl);
|
gfs2_glock_put_nolock(gl);
|
||||||
spin_unlock(&gl->gl_spin);
|
spin_unlock(&gl->gl_spin);
|
||||||
clear_bit(GLF_LOCK, &gl->gl_flags);
|
|
||||||
spin_lock(&lru_lock);
|
spin_lock(&lru_lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue