From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EB021A5B9D; Tue, 17 Jun 2025 16:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750178217; cv=none; b=jjan/FYpVntYvuM8HNNahQgHtKEQpdvL4f6yJO14ZnvP1kGzQnPnagL98zkaxwr3bA1X226ARZzsJeyi8xJMDd6HCT/NgqU9iBBIQ7HA/Wf8vJL/rRroEpuNQNoz8uUbm9uZSftyPRX55aa+D9vj64eEG+73+DgF8R47q85lTwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750178217; c=relaxed/simple; bh=Znm2M2ukfpvVJhVjLDAHQgRjN0uq9tGGz5kgVbhYT30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bej2f1FTqAEh7JbN/GX0SgILO+tgK54kovuWNdvDXEhAQZ8yiI90Fe+hPH7f0/6GoKwWwWL/P/+gs8g6aYZ4ttJ909qeGDLAHCh+8goO5ZH0H9+h0N9thlUj6JnT7/I0PAz3aBfMOuz2CDPOMq5PNhItyv1V2tDgXGMrxQUUhNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2AktmosY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2AktmosY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B3C8C4CEE3; Tue, 17 Jun 2025 16:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750178217; bh=Znm2M2ukfpvVJhVjLDAHQgRjN0uq9tGGz5kgVbhYT30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2AktmosYHO+fkNVO1lL0hhmxmCpY7uDlP0SF60yc6J29b0sJCmFG0/mr05axvo4Lh 55BZyMkIzjAATZP4ebap1AOMmvUbrFLOwtOkGHFK70/PfpdVpZ+cTNKdP04HAyWtY5 y48brNRmc6A98/6Ma8UIeICN9j3smX9hgaZZsD4s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Benjamin Marzinski , Mikulas Patocka , Sasha Levin Subject: [PATCH 6.15 426/780] dm: free table mempools if not used in __bind Date: Tue, 17 Jun 2025 17:22:14 +0200 Message-ID: <20250617152508.818901002@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152451.485330293@linuxfoundation.org> References: <20250617152451.485330293@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Marzinski [ Upstream commit e8819e7f03470c5b468720630d9e4e1d5b99159e ] With request-based dm, the mempools don't need reloading when switching tables, but the unused table mempools are not freed until the active table is finally freed. Free them immediately if they are not needed. Fixes: 29dec90a0f1d9 ("dm: fix bio_set allocation") Reviewed-by: Damien Le Moal Tested-by: Damien Le Moal Signed-off-by: Benjamin Marzinski Signed-off-by: Mikulas Patocka Signed-off-by: Sasha Levin --- drivers/md/dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index f5c5ccb6f8d25..292414da871da 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2461,10 +2461,10 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, * requests in the queue may refer to bio from the old bioset, * so you must walk through the queue to unprep. */ - if (!md->mempools) { + if (!md->mempools) md->mempools = t->mempools; - t->mempools = NULL; - } + else + dm_free_md_mempools(t->mempools); } else { /* * The md may already have mempools that need changing. @@ -2473,8 +2473,8 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, */ dm_free_md_mempools(md->mempools); md->mempools = t->mempools; - t->mempools = NULL; } + t->mempools = NULL; old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); rcu_assign_pointer(md->map, (void *)t); -- 2.39.5