Skip to content

Commit fa8db49

Browse files
committed
dm: don't use bio_trim() afterall
bio_trim() has an early return, which makes it _not_ idempotent, if the offset is 0 and the bio's bi_size already matches the requested size. Prior to DM, all users of bio_trim() were fine with this. But DM has exposed the fact that bio_trim()'s early return is incompatible with a cloned bio whose integrity payload must be trimmed via bio_integrity_trim(). Fix this by reverting DM back to doing the equivalent of bio_trim() but in an idempotent manner (so bio_integrity_trim is always performed). Follow-on work is needed to assess what benefit bio_trim()'s early return is providing to its existing callers. Reported-by: Milan Broz <gmazyland@gmail.com> Fixes: 57c3651 ("dm: fix clone_bio() to trigger blk_recount_segments()") Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 645efa8 commit fa8db49

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/md/dm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,11 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
13361336
return r;
13371337
}
13381338

1339-
bio_trim(clone, sector - clone->bi_iter.bi_sector, len);
1339+
bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector));
1340+
clone->bi_iter.bi_size = to_bytes(len);
1341+
1342+
if (bio_integrity(bio))
1343+
bio_integrity_trim(clone);
13401344

13411345
return 0;
13421346
}

0 commit comments

Comments
 (0)