public inbox for dm-devel@redhat.com
 help / color / mirror / Atom feed
* [PATCH] dm-verity: remove useless mempool
@ 2025-11-17 20:43 Mikulas Patocka
  2025-11-21  1:48 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2025-11-17 20:43 UTC (permalink / raw)
  To: Sami Tolvanen, Alasdair Kergon, Mike Snitzer
  Cc: dm-devel, Ondrej Kozina, Milan Broz

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

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 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 */
 };


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm-verity: remove useless mempool
  2025-11-17 20:43 [PATCH] dm-verity: remove useless mempool Mikulas Patocka
@ 2025-11-21  1:48 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2025-11-21  1:48 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Sami Tolvanen, Alasdair Kergon, Mike Snitzer, dm-devel,
	Ondrej Kozina, Milan Broz

On Mon, Nov 17, 2025 at 09:43:54PM +0100, Mikulas Patocka wrote:
> v->fec->extra_pool has zero reserved entries, so we can remove it and use
> the kernel cache directly.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> ---
>  drivers/md/dm-verity-fec.c |   12 +++---------
>  drivers/md/dm-verity-fec.h |    1 -
>  2 files changed, 3 insertions(+), 10 deletions(-)

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-21  1:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 20:43 [PATCH] dm-verity: remove useless mempool Mikulas Patocka
2025-11-21  1:48 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox