Skip to content

Commit c8691cd

Browse files
author
Mikulas Patocka
committed
Revert "dm: requeue IO if mapping table not yet available"
This reverts commit fa24708. The following sequence of commands causes a livelock - there will be workqueue process looping and consuming 100% CPU: dmsetup create --notable test truncate -s 1MiB testdata losetup /dev/loop0 testdata dmsetup load test --table '0 2048 linear /dev/loop0 0' dd if=/dev/zero of=/dev/dm-0 bs=16k count=1 conv=fdatasync The livelock is caused by the commit fa24708. The commit claims that it fixes a race condition, however, it is unknown what the actual race condition is and what program is involved in the race condition. When the inactive table is loaded, the nodes /dev/dm-0 and /sys/block/dm-0 are created. /dev/dm-0 has zero size at this point. When the device is suspended and resumed, the nodes /dev/mapper/test and /dev/disk/* are created. If some program opens a block device before it is created by dmsetup or lvm, the program is buggy, so dm could just report an error as it used to do before. Reported-by: Zdenek Kabelac <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]> Fixes: fa24708 ("dm: requeue IO if mapping table not yet available")
1 parent 9c2010b commit c8691cd

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

drivers/md/dm-rq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,10 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
496496

497497
map = dm_get_live_table(md, &srcu_idx);
498498
if (unlikely(!map)) {
499+
DMERR_LIMIT("%s: mapping table unavailable, erroring io",
500+
dm_device_name(md));
499501
dm_put_live_table(md, srcu_idx);
500-
return BLK_STS_RESOURCE;
502+
return BLK_STS_IOERR;
501503
}
502504
ti = dm_table_find_target(map, 0);
503505
dm_put_live_table(md, srcu_idx);

drivers/md/dm.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,10 +2030,15 @@ static void dm_submit_bio(struct bio *bio)
20302030
struct dm_table *map;
20312031

20322032
map = dm_get_live_table(md, &srcu_idx);
2033+
if (unlikely(!map)) {
2034+
DMERR_LIMIT("%s: mapping table unavailable, erroring io",
2035+
dm_device_name(md));
2036+
bio_io_error(bio);
2037+
goto out;
2038+
}
20332039

2034-
/* If suspended, or map not yet available, queue this IO for later */
2035-
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) ||
2036-
unlikely(!map)) {
2040+
/* If suspended, queue this IO for later */
2041+
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
20372042
if (bio->bi_opf & REQ_NOWAIT)
20382043
bio_wouldblock_error(bio);
20392044
else if (bio->bi_opf & REQ_RAHEAD)

0 commit comments

Comments
 (0)