[Sheepdog] [PATCH 1/2] use O_DSYNC instead of O_SYNC
Christoph Hellwig
hch at infradead.org
Thu Nov 10 22:55:43 CET 2011
Using O_DSYNC means we do not have to write out the inode if we are
overwriting full allocated blocks. For sheepdog that is a fairly usual
use case when blocks in an image has already been allocated and the guest
OS overwrites previously deleted blocks with new data.
Signed-off-by: Christoph Hellwig <hch at lst.de>
Index: sheepdog/sheep/journal.c
===================================================================
--- sheepdog.orig/sheep/journal.c 2011-11-10 21:24:20.851800458 +0100
+++ sheepdog/sheep/journal.c 2011-11-10 21:24:29.227795709 +0100
@@ -65,7 +65,7 @@ static int jrnl_close(struct jrnl_descri
static int jrnl_create(struct jrnl_descriptor *jd, const char *jrnl_dir)
{
snprintf(jd->path, sizeof(jd->path), "%sXXXXXX", jrnl_dir);
- jd->fd = mkostemp(jd->path, O_SYNC);
+ jd->fd = mkostemp(jd->path, O_DSYNC);
if (jd->fd < 0) {
eprintf("failed to create %s: %m\n", jd->path);
@@ -283,7 +283,7 @@ int jrnl_recover(const char *jrnl_dir)
}
if (!jrnl_has_end_mark(&jd))
goto end_while_2;
- jd.target_fd = open(jd.head.target_path, O_SYNC | O_RDWR);
+ jd.target_fd = open(jd.head.target_path, O_DSYNC | O_RDWR);
if (ret) {
eprintf("unable to open the object file %s for recovery\n",
jd.head.target_path);
Index: sheepdog/sheep/store.c
===================================================================
--- sheepdog.orig/sheep/store.c 2011-11-10 21:24:20.871799279 +0100
+++ sheepdog/sheep/store.c 2011-11-10 21:24:45.804065749 +0100
@@ -439,7 +439,7 @@ static int ob_open(uint32_t epoch, uint6
if (sys->use_directio && is_data_obj(oid))
flags = O_DIRECT | O_RDWR | aflags;
else
- flags = O_SYNC | O_RDWR | aflags;
+ flags = O_DSYNC | O_RDWR | aflags;
snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path, epoch, oid);
@@ -482,7 +482,7 @@ int update_epoch_log(int epoch)
dprintf("update epoch: %d, %d\n", epoch, sys->nr_nodes);
snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);
- fd = open(path, O_RDWR | O_CREAT | O_SYNC, def_fmode);
+ fd = open(path, O_RDWR | O_CREAT | O_DSYNC, def_fmode);
if (fd < 0) {
ret = fd;
goto err_open;
@@ -1008,7 +1008,7 @@ int set_cluster_ctime(uint64_t ct)
{
int fd, ret;
- fd = open(config_path, O_SYNC | O_WRONLY);
+ fd = open(config_path, O_DSYNC | O_WRONLY);
if (fd < 0)
return -1;
@@ -1310,7 +1310,7 @@ next:
if (rsp->result == SD_RES_SUCCESS) {
char path[PATH_MAX], tmp_path[PATH_MAX];
- int flags = O_SYNC | O_RDWR | O_CREAT;
+ int flags = O_DSYNC | O_RDWR | O_CREAT;
snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path,
epoch, oid);
@@ -2043,7 +2043,7 @@ int set_cluster_copies(uint8_t copies)
{
int fd, ret;
- fd = open(config_path, O_SYNC | O_WRONLY);
+ fd = open(config_path, O_DSYNC | O_WRONLY);
if (fd < 0)
return SD_RES_EIO;
@@ -2080,7 +2080,7 @@ int set_cluster_flags(uint16_t flags)
{
int fd, ret = SD_RES_EIO;
- fd = open(config_path, O_SYNC | O_WRONLY);
+ fd = open(config_path, O_DSYNC | O_WRONLY);
if (fd < 0)
goto out;
More information about the sheepdog
mailing list