]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dm: free table mempools if not used in __bind
authorBenjamin Marzinski <bmarzins@redhat.com>
Thu, 10 Apr 2025 19:49:39 +0000 (15:49 -0400)
committerMikulas Patocka <mpatocka@redhat.com>
Fri, 11 Apr 2025 11:38:50 +0000 (13:38 +0200)
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 <dlemoal@kernel.org>
Tested-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm.c

index f5c5ccb6f8d25a37497981f3c9dea918094d2c9c..292414da871daff72d77d6962843af6be172b269 100644 (file)
@@ -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);