Clean up defer_recovery() functions

Signed-off-by: David Zafman <david.zafman@inktank.com>
AsyncReserver: Remove assert in set_max() for max > 0

Signed-off-by: David Zafman <david.zafman@inktank.com>
Add priority option to AsyncReserver class

Add priority to request_reservation()
Change to map of lists by prioriry
Add priority to queue_pointers mappped type

Signed-off-by: David Zafman <david.zafman@inktank.com>
osd: prioritize recovery for degraded pgs

Three Reservation priorities from RECOVERY, BACKFILL_HIGH, BACKFILL_LOW

fixes: #4273

Signed-off-by: David Zafman <david.zafman@inktank.com>
Throttle: add a simpler throttle that just blocks above a threshold

This is convenient to use to turn synchronous calls into asynchronous
calls with a limited number of operations in flight concurrently.
It assumes the caller will wait for all operations to complete at the
end.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: delete more than one object at once

Speed up deletions when resizing down or removing an image by keeping
up 10 operations in flight by default.

Refs: #2256
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librados: add selfmanaged_snap_rollback as an ObjectOperation

This allows it to be done asynchronously, or in conjunction with
other operations.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
ObjectStore.cc: add missing break in switch

Fix switch handling for case OP_SPLIT_COLLECTION2, add break after
the case to prevent fall through into default case.

CID 1019562 Missing break in switch (CWE-484)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
client/SyntheticClient.cc: add missing break in switch

Fix switch handling for case SYNCLIENT_MODE_OVERLOAD_OSD_0, add break
after the case to prevent fall through into next case.

CID 716958 Missing break in switch (CWE-484)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rgw/rgw_user.cc: add missing break in switch

Fix switch handling for case KEY_TYPE_SWIFT, add break after the
case to prevent fall through into KEY_TYPE_S3 case.

CID 1019563 Missing break in switch (CWE-484)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
libcephfs/test.cc: add assert for result of ceph_getxattr()

Check result of ceph_getxattr() before pass it as parameter to
strncmp(). Make sure it's not negative.

CID 739411 Argument cannot be negative (CWE-687)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test/omap_bench.cc: remove dead code

CID 716900 Logically dead code (CWE-561)
CID 716901 Logically dead code (CWE-561)
CID 727968 Logically dead code (CWE-561)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rados_sync.cc: remove dead and not needed code

The first if handles all chars < 32, the last 2 if's check for
'\n' (10) and '\r' (13). This code will never be reached and
is already covered. Remove unneeded code.

CID 1019549 Logically dead code (CWE-561)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rbd.cc: fix error handling

Fix undead code. Get error code from write_fd() before check
the result against < 0.

CID 1019550 Logically dead code (CWE-561)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rgw/rgw_rest.cc: remove dead and unneeded code

Since origin and meth are already checked to be true there is
no need to check again in s->cio->print() after the initial check.

1019551 Logically dead code (CWE-561)
1019552 Logically dead code (CWE-561)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
osd/OSD.h: add missing unlock of osd_lock

CID 1019560 Missing unlock (CWE-667)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
mds/Server.cc: remove dead default in switch

The default switch can't get executed since the switch value
can only have the two values already checked.

CID 716894 Dead default in switch (CWE-561)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
mds/MDCache.cc: add NULL pointer check

Check for result of get_inode() for NULL before use the pointer.

716990 Dereference null return value (CWE-476)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
mds/MDCache.cc: fix dereference NULL pointer

Fix possible NULL pointer dereference. Change return value of
CInode::get_dirfrag() to return NULL instead of 0 since it's a
pointer returned.

CID 716991 Dereference null return value (CWE-478)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
client/SyntheticClient.cc: fix memory leak

Fix memory leak in read_random: call delete[] on buf before
call new[] again in the for-loop.

CID 717070 Resource leak (CWE-404)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>