From patchwork Tue Apr 11 09:29:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9674805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64DB960234 for ; Tue, 11 Apr 2017 09:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61D3B2839B for ; Tue, 11 Apr 2017 09:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 549E928505; Tue, 11 Apr 2017 09:29:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4B3A2839B for ; Tue, 11 Apr 2017 09:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754042AbdDKJ3J (ORCPT ); Tue, 11 Apr 2017 05:29:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:56154 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751620AbdDKJ3I (ORCPT ); Tue, 11 Apr 2017 05:29:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2B95AAC30; Tue, 11 Apr 2017 09:29:07 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B9E1B1E114E; Tue, 11 Apr 2017 11:29:05 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Jan Kara Subject: [PATCH] block: Fix list corruption of blk stats callback list Date: Tue, 11 Apr 2017 11:29:01 +0200 Message-Id: <20170411092901.5974-1-jack@suse.cz> X-Mailer: git-send-email 2.12.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);