block: add warning to blk_make_request()
authorJens Axboe <jens.axboe@oracle.com>
Tue, 19 May 2009 17:52:35 +0000 (19:52 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 19 May 2009 17:52:35 +0000 (19:52 +0200)
Add a note about how one needs to be careful when setting up these bio
chains.

Extracted from Boaz's updated patch.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/blk-core.c

index bec1d69952d07e68e1d78b0cc1e73e60c6b2bda6..49065075d4622b4f53392bf4c4cca65c6c7374d3 100644 (file)
@@ -910,6 +910,15 @@ EXPORT_SYMBOL(blk_get_request);
  * need bouncing, by calling the appropriate masked or flagged allocator,
  * suitable for the target device. Otherwise the call to blk_queue_bounce will
  * BUG.
+ *
+ * WARNING: When allocating/cloning a bio-chain, careful consideration should be
+ * given to how you allocate bios. In particular, you cannot use __GFP_WAIT for
+ * anything but the first bio in the chain. Otherwise you risk waiting for IO
+ * completion of a bio that hasn't been submitted yet, thus resulting in a
+ * deadlock. Alternatively bios should be allocated using bio_kmalloc() instead
+ * of bio_alloc(), as that avoids the mempool deadlock.
+ * If possible a big IO should be split into smaller parts when allocation
+ * fails. Partial allocation should not be an error, or you risk a live-lock.
  */
 struct request *blk_make_request(struct request_queue *q, struct bio *bio,
                                 gfp_t gfp_mask)