[sheepdog] [PATCH] sheep: recover uatomic_bool assertions

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Feb 5 16:49:22 CET 2013


In the commit 55edb8430f74, the assert() in uatomic_set_false() is
removed. This patch adds new asserts which share same purpose with the
removed one to caller side.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/object_cache.c |    1 +
 sheep/sockfd_cache.c |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 8cf2c63..712561b 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -554,6 +554,7 @@ static void do_reclaim(struct work *work)
 static void reclaim_done(struct work *work)
 {
 	struct reclaim_work *rw = container_of(work, struct reclaim_work, work);
+	assert(uatomic_is_true(&gcache.in_reclaim));
 	uatomic_set_false(&gcache.in_reclaim);
 	free(rw);
 }
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
index 168e9fb..0a4d1c6 100644
--- a/sheep/sockfd_cache.c
+++ b/sheep/sockfd_cache.c
@@ -318,6 +318,7 @@ static void grow_fds_done(struct work *work)
 	fds_count *= 2;
 	fds_high_watermark = FDS_WATERMARK(fds_count);
 	sd_dprintf("fd count has been grown into %d\n", fds_count);
+	assert(uatomic_is_true(&fds_in_grow));
 	uatomic_set_false(&fds_in_grow);
 	free(work);
 }
@@ -431,8 +432,10 @@ static void sockfd_cache_put(const struct node_id *nid, int idx)
 
 	pthread_rwlock_rdlock(&sockfd_cache.lock);
 	entry = sockfd_cache_search(nid);
-	if (entry)
+	if (entry) {
+		assert(uatomic_is_true(&entry->fds[idx].in_use));
 		uatomic_set_false(&entry->fds[idx].in_use);
+	}
 	pthread_rwlock_unlock(&sockfd_cache.lock);
 }
 
-- 
1.7.5.1




More information about the sheepdog mailing list