aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ceph/debugfs.c13
-rw-r--r--fs/ceph/mon_client.c82
-rw-r--r--fs/ceph/mon_client.h15
3 files changed, 58 insertions, 52 deletions
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index f7048da92acc..3be33fb066cc 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -113,7 +113,7 @@ static int osdmap_show(struct seq_file *s, void *p)
113static int monc_show(struct seq_file *s, void *p) 113static int monc_show(struct seq_file *s, void *p)
114{ 114{
115 struct ceph_client *client = s->private; 115 struct ceph_client *client = s->private;
116 struct ceph_mon_statfs_request *req; 116 struct ceph_mon_generic_request *req;
117 struct ceph_mon_client *monc = &client->monc; 117 struct ceph_mon_client *monc = &client->monc;
118 struct rb_node *rp; 118 struct rb_node *rp;
119 119
@@ -126,9 +126,14 @@ static int monc_show(struct seq_file *s, void *p)
126 if (monc->want_next_osdmap) 126 if (monc->want_next_osdmap)
127 seq_printf(s, "want next osdmap\n"); 127 seq_printf(s, "want next osdmap\n");
128 128
129 for (rp = rb_first(&monc->statfs_request_tree); rp; rp = rb_next(rp)) { 129 for (rp = rb_first(&monc->generic_request_tree); rp; rp = rb_next(rp)) {
130 req = rb_entry(rp, struct ceph_mon_statfs_request, node); 130 __u16 op;
131 seq_printf(s, "%lld statfs\n", req->tid); 131 req = rb_entry(rp, struct ceph_mon_generic_request, node);
132 op = le16_to_cpu(req->request->hdr.type);
133 if (op == CEPH_MSG_STATFS)
134 seq_printf(s, "%lld statfs\n", req->tid);
135 else
136 seq_printf(s, "%lld unknown\n", req->tid);
132 } 137 }
133 138
134 mutex_unlock(&monc->mutex); 139 mutex_unlock(&monc->mutex);
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 9900706fee75..7df2f8c157f1 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -353,14 +353,14 @@ out:
353/* 353/*
354 * statfs 354 * statfs
355 */ 355 */
356static struct ceph_mon_statfs_request *__lookup_statfs( 356static struct ceph_mon_generic_request *__lookup_generic_req(
357 struct ceph_mon_client *monc, u64 tid) 357 struct ceph_mon_client *monc, u64 tid)
358{ 358{
359 struct ceph_mon_statfs_request *req; 359 struct ceph_mon_generic_request *req;
360 struct rb_node *n = monc->statfs_request_tree.rb_node; 360 struct rb_node *n = monc->generic_request_tree.rb_node;
361 361
362 while (n) { 362 while (n) {
363 req = rb_entry(n, struct ceph_mon_statfs_request, node); 363 req = rb_entry(n, struct ceph_mon_generic_request, node);
364 if (tid < req->tid) 364 if (tid < req->tid)
365 n = n->rb_left; 365 n = n->rb_left;
366 else if (tid > req->tid) 366 else if (tid > req->tid)
@@ -371,16 +371,16 @@ static struct ceph_mon_statfs_request *__lookup_statfs(
371 return NULL; 371 return NULL;
372} 372}
373 373
374static void __insert_statfs(struct ceph_mon_client *monc, 374static void __insert_generic_request(struct ceph_mon_client *monc,
375 struct ceph_mon_statfs_request *new) 375 struct ceph_mon_generic_request *new)
376{ 376{
377 struct rb_node **p = &monc->statfs_request_tree.rb_node; 377 struct rb_node **p = &monc->generic_request_tree.rb_node;
378 struct rb_node *parent = NULL; 378 struct rb_node *parent = NULL;
379 struct ceph_mon_statfs_request *req = NULL; 379 struct ceph_mon_generic_request *req = NULL;
380 380
381 while (*p) { 381 while (*p) {
382 parent = *p; 382 parent = *p;
383 req = rb_entry(parent, struct ceph_mon_statfs_request, node); 383 req = rb_entry(parent, struct ceph_mon_generic_request, node);
384 if (new->tid < req->tid) 384 if (new->tid < req->tid)
385 p = &(*p)->rb_left; 385 p = &(*p)->rb_left;
386 else if (new->tid > req->tid) 386 else if (new->tid > req->tid)
@@ -390,13 +390,13 @@ static void __insert_statfs(struct ceph_mon_client *monc,
390 } 390 }
391 391
392 rb_link_node(&new->node, parent, p); 392 rb_link_node(&new->node, parent, p);
393 rb_insert_color(&new->node, &monc->statfs_request_tree); 393 rb_insert_color(&new->node, &monc->generic_request_tree);
394} 394}
395 395
396static void release_statfs_request(struct kref *kref) 396static void release_generic_request(struct kref *kref)
397{ 397{
398 struct ceph_mon_statfs_request *req = 398 struct ceph_mon_generic_request *req =
399 container_of(kref, struct ceph_mon_statfs_request, kref); 399 container_of(kref, struct ceph_mon_generic_request, kref);
400 400
401 if (req->reply) 401 if (req->reply)
402 ceph_msg_put(req->reply); 402 ceph_msg_put(req->reply);
@@ -404,33 +404,33 @@ static void release_statfs_request(struct kref *kref)
404 ceph_msg_put(req->request); 404 ceph_msg_put(req->request);
405} 405}
406 406
407static void put_statfs_request(struct ceph_mon_statfs_request *req) 407static void put_generic_request(struct ceph_mon_generic_request *req)
408{ 408{
409 kref_put(&req->kref, release_statfs_request); 409 kref_put(&req->kref, release_generic_request);
410} 410}
411 411
412static void get_statfs_request(struct ceph_mon_statfs_request *req) 412static void get_generic_request(struct ceph_mon_generic_request *req)
413{ 413{
414 kref_get(&req->kref); 414 kref_get(&req->kref);
415} 415}
416 416
417static struct ceph_msg *get_statfs_reply(struct ceph_connection *con, 417static struct ceph_msg *get_generic_reply(struct ceph_connection *con,
418 struct ceph_msg_header *hdr, 418 struct ceph_msg_header *hdr,
419 int *skip) 419 int *skip)
420{ 420{
421 struct ceph_mon_client *monc = con->private; 421 struct ceph_mon_client *monc = con->private;
422 struct ceph_mon_statfs_request *req; 422 struct ceph_mon_generic_request *req;
423 u64 tid = le64_to_cpu(hdr->tid); 423 u64 tid = le64_to_cpu(hdr->tid);
424 struct ceph_msg *m; 424 struct ceph_msg *m;
425 425
426 mutex_lock(&monc->mutex); 426 mutex_lock(&monc->mutex);
427 req = __lookup_statfs(monc, tid); 427 req = __lookup_generic_req(monc, tid);
428 if (!req) { 428 if (!req) {
429 dout("get_statfs_reply %lld dne\n", tid); 429 dout("get_generic_reply %lld dne\n", tid);
430 *skip = 1; 430 *skip = 1;
431 m = NULL; 431 m = NULL;
432 } else { 432 } else {
433 dout("get_statfs_reply %lld got %p\n", tid, req->reply); 433 dout("get_generic_reply %lld got %p\n", tid, req->reply);
434 m = ceph_msg_get(req->reply); 434 m = ceph_msg_get(req->reply);
435 /* 435 /*
436 * we don't need to track the connection reading into 436 * we don't need to track the connection reading into
@@ -445,7 +445,7 @@ static struct ceph_msg *get_statfs_reply(struct ceph_connection *con,
445static void handle_statfs_reply(struct ceph_mon_client *monc, 445static void handle_statfs_reply(struct ceph_mon_client *monc,
446 struct ceph_msg *msg) 446 struct ceph_msg *msg)
447{ 447{
448 struct ceph_mon_statfs_request *req; 448 struct ceph_mon_generic_request *req;
449 struct ceph_mon_statfs_reply *reply = msg->front.iov_base; 449 struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
450 u64 tid = le64_to_cpu(msg->hdr.tid); 450 u64 tid = le64_to_cpu(msg->hdr.tid);
451 451
@@ -454,21 +454,21 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
454 dout("handle_statfs_reply %p tid %llu\n", msg, tid); 454 dout("handle_statfs_reply %p tid %llu\n", msg, tid);
455 455
456 mutex_lock(&monc->mutex); 456 mutex_lock(&monc->mutex);
457 req = __lookup_statfs(monc, tid); 457 req = __lookup_generic_req(monc, tid);
458 if (req) { 458 if (req) {
459 *req->buf = reply->st; 459 *(struct ceph_statfs *)req->buf = reply->st;
460 req->result = 0; 460 req->result = 0;
461 get_statfs_request(req); 461 get_generic_request(req);
462 } 462 }
463 mutex_unlock(&monc->mutex); 463 mutex_unlock(&monc->mutex);
464 if (req) { 464 if (req) {
465 complete(&req->completion); 465 complete(&req->completion);
466 put_statfs_request(req); 466 put_generic_request(req);
467 } 467 }
468 return; 468 return;
469 469
470bad: 470bad:
471 pr_err("corrupt statfs reply, no tid\n"); 471 pr_err("corrupt generic reply, no tid\n");
472 ceph_msg_dump(msg); 472 ceph_msg_dump(msg);
473} 473}
474 474
@@ -477,7 +477,7 @@ bad:
477 */ 477 */
478int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) 478int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
479{ 479{
480 struct ceph_mon_statfs_request *req; 480 struct ceph_mon_generic_request *req;
481 struct ceph_mon_statfs *h; 481 struct ceph_mon_statfs *h;
482 int err; 482 int err;
483 483
@@ -509,8 +509,8 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
509 mutex_lock(&monc->mutex); 509 mutex_lock(&monc->mutex);
510 req->tid = ++monc->last_tid; 510 req->tid = ++monc->last_tid;
511 req->request->hdr.tid = cpu_to_le64(req->tid); 511 req->request->hdr.tid = cpu_to_le64(req->tid);
512 __insert_statfs(monc, req); 512 __insert_generic_request(monc, req);
513 monc->num_statfs_requests++; 513 monc->num_generic_requests++;
514 mutex_unlock(&monc->mutex); 514 mutex_unlock(&monc->mutex);
515 515
516 /* send request and wait */ 516 /* send request and wait */
@@ -518,28 +518,28 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
518 err = wait_for_completion_interruptible(&req->completion); 518 err = wait_for_completion_interruptible(&req->completion);
519 519
520 mutex_lock(&monc->mutex); 520 mutex_lock(&monc->mutex);
521 rb_erase(&req->node, &monc->statfs_request_tree); 521 rb_erase(&req->node, &monc->generic_request_tree);
522 monc->num_statfs_requests--; 522 monc->num_generic_requests--;
523 mutex_unlock(&monc->mutex); 523 mutex_unlock(&monc->mutex);
524 524
525 if (!err) 525 if (!err)
526 err = req->result; 526 err = req->result;
527 527
528out: 528out:
529 kref_put(&req->kref, release_statfs_request); 529 kref_put(&req->kref, release_generic_request);
530 return err; 530 return err;
531} 531}
532 532
533/* 533/*
534 * Resend pending statfs requests. 534 * Resend pending statfs requests.
535 */ 535 */
536static void __resend_statfs(struct ceph_mon_client *monc) 536static void __resend_generic_request(struct ceph_mon_client *monc)
537{ 537{
538 struct ceph_mon_statfs_request *req; 538 struct ceph_mon_generic_request *req;
539 struct rb_node *p; 539 struct rb_node *p;
540 540
541 for (p = rb_first(&monc->statfs_request_tree); p; p = rb_next(p)) { 541 for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) {
542 req = rb_entry(p, struct ceph_mon_statfs_request, node); 542 req = rb_entry(p, struct ceph_mon_generic_request, node);
543 ceph_con_send(monc->con, ceph_msg_get(req->request)); 543 ceph_con_send(monc->con, ceph_msg_get(req->request));
544 } 544 }
545} 545}
@@ -652,8 +652,8 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
652 monc->sub_sent = 0; 652 monc->sub_sent = 0;
653 653
654 INIT_DELAYED_WORK(&monc->delayed_work, delayed_work); 654 INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
655 monc->statfs_request_tree = RB_ROOT; 655 monc->generic_request_tree = RB_ROOT;
656 monc->num_statfs_requests = 0; 656 monc->num_generic_requests = 0;
657 monc->last_tid = 0; 657 monc->last_tid = 0;
658 658
659 monc->have_mdsmap = 0; 659 monc->have_mdsmap = 0;
@@ -717,7 +717,7 @@ static void handle_auth_reply(struct ceph_mon_client *monc,
717 monc->client->msgr->inst.name.num = monc->auth->global_id; 717 monc->client->msgr->inst.name.num = monc->auth->global_id;
718 718
719 __send_subscribe(monc); 719 __send_subscribe(monc);
720 __resend_statfs(monc); 720 __resend_generic_request(monc);
721 } 721 }
722 mutex_unlock(&monc->mutex); 722 mutex_unlock(&monc->mutex);
723} 723}
@@ -809,7 +809,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
809 m = ceph_msg_get(monc->m_subscribe_ack); 809 m = ceph_msg_get(monc->m_subscribe_ack);
810 break; 810 break;
811 case CEPH_MSG_STATFS_REPLY: 811 case CEPH_MSG_STATFS_REPLY:
812 return get_statfs_reply(con, hdr, skip); 812 return get_generic_reply(con, hdr, skip);
813 case CEPH_MSG_AUTH_REPLY: 813 case CEPH_MSG_AUTH_REPLY:
814 m = ceph_msg_get(monc->m_auth_reply); 814 m = ceph_msg_get(monc->m_auth_reply);
815 break; 815 break;
diff --git a/fs/ceph/mon_client.h b/fs/ceph/mon_client.h
index 0046deed0740..76887785a4d7 100644
--- a/fs/ceph/mon_client.h
+++ b/fs/ceph/mon_client.h
@@ -22,7 +22,7 @@ struct ceph_monmap {
22}; 22};
23 23
24struct ceph_mon_client; 24struct ceph_mon_client;
25struct ceph_mon_statfs_request; 25struct ceph_mon_generic_request;
26 26
27 27
28/* 28/*
@@ -40,15 +40,16 @@ struct ceph_mon_request {
40}; 40};
41 41
42/* 42/*
43 * statfs() is done a bit differently because we need to get data back 43 * ceph_mon_generic_request is being used for the statfs and poolop requests
44 * which are bening done a bit differently because we need to get data back
44 * to the caller 45 * to the caller
45 */ 46 */
46struct ceph_mon_statfs_request { 47struct ceph_mon_generic_request {
47 struct kref kref; 48 struct kref kref;
48 u64 tid; 49 u64 tid;
49 struct rb_node node; 50 struct rb_node node;
50 int result; 51 int result;
51 struct ceph_statfs *buf; 52 void *buf;
52 struct completion completion; 53 struct completion completion;
53 struct ceph_msg *request; /* original request */ 54 struct ceph_msg *request; /* original request */
54 struct ceph_msg *reply; /* and reply */ 55 struct ceph_msg *reply; /* and reply */
@@ -71,9 +72,9 @@ struct ceph_mon_client {
71 struct ceph_connection *con; 72 struct ceph_connection *con;
72 bool have_fsid; 73 bool have_fsid;
73 74
74 /* pending statfs requests */ 75 /* pending generic requests */
75 struct rb_root statfs_request_tree; 76 struct rb_root generic_request_tree;
76 int num_statfs_requests; 77 int num_generic_requests;
77 u64 last_tid; 78 u64 last_tid;
78 79
79 /* mds/osd map */ 80 /* mds/osd map */