mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-05 13:09:33 +00:00
btrfs-progs: refactor find_free_dev_extent_start()
Factor out the function dev_extent_search_start() from find_free_dev_extent_start() to decide the starting position of a device extent search. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
1da9fede64
commit
ff65b83306
@ -444,6 +444,21 @@ int btrfs_scan_one_device(int fd, const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
|
||||
{
|
||||
switch (device->fs_devices->chunk_alloc_policy) {
|
||||
case BTRFS_CHUNK_ALLOC_REGULAR:
|
||||
/*
|
||||
* We don't want to overwrite the superblock on the drive nor
|
||||
* any area used by the boot loader (grub for example), so we
|
||||
* make sure to start at an offset of at least 1MB.
|
||||
*/
|
||||
return max(start, BTRFS_BLOCK_RESERVED_1M_FOR_SUPER);
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* find_free_dev_extent_start - find free space in the specified device
|
||||
* @device: the device which we search the free space in
|
||||
@ -481,15 +496,8 @@ static int find_free_dev_extent_start(struct btrfs_device *device,
|
||||
int ret;
|
||||
int slot;
|
||||
struct extent_buffer *l;
|
||||
u64 min_search_start;
|
||||
|
||||
/*
|
||||
* We don't want to overwrite the superblock on the drive nor any area
|
||||
* used by the boot loader (grub for example), so we make sure to start
|
||||
* at an offset of at least 1MB.
|
||||
*/
|
||||
min_search_start = BTRFS_BLOCK_RESERVED_1M_FOR_SUPER;
|
||||
search_start = max(search_start, min_search_start);
|
||||
search_start = dev_extent_search_start(device, search_start);
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path)
|
||||
|
Loading…
Reference in New Issue
Block a user