Am 26.06.2019 um 10:46 hat Denis Plotnikov geschrieben: > On 24.06.2019 12:46, Denis Plotnikov wrote: > > On 21.06.2019 12:59, Vladimir Sementsov-Ogievskiy wrote: > >> 21.06.2019 12:16, Kevin Wolf wrote: > >>> Am 09.04.2019 um 12:01 hat Kevin Wolf geschrieben: > >>>> Am 02.04.2019 um 10:35 hat Denis Plotnikov geschrieben: > >>>>> On 13.03.2019 19:04, Kevin Wolf wrote: > >>>>>> Am 14.12.2018 um 12:54 hat Denis Plotnikov geschrieben: > >>>>>>> On 13.12.2018 15:20, Kevin Wolf wrote: > >>>>>>>> Am 13.12.2018 um 12:07 hat Denis Plotnikov geschrieben: > >>>>>>>>> Sounds it should be so, but it doesn't work that way and that's why: > >>>>>>>>> when doing mirror we may resume postponed coroutines too early when > >>>>>>>>> the > >>>>>>>>> underlying bs is protected from writing at and thus we encounter the > >>>>>>>>> assert on a write request execution at bdrv_co_write_req_prepare > >>>>>>>>> when > >>>>>>>>> resuming the postponed coroutines. > >>>>>>>>> > >>>>>>>>> The thing is that the bs is protected for writing before execution > >>>>>>>>> of > >>>>>>>>> bdrv_replace_node at mirror_exit_common and bdrv_replace_node calls > >>>>>>>>> bdrv_replace_child_noperm which, in turn, calls > >>>>>>>>> child->role->drained_end > >>>>>>>>> where one of the callbacks is blk_root_drained_end which check > >>>>>>>>> if(--blk->quiesce_counter == 0) and runs the postponed requests > >>>>>>>>> (coroutines) if the coundition is true. > >>>>>>>> > >>>>>>>> Hm, so something is messed up with the drain sections in the mirror > >>>>>>>> driver. We have: > >>>>>>>> > >>>>>>>> bdrv_drained_begin(target_bs); > >>>>>>>> bdrv_replace_node(to_replace, target_bs, &local_err); > >>>>>>>> bdrv_drained_end(target_bs); > >>>>>>>> > >>>>>>>> Obviously, the intention was to keep the BlockBackend drained during > >>>>>>>> bdrv_replace_node(). So how could blk->quiesce_counter ever get to 0 > >>>>>>>> inside bdrv_replace_node() when target_bs is drained? > >>>>>>>> > >>>>>>>> Looking at bdrv_replace_child_noperm(), it seems that the function > >>>>>>>> has > >>>>>>>> a bug: Even if old_bs and new_bs are both drained, the > >>>>>>>> quiesce_counter > >>>>>>>> for the parent reaches 0 for a moment because we call .drained_end > >>>>>>>> for > >>>>>>>> the old child first and .drained_begin for the new one later. > >>>>>>>> > >>>>>>>> So it seems the fix would be to reverse the order and first call > >>>>>>>> .drained_begin for the new child and then .drained_end for the old > >>>>>>>> child. Sounds like a good new testcase for tests/test-bdrv-drain.c, > >>>>>>>> too. > >>>>>>> Yes, it's true, but it's not enough... > >>>>>> > >>>>>> Did you ever implement the changes suggested so far, so that we could > >>>>>> continue from there? Or should I try and come up with something myself? > >>>>> > >>>>> Sorry for the late reply... > >>>>> Yes, I did ... > >>>> > >>>> If there are more question or problems, can you post the patches in > >>>> their current shape (as an RFC) or a git URL so I can play with it a > >>>> bit? If you could include a failing test case, too, that would be ideal. > >>> > >>> Denis? Please? > >>> > >>> We really should get this fixed and I would be willing to lend a hand, > >>> but if you keep your patches secret, I can't really do so and would have > >>> to duplicate your work. > >>> > >>> Also, please see my old answer from April below for the last problem you > >>> had with implementing the correct approach. > >>> > >>> Kevin > > > > Hi Kevin, > > I'm sorry for not replying for so long. Please, give me some time (a day > > or two) so I could refresh everything and send the current state of the > > patches as well as the test case checking the issue > > Hi Kevin, > The current state of the patches is available at > https://github.com/denis-plotnikov/qemu/tree/postponed-request
Are you sure you pushed the correct version? I don't see any of the things we discussed above in this branch, i.e. using blk_root_drained_begin/end, fixing bdrv_replace_child_noperm(), fixing the drain calls in mirror etc. > I didn't manage to create an automatic reproducer but one of the patches > contains a step-by-step description of how to reproduce the problem. Ok, I'll try whether I can reproduce this. Kevin