Commit c29b70f6 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by Jens Axboe

libosd: Use of new blk_make_request

Use new blk_make_request() to allocate a request from bio
and avoid using deprecated blk_rq_append_bio().

This patch is dependent on a block layer patch titled:
    [BLOCK] New blk_make_request() takes bio returns request

This is the last usage of blk_rq_append_bio in osd, it can now
be un-exported.
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
CC: Jeff Garzik <jeff@garzik.org>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 79eb63e9
...@@ -1200,6 +1200,21 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or, ...@@ -1200,6 +1200,21 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or,
/* /*
* osd_finalize_request and helpers * osd_finalize_request and helpers
*/ */
static struct request *_make_request(struct request_queue *q, bool has_write,
struct _osd_io_info *oii, gfp_t flags)
{
if (oii->bio)
return blk_make_request(q, oii->bio, flags);
else {
struct request *req;
req = blk_get_request(q, has_write ? WRITE : READ, flags);
if (unlikely(!req))
return ERR_PTR(-ENOMEM);
return req;
}
}
static int _init_blk_request(struct osd_request *or, static int _init_blk_request(struct osd_request *or,
bool has_in, bool has_out) bool has_in, bool has_out)
...@@ -1208,11 +1223,13 @@ static int _init_blk_request(struct osd_request *or, ...@@ -1208,11 +1223,13 @@ static int _init_blk_request(struct osd_request *or,
struct scsi_device *scsi_device = or->osd_dev->scsi_device; struct scsi_device *scsi_device = or->osd_dev->scsi_device;
struct request_queue *q = scsi_device->request_queue; struct request_queue *q = scsi_device->request_queue;
struct request *req; struct request *req;
int ret = -ENOMEM; int ret;
req = blk_get_request(q, has_out, flags); req = _make_request(q, has_out, has_out ? &or->out : &or->in, flags);
if (!req) if (IS_ERR(req)) {
ret = PTR_ERR(req);
goto out; goto out;
}
or->request = req; or->request = req;
req->cmd_type = REQ_TYPE_BLOCK_PC; req->cmd_type = REQ_TYPE_BLOCK_PC;
...@@ -1225,9 +1242,10 @@ static int _init_blk_request(struct osd_request *or, ...@@ -1225,9 +1242,10 @@ static int _init_blk_request(struct osd_request *or,
or->out.req = req; or->out.req = req;
if (has_in) { if (has_in) {
/* allocate bidi request */ /* allocate bidi request */
req = blk_get_request(q, READ, flags); req = _make_request(q, false, &or->in, flags);
if (!req) { if (IS_ERR(req)) {
OSD_DEBUG("blk_get_request for bidi failed\n"); OSD_DEBUG("blk_get_request for bidi failed\n");
ret = PTR_ERR(req);
goto out; goto out;
} }
req->cmd_type = REQ_TYPE_BLOCK_PC; req->cmd_type = REQ_TYPE_BLOCK_PC;
...@@ -1271,26 +1289,6 @@ int osd_finalize_request(struct osd_request *or, ...@@ -1271,26 +1289,6 @@ int osd_finalize_request(struct osd_request *or,
return ret; return ret;
} }
if (or->out.bio) {
ret = blk_rq_append_bio(or->request->q, or->out.req,
or->out.bio);
if (ret) {
OSD_DEBUG("blk_rq_append_bio out failed\n");
return ret;
}
OSD_DEBUG("out bytes=%llu (bytes_req=%u)\n",
_LLU(or->out.total_bytes), blk_rq_bytes(or->out.req));
}
if (or->in.bio) {
ret = blk_rq_append_bio(or->request->q, or->in.req, or->in.bio);
if (ret) {
OSD_DEBUG("blk_rq_append_bio in failed\n");
return ret;
}
OSD_DEBUG("in bytes=%llu (bytes_req=%u)\n",
_LLU(or->in.total_bytes), blk_rq_bytes(or->in.req));
}
or->out.pad_buff = sg_out_pad_buffer; or->out.pad_buff = sg_out_pad_buffer;
or->in.pad_buff = sg_in_pad_buffer; or->in.pad_buff = sg_in_pad_buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment