ceph_assert(r == 0);
r = admin_socket->register_command("scrub_path name=path,type=CephString "
"name=scrubops,type=CephChoices,"
- "strings=force|recursive|repair,n=N,req=false",
+ "strings=force|recursive|repair,n=N,req=false "
+ "name=tag,type=CephString,req=false",
asok_hook,
"scrub an inode and output results");
ceph_assert(r == 0);
+ r = admin_socket->register_command("scrub start "
+ "name=path,type=CephString "
+ "name=scrubops,type=CephChoices,strings=force|recursive|repair,n=N,req=false "
+ "name=tag,type=CephString,req=false",
+ asok_hook,
+ "scrub and inode and output results");
+ ceph_assert(r == 0);
+ r = admin_socket->register_command("scrub abort",
+ asok_hook,
+ "Abort in progress scrub operations(s)");
+ ceph_assert(r == 0);
+ r = admin_socket->register_command("scrub pause",
+ asok_hook,
+ "Pause in progress scrub operations(s)");
+ ceph_assert(r == 0);
+ r = admin_socket->register_command("scrub resume",
+ asok_hook,
+ "Resume paused scrub operations(s)");
+ ceph_assert(r == 0);
+ r = admin_socket->register_command("scrub status",
+ asok_hook,
+ "Status of scrub operations(s)");
+ ceph_assert(r == 0);
r = admin_socket->register_command("tag path name=path,type=CephString"
" name=tag,type=CephString",
asok_hook,
MDSCommand("damage ls", "List detected metadata damage"),
MDSCommand("damage rm name=damage_id,type=CephInt", "Remove a damage table entry"),
MDSCommand("cache drop name=timeout,type=CephInt,range=0,req=false", "trim cache and optionally request client to release all caps and flush the journal"),
- MDSCommand("scrub start name=path,type=CephString name=scrubops,type=CephChoices,strings=force|recursive|repair,n=N,req=false name=tag,type=CephString,req=false",
- "scrub an inode and output results"),
- MDSCommand("scrub abort", "Abort in progress scrub operation(s)"),
- MDSCommand("scrub pause", "Pause in progress scrub operation(s)"),
- MDSCommand("scrub resume", "Resume paused scrub operation(s)"),
- MDSCommand("scrub status", "Status of scrub operation"),
};
return commands;
};
std::lock_guard l(mds_lock);
r = config_client(client_id, !got_value, option, value, ss);
- } else if (command == "scrub_path") {
+ } else if (command == "scrub start" ||
+ command == "scrub_start") {
string path;
+ string tag;
vector<string> scrubop_vec;
cmd_getval(g_ceph_context, cmdmap, "scrubops", scrubop_vec);
cmd_getval(g_ceph_context, cmdmap, "path", path);
-
- C_SaferCond cond;
- command_scrub_start(f, path, "", scrubop_vec, &cond);
- cond.wait();
+ cmd_getval(g_ceph_context, cmdmap, "tag", tag);
+ finisher->queue(
+ new LambdaContext(
+ [this, on_finish, f, path, tag, scrubop_vec](int r) {
+ command_scrub_start(
+ f, path, tag, scrubop_vec,
+ new LambdaContext(
+ [on_finish](int r) {
+ bufferlist outbl;
+ on_finish(r, {}, outbl);
+ }));
+ }));
+ return;
+ } else if (command == "scrub abort") {
+ finisher->queue(
+ new LambdaContext(
+ [this, on_finish, f](int r) {
+ command_scrub_abort(
+ f,
+ new LambdaContext(
+ [on_finish, f](int r) {
+ bufferlist outbl;
+ f->open_object_section("result");
+ f->dump_int("return_code", r);
+ f->close_section();
+ on_finish(r, {}, outbl);
+ }));
+ }));
+ return;
+ } else if (command == "scrub pause") {
+ finisher->queue(
+ new LambdaContext(
+ [this, on_finish, f](int r) {
+ command_scrub_pause(
+ f,
+ new LambdaContext(
+ [on_finish, f](int r) {
+ bufferlist outbl;
+ f->open_object_section("result");
+ f->dump_int("return_code", r);
+ f->close_section();
+ on_finish(r, {}, outbl);
+ }));
+ }));
+ return;
+ } else if (command == "scrub resume") {
+ command_scrub_resume(f);
+ } else if (command == "scrub status") {
+ command_scrub_status(f);
} else if (command == "tag path") {
string path;
cmd_getval(g_ceph_context, cmdmap, "path", path);
uint64_t timeout;
};
-class C_ScrubExecAndReply : public C_ExecAndReply {
-public:
- C_ScrubExecAndReply(MDSRank *mds, const cref_t<MCommand> &m,
- const std::string &path, const std::string &tag,
- const std::vector<std::string> &scrubop)
- : C_ExecAndReply(mds, m), path(path), tag(tag), scrubop(scrubop) {
- }
-
- void exec() override {
- mds->command_scrub_start(&f, path, tag, scrubop, this);
- }
-
-private:
- std::string path;
- std::string tag;
- std::vector<std::string> scrubop;
-};
-
-class C_ScrubControlExecAndReply : public C_ExecAndReply {
-public:
- C_ScrubControlExecAndReply(MDSRank *mds, const cref_t<MCommand> &m,
- const std::string &command)
- : C_ExecAndReply(mds, m), command(command) {
- }
-
- void exec() override {
- if (command == "abort") {
- mds->command_scrub_abort(&f, this);
- } else if (command == "pause") {
- mds->command_scrub_pause(&f, this);
- } else {
- ceph_abort();
- }
- }
-
- void finish(int r) override {
- f.open_object_section("result");
- f.dump_int("return_code", r);
- f.close_section();
- C_ExecAndReply::finish(r);
- }
-
-private:
- std::string command;
-};
-
/**
* This function drops the mds_lock, so don't do anything with
* MDSRank after calling it (we could have gone into shutdown): just
}
void MDSRank::command_scrub_resume(Formatter *f) {
+ std::lock_guard l(mds_lock);
int r = scrubstack->scrub_resume();
f->open_object_section("result");
}
void MDSRank::command_scrub_status(Formatter *f) {
+ std::lock_guard l(mds_lock);
scrubstack->scrub_status(f);
}
*run_later = create_async_exec_context(new C_CacheDropExecAndReply
(this, m, (uint64_t)timeout));
return true;
- } else if (prefix == "scrub start") {
- string path;
- string tag;
- vector<string> scrubop_vec;
- cmd_getval(g_ceph_context, cmdmap, "scrubops", scrubop_vec);
- cmd_getval(g_ceph_context, cmdmap, "path", path);
- cmd_getval(g_ceph_context, cmdmap, "tag", tag);
-
- *need_reply = false;
- *run_later = create_async_exec_context(new C_ScrubExecAndReply
- (this, m, path, tag, scrubop_vec));
- return true;
- } else if (prefix == "scrub abort") {
- *need_reply = false;
- *run_later = create_async_exec_context(new C_ScrubControlExecAndReply
- (this, m, "abort"));
- return true;
- } else if (prefix == "scrub pause") {
- *need_reply = false;
- *run_later = create_async_exec_context(new C_ScrubControlExecAndReply
- (this, m, "pause"));
- return true;
- } else if (prefix == "scrub resume") {
- JSONFormatter f(true);
- command_scrub_resume(&f);
- f.flush(*ds);
- return true;
- } else if (prefix == "scrub status") {
- JSONFormatter f(true);
- command_scrub_status(&f);
- f.flush(*ds);
- return true;
} else {
return false;
}