diff options
author | Alex Elder <elder@inktank.com> | 2013-04-03 22:32:51 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:12 -0400 |
commit | 79528734f3ae4699a2886f62f55e18fb34fb3651 (patch) | |
tree | 51905378486b592fc2d4037d67ef3b577fe4eaa7 /drivers/block/rbd.c | |
parent | 430c28c3cb7f3dbd87de266ed52d65928957ff78 (diff) |
libceph: keep source rather than message osd op array
An osd request keeps a pointer to the osd operations (ops) array
that it builds in its request message.
In order to allow each op in the array to have its own distinct
data, we will need to keep track of each op's data, and that
information does not go over the wire.
As long as we're tracking the data we might as well just track the
entire (source) op definition for each of the ops. And if we're
doing that, we'll have no more need to keep a pointer to the
wire-encoded version.
This patch makes the array of source ops be kept with the osd
request structure, and uses that instead of the version encoded in
the message in places where that was previously used. The array
will be embedded in the request structure, and the maximum number of
ops we ever actually use is currently 2. So reduce CEPH_OSD_MAX_OP
to 2 to reduce the size of the structure.
The result of doing this sort of ripples back up, and as a result
various function parameters and local variables become unnecessary.
Make r_num_ops be unsigned, and move the definition of struct
ceph_osd_req_op earlier to ensure it's defined where needed.
It does not yet add per-op data, that's coming soon.
This resolves:
http://tracker.ceph.com/issues/4656
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4a4be14a9189..c12b55559f16 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1285,7 +1285,7 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, | |||
1285 | */ | 1285 | */ |
1286 | obj_request->xferred = osd_req->r_reply_op_len[0]; | 1286 | obj_request->xferred = osd_req->r_reply_op_len[0]; |
1287 | rbd_assert(obj_request->xferred < (u64) UINT_MAX); | 1287 | rbd_assert(obj_request->xferred < (u64) UINT_MAX); |
1288 | opcode = osd_req->r_request_ops[0].op; | 1288 | opcode = osd_req->r_ops[0].op; |
1289 | switch (opcode) { | 1289 | switch (opcode) { |
1290 | case CEPH_OSD_OP_READ: | 1290 | case CEPH_OSD_OP_READ: |
1291 | rbd_osd_read_callback(obj_request); | 1291 | rbd_osd_read_callback(obj_request); |
@@ -1312,8 +1312,7 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, | |||
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, | 1314 | static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, |
1315 | bool write_request, | 1315 | bool write_request) |
1316 | struct ceph_osd_req_op *op) | ||
1317 | { | 1316 | { |
1318 | struct rbd_img_request *img_request = obj_request->img_request; | 1317 | struct rbd_img_request *img_request = obj_request->img_request; |
1319 | struct ceph_snap_context *snapc = NULL; | 1318 | struct ceph_snap_context *snapc = NULL; |
@@ -1333,7 +1332,7 @@ static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request, | |||
1333 | } | 1332 | } |
1334 | 1333 | ||
1335 | ceph_osdc_build_request(obj_request->osd_req, obj_request->offset, | 1334 | ceph_osdc_build_request(obj_request->osd_req, obj_request->offset, |
1336 | 1, op, snapc, snap_id, mtime); | 1335 | snapc, snap_id, mtime); |
1337 | } | 1336 | } |
1338 | 1337 | ||
1339 | static struct ceph_osd_request *rbd_osd_req_create( | 1338 | static struct ceph_osd_request *rbd_osd_req_create( |
@@ -1562,7 +1561,7 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, | |||
1562 | while (resid) { | 1561 | while (resid) { |
1563 | const char *object_name; | 1562 | const char *object_name; |
1564 | unsigned int clone_size; | 1563 | unsigned int clone_size; |
1565 | struct ceph_osd_req_op op; | 1564 | struct ceph_osd_req_op *op; |
1566 | u64 offset; | 1565 | u64 offset; |
1567 | u64 length; | 1566 | u64 length; |
1568 | 1567 | ||
@@ -1591,8 +1590,9 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, | |||
1591 | if (!obj_request->osd_req) | 1590 | if (!obj_request->osd_req) |
1592 | goto out_partial; | 1591 | goto out_partial; |
1593 | 1592 | ||
1594 | osd_req_op_extent_init(&op, opcode, offset, length, 0, 0); | 1593 | op = &obj_request->osd_req->r_ops[0]; |
1595 | rbd_osd_req_format_op(obj_request, write_request, &op); | 1594 | osd_req_op_extent_init(op, opcode, offset, length, 0, 0); |
1595 | rbd_osd_req_format_op(obj_request, write_request); | ||
1596 | 1596 | ||
1597 | /* status and version are initially zero-filled */ | 1597 | /* status and version are initially zero-filled */ |
1598 | 1598 | ||
@@ -1694,7 +1694,7 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, | |||
1694 | u64 ver, u64 notify_id) | 1694 | u64 ver, u64 notify_id) |
1695 | { | 1695 | { |
1696 | struct rbd_obj_request *obj_request; | 1696 | struct rbd_obj_request *obj_request; |
1697 | struct ceph_osd_req_op op; | 1697 | struct ceph_osd_req_op *op; |
1698 | struct ceph_osd_client *osdc; | 1698 | struct ceph_osd_client *osdc; |
1699 | int ret; | 1699 | int ret; |
1700 | 1700 | ||
@@ -1708,8 +1708,9 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, | |||
1708 | if (!obj_request->osd_req) | 1708 | if (!obj_request->osd_req) |
1709 | goto out; | 1709 | goto out; |
1710 | 1710 | ||
1711 | osd_req_op_watch_init(&op, CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver, 0); | 1711 | op = &obj_request->osd_req->r_ops[0]; |
1712 | rbd_osd_req_format_op(obj_request, false, &op); | 1712 | osd_req_op_watch_init(op, CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver, 0); |
1713 | rbd_osd_req_format_op(obj_request, false); | ||
1713 | 1714 | ||
1714 | osdc = &rbd_dev->rbd_client->client->osdc; | 1715 | osdc = &rbd_dev->rbd_client->client->osdc; |
1715 | obj_request->callback = rbd_obj_request_put; | 1716 | obj_request->callback = rbd_obj_request_put; |
@@ -1749,7 +1750,7 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start) | |||
1749 | { | 1750 | { |
1750 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; | 1751 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; |
1751 | struct rbd_obj_request *obj_request; | 1752 | struct rbd_obj_request *obj_request; |
1752 | struct ceph_osd_req_op op; | 1753 | struct ceph_osd_req_op *op; |
1753 | int ret; | 1754 | int ret; |
1754 | 1755 | ||
1755 | rbd_assert(start ^ !!rbd_dev->watch_event); | 1756 | rbd_assert(start ^ !!rbd_dev->watch_event); |
@@ -1773,10 +1774,11 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start) | |||
1773 | if (!obj_request->osd_req) | 1774 | if (!obj_request->osd_req) |
1774 | goto out_cancel; | 1775 | goto out_cancel; |
1775 | 1776 | ||
1776 | osd_req_op_watch_init(&op, CEPH_OSD_OP_WATCH, | 1777 | op = &obj_request->osd_req->r_ops[0]; |
1778 | osd_req_op_watch_init(op, CEPH_OSD_OP_WATCH, | ||
1777 | rbd_dev->watch_event->cookie, | 1779 | rbd_dev->watch_event->cookie, |
1778 | rbd_dev->header.obj_version, start); | 1780 | rbd_dev->header.obj_version, start); |
1779 | rbd_osd_req_format_op(obj_request, true, &op); | 1781 | rbd_osd_req_format_op(obj_request, true); |
1780 | 1782 | ||
1781 | if (start) | 1783 | if (start) |
1782 | ceph_osdc_set_request_linger(osdc, obj_request->osd_req); | 1784 | ceph_osdc_set_request_linger(osdc, obj_request->osd_req); |
@@ -1836,7 +1838,7 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, | |||
1836 | { | 1838 | { |
1837 | struct rbd_obj_request *obj_request; | 1839 | struct rbd_obj_request *obj_request; |
1838 | struct ceph_osd_client *osdc; | 1840 | struct ceph_osd_client *osdc; |
1839 | struct ceph_osd_req_op op; | 1841 | struct ceph_osd_req_op *op; |
1840 | struct page **pages; | 1842 | struct page **pages; |
1841 | u32 page_count; | 1843 | u32 page_count; |
1842 | int ret; | 1844 | int ret; |
@@ -1866,9 +1868,10 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, | |||
1866 | if (!obj_request->osd_req) | 1868 | if (!obj_request->osd_req) |
1867 | goto out; | 1869 | goto out; |
1868 | 1870 | ||
1869 | osd_req_op_cls_init(&op, CEPH_OSD_OP_CALL, class_name, method_name, | 1871 | op = &obj_request->osd_req->r_ops[0]; |
1872 | osd_req_op_cls_init(op, CEPH_OSD_OP_CALL, class_name, method_name, | ||
1870 | outbound, outbound_size); | 1873 | outbound, outbound_size); |
1871 | rbd_osd_req_format_op(obj_request, false, &op); | 1874 | rbd_osd_req_format_op(obj_request, false); |
1872 | 1875 | ||
1873 | osdc = &rbd_dev->rbd_client->client->osdc; | 1876 | osdc = &rbd_dev->rbd_client->client->osdc; |
1874 | ret = rbd_obj_request_submit(osdc, obj_request); | 1877 | ret = rbd_obj_request_submit(osdc, obj_request); |
@@ -2046,8 +2049,8 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, | |||
2046 | char *buf, u64 *version) | 2049 | char *buf, u64 *version) |
2047 | 2050 | ||
2048 | { | 2051 | { |
2049 | struct ceph_osd_req_op op; | ||
2050 | struct rbd_obj_request *obj_request; | 2052 | struct rbd_obj_request *obj_request; |
2053 | struct ceph_osd_req_op *op; | ||
2051 | struct ceph_osd_client *osdc; | 2054 | struct ceph_osd_client *osdc; |
2052 | struct page **pages = NULL; | 2055 | struct page **pages = NULL; |
2053 | u32 page_count; | 2056 | u32 page_count; |
@@ -2072,8 +2075,9 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, | |||
2072 | if (!obj_request->osd_req) | 2075 | if (!obj_request->osd_req) |
2073 | goto out; | 2076 | goto out; |
2074 | 2077 | ||
2075 | osd_req_op_extent_init(&op, CEPH_OSD_OP_READ, offset, length, 0, 0); | 2078 | op = &obj_request->osd_req->r_ops[0]; |
2076 | rbd_osd_req_format_op(obj_request, false, &op); | 2079 | osd_req_op_extent_init(op, CEPH_OSD_OP_READ, offset, length, 0, 0); |
2080 | rbd_osd_req_format_op(obj_request, false); | ||
2077 | 2081 | ||
2078 | osdc = &rbd_dev->rbd_client->client->osdc; | 2082 | osdc = &rbd_dev->rbd_client->client->osdc; |
2079 | ret = rbd_obj_request_submit(osdc, obj_request); | 2083 | ret = rbd_obj_request_submit(osdc, obj_request); |