Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ublk: handle UBLK_IO_FETCH_REQ earlier

Check for UBLK_IO_FETCH_REQ early in __ublk_ch_uring_cmd() and skip the
rest of the checks in this case. This allows removing the checks for
NULL io->task and UBLK_IO_FLAG_OWNED_BY_SRV unset in io->flags, which
are only allowed for FETCH.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250620151008.3976463-5-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
ee977363 5af8b36f

+12 -9
+12 -9
drivers/block/ublk_drv.c
··· 2215 2215 goto out; 2216 2216 2217 2217 io = &ubq->ios[tag]; 2218 + /* UBLK_IO_FETCH_REQ can be handled on any task, which sets io->task */ 2219 + if (unlikely(_IOC_NR(cmd_op) == UBLK_IO_FETCH_REQ)) { 2220 + ret = ublk_fetch(cmd, ubq, io, ub_cmd->addr); 2221 + if (ret) 2222 + goto out; 2223 + 2224 + ublk_prep_cancel(cmd, issue_flags, ubq, tag); 2225 + return -EIOCBQUEUED; 2226 + } 2227 + 2218 2228 task = READ_ONCE(io->task); 2219 - if (task && task != current) 2229 + if (task != current) 2220 2230 goto out; 2221 2231 2222 2232 /* there is pending io cmd, something must be wrong */ ··· 2235 2225 goto out; 2236 2226 } 2237 2227 2238 - /* only UBLK_IO_FETCH_REQ is allowed if io is not OWNED_BY_SRV */ 2239 - if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV) && 2240 - _IOC_NR(cmd_op) != UBLK_IO_FETCH_REQ) 2228 + if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV)) 2241 2229 goto out; 2242 2230 2243 2231 /* ··· 2251 2243 return ublk_register_io_buf(cmd, ubq, io, ub_cmd->addr, issue_flags); 2252 2244 case UBLK_IO_UNREGISTER_IO_BUF: 2253 2245 return ublk_unregister_io_buf(cmd, ubq, ub_cmd->addr, issue_flags); 2254 - case UBLK_IO_FETCH_REQ: 2255 - ret = ublk_fetch(cmd, ubq, io, ub_cmd->addr); 2256 - if (ret) 2257 - goto out; 2258 - break; 2259 2246 case UBLK_IO_COMMIT_AND_FETCH_REQ: 2260 2247 ret = ublk_commit_and_fetch(ubq, io, cmd, ub_cmd, issue_flags); 2261 2248 if (ret)