Skip to content

Commit

Permalink
Merge pull request ceph#29651 from rzarzynski/wip-crimson-cls
Browse files Browse the repository at this point in the history
crimson, osd: add support for Ceph Classes, part 1

Reviewed-by: Samuel Just <sjust@redhat.com>
Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov authored Aug 25, 2019
2 parents 083c3a5 + 6435c6c commit a576f9b
Show file tree
Hide file tree
Showing 25 changed files with 1,832 additions and 875 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ add_subdirectory(osd)
set(ceph_osd_srcs
# Link the Object Class API implementation directly as intermediary
# static library (like libosd.a) nullifies the effect of `-rdynamic`.
osd/objclass.cc
objclass/class_api.cc
ceph_osd.cc)
add_executable(ceph-osd ${ceph_osd_srcs})
Expand Down
1 change: 1 addition & 0 deletions src/cls/cephfs/cls_cephfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <errno.h>

#include "objclass/objclass.h"
#include "osd/osd_types.h"

#include "cls_cephfs.h"

Expand Down
1 change: 1 addition & 0 deletions src/cls/hello/cls_hello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <cerrno>

#include "objclass/objclass.h"
#include "osd/osd_types.h"

using ceph::bufferlist;
using std::string;
Expand Down
10 changes: 8 additions & 2 deletions src/crimson/os/cyan_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ seastar::future<std::vector<ghobject_t>, ghobject_t>
CyanStore::list_objects(CollectionRef c,
const ghobject_t& start,
const ghobject_t& end,
uint64_t limit)
uint64_t limit) const
{
logger().debug("{} {} {} {} {}",
__func__, c->cid, start, end, limit);
Expand Down Expand Up @@ -201,7 +201,7 @@ seastar::future<ceph::bufferlist> CyanStore::read(CollectionRef c,

seastar::future<ceph::bufferptr> CyanStore::get_attr(CollectionRef c,
const ghobject_t& oid,
std::string_view name)
std::string_view name) const
{
logger().debug("{} {} {}",
__func__, c->cid, oid);
Expand Down Expand Up @@ -631,4 +631,10 @@ uuid_d CyanStore::get_fsid() const
{
return osd_fsid;
}

unsigned CyanStore::get_max_attr_name_length() const
{
// arbitrary limitation exactly like in the case of MemStore.
return 256;
}
}
5 changes: 3 additions & 2 deletions src/crimson/os/cyan_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CyanStore final : public FuturizedStore {
uint32_t op_flags = 0) final;
seastar::future<ceph::bufferptr> get_attr(CollectionRef c,
const ghobject_t& oid,
std::string_view name) final;
std::string_view name) const final;
seastar::future<attrs_t> get_attrs(CollectionRef c,
const ghobject_t& oid) final;

Expand All @@ -64,7 +64,7 @@ class CyanStore final : public FuturizedStore {
CollectionRef c,
const ghobject_t& start,
const ghobject_t& end,
uint64_t limit) final;
uint64_t limit) const final;

/// Retrieves paged set of values > start (if present)
seastar::future<bool, omap_values_t> omap_get_values(
Expand All @@ -84,6 +84,7 @@ class CyanStore final : public FuturizedStore {
const std::string& value) final;
int read_meta(const std::string& key, std::string* value) final;
uuid_d get_fsid() const final;
unsigned get_max_attr_name_length() const final;

private:
int _remove(const coll_t& cid, const ghobject_t& oid);
Expand Down
5 changes: 3 additions & 2 deletions src/crimson/os/futurized_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FuturizedStore {
uint32_t op_flags = 0) = 0;
virtual seastar::future<ceph::bufferptr> get_attr(CollectionRef c,
const ghobject_t& oid,
std::string_view name) = 0;
std::string_view name) const = 0;

using attrs_t = std::map<std::string, ceph::bufferptr, std::less<>>;
virtual seastar::future<attrs_t> get_attrs(CollectionRef c,
Expand All @@ -87,7 +87,7 @@ class FuturizedStore {
CollectionRef c,
const ghobject_t& start,
const ghobject_t& end,
uint64_t limit) = 0;
uint64_t limit) const = 0;
virtual seastar::future<bool, omap_values_t> omap_get_values(
CollectionRef c, ///< [in] collection
const ghobject_t &oid, ///< [in] oid
Expand All @@ -105,6 +105,7 @@ class FuturizedStore {
const std::string& value) = 0;
virtual int read_meta(const std::string& key, std::string* value) = 0;
virtual uuid_d get_fsid() const = 0;
virtual unsigned get_max_attr_name_length() const = 0;
};

}
4 changes: 4 additions & 0 deletions src/crimson/osd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_executable(crimson-osd
pg_meta.cc
replicated_backend.cc
shard_services.cc
ops_executer.cc
osd_operation.cc
osd_operations/client_request.cc
osd_operations/compound_peering_request.cc
Expand All @@ -18,6 +19,9 @@ add_executable(crimson-osd
osd_operations/replicated_request.cc
osdmap_gate.cc
pg_map.cc
objclass.cc
${PROJECT_SOURCE_DIR}/src/objclass/class_api.cc
${PROJECT_SOURCE_DIR}/src/osd/ClassHandler.cc
${PROJECT_SOURCE_DIR}/src/osd/PeeringState.cc
${PROJECT_SOURCE_DIR}/src/osd/PGPeeringEvent.cc
${PROJECT_SOURCE_DIR}/src/osd/PGStateUtils.cc
Expand Down
49 changes: 46 additions & 3 deletions src/crimson/osd/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,55 @@
#pragma once

#include <exception>
#include <system_error>

class object_not_found : public std::exception {
namespace ceph::osd {
class error : private std::system_error {
public:
error(const std::errc ec)
: system_error(std::make_error_code(ec)) {
}

using system_error::code;
using system_error::what;

friend error make_error(int ret);

private:
error(const int ret) noexcept
: system_error(ret, std::system_category()) {
}
};

class object_corrupted : public std::exception {
inline error make_error(const int ret) {
return error{-ret};
}

struct object_not_found : public error {
object_not_found() : error(std::errc::no_such_file_or_directory) {}
};

class invalid_argument : public std::exception {
struct object_corrupted : public error {
object_corrupted() : error(std::errc::illegal_byte_sequence) {}
};

struct invalid_argument : public error {
invalid_argument() : error(std::errc::invalid_argument) {}
};

// FIXME: error handling
struct operation_not_supported : public error {
operation_not_supported()
: error(std::errc::operation_not_supported) {
}
};

struct permission_denied : public error {
permission_denied() : error(std::errc::operation_not_permitted) {}
};

struct input_output_error : public error {
input_output_error() : error(std::errc::io_error) {}
};

} // namespace ceph::osd
Loading

0 comments on commit a576f9b

Please sign in to comment.