From patchwork Thu Aug 9 14:53:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6642C1057 for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55B592B17F for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53E592B5BB; Thu, 9 Aug 2018 14:53:57 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 2333E2B568 for ; Thu, 9 Aug 2018 14:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732427AbeHIRTK (ORCPT ); Thu, 9 Aug 2018 13:19:10 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:55108 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732370AbeHIRTK (ORCPT ); Thu, 9 Aug 2018 13:19:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533826437; x=1565362437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hvS2H+y1QEVr7mVM9CmsYUDykvc0anjwXO8wsfTCrcM=; b=Ox5a+ThROle4GLTKvoWIAORGetBZEmFTHJ3jG4rVTfiUemrtixcATBY3 0azTC3N1aVSg9dQJ5NLlUPZZZL3nWOipgFYYrIoLiTggLUGEKywSNnR1N dOjAJ7GYX9KRn8wtpk93qcGo636hQICYNjcuvNUc96L9WJbXYt0w2K6Wc LB06AFcwASDWiOGLYd/3kr5gsryL+w2asJ8HpxRpSAfNgT3pjyPH+E3Q7 Yn5wMufUHng7WtskmeLYu72IiUbtIkD1ew4sJ1snsQ51160JDE6xF1DwU 1CNqpVV8HyqqsGoCvEqgXB8IcsRXqckx1DImqeAUNfkDLG54Azf4lKPPs g==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="184535005" Received: from mail-sn1nam04lp0080.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.80]) by ob1.hgst.iphmx.com with ESMTP; 09 Aug 2018 22:53:56 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WHdKxmiCYVHSOO103q4k4BGFNgJSA6bJTX/cUZ8oWxI=; b=O0k3KD4iGfc+WmilxT2KJ4/MJIgHd+ppGjmmRgiqKDiH/NHXlaNwBGlDo00wEmqZExbwR42jouEVvbYetnRvXeTiV9xePxHG+r9rBXgL2kD1U1dkc3lwqJUjcX61Lj5XFL44aKT4Q3iXSnnyv7HChPG+s5t6EVvTYVcnVNmZZ88= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.17; Thu, 9 Aug 2018 14:53:51 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Tejun Heo , Ming Lei , Omar Sandoval , Johannes Thumshirn , Alexandru Moise <00moses.alexander00@gmail.com>, Joseph Qi , stable@vger.kernel.org Subject: [PATCH v5 1/3] blkcg: Introduce blkg_root_lookup() Date: Thu, 9 Aug 2018 07:53:36 -0700 Message-Id: <20180809145338.6160-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809145338.6160-1-bart.vanassche@wdc.com> References: <20180809145338.6160-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR15CA0072.namprd15.prod.outlook.com (2603:10b6:301:4c::34) To DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc9a1ca8-7be4-41cc-37e2-08d5fe07ebfa X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM5PR04MB1196; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;3:I72Sft/fzvorHhj51Sy8J60gTA0L/7NuivoI3qhQtm90ggrDkA82R/Fqj6LS3LFDVgK2af24U+sDWtn9TFiPNVWNsecQ+r2UI/2dYKlZcsR60JZOzmfSl2xTjwhrkbptG19ed0HU+94p+5FaEBQojvOZSKf1lw5RImKF5e2Kn6JD+t/MdWsC4Rh2jnilQma9bWIX7mmAjgbph1noxTkWUUUgmlFFd0usnf2jDujPZlnmX2ix8KyCGNcl5pMh635G;25:H9SDgV+M+r+4+KNKkqL+8K0FrWzNw06BMndrtPOHiSLB/W75vofJJb6j6cw5nNpuxGTxC7tHvQTABtnrEsB5uKipoUPXtUb4xUT4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eHDCASPaFNLPnnNqePE;4:yTo5FK24erOtzdQxfhFCMB4GW/VUxhc+AORFa1ZTlqvp0qm+nja4QekFqE6gV820SvQmj5Jy3+2F35Wvx1QpqtefqBRUcT2bnt6WvOnxlX8MWa/wbD5ZmKww/4h6gaQtrTxHn76qv89Z1l8PnTuXji6jA8XNqAah62rgpqT3w+ABabPnkL2KdaZHG8+/BqdIkEFISNK3PDb+L1PSU1nR0ZrKGLF/8xwUyjYANWWElvI3c8j4x7NuTKH46FYG1k2LoY1ANSJQrNvShhLFzhB6qUVV38fKAaXWf+MSr+fDHDsPqk3p/EqEnn+ujgXCy0yP8Po1m6azPZ/1wl7JBYn/kaSVGIo+f5dRCpHPdTOHPbyF6ChYhZP4YP9X46IfHjY7yV+VX0/19x33lcOIZ59nJ9nEFtS3mepGJV8aXG qCTmw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(67672495146484)(168385556255192); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:DM5PR04MB1196;BCL:0;PCL:0;RULEID:;SRVR:DM5PR04MB1196; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(136003)(346002)(39860400002)(199004)(189003)(54906003)(11346002)(486006)(956004)(16526019)(316002)(2906002)(86362001)(446003)(48376002)(52116002)(81156014)(66066001)(476003)(2616005)(81166006)(16586007)(386003)(6506007)(51416003)(6512007)(36756003)(26005)(305945005)(7736002)(8676002)(105586002)(186003)(53936002)(6486002)(50226002)(3846002)(6116002)(5660300001)(8936002)(7416002)(14444005)(47776003)(68736007)(1076002)(4326008)(39060400002)(25786009)(6666003)(6916009)(76176011)(478600001)(97736004)(50466002)(72206003)(106356001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR04MB1196;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;23:q21svK4EyUaoneOc/UQ0pCSCnGgmmtD5F245VHWiTrOMlRnrcHHLCYR0jKi3JoQAJXVgFidUtxlMgm+3V3gGqXC7h3+eX80XLM1FiOvjRwvpQZKW8ZFYTpmxZoZr2UUdHqLwHz1svSt7nQgnJpHuDhRfGxjsWEmQdE0JdI+PQJRUiHy+jOlSn3r/9LuEIIn+34TNDPEFSBGBmP6ACeDui3qCivSh/pFxq4wHDYlTbvcbwbjCbn2kZshZBD6rv2bq/xmz1JWR3kfDGpI+6KT9abDZwk42m8LT76V0nu2GDJDKRc75JnSAppLQdp9vwza0noYX7145zZ8hZsBMVwjOOstBfraCjFp/37HgzyC+bQmEIYv7M2fZ7oHDpVSqHDHHS1kN5IsGTDyh99ZM1yVlxS3nHJwOMLlECPQYJsdFwBN45KTcAbZCBW3xwiTgAKc9d4gop4c3JbjvxHYLe45vKoTZdw/qglIcYVAy5pZuUcOk+TxAeHwP/Y1GnNgKoA30EnsstenXoY2Ak5rA7efXZw+jBnxZmT3FQoZG/UQIj6fiyniZH/ez2oaDIJ773lVEFeH81zOyqeDx5MeMFvRAlsktjjNLdjIuHgRAY9z/VqYPvxMqfaaC+5GVEgAOTHK+DJhs3BnbesAbwjXksFNlOUeSBiVniaUZr94WP1FGUa+CBaLYTE5rpHkwXsdujnY0Tv5btiNIdSG7bXcOCKjdMn4QtpOkWyYyEkcopuiYfp/ZOyylXc44k8JOxlhofZEqwwrAT1zO/gUM98EG6J81JLvsMzzqbtxUDTcz8uk3I4MsmwHH7HgMmXjUx8HX8vD09cJBefMQZskMqv6LOJfxSYJVFXhSehDhDLvzLh3S0EiUhO2oL7ZiDjISkvbFh0xrxuc1vwWcxMTQejRroR2VYVI7lSdOxg1ssg3QZalpWCT3YuPciAdm4vjTJF0rNcaM0PyrPaDVsQ/oHTAKJ2XOtadruuV3Tbw+F90HgaGTMr93mc4R/9Uq4dtxHfUMf9Wvyx5FAZgVmrLJy3BIsBu/AoOf+VjDfw9mIWLkNAzTtB3q9iOi5pPluid89anUJO4+Dy4NFsqW+SPdfUHXWj6jlzH2TTtN9GzC687uVs8zxi1z9GKtkkcPYXVjTFgoK5pxGD93Bg0naBZhd0hKBgJUx3LHaaKv5YjrxKgiNfcZR2ukThVacAfFG+0H69BknDM4CS+xeYlwqmG9R/mHHFjyceDiPpSI0AVNpc73q/nA0qfj8BnENhxIp5/EkyafnELnqbu7fJTFfwTaU5f8AwryKA== X-Microsoft-Antispam-Message-Info: JTjMggtpocLV9mk7/dINo5gcUaE07yu6ddHR21hr+7QAuDzIPQ0dRdwd5yyCOMx8R58gVUtEJozrtgxS09vjIR4/C7IySxGN0GC1wMK4wfHqY0gTercw30LN7AiRplld9opmTHbda8BCww/NIJue1Tnt6n+qgPJawlt3SXdQAFcZPTiDi7huPyKasCDEAzkE8cXd5qM1h6PW1+2OZxbI0qi1i+88v8e9Oh18WZn/g2idngEM6e80eJ34NJT97iqx9MklaTqo9TXbEt5vpU7WO5WsiTIvK5UME9UlQIipZJij1vRcWwDYmRsp3p/QS6sg2yBL5FY2X9BbEW5IOO5CIqCe9Hut5m/7gV71bJcFuNc= X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;6:/5D2OwL166tOB8UhcOPMIRW8ncwiYlwGJip9TWIe+MgFGa95VS8WnSXZJXn8wCHgKL36txA8jkgagAOaruMT6qVatEp1E5nQHxYSM9dQ/463lafLeiZ4kxApRmi92Kywfx3ufx9GLiahIvHDTwomsV3Swoko/GU4WHwg+WvrfhygiVRECpYrtKVXQ4vPBVHww5e+05/CU+zSANS+h/qlA3ULnAf6VN1hxXvokKZqDZG9Q2ikzbaRiJZh4y1zVR86M8n3VijvEEVSQCFkLp/qWCbXnRO+y689b60b1ZxbzZkuMfQZygyv2t+oYkDq6K00knbzqccZD2eG2Ao5y9VcgkVAE2NsFrpXXzMFa1WA5UQlDRMzBQslh2FP8PRjTIiGYac5rMGB/ki+4lwPqdzH9sSqGgMWr283YgRy5ZSdLNp364eplT7auEDVZ+iHcM5ssY7yErmlEylYi9nCrY8YoQ==;5:UxvoZbuJXMNxncqB2ofy6bMxjT2ja8LhTwRKr7+5+jl10H1nXtaZK20eTQluDFT8aTUhoyMou6ydJb0Ql0w04MzpxFAzjWlZhgHnBStHFWI+BaXV00mYoV4ZsNf2YsiJeKbK596Ei10l3QX89gOK+FDDWyJlPNRRPfGtFzaD9X8=;7:4Rw5+KEMlVPJj9x2gbPYYkTcqL81XLuFhjpe1PneB1DaSAJx1TA3ToQCp0woWd+FOdl41yvFiMytX6AE9AJp6vYhlkd+lZk7BQMY9Iil8IPNyGsAMj6+jXt/kijCwbPVYPEaPwLphZyJ44iFUO1JaK0XGzrEJmG6QFEJAl+vgQx+zU6arkNx8FeAVurHZ1SmF3uvv7ApUEfnCm0tYZZNi+f5/HuOPPbbTfFO5qGMPcSRmP2z9f8slcLXIZncR4DL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:SSAWhm9UbA3HDxhFmj/hS6oIZZBg3H/x7jczEnWWz+HmqNvLkEV9oTXrhwnJYCmjWY/RWWCtABlieoqpVFfvqcyHflcD9F2EWwcRSzGrKBlxZs/Rz6VVdk+bn+orNC4khSO9tO9VH+IHcPJMErHy+YMpb8S+4HKEb2EhYbcHESc= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 14:53:51.1156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc9a1ca8-7be4-41cc-37e2-08d5fe07ebfa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB1196 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 This new function will be used in a later patch to verify whether a queue has been dissociated from the cgroup controller before being released. Signed-off-by: Bart Van Assche Cc: Tejun Heo Cc: Christoph Hellwig Cc: Ming Lei Cc: Omar Sandoval Cc: Johannes Thumshirn Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Joseph Qi Cc: --- include/linux/blk-cgroup.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index f7b910768306..1361cfc9b878 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -341,6 +341,23 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, return __blkg_lookup(blkcg, q, false); } +/** + * blkg_lookup - look up blkg for the specified request queue + * @q: request_queue of interest + * + * Lookup blkg for @q at the root level. See also blkg_lookup(). + */ +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) +{ + struct blkcg_gq *blkg; + + rcu_read_lock(); + blkg = blkg_lookup(&blkcg_root, q); + rcu_read_unlock(); + + return blkg; +} + /** * blkg_to_pdata - get policy private data * @blkg: blkg of interest @@ -864,6 +881,7 @@ static inline bool blk_cgroup_congested(void) { return false; } static inline void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay) { } static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; } +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) { return NULL; } static inline int blkcg_init_queue(struct request_queue *q) { return 0; } static inline void blkcg_drain_queue(struct request_queue *q) { } static inline void blkcg_exit_queue(struct request_queue *q) { } From patchwork Thu Aug 9 14:53:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE6EE1515 for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A55BE2B581 for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3B882B5CC; Thu, 9 Aug 2018 14:53:57 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 E97752B581 for ; Thu, 9 Aug 2018 14:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732429AbeHIRTL (ORCPT ); Thu, 9 Aug 2018 13:19:11 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:55108 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732399AbeHIRTK (ORCPT ); Thu, 9 Aug 2018 13:19:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533826438; x=1565362438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SvQoFdQckMNs+sCOvs03eBdeOlavsxjgMKxiiqkM5dc=; b=LOt38L1noofhZ9P/wMqsZKecJuP47UFgHusAvvij1MqBkWefZA2dxGiW fA0lRS1FL8tL+SxZX2VVPa3jsfzvz7kf5xoTIhNVNqsFNH20D0LQAKgD9 +7RTX200b4FhxpevIwict1mNm2+07xlUXPjN7sO1v6lar8Dity8QsdIwx RywfMNeSQ10qePBVTHnoesIA+1yx6Zzaf+vhKLEKTRcpgLWiH7x65Fgyl hwyA5bx7vKyfIsOZR8nsEU1P+MzIgftNEF/DnB3ks17eh5BkRsviP3NFg ige/2mx5CMffH9Ql/VQZFgcEWX/vkmLTh0yrAfjFI2Mwv34EWY9VjEhX/ Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="184535009" Received: from mail-sn1nam04lp0080.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.80]) by ob1.hgst.iphmx.com with ESMTP; 09 Aug 2018 22:53:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T00N+IyWENR6DKFEtA9rDKgKLmT9Fugjo+wwV+wen7k=; b=X+jeH647dow4O/qfPkm6hrVsNc2dCB22yYhlSZISzWn7yGU5w8dKOHIxr56uIL77IZ9I8y06Z/hvZ2qNMLsC3FTJEeEWo4iRoW1sWDlu9Ud8Ok7BRUaaZlY27eD4nsQP0dPPKxUsTN+YMoPz4P6kQ60UNy/RSWPYuGx9OhSkf0Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.17; Thu, 9 Aug 2018 14:53:52 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Omar Sandoval , Alexandru Moise <00moses.alexander00@gmail.com>, Joseph Qi , stable@vger.kernel.org Subject: [PATCH v5 2/3] block: Introduce blk_exit_queue() Date: Thu, 9 Aug 2018 07:53:37 -0700 Message-Id: <20180809145338.6160-3-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809145338.6160-1-bart.vanassche@wdc.com> References: <20180809145338.6160-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR15CA0072.namprd15.prod.outlook.com (2603:10b6:301:4c::34) To DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9dc7de1-fadf-4416-45e4-08d5fe07eca8 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM5PR04MB1196; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;3:m3WjeaqVriw5WkkykUlscajsTPnRP1VuQOVxW81OTgUH5kH5KBUrCakV/kiH1Oyf/NPlqCOVNxejURGtlYZo6I6m1c/wKFeFfaoZH6SbenMdhJdbolzcFlLdHMhBgdtwatTEenyo/+LtVLPwd6eUNvbsKf8GIhvVFbdd0oYLloxSDEpmYHmXFkA95elGVnguBBHbjoPRhdlkxboOG6Ag37AD1yRf9raV3kG3m/mmimJup7VOqc3ijAhPNamBibFP;25:mdUZhO0CCFnUrLnCMz0tBxW5OBlPjvLU7a1qsCKKyH/8mc8HMtKSikgEKxR2b0PP/eXyKe9uCY1So1Bfl8QWVO2OKDeLfFgqaB26nQ0Oql9F5jmw0ZM5/RLjQ+pnYeQG5ej6++McOAm3eY021alM+9mNSUbTuB5gLs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v5osuAnIlmHEziIRzfJ9crqajx4aMN6t2xzSCe8n1aUXtnl/5Whvp1zPN3UMJ/y4obtkah79hJfZ0cVoXhB+b8B3HkXSM44jgCTILrEhLMUhJvQW9WoX/TlklOVFqSIYiqfLimgZyCMUZTL+J6zPaldaxiUL0kuDgwqrcYPkVo2G/Cg2lj5dlVjFEE1olxTAsVDEUhkRcCZG++y73twnJtI/uSACcUWzkqBTnHOB7ob6/dOPLOkO3HtASFgsPnG3AzvuPgnyfahRld8lWq+0LQDTBoepnCdj3ExRybUA3XC0n/UkLKdzhJbTfBHw+5ekiXQSbmF0SG+fDoZ1Eo9/EmXdWkCYW92t4taaJmkLHoJc5FTQajJarX cGc4k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(67672495146484)(168385556255192); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:DM5PR04MB1196;BCL:0;PCL:0;RULEID:;SRVR:DM5PR04MB1196; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(136003)(346002)(39860400002)(199004)(189003)(54906003)(11346002)(486006)(956004)(16526019)(316002)(2906002)(86362001)(446003)(48376002)(52116002)(81156014)(66066001)(476003)(2616005)(81166006)(16586007)(386003)(6506007)(51416003)(6512007)(36756003)(26005)(305945005)(7736002)(8676002)(105586002)(186003)(53936002)(6486002)(50226002)(3846002)(6116002)(5660300001)(8936002)(14444005)(47776003)(68736007)(1076002)(4326008)(39060400002)(25786009)(6666003)(6916009)(76176011)(478600001)(97736004)(50466002)(72206003)(106356001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EqKKhEBrMKeAqtP2eBQiE3Dc/U4hBbYxuY6ca5BSPtqiCo7q0VGXhSF2deoBY0Rs7hhQrmJgayJq1lxKQKYoUBCk1pBKrGHB/SnKJQ2kd6B6+G0KxjoO+vQlw1YGXAKc8pENkFE/BG4RzjU6kxH2m5K5ENQ==;5:HA0NBQ4FW3fygedpourUQTTQkemy3wc7RDn6DBIIxtD+gWR6E/dM2o2F8u6OXNsYHREAXgAGGrM+2agfPzYrUp2GylhFwL+zzbO637rM5nlS1o958f9eftQ32gzHv/tioCuYmlNr3OzqVajtrYLFzev6gNloxm++MAuMIyjqsbU=;7:cTE1cgFvewuQkGaem4Or7XhKHFpLHQxFPdTON+tRd7EDphjijWvKm86AKd+323hQPmpwI9ZcdYze5uiJbVgU/GA3B5d3hY3GeRtTHiuym9HpZYilydds0YcnHcQg6CLF+pHyYnbLZa92mSbow5UGz7Pzv65LYhemK3AFcsCGM7VHkNLoNeDZdVjf2s9pTy5RTE3qPB9lchHHMIKkN9nRwtBIJXQJgZ/XHq17dnqEjxb7SiReLHNU02W7AlRZhGzy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:SYaw+TDkEov6KzLl/OJY7O8doLVw6aX9zcsFLMR0Xjos/bKROp13M3EIKTKNB4ea9ZnHX9xzqt4L1w/WJt+56VgTLNC76Jvn/GYL+OzUOngECSGCuXE/U7zxAHmyH9KjErjQrjGnxLRXX/bl0e5xG1nU+/L6fs4J3GGMJnZhc08= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 14:53:52.3813 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9dc7de1-fadf-4416-45e4-08d5fe07eca8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB1196 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 This patch does not change any functionality. Signed-off-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Cc: Christoph Hellwig Cc: Ming Lei Cc: Omar Sandoval Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Joseph Qi Cc: --- block/blk-core.c | 54 +++++++++++++++++++++++++++--------------------- block/blk.h | 1 + 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 2e054b65de42..55bc22ef2934 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -719,6 +719,35 @@ void blk_set_queue_dying(struct request_queue *q) } EXPORT_SYMBOL_GPL(blk_set_queue_dying); +/* Unconfigure the I/O scheduler and dissociate from the cgroup controller. */ +void blk_exit_queue(struct request_queue *q) +{ + /* + * Since the I/O scheduler exit code may access cgroup information, + * perform I/O scheduler exit before disassociating from the block + * cgroup controller. + */ + if (q->elevator) { + ioc_clear_queue(q); + elevator_exit(q, q->elevator); + q->elevator = NULL; + } + + /* + * Remove all references to @q from the block cgroup controller before + * restoring @q->queue_lock to avoid that restoring this pointer causes + * e.g. blkcg_print_blkgs() to crash. + */ + blkcg_exit_queue(q); + + /* + * Since the cgroup code may dereference the @q->backing_dev_info + * pointer, only decrease its reference count after having removed the + * association with the block cgroup controller. + */ + bdi_put(q->backing_dev_info); +} + /** * blk_cleanup_queue - shutdown a request queue * @q: request queue to shutdown @@ -788,30 +817,7 @@ void blk_cleanup_queue(struct request_queue *q) */ WARN_ON_ONCE(q->kobj.state_in_sysfs); - /* - * Since the I/O scheduler exit code may access cgroup information, - * perform I/O scheduler exit before disassociating from the block - * cgroup controller. - */ - if (q->elevator) { - ioc_clear_queue(q); - elevator_exit(q, q->elevator); - q->elevator = NULL; - } - - /* - * Remove all references to @q from the block cgroup controller before - * restoring @q->queue_lock to avoid that restoring this pointer causes - * e.g. blkcg_print_blkgs() to crash. - */ - blkcg_exit_queue(q); - - /* - * Since the cgroup code may dereference the @q->backing_dev_info - * pointer, only decrease its reference count after having removed the - * association with the block cgroup controller. - */ - bdi_put(q->backing_dev_info); + blk_exit_queue(q); if (q->mq_ops) blk_mq_free_queue(q); diff --git a/block/blk.h b/block/blk.h index 6adae8f94279..aeb8026f4d7b 100644 --- a/block/blk.h +++ b/block/blk.h @@ -130,6 +130,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q); int blk_init_rl(struct request_list *rl, struct request_queue *q, gfp_t gfp_mask); void blk_exit_rl(struct request_queue *q, struct request_list *rl); +void blk_exit_queue(struct request_queue *q); void blk_rq_bio_prep(struct request_queue *q, struct request *rq, struct bio *bio); void blk_queue_bypass_start(struct request_queue *q); From patchwork Thu Aug 9 14:53:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BC4A1057 for ; Thu, 9 Aug 2018 14:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B3D02B559 for ; Thu, 9 Aug 2018 14:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38BD92B237; Thu, 9 Aug 2018 14:53:58 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 A37642B5C5 for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732440AbeHIRTM (ORCPT ); Thu, 9 Aug 2018 13:19:12 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:55108 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732399AbeHIRTL (ORCPT ); Thu, 9 Aug 2018 13:19:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533826438; x=1565362438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=L2Oo1bzdEYY3hWMp3Bc7Whq+0W191dGEJHDqlhJJlIw=; b=P3gLxcxsI+f/PCN7p/G+jrHmDphyU0ZFLKC1tJaDaK/L1v172Ccc4FtG N6t8DAXrhEMc4JIQbHpM8c0M0ksHkk6xW3Tq/BeY4ZiQhBVLPiB4A4d/u zzj484RmVoRmFD7SQ8yj+RpW4RLqYNWNmBNLKKdTQQU9oQow4daWUyAAd nHfwZC7pxfB5ruxh7T2ypA0VxyuejfLmyZHPLBiLl8pTupcTc+wf7gt/h D45e5Mja1KkFBidOH3xyVXae4cdfS0cwRJIESjkjQqI5XKNu5jIAQiwuG v2KQjs4/U+DQlBUgJnaf9BIkzThyEcA6DcvM/ZNRvnl28zk4X2fFJFbyO Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="184535012" Received: from mail-sn1nam04lp0084.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.84]) by ob1.hgst.iphmx.com with ESMTP; 09 Aug 2018 22:53:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lW8ZHIowgu7w5Gj6AZDoWHkpAn0SzCcunPXP7eHSpfU=; b=NOiwQLdNxb2cBjKXw38eH9jRoiimmQXCSFViEQg40xJImQ349ZMIrSBIKwmmtmJgOAHYXIgJtWSdDtI3Yz9jZQ8ETxtI6NITp0BtXrxCcsI1tsKKG37YE/vO1O4LreYuE7UGz6lXRgn9Biz2GJw4n3afFGM6FzXSNmTr4EsvuME= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.17; Thu, 9 Aug 2018 14:53:53 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Tejun Heo , Ming Lei , Alexandru Moise <00moses.alexander00@gmail.com>, Joseph Qi , stable@vger.kernel.org Subject: [PATCH v5 3/3] block: Ensure that a request queue is dissociated from the cgroup controller Date: Thu, 9 Aug 2018 07:53:38 -0700 Message-Id: <20180809145338.6160-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809145338.6160-1-bart.vanassche@wdc.com> References: <20180809145338.6160-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR15CA0072.namprd15.prod.outlook.com (2603:10b6:301:4c::34) To DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55ba63c1-689d-4e53-f187-08d5fe07ed53 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM5PR04MB1196; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;3:FQwHRQ0KgR9YGKoZJMZe34XVRyDVYMWFBN57/PFSxylTqlvnimUn8h0cc3mEx3YIP+zd9UzrEFEHFyOOHGKOE8xl9frqnOvSOq3NtmyRUwHho99Fot4qEYUYeNU0ex29jLrAsS+mAceKj2ziwtDoXsiNLxv/xTxPB4ALHhQv2985wWOc4V48wv3lmF+21gXweD6/iVE68n5RZGCeRSIfYBZgYnaSPJMjMe4VWAib4mpS03thCw6CAbe2A1yMiyMG;25:DhaiXtiVnZmlSfAjfCnHgcafTChBSIENEJbIwUHyaOSn3tj67Es7QWLTrkLm5y6kSPjkc3kR1x5Ct5TdHFcimnUAYelUBbPwZb+poUX+zRKLGZINPk9cuPlzxtRNPNE+sdK1gInTfQIfGJ7AVs0KCTup/x9O1MTpaunAP/p48yzV8AaSLl12zhw4srndnOB7hkeftJeuElhp/ds7QZvtHvmAWyYogkI3uvQyU6NY5f9hrKazz1ezeY/OryO1YKh7CE8ree6skkeSDWg1/KX6F7s+b5+P1CMP4SScJWgWfA2IheKDFDuPTXBQ8fWnlyvQ8WXIwBInlKK7kWwdc47BYA==;31:vcmFT9Ll5pEUU+Mi7/D+7sFvUeAhok3BkW1GY70MVqDn98rh33UTmiviKsR1pTCBTXLwgZcxuJHStAaORa8+mGfr+mhfb9bnByCDKXq24dHw4q4Tqf5ebiXkq2sJ6Myvrb9DTBd4+O0O2bV8wGamCrhZJdNn833f1bKdshi0BJhtJjAP88ME87M0hkBLh9s9vB2oS6zpr2HPbNHIbqvkDPjGlUZ4Ijr32mKg19eiiak= X-MS-TrafficTypeDiagnostic: DM5PR04MB1196: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:PogAZrasWoJMx4NEqqKVEeizix5N5javkl7HWHRMe2uGp8K34STCfScj6lztXrUsKUQfGXFGbZtYp1diXwxpBJ+ng407PC5YO2K5/Jtodtf6aZQoRSeGBoGxK7tb8lE2+ekgdYxQEVzll+usG9iTTxrNhSkJJmjdfrXz+FnKDRbR7ebPfpUF91+lWmPvJH0WaR356rwSLg9UGOen3jFpFslktHWM+tgXazsQB9fVIwQcUJTowEKLhilYswFrJQZD06Zh0lrJldJiO8K5PH4BvSPExl+hn+S+i7sFZIDmDSyk4LtLq0Stxf77guizc2+srmUUUrvFhbNxU+xQKjwiyTtXPBdtacf9RBUgc+7H8m1x4XDRzXQy8Y8ORdg72nodRLZpqgNRiZk9Pyop02QEXck9PgXbp/a1v3mGmo40ssVGZuXuUYMYvZTYjYPdJKsX0AUtx4CU8yzoUlLZA56cMAHu9OLRbARubQAFKfYNuCAia3RIqcsfMidGy/8j6Pwo;4:97lXSulDkriBnaxAW7DFQVWk63XcRfeS2oQL8zOxeghTPZlS8wyMlCup1QdnEH5YkTS/S18FCdsKq9PL+KQ0jm4iwkYuDcTXnj84kC1dXklGseDrxgEjh5N8fHEo4mdLn0Czw9Qv7Td/tlxdqgbHW5CVvWwaJHdihXGFLECf/zWhrN4Ro5mJxaq4vsfti4aB1MFHc1jn5juk4m5H8MCWVhg40V4N52k/GoaI6p3IzTiQYjNxSY0pW8ldXq0vgmXxDjkKaVAmv/x7M8564jXlxWFBkFFPknr8U2XaqcpF9do14JUSNKljqv2Rdi7P2tgbWBF8B/pMPg36kaR+tBntR4luN2JGd8hDAh0MpaqYtNzx9nNNwJ6R9MW9R728RuzI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(168385556255192); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:DM5PR04MB1196;BCL:0;PCL:0;RULEID:;SRVR:DM5PR04MB1196; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(136003)(346002)(39860400002)(199004)(189003)(54906003)(11346002)(486006)(956004)(16526019)(316002)(2906002)(86362001)(446003)(48376002)(52116002)(81156014)(66066001)(476003)(2616005)(81166006)(16586007)(386003)(6506007)(51416003)(6512007)(36756003)(26005)(305945005)(7736002)(8676002)(105586002)(186003)(53936002)(6486002)(50226002)(3846002)(6116002)(5660300001)(8936002)(14444005)(47776003)(68736007)(1076002)(4326008)(39060400002)(25786009)(6666003)(6916009)(76176011)(478600001)(97736004)(50466002)(72206003)(106356001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR04MB1196;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;23:4sY6n/m1ND+CdS487rmv4cHAxSRW6BEIXBTXHqRQY1RehUUzJ/wgUQe8kAszpdoxNxs4KMRL7I/SWQ88pURmFg4TP/j4frQEvz26agMEtL08ufkmKLbBeSoh094tLR3c0kPa0AYq9hnkyAgfEx6LfJj83+2uiMmJhGpgBM9nzWpK3JuIjaZXuKk3Fz8iJ3I9iXxBpHFBQCzFom3wytLLrPUh41D6qEjkU0IsrzhaL8l6xItTF2dSrgwy0Z57kVlWK0pH7BAbwYeQeulCvbXU29s6JqXjQR8atXhpS9bJNK4AQps6lcQfTkZ/kBLbdJSA6aLpNPhDb2kdratVDLD+hxl+xYOuRLhPyjAlpGC4rNQs7UjILaWSnwVkc1Oivg2FJ1s5kEKHhssU93RCWSFu7h/a4EAXAZ9kFKZoGB5FuVcGtfUd4nZtsszwUkDdfJglhDUj0nyUPQGkn7tmkOMpqo/+fjrRkW0upOI5ZZ8qzejGvuDF9ajeRb0m4/gLcJbdk4yud3+3X6ag7s0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d3068OXWrPrVQHv4Oz3mDc0zD0UmsfRDHPKSDNI= X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;6:/BREkMMf3dFVYY52JEDKVl5rBhxmmxE5KmDhiMPIeelMhIbOdesTI3Wr4HWQ2xcFfXwrVNKRlI6iXwFYOLHczBMoCtU8hm6w5Llb+JHQFlzMJb2N3snnFF6THJMbNkFHVKbzBhIW+Ct73v38WEfNtl6Fx67deHSdNBLqZN0O4JeGxoDLaFW0I8ZwqEykxdLLapupafUE9QQjG9mPKusNTipXOyDA+fePykBnSAz64G0XbqoMaTY/d7SWfof2JzNbkJV7kBw5lvMEb1YNQXaKDXN0ItoCYiGN7LOU4HhCfWdQN1j0GEuSP2DHeOLoprbqM7ppQxT+azXItwCfgfqBmibfxZq+5yka7rvL063txexqvZs9bQgBUJFN4byoZ6H4MmeJgtyNNVbP+5Nuv6z8MoPGtcq9f6E4ReOQ2yB4yYXlGi+AYHQ0I8iZeMYu/Pou5ZEcgkdPuXUWkZuKbzl8iw==;5:+iz3T8qGlI2VrtaCrz5/qezLa60TjpOc/3nvrLH0FVNRfPR1fBtoB8xDms9hnk8PLgKXL8rXnktryQfBjgAREUIuRLPxR4a1TSO5Kfa4AobncsinKfHSja2cT39hz/7nEoX/OJ7cnA6oNfArU9Sv4KhdO6rUIHtp5F5ikruMztM=;7:Ue5cFa4Jv9EbpT7ya+CRTXCvMJJ1bpTxxmDLKjphFV0yj4ainReDDuk8RIhxtXl8xFN8V5D+xSgckTt5y3r6vBMSCIgDZWcdozvqFnLIECRgvE42DU4quXRDrvvTAmElWfY76derbRGURIJQ9M2JiHCpwr5ew0rHJBvBz4YkI1NcEamO0NMaRM7eVULZvZS4q/m44urI3pY5KdFjDQv0nfTiVAGI4H1kJPssrmorGeO7ptkB0/tUSyYCoQOn/MQM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:xC8wnCmksi9ZBATE/yJMsUzHhWb9FNfYCtoWB2Y0PjlMqjJut65qzkPT9tqknlcA+2uVtbhYzQHibknsQwLlYJ5+XvLu8SgrvLDgDYB7jJR5yO9qMNUUdAm91K6mOYEIpMoyqUHIMCI3gKSKmsGV8gybl5/Yf6O0TNHZjVS0aBo= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 14:53:53.5220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55ba63c1-689d-4e53-f187-08d5fe07ed53 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB1196 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 Several block drivers call alloc_disk() followed by put_disk() if something fails before device_add_disk() is called without calling blk_cleanup_queue(). Make sure that also for this scenario a request queue is dissociated from the cgroup controller. This patch avoids that loading the parport_pc, paride and pf drivers triggers the following kernel crash: BUG: KASAN: null-ptr-deref in pi_init+0x42e/0x580 [paride] Read of size 4 at addr 0000000000000008 by task modprobe/744 Call Trace: dump_stack+0x9a/0xeb kasan_report+0x139/0x350 pi_init+0x42e/0x580 [paride] pf_init+0x2bb/0x1000 [pf] do_one_initcall+0x8e/0x405 do_init_module+0xd9/0x2f2 load_module+0x3ab4/0x4700 SYSC_finit_module+0x176/0x1a0 do_syscall_64+0xee/0x2b0 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Reported-by: Alexandru Moise <00moses.alexander00@gmail.com> Fixes: a063057d7c73 ("block: Fix a race between request queue removal and the block cgroup controller") # v4.17 Signed-off-by: Bart Van Assche Tested-by: Alexandru Moise <00moses.alexander00@gmail.com> Reviewed-by: Johannes Thumshirn Cc: Tejun Heo Cc: Christoph Hellwig Cc: Ming Lei Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Joseph Qi Cc: --- block/blk-sysfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index ca1984ecbdeb..fcadea471779 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -802,6 +802,21 @@ static void __blk_release_queue(struct work_struct *work) blk_stat_remove_callback(q, q->poll_cb); blk_stat_free_callback(q->poll_cb); + if (!blk_queue_dead(q)) { + /* + * Last reference was dropped without having called + * blk_cleanup_queue(). + */ + WARN_ONCE(blk_queue_init_done(q), + "request queue %p has been registered but blk_cleanup_queue() has not been called for that queue\n", + q); + blk_exit_queue(q); + } + + WARN(blkg_root_lookup(q), + "request queue %p is being released but it has not yet been removed from the blkcg controller\n", + q); + blk_free_queue_stats(q->stats); blk_exit_rl(q, &q->root_rl);