File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -124,9 +124,8 @@ struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx, int type)
124124
125125 node = kzalloc (sizeof (* node ), GFP_KERNEL );
126126 if (node ) {
127- node -> ctx = ctx ;
127+ node -> ctx_ptr = ( unsigned long ) ctx | type ;
128128 node -> refs = 1 ;
129- node -> type = type ;
130129 }
131130 return node ;
132131}
@@ -445,21 +444,21 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
445444
446445void io_free_rsrc_node (struct io_rsrc_node * node )
447446{
448- struct io_ring_ctx * ctx = node -> ctx ;
447+ struct io_ring_ctx * ctx = io_rsrc_node_ctx ( node ) ;
449448
450449 lockdep_assert_held (& ctx -> uring_lock );
451450
452451 if (node -> tag )
453- io_post_aux_cqe (node -> ctx , node -> tag , 0 , 0 );
452+ io_post_aux_cqe (ctx , node -> tag , 0 , 0 );
454453
455- switch (node -> type ) {
454+ switch (io_rsrc_node_type ( node ) ) {
456455 case IORING_RSRC_FILE :
457456 if (io_slot_file (node ))
458457 fput (io_slot_file (node ));
459458 break ;
460459 case IORING_RSRC_BUFFER :
461460 if (node -> buf )
462- io_buffer_unmap (node -> ctx , node );
461+ io_buffer_unmap (ctx , node );
463462 break ;
464463 default :
465464 WARN_ON_ONCE (1 );
Original file line number Diff line number Diff line change 1111enum {
1212 IORING_RSRC_FILE = 0 ,
1313 IORING_RSRC_BUFFER = 1 ,
14+
15+ IORING_RSRC_TYPE_MASK = 0x3UL ,
1416};
1517
1618struct io_rsrc_node {
17- struct io_ring_ctx * ctx ;
19+ unsigned long ctx_ptr ;
1820 int refs ;
19- u16 type ;
2021
2122 u64 tag ;
2223 union {
@@ -100,11 +101,21 @@ static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
100101 req -> rsrc_nodes [IORING_RSRC_BUFFER ] = NULL ;
101102}
102103
104+ static inline struct io_ring_ctx * io_rsrc_node_ctx (struct io_rsrc_node * node )
105+ {
106+ return (struct io_ring_ctx * ) (node -> ctx_ptr & ~IORING_RSRC_TYPE_MASK );
107+ }
108+
109+ static inline int io_rsrc_node_type (struct io_rsrc_node * node )
110+ {
111+ return node -> ctx_ptr & IORING_RSRC_TYPE_MASK ;
112+ }
113+
103114static inline void io_req_assign_rsrc_node (struct io_kiocb * req ,
104115 struct io_rsrc_node * node )
105116{
106117 node -> refs ++ ;
107- req -> rsrc_nodes [node -> type ] = node ;
118+ req -> rsrc_nodes [io_rsrc_node_type ( node ) ] = node ;
108119}
109120
110121int io_files_update (struct io_kiocb * req , unsigned int issue_flags );
You can’t perform that action at this time.
0 commit comments