Skip to content

Commit 09fe05c

Browse files
committed
rbd: move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting
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: [email protected] Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Dongsheng Yang <[email protected]>
1 parent 9561de3 commit 09fe05c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

drivers/block/rbd.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,14 +1334,28 @@ static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req)
13341334
/*
13351335
* Must be called after rbd_obj_calc_img_extents().
13361336
*/
1337-
static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req)
1337+
static void rbd_obj_set_copyup_enabled(struct rbd_obj_request *obj_req)
13381338
{
1339-
if (!obj_req->num_img_extents ||
1340-
(rbd_obj_is_entire(obj_req) &&
1341-
!obj_req->img_request->snapc->num_snaps))
1342-
return false;
1339+
if (obj_req->img_request->op_type == OBJ_OP_DISCARD) {
1340+
dout("%s %p objno %llu discard\n", __func__, obj_req,
1341+
obj_req->ex.oe_objno);
1342+
return;
1343+
}
13431344

1344-
return true;
1345+
if (!obj_req->num_img_extents) {
1346+
dout("%s %p objno %llu not overlapping\n", __func__, obj_req,
1347+
obj_req->ex.oe_objno);
1348+
return;
1349+
}
1350+
1351+
if (rbd_obj_is_entire(obj_req) &&
1352+
!obj_req->img_request->snapc->num_snaps) {
1353+
dout("%s %p objno %llu entire\n", __func__, obj_req,
1354+
obj_req->ex.oe_objno);
1355+
return;
1356+
}
1357+
1358+
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
13451359
}
13461360

13471361
static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req)
@@ -2233,9 +2247,6 @@ static int rbd_obj_init_write(struct rbd_obj_request *obj_req)
22332247
if (ret)
22342248
return ret;
22352249

2236-
if (rbd_obj_copyup_enabled(obj_req))
2237-
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
2238-
22392250
obj_req->write_state = RBD_OBJ_WRITE_START;
22402251
return 0;
22412252
}
@@ -2341,8 +2352,6 @@ static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req)
23412352
if (ret)
23422353
return ret;
23432354

2344-
if (rbd_obj_copyup_enabled(obj_req))
2345-
obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED;
23462355
if (!obj_req->num_img_extents) {
23472356
obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT;
23482357
if (rbd_obj_is_entire(obj_req))
@@ -3286,6 +3295,7 @@ static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result)
32863295
case RBD_OBJ_WRITE_START:
32873296
rbd_assert(!*result);
32883297

3298+
rbd_obj_set_copyup_enabled(obj_req);
32893299
if (rbd_obj_write_is_noop(obj_req))
32903300
return true;
32913301

0 commit comments

Comments
 (0)