[Sheepdog] [PATCH 2/2] sheep: make gateway and io workers configurable

Liu Yuan namei.unix at gmail.com
Thu Apr 12 16:53:22 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

Most of the time one VM would issue multiple requests in one
go, so it would be useful to let users to decide how many workers
are useful if we have more than several VMs in single sheep node.

In a large set nodes of cluster, every single node will get multiple
concurrent recovery IO requests, so it would be useful to have it as
configurable.

default 4 workers for both and maximum 128.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c      |   31 ++++++++++++++++++++++++++++---
 sheep/sheep_priv.h |    3 ---
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index a0a44a9..4b868fe 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -27,6 +27,9 @@
 #define DEFAULT_OBJECT_DIR "/tmp"
 #define LOG_FILE_NAME "sheep.log"
 
+static int nr_io_worker = 4;
+static int nr_gateway_worker = 4;
+
 LIST_HEAD(cluster_drivers);
 static char program_name[] = "sheep";
 
@@ -37,6 +40,8 @@ static struct option const long_options[] = {
 	{"debug", no_argument, NULL, 'd'},
 	{"directio", no_argument, NULL, 'D'},
 	{"asyncflush", no_argument, NULL, 'a'},
+	{"gworker", required_argument, NULL, 'g'},
+	{"iworker", required_argument, NULL, 'i'},
 	{"zone", required_argument, NULL, 'z'},
 	{"vnodes", required_argument, NULL, 'v'},
 	{"cluster", required_argument, NULL, 'c'},
@@ -44,7 +49,7 @@ static struct option const long_options[] = {
 	{NULL, 0, NULL, 0},
 };
 
-static const char *short_options = "p:fl:dDaz:v:c:h";
+static const char *short_options = "p:fl:dDag:i:z:v:c:h";
 
 static void usage(int status)
 {
@@ -62,6 +67,8 @@ Options:\n\
   -d, --debug             include debug messages in the log\n\
   -D, --directio          use direct IO when accessing the object from object cache\n\
   -a, --asyncflush        flush the object cache asynchronously\n\
+  -g, --gworker           set the number of workers for Guests' requests (default 4)\n\
+  -i, --iworker           set the number of workers for sheep internal requests (default 4)\n\
   -z, --zone              specify the zone id\n\
   -v, --vnodes            specify the number of virtual nodes\n\
   -c, --cluster           specify the cluster driver\n\
@@ -138,6 +145,24 @@ int main(int argc, char **argv)
 		case 'a':
 			sys->async_flush = 1;
 			break;
+		case 'g':
+			nr_gateway_worker = strtol(optarg, &p, 10);
+			if (optarg == p || nr_gateway_worker < 4 || nr_gateway_worker > 128) {
+				fprintf(stderr, "Invalid number of gateway workers '%s': "
+					"must be an integer between 4 and %u\n",
+					optarg, 128);
+				exit(1);
+			}
+			break;
+		case 'i':
+			nr_io_worker = strtol(optarg, &p, 10);
+			if (optarg == p || nr_io_worker < 4 || nr_io_worker > 128) {
+				fprintf(stderr, "Invalid number of internal IO workers '%s': "
+					"must be an integer between 4 and %u\n",
+					optarg, 128);
+				exit(1);
+			}
+			break;
 		case 'z':
 			zone = strtol(optarg, &p, 10);
 			if (optarg == p || zone < 0 || UINT32_MAX < zone) {
@@ -217,8 +242,8 @@ int main(int argc, char **argv)
 	}
 
 	sys->event_wqueue = init_work_queue(1);
-	sys->gateway_wqueue = init_work_queue(NR_GW_WORKER_THREAD);
-	sys->io_wqueue = init_work_queue(NR_IO_WORKER_THREAD);
+	sys->gateway_wqueue = init_work_queue(nr_gateway_worker);
+	sys->io_wqueue = init_work_queue(nr_io_worker);
 	sys->recovery_wqueue = init_work_queue(1);
 	sys->deletion_wqueue = init_work_queue(1);
 	sys->flush_wqueue = init_work_queue(1);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 78cc8aa..e04715c 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -276,9 +276,6 @@ int store_remove_obj(const struct sd_req *, struct sd_rsp *, void *);
 int store_file_write(void *buffer, size_t len);
 void *store_file_read(void);
 
-#define NR_GW_WORKER_THREAD 4
-#define NR_IO_WORKER_THREAD 4
-
 int epoch_log_read(uint32_t epoch, char *buf, int len);
 int epoch_log_read_nr(uint32_t epoch, char *buf, int len);
 int epoch_log_read_remote(uint32_t epoch, char *buf, int len);
-- 
1.7.8.2




More information about the sheepdog mailing list