Skip to content

Commit e2c6c8a

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: eliminate GLF_QUEUED flag in favor of list_empty(gl_holders)
Before this patch, glock.c maintained a flag, GLF_QUEUED, which indicated when a glock had a holder queued. It was only checked for inode glocks, although set and cleared by all glocks, and it was only used to determine whether the glock should be held for the minimum hold time before releasing. The problem is that the flag is not accurate at all. If a process holds the glock, the flag is set. When they dequeue the glock, it only cleared the flag in cases when the state actually changed. So if the state doesn't change, the flag may still be set, even when nothing is queued. This happens to iopen glocks often: the get held in SH, then the file is closed, but the glock remains in SH mode. We don't need a special flag to indicate this: we can simply tell whether the glock has any items queued to the holders queue. It's a waste of cpu time to maintain it. This patch eliminates the flag in favor of simply checking list_empty on the glock holders. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent b2a846d commit e2c6c8a

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

fs/gfs2/glock.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,6 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
458458
else
459459
gl->gl_lockref.count--;
460460
}
461-
if (held1 && held2 && list_empty(&gl->gl_holders))
462-
clear_bit(GLF_QUEUED, &gl->gl_flags);
463-
464461
if (new_state != gl->gl_target)
465462
/* shorten our minimum hold time */
466463
gl->gl_hold_time = max(gl->gl_hold_time - GL_GLOCK_HOLD_DECR,
@@ -1350,7 +1347,6 @@ __acquires(&gl->gl_lockref.lock)
13501347
if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt))
13511348
insert_pt = &gh2->gh_list;
13521349
}
1353-
set_bit(GLF_QUEUED, &gl->gl_flags);
13541350
trace_gfs2_glock_queue(gh, 1);
13551351
gfs2_glstats_inc(gl, GFS2_LKS_QCOUNT);
13561352
gfs2_sbstats_inc(gl, GFS2_LKS_QCOUNT);
@@ -1651,16 +1647,15 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
16511647
unsigned long now = jiffies;
16521648

16531649
gfs2_glock_hold(gl);
1650+
spin_lock(&gl->gl_lockref.lock);
16541651
holdtime = gl->gl_tchange + gl->gl_hold_time;
1655-
if (test_bit(GLF_QUEUED, &gl->gl_flags) &&
1652+
if (!list_empty(&gl->gl_holders) &&
16561653
gl->gl_name.ln_type == LM_TYPE_INODE) {
16571654
if (time_before(now, holdtime))
16581655
delay = holdtime - now;
16591656
if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags))
16601657
delay = gl->gl_hold_time;
16611658
}
1662-
1663-
spin_lock(&gl->gl_lockref.lock);
16641659
handle_callback(gl, state, delay, true);
16651660
__gfs2_glock_queue_work(gl, delay);
16661661
spin_unlock(&gl->gl_lockref.lock);
@@ -2105,7 +2100,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
21052100
*p++ = 'I';
21062101
if (test_bit(GLF_FROZEN, gflags))
21072102
*p++ = 'F';
2108-
if (test_bit(GLF_QUEUED, gflags))
2103+
if (!list_empty(&gl->gl_holders))
21092104
*p++ = 'q';
21102105
if (test_bit(GLF_LRU, gflags))
21112106
*p++ = 'L';

fs/gfs2/incore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ enum {
340340
GLF_REPLY_PENDING = 9,
341341
GLF_INITIAL = 10,
342342
GLF_FROZEN = 11,
343-
GLF_QUEUED = 12,
344343
GLF_LRU = 13,
345344
GLF_OBJECT = 14, /* Used only for tracing */
346345
GLF_BLOCKING = 15,

fs/gfs2/trace_gfs2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
{(1UL << GLF_REPLY_PENDING), "r" }, \
5757
{(1UL << GLF_INITIAL), "I" }, \
5858
{(1UL << GLF_FROZEN), "F" }, \
59-
{(1UL << GLF_QUEUED), "q" }, \
6059
{(1UL << GLF_LRU), "L" }, \
6160
{(1UL << GLF_OBJECT), "o" }, \
6261
{(1UL << GLF_BLOCKING), "b" })

0 commit comments

Comments
 (0)