Skip to content

Commit

Permalink
Merge pull request ceph#38193 from dang/wip-dang-zipper-9
Browse files Browse the repository at this point in the history
RGW - Zipper 9: Write path
  • Loading branch information
dang authored Nov 20, 2020
2 parents c2a1edb + 8208d84 commit e8dac81
Show file tree
Hide file tree
Showing 25 changed files with 1,010 additions and 640 deletions.
115 changes: 11 additions & 104 deletions src/common/static_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,14 @@ namespace _mem {
// of the same arguments (which is not true for function type erasure)
// it's a pretty good one.
enum class op {
copy, move, destroy, size
move, destroy, size
};
template<typename T>
static std::size_t op_fun(op oper, void* p1, void* p2)
{
auto me = static_cast<T*>(p1);

switch (oper) {
case op::copy:
// One conspicuous downside is that immovable/uncopyable functions
// kill compilation right here, even if nobody ever calls the move
// or copy methods. Working around this is a pain, since we'd need
// four operator functions and a top-level class to
// provide/withhold copy/move operations as appropriate.
new (p2) T(*me);
break;

case op::move:
new (p2) T(std::move(*me));
break;
Expand Down Expand Up @@ -137,27 +128,13 @@ class static_ptr {
// Set from another static pointer.
//
// Since the templated versions don't count for overriding the defaults
static_ptr(const static_ptr& rhs)
noexcept(std::is_nothrow_copy_constructible_v<Base>) : operate(rhs.operate) {
if (operate) {
operate(_mem::op::copy, &rhs.buf, &buf);
}
}
static_ptr(static_ptr&& rhs)
noexcept(std::is_nothrow_move_constructible_v<Base>) : operate(rhs.operate) {
if (operate) {
operate(_mem::op::move, &rhs.buf, &buf);
}
}

template<typename U, std::size_t S>
static_ptr(const static_ptr<U, S>& rhs)
noexcept(std::is_nothrow_copy_constructible_v<U>) : operate(rhs.operate) {
create_ward<U, S>();
if (operate) {
operate(_mem::op::copy, &rhs.buf, &buf);
}
}
template<typename U, std::size_t S>
static_ptr(static_ptr<U, S>&& rhs)
noexcept(std::is_nothrow_move_constructible_v<U>) : operate(rhs.operate) {
Expand All @@ -167,16 +144,6 @@ class static_ptr {
}
}

static_ptr& operator =(const static_ptr& rhs)
noexcept(std::is_nothrow_copy_constructible_v<Base>) {
reset();
if (rhs) {
operate = rhs.operate;
operate(_mem::op::copy,
const_cast<void*>(static_cast<const void*>(&rhs.buf)), &buf);
}
return *this;
}
static_ptr& operator =(static_ptr&& rhs)
noexcept(std::is_nothrow_move_constructible_v<Base>) {
reset();
Expand All @@ -187,18 +154,6 @@ class static_ptr {
return *this;
}

template<typename U, std::size_t S>
static_ptr& operator =(const static_ptr<U, S>& rhs)
noexcept(std::is_nothrow_copy_constructible_v<U>) {
create_ward<U, S>();
reset();
if (rhs) {
operate = rhs.operate;
operate(_mem::op::copy,
const_cast<void*>(static_cast<const void*>(&rhs.buf)), &buf);
}
return *this;
}
template<typename U, std::size_t S>
static_ptr& operator =(static_ptr<U, S>&& rhs)
noexcept(std::is_nothrow_move_constructible_v<U>) {
Expand Down Expand Up @@ -300,20 +255,6 @@ class static_ptr {
// nice idiom. Having to release and reconstruct is obnoxious.
//
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> static_pointer_cast(const static_ptr<T, S>& p) {
static_assert(Z >= S,
"Value too large.");
static_ptr<U, Z> r;
// Really, this is always true because static_cast either succeeds
// or fails to compile, but it prevents an unused variable warning
// and should be optimized out.
if (static_cast<U*>(p.get())) {
p.operate(_mem::op::copy, &p.buf, &r.buf);
r.operate = p.operate;
}
return r;
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> static_pointer_cast(static_ptr<T, S>&& p) {
static_assert(Z >= S,
"Value too large.");
Expand All @@ -329,17 +270,6 @@ static_ptr<U, Z> static_pointer_cast(static_ptr<T, S>&& p) {
// same behavior as dynamic_cast.
//
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> dynamic_pointer_cast(const static_ptr<T, S>& p) {
static_assert(Z >= S,
"Value too large.");
static_ptr<U, Z> r;
if (dynamic_cast<U*>(p.get())) {
p.operate(_mem::op::copy, &p.buf, &r.buf);
r.operate = p.operate;
}
return r;
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> dynamic_pointer_cast(static_ptr<T, S>&& p) {
static_assert(Z >= S,
"Value too large.");
Expand All @@ -351,17 +281,6 @@ static_ptr<U, Z> dynamic_pointer_cast(static_ptr<T, S>&& p) {
return r;
}

template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> const_pointer_cast(const static_ptr<T, S>& p) {
static_assert(Z >= S,
"Value too large.");
static_ptr<U, Z> r;
if (const_cast<U*>(p.get())) {
p.operate(_mem::op::copy, &p.buf, &r.buf);
r.operate = p.operate;
}
return r;
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> const_pointer_cast(static_ptr<T, S>&& p) {
static_assert(Z >= S,
Expand All @@ -378,15 +297,6 @@ static_ptr<U, Z> const_pointer_cast(static_ptr<T, S>&& p) {
// where they might. It works, though!
//
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> reinterpret_pointer_cast(const static_ptr<T, S>& p) {
static_assert(Z >= S,
"Value too large.");
static_ptr<U, Z> r;
p.operate(_mem::op::copy, &p.buf, &r.buf);
r.operate = p.operate;
return r;
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> reinterpret_pointer_cast(static_ptr<T, S>&& p) {
static_assert(Z >= S,
"Value too large.");
Expand All @@ -404,17 +314,6 @@ static_ptr<U, Z> reinterpret_pointer_cast(static_ptr<T, S>&& p) {
// I follow cast semantics. Since this is a pointer-like type, it
// returns a null value rather than throwing.
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> resize_pointer_cast(const static_ptr<T, S>& p) {
static_assert(std::is_same_v<U, T>,
"resize_pointer_cast only changes size, not type.");
static_ptr<U, Z> r;
if (Z >= p.operate(_mem::op::size, &p.buf, nullptr)) {
p.operate(_mem::op::copy, &p.buf, &r.buf);
r.operate = p.operate;
}
return r;
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> resize_pointer_cast(static_ptr<T, S>&& p) {
static_assert(std::is_same_v<U, T>,
"resize_pointer_cast only changes size, not type.");
Expand All @@ -427,11 +326,19 @@ static_ptr<U, Z> resize_pointer_cast(static_ptr<T, S>&& p) {
}

template<typename Base, std::size_t Size>
bool operator ==(static_ptr<Base, Size> s, std::nullptr_t) {
bool operator ==(const static_ptr<Base, Size>& s, std::nullptr_t) {
return !s;
}
template<typename Base, std::size_t Size>
bool operator ==(std::nullptr_t, const static_ptr<Base, Size>& s) {
return !s;
}
template<typename Base, std::size_t Size>
bool operator ==(static_ptr<Base, Size>& s, std::nullptr_t) {
return !s;
}
template<typename Base, std::size_t Size>
bool operator ==(std::nullptr_t, static_ptr<Base, Size> s) {
bool operator ==(std::nullptr_t, static_ptr<Base, Size>& s) {
return !s;
}

Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class ACLOwner
string display_name;
public:
ACLOwner() {}
ACLOwner(const rgw_user& _id) : id(_id) {}
~ACLOwner() {}

void encode(bufferlist& bl) const {
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7224,7 +7224,7 @@ int main(int argc, const char **argv)

if (opt_cmd == OPT::LC_LIST) {
formatter->open_array_section("lifecycle_list");
vector<cls_rgw_lc_entry> bucket_lc_map;
vector<rgw::sal::Lifecycle::LCEntry> bucket_lc_map;
string marker;
int index{0};
#define MAX_LC_LIST_ENTRIES 100
Expand Down
5 changes: 3 additions & 2 deletions src/rgw/rgw_bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& buck
max_aio = concurrent_max;
}

rgw_raw_obj last_obj = miter.get_location().get_raw_obj(store->getRados());
rgw_raw_obj last_obj = miter.get_location().get_raw_obj(store);
if (last_obj == raw_head_obj) {
// have the head obj deleted at the end
continue;
Expand Down Expand Up @@ -1819,7 +1819,8 @@ static int fix_single_bucket_lc(rgw::sal::RGWRadosStore *store,
return ret;
}

return rgw::lc::fix_lc_shard_entry(store, bucket_info, bucket_attrs);
return rgw::lc::fix_lc_shard_entry(store, store->get_rgwlc()->get_lc(), bucket_info,
bucket_attrs);
}

static void format_lc_status(Formatter* formatter,
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_cr_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ int RGWAsyncFetchRemoteObj::_send_request()

char buf[16];
snprintf(buf, sizeof(buf), ".%lld", (long long)store->getRados()->instance_id());
map<string, bufferlist> attrs;
rgw::sal::RGWAttrs attrs;

rgw::sal::RGWRadosBucket bucket(store, src_bucket);
rgw::sal::RGWRadosObject src_obj(store, key, &bucket);
Expand Down
3 changes: 2 additions & 1 deletion src/rgw/rgw_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,8 @@ namespace rgw {
&state->dest_placement,
state->bucket_owner.get_id(),
*static_cast<RGWObjectCtx *>(state->obj_ctx),
state->object->get_obj(), olh_epoch, state->req_id, this, state->yield);
std::move(state->object->clone()), olh_epoch, state->req_id,
this, state->yield);

op_ret = processor->prepare(state->yield);
if (op_ret < 0) {
Expand Down
Loading

0 comments on commit e8dac81

Please sign in to comment.