aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-04-05 02:27:12 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:18:16 -0400
commit2fa123201a86ff979813e24f9e5c5fa54931ab7f (patch)
treea5332211e304489471f50e4b12ca30c712295997
parentc99d2d4abb6c405ef52e9bc1da87b382b8f41739 (diff)
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/4658 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--drivers/block/rbd.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 80ac772587c8..06912abca601 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1311,12 +1311,11 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
1311 rbd_obj_request_complete(obj_request); 1311 rbd_obj_request_complete(obj_request);
1312} 1312}
1313 1313
1314static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, 1314static void rbd_osd_req_format(struct rbd_obj_request *obj_request,
1315 bool write_request) 1315 bool write_request)
1316{ 1316{
1317 struct rbd_img_request *img_request = obj_request->img_request; 1317 struct rbd_img_request *img_request = obj_request->img_request;
1318 struct ceph_osd_request *osd_req = obj_request->osd_req; 1318 struct ceph_osd_request *osd_req = obj_request->osd_req;
1319 struct ceph_osd_data *osd_data = NULL;
1320 struct ceph_snap_context *snapc = NULL; 1319 struct ceph_snap_context *snapc = NULL;
1321 u64 snap_id = CEPH_NOSNAP; 1320 u64 snap_id = CEPH_NOSNAP;
1322 struct timespec *mtime = NULL; 1321 struct timespec *mtime = NULL;
@@ -1325,28 +1324,12 @@ static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request,
1325 rbd_assert(osd_req != NULL); 1324 rbd_assert(osd_req != NULL);
1326 1325
1327 if (write_request) { 1326 if (write_request) {
1328 osd_data = &osd_req->r_data_out;
1329 now = CURRENT_TIME; 1327 now = CURRENT_TIME;
1330 mtime = &now; 1328 mtime = &now;
1331 if (img_request) 1329 if (img_request)
1332 snapc = img_request->snapc; 1330 snapc = img_request->snapc;
1333 } else { 1331 } else if (img_request) {
1334 osd_data = &osd_req->r_data_in; 1332 snap_id = img_request->snap_id;
1335 if (img_request)
1336 snap_id = img_request->snap_id;
1337 }
1338 if (obj_request->type != OBJ_REQUEST_NODATA) {
1339 /*
1340 * If it has data, it's either a object class method
1341 * call (cls) or it's an extent operation.
1342 */
1343 /* XXX This use of the ops array goes away in the next patch */
1344 if (obj_request->osd_req->r_ops[0].op == CEPH_OSD_OP_CALL)
1345 osd_req_op_cls_response_data(obj_request->osd_req, 0,
1346 osd_data);
1347 else
1348 osd_req_op_extent_osd_data(obj_request->osd_req, 0,
1349 osd_data);
1350 } 1333 }
1351 ceph_osdc_build_request(osd_req, obj_request->offset, 1334 ceph_osdc_build_request(osd_req, obj_request->offset,
1352 snapc, snap_id, mtime); 1335 snapc, snap_id, mtime);
@@ -1576,6 +1559,8 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
1576 resid = img_request->length; 1559 resid = img_request->length;
1577 rbd_assert(resid > 0); 1560 rbd_assert(resid > 0);
1578 while (resid) { 1561 while (resid) {
1562 struct ceph_osd_request *osd_req;
1563 struct ceph_osd_data *osd_data;
1579 const char *object_name; 1564 const char *object_name;
1580 unsigned int clone_size; 1565 unsigned int clone_size;
1581 u64 offset; 1566 u64 offset;
@@ -1601,14 +1586,18 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
1601 if (!obj_request->bio_list) 1586 if (!obj_request->bio_list)
1602 goto out_partial; 1587 goto out_partial;
1603 1588
1604 obj_request->osd_req = rbd_osd_req_create(rbd_dev, 1589 osd_req = rbd_osd_req_create(rbd_dev, write_request,
1605 write_request, obj_request); 1590 obj_request);
1606 if (!obj_request->osd_req) 1591 if (!osd_req)
1607 goto out_partial; 1592 goto out_partial;
1593 obj_request->osd_req = osd_req;
1608 1594
1609 osd_req_op_extent_init(obj_request->osd_req, 0, 1595 osd_data = write_request ? &osd_req->r_data_out
1610 opcode, offset, length, 0, 0); 1596 : &osd_req->r_data_in;
1611 rbd_osd_req_format_op(obj_request, write_request); 1597 osd_req_op_extent_init(osd_req, 0, opcode, offset, length,
1598 0, 0);
1599 osd_req_op_extent_osd_data(osd_req, 0, osd_data);
1600 rbd_osd_req_format(obj_request, write_request);
1612 1601
1613 /* status and version are initially zero-filled */ 1602 /* status and version are initially zero-filled */
1614 1603
@@ -1725,7 +1714,7 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev,
1725 1714
1726 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK, 1715 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK,
1727 notify_id, ver, 0); 1716 notify_id, ver, 0);
1728 rbd_osd_req_format_op(obj_request, false); 1717 rbd_osd_req_format(obj_request, false);
1729 1718
1730 osdc = &rbd_dev->rbd_client->client->osdc; 1719 osdc = &rbd_dev->rbd_client->client->osdc;
1731 obj_request->callback = rbd_obj_request_put; 1720 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 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH, 1780 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH,
1792 rbd_dev->watch_event->cookie, 1781 rbd_dev->watch_event->cookie,
1793 rbd_dev->header.obj_version, start); 1782 rbd_dev->header.obj_version, start);
1794 rbd_osd_req_format_op(obj_request, true); 1783 rbd_osd_req_format(obj_request, true);
1795 1784
1796 if (start) 1785 if (start)
1797 ceph_osdc_set_request_linger(osdc, obj_request->osd_req); 1786 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 u64 *version) 1839 u64 *version)
1851{ 1840{
1852 struct rbd_obj_request *obj_request; 1841 struct rbd_obj_request *obj_request;
1842 struct ceph_osd_data *osd_data;
1853 struct ceph_osd_client *osdc; 1843 struct ceph_osd_client *osdc;
1854 struct page **pages; 1844 struct page **pages;
1855 u32 page_count; 1845 u32 page_count;
@@ -1880,10 +1870,12 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
1880 if (!obj_request->osd_req) 1870 if (!obj_request->osd_req)
1881 goto out; 1871 goto out;
1882 1872
1873 osd_data = &obj_request->osd_req->r_data_in;
1883 osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL, 1874 osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL,
1884 class_name, method_name, 1875 class_name, method_name,
1885 outbound, outbound_size); 1876 outbound, outbound_size);
1886 rbd_osd_req_format_op(obj_request, false); 1877 osd_req_op_cls_response_data(obj_request->osd_req, 0, osd_data);
1878 rbd_osd_req_format(obj_request, false);
1887 1879
1888 osdc = &rbd_dev->rbd_client->client->osdc; 1880 osdc = &rbd_dev->rbd_client->client->osdc;
1889 ret = rbd_obj_request_submit(osdc, obj_request); 1881 ret = rbd_obj_request_submit(osdc, obj_request);
@@ -2062,6 +2054,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
2062 2054
2063{ 2055{
2064 struct rbd_obj_request *obj_request; 2056 struct rbd_obj_request *obj_request;
2057 struct ceph_osd_data *osd_data;
2065 struct ceph_osd_client *osdc; 2058 struct ceph_osd_client *osdc;
2066 struct page **pages = NULL; 2059 struct page **pages = NULL;
2067 u32 page_count; 2060 u32 page_count;
@@ -2086,9 +2079,11 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
2086 if (!obj_request->osd_req) 2079 if (!obj_request->osd_req)
2087 goto out; 2080 goto out;
2088 2081
2082 osd_data = &obj_request->osd_req->r_data_in;
2089 osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ, 2083 osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ,
2090 offset, length, 0, 0); 2084 offset, length, 0, 0);
2091 rbd_osd_req_format_op(obj_request, false); 2085 osd_req_op_extent_osd_data(obj_request->osd_req, 0, osd_data);
2086 rbd_osd_req_format(obj_request, false);
2092 2087
2093 osdc = &rbd_dev->rbd_client->client->osdc; 2088 osdc = &rbd_dev->rbd_client->client->osdc;
2094 ret = rbd_obj_request_submit(osdc, obj_request); 2089 ret = rbd_obj_request_submit(osdc, obj_request);