os: add apply_transaction() variant that takes a sequencer

Also, move the convenience wrappers into the interface and funnel through
a single implementation.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit f6c69c3f1ac35546b90315fff625993ba5cd8c07)
os: move apply_transactions() sync wrapper into ObjectStore

This has nothing to do with the backend implementation.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit bc994045ad67fb70c7a0457b8cd29273dd5d1654)
osd: make pg removal thread more friendly

For a large PG these are saturating the filestore and journal queues.  Do
them synchronously to make them more friendly.  They don't need to be fast.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 4712e984d3f62cdf51ea67da8197eed18a5983dd)
osd: set pg removal transactions based on configurable

Use the osd_target_transaction_size knob, and gracefully tolerate bogus
values (e.g., <= 0).

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 5e00af406b89c9817e9a429f92a05ca9c29b19c3)
os/FileStore: fix compile when sync_file_range is missing;

If sync_file_range is not present, we always close inline, and flush
via fdatasync(2).

Fixes compile on ancient platforms like RHEL5.8.

Backport: bobtail
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 8ddb55d34c72e6df1023cf427cbd41f3f98da402)
os/FileStore: only flush inline if write is sufficiently large

Honor filestore_flush_min in the inline flush case.

Backport: bobtail
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 49726dcf973c38c7313ab78743b45ccc879671ea)
osd/PG: move scrub schedule registration into a helper

Simplifies callers, and will let us easily modify the decision of when
to schedule the PG for scrub.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 796907e2159371f84a16cbd35f6caa8ac868acf6)
osd/PG: introduce flags to indicate explicitly requested scrubs

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 1441095d6babfacd781929e8a54ed2f8a4444467)
osd/PG: trigger scrub via scrub schedule, must_ flags

When a scrub is requested, flag it and move it to the front of the
scrub schedule instead of immediately queuing it.  This avoids
bypassing the scrub reservation framework, which can lead to a heavier
impact on performance.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 62ee6e099a8e4873287b54f9bba303ea9523d040)
osd: move scrub schedule random backoff to seperate helper

Separate this from the load check, which will soon vary dependon on the
PG.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit a148120776d0930b265411332a60e93abfbf0423)
osd/PG: remove useless osd_scrub_min_interval check

This was already a no-op: we don't call PG::scrub_sched() unless it has
been osd_scrub_max_interval seconds since we last scrubbed.  Unless we
explicitly requested in, in which case we don't want this check anyway.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 16d67c798b6f752a6e03084bafe861396b86baae)
osd: change scrub min/max thresholds

The previous 'osd scrub min interval' was mostly meaningless and useless.
Meanwhile, the 'osd scrub max interval' would only trigger a scrub if the
load was sufficiently low; if it was high, the PG might *never* scrub.

Instead, make the 'min' what the max used to be.  If it has been more than
this many seconds, and the load is low, scrub.  And add an additional
condition that if it has been more than the max threshold, scrub the PG
no matter what--regardless of the load.

Note that this does not change the default scrub interval for less-loaded
clusters, but it *does* change the meaning of existing config options.

Fixes: #3786
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 299548024acbf8123a4e488424c06e16365fba5a)

Conflicts:

	PendingReleaseNotes
osd: fix object_stat_sum_t dump signedness

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 6f6a41937f1bd05260a8d70b4c4a58ecadb34a2f)
osd: add last_clean_scrub_stamp to pg_stat_t, pg_history_t

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit d738328488de831bf090f23e3fa6d25f6fa819df)
osd: add num_scrub_errors to object_stat_t

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 2475066c3247774a2ad048a2e32968e47da1b0f5)
osd: note last_clean_scrub_stamp, last_scrub_errors

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 389bed5d338cf32ab14c9fc2abbc7bcc386b8a28)
osd: fix scrub scheduling for 0.0

The initial value for pair<utime_t,pg_t> can match pg 0.0, preventing it
from being manually scrubbed.  Fix!

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 26a63df97b2a12fd1a7c1e3cc9ccd34ca2ef9834)
osd: based INCONSISTENT pg state on persistent scrub errors

This makes the state persistent across PG peering and OSD restarts.

This has the side-effect that, on recovery, we rescrub any PGs marked
inconsistent.  This is new behavior!

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 2baf1253eed630a7c4ae4cb43aab6475efd82425)
osd: note must_scrub* flags in PG operator<<

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit d56af797f996ac92bf4e0886d416fd358a2aa08e)
osd: fix rescrub after repair

We were rescrubbing if INCONSISTENT is set, but that is now persistent.
Add a new scrub_after_recovery flag that is reset on each peering interval
and set that when repair encounters errors.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit a586966a3cfb10b5ffec0e9140053a7e4ff105d2)