From patchwork Sat Sep 19 00:23:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7221331 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 46FE7BEEC1 for ; Sat, 19 Sep 2015 00:25:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F1B0209AA for ; Sat, 19 Sep 2015 00:25:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F5CC209A5 for ; Sat, 19 Sep 2015 00:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754053AbbISAZQ (ORCPT ); Fri, 18 Sep 2015 20:25:16 -0400 Received: from mail-bl2on0100.outbound.protection.outlook.com ([65.55.169.100]:39917 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754078AbbISAZN (ORCPT ); Fri, 18 Sep 2015 20:25:13 -0400 Received: from BY2PR02CA0120.namprd02.prod.outlook.com (10.163.44.174) by BLUPR02MB1249.namprd02.prod.outlook.com (10.163.80.154) with Microsoft SMTP Server (TLS) id 15.1.268.17; Sat, 19 Sep 2015 00:25:09 +0000 Received: from BY2FFO11OLC002.protection.gbl (2a01:111:f400:7c0c::109) by BY2PR02CA0120.outlook.office365.com (2a01:111:e400:5261::46) with Microsoft SMTP Server (TLS) id 15.1.274.16 via Frontend Transport; Sat, 19 Sep 2015 00:25:08 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) 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.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BY2FFO11OLC002.mail.protection.outlook.com (10.1.15.178) with Microsoft SMTP Server id 15.1.274.4 via Frontend Transport; Sat, 19 Sep 2015 00:25:06 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep11.sandisk.com (Symantec Messaging Gateway) with SMTP id 04.B6.04667.16BACF55; Fri, 18 Sep 2015 17:25:05 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.248.2; Fri, 18 Sep 2015 17:23:42 -0700 X-AuditID: ac160a68-f790b6d00000123b-30-55fcab61ad32 Received: from [10.60.52.33] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id B8.7B.03643.E0BACF55; Fri, 18 Sep 2015 17:23:42 -0700 (PDT) To: James Bottomley CC: Hannes Reinecke , Christoph Hellwig , "Martin K. Petersen" , "linux-scsi@vger.kernel.org" From: Bart Van Assche Subject: [PATCH] scsi: Fix a bdi reregistration race Message-ID: <55FCAB0E.3020707@sandisk.com> Date: Fri, 18 Sep 2015 17:23:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRmVeSWpSXmKPExsWyRoxnkW7i6j+hBif7DSz2LJrEZLFy9VEm i//rb7NYdF/fwWax/Pg/JgdWj903G9g8Dv/4wezx8ektFo/Np6s9Pm+SC2CN4rJJSc3JLEst 0rdL4Mq4tO00U8Fd0Yqrv1ezNjC2CncxcnJICJhIfPq9hxXCFpO4cG89WxcjF4eQwAlGiTOL fjBDODsY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TzN/OHm9yXPIh7lBofN +s30M0vr8D+fuD1VKzOavpcEaJ7azjU//ylPCvOnNb7f+iax867Nj6jg8lKMWMeyu1vB5avY jnB/BkvP0NbZEZta7ZTdrtxRCcuNWMRV0a7EUpyRaKjFXFScCADuRo6V9AEAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC002; 1:KgeLRx8zh3gqoXYYbAxxSjjbmUXNP7HdbksffYfpyWvM/trnMxULVTc/mOn2Jlzcvj+hMhnG5MRHkuhxCWQarEqKmzJcvPT0PhGB/1L0vA6LT9TQuRgS4ggdOyj7UaMV8UBj7ZgnkamZlFhHfHzeeLPvOKIZP6pR681bgZSxz00xEjONUscRmHg/3ztrWXP14lofO7blJsvLxk/4F1nrOLBLgDdCyq+MtlfstDdGqlVw1hTCQCzb7a7AseXBwiku2/iFRsbLXWQr+PAuRCFXXpPgSapmIqgVhyPDb9clQbdBguEyXI2eC5HA58JrNzsgd5qAUz8y4fRCKsnn7kYf8DOFtQNSc5mC/ObcopQEtC8IEvkZoV54jm9K/cMbsdvh+QyHhG0v5p3dvaxc2hN8BQ== X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(51234002)(189002)(5001860100001)(5001830100001)(110136002)(81156007)(64126003)(19580405001)(59896002)(50466002)(54356999)(33656002)(189998001)(77156002)(62966003)(87936001)(65956001)(5001960100002)(47776003)(68736005)(77096005)(36756003)(11100500001)(64706001)(5007970100001)(4001540100001)(92566002)(46102003)(83506001)(23676002)(97736004)(229853001)(4001350100001)(65806001)(50986999)(87266999)(86362001)(19580395003)(69596002)(106466001)(65816999)(80316001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR02MB1249; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB1249; 2:eQQC3t10emRrEruusIYUFvKN884Uv5LK04u1VJL2GsqTQRghw+YjcM9ci0SpK6mHCGRw967GS97wnZ29+80+WewgpcesBExCMgr7tWd7ceHZw+rqTFUhTDvWvbvyEDFGmlp6EftKuTMCwHZyF5jf3tmf+yAeceErDG+ElasElIU=; 3:NgrrZLgXIRx8wX73bSt5IKZbpo0ATrOQ2Z9NHR+qom/nSuOI/1FPJwAcf9mkTmhuR3XJQlImmvmZtTt+Wj9JImIpAM/NFpBIyNAmNCaIY7SO7tSh7ASoxz8lWvZPqYMNIXMeGN8iMOsPmB8k6iKrfyUhZSwPrqzl1O9A+xqmLqNQE+GFKprochd+r10DbCALeN65CGPCN4OFDrsEQvxCNty+4RzSnxx+D1sGQNgniLv+tBnf9BDCoBJLZ3rICB1jrNfNoBnuHxy14je1g+/n2w==; 25:7XoNbxn6vBOxM5FCfjYRWAC2/3aDZNRMkF9G9YpATqk7i7hbVvWIsXotVQVB6Zmofd63WOehm5TFwHHE1CEnMM5tXMz3QucHBxNwWjmL/oVb9ewzkD4iTCO5qEkr9AueQexuXzPIWwKRql3lcM289UYhUqqcfbN63E4Reyjq7vQTRpysqNvt96lDolnHSdcburblpBb+6QCE0hUb7L4FIE0T2l+8bbwGXq3EhqS9EEAHjdZU/bMtdlnnyE8U8YTCqu34zc++3qPmLLmXEvVdUQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BLUPR02MB1249; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB1249; 20:SMtGGu8zMYKtQc6Mwo6DDEpd/sBp1lREngnfzqLtEDvq57ZYFbTj17PMpde9Orp+D5DTKBexmVaggFNnyuSRYwiD0D6KTCgL1zjRDcLMHoytkhO1Svv2nGwSvYNf5SLiNAJ/MYeNGyS2yNMJcvuQEyizGqXTxECyCWM4Xz8mRhGDynCZDFPwv3enlClOSL1BE16OjIiPW/eiGtd9n3krsLVCcVYgPPAyPuWNF/Jp+zUZYhksytHI4HJSh/TyUKYLl6JkBjVYPkunNajj4KhUwfwEXTItbIM/tnrd5vI1ecsi/+DS6+h8b8D19F2/ww+nNH2FWZFiTnKGlP4KOIPl347ur7LLmkWxx3ywTktdVQWX0DV8GR6eNFxslIYrsArqL+kXs4b4ytMPqzM7Eod6/fPWpb7SB6qJby/y361HahDrhKDXXI4oLFse+KRjE2gKMVsY/qHGgInIXQKi5PS2Srrvmh67e44bnRYd5VP1eXFSuVsrIoczDelST5P4oYzu; 4:EksfSHaY9GFRlcVOflMzXbWC2NpItwlkrYui1WMmEGEIRxVHrZkHhTVcEV5GaWxzSm+tOdZoqRo+Qp1/rFQQdnfE4RFoflq6gCE5NTy4H7aaFVXbrNdWkifsKsZ/jses7kaiylQrm1ZNBt9uFBtgaoUJFvUeWKo7OyLO5P5Ek1Is9xNMdQUqBPEjqJ3VeUb6LKY7604zXg+aNLnkrY974E7A2zlxp2DYU5PtROy3R6P/eEZHNNz+FUcuUdyF2ocI7gfYpc8goHeuHz9XeqpzT+sE/w5L7hUtJHLZS+aQDZumFWxRNm4CyYEuUexrm7/DpFY1IasMRup5FC+fOgpraWKhlIaw1hb0wFUusyRK7YI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(520078)(520075)(5005006)(8121501046)(3002001); SRVR:BLUPR02MB1249; BCL:0; PCL:0; RULEID:; SRVR:BLUPR02MB1249; X-Forefront-PRVS: 0704670F76 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjAyTUIxMjQ5OzIzOkFSUzYrOEJZQ1lHWUxobm5hSzZDMlZrSnl6?= =?utf-8?B?OUNUOG5vMEloWWQwRVJHdTY5UFo2Z2Z3TktEREY5K1RHeHV6R0MwUjUyUzhG?= =?utf-8?B?bmplaVB0bVR5Rlgrc3lvemRKZXBhajNFVzZqUnI2NUlsZWJBNDA2STVZb1RI?= =?utf-8?B?V3RjWHVmM2p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oyTKB0x66jGeYo6lMa23bKMke9YvKDuM55bnHA4HsezZ4lnH55nYQaUGVMtNYbrjD1CyVrpO/D4epzE09YkP8oUuIwo7YVhRbPFOOuX9iF/Ujfcoof1GeU3gCxG6cByjzXiwvkBcbqUinfyxE0hYJLhnDqirNDmra3e7W3ms8JnWQqw+gzGL99FhFPtnIStNhEKBYB2ykViA9khYCDI6E5P4zL SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2015 00:25:06.2451 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1249 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unregister and reregister BDI devices in the proper order. This patch avoids that the following kernel warning can get triggered: WARNING: CPU: 7 PID: 203 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x68/0x80() sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:32' Workqueue: events_unbound async_run_entry_fn Call Trace: [] dump_stack+0x4c/0x65 [] warn_slowpath_common+0x8a/0xc0 [] warn_slowpath_fmt+0x46/0x50 [] sysfs_warn_dup+0x68/0x80 [] sysfs_create_dir_ns+0x7e/0x90 [] kobject_add_internal+0xa8/0x320 [] kobject_add+0x60/0xb0 [] device_add+0x107/0x5e0 [] device_create_groups_vargs+0xd8/0x100 [] device_create_vargs+0x1c/0x20 [] bdi_register+0x63/0x2a0 [] bdi_register_dev+0x27/0x30 [] add_disk+0x1a9/0x4e0 [] sd_probe_async+0x119/0x1d0 [sd_mod] [] async_run_entry_fn+0x4a/0x140 [] process_one_work+0x1d8/0x7c0 [] worker_thread+0x114/0x460 [] kthread+0xf8/0x110 [] ret_from_fork+0x3f/0x70 See also patch "block: destroy bdi before blockdev is unregistered" (commit ID 6cd18e711dd8). Signed-off-by: Bart Van Assche Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Martin K. Petersen Cc: Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_sysfs.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index b333389..5e085d4 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1084,9 +1084,7 @@ void __scsi_remove_device(struct scsi_device *sdev) device_unregister(&sdev->sdev_dev); transport_remove_device(dev); scsi_dh_remove_device(sdev); - device_del(dev); - } else - put_device(&sdev->sdev_dev); + } /* * Stop accepting new requests and wait until all queuecommand() and @@ -1097,6 +1095,16 @@ void __scsi_remove_device(struct scsi_device *sdev) blk_cleanup_queue(sdev->request_queue); cancel_work_sync(&sdev->requeue_work); + /* + * Remove the device after blk_cleanup_queue() has been called such + * a possible bdi_register() call with the same name occurs after + * blk_cleanup_queue() has called bdi_destroy(). + */ + if (sdev->is_visible) + device_del(dev); + else + put_device(&sdev->sdev_dev); + if (sdev->host->hostt->slave_destroy) sdev->host->hostt->slave_destroy(sdev); transport_destroy_device(dev);