From: Mingxin Liu Date: Sat, 25 Jun 2016 03:19:01 +0000 (+0800) Subject: tools/rados: default to include clone objects when excuting "cache-flush-evict-all" X-Git-Tag: v10.2.6~30^2~3^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9c001e297060d95582559792d52489e1713c0d60;p=ceph.git tools/rados: default to include clone objects when excuting "cache-flush-evict-all" Signed-off-by: Mingxin Liu (cherry picked from commit b1cf2d9276834d04172d45d5f4dd48ca3e99d338) --- diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 09f95dd2b3779..4f53a68ed8a7a 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -1189,22 +1189,59 @@ static int do_cache_flush_evict_all(IoCtx& io_ctx, bool blocking) io_ctx.locator_set_key(string()); } io_ctx.set_namespace(i->get_nspace()); - if (blocking) - r = do_cache_flush(io_ctx, i->get_oid()); - else - r = do_cache_try_flush(io_ctx, i->get_oid()); + snap_set_t ls; + io_ctx.snap_set_read(LIBRADOS_SNAP_DIR); + r = io_ctx.list_snaps(i->get_oid(), &ls); if (r < 0) { - cerr << "failed to flush " << i->get_nspace() << "/" << i->get_oid() << ": " - << cpp_strerror(r) << std::endl; - ++errors; - continue; + cerr << "error listing snap shots " << i->get_nspace() << "/" << i->get_oid() << ": " + << cpp_strerror(r) << std::endl; + ++errors; + continue; } - r = do_cache_evict(io_ctx, i->get_oid()); - if (r < 0) { - cerr << "failed to evict " << i->get_nspace() << "/" << i->get_oid() << ": " - << cpp_strerror(r) << std::endl; - ++errors; - continue; + std::vector::iterator ci = ls.clones.begin(); + // no snapshots + if (ci == ls.clones.end()) { + io_ctx.snap_set_read(CEPH_NOSNAP); + if (blocking) + r = do_cache_flush(io_ctx, i->get_oid()); + else + r = do_cache_try_flush(io_ctx, i->get_oid()); + if (r < 0) { + cerr << "failed to flush " << i->get_nspace() << "/" << i->get_oid() << ": " + << cpp_strerror(r) << std::endl; + ++errors; + continue; + } + r = do_cache_evict(io_ctx, i->get_oid()); + if (r < 0) { + cerr << "failed to evict " << i->get_nspace() << "/" << i->get_oid() << ": " + << cpp_strerror(r) << std::endl; + ++errors; + continue; + } + } else { + // has snapshots + for (std::vector::iterator ci = ls.clones.begin(); + ci != ls.clones.end(); ++ci) { + io_ctx.snap_set_read(ci->cloneid); + if (blocking) + r = do_cache_flush(io_ctx, i->get_oid()); + else + r = do_cache_try_flush(io_ctx, i->get_oid()); + if (r < 0) { + cerr << "failed to flush " << i->get_nspace() << "/" << i->get_oid() << ": " + << cpp_strerror(r) << std::endl; + ++errors; + break; + } + r = do_cache_evict(io_ctx, i->get_oid()); + if (r < 0) { + cerr << "failed to evict " << i->get_nspace() << "/" << i->get_oid() << ": " + << cpp_strerror(r) << std::endl; + ++errors; + break; + } + } } } }