From: Sage Weil Date: Thu, 16 Apr 2015 21:08:55 +0000 (-0700) Subject: os/newstore: rebuild buffers to be page-aligned for O_DIRECT X-Git-Tag: v9.1.0~242^2~60 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfd389e66abb572c8504651cc539bbbf48a6128a;p=ceph.git os/newstore: rebuild buffers to be page-aligned for O_DIRECT Signed-off-by: Sage Weil --- diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index 9959a6795b5d..750f6dd6782d 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -2290,6 +2290,11 @@ int NewStore::_do_wal_transaction(wal_transaction_t& wt) (p->length & ~CEPH_PAGE_MASK) == 0) { dout(20) << __func__ << " page-aligned, using O_DIRECT" << dendl; flags |= O_DIRECT; + if (!p->data.is_page_aligned()) { + dout(20) << __func__ << " rebuilding buffer to be page-aligned" + << dendl; + p->data.rebuild(); + } } int fd = _open_fid(p->fid, flags); if (fd < 0) @@ -2982,11 +2987,12 @@ int NewStore::_do_write_all_overlays(TransContext *txc, int NewStore::_do_write(TransContext *txc, OnodeRef o, uint64_t offset, uint64_t length, - const bufferlist& bl, + bufferlist& bl, uint32_t fadvise_flags) { int fd = -1; int r = 0; + unsigned flags; dout(20) << __func__ << " have " << o->onode.size << " bytes in " << o->onode.data_map.size() @@ -3025,17 +3031,22 @@ int NewStore::_do_write(TransContext *txc, goto out; } + flags = O_RDWR; + if (g_conf->newstore_o_direct && + (offset & ~CEPH_PAGE_MASK) == 0 && + (length & ~CEPH_PAGE_MASK) == 0) { + dout(20) << __func__ << " page-aligned, can use O_DIRECT" << dendl; + flags |= O_DIRECT; + if (!bl.is_page_aligned()) { + dout(20) << __func__ << " rebuilding buffer to be page-aligned" << dendl; + bl.rebuild(); + } + } + if (o->onode.size <= offset || o->onode.size == 0 || o->onode.data_map.empty()) { _do_overlay_clear(txc, o); - unsigned flags = O_RDWR; - if (g_conf->newstore_o_direct && - (offset & ~CEPH_PAGE_MASK) == 0 && - (length & ~CEPH_PAGE_MASK) == 0) { - dout(20) << __func__ << " page-aligned, using O_DIRECT" << dendl; - flags |= O_DIRECT; - } if (o->onode.data_map.empty()) { // create fragment_t &f = o->onode.data_map[0]; @@ -3180,7 +3191,7 @@ int NewStore::_write(TransContext *txc, CollectionRef& c, const ghobject_t& oid, uint64_t offset, size_t length, - const bufferlist& bl, + bufferlist& bl, uint32_t fadvise_flags) { dout(15) << __func__ << " " << c->cid << " " << oid diff --git a/src/os/newstore/NewStore.h b/src/os/newstore/NewStore.h index 0fcd66e188ef..ba12cc6e3ecd 100644 --- a/src/os/newstore/NewStore.h +++ b/src/os/newstore/NewStore.h @@ -600,7 +600,7 @@ private: CollectionRef& c, const ghobject_t& oid, uint64_t offset, size_t len, - const bufferlist& bl, + bufferlist& bl, uint32_t fadvise_flags); int _do_overlay_clear(TransContext *txc, OnodeRef o); @@ -618,7 +618,7 @@ private: int _do_write(TransContext *txc, OnodeRef o, uint64_t offset, uint64_t length, - const bufferlist& bl, + bufferlist& bl, uint32_t fadvise_flags); int _touch(TransContext *txc, CollectionRef& c,