diff options
author | Bob Peterson <rpeterso@redhat.com> | 2011-05-24 10:44:42 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2011-05-25 05:37:11 -0400 |
commit | f90e5b5b136ede1f0fd15999e95f13124d6b0dbd (patch) | |
tree | d632331ee9a282954c1d5ed6fa6160c59a1611fb /fs | |
parent | 4a7df24ddc7097cd789a7527187826552ea0765e (diff) |
GFS2: Processes waiting on inode glock that no processes are holding
This patch fixes a race in the GFS2 glock state machine that may
result in lockups. The symptom is that all nodes but one will
hang, waiting for a particular glock. All the holder records
will have the "W" (Waiting) bit set. The other node will
typically have the glock stuck in Exclusive mode (EX) with no
holder records, but the dinode will be cached. In other words,
an entry with "I:" will appear in the glock dump for that glock,
but nothing else.
The race has to do with the glock "Pending Demote" bit, which
can be set, then immediately reset, thus losing the fact that
another node needs the glock. The sequence of events is:
1. Something schedules the glock workqueue (e.g. glock request from fs)
2. The glock workqueue gets to the point between the test of the reply pending
bit and the spin lock:
if (test_and_clear_bit(GLF_REPLY_PENDING, &gl->gl_flags)) {
finish_xmote(gl, gl->gl_reply);
drop_ref = 1;
}
down_read(&gfs2_umount_flush_sem); <---- i.e. here
spin_lock(&gl->gl_spin);
3. In comes (a) the reply to our EX lock request setting GLF_REPLY_PENDING and
(b) the demote request which sets GLF_PENDING_DEMOTE
4. The following test is executed:
if (test_and_clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
gl->gl_state != LM_ST_UNLOCKED &&
gl->gl_demote_state != LM_ST_EXCLUSIVE) {
This resets the pending demote flag, and gl->gl_demote_state is not equal to
exclusive, however because the reply from the dlm arrived after we checked for
the GLF_REPLY_PENDING flag, gl->gl_state is still equal to unlocked, so
although we reset the GLF_PENDING_DEMOTE flag, we didn't then set the
GLF_DEMOTE flag or reinstate the GLF_PENDING_DEMOTE_FLAG.
The patch closes the timing window by only transitioning the
"Pending demote" bit to the "demote" flag once we know the
other conditions (not unlocked and not exclusive) are met.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/glock.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index a2a6abbccc07..7137750f17f0 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -663,14 +663,19 @@ static void glock_work_func(struct work_struct *work) | |||
663 | drop_ref = 1; | 663 | drop_ref = 1; |
664 | } | 664 | } |
665 | spin_lock(&gl->gl_spin); | 665 | spin_lock(&gl->gl_spin); |
666 | if (test_and_clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) && | 666 | if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) && |
667 | gl->gl_state != LM_ST_UNLOCKED && | 667 | gl->gl_state != LM_ST_UNLOCKED && |
668 | gl->gl_demote_state != LM_ST_EXCLUSIVE) { | 668 | gl->gl_demote_state != LM_ST_EXCLUSIVE) { |
669 | unsigned long holdtime, now = jiffies; | 669 | unsigned long holdtime, now = jiffies; |
670 | |||
670 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; | 671 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; |
671 | if (time_before(now, holdtime)) | 672 | if (time_before(now, holdtime)) |
672 | delay = holdtime - now; | 673 | delay = holdtime - now; |
673 | set_bit(delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE, &gl->gl_flags); | 674 | |
675 | if (!delay) { | ||
676 | clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags); | ||
677 | set_bit(GLF_DEMOTE, &gl->gl_flags); | ||
678 | } | ||
674 | } | 679 | } |
675 | run_queue(gl, 0); | 680 | run_queue(gl, 0); |
676 | spin_unlock(&gl->gl_spin); | 681 | spin_unlock(&gl->gl_spin); |