]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: osd_objectstore_fuse
authorSage Weil <sage@redhat.com>
Wed, 6 Jan 2016 22:56:12 +0000 (17:56 -0500)
committerSage Weil <sage@redhat.com>
Wed, 27 Jan 2016 19:06:12 +0000 (14:06 -0500)
Expose underlying ObjectStore via fuse at $osd_data/fuse/.  Can be enabled/
disabled at runtime.

Signed-off-by: Sage Weil <sage@redhat.com>
src/CMakeLists.txt
src/common/config_opts.h
src/osd/OSD.cc
src/osd/OSD.h

index 254947e109b3c2dfff3e849d4d8e9e195a2c4081..371587e38df7470d01cbb3969dc3999957a49b2e 100644 (file)
@@ -727,7 +727,7 @@ add_executable(ceph-osd ${ceph_osd_srcs}
   $<TARGET_OBJECTS:heap_profiler_objs>
   $<TARGET_OBJECTS:common_util_obj>)
 add_dependencies(ceph-osd erasure_code_plugins)
-target_link_libraries(ceph-osd osd os global ${BLKID_LIBRARIES} ${ALLOC_LIBS})
+target_link_libraries(ceph-osd osd os global ${BLKID_LIBRARIES} ${ALLOC_LIBS} fuse)
 install(TARGETS ceph-osd DESTINATION bin)
 
 # MDS
index f0277be2b402d97a339b7917dec870df827e724c..a5f4afd1dedec12ea1aa66cc947fa98f8c783c03 100644 (file)
@@ -833,6 +833,7 @@ OPTION(osd_objectstore_tracing, OPT_BOOL, false) // true if LTTng-UST tracepoint
 // Override maintaining compatibility with older OSDs
 // Set to true for testing.  Users should NOT set this.
 OPTION(osd_debug_override_acting_compat, OPT_BOOL, false)
+OPTION(osd_objectstore_fuse, OPT_BOOL, false)
 
 OPTION(osd_bench_small_size_max_iops, OPT_U32, 100) // 100 IOPS
 OPTION(osd_bench_large_size_max_throughput, OPT_U64, 100 << 20) // 100 MB/s
index a8889293adc324773a17c06d6fe57709952335c3..5c664be9f3108776776113345d37b525a23b9794 100644 (file)
@@ -44,6 +44,7 @@
 #include "common/io_priority.h"
 
 #include "os/ObjectStore.h"
+#include "os/FuseStore.h"
 
 #include "ReplicatedPG.h"
 
@@ -1549,6 +1550,7 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
   logger(NULL),
   recoverystate_perf(NULL),
   store(store_),
+  fuse_store(NULL),
   log_client(cct, client_messenger, &mc->monmap, LogClient::NO_FLAGS),
   clog(log_client.create_channel()),
   whoami(id),
@@ -1810,6 +1812,45 @@ public:
 
 };
 
+int OSD::enable_disable_fuse(bool stop)
+{
+  int r;
+  string mntpath = g_conf->osd_data + "/fuse";
+  if (fuse_store && (stop || !g_conf->osd_objectstore_fuse)) {
+    dout(1) << __func__ << " disabling" << dendl;
+    fuse_store->stop();
+    delete fuse_store;
+    fuse_store = NULL;
+    r = ::rmdir(mntpath.c_str());
+    if (r < 0)
+      r = -errno;
+    if (r < 0) {
+      derr << __func__ << " failed to rmdir " << mntpath << dendl;
+      return r;
+    }
+  }
+  if (!fuse_store && g_conf->osd_objectstore_fuse) {
+    dout(1) << __func__ << " enabling" << dendl;
+    r = ::mkdir(mntpath.c_str(), 0700);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " unable to create " << mntpath << ": "
+          << cpp_strerror(r) << dendl;
+      return r;
+    }
+    fuse_store = new FuseStore(store, mntpath);
+    r = fuse_store->start();
+    if (r < 0) {
+      derr << __func__ << " unable to start fuse: " << cpp_strerror(r) << dendl;
+      delete fuse_store;
+      fuse_store = NULL;
+      return r;
+    }
+  }
+  return 0;
+}
+
 int OSD::init()
 {
   CompatSet initial, diff;
@@ -1832,6 +1873,8 @@ int OSD::init()
     return r;
   }
 
+  enable_disable_fuse(false);
+
   dout(2) << "boot" << dendl;
 
   // initialize the daily loadavg with current 15min loadavg
@@ -2022,8 +2065,10 @@ monout:
   monc->shutdown();
 
 out:
+  enable_disable_fuse(true);
   store->umount();
   delete store;
+  store = NULL;
   return r;
 }
 
@@ -2455,6 +2500,7 @@ int OSD::shutdown()
   }
 
   dout(10) << "syncing store" << dendl;
+  enable_disable_fuse(true);
   store->umount();
   delete store;
   store = 0;
@@ -8568,6 +8614,7 @@ const char** OSD::get_tracked_conf_keys() const
     "clog_to_syslog",
     "clog_to_syslog_facility",
     "clog_to_syslog_level",
+    "osd_objectstore_fuse",
     NULL
   };
   return KEYS;
@@ -8612,6 +8659,11 @@ void OSD::handle_conf_change(const struct md_config_t *conf,
       changed.count("clog_to_syslog_facility")) {
     update_log_config();
   }
+  if (changed.count("osd_objectstore_fuse")) {
+    if (store) {
+      enable_disable_fuse(false);
+    }
+  }
 
   check_config();
 }
index 0b2bbbbea2faaff0841b8c1d648d3fece7338ca0..6faa5771abd435dc4cac28f71fefeed66cc68823 100644 (file)
@@ -202,6 +202,7 @@ class Message;
 class MonClient;
 class PerfCounters;
 class ObjectStore;
+class FuseStore;
 class OSDMap;
 class MLog;
 class MClass;
@@ -1079,6 +1080,7 @@ protected:
   PerfCounters      *logger;
   PerfCounters      *recoverystate_perf;
   ObjectStore *store;
+  FuseStore *fuse_store;
 
   LogClient log_client;
   LogChannelRef clog;
@@ -2354,6 +2356,8 @@ public:
   int init();
   void final_init();
 
+  int enable_disable_fuse(bool stop);
+
   void suicide(int exitcode);
   int shutdown();