From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Pavel Begunkov <asml.silence@gmail.com>,
Mike Snitzer <snitzer@redhat.com>,
Philipp Reisner <philipp.reisner@linbit.com>,
Lars Ellenberg <lars.ellenberg@linbit.com>,
linux-block@vger.kernel.org, dm-devel@redhat.com,
drbd-dev@lists.linbit.com
Subject: [PATCH 03/14] dm: fold clone_bio into __clone_and_map_data_bio
Date: Thu, 27 Jan 2022 07:35:35 +0100 [thread overview]
Message-ID: <20220127063546.1314111-4-hch@lst.de> (raw)
In-Reply-To: <20220127063546.1314111-1-hch@lst.de>
Fold clone_bio into its only caller to prepare for refactoring.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm.c | 43 +++++++++++++++++--------------------------
1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 692a06156c927..e1356a4ce0393 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1190,17 +1190,22 @@ static void bio_setup_sector(struct bio *bio, sector_t sector, unsigned len)
/*
* Creates a bio that consists of range of complete bvecs.
*/
-static int clone_bio(struct dm_target_io *tio, struct bio *bio,
- sector_t sector, unsigned len)
+static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
+ sector_t sector, unsigned *len)
{
- struct bio *clone = &tio->clone;
+ struct bio *bio = ci->bio, *clone;
+ struct dm_target_io *tio;
int r;
+ tio = alloc_tio(ci, ti, 0, GFP_NOIO);
+ tio->len_ptr = len;
+
+ clone = &tio->clone;
__bio_clone_fast(clone, bio);
r = bio_crypt_clone(clone, bio, GFP_NOIO);
if (r < 0)
- return r;
+ goto free_tio;
if (bio_integrity(bio)) {
if (unlikely(!dm_target_has_integrity(tio->ti->type) &&
@@ -1208,21 +1213,26 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
DMWARN("%s: the target %s doesn't support integrity data.",
dm_device_name(tio->io->md),
tio->ti->type->name);
- return -EIO;
+ r = -EIO;
+ goto free_tio;
}
r = bio_integrity_clone(clone, bio, GFP_NOIO);
if (r < 0)
- return r;
+ goto free_tio;
}
bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector));
- clone->bi_iter.bi_size = to_bytes(len);
+ clone->bi_iter.bi_size = to_bytes(*len);
if (bio_integrity(bio))
bio_integrity_trim(clone);
+ __map_bio(tio);
return 0;
+free_tio:
+ free_tio(tio);
+ return r;
}
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
@@ -1313,25 +1323,6 @@ static int __send_empty_flush(struct clone_info *ci)
return 0;
}
-static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
- sector_t sector, unsigned *len)
-{
- struct bio *bio = ci->bio;
- struct dm_target_io *tio;
- int r;
-
- tio = alloc_tio(ci, ti, 0, GFP_NOIO);
- tio->len_ptr = len;
- r = clone_bio(tio, bio, sector, *len);
- if (r < 0) {
- free_tio(tio);
- return r;
- }
- __map_bio(tio);
-
- return 0;
-}
-
static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios)
{
--
2.30.2
next prev parent reply other threads:[~2022-01-27 6:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 6:35 improve the bio cloning interface Christoph Hellwig
2022-01-27 6:35 ` [PATCH 01/14] drbd: set ->bi_bdev in drbd_req_new Christoph Hellwig
2022-01-27 6:35 ` [PATCH 02/14] dm: add a clone_to_tio helper Christoph Hellwig
2022-01-27 6:35 ` Christoph Hellwig [this message]
2022-01-27 6:35 ` [PATCH 04/14] dm: fold __send_duplicate_bios into __clone_and_map_simple_bio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 05/14] dm: move cloning the bio into alloc_tio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 06/14] dm: pass the bio instead of tio to __map_bio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 07/14] dm: retun the clone bio from alloc_tio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 08/14] dm: simplify the single bio fast path in __send_duplicate_bios Christoph Hellwig
2022-01-27 6:35 ` [PATCH 09/14] dm: add a missing bio initialization to alloc_tio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 10/14] dm-cache: remove __remap_to_origin_clear_discard Christoph Hellwig
2022-01-27 6:35 ` [PATCH 11/14] block: clone crypto and integrity data in __bio_clone_fast Christoph Hellwig
2022-01-27 6:35 ` [PATCH 12/14] dm: use bio_clone_fast in alloc_tio Christoph Hellwig
2022-01-27 6:35 ` [PATCH 13/14] block: initialize the target bio in __bio_clone_fast Christoph Hellwig
2022-01-27 6:35 ` [PATCH 14/14] block: pass a block_device to bio_clone_fast Christoph Hellwig
2022-01-27 16:52 ` improve the bio cloning interface Mike Snitzer
2022-01-27 19:58 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220127063546.1314111-4-hch@lst.de \
--to=hch@lst.de \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
--cc=snitzer@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).