Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp831236rwb; Thu, 11 Aug 2022 10:37:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR41NAteWkXTr7m+sQCYc6iuzKfYG3LJT9qjSsEUYMfnT94TD7+6Js3SPJBty8hXqfOtmR8O X-Received: by 2002:a63:fc20:0:b0:41d:234f:53e2 with SMTP id j32-20020a63fc20000000b0041d234f53e2mr122653pgi.199.1660239458744; Thu, 11 Aug 2022 10:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660239458; cv=none; d=google.com; s=arc-20160816; b=n/IKAoY4VLGUsXQUGP7whPyEzZjOpDSn16r9mx9vuW5CbbNnIeuH0+8SWKJU/fpWBe Zc4FUvVqRZI5N94Je2yrfvoSlptGj+OcsRmwNRWhWqP0GnoMvvthMTJJmuzQuOYgOfwz wu4YOrlo8+cZlN89tZ8YiGkeGmfBI6QIMBIjYkRK70v5dJ1qzXAbd8dApz5iwPosxmNj WvuU1E2aKHUimiQOHvHv0ZMS4m/q6zd1/VErbIGH1hAgk2ykDgzxVOv8Itjh9V2hZIZ/ W9ZRDvfl3arsxKjSBAEmRe0OkH3PnvshzuR4FTkMbwH1WXG+cpKenRiy8Fb6gNT9cbh3 62qw== 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=LtG2lQ8g4UFMf1coUU5mYDsEFUIxxdCEAwjofNBnS6E=; b=Qja/UsZ/w4rd7JEfZGpS/vI0FMfXQVe/7OhhfUxkjrYCL81dQyb+mSHs8w67m11fzu aA6GiUYPio/xdgOp+FrG0K1xjlCNGgHwe2pBoDFQeaYSidlZbqmP1CbaoKDSkQSm/tpd 1mv03Md/BpTYE6jrmWsrBe0lWNSPN6lbtWO7wYCLjZPiQa/8HyUYrzuZXBRaG+n7vD9I nmQfGcUbZbhLOCciT8GmKjLg4OK8xX9f8lawYjmofr6YkHIgj/meMvZp9fV2bkTb2GhW GDkXPXCmpmqfrzZhQDH6s/kCneHzraPnpBwfw/cagK7iNCm3Ns8t+IxT/xYEyI8mETvK 2whQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=COivCoJd; 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 l7-20020a170902f68700b00169ff93b923si6186883plg.48.2022.08.11.10.37.25; Thu, 11 Aug 2022 10:37:38 -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=COivCoJd; 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 S236468AbiHKRS4 (ORCPT + 99 others); Thu, 11 Aug 2022 13:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235244AbiHKRSf (ORCPT ); Thu, 11 Aug 2022 13:18:35 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 054FB98CB0; Thu, 11 Aug 2022 10:14:28 -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=LtG2lQ8g4UFMf1coUU5mYDsEFUIxxdCEAwjofNBnS6E=; b=COivCoJdVPvxuCsM3im5fV1ASK 4oXPj5JLozg6OMvSWP+UnzS4S5WPNzPBVVsTCtBd61dIJJoy6DeJQh+P3Gp1XSrM9KlVGeUFq+lwi o+FrcMVlJ9aeOBQuqbzfKKeuQMbMoDA4veJN5pMO6LgazRocaxoaYOZFo8YKWs+2Z/8Lyz52WImnf KraCvCojyNHbWODv3mBzYrsc2uDbTredmcoj5GXepEE0UhXnwb39s/nKmHNm8ToQXAUYuXBbCX0DP L9SpcRtartqLx7cLb/SLherpd+t5snbpknNaAXCOaWHv1AwVwDIcuG46E4LuoW8FfKtt8HsJPN7OW Z631nn/A==; 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 1oMBlJ-00EAyg-Rl; Thu, 11 Aug 2022 11:14:27 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1oMBlH-000cR7-Qc; Thu, 11 Aug 2022 11:14:23 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Guoqing Jiang , Stephen Bates , Martin Oliveira , David Sloan , David Sloan , Logan Gunthorpe Date: Thu, 11 Aug 2022 11:14:13 -0600 Message-Id: <20220811171417.147697-2-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811171417.147697-1-logang@deltatee.com> References: <20220811171417.147697-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, sbates@raithlin.com, Martin.Oliveira@eideticom.com, David.Sloan@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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH 1/5] md: Flush workqueue md_rdev_misc_wq in md_alloc() 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 From: David Sloan A race condition still exists when removing and re-creating md devices in test cases. However, it is only seen on some setups. The race condition was tracked down to a reference still being held to the kobject by the rdev in the md_rdev_misc_wq which will be released in rdev_delayed_delete(). md_alloc() waits for previous deletions by waiting on the md_misc_wq, but the md_rdev_misc_wq may still be holding a reference to a recently removed device. To fix this, also flush the md_rdev_misc_wq in md_alloc(). Signed-off-by: David Sloan [logang@deltatee.com: rewrote commit message] Signed-off-by: Logan Gunthorpe --- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index afaf36b2f6ab..71d221601bf8 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5620,6 +5620,7 @@ struct mddev *md_alloc(dev_t dev, char *name) * removed (mddev_delayed_delete). */ flush_workqueue(md_misc_wq); + flush_workqueue(md_rdev_misc_wq); mutex_lock(&disks_mutex); mddev = mddev_alloc(dev); -- 2.30.2