Patch "Revert "dm: requeue IO if mapping table not yet available"" has been added to the 6.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    Revert "dm: requeue IO if mapping table not yet available"

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     revert-dm-requeue-io-if-mapping-table-not-yet-availa.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ae2e189cb3df7b71761469b21a774480cb61e130
Author: Mikulas Patocka <mpatocka@xxxxxxxxxx>
Date:   Fri Sep 13 15:05:18 2024 +0200

    Revert "dm: requeue IO if mapping table not yet available"
    
    [ Upstream commit c8691cd0fc11197515ed148de0780d927bfca38b ]
    
    This reverts commit fa247089de9936a46e290d4724cb5f0b845600f5.
    
    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 fa247089de99. 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 <zkabelac@xxxxxxxxxx>
    Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>
    Fixes: fa247089de99 ("dm: requeue IO if mapping table not yet available")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index f7e9a3632eb3d..499f8cc8a39fb 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -496,8 +496,10 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 		map = dm_get_live_table(md, &srcu_idx);
 		if (unlikely(!map)) {
+			DMERR_LIMIT("%s: mapping table unavailable, erroring io",
+				    dm_device_name(md));
 			dm_put_live_table(md, srcu_idx);
-			return BLK_STS_RESOURCE;
+			return BLK_STS_IOERR;
 		}
 		ti = dm_table_find_target(map, 0);
 		dm_put_live_table(md, srcu_idx);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 6e15ac4e0845c..a0b4afba8c608 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1880,10 +1880,15 @@ static void dm_submit_bio(struct bio *bio)
 	struct dm_table *map;
 
 	map = dm_get_live_table(md, &srcu_idx);
+	if (unlikely(!map)) {
+		DMERR_LIMIT("%s: mapping table unavailable, erroring io",
+			    dm_device_name(md));
+		bio_io_error(bio);
+		goto out;
+	}
 
-	/* If suspended, or map not yet available, queue this IO for later */
-	if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) ||
-	    unlikely(!map)) {
+	/* If suspended, queue this IO for later */
+	if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
 		if (bio->bi_opf & REQ_NOWAIT)
 			bio_wouldblock_error(bio);
 		else if (bio->bi_opf & REQ_RAHEAD)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux