Skip to content

Commit

Permalink
Initial changes for object store factory
Browse files Browse the repository at this point in the history
Signed-off-by: Varada Kari <varada.kari@sandisk.com>
  • Loading branch information
Varada Kari committed Jun 22, 2015
1 parent 294bef3 commit 9d5fe2f
Show file tree
Hide file tree
Showing 91 changed files with 1,380 additions and 230 deletions.
12 changes: 7 additions & 5 deletions src/Makefile-env.am
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AM_CCASFLAGS = -f elf64
#####################
## library definitions and dependencies

EXTRALIBS = -luuid -lm
EXTRALIBS = -luuid -lm -lleveldb
if FREEBSD
EXTRALIBS += -lexecinfo
endif # FREEBSD
Expand All @@ -140,7 +140,9 @@ LIBCRUSH = libcrush.la
LIBJSON_SPIRIT = libjson_spirit.la
LIBLOG = liblog.la
LIBOS = libos.la
LIBOS_TYPES = libos_types.la
LIBKVSTORE = libceph_keyvaluestore.la
LIBMEMSTORE = libceph_memstore.la
LIBFILESTORE = libceph_filestore.la
LIBOSD = libosd.la
LIBOSD_TYPES = libosd_types.la
LIBOSDC = libosdc.la
Expand Down Expand Up @@ -168,11 +170,11 @@ LIBOS += -laio
endif # WITH_LIBAIO

if WITH_LIBZFS
LIBOS += libos_zfs.a -lzfs
LIBFILESTORE += libceph_filestore_zfs.a -lzfs
endif # WITH_LIBZFS

if WITH_LIBROCKSDB
LIBOS += libos_rocksdb.la
LIBKVSTORE += libceph_keyvaluestore_rocksdb.la
endif # WITH_LIBROCKSDB

if WITH_TCMALLOC
Expand All @@ -199,7 +201,7 @@ LIBOSD += $(LIBPERFGLUE)
LIBMDS += $(LIBPERFGLUE)

# Always use system leveldb
LIBOS += -lleveldb -lsnappy
LIBKVSTORE += -lleveldb -lsnappy

# Use this for binaries requiring libglobal
CEPH_GLOBAL = $(LIBGLOBAL) $(LIBCOMMON) $(PTHREAD_LIBS) -lm $(CRYPTO_LIBS) $(EXTRALIBS)
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile-server.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ su_sbin_SCRIPTS += mount.fuse.ceph
if WITH_MON

ceph_mon_SOURCES = ceph_mon.cc
ceph_mon_LDADD = $(LIBMON) $(LIBOS) $(CEPH_GLOBAL) $(LIBCOMMON)
ceph_mon_LDADD = $(LIBMON) $(LIBOS) $(CEPH_GLOBAL) $(LIBCOMMON) $(LIBKVSTORE)
bin_PROGRAMS += ceph-mon

endif # WITH_MON
Expand All @@ -45,7 +45,7 @@ bin_SCRIPTS += \
ceph-clsinfo

ceph_osd_SOURCES = ceph_osd.cc
ceph_osd_LDADD = $(LIBOSD) $(CEPH_GLOBAL) $(LIBCOMMON)
ceph_osd_LDADD = $(LIBOSD) $(CEPH_GLOBAL) $(LIBCOMMON) $(LIBKVSTORE) $(LIBFILESTORE) $(LIBMEMSTORE)
bin_PROGRAMS += ceph-osd

endif # WITH_OSD
Expand Down
11 changes: 11 additions & 0 deletions src/ceph_osd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ int preload_erasure_code()
return r;
}

int preload_plugins()
{
stringstream ss;
PluginRegistry *reg = g_ceph_context->get_plugin_registry();
assert(reg);
int r = reg->load("objectstore", g_conf->osd_objectstore);
return r;
}

int main(int argc, const char **argv)
{
vector<const char*> args;
Expand Down Expand Up @@ -206,6 +215,8 @@ int main(int argc, const char **argv)
derr << "must specify '--osd-data=foo' data path" << dendl;
usage();
}
if (preload_plugins() < 0)
return -1;

