Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2759108iof; Wed, 8 Jun 2022 11:24:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtt3ZGto4NBtPaNh8R6CzacVBQc4/pAz3yja10vCGwrBBGnr91OcNwEp1cxy4YXg1EQtwa X-Received: by 2002:a17:907:86a5:b0:6f9:aa0f:a838 with SMTP id qa37-20020a17090786a500b006f9aa0fa838mr31989860ejc.340.1654712644643; Wed, 08 Jun 2022 11:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654712644; cv=none; d=google.com; s=arc-20160816; b=l0ZR+AAasHcUQj68UrHgzXjfIP50ZPgSXBNauFJzsMgSIVV81JtJYPT3qDU/QlyXzm KfpGUlYc8/2kybk11E+ljn0iZzGjqfJ03pEDqRYcB0wC3ZFq58w4lJ9081a4vXu7YfWe DJJ5sJ4OMCaKk2WMtUDSLQ9dBDr1LbShUeVb2XRLb+ybujoT8Q3+XujIC6j2NEOciLh3 3e+7bARwRHQr2FZoS69RrdRw1ezG57pRRjUV7XebE16XX36P7zwKGwOcmpXCZF5sb85w 49/bzJrERf0FYU5xsTz/6+8uVyd/BuAsO3hNPMO0yBZuTCC+OwiTYTmZniBErenS6CQS gjuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:in-reply-to :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=XkHYb+oSLXpBEo6cMCxhRVOvyJgyvCtSljAnI7lNXXs=; b=YVww5/lrYfcJhFT3e3ZQv8XECm0sqrPeyA51CFcIRepJQh/BZ6CNBX7S7tcILUWMc2 LdNajmCjLSnhE7iG7JnxPNgm8xhn5/bHUeGP7mSU1mZ7mZ3hoXeoQclspvDe6XBr1OSv 1DO9E+F2OqVLka+ZYWQF+7lzWb9RwIOIR43K+YHc5hJj7je299H2889mjqFMIsLrJUuF b6MIzDD8pTSamOchHacomMySz5mPv/CZRReGzmpO6XHhCMa/69pwA7wKCiwLJH8Vbg7q uVquPZaf0j46giPWhJzb5adh5axw1LP5JBXpSKARB/LsRJTe4aiBIgUQ7SDsk/CkpdTT LD7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=dMHipBDX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a1709060f1600b006fec6226554si13069175eji.422.2022.06.08.11.23.38; Wed, 08 Jun 2022 11:24:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=dMHipBDX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234239AbiFHSV4 (ORCPT + 99 others); Wed, 8 Jun 2022 14:21:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234109AbiFHSVy (ORCPT ); Wed, 8 Jun 2022 14:21:54 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2EF1C116; Wed, 8 Jun 2022 11:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:From:References:Cc:To: MIME-Version:Date:Message-ID:content-disposition; bh=XkHYb+oSLXpBEo6cMCxhRVOvyJgyvCtSljAnI7lNXXs=; b=dMHipBDXa0Xk7SK9ngGdmavKtu 1iGj6Wpj4Oup+A1YqQ38iNCwOd6Z0Dp9AYpaGR6Wodq86/c2sw2fPweXbUW8qf8WUF0p/OjEJpVI0 DmYiI7SVKaCkBEebjgJ4fsaBCakf+w/0HzcENdOY6m5WXlRn5IsJYdsFag/mhpg9AJJTUwSoBEDkZ GNP8av8fYRVGWzCXSeldXEmIW9QkY1BKk5SPjgcR2mHVggTjPLK+D67BEhPT9eVpf4doOsGSSsNec ogK9HDp1Atv+v2LQpzqUGm8EHynoNyyzqyqSTNAHHYiOTgA8dXxqsIAejkeK7DgHIQ6031aM5/tOd u1Y7TwGg==; Received: from s0106ac1f6bb1ecac.cg.shawcable.net ([70.73.163.230] helo=[192.168.11.155]) by ale.deltatee.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nz0JP-0028yT-Ow; Wed, 08 Jun 2022 12:21:48 -0600 Message-ID: <08b80caa-d726-b9f3-7ce0-f486b8080ec5@deltatee.com> Date: Wed, 8 Jun 2022 12:21:46 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US To: Song Liu Cc: open list , linux-raid , Christoph Hellwig , Donald Buczek , Guoqing Jiang , Xiao Ni , Stephen Bates , Martin Oliveira , David Sloan , Christoph Hellwig References: <20220608162756.144600-1-logang@deltatee.com> <20220608162756.144600-5-logang@deltatee.com> From: Logan Gunthorpe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.73.163.230 X-SA-Exim-Rcpt-To: song@kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, hch@infradead.org, buczek@molgen.mpg.de, guoqing.jiang@linux.dev, xni@redhat.com, sbates@raithlin.com, Martin.Oliveira@eideticom.com, David.Sloan@eideticom.com, hch@lst.de X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: [PATCH v4 04/11] md/raid5: Ensure array is suspended for calls to log_exit() X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-06-08 11:59, Song Liu wrote: > On Wed, Jun 8, 2022 at 9:28 AM Logan Gunthorpe wrote: >> >> The raid5-cache code relies on there being no IO in flight when >> log_exit() is called. There are two places where this is not >> guaranteed so add mddev_suspend() and mddev_resume() calls to these >> sites. >> >> The site in raid5_remove_disk() has a comment saying that it is >> called in raid5d and thus cannot wait for pending writes; however that >> does not appear to be correct anymore (if it ever was) as >> raid5_remove_disk() is called from hot_remove_disk() which only >> appears to be called in the md_ioctl(). Thus, the comment is removed, >> as well as the racy check and replaced with calls to suspend/resume. >> >> The site in raid5_change_consistency_policy() is in the error path, >> and another similar call site already has suspend/resume calls just >> below it; so it should be equally safe to make that change here. >> >> Signed-off-by: Logan Gunthorpe >> Reviewed-by: Christoph Hellwig >> --- >> drivers/md/raid5.c | 18 ++++++------------ >> 1 file changed, 6 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c >> index 5d09256d7f81..3ad37dd4c5cd 100644 >> --- a/drivers/md/raid5.c >> +++ b/drivers/md/raid5.c >> @@ -7938,18 +7938,9 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev) >> >> print_raid5_conf(conf); >> if (test_bit(Journal, &rdev->flags) && conf->log) { >> - /* >> - * we can't wait pending write here, as this is called in >> - * raid5d, wait will deadlock. >> - * neilb: there is no locking about new writes here, >> - * so this cannot be safe. >> - */ >> - if (atomic_read(&conf->active_stripes) || >> - atomic_read(&conf->r5c_cached_full_stripes) || >> - atomic_read(&conf->r5c_cached_partial_stripes)) { >> - return -EBUSY; >> - } >> + mddev_suspend(mddev); > > Unfortunately, the comment about deadlock is still true, and we cannot call > mddev_suspend here. To trigger it: Ah, yes. What a tangle. I think we can just drop this patch. Now that we are removing RCU it isn't actually necessary to fix the bug I was seeing. It's still probably broken as the comment notes though. Thanks, Logan