libceph: isolate other message data fields
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ceph / mds_client.c
index 442880d099c939480583b3366eee9142e2d63d89..3b2aa8702ae0fa4adefb962dd9a07c15ddc18327 100644 (file)
@@ -265,7 +265,8 @@ static int parse_reply_info_extra(void **p, void *end,
 {
        if (info->head->op == CEPH_MDS_OP_GETFILELOCK)
                return parse_reply_info_filelock(p, end, info, features);
-       else if (info->head->op == CEPH_MDS_OP_READDIR)
+       else if (info->head->op == CEPH_MDS_OP_READDIR ||
+                info->head->op == CEPH_MDS_OP_LSSNAP)
                return parse_reply_info_dir(p, end, info, features);
        else if (info->head->op == CEPH_MDS_OP_CREATE)
                return parse_reply_info_create(p, end, info, features);
@@ -1196,6 +1197,8 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
        session->s_trim_caps--;
        if (oissued) {
                /* we aren't the only cap.. just remove us */
+               __queue_cap_release(session, ceph_ino(inode), cap->cap_id,
+                                   cap->mseq, cap->issue_seq);
                __ceph_remove_cap(cap);
        } else {
                /* try to drop referring dentries */
@@ -1718,8 +1721,8 @@ 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->nr_pages = req->r_num_pages;
+       ceph_msg_data_set_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);
 
@@ -1913,6 +1916,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);
        }
 }
@@ -2026,7 +2030,7 @@ out:
 }
 
 /*
- * Invalidate dir D_COMPLETE, dentry lease state on an aborted MDS
+ * Invalidate dir I_COMPLETE, dentry lease state on an aborted MDS
  * namespace request.
  */
 void ceph_invalidate_dir_request(struct ceph_mds_request *req)
@@ -2034,9 +2038,9 @@ 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 (D_COMPLETE, lease(s))\n", inode);
+       dout("invalidate_dir_request %p (I_COMPLETE, lease(s))\n", inode);
        spin_lock(&ci->i_ceph_lock);
-       ceph_dir_clear_complete(inode);
+       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
        ci->i_release_count++;
        spin_unlock(&ci->i_ceph_lock);
 
@@ -2599,11 +2603,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
                        goto fail;
        }
 
-       reply->pagelist = pagelist;
+       ceph_msg_data_set_pagelist(reply, pagelist);
        if (recon_state.flock)
                reply->hdr.version = cpu_to_le16(2);
        reply->hdr.data_len = cpu_to_le32(pagelist->length);
-       reply->nr_pages = calc_pages_for(0, pagelist->length);
        ceph_con_send(&session->s_con, reply);
 
        mutex_unlock(&session->s_mutex);
@@ -3470,6 +3473,27 @@ static int invalidate_authorizer(struct ceph_connection *con)
        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,
@@ -3478,6 +3502,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 */