Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60ca842e authored by Omar Sandoval's avatar Omar Sandoval Committed by David Sterba
Browse files

Btrfs: rename and export get_chunk_map



The Btrfs swap code is going to need it, so give it a btrfs_ prefix and
make it non-static.

Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent eede2bf3
Loading
Loading
Loading
Loading
+18 −11
Original line number Original line Diff line number Diff line
@@ -2726,7 +2726,14 @@ static int btrfs_del_sys_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
	return ret;
	return ret;
}
}


static struct extent_map *get_chunk_map(struct btrfs_fs_info *fs_info,
/*
 * btrfs_get_chunk_map() - Find the mapping containing the given logical extent.
 * @logical: Logical block offset in bytes.
 * @length: Length of extent in bytes.
 *
 * Return: Chunk mapping or ERR_PTR.
 */
struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
				       u64 logical, u64 length)
				       u64 logical, u64 length)
{
{
	struct extent_map_tree *em_tree;
	struct extent_map_tree *em_tree;
@@ -2764,7 +2771,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
	int i, ret = 0;
	int i, ret = 0;
	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;


	em = get_chunk_map(fs_info, chunk_offset, 1);
	em = btrfs_get_chunk_map(fs_info, chunk_offset, 1);
	if (IS_ERR(em)) {
	if (IS_ERR(em)) {
		/*
		/*
		 * This is a logic error, but we don't want to just rely on the
		 * This is a logic error, but we don't want to just rely on the
@@ -4909,7 +4916,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
	int i = 0;
	int i = 0;
	int ret = 0;
	int ret = 0;


	em = get_chunk_map(fs_info, chunk_offset, chunk_size);
	em = btrfs_get_chunk_map(fs_info, chunk_offset, chunk_size);
	if (IS_ERR(em))
	if (IS_ERR(em))
		return PTR_ERR(em);
		return PTR_ERR(em);


@@ -5051,7 +5058,7 @@ int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset)
	int miss_ndevs = 0;
	int miss_ndevs = 0;
	int i;
	int i;


	em = get_chunk_map(fs_info, chunk_offset, 1);
	em = btrfs_get_chunk_map(fs_info, chunk_offset, 1);
	if (IS_ERR(em))
	if (IS_ERR(em))
		return 1;
		return 1;


@@ -5111,7 +5118,7 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
	struct map_lookup *map;
	struct map_lookup *map;
	int ret;
	int ret;


	em = get_chunk_map(fs_info, logical, len);
	em = btrfs_get_chunk_map(fs_info, logical, len);
	if (IS_ERR(em))
	if (IS_ERR(em))
		/*
		/*
		 * We could return errors for these cases, but that could get
		 * We could return errors for these cases, but that could get
@@ -5157,7 +5164,7 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
	struct map_lookup *map;
	struct map_lookup *map;
	unsigned long len = fs_info->sectorsize;
	unsigned long len = fs_info->sectorsize;


	em = get_chunk_map(fs_info, logical, len);
	em = btrfs_get_chunk_map(fs_info, logical, len);


	if (!WARN_ON(IS_ERR(em))) {
	if (!WARN_ON(IS_ERR(em))) {
		map = em->map_lookup;
		map = em->map_lookup;
@@ -5174,7 +5181,7 @@ int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
	struct map_lookup *map;
	struct map_lookup *map;
	int ret = 0;
	int ret = 0;


	em = get_chunk_map(fs_info, logical, len);
	em = btrfs_get_chunk_map(fs_info, logical, len);


	if(!WARN_ON(IS_ERR(em))) {
	if(!WARN_ON(IS_ERR(em))) {
		map = em->map_lookup;
		map = em->map_lookup;
@@ -5333,7 +5340,7 @@ static int __btrfs_map_block_for_discard(struct btrfs_fs_info *fs_info,
	/* discard always return a bbio */
	/* discard always return a bbio */
	ASSERT(bbio_ret);
	ASSERT(bbio_ret);


	em = get_chunk_map(fs_info, logical, length);
	em = btrfs_get_chunk_map(fs_info, logical, length);
	if (IS_ERR(em))
	if (IS_ERR(em))
		return PTR_ERR(em);
		return PTR_ERR(em);


@@ -5659,7 +5666,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
		return __btrfs_map_block_for_discard(fs_info, logical,
		return __btrfs_map_block_for_discard(fs_info, logical,
						     *length, bbio_ret);
						     *length, bbio_ret);


	em = get_chunk_map(fs_info, logical, *length);
	em = btrfs_get_chunk_map(fs_info, logical, *length);
	if (IS_ERR(em))
	if (IS_ERR(em))
		return PTR_ERR(em);
		return PTR_ERR(em);


@@ -5962,7 +5969,7 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
	u64 rmap_len;
	u64 rmap_len;
	int i, j, nr = 0;
	int i, j, nr = 0;


	em = get_chunk_map(fs_info, chunk_start, 1);
	em = btrfs_get_chunk_map(fs_info, chunk_start, 1);
	if (IS_ERR(em))
	if (IS_ERR(em))
		return -EIO;
		return -EIO;


+2 −0
Original line number Original line Diff line number Diff line
@@ -462,6 +462,8 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
			     u64 chunk_offset, u64 chunk_size);
			     u64 chunk_offset, u64 chunk_size);
int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset);
int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset);
struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
				       u64 logical, u64 length);


static inline void btrfs_dev_stat_inc(struct btrfs_device *dev,
static inline void btrfs_dev_stat_inc(struct btrfs_device *dev,
				      int index)
				      int index)