rbd: move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting

commit 09fe05c57b5aaf23e2c35036c98ea9f282b19a77 upstream.

Move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting into the object request
state machine to allow for the snapshot context to be captured in the
image request state machine rather than in rbd_queue_workfn().

Cc: stable@vger.kernel.org
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ilya Dryomov 2023-06-05 16:33:35 +02:00 committed by Greg Kroah-Hartman
parent 69653f9416
commit c6e8425550

View File

@ -1493,14 +1493,28 @@ static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req)
/* /*
* Must be called after rbd_obj_calc_img_extents(). * Must be called after rbd_obj_calc_img_extents().
*/ */
static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req) static void rbd_obj_set_copyup_enabled(struct rbd_obj_request *obj_req)
{ {
if (!obj_req->num_img_extents || if (obj_req->img_request->op_type == OBJ_OP_DISCARD) {
(rbd_obj_is_entire(obj_req) && dout("%s %p objno %llu discard\n", __func__, obj_req,
!obj_req->img_request->snapc->num_snaps)) obj_req->ex.oe_objno);
return false; return;
}
return true; if (!obj_req->num_img_extents) {
dout("%s %p objno %llu not overlapping\n", __func__, obj_req,
obj_req->ex.oe_objno);
return;
}
if (rbd_obj_is_entire(obj_req) &&
!obj_req->img_request->snapc->num_snaps) {
dout("%s %p objno %llu entire\n", __func__, obj_req,
obj_req->ex.oe_objno);
return;
}
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
} }
static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req)
@ -2389,9 +2403,6 @@ static int rbd_obj_init_write(struct rbd_obj_request *obj_req)
if (ret) if (ret)
return ret; return ret;
if (rbd_obj_copyup_enabled(obj_req))
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
obj_req->write_state = RBD_OBJ_WRITE_START; obj_req->write_state = RBD_OBJ_WRITE_START;
return 0; return 0;
} }
@ -2497,8 +2508,6 @@ static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req)
if (ret) if (ret)
return ret; return ret;
if (rbd_obj_copyup_enabled(obj_req))
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
if (!obj_req->num_img_extents) { if (!obj_req->num_img_extents) {
obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT;
if (rbd_obj_is_entire(obj_req)) if (rbd_obj_is_entire(obj_req))
@ -3439,6 +3448,7 @@ again:
case RBD_OBJ_WRITE_START: case RBD_OBJ_WRITE_START:
rbd_assert(!*result); rbd_assert(!*result);
rbd_obj_set_copyup_enabled(obj_req);
if (rbd_obj_write_is_noop(obj_req)) if (rbd_obj_write_is_noop(obj_req))
return true; return true;