Skip to content

Commit

Permalink
bio: use bio_kmalloc() in copy/map functions
Browse files Browse the repository at this point in the history
Impact: remove possible deadlock condition

There is no reason to use mempool backed allocation for map functions.
Also, because kern mapping is used inside LLDs (e.g. for EH), using
mempool backed allocation can lead to deadlock under extreme
conditions (mempool already consumed by the time a request reached EH
and requests are blocked on EH).

Switch copy/map functions to bio_kmalloc().

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Apr 22, 2009
1 parent 451a9eb commit a9e9dc2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
return ERR_PTR(-ENOMEM);

ret = -ENOMEM;
bio = bio_alloc(gfp_mask, nr_pages);
bio = bio_kmalloc(gfp_mask, nr_pages);
if (!bio)
goto out_bmd;

Expand Down Expand Up @@ -946,7 +946,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
if (!nr_pages)
return ERR_PTR(-EINVAL);

bio = bio_alloc(gfp_mask, nr_pages);
bio = bio_kmalloc(gfp_mask, nr_pages);
if (!bio)
return ERR_PTR(-ENOMEM);

Expand Down Expand Up @@ -1130,7 +1130,7 @@ static struct bio *__bio_map_kern(struct request_queue *q, void *data,
int offset, i;
struct bio *bio;

bio = bio_alloc(gfp_mask, nr_pages);
bio = bio_kmalloc(gfp_mask, nr_pages);
if (!bio)
return ERR_PTR(-ENOMEM);

Expand Down

0 comments on commit a9e9dc2

Please sign in to comment.