mon/OSDMonitor: fix pool deletion checks, races

Unify the pool deletion safety checks into a single set of functions.
Make sure we check the committed state and error out if there is a problem.
Also check the pending state, if any, and delay+retry if there is a
problem there.

This ensures that we correctly verify that a pool is not in use when it
is deleted (by another tier or by cephfs).  These checks are also now
applied to librados calls.

Fixes: #7590
Signed-off-by: Sage Weil <sage@inktank.com>
Merge pull request #1380 from ceph/wip-pool-delete

mon/OSDMonitor: fix pool deletion races

Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
Merge pull request #1378 from ceph/wip-7487

mon: no crush buckets with type 0 (#7487)

Reviewed-by: Greg Farnum <greg@inktank.com>
1. simplified the 'bytes' info to just be bytes
2. prefix all the members of the components_info with 'num_'

Signed-off-by: Babu Shanmugam <anbu@enovance.com>
1. Removed name of the pool from pool_metadata
2. Included pool type in pool_metadata
3. Renamed rep_size attribute to size in pool_metadata

Signed-off-by: Babu Shanmugam <anbu@enovance.com>
ReplicatedPG: ensure clones are readable after find_object_context

We only get EAGAIN if the object is missing.  We also need the
clone to be readable if we are reading it.

The other find_object_context callers already require !degraded.

Fixes: #7624
Signed-off-by: Samuel Just <sam.just@inktank.com>
Merge pull request #1379 from ceph/wip-7562

mon: make quorum list (by name) be in quorum order

Reviewed-by: Greg Farnum <greg@inktank.com>
Merge pull request #1320 from ceph/wip-libcephfs-fixes

Wip libcephfs fixes

Reviewed-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
Merge pull request #1387 from ceph/wip-7618

ReplicatedPG::wait_for_degraded_object: only recover if found

Reviewed-by: Sage Weil <sage@inktank.com>
Merge pull request #1386 from ceph/wip-7624

ReplicatedPG: ensure clones are readable after find_object_context

Reviewed-by: Sage Weil <sage@inktank.com>
obj_bencher: allocate contentsChars to object_size, not op_size

Otherwise, our attempt to sanitize object_size bytes of
data.object_contents will be doomed to memory corruption.

Fixes: #7610
Signed-off-by: Samuel Just <sam.just@inktank.com>
Client: fix build issue (lost semicolon)

Signed-off-by: Greg Farnum <greg@inktank.com>
osd: bracket role changes with scrub reg/unreg

Make sure the reg/unreg calls for putting ourselves in the scrub schedule
bracket any PG role changes, or that initial reg happens after the role
has been initialized.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: only register for scrub if we are the PG primary

There is no reason to put non-primary PGs on the scrub schedule as they
will be ignored when the worker comes around.  This reduces lock
contention and is generally cleaner.

Signed-off-by: Guang Yang <yguang@yahoo-inc.com>
Signed-off-by: Sage Weil <sage@inktank.com>
ReplicatedPG: clean up num_dirty adjustments

Previously, a _delete_head() followed by a recreation on an object in
the same transaction would result in num_dirty being decremented in
_delete_head() without the flag being cleared.  make_writeable() would
then see exists and was_dirty and therefore not increment num_dirty
resulting in a mismatch.  Rather than trying to maintain the num_dirty
number in _delete_head(), rollback_to(), and make_writeable(), it seems
simpler to do the adjustment once in make_writeable based on undirty,
ctx->obc->obs.oi, and ctx->new_obs->oi.

Fixes: 7393
Signed-off-by: Samuel Just <sam.just@inktank.com>
ReplicatedPG: consistently use ctx->at_version.version for stashed object

Otherwise, two ops might end up using the same version number.

Fixes: #7632
Signed-off-by: Samuel Just <sam.just@inktank.com>
os/ObjectStore: dump COLL_MOVE_RENAME

This got missed way back in ef7cffc34f3bad4ffc090361ad9030a47584a3bf
(pre-0.71).

Signed-off-by: Sage Weil <sage@inktank.com>
qa/workunits/rest/test.py: do not test 'osd thrash'

This wreaks havoc on our QA because it marks osds up and down and then
immediately after that we try to scrub and some osds are still down.

Adjust the CLI test to wait for all OSDs to come back up after thrashing.

Signed-off-by: Sage Weil <sage@inktank.com>
ReplicatedPG: use hobject_t for snapset_contexts map

Otherwise, two objects with different namespaces but
the same object_t will end up clobbering each other's
contexts.

Fixes: #7634
Signed-off-by: Samuel Just <sam.just@inktank.com>
ReplicatedPG::trim_object: use old_snaps for rollback

We need to rollback the old value of snaps, not the
new one.

Fixes: #7638
Signed-off-by: Samuel Just <sam.just@inktank.com>