Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2688470iof; Wed, 8 Jun 2022 09:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrvGI8OglZoo/1Dk1dc9RcojgaUC4ldiYkmZFCn9UkYgQLmwhevgQs/j7Y1Y8X9rQu+NGB X-Received: by 2002:a17:902:c745:b0:166:496a:b455 with SMTP id q5-20020a170902c74500b00166496ab455mr30816734plq.135.1654707500082; Wed, 08 Jun 2022 09:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707500; cv=none; d=google.com; s=arc-20160816; b=f2b73tjNjXzFwCorM3KNgPyJ2+rM8QPzDKSPSpWdTUDIKRVrSclzWNGDSzMnRWDc+n 1LLLEeOUT+MYYft2Elxx1Sfp/wyzRIJa5T+AL4Nv62lp0nd6AXwMRbuEcv5WVGlrugzL BFzSbaS8H+BK1mztRB/joBui9BfjIHpT42JByTueBoKcNS20pHKYZbPSOhuADD1Np+1W mfz8wLpX7ma3JkbqEodS5SC3zvEA0bLqq//03TIpbklxRhoNhGBSBuY9/de4L1fRaYIt sBdC+Ppt5qhh+z5haW4le6b4Sv7RTNrEx7slEklIhzmt05S79jFC9MTwZNwhRjBn4Dl0 7aGA== 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=bUpZA46sZ11cw7jxGZ4w7Z7/qydqr8hAOH9KDD+fmoQ=; b=MuiRjlvGAJ10ezmo9SGQMIqjurcyiTlLoPcx12kKs2H+5DOPuADLb1VjnE8+jJaVqi kj5JSlAUyN7BbdH87zBaigTczo+6c17iFc/jD7zTndVXna2ipTry0iTDjMhYLB3kQo45 AOsAiHIWxPfB8QoRhLr6Jkm5uWwSbeOVHF7J6J9qblueOQTtOrFMkpWa7b+2O4UsDJ/p sMetP4Pe9e+HfZVNR+RRLjGpbfhAe3xk2+3947k+0S1498YXkRPzxrtoePsGAoIfs4BR yrzJ4dDqdVmNH5edjObwHgEm70lMZPny28g7vlhJL2OZ6Ogop2cn9mMN2T2qRYotDwv8 JaPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b="MBeHV/M5"; 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 69-20020a621948000000b004fa843103dbsi25473935pfz.193.2022.06.08.09.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:58:20 -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="MBeHV/M5"; 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 2BBC323BC05; Wed, 8 Jun 2022 09:29:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245612AbiFHQ2i (ORCPT + 99 others); Wed, 8 Jun 2022 12:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245168AbiFHQ2H (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 6659C1FE3A7; Wed, 8 Jun 2022 09:28:06 -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=bUpZA46sZ11cw7jxGZ4w7Z7/qydqr8hAOH9KDD+fmoQ=; b=MBeHV/M5l/YxQx4I1r41O7dup1 fRpplw19z4K5TvfpcMv0UTdkpg07qzMCc+/hxBz5Q/nBYLsoPiYDZwjtYazefqKm+WeJPE/1BvrfG HZd/hR25qGA6dQ6INYaWuSwEj89aoSosE/bY87pCn82Ikk/BvhFjcjaOq6+PhpsMMj/V+uvEKiPIs l/CA5La7RKgdHqmpMohIxO/uep0lhWDU7bc46eYZyRug8XCHrJEqZhlEXv5lzGEgO9OxuDwHBEJqM ReAXTGHVLotloIJ1Ws2TyWiD1wGE46ZBcdA99eqedtvHst0KNmBvx509cCOU+ZjP7yfM7sA2pNN0K ScvV6uwg==; 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 1nyyXL-0026n5-Ca; Wed, 08 Jun 2022 10:28:05 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nyyXH-000bdl-VA; Wed, 08 Jun 2022 10:28:00 -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:55 -0600 Message-Id: <20220608162756.144600-11-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 10/11] md: Ensure resync is reported after it starts 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 07layouts test in mdadm fails on some systems. The failure presents itself as the backup file not being removed before the next layout is grown into: mdadm: /dev/md0: cannot create backup file /tmp/md-test-backup: File exists This is because the background mdadm process, which is responsible for cleaning up this backup file gets into an infinite loop waiting for the reshape to start. mdadm checks the mdstat file if a reshape is going and, if it is not, it waits for an event on the file or times out in 5 seconds. On faster machines, the reshape may complete before the 5 seconds times out, and thus the background mdadm process loops waiting for a reshape to start that has already occurred. mdadm reads the mdstat file to start, but mdstat does not report that the reshape has begun, even though it has indeed begun. So the mdstat_wait() call (in mdadm) which polls on the mdstat file won't ever return until timing out. The reason mdstat reports the reshape has started is due to an issue in status_resync(). recovery_active is subtracted from curr_resync which will result in a value of zero for the first chunk of reshaped data, and the resulting read will report no reshape in progress. To fix this, if "resync - recovery_active" is an overloaded value, force the value to be MD_RESYNC_ACTIVE so the code reports a resync in progress. Signed-off-by: Logan Gunthorpe Reviewed-by: Christoph Hellwig --- drivers/md/md.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 42923832c077..ec46b83adf29 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8022,10 +8022,20 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev) if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) /* Still cleaning up */ resync = max_sectors; - } else if (resync > max_sectors) + } else if (resync > max_sectors) { resync = max_sectors; - else + } else { resync -= atomic_read(&mddev->recovery_active); + if (resync < MD_RESYNC_ACTIVE) { + /* + * Resync has started, but the subtraction has + * yielded one of the special values. Force it + * to active to ensure the status reports an + * active resync. + */ + resync = MD_RESYNC_ACTIVE; + } + } if (resync == MD_RESYNC_NONE) { if (test_bit(MD_RESYNCING_REMOTE, &mddev->recovery)) { -- 2.30.2