From: Jimyeong Lee Date: Sun, 16 Jul 2023 15:44:19 +0000 (+0900) Subject: client: Apply multi target MDS result handling X-Git-Tag: v18.2.4~170^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a2123c94d99e73323f9436f81da33180a01b202;p=ceph.git client: Apply multi target MDS result handling To fix the issue that multi target MDSs result is overwritten Signed-off-by: Jimyeong Lee (cherry picked from commit 0d03e9793b6a91b8938d50eac88ba097587b4313) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 2b7db5a894d1..21940dde6f31 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6354,6 +6354,12 @@ int Client::mds_command( 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) { @@ -6366,7 +6372,7 @@ int Client::mds_command( { 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; @@ -6403,8 +6409,33 @@ void Client::handle_command_reply(const MConstRef& m) } 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;