diff mbox series

[V2,3/3] ublk: return -EINTR if breaking from waiting for existed users in DEL_DEV

Message ID 20230726144502.566785-4-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series ublk: fail to start/recover/del device if interrupted by signal | expand

Commit Message

Ming Lei July 26, 2023, 2:45 p.m. UTC
If user interrupts wait_event_interruptible() in ublk_ctrl_del_dev(),
return -EINTR and let user know what happens.

Fixes: 0abe39dec065 ("block: ublk: improve handling device deletion")
Reported-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/block/ublk_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Garzarella July 27, 2023, 1:05 p.m. UTC | #1
On Wed, Jul 26, 2023 at 10:45:02PM +0800, Ming Lei wrote:
>If user interrupts wait_event_interruptible() in ublk_ctrl_del_dev(),
>return -EINTR and let user know what happens.
>
>Fixes: 0abe39dec065 ("block: ublk: improve handling device deletion")
>Reported-by: Stefano Garzarella <sgarzare@redhat.com>
>Signed-off-by: Ming Lei <ming.lei@redhat.com>
>---
> drivers/block/ublk_drv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
>index 9fcba3834e8d..21d2e71c5514 100644
>--- a/drivers/block/ublk_drv.c
>+++ b/drivers/block/ublk_drv.c
>@@ -2126,8 +2126,8 @@ static int ublk_ctrl_del_dev(struct ublk_device **p_ub)
> 	 * - the device number is freed already, we will not find this
> 	 *   device via ublk_get_device_from_id()
> 	 */
>-	wait_event_interruptible(ublk_idr_wq, ublk_idr_freed(idx));
>-
>+	if (wait_event_interruptible(ublk_idr_wq, ublk_idr_freed(idx)))
>+		return -EINTR;
> 	return 0;
> }
>
>-- 
>2.40.1
>
diff mbox series

Patch

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 9fcba3834e8d..21d2e71c5514 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2126,8 +2126,8 @@  static int ublk_ctrl_del_dev(struct ublk_device **p_ub)
 	 * - the device number is freed already, we will not find this
 	 *   device via ublk_get_device_from_id()
 	 */
-	wait_event_interruptible(ublk_idr_wq, ublk_idr_freed(idx));
-
+	if (wait_event_interruptible(ublk_idr_wq, ublk_idr_freed(idx)))
+		return -EINTR;
 	return 0;
 }