diff options
author | David Sterba <dsterba@suse.cz> | 2015-01-16 11:21:12 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-03-03 11:23:57 -0500 |
commit | f8c269d7223f6b63cc5936eb191bc3b170d24342 (patch) | |
tree | 2e82cc23da9f436bbb6fde058b3321619f990db2 /fs/btrfs/free-space-cache.c | |
parent | 351810c1d2aafa288af61844d877941d516fb031 (diff) |
btrfs: cleanup 64bit/32bit divs, compile time constants
Switch to div_u64 if the divisor is a numeric constant or sum of
sizeof()s. We can remove a few instances of do_div that has the hidden
semtantics of changing the 1st argument.
Small power-of-two divisors are converted to bitshifts, large values are
kept intact for clarity.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 96611fed552f..cb84923561e4 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -1537,7 +1537,7 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) | |||
1537 | max_bytes = MAX_CACHE_BYTES_PER_GIG; | 1537 | max_bytes = MAX_CACHE_BYTES_PER_GIG; |
1538 | else | 1538 | else |
1539 | max_bytes = MAX_CACHE_BYTES_PER_GIG * | 1539 | max_bytes = MAX_CACHE_BYTES_PER_GIG * |
1540 | div64_u64(size, 1024 * 1024 * 1024); | 1540 | div_u64(size, 1024 * 1024 * 1024); |
1541 | 1541 | ||
1542 | /* | 1542 | /* |
1543 | * we want to account for 1 more bitmap than what we have so we can make | 1543 | * we want to account for 1 more bitmap than what we have so we can make |
@@ -1552,14 +1552,14 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) | |||
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | /* | 1554 | /* |
1555 | * we want the extent entry threshold to always be at most 1/2 the maxw | 1555 | * we want the extent entry threshold to always be at most 1/2 the max |
1556 | * bytes we can have, or whatever is less than that. | 1556 | * bytes we can have, or whatever is less than that. |
1557 | */ | 1557 | */ |
1558 | extent_bytes = max_bytes - bitmap_bytes; | 1558 | extent_bytes = max_bytes - bitmap_bytes; |
1559 | extent_bytes = min_t(u64, extent_bytes, div64_u64(max_bytes, 2)); | 1559 | extent_bytes = min_t(u64, extent_bytes, max_bytes >> 1); |
1560 | 1560 | ||
1561 | ctl->extents_thresh = | 1561 | ctl->extents_thresh = |
1562 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); | 1562 | div_u64(extent_bytes, sizeof(struct btrfs_free_space)); |
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | 1565 | static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, |