Skip to contentSkip to conversation

rbd: don't put snap_context twice in rbd_queue_workfn()

PATCH In review Ilya Dryomov 2 participants 2 messages Dec 1, 2015

Subsystems (2)
lore
Share & tools
lore

Ilya Dryomov

author maintainer
#0 lore raw

PATCH 1/1 rbd: don't put snap_context twice in rbd_queue_workfn()

Commit 4e752f0ab0e8 ("rbd: access snapshot context and mapping size safely") moved ceph_get_snap_context() out of rbd_img_request_create() and into rbd_queue_workfn(), adding a ceph_put_snap_context() to the error path in rbd_queue_workfn(). However, rbd_img_request_create() consumes a ref on snapc, so calling ceph_put_snap_context() after a successful rbd_img_request_create() leads to an extra put. Fix it.

---
 drivers/block/rbd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/rbd.c +1 -0
index 24a757e97d56..4a876785b68c 100644
@@ -3442,6 +3442,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 		goto err_rq;
 	}
 	img_request->rq = rq;
+	snapc = NULL; /* img_request consumes a ref */
 
 	if (op_type == OBJ_OP_DISCARD)
 		result = rbd_img_request_fill(img_request, OBJ_REQUEST_NODATA,
Signature · 1 line
2.4.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ilya Dryomov

Commit 4e752f0ab0e8 ("rbd: access snapshot context and mapping size safely") moved ceph_get_snap_context() out of rbd_img_request_create() and into rbd_queue_workfn(), adding a ceph_put_snap_context() to the error path in rbd_queue_workfn(). However, rbd_img_request_create() consumes a ref on snapc, so calling ceph_put_snap_context() after a successful rbd_img_request_create() leads to an extra put. Fix it.

Whoops!

Quoted 16 lines
  drivers/block/rbd.c | 1 +
  1 file changed, 1 insertion(+)
drivers/block/rbd.c +1 -0
index 24a757e97d56..4a876785b68c 100644
@@ -3442,6 +3442,7 @@ static void rbd_queue_workfn(struct work_struct *work)
  		goto err_rq;
  	}
  	img_request->rq = rq;
+	snapc = NULL; /* img_request consumes a ref */
 
  	if (op_type == OBJ_OP_DISCARD)
  		result = rbd_img_request_fill(img_request, OBJ_REQUEST_NODATA,