rbd: remove fiemap use from import

On some kernels and filesystems fiemap can be racy and provide
incorrect data even after an fsync. Later we can use SEEK_HOLE and
SEEK_DATA, but for now just detect zero runs like we do with stdin.

Basically this adapts import from stdin to work in the case of a file
or block device, and gets rid of other cruft in the import that used
fiemap.

Fixes: #4388
Backport: bobtail
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 3091283895e8ffa3e4bda13399318a6e720d498f)
test_librbd_fsx: fix image closing

Always close the image we opened in check_clone(), and check the
return code of the rbd_close() called before cloning.

Refs: #3958
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 94ae72546507799667197fd941633bb1fd2520c2)
osd: tolerate rmw_flags==0

We will let OSD return a proper error instead of asserting.

This is effectively a backport of c313423cfda55a2231e000cd5ff20729310867f8.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix detection of non-existent class method

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 50b831e3641c21cd5b145271688189e199f432d1)
osd: EINVAL when rmw_flags is 0

A broken client (e.g., v0.56) can send a request that ends up with an
rmw_flags of 0.  Treat this as invalid and return EINVAL.

Fixes: #4556
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit f2dda43c9ed4fda9cfa87362514985ee79e0ae15)
osd: disallow classes with flags==0

They must be RD, WR, or something....

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 89c69016e1dddb9f3ca40fd699e4a995ef1e3eee)
ReplicatedPG: send entire stats on OP_BACKFILL_FINISH

Otherwise, we update the stat.stat structure, but not the
stat.invalid_stats part.  This will result in a recently
split primary propogating the invalid stats but not the
invalid marker.  Sending the whole pg_stat_t structure
also mirrors MOSDSubOp.

Fixes: #4557
Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 76b296f01fd0d337c8fc9f79013883e62146f0c6)
PG: update PGPool::name in PGPool::update

Fixes: #4471
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit f804892d725cfa25c242bdc577b12ee81dcc0dcc)
OSD: always activate_map in advance_pgs, only send messages if up

We should always handle_activate_map() after handle_advance_map() in
order to kick the pg into a valid peering state for processing requests
prior to dropping the lock.

Additionally, we would prefer to avoid sending irrelevant messages
during boot, so only send if we are up according to the current service
osdmap.

Fixes: #4572
Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 4dfcad44431855ba7d68a1ccb41dc3cb5db6bb50)
Merge remote-tracking branch 'upstream/bobtail-4556' into bobtail

Reviewed-by: Samuel Just <sam.just@inktank.com>
silence logrotate some more

I was getting email with logrotate error output from “which invoke-rc.d”
on systems without an invoke-rc.d.  This patch silences it.

Silence stderr from which when running logrotate

From: Alexandre Oliva <oliva@gnu.org>

Signed-off-by: Alexandre Oliva <oliva@gnu.org>
(cherry picked from commit d02340d90c9d30d44c962bea7171db3fe3bfba8e)
msgr: add second per-message throttler to message policy

We already have a throttler that lets of limit the amount of memory
consumed by messages from a given source.  Currently this is based only
on the size of the message payload.  Add a second throttler that limits
the number of messages so that we can effectively throttle small requests
as well.

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

Conflicts:
	src/ceph_osd.cc
	src/msg/Pipe.cc
osd: throttle client messages by count, not just by bytes

This lets us put a cap on outstanding client IOs.  This is particularly
important for clients issuing lots of small IOs.

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

Conflicts:
	src/ceph_osd.cc