From: Sage Weil Date: Fri, 18 Sep 2009 20:08:25 +0000 (-0700) Subject: kclient: use msgpools for other monc messages X-Git-Tag: v0.15~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3be2b62b3faae98794c0fca37ad72c240314d8af;p=ceph.git kclient: use msgpools for other monc messages --- diff --git a/src/kernel/mon_client.c b/src/kernel/mon_client.c index 2a9df9b00956..1c1decc098dc 100644 --- a/src/kernel/mon_client.c +++ b/src/kernel/mon_client.c @@ -441,7 +441,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) init_completion(&req.completion); /* allocate memory for reply */ - err = ceph_msgpool_resv(&monc->client->msgpool_statfs_reply, 1); + err = ceph_msgpool_resv(&monc->msgpool_statfs_reply, 1); if (err) return err; @@ -466,7 +466,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) mutex_lock(&monc->mutex); radix_tree_delete(&monc->statfs_request_tree, req.tid); monc->num_statfs_requests--; - ceph_msgpool_resv(&monc->client->msgpool_statfs_reply, -1); + ceph_msgpool_resv(&monc->msgpool_statfs_reply, -1); mutex_unlock(&monc->mutex); if (!err) @@ -526,6 +526,8 @@ static void delayed_work(struct work_struct *work) int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) { + int err = 0; + dout("init\n"); memset(monc, 0, sizeof(*monc)); monc->client = cl; @@ -534,6 +536,18 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) monc->con = NULL; + /* msg pools */ + err = ceph_msgpool_init(&monc->msgpool_mount_ack, 4096, 1, false); + if (err < 0) + goto out; + err = ceph_msgpool_init(&monc->msgpool_subscribe_ack, 8, 1, false); + if (err < 0) + goto out; + err = ceph_msgpool_init(&monc->msgpool_statfs_reply, + sizeof(struct ceph_mon_statfs_reply), 0, false); + if (err < 0) + goto out; + monc->cur_mon = -1; monc->hunting = false; /* not really */ monc->sub_renew_after = jiffies; @@ -548,7 +562,8 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) monc->have_osdmap = 0; monc->want_next_osdmap = 1; monc->want_mount = true; - return 0; +out: + return err; } void ceph_monc_stop(struct ceph_mon_client *monc) @@ -565,6 +580,10 @@ void ceph_monc_stop(struct ceph_mon_client *monc) } mutex_unlock(&monc->mutex); + ceph_msgpool_destroy(&monc->msgpool_mount_ack); + ceph_msgpool_destroy(&monc->msgpool_subscribe_ack); + ceph_msgpool_destroy(&monc->msgpool_statfs_reply); + kfree(monc->monmap); } @@ -618,8 +637,12 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con, int type = le32_to_cpu(hdr->type); switch (type) { + case CEPH_MSG_CLIENT_MOUNT_ACK: + return ceph_msgpool_get(&monc->msgpool_mount_ack); + case CEPH_MSG_MON_SUBSCRIBE_ACK: + return ceph_msgpool_get(&monc->msgpool_subscribe_ack); case CEPH_MSG_STATFS_REPLY: - return ceph_msgpool_get(&monc->client->msgpool_statfs_reply); + return ceph_msgpool_get(&monc->msgpool_statfs_reply); } return ceph_alloc_msg(con, hdr); } diff --git a/src/kernel/mon_client.h b/src/kernel/mon_client.h index d2d87dc5c660..f6a2346feae7 100644 --- a/src/kernel/mon_client.h +++ b/src/kernel/mon_client.h @@ -1,10 +1,12 @@ #ifndef _FS_CEPH_MON_CLIENT_H #define _FS_CEPH_MON_CLIENT_H -#include "messenger.h" #include #include +#include "messenger.h" +#include "msgpool.h" + struct ceph_client; struct ceph_mount_args; @@ -61,6 +63,11 @@ struct ceph_mon_client { unsigned long sub_sent, sub_renew_after; struct ceph_connection *con; + /* msg pools */ + struct ceph_msg_pool msgpool_mount_ack; + struct ceph_msg_pool msgpool_subscribe_ack; + struct ceph_msg_pool msgpool_statfs_reply; + /* pending statfs requests */ struct radix_tree_root statfs_request_tree; int num_statfs_requests; diff --git a/src/kernel/super.c b/src/kernel/super.c index 6a2f93f91b8a..8390da62cbd4 100644 --- a/src/kernel/super.c +++ b/src/kernel/super.c @@ -612,13 +612,6 @@ static struct ceph_client *ceph_create_client(void) if (client->trunc_wq == NULL) goto fail; - /* msg pools */ - /* preallocated at request time: */ - err = ceph_msgpool_init(&client->msgpool_statfs_reply, - sizeof(struct ceph_mon_statfs_reply), 0, false); - if (err < 0) - goto fail; - /* subsystems */ err = ceph_monc_init(&client->monc, client); if (err < 0) @@ -656,9 +649,6 @@ static void ceph_destroy_client(struct ceph_client *client) if (client->wb_pagevec_pool) mempool_destroy(client->wb_pagevec_pool); - /* msg pools */ - ceph_msgpool_destroy(&client->msgpool_statfs_reply); - release_mount_args(&client->mount_args); kfree(client); diff --git a/src/kernel/super.h b/src/kernel/super.h index 2e0560802a0a..2753b10a4df3 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -133,9 +133,6 @@ struct ceph_client { struct ceph_mds_client mdsc; struct ceph_osd_client osdc; - /* msg pools */ - struct ceph_msg_pool msgpool_statfs_reply; - /* writeback */ mempool_t *wb_pagevec_pool; struct workqueue_struct *wb_wq;