cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH] GFS2: don't bother to ask DLM for try locks we know will fail
@ 2012-10-17 17:39 Bob Peterson
  0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2012-10-17 17:39 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

While search for a suitable resource group, this patch checks the
glock holders queue for exclusive holders. If it finds any, it
doesn't bother queueing up the TRY lock only to waste time having
DLM shoot it down in favor of the other.

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
---
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7635500..77400b0 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1694,6 +1694,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested)
 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
 	struct gfs2_rgrpd *begin = NULL;
 	struct gfs2_blkreserv *rs = ip->i_res;
+	struct gfs2_holder *ogh;
 	int error = 0, rg_locked, flags = LM_FLAG_TRY;
 	u64 last_unlinked = NO_BLOCK;
 	int loops = 0;
@@ -1718,6 +1719,22 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested)
 
 		if (!gfs2_glock_is_locked_by_me(rs->rs_rbm.rgd->rd_gl)) {
 			rg_locked = 0;
+			if (flags == LM_FLAG_TRY) {
+				spin_lock(&rs->rs_rbm.rgd->rd_gl->gl_spin);
+				/* Check to see if there's another EX request
+				   on the holders queue. If so, it's pointless
+				   for us to try (they'll get it first). */
+				list_for_each_entry(ogh,
+					&rs->rs_rbm.rgd->rd_gl->gl_holders,
+						    gh_list) {
+					if (ogh->gh_state == LM_ST_EXCLUSIVE) {
+						spin_unlock(&rs->rs_rbm.rgd->
+							    rd_gl->gl_spin);
+						goto next_rgrp;
+					}
+				}
+				spin_unlock(&rs->rs_rbm.rgd->rd_gl->gl_spin);
+			}
 			error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl,
 						   LM_ST_EXCLUSIVE, flags,
 						   &rs->rs_rgd_gh);



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-17 17:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 17:39 [Cluster-devel] [GFS2 PATCH] GFS2: don't bother to ask DLM for try locks we know will fail Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).