Skip to content

Commit 525916c

Browse files
joannekoongaxboe
authored andcommitted
io_uring/rsrc: fix lost entries after cloned range
When cloning with node replacements (IORING_REGISTER_DST_REPLACE), destination entries after the cloned range are not copied over. Add logic to copy them over to the new destination table. Fixes: c132953 ("io_uring/rsrc: allow cloning with node replacements") Cc: [email protected] Signed-off-by: Joanne Koong <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e29af2a commit 525916c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

io_uring/rsrc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
12051205
if (ret)
12061206
return ret;
12071207

1208-
/* Fill entries in data from dst that won't overlap with src */
1208+
/* Copy original dst nodes from before the cloned range */
12091209
for (i = 0; i < min(arg->dst_off, ctx->buf_table.nr); i++) {
12101210
struct io_rsrc_node *node = ctx->buf_table.nodes[i];
12111211

@@ -1238,6 +1238,16 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
12381238
i++;
12391239
}
12401240

1241+
/* Copy original dst nodes from after the cloned range */
1242+
for (i = nbufs; i < ctx->buf_table.nr; i++) {
1243+
struct io_rsrc_node *node = ctx->buf_table.nodes[i];
1244+
1245+
if (node) {
1246+
data.nodes[i] = node;
1247+
node->refs++;
1248+
}
1249+
}
1250+
12411251
/*
12421252
* If asked for replace, put the old table. data->nodes[] holds both
12431253
* old and new nodes at this point.

0 commit comments

Comments
 (0)