This is being done so that we could reuse the statfs
infrastructure with other requests that return values.
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
static int monc_show(struct seq_file *s, void *p)
{
struct ceph_client *client = s->private;
static int monc_show(struct seq_file *s, void *p)
{
struct ceph_client *client = s->private;
- struct ceph_mon_statfs_request *req;
+ struct ceph_mon_generic_request *req;
struct ceph_mon_client *monc = &client->monc;
struct rb_node *rp;
struct ceph_mon_client *monc = &client->monc;
struct rb_node *rp;
if (monc->want_next_osdmap)
seq_printf(s, "want next osdmap\n");
if (monc->want_next_osdmap)
seq_printf(s, "want next osdmap\n");
- for (rp = rb_first(&monc->statfs_request_tree); rp; rp = rb_next(rp)) {
- req = rb_entry(rp, struct ceph_mon_statfs_request, node);
- seq_printf(s, "%lld statfs\n", req->tid);
+ for (rp = rb_first(&monc->generic_request_tree); rp; rp = rb_next(rp)) {
+ __u16 op;
+ req = rb_entry(rp, struct ceph_mon_generic_request, node);
+ op = le16_to_cpu(req->request->hdr.type);
+ if (op == CEPH_MSG_STATFS)
+ seq_printf(s, "%lld statfs\n", req->tid);
+ else
+ seq_printf(s, "%lld unknown\n", req->tid);
}
mutex_unlock(&monc->mutex);
}
mutex_unlock(&monc->mutex);
-static struct ceph_mon_statfs_request *__lookup_statfs(
+static struct ceph_mon_generic_request *__lookup_generic_req(
struct ceph_mon_client *monc, u64 tid)
{
struct ceph_mon_client *monc, u64 tid)
{
- struct ceph_mon_statfs_request *req;
- struct rb_node *n = monc->statfs_request_tree.rb_node;
+ struct ceph_mon_generic_request *req;
+ struct rb_node *n = monc->generic_request_tree.rb_node;
- req = rb_entry(n, struct ceph_mon_statfs_request, node);
+ req = rb_entry(n, struct ceph_mon_generic_request, node);
if (tid < req->tid)
n = n->rb_left;
else if (tid > req->tid)
if (tid < req->tid)
n = n->rb_left;
else if (tid > req->tid)
-static void __insert_statfs(struct ceph_mon_client *monc,
- struct ceph_mon_statfs_request *new)
+static void __insert_generic_request(struct ceph_mon_client *monc,
+ struct ceph_mon_generic_request *new)
- struct rb_node **p = &monc->statfs_request_tree.rb_node;
+ struct rb_node **p = &monc->generic_request_tree.rb_node;
struct rb_node *parent = NULL;
struct rb_node *parent = NULL;
- struct ceph_mon_statfs_request *req = NULL;
+ struct ceph_mon_generic_request *req = NULL;
while (*p) {
parent = *p;
while (*p) {
parent = *p;
- req = rb_entry(parent, struct ceph_mon_statfs_request, node);
+ req = rb_entry(parent, struct ceph_mon_generic_request, node);
if (new->tid < req->tid)
p = &(*p)->rb_left;
else if (new->tid > req->tid)
if (new->tid < req->tid)
p = &(*p)->rb_left;
else if (new->tid > req->tid)
}
rb_link_node(&new->node, parent, p);
}
rb_link_node(&new->node, parent, p);
- rb_insert_color(&new->node, &monc->statfs_request_tree);
+ rb_insert_color(&new->node, &monc->generic_request_tree);
-static void release_statfs_request(struct kref *kref)
+static void release_generic_request(struct kref *kref)
- struct ceph_mon_statfs_request *req =
- container_of(kref, struct ceph_mon_statfs_request, kref);
+ struct ceph_mon_generic_request *req =
+ container_of(kref, struct ceph_mon_generic_request, kref);
if (req->reply)
ceph_msg_put(req->reply);
if (req->reply)
ceph_msg_put(req->reply);
ceph_msg_put(req->request);
}
ceph_msg_put(req->request);
}
-static void put_statfs_request(struct ceph_mon_statfs_request *req)
+static void put_generic_request(struct ceph_mon_generic_request *req)
- kref_put(&req->kref, release_statfs_request);
+ kref_put(&req->kref, release_generic_request);
-static void get_statfs_request(struct ceph_mon_statfs_request *req)
+static void get_generic_request(struct ceph_mon_generic_request *req)
{
kref_get(&req->kref);
}
{
kref_get(&req->kref);
}
-static struct ceph_msg *get_statfs_reply(struct ceph_connection *con,
+static struct ceph_msg *get_generic_reply(struct ceph_connection *con,
struct ceph_msg_header *hdr,
int *skip)
{
struct ceph_mon_client *monc = con->private;
struct ceph_msg_header *hdr,
int *skip)
{
struct ceph_mon_client *monc = con->private;
- struct ceph_mon_statfs_request *req;
+ struct ceph_mon_generic_request *req;
u64 tid = le64_to_cpu(hdr->tid);
struct ceph_msg *m;
mutex_lock(&monc->mutex);
u64 tid = le64_to_cpu(hdr->tid);
struct ceph_msg *m;
mutex_lock(&monc->mutex);
- req = __lookup_statfs(monc, tid);
+ req = __lookup_generic_req(monc, tid);
- dout("get_statfs_reply %lld dne\n", tid);
+ dout("get_generic_reply %lld dne\n", tid);
*skip = 1;
m = NULL;
} else {
*skip = 1;
m = NULL;
} else {
- dout("get_statfs_reply %lld got %p\n", tid, req->reply);
+ dout("get_generic_reply %lld got %p\n", tid, req->reply);
m = ceph_msg_get(req->reply);
/*
* we don't need to track the connection reading into
m = ceph_msg_get(req->reply);
/*
* we don't need to track the connection reading into
static void handle_statfs_reply(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
static void handle_statfs_reply(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
- struct ceph_mon_statfs_request *req;
+ struct ceph_mon_generic_request *req;
struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
u64 tid = le64_to_cpu(msg->hdr.tid);
struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
u64 tid = le64_to_cpu(msg->hdr.tid);
dout("handle_statfs_reply %p tid %llu\n", msg, tid);
mutex_lock(&monc->mutex);
dout("handle_statfs_reply %p tid %llu\n", msg, tid);
mutex_lock(&monc->mutex);
- req = __lookup_statfs(monc, tid);
+ req = __lookup_generic_req(monc, tid);
+ *(struct ceph_statfs *)req->buf = reply->st;
- get_statfs_request(req);
+ get_generic_request(req);
}
mutex_unlock(&monc->mutex);
if (req) {
complete(&req->completion);
}
mutex_unlock(&monc->mutex);
if (req) {
complete(&req->completion);
- put_statfs_request(req);
+ put_generic_request(req);
- pr_err("corrupt statfs reply, no tid\n");
+ pr_err("corrupt generic reply, no tid\n");
*/
int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
{
*/
int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
{
- struct ceph_mon_statfs_request *req;
+ struct ceph_mon_generic_request *req;
struct ceph_mon_statfs *h;
int err;
struct ceph_mon_statfs *h;
int err;
mutex_lock(&monc->mutex);
req->tid = ++monc->last_tid;
req->request->hdr.tid = cpu_to_le64(req->tid);
mutex_lock(&monc->mutex);
req->tid = ++monc->last_tid;
req->request->hdr.tid = cpu_to_le64(req->tid);
- __insert_statfs(monc, req);
- monc->num_statfs_requests++;
+ __insert_generic_request(monc, req);
+ monc->num_generic_requests++;
mutex_unlock(&monc->mutex);
/* send request and wait */
mutex_unlock(&monc->mutex);
/* send request and wait */
err = wait_for_completion_interruptible(&req->completion);
mutex_lock(&monc->mutex);
err = wait_for_completion_interruptible(&req->completion);
mutex_lock(&monc->mutex);
- rb_erase(&req->node, &monc->statfs_request_tree);
- monc->num_statfs_requests--;
+ rb_erase(&req->node, &monc->generic_request_tree);
+ monc->num_generic_requests--;
mutex_unlock(&monc->mutex);
if (!err)
err = req->result;
out:
mutex_unlock(&monc->mutex);
if (!err)
err = req->result;
out:
- kref_put(&req->kref, release_statfs_request);
+ kref_put(&req->kref, release_generic_request);
return err;
}
/*
* Resend pending statfs requests.
*/
return err;
}
/*
* Resend pending statfs requests.
*/
-static void __resend_statfs(struct ceph_mon_client *monc)
+static void __resend_generic_request(struct ceph_mon_client *monc)
- struct ceph_mon_statfs_request *req;
+ struct ceph_mon_generic_request *req;
- for (p = rb_first(&monc->statfs_request_tree); p; p = rb_next(p)) {
- req = rb_entry(p, struct ceph_mon_statfs_request, node);
+ for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) {
+ req = rb_entry(p, struct ceph_mon_generic_request, node);
ceph_con_send(monc->con, ceph_msg_get(req->request));
}
}
ceph_con_send(monc->con, ceph_msg_get(req->request));
}
}
monc->sub_sent = 0;
INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
monc->sub_sent = 0;
INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
- monc->statfs_request_tree = RB_ROOT;
- monc->num_statfs_requests = 0;
+ monc->generic_request_tree = RB_ROOT;
+ monc->num_generic_requests = 0;
monc->last_tid = 0;
monc->have_mdsmap = 0;
monc->last_tid = 0;
monc->have_mdsmap = 0;
monc->client->msgr->inst.name.num = monc->auth->global_id;
__send_subscribe(monc);
monc->client->msgr->inst.name.num = monc->auth->global_id;
__send_subscribe(monc);
+ __resend_generic_request(monc);
}
mutex_unlock(&monc->mutex);
}
}
mutex_unlock(&monc->mutex);
}
m = ceph_msg_get(monc->m_subscribe_ack);
break;
case CEPH_MSG_STATFS_REPLY:
m = ceph_msg_get(monc->m_subscribe_ack);
break;
case CEPH_MSG_STATFS_REPLY:
- return get_statfs_reply(con, hdr, skip);
+ return get_generic_reply(con, hdr, skip);
case CEPH_MSG_AUTH_REPLY:
m = ceph_msg_get(monc->m_auth_reply);
break;
case CEPH_MSG_AUTH_REPLY:
m = ceph_msg_get(monc->m_auth_reply);
break;
};
struct ceph_mon_client;
};
struct ceph_mon_client;
-struct ceph_mon_statfs_request;
+struct ceph_mon_generic_request;
- * statfs() is done a bit differently because we need to get data back
+ * ceph_mon_generic_request is being used for the statfs and poolop requests
+ * which are bening done a bit differently because we need to get data back
-struct ceph_mon_statfs_request {
+struct ceph_mon_generic_request {
struct kref kref;
u64 tid;
struct rb_node node;
int result;
struct kref kref;
u64 tid;
struct rb_node node;
int result;
- struct ceph_statfs *buf;
struct completion completion;
struct ceph_msg *request; /* original request */
struct ceph_msg *reply; /* and reply */
struct completion completion;
struct ceph_msg *request; /* original request */
struct ceph_msg *reply; /* and reply */
struct ceph_connection *con;
bool have_fsid;
struct ceph_connection *con;
bool have_fsid;
- /* pending statfs requests */
- struct rb_root statfs_request_tree;
- int num_statfs_requests;
+ /* pending generic requests */
+ struct rb_root generic_request_tree;
+ int num_generic_requests;
u64 last_tid;
/* mds/osd map */
u64 last_tid;
/* mds/osd map */