[sheepdog] [PATCH v2] sheep: add nosync for testing purpose

Liu Yuan namei.unix at gmail.com
Wed Feb 6 07:05:49 CET 2013


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

This is only useful for testing, users are not expected to use it.

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

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index fe08419..53dea60 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -25,7 +25,8 @@ static int get_open_flags(uint64_t oid, bool create, int fl)
 	int flags = O_DSYNC | O_RDWR;
 
 	if ((fl & SD_FLAG_CMD_CACHE && is_disk_cache_enabled()) ||
-	    uatomic_is_true(&sys->use_journal))
+	    uatomic_is_true(&sys->use_journal) ||
+	    sys->nosync == true)
 		flags &= ~O_DSYNC;
 
 	/*
diff --git a/sheep/sheep.c b/sheep/sheep.c
index a9b9bdb..c743859 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -52,6 +52,7 @@ static struct sd_option sheep_options[] = {
 	{'i', "ioaddr", true, "use separate network card to handle IO requests"},
 	{'j', "journal", true, "use jouranl file to log all the write operations"},
 	{'l', "loglevel", true, "specify the level of logging detail"},
+	{'n', "nosync", false, "drop SYNC for write, only used for testing purpose"},
 	{'o', "stdout", false, "log to stdout instead of shared logger"},
 	{'p', "port", true, "specify the TCP port on which to listen"},
 	{'P', "pidfile", true, "create a pid file"},
@@ -465,6 +466,9 @@ int main(int argc, char **argv)
 				exit(1);
 			}
 			break;
+		case 'n':
+			sys->nosync = true;
+			break;
 		case 'y':
 			if (!str_to_addr(optarg, sys->this_node.nid.addr)) {
 				fprintf(stderr, "Invalid address: '%s'\n",
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index e2536c5..e0f8bba 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -105,6 +105,7 @@ struct cluster_info {
 
 	bool gateway_only;
 	bool disable_recovery;
+	bool nosync;
 
 	struct work_queue *gateway_wqueue;
 	struct work_queue *io_wqueue;
-- 
1.7.9.5




More information about the sheepdog mailing list