Skip to content

Commit 679a97d

Browse files
hreineckeidryomov
authored andcommitted
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: Hannes Reinecke <hare@suse.de> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent bbb480a commit 679a97d

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

‎drivers/block/rbd.c‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ struct rbd_img_request {
349349
struct pending_result pending;
350350
struct work_struct work;
351351
int work_result;
352-
struct kref kref;
353352
};
354353

355354
#define for_each_obj_request(ireq, oreq) \
@@ -1320,15 +1319,6 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request)
13201319
kref_put(&obj_request->kref, rbd_obj_request_destroy);
13211320
}
13221321

1323-
static void rbd_img_request_destroy(struct kref *kref);
1324-
static void rbd_img_request_put(struct rbd_img_request *img_request)
1325-
{
1326-
rbd_assert(img_request != NULL);
1327-
dout("%s: img %p (was %d)\n", __func__, img_request,
1328-
kref_read(&img_request->kref));
1329-
kref_put(&img_request->kref, rbd_img_request_destroy);
1330-
}
1331-
13321322
static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request,
13331323
struct rbd_obj_request *obj_request)
13341324
{
@@ -1656,19 +1646,15 @@ static struct rbd_img_request *rbd_img_request_create(
16561646
INIT_LIST_HEAD(&img_request->lock_item);
16571647
INIT_LIST_HEAD(&img_request->object_extents);
16581648
mutex_init(&img_request->state_mutex);
1659-
kref_init(&img_request->kref);
16601649

16611650
return img_request;
16621651
}
16631652

1664-
static void rbd_img_request_destroy(struct kref *kref)
1653+
static void rbd_img_request_destroy(struct rbd_img_request *img_request)
16651654
{
1666-
struct rbd_img_request *img_request;
16671655
struct rbd_obj_request *obj_request;
16681656
struct rbd_obj_request *next_obj_request;
16691657

1670-
img_request = container_of(kref, struct rbd_img_request, kref);
1671-
16721658
dout("%s: img %p\n", __func__, img_request);
16731659

16741660
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)
28852871
obj_req->copyup_bvecs);
28862872
}
28872873
if (ret) {
2888-
rbd_img_request_put(child_img_req);
2874+
rbd_img_request_destroy(child_img_req);
28892875
return ret;
28902876
}
28912877

@@ -3644,15 +3630,15 @@ static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
36443630
if (test_bit(IMG_REQ_CHILD, &img_req->flags)) {
36453631
struct rbd_obj_request *obj_req = img_req->obj_request;
36463632

3647-
rbd_img_request_put(img_req);
3633+
rbd_img_request_destroy(img_req);
36483634
if (__rbd_obj_handle_request(obj_req, &result)) {
36493635
img_req = obj_req->img_request;
36503636
goto again;
36513637
}
36523638
} else {
36533639
struct request *rq = img_req->rq;
36543640

3655-
rbd_img_request_put(img_req);
3641+
rbd_img_request_destroy(img_req);
36563642
blk_mq_end_request(rq, errno_to_blk_status(result));
36573643
}
36583644
}
@@ -4798,7 +4784,7 @@ static void rbd_queue_workfn(struct work_struct *work)
47984784
return;
47994785

48004786
err_img_request:
4801-
rbd_img_request_put(img_request);
4787+
rbd_img_request_destroy(img_request);
48024788
err_rq:
48034789
if (result)
48044790
rbd_warn(rbd_dev, "%s %llx at %llx result %d",

0 commit comments

Comments
 (0)