mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
osd,librados: a rados op to promote the object (redirect, chunked)
Signed-off-by: Myoungwon Oh <omwmw@sk.com>
This commit is contained in:
parent
03fe7d8cc8
commit
c6945d0361
@ -313,6 +313,7 @@ extern int ceph_release_from_features(uint64_t features);
|
||||
/* Extensible */ \
|
||||
f(SET_REDIRECT, __CEPH_OSD_OP(WR, DATA, 39), "set-redirect") \
|
||||
f(SET_CHUNK, __CEPH_OSD_OP(WR, DATA, 40), "set-chunk") \
|
||||
f(TIER_PROMOTE, __CEPH_OSD_OP(WR, DATA, 41), "tier-promote") \
|
||||
\
|
||||
/** attrs **/ \
|
||||
/* read */ \
|
||||
|
@ -473,6 +473,7 @@ namespace librados
|
||||
uint64_t tgt_version);
|
||||
void set_chunk(uint64_t src_offset, uint64_t src_length, const IoCtx& tgt_ioctx,
|
||||
std::string tgt_oid, uint64_t tgt_offset);
|
||||
void tier_promote();
|
||||
|
||||
|
||||
friend class IoCtx;
|
||||
|
@ -625,6 +625,12 @@ void librados::ObjectWriteOperation::set_chunk(uint64_t src_offset,
|
||||
tgt_ioctx.io_ctx_impl->oloc, object_t(tgt_oid), tgt_offset);
|
||||
}
|
||||
|
||||
void librados::ObjectWriteOperation::tier_promote()
|
||||
{
|
||||
::ObjectOperation *o = &impl->o;
|
||||
o->tier_promote();
|
||||
}
|
||||
|
||||
void librados::ObjectWriteOperation::tmap_put(const bufferlist &bl)
|
||||
{
|
||||
::ObjectOperation *o = &impl->o;
|
||||
|
@ -5489,6 +5489,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
|
||||
case CEPH_OSD_OP_CACHE_PIN:
|
||||
case CEPH_OSD_OP_CACHE_UNPIN:
|
||||
case CEPH_OSD_OP_SET_REDIRECT:
|
||||
case CEPH_OSD_OP_TIER_PROMOTE:
|
||||
break;
|
||||
default:
|
||||
if (op.op & CEPH_OSD_OP_MODE_WR)
|
||||
@ -6681,6 +6682,35 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
|
||||
|
||||
break;
|
||||
|
||||
case CEPH_OSD_OP_TIER_PROMOTE:
|
||||
++ctx->num_write;
|
||||
{
|
||||
if (pool.info.is_tier()) {
|
||||
result = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (!obs.exists) {
|
||||
result = -ENOENT;
|
||||
break;
|
||||
}
|
||||
if (get_osdmap()->require_osd_release < CEPH_RELEASE_LUMINOUS) {
|
||||
result = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
if (!obs.oi.has_manifest()) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
object_locator_t tgt_oloc(obs.oi.soid);
|
||||
promote_object(ctx->obc, obs.oi.soid, tgt_oloc, ctx->op, NULL);
|
||||
|
||||
dout(10) << "tier-promote oid:" << oi.soid << " manifest: " << obs.oi.manifest << dendl;
|
||||
result = -EAGAIN;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// -- object attrs --
|
||||
|
||||
case CEPH_OSD_OP_SETXATTR:
|
||||
|
@ -1152,6 +1152,10 @@ struct ObjectOperation {
|
||||
encode(tgt_offset, osd_op.indata);
|
||||
}
|
||||
|
||||
void tier_promote() {
|
||||
add_op(CEPH_OSD_OP_TIER_PROMOTE);
|
||||
}
|
||||
|
||||
void set_alloc_hint(uint64_t expected_object_size,
|
||||
uint64_t expected_write_size,
|
||||
uint32_t flags) {
|
||||
|
@ -128,6 +128,7 @@ void usage(ostream& out)
|
||||
" set redirect target\n"
|
||||
" set-chunk <object A> <offset> <length> --target-pool <caspool> <target object A> <taget-offset>\n"
|
||||
" convert an object to chunked object\n"
|
||||
" tier-promote <obj-name> promote the object to the base tier\n"
|
||||
"\n"
|
||||
"IMPORT AND EXPORT\n"
|
||||
" export [filename]\n"
|
||||
@ -3580,6 +3581,19 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
|
||||
<< "tgt_offset: " << tgt_offset << " : " << cpp_strerror(ret) << std::endl;
|
||||
goto out;
|
||||
}
|
||||
} else if (strcmp(nargs[0], "tier-promote") == 0) {
|
||||
if (!pool_name || nargs.size() < 2)
|
||||
usage_exit();
|
||||
string oid(nargs[1]);
|
||||
|
||||
ObjectWriteOperation op;
|
||||
op.tier_promote();
|
||||
ret = io_ctx.operate(oid, &op);
|
||||
if (ret < 0) {
|
||||
cerr << "error tier-promote " << pool_name << "/" << oid << " : "
|
||||
<< cpp_strerror(ret) << std::endl;
|
||||
goto out;
|
||||
}
|
||||
} else if (strcmp(nargs[0], "export") == 0) {
|
||||
// export [filename]
|
||||
if (!pool_name || nargs.size() > 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user