/**
* Fetch backtrace and set tag if tag is non-empty
*/
- void fetch_backtrace_and_tag(CInode *in, std::string_view tag,
+ void fetch_backtrace_and_tag(CInode *in,
+ std::string_view tag, bool is_internal,
Context *fin, int *bt_r, bufferlist *bt)
{
const int64_t pool = in->get_backtrace_pool();
in->mdcache->mds->objecter->read(oid, object_locator_t(pool), fetch, CEPH_NOSNAP,
NULL, 0, fin);
using ceph::encode;
- if (!tag.empty()) {
- ObjectOperation scrub_tag;
+ if (!is_internal) {
+ ObjectOperation scrub_tag;
bufferlist tag_bl;
encode(tag, tag_bl);
scrub_tag.setxattr("scrub_tag", tag_bl);
in->mdcache->mds->finisher);
std::string_view tag = in->scrub_infop->header->get_tag();
+ bool is_internal = in->scrub_infop->header->is_internal_tag();
// Rather than using the usual CInode::fetch_backtrace,
// use a special variant that optionally writes a tag in the same
// operation.
- fetch_backtrace_and_tag(in, tag, conf, &results->backtrace.ondisk_read_retval, &bl);
+ fetch_backtrace_and_tag(in, tag, is_internal, conf, &results->backtrace.ondisk_read_retval, &bl);
return false;
}
if (scrub_infop->header->get_origin() == this) {
// We are at the point that a tagging scrub was initiated
LogChannelRef clog = mdcache->mds->clog;
- if (scrub_infop->header->get_tag().empty()) {
- clog->info() << "scrub complete";
- } else {
- clog->info() << "scrub complete with tag '"
- << scrub_infop->header->get_tag() << "'";
- }
+ clog->info() << "scrub complete with tag '"
+ << scrub_infop->header->get_tag() << "'";
}
}
}
C_MDS_EnqueueScrub *cs = new C_MDS_EnqueueScrub(f, fin);
+
+ bool is_internal = false;
+ std::string tag_str(tag);
+ if (tag_str.empty()) {
+ uuid_d uuid_gen;
+ uuid_gen.generate_random();
+ tag_str = uuid_gen.to_string();
+ is_internal = true;
+ }
+
cs->header = std::make_shared<ScrubHeader>(
- tag, force, recursive, repair, f);
+ tag_str, is_internal, force, recursive, repair, f);
mdr->internal_op_finish = cs;
enqueue_scrub_work(mdr);
*/
class ScrubHeader {
public:
- ScrubHeader(std::string_view tag_, bool force_, bool recursive_,
- bool repair_, Formatter *f_)
- : tag(tag_), force(force_), recursive(recursive_), repair(repair_),
- formatter(f_), origin(nullptr)
+ ScrubHeader(std::string_view tag_, bool is_tag_internal_, bool force_,
+ bool recursive_, bool repair_, Formatter *f_)
+ : tag(tag_), is_tag_internal(is_tag_internal_), force(force_),
+ recursive(recursive_), repair(repair_), formatter(f_), origin(nullptr)
{
ceph_assert(formatter != nullptr);
}
bool get_recursive() const { return recursive; }
bool get_repair() const { return repair; }
bool get_force() const { return force; }
+ bool is_internal_tag() const { return is_tag_internal; }
CInode *get_origin() const { return origin; }
std::string_view get_tag() const { return tag; }
Formatter &get_formatter() const { return *formatter; }
protected:
const std::string tag;
+ bool is_tag_internal;
const bool force;
const bool recursive;
const bool repair;