Skip to content

Commit

Permalink
O_DIRECT is not a replacement for O_DSYNC
Browse files Browse the repository at this point in the history
Even if a file is opened with O_DIRECT we still need O_DSYNC / fdatasync
to make sure all metadata required to find the data made it to disk.

Also clean up the flags handling in ob_open a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
  • Loading branch information
Christoph Hellwig authored and kazum committed Nov 11, 2011
1 parent 9c043dd commit 873d74b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sheep/store.c
Expand Up @@ -158,7 +158,7 @@ int get_obj_list(const struct sd_list_req *hdr, struct sd_list_rsp *rsp, void *d
return res;
}

static int ob_open(uint32_t epoch, uint64_t oid, int aflags, int *ret);
static int ob_open(uint32_t epoch, uint64_t oid, int flags, int *ret);

static int read_from_one(struct request *req, uint32_t epoch, uint64_t oid,
unsigned *ori_rlen, void *buf, uint64_t offset)
Expand Down Expand Up @@ -430,16 +430,14 @@ static int forward_write_obj_req(struct request *req, int idx)
return ret;
}

static int ob_open(uint32_t epoch, uint64_t oid, int aflags, int *ret)
static int ob_open(uint32_t epoch, uint64_t oid, int flags, int *ret)
{
char path[1024];
int flags;
int fd;

flags |= O_DSYNC | O_RDWR;
if (sys->use_directio && is_data_obj(oid))
flags = O_DIRECT | O_RDWR | aflags;
else
flags = O_DSYNC | O_RDWR | aflags;
flags |= O_DIRECT;

snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path, epoch, oid);

Expand Down

0 comments on commit 873d74b

Please sign in to comment.