[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] nbd/server: introduce NBDClient->lock to protect fields
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 6/6] nbd/server: introduce NBDClient->lock to protect fields |
Date: |
Thu, 21 Dec 2023 08:26:58 +0100 |
User-agent: |
Mozilla Thunderbird |
On 12/21/23 02:49, Stefan Hajnoczi wrote:
nbd_client_receive_next_request(client);
+
+ qemu_mutex_unlock(&client->lock);
+
if (ret == -EIO) {
goto disconnect;
}
I think I slightly prefer if disconnect is reached with lock taken, for
consistency with the "done" label. It does not complicate the code,
because you can just move qio_channel_set_cork() and replace:
@@ -3024,8 +3072,10 @@ static coroutine_fn void nbd_trip(void *opaque)
}
qio_channel_set_cork(client->ioc, false);
+ qemu_mutex_lock(&client->lock);
with:
+ qio_channel_set_cork(client->ioc, false);
+ qemu_mutex_lock(&client->lock);
if (ret < 0) {
error_prepend(&local_err, "Failed to send reply: ");
goto disconnect;
}
/*
* We must disconnect after NBD_CMD_WRITE or BLOCK_STATUS with
* payload if we did not read the payload.
*/
if (!req->complete) {
error_setg(&local_err, "Request handling failed in
intermediate state");
goto disconnect;
}
- qio_channel_set_cork(client->ioc, false);
done:
Thanks,
Paolo
done:
nbd_request_put(req);
+ qemu_mutex_unlock(&client->lock);
- [PATCH 0/6] qemu-iotests fixes for Kevin's block tree, Stefan Hajnoczi, 2023/12/20
- [PATCH 1/6] fixup block-coroutine-wrapper: use qemu_get_current_aio_context(), Stefan Hajnoczi, 2023/12/20
- [PATCH 2/6] fixup block: remove AioContext locking, Stefan Hajnoczi, 2023/12/20
- [PATCH 3/6] fixup scsi: only access SCSIDevice->requests from one thread, Stefan Hajnoczi, 2023/12/20
- [PATCH 4/6] nbd/server: avoid per-NBDRequest nbd_client_get/put(), Stefan Hajnoczi, 2023/12/20
- [PATCH 5/6] nbd/server: only traverse NBDExport->clients from main loop thread, Stefan Hajnoczi, 2023/12/20
- [PATCH 6/6] nbd/server: introduce NBDClient->lock to protect fields, Stefan Hajnoczi, 2023/12/20