2006-10-05 05:39:29 +00:00
|
|
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
2007-06-01 19:51:31 +00:00
|
|
|
// vim: ts=8 sw=2 smarttab
|
2006-10-05 05:39:29 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-01-16 14:06:02 +00:00
|
|
|
/* Object Store Device (OSD) Monitor
|
|
|
|
*/
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2010-06-12 13:04:11 +00:00
|
|
|
#ifndef CEPH_OSDMONITOR_H
|
|
|
|
#define CEPH_OSDMONITOR_H
|
2006-10-05 05:39:29 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "include/types.h"
|
|
|
|
#include "msg/Messenger.h"
|
|
|
|
|
|
|
|
#include "osd/OSDMap.h"
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
#include "PaxosService.h"
|
2009-09-21 21:30:19 +00:00
|
|
|
#include "Session.h"
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
class Monitor;
|
2012-11-15 02:16:17 +00:00
|
|
|
#include "messages/MOSDBoot.h"
|
|
|
|
#include "messages/MMonCommand.h"
|
|
|
|
#include "messages/MOSDMap.h"
|
|
|
|
#include "messages/MOSDFailure.h"
|
|
|
|
#include "messages/MPoolOp.h"
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2012-09-18 21:38:47 +00:00
|
|
|
/// information about a particular peer's failure reports for one osd
|
|
|
|
struct failure_reporter_t {
|
|
|
|
int num_reports; ///< reports from this reporter
|
|
|
|
utime_t failed_since; ///< when they think it failed
|
2012-09-04 20:04:58 +00:00
|
|
|
MOSDFailure *msg; ///< most recent failure message
|
2012-09-18 21:38:47 +00:00
|
|
|
|
2012-09-04 20:04:58 +00:00
|
|
|
failure_reporter_t() : num_reports(0), msg(NULL) {}
|
|
|
|
failure_reporter_t(utime_t s) : num_reports(1), failed_since(s), msg(NULL) {}
|
2013-06-23 15:53:09 +00:00
|
|
|
~failure_reporter_t() {
|
|
|
|
// caller should have taken this message before removing the entry.
|
|
|
|
assert(!msg);
|
|
|
|
}
|
2012-09-18 21:38:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// information about all failure reports for one osd
|
|
|
|
struct failure_info_t {
|
|
|
|
map<int, failure_reporter_t> reporters; ///< reporter -> # reports
|
|
|
|
utime_t max_failed_since; ///< most recent failed_since
|
|
|
|
int num_reports;
|
|
|
|
|
|
|
|
failure_info_t() : num_reports(0) {}
|
|
|
|
|
2012-09-04 18:50:30 +00:00
|
|
|
utime_t get_failed_since() {
|
2013-02-13 13:10:21 +00:00
|
|
|
if (max_failed_since == utime_t() && !reporters.empty()) {
|
2012-09-04 18:50:30 +00:00
|
|
|
// the old max must have canceled; recalculate.
|
|
|
|
for (map<int, failure_reporter_t>::iterator p = reporters.begin();
|
|
|
|
p != reporters.end();
|
|
|
|
++p)
|
|
|
|
if (p->second.failed_since > max_failed_since)
|
|
|
|
max_failed_since = p->second.failed_since;
|
|
|
|
}
|
|
|
|
return max_failed_since;
|
|
|
|
}
|
|
|
|
|
2012-09-04 20:04:58 +00:00
|
|
|
// set the message for the latest report. return any old message we had,
|
|
|
|
// if any, so we can discard it.
|
|
|
|
MOSDFailure *add_report(int who, utime_t failed_since, MOSDFailure *msg) {
|
2012-09-18 21:38:47 +00:00
|
|
|
map<int, failure_reporter_t>::iterator p = reporters.find(who);
|
|
|
|
if (p == reporters.end()) {
|
|
|
|
if (max_failed_since == utime_t())
|
|
|
|
max_failed_since = failed_since;
|
|
|
|
else if (max_failed_since < failed_since)
|
|
|
|
max_failed_since = failed_since;
|
2012-09-04 20:04:58 +00:00
|
|
|
p = reporters.insert(map<int, failure_reporter_t>::value_type(who, failure_reporter_t(failed_since))).first;
|
2012-09-18 21:38:47 +00:00
|
|
|
} else {
|
|
|
|
p->second.num_reports++;
|
|
|
|
}
|
|
|
|
num_reports++;
|
2012-09-04 20:04:58 +00:00
|
|
|
|
|
|
|
MOSDFailure *ret = p->second.msg;
|
|
|
|
p->second.msg = msg;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void take_report_messages(list<MOSDFailure*>& ls) {
|
|
|
|
for (map<int, failure_reporter_t>::iterator p = reporters.begin();
|
|
|
|
p != reporters.end();
|
|
|
|
++p) {
|
|
|
|
if (p->second.msg) {
|
|
|
|
ls.push_back(p->second.msg);
|
|
|
|
p->second.msg = NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-09-18 21:38:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cancel_report(int who) {
|
|
|
|
map<int, failure_reporter_t>::iterator p = reporters.find(who);
|
|
|
|
if (p == reporters.end())
|
|
|
|
return;
|
|
|
|
num_reports -= p->second.num_reports;
|
|
|
|
reporters.erase(p);
|
|
|
|
if (reporters.empty())
|
|
|
|
max_failed_since = utime_t();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
class OSDMonitor : public PaxosService {
|
2006-10-24 16:55:51 +00:00
|
|
|
public:
|
2006-10-11 21:36:16 +00:00
|
|
|
OSDMap osdmap;
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2006-10-24 16:55:51 +00:00
|
|
|
private:
|
2006-10-09 19:10:44 +00:00
|
|
|
// [leader]
|
|
|
|
OSDMap::Incremental pending_inc;
|
2012-09-18 21:38:47 +00:00
|
|
|
map<int, failure_info_t> failure_info;
|
2006-10-09 19:10:44 +00:00
|
|
|
map<int,utime_t> down_pending_out; // osd down -> out
|
|
|
|
|
2007-09-28 21:07:08 +00:00
|
|
|
map<int,double> osd_weight;
|
2012-04-25 16:23:49 +00:00
|
|
|
|
2013-04-26 19:22:28 +00:00
|
|
|
/*
|
|
|
|
* cache what epochs we think osds have. this is purely
|
|
|
|
* optimization to try to avoid sending the same inc maps twice.
|
|
|
|
*/
|
|
|
|
map<int,epoch_t> osd_epoch;
|
|
|
|
|
2012-09-04 20:20:32 +00:00
|
|
|
void check_failures(utime_t now);
|
|
|
|
bool check_failure(utime_t now, int target_osd, failure_info_t& fi);
|
|
|
|
|
2012-04-25 16:23:49 +00:00
|
|
|
// map thrashing
|
|
|
|
int thrash_map;
|
|
|
|
int thrash_last_up_osd;
|
|
|
|
bool thrash();
|
|
|
|
|
2013-04-27 00:16:53 +00:00
|
|
|
bool _have_pending_crush();
|
|
|
|
CrushWrapper &_get_stable_crush();
|
2013-03-22 21:27:21 +00:00
|
|
|
void _get_pending_crush(CrushWrapper& newcrush);
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
// svc
|
2008-03-10 23:23:41 +00:00
|
|
|
public:
|
2011-11-11 18:45:27 +00:00
|
|
|
void create_initial();
|
2008-03-10 23:23:41 +00:00
|
|
|
private:
|
2013-05-31 22:32:06 +00:00
|
|
|
void update_from_paxos(bool *need_bootstrap);
|
2007-07-01 14:43:27 +00:00
|
|
|
void create_pending(); // prepare a new pending
|
mon: Single-paxos and key/value store support
We are converting the monitor subsystem to a Single-Paxos architecture,
backed by a key/value store. The previous architecture used a Paxos
instance for each Paxos Service, backed by a nasty Monitor Store that
provided few to no consistency guarantees whatsoever, which led to a fair
amount of workarounds.
Changes:
* Paxos:
- Add k/v store support
- Add documentation describing the new Paxos storage layout and behavior
- Get rid of the stashing code, which was used as a consistency point
mechanism (we no longer need it, because of our k/v store)
- Debug level of 30 will output json-formatted transaction dumps
- Allows for proposal queueing, to be proposed in the same order as
they were queued.
- No more 'is_leader()' function, using instead the Monitor's for
enhanced simplicity.
- Add 'is_lease_valid()' function.
- Disregard 'stashed versions'
- Make the paxos 'state' variable a bit-map, so we lock the proposal
mechanism while maintaining the state [5].
- Related notes: [3]
* PaxosService:
- Add k/v store support, creating wrappers to be used by the services
- Add documentation
- Support single-paxos behavior, creating wrappers to be used by the
services and service-specific version
- Rearrange variables so they are neatly organized in the beginning of
the class
- Add a trim_to() function to be used by the services, instead of letting
them rely on Paxos::trim_to(), which is no longer adequate to the job
at hand
- Debug level of 30 will output json-formatted transaction dumps
- Support proposal queueing, taking it into consideration when
assessing the current state of the service (active, writeable,
readable, ...)
- Redefine the conditions for 'is_{active,readable,writeable}()' given
the new single-paxos approach, with proposal queueing [1].
- Use our own waiting_for_* callback lists, which now must be
dissociated from their Paxos counterparts [2].
- Related notes: [3], [4]
* Monitor:
- Add k/v store support
- Use only one Paxos instance and pass it down to each service instance
- Crank up CEPH_MON_PROTOCOL to 10
* {Auth,Log,MDS,Monmap,OSD,PG}Monitor:
- Add k/v store support
- Add single-paxos support
* AuthMonitor:
- Don't always propose full versions: if the KeyServer doesn't have
keys, we cannot propose a full version. This should only happen when
we start with a brand new store and we are creating the first
pending proposal, and if we were to commit a full version filled
with nothing but a big void of nothingness, we could eventually end
up with a corrupted version.
* Elector:
- Add k/v store support
- Add single-paxos support
* ceph-mon:
- Use the monitor's k/v store instead of MonitorStore
* MMonPaxos:
- remove the machine_id field: This field was used to identify from/to
which paxos service a given message belonged. We no longer have a Paxos
for each service, so this field became obsolete.
Notes:
[1] Redefine the conditions for 'is_{active,readable,writeable}()' on
the PaxosService class, to be used with single-paxos and proposal
queueing:
We should not rely on the Paxos::is_*() functions, since they do not apply
directly to the PaxosService.
All the PaxosService classes share the same Paxos class, but they do not
rely on its values. Each service only relies, uses and updates its own
values on the k/v store. Thus, we may have a given service (e.g., the
OSDMonitor) proposing a new value, hence updating or waiting to update its
store, and we may still consider the LogMonitor as being able to read and
write its own values on the k/v store. In a nutshell, different services
do not overlap on their access to their own store when it comes to reading,
and since the Paxos will queue their updates and deal with them in a FIFO
order, their updates won't overlap either.
Therefore, the conditions for the PaxosService::is_{active,readable,
writeable} differ from those on the Paxos::is_{active,readable,writeable}.
* PaxosService::is_active() - the PaxosService will be considered as
active iff it is not proposing and the Paxos is not recovering. This
means that a given PaxosService (e.g., the OSDMonitor) may be considered
as being active even though some other service (e.g., the LogMonitor) is
proposing a new value and the Paxos is on the UPDATING state. This means
that the OSDMonitor will be able to read its own versions and queue any
changes on to the Paxos. However, if the Paxos is on state RECOVERING,
we cannot be considered as active.
* PaxosService::is_writeable() - We will be able to propose new values
iff we are the Leader, we have a valid lease, and we are not already
proposing. If we are proposing, we must wait for our proposal to finish
in order to proceed with writing to our k/v store; otherwise we could
incur in assuming that our last committed version was, say, 10; then
assign map epochs/versions taking that into consideration, make changes
to the store based on those values, just to come to smash previously
proposed values on the store. We really don't want that. To be fair,
there was a chance we could assume we were always writable, but there
may be unforeseen consequences to this; so we take the conservative
approach here for now, and we will relax it in the future if we believe
it to be fruitful.
* PaxosService::is_readable() - We will be readable iff we are not
proposing and the Paxos is not recovering; if our last committed version
exists; and if we are either a cluster of one or we have a valid lease.
[2] Use own waiting_for_* callback lists on PaxosService, which now must
be dissociated from their Paxos counterparts:
We were relying on Paxos to wait for state changes, but since our state
became somewhat independent from the Paxos state, we have to deal with
callbacks waiting for 'readable', 'writable' or 'active' on different
terms than those that Paxos provide.
So, basically, we will take one of two approaches when it comes to waiting:
* If we are proposing, queue ourselves on our own list, waiting for the
proposal to finish;
* Otherwise, the cause for the need to wait comes from Paxos, so queue
the callback directly on Paxos.
This approach means that we must make sure to check our desired state
whenever the callback is fired up, and re-queue ourselves if the state
didn't quite change (or if it changed but our waiting condition result
didn't). For instance, if we were waiting for a proposal to finish due to
a failed 'is_active()', we will need to recheck if we are active before
continuing once the callback is fired. This is mainly because we may have
finished our proposal, but a new Election may have been called and the
Paxos may not be active.
[3] Propose everything in the queue before bootstrapping, but don't
allow new proposals:
The MonmapMonitor may issue bootstraps once it is updated. We must ensure
that we propose every single pending proposal before we actually do it.
However, ee don't want to propose if we are going to bootstrap; otherwise,
we may end up losing proposals.
[4] Handle the case when first_committed_version equals 0 on a
PaxosService
In a nutshell, the services do not set the first committed version, as
they consider it as a SEP (Somebody Else's Problem). They do rely on it
though, and we, the PaxosService, must ensure that it contains a valid
value (that is, higher than zero) at all times.
Since we will only have a first_committed version equal to zero once,
and that is before the service's first proposal, we are safe to simply
read the variable from the store and assign the first_committed the same
value as the last_committed iff the first_committed version is zero.
This also affects trimming, since trimming relies on the first_committed
version as the lower bound for version trimming. Even though the k/v store
will gracefully ignore any problem from trying to remove non-existent
versions, the main issue would still stand: we'd be removing a non-existent
version and that just doesn't make any sense.
[5] 'lock' paxos when we are running some internal proposals
Force the paxos services to wait for us to complete whatever we are
doing before they can proceed. This is required because on certain
occasions we might need to run internal proposals, not affected to any of
the paxos services (for instance, when learning an old value), and we need
them to stay put, or they might incur in erroneous state and crash the
monitor.
This could have been done with an extra bool, but there was no point
in creating a new variable when we can just as easily reuse the
'state' variable for our twisted interests.
Fixes: #4175
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
2012-06-11 13:55:21 +00:00
|
|
|
void encode_pending(MonitorDBStore::Transaction *t);
|
2011-12-08 20:53:14 +00:00
|
|
|
void on_active();
|
2013-07-16 21:49:55 +00:00
|
|
|
void on_shutdown();
|
2006-10-09 19:10:44 +00:00
|
|
|
|
2013-07-23 15:34:26 +00:00
|
|
|
/**
|
|
|
|
* we haven't delegated full version stashing to paxosservice for some time
|
|
|
|
* now, making this function useless in current context.
|
|
|
|
*/
|
|
|
|
virtual void encode_full(MonitorDBStore::Transaction *t) { }
|
2013-07-08 22:04:59 +00:00
|
|
|
/**
|
|
|
|
* do not let paxosservice periodically stash full osdmaps, or we will break our
|
|
|
|
* locally-managed full maps. (update_from_paxos loads the latest and writes them
|
|
|
|
* out going forward from there, but if we just synced that may mean we skip some.)
|
|
|
|
*/
|
|
|
|
virtual bool should_stash_full() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hook into trim to include the oldest full map in the trim transaction
|
|
|
|
*
|
|
|
|
* This ensures that anyone post-sync will have enough to rebuild their
|
|
|
|
* full osdmaps.
|
|
|
|
*/
|
|
|
|
void encode_trim_extra(MonitorDBStore::Transaction *tx, version_t first);
|
|
|
|
|
2012-08-13 17:46:30 +00:00
|
|
|
void update_msgr_features();
|
|
|
|
|
2011-11-18 17:56:10 +00:00
|
|
|
void share_map_with_random_osd();
|
2007-09-09 23:47:09 +00:00
|
|
|
|
2011-12-08 20:53:14 +00:00
|
|
|
void update_logger();
|
|
|
|
|
2009-06-23 21:03:34 +00:00
|
|
|
void handle_query(PaxosServiceMessage *m);
|
|
|
|
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
|
|
|
|
bool prepare_update(PaxosServiceMessage *m);
|
2007-08-27 02:49:41 +00:00
|
|
|
bool should_propose(double &delay);
|
2006-10-09 19:10:44 +00:00
|
|
|
|
2013-07-09 04:54:53 +00:00
|
|
|
version_t get_trim_to();
|
mon: Paxos: trim through Paxos
Instead of directly modifying the store whenever we want to trim our Paxos
state, we should do it through Paxos, proposing the trim to the quorum and
commit it once accepted.
This enforces three major invariants that we will be able to leverage later
on during the store synchronization:
1) The Leader will set the pace for trimming across the system. No one
will trim their state unless they are committing the value proposed by
the Leader;
2) Following (1), the monitors in the quorum will trim at the same time.
There will be no diverging states due to trimming on different monitors.
3) Each trim will be kept as a transaction in the Paxos' store allowing
us to obtain a consistent state during synchronization, by shipping
the Paxos versions to the other monitor and applying them. We could
incur in an inconsistent state if the trim happened without
constraints, without being logged; by going through Paxos this concern
is no longer relevant.
The trimming itself may be triggered each time a proposal finishes, which
is the time at which we know we have committed a new version on the store.
It shall be triggered iff we are sure we have enough versions on the store
to fill the gap of any monitor that might become alive and still hasn't
drifted enough to require synchronization. Roughly speaking, we will check
if the number of available versions is higher than 'paxos_max_join_drift'.
Furthermore, we added a new option, 'paxos_trim_tolerance', so we are able
to avoid trimming every single time the above condition is met -- which
would happen every time we trimmed a version, and then proposed a new one,
and then we would trim it again, etc. So, just tolerate a couple of commits
before trimming again.
Finally, we added support to enable/disable trimming, which will be
essential during the store synchronization process.
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
2012-07-04 10:47:03 +00:00
|
|
|
|
2012-04-25 18:15:34 +00:00
|
|
|
bool can_mark_down(int o);
|
|
|
|
bool can_mark_up(int o);
|
|
|
|
bool can_mark_out(int o);
|
|
|
|
bool can_mark_in(int o);
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
// ...
|
2011-10-04 20:43:25 +00:00
|
|
|
MOSDMap *build_latest_full();
|
2010-09-09 18:09:57 +00:00
|
|
|
MOSDMap *build_incremental(epoch_t first, epoch_t last);
|
2011-10-04 20:43:25 +00:00
|
|
|
void send_full(PaxosServiceMessage *m);
|
2010-09-09 18:09:57 +00:00
|
|
|
void send_incremental(PaxosServiceMessage *m, epoch_t first);
|
2011-10-04 20:43:25 +00:00
|
|
|
void send_incremental(epoch_t first, entity_inst_t& dest, bool onetime);
|
2010-07-15 18:05:16 +00:00
|
|
|
|
2010-07-30 20:16:24 +00:00
|
|
|
void remove_redundant_pg_temp();
|
2012-12-19 18:33:40 +00:00
|
|
|
void remove_down_pg_temp();
|
2010-12-15 00:21:39 +00:00
|
|
|
int reweight_by_utilization(int oload, std::string& out_str);
|
2013-03-20 21:30:29 +00:00
|
|
|
|
|
|
|
bool check_source(PaxosServiceMessage *m, uuid_d fsid);
|
2007-07-01 14:43:27 +00:00
|
|
|
|
2013-03-20 21:30:49 +00:00
|
|
|
bool preprocess_mark_me_down(class MOSDMarkMeDown *m);
|
|
|
|
|
|
|
|
friend class C_AckMarkedDown;
|
2007-07-01 14:43:27 +00:00
|
|
|
bool preprocess_failure(class MOSDFailure *m);
|
|
|
|
bool prepare_failure(class MOSDFailure *m);
|
2013-03-20 21:30:49 +00:00
|
|
|
bool prepare_mark_me_down(class MOSDMarkMeDown *m);
|
2012-11-12 21:39:02 +00:00
|
|
|
void process_failures();
|
2013-07-19 23:55:03 +00:00
|
|
|
void take_all_failures(list<MOSDFailure*>& ls);
|
2007-07-01 14:43:27 +00:00
|
|
|
|
|
|
|
bool preprocess_boot(class MOSDBoot *m);
|
|
|
|
bool prepare_boot(class MOSDBoot *m);
|
2009-04-27 17:50:37 +00:00
|
|
|
void _booted(MOSDBoot *m, bool logit);
|
2007-07-01 14:43:27 +00:00
|
|
|
|
2008-05-13 21:54:29 +00:00
|
|
|
bool preprocess_alive(class MOSDAlive *m);
|
|
|
|
bool prepare_alive(class MOSDAlive *m);
|
2009-10-10 05:27:38 +00:00
|
|
|
void _reply_map(PaxosServiceMessage *m, epoch_t e);
|
2009-08-06 23:15:48 +00:00
|
|
|
|
|
|
|
bool preprocess_pgtemp(class MOSDPGTemp *m);
|
|
|
|
bool prepare_pgtemp(class MOSDPGTemp *m);
|
2008-05-13 19:19:05 +00:00
|
|
|
|
2011-08-25 20:30:49 +00:00
|
|
|
int _prepare_remove_pool(uint64_t pool);
|
2012-06-29 21:51:32 +00:00
|
|
|
int _prepare_rename_pool(uint64_t pool, string newname);
|
2011-05-26 20:17:12 +00:00
|
|
|
|
2009-07-07 22:06:33 +00:00
|
|
|
bool preprocess_pool_op ( class MPoolOp *m);
|
2009-07-07 23:04:58 +00:00
|
|
|
bool preprocess_pool_op_create ( class MPoolOp *m);
|
2009-07-07 22:06:33 +00:00
|
|
|
bool prepare_pool_op (MPoolOp *m);
|
2009-07-07 23:04:58 +00:00
|
|
|
bool prepare_pool_op_create (MPoolOp *m);
|
2010-02-12 22:25:57 +00:00
|
|
|
bool prepare_pool_op_delete(MPoolOp *m);
|
2012-01-10 19:25:25 +00:00
|
|
|
int prepare_new_pool(string& name, uint64_t auid, int crush_rule,
|
2013-09-09 11:23:42 +00:00
|
|
|
unsigned pg_num, unsigned pgp_num,
|
|
|
|
const vector<string> &properties);
|
2010-03-08 14:44:51 +00:00
|
|
|
int prepare_new_pool(MPoolOp *m);
|
2013-03-30 00:59:35 +00:00
|
|
|
|
|
|
|
void update_pool_flags(int64_t pool_id, uint64_t flags);
|
|
|
|
bool update_pools_status();
|
|
|
|
void get_pools_health(list<pair<health_status_t,string> >& summary,
|
|
|
|
list<pair<health_status_t,string> > *detail) const;
|
|
|
|
|
2012-04-24 03:33:48 +00:00
|
|
|
bool prepare_set_flag(MMonCommand *m, int flag);
|
|
|
|
bool prepare_unset_flag(MMonCommand *m, int flag);
|
2010-03-10 20:56:37 +00:00
|
|
|
|
2011-07-07 21:13:14 +00:00
|
|
|
void _pool_op_reply(MPoolOp *m, int ret, epoch_t epoch, bufferlist *blp=NULL);
|
2009-06-16 21:22:32 +00:00
|
|
|
|
2008-05-13 19:19:05 +00:00
|
|
|
struct C_Booted : public Context {
|
2007-07-01 14:43:27 +00:00
|
|
|
OSDMonitor *cmon;
|
|
|
|
MOSDBoot *m;
|
2010-01-29 21:05:44 +00:00
|
|
|
bool logit;
|
|
|
|
C_Booted(OSDMonitor *cm, MOSDBoot *m_, bool l=true) :
|
|
|
|
cmon(cm), m(m_), logit(l) {}
|
2007-07-01 14:43:27 +00:00
|
|
|
void finish(int r) {
|
|
|
|
if (r >= 0)
|
2010-01-29 21:05:44 +00:00
|
|
|
cmon->_booted(m, logit);
|
2013-02-08 06:06:14 +00:00
|
|
|
else if (r == -ECANCELED)
|
|
|
|
m->put();
|
2013-02-08 07:13:17 +00:00
|
|
|
else if (r == -EAGAIN)
|
2009-06-23 21:03:34 +00:00
|
|
|
cmon->dispatch((PaxosServiceMessage*)m);
|
2013-02-08 07:13:17 +00:00
|
|
|
else
|
|
|
|
assert(0 == "bad C_Booted return value");
|
2007-07-01 14:43:27 +00:00
|
|
|
}
|
|
|
|
};
|
2009-06-23 21:03:34 +00:00
|
|
|
|
2009-08-06 23:15:48 +00:00
|
|
|
struct C_ReplyMap : public Context {
|
2008-05-13 19:19:05 +00:00
|
|
|
OSDMonitor *osdmon;
|
2009-10-10 05:27:38 +00:00
|
|
|
PaxosServiceMessage *m;
|
2009-08-06 23:15:48 +00:00
|
|
|
epoch_t e;
|
2009-10-10 05:27:38 +00:00
|
|
|
C_ReplyMap(OSDMonitor *o, PaxosServiceMessage *mm, epoch_t ee) : osdmon(o), m(mm), e(ee) {}
|
2008-05-13 19:19:05 +00:00
|
|
|
void finish(int r) {
|
2013-02-08 07:13:17 +00:00
|
|
|
if (r >= 0)
|
2013-02-08 06:06:14 +00:00
|
|
|
osdmon->_reply_map(m, e);
|
2013-02-08 07:13:17 +00:00
|
|
|
else if (r == -ECANCELED)
|
2013-02-08 06:06:14 +00:00
|
|
|
m->put();
|
2013-02-08 07:13:17 +00:00
|
|
|
else if (r == -EAGAIN)
|
2013-02-08 06:06:14 +00:00
|
|
|
osdmon->dispatch(m);
|
2013-02-08 07:13:17 +00:00
|
|
|
else
|
|
|
|
assert(0 == "bad C_ReplyMap return value");
|
2008-05-13 19:19:05 +00:00
|
|
|
}
|
|
|
|
};
|
2009-07-07 22:06:33 +00:00
|
|
|
struct C_PoolOp : public Context {
|
2009-06-16 21:22:32 +00:00
|
|
|
OSDMonitor *osdmon;
|
2009-07-07 22:06:33 +00:00
|
|
|
MPoolOp *m;
|
2009-06-16 21:22:32 +00:00
|
|
|
int replyCode;
|
|
|
|
int epoch;
|
2012-12-09 05:44:54 +00:00
|
|
|
bufferlist reply_data;
|
|
|
|
C_PoolOp(OSDMonitor * osd, MPoolOp *m_, int rc, int e, bufferlist *rd=NULL) :
|
|
|
|
osdmon(osd), m(m_), replyCode(rc), epoch(e) {
|
|
|
|
if (rd)
|
|
|
|
reply_data = *rd;
|
|
|
|
}
|
2009-06-16 21:22:32 +00:00
|
|
|
void finish(int r) {
|
2013-02-08 07:13:17 +00:00
|
|
|
if (r >= 0)
|
2013-02-08 06:06:14 +00:00
|
|
|
osdmon->_pool_op_reply(m, replyCode, epoch, &reply_data);
|
2013-02-08 07:13:17 +00:00
|
|
|
else if (r == -ECANCELED)
|
2013-02-08 06:06:14 +00:00
|
|
|
m->put();
|
2013-02-08 07:13:17 +00:00
|
|
|
else if (r == -EAGAIN)
|
2013-02-08 06:06:14 +00:00
|
|
|
osdmon->dispatch(m);
|
2013-02-08 07:13:17 +00:00
|
|
|
else
|
|
|
|
assert(0 == "bad C_PoolOp return value");
|
2009-06-16 21:22:32 +00:00
|
|
|
}
|
|
|
|
};
|
2007-07-01 14:43:27 +00:00
|
|
|
|
2013-08-09 09:58:58 +00:00
|
|
|
bool preprocess_remove_snaps(struct MRemoveSnaps *m);
|
|
|
|
bool prepare_remove_snaps(struct MRemoveSnaps *m);
|
2008-08-07 21:21:16 +00:00
|
|
|
|
2006-10-05 05:39:29 +00:00
|
|
|
public:
|
mon: Single-paxos and key/value store support
We are converting the monitor subsystem to a Single-Paxos architecture,
backed by a key/value store. The previous architecture used a Paxos
instance for each Paxos Service, backed by a nasty Monitor Store that
provided few to no consistency guarantees whatsoever, which led to a fair
amount of workarounds.
Changes:
* Paxos:
- Add k/v store support
- Add documentation describing the new Paxos storage layout and behavior
- Get rid of the stashing code, which was used as a consistency point
mechanism (we no longer need it, because of our k/v store)
- Debug level of 30 will output json-formatted transaction dumps
- Allows for proposal queueing, to be proposed in the same order as
they were queued.
- No more 'is_leader()' function, using instead the Monitor's for
enhanced simplicity.
- Add 'is_lease_valid()' function.
- Disregard 'stashed versions'
- Make the paxos 'state' variable a bit-map, so we lock the proposal
mechanism while maintaining the state [5].
- Related notes: [3]
* PaxosService:
- Add k/v store support, creating wrappers to be used by the services
- Add documentation
- Support single-paxos behavior, creating wrappers to be used by the
services and service-specific version
- Rearrange variables so they are neatly organized in the beginning of
the class
- Add a trim_to() function to be used by the services, instead of letting
them rely on Paxos::trim_to(), which is no longer adequate to the job
at hand
- Debug level of 30 will output json-formatted transaction dumps
- Support proposal queueing, taking it into consideration when
assessing the current state of the service (active, writeable,
readable, ...)
- Redefine the conditions for 'is_{active,readable,writeable}()' given
the new single-paxos approach, with proposal queueing [1].
- Use our own waiting_for_* callback lists, which now must be
dissociated from their Paxos counterparts [2].
- Related notes: [3], [4]
* Monitor:
- Add k/v store support
- Use only one Paxos instance and pass it down to each service instance
- Crank up CEPH_MON_PROTOCOL to 10
* {Auth,Log,MDS,Monmap,OSD,PG}Monitor:
- Add k/v store support
- Add single-paxos support
* AuthMonitor:
- Don't always propose full versions: if the KeyServer doesn't have
keys, we cannot propose a full version. This should only happen when
we start with a brand new store and we are creating the first
pending proposal, and if we were to commit a full version filled
with nothing but a big void of nothingness, we could eventually end
up with a corrupted version.
* Elector:
- Add k/v store support
- Add single-paxos support
* ceph-mon:
- Use the monitor's k/v store instead of MonitorStore
* MMonPaxos:
- remove the machine_id field: This field was used to identify from/to
which paxos service a given message belonged. We no longer have a Paxos
for each service, so this field became obsolete.
Notes:
[1] Redefine the conditions for 'is_{active,readable,writeable}()' on
the PaxosService class, to be used with single-paxos and proposal
queueing:
We should not rely on the Paxos::is_*() functions, since they do not apply
directly to the PaxosService.
All the PaxosService classes share the same Paxos class, but they do not
rely on its values. Each service only relies, uses and updates its own
values on the k/v store. Thus, we may have a given service (e.g., the
OSDMonitor) proposing a new value, hence updating or waiting to update its
store, and we may still consider the LogMonitor as being able to read and
write its own values on the k/v store. In a nutshell, different services
do not overlap on their access to their own store when it comes to reading,
and since the Paxos will queue their updates and deal with them in a FIFO
order, their updates won't overlap either.
Therefore, the conditions for the PaxosService::is_{active,readable,
writeable} differ from those on the Paxos::is_{active,readable,writeable}.
* PaxosService::is_active() - the PaxosService will be considered as
active iff it is not proposing and the Paxos is not recovering. This
means that a given PaxosService (e.g., the OSDMonitor) may be considered
as being active even though some other service (e.g., the LogMonitor) is
proposing a new value and the Paxos is on the UPDATING state. This means
that the OSDMonitor will be able to read its own versions and queue any
changes on to the Paxos. However, if the Paxos is on state RECOVERING,
we cannot be considered as active.
* PaxosService::is_writeable() - We will be able to propose new values
iff we are the Leader, we have a valid lease, and we are not already
proposing. If we are proposing, we must wait for our proposal to finish
in order to proceed with writing to our k/v store; otherwise we could
incur in assuming that our last committed version was, say, 10; then
assign map epochs/versions taking that into consideration, make changes
to the store based on those values, just to come to smash previously
proposed values on the store. We really don't want that. To be fair,
there was a chance we could assume we were always writable, but there
may be unforeseen consequences to this; so we take the conservative
approach here for now, and we will relax it in the future if we believe
it to be fruitful.
* PaxosService::is_readable() - We will be readable iff we are not
proposing and the Paxos is not recovering; if our last committed version
exists; and if we are either a cluster of one or we have a valid lease.
[2] Use own waiting_for_* callback lists on PaxosService, which now must
be dissociated from their Paxos counterparts:
We were relying on Paxos to wait for state changes, but since our state
became somewhat independent from the Paxos state, we have to deal with
callbacks waiting for 'readable', 'writable' or 'active' on different
terms than those that Paxos provide.
So, basically, we will take one of two approaches when it comes to waiting:
* If we are proposing, queue ourselves on our own list, waiting for the
proposal to finish;
* Otherwise, the cause for the need to wait comes from Paxos, so queue
the callback directly on Paxos.
This approach means that we must make sure to check our desired state
whenever the callback is fired up, and re-queue ourselves if the state
didn't quite change (or if it changed but our waiting condition result
didn't). For instance, if we were waiting for a proposal to finish due to
a failed 'is_active()', we will need to recheck if we are active before
continuing once the callback is fired. This is mainly because we may have
finished our proposal, but a new Election may have been called and the
Paxos may not be active.
[3] Propose everything in the queue before bootstrapping, but don't
allow new proposals:
The MonmapMonitor may issue bootstraps once it is updated. We must ensure
that we propose every single pending proposal before we actually do it.
However, ee don't want to propose if we are going to bootstrap; otherwise,
we may end up losing proposals.
[4] Handle the case when first_committed_version equals 0 on a
PaxosService
In a nutshell, the services do not set the first committed version, as
they consider it as a SEP (Somebody Else's Problem). They do rely on it
though, and we, the PaxosService, must ensure that it contains a valid
value (that is, higher than zero) at all times.
Since we will only have a first_committed version equal to zero once,
and that is before the service's first proposal, we are safe to simply
read the variable from the store and assign the first_committed the same
value as the last_committed iff the first_committed version is zero.
This also affects trimming, since trimming relies on the first_committed
version as the lower bound for version trimming. Even though the k/v store
will gracefully ignore any problem from trying to remove non-existent
versions, the main issue would still stand: we'd be removing a non-existent
version and that just doesn't make any sense.
[5] 'lock' paxos when we are running some internal proposals
Force the paxos services to wait for us to complete whatever we are
doing before they can proceed. This is required because on certain
occasions we might need to run internal proposals, not affected to any of
the paxos services (for instance, when learning an old value), and we need
them to stay put, or they might incur in erroneous state and crash the
monitor.
This could have been done with an extra bool, but there was no point
in creating a new variable when we can just as easily reuse the
'state' variable for our twisted interests.
Fixes: #4175
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
2012-06-11 13:55:21 +00:00
|
|
|
OSDMonitor(Monitor *mn, Paxos *p, string service_name)
|
|
|
|
: PaxosService(mn, p, service_name),
|
|
|
|
thrash_map(0), thrash_last_up_osd(-1) { }
|
2006-10-05 05:39:29 +00:00
|
|
|
|
|
|
|
void tick(); // check state, take actions
|
|
|
|
|
2012-09-10 22:45:50 +00:00
|
|
|
int parse_osd_id(const char *s, stringstream *pss);
|
2013-05-21 23:23:04 +00:00
|
|
|
void parse_loc_map(const vector<string>& args, map<string,string> *ploc);
|
2012-09-10 22:45:50 +00:00
|
|
|
|
2012-03-07 04:55:11 +00:00
|
|
|
void get_health(list<pair<health_status_t,string> >& summary,
|
|
|
|
list<pair<health_status_t,string> > *detail) const;
|
2008-02-28 18:21:48 +00:00
|
|
|
bool preprocess_command(MMonCommand *m);
|
|
|
|
bool prepare_command(MMonCommand *m);
|
2007-12-19 04:53:48 +00:00
|
|
|
|
2013-10-10 22:34:06 +00:00
|
|
|
int prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
|
|
|
|
stringstream& ss);
|
|
|
|
|
2011-01-06 21:33:07 +00:00
|
|
|
void handle_osd_timeouts(const utime_t &now,
|
2012-04-24 17:55:18 +00:00
|
|
|
std::map<int,utime_t> &last_osd_report);
|
2007-02-26 00:17:32 +00:00
|
|
|
void mark_all_down();
|
|
|
|
|
2009-10-10 05:27:38 +00:00
|
|
|
void send_latest(PaxosServiceMessage *m, epoch_t start=0);
|
2009-11-06 21:54:53 +00:00
|
|
|
void send_latest_now_nodelete(PaxosServiceMessage *m, epoch_t start=0) {
|
|
|
|
send_incremental(m, start);
|
|
|
|
}
|
2007-05-16 21:53:22 +00:00
|
|
|
|
2012-10-21 22:31:17 +00:00
|
|
|
epoch_t blacklist(const entity_addr_t& a, utime_t until);
|
2008-12-16 18:41:55 +00:00
|
|
|
|
2012-08-21 21:22:20 +00:00
|
|
|
void dump_info(Formatter *f);
|
|
|
|
|
2009-08-28 23:48:09 +00:00
|
|
|
void check_subs();
|
2009-09-21 21:30:19 +00:00
|
|
|
void check_sub(Subscription *sub);
|
2009-08-28 23:48:09 +00:00
|
|
|
|
2009-10-22 05:48:12 +00:00
|
|
|
void add_flag(int flag) {
|
2009-10-23 00:15:20 +00:00
|
|
|
if (!(osdmap.flags & flag)) {
|
|
|
|
if (pending_inc.new_flags < 0)
|
|
|
|
pending_inc.new_flags = osdmap.flags;
|
|
|
|
pending_inc.new_flags |= flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void remove_flag(int flag) {
|
|
|
|
if(osdmap.flags & flag) {
|
|
|
|
if (pending_inc.new_flags < 0)
|
|
|
|
pending_inc.new_flags = osdmap.flags;
|
|
|
|
pending_inc.new_flags &= ~flag;
|
|
|
|
}
|
2009-10-22 05:48:12 +00:00
|
|
|
}
|
2006-10-05 05:39:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|