From 5d8e14653dcfc140da3d37af3b185dc204d47def Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 20 Apr 2015 12:49:46 -0700 Subject: [PATCH] os/newstore: combined O_DSYNC with O_DIRECT This avoids the need for an explicit fdatasync when doing O_DIRECT. Signed-off-by: Sage Weil --- src/os/newstore/NewStore.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index 7de2092308d91..6cbbef8cbdd65 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -2362,7 +2362,7 @@ int NewStore::_do_wal_transaction(wal_transaction_t& wt) (p->length & ~CEPH_PAGE_MASK) == 0) { dout(20) << __func__ << " page-aligned io, using O_DIRECT, " << p->data.buffers().size() << " buffers" << dendl; - flags |= O_DIRECT; + flags |= O_DIRECT | O_DSYNC; if (!p->data.is_page_aligned()) { dout(20) << __func__ << " rebuilding buffer to be page-aligned" << dendl; @@ -2385,7 +2385,9 @@ int NewStore::_do_wal_transaction(wal_transaction_t& wt) << cpp_strerror(r) << dendl; return r; } - sync_fds.push_back(fd); + if (!(flags & O_DSYNC)) { + sync_fds.push_back(fd); + } } break; case wal_op_t::OP_ZERO: @@ -3139,7 +3141,7 @@ int NewStore::_do_write(TransContext *txc, (length & ~CEPH_PAGE_MASK) == 0) { dout(20) << __func__ << " page-aligned, can use O_DIRECT, " << bl.buffers().size() << " buffers" << dendl; - flags |= O_DIRECT; + flags |= O_DIRECT | O_DSYNC; if (!bl.is_page_aligned()) { dout(20) << __func__ << " rebuilding buffer to be page-aligned" << dendl; bl.rebuild(); @@ -3202,7 +3204,9 @@ int NewStore::_do_write(TransContext *txc, goto out; } } - txc->sync_fd(fd); + if (!(flags & O_DSYNC)) { + txc->sync_fd(fd); + } r = 0; goto out; } -- 2.39.5