summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorLiu Bo2017-05-16 02:43:31 +0200
committerDavid Sterba2017-06-19 18:25:58 +0200
commit2f8e9140426dff6091b7a40d441befc791882658 (patch)
treeb7f6b66a9fc9f20b1d6eb3d1aa855c3103b23a75 /fs/btrfs/extent_io.c
parentBtrfs: use bio_clone_fast to clone our bio (diff)
downloadkernel-qcow2-linux-2f8e9140426dff6091b7a40d441befc791882658.tar.gz
kernel-qcow2-linux-2f8e9140426dff6091b7a40d441befc791882658.tar.xz
kernel-qcow2-linux-2f8e9140426dff6091b7a40d441befc791882658.zip
Btrfs: new helper btrfs_bio_clone_partial
This adds a new helper btrfs_bio_clone_partial, it'll allocate a cloned bio that only owns a part of the original bio's data. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 292e458b2a9d..db2bbf92b4bc 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2720,6 +2720,24 @@ struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
return bio;
}
+struct bio *btrfs_bio_clone_partial(struct bio *orig, gfp_t gfp_mask,
+ int offset, int size)
+{
+ struct bio *bio;
+ struct btrfs_io_bio *btrfs_bio;
+
+ /* this will never fail when it's backed by a bioset */
+ bio = bio_clone_fast(orig, gfp_mask, btrfs_bioset);
+ ASSERT(bio);
+
+ btrfs_bio = btrfs_io_bio(bio);
+ btrfs_bio->csum = NULL;
+ btrfs_bio->csum_allocated = NULL;
+ btrfs_bio->end_io = NULL;
+
+ bio_trim(bio, offset >> 9, size >> 9);
+ return bio;
+}
static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
unsigned long bio_flags)