If a pio terminates with 0 bytes dm-ploop resubmits that pio
advanced zero bytes which again results in zero lenght IO.
To avoid that terminate such case with EIO - as this could
only happen as a result of a BUG choose the error so that
any potential damage is prevented.

https://virtuozzo.atlassian.net/browse/PSBM-156506
Signed-off-by: Alexander Atanasov <alexander.atana...@virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ea04b3e53567e..33aac1a69fdf9 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1202,15 +1202,21 @@ static void ploop_data_rw_complete(struct pio *pio)
                if (pio->ret >= 0) {
                        /* Partial IO */
                        WARN_ON_ONCE(pio->ret == 0);
-                       ploop_pio_advance(pio, pio->ret);
-                       ploop_queue_resubmit(pio);
-                       return;
+                       /* Do not resubmit zero length pio */
+                       if (pio->ret > 0) {
+                               ploop_pio_advance(pio, pio->ret);
+                               ploop_queue_resubmit(pio);
+                               return;
+                       } else {
+                               pio->bi_status = BLK_STS_IOERR;
+                               goto check_da;
+                       }
                }
                if (static_branch_unlikely(&ploop_standby_check))
                        ploop_check_standby_mode(pio->ploop, pio->ret);
                pio->bi_status = errno_to_blk_status(pio->ret);
        }
-
+check_da:
        if (pio->is_data_alloc) {
                completed = ploop_data_pio_end(pio);
                if (!completed)
-- 
2.43.0

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

Reply via email to