librados: restored pre-infernalis API compatibility

Fixes: #13429
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2015-10-09 12:59:39 -04:00
parent cac1d6f936
commit 6eca7d0889
5 changed files with 42 additions and 19 deletions

View File

@ -422,7 +422,9 @@ namespace librados
* @param src_fadvise_flags the fadvise flags for source object
*/
void copy_from(const std::string& src, const IoCtx& src_ioctx,
uint64_t src_version, uint32_t src_fadvise_flags);
uint64_t src_version);
void copy_from2(const std::string& src, const IoCtx& src_ioctx,
uint64_t src_version, uint32_t src_fadvise_flags);
/**
* undirty an object
@ -775,10 +777,12 @@ namespace librados
/// Start enumerating objects for a pool
NObjectIterator nobjects_begin(const bufferlist &filter=bufferlist());
NObjectIterator nobjects_begin();
NObjectIterator nobjects_begin(const bufferlist &filter);
/// Start enumerating objects for a pool starting from a hash position
NObjectIterator nobjects_begin(uint32_t start_hash_position);
NObjectIterator nobjects_begin(uint32_t start_hash_position,
const bufferlist &filter=bufferlist());
const bufferlist &filter);
/// Iterator indicating the end of a pool
const NObjectIterator& nobjects_end() const;

View File

@ -419,9 +419,16 @@ void librados::ObjectWriteOperation::omap_rm_keys(
}
void librados::ObjectWriteOperation::copy_from(const std::string& src,
const IoCtx& src_ioctx,
uint64_t src_version,
uint32_t src_fadvise_flags)
const IoCtx& src_ioctx,
uint64_t src_version)
{
copy_from2(src, src_ioctx, src_version, 0);
}
void librados::ObjectWriteOperation::copy_from2(const std::string& src,
const IoCtx& src_ioctx,
uint64_t src_version,
uint32_t src_fadvise_flags)
{
::ObjectOperation *o = (::ObjectOperation *)impl;
o->copy_from(object_t(src), src_ioctx.io_ctx_impl->snap_seq,
@ -1554,6 +1561,12 @@ int librados::IoCtx::list_lockers(const std::string &oid, const std::string &nam
return tmp_lockers.size();
}
librados::NObjectIterator librados::IoCtx::nobjects_begin()
{
bufferlist bl;
return nobjects_begin(bl);
}
librados::NObjectIterator librados::IoCtx::nobjects_begin(
const bufferlist &filter)
{
@ -1567,6 +1580,12 @@ librados::NObjectIterator librados::IoCtx::nobjects_begin(
return iter;
}
librados::NObjectIterator librados::IoCtx::nobjects_begin(uint32_t pos)
{
bufferlist bl;
return nobjects_begin(pos, bl);
}
librados::NObjectIterator librados::IoCtx::nobjects_begin(
uint32_t pos, const bufferlist &filter)
{

View File

@ -610,18 +610,18 @@ TEST_F(LibRadosMiscPP, CopyPP) {
{
// pass future version
ObjectWriteOperation op;
op.copy_from("foo", ioctx, uv + 1, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
op.copy_from2("foo", ioctx, uv + 1, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
ASSERT_EQ(-EOVERFLOW, ioctx.operate("foo.copy", &op));
}
{
// pass old version
ObjectWriteOperation op;
op.copy_from("foo", ioctx, uv - 1, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
op.copy_from2("foo", ioctx, uv - 1, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
ASSERT_EQ(-ERANGE, ioctx.operate("foo.copy", &op));
}
{
ObjectWriteOperation op;
op.copy_from("foo", ioctx, uv, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
op.copy_from2("foo", ioctx, uv, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
ASSERT_EQ(0, ioctx.operate("foo.copy", &op));
bufferlist bl2, x2;
@ -634,7 +634,7 @@ TEST_F(LibRadosMiscPP, CopyPP) {
// small object without a version
{
ObjectWriteOperation op;
op.copy_from("foo", ioctx, 0, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
op.copy_from2("foo", ioctx, 0, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
ASSERT_EQ(0, ioctx.operate("foo.copy2", &op));
bufferlist bl2, x2;
@ -655,7 +655,7 @@ TEST_F(LibRadosMiscPP, CopyPP) {
{
ObjectWriteOperation op;
op.copy_from("big", ioctx, ioctx.get_last_version(), LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
op.copy_from2("big", ioctx, ioctx.get_last_version(), LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
ASSERT_EQ(0, ioctx.operate("big.copy", &op));
bufferlist bl2, x2;
@ -667,7 +667,7 @@ TEST_F(LibRadosMiscPP, CopyPP) {
{
ObjectWriteOperation op;
op.copy_from("big", ioctx, 0, LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL);
op.copy_from2("big", ioctx, 0, LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL);
ASSERT_EQ(0, ioctx.operate("big.copy2", &op));
bufferlist bl2, x2;
@ -726,7 +726,7 @@ TEST_F(LibRadosTwoPoolsECPP, CopyFrom) {
version_t uv = src_ioctx.get_last_version();
ObjectWriteOperation op;
op.copy_from("foo", src_ioctx, uv, 0);
op.copy_from("foo", src_ioctx, uv);
ASSERT_EQ(-EOPNOTSUPP, ioctx.operate("foo.copy", &op));
}
@ -783,25 +783,25 @@ TEST_F(LibRadosMiscPP, CopyScrubPP) {
{
ObjectWriteOperation op;
op.copy_from("small", ioctx, 0, 0);
op.copy_from("small", ioctx, 0);
ASSERT_EQ(0, ioctx.operate("small.copy", &op));
}
{
ObjectWriteOperation op;
op.copy_from("big", ioctx, 0, 0);
op.copy_from("big", ioctx, 0);
ASSERT_EQ(0, ioctx.operate("big.copy", &op));
}
{
ObjectWriteOperation op;
op.copy_from("big2", ioctx, 0, 0);
op.copy_from("big2", ioctx, 0);
ASSERT_EQ(0, ioctx.operate("big2.copy", &op));
}
{
ObjectWriteOperation op;
op.copy_from("big3", ioctx, 0, 0);
op.copy_from("big3", ioctx, 0);
ASSERT_EQ(0, ioctx.operate("big3.copy", &op));
}

View File

@ -1657,7 +1657,7 @@ public:
}
string src = context->prefix+oid_src;
op.copy_from(src.c_str(), context->io_ctx, src_value.version, 0);
op.copy_from(src.c_str(), context->io_ctx, src_value.version);
pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
new pair<TestOp*, TestOp::CallbackInfo*>(this,

View File

@ -305,7 +305,7 @@ static int do_copy(IoCtx& io_ctx, const char *objname,
__le32 src_fadvise_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL | LIBRADOS_OP_FLAG_FADVISE_NOCACHE;
__le32 dest_fadvise_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL | LIBRADOS_OP_FLAG_FADVISE_DONTNEED;
ObjectWriteOperation op;
op.copy_from(objname, io_ctx, 0, src_fadvise_flags);
op.copy_from2(objname, io_ctx, 0, src_fadvise_flags);
op.set_op_flags2(dest_fadvise_flags);
return target_ctx.operate(target_obj, &op);