From f85674a2d88725ce6005293d123116da145e03d4 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Wed, 28 Feb 2018 17:58:16 +0800 Subject: [PATCH] os/bluestore: make PMEMDevice work based on latest pmdk. Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlockDevice.cc | 9 +++++++-- src/os/bluestore/PMEMDevice.cc | 21 ++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index 3f91651990aec..dbca074c1bfab 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -99,11 +99,16 @@ BlockDevice *BlockDevice::create(CephContext* cct, const string& path, #if defined(HAVE_PMEM) if (type == "kernel") { int is_pmem = 0; - void *addr = pmem_map_file(path.c_str(), 1024*1024, PMEM_FILE_EXCL, O_RDONLY, NULL, &is_pmem); + size_t map_len = 0; + void *addr = pmem_map_file(path.c_str(), 0, PMEM_FILE_EXCL, O_RDONLY, &map_len, &is_pmem); if (addr != NULL) { if (is_pmem) type = "pmem"; - pmem_unmap(addr, 1024*1024); + else + dout(1) << path.c_str() << " isn't pmem file" << dendl; + pmem_unmap(addr, map_len); + } else { + dout(1) << "pmem_map_file:" << path.c_str() << " failed." << pmem_errormsg() << dendl; } } #endif diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 11f66706a9c34..666336de80fca 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -82,21 +82,11 @@ int PMEMDevice::open(const string& p) derr << __func__ << " fstat got " << cpp_strerror(r) << dendl; goto out_fail; } - if (S_ISBLK(st.st_mode)) { - int64_t s; - r = get_block_device_size(fd, &s); - if (r < 0) { - goto out_fail; - } - size = s; - } else { - size = st.st_size; - } size_t map_len; - addr = (char *)pmem_map_file(path.c_str(), size, PMEM_FILE_EXCL, O_RDWR, &map_len, NULL); + addr = (char *)pmem_map_file(path.c_str(), 0, PMEM_FILE_EXCL, O_RDWR, &map_len, NULL); if (addr == NULL) { - derr << __func__ << " pmem_map_file error" << dendl; + derr << __func__ << " pmem_map_file failed: " << pmem_errormsg() << dendl; goto out_fail; } size = map_len; @@ -210,6 +200,12 @@ int PMEMDevice::flush() void PMEMDevice::aio_submit(IOContext *ioc) { + if (ioc->priv) { + assert(ioc->num_running == 0); + aio_callback(aio_callback_priv, ioc->priv); + } else { + ioc->try_aio_wake(); + } return; } @@ -240,7 +236,6 @@ int PMEMDevice::write(uint64_t off, bufferlist& bl, bool buffered) len -= l; off1 += l; } - return 0; } -- 2.39.5