]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: fix msgpool reservation leak
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 15 Dec 2009 01:00:40 +0000 (17:00 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 15 Dec 2009 01:00:40 +0000 (17:00 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
fs/ceph/osd_client.c
fs/ceph/osd_client.h

index 67ef8ab06af4cf459385c30d7d412561787e765e..194b695f601e3c0a71a1df20be30aea7b1a4e446 100644 (file)
@@ -145,6 +145,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
                ceph_osdc_put_request(req);
                return ERR_PTR(-ENOMEM);
        }
+       req->r_num_prealloc_reply = num_reply;
 
        req->r_osdc = osdc;
        req->r_mempool = use_mempool;
@@ -165,7 +166,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
        else
                msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
        if (IS_ERR(msg)) {
-               ceph_msgpool_resv(&osdc->msgpool_op_reply, num_reply);
+               ceph_msgpool_resv(&osdc->msgpool_op_reply, -num_reply);
                ceph_osdc_put_request(req);
                return ERR_PTR(PTR_ERR(msg));
        }
@@ -465,6 +466,8 @@ static void __unregister_request(struct ceph_osd_client *osdc,
        rb_erase(&req->r_node, &osdc->requests);
        osdc->num_requests--;
 
+       ceph_msgpool_resv(&osdc->msgpool_op_reply, -req->r_num_prealloc_reply);
+
        if (req->r_osd) {
                /* make sure the original request isn't in flight. */
                ceph_con_revoke(&req->r_osd->o_con, req->r_request);
@@ -746,8 +749,9 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
 
        /* either this is a read, or we got the safe response */
        if ((flags & CEPH_OSD_FLAG_ONDISK) ||
-           ((flags & CEPH_OSD_FLAG_WRITE) == 0))
+           ((flags & CEPH_OSD_FLAG_WRITE) == 0)) {
                __unregister_request(osdc, req);
+       }
 
        mutex_unlock(&osdc->request_mutex);
 
index 20ee61847416e830288759d3e22098726eaab881..2e4cfd1e9f1079b45e717aed668bdaa781957bfe 100644 (file)
@@ -48,6 +48,7 @@ struct ceph_osd_request {
        int               r_flags;     /* any additional flags for the osd */
        u32               r_sent;      /* >0 if r_request is sending/sent */
        int r_prepared_pages, r_got_reply;
+       int               r_num_prealloc_reply;
 
        struct ceph_osd_client *r_osdc;
        struct kref       r_kref;