From patchwork Mon Apr 9 22:54:57 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: 10332089 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 19E6A6053B for ; Mon, 9 Apr 2018 22:55:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7CF628C09 for ; Mon, 9 Apr 2018 22:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D829128C27; Mon, 9 Apr 2018 22:55:05 +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 4DAD428C22 for ; Mon, 9 Apr 2018 22:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbeDIWzB (ORCPT ); Mon, 9 Apr 2018 18:55:01 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:56678 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750982AbeDIWzA (ORCPT ); Mon, 9 Apr 2018 18:55:00 -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=1523315050; x=1554851050; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=az1XbHfwkJa6b3PKjlqLiISOTy6AfydtI8YzEay5rq8=; b=YVI3DWeXM9O7rQ18kc5nRfqg7yj1lHi7FH6xd6YKOONzGxMKIuFGvDhu A+7QwY4UILQPT/WwSORDb/atTnfXQkxWA5sZImlZWHL5yN3+L17QV0W3p /kvUa1R4kv+Gec1UhwoukCp61gN7Lf1ndbs4UWainFJ1eTKrCmCFKeJ47 UUYe4FE4VZiCM9IlhIp1JDvLfxAV8MekiNdvo7HKxIUO5azdcwN/HDzwP 2yZN6WXcCX+dU+xQ0+egT0q7MjwDwpUNgF56/gphY3wIroPObs/dEjE7f 7WxF6QrxtbIzAI+1RGCqJB5etutDvNI+thLQ1AYienQSJ/16bdYJwqwY4 Q==; X-IronPort-AV: E=Sophos;i="5.48,429,1517846400"; d="scan'208";a="172177539" Received: from mail-sn1nam01lp0118.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.118]) by ob1.hgst.iphmx.com with ESMTP; 10 Apr 2018 07:04:08 +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; bh=az1XbHfwkJa6b3PKjlqLiISOTy6AfydtI8YzEay5rq8=; b=ZOy5wWZf41OSKcMGsacDxqlwqhniEqLdUrN7ifay3kpBiWxog/5WUNE+7mIDCk6d4oPLfNXnqUxS8jX6uLhkNP0AFUzHKLuySSrB3fynngrZOfelZYMRK8LAkSouihsAq50MhLxohpM/C2avkJQAdGYBqLVVjYPH3eniP6MEwi4= Received: from MWHPR04MB1198.namprd04.prod.outlook.com (10.173.48.151) by MWHPR04MB1038.namprd04.prod.outlook.com (10.174.250.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Mon, 9 Apr 2018 22:54:58 +0000 Received: from MWHPR04MB1198.namprd04.prod.outlook.com ([fe80::bc43:e461:43cb:4d27]) by MWHPR04MB1198.namprd04.prod.outlook.com ([fe80::bc43:e461:43cb:4d27%14]) with mapi id 15.20.0653.014; Mon, 9 Apr 2018 22:54:58 +0000 From: Bart Van Assche To: "axboe@kernel.dk" , "joseph.qi@linux.alibaba.com" , "ming.lei@redhat.com" CC: "linux-block@vger.kernel.org" Subject: Re: [block regression] kernel oops triggered by removing scsi device dring IO Thread-Topic: [block regression] kernel oops triggered by removing scsi device dring IO Thread-Index: AQHTzvEVSGuTDcM2zkK3qfeX9OrP7aP33eUAgAAjWACAAQxqAA== Date: Mon, 9 Apr 2018 22:54:57 +0000 Message-ID: References: <20180408042112.GB19128@ming.t460p> <678220c26fa1677ab162006620b345ea4f38c86b.camel@wdc.com> <44abf88a-ded4-bbf5-8410-6692ee5ebabb@linux.alibaba.com> In-Reply-To: <44abf88a-ded4-bbf5-8410-6692ee5ebabb@linux.alibaba.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [67.142.235.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB1038; 7:HqAvYfeeWEbgtmnLvztoss65AC6XOdwIUAohoI3hCHfPvsUJm56TjAW10y7UO8ZcsDe6Hc5AjgJE8Tchf6+19Ld+WAzqvwR0+f6DwpHijYL8p+OtZtm2edfIkH9rVyWs2ETWBIjG9Y99PwurP+5XXgBSejSpv0NW91f/4HwTt13XLORQoWyv2kwGsjAqm3Pen2qPnbjDD6uoJJfRvD1MZByrK63RwqCxufDX/yDq2yo9yYafm9DDpBaVG/PsYa+6; 20:EgSXZLlLvbY1TRpw6UvtOiMDZkvTiC3RAbs9RSf+wYwUwYODrc4Hgelje68VpBmq5afz95z7kJu+pCOWzPZeUVfvtzTBbuvQTVeqJsIJ63HWRhoMSGezAEMsZ4UUBBfCO2FVfKxLcTVpfV9orbv/ZTchwRpwH2JQNeY398caN2w= x-ms-exchange-antispam-srfa-diagnostics: SOS; X-MS-Office365-Filtering-Correlation-Id: 0550127d-653f-49a8-4bfc-08d59e6ceb38 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB1038; x-ms-traffictypediagnostic: MWHPR04MB1038: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231221)(944501327)(52105095)(10201501046)(6055026)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR04MB1038; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB1038; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39860400002)(366004)(396003)(39380400002)(376002)(377424004)(199004)(189003)(102836004)(81156014)(72206003)(97736004)(6506007)(8676002)(59450400001)(81166006)(476003)(6512007)(99286004)(26005)(478600001)(11346002)(446003)(53936002)(2616005)(6436002)(6246003)(36756003)(2501003)(486006)(14454004)(5250100002)(6486002)(25786009)(186003)(2900100001)(6116002)(106356001)(86362001)(68736007)(3280700002)(3660700001)(3846002)(2201001)(118296001)(8936002)(110136005)(76176011)(305945005)(5660300001)(316002)(229853002)(7736002)(2906002)(105586002)(66066001)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB1038; H:MWHPR04MB1198.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: I15+ZkRZK2jjcxnLJnpmbG/uQLCjHMNfBQgsCuf9tHe6Mp97B2sCt5umB/CJUzvMdwd7VYmgmOXFx4jZJ4C1DrQ3CL9TiKzksgvoYHF/cilsw7PIYb90RN9h4ZGN/yYq0q/UeP2PctkESq0JLFh2u9FAH9orKomT9gddPZ/KXFcdTaeEhufWUCxdBGh/OSVkQgdx3yHJmUrzPM5iNWA936Ye1GKWRaUtMLTT8QoTvP1nIZE3X/OFaH+RQLZu5TJUxsnhQ/AV9u74w7t85ATpGCLlNGMBK2sqcZD84JgdkRwA/I2LkKue9cmV4HRJDarsXnePTjkJQxRlPPSm1hXznASvtIkQOkMXXJoQ5Xx6H8r54dq/WxKOHZMzx4me0/aNCWsX/hc394nfd9M5G1vuIMvGQU3FOLfdYrXExFQzJZE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <1E7430A8D28E3E4183522E39DF64D48B@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0550127d-653f-49a8-4bfc-08d59e6ceb38 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 22:54:58.1535 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1038 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 On Mon, 2018-04-09 at 14:54 +0800, Joseph Qi wrote: > The oops happens during generic_make_request_checks(), in > blk_throtl_bio() exactly. > So if we want to bypass dying queue, we have to check this before > generic_make_request_checks(), I think. How about something like the patch below? Thanks, Bart. Subject: [PATCH] blk-mq: Avoid that submitting a bio concurrently with device removal triggers a crash Because blkcg_exit_queue() is now called from inside blk_cleanup_queue() it is no longer safe to access cgroup information during or after the blk_cleanup_queue() call. Hence protect the generic_make_request_checks() call with a blk_queue_enter() / blk_queue_exit() pair. --- block/blk-core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 2.16.2 diff --git a/block/blk-core.c b/block/blk-core.c index d69888ff52f0..0c48bef8490f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2388,9 +2388,24 @@ blk_qc_t generic_make_request(struct bio *bio) * yet. */ struct bio_list bio_list_on_stack[2]; + blk_mq_req_flags_t flags = bio->bi_opf & REQ_NOWAIT ? + BLK_MQ_REQ_NOWAIT : 0; + struct request_queue *q = bio->bi_disk->queue; + bool check_result; blk_qc_t ret = BLK_QC_T_NONE; - if (!generic_make_request_checks(bio)) + if (blk_queue_enter(q, flags) < 0) { + if (!blk_queue_dying(q) && (bio->bi_opf & REQ_NOWAIT)) + bio_wouldblock_error(bio); + else + bio_io_error(bio); + return ret; + } + + check_result = generic_make_request_checks(bio); + blk_queue_exit(q); + + if (!check_result) goto out; /*