populate_metadata("");
}
+ ceph_tid_t multi_target_id = 0;
+ if (non_laggy.size() > 1) {
+ std::scoped_lock cmd_lock(command_lock);
+ multi_target_id = command_table.get_new_multi_target_id();
+ }
+
// Send commands to targets
C_GatherBuilder gather(cct, onfinish);
for (const auto& target_gid : non_laggy) {
{
std::scoped_lock cmd_lock(command_lock);
// Generate MDSCommandOp state
- auto &op = command_table.start_command();
+ auto &op = command_table.start_command(multi_target_id);
op.on_finish = gather.new_sub();
op.cmd = cmd;
}
auto &op = command_table.get_command(tid);
+ ceph_tid_t multi_id = command_table.get_multi_target_id(tid);
+
if (op.outbl) {
- *op.outbl = m->get_data();
+ if (multi_id != 0 && m->r == 0) {
+ string prefix;
+ string suffix = "}";
+ string mds_name = fmt::format("mds.{}", fsmap->get_info_gid(op.mds_gid).name);
+
+ if (op.outbl->length() == 0) { // very first command result
+ prefix = fmt::format("[{{\"{}\":", mds_name);
+ }
+ else {
+ prefix = fmt::format(",{{\"{}\":", mds_name);
+ }
+
+ op.outbl->append(prefix);
+ op.outbl->append(m->get_data());
+ op.outbl->append(suffix);
+
+ // when this command is the last one
+ if (command_table.count_multi_commands(multi_id) == 1) {
+ op.outbl->append("]");
+ }
+ }
+ else if (multi_id == 0) {
+ *op.outbl = m->get_data();
+ }
}
if (op.outs) {
*op.outs = m->rs;