[sheepdog] [PATCH] cache: don't push read-only object
Liu Yuan
namei.unix at gmail.com
Fri Jul 12 13:13:43 CEST 2013
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
sheep/object_cache.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 06054c3..721bff6 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -875,10 +875,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.9.5
More information about the sheepdog
mailing list