nfsd: support ext4 i_version
[safe/jmp/linux-2.6] / block / blk-map.c
index 572140c..f103729 100644 (file)
@@ -63,6 +63,9 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
        if (IS_ERR(bio))
                return PTR_ERR(bio);
 
+       if (map_data && map_data->null_mapped)
+               bio->bi_flags |= (1 << BIO_NULL_MAPPED);
+
        orig_bio = bio;
        blk_queue_bounce(q, &bio);
 
@@ -115,7 +118,10 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
 
        if (len > (q->max_hw_sectors << 9))
                return -EINVAL;
-       if (!len || !ubuf)
+       if (!len)
+               return -EINVAL;
+
+       if (!ubuf && (!map_data || !map_data->null_mapped))
                return -EINVAL;
 
        while (bytes_read != len) {
@@ -142,6 +148,9 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
                        bio = rq->bio;
                bytes_read += ret;
                ubuf += ret;
+
+               if (map_data)
+                       map_data->offset += ret;
        }
 
        if (!bio_flagged(bio, BIO_USER_MAPPED))
@@ -209,8 +218,14 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
                return PTR_ERR(bio);
 
        if (bio->bi_size != len) {
+               /*
+                * Grab an extra reference to this bio, as bio_unmap_user()
+                * expects to be able to drop it twice as it happens on the
+                * normal IO completion path
+                */
+               bio_get(bio);
                bio_endio(bio, 0);
-               bio_unmap_user(bio);
+               __blk_rq_unmap_user(bio);
                return -EINVAL;
        }