+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#ifndef __MAUTHMON_H
-#define __MAUTHMON_H
-
-#include "messages/PaxosServiceMessage.h"
-
-enum {
- AUTH_NOOP = 0,
- AUTH_GET,
- AUTH_SET,
- AUTH_RESPONSE,
-};
-
-class MAuthMon : public PaxosServiceMessage {
-public:
- ceph_fsid_t fsid;
- deque<pair<EntityName, EntityAuth> > info;
- deque<bool> add;
- version_t last;
- __s32 action;
-
-
- MAuthMon() : PaxosServiceMessage(MSG_AUTHMON, 0) {}
- MAuthMon(const ceph_fsid_t& f, version_t l) : PaxosServiceMessage(MSG_AUTHMON, 0), fsid(f), last(l) {}
- MAuthMon(const ceph_fsid_t& f, version_t l, version_t paxos_version) :
- PaxosServiceMessage(MSG_AUTHMON, paxos_version), fsid(f), last(l) {}
-
- const char *get_type_name() { return "class"; }
- void print(ostream& out) {
- out << "class(";
- switch (action) {
- case AUTH_NOOP:
- out << "NOOP, ";
- break;
- case AUTH_GET:
- out << "GET, ";
- break;
- case AUTH_SET:
- out << "SET, ";
- break;
- case AUTH_RESPONSE:
- out << "RESPONSE, ";
- break;
- default:
- out << "Unknown op, ";
- break;
- }
- if (info.size())
- out << info.size() << " entries";
- if (last)
- out << "last " << last;
- out << ")";
- }
-
- void encode_payload() {
- paxos_encode();
- ::encode(fsid, payload);
- ::encode(info, payload);
- ::encode(add, payload);
- ::encode(last, payload);
- ::encode(action, payload);
- }
- void decode_payload() {
- bufferlist::iterator p = payload.begin();
- paxos_decode(p);
- ::decode(fsid, p);
- ::decode(info, p);
- ::decode(add, p);
- ::decode(last, p);
- ::decode(action, p);
- }
-};
-
-#endif
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#ifndef __MAUTHMONACK_H
-#define __MHAUTHMONACK_H
-
-class MAuthMonAck : public PaxosServiceMessage {
-public:
- ceph_fsid_t fsid;
- version_t last;
-
- MAuthMonAck() : PaxosServiceMessage(MSG_AUTHMON_ACK, 0) {}
- MAuthMonAck(ceph_fsid_t& f, version_t l) : PaxosServiceMessage(MSG_AUTHMON_ACK, 0),
- fsid(f), last(l) {}
-
- MAuthMonAck(ceph_fsid_t& f, version_t l, version_t paxos_version) :
- PaxosServiceMessage(MSG_AUTHMON_ACK, paxos_version), fsid(f), last(l) {}
-
-
- const char *get_type_name() { return "auth_mon_ack"; }
- void print(ostream& out) {
- out << "auth_mon(last " << last << ")";
- }
-
- void encode_payload() {
- paxos_encode();
- ::encode(fsid, payload);
- ::encode(last, payload);
- }
- void decode_payload() {
- bufferlist::iterator p = payload.begin();
- paxos_decode(p);
- ::decode(fsid, p);
- ::decode(last, p);
- }
-};
-
-#endif
#include "messages/MMonCommand.h"
#include "messages/MAuth.h"
#include "messages/MAuthReply.h"
-#include "messages/MAuthMon.h"
-#include "messages/MAuthMonAck.h"
#include "messages/MAuthRotating.h"
#include "common/Timer.h"
case MSG_AUTH_ROTATING:
return preprocess_auth_rotating((MAuthRotating *)m);
- case MSG_AUTHMON:
- return preprocess_auth_mon((MAuthMon*)m);
-
default:
assert(0);
delete m;
switch (m->get_type()) {
case MSG_MON_COMMAND:
return prepare_command((MMonCommand*)m);
- case MSG_AUTHMON:
- return prepare_auth_mon((MAuthMon*)m);
default:
assert(0);
delete m;
return true;
}
-
-// auth mon
-
-bool AuthMonitor::preprocess_auth_mon(MAuthMon *m)
-{
- dout(10) << "preprocess_auth_mon " << *m << " from " << m->get_orig_source() << dendl;
-
- int num_new = 0;
- for (deque<pair<EntityName,EntityAuth> >::iterator p = m->info.begin();
- p != m->info.end();
- p++)
- if (!mon->key_server.contains(p->first))
- num_new++;
- if (!num_new) {
- dout(10) << " nothing new" << dendl;
- return true;
- }
- return false;
-}
-
-bool AuthMonitor::prepare_auth_mon(MAuthMon *m)
-{
- dout(10) << "prepare_auth " << *m << " from " << m->get_orig_source() << dendl;
-
- if (ceph_fsid_compare(&m->fsid, &mon->monmap->fsid)) {
- dout(0) << "handle_auth on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
- delete m;
- return false;
- }
- for (deque<pair<EntityName,EntityAuth> >::iterator p = m->info.begin();
- p != m->info.end(); p++) {
- dout(10) << " writing auth " << *p << dendl;
-
- KeyServerData::Incremental inc;
- inc.name = p->first;
- inc.auth = p->second;
- assert(m->action == AUTH_SET);
- inc.op = KeyServerData::AUTH_INC_ADD;
- pending_auth.push_back(inc);
- }
-
- paxos->wait_for_commit(new C_Auth(this, m, m->get_orig_source_inst()));
- return true;
-}
-
-void AuthMonitor::_updated_auth(MAuthMon *m, entity_inst_t who)
-{
- dout(7) << "_updated_auth for " << who << dendl;
- mon->messenger->send_message(new MAuthMonAck(m->fsid, m->last), who);
- delete m;
-}
-
void AuthMonitor::auth_usage(stringstream& ss)
{
ss << "error: usage:" << std::endl;
bool preprocess_auth_rotating(MAuthRotating *m);
- bool preprocess_auth_mon(MAuthMon *m);
- bool prepare_auth_mon(MAuthMon *m);
- void _updated_auth(MAuthMon *m, entity_inst_t who);
-
- struct C_Auth : public Context {
- AuthMonitor *authmon;
- MAuthMon *ack;
- entity_inst_t who;
- C_Auth(AuthMonitor *p, MAuthMon *a, entity_inst_t w) : authmon(p), ack(a), who(w) {}
- void finish(int r) {
- authmon->_updated_auth(ack, who);
- }
- };
-
bool preprocess_command(MMonCommand *m);
bool prepare_command(MMonCommand *m);
// auth
case CEPH_MSG_AUTH:
case MSG_AUTH_ROTATING:
- case MSG_AUTHMON:
paxos_service[PAXOS_AUTH]->dispatch((PaxosServiceMessage*)m);
break;
#define MSG_GETPOOLSTATS 58
#define MSG_GETPOOLSTATSREPLY 59
-#define MSG_AUTHMON 60
-#define MSG_AUTHMON_ACK 61
#define MSG_AUTH_ROTATING 62
#define MSG_POOLOP 49