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)
124
124
125
125
node = kzalloc (sizeof (* node ), GFP_KERNEL );
126
126
if (node ) {
127
- node -> ctx = ctx ;
127
+ node -> ctx_ptr = ( unsigned long ) ctx | type ;
128
128
node -> refs = 1 ;
129
- node -> type = type ;
130
129
}
131
130
return node ;
132
131
}
@@ -445,21 +444,21 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
445
444
446
445
void io_free_rsrc_node (struct io_rsrc_node * node )
447
446
{
448
- struct io_ring_ctx * ctx = node -> ctx ;
447
+ struct io_ring_ctx * ctx = io_rsrc_node_ctx ( node ) ;
449
448
450
449
lockdep_assert_held (& ctx -> uring_lock );
451
450
452
451
if (node -> tag )
453
- io_post_aux_cqe (node -> ctx , node -> tag , 0 , 0 );
452
+ io_post_aux_cqe (ctx , node -> tag , 0 , 0 );
454
453
455
- switch (node -> type ) {
454
+ switch (io_rsrc_node_type ( node ) ) {
456
455
case IORING_RSRC_FILE :
457
456
if (io_slot_file (node ))
458
457
fput (io_slot_file (node ));
459
458
break ;
460
459
case IORING_RSRC_BUFFER :
461
460
if (node -> buf )
462
- io_buffer_unmap (node -> ctx , node );
461
+ io_buffer_unmap (ctx , node );
463
462
break ;
464
463
default :
465
464
WARN_ON_ONCE (1 );
Original file line number Diff line number Diff line change 11
11
enum {
12
12
IORING_RSRC_FILE = 0 ,
13
13
IORING_RSRC_BUFFER = 1 ,
14
+
15
+ IORING_RSRC_TYPE_MASK = 0x3UL ,
14
16
};
15
17
16
18
struct io_rsrc_node {
17
- struct io_ring_ctx * ctx ;
19
+ unsigned long ctx_ptr ;
18
20
int refs ;
19
- u16 type ;
20
21
21
22
u64 tag ;
22
23
union {
@@ -100,11 +101,21 @@ static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
100
101
req -> rsrc_nodes [IORING_RSRC_BUFFER ] = NULL ;
101
102
}
102
103
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
+
103
114
static inline void io_req_assign_rsrc_node (struct io_kiocb * req ,
104
115
struct io_rsrc_node * node )
105
116
{
106
117
node -> refs ++ ;
107
- req -> rsrc_nodes [node -> type ] = node ;
118
+ req -> rsrc_nodes [io_rsrc_node_type ( node ) ] = node ;
108
119
}
109
120
110
121
int io_files_update (struct io_kiocb * req , unsigned int issue_flags );
You can’t perform that action at this time.
0 commit comments