Skip to content

Commit b9dd1f7

Browse files
author
Mikulas Patocka
committed
dm-verity: remove useless mempool
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> Reviewed-by: Eric Biggers <ebiggers@kernel.org>
1 parent d9f3e47 commit b9dd1f7

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

drivers/md/dm-verity-fec.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static int fec_alloc_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio)
333333
if (fio->bufs[n])
334334
continue;
335335

336-
fio->bufs[n] = mempool_alloc(&v->fec->extra_pool, GFP_NOWAIT);
336+
fio->bufs[n] = kmem_cache_alloc(v->fec->cache, GFP_NOWAIT);
337337
/* we can manage with even one buffer if necessary */
338338
if (unlikely(!fio->bufs[n]))
339339
break;
@@ -482,7 +482,8 @@ void verity_fec_finish_io(struct dm_verity_io *io)
482482
mempool_free(fio->bufs[n], &f->prealloc_pool);
483483

484484
fec_for_each_extra_buffer(fio, n)
485-
mempool_free(fio->bufs[n], &f->extra_pool);
485+
if (fio->bufs[n])
486+
kmem_cache_free(f->cache, fio->bufs[n]);
486487

487488
mempool_free(fio->output, &f->output_pool);
488489
}
@@ -534,7 +535,6 @@ void verity_fec_dtr(struct dm_verity *v)
534535

535536
mempool_exit(&f->rs_pool);
536537
mempool_exit(&f->prealloc_pool);
537-
mempool_exit(&f->extra_pool);
538538
mempool_exit(&f->output_pool);
539539
kmem_cache_destroy(f->cache);
540540

@@ -787,12 +787,6 @@ int verity_fec_ctr(struct dm_verity *v)
787787
return ret;
788788
}
789789

790-
ret = mempool_init_slab_pool(&f->extra_pool, 0, f->cache);
791-
if (ret) {
792-
ti->error = "Cannot allocate FEC buffer extra pool";
793-
return ret;
794-
}
795-
796790
/* Preallocate an output buffer for each thread */
797791
ret = mempool_init_kmalloc_pool(&f->output_pool, num_online_cpus(),
798792
1 << v->data_dev_block_bits);

drivers/md/dm-verity-fec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct dm_verity_fec {
4242
unsigned char rsn; /* N of RS(M, N) */
4343
mempool_t rs_pool; /* mempool for fio->rs */
4444
mempool_t prealloc_pool; /* mempool for preallocated buffers */
45-
mempool_t extra_pool; /* mempool for extra buffers */
4645
mempool_t output_pool; /* mempool for output */
4746
struct kmem_cache *cache; /* cache for buffers */
4847
atomic64_t corrected; /* corrected errors */

0 commit comments

Comments
 (0)