Commit 679a97d2 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Ilya Dryomov

rbd: kill img_request kref

The reference counter is never increased, so we can as well call
rbd_img_request_destroy() directly and drop the kref.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent bbb480ab
...@@ -349,7 +349,6 @@ struct rbd_img_request { ...@@ -349,7 +349,6 @@ struct rbd_img_request {
struct pending_result pending; struct pending_result pending;
struct work_struct work; struct work_struct work;
int work_result; int work_result;
struct kref kref;
}; };
#define for_each_obj_request(ireq, oreq) \ #define for_each_obj_request(ireq, oreq) \
...@@ -1320,15 +1319,6 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request) ...@@ -1320,15 +1319,6 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request)
kref_put(&obj_request->kref, rbd_obj_request_destroy); kref_put(&obj_request->kref, rbd_obj_request_destroy);
} }
static void rbd_img_request_destroy(struct kref *kref);
static void rbd_img_request_put(struct rbd_img_request *img_request)
{
rbd_assert(img_request != NULL);
dout("%s: img %p (was %d)\n", __func__, img_request,
kref_read(&img_request->kref));
kref_put(&img_request->kref, rbd_img_request_destroy);
}
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)
{ {
...@@ -1656,19 +1646,15 @@ static struct rbd_img_request *rbd_img_request_create( ...@@ -1656,19 +1646,15 @@ static struct rbd_img_request *rbd_img_request_create(
INIT_LIST_HEAD(&img_request->lock_item); INIT_LIST_HEAD(&img_request->lock_item);
INIT_LIST_HEAD(&img_request->object_extents); INIT_LIST_HEAD(&img_request->object_extents);
mutex_init(&img_request->state_mutex); mutex_init(&img_request->state_mutex);
kref_init(&img_request->kref);
return img_request; return img_request;
} }
static void rbd_img_request_destroy(struct kref *kref) static void rbd_img_request_destroy(struct rbd_img_request *img_request)
{ {
struct rbd_img_request *img_request;
struct rbd_obj_request *obj_request; struct rbd_obj_request *obj_request;
struct rbd_obj_request *next_obj_request; struct rbd_obj_request *next_obj_request;
img_request = container_of(kref, struct rbd_img_request, kref);
dout("%s: img %p\n", __func__, img_request); dout("%s: img %p\n", __func__, img_request);
WARN_ON(!list_empty(&img_request->lock_item)); WARN_ON(!list_empty(&img_request->lock_item));
...@@ -2885,7 +2871,7 @@ static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) ...@@ -2885,7 +2871,7 @@ static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req)
obj_req->copyup_bvecs); obj_req->copyup_bvecs);
} }
if (ret) { if (ret) {
rbd_img_request_put(child_img_req); rbd_img_request_destroy(child_img_req);
return ret; return ret;
} }
...@@ -3644,7 +3630,7 @@ static void rbd_img_handle_request(struct rbd_img_request *img_req, int result) ...@@ -3644,7 +3630,7 @@ static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
if (test_bit(IMG_REQ_CHILD, &img_req->flags)) { if (test_bit(IMG_REQ_CHILD, &img_req->flags)) {
struct rbd_obj_request *obj_req = img_req->obj_request; struct rbd_obj_request *obj_req = img_req->obj_request;
rbd_img_request_put(img_req); rbd_img_request_destroy(img_req);
if (__rbd_obj_handle_request(obj_req, &result)) { if (__rbd_obj_handle_request(obj_req, &result)) {
img_req = obj_req->img_request; img_req = obj_req->img_request;
goto again; goto again;
...@@ -3652,7 +3638,7 @@ static void rbd_img_handle_request(struct rbd_img_request *img_req, int result) ...@@ -3652,7 +3638,7 @@ static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
} else { } else {
struct request *rq = img_req->rq; struct request *rq = img_req->rq;
rbd_img_request_put(img_req); rbd_img_request_destroy(img_req);
blk_mq_end_request(rq, errno_to_blk_status(result)); blk_mq_end_request(rq, errno_to_blk_status(result));
} }
} }
...@@ -4798,7 +4784,7 @@ static void rbd_queue_workfn(struct work_struct *work) ...@@ -4798,7 +4784,7 @@ static void rbd_queue_workfn(struct work_struct *work)
return; return;
err_img_request: err_img_request:
rbd_img_request_put(img_request); rbd_img_request_destroy(img_request);
err_rq: err_rq:
if (result) if (result)
rbd_warn(rbd_dev, "%s %llx at %llx result %d", rbd_warn(rbd_dev, "%s %llx at %llx result %d",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment