cls_rbd: remove unused test_exec and snap_revert methods

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
cls_rbd: add indent settings header

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: add indent settings header

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: pass strings as const references

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
cls_rgw: add indent settings header

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
test_librbd: don't include a .cc file

Add it as a source like the rest of the gtests.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
class_debug: add indent settings header

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: allow classes to log at different levels

Add a logging level parameter to CLS_LOG, and a CLS_ERR that's
analagous to derr.

For now cls_rgw is all logging at level 1, preserving existing
behavior. I'm more familiar with cls_rbd, so I changed those
logging levels.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: rename omap methods to be consistent with other interfaces

The osd ops and the librados methods all distinguish between keys
and values. It's useful to be able to read a bunch of keys without
fetching the values sometimes too.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: add methods to get keys without values, and set multiple values

These will be useful in the new rbd header format. This brings the
API into parity with the available OSD ops for omaps.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
vstart: debug osd classes when debugging is on

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
DBObjectMap: remove extra semicolon

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: remove useless ENOMEM checks

There will be an exception if memory can't be allocated.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
cls_rbd: add methods for interacting with the new header format

Add the client side (cls_rbd_client) for testing as well.
librbd will use the functions in cls_rbd_client to interact with cls_rbd.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: Update ImageCtx for new format

Detect the format when an image is opened by the presence of the
original format header object. Use member variables of ImageCtx to
store image metadata instead of the on-disk header format
ImageCtx::header.

This lays the foundation for changing the rest of librbd to work with
old and new formats.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: update ictx_refresh to work with both formats

It now sets the member variables of ImageCtx so other functions
don't have to use the on-disk header. If the features use by
the new format are incompatible with this client, an error is returned.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: check that the current snapid for a snap name matches

Checking that it exists doesn't prevent you from having the snapshot
change out from under you in the following situation:

You have the image open at snapshot "foo".
Someone removes snapshot "foo", writes some data to the image, and
creates a new snapshot called "foo".

This second snapshot will have a different id, but nothing prevents it
from having the name of a previously deleted snapshot.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: remove on-disk header argument from helper functions

Make most of them take the parameters they actually use.
trim_image() now takes an ImageCtx, which means remove() must
open the image. This has the nice side effect of not duplicating
the snapshot listing code for the old format.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: use cls_client functions for calling class methods

Use the old or new methods make resize, snapshot add and snapsnhot
remove work with both old and new formats.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: make rename work with any header format

Instead of interpreting the header, just copy all the data and
omap values from the original header to the newly name one.
This will continue working with future header changes.

We can create the new header and write all data and omap values
to it atomically to avoid some races.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>