[sheepdog] [PATCH stable-0.6 3/3] cache: don't push read-only object

Hitoshi Mitake mitake.hitoshi at gmail.com
Fri Jul 19 17:51:07 CEST 2013


From: Liu Yuan <namei.unix at gmail.com>

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/object_cache.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 6ed1105..1e4ac2d 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -835,10 +835,20 @@ static void do_push_object(struct work *work)
 	sd_dprintf("%"PRIx64, oid);
 
 	read_lock_entry(entry);
+	/*
+	 * We might happen to push readonly object in following scenario
+	 * 1. sheep pulled some read-only objects
+	 * 2. sheep crashed
+	 * 3. sheep restarted and marked all the objects in cache dirty blindly
+	 */
+	if (oid_is_readonly(idx_to_oid(oc->vid, entry_idx(entry))))
+		goto clean;
+
 	if (push_cache_object(oc->vid, entry_idx(entry), entry->bmap,
 			      !!(entry->idx & CACHE_CREATE_BIT))
 	    != SD_RES_SUCCESS)
 		panic("push failed but should never fail");
+clean:
 	if (uatomic_sub_return(&oc->push_count, 1) == 0)
 		eventfd_write(oc->push_efd, 1);
 	entry->idx &= ~CACHE_CREATE_BIT;
-- 
1.7.5.1




More information about the sheepdog mailing list