@@ -86,74 +86,3 @@ void io_notif_slot_flush(struct io_notif_slot *slot)
8686 io_req_task_work_add (notif );
8787 }
8888}
89-
90- __cold int io_notif_unregister (struct io_ring_ctx * ctx )
91- __must_hold (& ctx - > uring_lock )
92- {
93- int i ;
94-
95- if (!ctx -> notif_slots )
96- return - ENXIO ;
97-
98- for (i = 0 ; i < ctx -> nr_notif_slots ; i ++ ) {
99- struct io_notif_slot * slot = & ctx -> notif_slots [i ];
100- struct io_kiocb * notif = slot -> notif ;
101- struct io_notif_data * nd ;
102-
103- if (!notif )
104- continue ;
105- nd = io_notif_to_data (notif );
106- slot -> notif = NULL ;
107- if (!refcount_dec_and_test (& nd -> uarg .refcnt ))
108- continue ;
109- notif -> io_task_work .func = __io_notif_complete_tw ;
110- io_req_task_work_add (notif );
111- }
112-
113- kvfree (ctx -> notif_slots );
114- ctx -> notif_slots = NULL ;
115- ctx -> nr_notif_slots = 0 ;
116- return 0 ;
117- }
118-
119- __cold int io_notif_register (struct io_ring_ctx * ctx ,
120- void __user * arg , unsigned int size )
121- __must_hold (& ctx - > uring_lock )
122- {
123- struct io_uring_notification_slot __user * slots ;
124- struct io_uring_notification_slot slot ;
125- struct io_uring_notification_register reg ;
126- unsigned i ;
127-
128- if (ctx -> nr_notif_slots )
129- return - EBUSY ;
130- if (size != sizeof (reg ))
131- return - EINVAL ;
132- if (copy_from_user (& reg , arg , sizeof (reg )))
133- return - EFAULT ;
134- if (!reg .nr_slots || reg .nr_slots > IORING_MAX_NOTIF_SLOTS )
135- return - EINVAL ;
136- if (reg .resv || reg .resv2 || reg .resv3 )
137- return - EINVAL ;
138-
139- slots = u64_to_user_ptr (reg .data );
140- ctx -> notif_slots = kvcalloc (reg .nr_slots , sizeof (ctx -> notif_slots [0 ]),
141- GFP_KERNEL_ACCOUNT );
142- if (!ctx -> notif_slots )
143- return - ENOMEM ;
144-
145- for (i = 0 ; i < reg .nr_slots ; i ++ , ctx -> nr_notif_slots ++ ) {
146- struct io_notif_slot * notif_slot = & ctx -> notif_slots [i ];
147-
148- if (copy_from_user (& slot , & slots [i ], sizeof (slot ))) {
149- io_notif_unregister (ctx );
150- return - EFAULT ;
151- }
152- if (slot .resv [0 ] | slot .resv [1 ] | slot .resv [2 ]) {
153- io_notif_unregister (ctx );
154- return - EINVAL ;
155- }
156- notif_slot -> tag = slot .tag ;
157- }
158- return 0 ;
159- }
0 commit comments