* [PATCH] block: Fix list corruption of blk stats callback list
@ 2017-04-11 9:29 Jan Kara
2017-04-11 14:09 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2017-04-11 9:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Jan Kara
When CFQ calls wbt_disable_default(), it will call
blk_stat_remove_callback() to stop gathering IO statistics for the
purposes of writeback throttling. Later, when request_queue is
unregistered, wbt_exit() will call blk_stat_remove_callback() again
which will try to delete callback from the list again and possibly cause
list corruption.
Fix the problem by making wbt_disable_default() called wbt_exit() which
is properly guarded against being called multiple times.
Signed-off-by: Jan Kara <jack@suse.cz>
---
block/blk-wbt.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
So this fixes the list debug errors reported by 0-day for me. It was a
pre-existing problem with wbt_disable_default().
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index ffa80e11cf14..b3b79149d3a0 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -653,19 +653,15 @@ void wbt_set_write_cache(struct rq_wb *rwb, bool write_cache_on)
rwb->wc = write_cache_on;
}
- /*
- * Disable wbt, if enabled by default. Only called from CFQ, if we have
- * cgroups enabled
+/*
+ * Disable wbt, if enabled by default. Only called from CFQ.
*/
void wbt_disable_default(struct request_queue *q)
{
struct rq_wb *rwb = q->rq_wb;
- if (rwb && rwb->enable_state == WBT_STATE_ON_DEFAULT) {
- blk_stat_remove_callback(q, rwb->cb);
- rwb->win_nsec = rwb->min_lat_nsec = 0;
- wbt_update_limits(rwb);
- }
+ if (rwb && rwb->enable_state == WBT_STATE_ON_DEFAULT)
+ wbt_exit(q);
}
EXPORT_SYMBOL_GPL(wbt_disable_default);
--
2.12.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: Fix list corruption of blk stats callback list
2017-04-11 9:29 [PATCH] block: Fix list corruption of blk stats callback list Jan Kara
@ 2017-04-11 14:09 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-04-11 14:09 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-block
On 04/11/2017 03:29 AM, Jan Kara wrote:
> When CFQ calls wbt_disable_default(), it will call
> blk_stat_remove_callback() to stop gathering IO statistics for the
> purposes of writeback throttling. Later, when request_queue is
> unregistered, wbt_exit() will call blk_stat_remove_callback() again
> which will try to delete callback from the list again and possibly cause
> list corruption.
>
> Fix the problem by making wbt_disable_default() called wbt_exit() which
> is properly guarded against being called multiple times.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> block/blk-wbt.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> So this fixes the list debug errors reported by 0-day for me. It was a
> pre-existing problem with wbt_disable_default().
Thanks Jan, added for 4.12.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-11 14:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 9:29 [PATCH] block: Fix list corruption of blk stats callback list Jan Kara
2017-04-11 14:09 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.