mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-16 11:19:12 +08:00
ublk: factor out ublk_start_io() helper
In preparation for calling it from outside ublk_dispatch_req(), factor out the code responsible for setting up an incoming ublk I/O request. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20250430225234.2676781-7-csander@purestorage.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
551270690d
commit
2fcb88bdf2
@@ -1152,13 +1152,41 @@ static inline void __ublk_abort_rq(struct ublk_queue *ubq,
|
||||
blk_mq_end_request(rq, BLK_STS_IOERR);
|
||||
}
|
||||
|
||||
static bool ublk_start_io(const struct ublk_queue *ubq, struct request *req,
|
||||
struct ublk_io *io)
|
||||
{
|
||||
unsigned mapped_bytes = ublk_map_io(ubq, req, io);
|
||||
|
||||
/* partially mapped, update io descriptor */
|
||||
if (unlikely(mapped_bytes != blk_rq_bytes(req))) {
|
||||
/*
|
||||
* Nothing mapped, retry until we succeed.
|
||||
*
|
||||
* We may never succeed in mapping any bytes here because
|
||||
* of OOM. TODO: reserve one buffer with single page pinned
|
||||
* for providing forward progress guarantee.
|
||||
*/
|
||||
if (unlikely(!mapped_bytes)) {
|
||||
blk_mq_requeue_request(req, false);
|
||||
blk_mq_delay_kick_requeue_list(req->q,
|
||||
UBLK_REQUEUE_DELAY_MS);
|
||||
return false;
|
||||
}
|
||||
|
||||
ublk_get_iod(ubq, req->tag)->nr_sectors =
|
||||
mapped_bytes >> 9;
|
||||
}
|
||||
|
||||
ublk_init_req_ref(ubq, req);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ublk_dispatch_req(struct ublk_queue *ubq,
|
||||
struct request *req,
|
||||
unsigned int issue_flags)
|
||||
{
|
||||
int tag = req->tag;
|
||||
struct ublk_io *io = &ubq->ios[tag];
|
||||
unsigned int mapped_bytes;
|
||||
|
||||
pr_devel("%s: complete: qid %d tag %d io_flags %x addr %llx\n",
|
||||
__func__, ubq->q_id, req->tag, io->flags,
|
||||
@@ -1205,29 +1233,9 @@ static void ublk_dispatch_req(struct ublk_queue *ubq,
|
||||
ublk_get_iod(ubq, req->tag)->addr);
|
||||
}
|
||||
|
||||
mapped_bytes = ublk_map_io(ubq, req, io);
|
||||
if (!ublk_start_io(ubq, req, io))
|
||||
return;
|
||||
|
||||
/* partially mapped, update io descriptor */
|
||||
if (unlikely(mapped_bytes != blk_rq_bytes(req))) {
|
||||
/*
|
||||
* Nothing mapped, retry until we succeed.
|
||||
*
|
||||
* We may never succeed in mapping any bytes here because
|
||||
* of OOM. TODO: reserve one buffer with single page pinned
|
||||
* for providing forward progress guarantee.
|
||||
*/
|
||||
if (unlikely(!mapped_bytes)) {
|
||||
blk_mq_requeue_request(req, false);
|
||||
blk_mq_delay_kick_requeue_list(req->q,
|
||||
UBLK_REQUEUE_DELAY_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
ublk_get_iod(ubq, req->tag)->nr_sectors =
|
||||
mapped_bytes >> 9;
|
||||
}
|
||||
|
||||
ublk_init_req_ref(ubq, req);
|
||||
ublk_complete_io_cmd(io, UBLK_IO_RES_OK, issue_flags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user