java: remove create/release synchronization

The constructor calls create, and finalize() calls release. Since each
of these can only happen once (enforced by Java), there is no fear of a
race condition.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
java: remove unnecessary synchronization

The body of ceph_unmount is a call to a synchronized method.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
java: remove all intrinsic locks

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
java: add fine grained synchronization

Adds r/w lock to protect against some races.

1. Mutual exclusion for mount/unmount prevents races between the two in
libcephfs, which isn't safe (access to ceph_mount_info state).

2. An extremely narrow race between unmount and ceph_* calls in
libcephfs. ThreadA calls ceph_xxx, is_mounted test passes, then ThreadB
calls unmount and destroys the client. ThreadA resumes with a bad client
pointer.

3. Race between unmount and ceph_* calls in JNI. In JNI we hold the
CephContext reference across ceph_* calls. If the ceph mount were to be
released while a thread was returning from a ceph_* call then an attempt
to write to the log (e.g. the return value) would reference bad context.
Since ceph_release is only called by finalize() then no thread can be in
JNI.  So this is actually safe.

Using r/w here provides trade-off between allowing concurrency into
libcephfs, and not having to constantly update the Java bindings. The
only assumption is that unmount/mount race with the rest of the
interface.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Merge branch 'wip-java-sync'

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Reviewed-by: Joe Buck <jbbuck@gmail.com>