[Sheepdog] [PATCH] store: use O_DIRECT IO for backend store
Liu Yuan
namei.unix at gmail.com
Mon Apr 2 11:49:57 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
Backend store don't need page cache, by this way we make room of memory for
object cache to maximize its performance.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/farm/farm.c | 9 ++++++---
sheep/simple_store.c | 6 +++---
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index fa008ea..7a9e9e5 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -20,7 +20,7 @@
char farm_obj_dir[PATH_MAX];
char farm_dir[PATH_MAX];
-static int def_open_flags = O_DSYNC | O_RDWR;
+static int def_open_flags = O_DIRECT | O_DSYNC | O_RDWR;
extern char *obj_path;
extern mode_t def_fmode;
extern mode_t def_dmode;
@@ -153,8 +153,8 @@ static int farm_open(uint64_t oid, struct siocb *iocb, int create)
if (iocb->epoch < sys->epoch)
goto out;
- if (sys->use_directio && is_data_obj(oid))
- flags |= O_DIRECT;
+ if (is_vdi_obj(oid))
+ flags &= ~O_DIRECT;
if (create)
flags |= O_CREAT | O_TRUNC;
@@ -397,6 +397,9 @@ static int farm_atomic_put(uint64_t oid, struct siocb *iocb)
snprintf(path, sizeof(path), "%s%016" PRIx64, obj_path, oid);
snprintf(tmp_path, sizeof(tmp_path), "%s%016" PRIx64 ".tmp",
obj_path, oid);
+
+ if (is_vdi_obj(oid))
+ flags &= ~O_DIRECT;
fd = open(tmp_path, flags, def_fmode);
if (fd < 0) {
eprintf("failed to open %s: %m\n", tmp_path);
diff --git a/sheep/simple_store.c b/sheep/simple_store.c
index dd3c62d..f1077f7 100644
--- a/sheep/simple_store.c
+++ b/sheep/simple_store.c
@@ -30,7 +30,7 @@ extern char *obj_path;
extern mode_t def_fmode;
-static int def_store_flags = O_DSYNC | O_RDWR;
+static int def_store_flags = O_DIRECT | O_DSYNC | O_RDWR;
static int simple_store_write(uint64_t oid, struct siocb *iocb);
@@ -108,8 +108,8 @@ static int simple_store_open(uint64_t oid, struct siocb *iocb, int create)
int ret;
int flags = def_store_flags;
- if (sys->use_directio && is_data_obj(oid))
- flags |= O_DIRECT;
+ if (is_vdi_obj(oid))
+ flags &= ~O_DIRECT;
if (create)
flags |= O_CREAT | O_TRUNC;
--
1.7.8.2
More information about the sheepdog
mailing list