@@ -4177,6 +4177,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
static int thin_map(struct dm_target *ti, struct bio *bio)
{
bio->bi_iter.bi_sector = dm_target_offset(ti, bio->bi_iter.bi_sector);
+ dm_retain_bio_blkcg(bio);
return thin_bio_map(ti, bio);
}
@@ -1290,9 +1290,10 @@ static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio)
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
dm_put_live_table(md, srcu_idx);
- if (!(bio->bi_opf & REQ_RAHEAD))
+ if (!(bio->bi_opf & REQ_RAHEAD)) {
+ dm_retain_bio_blkcg(bio);
queue_io(md, bio);
- else
+ } else
bio_io_error(bio);
return BLK_QC_T_NONE;
}
@@ -214,4 +214,10 @@ void dm_free_md_mempools(struct dm_md_mempools *pools);
*/
unsigned dm_get_reserved_bio_based_ios(void);
+static inline void dm_retain_bio_blkcg(struct bio *bio)
+{
+ if (!bio->bi_css)
+ bio_associate_current(bio);
+}
+
#endif