From: Sage Weil Date: Mon, 20 Apr 2015 19:49:46 +0000 (-0700) Subject: os/newstore: combined O_DSYNC with O_DIRECT X-Git-Tag: v9.1.0~242^2~54 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d8e14653dcfc140da3d37af3b185dc204d47def;p=ceph.git 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 --- diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index 7de2092308d9..6cbbef8cbdd6 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; }