Message ID | 20211209063131.18537-7-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/11] block: remove the nr_task field from struct io_context | expand |
On Thu 09-12-21 07:31:26, Christoph Hellwig wrote: > 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. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > block/blk-ioc.c | 33 +++++++++++---------------------- > 1 file changed, 11 insertions(+), 22 deletions(-) > > diff --git a/block/blk-ioc.c b/block/blk-ioc.c > index ca996214c10a6..f98a29ee8f362 100644 > --- a/block/blk-ioc.c > +++ b/block/blk-ioc.c > @@ -192,27 +192,6 @@ void exit_io_context(struct task_struct *task) > } > } > > -static void __ioc_clear_queue(struct list_head *icq_list) > -{ > - unsigned long flags; > - > - rcu_read_lock(); > - while (!list_empty(icq_list)) { > - struct io_cq *icq = list_entry(icq_list->next, > - struct io_cq, q_node); > - struct io_context *ioc = icq->ioc; > - > - spin_lock_irqsave(&ioc->lock, flags); > - if (icq->flags & ICQ_DESTROYED) { > - spin_unlock_irqrestore(&ioc->lock, flags); > - continue; > - } > - ioc_destroy_icq(icq); > - spin_unlock_irqrestore(&ioc->lock, flags); > - } > - rcu_read_unlock(); > -} > - > /** > * ioc_clear_queue - break any ioc association with the specified queue > * @q: request_queue being cleared > @@ -227,7 +206,17 @@ void ioc_clear_queue(struct request_queue *q) > list_splice_init(&q->icq_list, &icq_list); > spin_unlock_irq(&q->queue_lock); > > - __ioc_clear_queue(&icq_list); > + rcu_read_lock(); > + while (!list_empty(&icq_list)) { > + struct io_cq *icq = > + list_entry(icq_list.next, struct io_cq, q_node); > + > + spin_lock_irq(&icq->ioc->lock); > + if (!(icq->flags & ICQ_DESTROYED)) > + ioc_destroy_icq(icq); > + spin_unlock_irq(&icq->ioc->lock); > + } > + rcu_read_unlock(); > } > > static struct io_context *alloc_io_context(gfp_t gfp_flags, int node) > -- > 2.30.2 >
diff --git a/block/blk-ioc.c b/block/blk-ioc.c index ca996214c10a6..f98a29ee8f362 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -192,27 +192,6 @@ void exit_io_context(struct task_struct *task) } } -static void __ioc_clear_queue(struct list_head *icq_list) -{ - unsigned long flags; - - rcu_read_lock(); - while (!list_empty(icq_list)) { - struct io_cq *icq = list_entry(icq_list->next, - struct io_cq, q_node); - struct io_context *ioc = icq->ioc; - - spin_lock_irqsave(&ioc->lock, flags); - if (icq->flags & ICQ_DESTROYED) { - spin_unlock_irqrestore(&ioc->lock, flags); - continue; - } - ioc_destroy_icq(icq); - spin_unlock_irqrestore(&ioc->lock, flags); - } - rcu_read_unlock(); -} - /** * ioc_clear_queue - break any ioc association with the specified queue * @q: request_queue being cleared @@ -227,7 +206,17 @@ void ioc_clear_queue(struct request_queue *q) list_splice_init(&q->icq_list, &icq_list); spin_unlock_irq(&q->queue_lock); - __ioc_clear_queue(&icq_list); + rcu_read_lock(); + while (!list_empty(&icq_list)) { + struct io_cq *icq = + list_entry(icq_list.next, struct io_cq, q_node); + + spin_lock_irq(&icq->ioc->lock); + if (!(icq->flags & ICQ_DESTROYED)) + ioc_destroy_icq(icq); + spin_unlock_irq(&icq->ioc->lock); + } + rcu_read_unlock(); } static struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
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. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-ioc.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)