Skip to content

Commit 4a993fb

Browse files
committed
GFS2: Add structure to contain rgrp, bitmap, offset tuple
This patch introduces a new structure, gfs2_rbm, which is a tuple of a resource group, a bitmap within the resource group and an offset within that bitmap. This is designed to make manipulating these sets of variables easier. There is also a new helper function which converts this representation back to a disk block address. In addition, the rbtree nodes which are used for the reservations were not being correctly initialised, which is now fixed. Also, the tracing was not passing through the inode where it should have been. That is mostly fixed aside from one corner case. This needs to be revisited since there can also be a NULL rgrp in some cases which results in the device being incorrect in the trace. This is intended to be the first step towards cleaning up some of the allocation code, and some further bug fixes. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 71f890f commit 4a993fb

6 files changed

Lines changed: 105 additions & 115 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
786786
goto out_rlist;
787787

788788
if (gfs2_rs_active(ip->i_res)) /* needs to be done with the rgrp glock held */
789-
gfs2_rs_deltree(ip->i_res);
789+
gfs2_rs_deltree(ip, ip->i_res);
790790

791791
error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
792792
RES_INDIRECT + RES_STATFS + RES_QUOTA,

‎fs/gfs2/incore.h‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ struct gfs2_rgrpd {
102102
u32 rd_rs_cnt; /* count of current reservations */
103103
};
104104

105+
struct gfs2_rbm {
106+
struct gfs2_rgrpd *rgd;
107+
struct gfs2_bitmap *bi; /* Bitmap must belong to the rgd */
108+
u32 offset; /* The offset is bitmap relative */
109+
};
110+
111+
static inline u64 gfs2_rbm_to_block(const struct gfs2_rbm *rbm)
112+
{
113+
return rbm->rgd->rd_data0 + (rbm->bi->bi_start * GFS2_NBBY) + rbm->offset;
114+
}
115+
105116
enum gfs2_state_bits {
106117
BH_Pinned = BH_PrivateStart,
107118
BH_Escaped = BH_PrivateStart + 1,
@@ -251,13 +262,11 @@ struct gfs2_blkreserv {
251262
atomic_t rs_sizehint; /* hint of the write size */
252263

253264
/* components used during get_local_rgrp (step 3): */
254-
struct gfs2_rgrpd *rs_rgd; /* pointer to the gfs2_rgrpd */
265+
struct gfs2_rbm rs_rbm;
255266
struct gfs2_holder rs_rgd_gh; /* Filled in by get_local_rgrp */
256267
struct rb_node rs_node; /* link to other block reservations */
257268

258269
/* components used during block searches and assignments (step 4): */
259-
struct gfs2_bitmap *rs_bi; /* bitmap for the current allocation */
260-
u32 rs_biblk; /* start block relative to the bi */
261270
u32 rs_free; /* how many blocks are still free */
262271

263272
/* ancillary quota stuff */

0 commit comments

Comments
 (0)