Skip to content

Commit 428a715

Browse files
Douglas Fulleridryomov
authored andcommitted
libceph: add ceph_osdc_call() single-page helper
Add a convenience function to osd_client to send Ceph OSD 'class' ops. The interface assumes that the request and reply data each consist of single pages. Signed-off-by: Douglas Fuller <dfuller@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Alex Elder <elder@linaro.org>
1 parent a4ed38d commit 428a715

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

include/linux/ceph/osd_client.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
397397
extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc);
398398
void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc);
399399

400+
int ceph_osdc_call(struct ceph_osd_client *osdc,
401+
struct ceph_object_id *oid,
402+
struct ceph_object_locator *oloc,
403+
const char *class, const char *method,
404+
unsigned int flags,
405+
struct page *req_page, size_t req_len,
406+
struct page *resp_page, size_t *resp_len);
407+
400408
extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
401409
struct ceph_vino vino,
402410
struct ceph_file_layout *layout,

net/ceph/osd_client.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,6 +4026,57 @@ void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc)
40264026
}
40274027
EXPORT_SYMBOL(ceph_osdc_maybe_request_map);
40284028

4029+
/*
4030+
* Execute an OSD class method on an object.
4031+
*
4032+
* @flags: CEPH_OSD_FLAG_*
4033+
* @resp_len: out param for reply length
4034+
*/
4035+
int ceph_osdc_call(struct ceph_osd_client *osdc,
4036+
struct ceph_object_id *oid,
4037+
struct ceph_object_locator *oloc,
4038+
const char *class, const char *method,
4039+
unsigned int flags,
4040+
struct page *req_page, size_t req_len,
4041+
struct page *resp_page, size_t *resp_len)
4042+
{
4043+
struct ceph_osd_request *req;
4044+
int ret;
4045+
4046+
req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO);
4047+
if (!req)
4048+
return -ENOMEM;
4049+
4050+
ceph_oid_copy(&req->r_base_oid, oid);
4051+
ceph_oloc_copy(&req->r_base_oloc, oloc);
4052+
req->r_flags = flags;
4053+
4054+
ret = ceph_osdc_alloc_messages(req, GFP_NOIO);
4055+
if (ret)
4056+
goto out_put_req;
4057+
4058+
osd_req_op_cls_init(req, 0, CEPH_OSD_OP_CALL, class, method);
4059+
if (req_page)
4060+
osd_req_op_cls_request_data_pages(req, 0, &req_page, req_len,
4061+
0, false, false);
4062+
if (resp_page)
4063+
osd_req_op_cls_response_data_pages(req, 0, &resp_page,
4064+
PAGE_SIZE, 0, false, false);
4065+
4066+
ceph_osdc_start_request(osdc, req, false);
4067+
ret = ceph_osdc_wait_request(osdc, req);
4068+
if (ret >= 0) {
4069+
ret = req->r_ops[0].rval;
4070+
if (resp_page)
4071+
*resp_len = req->r_ops[0].outdata_len;
4072+
}
4073+
4074+
out_put_req:
4075+
ceph_osdc_put_request(req);
4076+
return ret;
4077+
}
4078+
EXPORT_SYMBOL(ceph_osdc_call);
4079+
40294080
/*
40304081
* init, shutdown
40314082
*/

0 commit comments

Comments
 (0)