diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-06-02 18:00:38 +0200 |
|---|---|---|
| committer | Vlastimil Babka (SUSE) <vbabka@kernel.org> | 2026-06-03 18:20:47 +0200 |
| commit | be6e0a533d4f42f87e5fe1190d742478e4184f86 (patch) | |
| tree | 190fa04d159d24656eb35407cfbe772c3cd97e79 /block | |
| parent | 6bb0009862c5f0e89a6e4afc09b499a02576c7da (diff) | |
| download | ath-be6e0a533d4f42f87e5fe1190d742478e4184f86.tar.gz | |
mm: simplify the mempool_alloc_bulk API
The mempool_alloc_bulk was modelled after the alloc_pages_bulk API,
including some misunderstanding of it.
Remove checking for NULL slots in the array, as alloc_pages_bulk and
kmem_cache_alloc_bulk always fill the array from the beginning and thus
we know the offset of the first failing allocation. This removes support
for working well with alloc_pages_bulk used to refill page arrays that
might have an entry removed from in the middle, but that is only used by
sunrpc and hopefully on it's way out.
Also remove the allocated parameter as it is redundant because the caller
can simply specific and offset into the entries array.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260602160038.3976341-1-hch@lst.de
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/blk-crypto-fallback.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 61f5954108329..ab6924fba280c 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -199,8 +199,8 @@ static struct bio *blk_crypto_alloc_enc_bio(struct bio *bio_src, pages += nr_segs * (PAGE_PTRS_PER_BVEC - 1); /* - * Try a bulk allocation first. This could leave random pages in the - * array unallocated, but we'll fix that up later in mempool_alloc_bulk. + * Try a bulk allocation first. This might not fill all allocated + * pages, but we'll fix that up later in mempool_alloc_bulk. * * Note: alloc_pages_bulk needs the array to be zeroed, as it assumes * any non-zero slot already contains a valid allocation. @@ -208,8 +208,9 @@ static struct bio *blk_crypto_alloc_enc_bio(struct bio *bio_src, memset(pages, 0, sizeof(struct page *) * nr_segs); nr_allocated = alloc_pages_bulk(GFP_KERNEL, nr_segs, pages); if (nr_allocated < nr_segs) - mempool_alloc_bulk(blk_crypto_bounce_page_pool, (void **)pages, - nr_segs, nr_allocated); + mempool_alloc_bulk(blk_crypto_bounce_page_pool, + (void **)pages + nr_allocated, + nr_segs - nr_allocated); memalloc_noio_restore(memflags); *pages_ret = pages; return bio; |
