GFS2: don't bother to ask DLM for try locks we know will fail
PATCH 1/1 GFS2: don't bother to ask DLM for try locks we know will fail
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 <[email protected]>
---
fs/gfs2/rgrp.c +17 -0
@@ -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);