Requests that fail with ENOSPC are parked on tgt->enospc_qios and resubmitted by a timer. The same mechanism is going to hold requests failed with other errors, depending on the disk error policy, so rename enospc_qios, enospc_timer and qcow2_try_delay_enospc() to held_qios, held_timer and qcow2_try_hold_error(), and let the latter decide whether a status is to be held.
Drop the WARN_ON_ONCE() for a non-write ENOSPC. A read can get ENOSPC from the read_iter of an image on FUSE, and a WARN on an error of the lower file system takes the node down with panic_on_warn. Such a read is still held, as before. No other functional change. https://virtuozzo.atlassian.net/browse/VSTOR-152175 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Alexander Ivanov <[email protected]> --- drivers/md/dm-qcow2-map.c | 31 ++++++++++++++++--------------- drivers/md/dm-qcow2-target.c | 16 ++++++++-------- drivers/md/dm-qcow2.h | 6 +++--- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 32373114580e..b987d459863d 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -4566,14 +4566,18 @@ void do_qcow2_fsync_work(struct work_struct *ws) current_restore_flags(pflags, PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO); } -static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qrq, struct qio *qio) +static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq, + struct qio *qio, blk_status_t bi_status) { - bool delayed = true; + bool held = true; unsigned long flags; + if (bi_status != BLK_STS_NOSPC) + return false; + spin_lock_irqsave(&tgt->event_lock, flags); if (unlikely(tgt->wants_suspend)) { - delayed = false; + held = false; goto unlock; } @@ -4582,15 +4586,15 @@ static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qr pr_err_once(QCOW2_FMT("underlying disk is almost full"), qcow2_device_name(tgt->ti)); tgt->event_enospc = true; - list_add_tail(&qio->link, &tgt->enospc_qios); + list_add_tail(&qio->link, &tgt->held_qios); unlock: spin_unlock_irqrestore(&tgt->event_lock, flags); - if (delayed) - mod_timer(&tgt->enospc_timer, jiffies + ENOSPC_TIMEOUT_JI); + if (held) + mod_timer(&tgt->held_timer, jiffies + HOLD_TIMEOUT_JI); schedule_work(&tgt->event_work); - return delayed; + return held; } static void qrq_endio(struct qcow2_target *tgt, struct qio *qio, @@ -4602,18 +4606,15 @@ static void qrq_endio(struct qcow2_target *tgt, struct qio *qio, if (qrq->bvec) kvfree(qrq->bvec); /* - * Here is exit point for rq, and here we handle ENOSPC. + * Here is exit point for rq, and here we handle errors. * Embedded qios will be reinitialized like they've just * came from upper dm level, and later resubmitted after * timeout. Note, that we do not handle merge here: merge - * callers receive -ENOSPC synchronous without intermediaries. + * callers receive errors synchronous without intermediaries. */ - if (unlikely(bi_status == BLK_STS_NOSPC)) { - WARN_ON_ONCE(!op_is_write(qio->bi_op) && - qio->bi_op != REQ_OP_FLUSH); - if (qcow2_try_delay_enospc(tgt, qrq, qio)) - return; - } + if (unlikely(bi_status != BLK_STS_OK) && + qcow2_try_hold_error(tgt, qrq, qio, bi_status)) + return; mempool_free(qrq, tgt->qrq_pool); dm_complete_request(rq, bi_status); diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c index aa0bbb6b4a97..89b12c4f971b 100644 --- a/drivers/md/dm-qcow2-target.c +++ b/drivers/md/dm-qcow2-target.c @@ -254,7 +254,7 @@ static void qcow2_tgt_destroy(struct qcow2_target *tgt) destroy_workqueue(tgt->wq); } qcow2_merge_backward_cancel(tgt); - timer_shutdown_sync(&tgt->enospc_timer); + timer_shutdown_sync(&tgt->held_timer); cancel_work_sync(&tgt->event_work); mempool_destroy(tgt->qio_pool); @@ -480,14 +480,14 @@ static void inflight_ref_exit1(struct percpu_ref *ref) complete(&tgt->inflight_ref_comp); } -static void qcow2_enospc_timer(struct timer_list *timer) +static void qcow2_held_timer(struct timer_list *timer) { - struct qcow2_target *tgt = timer_container_of(tgt, timer, enospc_timer); + struct qcow2_target *tgt = timer_container_of(tgt, timer, held_timer); unsigned long flags; LIST_HEAD(list); spin_lock_irqsave(&tgt->event_lock, flags); - list_splice_init(&tgt->enospc_qios, &list); + list_splice_init(&tgt->held_qios, &list); spin_unlock_irqrestore(&tgt->event_lock, flags); qcow2_submit_embedded_qios(tgt, &list); @@ -542,8 +542,8 @@ static struct qcow2_target *alloc_qcow2_target(struct dm_target *ti) init_rwsem(&tgt->seek_rwsem); init_waitqueue_head(&tgt->service_wq); INIT_WORK(&tgt->event_work, qcow2_event_work); - INIT_LIST_HEAD(&tgt->enospc_qios); - timer_setup(&tgt->enospc_timer, qcow2_enospc_timer, 0); + INIT_LIST_HEAD(&tgt->held_qios); + timer_setup(&tgt->held_timer, qcow2_held_timer, 0); ti->private = tgt; tgt->ti = ti; @@ -1165,8 +1165,8 @@ static void qcow2_presuspend(struct dm_target *ti) qcow2_set_service_operations(ti, false); qcow2_set_wants_suspend(ti, true); - timer_delete_sync(&tgt->enospc_timer); - qcow2_enospc_timer(&tgt->enospc_timer); + timer_delete_sync(&tgt->held_timer); + qcow2_held_timer(&tgt->held_timer); } static void qcow2_presuspend_undo(struct dm_target *ti) { diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h index 3f1d5b5eef26..ea6bc6258cb0 100644 --- a/drivers/md/dm-qcow2.h +++ b/drivers/md/dm-qcow2.h @@ -19,7 +19,7 @@ #define MIN_QIOS 512 #define WB_TIMEOUT_JI (60 * HZ) -#define ENOSPC_TIMEOUT_JI (20 * HZ) +#define HOLD_TIMEOUT_JI (20 * HZ) #define PREALLOC_SIZE (128ULL * 1024 * 1024) struct QCowHeader { @@ -213,8 +213,8 @@ struct qcow2_target { atomic_t service_qios; struct wait_queue_head service_wq; - struct list_head enospc_qios; /* Delayed after ENOSPC */ - struct timer_list enospc_timer; + struct list_head held_qios; /* Failed, waiting for resubmission */ + struct timer_list held_timer; struct work_struct event_work; spinlock_t event_lock; -- 2.53.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
