Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932306AbbKXWgf (ORCPT ); Tue, 24 Nov 2015 17:36:35 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40335 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755457AbbKXWfl (ORCPT ); Tue, 24 Nov 2015 17:35:41 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Hannes Reinecke" , "James Bottomley" , "Bart Van Assche" Date: Tue, 24 Nov 2015 22:33:59 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 39/52] scsi: Fix a bdi reregistration race In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.247 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3079 Lines: 83 3.2.74-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit bf2cf3baa20b0a6cd2d08707ef05dc0e992a8aa0 upstream. 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 Reviewed-by: Hannes Reinecke Signed-off-by: James Bottomley [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- drivers/scsi/scsi_sysfs.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -955,9 +955,7 @@ void __scsi_remove_device(struct scsi_de bsg_unregister_queue(sdev->request_queue); device_unregister(&sdev->sdev_dev); transport_remove_device(dev); - device_del(dev); - } else - put_device(&sdev->sdev_dev); + } /* * Stop accepting new requests and wait until all queuecommand() and @@ -968,6 +966,16 @@ void __scsi_remove_device(struct scsi_de 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/