summaryrefslogtreecommitdiff
path: root/block/nfs.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-05-04 20:35:59 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-05-04 20:35:59 +0100
commit5c7c46fea9f745956fcc7bea5c3af8380a599ee4 (patch)
tree430973a6470b5f1a7718715d04401b03c4ef201b /block/nfs.c
parent5375af3cd7b8adcc10c18d8083b7be63976c9645 (diff)
parent08b689aa6b521964b8275dd7a2564aefa5d68129 (diff)
downloadqemu-5c7c46fea9f745956fcc7bea5c3af8380a599ee4.zip
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Pull request v2: * Fixed stray slirp submodule change [Peter] Fixes for the lock guard macros, code conversions to the lock guard macros, and support for selecting fuzzer targets with argv[0]. # gpg: Signature made Mon 04 May 2020 16:11:11 BST # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: lockable: Replace locks with lock guard macros lockable: replaced locks with lock guard macros where appropriate lockable: fix __COUNTER__ macro to be referenced properly fuzz: select fuzz target using executable name Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block/nfs.c')
-rw-r--r--block/nfs.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/block/nfs.c b/block/nfs.c
index 2393fbfe6b..b86ba5bfa1 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -273,15 +273,14 @@ static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, uint64_t offset,
nfs_co_init_task(bs, &task);
task.iov = iov;
- qemu_mutex_lock(&client->mutex);
- if (nfs_pread_async(client->context, client->fh,
- offset, bytes, nfs_co_generic_cb, &task) != 0) {
- qemu_mutex_unlock(&client->mutex);
- return -ENOMEM;
- }
+ WITH_QEMU_LOCK_GUARD(&client->mutex) {
+ if (nfs_pread_async(client->context, client->fh,
+ offset, bytes, nfs_co_generic_cb, &task) != 0) {
+ return -ENOMEM;
+ }
- nfs_set_events(client);
- qemu_mutex_unlock(&client->mutex);
+ nfs_set_events(client);
+ }
while (!task.complete) {
qemu_coroutine_yield();
}
@@ -320,19 +319,18 @@ static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offset,
buf = iov->iov[0].iov_base;
}
- qemu_mutex_lock(&client->mutex);
- if (nfs_pwrite_async(client->context, client->fh,
- offset, bytes, buf,
- nfs_co_generic_cb, &task) != 0) {
- qemu_mutex_unlock(&client->mutex);
- if (my_buffer) {
- g_free(buf);
+ WITH_QEMU_LOCK_GUARD(&client->mutex) {
+ if (nfs_pwrite_async(client->context, client->fh,
+ offset, bytes, buf,
+ nfs_co_generic_cb, &task) != 0) {
+ if (my_buffer) {
+ g_free(buf);
+ }
+ return -ENOMEM;
}
- return -ENOMEM;
- }
- nfs_set_events(client);
- qemu_mutex_unlock(&client->mutex);
+ nfs_set_events(client);
+ }
while (!task.complete) {
qemu_coroutine_yield();
}
@@ -355,15 +353,14 @@ static int coroutine_fn nfs_co_flush(BlockDriverState *bs)
nfs_co_init_task(bs, &task);
- qemu_mutex_lock(&client->mutex);
- if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb,
- &task) != 0) {
- qemu_mutex_unlock(&client->mutex);
- return -ENOMEM;
- }
+ WITH_QEMU_LOCK_GUARD(&client->mutex) {
+ if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb,
+ &task) != 0) {
+ return -ENOMEM;
+ }
- nfs_set_events(client);
- qemu_mutex_unlock(&client->mutex);
+ nfs_set_events(client);
+ }
while (!task.complete) {
qemu_coroutine_yield();
}