Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e6339dd authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

GFS2: Use rbm for gfs2_setbit()



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: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent c04a2ef3
Loading
Loading
Loading
Loading
+20 −26
Original line number Original line Diff line number Diff line
@@ -69,47 +69,42 @@ static const char valid_change[16] = {


/**
/**
 * gfs2_setbit - Set a bit in the bitmaps
 * gfs2_setbit - Set a bit in the bitmaps
 * @rgd: the resource group descriptor
 * @rbm: The position of the bit to set
 * @buf2: the clone buffer that holds the bitmaps
 * @do_clone: Also set the clone bitmap, if it exists
 * @bi: the bitmap structure
 * @block: the block to set
 * @new_state: the new state of the block
 * @new_state: the new state of the block
 *
 *
 */
 */


static inline void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buf2,
static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,
			       struct gfs2_bitmap *bi, u32 block,
			       unsigned char new_state)
			       unsigned char new_state)
{
{
	unsigned char *byte1, *byte2, *end, cur_state;
	unsigned char *byte1, *byte2, *end, cur_state;
	unsigned int buflen = bi->bi_len;
	unsigned int buflen = rbm->bi->bi_len;
	const unsigned int bit = (block % GFS2_NBBY) * GFS2_BIT_SIZE;
	const unsigned int bit = (rbm->offset % GFS2_NBBY) * GFS2_BIT_SIZE;


	byte1 = bi->bi_bh->b_data + bi->bi_offset + (block / GFS2_NBBY);
	byte1 = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
	end = bi->bi_bh->b_data + bi->bi_offset + buflen;
	end = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + buflen;


	BUG_ON(byte1 >= end);
	BUG_ON(byte1 >= end);


	cur_state = (*byte1 >> bit) & GFS2_BIT_MASK;
	cur_state = (*byte1 >> bit) & GFS2_BIT_MASK;


	if (unlikely(!valid_change[new_state * 4 + cur_state])) {
	if (unlikely(!valid_change[new_state * 4 + cur_state])) {
		printk(KERN_WARNING "GFS2: buf_blk = 0x%llx old_state=%d, "
		printk(KERN_WARNING "GFS2: buf_blk = 0x%x old_state=%d, "
		       "new_state=%d\n",
		       "new_state=%d\n", rbm->offset, cur_state, new_state);
		       (unsigned long long)block, cur_state, new_state);
		printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%x\n",
		printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%lx\n",
		       (unsigned long long)rbm->rgd->rd_addr,
		       (unsigned long long)rgd->rd_addr,
		       rbm->bi->bi_start);
		       (unsigned long)bi->bi_start);
		printk(KERN_WARNING "GFS2: bi_offset=0x%x bi_len=0x%x\n",
		printk(KERN_WARNING "GFS2: bi_offset=0x%lx bi_len=0x%lx\n",
		       rbm->bi->bi_offset, rbm->bi->bi_len);
		       (unsigned long)bi->bi_offset,
		       (unsigned long)bi->bi_len);
		dump_stack();
		dump_stack();
		gfs2_consist_rgrpd(rgd);
		gfs2_consist_rgrpd(rbm->rgd);
		return;
		return;
	}
	}
	*byte1 ^= (cur_state ^ new_state) << bit;
	*byte1 ^= (cur_state ^ new_state) << bit;


	if (buf2) {
	if (do_clone && rbm->bi->bi_clone) {
		byte2 = buf2 + bi->bi_offset + (block / GFS2_NBBY);
		byte2 = rbm->bi->bi_clone + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
		cur_state = (*byte2 >> bit) & GFS2_BIT_MASK;
		cur_state = (*byte2 >> bit) & GFS2_BIT_MASK;
		*byte2 ^= (cur_state ^ new_state) << bit;
		*byte2 ^= (cur_state ^ new_state) << bit;
	}
	}
@@ -1852,8 +1847,7 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
	*n = 1;
	*n = 1;
	block = gfs2_rbm_to_block(rbm);
	block = gfs2_rbm_to_block(rbm);
	gfs2_trans_add_bh(rbm->rgd->rd_gl, rbm->bi->bi_bh, 1);
	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,
	gfs2_setbit(rbm, true, dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
		    dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
	block++;
	block++;
	while (*n < elen) {
	while (*n < elen) {
		ret = gfs2_rbm_from_block(&pos, block);
		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)
		if (gfs2_testbit(&pos) != GFS2_BLKST_FREE)
			break;
			break;
		gfs2_trans_add_bh(pos.rgd->rd_gl, pos.bi->bi_bh, 1);
		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)++;
		(*n)++;
		block++;
		block++;
	}
	}
@@ -1900,7 +1894,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
			       rbm.bi->bi_len);
			       rbm.bi->bi_len);
		}
		}
		gfs2_trans_add_bh(rbm.rgd->rd_gl, rbm.bi->bi_bh, 1);
		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;
	return rbm.rgd;