osd: osd_objectstore_fuse

Expose underlying ObjectStore via fuse at $osd_data/fuse/.  Can be enabled/
disabled at runtime.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-01-06 17:56:12 -05:00
parent 96643e9cc3
commit d01967d372
4 changed files with 58 additions and 1 deletions

View 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

View 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

View 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();
}

View 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();