Skip to content

Commit

Permalink
ublk: add helper of ublk_need_map_io()
Browse files Browse the repository at this point in the history
ublk_need_map_io() is more readable.

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250327095123.179113-5-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Ming Lei authored and Jens Axboe committed Mar 28, 2025
1 parent 705b808 commit 1d781c0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/block/ublk_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ static inline bool ublk_support_user_copy(const struct ublk_queue *ubq)
return ubq->flags & (UBLK_F_USER_COPY | UBLK_F_SUPPORT_ZERO_COPY);
}

static inline bool ublk_need_map_io(const struct ublk_queue *ubq)
{
return !ublk_support_user_copy(ubq);
}

static inline bool ublk_need_req_ref(const struct ublk_queue *ubq)
{
/*
Expand Down Expand Up @@ -923,7 +928,7 @@ static int ublk_map_io(const struct ublk_queue *ubq, const struct request *req,
{
const unsigned int rq_bytes = blk_rq_bytes(req);

if (ublk_support_user_copy(ubq))
if (!ublk_need_map_io(ubq))
return rq_bytes;

/*
Expand All @@ -947,7 +952,7 @@ static int ublk_unmap_io(const struct ublk_queue *ubq,
{
const unsigned int rq_bytes = blk_rq_bytes(req);

if (ublk_support_user_copy(ubq))
if (!ublk_need_map_io(ubq))
return rq_bytes;

if (ublk_need_unmap_req(req)) {
Expand Down Expand Up @@ -1867,7 +1872,7 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
if (io->flags & UBLK_IO_FLAG_OWNED_BY_SRV)
goto out;

if (!ublk_support_user_copy(ubq)) {
if (ublk_need_map_io(ubq)) {
/*
* FETCH_RQ has to provide IO buffer if NEED GET
* DATA is not enabled
Expand All @@ -1889,7 +1894,7 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV))
goto out;

if (!ublk_support_user_copy(ubq)) {
if (ublk_need_map_io(ubq)) {
/*
* COMMIT_AND_FETCH_REQ has to provide IO buffer if
* NEED GET DATA is not enabled or it is Read IO.
Expand Down

0 comments on commit 1d781c0

Please sign in to comment.