qa/run_xfstests.sh: use cloned xfstests repository

Use our own copy of the xfstests repository rather than hitting
the upstream one repeatedly.

Signed-off-by: Alex Elder <elder@inktank.com>
mon: OSDMonitor: only share osdmap with up OSDs

Try to share the map with a randomly picked OSD; if the picked monitor is
not 'up', then try to find the nearest 'up' OSD in the map by doing a
backward and a forward linear search on the map -- this would be O(n) in
the worst case scenario, as we only do a single iteration starting on the
picked position, incrementing and decrementing two different iterators
until we find an appropriate OSD or we exhaust the map.

Fixes: #3629
Backport: bobtail

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
rbd: support plain/json/xml output formatting

This patch renames the --format option to --image-format, for
specifying the RBD image format, and uses --format to specify the
output formatting (to be consistent with the other ceph tools). To
avoid breaking backwards compatibility with existing scripts, rbd will
still accept --format [1|2] for the image format, but will print a
warning message, noting its use is deprecated.

The rbd subcommands that support the new --format option are : ls, info, snap
list, children, showmapped, lock list.

Signed-off-by: Stratos Psomadakis <psomas@grnet.gr>
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: fix long lines

Several >80 characters have crept in recently.
The older ones generally don't have very useful history,
so I'm not worried about obscuring the history any more.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: move Formatter construction to main

Each method that uses a formatter is doing the same thing.
Simplify by constructing and handling errors only once.
Also use a scoped_ptr for easy clean up.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: add --pretty-format option

This is the same option the rados and radosgw-admin tool use for more
human-readable json/xml.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
XMLFormatter: fix pretty printing

It used the wrong indentation level and did not add a newline after
closing a section. dump_stream() did not indent at all.

Simplify a little and remove the parameter from print_spaces(). If we just
remove the element from m_sections before calling print_spaces() in
close_section(), the number of elements in m_sections is always the
indentation level.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: regenerate man page and cli test

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: always output result for formatted output

When there's nothing, return an empty array.
This way scripts don't have to special case this.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
test: add cram integration test for formatted output

This can be used with the new teuthology cram task.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Merge branch 'wip-rbd-formatted-output'

Reviewed-by: Dan Mick <dan.mick@inktank.com>

Conflicts:
	src/rbd.cc
	src/test/cli/rbd/help.t
rados.cc: fix listomapvals usage: key,val are not needed

Fixes: #3812
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: David Zafman <david.zafman@inktank.com>
rados.cc: use omap_get_vals_by_keys in getomapval

Fixes: #3811
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: David Zafman <david.zafman@inktank.com>
librados.hpp: fix omap_get_vals and omap_get_keys comments

We list keys greater than start_after.

Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: David Zafman <david.zafman@inktank.com>
rados.cc: fix rmomapkey usage: val not needed

Signed-off-by: David Zafman <david.zafman@inktank.com>
Reviewed-by: Samuel Just <samuel.just@inktank.com>
ReplicatedPG: make_snap_collection when moving snap link in snap_trimmer

Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
ReplicatedPG: correctly handle new snap collections on replica

Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
PG: move auth replica selection to helper in scrub

Signed-off-by: Samuel Just <sam.just@inktank.com>
osd_types: add nlink and snapcolls fields to ScrubMap::object

Signed-off-by: Samuel Just <sam.just@inktank.com>
ReplicatedPG/PG: check snap collections during _scan_list

During _scan_list check the snapcollections corresponding to the
object_info attr on the object.  Report inconsistencies during
scrub_finalize.

Signed-off-by: Samuel Just <sam.just@inktank.com>