Skip to contentSkip to conversation

GFS2: Don't delay TRY locks

PATCH New Bob Peterson 1 participant 1 message Oct 17, 2012 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GFS2: Don't delay TRY locks

Hi,

This patch changes the glock minimum hold time down to zero if the glock is a "try" lock.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/glock.c +7 -0
index 3f1df8b..98ae8a2 100644
@@ -1289,6 +1289,7 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
 	unsigned long delay = 0;
 	unsigned long holdtime;
 	unsigned long now = jiffies;
+	const struct gfs2_holder *gh_head;
 
 	gfs2_glock_hold(gl);
 	holdtime = gl->gl_tchange + gl->gl_hold_time;
@@ -1301,6 +1302,12 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
 	}
 
 	spin_lock(&gl->gl_spin);
+	if (!list_empty(&gl->gl_holders)) {
+		gh_head = list_entry(gl->gl_holders.next,
+				     const struct gfs2_holder, gh_list);
+		if (gh_head->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
+			delay = 0;
+	}
 	handle_callback(gl, state, delay);
 	spin_unlock(&gl->gl_spin);
 	if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)