direct IO write result ENOTBLK or 0(in ext4 case) means retry IO in buffered mode. We wrongly assumed that it is a short write and handled it incorrectly
Since we can not retry in buffered mode, code is not ready for it. Take a different route. This error happens if page invalidation fails, which is a very rare situation. So call synchronize_rcu() and just resubmit pio. Try this three times and end pio with error. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Suggested-by: Alexey Kuznetsov <kuz...@virtuozzo.com> Signed-off-by: Alexander Atanasov <alexander.atana...@virtuozzo.com> --- drivers/md/dm-ploop-map.c | 31 +++++++++++++++++++++++-------- drivers/md/dm-ploop.h | 1 + 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index dc150c8050d9..7d5e2cf443ee 100644 --- a/drivers/md/dm-ploop-map.c +++ b/drivers/md/dm-ploop-map.c @@ -94,6 +94,7 @@ void ploop_init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio) /* FIXME: assign real clu? */ pio->clu = UINT_MAX; pio->level = BAT_LEVEL_INVALID; + pio->retries = 0; } /* Check that rq end byte is not behind end of device */ @@ -1322,18 +1323,32 @@ static void ploop_data_rw_complete(struct pio *pio) bool completed; if (pio->ret != pio->bi_iter.bi_size) { - if (pio->ret >= 0) { - /* Partial IO */ - WARN_ON_ONCE(pio->ret == 0); - /* Do not resubmit zero length pio */ + if (pio->ret >= 0 || pio->ret == -ENOTBLK) { + /* Partial IO or request to retry in buffered mode */ + if (pio->ret == 0 || pio->ret == -ENOTBLK) { + /* + * ENOTBLK means we should retry in buffered io + * but we can not, so try again in DIO + * ext4 returns 0 for ENOTBLK + */ + struct ploop *ploop = pio->ploop; + + if (pio->retries++ < 3) { + PL_ERR("ret = 0 bi_size=%d\n", pio->bi_iter.bi_size); + synchronize_rcu(); + ploop_queue_resubmit(pio); + } else { + /* we retried but still failed */ + pio->bi_status = BLK_STS_IOERR; + goto check_da; + } + } + 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; } + return; } if (static_branch_unlikely(&ploop_standby_check)) ploop_check_standby_mode(pio->ploop, pio->ret); diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h index 9f193afab618..11e50ab1293b 100644 --- a/drivers/md/dm-ploop.h +++ b/drivers/md/dm-ploop.h @@ -315,6 +315,7 @@ struct pio { unsigned int runner_id; atomic_t md_inflight; + unsigned char retries; }; /* Delta COW private */ -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel