]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
blk: use choose_fd for all filehandle references wjw-wip-bluestore-choose_fdv3
authorWillem Jan Withagen <wjw@digiware.nl>
Sat, 26 Jun 2021 13:24:17 +0000 (15:24 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Sat, 26 Jun 2021 13:38:13 +0000 (15:38 +0200)
This is a leading part of the changes to implement bluestore on
FreeBSD. Without this invalid indexing in the descriptor arrays
will occur.

Creates a new enum: `blk_access_mode_t`
to describe `BUFFERED` and `DIRECT `mode access
with `choose_fd()` to get the correct file for the typed access
and adds
a pretty-printer
boolean convertor `blk_access_mode_t::buffermode(bool)`

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/blk/BlockDevice.cc
src/blk/kernel/KernelDevice.cc
src/blk/kernel/KernelDevice.h

index d5d3169e9131e0f58b00d5a30c8a39b51d9a09e3..5932d0d33b5a46e4660d7cea31012772957e0d05 100644 (file)
 
 using std::string;
 
+std::ostream& operator<<(std::ostream& os, const blk_access_mode_t buffered)
+{
+  os << (buffered == blk_access_mode_t::BUFFERED ? "(buffered)" : "(direct)");
+  return os;
+}
+
+blk_access_mode_t buffermode(bool buffered) {
+  return buffered ? blk_access_mode_t::BUFFERED : blk_access_mode_t::DIRECT;
+}
+
 void IOContext::aio_wait()
 {
   std::unique_lock l(lock);
index 049a99de77fdb3ac614278efa46ce8887ce2aeff..ab4afbfd9651e477493b0ea9cb264746bf4603cb 100644 (file)
@@ -52,6 +52,11 @@ using ceph::make_timespan;
 using ceph::mono_clock;
 using ceph::operator <<;
 
+std::ostream& operator<<(std::ostream& os, const blk_access_mode_t buffered);
+blk_access_mode_t buffermode(bool buffered) {
+  return buffered ? blk_access_mode_t::BUFFERED : blk_access_mode_t::DIRECT;
+}
+
 KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
   : BlockDevice(cct, cb, cbpriv),
     aio(false), dio(false),
index 7ac9b1e7e1e3ab3a980c445982489dd9df919ff6..6a934fb3ad332f85d25da26fb0743afd19c8089c 100644 (file)
 
 #define RW_IO_MAX (INT_MAX & CEPH_PAGE_MASK)
 
+enum struct blk_access_mode_t {
+    DIRECT,
+    BUFFERED
+};
 
 class KernelDevice : public BlockDevice {
   std::vector<int> fd_directs, fd_buffereds;