Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6824367rwn; Tue, 13 Sep 2022 09:27:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR5yrwdREaWJTgTEcm/B6cxnajJmZUZlWkB8cD+oJoH+IxkOnkAvXIqXZfl05IitG/VBvfQV X-Received: by 2002:a50:9344:0:b0:448:ce76:7c81 with SMTP id n4-20020a509344000000b00448ce767c81mr27047944eda.187.1663086444519; Tue, 13 Sep 2022 09:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086444; cv=none; d=google.com; s=arc-20160816; b=pS4fsnectjqnvEV4KDLArChLLSwBesxtS59WQxgy2ppHU4J1/PIwliMYfhbVwz+QJ5 hn751O8OTFLzEImeF6SsD7yngoWXjjvaISLvw9ty3zC5zmPhF4pQ9AEmRYowI1dyqJF0 /Xe5EaxsnBWy4NkvP3V/OKn3LH//mPvjxXJl/x5k/eGdtuX+V/8C0UsOdfUWQZ38n8dh B1Wo0WbhZSPb9ksOb7ouho40oe5v922VaezS+KIaohkYRdszD4bc2ppAPEVuZozWWPGM 2HOhxs1c5zJu/AQEKmGe/tnfNNK9t2ZyZ1A+ShB1AtjWB0yJQwVGHtn0Kuq4BXA/K0yn w1sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j1oDCvBPgtJu7r/XY76St6e1etabMgeBZzZT9nM1tBI=; b=WIik9uuindfQCidbNZKDh9Hxv6Yat9NIL/n21fzI1242zgg5x7vdv4vV5F2QFa7cxK zAEqbcmF2UhkyByipRnheU205NZ5BCtSN9gg5IZnXXOCCNxn8GfhoEtK9j+nn5B+iXOT +v6FNxytfn4g0iW14MSI5trmh7lkLOtebPBLlPK5t+AApoPmG1RuuVAvIYv6JPxcyXMN RYc9dHzZIzaS8JX2L0iJtPiratCoyeY6eZVOLDrpRGBROk2KeKhzXTaHQ+wdGvGT0G/+ kGr+i6zcftvtNVNphKnY+++g6xau4uxrcR/Dspzpqk4Rf8cHAOKSwp8oFTpif/OWBHkF wq5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kVTjGLjp; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bb8-20020a1709070a0800b007413d43db0fsi3013775ejc.732.2022.09.13.09.26.57; Tue, 13 Sep 2022 09:27:24 -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=@linuxfoundation.org header.s=korg header.b=kVTjGLjp; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234488AbiIMOvn (ORCPT + 99 others); Tue, 13 Sep 2022 10:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234529AbiIMOsx (ORCPT ); Tue, 13 Sep 2022 10:48:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6063566A6C; Tue, 13 Sep 2022 07:25:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D653BB80F88; Tue, 13 Sep 2022 14:17:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D5A3C433D6; Tue, 13 Sep 2022 14:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078630; bh=K1zKnhaS0xWYZkglRZlSKoFxP/z5W33rxEsdOrt6MQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kVTjGLjpjFZb2x6SIplqbxsNbZKf4aYIkntdE+YR+IuK3temOUaVk+FT2bNSgnKzD UmYle7pyEYRhBNRit22x9/D6Xkr1MknUrx38l2idPucgksCT11XTMqCwWBRM2FXRIy 5ijEaKw7JX0vMUnbB1K84uUrdn4aeWqFNApsosyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Sloan , Logan Gunthorpe , Song Liu , Sasha Levin Subject: [PATCH 5.15 023/121] md: Flush workqueue md_rdev_misc_wq in md_alloc() Date: Tue, 13 Sep 2022 16:03:34 +0200 Message-Id: <20220913140358.341556082@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Sloan [ Upstream commit 5e8daf906f890560df430d30617c692a794acb73 ] 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 Signed-off-by: Song Liu Signed-off-by: Sasha Levin --- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index c8f2e8524bfb7..04e1e294b4b1e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5651,6 +5651,7 @@ static int 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.35.1