mirror of
https://github.com/ceph/ceph
synced 2025-01-02 00:52:22 +00:00
mon:Added server-side handling of MPoolSnap.
Currently assumes it's a snap-create message.
This commit is contained in:
parent
ed34a0c7dc
commit
9ce5802a5e
@ -21,10 +21,12 @@ public:
|
||||
ceph_fsid_t fsid;
|
||||
tid_t tid;
|
||||
int replyCode;
|
||||
int epoch;
|
||||
|
||||
|
||||
MPoolSnapReply() : Message(MSG_POOLSNAPREPLY) {}
|
||||
MPoolSnapReply( ceph_fsid_t& f, tid_t t, int rc) :
|
||||
Message(MSG_POOLSNAPREPLY), fsid(f), tid(t), replyCode(rc) {}
|
||||
MPoolSnapReply( ceph_fsid_t& f, tid_t t, int rc, int e) :
|
||||
Message(MSG_POOLSNAPREPLY), fsid(f), tid(t), replyCode(rc), epoch(e) {}
|
||||
|
||||
const char *get_type_name() { return "poolsnapreply"; }
|
||||
|
||||
|
@ -419,6 +419,10 @@ bool Monitor::dispatch_impl(Message *m)
|
||||
paxos_service[PAXOS_PGMAP]->dispatch(m);
|
||||
break;
|
||||
|
||||
case MSG_POOLSNAP:
|
||||
paxos_service[PAXOS_OSDMAP]->dispatch(m);
|
||||
break;
|
||||
|
||||
// log
|
||||
case MSG_LOG:
|
||||
paxos_service[PAXOS_LOG]->dispatch(m);
|
||||
|
@ -271,6 +271,9 @@ bool OSDMonitor::preprocess_query(Message *m)
|
||||
return preprocess_out((MOSDOut*)m);
|
||||
*/
|
||||
|
||||
case MSG_POOLSNAP:
|
||||
return preprocess_pool_snap((MPoolSnap*)m);
|
||||
|
||||
case MSG_REMOVE_SNAPS:
|
||||
return preprocess_remove_snaps((MRemoveSnaps*)m);
|
||||
|
||||
@ -301,6 +304,8 @@ bool OSDMonitor::prepare_update(Message *m)
|
||||
case MSG_OSD_OUT:
|
||||
return prepare_out((MOSDOut*)m);
|
||||
*/
|
||||
case MSG_POOLSNAP:
|
||||
return prepare_pool_snap((MPoolSnap*)m);
|
||||
|
||||
case MSG_REMOVE_SNAPS:
|
||||
return prepare_remove_snaps((MRemoveSnaps*)m);
|
||||
@ -1264,4 +1269,44 @@ out:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OSDMonitor::preprocess_pool_snap ( MPoolSnap *m) {
|
||||
if (m->pool < 0 ) {
|
||||
ss << "unrecognized pool '" << m->pool << "'";
|
||||
err = -ENOENT;
|
||||
//create reply, set replyCode to badness
|
||||
_pool_snap(m->fsid, m->tid, -1, pending_inc.epoch);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool OSDMonitor::prepare_pool_snap ( MPoolSnap *m) {
|
||||
const pg_pool_t *p = &osdmap.get_pg_pool(m->pool);
|
||||
pg_pool_t *pp = 0;
|
||||
if (pending_inc.new_pools.count(pool)) pp = &pending_inc.new_pools[pool];
|
||||
//if the snapname is already in use, we have a problem
|
||||
if (p->snap_exists(m->name) ||
|
||||
pp && pp->snap_exists(m->name)) {
|
||||
ss << "pool " << m->pool << " snap " << m->name << " already exists";
|
||||
err = -EEXIST;
|
||||
_pool_snap(m->fsid, m->tid, -2, pending_inc.epoch);
|
||||
return false;
|
||||
} else {
|
||||
if(!pp) {
|
||||
pp = &pending_inc.new_pools[pool];
|
||||
*pp = *p;
|
||||
}
|
||||
pp->add_snap(m->name, g_clock.now());
|
||||
pp->set_snap_epoch(pending_inc.epoch);
|
||||
ss << "created pool " << m->pool << " snap " << m->name;
|
||||
getline(ss, rs);
|
||||
paxos->wait_for_commit(new Monitor::C_Snap(mon, m, 0, pending_inc.epoch));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void _pool_snap(ceph_fsid_t fsid, tid_t tid, int replyCode, int epoch) {
|
||||
MPoolSnapReply *m = new MPoolSnapReply(fsid, tid, replyCode, epoch);
|
||||
mon->messenger->send_message(m, m->get_orig_source_inst());
|
||||
delete m;
|
||||
}
|
||||
|
@ -83,6 +83,10 @@ private:
|
||||
bool prepare_alive(class MOSDAlive *m);
|
||||
void _alive(MOSDAlive *m);
|
||||
|
||||
bool preprocess_pool_snap ( class MPoolSnap *m);
|
||||
bool prepare_pool_snap (MPoolSnap *m);
|
||||
void _pool_snap(ceph_fsid_t fsid, tid_t tid, int replyCode, int epoch);
|
||||
|
||||
struct C_Booted : public Context {
|
||||
OSDMonitor *cmon;
|
||||
MOSDBoot *m;
|
||||
@ -115,6 +119,17 @@ private:
|
||||
cmon->dispatch((Message*)m);
|
||||
}
|
||||
};
|
||||
struct C_Snap : public Context {
|
||||
OSDMonitor *osdmon;
|
||||
MPoolSnap *m;
|
||||
int replyCode;
|
||||
int epoch;
|
||||
C_Snap(OSDMonitor * osd, MPoolSnap *m_, int rc, int e) :
|
||||
osdmon(osd), m(m_), replyCode(rc), epoch(e) {}
|
||||
void finish(int r) {
|
||||
osdmon->_pool_snap(m->fsid, m->tid, replyCode, epoch);
|
||||
}
|
||||
};
|
||||
|
||||
bool preprocess_out(class MOSDOut *m);
|
||||
bool prepare_out(class MOSDOut *m);
|
||||
|
Loading…
Reference in New Issue
Block a user