From patchwork Mon Mar 27 17:43:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9647263 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 34DE1601D7 for ; Mon, 27 Mar 2017 17:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26C66283FD for ; Mon, 27 Mar 2017 17:45:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BB6528403; Mon, 27 Mar 2017 17:45:09 +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,DKIM_SIGNED, DKIM_VALID,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 65F58283FD for ; Mon, 27 Mar 2017 17:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbdC0RpG (ORCPT ); Mon, 27 Mar 2017 13:45:06 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36258 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbdC0RpF (ORCPT ); Mon, 27 Mar 2017 13:45:05 -0400 Received: by mail-pg0-f42.google.com with SMTP id g2so46588303pge.3 for ; Mon, 27 Mar 2017 10:45:00 -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=onF4pWTQGz6Ia7SBzG5/bbIhSyNNyOXsT0FtyRB5bdU=; b=2TDImeL2101ogPxcSha7GSkBOglTe7fChMUl2eAn+LOQRGNtiju4n6yVidL84ffmHf GttBWsYC0rKoxFia/fJKqIYZ6QOsyw5aS/+74iZy8q6WupaxzHDq+SUyNwETdtrapV7+ 4XTalOXNmcQWFDSsTa9Q4ir53AGSgQ+z916mUN0/Mnxri/RLjNdwbkZGAcD8ugAgpsBt 6A+/O95j78uO1tWS00BnB/ZWJJ7f4BXslRlM3MeqgVhU0ahGXkP4Zm+Cy4v2tCD3YYEs HjO4QlPqvPdEWZE6ZyllspmeuO3pOX+bTR1DXb3trQgqqaJYFHOz6R7Gu30v8rr/c1s3 wQNA== 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=onF4pWTQGz6Ia7SBzG5/bbIhSyNNyOXsT0FtyRB5bdU=; b=Ezwhhd+d8HYJNy0F4q+Ap/utaFmL76E4MHM8c86sHxEPKC92VSao0kM4JsQ7B9az7w YwNKGLZq4E1JQsRUeNUFwye6Xefv9YcEI1hV/fZkYgZC/BEN2TBw+HNV/oRwK+4OxDB7 qwhBPGTF3G8R3WZtJftr+SKiQMPAqsuejPA78/hA/67qrtUuLc08uXuc1KE2bTsaz+xB vzRvY1VNnu4PW8V1c/8RYvnxukz0JFOe83XUXtr7FBZMRgcn+rJ5rMojyTKxHEcTR8oS jgH61XigjUXRaMowCK2VjSop2lbqiQSPu7FOGyQsM/r9jcKSJeqt76ZzmvAhSe02qJNM teNA== X-Gm-Message-State: AFeK/H2EpV7O7GIzN4gaH/NlO13EcvfShwa2+XKHPkErxk4I8ECsUw38YseYssltfTEhHTBT X-Received: by 10.99.177.4 with SMTP id r4mr9302109pgf.16.1490636699195; Mon, 27 Mar 2017 10:44:59 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::f:853d]) by smtp.gmail.com with ESMTPSA id q23sm2431806pfg.63.2017.03.27.10.44.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 10:44:58 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 2/2] block: fix leak of q->rq_wb Date: Mon, 27 Mar 2017 10:43:59 -0700 Message-Id: X-Mailer: git-send-email 2.12.1 In-Reply-To: References: In-Reply-To: References: 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 in a couple of cases: when a request queue is reregistered and when gendisks share a request_queue. This has been a problem since wbt was introduced, but the WARN_ON(!list_empty(&stats->callbacks)) in the blk-stat rework exposed it. The fix is unfortunately a hack until we fix all of the drivers sharing a request_queue. Fixes: 87760e5eef35 ("block: hook up writeback throttling") Signed-off-by: Omar Sandoval --- block/blk-sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index fa831cb2fc30..a187e3f70028 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -893,7 +893,21 @@ int blk_register_queue(struct gendisk *disk) kobject_uevent(&q->kobj, KOBJ_ADD); - blk_wb_init(q); + /* + * There are two cases where wbt may have already been initialized: + * 1. A call sequence of blk_register_queue(); blk_unregister_queue(); + * blk_register_queue(). + * 2. Multiple gendisks sharing a request_queue. + * + * To fix case 1, we'd like to call wbt_exit() in + * blk_unregister_queue(). However, that's unsafe for case 2. So, we're + * forced to do this and call wbt_exit() in blk_release_queue() instead. + * + * Note that in case 2, wbt will account across disks until those legacy + * drivers are fixed. + */ + if (!q->rq_wb) + blk_wb_init(q); if (q->request_fn || (q->mq_ops && q->elevator)) { ret = elv_register_queue(q);