cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start
@ 2013-09-11 18:44 Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 2/5] GFS2: introduce bi_blocks for optimization Bob Peterson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bob Peterson @ 2013-09-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

In function gfs2_rbm_from_block, it starts by checking if the block
falls within the first bitmap. It does so by checking if the rbm's
offset is less than (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY.
However, the first bitmap will always have bi_start==0. Therefore
this is an unnecessary calculation in a function that gets called
billions of times. This patch removes the reference to bi_start.
---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 6931743..7a6fa03 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -262,7 +262,7 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 	rbm->bi = rbm->rgd->rd_bits;
 	rbm->offset = (u32)(rblock);
 	/* Check if the block is within the first block */
-	if (rbm->offset < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY)
+	if (rbm->offset < rbm->bi->bi_len * GFS2_NBBY)
 		return 0;
 
 	/* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH 2/5] GFS2: introduce bi_blocks for optimization
  2013-09-11 18:44 [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start Bob Peterson
@ 2013-09-11 18:44 ` Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 3/5] GFS2: Introduce rbm field bii Bob Peterson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2013-09-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch introduces a new field in the bitmap structure called
bi_blocks. Its purpose is to save us from constantly multiplying
bi_len by the constant GFS2_NBBY. It also paves the way for more
optimization in a future patch.
---
 fs/gfs2/incore.h | 1 +
 fs/gfs2/rgrp.c   | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 26aabd7..f1a3243 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -71,6 +71,7 @@ struct gfs2_bitmap {
 	u32 bi_offset;
 	u32 bi_start;
 	u32 bi_len;
+	u32 bi_blocks;
 };
 
 struct gfs2_rgrpd {
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7a6fa03..7d64a27 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -262,7 +262,7 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 	rbm->bi = rbm->rgd->rd_bits;
 	rbm->offset = (u32)(rblock);
 	/* Check if the block is within the first block */
-	if (rbm->offset < rbm->bi->bi_len * GFS2_NBBY)
+	if (rbm->offset < rbm->bi->bi_blocks)
 		return 0;
 
 	/* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */
@@ -743,18 +743,21 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
 			bi->bi_offset = sizeof(struct gfs2_rgrp);
 			bi->bi_start = 0;
 			bi->bi_len = bytes;
+			bi->bi_blocks = bytes * GFS2_NBBY;
 		/* header block */
 		} else if (x == 0) {
 			bytes = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_rgrp);
 			bi->bi_offset = sizeof(struct gfs2_rgrp);
 			bi->bi_start = 0;
 			bi->bi_len = bytes;
+			bi->bi_blocks = bytes * GFS2_NBBY;
 		/* last block */
 		} else if (x + 1 == length) {
 			bytes = bytes_left;
 			bi->bi_offset = sizeof(struct gfs2_meta_header);
 			bi->bi_start = rgd->rd_bitbytes - bytes_left;
 			bi->bi_len = bytes;
+			bi->bi_blocks = bytes * GFS2_NBBY;
 		/* other blocks */
 		} else {
 			bytes = sdp->sd_sb.sb_bsize -
@@ -762,6 +765,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
 			bi->bi_offset = sizeof(struct gfs2_meta_header);
 			bi->bi_start = rgd->rd_bitbytes - bytes_left;
 			bi->bi_len = bytes;
+			bi->bi_blocks = bytes * GFS2_NBBY;
 		}
 
 		bytes_left -= bytes;
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH 3/5] GFS2: Introduce rbm field bii
  2013-09-11 18:44 [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 2/5] GFS2: introduce bi_blocks for optimization Bob Peterson
@ 2013-09-11 18:44 ` Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 4/5] GFS2: new function gfs2_rbm_incr Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations Bob Peterson
  3 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2013-09-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH 4/5] GFS2: new function gfs2_rbm_incr
  2013-09-11 18:44 [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 2/5] GFS2: introduce bi_blocks for optimization Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 3/5] GFS2: Introduce rbm field bii Bob Peterson
@ 2013-09-11 18:44 ` Bob Peterson
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations Bob Peterson
  3 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2013-09-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch adds a new function, gfs2_rbm_incr, which increments
