[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [GFS2 PATCH 3/5] GFS2: Introduce rbm field bii



This patch adds a new field to the rbm structure, called bii.
The purpose of this structure is to keep track of which bitmap
the rbm is on (an index into the bitmap array). This is being
added to enable optimizations in future patches.
---
 fs/gfs2/incore.h |  1 +
 fs/gfs2/rgrp.c   | 23 +++++++++++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index f1a3243..0c8b5d8 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -104,6 +104,7 @@ struct gfs2_rbm {
 	struct gfs2_rgrpd *rgd;
 	struct gfs2_bitmap *bi;	/* Bitmap must belong to the rgd */
 	u32 offset;		/* The offset is bitmap relative */
+	int bii;		/* Bitmap index */
 };
 
 static inline u64 gfs2_rbm_to_block(const struct gfs2_rbm *rbm)
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7d64a27..fddc3f9 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -252,7 +252,6 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len,
 static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 {
 	u64 rblock = block - rbm->rgd->rd_data0;
-	u32 x;
 
 	if (WARN_ON_ONCE(rblock > UINT_MAX))
 		return -EINVAL;
@@ -260,6 +259,7 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 		return -E2BIG;
 
 	rbm->bi = rbm->rgd->rd_bits;
+	rbm->bii = 0;
 	rbm->offset = (u32)(rblock);
 	/* Check if the block is within the first block */
 	if (rbm->offset < rbm->bi->bi_blocks)
@@ -268,9 +268,9 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 	/* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */
 	rbm->offset += (sizeof(struct gfs2_rgrp) -
 			sizeof(struct gfs2_meta_header)) * GFS2_NBBY;
-	x = rbm->offset / rbm->rgd->rd_sbd->sd_blocks_per_bitmap;
-	rbm->offset -= x * rbm->rgd->rd_sbd->sd_blocks_per_bitmap;
-	rbm->bi += x;
+	rbm->bii = rbm->offset / rbm->rgd->rd_sbd->sd_blocks_per_bitmap;
+	rbm->offset -= rbm->bii * rbm->rgd->rd_sbd->sd_blocks_per_bitmap;
+	rbm->bi += rbm->bii;
 	return 0;
 }
 
@@ -1562,7 +1562,6 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 minext,
 	u32 initial_offset;
 	u32 offset;
 	u8 *buffer;
-	int index;
 	int n = 0;
 	int iters = rbm->rgd->rd_length;
 	int ret;
@@ -1601,7 +1600,7 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 minext,
 			goto next_iter;
 		}
 		if (ret == -E2BIG) {
-			index = 0;
+			rbm->bii = 0;
 			rbm->offset = 0;
 			n += (rbm->bi - initial_bi);
 			goto res_covered_end_of_rgrp;
@@ -1614,13 +1613,13 @@ bitmap_full:	/* Mark bitmap as full and fall through */
 
 next_bitmap:	/* Find next bitmap in the rgrp */
 		rbm->offset = 0;
-		index = rbm->bi - rbm->rgd->rd_bits;
-		index++;
-		if (index == rbm->rgd->rd_length)
-			index = 0;
+		rbm->bii = rbm->bi - rbm->rgd->rd_bits;
+		rbm->bii++;
+		if (rbm->bii == rbm->rgd->rd_length)
+			rbm->bii = 0;
 res_covered_end_of_rgrp:
-		rbm->bi = &rbm->rgd->rd_bits[index];
-		if ((index == 0) && nowrap)
+		rbm->bi = &rbm->rgd->rd_bits[rbm->bii];
+		if ((rbm->bii == 0) && nowrap)
 			break;
 		n++;
 next_iter:
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]