aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-08-13 06:37:51 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-09-24 05:47:16 -0400
commit3e6339dd2850353781513dec42a8d56690e9e1db (patch)
tree389902a31fd41fb669de7c37f49dba0fe13cec1d /fs/gfs2
parentc04a2ef3a8b51cf58d8ff18bb4d6af17252f0fb6 (diff)
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: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/rgrp.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 3a288cec5af0..55a2651666c9 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -69,47 +69,42 @@ static const char valid_change[16] = {
69 69
70/** 70/**
71 * gfs2_setbit - Set a bit in the bitmaps 71 * gfs2_setbit - Set a bit in the bitmaps
72 * @rgd: the resource group descriptor 72 * @rbm: The position of the bit to set
73 * @buf2: the clone buffer that holds the bitmaps 73 * @do_clone: Also set the clone bitmap, if it exists
74 * @bi: the bitmap structure
75 * @block: the block to set
76 * @new_state: the new state of the block 74 * @new_state: the new state of the block
77 * 75 *
78 */ 76 */
79 77
80static inline void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buf2, 78static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,
81 struct gfs2_bitmap *bi, u32 block,
82 unsigned char new_state) 79 unsigned char new_state)
83{ 80{
84 unsigned char *byte1, *byte2, *end, cur_state; 81 unsigned char *byte1, *byte2, *end, cur_state;
85 unsigned int buflen = bi->bi_len; 82 unsigned int buflen = rbm->bi->bi_len;
86 const unsigned int bit = (block % GFS2_NBBY) * GFS2_BIT_SIZE; 83 const unsigned int bit = (rbm->offset % GFS2_NBBY) * GFS2_BIT_SIZE;
87 84
88 byte1 = bi->bi_bh->b_data + bi->bi_offset + (block / GFS2_NBBY); 85 byte1 = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
89 end = bi->bi_bh->b_data + bi->bi_offset + buflen; 86 end = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset + buflen;
90 87
91 BUG_ON(byte1 >= end); 88 BUG_ON(byte1 >= end);
92 89
93 cur_state = (*byte1 >> bit) & GFS2_BIT_MASK; 90 cur_state = (*byte1 >> bit) & GFS2_BIT_MASK;
94 91
95 if (unlikely(!valid_change[new_state * 4 + cur_state])) { 92 if (unlikely(!valid_change[new_state * 4 + cur_state])) {
96 printk(KERN_WARNING "GFS2: buf_blk = 0x%llx old_state=%d, " 93 printk(KERN_WARNING "GFS2: buf_blk = 0x%x old_state=%d, "
97 "new_state=%d\n", 94 "new_state=%d\n", rbm->offset, cur_state, new_state);
98 (unsigned long long)block, cur_state, new_state); 95 printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%x\n",
99 printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%lx\n", 96 (unsigned long long)rbm->rgd->rd_addr,
100 (unsigned long long)rgd->rd_addr, 97 rbm->bi->bi_start);
101 (unsigned long)bi->bi_start); 98 printk(KERN_WARNING "GFS2: bi_offset=0x%x bi_len=0x%x\n",
102 printk(KERN_WARNING "GFS2: bi_offset=0x%lx bi_len=0x%lx\n", 99 rbm->bi->bi_offset, rbm->bi->bi_len);
103 (unsigned long)bi->bi_offset,
104 (unsigned long)bi->bi_len);
105 dump_stack(); 100 dump_stack();
106 gfs2_consist_rgrpd(rgd); 101 gfs2_consist_rgrpd(rbm->rgd);
107 return; 102 return;
108 } 103 }
109 *byte1 ^= (cur_state ^ new_state) << bit; 104 *byte1 ^= (cur_state ^ new_state) << bit;
110 105
111 if (buf2) { 106 if (do_clone && rbm->bi->bi_clone) {
112 byte2 = buf2 + bi->bi_offset + (block / GFS2_NBBY); 107 byte2 = rbm->bi->bi_clone + rbm->bi->bi_offset + (rbm->offset / GFS2_NBBY);
113 cur_state = (*byte2 >> bit) & GFS2_BIT_MASK; 108 cur_state = (*byte2 >> bit) & GFS2_BIT_MASK;
114 *byte2 ^= (cur_state ^ new_state) << bit; 109 *byte2 ^= (cur_state ^ new_state) << bit;
115 } 110 }
@@ -1852,8 +1847,7 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
1852 *n = 1; 1847 *n = 1;
1853 block = gfs2_rbm_to_block(rbm); 1848 block = gfs2_rbm_to_block(rbm);
1854 gfs2_trans_add_bh(rbm->rgd->rd_gl, rbm->bi->bi_bh, 1); 1849 gfs2_trans_add_bh(rbm->rgd->rd_gl, rbm->bi->bi_bh, 1);
1855 gfs2_setbit(rbm->rgd, rbm->bi->bi_clone, rbm->bi, rbm->offset, 1850 gfs2_setbit(rbm, true, dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
1856 dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
1857 block++; 1851 block++;
1858 while (*n < elen) { 1852 while (*n < elen) {
1859 ret = gfs2_rbm_from_block(&pos, block); 1853 ret = gfs2_rbm_from_block(&pos, block);
@@ -1861,7 +1855,7 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
1861 if (gfs2_testbit(&pos) != GFS2_BLKST_FREE) 1855 if (gfs2_testbit(&pos) != GFS2_BLKST_FREE)
1862 break; 1856 break;
1863 gfs2_trans_add_bh(pos.rgd->rd_gl, pos.bi->bi_bh, 1); 1857 gfs2_trans_add_bh(pos.rgd->rd_gl, pos.bi->bi_bh, 1);
1864 gfs2_setbit(pos.rgd, pos.bi->bi_clone, pos.bi, pos.offset, GFS2_BLKST_USED); 1858 gfs2_setbit(&pos, true, GFS2_BLKST_USED);
1865 (*n)++; 1859 (*n)++;
1866 block++; 1860 block++;
1867 } 1861 }
@@ -1900,7 +1894,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
1900 rbm.bi->bi_len); 1894 rbm.bi->bi_len);
1901 } 1895 }
1902 gfs2_trans_add_bh(rbm.rgd->rd_gl, rbm.bi->bi_bh, 1); 1896 gfs2_trans_add_bh(rbm.rgd->rd_gl, rbm.bi->bi_bh, 1);
1903 gfs2_setbit(rbm.rgd, NULL, rbm.bi, rbm.offset, new_state); 1897 gfs2_setbit(&rbm, false, new_state);
1904 } 1898 }
1905 1899
1906 return rbm.rgd; 1900 return rbm.rgd;