On Mon, Jul 1, 2019 at 7:28 AM Dongsheng Yang <dongsheng.yang@xxxxxxxxxxxx> wrote: > > > > On 06/25/2019 10:40 PM, Ilya Dryomov wrote: > > Start eliminating asymmetry where the initial OSD request is allocated > > and submitted from outside the state machine, making error handling and > > restarts harder than they could be. This commit deals with submission, > > a commit that deals with allocation will follow. > > > > Note that this commit adds parent chain recursion on the submission > > side: > > > > rbd_img_request_submit > > rbd_obj_handle_request > > __rbd_obj_handle_request > > rbd_obj_handle_read > > rbd_obj_handle_write_guard > > rbd_obj_read_from_parent > > rbd_img_request_submit > > > > This will be fixed in the next commit. > > > > Signed-off-by: Ilya Dryomov <idryomov@xxxxxxxxx> > > --- > > drivers/block/rbd.c | 60 ++++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 49 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > > index 488da877a2bb..9c6be82353c0 100644 > > --- a/drivers/block/rbd.c > > +++ b/drivers/block/rbd.c > > @@ -223,7 +223,8 @@ enum obj_operation_type { > > #define RBD_OBJ_FLAG_COPYUP_ENABLED (1U << 1) > > > > enum rbd_obj_read_state { > > - RBD_OBJ_READ_OBJECT = 1, > > + RBD_OBJ_READ_START = 1, > > + RBD_OBJ_READ_OBJECT, > > RBD_OBJ_READ_PARENT, > > }; > > > > @@ -253,7 +254,8 @@ enum rbd_obj_read_state { > > * even if there is a parent). > > */ > > enum rbd_obj_write_state { > > - RBD_OBJ_WRITE_OBJECT = 1, > > + RBD_OBJ_WRITE_START = 1, > > + RBD_OBJ_WRITE_OBJECT, > > RBD_OBJ_WRITE_READ_FROM_PARENT, > > RBD_OBJ_WRITE_COPYUP_EMPTY_SNAPC, > > RBD_OBJ_WRITE_COPYUP_OPS, > > @@ -284,6 +286,7 @@ struct rbd_obj_request { > > > > struct ceph_osd_request *osd_req; > > > > + struct mutex state_mutex; > > struct kref kref; > > }; > > > > @@ -1560,6 +1563,7 @@ static struct rbd_obj_request *rbd_obj_request_create(void) > > return NULL; > > > > ceph_object_extent_init(&obj_request->ex); > > + mutex_init(&obj_request->state_mutex); > > kref_init(&obj_request->kref); > > > > dout("%s %p\n", __func__, obj_request); > > @@ -1802,7 +1806,7 @@ static int rbd_obj_setup_read(struct rbd_obj_request *obj_req) > > rbd_osd_req_setup_data(obj_req, 0); > > > > rbd_osd_req_format_read(obj_req); > > - obj_req->read_state = RBD_OBJ_READ_OBJECT; > > + obj_req->read_state = RBD_OBJ_READ_START; > > return 0; > > } > > > > @@ -1885,7 +1889,7 @@ static int rbd_obj_setup_write(struct rbd_obj_request *obj_req) > > return ret; > > } > > > > - obj_req->write_state = RBD_OBJ_WRITE_OBJECT; > > + obj_req->write_state = RBD_OBJ_WRITE_START; > > __rbd_obj_setup_write(obj_req, which); > > return 0; > > } > > @@ -1943,7 +1947,7 @@ static int rbd_obj_setup_discard(struct rbd_obj_request *obj_req) > > off, next_off - off, 0, 0); > > } > > > > - obj_req->write_state = RBD_OBJ_WRITE_OBJECT; > > + obj_req->write_state = RBD_OBJ_WRITE_START; > > rbd_osd_req_format_write(obj_req); > > return 0; > > } > > @@ -2022,7 +2026,7 @@ static int rbd_obj_setup_zeroout(struct rbd_obj_request *obj_req) > > return ret; > > } > > > > - obj_req->write_state = RBD_OBJ_WRITE_OBJECT; > > + obj_req->write_state = RBD_OBJ_WRITE_START; > > __rbd_obj_setup_zeroout(obj_req, which); > > return 0; > > } > > @@ -2363,11 +2367,17 @@ static void rbd_img_request_submit(struct rbd_img_request *img_request) > > > > rbd_img_request_get(img_request); > > for_each_obj_request(img_request, obj_request) > > - rbd_obj_request_submit(obj_request); > > + rbd_obj_handle_request(obj_request, 0); > > > > rbd_img_request_put(img_request); > > } > > > > +static int rbd_obj_read_object(struct rbd_obj_request *obj_req) > > +{ > > + rbd_obj_request_submit(obj_req); > > + return 0; > always return 0? So if I understand it correctly, this function will be > filled by other operations in later commits, right? Correct. Thanks, Ilya