mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
Block layer patches
- NBD server: Fix crashes related to switching between AioContexts - file-posix: Workaround for discard/write_zeroes on buggy filesystems - Follow-up fixes for the reopen vs. permission changes - quorum: Fix error handling for flush - block-copy: Refactor copy_range handling - docs: Describe how to use 'null-co' block driver -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmC3iy8RHGt3b2xmQHJl ZGhhdC5jb20ACgkQfwmycsiPL9ZP0hAAuh07CFWLzHCcRC7PBzekSPfzRYYBLDSW EObJ1Ov4mvz8UZoP6BDJ5QVzLPhel6hXkxTd83B1D7t/Dq+yJYR0z8Kv3USpaVJ4 2U26SsoGQM8BmtVDL1Q8tQ5eDWQ4ykxNx6F2/lKBe1EH1lfaun04Xj1rNh7jpilo nNmKMDDI1UOkH0lKDR3tqfEV0XQE7o+ZKfPlIbvYMjXk9ZPKUHfjNPGVdCLQVnqH VJI01hF7eEx1ykSMdlC+TzNoVGG+mCBokGuW0JlUvOpX6FcGnAlxXQx8u53c1I8O lggZV8b2IbrNBUVwXQHLLrXxjOo+u54Ct9y/gXUTAj8qai+9jVRp60Y1pnCyeIeu DzFx10xwy04PGleb7AAZ4dT8du2+PTkuyQ9KmlvQ2U4IUcgW124CrDeO7XYr1aif hCTJPeEDrC9YNU6AQ8rLXrYUtkumSm2zUzU5nZ//i5WH41475/vsmgP5A+Jr457A Xu0yiI2Gqkr9CNsP9ZzMkNj03oIBhPFuGxiwibLQsy/6UVnaDYS0+rQ8FXYnF5+K iEpgXe3vKTWxM097kzJMBTDVRMXRa75NtK7KWXMDgVpHTbcv1t1otsn+6dfv+B55 ULJM1ETsyYS0T6BqNglvdytsraSt7JgSF+ZLHbYk3KVDshwnq/0ksgSqHNNA14ca kYTzHhMgo5w= =gSq/ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block layer patches - NBD server: Fix crashes related to switching between AioContexts - file-posix: Workaround for discard/write_zeroes on buggy filesystems - Follow-up fixes for the reopen vs. permission changes - quorum: Fix error handling for flush - block-copy: Refactor copy_range handling - docs: Describe how to use 'null-co' block driver # gpg: Signature made Wed 02 Jun 2021 14:44:15 BST # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: docs/secure-coding-practices: Describe how to use 'null-co' block driver block-copy: refactor copy_range handling block-copy: fix block_copy_task_entry() progress update nbd/server: Use drained block ops to quiesce the server block-backend: add drained_poll block: improve permission conflict error message block: simplify bdrv_child_user_desc() block/vvfat: inherit child_vvfat_qcow from child_of_bds block: improve bdrv_child_get_parent_desc() block-backend: improve blk_root_get_parent_desc() block: document child argument of bdrv_attach_child_common() block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE block/file-posix: Fix problem with fallocate(PUNCH_HOLE) on GPFS block: drop BlockBackendRootState::read_only block: drop BlockDriverState::read_only block: consistently use bdrv_is_read_only() block/vvfat: fix vvfat_child_perm crash block/vvfat: child_vvfat_qcow: add .get_parent_aio_context, fix crash qemu-io-cmds: assert that we don't have .perm requested in no-blk case block/quorum: Provide .bdrv_co_flush instead of .bdrv_co_flush_to_disk Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
8e6dad2028
24 changed files with 250 additions and 147 deletions
100
nbd/server.c
100
nbd/server.c
|
@ -1513,6 +1513,11 @@ static void nbd_request_put(NBDRequestData *req)
|
|||
g_free(req);
|
||||
|
||||
client->nb_requests--;
|
||||
|
||||
if (client->quiescing && client->nb_requests == 0) {
|
||||
aio_wait_kick();
|
||||
}
|
||||
|
||||
nbd_client_receive_next_request(client);
|
||||
|
||||
nbd_client_put(client);
|
||||
|
@ -1530,51 +1535,70 @@ static void blk_aio_attached(AioContext *ctx, void *opaque)
|
|||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
qio_channel_attach_aio_context(client->ioc, ctx);
|
||||
|
||||
assert(client->nb_requests == 0);
|
||||
assert(client->recv_coroutine == NULL);
|
||||
assert(client->send_coroutine == NULL);
|
||||
|
||||
if (client->quiescing) {
|
||||
client->quiescing = false;
|
||||
nbd_client_receive_next_request(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void nbd_aio_detach_bh(void *opaque)
|
||||
{
|
||||
NBDExport *exp = opaque;
|
||||
NBDClient *client;
|
||||
|
||||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
qio_channel_detach_aio_context(client->ioc);
|
||||
client->quiescing = true;
|
||||
|
||||
if (client->recv_coroutine) {
|
||||
if (client->read_yielding) {
|
||||
qemu_aio_coroutine_enter(exp->common.ctx,
|
||||
client->recv_coroutine);
|
||||
} else {
|
||||
AIO_WAIT_WHILE(exp->common.ctx, client->recv_coroutine != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (client->send_coroutine) {
|
||||
AIO_WAIT_WHILE(exp->common.ctx, client->send_coroutine != NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void blk_aio_detach(void *opaque)
|
||||
{
|
||||
NBDExport *exp = opaque;
|
||||
NBDClient *client;
|
||||
|
||||
trace_nbd_blk_aio_detach(exp->name, exp->common.ctx);
|
||||
|
||||
aio_wait_bh_oneshot(exp->common.ctx, nbd_aio_detach_bh, exp);
|
||||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
qio_channel_detach_aio_context(client->ioc);
|
||||
}
|
||||
|
||||
exp->common.ctx = NULL;
|
||||
}
|
||||
|
||||
static void nbd_drained_begin(void *opaque)
|
||||
{
|
||||
NBDExport *exp = opaque;
|
||||
NBDClient *client;
|
||||
|
||||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
client->quiescing = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void nbd_drained_end(void *opaque)
|
||||
{
|
||||
NBDExport *exp = opaque;
|
||||
NBDClient *client;
|
||||
|
||||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
client->quiescing = false;
|
||||
nbd_client_receive_next_request(client);
|
||||
}
|
||||
}
|
||||
|
||||
static bool nbd_drained_poll(void *opaque)
|
||||
{
|
||||
NBDExport *exp = opaque;
|
||||
NBDClient *client;
|
||||
|
||||
QTAILQ_FOREACH(client, &exp->clients, next) {
|
||||
if (client->nb_requests != 0) {
|
||||
/*
|
||||
* If there's a coroutine waiting for a request on nbd_read_eof()
|
||||
* enter it here so we don't depend on the client to wake it up.
|
||||
*/
|
||||
if (client->recv_coroutine != NULL && client->read_yielding) {
|
||||
qemu_aio_coroutine_enter(exp->common.ctx,
|
||||
client->recv_coroutine);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void nbd_eject_notifier(Notifier *n, void *data)
|
||||
{
|
||||
NBDExport *exp = container_of(n, NBDExport, eject_notifier);
|
||||
|
@ -1594,6 +1618,12 @@ void nbd_export_set_on_eject_blk(BlockExport *exp, BlockBackend *blk)
|
|||
blk_add_remove_bs_notifier(blk, &nbd_exp->eject_notifier);
|
||||
}
|
||||
|
||||
static const BlockDevOps nbd_block_ops = {
|
||||
.drained_begin = nbd_drained_begin,
|
||||
.drained_end = nbd_drained_end,
|
||||
.drained_poll = nbd_drained_poll,
|
||||
};
|
||||
|
||||
static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
|
||||
Error **errp)
|
||||
{
|
||||
|
@ -1715,8 +1745,17 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
|
|||
|
||||
exp->allocation_depth = arg->allocation_depth;
|
||||
|
||||
/*
|
||||
* We need to inhibit request queuing in the block layer to ensure we can
|
||||
* be properly quiesced when entering a drained section, as our coroutines
|
||||
* servicing pending requests might enter blk_pread().
|
||||
*/
|
||||
blk_set_disable_request_queuing(blk, true);
|
||||
|
||||
blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, exp);
|
||||
|
||||
blk_set_dev_ops(blk, &nbd_block_ops, exp);
|
||||
|
||||
QTAILQ_INSERT_TAIL(&exports, exp, next);
|
||||
|
||||
return 0;
|
||||
|
@ -1788,6 +1827,7 @@ static void nbd_export_delete(BlockExport *blk_exp)
|
|||
}
|
||||
blk_remove_aio_context_notifier(exp->common.blk, blk_aio_attached,
|
||||
blk_aio_detach, exp);
|
||||
blk_set_disable_request_queuing(exp->common.blk, false);
|
||||
}
|
||||
|
||||
for (i = 0; i < exp->nr_export_bitmaps; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue