aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2013-09-17 13:14:35 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2013-09-18 05:40:38 -0400
commit149ed7f51e279916e7a7a1eef5cec50da67d7cfe (patch)
tree36e24333ca87d57d2bff0996c9d7680037945539 /fs/gfs2
parente579ed4f446e64748a2d26eed8f8b28f728495bd (diff)
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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/rgrp.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index dd3c4d3d7f41..285dd363199a 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -274,6 +274,32 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
274} 274}
275 275
276/** 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
288static 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
302/**
277 * gfs2_unaligned_extlen - Look for free blocks which are not byte aligned 303 * gfs2_unaligned_extlen - Look for free blocks which are not byte aligned
278 * @rbm: Position to search (value/result) 304 * @rbm: Position to search (value/result)
279 * @n_unaligned: Number of unaligned blocks to check 305 * @n_unaligned: Number of unaligned blocks to check
@@ -284,7 +310,6 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
284 310
285static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *len) 311static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *len)
286{ 312{
287 u64 block;
288 u32 n; 313 u32 n;
289 u8 res; 314 u8 res;
290 315
@@ -295,8 +320,7 @@ static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *le
295 (*len)--; 320 (*len)--;
296 if (*len == 0) 321 if (*len == 0)
297 return true; 322 return true;
298 block = gfs2_rbm_to_block(rbm); 323 if (gfs2_rbm_incr(rbm))
299 if (gfs2_rbm_from_block(rbm, block + 1))
300 return true; 324 return true;
301 } 325 }
302 326