]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/os/filestore/GenericFileStoreBackend.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / os / filestore / GenericFileStoreBackend.cc
index b21e3437f2e636496835438157f92b0c32b6d80d..a75d501f11fc2cd8f962e243fec733ecc6c0a3ab 100644 (file)
@@ -74,17 +74,10 @@ GenericFileStoreBackend::GenericFileStoreBackend(FileStore *fs):
     if (fd < 0) {
       return;
     }
-    char partition[PATH_MAX], devname[PATH_MAX];
-    int r = get_device_by_fd(fd, partition, devname, sizeof(devname));
-    if (r < 0) {
-      dout(1) << "unable to get device name for " << get_basedir_path() << ": "
-             << cpp_strerror(r) << dendl;
-      m_rotational = true;
-    } else {
-      m_rotational = block_device_is_rotational(devname);
-      dout(20) << __func__ << " devname " << devname
-              << " rotational " << (int)m_rotational << dendl;
-    }
+    BlkDev blkdev(fd);
+    m_rotational = blkdev.is_rotational();
+    dout(20) << __func__ << " basedir " << fn
+            << " rotational " << (int)m_rotational << dendl;
     ::close(fd);
   }
   // journal rotational?
@@ -95,17 +88,10 @@ GenericFileStoreBackend::GenericFileStoreBackend(FileStore *fs):
     if (fd < 0) {
       return;
     }
-    char partition[PATH_MAX], devname[PATH_MAX];
-    int r = get_device_by_fd(fd, partition, devname, sizeof(devname));
-    if (r < 0) {
-      dout(1) << "unable to get journal device name for "
-              << get_journal_path() << ": " << cpp_strerror(r) << dendl;
-      m_journal_rotational = true;
-    } else {
-      m_journal_rotational = block_device_is_rotational(devname);
-      dout(20) << __func__ << " journal devname " << devname
-               << " journal rotational " << (int)m_journal_rotational << dendl;
-    }
+    BlkDev blkdev(fd);
+    m_journal_rotational = blkdev.is_rotational();
+    dout(20) << __func__ << " journal filename " << fn.c_str()
+            << " journal rotational " << (int)m_journal_rotational << dendl;
     ::close(fd);
   }
 }
@@ -332,7 +318,7 @@ int GenericFileStoreBackend::do_fiemap(int fd, off_t start, size_t len, struct f
   fiemap->fm_length = len + start % CEPH_PAGE_SIZE;
   fiemap->fm_flags = FIEMAP_FLAG_SYNC; /* flush extents to disk if needed */
 
-#if defined(DARWIN) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
   ret = -ENOTSUP;
   goto done_err;
 #else
@@ -356,7 +342,7 @@ int GenericFileStoreBackend::do_fiemap(int fd, off_t start, size_t len, struct f
   fiemap->fm_extent_count = fiemap->fm_mapped_extents;
   fiemap->fm_mapped_extents = 0;
 
-#if defined(DARWIN) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
   ret = -ENOTSUP;
   goto done_err;
 #else
@@ -396,9 +382,9 @@ int GenericFileStoreBackend::_crc_load_or_init(int fd, SloppyCRCMap *cm)
   }
   bufferlist bl;
   bl.append(std::move(bp));
-  bufferlist::iterator p = bl.begin();
+  auto p = bl.cbegin();
   try {
-    ::decode(*cm, p);
+    decode(*cm, p);
   }
   catch (buffer::error &e) {
     r = -EIO;
@@ -411,7 +397,7 @@ int GenericFileStoreBackend::_crc_load_or_init(int fd, SloppyCRCMap *cm)
 int GenericFileStoreBackend::_crc_save(int fd, SloppyCRCMap *cm)
 {
   bufferlist bl;
-  ::encode(*cm, bl);
+  encode(*cm, bl);
   int r = chain_fsetxattr(fd, SLOPPY_CRC_XATTR, bl.c_str(), bl.length());
   if (r < 0)
     derr << __func__ << " got " << cpp_strerror(r) << dendl;