@@ -409,6 +409,10 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
409409 if (held1 && held2 && list_empty(&gl->gl_holders))
410410 clear_bit(GLF_QUEUED, &gl->gl_flags);
411411
412+ if (new_state != gl->gl_target)
413+ /* shorten our minimum hold time */
414+ gl->gl_hold_time = max(gl->gl_hold_time - GL_GLOCK_HOLD_DECR,
415+ GL_GLOCK_MIN_HOLD);
412416 gl->gl_state = new_state;
413417 gl->gl_tchange = jiffies;
414418}
@@ -668,7 +672,7 @@ static void glock_work_func(struct work_struct *work)
668672 gl->gl_demote_state != LM_ST_EXCLUSIVE) {
669673 unsigned long holdtime, now = jiffies;
670674
671- holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time ;
675+ holdtime = gl->gl_tchange + gl->gl_hold_time ;
672676 if (time_before(now, holdtime))
673677 delay = holdtime - now;
674678
@@ -679,9 +683,14 @@ static void glock_work_func(struct work_struct *work)
679683 }
680684 run_queue(gl, 0);
681685 spin_unlock(&gl->gl_spin);
682- if (!delay ||
683- queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
686+ if (!delay)
684687 gfs2_glock_put(gl);
688+ else {
689+ if (gl->gl_name.ln_type != LM_TYPE_INODE)
690+ delay = 0;
691+ if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
692+ gfs2_glock_put(gl);
693+ }
685694 if (drop_ref)
686695 gfs2_glock_put(gl);
687696}
@@ -743,6 +752,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
743752 gl->gl_tchange = jiffies;
744753 gl->gl_object = NULL;
745754 gl->gl_sbd = sdp;
755+ gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
746756 INIT_DELAYED_WORK(&gl->gl_work, glock_work_func);
747757 INIT_WORK(&gl->gl_delete, delete_work_func);
748758
@@ -855,8 +865,15 @@ static int gfs2_glock_demote_wait(void *word)
855865
856866static void wait_on_holder(struct gfs2_holder *gh)
857867{
868+ unsigned long time1 = jiffies;
869+
858870 might_sleep();
859871 wait_on_bit(&gh->gh_iflags, HIF_WAIT, gfs2_glock_holder_wait, TASK_UNINTERRUPTIBLE);
872+ if (time_after(jiffies, time1 + HZ)) /* have we waited > a second? */
873+ /* Lengthen the minimum hold time. */
874+ gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time +
875+ GL_GLOCK_HOLD_INCR,
876+ GL_GLOCK_MAX_HOLD);
860877}
861878
862879static void wait_on_demote(struct gfs2_glock *gl)
@@ -1093,8 +1110,9 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
10931110
10941111 gfs2_glock_hold(gl);
10951112 if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
1096- !test_bit(GLF_DEMOTE, &gl->gl_flags))
1097- delay = gl->gl_ops->go_min_hold_time;
1113+ !test_bit(GLF_DEMOTE, &gl->gl_flags) &&
1114+ gl->gl_name.ln_type == LM_TYPE_INODE)
1115+ delay = gl->gl_hold_time;
10981116 if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
10991117 gfs2_glock_put(gl);
11001118}
@@ -1273,12 +1291,13 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
12731291 unsigned long now = jiffies;
12741292
12751293 gfs2_glock_hold(gl);
1276- holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time;
1277- if (test_bit(GLF_QUEUED, &gl->gl_flags)) {
1294+ holdtime = gl->gl_tchange + gl->gl_hold_time;
1295+ if (test_bit(GLF_QUEUED, &gl->gl_flags) &&
1296+ gl->gl_name.ln_type == LM_TYPE_INODE) {
12781297 if (time_before(now, holdtime))
12791298 delay = holdtime - now;
12801299 if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags))
1281- delay = gl->gl_ops->go_min_hold_time ;
1300+ delay = gl->gl_hold_time ;
12821301 }
12831302
12841303 spin_lock(&gl->gl_spin);
@@ -1667,7 +1686,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
16671686 dtime *= 1000000/HZ; /* demote time in uSec */
16681687 if (!test_bit(GLF_DEMOTE, &gl->gl_flags))
16691688 dtime = 0;
1670- gfs2_print_dbg(seq, "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d v:%d r:%d\n",
1689+ gfs2_print_dbg(seq, "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d v:%d r:%d m:%ld \n",
16711690 state2str(gl->gl_state),
16721691 gl->gl_name.ln_type,
16731692 (unsigned long long)gl->gl_name.ln_number,
@@ -1676,7 +1695,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
16761695 state2str(gl->gl_demote_state), dtime,
16771696 atomic_read(&gl->gl_ail_count),
16781697 atomic_read(&gl->gl_revokes),
1679- atomic_read(&gl->gl_ref));
1698+ atomic_read(&gl->gl_ref), gl->gl_hold_time );
16801699
16811700 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
16821701 error = dump_holder(seq, gh);
0 commit comments