diff options
author | Bob Peterson <rpeterso@redhat.com> | 2012-08-07 13:28:17 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2012-09-24 05:47:04 -0400 |
commit | 8d8b752a0f55282498b918f6a28f87ee2bcf19c3 (patch) | |
tree | 5d8727cc91b4bf928e313fc28ae291b222bbf097 /fs/gfs2 | |
parent | 5d50d5324612d28c47b9361e5424f13a19c888cd (diff) |
GFS2: rbm code cleanup
This patch fixes a few small rbm related things. First, it fixes
a corner case where the rbm needs to switch bitmaps and wasn't
adjusting its buffer pointer. Second, there's a white space issue
fixed. Third, the logic in function gfs2_rbm_from_block was optimized
a bit. Lastly, a check for goal block overflows was added to function
gfs2_alloc_blocks.
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.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index c17029a92b8f..c26711882a6b 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -467,7 +467,7 @@ int gfs2_rs_alloc(struct gfs2_inode *ip) | |||
467 | static void dump_rs(struct seq_file *seq, struct gfs2_blkreserv *rs) | 467 | static void dump_rs(struct seq_file *seq, struct gfs2_blkreserv *rs) |
468 | { | 468 | { |
469 | gfs2_print_dbg(seq, " r: %llu s:%llu b:%u f:%u\n", | 469 | gfs2_print_dbg(seq, " r: %llu s:%llu b:%u f:%u\n", |
470 | rs->rs_rbm.rgd->rd_addr, gfs2_rbm_to_block(&rs->rs_rbm), | 470 | rs->rs_rbm.rgd->rd_addr, gfs2_rbm_to_block(&rs->rs_rbm), |
471 | rs->rs_rbm.offset, rs->rs_free); | 471 | rs->rs_rbm.offset, rs->rs_free); |
472 | } | 472 | } |
473 | 473 | ||
@@ -1493,16 +1493,18 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) | |||
1493 | 1493 | ||
1494 | if (WARN_ON_ONCE(rblock > UINT_MAX)) | 1494 | if (WARN_ON_ONCE(rblock > UINT_MAX)) |
1495 | return -EINVAL; | 1495 | return -EINVAL; |
1496 | if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) | ||
1497 | return -E2BIG; | ||
1496 | 1498 | ||
1497 | for (x = 0; x < rbm->rgd->rd_length; x++) { | 1499 | for (x = 0; x < rbm->rgd->rd_length; x++) { |
1498 | rbm->bi = rbm->rgd->rd_bits + x; | 1500 | rbm->bi = rbm->rgd->rd_bits + x; |
1499 | if (goal < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) { | 1501 | if (goal < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) { |
1500 | rbm->offset = goal - (rbm->bi->bi_start * GFS2_NBBY); | 1502 | rbm->offset = goal - (rbm->bi->bi_start * GFS2_NBBY); |
1501 | return 0; | 1503 | break; |
1502 | } | 1504 | } |
1503 | } | 1505 | } |
1504 | 1506 | ||
1505 | return -E2BIG; | 1507 | return 0; |
1506 | } | 1508 | } |
1507 | 1509 | ||
1508 | /** | 1510 | /** |
@@ -1579,7 +1581,6 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, | |||
1579 | WARN_ON(!buffer_uptodate(bh)); | 1581 | WARN_ON(!buffer_uptodate(bh)); |
1580 | if (state != GFS2_BLKST_UNLINKED && rbm->bi->bi_clone) | 1582 | if (state != GFS2_BLKST_UNLINKED && rbm->bi->bi_clone) |
1581 | buffer = rbm->bi->bi_clone + rbm->bi->bi_offset; | 1583 | buffer = rbm->bi->bi_clone + rbm->bi->bi_offset; |
1582 | find_next: | ||
1583 | initial_offset = rbm->offset; | 1584 | initial_offset = rbm->offset; |
1584 | offset = gfs2_bitfit(buffer, rbm->bi->bi_len, rbm->offset, state); | 1585 | offset = gfs2_bitfit(buffer, rbm->bi->bi_len, rbm->offset, state); |
1585 | if (offset == BFITNOENT) | 1586 | if (offset == BFITNOENT) |
@@ -1594,7 +1595,7 @@ find_next: | |||
1594 | return 0; | 1595 | return 0; |
1595 | if (ret > 0) { | 1596 | if (ret > 0) { |
1596 | n += (rbm->bi - initial_bi); | 1597 | n += (rbm->bi - initial_bi); |
1597 | goto find_next; | 1598 | goto next_iter; |
1598 | } | 1599 | } |
1599 | if (ret == -E2BIG) { | 1600 | if (ret == -E2BIG) { |
1600 | index = 0; | 1601 | index = 0; |
@@ -1619,6 +1620,7 @@ res_covered_end_of_rgrp: | |||
1619 | if ((index == 0) && nowrap) | 1620 | if ((index == 0) && nowrap) |
1620 | break; | 1621 | break; |
1621 | n++; | 1622 | n++; |
1623 | next_iter: | ||
1622 | if (n >= iters) | 1624 | if (n >= iters) |
1623 | break; | 1625 | break; |
1624 | } | 1626 | } |
@@ -2028,6 +2030,10 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks, | |||
2028 | else | 2030 | else |
2029 | goal = rbm.rgd->rd_last_alloc + rbm.rgd->rd_data0; | 2031 | goal = rbm.rgd->rd_last_alloc + rbm.rgd->rd_data0; |
2030 | 2032 | ||
2033 | if ((goal < rbm.rgd->rd_data0) || | ||
2034 | (goal >= rbm.rgd->rd_data0 + rbm.rgd->rd_data)) | ||
2035 | rbm.rgd = gfs2_blk2rgrpd(sdp, goal, 1); | ||
2036 | |||
2031 | gfs2_rbm_from_block(&rbm, goal); | 2037 | gfs2_rbm_from_block(&rbm, goal); |
2032 | error = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, ip, false); | 2038 | error = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, ip, false); |
2033 | 2039 | ||