cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 3/5] GFS2: Introduce rbm field bii
Date: Wed, 11 Sep 2013 13:43:58 -0500	[thread overview]
Message-ID: <1378925045-23318-4-git-send-email-rpeterso@redhat.com> (raw)

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



             reply	other threads:[~2013-09-11 18:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 18:43 Bob Peterson [this message]
2013-09-17 17:12 ` [Cluster-devel] [PATCH 3/5][TRY #2] GFS2: Introduce rbm field bii Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378925045-23318-4-git-send-email-rpeterso@redhat.com \
    --to=rpeterso@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).