PG: create macro for simple events

This should make defining no-information events a bit simpler.

Signed-off-by: Samuel Just <sam.just@inktank.com>
osd: return -EPERM on insufficient caps

Send a failure to the client instead of dropping the request on the floor.

Fixes: #3066
Signed-off-by: Sage Weil <sage@inktank.com>
osd: some whitespace

Signed-off-by: Sage Weil <sage@inktank.com>
osd: catch decoding errors from client ops

Check for decode errors in client ops and return -EINVAL.

Fixes: #2500
Signed-off-by: Sage Weil <sage@inktank.com>
ReplicatedPG: set op return version to pg version on ENOENT

This will be useful for detecting read-delete races in
radosgw.

Signed-off-by: Samuel Just <sam.just@inktank.com>
librados: note that watch's version param is ignored

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: ensure header is up to date after initial read

Use an assert version op in combination with our watch, and re-read
the header until it's not stale. Header updates are infrequent, so
this should not cause any delay with normal use.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSD: add init and shutdown for OSDService

Signed-off-by: Samuel Just <sam.just@inktank.com>
rgw: url_decode should allocate extra byte for dest

Was missing extra byte for null termination

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
osd/: add backfill reservations

Previously, a new osd would be bombarded by backfills from many osds
simultaneously, resulting in excessively high load.  Instead, we
want to limit the number of backfills coming into and going out
from a single osd.

To that end, each OSDService now has two AsyncReserver instances: one
for backfills going from the osd (local_reserver) and one for backfills
going to the osd (remote_reserver).  For a primary to initiate a
backfill, it must first obtain a reservation from its own
local_reserver.  Then, it must obtain a reservation from the backfill
target's remote_reserver via a MBackfillReserve message. This process is
managed by substates of Active and ReplicaActive (see the changes in
PG.h).  The reservations are dropped either on the Backfilled event,
which is sent on the primary before calling recovery_complete and on the
replica on receipt of the BackfillComplete progress message), or upon
leaving Active or ReplicaActive.

It's important that we always grab the local reservation before the
remote reservation in order to prevent a circular dependency.

Signed-off-by: Samuel Just <sam.just@inktank.com>
osd/: add PG_STATE_BACKFILLING

PG_STATE_BACKFILLING is set when the pg enters the Backfilling state.
That is, +backfilling indicates that the pg has obtained its
reservations and is now actively backfilling.

Signed-off-by: Samuel Just <sam.just@inktank.com>
doc/: added documentation for backfill_reservation

Signed-off-by: Samuel Just <sam.just@inktank.com>
PG: add CEPH_FEATURE for backfill reservation

Also adds backwards compatibility by just post_event-ing
the RemoteBackfillReserved() rather than sending the
message to an older replica.

Signed-off-by: Samuel Just <sam.just@inktank.com>
PG,osd_types,PGMonitor: make backfill state names more descriptive

PG_STATE_BACKFILL->PG_STATE_BACKFILL_WAIT
and
PG_STATE_BACKFILLING->PG_STATE_BACKFILL

backfill -> wait_backfill
backfill+backfilling -> backfill

Signed-off-by: Samuel Just <sam.just@inktank.com>
librbd: fix coverity warnings for AioCompletions

CID 717220: Uninitialized pointer field (UNINIT_CTOR)
At (4): Non-static class member "aio_type" is not initialized in this
constructor nor in any functions that it calls.

CID 717221: Uninitialized pointer field (UNINIT_CTOR)
At (2): Non-static class member "m_req" is not initialized in this
constructor nor in any functions that it calls.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: init everything in default AioRequest constructors

CID 717222: Uninitialized pointer field (UNINIT_CTOR)
At (16): Non-static class member "m_hide_enoent" is not initialized
in this constructor nor in any functions that it calls.

CID 717223: Uninitialized scalar field (UNINIT_CTOR)
At (4): Non-static class member "m_has_parent" is not initialized in
this constructor nor in any functions that it calls.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: initialize on-disk header in ImageCtx ctor

CID 717224: Uninitialized scalar field (UNINIT_CTOR)
At (26): Non-static class member field "header.snaps" is not
initialized in this constructor nor in any functions that it calls.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: init m_req in LibrbdWriteback::C_Read ctor

CID 717225: Uninitialized pointer field (UNINIT_CTOR)
At (2): Non-static class member "m_req" is not initialized in this
constructor nor in any functions that it calls.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: init cookie in WatchCtx ctor

CID 717226: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "cookie" is not initialized in this
constructor nor in any functions that it calls.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: use 64-bits to shift order

Order is never actually this high currently, but it be via librbd.

CID 716937: Overflowed return value (INTEGER_OVERFLOW)
At (3): Overflowed or truncated value (or a value computed from an
overflowed or truncated value) "offset" used as return value.

CID 717012: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "1 << obj_order" with type
"int" (32 bits, signed) is evaluated using 32-bit arithmetic before
being used in a context which expects an expression of type "uint64_t"
(64 bits, unsigned). To avoid overflow, cast the left operand to
"uint64_t" before performing the left shift.

CID 717011: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "1 << order" with type
"int" (32 bits, signed) is evaluated using 32-bit arithmetic before
being used in a context which expects an expression of type "uint64_t"
(64 bits, unsigned). To avoid overflow, cast the left operand to
"uint64_t" before performing the left shift.

CID 717013: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "1 << order" with type
"int" (32 bits, signed) is evaluated using 32-bit arithmetic before
being used in a context which expects an expression of type "uint64_t"
(64 bits, unsigned). To avoid overflow, cast the left operand to
"uint64_t" before performing the left shift.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>