an rbm structure. This is more efficient than calling gfs2_rbm_to_block,
incrementing, then calling gfs2_rbm_from_block.
---
 fs/gfs2/rgrp.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index fddc3f9..f023ca6 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -275,6 +275,33 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 }
 
 /**
+ * gfs2_rbm_incr - increment an rbm structure
+ * @rbm: The rbm with rgd already set correctly
+ *
+ * This function takes an existing rbm structure and increments it to the next
+ * viable block offset.
+ *
+ * Returns: If incrementing the offset would cause the rbm to go past the
+ *          end of the rgrp, true is returned, otherwise false.
+ *
+ */
+
+static bool gfs2_rbm_incr(struct gfs2_rbm *rbm)
+{
+	if (rbm->offset + 1 < rbm->bi->bi_blocks) { /* in the same bitmap */
+		rbm->offset++;
+		return false;
+	}
+	if (rbm->bii == rbm->rgd->rd_length - 1) /* at the last bitmap */
+		return true;
+
+	rbm->offset = 0;
+	rbm->bii++;
+	rbm->bi++;
+	return false;
+}
+
+/**
  * gfs2_unaligned_extlen - Look for free blocks which are not byte aligned
  * @rbm: Position to search (value/result)
  * @n_unaligned: Number of unaligned blocks to check
@@ -285,7 +312,6 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 
 static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *len)
 {
-	u64 block;
 	u32 n;
 	u8 res;
 
@@ -296,8 +322,7 @@ static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *le
 		(*len)--;
 		if (*len == 0)
 			return true;
-		block = gfs2_rbm_to_block(rbm);
-		if (gfs2_rbm_from_block(rbm, block + 1))
+		if (gfs2_rbm_incr(rbm))
 			return true;
 	}
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations
  2013-09-11 18:44 [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start Bob Peterson
                   ` (2 preceding siblings ...)
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 4/5] GFS2: new function gfs2_rbm_incr Bob Peterson
@ 2013-09-11 18:44 ` Bob Peterson
  2013-09-17  9:48   ` Steven Whitehouse
  3 siblings, 1 reply; 6+ messages in thread
From: Bob Peterson @ 2013-09-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

When we used try locks for rgrps on block allocations, it was important
to clear the flags field so that we used a blocking hold on the glock.
Now that we're not doing try locks, clearing flags is unnecessary, and
a waste of time. In fact, it's probably doing the wrong thing because
it clears the GL_SKIP bit that was set for the lvb tracking purposes.
---
 fs/gfs2/rgrp.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index f023ca6..e4f3362 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1849,7 +1849,6 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested, u32 aflags)
 		return -EINVAL;
 	if (gfs2_rs_active(rs)) {
 		begin = rs->rs_rbm.rgd;
-		flags = 0; /* Yoda: Do or do not. There is no try */
 	} else if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) {
 		rs->rs_rbm.rgd = begin = ip->i_rgd;
 	} else {
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations
  2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations Bob Peterson
@ 2013-09-17  9:48   ` Steven Whitehouse
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Whitehouse @ 2013-09-17  9:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

So I've taken patches 1,2 and 5 from this series. I know that you are
looking into being able to reduce the rbm size by using just the bii and
removing the bitmap pointer, so I'll leave 3 & 4 until thats ready too,
if that makes sense?

Steve.

On Wed, 2013-09-11 at 13:44 -0500, Bob Peterson wrote:
> When we used try locks for rgrps on block allocations, it was important
> to clear the flags field so that we used a blocking hold on the glock.
> Now that we're not doing try locks, clearing flags is unnecessary, and
> a waste of time. In fact, it's probably doing the wrong thing because
> it clears the GL_SKIP bit that was set for the lvb tracking purposes.
> ---
>  fs/gfs2/rgrp.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index f023ca6..e4f3362 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -1849,7 +1849,6 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested, u32 aflags)
>  		return -EINVAL;
>  	if (gfs2_rs_active(rs)) {
>  		begin = rs->rs_rbm.rgd;
> -		flags = 0; /* Yoda: Do or do not. There is no try */
>  	} else if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) {
>  		rs->rs_rbm.rgd = begin = ip->i_rgd;
>  	} else {




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-17  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 18:44 [Cluster-devel] [GFS2 PATCH 1/5] GFS2: optimize rbm_from_block wrt bi_start Bob Peterson
2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 2/5] GFS2: introduce bi_blocks for optimization Bob Peterson
2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 3/5] GFS2: Introduce rbm field bii Bob Peterson
2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 4/5] GFS2: new function gfs2_rbm_incr Bob Peterson
2013-09-11 18:44 ` [Cluster-devel] [GFS2 PATCH 5/5] GFS2: Do not reset flags on active reservations Bob Peterson
2013-09-17  9:48   ` Steven Whitehouse

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).