[sheepdog] [PATCH] sheep: use long type for object cache size

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Sep 24 19:29:48 CEST 2012


This enables us to use more than 4 GB object cache on 64 bit machines.
This also works on i386 machines because long type is supported by
urcu on both x86_64 and i386.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/object_cache.c |    4 ++--
 sheep/ops.c          |    6 +++---
 sheep/sheep.c        |    6 +++---
 sheep/sheep_priv.h   |    2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 109b56e..8a177b9 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -48,7 +48,7 @@
 
 
 struct global_cache {
-	uint32_t cache_size;
+	unsigned long cache_size;
 	int in_reclaim;
 	struct cds_list_head cache_lru_list;
 };
@@ -515,7 +515,7 @@ static int do_reclaim_object(struct object_cache_entry *entry)
 		goto out;
 	}
 
-	dprintf("oid %"PRIx64" reclaimed successfully, cache_size: %"PRId32"\n",
+	dprintf("oid %"PRIx64" reclaimed successfully, cache_size: %ld\n",
 		oid, uatomic_read(&sys_cache.cache_size));
 	del_from_object_tree_and_list(entry, &oc->object_tree);
 out:
diff --git a/sheep/ops.c b/sheep/ops.c
index ac02683..8520695 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -614,10 +614,10 @@ static int cluster_recovery_completion(const struct sd_req *req,
 static int local_set_cache_size(const struct sd_req *req, struct sd_rsp *rsp,
 				  void *data)
 {
-	uint32_t cache_size = *(uint32_t *)data;
+	unsigned long cache_size = *(uint32_t *)data;
 
-	uatomic_set(&sys->object_cache_size, cache_size);
-	dprintf("Max cache size set to %dM\n", cache_size);
+	uatomic_set(&sys->object_cache_size, cache_size * 1024 * 1024);
+	dprintf("Max cache size set to %ldM\n", cache_size);
 
 	object_cache_try_to_reclaim();
 
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 3be45ff..f54b994 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -193,8 +193,8 @@ static void object_cache_size_set(char *s)
 	const char *header = "size=";
 	int len = strlen(header);
 	char *size, *p;
-	uint32_t cache_size;
-	const uint32_t max_cache_size = UINT32_MAX / 1024 / 1024;
+	unsigned long cache_size;
+	const unsigned long max_cache_size = ULONG_MAX / 1024 / 1024;
 
 	assert(!strncmp(s, header, len));
 
@@ -208,7 +208,7 @@ static void object_cache_size_set(char *s)
 
 err:
 	fprintf(stderr, "Invalid object cache option '%s': "
-		"size must be an integer between 0 and %"PRIu32"\n",
+		"size must be an integer between 0 and %lu\n",
 		s, max_cache_size);
 	exit(1);
 }
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index cad25ce..eec9a45 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -120,7 +120,7 @@ struct cluster_info {
 #define CACHE_TYPE_DISK   0x2
 	int enabled_cache_type;
 
-	uint32_t object_cache_size;
+	unsigned long object_cache_size;
 	bool object_cache_directio;
 
 	bool use_journal;
-- 
1.7.2.5




More information about the sheepdog mailing list