On 03.04.20 12:44, Kevin Wolf wrote: > Calling blk_wait_while_drained() while blk->in_flight is increased for > the current request is wrong because it will cause the drain operation > to deadlock. > > Many callers of blk_wait_while_drained() have already increased > blk->in_flight when called in a blk_aio_*() path, but can also be called > in synchonous code paths where blk->in_flight isn't increased. This > means that these calls of blk_wait_while_drained() are wrong at least in > some cases. > > In order to fix this, increase blk->in_flight even for synchronous > operations and temporarily decrease the counter again in > blk_wait_while_drained(). > > Fixes: cf3129323f900ef5ddbccbe86e4fa801e88c566e > Signed-off-by: Kevin Wolf > --- > block/block-backend.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) blk_co_pdiscard() and blk_co_flush() are called from outside of block-backend.c (namely from mirror.c and nbd/server.c). Is that OK? Max