[sheepdog] [PATCH v2] sheep: set bit in vdi_inuse in atomic manner

Liu Yuan namei.unix at gmail.com
Wed Aug 28 10:31:31 CEST 2013


On Wed, Aug 28, 2013 at 12:28:10PM +0900, Hitoshi Mitake wrote:
> sys->vdi_inuse should be operated in atomic manner because it is manipulated by
> multiple threads. This patch implements a new bit operator atomic_set_bit() and
> lets get_vdis_from() use this.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> 
> v2:
>  - removed needless variable
>  - replace more set_bit() for vdi_inuse
> 
>  include/bitops.h    |    5 +++++
>  sheep/group.c       |    2 +-
>  sheep/ops.c         |    4 ++--
>  sheep/plain_store.c |    2 +-
>  4 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/include/bitops.h b/include/bitops.h
> index c4e8f74..c676c3a 100644
> --- a/include/bitops.h
> +++ b/include/bitops.h
> @@ -135,6 +135,11 @@ static inline void set_bit(int nr, unsigned long *addr)
>  	addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);
>  }
>  
> +static inline void atomic_set_bit(int nr, unsigned long *addr)
> +{
> +	uatomic_or(addr + nr / BITS_PER_LONG, 1UL << (nr % BITS_PER_LONG);

forgot last )?

Thanks
Yuan



More information about the sheepdog mailing list