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.

io_uring/rsrc: add & apply io_req_assign_buf_node()

The following pattern becomes more and more:

+ io_req_assign_rsrc_node(&req->buf_node, node);
+ req->flags |= REQ_F_BUF_NODE;

so make it a helper, which is less fragile to use than above code, for
example, the BUF_NODE flag is even missed in current io_uring_cmd_prep().

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20241107110149.890530-4-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
039c878d 4f219fcc

+11 -7
+1 -2
io_uring/net.c
··· 1348 1348 io_ring_submit_lock(ctx, issue_flags); 1349 1349 node = io_rsrc_node_lookup(&ctx->buf_table, sr->buf_index); 1350 1350 if (node) { 1351 - io_req_assign_rsrc_node(&sr->notif->buf_node, node); 1352 - sr->notif->flags |= REQ_F_BUF_NODE; 1351 + io_req_assign_buf_node(sr->notif, node); 1353 1352 ret = 0; 1354 1353 } 1355 1354 io_ring_submit_unlock(ctx, issue_flags);
+1 -2
io_uring/nop.c
··· 67 67 io_ring_submit_lock(ctx, issue_flags); 68 68 node = io_rsrc_node_lookup(&ctx->buf_table, nop->buffer); 69 69 if (node) { 70 - io_req_assign_rsrc_node(&req->buf_node, node); 71 - req->flags |= REQ_F_BUF_NODE; 70 + io_req_assign_buf_node(req, node); 72 71 ret = 0; 73 72 } 74 73 io_ring_submit_unlock(ctx, issue_flags);
+7
io_uring/rsrc.h
··· 111 111 *dst_node = node; 112 112 } 113 113 114 + static inline void io_req_assign_buf_node(struct io_kiocb *req, 115 + struct io_rsrc_node *node) 116 + { 117 + io_req_assign_rsrc_node(&req->buf_node, node); 118 + req->flags |= REQ_F_BUF_NODE; 119 + } 120 + 114 121 int io_files_update(struct io_kiocb *req, unsigned int issue_flags); 115 122 int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 116 123
+1 -2
io_uring/rw.c
··· 341 341 node = io_rsrc_node_lookup(&ctx->buf_table, req->buf_index); 342 342 if (!node) 343 343 return -EFAULT; 344 - io_req_assign_rsrc_node(&req->buf_node, node); 345 - req->flags |= REQ_F_BUF_NODE; 344 + io_req_assign_buf_node(req, node); 346 345 347 346 io = req->async_data; 348 347 ret = io_import_fixed(ddir, &io->iter, node->buf, rw->addr, rw->len);
+1 -1
io_uring/uring_cmd.c
··· 219 219 * being called. This prevents destruction of the mapped buffer 220 220 * we'll need at actual import time. 221 221 */ 222 - io_req_assign_rsrc_node(&req->buf_node, node); 222 + io_req_assign_buf_node(req, node); 223 223 } 224 224 ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); 225 225