@@ -130,13 +130,13 @@ struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx, int type)
130130 return node ;
131131}
132132
133- __cold void io_rsrc_data_free (struct io_rsrc_data * data )
133+ __cold void io_rsrc_data_free (struct io_ring_ctx * ctx , struct io_rsrc_data * data )
134134{
135135 if (!data -> nr )
136136 return ;
137137 while (data -> nr -- ) {
138138 if (data -> nodes [data -> nr ])
139- io_put_rsrc_node (data -> nodes [data -> nr ]);
139+ io_put_rsrc_node (ctx , data -> nodes [data -> nr ]);
140140 }
141141 kvfree (data -> nodes );
142142 data -> nodes = NULL ;
@@ -184,7 +184,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
184184 continue ;
185185
186186 i = up -> offset + done ;
187- if (io_reset_rsrc_node (& ctx -> file_table .data , i ))
187+ if (io_reset_rsrc_node (ctx , & ctx -> file_table .data , i ))
188188 io_file_bitmap_clear (& ctx -> file_table , i );
189189
190190 if (fd != -1 ) {
@@ -266,7 +266,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
266266 node -> tag = tag ;
267267 }
268268 i = array_index_nospec (up -> offset + done , ctx -> buf_table .nr );
269- io_reset_rsrc_node (& ctx -> buf_table , i );
269+ io_reset_rsrc_node (ctx , & ctx -> buf_table , i );
270270 ctx -> buf_table .nodes [i ] = node ;
271271 if (ctx -> compat )
272272 user_data += sizeof (struct compat_iovec );
@@ -442,10 +442,8 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
442442 return IOU_OK ;
443443}
444444
445- void io_free_rsrc_node (struct io_rsrc_node * node )
445+ void io_free_rsrc_node (struct io_ring_ctx * ctx , struct io_rsrc_node * node )
446446{
447- struct io_ring_ctx * ctx = io_rsrc_node_ctx (node );
448-
449447 lockdep_assert_held (& ctx -> uring_lock );
450448
451449 if (node -> tag )
@@ -473,7 +471,7 @@ int io_sqe_files_unregister(struct io_ring_ctx *ctx)
473471 if (!ctx -> file_table .data .nr )
474472 return - ENXIO ;
475473
476- io_free_file_tables (& ctx -> file_table );
474+ io_free_file_tables (ctx , & ctx -> file_table );
477475 io_file_table_set_alloc_range (ctx , 0 , 0 );
478476 return 0 ;
479477}
@@ -494,7 +492,7 @@ int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
494492 return - EMFILE ;
495493 if (nr_args > rlimit (RLIMIT_NOFILE ))
496494 return - EMFILE ;
497- if (!io_alloc_file_tables (& ctx -> file_table , nr_args ))
495+ if (!io_alloc_file_tables (ctx , & ctx -> file_table , nr_args ))
498496 return - ENOMEM ;
499497
500498 for (i = 0 ; i < nr_args ; i ++ ) {
@@ -551,7 +549,7 @@ int io_sqe_buffers_unregister(struct io_ring_ctx *ctx)
551549{
552550 if (!ctx -> buf_table .nr )
553551 return - ENXIO ;
554- io_rsrc_data_free (& ctx -> buf_table );
552+ io_rsrc_data_free (ctx , & ctx -> buf_table );
555553 return 0 ;
556554}
557555
@@ -788,7 +786,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
788786 if (ret ) {
789787 kvfree (imu );
790788 if (node )
791- io_put_rsrc_node (node );
789+ io_put_rsrc_node (ctx , node );
792790 node = ERR_PTR (ret );
793791 }
794792 kvfree (pages );
@@ -1018,7 +1016,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
10181016 * old and new nodes at this point.
10191017 */
10201018 if (arg -> flags & IORING_REGISTER_DST_REPLACE )
1021- io_rsrc_data_free (& ctx -> buf_table );
1019+ io_rsrc_data_free (ctx , & ctx -> buf_table );
10221020
10231021 /*
10241022 * ctx->buf_table should be empty now - either the contents are being
@@ -1042,7 +1040,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
10421040 kfree (data .nodes [i ]);
10431041 }
10441042out_unlock :
1045- io_rsrc_data_free (& data );
1043+ io_rsrc_data_free (ctx , & data );
10461044 mutex_unlock (& src_ctx -> uring_lock );
10471045 mutex_lock (& ctx -> uring_lock );
10481046 return ret ;
0 commit comments