MCPcopy Create free account
hub / github.com/ceph/ceph / prepare_command

Method prepare_command

src/mon/MDSMonitor.cc:1479–1562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1477}
1478
1479bool MDSMonitor::prepare_command(MonOpRequestRef op)
1480{
1481 op->mark_mdsmon_event(__func__);
1482 auto m = op->get_req<MMonCommand>();
1483 int r = -EINVAL;
1484 stringstream ss;
1485 bufferlist rdata;
1486
1487 cmdmap_t cmdmap;
1488 if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) {
1489 string rs = ss.str();
1490 mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed());
1491 return false;
1492 }
1493
1494 string prefix;
1495 cmd_getval(cmdmap, "prefix", prefix);
1496
1497 /* Refuse access if message not associated with a valid session */
1498 MonSession *session = op->get_session();
1499 if (!session) {
1500 mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
1501 return false;
1502 }
1503
1504 auto &pending = get_pending_fsmap_writeable();
1505
1506 for (const auto &h : handlers) {
1507 r = h->can_handle(prefix, op, pending, cmdmap, ss);
1508 if (r == 1) {
1509 ; // pass, since we got the right handler.
1510 } else if (r == 0) {
1511 continue;
1512 } else {
1513 goto out;
1514 }
1515
1516 r = h->handle(&mon, pending, op, cmdmap, ss);
1517
1518 if (r == -EAGAIN) {
1519 // message has been enqueued for retry; return.
1520 dout(4) << __func__ << " enqueue for retry by prepare_command" << dendl;
1521 return false;
1522 } else {
1523 if (r == 0) {
1524 // On successful updates, print the updated map
1525 print_map(pending);
1526 }
1527 // Successful or not, we're done: respond.
1528 goto out;
1529 }
1530 }
1531
1532 r = filesystem_command(pending, op, prefix, cmdmap, ss);
1533 if (r >= 0) {
1534 goto out;
1535 } else if (r == -EAGAIN) {
1536 // Do not reply, the message has been enqueued for retry

Callers

nothing calls this directly

Calls 9

cmdmap_from_jsonFunction · 0.85
mark_mdsmon_eventMethod · 0.80
reply_commandMethod · 0.80
can_handleMethod · 0.80
cmd_getvalFunction · 0.70
strMethod · 0.45
get_sessionMethod · 0.45
handleMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected