From patchwork Wed May 31 21:43:45 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: 9758205 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 EA2C660390 for ; Wed, 31 May 2017 21:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC71F1FE85 for ; Wed, 31 May 2017 21:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1216284C3; Wed, 31 May 2017 21:44:08 +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 31DE51FE85 for ; Wed, 31 May 2017 21:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751090AbdEaVoG (ORCPT ); Wed, 31 May 2017 17:44:06 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:54498 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751053AbdEaVoD (ORCPT ); Wed, 31 May 2017 17:44:03 -0400 X-IronPort-AV: E=Sophos;i="5.39,276,1493654400"; d="scan'208";a="124437105" Received: from mail-bn3nam01lp0181.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([216.32.180.181]) by ob1.hgst.iphmx.com with ESMTP; 01 Jun 2017 05:44:01 +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=WsmRElRjKX0z67ABZMY0I4cOkshiNDRFtv6IM2CGE1k=; b=cQrA+0ad//NUUbFa0BH7vG7ms1LDLyK4ZGgX5dx0u1WqM9TdTcKFR7d4H3lQ5DTudRQSKVH6tbnGfKa5tuIMPQtG2H947HQ0LHopX2q1o+wXDCIGPXj701vW4B2n8OpTDsccDBzzow1rkrpSTNNeYx8K0CLd9hti7azFaDMnYrQ= Received: from MWHPR04CA0053.namprd04.prod.outlook.com (10.173.46.15) by BN1PR0401MB0914.namprd04.prod.outlook.com (10.160.78.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Wed, 31 May 2017 21:43:57 +0000 Received: from SN1NAM04FT006.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4c::206) by MWHPR04CA0053.outlook.office365.com (2603:10b6:300:6c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10 via Frontend Transport; Wed, 31 May 2017 21:43:56 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; lst.de; dkim=none (message not signed) header.d=none;lst.de; 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 SN1NAM04FT006.mail.protection.outlook.com (10.152.88.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1101.12 via Frontend Transport; Wed, 31 May 2017 21:43:55 +0000 Received: from MILHUBIP03.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 F4.22.51736.A193F295; Wed, 31 May 2017 14:43:55 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Wed, 31 May 2017 14:43:53 -0700 X-AuditID: 0ac94369-36bff7000000ca18-b9-592f391aff31 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 69.DD.18148.7193F295; Wed, 31 May 2017 14:43:53 -0700 (PDT) From: Bart Van Assche To: Jens Axboe CC: , Christoph Hellwig , "Bart Van Assche" , Jan Kara , Subject: [PATCH v2 1/6] block: Avoid that blk_exit_rl() triggers a use-after-free Date: Wed, 31 May 2017 14:43:45 -0700 Message-ID: <20170531214350.31157-2-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170531214350.31157-1-bart.vanassche@sandisk.com> References: <20170531214350.31157-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJLMWRmVeSWpSXmKPExsXCddJ5ka60pX6kQctsUYvVd/vZLFauPspk MXt6M5PF3lvaFgs2PmJ0YPW4fLbUY/fNBjaPMwuOsHt83iQXwBLFZZOSmpNZllqkb5fAlTG7 Zy9rwWP5iuYPm9gaGH9LdTFyckgImEh8eLaGuYuRi0NIYCmTRPPJRewQzjZGiWs3j7HBVH39 MpsFIrGZUeLP4o/sIAk2ASOJb+9nsoDYIgIKEj2/V4I1MAssY5R4syMMxBYWCJQ4Pf8yI4jN IqAq8fL2f6AaDg5eAXuJM08VIebLS5zdspMZxOYUcJCY0vEMbLwQUMn7+x1geyUE+lglju+9 DjaHV0BQ4uTMJywQuyQkDr54wQzRoC5xcsl8pgmMQrOQlM1CUraAkWkVo1huZk5xbnpqgaGp XnFiXkpmcbZecn7uJkZIgGfuYLz7xPsQowAHoxIPr8BFvUgh1sSy4srcQ4wSHMxKIry+avqR QrwpiZVVqUX58UWlOanFhxilOViUxHnPyUyNEBJITyxJzU5NLUgtgskycXBKNTBa/4kOkbgU ZlKWtqxULz4vLGhJw97rFpVSH+d91d5dedx5bVLp1ocujOa3tmiG3zB+niEl+1/10brUsCuh bxuuu1zcb1C5xX+lUrzkfsZ0f2ee9axfvt5mCLPeUzlhXXFoXpO6hKWABcfaZZsjkm1z5329 U7d0whQft5m7RXn8JHlX1a2rUlFiKc5INNRiLipOBADwGCXIbAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFJMWRmVeSWpSXmKPExsXCtZEjRVfSUj/SYFmHhcXqu/1sFgd/tjFa rFx9lMli9vRmJou9t7QtFmx8xOjA5nH5bKnH7psNbB7T1pxn8jiz4Ai7x+dNcgGsUVw2Kak5 mWWpRfp2CVwZs3v2shY8lq9o/rCJrYHxt1QXIyeHhICJxNcvs1m6GLk4hAQ2Mkp87z7DCpJg EzCS+PZ+JguILSKgINHzeyUbSBGzwDJGiQ2t69hAEsICgRKn519mBLFZBFQlXt7+DxbnFbCX +LTrLjPEBnmJs1t2gtmcAg4SUzqesYPYQkA17+93sExg5F7AyLCKUSw3M6c4Nz2zwNBIrzgx LyWzOFsvOT93EyM4NDijdjBen2h+iJGJg1OqgVHu2IJnt413hbAeP3XR7sMGqT2xPOmq/75M U05fpRpuuvPTx+VHfv5wsOop7j1eserN9iOXhTMVHnMqMapNa63u/b9lRRzLW0cxxomBbls4 Dx6Y3Ny2OklBIjWvwL5164T0jouqte+W5h15fPPNSo2r0fMnKTQqPpsck6GSUGh0cvKu47N3 KXgqsRRnJBpqMRcVJwIAthLWlb0BAAA= 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)(39850400002)(39400400002)(39410400002)(39840400002)(39860400002)(39450400003)(2980300002)(438002)(9170700003)(230783001)(2950100002)(6666003)(2906002)(33646002)(77096006)(6916009)(76176999)(54906002)(5003940100001)(50986999)(356003)(50226002)(72206003)(53936002)(4326008)(36756003)(575784001)(86362001)(1076002)(38730400002)(48376002)(8936002)(110136004)(106466001)(50466002)(478600001)(189998001)(305945005)(8676002)(47776003)(5660300001)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0401MB0914; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM04FT006; 1:x9ow3rct+4jtnkUzQVlPckO5V+RvWroRUV6cnCtU+9XJyKfPvVxP/nwZMfraccAI015o/sf669Z3FnMIg6UmQAEu6dPgMwCmZx9pbXWX5hUOI6mVvkHPk7Z8t8n6eiwwoxAENSF5YVWjMx0nEl2ETm9FeVSlXCrkyAuCWPCMMzgzwrwBfQvDn0/MjUcdPKDss+4vK+fMPRwVC0vpDWSWThJsahW9SwiDljE0l/lx3oeaC70azu8PPNUZezNiCzXLeulYx6n4fskghhscN4OsbHmv1pQA60LqMRb9mgSWCud7NOxuOVUYT/d1UU/BoELJ0qSHvsIVr1+/dVvHRzf0gnKIEoH3Qy0lL2C5rD8ANJU/t4/lrbzt4/bNLrbYBNyQZbMWZlYA9tte4h6Y4oNSWFkhOzsbd1im6iNMVY1/czoVwNHXrVNSEFBNSKIgQz0VG0mwRUr7M3of+IEkG/BnATrwAdSKPXMB4dKb4nqkQxZRDsi3nuL8Dck30OOfIK4Lh5QRTHsZZHCC63j0RF/pJygjKp8mwZIbCvA3qq3KOsmNOyosbvN4s3Nykl7Wy2Qg X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PR0401MB0914: X-MS-Office365-Filtering-Correlation-Id: e2aefda0-cc27-44b4-c0f6-08d4a86e236c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BN1PR0401MB0914; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0401MB0914; 3:W/sN3BSiQvACMokqBSkQntE+IXeE+lcLATFoFHLCgmcjgTchmwIFwxRknDgzcXBTqWB4jxRSokji9tx18dS7JIgpCUC1KF/y+uCOhuzRHFo/YvJBNOFtaBkjXFQ2RD5ETLh8okeFQpE+kPatayAewDQcXuMf5P31gz9chzg5a409jOfr0qwAPdOuUo4pDs/FLR0LiLw7/ZRqnQj8H2uW6lK/QQAdLcEKOQeU85x7LzFDfUypXYtM62M8sCCzqfbHTfqP3ZpCa28IEdi++oirx+PNjVb/7B013dgYQSMhAR+9X8R/vI3S3mBIAoDcbH4yRSFlM/De2QF14t2noYp5etoG7YVZlAbDkV99vUZeBvXt0FvqZkTTn6zcnNnJoR3ax/zFQYEm92yhmzmZon7KGXV0rHTN6rgrZsU5nLiddOJEaseXFkmY8pPzdP9iwoh6H14sCRZ8yy526m6yiapuWIXSKl0HfJ/qIk8vM4o9tyiO80wcfEEmVFp5q0oI0ogMtYZlBGIN8tE4G7iM5qHETw== X-Microsoft-Exchange-Diagnostics: 1; BN1PR0401MB0914; 25:Hq/yTDqq6bR4vdyyy8qJ+Uy8UW/IfQqcBjpLSqOFYD84W/j/aQc8W+jrVgidxlxop9OSaK9k6eBRpTw+OHPVRJ5E1TM5X+ic7QSdu85Df7XfI7PlZrNN7YCNnyoW7ywXA8g/bsFVqPOOO0KeemBXuEZ7AStjFpgc2MoF7uUdlYsIa/vFgWMvUqAl2FybpuVNFOsQJD2UQC8yqY0ZPwBt+S93p8i4+wKtpGWOyXchmLe9vKftchBmmE/eBKaRf/zzAWKCoCSE81VPMEuqoTQV60/msFBrImApHPBak1sUUo7LEYPYAaF44Vr2PbaaXSBB0nFXAKQnLZNVlTyWHviDS+53hf9fgvsRI7F7am9atnBxxyb0eY99Tozz2tl0S20gQWgw0HdF3ovd9FHorGs+Af9ay9wAQ+Ol5Tii1GFWheAu0x/iPkrosjbMqs/XT2wWz1HwWqZ8jfyXpVQ8eXnbUeSbyE93PlnISzzod5Fs6aU=; 31:s2CqL34KrD4czfwZ45sR0JBcJz4bUsgEuCSO/f4FombquQ9kYKTz3qrBGRhhbqJxW3hnzKTF/dgXCkx0NTnSX6phkJTW2JDlhusBVWumD6EdNGqyiJBXT/kfqJEh1nU1w/TiePAScQog+Ro/aXAhADFG/Az9qcgZYJv7H8rDjJF6JL/wLz73jGuFmf5AG3Bn20hO1QG0c8SlRUDmrFhcvpiuWsvuv9t7t5P+tq/lmZ2t8LFt5bAYwR1rUq+f0g4zrkTdnq4JY1svVyV+cetmUQ== WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN1PR0401MB0914; 20:RYAN4Nrzt715UHzvFJLsGHMFf/OHHmS7F9zdhpwkrtQg5k5M7EcmufDuki2Pkwg/OU8zFoSrrvG9PxhlbZZ4vq93VuLf4E462uBORrDe5OYZLvk1QPYPjG3yLAUQ9s0XTcbuBSDN5QDJ8AIDp5oU4Wfok4QuzKaWjxG/vsH7Pyw/bpusVCoigmrPRxNg3G3PAfMzds5P9wUFp9hrrrO6GBb5YhQl8Wf+fT9BAgyn04XfQ2itEmdQ/c3/Vi2+TZ4aFJ82MdyQjHm4teDCN55OuuXfxlMbnNQXCWz+MbDsUY860LVykqE95Fj8I+DjqXhhpYx3tKTqt8mQPn1cSqTHcv3oNcdc9l2yvjjw2q+VH4Uy0YeijlAfXPWRGAxK5lzKNEs7kkd1gIG7SA7HN82pgo8E1FjEsFzTqMTwYdCnQM1Cu3v7cQkd6gxWOET8zht0vSlpRb2pn7E6tnwmL4CnURHPWAaOQPzA1oFJoEmKzm6874sk0z9dJsWvs2R8rlHM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13016025)(5005006)(8121501046)(13018025)(3002001)(93006095)(93004095)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148); SRVR:BN1PR0401MB0914; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0401MB0914; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0401MB0914; 4:sKBCJtgF0SKXaExBjctMVmIwiwLSJAUOFHHSwI7j3vObgLDAczJebvvqN//W4vmWzUeAtjE32KaMBTGXGgpButiQnXYxTZevQIzRTTQBnmLjMPQBtt5iZ036xA5aa8wA61rKus9xGCWQ6vDFtbP+MxMzyxsB3grofsVdrAf6qnwAblAW6OgNoOwK4LDXWqf3lqmiZBlVmd/6gB1FnesxsVG+mitWCrZiZAHow3vlvJEBz3HSnqDzokrDv14xcK3Fh3Dwbq8Ea5XRJuREIWwsno3hwZfuSAHk3febDgt6Ut2HtgxcoYFlgtjFcHcipeQIeTtzgKaxm9gJ3jTxNC4n4qPSIhuSZyg416KiXKiDsBTJmTNvY+eQFaSDMLHE97D3lDo7eFPzcfRlTwrxfRJ/nlCYzfdSxYqkShCVIa+Lgg48Bg/trbE+8laxMfuSkMeRmqbSIh17mRDeeeN1RQJIsKCYuLbHszdkgDQP55WWjlWEdgBHoRvLMio+urLKx2ljheBz3/f60C+RJB3/vTxoYdo2w5KSRQms1WmlrY0eESaPMePj808+pDtDZpRblLmw382weHRi7FEqcjejFZoUTE+xkYsjKB06gVvqXL147DkGUE/Mvuj3mOJ8ix1kvY1m32ZiJHmAjPs5D3FPMqgtc9QGsjk5CmrcRBK8ZEje8ZDYFg1S2HEo1MHDEeZqW3+CNhJmsitq3yHnqlzinObKEe6l9AzH4wUUUlKmcgHk9Jc0Tola5usmiIydjVxoz3yGePzI+K13CE/qluHnE4Uuszo8sqHZiXXbG2ESarpl5ZiYjRdHkwnAvoF05iobZSSx3SQ6tWWfO/l76nwFYeLCwzctzM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mlB0gEi6p9w8xzwMtQvey1+Cfu76hEeuvEPeKLGtQ6kDIa+8XbFAjJ3lOOfj3hh7+rdMQGLkxMqTIkxH73Sl14AurG3m75b/dPe+R0QzTpnc/mDyPcSdnPmt2MmUVbeR0cr8Yw==; 24:WNQ+8rLK34YvLUO7eeSVx3El/W+9iSqZsijDKVNKnMRdMn2fXFGjtbwyaIIus9WmAf3PkJjbDneM1ZZB5/nV4u/ZSmFvEy0B44yhh6i07+o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR0401MB0914; 7:TGOPkrqL0FTA5AplyPqR9q/cCbdf/pbuZB9xI8Sun0bXeOwIYrwmbVdMeub2yRCSmVPPI6tikguK65cm17H1hGRCFZGOZW4XE3U4eonXXZjohOX5o3mwYsQGKGdTHrmv38VbTeMN4qt0Snq8Nj6svUIpG50qEZSd3waPuJymQRLp4HTtrx7w7qqPLUusL0hWcJddFc2OlIGEi2UBMfFjc4j66TCy8JIiLd3rzCt3BSNAHcqdg8QyH2uTUcSplGcJDRP/2H21Wr3k+qWXMaoeY/5C7+Owk7aKSakNd2GG96NzF7sqcz1nSCPRv/L9yPudq0zLf7ylcyeiCgwzu3tEXg==; 20:X4ic3MC4UvZwnlja4bzawDX37GSGzIwf5LvXjQvKBSzyc2CPRziL0ZSo9QOaDU6wrNLBP8iHvVaFCAkvJwaVFMNGlEKr1y2zfjGDXuFwWeVeA9dO2uRyebG/ypUVW18iTbeuEzozSD9QC8KW8699Jn+1XP3Ofa5GxZ2ufdUhXV8= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2017 21:43:55.5437 (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: BN1PR0401MB0914 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 Since the introduction of .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 Acked-by: Tejun Heo Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Jan Kara Cc: # v4.11+ --- 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..a7421b772d0e 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) + WARN_ON_ONCE(!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 712b018e9f54..283da7fbe034 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);