* [PATCH] scsi: Fix a bdi reregistration race
@ 2015-09-19 0:23 Bart Van Assche
2015-09-19 7:46 ` Hannes Reinecke
2015-09-20 9:57 ` Sagi Grimberg
0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2015-09-19 0:23 UTC (permalink / raw)
To: James Bottomley
Cc: Hannes Reinecke, Christoph Hellwig, Martin K. Petersen,
linux-scsi@vger.kernel.org
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:
[<ffffffff814ff5a4>] dump_stack+0x4c/0x65
[<ffffffff810746ba>] warn_slowpath_common+0x8a/0xc0
[<ffffffff81074736>] warn_slowpath_fmt+0x46/0x50
[<ffffffff81237ca8>] sysfs_warn_dup+0x68/0x80
[<ffffffff81237d8e>] sysfs_create_dir_ns+0x7e/0x90
[<ffffffff81291f58>] kobject_add_internal+0xa8/0x320
[<ffffffff812923a0>] kobject_add+0x60/0xb0
[<ffffffff8138c937>] device_add+0x107/0x5e0
[<ffffffff8138d018>] device_create_groups_vargs+0xd8/0x100
[<ffffffff8138d05c>] device_create_vargs+0x1c/0x20
[<ffffffff8117f233>] bdi_register+0x63/0x2a0
[<ffffffff8117f497>] bdi_register_dev+0x27/0x30
[<ffffffff81281549>] add_disk+0x1a9/0x4e0
[<ffffffffa00c5739>] sd_probe_async+0x119/0x1d0 [sd_mod]
[<ffffffff8109a81a>] async_run_entry_fn+0x4a/0x140
[<ffffffff81091078>] process_one_work+0x1d8/0x7c0
[<ffffffff81091774>] worker_thread+0x114/0x460
[<ffffffff81097878>] kthread+0xf8/0x110
[<ffffffff8150801f>] ret_from_fork+0x3f/0x70
See also patch "block: destroy bdi before blockdev is unregistered"
(commit ID 6cd18e711dd8).
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: <stable@vger.kernel.org>
---
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);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: Fix a bdi reregistration race
2015-09-19 0:23 [PATCH] scsi: Fix a bdi reregistration race Bart Van Assche
@ 2015-09-19 7:46 ` Hannes Reinecke
2015-09-20 9:57 ` Sagi Grimberg
1 sibling, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2015-09-19 7:46 UTC (permalink / raw)
To: Bart Van Assche, James Bottomley
Cc: Christoph Hellwig, Martin K. Petersen, linux-scsi@vger.kernel.org
On 09/19/2015 02:23 AM, Bart Van Assche wrote:
> 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:
> [<ffffffff814ff5a4>] dump_stack+0x4c/0x65
> [<ffffffff810746ba>] warn_slowpath_common+0x8a/0xc0
> [<ffffffff81074736>] warn_slowpath_fmt+0x46/0x50
> [<ffffffff81237ca8>] sysfs_warn_dup+0x68/0x80
> [<ffffffff81237d8e>] sysfs_create_dir_ns+0x7e/0x90
> [<ffffffff81291f58>] kobject_add_internal+0xa8/0x320
> [<ffffffff812923a0>] kobject_add+0x60/0xb0
> [<ffffffff8138c937>] device_add+0x107/0x5e0
> [<ffffffff8138d018>] device_create_groups_vargs+0xd8/0x100
> [<ffffffff8138d05c>] device_create_vargs+0x1c/0x20
> [<ffffffff8117f233>] bdi_register+0x63/0x2a0
> [<ffffffff8117f497>] bdi_register_dev+0x27/0x30
> [<ffffffff81281549>] add_disk+0x1a9/0x4e0
> [<ffffffffa00c5739>] sd_probe_async+0x119/0x1d0 [sd_mod]
> [<ffffffff8109a81a>] async_run_entry_fn+0x4a/0x140
> [<ffffffff81091078>] process_one_work+0x1d8/0x7c0
> [<ffffffff81091774>] worker_thread+0x114/0x460
> [<ffffffff81097878>] kthread+0xf8/0x110
> [<ffffffff8150801f>] ret_from_fork+0x3f/0x70
>
> See also patch "block: destroy bdi before blockdev is unregistered"
> (commit ID 6cd18e711dd8).
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: <stable@vger.kernel.org>
> ---
> 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);
>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: Fix a bdi reregistration race
2015-09-19 0:23 [PATCH] scsi: Fix a bdi reregistration race Bart Van Assche
2015-09-19 7:46 ` Hannes Reinecke
@ 2015-09-20 9:57 ` Sagi Grimberg
2015-09-20 13:49 ` Bart Van Assche
1 sibling, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2015-09-20 9:57 UTC (permalink / raw)
To: Bart Van Assche
Cc: James Bottomley, Hannes Reinecke, Christoph Hellwig,
Martin K. Petersen, linux-scsi@vger.kernel.org
On 9/19/2015 3:23 AM, Bart Van Assche wrote:
> Unregister and reregister BDI devices in the proper order. This patch
> avoids that the following kernel warning can get triggered:
Hi Bart,
Can you share the scenario that reproduced this? I think I might
have seen this before.
Thanks,
Sagi.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: Fix a bdi reregistration race
2015-09-20 9:57 ` Sagi Grimberg
@ 2015-09-20 13:49 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2015-09-20 13:49 UTC (permalink / raw)
To: Sagi Grimberg
Cc: James Bottomley, Hannes Reinecke, Christoph Hellwig,
Martin K. Petersen, linux-scsi@vger.kernel.org
On 09/20/15 02:57, Sagi Grimberg wrote:
> On 9/19/2015 3:23 AM, Bart Van Assche wrote:
>> Unregister and reregister BDI devices in the proper order. This patch
>> avoids that the following kernel warning can get triggered:
>
> Can you share the scenario that reproduced this? I think I might
> have seen this before.
Hello Sagi,
The details of the setup on which I can reproduce the reported behavior
easily are as follows:
* Several kernel debugging options were enabled on the initiator system
(PROVE_LOCKING, SLUB_DEBUG, KMEMLEAK, ...).
* srp_daemon and multipathd were running on the initiator system.
* Four IB ports were present the initiator system.
* Eight IB ports were present the target system.
* 100 LUNs were defined on the target system.
* As a result, 3200 /dev/sd* device nodes were created on the
initiator system by the SRP initiator driver.
* The following command was run on the initiator system:
for p in /sys/class/srp_remote_ports/*; do echo 1 >$p/delete & done;
wait; dmsetup remove_all
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-20 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-19 0:23 [PATCH] scsi: Fix a bdi reregistration race Bart Van Assche
2015-09-19 7:46 ` Hannes Reinecke
2015-09-20 9:57 ` Sagi Grimberg
2015-09-20 13:49 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).