[sheepdog] [PATCH v3 2/2] sheep: add an option to control directio for backend store

Liu Yuan namei.unix at gmail.com
Mon Nov 12 06:08:45 CET 2012


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

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

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/plain_store.c |    6 ++++++
 sheep/sheep.c       |    5 +++++
 sheep/sheep_priv.h  |    1 +
 3 files changed, 12 insertions(+)

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index fa8ccfa..cd3054e 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -28,6 +28,12 @@ static int get_open_flags(uint64_t oid, bool create, int fl)
 	    uatomic_is_true(&sys->use_journal))
 		flags &= ~O_DSYNC;
 
+	/*
+	 * We can not use DIO for inode object because it is not 512B aligned.
+	 */
+	if (sys->backend_dio && is_data_obj(oid))
+		flags |= O_DIRECT;
+
 	if (create)
 		flags |= O_CREAT | O_EXCL;
 
diff --git a/sheep/sheep.c b/sheep/sheep.c
index ab15526..a8f4f3f 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -43,6 +43,7 @@ static struct option const long_options[] = {
 	{"bindaddr", required_argument, NULL, 'b'},
 	{"cluster", required_argument, NULL, 'c'},
 	{"debug", no_argument, NULL, 'd'},
+	{"directio", no_argument, NULL, 'D'},
 	{"foreground", no_argument, NULL, 'f'},
 	{"gateway", no_argument, NULL, 'g'},
 	{"help", no_argument, NULL, 'h'},
@@ -74,6 +75,7 @@ Options:\n\
   -b, --bindaddr          specify IP address of interface to listen on\n\
   -c, --cluster           specify the cluster driver\n\
   -d, --debug             include debug messages in the log\n\
+  -D, --directio          use direct IO for backend store\n\
   -f, --foreground        make the program run in the foreground\n\
   -g, --gateway           make the progam run as a gateway mode\n\
   -h, --help              display this help and exit\n\
@@ -407,6 +409,9 @@ int main(int argc, char **argv)
 			/* removed soon. use loglevel instead */
 			log_level = SDOG_DEBUG;
 			break;
+		case 'D':
+			sys->backend_dio = true;
+			break;
 		case 'g':
 			/* same as '-v 0' */
 			nr_vnodes = 0;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 6deaf64..00bc032 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -123,6 +123,7 @@ struct cluster_info {
 	bool object_cache_directio;
 
 	uatomic_bool use_journal;
+	bool backend_dio;
 	bool upgrade; /* upgrade data layout before starting service
 		       * if necessary*/
 };
-- 
1.7.9.5




More information about the sheepdog mailing list