]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use msgpools for other monc messages
authorSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 20:08:25 +0000 (13:08 -0700)
committerSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 20:08:25 +0000 (13:08 -0700)
src/kernel/mon_client.c
src/kernel/mon_client.h
src/kernel/super.c
src/kernel/super.h

index 2a9df9b00956a75ad5178fe8bf55e523e60d6786..1c1decc098dcc66de47a65c0c66a811580afd350 100644 (file)
@@ -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);
 }
index d2d87dc5c660c4376732fb0dcb2733c955395a33..f6a2346feae78783cf600ce08b94d03690974a34 100644 (file)
@@ -1,10 +1,12 @@
 #ifndef _FS_CEPH_MON_CLIENT_H
 #define _FS_CEPH_MON_CLIENT_H
 
-#include "messenger.h"
 #include <linux/completion.h>
 #include <linux/radix-tree.h>
 
+#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;
index 6a2f93f91b8a7043b7be28d15c3c20dc27140bdc..8390da62cbd4b6f81fad95b49624c0263bb10b70 100644 (file)
@@ -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);
index 2e0560802a0a2cde78ba554bed41aa35989a40a1..2753b10a4df388222f2fe58d4882569a60562731 100644 (file)
@@ -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;