Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3271759lfo; Mon, 23 May 2022 00:24:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIssPXol5IMDFS7LbJ4V8gQE4ScZ6T3VnkZL5F5NcytuoqgWcFf4xoV/hi9qc2WZxApbIk X-Received: by 2002:a17:90a:4803:b0:1dc:b4c9:1958 with SMTP id a3-20020a17090a480300b001dcb4c91958mr24960082pjh.61.1653290663901; Mon, 23 May 2022 00:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290663; cv=none; d=google.com; s=arc-20160816; b=MCWr6ZKDwEVpxRWgm2uL09ntKm/ffTOvHDcOPjHWD8/zAR082P/XD79JRpt1yL5zUs GqbrOL30GJek+CMSGWRzybz0JfS76LY2K4Td+Zc9eak/lECeSBR1DumwTlipYfFV7ena EW2pbklEfqdGxuPUAQsRrgx/ziUbjrq9PLN2/Qf+mkYFwjrswu3h6rp4cgxyoJLEYbox mR9vRUjmQD/y3odo7kP01oNMkwk4cDf28nRXjEHUpsEm6CyYL3jEZQHkUYDByf08v4hv aC8Mrydf/I7brb+Xtjg5dhqVvzZIqYPxWWHo8L2cxFdNft8XyU3+TlKTG0Jfoli95moT i1oA== 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=jpnVmJs1KfzZmF3zwWdAWzAxHHjPyHXS6ik10MBhG+A=; b=madnBzTL7Zq4NXSbi/ECNxqXvklXZO5bwOt1WUMAM5mH1NE/1ZcqgdrnBKGykEjm4D c0mqz9e66ZHjhuPQqQHkfWkuwDubbJhAkWhtpixgNJd+JfWT9BAaZIcgmIvDaGjmQ6WP oo4TC4EC4Pf2192UTMv2tUTSNBgGChNWDnpiD3CGCJCIeEBC3EJ0U0QFeJD0HPnr2TfF fVsiR3jpIR2fDtgU2hGqPwLUHmLZDzWeZiMPXD2xvqEMvoNNurUxsOtzRsGEepDDRwVb a2/nVEbC5KEs9ifJEUzT5ZBAJXWXNmpGmgZPMkl3Q62aq4nAh+CknjqZ+Ihd7DfGvSzk XFDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=PIfym8rn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u4-20020a63f644000000b0039dae898c4fsi9111302pgj.220.2022.05.23.00.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=PIfym8rn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 3AE52C1EFD; Sun, 22 May 2022 23:38:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244424AbiESTNy (ORCPT + 99 others); Thu, 19 May 2022 15:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244328AbiESTNZ (ORCPT ); Thu, 19 May 2022 15:13:25 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C69AF1DF; Thu, 19 May 2022 12:13: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=jpnVmJs1KfzZmF3zwWdAWzAxHHjPyHXS6ik10MBhG+A=; b=PIfym8rnKlEZJ4wOsJxYgvHPRj Pw0ovd8XddoS/VUgjOQO9+2I06h0d8AvXWExgV+aWUyigrUt8Ot613BVCJUHFh50jT4guweXddWpR JcGBwrphW9EmqMIOuHMZQ8qL6icNtP2gnDClzUmisVWHCaRP3NokuWbErY5Ppc34Z9NsWqRh7RRgF V2+UQpYvkDSF4k7kf+gy7njuRodsGwY3cxPwpPpe9TdWiKEFb0qxW2aUY66vgw+PARSL/NZbtixgs fG95PWOn1YcoFVXgrvBpmYisH8AZ2yE0vO0nR89GUvomhmVJAk3oSTczS+HBmT1EcaM3y1yV63H84 iLCRq8lg==; 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 1nrlaG-002TqU-58; Thu, 19 May 2022 13:13:18 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nrlaF-0004Tl-5s; Thu, 19 May 2022 13:13:15 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Guoqing Jiang , Xiao Ni , Stephen Bates , Martin Oliveira , David Sloan , Logan Gunthorpe Date: Thu, 19 May 2022 13:13:07 -0600 Message-Id: <20220519191311.17119-12-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220519191311.17119-1-logang@deltatee.com> References: <20220519191311.17119-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, guoqing.jiang@linux.dev, xni@redhat.com, sbates@raithlin.com, Martin.Oliveira@eideticom.com, David.Sloan@eideticom.com, logang@deltatee.com 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 v1 11/15] 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 --- 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 09e768f2d32c..37fe2af77c93 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