[sheepdog] [PATCH RFT 3/4] libsheepdog: provide atomic_clear_bit

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Dec 15 10:36:59 CET 2014


The new function is required because the bitmaps (vdi_inuse and
vdi_deleted) can be cleared now.

Cc: Saeki Masaki <saeki.masaki at po.ntts.co.jp>
Cc: Yuka Kawasaki <kawasaki.yuka at po.ntts.co.jp>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 include/bitops.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/bitops.h b/include/bitops.h
index 86a8ac1..6b605fb 100644
--- a/include/bitops.h
+++ b/include/bitops.h
@@ -146,6 +146,11 @@ static inline void atomic_set_bit(int nr, unsigned long *addr)
 	uatomic_or(addr + nr / BITS_PER_LONG, 1UL << (nr % BITS_PER_LONG));
 }
 
+static inline void atomic_clear_bit(int nr, unsigned long *addr)
+{
+	uatomic_and(addr + nr / BITS_PER_LONG, ~(1UL << (nr % BITS_PER_LONG)));
+}
+
 static inline int test_bit(unsigned int nr, const unsigned long *addr)
 {
 	return ((1UL << (nr % BITS_PER_LONG)) &
-- 
1.8.3.2




More information about the sheepdog mailing list