Patch "dm thin: resume even if in FAIL mode" has been added to the 5.4-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

    dm thin: resume even if in FAIL mode

to the 5.4-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:
     dm-thin-resume-even-if-in-fail-mode.patch
and it can be found in the queue-5.4 subdirectory.

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



commit ac99413d3a22b5c9db7fc55f0ecca8d9798a622f
Author: Luo Meng <luomeng12@xxxxxxxxxx>
Date:   Wed Nov 30 10:09:45 2022 +0800

    dm thin: resume even if in FAIL mode
    
    [ Upstream commit 19eb1650afeb1aa86151f61900e9e5f1de5d8d02 ]
    
    If a thinpool set fail_io while suspending, resume will fail with:
     device-mapper: resume ioctl on vg-thinpool  failed: Invalid argument
    
    The thin-pool also can't be removed if an in-flight bio is in the
    deferred list.
    
    This can be easily reproduced using:
    
      echo "offline" > /sys/block/sda/device/state
      dd if=/dev/zero of=/dev/mapper/thin bs=4K count=1
      dmsetup suspend /dev/mapper/pool
      mkfs.ext4 /dev/mapper/thin
      dmsetup resume /dev/mapper/pool
    
    The root cause is maybe_resize_data_dev() will check fail_io and return
    error before called dm_resume.
    
    Fix this by adding FAIL mode check at the end of pool_preresume().
    
    Cc: stable@xxxxxxxxxxxxxxx
    Fixes: da105ed5fd7e ("dm thin metadata: introduce dm_pool_abort_metadata")
    Signed-off-by: Luo Meng <luomeng12@xxxxxxxxxx>
    Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 1af5873923e8..4f161725dda0 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -3593,23 +3593,31 @@ static int pool_preresume(struct dm_target *ti)
 	 */
 	r = bind_control_target(pool, ti);
 	if (r)
-		return r;
+		goto out;
 
 	dm_pool_register_pre_commit_callback(pool->pmd,
 					     metadata_pre_commit_callback, pt);
 
 	r = maybe_resize_data_dev(ti, &need_commit1);
 	if (r)
-		return r;
+		goto out;
 
 	r = maybe_resize_metadata_dev(ti, &need_commit2);
 	if (r)
-		return r;
+		goto out;
 
 	if (need_commit1 || need_commit2)
 		(void) commit(pool);
+out:
+	/*
+	 * When a thin-pool is PM_FAIL, it cannot be rebuilt if
+	 * bio is in deferred list. Therefore need to return 0
+	 * to allow pool_resume() to flush IO.
+	 */
+	if (r && get_pool_mode(pool) == PM_FAIL)
+		r = 0;
 
-	return 0;
+	return r;
 }
 
 static void pool_suspend_active_thins(struct pool *pool)

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux