rbd: quiescing lock should wait for image requests
authorIlya Dryomov <idryomov@gmail.com>
Thu, 30 May 2019 14:07:48 +0000 (16:07 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 8 Jul 2019 12:01:45 +0000 (14:01 +0200)
commite1fddc8fdd22ed5a55fc7e7a81437c4663c7ba8c
tree8b89d209d035aa2538c4bf32facf32f4e0486e92
parenta2b1da09793d003410b57f96eaf7e83e43b7a50a
rbd: quiescing lock should wait for image requests

Syncing OSD requests doesn't really work.  A single image request may
be comprised of multiple object requests, each of which can go through
a series of OSD requests (original, copyups, etc).  On top of that, the
OSD cliest may be shared with other rbd devices.

What we want is to ensure that all in-flight image requests complete.
Introduce rbd_dev->running_list and block in RBD_LOCK_STATE_RELEASING
until that happens.  New OSD requests may be started during this time.

Note that __rbd_img_handle_request() acquires rbd_dev->lock_rwsem only
if need_exclusive_lock() returns true.  This avoids a deadlock similar
to the one outlined in the previous commit between unlock and I/O that
doesn't require lock, such as a read with object-map feature disabled.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
drivers/block/rbd.c