mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: linux-kernel@vger.kernel.org, cluster-devel@redhat.com
Cc: Steven Whitehouse <swhiteho@redhat.com>
Subject: [PATCH 17/27] GFS2: Use rbm for gfs2_setbit()
Date: Wed, 26 Sep 2012 09:25:38 +0100	[thread overview]
Message-ID: <1348647948-3219-18-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1348647948-3219-1-git-send-email-swhiteho@redhat.com>

Use the rbm structure for gfs2_setbit() in order to simplify the
arguments to the function. We have to add a bool to control whether
the clone bitmap should be updated (if it exists) but otherwise it
is a more or less direct substitution.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 3a288ce..55a2651 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -69,47 +69,42 @@ static const char valid_change[16] = {
 
 /**
  * gfs2_setbit - Set a bit in the bitmaps
- * @rgd: the resource group descriptor
- * @buf2: the clone buffer that holds the bitmaps
- * @bi: the bitmap structure
- * @block: the block to set
+ * @rbm: The position of the bit to set
+ * @do_clone: Also set the clone bitmap, if it exists
  * @new_state: the new state of the block
  *
  */
 
-static inline void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buf2,
-			       struct gfs2_bitmap *bi, u32 block,
+static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,
 			       unsigned char new_state)
 {
 	unsigned char *byte1, *byte2, *end, cur_state;
-	unsigned int buflen = bi->bi_len;
-	const unsigned int bit = (block % GFS2_NBBY) * GFS2_BIT_SIZE;
+	unsigned int buflen = rbm->bi->bi_len;
+	const unsigned int bit = (rbm->offset % GFS2_NBBY) * GFS2_BIT_SIZE;
 
-	byte1 = bi->bi_bh->b_data + bi->bi_offset + (block / GFS2_NBBY);
-	end = bi->bi_bh->b_data + bi->bi_offset + buflen;
+	byte1 = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
+	end = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + buflen;
 
 	BUG_ON(byte1 >= end);
 
 	cur_state = (*byte1 >> bit) & GFS2_BIT_MASK;
 
 	if (unlikely(!valid_change[new_state * 4 + cur_state])) {
-		printk(KERN_WARNING "GFS2: buf_blk = 0x%llx old_state=%d, "
-		       "new_state=%d\n",
-		       (unsigned long long)block, cur_state, new_state);
-		printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%lx\n",
-		       (unsigned long long)rgd->rd_addr,
-		       (unsigned long)bi->bi_start);
-		printk(KERN_WARNING "GFS2: bi_offset=0x%lx bi_len=0x%lx\n",
-		       (unsigned long)bi->bi_offset,
-		       (unsigned long)bi->bi_len);
+		printk(KERN_WARNING "GFS2: buf_blk = 0x%x old_state=%d, "
+		       "new_state=%d\n", rbm->offset, cur_state, new_state);
+		printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%x\n",
+		       (unsigned long long)rbm->rgd->rd_addr,
+		       rbm->bi->bi_start);
+		printk(KERN_WARNING "GFS2: bi_offset=0x%x bi_len=0x%x\n",
+		       rbm->bi->bi_offset, rbm->bi->bi_len);
 		dump_stack();
-		gfs2_consist_rgrpd(rgd);
+		gfs2_consist_rgrpd(rbm->rgd);
 		return;
 	}
 	*byte1 ^= (cur_state ^ new_state) << bit;
 
-	if (buf2) {
-		byte2 = buf2 + bi->bi_offset + (block / GFS2_NBBY);
+	if (do_clone && rbm->bi->bi_clone) {
+		byte2 = rbm->bi->bi_clone + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
 		cur_state = (*byte2 >> bit) & GFS2_BIT_MASK;
 		*byte2 ^= (cur_state ^ new_state) << bit;
 	}
@@ -1852,8 +1847,7 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
 	*n = 1;
 	block = gfs2_rbm_to_block(rbm);
 	gfs2_trans_add_bh(rbm->rgd->rd_gl, rbm->bi->bi_bh, 1);
-	gfs2_setbit(rbm->rgd, rbm->bi->bi_clone, rbm->bi, rbm->offset,
-		    dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
+	gfs2_setbit(rbm, true, dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
 	block++;
 	while (*n < elen) {
 		ret = gfs2_rbm_from_block(&pos, block);
@@ -1861,7 +1855,7 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
 		if (gfs2_testbit(&pos) != GFS2_BLKST_FREE)
 			break;
 		gfs2_trans_add_bh(pos.rgd->rd_gl, pos.bi->bi_bh, 1);
-		gfs2_setbit(pos.rgd, pos.bi->bi_clone, pos.bi, pos.offset, GFS2_BLKST_USED);
+		gfs2_setbit(&pos, true, GFS2_BLKST_USED);
 		(*n)++;
 		block++;
 	}
@@ -1900,7 +1894,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
 			       rbm.bi->bi_len);
 		}
 		gfs2_trans_add_bh(rbm.rgd->rd_gl, rbm.bi->bi_bh, 1);
-		gfs2_setbit(rbm.rgd, NULL, rbm.bi, rbm.offset, new_state);
+		gfs2_setbit(&rbm, false, new_state);
 	}
 
 	return rbm.rgd;
