Skip to content

Commit

Permalink
aio: be defensive to ensure request batching is non-zero instead of B…
Browse files Browse the repository at this point in the history
…UG_ON()

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 <[email protected]>
  • Loading branch information
bcrl committed Jul 31, 2013
1 parent db446a0 commit 6878ea7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6878ea7

Please sign in to comment.