On Thu, Apr 20, 2017 at 02:00:42PM +0200, Paolo Bonzini wrote:
>  void bdrv_disable_copy_on_read(BlockDriverState *bs)
>  {
> -    assert(bs->copy_on_read > 0);
> -    bs->copy_on_read--;
> +    assert(atomic_read(&bs->copy_on_read) > 0);
> +    atomic_dec(&bs->copy_on_read);
>  }

To make this truly thread-safe:

  old = atomic_dec_fetch(&bs->copy_on_read);
  assert(old > 0);

Attachment: signature.asc
Description: PGP signature

Reply via email to