Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp454986rdb; Sat, 17 Feb 2024 17:34:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCsuiaoEJAGrSARgZ/PsRsMjuxekt5JH+JKHr8u0om821oz9ntPqGEiC6xGRAbOvbzbhyb9EqTbZNTB8bE7h7bVQ3P0zgVYNHsIIW8dg== X-Google-Smtp-Source: AGHT+IGnjs7XldgdFtNKzy8UnlUTGP5TWeK3YXOkuPN9k2AA/ttVnTrMinfgxBU4mm2C19VzgUdM X-Received: by 2002:a05:6808:3094:b0:3c1:521b:11c0 with SMTP id bl20-20020a056808309400b003c1521b11c0mr2303007oib.2.1708220043235; Sat, 17 Feb 2024 17:34:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708220043; cv=pass; d=google.com; s=arc-20160816; b=M3UVKebS50uKrzT1Q8cw4GB+ZOv3YbDTDnsErO/zdLHo83M9aPMgeVxXt4IwjhTF2D mNo/wUfH7kIjUHVJfWTlZaTtgHGUzjsZkdM3x4tP+NPjGCsYCtO6PWUiDpnAcARxtkn4 V0ECwNm0BMmfCjXQczUCBHC8h29EQDNdtphueKlv/TymP7gM37nIHWyCvrwEpWMXJUNl hZGt6wlBTSLdJKGVINTGW3YNr8hJPOSVgpQmPAzxHyTgDmg7Aij/xC1kAcdL5gqlhQem GMGehAHu3fSOvnmrJScISa2MFufn+iBmbPR0KGDXIoMCDg5h7VWiaUs31bYO7USc7pF+ BUiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Arbd8TS6QkRLNnADRY4SzeJ5a3a+RPD5q4GAzUNO2hw=; fh=v0r7QX+gCu1Td5MqZgKYiwucT0IrWU/aOA+O3iuN97Q=; b=zj0n9ykMSqsw3l/k/OXVOhC+XgzLZXNcaiu4cAshThAfRxgl5cR7rCZ/q8oc2s8jbf jyBaj/xMsHulleRV+G+VLlXb5mWJ+bz67sTfM+j5HDV+/SCKbE0MNx23qdJJZu3nz99C RoW0JG0IYxfJ93/yJO4r6D69PuGTJQgjMOjzQF0ioehGzkdtXsivrpb7cpsAPt6FM0gx s6ibiC+8cheoYek3/3dd+Fe4f+MLS6dmNsu6lFJ5IbFQuYfnFR85wXHZ7qdxB9VIOU12 QOe3NkQeFI77vkftb3KIxzJy+02JHZaDHUjkBkH+NZQb/kS91AB4A9XAqO0kCp9oyVJy o/WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f7zrhfkE; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-70137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s63-20020a635e42000000b005cdf8b4d2fesi2155778pgb.747.2024.02.17.17.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 17:34:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70137-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f7zrhfkE; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-70137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 E175B282436 for ; Sun, 18 Feb 2024 01:34:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A138D17FF; Sun, 18 Feb 2024 01:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f7zrhfkE" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 D4153EDD for ; Sun, 18 Feb 2024 01:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708220035; cv=none; b=B9H01A0p1wM/AKjRLGjBEqGxBIUkPEmabK++QBH++1s29cOvL36mZOARr7Fq/myWcgE6Y6fAh6QunA8xBM7IUET0Ntssm3QwcmIUcmFHPRwDoZVfydk17hvd7kaXyAd8bA0ey9pqyqrUGkRiQO3ozKkp5xQrnA9+PU32hD8QMII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708220035; c=relaxed/simple; bh=sN27NeahzJVaG38gKCisWN3iwjTBOQ9bEfCLMhCKwyc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hBorXk42xNLYjFXii2droAsLWydIeyaF6lm+tka/LIsNtbQ+6hFj7BTQo93szdXnXj9tKvmBG7PE357cQM64YaTkOqdc4ZpW6481gtqfJkX6wi0mMEaFqwSU0xmfPqDb+kuvmV7HCNstYUxaVLQmmJNtd70ZAjOnOsN5B+XnFCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=f7zrhfkE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708220032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Arbd8TS6QkRLNnADRY4SzeJ5a3a+RPD5q4GAzUNO2hw=; b=f7zrhfkEXHUdYnzaABv7rZL6kKPyDFpr8TQu+QP33Hietdic/7ceNBn0j1a5EUNxQ2Fj+K nIrJUgcKHU6LhmYXxJsw1IrD4YmrVb5sOGNZvJOG1QiR6n1bfA3jrL6KRm9zbbIH/TnKW6 7yuTkUch3gfRQYKpTixZyexm9PWy6FE= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-2TI0ih4iO6mK7-et8qWA5g-1; Sat, 17 Feb 2024 20:33:51 -0500 X-MC-Unique: 2TI0ih4iO6mK7-et8qWA5g-1 Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-5ca4ee5b97aso1280381a12.1 for ; Sat, 17 Feb 2024 17:33:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708220030; x=1708824830; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Arbd8TS6QkRLNnADRY4SzeJ5a3a+RPD5q4GAzUNO2hw=; b=cHNGgy4A5zV5Y+RlcNt9MxLi/7RWLZoKABVLg8MtbePOJ0Z6OUeRqBZ1ddZyPF1OsE 2JPJ/HgJK8QZlj2EljPg0yUpP1wkFaYx1iT5C5L0HMsbqRgjZCX7K1YgByJpAj5LXahJ gpqvbeVjVZRNqs4VzUhMXB6uukDsiS0Nva4IWQUY4T1fF8bI9WivnP2qI+wvsGm9Mqf/ 6zvl67FzCJWc9iuO4BJh9nN9w/gFPyg4qpVKTvxa6dkWbgn3SnrkSV7+ZFqdT4vNDm6z cnJ9dKVUkmhwsUJAls7Q0/z/cx9BoI+fbsVmV5/bT4pG/1QdsOXFgM6BuJvqTwygvS9w l6/g== X-Forwarded-Encrypted: i=1; AJvYcCUNg+ZrOwuRFUHHpSZ5w2BNQedkh47ltDQnvNkxWEFwqRlGeMCiW9KGpQOwhrZD2rLZJrn6QwLhBtyXk3/6U7GhtwdsLNSe05KTWj07 X-Gm-Message-State: AOJu0YwXm9Nu5diU+oS22o9cEkyq1oifeqaLDS7SZaSxKgYFx4Pqcd5r Tj3PvP1CBqFfrN/CjzUYVfuvx64zY3dG6KRdCzqevyxLCiXaLPdedhhrCS5rhBTJQuGuq5GrQVK G4Sa7a3hFPsvBp74KV7X/yXYpcE3xmZ66xkWFYNuNi6xFf3/TTIctdVeww9EWgNc4WFIDJdv+TK KXgZM2MP81CcLXGmarOySuJnjGX8Sy2UTz8878 X-Received: by 2002:a05:6a20:a999:b0:19e:c32f:35d6 with SMTP id cc25-20020a056a20a99900b0019ec32f35d6mr6651290pzb.19.1708220030104; Sat, 17 Feb 2024 17:33:50 -0800 (PST) X-Received: by 2002:a05:6a20:a999:b0:19e:c32f:35d6 with SMTP id cc25-20020a056a20a99900b0019ec32f35d6mr6651280pzb.19.1708220029804; Sat, 17 Feb 2024 17:33:49 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240201092559.910982-1-yukuai1@huaweicloud.com> <20240201092559.910982-2-yukuai1@huaweicloud.com> <64d27757-9387-09dc-48e8-a9eedd67f075@huaweicloud.com> In-Reply-To: <64d27757-9387-09dc-48e8-a9eedd67f075@huaweicloud.com> From: Xiao Ni Date: Sun, 18 Feb 2024 09:33:38 +0800 Message-ID: Subject: Re: [PATCH v5 01/14] md: don't ignore suspended array in md_check_recovery() To: Yu Kuai Cc: mpatocka@redhat.com, heinzm@redhat.com, blazej.kucman@linux.intel.com, agk@redhat.com, snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org, jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com, akpm@osdl.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 18, 2024 at 9:15=E2=80=AFAM Yu Kuai w= rote: > > Hi, > > =E5=9C=A8 2024/02/16 14:58, Xiao Ni =E5=86=99=E9=81=93: > > On Thu, Feb 1, 2024 at 5:30=E2=80=AFPM Yu Kuai wrote: > >> > >> From: Yu Kuai > >> > >> 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: > > > > Hi Kuai > > > > After applying this patch, it's still stuck at mddev_suspend. Maybe > > the deadlock can be fixed by other patches from the patch set. But > > this patch can't fix this issue. If so, the comment is not right. > > This patch alone can't fix the problem that mddev_suspend() can stuck > thoroughly, patches 1-4 will all be needed. > > Thanks, > Kuai > > > > >> > >> 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; > > > > I add some debug logs when stopping dmraid with lvremove command. The > > step you mentioned are sequential but not async. The process is : > > dev_remove->dm_destroy->__dm_destroy->dm_table_postsuspend_targets(raid= _postsuspend) > > -> dm_table_destroy(raid_dtr). It looks like mddev_suspend is waiting > > for active_io to be zero. The deadlock problem mentioned in this patch should not be right? Regards Xiao > > > > Best Regards > > Xiao > > > >> 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@r= edhat.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 > >> > > > > > > . > > >