aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-08-13 06:14:57 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-09-24 05:47:14 -0400
commitc04a2ef3a8b51cf58d8ff18bb4d6af17252f0fb6 (patch)
tree7ba97efc107f3dc3b211c09121a160feacb266b0 /fs/gfs2
parent29c05b205d4d30248982d5167bb142146db89bd3 (diff)
GFS2: Use rbm for gfs2_testbit()
Change the arguments to gfs2_testbit() so that it now just takes an rbm specifying the position of the two bit entry to return. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/rgrp.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 47d2346575a..3a288cec5af 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -117,30 +117,21 @@ static inline void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buf2,
117 117
118/** 118/**
119 * gfs2_testbit - test a bit in the bitmaps 119 * gfs2_testbit - test a bit in the bitmaps
120 * @rgd: the resource group descriptor 120 * @rbm: The bit to test
121 * @buffer: the buffer that holds the bitmaps
122 * @buflen: the length (in bytes) of the buffer
123 * @block: the block to read
124 * 121 *
122 * Returns: The two bit block state of the requested bit
125 */ 123 */
126 124
127static inline unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, 125static inline u8 gfs2_testbit(const struct gfs2_rbm *rbm)
128 const unsigned char *buffer,
129 unsigned int buflen, u32 block)
130{ 126{
131 const unsigned char *byte, *end; 127 const u8 *buffer = rbm->bi->bi_bh->b_data + rbm->bi->bi_offset;
132 unsigned char cur_state; 128 const u8 *byte;
133 unsigned int bit; 129 unsigned int bit;
134 130
135 byte = buffer + (block / GFS2_NBBY); 131 byte = buffer + (rbm->offset / GFS2_NBBY);
136 bit = (block % GFS2_NBBY) * GFS2_BIT_SIZE; 132 bit = (rbm->offset % GFS2_NBBY) * GFS2_BIT_SIZE;
137 end = buffer + buflen;
138
139 gfs2_assert(rgd->rd_sbd, byte < end);
140
141 cur_state = (*byte >> bit) & GFS2_BIT_MASK;
142 133
143 return cur_state; 134 return (*byte >> bit) & GFS2_BIT_MASK;
144} 135}
145 136
146/** 137/**
@@ -1837,8 +1828,7 @@ static unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block)
1837 ret = gfs2_rbm_from_block(&rbm, block); 1828 ret = gfs2_rbm_from_block(&rbm, block);
1838 WARN_ON_ONCE(ret != 0); 1829 WARN_ON_ONCE(ret != 0);
1839 1830
1840 return gfs2_testbit(rgd, rbm.bi->bi_bh->b_data + rbm.bi->bi_offset, 1831 return gfs2_testbit(&rbm);
1841 rbm.bi->bi_len, rbm.offset);
1842} 1832}
1843 1833
1844 1834
@@ -1846,42 +1836,35 @@ static unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block)
1846 * gfs2_alloc_extent - allocate an extent from a given bitmap 1836 * gfs2_alloc_extent - allocate an extent from a given bitmap
1847 * @rbm: the resource group information 1837 * @rbm: the resource group information
1848 * @dinode: TRUE if the first block we allocate is for a dinode 1838 * @dinode: TRUE if the first block we allocate is for a dinode
1849 * @n: The extent length 1839 * @n: The extent length (value/result)
1850 * 1840 *
1851 * Add the found bitmap buffer to the transaction. 1841 * Add the bitmap buffer to the transaction.
1852 * Set the found bits to @new_state to change block's allocation state. 1842 * Set the found bits to @new_state to change block's allocation state.
1853 * Returns: starting block number of the extent (fs scope)
1854 */ 1843 */
1855static u64 gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode, 1844static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
1856 unsigned int *n) 1845 unsigned int *n)
1857{ 1846{
1858 struct gfs2_rgrpd *rgd = rbm->rgd; 1847 struct gfs2_rbm pos = { .rgd = rbm->rgd, };
1859 struct gfs2_bitmap *bi = rbm->bi;
1860 u32 blk = rbm->offset;
1861 const unsigned int elen = *n; 1848 const unsigned int elen = *n;
1862 u32 goal; 1849 u64 block;
1863 const u8 *buffer = NULL; 1850 int ret;
1864 1851
1865 *n = 0; 1852 *n = 1;
1866 buffer = bi->bi_bh->b_data + bi->bi_offset; 1853 block = gfs2_rbm_to_block(rbm);
1867 gfs2_trans_add_bh(rgd->rd_gl, bi->bi_bh, 1); 1854 gfs2_trans_add_bh(rbm->rgd->rd_gl, rbm->bi->bi_bh, 1);
1868 gfs2_setbit(rgd, bi->bi_clone, bi, blk, 1855 gfs2_setbit(rbm->rgd, rbm->bi->bi_clone, rbm->bi, rbm->offset,
1869 dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); 1856 dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
1870 (*n)++; 1857 block++;
1871 goal = blk;
1872 while (*n < elen) { 1858 while (*n < elen) {
1873 goal++; 1859 ret = gfs2_rbm_from_block(&pos, block);
1874 if (goal >= (bi->bi_len * GFS2_NBBY)) 1860 WARN_ON(ret);
1875 break; 1861 if (gfs2_testbit(&pos) != GFS2_BLKST_FREE)
1876 if (gfs2_testbit(rgd, buffer, bi->bi_len, goal) !=
1877 GFS2_BLKST_FREE)
1878 break; 1862 break;
1879 gfs2_setbit(rgd, bi->bi_clone, bi, goal, GFS2_BLKST_USED); 1863 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);
1880 (*n)++; 1865 (*n)++;
1866 block++;
1881 } 1867 }
1882 blk = gfs2_bi2rgd_blk(bi, blk);
1883 rgd->rd_last_alloc = blk + *n - 1;
1884 return rgd->rd_data0 + blk;
1885} 1868}
1886 1869
1887/** 1870/**
@@ -2042,7 +2025,8 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
2042 goto rgrp_error; 2025 goto rgrp_error;
2043 } 2026 }
2044 2027
2045 block = gfs2_alloc_extent(&rbm, dinode, nblocks); 2028 gfs2_alloc_extent(&rbm, dinode, nblocks);
2029 block = gfs2_rbm_to_block(&rbm);
2046 if (gfs2_rs_active(ip->i_res)) 2030 if (gfs2_rs_active(ip->i_res))
2047 gfs2_adjust_reservation(ip, &rbm, *nblocks); 2031 gfs2_adjust_reservation(ip, &rbm, *nblocks);
2048 ndata = *nblocks; 2032 ndata = *nblocks;