[sheepdog] [PATCH 7/8] object cache: remove from cache object tree when removing a cached object
levin li
levin108 at gmail.com
Mon Jul 9 08:29:21 CEST 2012
From: levin li <xingke.lwp at taobao.com>
Signed-off-by: levin li <xingke.lwp at taobao.com>
---
sheep/object_cache.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index cc39a90..335cb1e 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1291,7 +1291,8 @@ void object_cache_remove(uint64_t oid)
uint32_t vid = oid_to_vid(oid);
uint32_t idx = object_cache_oid_to_idx(oid);
struct object_cache *oc;
- struct dirty_cache_entry *entry;
+ struct dirty_cache_entry *dirty_entry;
+ struct object_cache_entry *entry;
int tree_id = 0;
oc = find_object_cache(vid, 0);
@@ -1299,16 +1300,22 @@ void object_cache_remove(uint64_t oid)
return;
pthread_mutex_lock(&oc->lock);
- entry = dirty_tree_search(&oc->dirty_trees[tree_id], idx);
- if (!entry) {
+
+ dirty_entry = dirty_tree_search(&oc->dirty_trees[tree_id], idx);
+ if (!dirty_entry) {
tree_id = 1;
- entry = dirty_tree_search(&oc->dirty_trees[tree_id], idx);
+ dirty_entry = dirty_tree_search(&oc->dirty_trees[tree_id], idx);
}
- if (!entry)
- goto out;
- del_from_dirty_tree_and_list(entry, &oc->dirty_trees[tree_id]);
-out:
+ if (dirty_entry) {
+ del_from_dirty_tree_and_list(dirty_entry,
+ &oc->dirty_trees[tree_id]);
+ entry = dirty_entry->sys_entry;
+ } else
+ entry = object_tree_search(&oc->object_tree, idx);
+ if (entry)
+ del_from_object_tree_and_list(entry, &oc->object_tree);
pthread_mutex_unlock(&oc->lock);
+
return;
}
--
1.7.1
More information about the sheepdog
mailing list