summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
authorLi Zefan2011-03-14 06:40:51 +0100
committerLi Zefan2011-04-25 10:46:01 +0200
commitf38b6e754d8cc4605ac21d9c1094d569d88b163b (patch)
tree7aec7cc9a9d68f1e7ce97771500c63151a1b2319 /fs/btrfs/free-space-cache.c
parentBtrfs: Remove unused btrfs_block_group_free_space() (diff)
downloadkernel-qcow2-linux-f38b6e754d8cc4605ac21d9c1094d569d88b163b.tar.gz
kernel-qcow2-linux-f38b6e754d8cc4605ac21d9c1094d569d88b163b.tar.xz
kernel-qcow2-linux-f38b6e754d8cc4605ac21d9c1094d569d88b163b.zip
Btrfs: Use bitmap_set/clear()
No functional change. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 3af64c6ea9df..0e23bbabbba2 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1134,15 +1134,13 @@ static void bitmap_clear_bits(struct btrfs_block_group_cache *block_group,
struct btrfs_free_space *info, u64 offset,
u64 bytes)
{
- unsigned long start, end;
- unsigned long i;
+ unsigned long start, count;
start = offset_to_bit(info->offset, block_group->sectorsize, offset);
- end = start + bytes_to_bits(bytes, block_group->sectorsize);
- BUG_ON(end > BITS_PER_BITMAP);
+ count = bytes_to_bits(bytes, block_group->sectorsize);
+ BUG_ON(start + count > BITS_PER_BITMAP);
- for (i = start; i < end; i++)
- clear_bit(i, info->bitmap);
+ bitmap_clear(info->bitmap, start, count);
info->bytes -= bytes;
block_group->free_space -= bytes;
@@ -1152,15 +1150,13 @@ static void bitmap_set_bits(struct btrfs_block_group_cache *block_group,
struct btrfs_free_space *info, u64 offset,
u64 bytes)
{
- unsigned long start, end;
- unsigned long i;
+ unsigned long start, count;
start = offset_to_bit(info->offset, block_group->sectorsize, offset);
- end = start + bytes_to_bits(bytes, block_group->sectorsize);
- BUG_ON(end > BITS_PER_BITMAP);
+ count = bytes_to_bits(bytes, block_group->sectorsize);
+ BUG_ON(start + count > BITS_PER_BITMAP);
- for (i = start; i < end; i++)
- set_bit(i, info->bitmap);
+ bitmap_set(info->bitmap, start, count);
info->bytes += bytes;
block_group->free_space += bytes;