From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Wed, 17 Oct 2012 13:39:54 -0400 (EDT) Subject: [Cluster-devel] [GFS2 PATCH] GFS2: don't bother to ask DLM for try locks we know will fail Message-ID: <1185915495.19794272.1350495594979.JavaMail.root@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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);