[sheepdog] [PATCH] sheep: disable journal by default

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Sep 7 11:17:01 CEST 2012


It seems that most modern disk drives implement atomic sector writes
(e.g. section 7.4 in http://www.sqlite.org/atomiccommit.html).  If it
is true, we don't need to use journal for vdi object updates because
we don't update them across a sector boundary.

This patch uses atomic_put() for vdi creation, and doesn't use journal
for vdi updates by default.

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

diff --git a/sheep/ops.c b/sheep/ops.c
index 6aff0d5..4c0426f 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -886,7 +886,10 @@ static int do_write_obj(struct siocb *iocb, struct sd_req *hdr, uint32_t epoch,
 	iocb->buf = data;
 	iocb->length = hdr->data_length;
 	iocb->offset = hdr->obj.offset;
-	if (is_vdi_obj(oid)) {
+
+	if (is_vdi_obj(oid) && create)
+		ret = sd_store->atomic_put(oid, iocb);
+	else if (is_vdi_obj(oid) && sys->use_journal) {
 		struct strbuf buf = STRBUF_INIT;
 
 		strbuf_addf(&buf, "%s%016" PRIx64, obj_path, oid);
diff --git a/sheep/sheep.c b/sheep/sheep.c
index b09443f..cdf447d 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -43,6 +43,7 @@ static struct option const long_options[] = {
 	{"foreground", no_argument, NULL, 'f'},
 	{"gateway", no_argument, NULL, 'g'},
 	{"help", no_argument, NULL, 'h'},
+	{"journal", no_argument, NULL, 'j'},
 	{"loglevel", required_argument, NULL, 'l'},
 	{"myaddr", required_argument, NULL, 'y'},
 	{"stdout", no_argument, NULL, 'o'},
@@ -54,7 +55,7 @@ static struct option const long_options[] = {
 	{NULL, 0, NULL, 0},
 };
 
-static const char *short_options = "c:dDfghl:op:P:s:w:y:z:";
+static const char *short_options = "c:dDfghjl:op:P:s:w:y:z:";
 
 static void usage(int status)
 {
@@ -71,6 +72,7 @@ Options:\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\
+  -j, --journal           use jouranl to update vdi objects\n\
   -l, --loglevel          specify the level of logging detail\n\
   -o, --stdout            log to stdout instead of shared logger\n\
   -p, --port              specify the TCP port on which to listen\n\
@@ -409,6 +411,9 @@ int main(int argc, char **argv)
 		case 'w':
 			init_cache_type(optarg);
 			break;
+		case 'j':
+			sys->use_journal = true;
+			break;
 		case 'h':
 			usage(0);
 			break;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index b31328a..5cd9d3f 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -122,6 +122,8 @@ struct cluster_info {
 
 	uint64_t object_cache_size;
 	bool object_cache_directio;
+
+	bool use_journal;
 };
 
 struct siocb {
-- 
1.7.2.5




More information about the sheepdog mailing list