[Cluster-devel] [GFS2 PATCH 3/3] GFS2: Don't insert into reservations tree unless rgrp has enough blocks

Bob Peterson rpeterso at redhat.com
Mon Sep 16 20:10:44 UTC 2013


The previous two patches simplified the logic in gfs2_inplace_reserve
and ensured that inadequate reservations are dropped before we enter
the main loop. This patch takes the next logical step and makes sure
that new reservations don't get inserted into the rgrp reservations
tree unless they are also adequate. So now we don't have to repeatly
insert a reservation, determine it's inadequate, then remove it from
the tree again. We can take a proactive approach that says: Only
insert it if it's adequate. That's makes the code a little faster.
---
 fs/gfs2/rgrp.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index ed57fdf..59637ab 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1455,7 +1455,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
 		return;
 
 	ret = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, extlen, ip, true);
-	if (ret == 0) {
+	if (ret == 0 && rgd->rd_free_clone >= requested) {
 		rs->rs_rbm = rbm;
 		rs->rs_free = extlen;
 		rs->rs_inum = ip->i_no_addr;
@@ -1936,16 +1936,11 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested, u32 aflags)
 			rg_mblk_search(rs->rs_rbm.rgd, ip, requested);
 
 		/* Skip rgrps when we can't get a reservation on first pass */
-		if (gfs2_rs_active(rs) || (loops >= 1)) {
-			/* If rgrp has enough free space, use it */
-			if (rs->rs_rbm.rgd->rd_free_clone >= requested) {
-				ip->i_rgd = rs->rs_rbm.rgd;
-				return 0;
-			}
-
-			/* Drop reservation if we couldn't use reserved rgrp */
-			if (gfs2_rs_active(rs))
-				gfs2_rs_deltree(rs);
+		if (gfs2_rs_active(rs) ||
+		    ((loops >= 1) &&
+		     (rs->rs_rbm.rgd->rd_free_clone >= requested))) {
+			    ip->i_rgd = rs->rs_rbm.rgd;
+			    return 0;
 		}
 		/* Check for unlinked inodes which can be reclaimed */
 		if (rs->rs_rbm.rgd->rd_flags & GFS2_RDF_CHECK)
-- 
1.8.3.1




More information about the Cluster-devel mailing list