Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
[cascardo/linux.git] / fs / ceph / mds_client.c
index 56da380..4f22671 100644 (file)
@@ -365,9 +365,9 @@ void ceph_put_mds_session(struct ceph_mds_session *s)
             atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
        if (atomic_dec_and_test(&s->s_ref)) {
                if (s->s_auth.authorizer)
-                    s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer(
-                            s->s_mdsc->fsc->client->monc.auth,
-                            s->s_auth.authorizer);
+                       ceph_auth_destroy_authorizer(
+                               s->s_mdsc->fsc->client->monc.auth,
+                               s->s_auth.authorizer);
                kfree(s);
        }
 }
@@ -1721,8 +1721,12 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
        msg->front.iov_len = p - msg->front.iov_base;
        msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
 
-       msg->pages = req->r_pages;
-       msg->page_count = req->r_num_pages;
+       if (req->r_data_len) {
+               /* outbound data set only by ceph_sync_setxattr() */
+               BUG_ON(!req->r_pages);
+               ceph_msg_data_add_pages(msg, req->r_pages, req->r_data_len, 0);
+       }
+
        msg->hdr.data_len = cpu_to_le32(req->r_data_len);
        msg->hdr.data_off = cpu_to_le16(0);
 
@@ -1916,6 +1920,7 @@ static void __wake_requests(struct ceph_mds_client *mdsc,
                req = list_entry(tmp_list.next,
                                 struct ceph_mds_request, r_wait);
                list_del_init(&req->r_wait);
+               dout(" wake request %p tid %llu\n", req, req->r_tid);
                __do_request(mdsc, req);
        }
 }
@@ -2029,20 +2034,16 @@ out:
 }
 
 /*
- * Invalidate dir I_COMPLETE, dentry lease state on an aborted MDS
+ * Invalidate dir's completeness, dentry lease state on an aborted MDS
  * namespace request.
  */
 void ceph_invalidate_dir_request(struct ceph_mds_request *req)
 {
        struct inode *inode = req->r_locked_dir;
-       struct ceph_inode_info *ci = ceph_inode(inode);
 
-       dout("invalidate_dir_request %p (I_COMPLETE, lease(s))\n", inode);
-       spin_lock(&ci->i_ceph_lock);
-       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
-       ci->i_release_count++;
-       spin_unlock(&ci->i_ceph_lock);
+       dout("invalidate_dir_request %p (complete, lease(s))\n", inode);
 
+       ceph_dir_clear_complete(inode);
        if (req->r_dentry)
                ceph_invalidate_dentry_lease(req->r_dentry);
        if (req->r_old_dentry)
@@ -2602,11 +2603,13 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
                        goto fail;
        }
 
-       reply->pagelist = pagelist;
-       reply->pagelist_count = calc_pages_for(0, pagelist->length);
        if (recon_state.flock)
                reply->hdr.version = cpu_to_le16(2);
-       reply->hdr.data_len = cpu_to_le32(pagelist->length);
+       if (pagelist->length) {
+               /* set up outbound data if we have any */
+               reply->hdr.data_len = cpu_to_le32(pagelist->length);
+               ceph_msg_data_add_pagelist(reply, pagelist);
+       }
        ceph_con_send(&session->s_con, reply);
 
        mutex_unlock(&session->s_mutex);
@@ -3436,13 +3439,17 @@ static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
        struct ceph_auth_handshake *auth = &s->s_auth;
 
        if (force_new && auth->authorizer) {
-               if (ac->ops && ac->ops->destroy_authorizer)
-                       ac->ops->destroy_authorizer(ac, auth->authorizer);
+               ceph_auth_destroy_authorizer(ac, auth->authorizer);
                auth->authorizer = NULL;
        }
-       if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) {
-               int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
-                                                       auth);
+       if (!auth->authorizer) {
+               int ret = ceph_auth_create_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
+                                                     auth);
+               if (ret)
+                       return ERR_PTR(ret);
+       } else {
+               int ret = ceph_auth_update_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
+                                                     auth);
                if (ret)
                        return ERR_PTR(ret);
        }
@@ -3458,7 +3465,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len)
        struct ceph_mds_client *mdsc = s->s_mdsc;
        struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
 
-       return ac->ops->verify_authorizer_reply(ac, s->s_auth.authorizer, len);
+       return ceph_auth_verify_authorizer_reply(ac, s->s_auth.authorizer, len);
 }
 
 static int invalidate_authorizer(struct ceph_connection *con)
@@ -3467,12 +3474,32 @@ static int invalidate_authorizer(struct ceph_connection *con)
        struct ceph_mds_client *mdsc = s->s_mdsc;
        struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
 
-       if (ac->ops->invalidate_authorizer)
-               ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_MDS);
+       ceph_auth_invalidate_authorizer(ac, CEPH_ENTITY_TYPE_MDS);
 
        return ceph_monc_validate_auth(&mdsc->fsc->client->monc);
 }
 
+static struct ceph_msg *mds_alloc_msg(struct ceph_connection *con,
+                               struct ceph_msg_header *hdr, int *skip)
+{
+       struct ceph_msg *msg;
+       int type = (int) le16_to_cpu(hdr->type);
+       int front_len = (int) le32_to_cpu(hdr->front_len);
+
+       if (con->in_msg)
+               return con->in_msg;
+
+       *skip = 0;
+       msg = ceph_msg_new(type, front_len, GFP_NOFS, false);
+       if (!msg) {
+               pr_err("unable to allocate msg type %d len %d\n",
+                      type, front_len);
+               return NULL;
+       }
+
+       return msg;
+}
+
 static const struct ceph_connection_operations mds_con_ops = {
        .get = con_get,
        .put = con_put,
@@ -3481,6 +3508,7 @@ static const struct ceph_connection_operations mds_con_ops = {
        .verify_authorizer_reply = verify_authorizer_reply,
        .invalidate_authorizer = invalidate_authorizer,
        .peer_reset = peer_reset,
+       .alloc_msg = mds_alloc_msg,
 };
 
 /* eof */