The patch implements what Dima Monakhov suggested:

>  AFAIU you have a re-entrance issue if several tasks want performs ioctls
>   task1:ioctl->wait
>                   task2:ioctl->wait
>
>   Just change wait sequence like this and you are safe:
>                  /* blocking case */
>                 if (unlikely(pbd->ppb_waiting))
>                      /* Other task is already waitng for event */
>                      err = -EBUSY;
>                      goto get_pending_unlock;
>                 }
>                 pbd->ppb_waiting = true;
>                 spin_unlock(&pbd->ppb_lock);
>                 mutex_unlock(&plo->ctl_mutex);

Signed-off-by: Maxim Patlasov <mpatla...@virtuozzo.com>
---
 drivers/block/ploop/push_backup.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/block/ploop/push_backup.c 
b/drivers/block/ploop/push_backup.c
index 4d671a5..10fd55a 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -466,6 +466,11 @@ int ploop_pb_get_pending(struct ploop_pushbackup_desc *pbd,
                }
 
                 /* blocking case */
+               if (unlikely(pbd->ppb_waiting)) {
+                       /* Other task is already waitng for event */
+                       err = -EBUSY;
+                       goto get_pending_unlock;
+               }
                pbd->ppb_waiting = true;
                spin_unlock(&pbd->ppb_lock);
 

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to