Skip to content

Commit 149ed7f

Browse files
AstralBobswhiteho
authored andcommitted
GFS2: new function gfs2_rbm_incr
Since the previous patch eliminated bi in favor of bii, this follow-on patch needed to be adjusted accordingly. Here is the revised version. This patch adds a new function, gfs2_rbm_incr, which increments an rbm structure. This is more efficient than calling gfs2_rbm_to_block, incrementing, then calling gfs2_rbm_from_block. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent e579ed4 commit 149ed7f

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

‎fs/gfs2/rgrp.c‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,32 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
273273
return 0;
274274
}
275275

276+
/**
277+
* gfs2_rbm_incr - increment an rbm structure
278+
* @rbm: The rbm with rgd already set correctly
279+
*
280+
* This function takes an existing rbm structure and increments it to the next
281+
* viable block offset.
282+
*
283+
* Returns: If incrementing the offset would cause the rbm to go past the
284+
* end of the rgrp, true is returned, otherwise false.
285+
*
286+
*/
287+
288+
static bool gfs2_rbm_incr(struct gfs2_rbm *rbm)
289+
{
290+
if (rbm->offset + 1 < rbm_bi(rbm)->bi_blocks) { /* in the same bitmap */
291+
rbm->offset++;
292+
return false;
293+
}
294+
if (rbm->bii == rbm->rgd->rd_length - 1) /* at the last bitmap */
295+
return true;
296+
297+
rbm->offset = 0;
298+
rbm->bii++;
299+
return false;
300+
}
301+
276302
/**
277303
* gfs2_unaligned_extlen - Look for free blocks which are not byte aligned
278304
* @rbm: Position to search (value/result)
@@ -284,7 +310,6 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
284310

285311
static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *len)
286312
{
287-
u64 block;
288313
u32 n;
289314
u8 res;
290315

@@ -295,8 +320,7 @@ static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *le
295320
(*len)--;
296321
if (*len == 0)
297322
return true;
298-
block = gfs2_rbm_to_block(rbm);
299-
if (gfs2_rbm_from_block(rbm, block + 1))
323+
if (gfs2_rbm_incr(rbm))
300324
return true;
301325
}
302326

0 commit comments

Comments
 (0)