blk-map.c (f72222c74bd642182cc892c99df65cb105c61193) blk-map.c (7b6d91daee5cac6402186ff224c3af39d79f4a0e)
1/*
2 * Functions related to mapping data to requests
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/bio.h>
7#include <linux/blkdev.h>
8#include <scsi/sg.h> /* for struct sg_iovec */

--- 293 unchanged lines hidden (view full) ---

302 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
303 else
304 bio = bio_map_kern(q, kbuf, len, gfp_mask);
305
306 if (IS_ERR(bio))
307 return PTR_ERR(bio);
308
309 if (rq_data_dir(rq) == WRITE)
1/*
2 * Functions related to mapping data to requests
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/bio.h>
7#include <linux/blkdev.h>
8#include <scsi/sg.h> /* for struct sg_iovec */

--- 293 unchanged lines hidden (view full) ---

302 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
303 else
304 bio = bio_map_kern(q, kbuf, len, gfp_mask);
305
306 if (IS_ERR(bio))
307 return PTR_ERR(bio);
308
309 if (rq_data_dir(rq) == WRITE)
310 bio->bi_rw |= (1 << BIO_RW);
310 bio->bi_rw |= (1 << REQ_WRITE);
311
312 if (do_copy)
313 rq->cmd_flags |= REQ_COPY_USER;
314
315 ret = blk_rq_append_bio(q, rq, bio);
316 if (unlikely(ret)) {
317 /* request is too big */
318 bio_put(bio);
319 return ret;
320 }
321
322 blk_queue_bounce(q, &rq->bio);
323 rq->buffer = NULL;
324 return 0;
325}
326EXPORT_SYMBOL(blk_rq_map_kern);
311
312 if (do_copy)
313 rq->cmd_flags |= REQ_COPY_USER;
314
315 ret = blk_rq_append_bio(q, rq, bio);
316 if (unlikely(ret)) {
317 /* request is too big */
318 bio_put(bio);
319 return ret;
320 }
321
322 blk_queue_bounce(q, &rq->bio);
323 rq->buffer = NULL;
324 return 0;
325}
326EXPORT_SYMBOL(blk_rq_map_kern);