From: Adam Emerson Date: Mon, 14 Aug 2023 23:11:27 +0000 (-0400) Subject: neorados: Take `claim_append`ed `buffer::list`s by value X-Git-Tag: v19.3.0~349^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=39ede8b1009bd6dd1c19a277343c68e9121a3738;p=ceph.git neorados: Take `claim_append`ed `buffer::list`s by value Since both const lvalue and rvalue make sense, instead of duplicating everything, just take a value and move from it. Signed-off-by: Adam Emerson --- diff --git a/src/include/neorados/RADOS.hpp b/src/include/neorados/RADOS.hpp index aaa1fea005c..e89c7d02e41 100644 --- a/src/include/neorados/RADOS.hpp +++ b/src/include/neorados/RADOS.hpp @@ -336,7 +336,7 @@ public: void set_fadvise_dontneed(); void set_fadvise_nocache(); - void cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, + void cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* unmatch = nullptr); void cmpxattr(std::string_view name, cmp_op op, const ceph::buffer::list& val); @@ -584,12 +584,12 @@ public: return std::move(*this); } - ReadOp& cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, + ReadOp& cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* unmatch = nullptr) & { Op::cmpext(off, std::move(cmp_bl), unmatch); return *this; } - ReadOp&& cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, + ReadOp&& cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* unmatch = nullptr) && { Op::cmpext(off, std::move(cmp_bl), unmatch); return std::move(*this); @@ -827,22 +827,22 @@ public: WriteOp&& create(bool exclusive) && { return std::move(create(exclusive)); } - WriteOp& write(uint64_t off, ceph::buffer::list&& bl) &; - WriteOp&& write(uint64_t off, ceph::buffer::list&& bl) && { + WriteOp& write(uint64_t off, ceph::buffer::list bl) &; + WriteOp&& write(uint64_t off, ceph::buffer::list bl) && { return std::move(write(off, std::move(bl))); } - WriteOp& write_full(ceph::buffer::list&& bl) &; - WriteOp&& write_full(ceph::buffer::list&& bl) && { + WriteOp& write_full(ceph::buffer::list bl) &; + WriteOp&& write_full(ceph::buffer::list bl) && { return std::move(write_full(std::move(bl))); } WriteOp& writesame(std::uint64_t off, std::uint64_t write_len, - ceph::buffer::list&& bl) &; + ceph::buffer::list bl) &; WriteOp&& writesame(std::uint64_t off, std::uint64_t write_len, - ceph::buffer::list&& bl) && { + ceph::buffer::list bl) && { return std::move(writesame(off, write_len, std::move(bl))); } - WriteOp& append(ceph::buffer::list&& bl) &; - WriteOp&& append(ceph::buffer::list&& bl) && { + WriteOp& append(ceph::buffer::list bl) &; + WriteOp&& append(ceph::buffer::list bl) && { return std::move(append(std::move(bl))); } WriteOp& remove() &; @@ -862,9 +862,9 @@ public: return std::move(rmxattr(name)); } WriteOp& setxattr(std::string_view name, - ceph::buffer::list&& bl) &; + ceph::buffer::list bl) &; WriteOp&& setxattr(std::string_view name, - ceph::buffer::list&& bl) && { + ceph::buffer::list bl) && { return std::move(setxattr(name, std::move(bl))); } WriteOp& rollback(uint64_t snapid) &; @@ -877,8 +877,8 @@ public: const boost::container::flat_map& map) && { return std::move(set_omap(map)); } - WriteOp& set_omap_header(ceph::buffer::list&& bl) &; - WriteOp&& set_omap_header(ceph::buffer::list&& bl) && { + WriteOp& set_omap_header(ceph::buffer::list bl) &; + WriteOp&& set_omap_header(ceph::buffer::list bl) && { return std::move(set_omap_header(std::move(bl))); } WriteOp& clear_omap() &; @@ -964,12 +964,12 @@ public: return std::move(*this); } - WriteOp& cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, + WriteOp& cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* unmatch = nullptr) & { Op::cmpext(off, std::move(cmp_bl), unmatch); return *this; } - WriteOp&& cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, + WriteOp&& cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* unmatch = nullptr) && { Op::cmpext(off, std::move(cmp_bl), unmatch); return std::move(*this); diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc index b04aa6c2b9b..91c55ba5f84 100644 --- a/src/neorados/RADOS.cc +++ b/src/neorados/RADOS.cc @@ -420,7 +420,7 @@ void Op::set_fadvise_nocache() { CEPH_OSD_OP_FLAG_FADVISE_NOCACHE); } -void Op::cmpext(uint64_t off, bufferlist&& cmp_bl, uint64_t* unmatch) { +void Op::cmpext(uint64_t off, bufferlist cmp_bl, uint64_t* unmatch) { reinterpret_cast(&impl)->op.cmpext(off, std::move(cmp_bl), nullptr, unmatch); } @@ -676,23 +676,23 @@ WriteOp& WriteOp::create(bool exclusive) & { return *this; } -WriteOp& WriteOp::write(uint64_t off, bufferlist&& bl) & { - reinterpret_cast(&impl)->op.write(off, bl); +WriteOp& WriteOp::write(uint64_t off, bufferlist bl) & { + reinterpret_cast(&impl)->op.write(off, std::move(bl)); return *this; } -WriteOp& WriteOp::write_full(bufferlist&& bl) & { - reinterpret_cast(&impl)->op.write_full(bl); +WriteOp& WriteOp::write_full(bufferlist bl) & { + reinterpret_cast(&impl)->op.write_full(std::move(bl)); return *this; } -WriteOp& WriteOp::writesame(uint64_t off, uint64_t write_len, bufferlist&& bl) & { - reinterpret_cast(&impl)->op.writesame(off, write_len, bl); +WriteOp& WriteOp::writesame(uint64_t off, uint64_t write_len, bufferlist bl) & { + reinterpret_cast(&impl)->op.writesame(off, write_len, std::move(bl)); return *this; } -WriteOp& WriteOp::append(bufferlist&& bl) & { - reinterpret_cast(&impl)->op.append(bl); +WriteOp& WriteOp::append(bufferlist bl) & { + reinterpret_cast(&impl)->op.append(std::move(bl)); return *this; } @@ -717,8 +717,8 @@ WriteOp& WriteOp::rmxattr(std::string_view name) & { } WriteOp& WriteOp::setxattr(std::string_view name, - bufferlist&& bl) & { - reinterpret_cast(&impl)->op.setxattr(name, bl); + bufferlist bl) & { + reinterpret_cast(&impl)->op.setxattr(name, std::move(bl)); return *this; } @@ -733,8 +733,8 @@ WriteOp& WriteOp::set_omap( return *this; } -WriteOp& WriteOp::set_omap_header(bufferlist&& bl) & { - reinterpret_cast(&impl)->op.omap_set_header(bl); +WriteOp& WriteOp::set_omap_header(bufferlist bl) & { + reinterpret_cast(&impl)->op.omap_set_header(std::move(bl)); return *this; } diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 2fd8bf5fb46..c54d87bace4 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -579,15 +579,27 @@ struct ObjectOperation { void write(uint64_t off, ceph::buffer::list& bl) { write(off, bl, 0, 0); } + void write(uint64_t off, ceph::buffer::list&& bl) { + write(off, bl, 0, 0); + } void write_full(ceph::buffer::list& bl) { add_data(CEPH_OSD_OP_WRITEFULL, 0, bl.length(), bl); } + void write_full(ceph::buffer::list&& bl) { + add_data(CEPH_OSD_OP_WRITEFULL, 0, bl.length(), bl); + } void writesame(uint64_t off, uint64_t write_len, ceph::buffer::list& bl) { add_writesame(CEPH_OSD_OP_WRITESAME, off, write_len, bl); } + void writesame(uint64_t off, uint64_t write_len, ceph::buffer::list&& bl) { + add_writesame(CEPH_OSD_OP_WRITESAME, off, write_len, bl); + } void append(ceph::buffer::list& bl) { add_data(CEPH_OSD_OP_APPEND, 0, bl.length(), bl); } + void append(ceph::buffer::list&& bl) { + add_data(CEPH_OSD_OP_APPEND, 0, bl.length(), bl); + } void zero(uint64_t off, uint64_t len) { ceph::buffer::list bl; add_data(CEPH_OSD_OP_ZERO, off, len, bl); @@ -1357,7 +1369,11 @@ struct ObjectOperation { add_data(CEPH_OSD_OP_OMAPSETVALS, 0, bl.length(), bl); } - void omap_set_header(ceph::buffer::list &bl) { + void omap_set_header(ceph::buffer::list& bl) { + add_data(CEPH_OSD_OP_OMAPSETHEADER, 0, bl.length(), bl); + } + + void omap_set_header(ceph::buffer::list&& bl) { add_data(CEPH_OSD_OP_OMAPSETHEADER, 0, bl.length(), bl); } diff --git a/src/test/librados_test_stub/NeoradosTestStub.cc b/src/test/librados_test_stub/NeoradosTestStub.cc index 1eb0d627ebe..a1b61f2459b 100644 --- a/src/test/librados_test_stub/NeoradosTestStub.cc +++ b/src/test/librados_test_stub/NeoradosTestStub.cc @@ -331,7 +331,7 @@ void Op::assert_version(uint64_t ver) { &librados::TestIoCtxImpl::assert_version, _1, _2, ver)); } -void Op::cmpext(uint64_t off, ceph::buffer::list&& cmp_bl, uint64_t* s) { +void Op::cmpext(uint64_t off, ceph::buffer::list cmp_bl, uint64_t* s) { auto o = *reinterpret_cast(&impl); librados::ObjectOperationTestImpl op = std::bind( &librados::TestIoCtxImpl::cmpext, _1, _2, off, cmp_bl, _4); @@ -504,14 +504,14 @@ WriteOp& WriteOp::create(bool exclusive) & { return *this; } -WriteOp& WriteOp::write(uint64_t off, ceph::buffer::list&& bl) & { +WriteOp& WriteOp::write(uint64_t off, ceph::buffer::list bl) & { auto o = *reinterpret_cast(&impl); o->ops.push_back(std::bind( &librados::TestIoCtxImpl::write, _1, _2, bl, bl.length(), off, _5)); return *this; } -WriteOp& WriteOp::write_full(ceph::buffer::list&& bl) & { +WriteOp& WriteOp::write_full(ceph::buffer::list bl) & { auto o = *reinterpret_cast(&impl); o->ops.push_back(std::bind( &librados::TestIoCtxImpl::write_full, _1, _2, bl, _5)); @@ -540,7 +540,7 @@ WriteOp& WriteOp::zero(uint64_t off, uint64_t len) & { } WriteOp& WriteOp::writesame(std::uint64_t off, std::uint64_t write_len, - ceph::buffer::list&& bl) & { + ceph::buffer::list bl) & { auto o = *reinterpret_cast(&impl); o->ops.push_back(std::bind( &librados::TestIoCtxImpl::writesame, _1, _2, bl, write_len, off, _5));