~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/mon/MDSMonitor.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <sstream>
35
35
 
36
36
#include "common/config.h"
 
37
#include "include/assert.h"
37
38
 
38
39
#define dout_subsys ceph_subsys_mon
39
40
#undef dout_prefix
489
490
{
490
491
  tick();
491
492
  update_logger();
 
493
 
 
494
  if (mon->is_leader())
 
495
    mon->clog.info() << "mdsmap " << mdsmap << "\n";
492
496
}
493
497
 
494
498
void MDSMonitor::get_health(list<pair<health_status_t, string> >& summary,
503
507
  bufferlist rdata;
504
508
  stringstream ss;
505
509
 
 
510
  MonSession *session = m->get_session();
 
511
  if (!session ||
 
512
      (!session->caps.get_allow_all() &&
 
513
       !session->caps.check_privileges(PAXOS_MDSMAP, MON_CAP_R) &&
 
514
       !mon->_allowed_command(session, m->cmd))) {
 
515
    mon->reply_command(m, -EACCES, "access denied", rdata, paxos->get_version());
 
516
    return true;
 
517
  }
 
518
 
506
519
  vector<const char*> args;
507
520
  for (unsigned i = 1; i < m->cmd.size(); i++)
508
521
    args.push_back(m->cmd[i].c_str());
716
729
  stringstream ss;
717
730
  bufferlist rdata;
718
731
 
 
732
  MonSession *session = m->get_session();
 
733
  if (!session ||
 
734
      (!session->caps.get_allow_all() &&
 
735
       !session->caps.check_privileges(PAXOS_MDSMAP, MON_CAP_W) &&
 
736
       !mon->_allowed_command(session, m->cmd))) {
 
737
    mon->reply_command(m, -EACCES, "access denied", rdata, paxos->get_version());
 
738
    return true;
 
739
  }
 
740
 
719
741
  if (m->cmd.size() > 1) {
720
742
    if ((m->cmd[1] == "stop" || m->cmd[1] == "deactivate") && m->cmd.size() > 2) {
721
743
      int who = atoi(m->cmd[2].c_str());
862
884
      r = pending_mdsmap.remove_data_pg_pool(poolid);
863
885
      if (r == 0)
864
886
        ss << "removed data pool " << poolid << " from mdsmap";
865
 
    } else if (m->cmd[1] == "newfs" && m->cmd.size() == 4) {
 
887
    } else if (m->cmd[1] == "newfs" && m->cmd.size() >= 4) {
866
888
      MDSMap newmap;
867
889
      int metadata = atoi(m->cmd[2].c_str());
868
890
      int data = atoi(m->cmd[3].c_str());
869
 
      pending_mdsmap = newmap;
870
 
      pending_mdsmap.epoch = mdsmap.epoch + 1;
871
 
      create_new_fs(pending_mdsmap, metadata, data);
872
 
      ss << "new fs with metadata pool " << metadata << " and data pool " << data;
873
 
      string rs;
874
 
      getline(ss, rs);
875
 
      paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
876
 
      return true;
 
891
      if (m->cmd.size() < 5 || m->cmd[4] != "--yes-i-really-mean-it") {
 
892
        ss << "this is DANGEROUS and will wipe out the mdsmap's fs, and may clobber data in the new pools you specify.  add --yes-i-really-mean-it if you do.";
 
893
        r = -EPERM;
 
894
      } else {
 
895
        pending_mdsmap = newmap;
 
896
        pending_mdsmap.epoch = mdsmap.epoch + 1;
 
897
        create_new_fs(pending_mdsmap, metadata, data);
 
898
        ss << "new fs with metadata pool " << metadata << " and data pool " << data;
 
899
        string rs;
 
900
        getline(ss, rs);
 
901
        paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
 
902
        return true;
 
903
      }
877
904
    }    
878
905
  }
879
906
  if (r == -EINVAL)