Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp866793rdb; Tue, 23 Jan 2024 18:58:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpjLKka7OrPgwxbqhsPCGlgt1X0MreYnOgY6UfD9GpI2FnOCH6IGaGHAJh7EHHfRa3IMzi X-Received: by 2002:ac8:67d8:0:b0:42a:5419:e4d6 with SMTP id r24-20020ac867d8000000b0042a5419e4d6mr1364596qtp.13.1706065132116; Tue, 23 Jan 2024 18:58:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706065132; cv=pass; d=google.com; s=arc-20160816; b=sfEZZWf6Qn8Uec6tIbY+ibxlH8BLfDDyhcQmhiFyhAwAPjuOUAjwztS6/j+hyioMyV bMFBwb5wOv991zey3FF3XM1bZLIJ7RmCk4Cw2hjOcj64KrKbhakLGrC4ZSkJHGRmB3+A Q536wkYE6P3iNOc5pj0S7y/u8G2I+tyj9bzeZcqZN+ZCsF9Z9zfqAaHCPctoQfLiUO6O RqYK2+AXH0OblpYnOLtH4oe2HkjsKCJCqJYFFDZaE0qx6WvZU0HxDBfq8hjZ2BEt7A05 tIJN4rfHjDWrNyB4Shl3IyMrsBPyan9b/JYwC4mQ7lJk3FLQ09hmjp/uEQVeRGwe1pQf DKTw== 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=Aa5lqsF1sJUt2zL2UVZScY7jse2XJ4+k4JV/JtcjRIQ=; fh=KAKc+NuyL8rbO12XoWU2+4cHRnvnlpC7UHU+kXuBfxM=; b=UAaI9yvDTaMEnu2mrYQdjaEY18I8N07uIDTqM0R9EoROZ54xRwWygD+ciW4VlGUbLs rAumZNed3YtUp/+42EK+2DJKEJPDOvFgtOEdAV92tPCs+VaIeI1syMawfppz8ltoaGQ6 BSUS49c2VNZUGLOz2GYIlZN4bunwEp5gSILORggDxWvDqf+dJElS/zLCDQU01dWIbLIZ fArx+9MxynxCxibrcitGc64DE3k2LXi+wmKu9ugUWlYYR6Bs2ecfHUEgE3d5iHlT+T4/ mKdLzduPhwUVh9OtQnZ5T6L402Fiv06ZSt5G6t9nhfBYbgKdWOgjLjqZBtEOIOPuln1Z FjyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LL2WBjOi; 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-36368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t9-20020a05622a180900b0042a2b401ed8si9434463qtc.610.2024.01.23.18.58.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 18:58:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LL2WBjOi; 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-36368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36368-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CD6E31C21D83 for ; Wed, 24 Jan 2024 02:58:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B09C46105; Wed, 24 Jan 2024 02:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LL2WBjOi" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 D76C35244 for ; Wed, 24 Jan 2024 02:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706065123; cv=none; b=m47QYf5qnnTfIAOCQ4veU9W5+h8i7Kb8wH3ocFN80FTljw9EIhp/JVR6LwyxypDahL13mHa8IY1w8Imk/ccunx0m8cccHzHMF04ByMPri7cnFxaSVRQuEOyJXRzidp5qnC9hNhmM5UUPaBqk+EcNwbwZLHiDj9Y98KTtL0dmc5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706065123; c=relaxed/simple; bh=g73w3oGcjQjPTuHwF8LT2kH6K2o25tSddbNO6vmK7OE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bQGAyD/PsaZFbwaVWtRr+e78mT2wRjhDmjQ8JuJ5+g9Ag2kemhit3tvuOrloFNooN5yLQBcLjqLQd77v5dBPBu/beIOOByFPNROtZP9QVZugn05uXkSm0kPQItbfMLXLLGUyBOqah8SH2BR4OiimHSwzxRRUJUz4apGNztsx5vs= 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=LL2WBjOi; arc=none smtp.client-ip=170.10.129.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=1706065119; 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=Aa5lqsF1sJUt2zL2UVZScY7jse2XJ4+k4JV/JtcjRIQ=; b=LL2WBjOizx886bb+NBpSxU0y74b2bWKyk/xT3pSjmqR1zDu8Grw5RGfaQAC7tbyT0Vbf0g 2a+Fm0JN9ySMeKsWLP+P27VhNHTqR5k4ThSCCaJHkB2DZDLADK23NC5fN33VItxcc2uRPq 5T3n+j87c0LPQ8bQLCWPW4Fuj2I1NWU= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-GgKqxspEPyKYuOl1YUyr9Q-1; Tue, 23 Jan 2024 21:58:33 -0500 X-MC-Unique: GgKqxspEPyKYuOl1YUyr9Q-1 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-598dfff253bso4724254eaf.2 for ; Tue, 23 Jan 2024 18:58:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706065113; x=1706669913; 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=Aa5lqsF1sJUt2zL2UVZScY7jse2XJ4+k4JV/JtcjRIQ=; b=U1I0tkWQxQOdxQiyf5980Y03a3lBNvcb7x9Z+m2iTvN0Oi0/q3GxWQ+Vo9UN4Szbfi SQK488d9oP1W+rtfkKeRiW/odWK02h2hgBbZYvSqu5zuquDJEfZbK7ESeAA27q50C6QB XdB3DhOEf4p2rwAuPpWy1tbhs3b4e6AaXEWV07lshHTBbxsz/oyASGdwriwa1XaiyBpu f55Yb6Q1KZX41SyLlThPPWf7EKSFMC7P6i+Q8VDVzQsZVPMjp6LrDxzy7VSaCbgctst5 DzMNY2gM9KBGlHDCsHDzdDupTJesHBpx80dtWt4t1HTPNODFFuxMeLDNHNdVQeMXxMr/ 6smQ== X-Gm-Message-State: AOJu0YzFtyc5Nksdv3Rd9OCpLGMuleBK/1yNuEYx9mQVkj8RzJBeDUFg +xKr9+3+dauiFLhNKXJeOUpGm8GDnK6/btBRgWpvO2tVPiu/wTgGAjsFhZKMXvyEc4b1bla+FLF q2tuhm5lwfiTAjPvuqbuUeiIAwJv5Fq2xlHwOEO5U59AVpFRtJe4KoprVlDMZbfRzPbXBc6bJtV u9glmyVum+VqWtVt0xkES44URybcGf1tUak+ig X-Received: by 2002:a05:6358:923:b0:176:91b9:831 with SMTP id r35-20020a056358092300b0017691b90831mr40192rwi.63.1706065113100; Tue, 23 Jan 2024 18:58:33 -0800 (PST) X-Received: by 2002:a05:6358:923:b0:176:91b9:831 with SMTP id r35-20020a056358092300b0017691b90831mr40183rwi.63.1706065112851; Tue, 23 Jan 2024 18:58:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240120103734.4155446-1-yukuai1@huaweicloud.com> <20240120103734.4155446-4-yukuai1@huaweicloud.com> In-Reply-To: <20240120103734.4155446-4-yukuai1@huaweicloud.com> From: Xiao Ni Date: Wed, 24 Jan 2024 10:58:21 +0800 Message-ID: Subject: Re: [PATCH 3/5] md: make sure md_do_sync() will set MD_RECOVERY_DONE To: Yu Kuai Cc: mpatocka@redhat.com, dm-devel@lists.linux.dev, msnitzer@redhat.com, heinzm@redhat.com, song@kernel.org, yukuai3@huawei.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all MD_RECOVERY_WAIT was introduced in d5d885fd5. From this patch, MD_RECOVERY_WAIT only has one usage during creating raid device. resync job needs to wait until pers->start finishes(The only place which is checked). If we remove it from md_do_sync, will it break the logic? Or we don't need this flag anymore? If so can we remove this flag? dm-raid uses this bit in patch 644e2537f (dm raid: fix stripe adding reshape deadlock). It's the reason why md_do_sync can't set MD_RECOVERY_DONE. Now we stop sync thread asynchronously, can we revert this patch? Best Regards Xiao On Sat, Jan 20, 2024 at 6:41=E2=80=AFPM Yu Kuai w= rote: > > From: Yu Kuai > > stop_sync_thread() will interrupt md_do_sync(), and md_do_sync() must > set MD_RECOVERY_DONE, so that follow up md_check_recovery() will > unregister sync_thread, clear MD_RECOVERY_RUNNING and wake up > stop_sync_thread(). > > Before this patch, if MD_RECOVERY_WAIT is set or the array is read-only, > md_do_sync() will return without setting MD_RECOVERY_DONE, hence use > stop_sync_thread() directly will hang because md_check_recovery() can't > clear MD_RECOVERY_RUNNING, which is possible for dm-raid. > > Signed-off-by: Yu Kuai > --- > drivers/md/md.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 6906d023f1d6..ba45c7be3dbe 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -8788,12 +8788,13 @@ void md_do_sync(struct md_thread *thread) > int ret; > > /* just incase thread restarts... */ > - if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) || > - test_bit(MD_RECOVERY_WAIT, &mddev->recovery)) > + if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) > return; > - if (!md_is_rdwr(mddev)) {/* never try to sync a read-only array *= / > + > + if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) || > + !md_is_rdwr(mddev)) {/* never try to sync a read-only array *= / > set_bit(MD_RECOVERY_INTR, &mddev->recovery); > - return; > + goto out; > } > > if (mddev_is_clustered(mddev)) { > @@ -9171,6 +9172,7 @@ void md_do_sync(struct md_thread *thread) > mddev->array_sectors); > } > > +out: > spin_lock(&mddev->lock); > if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { > /* We completed so min/max setting can be forgotten if us= ed. */ > -- > 2.39.2 > >