]> Pileus Git - ~andy/linux/blobdiff - net/ceph/osd_client.c
libceph: init sent and completed when starting
[~andy/linux] / net / ceph / osd_client.c
index c842e877d504adc1331238bbe0b578d2bea67e42..d5953b87918c072daaa1427187246f9f9cfcad3e 100644 (file)
@@ -22,6 +22,8 @@
 #define OSD_OP_FRONT_LEN       4096
 #define OSD_OPREPLY_FRONT_LEN  512
 
+static struct kmem_cache       *ceph_osd_request_cache;
+
 static const struct ceph_connection_operations osd_con_ops;
 
 static void __send_queued(struct ceph_osd_client *osdc);
@@ -214,6 +216,18 @@ void osd_req_op_cls_request_data_pagelist(
 }
 EXPORT_SYMBOL(osd_req_op_cls_request_data_pagelist);
 
+void osd_req_op_cls_request_data_pages(struct ceph_osd_request *osd_req,
+                       unsigned int which, struct page **pages, u64 length,
+                       u32 alignment, bool pages_from_pool, bool own_pages)
+{
+       struct ceph_osd_data *osd_data;
+
+       osd_data = osd_req_op_data(osd_req, which, cls, request_data);
+       ceph_osd_data_pages_init(osd_data, pages, length, alignment,
+                               pages_from_pool, own_pages);
+}
+EXPORT_SYMBOL(osd_req_op_cls_request_data_pages);
+
 void osd_req_op_cls_response_data_pages(struct ceph_osd_request *osd_req,
                        unsigned int which, struct page **pages, u64 length,
                        u32 alignment, bool pages_from_pool, bool own_pages)
@@ -303,7 +317,8 @@ void ceph_osdc_release_request(struct kref *kref)
        if (req->r_mempool)
                mempool_free(req, req->r_osdc->req_mempool);
        else
-               kfree(req);
+               kmem_cache_free(ceph_osd_request_cache, req);
+
 }
 EXPORT_SYMBOL(ceph_osdc_release_request);
 
@@ -334,7 +349,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
                req = mempool_alloc(osdc->req_mempool, gfp_flags);
                memset(req, 0, sizeof(*req));
        } else {
-               req = kzalloc(sizeof(*req), gfp_flags);
+               req = kmem_cache_zalloc(ceph_osd_request_cache, gfp_flags);
        }
        if (req == NULL)
                return NULL;
@@ -565,8 +580,7 @@ void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
        BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH);
 
        op->watch.cookie = cookie;
-       /* op->watch.ver = version; */  /* XXX 3847 */
-       op->watch.ver = cpu_to_le64(version);
+       op->watch.ver = version;
        if (opcode == CEPH_OSD_OP_WATCH && flag)
                op->watch.flag = (u8)1;
 }
@@ -1190,6 +1204,7 @@ void ceph_osdc_unregister_linger_request(struct ceph_osd_client *osdc,
        mutex_lock(&osdc->request_mutex);
        if (req->r_linger) {
                __unregister_linger_request(osdc, req);
+               req->r_linger = 0;
                ceph_osdc_put_request(req);
        }
        mutex_unlock(&osdc->request_mutex);
@@ -2106,7 +2121,9 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
        down_read(&osdc->map_sem);
        mutex_lock(&osdc->request_mutex);
        __register_request(osdc, req);
-       WARN_ON(req->r_sent);
+       req->r_sent = 0;
+       req->r_got_reply = 0;
+       req->r_completed = 0;
        rc = __map_request(osdc, req, 0);
        if (rc < 0) {
                if (nofail) {
@@ -2354,6 +2371,26 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
 }
 EXPORT_SYMBOL(ceph_osdc_writepages);
 
+int ceph_osdc_setup(void)
+{
+       BUG_ON(ceph_osd_request_cache);
+       ceph_osd_request_cache = kmem_cache_create("ceph_osd_request",
+                                       sizeof (struct ceph_osd_request),
+                                       __alignof__(struct ceph_osd_request),
+                                       0, NULL);
+
+       return ceph_osd_request_cache ? 0 : -ENOMEM;
+}
+EXPORT_SYMBOL(ceph_osdc_setup);
+
+void ceph_osdc_cleanup(void)
+{
+       BUG_ON(!ceph_osd_request_cache);
+       kmem_cache_destroy(ceph_osd_request_cache);
+       ceph_osd_request_cache = NULL;
+}
+EXPORT_SYMBOL(ceph_osdc_cleanup);
+
 /*
  * handle incoming message
  */