// the store
ObjectStore *store = ObjectStore::create(g_ceph_context,
Expand Down
2 changes: 1 addition & 1 deletion src/common/PluginRegistry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Plugin *PluginRegistry::get(const std::string& type,
int PluginRegistry::load(const std::string &type,
const std::string &name)
{
assert(lock.is_locked());
Mutex::Locker l(lock);
ldout(cct, 10) << __func__ << " " << type << " " << name << dendl;

std::string fname = cct->_conf->plugin_dir + "/" + type + "/" PLUGIN_PREFIX
Expand Down
2 changes: 1 addition & 1 deletion src/common/PluginRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#ifndef CEPH_COMMON_PLUGINREGISTRY_H
#define CEPH_COMMON_PLUGINREGISTERY_H
#define CEPH_COMMON_PLUGINREGISTRY_H

#include <string>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion src/common/sync_filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# ifndef DARWIN
# include <sys/ioctl.h>
# include <syscall.h>
# include "../os/btrfs_ioctl.h"
# include "../os/filestore/btrfs_ioctl.h"
# endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mon/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ libmon_la_SOURCES = \
mon/HealthMonitor.cc \
mon/DataHealthService.cc \
mon/ConfigKeyService.cc
libmon_la_LIBADD = $(LIBAUTH) $(LIBCOMMON) $(LIBOS) $(LIBMON_TYPES)
libmon_la_LIBADD = $(LIBAUTH) $(LIBCOMMON) $(LIBOS) $(LIBFILESTORE) $(LIBMEMSTORE) $(LIBKVSTORE) $(LIBMON_TYPES)
noinst_LTLIBRARIES += libmon.la

noinst_HEADERS += \
Expand Down
2 changes: 1 addition & 1 deletion src/mon/MonitorDBStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string>
#include <boost/scoped_ptr.hpp>
#include <sstream>
#include "os/KeyValueDB.h"
#include "os/keyvaluestore/KeyValueDB.h"

#include "include/assert.h"
#include "common/Formatter.h"
Expand Down
101 changes: 9 additions & 92 deletions src/os/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,105 +1,22 @@
libos_types_la_SOURCES = \
os/Transaction.cc
libos_types_la_CXXFLAGS = ${AM_CXXFLAGS}
noinst_LTLIBRARIES += libos_types.la
include os/filestore/Makefile.am
include os/keyvaluestore/Makefile.am
include os/memstore/Makefile.am

if ENABLE_SERVER

noinst_HEADERS += \
os/ObjectStore.h

libos_la_SOURCES = \
os/chain_xattr.cc \
os/DBObjectMap.cc \
os/GenericObjectMap.cc \
os/FileJournal.cc \
os/FileStore.cc \
os/FlatIndex.cc \
os/GenericFileStoreBackend.cc \
os/HashIndex.cc \
os/IndexManager.cc \
os/JournalingObjectStore.cc \
os/LevelDBStore.cc \
os/LFNIndex.cc \
os/MemStore.cc \
os/KeyValueDB.cc \
os/KeyValueStore.cc \
os/ObjectStore.cc \
os/WBThrottle.cc \
os/KeyValueDB.cc \
os/Transaction.cc \
common/TrackedOp.cc

if LINUX
libos_la_SOURCES += os/BtrfsFileStoreBackend.cc
endif

if WITH_LIBXFS
libos_la_SOURCES += os/XfsFileStoreBackend.cc
endif

if WITH_LIBZFS
libos_la_SOURCES += os/ZFSFileStoreBackend.cc
endif

libos_la_CXXFLAGS = ${AM_CXXFLAGS}
libos_la_LIBADD = $(LIBOS_TYPES)
#libos_la_LIBADD = $(LIBOS_TYPES)
if WITH_LTTNG
libos_la_LIBADD += $(LIBOS_TP)
libos_la_LIBADD = $(LIBOS_TP)
endif

noinst_LTLIBRARIES += libos.la

noinst_HEADERS += \
os/btrfs_ioctl.h \
os/chain_xattr.h \
os/BtrfsFileStoreBackend.h \
os/CollectionIndex.h \
os/DBObjectMap.h \
os/GenericObjectMap.h \
os/FileJournal.h \
os/FileStore.h \
os/FlatIndex.h \
os/FDCache.h \
os/GenericFileStoreBackend.h \
os/HashIndex.h \
os/IndexManager.h \
os/Journal.h \
os/JournalingObjectStore.h \
os/KeyValueDB.h \
os/LevelDBStore.h \
os/LFNIndex.h \
os/MemStore.h \
os/KeyValueStore.h \
os/ObjectMap.h \
os/ObjectStore.h \
os/SequencerPosition.h \
os/WBThrottle.h \
os/XfsFileStoreBackend.h \
os/ZFSFileStoreBackend.h

if WITH_SLIBROCKSDB
libos_rocksdb_la_SOURCES = os/RocksDBStore.cc
libos_rocksdb_la_CXXFLAGS = ${AM_CXXFLAGS} ${LIBROCKSDB_CFLAGS} -std=gnu++11 -I rocksdb/include
libos_rocksdb_la_LIBADD = rocksdb/librocksdb.la
noinst_LTLIBRARIES += libos_rocksdb.la
noinst_HEADERS += os/RocksDBStore.h
endif
if WITH_DLIBROCKSDB
libos_rocksdb_la_SOURCES = os/RocksDBStore.cc
libos_rocksdb_la_CXXFLAGS = ${AM_CXXFLAGS} ${LIBROCKSDB_CFLAGS} -std=gnu++11
libos_rocksdb_la_LIBADD = -lrocksdb
noinst_LTLIBRARIES += libos_rocksdb.la
noinst_HEADERS += os/RocksDBStore.h
endif
if WITH_LIBZFS
libos_zfs_a_SOURCES = os/ZFS.cc
libos_zfs_a_CXXFLAGS = ${AM_CXXFLAGS} ${LIBZFS_CFLAGS}
noinst_LIBRARIES += libos_zfs.a
noinst_HEADERS += os/ZFS.h
endif

if WITH_KINETIC
libos_la_SOURCES += os/KineticStore.cc
libos_la_CXXFLAGS += -std=gnu++11
libos_la_LIBADD += -lkinetic_client -lprotobuf -lglog -lgflags libcrypto.a
noinst_HEADERS += os/KineticStore.h
endif

endif # ENABLE_SERVER
24 changes: 7 additions & 17 deletions src/os/ObjectStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "include/memory.h"
#include "ObjectStore.h"
#include "common/Formatter.h"
#include "FileStore.h"
#include "MemStore.h"
#include "KeyValueStore.h"
#include "filestore/FileStore.h"
#include "memstore/MemStore.h"
#include "keyvaluestore/KeyValueStore.h"
#include "common/safe_io.h"

ObjectStore *ObjectStore::create(CephContext *cct,
Expand All @@ -27,25 +27,17 @@ ObjectStore *ObjectStore::create(CephContext *cct,
const string& journal,
osflagbits_t flags)
{
if (type == "filestore") {
return new FileStore(data, journal, flags);
}
if (type == "memstore") {
return new MemStore(cct, data);
}
if (type == "keyvaluestore" &&
cct->check_experimental_feature_enabled("keyvaluestore")) {
return new KeyValueStore(data);
}

PluginRegistry *reg = cct->get_plugin_registry();

// assuming we have preloaded the all the supported types
Factory *factory = dynamic_cast<Factory*>(reg->get("objectstore", type));
if (factory) {
return factory->factory(cct, type, data, journal, flags);
}
return NULL;
}

#if 0
int ObjectStore::write_meta(const std::string& key,
const std::string& value)
{
Expand Down Expand Up @@ -74,13 +66,11 @@ int ObjectStore::read_meta(const std::string& key,
return 0;
}




ostream& operator<<(ostream& out, const ObjectStore::Sequencer& s)
{
return out << "osr(" << s.get_name() << " " << &s << ")";
}
#endif

unsigned ObjectStore::apply_transactions(Sequencer *osr,
list<Transaction*> &tls,
Expand Down
Loading

0 comments on commit 9d5fe2f

Please sign in to comment.