aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-01 19:00:14 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:18 -0400
commit1d866d1c31110db177cbd0636b95c4cb32ca2c6e (patch)
treea9d7c4b4ac31bbe2be7b084bfd51a8e9cb625c03 /net
parent41766f87f54cc8bef023b4b0550f48753959345a (diff)
libceph: drop mutex while allocating a message
In ceph_con_in_msg_alloc(), if no alloc_msg method is defined for a connection a new message is allocated with ceph_msg_new(). Drop the mutex before making this call, and make sure we're still connected when we get it back again. This is preparing for the next patch, which ensures all connections define an alloc_msg method, and then handles them all the same way. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Greg Farnum <greg@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 0f9933a5a8b0..6ec6051e1672 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2807,13 +2807,12 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
2807 int type = le16_to_cpu(hdr->type); 2807 int type = le16_to_cpu(hdr->type);
2808 int front_len = le32_to_cpu(hdr->front_len); 2808 int front_len = le32_to_cpu(hdr->front_len);
2809 int middle_len = le32_to_cpu(hdr->middle_len); 2809 int middle_len = le32_to_cpu(hdr->middle_len);
2810 struct ceph_msg *msg;
2810 int ret = 0; 2811 int ret = 0;
2811 2812
2812 BUG_ON(con->in_msg != NULL); 2813 BUG_ON(con->in_msg != NULL);
2813 2814
2814 if (con->ops->alloc_msg) { 2815 if (con->ops->alloc_msg) {
2815 struct ceph_msg *msg;
2816
2817 mutex_unlock(&con->mutex); 2816 mutex_unlock(&con->mutex);
2818 msg = con->ops->alloc_msg(con, hdr, skip); 2817 msg = con->ops->alloc_msg(con, hdr, skip);
2819 mutex_lock(&con->mutex); 2818 mutex_lock(&con->mutex);
@@ -2838,12 +2837,19 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
2838 } 2837 }
2839 } 2838 }
2840 if (!con->in_msg) { 2839 if (!con->in_msg) {
2841 con->in_msg = ceph_msg_new(type, front_len, GFP_NOFS, false); 2840 mutex_unlock(&con->mutex);
2842 if (!con->in_msg) { 2841 msg = ceph_msg_new(type, front_len, GFP_NOFS, false);
2842 mutex_lock(&con->mutex);
2843 if (!msg) {
2843 pr_err("unable to allocate msg type %d len %d\n", 2844 pr_err("unable to allocate msg type %d len %d\n",
2844 type, front_len); 2845 type, front_len);
2845 return -ENOMEM; 2846 return -ENOMEM;
2846 } 2847 }
2848 if (con->state != CON_STATE_OPEN) {
2849 ceph_msg_put(msg);
2850 return -EAGAIN;
2851 }
2852 con->in_msg = msg;
2847 con->in_msg->con = con->ops->get(con); 2853 con->in_msg->con = con->ops->get(con);
2848 BUG_ON(con->in_msg->con == NULL); 2854 BUG_ON(con->in_msg->con == NULL);
2849 con->in_msg->page_alignment = le16_to_cpu(hdr->data_off); 2855 con->in_msg->page_alignment = le16_to_cpu(hdr->data_off);