On Fri, Mar 5, 2021 at 9:44 AM Chaitanya Kulkarni <Chaitanya.Kulkarni@xxxxxxx> wrote: > > On 3/4/21 03:14, Kanchan Joshi wrote: > > On Wed, Mar 3, 2021 at 8:52 PM Chaitanya Kulkarni > > <Chaitanya.Kulkarni@xxxxxxx> wrote: > >> On 3/2/21 23:22, Kanchan Joshi wrote: > >>> -void nvme_execute_passthru_rq(struct request *rq) > >>> +void nvme_execute_passthru_rq_common(struct request *rq, > >>> + rq_end_io_fn *done) > >>> { > >>> struct nvme_command *cmd = nvme_req(rq)->cmd; > >>> struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl; > >>> @@ -1135,9 +1136,17 @@ void nvme_execute_passthru_rq(struct request *rq) > >>> u32 effects; > >>> > >>> effects = nvme_passthru_start(ctrl, ns, cmd->common.opcode); > >>> - blk_execute_rq(disk, rq, 0); > >>> + if (!done) > >>> + blk_execute_rq(disk, rq, 0); > >>> + else > >>> + blk_execute_rq_nowait(disk, rq, 0, done); > >>> nvme_passthru_end(ctrl, effects); > >> This needs a detailed explanation in order to prove the correctness. > > Do you see something wrong here? > > blk_execute_rq() employs the same helper (i.e. nowait one) and uses > > additional completion-variable to make it sync. > > > > There is no gurantee that command will finish between call to > blk_execute_rq_nowait() > and nvme_passthru_end() is there ? Got your concern now, thanks for elaborating. I will move the passthru_end to when completion actually occurs, and get it processed via workqueue. And perhaps I should send a micro-optimization patch which will call passthru_end only for non-zero command-effects. Currently we do three checks.