aio: be defensive to ensure request batching is non-zero instead of BUG_ON()
authorBenjamin LaHaise <bcrl@kvack.org>
Wed, 31 Jul 2013 14:34:18 +0000 (10:34 -0400)
committerBenjamin LaHaise <bcrl@kvack.org>
Wed, 31 Jul 2013 14:34:18 +0000 (10:34 -0400)
In the event that an overflow/underflow occurs while calculating req_batch,
clamp the minimum at 1 request instead of doing a BUG_ON().

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
fs/aio.c

index 52f200ebef072d02cb04ce89207a707deba4b321..588aff9dc3160204c82061ccf59333c3c32bde19 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -576,7 +576,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 
        atomic_set(&ctx->reqs_available, ctx->nr_events - 1);
        ctx->req_batch = (ctx->nr_events - 1) / (num_possible_cpus() * 4);
-       BUG_ON(!ctx->req_batch);
+       if (ctx->req_batch < 1)
+               ctx->req_batch = 1;
 
        err = ioctx_add_table(ctx, mm);
        if (err)