This is a note to let you know that I've just added the patch titled md: add a new helper reshape_interrupted() to the 6.7-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: md-add-a-new-helper-reshape_interrupted.patch and it can be found in the queue-6.7 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 93eea3476818fa2330767ddb72ecef859681c747 Author: Yu Kuai <yukuai3@xxxxxxxxxx> Date: Tue Mar 5 15:23:01 2024 +0800 md: add a new helper reshape_interrupted() [ Upstream commit 503f9d43790fdd0c6e6ae2f4dd3f70b146ac4159 ] The helper will be used for dm-raid456 later to detect the case that reshape can't make progress. Cc: stable@xxxxxxxxxxxxxxx # v6.7+ Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx> Signed-off-by: Xiao Ni <xni@xxxxxxxxxx> Acked-by: Mike Snitzer <snitzer@xxxxxxxxxx> Signed-off-by: Song Liu <song@xxxxxxxxxx> Link: https://lore.kernel.org/r/20240305072306.2562024-5-yukuai1@xxxxxxxxxxxxxxx Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/md/md.h b/drivers/md/md.h index db0cb00e4c9ac..ea0fd76c17e75 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -571,6 +571,25 @@ static inline bool md_is_rdwr(struct mddev *mddev) return (mddev->ro == MD_RDWR); } +static inline bool reshape_interrupted(struct mddev *mddev) +{ + /* reshape never start */ + if (mddev->reshape_position == MaxSector) + return false; + + /* interrupted */ + if (!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) + return true; + + /* running reshape will be interrupted soon. */ + if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) || + test_bit(MD_RECOVERY_INTR, &mddev->recovery) || + test_bit(MD_RECOVERY_FROZEN, &mddev->recovery)) + return true; + + return false; +} + static inline int __must_check mddev_lock(struct mddev *mddev) { return mutex_lock_interruptible(&mddev->reconfig_mutex);