lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220831155136.23434-5-ZiyangZhang@linux.alibaba.com>
Date:   Wed, 31 Aug 2022 23:51:34 +0800
From:   ZiyangZhang <ZiyangZhang@...ux.alibaba.com>
To:     ming.lei@...hat.com, axboe@...nel.dk
Cc:     xiaoguang.wang@...ux.alibaba.com, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org, joseph.qi@...ux.alibaba.com,
        ZiyangZhang <ZiyangZhang@...ux.alibaba.com>
Subject: [RFC PATCH V2 4/6] ublk_drv: requeue rqs with recovery feature enabled

With recovery feature enabled, in ublk_queue_rq or task work
(in exit_task_work or fallback wq), we requeue rqs instead of
ending(aborting) them.

No matter recovery feature is enabled or disabled, schedule monitor work
immediately after detecting a crash so it can find out the crash and
do aborting/recovery mechanism.

Signed-off-by: ZiyangZhang <ZiyangZhang@...ux.alibaba.com>
---
 drivers/block/ublk_drv.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 0c3d32e8d686..296b9d80f003 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -690,7 +690,16 @@ static inline void __ublk_rq_task_work(struct request *req)
 	 * (2) current->flags & PF_EXITING.
 	 */
 	if (unlikely(current != ubq->ubq_daemon || current->flags & PF_EXITING)) {
-		blk_mq_end_request(req, BLK_STS_IOERR);
+		pr_devel("%s: %s q_id %d tag %d io_flags %x.\n", __func__,
+				(ublk_can_use_recovery(ub)) ? "requeue" : "abort",
+				ubq->q_id, req->tag, io->flags);
+
+		if (ublk_can_use_recovery(ub)) {
+			/* We cannot process this req so just requeue it. */
+			blk_mq_requeue_request(req, false);
+		} else {
+			blk_mq_end_request(req, BLK_STS_IOERR);
+		}
 		mod_delayed_work(system_wq, &ub->monitor_work, 0);
 		return;
 	}
@@ -770,6 +779,7 @@ static blk_status_t ublk_queue_rq(struct blk_mq_hw_ctx *hctx,
 {
 	struct ublk_queue *ubq = hctx->driver_data;
 	struct request *rq = bd->rq;
+	struct ublk_io *io = &ubq->ios[rq->tag];
 	blk_status_t res;
 
 	/* fill iod to slot in io cmd buffer */
@@ -781,8 +791,18 @@ static blk_status_t ublk_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 	if (unlikely(ubq_daemon_is_dying(ubq))) {
  fail:
+		pr_devel("%s: %s q_id %d tag %d io_flags %x.\n", __func__,
+				(ublk_can_use_recovery(ubq->dev)) ? "requeue" : "abort",
+				ubq->q_id, rq->tag, io->flags);
+
 		mod_delayed_work(system_wq, &ubq->dev->monitor_work, 0);
-		return BLK_STS_IOERR;
+		if (ublk_can_use_recovery(ubq->dev)) {
+			/* We cannot process this rq so just requeue it. */
+			blk_mq_requeue_request(rq, false);
+			return BLK_STS_OK;
+		} else {
+			return BLK_STS_IOERR;
+		}
 	}
 
 	if (ublk_can_use_task_work(ubq)) {
@@ -793,7 +813,6 @@ static blk_status_t ublk_queue_rq(struct blk_mq_hw_ctx *hctx,
 		if (task_work_add(ubq->ubq_daemon, &data->work, notify_mode))
 			goto fail;
 	} else {
-		struct ublk_io *io = &ubq->ios[rq->tag];
 		struct io_uring_cmd *cmd = io->cmd;
 		struct ublk_uring_cmd_pdu *pdu = ublk_get_uring_cmd_pdu(cmd);
 
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