linux-um archives
 help / color / mirror / Atom feed
* [PATCH] Fix breakage from switching to MQ BLK framework
@ 2018-11-08 13:07 anton.ivanov
  2018-11-08 13:10 ` Jens Axboe
  2018-11-08 13:15 ` Geert Uytterhoeven
  0 siblings, 2 replies; 10+ messages in thread
From: anton.ivanov @ 2018-11-08 13:07 UTC (permalink / raw)
  To: linux-um; +Cc: axboe, richard, hch, Anton Ivanov

From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Initial version by Jens Axboe <axboe@kernel.dk>

1. Fix use of use unititalized req->error for SYNC commands
2. Guard the request submission by a spinlock

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
---
 arch/um/drivers/ubd_kern.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 74c002ddc0ce..e3d587d9eff6 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1305,6 +1305,7 @@ static int ubd_queue_one_vec(struct blk_mq_hw_ctx *hctx, struct request *req,
 		io_req->fds[0] = dev->cow.fd;
 	else
 		io_req->fds[0] = dev->fd;
+	io_req->error = 0;
 
 	if (req_op(req) == REQ_OP_FLUSH) {
 		io_req->op = UBD_FLUSH;
@@ -1313,9 +1314,7 @@ static int ubd_queue_one_vec(struct blk_mq_hw_ctx *hctx, struct request *req,
 		io_req->cow_offset = -1;
 		io_req->offset = off;
 		io_req->length = bvec->bv_len;
-		io_req->error = 0;
 		io_req->sector_mask = 0;
-
 		io_req->op = rq_data_dir(req) == READ ? UBD_READ : UBD_WRITE;
 		io_req->offsets[0] = 0;
 		io_req->offsets[1] = dev->cow.data_offset;
@@ -1341,11 +1340,15 @@ static int ubd_queue_one_vec(struct blk_mq_hw_ctx *hctx, struct request *req,
 static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
 				 const struct blk_mq_queue_data *bd)
 {
+	struct ubd *ubd_dev = hctx->queue->queuedata;
 	struct request *req = bd->rq;
+	unsigned long flags;
 	int ret = 0;
 
 	blk_mq_start_request(req);
 
+	spin_lock_irqsave(&ubd_dev->lock, flags);
+
 	if (req_op(req) == REQ_OP_FLUSH) {
 		ret = ubd_queue_one_vec(hctx, req, 0, NULL);
 	} else {
@@ -1361,6 +1364,8 @@ static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
 		}
 	}
 out:
+	spin_unlock_irqrestore(&ubd_dev->lock, flags);
+
 	if (ret < 0) {
 		blk_mq_requeue_request(req, true);
 	}
-- 
2.11.0


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-11-08 18:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-08 13:07 [PATCH] Fix breakage from switching to MQ BLK framework anton.ivanov
2018-11-08 13:10 ` Jens Axboe
2018-11-08 13:22   ` Anton Ivanov
2018-11-08 13:24     ` Jens Axboe
2018-11-08 13:33       ` Anton Ivanov
2018-11-08 13:38         ` Jens Axboe
2018-11-08 14:38           ` Anton Ivanov
2018-11-08 18:33             ` Anton Ivanov
2018-11-08 13:15 ` Geert Uytterhoeven
2018-11-08 13:24   ` Anton Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox