v->fec->extra_pool has zero reserved entries, so we can remove it and use
the kernel cache directly.

Signed-off-by: Mikulas Patocka <[email protected]>

---
 drivers/md/dm-verity-fec.c |   12 +++---------
 drivers/md/dm-verity-fec.h |    1 -
 2 files changed, 3 insertions(+), 10 deletions(-)

Index: linux-2.6/drivers/md/dm-verity-fec.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-verity-fec.c   2025-11-15 16:08:10.000000000 
+0100
+++ linux-2.6/drivers/md/dm-verity-fec.c        2025-11-15 17:24:59.000000000 
+0100
@@ -328,7 +328,7 @@ static int fec_alloc_bufs(struct dm_veri
                if (fio->bufs[n])
                        continue;
 
-               fio->bufs[n] = mempool_alloc(&v->fec->extra_pool, GFP_NOWAIT);
+               fio->bufs[n] = kmem_cache_alloc(v->fec->cache, GFP_NOWAIT);
                /* we can manage with even one buffer if necessary */
                if (unlikely(!fio->bufs[n]))
                        break;
@@ -477,7 +477,8 @@ void verity_fec_finish_io(struct dm_veri
                mempool_free(fio->bufs[n], &f->prealloc_pool);
 
        fec_for_each_extra_buffer(fio, n)
-               mempool_free(fio->bufs[n], &f->extra_pool);
+               if (fio->bufs[n])
+                       kmem_cache_free(f->cache, fio->bufs[n]);
 
        mempool_free(fio->output, &f->output_pool);
 }
@@ -529,7 +530,6 @@ void verity_fec_dtr(struct dm_verity *v)
 
        mempool_exit(&f->rs_pool);
        mempool_exit(&f->prealloc_pool);
-       mempool_exit(&f->extra_pool);
        mempool_exit(&f->output_pool);
        kmem_cache_destroy(f->cache);
 
@@ -782,12 +782,6 @@ int verity_fec_ctr(struct dm_verity *v)
                return ret;
        }
 
-       ret = mempool_init_slab_pool(&f->extra_pool, 0, f->cache);
-       if (ret) {
-               ti->error = "Cannot allocate FEC buffer extra pool";
-               return ret;
-       }
-
        /* Preallocate an output buffer for each thread */
        ret = mempool_init_kmalloc_pool(&f->output_pool, num_online_cpus(),
                                        1 << v->data_dev_block_bits);
Index: linux-2.6/drivers/md/dm-verity-fec.h
===================================================================
--- linux-2.6.orig/drivers/md/dm-verity-fec.h   2025-11-15 16:08:10.000000000 
+0100
+++ linux-2.6/drivers/md/dm-verity-fec.h        2025-11-15 16:08:10.000000000 
+0100
@@ -42,7 +42,6 @@ struct dm_verity_fec {
        unsigned char rsn;      /* N of RS(M, N) */
        mempool_t rs_pool;      /* mempool for fio->rs */
        mempool_t prealloc_pool;        /* mempool for preallocated buffers */
-       mempool_t extra_pool;   /* mempool for extra buffers */
        mempool_t output_pool;  /* mempool for output */
        struct kmem_cache *cache;       /* cache for buffers */
 };


Reply via email to