From 797ee53ab0a14373abd3548c29c42d881e85f4e6 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 16 Mar 2010 11:16:44 -0700 Subject: [PATCH] Revert "mon: PaxosServiceMessages now routed through paxos_dispatch and get caps set" This reverts commit 0c688f94bef805ce6c6a777885406e3e43b90b65. Revert "mon: Use PaxosServiceMessage::caps instead of Session::caps where applicable" This reverts commit e33e17ec2f8994527d23fbc6bd1d064e90c7fce8. This needs to be reworked slightly to handle inter-mon communication better. --- src/messages/PaxosServiceMessage.h | 2 -- src/mon/Monitor.cc | 24 +++++++----------------- src/mon/Monitor.h | 1 - src/mon/OSDMonitor.cc | 15 ++++++++------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/messages/PaxosServiceMessage.h b/src/messages/PaxosServiceMessage.h index d7acd7767cefa..4afa5e1505b2f 100644 --- a/src/messages/PaxosServiceMessage.h +++ b/src/messages/PaxosServiceMessage.h @@ -3,8 +3,6 @@ #include "msg/Message.h" -class MonCaps; - class PaxosServiceMessage : public Message { public: version_t version; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 86e3f7c6b2d41..71407360b98a6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -608,26 +608,26 @@ do { \ case MSG_OSD_PGTEMP: ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_OSD); ALLOW_CAPS(PAXOS_OSDMAP, MON_CAP_R); - paxos_dispatch(paxos_service[PAXOS_OSDMAP], m); + paxos_service[PAXOS_OSDMAP]->dispatch((PaxosServiceMessage*)m); break; case MSG_REMOVE_SNAPS: ALLOW_CAPS(PAXOS_OSDMAP, MON_CAP_RW); - paxos_dispatch(paxos_service[PAXOS_OSDMAP], m); + paxos_service[PAXOS_OSDMAP]->dispatch((PaxosServiceMessage*)m); break; // MDSs case MSG_MDS_BEACON: case MSG_MDS_OFFLOAD_TARGETS: ALLOW_CAPS(PAXOS_MDSMAP, MON_CAP_RW); - paxos_dispatch(paxos_service[PAXOS_MDSMAP], m); + paxos_service[PAXOS_MDSMAP]->dispatch((PaxosServiceMessage*)m); break; // auth case MSG_MON_GLOBAL_ID: case CEPH_MSG_AUTH: /* no need to check caps here */ - paxos_dispatch(paxos_service[PAXOS_AUTH], m); + paxos_service[PAXOS_AUTH]->dispatch((PaxosServiceMessage*)m); break; // pg @@ -635,18 +635,18 @@ do { \ case MSG_PGSTATS: case MSG_GETPOOLSTATS: ALLOW_CAPS(PAXOS_PGMAP, MON_CAP_R); - paxos_dispatch(paxos_service[PAXOS_PGMAP], m); + paxos_service[PAXOS_PGMAP]->dispatch((PaxosServiceMessage*)m); break; case MSG_POOLOP: ALLOW_CAPS(PAXOS_OSDMAP, MON_CAP_RX); - paxos_dispatch(paxos_service[PAXOS_OSDMAP], m); + paxos_service[PAXOS_OSDMAP]->dispatch((PaxosServiceMessage*)m); break; // log case MSG_LOG: ALLOW_CAPS(PAXOS_LOG, MON_CAP_RW); - paxos_dispatch(paxos_service[PAXOS_LOG], m); + paxos_service[PAXOS_LOG]->dispatch((PaxosServiceMessage*)m); break; // paxos @@ -706,16 +706,6 @@ out: return ret; } -void Monitor::paxos_dispatch(PaxosService *p, Message *message) -{ - PaxosServiceMessage *m = (PaxosServiceMessage*)message; - if (!m->caps) { - Session *s = (Session *) m->get_connection()->get_priv(); - m->caps = &s->caps; - } - p->dispatch(m); -} - void Monitor::handle_subscribe(MMonSubscribe *m) { dout(10) << "handle_subscribe " << *m << dendl; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index baaea734c1d15..d1201f769ff53 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -212,7 +212,6 @@ public: bool& isvalid); bool ms_handle_reset(Connection *con); void ms_handle_remote_reset(Connection *con) {} - void paxos_dispatch(PaxosService *p, Message *m); public: Monitor(int w, MonitorStore *s, Messenger *m, MonMap *map); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 29de8643295b3..442fe2b6113d8 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -1006,10 +1006,10 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) int OSDMonitor::prepare_new_pool(MPoolOp *m) { //check permissions for the auid, then pass off to next function - dout(10) << "prepare_new_pool from Session " << std::endl - << ((Session *) m->get_connection()->get_priv()) << dendl; + Session * session = (Session *) m->get_connection()->get_priv(); + dout(10) << "prepare_new_pool from Session " << std::endl << session << dendl; if (m->auid) { - if(m->caps->check_privileges(PAXOS_OSDMAP, MON_CAP_W, m->auid)) { + if(session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_W, m->auid)) { return prepare_new_pool(m->name, m->auid); } else { dout(5) << "attempt to create new pool without sufficient auid privileges!" @@ -1017,8 +1017,8 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m) return -EPERM; } } else { - if (m->caps->check_privileges(PAXOS_OSDMAP, MON_CAP_W)) { - return prepare_new_pool(m->name, m->caps->auid); + if (session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_W)) { + return prepare_new_pool(m->name, session->caps.auid); } else { dout(5) << "attempt to create new pool without sufficient caps!" << *m << dendl; @@ -1416,11 +1416,12 @@ bool OSDMonitor::prepare_pool_op_delete (MPoolOp *m) bool OSDMonitor::prepare_pool_op_auid (MPoolOp *m) { + Session * session = (Session *) m->get_connection()->get_priv(); //check that current user can write to new auid - if(m->caps->check_privileges(PAXOS_OSDMAP, MON_CAP_W, m->auid)) { + if(session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_W, m->auid)) { //check that current user can write to old auid int old_auid = osdmap.get_pg_pool(m->pool)->v.auid; - if(m->caps->check_privileges(PAXOS_OSDMAP, MON_CAP_W, old_auid)) { + if(session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_W, old_auid)) { //update pg_pool_t with new auid pending_inc.new_pools[m->pool] = *(osdmap.get_pg_pool(m->pool)); pending_inc.new_pools[m->pool].v.auid = m->auid; -- 2.39.5