Skip to content

Commit

Permalink
dm: fix clone_bio() to trigger blk_recount_segments()
Browse files Browse the repository at this point in the history
DM's clone_bio() now benefits from using bio_trim() by fixing the fact
that clone_bio() wasn't clearing BIO_SEG_VALID like bio_trim() does;
which triggers blk_recount_segments() via bio_phys_segments().

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mike Snitzer committed Jan 21, 2019
1 parent d445bd9 commit 57c3651
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,

__bio_clone_fast(clone, bio);

if (unlikely(bio_integrity(bio) != NULL)) {
if (bio_integrity(bio)) {
int r;

if (unlikely(!dm_target_has_integrity(tio->ti->type) &&
Expand All @@ -1336,11 +1336,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
return r;
}

bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector));
clone->bi_iter.bi_size = to_bytes(len);

if (unlikely(bio_integrity(bio) != NULL))
bio_integrity_trim(clone);
bio_trim(clone, sector - clone->bi_iter.bi_sector, len);

return 0;
}
Expand Down

0 comments on commit 57c3651

Please sign in to comment.