Re: [PATCH 16/22] dm: Refactor for new bio cloning/splitting

Kent Overstreet
2013-10-03T03:17:37Z

On Sat, Sep 28, 2013 at 12:59:09AM -0400, Mike Snitzer wrote:
> Hey Kent,
>
> I haven't been able to pinpoint the issue yet, but using your for-jens
> branch, if I create a dm-thin volume with this lvm command:
> lvcreate -L20G -V20G -T vg/pool --name thinlv
>
> and try to format /dev/vg/thinlv with XFS the kernel warns and then
> hangs with the following:

Thanks, for whatever reason ext4 wasn't tickling that codepath but xfs
does. I folded the fix into my for-jens branch, here's what changed:

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b60b350..79cee1a 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1098,7 +1098,7 @@ static void clone_bio(struct dm_target_io *tio, struct bio *bio,
bio_integrity_clone(clone, bio, GFP_NOIO);

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

if (bio_integrity(bio))
bio_integrity_trim(clone, 0, len);
@@ -1267,7 +1267,7 @@ static int __split_and_process_non_flush(struct clone_info *ci)
if (!dm_target_is_valid(ti))
return -EIO;

- len = min_t(unsigned, max_io_len(ci->sector, ti), bio_sectors(bio));
+ len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);

__clone_and_map_data_bio(ci, ti, ci->sector, len);