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>
This commit is contained in:
Paolo Bonzini 2017-06-05 14:38:54 +02:00 committed by Fam Zheng
parent 20fc71b25c
commit e2a6ae7fe5
5 changed files with 15 additions and 7 deletions

View file

@ -402,7 +402,8 @@ void bdrv_drain_all(void);
* block_job_defer_to_main_loop for how to do it). \
*/ \
assert(!bs_->wakeup); \
bs_->wakeup = true; \
/* Set bs->wakeup before evaluating cond. */ \
atomic_mb_set(&bs_->wakeup, true); \
while (busy_) { \
if ((cond)) { \
waited_ = busy_ = true; \
@ -414,7 +415,7 @@ void bdrv_drain_all(void);
waited_ |= busy_; \
} \
} \
bs_->wakeup = false; \
atomic_set(&bs_->wakeup, false); \
} \
waited_; })

View file

@ -604,8 +604,6 @@ struct BlockDriverState {
/* Callback before write request is processed */
NotifierWithReturnList before_write_notifiers;
bool wakeup;
/* Offset after the highest byte written to */
uint64_t wr_highest_offset;
@ -636,6 +634,11 @@ struct BlockDriverState {
unsigned int 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? */
int enable_write_cache;