From a73ec380d748b00b67286889dcee24bc36c709eb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 10 Aug 2009 15:31:17 -0700 Subject: [PATCH] kclient: specify incoming message allocation function --- src/kernel/messenger.c | 2 +- src/kernel/messenger.h | 4 ++++ src/kernel/super.c | 19 ++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/kernel/messenger.c b/src/kernel/messenger.c index ce3ca15985000..80db6d20a2315 100644 --- a/src/kernel/messenger.c +++ b/src/kernel/messenger.c @@ -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; diff --git a/src/kernel/messenger.h b/src/kernel/messenger.h index 7c8fdd44d4923..974dcaff2b815 100644 --- a/src/kernel/messenger.h +++ b/src/kernel/messenger.h @@ -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 */ diff --git a/src/kernel/super.c b/src/kernel/super.c index 30c5e767b8cd9..11e0a1a2cffb8 100644 --- a/src/kernel/super.c +++ b/src/kernel/super.c @@ -24,9 +24,10 @@ * 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. * -- 2.39.5