Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp2001408lfo; Sat, 28 May 2022 13:23:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVc4Wyebo0rv4woJ68mSbNiLU4oFyVJsA6/Cb0XmBzZ/RAxEPUWnkfoC/4CSQiA60pqfj4 X-Received: by 2002:a17:90a:4e4a:b0:1e0:8e2e:e0a5 with SMTP id t10-20020a17090a4e4a00b001e08e2ee0a5mr14869313pjl.216.1653769424127; Sat, 28 May 2022 13:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769424; cv=none; d=google.com; s=arc-20160816; b=hOTjrhoT/wbticl0PtqdN1nhuNlcf7BHpsNN/SquDpzkBP1MN8n74E0MDuVrDL4NfC Hvn4S/2/mWCiRr5yUzGdU7/F4+4hap0/6DAmwmMTwOqt/pniqyUitGSe/VBJBI2aWmFD KLD7vsFamaOa7JArS07J1IUNj7alHHgqEhjPV+JDZuBO4gvHj8L9EtXsrGQ73q7Xi9HW 4IwKJK/B0bHid47glXS3pg9e+OVIGFldujrHVaF7PxfBiP27FbdtZ2wRXzsSUZudypiE +IIPO5F4jK+Fnip7NjWIqW2cokm2rmcTLyXy+En1YdX/wUD6E99H0q3Lsdh/+LldvJK0 7oTA== 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:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=QyHrnH5ZuXktkhsga6G9I5lk9psWpw8ft+8WQu8yre4=; b=MzXxkz86y6dW3vFxW/4fQqWhqjN8tz/WaXiX+DGVKr/CA6BI2v4ZJvT/QPBjPIN9N5 SQNhtjdB2l0eWszKSdaWJE8hI1IQZ17VV6lW6RYbydGpfhKWRb+Fq8wLO8TQ/zczpkEL /vNHg523kmvO4ONok3RPHHqdz1LORBcIZrqpUmYsKqkaaJjkI9MszPJTM7svJwLyRN0d XPiKa6tJYu7BICp6JdL2gcXLB3ZHcoK15Y2e/ogr3W0wyhQelOgaV7T58pfdsmm/Qn4K yB9qBCkdW4vBnvytOI8eauyH4MCuV+DAbGYMClSfbVE/xzVDuxyBOBpjCVXM86vuFvTR AXjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=SGF2gA9O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j14-20020a17090a31ce00b001e012a01ddcsi6714268pjf.28.2022.05.28.13.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:23:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=SGF2gA9O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CF8A2166D4B; Sat, 28 May 2022 12:30:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236057AbiEZQhq (ORCPT + 99 others); Thu, 26 May 2022 12:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348154AbiEZQgY (ORCPT ); Thu, 26 May 2022 12:36:24 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC1E3B3C0; Thu, 26 May 2022 09:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=QyHrnH5ZuXktkhsga6G9I5lk9psWpw8ft+8WQu8yre4=; b=SGF2gA9OrU3pLiVsW/FZQRJago JPn8NFyCFlLAhhLSKCOPdFrg+2ZaD62MRS8+Mf9euTicQJDdWT9fumN5CZKBSF8RLATO+lO2E6J/V V5cTyn7QfpB4D7WjTB6N0oqR6POltT3STWuv6HzCW9EULMGkw+d2pyTiWrH3bKl0ENN9qtykN0NM8 QRab/EX5hzeTDzY8NKGBzzEalOOVBOjjXjLUbxt78ClUplEnU6Hyshrzi29hdd0uI74ibJID2iy2p eyj7CRN9xEXhznyhD/oYRd92gXQ4pfXUKk9dGKab4aCPp8RXp1ZD2pAl9kQeFSeHglqx8fonrU94h AduRxbpA==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nuGTF-008A7R-Rs; Thu, 26 May 2022 10:36:22 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nuGT9-0008Xf-VQ; Thu, 26 May 2022 10:36:16 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Donald Buczek , Guoqing Jiang , Xiao Ni , Stephen Bates , Martin Oliveira , David Sloan , Logan Gunthorpe , Christoph Hellwig Date: Thu, 26 May 2022 10:35:58 -0600 Message-Id: <20220526163604.32736-12-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220526163604.32736-1-logang@deltatee.com> References: <20220526163604.32736-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, song@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, logang@deltatee.com, hch@lst.de X-SA-Exim-Mail-From: gunthorp@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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH v2 11/17] 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 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 0d486f8aaf87..4b25a0262cb5 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); log_exit(conf); + mddev_resume(mddev); return 0; } if (rdev == rcu_access_pointer(p->rdev)) @@ -8697,8 +8688,11 @@ static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf) err = log_init(conf, NULL, true); if (!err) { err = resize_stripes(conf, conf->pool_size); - if (err) + if (err) { + mddev_suspend(mddev); log_exit(conf); + mddev_resume(mddev); + } } } else err = -EINVAL; -- 2.30.2