-- 
1.7.4


  parent reply	other threads:[~2012-09-26  8:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  8:25 GFS2: Pre-pull patch posting (merge window) Steven Whitehouse
2012-09-26  8:25 ` [PATCH 01/27] GFS2: Merge two nearly identical xattr functions Steven Whitehouse
2012-09-26  8:25 ` [PATCH 02/27] GFS2: Remove rs_requested field from reservations Steven Whitehouse
2012-09-26  8:25 ` [PATCH 03/27] GFS2: Add structure to contain rgrp, bitmap, offset tuple Steven Whitehouse
2012-09-26  8:25 ` [PATCH 04/27] GFS2: Replace rgblk_search with gfs2_rbm_find Steven Whitehouse
2012-09-26  8:25 ` [PATCH 05/27] GFS2: Update gfs2_get_block_type() to use rbm Steven Whitehouse
2012-09-26  8:25 ` [PATCH 06/27] GFS2: Update rgblk_free() " Steven Whitehouse
2012-09-26  8:25 ` [PATCH 07/27] GFS2: Use RB_CLEAR_NODE() rather than rb_init_node() Steven Whitehouse
2012-09-26  8:25 ` [PATCH 08/27] GFS2: Fix case where reservation finished at end of rgrp Steven Whitehouse
2012-09-26  8:25 ` [PATCH 09/27] GFS2: rbm code cleanup Steven Whitehouse
2012-09-26  8:25 ` [PATCH 10/27] GFS2: change function gfs2_direct_IO to use a normal gfs2_glock_dq Steven Whitehouse
2012-09-26  8:25 ` [PATCH 11/27] GFS2: inline __gfs2_glock_schedule_for_reclaim Steven Whitehouse
2012-09-26  8:25 ` [PATCH 12/27] GFS2: Combine functions gfs2_glock_wait and wait_on_holder Steven Whitehouse
2012-09-26  8:25 ` [PATCH 13/27] GFS2: Combine functions gfs2_glock_dq_wait and wait_on_demote Steven Whitehouse
2012-09-26  8:25 ` [PATCH 14/27] GFS2: Eliminate redundant calls to may_grant Steven Whitehouse
2012-09-26  8:25 ` [PATCH 15/27] GFS2: Eliminate unnecessary check for state > 3 in bitfit Steven Whitehouse
2012-09-26  8:25 ` [PATCH 16/27] GFS2: Use rbm for gfs2_testbit() Steven Whitehouse
2012-09-26  8:25 ` Steven Whitehouse [this message]
2012-09-26  8:25 ` [PATCH 18/27] GFS2: Fix ->show_options() for statfs slow Steven Whitehouse
2012-09-26  8:25 ` [PATCH 19/27] GFS2: Fall back to ignoring reservations, if there are no other blocks left Steven Whitehouse
2012-09-26  8:25 ` [PATCH 20/27] GFS2: Improve block reservation tracing Steven Whitehouse
2012-09-26  8:25 ` [PATCH 21/27] GFS2: Fix unclaimed_blocks() wrapping bug and clean up Steven Whitehouse
2012-09-26  8:25 ` [PATCH 22/27] GFS2: Stop block extents at the end of bitmaps Steven Whitehouse
2012-09-26  8:25 ` [PATCH 23/27] GFS2: Get rid of I_MUTEX_QUOTA usage Steven Whitehouse
2012-09-26  8:25 ` [PATCH 24/27] GFS2: Consolidate free block searching functions Steven Whitehouse
2012-09-26  8:25 ` [PATCH 25/27] GFS2: Fix infinite loop in rbm_find Steven Whitehouse
2012-09-26  8:25 ` [PATCH 26/27] GFS2: fix s_writers.counter imbalance in gfs2_ail_empty_gl Steven Whitehouse
2012-09-26  8:25 ` [PATCH 27/27] GFS2: Write out dirty inode metadata in delayed deletes Steven Whitehouse

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=1348647948-3219-18-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome