diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2010-09-03 04:39:20 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2010-09-20 06:19:50 -0400 |
commit | 7b5e3d5fcf0d6fce66050bd0313a7dc2ae4abc62 (patch) | |
tree | 2121e7587c5bb73faeaba6e438178ea8aff570ee /fs/gfs2 | |
parent | fe08d5a89726675a920b0e9bbbe849c46b27a6e5 (diff) |
GFS2: Don't enforce min hold time when two demotes occur in rapid succession
Due to the design of the VFS, it is quite usual for operations on GFS2
to consist of a lookup (requiring a shared lock) followed by an
operation requiring an exclusive lock. If a remote node has cached an
exclusive lock, then it will receive two demote events in rapid succession
firstly for a shared lock and then to unlocked. The existing min hold time
code was triggering in this case, even if the node was otherwise idle
since the state change time was being updated by the initial demote.
This patch introduces logic to skip the min hold timer in the case that
a "double demote" of this kind has occurred. The min hold timer will
still be used in all other cases.
A new glock flag is introduced which is used to keep track of whether
there have been any newly queued holders since the last glock state
change. The min hold time is only applied if the flag is set.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Tested-by: Abhijith Das <adas@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/glock.c | 15 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/trace_gfs2.h | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 9adf8f924e08..8e478e27f1f7 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -441,6 +441,8 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state) | |||
441 | else | 441 | else |
442 | gfs2_glock_put_nolock(gl); | 442 | gfs2_glock_put_nolock(gl); |
443 | } | 443 | } |
444 | if (held1 && held2 && list_empty(&gl->gl_holders)) | ||
445 | clear_bit(GLF_QUEUED, &gl->gl_flags); | ||
444 | 446 | ||
445 | gl->gl_state = new_state; | 447 | gl->gl_state = new_state; |
446 | gl->gl_tchange = jiffies; | 448 | gl->gl_tchange = jiffies; |
@@ -1012,6 +1014,7 @@ fail: | |||
1012 | if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) | 1014 | if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) |
1013 | insert_pt = &gh2->gh_list; | 1015 | insert_pt = &gh2->gh_list; |
1014 | } | 1016 | } |
1017 | set_bit(GLF_QUEUED, &gl->gl_flags); | ||
1015 | if (likely(insert_pt == NULL)) { | 1018 | if (likely(insert_pt == NULL)) { |
1016 | list_add_tail(&gh->gh_list, &gl->gl_holders); | 1019 | list_add_tail(&gh->gh_list, &gl->gl_holders); |
1017 | if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) | 1020 | if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) |
@@ -1310,10 +1313,12 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state) | |||
1310 | 1313 | ||
1311 | gfs2_glock_hold(gl); | 1314 | gfs2_glock_hold(gl); |
1312 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; | 1315 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; |
1313 | if (time_before(now, holdtime)) | 1316 | if (test_bit(GLF_QUEUED, &gl->gl_flags)) { |
1314 | delay = holdtime - now; | 1317 | if (time_before(now, holdtime)) |
1315 | if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags)) | 1318 | delay = holdtime - now; |
1316 | delay = gl->gl_ops->go_min_hold_time; | 1319 | if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags)) |
1320 | delay = gl->gl_ops->go_min_hold_time; | ||
1321 | } | ||
1317 | 1322 | ||
1318 | spin_lock(&gl->gl_spin); | 1323 | spin_lock(&gl->gl_spin); |
1319 | handle_callback(gl, state, delay); | 1324 | handle_callback(gl, state, delay); |
@@ -1660,6 +1665,8 @@ static const char *gflags2str(char *buf, const unsigned long *gflags) | |||
1660 | *p++ = 'I'; | 1665 | *p++ = 'I'; |
1661 | if (test_bit(GLF_FROZEN, gflags)) | 1666 | if (test_bit(GLF_FROZEN, gflags)) |
1662 | *p++ = 'F'; | 1667 | *p++ = 'F'; |
1668 | if (test_bit(GLF_QUEUED, gflags)) | ||
1669 | *p++ = 'q'; | ||
1663 | *p = 0; | 1670 | *p = 0; |
1664 | return buf; | 1671 | return buf; |
1665 | } | 1672 | } |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 578234bb03f8..b12ca10481e7 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -196,6 +196,7 @@ enum { | |||
196 | GLF_REPLY_PENDING = 9, | 196 | GLF_REPLY_PENDING = 9, |
197 | GLF_INITIAL = 10, | 197 | GLF_INITIAL = 10, |
198 | GLF_FROZEN = 11, | 198 | GLF_FROZEN = 11, |
199 | GLF_QUEUED = 12, | ||
199 | }; | 200 | }; |
200 | 201 | ||
201 | struct gfs2_glock { | 202 | struct gfs2_glock { |
diff --git a/fs/gfs2/trace_gfs2.h b/fs/gfs2/trace_gfs2.h index 148d55c14171..cedb0bb96d96 100644 --- a/fs/gfs2/trace_gfs2.h +++ b/fs/gfs2/trace_gfs2.h | |||
@@ -39,7 +39,8 @@ | |||
39 | {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \ | 39 | {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \ |
40 | {(1UL << GLF_REPLY_PENDING), "r" }, \ | 40 | {(1UL << GLF_REPLY_PENDING), "r" }, \ |
41 | {(1UL << GLF_INITIAL), "I" }, \ | 41 | {(1UL << GLF_INITIAL), "I" }, \ |
42 | {(1UL << GLF_FROZEN), "F" }) | 42 | {(1UL << GLF_FROZEN), "F" }, \ |
43 | {(1UL << GLF_QUEUED), "q" }) | ||
43 | 44 | ||
44 | #ifndef NUMPTY | 45 | #ifndef NUMPTY |
45 | #define NUMPTY | 46 | #define NUMPTY |