Skip to content

Commit 6d4bb66

Browse files
Ming Leikawasaki
authored andcommitted
ublk: let ublk_fill_io_cmd() cover more things
Let ublk_fill_io_cmd() cover more things: - store io command result - clear UBLK_IO_FLAG_OWNED_BY_SRV It is fine to do above for ublk_fetch(), ublk_commit_and_fetch() and handling UBLK_IO_NEED_GET_DATA. Signed-off-by: Ming Lei <[email protected]>
1 parent a5a0d54 commit 6d4bb66

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/block/ublk_drv.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,11 +2004,16 @@ static inline int ublk_check_cmd_op(u32 cmd_op)
20042004
}
20052005

20062006
static inline void ublk_fill_io_cmd(struct ublk_io *io,
2007-
struct io_uring_cmd *cmd, unsigned long buf_addr)
2007+
struct io_uring_cmd *cmd, unsigned long buf_addr,
2008+
int result)
20082009
{
20092010
io->cmd = cmd;
20102011
io->flags |= UBLK_IO_FLAG_ACTIVE;
20112012
io->addr = buf_addr;
2013+
io->res = result;
2014+
2015+
/* now this cmd slot is owned by ublk driver */
2016+
io->flags &= ~UBLK_IO_FLAG_OWNED_BY_SRV;
20122017
}
20132018

20142019
static inline void ublk_prep_cancel(struct io_uring_cmd *cmd,
@@ -2166,7 +2171,7 @@ static int ublk_fetch(struct io_uring_cmd *cmd, struct ublk_queue *ubq,
21662171
goto out;
21672172
}
21682173

2169-
ublk_fill_io_cmd(io, cmd, buf_addr);
2174+
ublk_fill_io_cmd(io, cmd, buf_addr, 0);
21702175
WRITE_ONCE(io->task, get_task_struct(current));
21712176
ublk_mark_io_ready(ub, ubq);
21722177
out:
@@ -2222,11 +2227,7 @@ static int ublk_commit_and_fetch(const struct ublk_queue *ubq,
22222227
return ret;
22232228
}
22242229

2225-
ublk_fill_io_cmd(io, cmd, ub_cmd->addr);
2226-
2227-
/* now this cmd slot is owned by ublk driver */
2228-
io->flags &= ~UBLK_IO_FLAG_OWNED_BY_SRV;
2229-
io->res = ub_cmd->result;
2230+
ublk_fill_io_cmd(io, cmd, ub_cmd->addr, ub_cmd->result);
22302231

22312232
if (req_op(req) == REQ_OP_ZONE_APPEND)
22322233
req->__sector = ub_cmd->zone_append_lba;
@@ -2346,8 +2347,7 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
23462347
* request
23472348
*/
23482349
req = io->req;
2349-
ublk_fill_io_cmd(io, cmd, ub_cmd->addr);
2350-
io->flags &= ~UBLK_IO_FLAG_OWNED_BY_SRV;
2350+
ublk_fill_io_cmd(io, cmd, ub_cmd->addr, 0);
23512351
if (likely(ublk_get_data(ubq, io, req))) {
23522352
__ublk_prep_compl_io_cmd(io, req);
23532353
return UBLK_IO_RES_OK;

0 commit comments

Comments
 (0)