[sheepdog] [PATCH v2 2/2] sheep: add an option to control directio for backend store
Liu Yuan
namei.unix at gmail.com
Thu Nov 8 14:26:11 CET 2012
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 6c319db..3ce2654 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 91325b4..90a53ca 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\
@@ -405,6 +407,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.12.84.gefa6462
More information about the sheepdog
mailing list