]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
client: add mountedness check inside client_lock
authorJeff Layton <jlayton@redhat.com>
Fri, 25 Aug 2017 12:31:47 +0000 (08:31 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 21 Sep 2017 08:35:16 +0000 (10:35 +0200)
commitf146b9f51da11e5698c7c4c9021635961b2790ad
tree87747df61f7ba48a2026870e5b23d42dbb2d2ee6
parent0132a275aa86ca80bf1dcacd9905243257317e6c
client: add mountedness check inside client_lock

Currently we check for mountedness in the high level wrappers, but those
checks are lockless. It's possible to have a call that races with
ceph_unmount(). It could pass one of the is_mounted() checks in the
wrapper, and then block on the client_lock while the unmount is actually
running. Eventually it picks up and runs after the unmount returns, with
questionable results -- possibly even a crash in some cases.

For now, we can explain this away with a simple admonition that
applications should ensure that no calls are running when ceph_unmount
is called. In the future though, we may need to forcibly shut down the
mount when certain events occur (not returning a lease or delegation in
time, for instance).

Sprinkle in a bunch of "unmounting" checks after taking the client_lock,
and simply have the functions return errors (or sensible values in some
cases) when the Client is being downed. With that, we ensure that this
sort of race can't occur, even when the unmount is not being driven by
userland. Note too that in some places I've replaced assertions in the
code with error returns, as that's nicer behavior for libraries.

Note that this can't replace the ->is_mounted() checks in the lockless
wrappers as those are needed to determine whether the client pointer in
the ceph_mount_info is still valid. The admonition not to allow
ceph_unmount to race with other calls is therefore still necessary.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
(cherry picked from commit efca340596ef4da2b254ff1c64ec4c462d7b95a5)
src/client/Client.cc