Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6286923iob; Tue, 10 May 2022 14:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5iAM9bSZPs0GAGsSsXqvjcavVyuK3Wcep1u10oKiesvbECdsE4YHjGHmy8P0dXdZJhdsP X-Received: by 2002:a17:906:974c:b0:6fa:8c68:62a8 with SMTP id o12-20020a170906974c00b006fa8c6862a8mr8816441ejy.293.1652219915642; Tue, 10 May 2022 14:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652219915; cv=none; d=google.com; s=arc-20160816; b=KI/eP/pfOp0NLfdcvfiXAfuwisUmJm5fd27e31bzpr2Ey0G2WXpp4SWFowrix5H5p3 OdsaiQZdnNvG4E76RWoLBYGG0h8oWbbLsXgFxPJtrbtzHUcENlJ1HaXeg463oqlr4S98 nFu762YAxdIvpC2cMU3HjdUjDmT3s0jysL7FIptgEWn+/hpuWzIpDVcchXBCHDi4ANrJ khqRsI9pYUQd8KelKmnz67S/jdL2oEr7i9TrsWvlGRmo2N5xebv8K3sa3mWhbGXQ+nVF VYTFitbsHYwoe0wskaoD0dBumtLYXsoacu2wFwPjnaBFER1sr+jkAN379j3qth9pMpEz 8B3A== 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=8k9m6/F0CqLoWXg3QrcQH+I0NRIOuLc07b2BKtMSOFo=; b=lrpGXqM0wqFitsDxaS8now9T2xHMQVfVqmkWCFYPYBOMqDBXOHgR1oa/JwGPCcw1El 3DWXqtiIO218tY171YXT98wU1qGznl2vv+vNb+hTTpU4Cd9oB6FpyGevZbUmbHjbO/jc kg7nW9OHj1HdYj2c3vFAKxcJ+C4EMXp5NUPsIbcva9G2d300MsFayyllOIpUZUvl9B4h jo8dldCoc6CTHv6enGasVKsH2qYWz/2KBqOpM+oS4noasbaw+552DypDoFru0n4VagW8 WMwPASAkOJfNIYNjSY4dJVQD5ZI2wBZwMGpuFXskjaYBIClvIjgb/wnu2j1llVVAw2Ox EYWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J95VxAbe; 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 z11-20020a056402274b00b004281bdf9050si283790edd.500.2022.05.10.14.58.11; Tue, 10 May 2022 14:58:35 -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=J95VxAbe; 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 S243429AbiEJNdw (ORCPT + 99 others); Tue, 10 May 2022 09:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242895AbiEJNZQ (ORCPT ); Tue, 10 May 2022 09:25:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39748369F7; Tue, 10 May 2022 06:17:59 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C987B61532; Tue, 10 May 2022 13:17:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C40D7C385C2; Tue, 10 May 2022 13:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652188678; bh=uxmI1h5GXmIVI9bUbztyAkNTD9CthJs/xPqH/27qeR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J95VxAbe0b6rk4oW5vlu06uwiQQmZItEtggUaWnmK6raOUxXrxKMIIyKPWpprkNf6 AvMLF3uaVuNfda8zCqvLx+g8i6uHBb8j8aqRbSVliPDn8Sp6CRAh6oIJ7UczxYS+aJ jOWC7ckgN6XMTLseO1phH7TWR5jCXHB8g9Tn0TMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer , Mike Snitzer Subject: [PATCH 4.14 76/78] dm: interlock pending dm_io and dm_wait_for_bios_completion Date: Tue, 10 May 2022 15:08:02 +0200 Message-Id: <20220510130734.778375785@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.522479698@linuxfoundation.org> References: <20220510130732.522479698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,URIBL_BLOCKED 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: Mike Snitzer commit 9f6dc633761006f974701d4c88da71ab68670749 upstream. Commit d208b89401e0 ("dm: fix mempool NULL pointer race when completing IO") didn't go far enough. When bio_end_io_acct ends the count of in-flight I/Os may reach zero and the DM device may be suspended. There is a possibility that the suspend races with dm_stats_account_io. Fix this by adding percpu "pending_io" counters to track outstanding dm_io. Move kicking of suspend queue to dm_io_dec_pending(). Also, rename md_in_flight_bios() to dm_in_flight_bios() and update it to iterate all pending_io counters. Fixes: d208b89401e0 ("dm: fix mempool NULL pointer race when completing IO") Cc: stable@vger.kernel.org Co-developed-by: Mikulas Patocka Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Mikulas Patocka Reviewed-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2230,6 +2230,8 @@ static int dm_wait_for_completion(struct } finish_wait(&md->wait, &wait); + smp_rmb(); /* paired with atomic_dec_return in end_io_acct */ + return r; }