Skip to content

Commit

Permalink
Merge remote-tracking branch 'me/wip-fusestore' into wip-sage-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
liewegas committed Jan 11, 2016
2 parents ae2e524 + 16f98e6 commit b26c24f
Show file tree
Hide file tree
Showing 24 changed files with 1,605 additions and 95 deletions.
15 changes: 11 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ endif(USE_NSS)

set(GCOV_PREFIX_STRIP 4)

get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
git_describe(CEPH_GIT_NICE_VER --always)
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
git_describe(CEPH_GIT_NICE_VER --always)
else(${ENABLE_GIT_VERSION})
set(CEPH_GIT_VER "no_version")
set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})

# Python stuff
find_package(PythonInterp 2 QUIET)
Expand Down Expand Up @@ -457,7 +463,7 @@ add_executable(ceph-objectstore-tool
tools/RadosDump.cc
$<TARGET_OBJECTS:common_util_obj>
$<TARGET_OBJECTS:heap_profiler_objs>)
target_link_libraries(ceph-objectstore-tool tcmalloc osd os global ${Boost_PROGRAM_OPTIONS_LIBRARY} dl)
target_link_libraries(ceph-objectstore-tool tcmalloc osd os global ${Boost_PROGRAM_OPTIONS_LIBRARY} fuse dl)
install(TARGETS ceph-objectstore-tool DESTINATION bin)


Expand Down Expand Up @@ -621,6 +627,7 @@ if(${HAVE_XFS})
os/fs/XFS.cc)
endif(${HAVE_XFS})
set(libos_srcs
os/FuseStore.cc
os/ObjectStore.cc
os/Transaction.cc
os/filestore/chain_xattr.cc
Expand Down Expand Up @@ -724,7 +731,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
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile-env.am
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ LIBKV += -llz4
endif
endif # WITH_SLIBROCKSDB
LIBKV += -lz -lleveldb -lsnappy
LIBOS += $(LIBOS_TYPES) $(LIBKV)
LIBOS += $(LIBOS_TYPES) $(LIBKV) $(LIBFUSE_LIBS)

LIBMON += $(LIBMON_TYPES)

Expand Down
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ SUBSYS(bdev, 1, 3)
SUBSYS(kstore, 1, 5)
SUBSYS(rocksdb, 4, 5)
SUBSYS(leveldb, 4, 5)
SUBSYS(fuse, 1, 5)

OPTION(key, OPT_STR, "")
OPTION(keyfile, OPT_STR, "")
Expand Down Expand Up @@ -823,6 +824,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
Expand Down
171 changes: 159 additions & 12 deletions src/common/hobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,124 @@ void hobject_t::generate_test_instances(list<hobject_t*>& o)
CEPH_SNAPDIR, 910, 1, "n2"));
}

static void append_out_escaped(const string &in, string *out)
{
for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
if (*i == '%' || *i == ':' || *i == '/' || *i < 32 || *i >= 127) {
out->push_back('%');
char buf[3];
snprintf(buf, sizeof(buf), "%02x", (int)(unsigned char)*i);
out->append(buf);
} else {
out->push_back(*i);
}
}
}

static const char *decode_out_escaped(const char *in, string *out)
{
while (*in && *in != ':') {
if (*in == '%') {
++in;
char buf[3];
buf[0] = *in;
++in;
buf[1] = *in;
buf[2] = 0;
int v = strtol(buf, NULL, 16);
out->push_back(v);
} else {
out->push_back(*in);
}
++in;
}
return in;
}

ostream& operator<<(ostream& out, const hobject_t& o)
{
if (o == hobject_t())
return out << "MIN";
if (o.is_max())
return out << "MAX";
out << o.pool << '/';
out << o.pool << ':';
out << std::hex;
out.width(8);
out.fill('0');
out << o.get_hash();
out << o.get_bitwise_key_u32(); // << '~' << o.get_hash();
out.width(0);
out.fill(' ');
out << std::dec;
if (o.nspace.length())
out << ":" << o.nspace;
if (o.get_key().length())
out << "." << o.get_key();
out << "/" << o.oid << "/" << o.snap;
out << ':';
string v;
append_out_escaped(o.nspace, &v);
v.push_back(':');
append_out_escaped(o.get_key(), &v);
v.push_back(':');
append_out_escaped(o.oid.name, &v);
out << v << ':' << o.snap;
return out;
}

