]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: make PMEMDevice work based on latest pmdk. 20411/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Wed, 28 Feb 2018 09:58:16 +0000 (17:58 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Wed, 28 Feb 2018 10:13:54 +0000 (18:13 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlockDevice.cc
src/os/bluestore/PMEMDevice.cc

index 3f91651990aec99e4b7198c4ce4a17b1f599187d..dbca074c1bfabefcfc3ef7b94633521d762110b8 100644 (file)
@@ -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
index 11f66706a9c348c29fbcddab4132663a99677809..666336de80fca5310cf674ab265457fcacee18f9 100644 (file)
@@ -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;
 }