Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2689398iof; Wed, 8 Jun 2022 09:59:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLRQzwiWhChRGNNnNtBWzyw4sueHbxNTU2dzQmwwOLGFzINyfqAbx9RukCQsGDsozV//vb X-Received: by 2002:a05:6a00:24c1:b0:50d:33cf:811f with SMTP id d1-20020a056a0024c100b0050d33cf811fmr35622593pfv.78.1654707579612; Wed, 08 Jun 2022 09:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707579; cv=none; d=google.com; s=arc-20160816; b=CHdPR+1p2+987uCVaF4yx5DtklwsGO9u+7GbSrs3NrZnmGxFK07yO/+kYrPIKarzbf evSd2GbdGZoBZlBgDBlhFf5B8JAzigYJ7kM6vMRuhahaMlhE9Iikl0PfeuPVNCrUWXwl eDYRFv0b7xyjfkwasQB6dJZOG45NASTi1lLrSKZgToIA1G/7kwgd1TP1djvZMHj4ArDw 5eIq1ZSsZnxgsRhjl9srDpDWj/3ug8bkm5akiJMXX4l6xZhlPqn+/OnqiWRI6qerNErl rk4kUjZySXWvEXjjBkEbTHvXfX678T2qmabbZDAL45IJYvmMRA6NegtvGf1lZXblh6hS 0XfQ== 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=RvulF/aPuXxyCuEJPCKiOovtKEBhHz6qdq0wafSQodo=; b=sqPn3xlfcKGaI1XUCelLCYhpBYS4H/7g8uGtZEspg4j8PIqsxj61cdUhnx7sF10BT0 Q/Z8DbttKy0SGskggpCBWKknM9LyRoGiLkKL+9qaAZvJl2zInuXuMgMlynJfF4D8/e+7 8kYaNVnmuGn+EgjMwREARZqAoe00GQasiHW+kw3UeIVW5qI8+3twYiUzBxe9pvfTL6pa iOGVtnGAQ5OYQHjUVurQAqju1YwCrq3/GGLWnTRiupxmMPhxEqWX6Qb6MylisNql4NS/ 68AYQWwZe1G9fq2dbovJn9L44cipzJqL3n/p3YnRd7RBa0VjPQV+erM8Hgs96W3eHzsN W2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=a5OP1PDB; 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 36-20020a630c64000000b003f641a6fe83si28658794pgm.277.2022.06.08.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:59:39 -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=a5OP1PDB; 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 4A65C26C0FA; Wed, 8 Jun 2022 09:30:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245505AbiFHQ2U (ORCPT + 99 others); Wed, 8 Jun 2022 12:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245159AbiFHQ2H (ORCPT ); Wed, 8 Jun 2022 12:28:07 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C751FDEB3; Wed, 8 Jun 2022 09:28:04 -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=RvulF/aPuXxyCuEJPCKiOovtKEBhHz6qdq0wafSQodo=; b=a5OP1PDBTcFCWeZ/q3d80TRtBz UfAMQQSb3+kdCigC/XdDPGU/PcLMuqzfsCDzIiKOF9xLH3L6pRC1WfW1aoFrOXqWSSLg3BNIm2E4I 10FZkoLrLfscpX4vYDwOxc9t+MO8Av3LO1GvTtRcZN2pG/gdlYrfa+IRbrsqFRkz922M7ohuEaKZN m3FdaDrVsLX1KH2k0jApK9JR/8CQpyMLaBnOSe8TDOP6s/PT4MQG48pkd5DS+dMpbhfS/vRP1vkmd 4oI1SBj2Cw6RZ72+v8bKI1Blh4Xj8Mocck/p4ayk8ldB0dnNxmUu7mVOLfJgOshQjiNyYD8tDs0/N rsgxDj2w==; 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 1nyyXK-0026n9-HP; Wed, 08 Jun 2022 10:28:03 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nyyXG-000bdP-Kn; Wed, 08 Jun 2022 10:27:58 -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: Wed, 8 Jun 2022 10:27:49 -0600 Message-Id: <20220608162756.144600-5-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220608162756.144600-1-logang@deltatee.com> References: <20220608162756.144600-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 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 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); 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