bool hobject_t::parse(const string &s)
{
if (s == "MIN") {
*this = hobject_t();
return true;
}
if (s == "MAX") {
*this = hobject_t::get_max();
return true;
}

const char *start = s.c_str();
long long po;
unsigned h;
int r = sscanf(start, "%lld:%x:", &po, &h);
if (r != 2)
return false;
for (; *start && *start != ':'; ++start) ;
for (++start; *start && isxdigit(*start); ++start) ;
if (*start != ':')
return false;

string ns, k, name;
const char *p = decode_out_escaped(start + 1, &ns);
if (*p != ':')
return false;
p = decode_out_escaped(p + 1, &k);
if (*p != ':')
return false;
p = decode_out_escaped(p + 1, &name);
if (*p != ':')
return false;
start = p + 1;

unsigned long long sn;
if (strncmp(start, "head", 4) == 0) {
sn = CEPH_NOSNAP;
start += 4;
if (*start != 0)
return false;
} else {
r = sscanf(start, "%llx", &sn);
if (r != 1)
return false;
for (++start; *start && isxdigit(*start); ++start) ;
if (*start)
return false;
}

max = false;
pool = po;
set_hash(_reverse_bits(h));
nspace = ns;
oid.name = name;
set_key(k);
snap = sn;
return true;
}

int cmp_nibblewise(const hobject_t& l, const hobject_t& r)
{
if (l.max < r.max)
Expand Down Expand Up @@ -402,14 +498,65 @@ ostream& operator<<(ostream& out, const ghobject_t& o)
if (o.is_max())
return out << "GHMAX";
if (o.shard_id != shard_id_t::NO_SHARD)
out << std::hex << o.shard_id << std::dec << ":";
out << o.hobj;
if (o.generation != ghobject_t::NO_GEN) {
out << "/" << std::hex << (unsigned)(o.generation) << std::dec;
}
out << std::hex << o.shard_id << std::dec;
out << '@' << o.hobj << '@';
if (o.generation != ghobject_t::NO_GEN)
out << std::hex << (unsigned long long)(o.generation) << std::dec;
return out;
}

bool ghobject_t::parse(const string& s)
{
if (s == "GHMIN") {
*this = ghobject_t();
return true;
}
if (s == "GHMAX") {
*this = ghobject_t::get_max();
return true;
}

// look for shard@ prefix
const char *start = s.c_str();
const char *p;
int sh = shard_id_t::NO_SHARD;
for (p = start; *p && isxdigit(*p); ++p) ;
if (!*p && *p != '@')
return false;
if (p > start) {
int r = sscanf(s.c_str(), "%x", &sh);
if (r < 1)
return false;
start = p + 1;
} else {
++start;
}

// look for @generation suffix
long long unsigned g = NO_GEN;
const char *last = start + strlen(start) - 1;
p = last;
while (isxdigit(*p))
p--;
if (*p != '@')
return false;
if (p < last) {
sscanf(p + 1, "%llx", &g);
}

string inner(start, p - start);
hobject_t h;
if (!h.parse(inner)) {
return false;
}

shard_id = shard_id_t(sh);
hobj = h;
generation = g;
max = false;
return true;
}

int cmp_nibblewise(const ghobject_t& l, const ghobject_t& r)
{
if (l.max < r.max)
Expand Down
4 changes: 4 additions & 0 deletions src/common/hobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ struct hobject_t {
return nspace;
}

bool parse(const string& s);

void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
void decode(json_spirit::Value& v);
Expand Down Expand Up @@ -415,6 +417,8 @@ struct ghobject_t {
shard_id = s;
}

bool parse(const string& s);

// maximum sorted value.
static ghobject_t get_max() {
ghobject_t h;
Expand Down

0 comments on commit b26c24f

Please sign in to comment.