aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWang Sheng-Hui <shhuiw@gmail.com>2012-11-30 01:30:14 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:17 -0500
commit960097622d48bf0ee8f6c0cf751a904066c4b45b (patch)
treed59435ff5f8e34cfb70586beb82dbbc654a7a279 /fs
parent43baa579b3b1f059f68c51ef754ec59c87a35745 (diff)
Btrfs: use ctl->unit for free space calculation instead of block_group->sectorsize
We should use ctl->unit for free space calculation instead of block_group->sectorsize even though for free space use_bitmap or free space cluster we only have sectorsize assigned to ctl->unit currently. Also, we can keep it consisten in code style. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/free-space-cache.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index efdd1d3f441c..59ea2e4349c9 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1353,7 +1353,7 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl)
1353 u64 bitmap_bytes; 1353 u64 bitmap_bytes;
1354 u64 extent_bytes; 1354 u64 extent_bytes;
1355 u64 size = block_group->key.offset; 1355 u64 size = block_group->key.offset;
1356 u64 bytes_per_bg = BITS_PER_BITMAP * block_group->sectorsize; 1356 u64 bytes_per_bg = BITS_PER_BITMAP * ctl->unit;
1357 int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg); 1357 int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg);
1358 1358
1359 BUG_ON(ctl->total_bitmaps > max_bitmaps); 1359 BUG_ON(ctl->total_bitmaps > max_bitmaps);
@@ -1639,8 +1639,7 @@ static bool use_bitmap(struct btrfs_free_space_ctl *ctl,
1639 * some block groups are so tiny they can't be enveloped by a bitmap, so 1639 * some block groups are so tiny they can't be enveloped by a bitmap, so
1640 * don't even bother to create a bitmap for this 1640 * don't even bother to create a bitmap for this
1641 */ 1641 */
1642 if (BITS_PER_BITMAP * block_group->sectorsize > 1642 if (BITS_PER_BITMAP * ctl->unit > block_group->key.offset)
1643 block_group->key.offset)
1644 return false; 1643 return false;
1645 1644
1646 return true; 1645 return true;
@@ -2287,10 +2286,10 @@ static int btrfs_bitmap_cluster(struct btrfs_block_group_cache *block_group,
2287 unsigned long total_found = 0; 2286 unsigned long total_found = 0;
2288 int ret; 2287 int ret;
2289 2288
2290 i = offset_to_bit(entry->offset, block_group->sectorsize, 2289 i = offset_to_bit(entry->offset, ctl->unit,
2291 max_t(u64, offset, entry->offset)); 2290 max_t(u64, offset, entry->offset));
2292 want_bits = bytes_to_bits(bytes, block_group->sectorsize); 2291 want_bits = bytes_to_bits(bytes, ctl->unit);
2293 min_bits = bytes_to_bits(min_bytes, block_group->sectorsize); 2292 min_bits = bytes_to_bits(min_bytes, ctl->unit);
2294 2293
2295again: 2294again:
2296 found_bits = 0; 2295 found_bits = 0;
@@ -2314,23 +2313,22 @@ again:
2314 2313
2315 total_found += found_bits; 2314 total_found += found_bits;
2316 2315
2317 if (cluster->max_size < found_bits * block_group->sectorsize) 2316 if (cluster->max_size < found_bits * ctl->unit)
2318 cluster->max_size = found_bits * block_group->sectorsize; 2317 cluster->max_size = found_bits * ctl->unit;
2319 2318
2320 if (total_found < want_bits || cluster->max_size < cont1_bytes) { 2319 if (total_found < want_bits || cluster->max_size < cont1_bytes) {
2321 i = next_zero + 1; 2320 i = next_zero + 1;
2322 goto again; 2321 goto again;
2323 } 2322 }
2324 2323
2325 cluster->window_start = start * block_group->sectorsize + 2324 cluster->window_start = start * ctl->unit + entry->offset;
2326 entry->offset;
2327 rb_erase(&entry->offset_index, &ctl->free_space_offset); 2325 rb_erase(&entry->offset_index, &ctl->free_space_offset);
2328 ret = tree_insert_offset(&cluster->root, entry->offset, 2326 ret = tree_insert_offset(&cluster->root, entry->offset,
2329 &entry->offset_index, 1); 2327 &entry->offset_index, 1);
2330 BUG_ON(ret); /* -EEXIST; Logic error */ 2328 BUG_ON(ret); /* -EEXIST; Logic error */
2331 2329
2332 trace_btrfs_setup_cluster(block_group, cluster, 2330 trace_btrfs_setup_cluster(block_group, cluster,
2333 total_found * block_group->sectorsize, 1); 2331 total_found * ctl->unit, 1);
2334 return 0; 2332 return 0;
2335} 2333}
2336 2334