@@ -38,22 +38,14 @@ static inline ktime_t net_to_ktime(unsigned long t)
38
38
return ns_to_ktime (t << 10 );
39
39
}
40
40
41
- void __io_napi_add (struct io_ring_ctx * ctx , struct socket * sock )
41
+ int __io_napi_add_id (struct io_ring_ctx * ctx , unsigned int napi_id )
42
42
{
43
43
struct hlist_head * hash_list ;
44
- unsigned int napi_id ;
45
- struct sock * sk ;
46
44
struct io_napi_entry * e ;
47
45
48
- sk = sock -> sk ;
49
- if (!sk )
50
- return ;
51
-
52
- napi_id = READ_ONCE (sk -> sk_napi_id );
53
-
54
46
/* Non-NAPI IDs can be rejected. */
55
47
if (napi_id < MIN_NAPI_ID )
56
- return ;
48
+ return - EINVAL ;
57
49
58
50
hash_list = & ctx -> napi_ht [hash_min (napi_id , HASH_BITS (ctx -> napi_ht ))];
59
51
@@ -62,13 +54,13 @@ void __io_napi_add(struct io_ring_ctx *ctx, struct socket *sock)
62
54
if (e ) {
63
55
WRITE_ONCE (e -> timeout , jiffies + NAPI_TIMEOUT );
64
56
rcu_read_unlock ();
65
- return ;
57
+ return - EEXIST ;
66
58
}
67
59
rcu_read_unlock ();
68
60
69
61
e = kmalloc (sizeof (* e ), GFP_NOWAIT );
70
62
if (!e )
71
- return ;
63
+ return - ENOMEM ;
72
64
73
65
e -> napi_id = napi_id ;
74
66
e -> timeout = jiffies + NAPI_TIMEOUT ;
@@ -77,12 +69,13 @@ void __io_napi_add(struct io_ring_ctx *ctx, struct socket *sock)
77
69
if (unlikely (io_napi_hash_find (hash_list , napi_id ))) {
78
70
spin_unlock (& ctx -> napi_lock );
79
71
kfree (e );
80
- return ;
72
+ return - EEXIST ;
81
73
}
82
74
83
75
hlist_add_tail_rcu (& e -> node , hash_list );
84
76
list_add_tail_rcu (& e -> list , & ctx -> napi_list );
85
77
spin_unlock (& ctx -> napi_lock );
78
+ return 0 ;
86
79
}
87
80
88
81
static void __io_napi_remove_stale (struct io_ring_ctx * ctx )
0 commit comments