diff options
author | Sage Weil <sage@newdream.net> | 2010-05-21 17:57:25 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-21 19:26:11 -0400 |
commit | 240ed68eb567d80dd6bab739341999a5ab0ad55d (patch) | |
tree | fabd30d0897a30fa401f85e858f8aecdedb02959 /fs/ceph/mon_client.c | |
parent | 970690012c572fc3b7be532080564b730f6a9c02 (diff) |
ceph: reuse mon subscribe message instead of allocated anew
Use the same message, allocated during startup. No need to reallocate a
new one each time around (and potentially ENOMEM).
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/mon_client.c')
-rw-r--r-- | fs/ceph/mon_client.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c index 12d94f24ee97..f6510a476e7e 100644 --- a/fs/ceph/mon_client.c +++ b/fs/ceph/mon_client.c | |||
@@ -188,16 +188,12 @@ static void __send_subscribe(struct ceph_mon_client *monc) | |||
188 | monc->want_next_osdmap); | 188 | monc->want_next_osdmap); |
189 | if ((__sub_expired(monc) && !monc->sub_sent) || | 189 | if ((__sub_expired(monc) && !monc->sub_sent) || |
190 | monc->want_next_osdmap == 1) { | 190 | monc->want_next_osdmap == 1) { |
191 | struct ceph_msg *msg; | 191 | struct ceph_msg *msg = monc->m_subscribe; |
192 | struct ceph_mon_subscribe_item *i; | 192 | struct ceph_mon_subscribe_item *i; |
193 | void *p, *end; | 193 | void *p, *end; |
194 | 194 | ||
195 | msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS); | ||
196 | if (!msg) | ||
197 | return; | ||
198 | |||
199 | p = msg->front.iov_base; | 195 | p = msg->front.iov_base; |
200 | end = p + msg->front.iov_len; | 196 | end = p + msg->front_max; |
201 | 197 | ||
202 | dout("__send_subscribe to 'mdsmap' %u+\n", | 198 | dout("__send_subscribe to 'mdsmap' %u+\n", |
203 | (unsigned)monc->have_mdsmap); | 199 | (unsigned)monc->have_mdsmap); |
@@ -227,7 +223,8 @@ static void __send_subscribe(struct ceph_mon_client *monc) | |||
227 | 223 | ||
228 | msg->front.iov_len = p - msg->front.iov_base; | 224 | msg->front.iov_len = p - msg->front.iov_base; |
229 | msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); | 225 | msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); |
230 | ceph_con_send(monc->con, msg); | 226 | ceph_con_revoke(monc->con, msg); |
227 | ceph_con_send(monc->con, ceph_msg_get(msg)); | ||
231 | 228 | ||
232 | monc->sub_sent = jiffies | 1; /* never 0 */ | 229 | monc->sub_sent = jiffies | 1; /* never 0 */ |
233 | } | 230 | } |
@@ -631,7 +628,7 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
631 | CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON | | 628 | CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON | |
632 | CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS; | 629 | CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS; |
633 | 630 | ||
634 | /* msg pools */ | 631 | /* msgs */ |
635 | err = -ENOMEM; | 632 | err = -ENOMEM; |
636 | monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, | 633 | monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, |
637 | sizeof(struct ceph_mon_subscribe_ack), | 634 | sizeof(struct ceph_mon_subscribe_ack), |
@@ -639,9 +636,13 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
639 | if (!monc->m_subscribe_ack) | 636 | if (!monc->m_subscribe_ack) |
640 | goto out_monmap; | 637 | goto out_monmap; |
641 | 638 | ||
639 | monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS); | ||
640 | if (!monc->m_subscribe) | ||
641 | goto out_subscribe_ack; | ||
642 | |||
642 | monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS); | 643 | monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS); |
643 | if (!monc->m_auth_reply) | 644 | if (!monc->m_auth_reply) |
644 | goto out_subscribe_ack; | 645 | goto out_subscribe; |
645 | 646 | ||
646 | monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS); | 647 | monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS); |
647 | monc->pending_auth = 0; | 648 | monc->pending_auth = 0; |
@@ -665,6 +666,8 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
665 | 666 | ||
666 | out_auth_reply: | 667 | out_auth_reply: |
667 | ceph_msg_put(monc->m_auth_reply); | 668 | ceph_msg_put(monc->m_auth_reply); |
669 | out_subscribe: | ||
670 | ceph_msg_put(monc->m_subscribe); | ||
668 | out_subscribe_ack: | 671 | out_subscribe_ack: |
669 | ceph_msg_put(monc->m_subscribe_ack); | 672 | ceph_msg_put(monc->m_subscribe_ack); |
670 | out_monmap: | 673 | out_monmap: |
@@ -691,6 +694,7 @@ void ceph_monc_stop(struct ceph_mon_client *monc) | |||
691 | 694 | ||
692 | ceph_msg_put(monc->m_auth); | 695 | ceph_msg_put(monc->m_auth); |
693 | ceph_msg_put(monc->m_auth_reply); | 696 | ceph_msg_put(monc->m_auth_reply); |
697 | ceph_msg_put(monc->m_subscribe); | ||
694 | ceph_msg_put(monc->m_subscribe_ack); | 698 | ceph_msg_put(monc->m_subscribe_ack); |
695 | 699 | ||
696 | kfree(monc->monmap); | 700 | kfree(monc->monmap); |