Commit 503f9d43 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu
Browse files

md: add a new helper reshape_interrupted()



The helper will be used for dm-raid456 later to detect the case that
reshape can't make progress.

Cc: stable@vger.kernel.org # v6.7+
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarXiao Ni <xni@redhat.com>
Acked-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240305072306.2562024-5-yukuai1@huaweicloud.com
parent 314e9af0
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -581,6 +581,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);