rbd: support data returned from OSD methods

An OSD object method call can be made using rbd_req_sync_exec().
Until now this has only been used for creating a new RBD snapshot,
and that has only required sending data out, not receiving anything
back from the OSD.

We will now need to get data back from an OSD on a method call, so
add parameters to rbd_req_sync_exec() that allow a buffer into which
returned data should be placed to be specified, along with its size.

Previously, rbd_req_sync_exec() passed a null pointer and zero
size to rbd_req_sync_op(); change this so the new inbound buffer
information is provided instead.

Rename the "buf" and "len" parameters in rbd_req_sync_op() to
make it more obvious they are describing inbound data.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
Alex Elder 2012-07-03 16:01:19 -05:00
parent 3cb4a687c7
commit f8d4de6e1c

View File

@ -1098,8 +1098,8 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
int flags, int flags,
struct ceph_osd_req_op *ops, struct ceph_osd_req_op *ops,
const char *object_name, const char *object_name,
u64 ofs, u64 len, u64 ofs, u64 inbound_size,
char *buf, char *inbound,
struct ceph_osd_request **linger_req, struct ceph_osd_request **linger_req,
u64 *ver) u64 *ver)
{ {
@ -1109,13 +1109,13 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
rbd_assert(ops != NULL); rbd_assert(ops != NULL);
num_pages = calc_pages_for(ofs , len); num_pages = calc_pages_for(ofs, inbound_size);
pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL); pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
if (IS_ERR(pages)) if (IS_ERR(pages))
return PTR_ERR(pages); return PTR_ERR(pages);
ret = rbd_do_request(NULL, rbd_dev, snapc, snapid, ret = rbd_do_request(NULL, rbd_dev, snapc, snapid,
object_name, ofs, len, NULL, object_name, ofs, inbound_size, NULL,
pages, num_pages, pages, num_pages,
flags, flags,
ops, ops,
@ -1125,8 +1125,8 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
if (ret < 0) if (ret < 0)
goto done; goto done;
if ((flags & CEPH_OSD_FLAG_READ) && buf) if ((flags & CEPH_OSD_FLAG_READ) && inbound)
ret = ceph_copy_from_page_vector(pages, buf, ofs, ret); ret = ceph_copy_from_page_vector(pages, inbound, ofs, ret);
done: done:
ceph_release_page_vector(pages, num_pages); ceph_release_page_vector(pages, num_pages);
@ -1445,6 +1445,8 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev,
const char *method_name, const char *method_name,
const char *outbound, const char *outbound,
size_t outbound_size, size_t outbound_size,
char *inbound,
size_t inbound_size,
int flags, int flags,
u64 *ver) u64 *ver)
{ {
@ -1478,7 +1480,8 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev,
ret = rbd_req_sync_op(rbd_dev, NULL, ret = rbd_req_sync_op(rbd_dev, NULL,
CEPH_NOSNAP, CEPH_NOSNAP,
flags, ops, flags, ops,
object_name, 0, 0, NULL, NULL, ver); object_name, 0, inbound_size, inbound,
NULL, ver);
rbd_destroy_ops(ops); rbd_destroy_ops(ops);
@ -1789,7 +1792,7 @@ static int rbd_header_add_snap(struct rbd_device *rbd_dev,
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name, ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "snap_add", "rbd", "snap_add",
data, (size_t) (p - data), data, (size_t) (p - data), NULL, 0,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
NULL); NULL);