mirror of https://github.com/proxmox/mirror_qemu
block: access wakeup with atomic ops
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20170605123908.18777-6-pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>master
parent
20fc71b25c
commit
e2a6ae7fe5
|
@ -501,7 +501,8 @@ static void dummy_bh_cb(void *opaque)
|
||||||
|
|
||||||
void bdrv_wakeup(BlockDriverState *bs)
|
void bdrv_wakeup(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
if (bs->wakeup) {
|
/* The barrier (or an atomic op) is in the caller. */
|
||||||
|
if (atomic_read(&bs->wakeup)) {
|
||||||
aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL);
|
aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,7 +730,9 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
|
||||||
if (task->ret < 0) {
|
if (task->ret < 0) {
|
||||||
error_report("NFS Error: %s", nfs_get_error(nfs));
|
error_report("NFS Error: %s", nfs_get_error(nfs));
|
||||||
}
|
}
|
||||||
task->complete = 1;
|
|
||||||
|
/* Set task->complete before reading bs->wakeup. */
|
||||||
|
atomic_mb_set(&task->complete, 1);
|
||||||
bdrv_wakeup(task->bs);
|
bdrv_wakeup(task->bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -698,7 +698,8 @@ out:
|
||||||
|
|
||||||
srco->co = NULL;
|
srco->co = NULL;
|
||||||
srco->ret = ret;
|
srco->ret = ret;
|
||||||
srco->finished = true;
|
/* Set srco->finished before reading bs->wakeup. */
|
||||||
|
atomic_mb_set(&srco->finished, true);
|
||||||
if (srco->bs) {
|
if (srco->bs) {
|
||||||
bdrv_wakeup(srco->bs);
|
bdrv_wakeup(srco->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,7 +402,8 @@ void bdrv_drain_all(void);
|
||||||
* block_job_defer_to_main_loop for how to do it). \
|
* block_job_defer_to_main_loop for how to do it). \
|
||||||
*/ \
|
*/ \
|
||||||
assert(!bs_->wakeup); \
|
assert(!bs_->wakeup); \
|
||||||
bs_->wakeup = true; \
|
/* Set bs->wakeup before evaluating cond. */ \
|
||||||
|
atomic_mb_set(&bs_->wakeup, true); \
|
||||||
while (busy_) { \
|
while (busy_) { \
|
||||||
if ((cond)) { \
|
if ((cond)) { \
|
||||||
waited_ = busy_ = true; \
|
waited_ = busy_ = true; \
|
||||||
|
@ -414,7 +415,7 @@ void bdrv_drain_all(void);
|
||||||
waited_ |= busy_; \
|
waited_ |= busy_; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
bs_->wakeup = false; \
|
atomic_set(&bs_->wakeup, false); \
|
||||||
} \
|
} \
|
||||||
waited_; })
|
waited_; })
|
||||||
|
|
||||||
|
|
|
@ -604,8 +604,6 @@ struct BlockDriverState {
|
||||||
/* Callback before write request is processed */
|
/* Callback before write request is processed */
|
||||||
NotifierWithReturnList before_write_notifiers;
|
NotifierWithReturnList before_write_notifiers;
|
||||||
|
|
||||||
bool wakeup;
|
|
||||||
|
|
||||||
/* Offset after the highest byte written to */
|
/* Offset after the highest byte written to */
|
||||||
uint64_t wr_highest_offset;
|
uint64_t wr_highest_offset;
|
||||||
|
|
||||||
|
@ -636,6 +634,11 @@ struct BlockDriverState {
|
||||||
unsigned int in_flight;
|
unsigned int in_flight;
|
||||||
unsigned int serialising_in_flight;
|
unsigned int serialising_in_flight;
|
||||||
|
|
||||||
|
/* Internal to BDRV_POLL_WHILE and bdrv_wakeup. Accessed with atomic
|
||||||
|
* ops.
|
||||||
|
*/
|
||||||
|
bool wakeup;
|
||||||
|
|
||||||
/* do we need to tell the quest if we have a volatile write cache? */
|
/* do we need to tell the quest if we have a volatile write cache? */
|
||||||
int enable_write_cache;
|
int enable_write_cache;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue