From patchwork Tue Mar 28 23:12:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9650625 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 A5E5A60349 for ; Tue, 28 Mar 2017 23:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 960BC2844E for ; Tue, 28 Mar 2017 23:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ACD128459; Tue, 28 Mar 2017 23:13:37 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 0DCB828451 for ; Tue, 28 Mar 2017 23:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755487AbdC1XNS (ORCPT ); Tue, 28 Mar 2017 19:13:18 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:34770 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753523AbdC1XNR (ORCPT ); Tue, 28 Mar 2017 19:13:17 -0400 Received: by mail-pg0-f47.google.com with SMTP id 21so85758978pgg.1 for ; Tue, 28 Mar 2017 16:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=zFeLkSS8oECc5Ibr14SCgkgtVEDD+/sHIPX+tqtb6tQ=; b=Yaq5d/aXTxu+BR48hwlVWL3R9zcaWdGZjPzMChsa6kPMIfpy2IhCLY66BWxjIG4flH 1uHbUuP7xnd9s7ukxoCx6bl289regyv1/EyMDUlDFj1JkLG4EWPBNkUAO+tAYP3r/dkV vG43SQEyvXFW6Axwd/RLKCsS8tl0q/vStnSaEBleVvxGepuEXTddPlR7ngMsEMadSpb2 VtdQVh/ErlzrUrxjOamu3NS1F+ka+ACig5R/j2eCG/ZdkKeGZoS9iELZT2+yqt69PvHL t3ayFM+JMaY8ZZrPZ4OaQMY6aDkh/nH2BJMjPsiIltqNbR0t7koSDHhggjCoVbv58xaX dHTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=zFeLkSS8oECc5Ibr14SCgkgtVEDD+/sHIPX+tqtb6tQ=; b=NPPmE3Rq+9C9G/4gUfDG0YBAPF8X05MIneXzyESYYfevoNWBCDaNzXjl1+KkXzfNm7 WhoHSIhbibbZdaEmNS082LLSehHxvclYcgGGROxr2aebk/Uu0gc5xLWGMYvLXWl7lx4L E62r8S3+qAzfvnn6z0kO+83+uEZuFj4Ump6GuWax7E0n9ONIZKCOSyGl0gXefuYVwBKY 9xeS9t759X8LLZWqlyRWBe9C7BeYVuqIUpP6RPcRUYJxyyF6C1ia5rVcgjbAaAXuqmSz zlu7eKtoPs4/qcnADKZESkN+XXkjo/ZBXs3z6PNx5IUAyGmaiytSGkwH1/wXKoRnf19C 0oYQ== X-Gm-Message-State: AFeK/H3guHpFL+dQTrdtgHajwFu78slMvJ9P+Bvuv7pMB9CifU7TlhC4vJ5ql//6Cj3ZVPou X-Received: by 10.84.204.8 with SMTP id a8mr38835890ple.4.1490742796140; Tue, 28 Mar 2017 16:13:16 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::a:d601]) by smtp.gmail.com with ESMTPSA id l9sm9289812pfi.97.2017.03.28.16.13.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 16:13:15 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH v2 3/3] block: fix leak of q->rq_wb Date: Tue, 28 Mar 2017 16:12:17 -0700 Message-Id: X-Mailer: git-send-email 2.12.1 In-Reply-To: <91d938665e5386f10f8756ee8c7ef3e6496ea260.1490742717.git.osandov@fb.com> References: <91d938665e5386f10f8756ee8c7ef3e6496ea260.1490742717.git.osandov@fb.com> In-Reply-To: <91d938665e5386f10f8756ee8c7ef3e6496ea260.1490742717.git.osandov@fb.com> References: <91d938665e5386f10f8756ee8c7ef3e6496ea260.1490742717.git.osandov@fb.com> 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 From: Omar Sandoval CONFIG_DEBUG_TEST_DRIVER_REMOVE found a possible leak of q->rq_wb when a request queue is reregistered. This has been a problem since wbt was introduced, but the WARN_ON(!list_empty(&stats->callbacks)) in the blk-stat rework exposed it. Fix it by cleaning up wbt when we unregister the queue. Fixes: 87760e5eef35 ("block: hook up writeback throttling") Signed-off-by: Omar Sandoval --- block/blk-sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 833fb7f9ce9d..45854266e398 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -795,7 +795,6 @@ static void blk_release_queue(struct kobject *kobj) struct request_queue *q = container_of(kobj, struct request_queue, kobj); - wbt_exit(q); if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags)) blk_stat_remove_callback(q, q->poll_cb); blk_stat_free_callback(q->poll_cb); @@ -938,6 +937,9 @@ void blk_unregister_queue(struct gendisk *disk) queue_flag_clear_unlocked(QUEUE_FLAG_REGISTERED, q); + wbt_exit(q); + + if (q->mq_ops) blk_mq_unregister_dev(disk_to_dev(disk), q);