]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - fs/ceph/mon_client.c
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[mirror_ubuntu-zesty-kernel.git] / fs / ceph / mon_client.c
index 542276e60798af19c8acdc31c024175c9e23091f..8fdc011ca956c64e5feb33285ff989fa8d792bdd 100644 (file)
@@ -1,6 +1,7 @@
 #include "ceph_debug.h"
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/sched.h>
 
@@ -95,6 +96,18 @@ int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
        return 0;
 }
 
+/*
+ * Send an auth request.
+ */
+static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
+{
+       monc->pending_auth = 1;
+       monc->m_auth->front.iov_len = len;
+       monc->m_auth->hdr.front_len = cpu_to_le32(len);
+       ceph_msg_get(monc->m_auth);  /* keep our ref */
+       ceph_con_send(monc->con, monc->m_auth);
+}
+
 /*
  * Close monitor session, if any.
  */
@@ -137,10 +150,7 @@ static int __open_session(struct ceph_mon_client *monc)
                ret = ceph_auth_build_hello(monc->auth,
                                            monc->m_auth->front.iov_base,
                                            monc->m_auth->front_max);
-               monc->m_auth->front.iov_len = ret;
-               monc->m_auth->hdr.front_len = cpu_to_le32(ret);
-               ceph_msg_get(monc->m_auth);  /* keep our ref */
-               ceph_con_send(monc->con, monc->m_auth);
+               __send_prepared_auth_request(monc, ret);
        } else {
                dout("open_session mon%d already open\n", monc->cur_mon);
        }
@@ -507,11 +517,9 @@ static void delayed_work(struct work_struct *work)
                __open_session(monc);  /* continue hunting */
        } else {
                ceph_con_keepalive(monc->con);
-               mutex_unlock(&monc->mutex);
 
                __validate_auth(monc);
 
-               mutex_lock(&monc->mutex);
                if (monc->auth->ops->is_authenticated(monc->auth))
                        __send_subscribe(monc);
        }
@@ -650,16 +658,6 @@ void ceph_monc_stop(struct ceph_mon_client *monc)
        kfree(monc->monmap);
 }
 
-static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
-{
-       monc->pending_auth = 1;
-       monc->m_auth->front.iov_len = len;
-       monc->m_auth->hdr.front_len = cpu_to_le32(len);
-       ceph_msg_get(monc->m_auth);  /* keep our ref */
-       ceph_con_send(monc->con, monc->m_auth);
-}
-
-
 static void handle_auth_reply(struct ceph_mon_client *monc,
                              struct ceph_msg *msg)
 {
@@ -766,7 +764,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
        struct ceph_mon_client *monc = con->private;
        int type = le16_to_cpu(hdr->type);
        int front_len = le32_to_cpu(hdr->front_len);
-       struct ceph_msg *m;
+       struct ceph_msg *m = NULL;
 
        *skip = 0;
 
@@ -780,13 +778,17 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
        case CEPH_MSG_AUTH_REPLY:
                m = ceph_msgpool_get(&monc->msgpool_auth_reply, front_len);
                break;
-       default:
-               return NULL;
+       case CEPH_MSG_MON_MAP:
+       case CEPH_MSG_MDS_MAP:
+       case CEPH_MSG_OSD_MAP:
+               m = ceph_msg_new(type, front_len, 0, 0, NULL);
+               break;
        }
 
-       if (!m)
+       if (!m) {
+               pr_info("alloc_msg unknown type %d\n", type);
                *skip = 1;
-
+       }
        return m;
 }