qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 01/17] block: access copy_on_read with atomic op


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [PATCH 01/17] block: access copy_on_read with atomic ops
Date: Thu, 4 May 2017 12:15:36 +0100
User-agent: Mutt/1.8.0 (2017-02-23)

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

[Prev in Thread] Current Thread [Next in Thread]