Skip to content

Commit

Permalink
block: Drain nodes before inactivating them
Browse files Browse the repository at this point in the history
So far the assumption has always been that if we try to inactivate a
node, it is already idle. This doesn't hold true any more if we allow
inactivating exported nodes because we can't know when new external
requests come in.

Drain the node around setting BDRV_O_INACTIVE so that requests can't
start operating on an active node and then in the middle it suddenly
becomes inactive. With this change, it's enough for exports to check
for new requests that they operate on an active node (or, like reads,
are allowed even on an inactive node).

Signed-off-by: Kevin Wolf <[email protected]>
Acked-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
kevmw committed Feb 6, 2025
1 parent 69f2817 commit 2849092
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -7032,7 +7032,9 @@ bdrv_inactivate_recurse(BlockDriverState *bs, bool top_level)
return -EPERM;
}

bdrv_drained_begin(bs);
bs->open_flags |= BDRV_O_INACTIVE;
bdrv_drained_end(bs);

/*
* Update permissions, they may differ for inactive nodes.
Expand Down

0 comments on commit 2849092

Please sign in to comment.