Commit d0b19705 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: async MON client generic requests

For map check, we are going to need to send CEPH_MSG_MON_GET_VERSION
messages asynchronously and get a callback on completion.  Refactor MON
client to allow firing off generic requests asynchronously and add an
async variant of ceph_monc_get_version().  ceph_monc_do_statfs() is
switched over and remains sync.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent b07d3c4b
...@@ -4896,7 +4896,7 @@ static int rbd_add_get_pool_id(struct rbd_client *rbdc, const char *pool_name) ...@@ -4896,7 +4896,7 @@ static int rbd_add_get_pool_id(struct rbd_client *rbdc, const char *pool_name)
again: again:
ret = ceph_pg_poolid_by_name(rbdc->client->osdc.osdmap, pool_name); ret = ceph_pg_poolid_by_name(rbdc->client->osdc.osdmap, pool_name);
if (ret == -ENOENT && tries++ < 1) { if (ret == -ENOENT && tries++ < 1) {
ret = ceph_monc_do_get_version(&rbdc->client->monc, "osdmap", ret = ceph_monc_get_version(&rbdc->client->monc, "osdmap",
&newest_epoch); &newest_epoch);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -39,20 +39,31 @@ struct ceph_mon_request { ...@@ -39,20 +39,31 @@ struct ceph_mon_request {
ceph_monc_request_func_t do_request; ceph_monc_request_func_t do_request;
}; };
typedef void (*ceph_monc_callback_t)(struct ceph_mon_generic_request *);
/* /*
* ceph_mon_generic_request is being used for the statfs and * ceph_mon_generic_request is being used for the statfs and
* mon_get_version requests which are being done a bit differently * mon_get_version requests which are being done a bit differently
* because we need to get data back to the caller * because we need to get data back to the caller
*/ */
struct ceph_mon_generic_request { struct ceph_mon_generic_request {
struct ceph_mon_client *monc;
struct kref kref; struct kref kref;
u64 tid; u64 tid;
struct rb_node node; struct rb_node node;
int result; int result;
void *buf;
struct completion completion; struct completion completion;
ceph_monc_callback_t complete_cb;
u64 private_data; /* r_tid/linger_id */
struct ceph_msg *request; /* original request */ struct ceph_msg *request; /* original request */
struct ceph_msg *reply; /* and reply */ struct ceph_msg *reply; /* and reply */
union {
struct ceph_statfs *st;
u64 newest;
} u;
}; };
struct ceph_mon_client { struct ceph_mon_client {
...@@ -124,8 +135,10 @@ extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch, ...@@ -124,8 +135,10 @@ extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
struct ceph_statfs *buf); struct ceph_statfs *buf);
extern int ceph_monc_do_get_version(struct ceph_mon_client *monc, int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
const char *what, u64 *newest); u64 *newest);
int ceph_monc_get_version_async(struct ceph_mon_client *monc, const char *what,
ceph_monc_callback_t cb, u64 private_data);
extern int ceph_monc_open_session(struct ceph_mon_client *monc); extern int ceph_monc_open_session(struct ceph_mon_client *monc);
......
This diff is collapsed.
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