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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fhTDL53xU8xl1SB3R12w/CTQuTBI7zF2B2eqlYdv5osuAnIlmHEziIRzfJ9crqajx4aMN6t2xzSCe8n1aUXtnl/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);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:kVnuBHqFsA/fHxGe9flc6I0Ubipt94SopkprZaCb0vAm2JZVDvWz1tbn8XatjzozPYE48f4cNI1r4SRy5FiLE7itSVrAjO/A9MIMHTjCW7vn8SbmiK/RU/EZCIjxoGw0lAiX1SSk6TOWAoFdA0I3O1Nyj4Lvy8JPXSBcmFWtQ6cBXjB7cNdL6piiyGCFbq/VGcfCF76Q1AM5w/SggxZ1+JPgz6rT5Yo7Y7g0aS1J2ro8wH/illYv3HVuzJk0pRqbCcSrVzRpiVhqDLNqst7FXjrR1xwI8YeU3U1blE9ShSoDZQ2n6buAEspBOLszOO3OfGKv0NJj6lXRHNEQUASPiYFulEEKljwdIM9B3Essg0csN2d7sH0/NsCEFziYhkzAJJDLBCFedxoB3AI/23SR19JsliZJDmroVspsHRTFSMkPQWuc6FyR8KMiaTz/Wr2cUvjAkyBdTfYXEwr8fbuxtflBrqUm8oJCMReiAzBs1l1ApiLXagbp9Nt+z1ts4pNUt9yVVMtV9Zp1mgKOMf/TtE32MNoctbM7noY5mttH8yQ2UzEOsIwDEOrfCZojkZ73tVuHFS42lhMSWVNpXUAb57U16jcSqJNibUHT/KFuk6PZA5HnNU0751pbfCHv11++dfi4l8lmdlo11SxT4qws3QM+WNdUjromn6AHOKK89grBahduGi8Qto0LzZTzE93e+oCWRw4yqsbpZD9aLEccNBOa/FPmUz7xxhj0XltiqN5aDv2eftre4RRw5W8WMOef++oF3WpGjk4P2ja3qQeQfpbF5y5yle3ArvWIADYKMQClxMTKlNnEZFB9W3IiN/iSBJrxEk0k06SRBf7XSaRAPZqHc16umT7sBxV8RdOvxuCmEKnFMpgz4hfhbBEK76st6SOGEvqVmbQErNbnz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V7chtmT0qoSMI0fg+ctfkJ2QRHoocftovJoscbx3+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);