[sheepdog] [PATCH] object cache: remove RECLAIM flag from reclaim path
levin li
levin108 at gmail.com
Mon Jul 30 06:50:35 CEST 2012
From: levin li <xingke.lwp at taobao.com>
Since we hold lock while calling find_cache_entry() and
reclaiming the cache entry, there's no necessary for RECLAIM flag
Signed-off-by: levin li <xingke.lwp at taobao.com>
---
sheep/object_cache.c | 17 +++--------------
1 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 1f3e631..a8db084 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -40,13 +40,10 @@
#define CACHE_VDI_BIT (UINT32_C(1) << CACHE_VDI_SHIFT)
#define CACHE_BLOCK_SIZE ((UINT64_C(1) << 10) * 64) /* 64 KB */
-#define CACHE_RECLAIM_SHIFT 27
-#define CACHE_RECLAIM_BIT (UINT32_C(1) << CACHE_RECLAIM_SHIFT)
-
-#define CACHE_CREATE_SHIFT 26
+#define CACHE_CREATE_SHIFT 27
#define CACHE_CREATE_BIT (UINT32_C(1) << CACHE_CREATE_SHIFT)
-#define CACHE_INDEX_MASK (CACHE_RECLAIM_BIT | CACHE_CREATE_BIT)
+#define CACHE_INDEX_MASK (CACHE_CREATE_BIT)
struct global_cache {
uint64_t cache_size;
@@ -457,8 +454,6 @@ static int reclaim_object(struct object_cache_entry *entry)
}
}
- entry->idx |= CACHE_RECLAIM_BIT;
-
ret = remove_cache_object(oc, entry->idx);
if (ret == SD_RES_SUCCESS)
del_from_object_tree_and_list(entry, &oc->object_tree);
@@ -671,13 +666,7 @@ static void add_to_object_cache(struct object_cache *oc, uint32_t idx)
static inline struct object_cache_entry *
find_cache_entry(struct object_cache *oc, uint32_t idx)
{
- struct object_cache_entry *entry;
-
- entry = object_tree_search(&oc->object_tree, idx);
- if (!entry || entry->idx & CACHE_RECLAIM_BIT)
- return NULL;
-
- return entry;
+ return object_tree_search(&oc->object_tree, idx);
}
static int object_cache_lookup(struct object_cache *oc, uint32_t idx,
--
1.7.1
More information about the sheepdog
mailing list