OSDMonitor: return EEXIST if users try to do a PG merge

This was returning a machine-code success if users tried to merge, and
was erroneously (but harmlessly) increasing the pool's last_change
marker even though it wasn't actually changing anything.

Backport: emperor

Signed-off-by: Greg Farnum <greg@inktank.com>
OSDMonitor: prevent extreme multipliers on PG splits

Fixes: #6922
Backport: emperor

Signed-off-by: Greg Farnum <greg@inktank.com>
OSDMap: use unsigned instead of int for OSD counts

These functions can never return <0, so use unsigned.

Signed-off-by: Greg Farnum <greg@inktank.com>
OSDMonitor: use a different approach to prevent extreme multipliers on PG splits

Signed-off-by: Greg Farnum <greg@inktank.com>
FileSTore: do not time out threads while they're waiting for op throttle

In order to support this, we pass TPHandle* through the ObjectStore
interface, and then if we have one we suspend the timeouts while
waiting to get our op/byte throttles in the FileStore.
The OSD uses this when doing PG splits.

Signed-off-by: Greg Farnum <greg@inktank.com>
Merge pull request #886 from ceph/wip-6922

Fix some pg_num change return codes and make them more resistant to mis-use

Reviewed-by: Sage Weil <sage@inktank.com>
encoding: fix [encode|decode]_array_nohead

We want to actually encode each element and keep it, rather than
writing each one at the position after the array end!

Signed-off-by: Greg Farnum <greg@inktank.com>
MonCommand: support encode/decode

Signed-off-by: Greg Farnum <greg@inktank.com>
MonCommand: add operator== and operator!=

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: expose local monitor commands to other compilation units

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: add a separate leader_supported_commands

This isn't used yet, but will be shortly.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: pull command mapping out of _allowed_command()

We want to be able to validate commands against both the leader and
local command sets, so make that functionality generic.

Signed-off-by: Greg Farnum <greg@inktank.com>
messages: make room for passing supported monitor commands in MMonElection

We're going to use this space to let leader tell everybody what
commands it supports.

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: transmit local api on election win, accept leader's on loss

If we're the leader, just point to our local set. Disseminating these
will let peons advertise the full command set supported by the leader.
INCOMPLETE: does not yet handle winning Electors who do not send a command set.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: disseminate leader's command set instead of our own

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: validate incoming commands against the leader's set too

Then check against our own, and forward if we don't recognize it
or for some reason don't match.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: import MonCommands.h from original Dumpling and expose it

If the Elector doesn't receive a set of commands from the elected leader, it
assumes the monitor is "classic" and uses the Dumpling command set as
the leader set.

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: share local command set when deferring

We're about to use this at a basic level, to identify when we have
"classic" monitors in-quorum, but could also do something more
sophisticated like a set intersection on the commands.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: Elector: share the classic command set if we have a classic mon

The leader now checks to see if any monitors did not provide their
command set, and if so, shares the list of "classic" commands instead
of his own set. This will prevent users from seeing different commands
(depending on whether they connect to an old or new mon) while
performing upgrades, and will make it really obvious if they forgot
to upgrade one of the monitors!

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: keep a list of classic mons instead of each mon's commands

We aren't actually using the sets, so don't bother keeping them.

Signed-off-by: Greg Farnum <greg@inktank.com>