block: don't allow splitting of a REQ_NOWAIT bio
[linux-2.6-block.git] / block / blk-merge.c
index 071c5f8cf0cfecbb57cdb7796731d007c0e5429e..b7c193d67185de9dc6b3a320fe49272229ebc32e 100644 (file)
@@ -309,6 +309,16 @@ static struct bio *bio_split_rw(struct bio *bio, const struct queue_limits *lim,
        *segs = nsegs;
        return NULL;
 split:
+       /*
+        * We can't sanely support splitting for a REQ_NOWAIT bio. End it
+        * with EAGAIN if splitting is required and return an error pointer.
+        */
+       if (bio->bi_opf & REQ_NOWAIT) {
+               bio->bi_status = BLK_STS_AGAIN;
+               bio_endio(bio);
+               return ERR_PTR(-EAGAIN);
+       }
+
        *segs = nsegs;
 
        /*