Fold __ioc_clear_queue into ioc_clear_queue and switch to always use plain _irq locking instead of the more expensive _irqsave that is not needed here.
Unified · Split
| @@ -192,27 +192,6 @@ void exit_io_context(struct task_struct *task) · 191 unmodified lines | ||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | −static void __ioc_clear_queue(struct list_head *icq_list) | |
| 196 | −{ | |
| 197 | − unsigned long flags; | |
| 198 | − | |
| 199 | − rcu_read_lock(); | |
| 200 | − while (!list_empty(icq_list)) { | |
| 201 | − struct io_cq *icq = list_entry(icq_list->next, | |
| 202 | − struct io_cq, q_node); | |
| 203 | − struct io_context *ioc = icq->ioc; | |
| 204 | − | |
| 205 | − spin_lock_irqsave(&ioc->lock, flags); | |
| 206 | − if (icq->flags & ICQ_DESTROYED) { | |
| 207 | − spin_unlock_irqrestore(&ioc->lock, flags); | |
| 208 | − continue; | |
| 209 | − } | |
| 210 | − ioc_destroy_icq(icq); | |
| 211 | − spin_unlock_irqrestore(&ioc->lock, flags); | |
| 212 | − } | |
| 213 | − rcu_read_unlock(); | |
| 214 | −} | |
| 215 | − | |
| 216 | 195 | /** |
| 217 | 196 | * ioc_clear_queue - break any ioc association with the specified queue |
| 218 | 197 | * @q: request_queue being cleared |
| @@ -227,7 +206,17 @@ void ioc_clear_queue(struct request_queue *q) · 8 unmodified lines | ||
| 227 | 206 | list_splice_init(&q->icq_list, &icq_list); |
| 228 | 207 | spin_unlock_irq(&q->queue_lock); |
| 229 | 208 | |
| 230 | − __ioc_clear_queue(&icq_list); | |
| 209 | + rcu_read_lock(); | |
| 210 | + while (!list_empty(&icq_list)) { | |
| 211 | + struct io_cq *icq = | |
| 212 | + list_entry(icq_list.next, struct io_cq, q_node); | |
| 213 | + | |
| 214 | + spin_lock_irq(&icq->ioc->lock); | |
| 215 | + if (!(icq->flags & ICQ_DESTROYED)) | |
| 216 | + ioc_destroy_icq(icq); | |
| 217 | + spin_unlock_irq(&icq->ioc->lock); | |
| 218 | + } | |
| 219 | + rcu_read_unlock(); | |
| 231 | 220 | } |
| 232 | 221 | |
| 233 | 222 | static struct io_context *alloc_io_context(gfp_t gfp_flags, int node) |