From ede9164db040a55a20130b7c27ea7e267f99a20b Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Tue, 21 Apr 2020 05:36:21 -0400 Subject: [PATCH] osd: change tier-flush's operation type to ReadOperation existing flush is the ReadOperation in order to flush older clone that head. Like existing flush, change tier-flush's type to ReadOperation Signed-off-by: Myoungwon Oh --- src/include/rados.h | 2 +- src/include/rados/librados.hpp | 7 ++++++- src/librados/librados_cxx.cc | 14 +++++++------- src/osd/PrimaryLogPG.cc | 3 ++- src/test/osd/RadosModel.h | 5 +++-- src/tools/rados/rados.cc | 12 ++++++++++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/include/rados.h b/src/include/rados.h index 9cf6d628986..1921ae1c9e0 100644 --- a/src/include/rados.h +++ b/src/include/rados.h @@ -326,7 +326,7 @@ extern const char *ceph_osd_state_name(int s); f(SET_CHUNK, __CEPH_OSD_OP(WR, DATA, 40), "set-chunk") \ f(TIER_PROMOTE, __CEPH_OSD_OP(WR, DATA, 41), "tier-promote") \ f(UNSET_MANIFEST, __CEPH_OSD_OP(WR, DATA, 42), "unset-manifest") \ - f(TIER_FLUSH, __CEPH_OSD_OP(WR, DATA, 43), "tier-flush") \ + f(TIER_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 43), "tier-flush") \ \ /** attrs **/ \ /* read */ \ diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 53aa31925d6..60f02852ba3 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -518,7 +518,6 @@ inline namespace v14_2_0 { std::string tgt_oid, uint64_t tgt_offset, int flag = 0); void tier_promote(); void unset_manifest(); - void tier_flush(); friend class IoCtx; @@ -733,6 +732,12 @@ inline namespace v14_2_0 { * triggering a promote on the OSD (that is then evicted). */ void cache_evict(); + + /** + * flush a manifest tier object to backing tier; will block racing + * updates. + */ + void tier_flush(); }; /* IoCtx : This is a context in which we can perform I/O. diff --git a/src/librados/librados_cxx.cc b/src/librados/librados_cxx.cc index bc399ea82e5..38144ad17c8 100644 --- a/src/librados/librados_cxx.cc +++ b/src/librados/librados_cxx.cc @@ -631,6 +631,13 @@ void librados::ObjectReadOperation::cache_evict() o->cache_evict(); } +void librados::ObjectReadOperation::tier_flush() +{ + ceph_assert(impl); + ::ObjectOperation *o = &impl->o; + o->tier_flush(); +} + void librados::ObjectWriteOperation::set_redirect(const std::string& tgt_obj, const IoCtx& tgt_ioctx, uint64_t tgt_version, @@ -669,13 +676,6 @@ void librados::ObjectWriteOperation::unset_manifest() o->unset_manifest(); } -void librados::ObjectWriteOperation::tier_flush() -{ - ceph_assert(impl); - ::ObjectOperation *o = &impl->o; - o->tier_flush(); -} - void librados::ObjectWriteOperation::tmap_update(const bufferlist& cmdbl) { ceph_assert(impl); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 1746ea8f1ec..9ff5dd05949 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -6994,7 +6994,8 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) result = -EOPNOTSUPP; break; } - if (soid.has_snapset()) { + if (ctx->snapc.snaps.size() || + (ctx->obc->ssc && ctx->obc->ssc->snapset.clones.size()) ) { result = -EOPNOTSUPP; break; } diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index 0825ae93863..734ca3e3765 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -2700,7 +2700,7 @@ public: class TierFlushOp : public TestOp { public: librados::AioCompletion *completion; - librados::ObjectWriteOperation op; + librados::ObjectReadOperation op; string oid; std::shared_ptr in_use; @@ -2728,8 +2728,9 @@ public: context->state_lock.unlock(); op.tier_flush(); + unsigned flags = librados::OPERATION_IGNORE_CACHE; int r = context->io_ctx.aio_operate(context->prefix+oid, completion, - &op); + &op, flags, NULL); ceph_assert(!r); } diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 9af05cfdf6d..6fb306ba655 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -3789,9 +3789,17 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } string oid(nargs[1]); - ObjectWriteOperation op; + ObjectReadOperation op; op.tier_flush(); - ret = io_ctx.operate(oid, &op); + librados::AioCompletion *completion = + librados::Rados::aio_create_completion(); + io_ctx.aio_operate(oid.c_str(), completion, &op, + librados::OPERATION_IGNORE_CACHE | + librados::OPERATION_IGNORE_OVERLAY, + NULL); + completion->wait_for_complete(); + ret = completion->get_return_value(); + completion->release(); if (ret < 0) { cerr << "error tier-flush " << pool_name << "/" << oid << " : " << cpp_strerror(ret) << std::endl; -- 2.39.5