librbd: add {rbd_}list_children() methods

These iterate over all pools and check for children of a
particular snapshot.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
rbd: add "children" command, update cli test files

Fixes: #2720
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
librbd: prevent racing clone and snap unprotect

If the following sequence of events occured,
a clone could be created of an unprotected snapshot:

1. A: begin clone - check that snap foo is protected
2. B: rbd unprotect snap foo
3. B: check that all pools have no clones of foo
4. B: unprotect snap foo
5. A: finish creating clone of foo, add it as a child

To stop this from happening, check at the beginning and end of
cloning that the parent snapshot is protected. If it is not,
or checking protection status fails (possibly because the parent
snapshot was removed), remove the clone and return an error.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
:doc: Added constraints and revised a description per joshd.


Signed-off-by: John Wilkins <john.wilkins@inktank.com>
client: renew/submit subs on startup

This fixes a delay in getting the initial MDSMap during startup (we wait
for the MonClient tick()).

Reported-by: Noah Watkins <jayhawk@cs.ucsc.edu>
Signed-off-by: Sage Weil <sage@inktank.com>
rbd: add --format option

This chooses whether to use the original (supported by krbd)
or the new (supports layering) format.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
doc: clarify rbd man page (esp. layering)

* a clone's size can't be overridden
* note which commands require format 2
* clarify details of copy
* add examples for cloning
* add pool to map example for consistency
* fix a couple warnings and re-sync man page with rst

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Merge branch 'wip-rbd-children'
java: add Java and C++ source files

This adds all of the Java and C++ source files that make up the
libcephfs Java wrappers package.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
automake: setup autotools to build cephfs-java

Adds --enable-cephfs-java and --with-jdk to build
the libcephfs Java bindings and specify the default
JDK directory, respectively.

Also adds default JDK paths to avoid --with-jdk in
the common case. Currently setup for the default
provided by Debian's default-jdk package, but other
default search paths can easily be added.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
debian: add libcephfs-java package

Creates libceph1-java package that contains
the libcephfs Java wrappers .jar file and the
JNI library.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
do_autogen.sh: add -j flag to enable java stuff

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Makefile: add src/include to #include path for libcephfs_jni_la

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
java: remove redundant dir ops
java: note set_default_file_replication is noop
java: remove CephDirectory in favor of listdir()

This replaces the CephDirectory interface to listing directory contents
with a simple listdir(path) interface. Using CephDirectory, while it
respected the 1-to-1-ness goal for libcephfs API, was overly complicated
for the vast majority of use cases where a user only wants the directory
contents.
libcephfs: return error when not mounted

Return an error rather than a segfault if a client uses the interface
when unmounted.
java: remove CephProxy, check errors at low-level

This removes the overly complicated CephProxy utility which managed the
state machine to avoid segfaults. The segfaults that did occur are
better handled at the library level.
java: remove CephStruct

CephStruct was originally added because there was common tasks done by
any class managing a low-level C object (state machine, ptr, etc...).
Turns out there aren't that many instances of these objects, and
CephStruct just make it more complicated than it needed to be.
java: serialize threads entering libcephfs

This adds the synchronized modifier to the JNI entry points. The
locking granularity should be made finer in the future, but more careful
thought needs to go into how Java threads interact with the locking
assumptions of Ceph.