diff options
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 66c3cfe94d0..3531d8e1da0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1135,6 +1135,38 @@ void blk_put_request(struct request *req) | |||
1135 | } | 1135 | } |
1136 | EXPORT_SYMBOL(blk_put_request); | 1136 | EXPORT_SYMBOL(blk_put_request); |
1137 | 1137 | ||
1138 | /** | ||
1139 | * blk_add_request_payload - add a payload to a request | ||
1140 | * @rq: request to update | ||
1141 | * @page: page backing the payload | ||
1142 | * @len: length of the payload. | ||
1143 | * | ||
1144 | * This allows to later add a payload to an already submitted request by | ||
1145 | * a block driver. The driver needs to take care of freeing the payload | ||
1146 | * itself. | ||
1147 | * | ||
1148 | * Note that this is a quite horrible hack and nothing but handling of | ||
1149 | * discard requests should ever use it. | ||
1150 | */ | ||
1151 | void blk_add_request_payload(struct request *rq, struct page *page, | ||
1152 | unsigned int len) | ||
1153 | { | ||
1154 | struct bio *bio = rq->bio; | ||
1155 | |||
1156 | bio->bi_io_vec->bv_page = page; | ||
1157 | bio->bi_io_vec->bv_offset = 0; | ||
1158 | bio->bi_io_vec->bv_len = len; | ||
1159 | |||
1160 | bio->bi_size = len; | ||
1161 | bio->bi_vcnt = 1; | ||
1162 | bio->bi_phys_segments = 1; | ||
1163 | |||
1164 | rq->__data_len = rq->resid_len = len; | ||
1165 | rq->nr_phys_segments = 1; | ||
1166 | rq->buffer = bio_data(bio); | ||
1167 | } | ||
1168 | EXPORT_SYMBOL_GPL(blk_add_request_payload); | ||
1169 | |||
1138 | void init_request_from_bio(struct request *req, struct bio *bio) | 1170 | void init_request_from_bio(struct request *req, struct bio *bio) |
1139 | { | 1171 | { |
1140 | req->cpu = bio->bi_comp_cpu; | 1172 | req->cpu = bio->bi_comp_cpu; |