提交 25dcf954 编写于 作者: A Alex Elder 提交者: Sage Weil

rbd: decrement obj request count when deleting

Decrement the obj_request_count value when deleting an object
request from its image request's list.  Rearrange a few lines
in the surrounding code.

This resolves:
    http://tracker.ceph.com/issues/3940Signed-off-by: NAlex Elder <elder@inktank.com>
Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
上级 975241af
...@@ -1063,22 +1063,29 @@ static void rbd_img_request_put(struct rbd_img_request *img_request) ...@@ -1063,22 +1063,29 @@ static void rbd_img_request_put(struct rbd_img_request *img_request)
static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request,
struct rbd_obj_request *obj_request) struct rbd_obj_request *obj_request)
{ {
rbd_assert(obj_request->img_request == NULL);
rbd_obj_request_get(obj_request); rbd_obj_request_get(obj_request);
obj_request->img_request = img_request; obj_request->img_request = img_request;
list_add_tail(&obj_request->links, &img_request->obj_requests); obj_request->which = img_request->obj_request_count;
obj_request->which = img_request->obj_request_count++;
rbd_assert(obj_request->which != BAD_WHICH); rbd_assert(obj_request->which != BAD_WHICH);
img_request->obj_request_count++;
list_add_tail(&obj_request->links, &img_request->obj_requests);
} }
static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request,
struct rbd_obj_request *obj_request) struct rbd_obj_request *obj_request)
{ {
rbd_assert(obj_request->which != BAD_WHICH); rbd_assert(obj_request->which != BAD_WHICH);
obj_request->which = BAD_WHICH;
list_del(&obj_request->links); list_del(&obj_request->links);
rbd_assert(img_request->obj_request_count > 0);
img_request->obj_request_count--;
rbd_assert(obj_request->which == img_request->obj_request_count);
obj_request->which = BAD_WHICH;
rbd_assert(obj_request->img_request == img_request); rbd_assert(obj_request->img_request == img_request);
obj_request->callback = NULL;
obj_request->img_request = NULL; obj_request->img_request = NULL;
obj_request->callback = NULL;
rbd_obj_request_put(obj_request); rbd_obj_request_put(obj_request);
} }
...@@ -1472,6 +1479,7 @@ static void rbd_img_request_destroy(struct kref *kref) ...@@ -1472,6 +1479,7 @@ static void rbd_img_request_destroy(struct kref *kref)
for_each_obj_request_safe(img_request, obj_request, next_obj_request) for_each_obj_request_safe(img_request, obj_request, next_obj_request)
rbd_img_obj_request_del(img_request, obj_request); rbd_img_obj_request_del(img_request, obj_request);
rbd_assert(img_request->obj_request_count == 0);
if (img_request->write_request) if (img_request->write_request)
ceph_put_snap_context(img_request->snapc); ceph_put_snap_context(img_request->snapc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册