Skip to content

Commit

Permalink
Btrfs: Use bitmap_set/clear()
Browse files Browse the repository at this point in the history
No functional change.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
  • Loading branch information
Li Zefan committed Apr 25, 2011
1 parent 92c4231 commit f38b6e7
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit f38b6e7

Please sign in to comment.