Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp996969rdb; Wed, 24 Jan 2024 01:19:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDEjhUYawTlUb7dabGINmPvG28iIGPkEnuPELDKYi1/wbKwxZrLRQa/98wWQcPM1Z7uEBo X-Received: by 2002:a17:90a:88b:b0:290:61:b83e with SMTP id v11-20020a17090a088b00b002900061b83emr3781852pjc.16.1706087958715; Wed, 24 Jan 2024 01:19:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706087958; cv=pass; d=google.com; s=arc-20160816; b=as+OrQ6AMjsJqr2miXBhL8pYbPxNwIDw0K7RVPM5Lbrz9ZbYO22ZM80sLXdaw54ZUh ZmALz0tsqqV6BrD30yAzauAzuYE5/SRAy9lMkKyYAqD8Rhl4dUkrYPj0QiLk1X9UEPSy 500O9DVWm5099LnFZidHACfIyigs/LMDP1xEjBjmTd4fq13H0wY4CHpPNavrLPPmcnc+ uhLQhRFjQJIr1uGNEwLygl0FOkK7peUEaYXflbDGfVjtjOPWf+NwO5/SkWPQvjuyaqqr nAjx9LJ42q+vPQY+mi2kQd3vvBBEwZpSdDYcPjDbLcDqzFX4oJmZSTl+DOANJRE94yH3 2OIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=owtSMFOrGCa/NPCIUmSolue1yqSq5XiGoPfbzedO3qs=; fh=SaJ9rWjnsGFI+7ibUS2Ywr9D7BSRvW01ZC90UJpOFqs=; b=NbLHrt7wZRVKPWGJxxEsYHYE8OmzCkTCpjXsRoEa+qucKT63eDm3NXxMwVv5yLpx0Q DYmS562C36MDsyrQWy1HZ0MOUExKCxg9lSIUg6pUc/oEnLGGg2URT/4YxoWNhvrHyYYW z9D6xo1sSTvUtGBeHL9fp1lL+mj1UAlR1GYpKlqbthOqcQxOPbYtbwoULbxam1PJQT2w +ryAxUc0UGRakYg8aAm2o2fhEghEcIijXtDzSno75iLywSjt3HO5/oJ20eENn6hlmR7t mISdTia1Oehku0O2r5uBTO60OJHGmtDnILNw0XNXCNfTDdIlwlHYGhwkJ5yIUSztUjto piTg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-36692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t4-20020a170902bc4400b001d73533966bsi6827840plz.97.2024.01.24.01.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 01:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-36692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5C1F328EBD9 for ; Wed, 24 Jan 2024 09:19:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12C1918032; Wed, 24 Jan 2024 09:18:57 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E35C717BD9; Wed, 24 Jan 2024 09:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087936; cv=none; b=nXgwP/cwGY2ECHOSqQM6gUeDxixs+DiybRgNEEy7gypjC1FNVBOQdTMRTJ+yxDCRShgLgSIQ3BCQfFq5HMj7Z4xWnBMayd/yp/M+odwuwRwm7uIix79sKDOoNJWQZ0Ae0yB1CbeKA5Olicch7ZNORII1xigMfhr4sidGuM7hmYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087936; c=relaxed/simple; bh=2sguAUmXQJy+/hHUZSNRGWcK1pkkMCFPkqUUzc67Cms=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DtwsReNc/A0UuadZaPRoWmmvQZIJKLty8R4RMV1ra7MWIfDGPkRIsUiKn70Tih6dHjSQ7engkX37JjwDp7RJ55DQHbw6Jy8I9prnH3Igvps2dJKGaR3n8LjlqRv9CLj0kgXaZOGgDB25xSzgC2JI4ZFBnIIILuFfCxUgvABNGU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TKdZ95hK4z1FJkm; Wed, 24 Jan 2024 17:14:25 +0800 (CST) Received: from kwepemm600009.china.huawei.com (unknown [7.193.23.164]) by mail.maildlp.com (Postfix) with ESMTPS id 463891A016E; Wed, 24 Jan 2024 17:18:32 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 24 Jan 2024 17:18:17 +0800 From: Yu Kuai To: , , , , , , , , , , , CC: , , , , Subject: [PATCH v2 01/11] md: don't ignore suspended array in md_check_recovery() Date: Wed, 24 Jan 2024 17:14:11 +0800 Message-ID: <20240124091421.1261579-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240124091421.1261579-1-yukuai3@huawei.com> References: <20240124091421.1261579-1-yukuai3@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600009.china.huawei.com (7.193.23.164) mddev_suspend() never stop sync_thread, hence it doesn't make sense to ignore suspended array in md_check_recovery(), which might cause sync_thread can't be unregistered. After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following hang can be triggered by test shell/integrity-caching.sh: 1) suspend the array: raid_postsuspend mddev_suspend 2) stop the array: raid_dtr md_stop __md_stop_writes stop_sync_thread set_bit(MD_RECOVERY_INTR, &mddev->recovery); md_wakeup_thread_directly(mddev->sync_thread); wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 3) sync thread done: md_do_sync set_bit(MD_RECOVERY_DONE, &mddev->recovery); md_wakeup_thread(mddev->thread); 4) daemon thread can't unregister sync thread: md_check_recovery if (mddev->suspended) return; -> return directly md_read_sync_thread clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang; This problem is not just related to dm-raid, fix it by ignoring suspended array in md_check_recovery(). And follow up patches will improve dm-raid better to frozen sync thread during suspend. Reported-by: Mikulas Patocka Closes: https://lore.kernel.org/all/8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com/ Fixes: 68866e425be2 ("MD: no sync IO while suspended") Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") Signed-off-by: Yu Kuai --- drivers/md/md.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 2266358d8074..07b80278eaa5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9469,9 +9469,6 @@ static void md_start_sync(struct work_struct *ws) */ void md_check_recovery(struct mddev *mddev) { - if (READ_ONCE(mddev->suspended)) - return; - if (mddev->bitmap) md_bitmap_daemon_work(mddev); -- 2.39.2