]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: specify incoming message allocation function
authorSage Weil <sage@newdream.net>
Mon, 10 Aug 2009 22:31:17 +0000 (15:31 -0700)
committerSage Weil <sage@newdream.net>
Mon, 10 Aug 2009 22:31:17 +0000 (15:31 -0700)
src/kernel/messenger.c
src/kernel/messenger.h
src/kernel/super.c

index ce3ca159850004aaa4928ab910bde02dfa279123..80db6d20a23158de97d0efaeb47f8edcebab90b6 100644 (file)
@@ -1424,7 +1424,7 @@ static int read_partial_message(struct ceph_connection *con)
             con->in_hdr.type, con->in_hdr.front_len, con->in_hdr.data_len);
 
        /* allocate message */
-       con->in_msg = ceph_msg_new(0, front_len, 0, 0, NULL);
+       con->in_msg = con->msgr->alloc_msg(con->msgr->parent, &con->in_hdr);
        if (IS_ERR(con->in_msg)) {
                ret = PTR_ERR(con->in_msg);
                con->in_msg = NULL;
index 7c8fdd44d4923d8655439b8e0d21971a3ff8b35a..974dcaff2b815e70de2ad10c989f6c8d9a6d89fe 100644 (file)
@@ -36,6 +36,9 @@ typedef int (*ceph_msgr_prepare_pages_t) (void *p, struct ceph_msg *m,
 typedef void (*ceph_msgr_peer_reset_t) (void *p, struct ceph_entity_addr *addr,
                                        struct ceph_entity_name *pn);
 
+typedef struct ceph_msg * (*ceph_msgr_alloc_msg_t) (void *p,
+                                           struct ceph_msg_header *hdr);
+
 static inline const char *ceph_name_type_str(int t)
 {
        switch (t) {
@@ -60,6 +63,7 @@ struct ceph_messenger {
        ceph_msgr_dispatch_t dispatch;
        ceph_msgr_peer_reset_t peer_reset;
        ceph_msgr_prepare_pages_t prepare_pages;
+       ceph_msgr_alloc_msg_t alloc_msg;
 
        struct ceph_entity_inst inst;    /* my name+address */
 
index 30c5e767b8cd9d6893be9cb58fd100f94cdeebe9..11e0a1a2cffb8bc14c12648f20a9eafcef6d7c84 100644 (file)
  * types to appropriate handlers and subsystems.
  */
 
-void ceph_dispatch(void *p, struct ceph_msg *msg);
-void ceph_peer_reset(void *p, struct ceph_entity_addr *peer_addr,
-                    struct ceph_entity_name *peer_name);
+static void ceph_dispatch(void *p, struct ceph_msg *msg);
+static void ceph_peer_reset(void *p, struct ceph_entity_addr *peer_addr,
+                           struct ceph_entity_name *peer_name);
+static struct ceph_msg *ceph_alloc_msg(void *p, struct ceph_msg_header *hdr);
 
 /*
  * find filename portion of a path (/foo/bar/baz -> baz)
@@ -820,6 +821,7 @@ static int ceph_mount(struct ceph_client *client, struct vfsmount *mnt,
                client->msgr->dispatch = ceph_dispatch;
                client->msgr->prepare_pages = ceph_osdc_prepare_pages;
                client->msgr->peer_reset = ceph_peer_reset;
+               client->msgr->alloc_msg = ceph_alloc_msg;
        }
 
        /* send mount request, and wait for mon, mds, and osd maps */
@@ -896,6 +898,17 @@ out:
 }
 
 
+/*
+ * Allocate incoming message.
+ */
+static struct ceph_msg *ceph_alloc_msg(void *p, struct ceph_msg_header *hdr)
+{
+       int type = le32_to_cpu(hdr->type);
+       int front_len = le32_to_cpu(hdr->front_len);
+
+       return ceph_msg_new(type, front_len, 0, 0, NULL);
+}
+
 /*
  * Process an incoming message.
  *