block: move blk_next_bio to bio.c
[linux-2.6-block.git] / block / bio.c
index 0d400ba2dbd18f65cd98f0ffdea563f14b48877c..1536579ed490a8665cbf7ef83a50a70cbc2e919a 100644 (file)
@@ -344,6 +344,19 @@ void bio_chain(struct bio *bio, struct bio *parent)
 }
 EXPORT_SYMBOL(bio_chain);
 
+struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp)
+{
+       struct bio *new = bio_alloc(gfp, nr_pages);
+
+       if (bio) {
+               bio_chain(bio, new);
+               submit_bio(bio);
+       }
+
+       return new;
+}
+EXPORT_SYMBOL_GPL(blk_next_bio);
+
 static void bio_alloc_rescue(struct work_struct *work)
 {
        struct bio_set *bs = container_of(work, struct bio_set, rescue_work);
@@ -569,7 +582,8 @@ static void bio_truncate(struct bio *bio, unsigned new_size)
                                offset = new_size - done;
                        else
                                offset = 0;
-                       zero_user(bv.bv_page, offset, bv.bv_len - offset);
+                       zero_user(bv.bv_page, bv.bv_offset + offset,
+                                 bv.bv_len - offset);
                        truncated = true;
                }
                done += bv.bv_len;