Commit ed8947bc authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: merge find_free_dev_extent() and find_free_dev_extent_start()

There is no point in having find_free_dev_extent() because it's just a
simple wrapper around find_free_dev_extent_start() which always passes a
value of 0 for the search_start argument. Since there are no other callers
of find_free_dev_extent_start(), remove find_free_dev_extent() and rename
find_free_dev_extent_start() to find_free_dev_extent(), removing its
search_start argument because it's always 0.
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 883647f4
...@@ -1439,18 +1439,18 @@ static bool contains_pending_extent(struct btrfs_device *device, u64 *start, ...@@ -1439,18 +1439,18 @@ static bool contains_pending_extent(struct btrfs_device *device, u64 *start,
return false; return false;
} }
static u64 dev_extent_search_start(struct btrfs_device *device, u64 start) static u64 dev_extent_search_start(struct btrfs_device *device)
{ {
switch (device->fs_devices->chunk_alloc_policy) { switch (device->fs_devices->chunk_alloc_policy) {
case BTRFS_CHUNK_ALLOC_REGULAR: case BTRFS_CHUNK_ALLOC_REGULAR:
return max_t(u64, start, BTRFS_DEVICE_RANGE_RESERVED); return BTRFS_DEVICE_RANGE_RESERVED;
case BTRFS_CHUNK_ALLOC_ZONED: case BTRFS_CHUNK_ALLOC_ZONED:
/* /*
* We don't care about the starting region like regular * We don't care about the starting region like regular
* allocator, because we anyway use/reserve the first two zones * allocator, because we anyway use/reserve the first two zones
* for superblock logging. * for superblock logging.
*/ */
return ALIGN(start, device->zone_info->zone_size); return 0;
default: default:
BUG(); BUG();
} }
...@@ -1582,15 +1582,15 @@ static bool dev_extent_hole_check(struct btrfs_device *device, u64 *hole_start, ...@@ -1582,15 +1582,15 @@ static bool dev_extent_hole_check(struct btrfs_device *device, u64 *hole_start,
* correct usable device space, as device extent freed in current transaction * correct usable device space, as device extent freed in current transaction
* is not reported as available. * is not reported as available.
*/ */
static int find_free_dev_extent_start(struct btrfs_device *device, static int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
u64 num_bytes, u64 search_start, u64 *start, u64 *start, u64 *len)
u64 *len)
{ {
struct btrfs_fs_info *fs_info = device->fs_info; struct btrfs_fs_info *fs_info = device->fs_info;
struct btrfs_root *root = fs_info->dev_root; struct btrfs_root *root = fs_info->dev_root;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_dev_extent *dev_extent; struct btrfs_dev_extent *dev_extent;
struct btrfs_path *path; struct btrfs_path *path;
u64 search_start;
u64 hole_size; u64 hole_size;
u64 max_hole_start; u64 max_hole_start;
u64 max_hole_size; u64 max_hole_size;
...@@ -1600,7 +1600,7 @@ static int find_free_dev_extent_start(struct btrfs_device *device, ...@@ -1600,7 +1600,7 @@ static int find_free_dev_extent_start(struct btrfs_device *device,
int slot; int slot;
struct extent_buffer *l; struct extent_buffer *l;
search_start = dev_extent_search_start(device, search_start); search_start = dev_extent_search_start(device);
WARN_ON(device->zone_info && WARN_ON(device->zone_info &&
!IS_ALIGNED(num_bytes, device->zone_info->zone_size)); !IS_ALIGNED(num_bytes, device->zone_info->zone_size));
...@@ -1726,13 +1726,6 @@ static int find_free_dev_extent_start(struct btrfs_device *device, ...@@ -1726,13 +1726,6 @@ static int find_free_dev_extent_start(struct btrfs_device *device,
return ret; return ret;
} }
static int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
u64 *start, u64 *len)
{
/* FIXME use last free of some kind */
return find_free_dev_extent_start(device, num_bytes, 0, start, len);
}
static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
struct btrfs_device *device, struct btrfs_device *device,
u64 start, u64 *dev_extent_len) u64 start, u64 *dev_extent_len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment