diff options
author | Stefan Roesch <shr@fb.com> | 2022-04-26 11:21:25 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-05-09 06:35:34 -0600 |
commit | baf9cb643b485d57c404b0ea9c1865036dde9eb7 (patch) | |
tree | 9819b95225ed3768c8b7e0391525ea19c94e2b45 | |
parent | 4e5bc0a9a1d0be5b20a0366fbfbe5a99d61c6003 (diff) | |
download | lwn-baf9cb643b485d57c404b0ea9c1865036dde9eb7.tar.gz lwn-baf9cb643b485d57c404b0ea9c1865036dde9eb7.zip |
io_uring: change ring size calculation for CQE32
This changes the function rings_size to take large CQE's into account.
Co-developed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Stefan Roesch <shr@fb.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20220426182134.136504-4-shr@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index da91723e8741..279ccf674bdd 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9994,8 +9994,8 @@ static void *io_mem_alloc(size_t size) return (void *) __get_free_pages(gfp, get_order(size)); } -static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, - size_t *sq_offset) +static unsigned long rings_size(struct io_ring_ctx *ctx, unsigned int sq_entries, + unsigned int cq_entries, size_t *sq_offset) { struct io_rings *rings; size_t off, sq_array_size; @@ -10003,6 +10003,10 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, off = struct_size(rings, cqes, cq_entries); if (off == SIZE_MAX) return SIZE_MAX; + if (ctx->flags & IORING_SETUP_CQE32) { + if (check_shl_overflow(off, 1, &off)) + return SIZE_MAX; + } #ifdef CONFIG_SMP off = ALIGN(off, SMP_CACHE_BYTES); @@ -11684,7 +11688,7 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx, ctx->sq_entries = p->sq_entries; ctx->cq_entries = p->cq_entries; - size = rings_size(p->sq_entries, p->cq_entries, &sq_array_offset); + size = rings_size(ctx, p->sq_entries, p->cq_entries, &sq_array_offset); if (size == SIZE_MAX) return -EOVERFLOW; |