| 2766 | } |
| 2767 | |
| 2768 | void OSD::asok_command( |
| 2769 | std::string_view prefix, const cmdmap_t& cmdmap, |
| 2770 | Formatter *f, |
| 2771 | const bufferlist& inbl, |
| 2772 | asok_finisher on_finish) |
| 2773 | { |
| 2774 | int ret = 0; |
| 2775 | stringstream ss; // stderr error message stream |
| 2776 | bufferlist outbl; // if empty at end, we'll dump formatter as output |
| 2777 | |
| 2778 | // --- PG commands are routed here to PG::do_command --- |
| 2779 | if (prefix == "pg" || |
| 2780 | prefix == "query" || |
| 2781 | prefix == "log" || |
| 2782 | prefix == "mark_unfound_lost" || |
| 2783 | prefix == "list_unfound" || |
| 2784 | prefix == "scrub" || |
| 2785 | prefix == "deep-scrub" || |
| 2786 | prefix == "scrub-abort" || |
| 2787 | prefix == "schedule-scrub" || ///< dev/tests only! |
| 2788 | prefix == "schedule-deep-scrub" ///< dev/tests only! |
| 2789 | ) { |
| 2790 | string pgidstr; |
| 2791 | pg_t pgid; |
| 2792 | if (!cmd_getval(cmdmap, "pgid", pgidstr)) { |
| 2793 | ss << "no pgid specified"; |
| 2794 | ret = -EINVAL; |
| 2795 | goto out; |
| 2796 | } |
| 2797 | if (!pgid.parse(pgidstr.c_str())) { |
| 2798 | ss << "couldn't parse pgid '" << pgidstr << "'"; |
| 2799 | ret = -EINVAL; |
| 2800 | goto out; |
| 2801 | } |
| 2802 | spg_t pcand; |
| 2803 | PGRef pg; |
| 2804 | if (get_osdmap()->get_primary_shard(pgid, &pcand) && |
| 2805 | (pg = _lookup_lock_pg(pcand))) { |
| 2806 | if (pg->is_primary()) { |
| 2807 | cmdmap_t new_cmdmap = cmdmap; |
| 2808 | try { |
| 2809 | pg->do_command(prefix, new_cmdmap, inbl, on_finish); |
| 2810 | pg->unlock(); |
| 2811 | return; // the pg handler calls on_finish directly |
| 2812 | } catch (const TOPNSPC::common::bad_cmd_get& e) { |
| 2813 | pg->unlock(); |
| 2814 | ss << e.what(); |
| 2815 | ret = -EINVAL; |
| 2816 | goto out; |
| 2817 | } |
| 2818 | } else { |
| 2819 | ss << "not primary for pgid " << pgid; |
| 2820 | // do not reply; they will get newer maps and realize they |
| 2821 | // need to resend. |
| 2822 | pg->unlock(); |
| 2823 | ret = -EAGAIN; |
| 2824 | goto out; |
| 2825 | } |
no test coverage detected