]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/newstore: combined O_DSYNC with O_DIRECT
authorSage Weil <sage@redhat.com>
Mon, 20 Apr 2015 19:49:46 +0000 (12:49 -0700)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:39 +0000 (13:39 -0400)
This avoids the need for an explicit fdatasync when doing O_DIRECT.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/newstore/NewStore.cc

index 7de2092308d919968a20210e37cbbdd2ff458ba6..6cbbef8cbdd6552afae0014c06efc1a61c55e8fe 100644 (file)
@@ -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;
   }