rbd: check for watchers before trimming an image on 'rbd rm'
Check for watchers before trimming image data to try to avoid getting
into the following situation:
- user does 'rbd rm' on a mapped image with an fs mounted from it
- 'rbd rm' trims (removes) all image data, only header is left
- 'rbd rm' tries to remove a header and fails because krbd has a
watcher registered on the header
- at this point image cannot be unmapped because of the mounted fs
- fs cannot be unmounted because all its data and metadata is gone
Unfortunately, this fix doesn't make it impossible to happen (the
required atomicity isn't there), but it's a big improvement over the
status quo.
Fixes: http://tracker.ceph.com/issues/7076
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
(cherry picked from commit
0a553cfa81b06e75585ab3c39927e307ec0f4cb6)