Commit 2fa12320 authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

rbd: don't set data in rbd_osd_req_format_op()

Currently an object request has its osd request's data field set in
rbd_osd_req_format_op().  That assumes a single osd op per object
request, and that won't be the case for long.

Move the code that sets this out and into the caller.

Rename rbd_osd_req_format_op() to be just rbd_osd_req_format(),
removing the notion that it's doing anything op-specific.

This and the next patch resolve:
    http://tracker.ceph.com/issues/4658Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent c99d2d4a
...@@ -1311,12 +1311,11 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, ...@@ -1311,12 +1311,11 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
rbd_obj_request_complete(obj_request); rbd_obj_request_complete(obj_request);
} }
static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, static void rbd_osd_req_format(struct rbd_obj_request *obj_request,
bool write_request) bool write_request)
{ {
struct rbd_img_request *img_request = obj_request->img_request; struct rbd_img_request *img_request = obj_request->img_request;
struct ceph_osd_request *osd_req = obj_request->osd_req; struct ceph_osd_request *osd_req = obj_request->osd_req;
struct ceph_osd_data *osd_data = NULL;
struct ceph_snap_context *snapc = NULL; struct ceph_snap_context *snapc = NULL;
u64 snap_id = CEPH_NOSNAP; u64 snap_id = CEPH_NOSNAP;
struct timespec *mtime = NULL; struct timespec *mtime = NULL;
...@@ -1325,29 +1324,13 @@ static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, ...@@ -1325,29 +1324,13 @@ static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request,
rbd_assert(osd_req != NULL); rbd_assert(osd_req != NULL);
if (write_request) { if (write_request) {
osd_data = &osd_req->r_data_out;
now = CURRENT_TIME; now = CURRENT_TIME;
mtime = &now; mtime = &now;
if (img_request) if (img_request)
snapc = img_request->snapc; snapc = img_request->snapc;
} else { } else if (img_request) {
osd_data = &osd_req->r_data_in;
if (img_request)
snap_id = img_request->snap_id; snap_id = img_request->snap_id;
} }
if (obj_request->type != OBJ_REQUEST_NODATA) {
/*
* If it has data, it's either a object class method
* call (cls) or it's an extent operation.
*/
/* XXX This use of the ops array goes away in the next patch */
if (obj_request->osd_req->r_ops[0].op == CEPH_OSD_OP_CALL)
osd_req_op_cls_response_data(obj_request->osd_req, 0,
osd_data);
else
osd_req_op_extent_osd_data(obj_request->osd_req, 0,
osd_data);
}
ceph_osdc_build_request(osd_req, obj_request->offset, ceph_osdc_build_request(osd_req, obj_request->offset,
snapc, snap_id, mtime); snapc, snap_id, mtime);
} }
...@@ -1576,6 +1559,8 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, ...@@ -1576,6 +1559,8 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
resid = img_request->length; resid = img_request->length;
rbd_assert(resid > 0); rbd_assert(resid > 0);
while (resid) { while (resid) {
struct ceph_osd_request *osd_req;
struct ceph_osd_data *osd_data;
const char *object_name; const char *object_name;
unsigned int clone_size; unsigned int clone_size;
u64 offset; u64 offset;
...@@ -1601,14 +1586,18 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, ...@@ -1601,14 +1586,18 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
if (!obj_request->bio_list) if (!obj_request->bio_list)
goto out_partial; goto out_partial;
obj_request->osd_req = rbd_osd_req_create(rbd_dev, osd_req = rbd_osd_req_create(rbd_dev, write_request,
write_request, obj_request); obj_request);
if (!obj_request->osd_req) if (!osd_req)
goto out_partial; goto out_partial;
obj_request->osd_req = osd_req;
osd_req_op_extent_init(obj_request->osd_req, 0, osd_data = write_request ? &osd_req->r_data_out
opcode, offset, length, 0, 0); : &osd_req->r_data_in;
rbd_osd_req_format_op(obj_request, write_request); osd_req_op_extent_init(osd_req, 0, opcode, offset, length,
0, 0);
osd_req_op_extent_osd_data(osd_req, 0, osd_data);
rbd_osd_req_format(obj_request, write_request);
/* status and version are initially zero-filled */ /* status and version are initially zero-filled */
...@@ -1725,7 +1714,7 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, ...@@ -1725,7 +1714,7 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev,
osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK, osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK,
notify_id, ver, 0); notify_id, ver, 0);
rbd_osd_req_format_op(obj_request, false); rbd_osd_req_format(obj_request, false);
osdc = &rbd_dev->rbd_client->client->osdc; osdc = &rbd_dev->rbd_client->client->osdc;
obj_request->callback = rbd_obj_request_put; obj_request->callback = rbd_obj_request_put;
...@@ -1791,7 +1780,7 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start) ...@@ -1791,7 +1780,7 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start)
osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH, osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH,
rbd_dev->watch_event->cookie, rbd_dev->watch_event->cookie,
rbd_dev->header.obj_version, start); rbd_dev->header.obj_version, start);
rbd_osd_req_format_op(obj_request, true); rbd_osd_req_format(obj_request, true);
if (start) if (start)
ceph_osdc_set_request_linger(osdc, obj_request->osd_req); ceph_osdc_set_request_linger(osdc, obj_request->osd_req);
...@@ -1850,6 +1839,7 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, ...@@ -1850,6 +1839,7 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
u64 *version) u64 *version)
{ {
struct rbd_obj_request *obj_request; struct rbd_obj_request *obj_request;
struct ceph_osd_data *osd_data;
struct ceph_osd_client *osdc; struct ceph_osd_client *osdc;
struct page **pages; struct page **pages;
u32 page_count; u32 page_count;
...@@ -1880,10 +1870,12 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, ...@@ -1880,10 +1870,12 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
if (!obj_request->osd_req) if (!obj_request->osd_req)
goto out; goto out;
osd_data = &obj_request->osd_req->r_data_in;
osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL, osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL,
class_name, method_name, class_name, method_name,
outbound, outbound_size); outbound, outbound_size);
rbd_osd_req_format_op(obj_request, false); osd_req_op_cls_response_data(obj_request->osd_req, 0, osd_data);
rbd_osd_req_format(obj_request, false);
osdc = &rbd_dev->rbd_client->client->osdc; osdc = &rbd_dev->rbd_client->client->osdc;
ret = rbd_obj_request_submit(osdc, obj_request); ret = rbd_obj_request_submit(osdc, obj_request);
...@@ -2062,6 +2054,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, ...@@ -2062,6 +2054,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
{ {
struct rbd_obj_request *obj_request; struct rbd_obj_request *obj_request;
struct ceph_osd_data *osd_data;
struct ceph_osd_client *osdc; struct ceph_osd_client *osdc;
struct page **pages = NULL; struct page **pages = NULL;
u32 page_count; u32 page_count;
...@@ -2086,9 +2079,11 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, ...@@ -2086,9 +2079,11 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
if (!obj_request->osd_req) if (!obj_request->osd_req)
goto out; goto out;
osd_data = &obj_request->osd_req->r_data_in;
osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ, osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ,
offset, length, 0, 0); offset, length, 0, 0);
rbd_osd_req_format_op(obj_request, false); osd_req_op_extent_osd_data(obj_request->osd_req, 0, osd_data);
rbd_osd_req_format(obj_request, false);
osdc = &rbd_dev->rbd_client->client->osdc; osdc = &rbd_dev->rbd_client->client->osdc;
ret = rbd_obj_request_submit(osdc, obj_request); ret = rbd_obj_request_submit(osdc, obj_request);
......
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