From patchwork Wed May 24 00:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9744787 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 BA242602A7 for ; Wed, 24 May 2017 00:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC1A02885B for ; Wed, 24 May 2017 00:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A02B528867; Wed, 24 May 2017 00:36:19 +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=unavailable 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 1FF212885B for ; Wed, 24 May 2017 00:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968992AbdEXAgS (ORCPT ); Tue, 23 May 2017 20:36:18 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54147 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760697AbdEXAfV (ORCPT ); Tue, 23 May 2017 20:35:21 -0400 X-IronPort-AV: E=Sophos;i="5.38,383,1491235200"; d="scan'208";a="21089179" Received: from mail-sn1nam02lp0024.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.24]) by ob1.hgst.iphmx.com with ESMTP; 24 May 2017 08:34:31 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Hxtni5iDhjiO4FB1oswEIF/HEf8q7RH/ohHd1cEO68g=; b=dFVSMUZLZ/+HcK32Ev4YdWhiCqvfXsv+Qw4ljtcMTtd5wB+jD78yk9b6qFMEU+FEEyu4vV0vHRVzaxyM/kIarLCeL7JVPGErSIt1WucKAGu7N/Zqt+clNVoV2/JCAQGfIPQLFB+ORdYUcn7vnPr+JlKfMdJbec8tu5zF4nRuazo= Received: from CY4PR04CA0035.namprd04.prod.outlook.com (10.172.133.21) by BN6PR04MB0501.namprd04.prod.outlook.com (10.173.201.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Wed, 24 May 2017 00:34:28 +0000 Received: from BN3NAM04FT005.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4e::208) by CY4PR04CA0035.outlook.office365.com (2603:10b6:903:c6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Wed, 24 May 2017 00:34:28 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BN3NAM04FT005.mail.protection.outlook.com (10.152.92.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1075.5 via Frontend Transport; Wed, 24 May 2017 00:34:27 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 77.43.45291.115D4295; Tue, 23 May 2017 17:34:25 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 23 May 2017 17:34:23 -0700 X-AuditID: 0ac94369-166ac9800001b0eb-f5-5924d5118b92 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 01.A3.18148.F05D4295; Tue, 23 May 2017 17:34:23 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , , "Bart Van Assche" , Jens Axboe , "Christoph Hellwig" , Tejun Heo , Jan Kara , Hannes Reinecke , Subject: [PATCH 09/31] block: Avoid that blk_exit_rl() triggers a use-after-free Date: Tue, 23 May 2017 17:33:58 -0700 Message-ID: <20170524003420.5381-10-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170524003420.5381-1-bart.vanassche@sandisk.com> References: <20170524003420.5381-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeLIzCtJLcpLzFFi42LhOum8SFfwqkqkwdJJ+hb/9xxjs1jwZi+b xcrVR5ksZk9vZrLY2M9hsfeWtkX39R1sFsuP/2OyWLDxEaPFr+VHGR24PCY2v2P3mDbpFJvH plWdbB67bzaweXx8eovFY/2WqyweZxYcYff4vEkugCOKyyYlNSezLLVI3y6BK6Pzu0DBffmK jkU72BoYP0p1MXJySAiYSEz/sIy1i5GLQ0hgKZPE933/WSCcHYwS7ztnsHcxcoBV3XzmChHf yCjxaPMNVpBuNgEjiW/vZ7KA2CIChRKXtnUwghQxC8xlkpjy5hMbSEJYIEDi6dp/YDaLgKrE 0TVTmEFsXgF7iT/XGtggzpC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jB/qcd/L2dq2zmj+Ir45mnVXWH51r8gO8VJiKc5I NNRiLipOBACyf39C5gEAAA== MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(39400400002)(39450400003)(39840400002)(39410400002)(39850400002)(2980300002)(438002)(199003)(189002)(9170700003)(54906002)(1076002)(6666003)(478600001)(575784001)(81166006)(8676002)(53936002)(356003)(8936002)(38730400002)(50226002)(47776003)(106466001)(77096006)(76176999)(189998001)(2950100002)(50986999)(48376002)(36756003)(5003940100001)(50466002)(72206003)(4326008)(7416002)(230783001)(33646002)(2906002)(5660300001)(86362001)(305945005); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR04MB0501; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3NAM04FT005; 1:9/6pO5fzltT8SvPuzlV6NDC2TvnfPtxMqwPnGRbKrSw6bELituvBlOgTYL3yD5TID8A8OzLLXBDhMwFKaYZOD4Pe3AteO7a7Jxth1AWpNGLhUqQSHxpS5/D7Lg4dSFDw29bAiX/JURVWez/FbcVGFG+i8lc9dP1lOd2YxJPwYJmLjdCbv3I90YLafme1aE8CGt7as8KglGKzVXchlgKCintt2tGm/cB6cWiZq7dRpqCaIpJOalxqCqQSoSjInoXTn7x93wav5uP3bPoyMU+lAFoG/NGCBrxBubB3xLu6hgJZkxDWJhvApL7F6iz3+FE50jIYKpS/OjM6KjQrMsx/umhJgy78kHVrwXdZSX1uwtlgcjb+UaeJGkQ8XtCQydRzXozC8YiSeAPEubQYbGzvZ7ZcmICTwDJDlKMQI85dzxaYZv7pR0rh8MEk81ZS00Xuug9gx0+/y85uR3hyyqjYsARpl3AJkODW+GF060hRTwZBpSD+niqf27eS+Gela+fAotWk8t/OjViyYdvtaoeO7y5KjpRGdcpZTjXBnX+d+/0= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 426a67cd-633c-45dc-60b5-08d4a23ca2da X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:BN6PR04MB0501; X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0501; 3:SrXgxKxtBn0B9aDQkI9VWzakyHYy2QXwnacCCqaLTeUCyq7vrElrgR96nHs7pJwg8ybxHGZldW8PjQdgeiIbj2XPQzz+XF1S1rQzoTZL1BdfVhU35ORQqoc5MB+1I3ffwMEuPszS8B5kXbBkJTCLisZk70IZb/JtuHW5HxxBdvP4J/W3fHKir6ahVmcJaRiUrceSgUKLJglDYTr9qv6q57vR/uEnCYg4iTgS/2O9d1NBcVudbMwEXwX00G6RVs9W1Ojgn1GT76cSM4xwsOD7n2dIYS8IrPwkAMlbcZWVa3od6NT8sDtf12R9zGQb6Ozx9n2QRg6PnOnxHry6qgAsHsJk5gYXA/2hjzY4WxoW6WMeN08D1KSt86O82IeDGrM2jzpN7+oSmhDFTdJGlU127NtT1pbmcL+Dwr30juUqf+D4zcrmC5SLeGXjsOQTL9m5cGc19TADTon45eLZ9h/g5yD/ZAME1aGpS0qq4bMVe9hFeNgI9luw3IiKeX8d/v8e X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0501; 25:+rfTQ4hhOHvyi3h/AMaXHxqwaU6XxsWcKCvoy9d41nO1V9ZI4Zu1h56JPeCoO1JhAdzqYEvc5n5kBj4rx+8qbfWUF9fSwavsyMUjJLlh/uqFTxHexMcP0DM/g75zT8XZFZAd7LBUR3B4krZFXKMEI7m5B8NMqdy79qhlQLQEwO2Eo1AZsDYc4fMFnlyXFh7EsmxA0eLgm6QWluXMjsNfnH0LgZG++qw98jD7c/4hemwIWVm0nIuF95rMFqPsYYVtnRGWRKnP53LgreQLnbDlvVayvsgRtpAGsf3RjFFdFRB7YpXzVaVEnMZs4imR+FL/vixqxyQsJfwyT+vbXzwqiNQ40ZI9JxFJtIOyb0DO4G7oMqheQH9OgzoMcH0hvp/iO9yVN80es7isiN9O/xY0qqjj88L1wka7gje7dfd6HCMmj/0p94DqOnyqg+ON+qwQUUmHzH0z87jjnneJAqajWkzi0kxY+WE4tEbTsNKJGCs=; 31:LQTpEM0wGKbRtFKZVwHDu01b3g0lMsZTapKMNfpKVEv3w99imUhu8jCRXQBnuT7Ob15tQpxQxlec1CGIKuTWFyZ386d5fyfRs5ybB/Y/tRvNDAgflMCpHayQI067LeLLXBbhY8Jxk2Z9QEISSLCrsAdDTIOC+Q9EQRrAZ1qwtHEhaYzkE7k0L7cwEksC6JRHjjr5hEn/l4YVk1+pBl4kA1T74SdTX5eqIU1/jYohCmG3vHCbbDdRGmVaONd1IbaNqTV+Fbw2VItolxbLqD0xjw== WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0501; 20:/FpTPjb4+sXEh2urui8kDYYga99nqwURK+thuNbRoZ5joBDkOS4Z8E52v/wAnYrxdhKecvmMVdkqKflHhoabhPo6pQKbW/2gfk+V3r3eOsUES+uIkhLtp76gW9dMalyxqFumf0h7mYe/Dm06YBAWp7KIhYQiEX8pFCHfOi3AiwtP58wJx+pl4jM5gb2Qg8EmoMVxNxgyginBqXVZSe9oq7RR7iWEejuWfd/JUu0XdjQPp4RSSzunmxOyLIEy1miyDHXWBgPhiC3ycm5OsDRGHmazcBTExzm14415IUzpisZ/FN0rEocFyVH+/rhygjWyZN8gDNtb76oqZ+yKIEEdwMQ1OeX3eOfeYFK8iFyXlJLg5mbP5q1rCuSAmb59aK46I4l6CA5t08cmt+H94fTxeZ2tOZOcgTe+2LliO7Agv+UN9POg1vHhozDmiJgD5lBwdD21ERlSw7rItMqaLRWPfXTNHzG3OCBOKWCsYVUqMY+y/EKx6LN4e6JNAQXwabX9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(67672495146484)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13016025)(5005006)(13018025)(8121501046)(3002001)(93006095)(93004095)(10201501046)(6055026)(6041248)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123558100)(6072148); SRVR:BN6PR04MB0501; BCL:0; PCL:0; RULEID:; SRVR:BN6PR04MB0501; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR04MB0501; 4:qoLY+r7JjMomutaPTeCgs8AkFo2Lq0vWGpo20nX/tw?= =?us-ascii?Q?ScqUUdWb8+K9C+IgIaqKE9MpSBw7o+iyulv4gx/X0yzMp1BSxnk67F80rptj?= =?us-ascii?Q?OHXIHK2Yr4FX2v0rE4QQvaqnDkeKGsan9/yf8cL93dRjQFY7EEt8m9L+eljL?= =?us-ascii?Q?7qePoeGBVgVzztLLE/EUUSuA4DL0L7A8+LShIjeZJVmbaLmQ+QIuB304K7HA?= =?us-ascii?Q?JAzZA+7fTX/8/7cSLzHQEo9txW8dZpQC/3yP9plogxisCcE4mKX4AlTHsc8T?= =?us-ascii?Q?k0zUWGuYAuDXJ0MxTX4wGHV5wwA5NMS0+EBYBNAjHlkk8OVEYeAQ8tlp3msy?= =?us-ascii?Q?v7MOTN0J6IoAQhtrgAOXReIsXJk5ZvM6vXS7KaB7CS/nEj08EcJLuA+xG+Ct?= =?us-ascii?Q?ThM83vfFBkTuSiqguq+BIg8cojI9o7DKD2e/xxiUt6g1GMoUv/ec3b8faDPl?= =?us-ascii?Q?6nBS3q3fAYhPVO7A4+lw4IboRMOVqkAlO7yDQNXPvyLIrSk2Eq25+4oQhIdj?= =?us-ascii?Q?r7jO7C5xoFIErXOmRKAKQ/Se/hEcoW0Jz71tSe7n+dvQQAjouAxatJeRr35e?= =?us-ascii?Q?MenZsm84xFR3D4Vqh5bqNH9SfAiaUwNio0TnHq7A1e558lhgCfZxC3NnBEj/?= =?us-ascii?Q?VhCi0W7C+tldxC4cL3iONhZiDKE31YH1RYcgBTLlQfZioa/FQC2Swto6uk8Q?= =?us-ascii?Q?xOI7eendu0k/ODZ6qggAPlLmn8WPIt6rM+6TeVbu8d8iurcVBjAeQcgLeHNL?= =?us-ascii?Q?GKvra4lLPnom3Nw442nE/cdXTYVO62vxPSdMO/ibdMw25L4PJmflgwGM0x8d?= =?us-ascii?Q?S5T1TMq945E/DN8ofilwh3UtzzFGcDWXDcArzB2mPboiexUTCN54VSIvoLSm?= =?us-ascii?Q?IlUeFFGUlwyYvJ5ZzVWzrHFpL4+pjnByDSQjyVS/+B6DsUz8uqdEJLP10niN?= =?us-ascii?Q?AlU0EePSezm7DdKZG7c8KA+iNtBSIhp5ycbnI57g=3D=3D?= X-Forefront-PRVS: 031763BCAF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR04MB0501; 23:Y/3P/0XLS5psBOnAhnMKIHgvWnU5/TkUD+HxUKTPf?= =?us-ascii?Q?JPoBoIdHwmrnZOzKseBxjFWAkC0J2ukyIyn6bhHpnwillMVeaZ/7PfhRFIM3?= =?us-ascii?Q?yV+XOFKEMzqwC9+Sm/un2vC6+X+BTugHOoAUeiF6okCsvfWewdnomgePZHLU?= =?us-ascii?Q?PCPWO5TZ7ZaKaikUgl0W3hmAqGFlukZstQwgIrDjBiaL8e7TdzAaATloObb8?= =?us-ascii?Q?nRWiNa6/KjKUAsB2dHRJmxY/e8tzWkmSfOYqMCKwOA2F56SSj1czjWngXCry?= =?us-ascii?Q?X1tVuyzW6J2/9LuIJgHPnNAluJiMTPgazVt1zTOoFtzW4A2m1ibWyYLpGpth?= =?us-ascii?Q?mBYKPL8vvTw7XPpBlC68puRjHkYNNNQuMOqP8vuB4K23UkWoUjpul0/FHhBD?= =?us-ascii?Q?o3qw2r6/DS3IngYQwmlt6x32h4qUhNAmNMXv6AuNWl5ZUnMZ7TSINedQF4DQ?= =?us-ascii?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XzCjJA0sWwwgIiPexmFdaITDrZM2ewlI0sY0ldb9OCilUt2rhs3hnRnRXEuanGeQvCYKSpkUDQdIsVlShXE2KUugJeYgSiMczW1xZ947oQ0fYW8TYQBBOaeeJ+ANOJMhDNyoikxnGB4RELBs= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2017 00:34:27.1602 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0501 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the introduction of the .init_rq_fn() and .exit_rq_fn() it is essential that the memory allocated for struct request_queue stays around until all blk_exit_rl() calls have finished. Hence make blk_init_rl() take a reference on struct request_queue. This patch fixes the following crash: general protection fault: 0000 [#2] SMP CPU: 3 PID: 28 Comm: ksoftirqd/3 Tainted: G D 4.12.0-rc2-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 task: ffff88013a108040 task.stack: ffffc9000071c000 RIP: 0010:free_request_size+0x1a/0x30 RSP: 0018:ffffc9000071fd38 EFLAGS: 00010202 RAX: 6b6b6b6b6b6b6b6b RBX: ffff880067362a88 RCX: 0000000000000003 RDX: ffff880067464178 RSI: ffff880067362a88 RDI: ffff880135ea4418 RBP: ffffc9000071fd40 R08: 0000000000000000 R09: 0000000100180009 R10: ffffc9000071fd38 R11: ffffffff81110800 R12: ffff88006752d3d8 R13: ffff88006752d3d8 R14: ffff88013a108040 R15: 000000000000000a FS: 0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa8ec1edb00 CR3: 0000000138ee8000 CR4: 00000000001406e0 Call Trace: mempool_destroy.part.10+0x21/0x40 mempool_destroy+0xe/0x10 blk_exit_rl+0x12/0x20 blkg_free+0x4d/0xa0 __blkg_release_rcu+0x59/0x170 rcu_process_callbacks+0x260/0x4e0 __do_softirq+0x116/0x250 smpboot_thread_fn+0x123/0x1e0 kthread+0x109/0x140 ret_from_fork+0x31/0x40 Fixes: commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request") Signed-off-by: Bart Van Assche Cc: Jens Axboe Cc: Christoph Hellwig Cc: Tejun Heo Cc: Jan Kara Cc: Hannes Reinecke Cc: # v4.11+ Reviewed-by: Hannes Reinecke Acked-by: Tejun Heo --- block/blk-cgroup.c | 2 +- block/blk-core.c | 10 ++++++++-- block/blk-sysfs.c | 2 +- block/blk.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 7c2947128f58..0480892e97e5 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -74,7 +74,7 @@ static void blkg_free(struct blkcg_gq *blkg) blkcg_policy[i]->pd_free_fn(blkg->pd[i]); if (blkg->blkcg != &blkcg_root) - blk_exit_rl(&blkg->rl); + blk_exit_rl(blkg->q, &blkg->rl); blkg_rwstat_exit(&blkg->stat_ios); blkg_rwstat_exit(&blkg->stat_bytes); diff --git a/block/blk-core.c b/block/blk-core.c index c7068520794b..55a7b76db7c2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -648,13 +648,19 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q, if (!rl->rq_pool) return -ENOMEM; + if (rl != &q->root_rl) + blk_get_queue(q); + return 0; } -void blk_exit_rl(struct request_list *rl) +void blk_exit_rl(struct request_queue *q, struct request_list *rl) { - if (rl->rq_pool) + if (rl->rq_pool) { mempool_destroy(rl->rq_pool); + if (rl != &q->root_rl) + blk_put_queue(q); + } } struct request_queue *blk_alloc_queue(gfp_t gfp_mask) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 504fee940052..2ff8842f0dc1 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -809,7 +809,7 @@ static void blk_release_queue(struct kobject *kobj) blk_free_queue_stats(q->stats); - blk_exit_rl(&q->root_rl); + blk_exit_rl(q, &q->root_rl); if (q->queue_tags) __blk_queue_free_tags(q); diff --git a/block/blk.h b/block/blk.h index 2ed70228e44f..83c8e1100525 100644 --- a/block/blk.h +++ b/block/blk.h @@ -59,7 +59,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_list *rl); +void blk_exit_rl(struct request_queue *q, struct request_list *rl); void blk_rq_bio_prep(struct request_queue *q, struct request *rq, struct bio *bio); void blk_queue_bypass_start(struct request_queue *q);