librbd: fix recursive locking on owner_lock in ImageDispatch
needs_exclusive_lock() calls acquire_lock() with owner_lock held.
If lock acquisiton races with lock shut down, ManagedLock completes
ImageDispatch context directly and dispatch is retried immediately on
the same thread (due to DISPATCH_RESULT_RESTART). This results in
recursion into needs_exclusive_lock() and, barring locking issues, can
lead to unbounded stack growth if lock shut down takes its time.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit
1d943f8c47b3510e47d40701e9acd213706754e5)