Skip to contentSkip to conversation

GFS2: Introduce rbm field bii

PATCH New Bob Peterson 1 participant 2 messages Sep 11, 2013 – Sep 17, 2013 GFS2 file system

lore
Share & tools
lore
#0 lore raw

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(-)
fs/gfs2/incore.h +1 -0
index f1a3243..0c8b5d8 100644
@@ -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)
fs/gfs2/rgrp.c +11 -12
index 7d64a27..fddc3f9 100644
@@ -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:
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 3/5 GFS2: Introduce rbm field bii

Hi,

This is a respin of the original patch. As Steve pointed out, the introduction of field bii makes it easy to eliminate bi itself. This revised patch does just that, replacing bi with bii.

This patch adds a new field to the rbm structure, called bii, which is an index into the array of bitmaps for an rgrp. This replaces *bi which was a pointer to the bitmap. This is being done for further optimizations.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/incore.h +9 -3
index f1a3243..a3af911 100644
@@ -102,19 +102,25 @@ struct gfs2_rgrpd {
 
 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 struct gfs2_bitmap *rbm_bi(const struct gfs2_rbm *rbm)
+{
+	return rbm->rgd->rd_bits + rbm->bii;
+}
+
 static inline u64 gfs2_rbm_to_block(const struct gfs2_rbm *rbm)
 {
-	return rbm->rgd->rd_data0 + (rbm->bi->bi_start * GFS2_NBBY) + rbm->offset;
+	return rbm->rgd->rd_data0 + (rbm_bi(rbm)->bi_start * GFS2_NBBY) +
+		rbm->offset;
 }
 
 static inline bool gfs2_rbm_eq(const struct gfs2_rbm *rbm1,
 			       const struct gfs2_rbm *rbm2)
 {
-	return (rbm1->rgd == rbm2->rgd) && (rbm1->bi == rbm2->bi) && 
+	return (rbm1->rgd == rbm2->rgd) && (rbm1->bii == rbm2->bii) && 
 	       (rbm1->offset == rbm2->offset);
 }
 
fs/gfs2/rgrp.c +56 -51

253 lines not on this page · raw message