mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 14:19:16 +00:00
btrfs: pass an ordered_extent to btrfs_extract_ordered_extent
To prepare for a new caller that already has the ordered_extent available, change btrfs_extract_ordered_extent to take an argument for it. Add a wrapper for the bio case that still has to do the lookup (for now). Reviewed-by: Josef Bacik <josef@toxicpanda.com> Tested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2e38a84bc6
commit
7edd339c8a
3 changed files with 25 additions and 20 deletions
|
@ -61,6 +61,20 @@ struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
|
|||
return bbio;
|
||||
}
|
||||
|
||||
static blk_status_t btrfs_bio_extract_ordered_extent(struct btrfs_bio *bbio)
|
||||
{
|
||||
struct btrfs_ordered_extent *ordered;
|
||||
int ret;
|
||||
|
||||
ordered = btrfs_lookup_ordered_extent(bbio->inode, bbio->file_offset);
|
||||
if (WARN_ON_ONCE(!ordered))
|
||||
return BLK_STS_IOERR;
|
||||
ret = btrfs_extract_ordered_extent(bbio, ordered);
|
||||
btrfs_put_ordered_extent(ordered);
|
||||
|
||||
return errno_to_blk_status(ret);
|
||||
}
|
||||
|
||||
static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_bio *orig_bbio,
|
||||
u64 map_length, bool use_append)
|
||||
|
@ -653,7 +667,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
|
|||
if (use_append) {
|
||||
bio->bi_opf &= ~REQ_OP_WRITE;
|
||||
bio->bi_opf |= REQ_OP_ZONE_APPEND;
|
||||
ret = btrfs_extract_ordered_extent(bbio);
|
||||
ret = btrfs_bio_extract_ordered_extent(bbio);
|
||||
if (ret)
|
||||
goto fail_put_bio;
|
||||
}
|
||||
|
|
|
@ -407,7 +407,8 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
|
|||
|
||||
int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
|
||||
u32 pgoff, u8 *csum, const u8 * const csum_expected);
|
||||
blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio);
|
||||
int btrfs_extract_ordered_extent(struct btrfs_bio *bbio,
|
||||
struct btrfs_ordered_extent *ordered);
|
||||
bool btrfs_data_csum_ok(struct btrfs_bio *bbio, struct btrfs_device *dev,
|
||||
u32 bio_offset, struct bio_vec *bv);
|
||||
noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
|
||||
|
|
|
@ -2601,37 +2601,27 @@ static int split_extent_map(struct btrfs_inode *inode, u64 start, u64 len, u64 p
|
|||
return ret;
|
||||
}
|
||||
|
||||
blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio)
|
||||
int btrfs_extract_ordered_extent(struct btrfs_bio *bbio,
|
||||
struct btrfs_ordered_extent *ordered)
|
||||
{
|
||||
u64 start = (u64)bbio->bio.bi_iter.bi_sector << SECTOR_SHIFT;
|
||||
u64 len = bbio->bio.bi_iter.bi_size;
|
||||
struct btrfs_inode *inode = bbio->inode;
|
||||
struct btrfs_ordered_extent *ordered;
|
||||
u64 ordered_len;
|
||||
u64 ordered_len = ordered->num_bytes;
|
||||
int ret = 0;
|
||||
|
||||
ordered = btrfs_lookup_ordered_extent(inode, bbio->file_offset);
|
||||
if (WARN_ON_ONCE(!ordered))
|
||||
return BLK_STS_IOERR;
|
||||
ordered_len = ordered->num_bytes;
|
||||
|
||||
/* Must always be called for the beginning of an ordered extent. */
|
||||
if (WARN_ON_ONCE(start != ordered->disk_bytenr)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (WARN_ON_ONCE(start != ordered->disk_bytenr))
|
||||
return -EINVAL;
|
||||
|
||||
/* No need to split if the ordered extent covers the entire bio. */
|
||||
if (ordered->disk_num_bytes == len)
|
||||
goto out;
|
||||
return 0;
|
||||
|
||||
ret = btrfs_split_ordered_extent(ordered, len);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = split_extent_map(inode, bbio->file_offset, ordered_len, len);
|
||||
out:
|
||||
btrfs_put_ordered_extent(ordered);
|
||||
return errno_to_blk_status(ret);
|
||||
return ret;
|
||||
return split_extent_map(inode, bbio->file_offset, ordered_len, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue