On 12/04/2018 16:25, Kevin Wolf wrote: > This is already the order we have there. What is probably different from > what you envision is that after the parents have concluded, we still > check that they are still quiescent in every iteration.
Yes, and that's the quadratic part. > What we could do easily is introducing a bool bs->quiesce_concluded or > something that bdrv_drain_poll() sets to true the first time that it > returns false. It also gets a shortcut so that it returns false > immediately if bs->quiesce_concluded is true. The field is reset in > bdrv_do_drained_end() when bs->quiesce_counter reaches 0. Or bs->quiescent, for the sake of bikeshedding. > That would be a rather simple optimisation that could be done as the > final patch in this series, and would ensure that we don't recurse back > to parents that are already quiescent. > > Would you be happy with this change? Yes, I'll leave the organization of the series to you of course. Paolo