osd: reintroduce inc_scrubs_active helper

This mostly generates nice debug output.  It also slightly simplifies
code and makes things symmetric.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: only dec_scrubs_active if we were active

This fixes a bug that puts scrubs_active negative.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: clear scrub state if queued scrub doesn't start

We set SCRUBBING when we queue a pg for scrub.  If we dequeue and
call scrub() but abort for some reason (!active, degraded, etc.), clear
that state bit.

Bug is easily reproduced with 'ceph osd scrub N' during cluster startup
when PGs are peering; some PGs can get left in the scrubbing state.

Signed-off-by: Sage Weil <sage@inktank.com>
PG: in sched_scrub() set PG_STATE_DEEP_SCRUB not scrubber.deep

scrubber.deep gets reset in scrub() to match
state_test(PG_STATE_DEEP_SCRUB).

Signed-off-by: Samuel Just <sam.just@inktank.com>
osd: allow transition from Clean -> WaitLocalRecoveryReserved for repair

If we do a scrub repair, we need to go from clean to recovery again to
copy objects around.

This fixes a simple repair of a missing object, either on the primary or
replica.

Signed-off-by: Sage Weil <sage@inktank.com>
PG::sched_scrub: return true if scrub newly kicked off

The previous return value wasn't really what OSD::sched_scrub
wanted to know.

Signed-off-by: Samuel Just <sam.just@inktank.com>
PG::sched_scrub: only set PG_STATE_DEEP_SCRUB once reserved

Otherwise we would have +DEEP before we have +SCRUB.

Signed-off-by: Samuel Just <sam.just@inktank.com>
auth: use none auth if keyring not found

If both cephx and none are accepted auth methods, and
cephx keyring cannot be found then resort to using
none, instead of failing.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
osd: clear CLEAN on exit from Clean state

This means we can drop the scrub repair state_clear() call.  We probably
can drop others, but lets leave that for another day.

Signed-off-by: Sage Weil <sage@inktank.com>
monc: only warn about missing keyring if we fail to authenticate

This avoids the situation where a librados or other user with the default
of 'cephx,none' and no keyring is authenticating against a cluster with
required of 'none' and an annoying warning is generated every time.  Now
we only print a helpful message if we actually failed.

Signed-off-by: Sage Weil <sage@inktank.com>
Merge remote-tracking branch 'gh/wip-3643' into next

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Merge remote-tracking branch 'gh/wip-scrub' into next
mkcephfs: error out if 'devs' defined but 'osd fs type' not defined

We can infer btrfs if they use btrfs devs, but if they use devs there is
no default fs.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix pg stat msgs vs timeout

We can get a pattern like so:

- new mon session
- after say 120 seconds, we decide to send a stats msg
- outstanding_pg_stats is finally true, we immediately time out (30 second
  grace), and reconnect to a new mon
-> repeat

The problem is that we don't reset the last_sent timestamp when we send.
Or that we do this check after sending instead of before.  Fix both.

This should resolve the issue #3661 where osds that don't have pgs
updating are not stats messags to the mon to check in, and are eventually
getting marked down as a result.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
librbd: move buf_is_zero() to new common/util.cc and include/util.h

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
rbd: check for all-zero buf in export, seek output if so

Use buf_is_zero in common/util.cc

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
rbd: harder-working sparse import from stdin

Try to accumulate image-sized blocks when importing from stdin, even if
each read is shorter than requested; if we get a full block, and it's
all zeroes, we can seek and make a sparse output file

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
import_export.sh: sparse import export

Add tests for:
   - sparse import makes expected sparse images
   - sparse export makes expected sparse files
   - sparse import from stdin also creates sparse images
   - import from partially-sparse file leads to partially-sparse image
   - import from stdin with zeros leads to sparse
   - export from zeros-image to file leads to sparse file

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
init-ceph: default osd_data path

Signed-off-by: Sage Weil <sage@inktank.com>
init-ceph,mkcephfs: default inode64 for mounting xfs

According to hch this is now the default or new kernels.

Signed-off-by: Sage Weil <sage@inktank.com>