]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
java: add fine grained synchronization
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 11 Jan 2013 23:56:10 +0000 (15:56 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Mon, 14 Jan 2013 21:11:09 +0000 (13:11 -0800)
commit13cb196ea7e862aa5554bb3d9b1d8f2fa8533b5f
tree219faab43a264a305d87118670e3a68282bf208e
parent85c1035754c3a931c90fce81a22672a2ef498a18
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>
src/java/java/com/ceph/fs/CephMount.java