Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Mon, Jan 30, 2017 at 12:57:05PM -0800, Dan Williams wrote: > > struct kref { > atomic_t refcount; > }; > > ...so what do we gain by open coding kref_get() and kref_put()? A much less ugly calling convention.
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Mon, Jan 30, 2017 at 01:53:36PM -0800, Dan Williams wrote: > On Mon, Jan 30, 2017 at 4:24 AM, Christoph Hellwig wrote: > > Hi Dan, > > > > this looks mostly fine to me. A few code comments below, but except > > for this there is another issue with it: We still have drivers > > that share a single request_queue for multiple gendisks, so I wonder > > scsi drivers or others? If those drivers can switch to dynamically > allocated devt (GENHD_FL_EXT_DEVT), then they don't need this fix. Mostly old floppy drivers.
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Mon, Jan 30, 2017 at 4:24 AM, Christoph Hellwig wrote: > Hi Dan, > > this looks mostly fine to me. A few code comments below, but except > for this there is another issue with it: We still have drivers > that share a single request_queue for multiple gendisks, so I wonder scsi drivers or others? If those drivers can switch to dynamically allocated devt (GENHD_FL_EXT_DEVT), then they don't need this fix. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Mon, Jan 30, 2017 at 4:24 AM, Christoph Hellwig wrote: > Hi Dan, > > this looks mostly fine to me. A few code comments below, but except > for this there is another issue with it: We still have drivers > that share a single request_queue for multiple gendisks, so I wonder > > Also I think you probably want one patch for the block framework, > and one to switch SCSI over to it. > >> +struct disk_devt { >> + struct kref kref; >> + void (*release)(struct kref *); >> +}; >> + >> +static inline void put_disk_devt(struct disk_devt *disk_devt) >> +{ >> + if (disk_devt) >> + kref_put(&disk_devt->kref, disk_devt->release); >> +} >> + >> +static inline void get_disk_devt(struct disk_devt *disk_devt) >> +{ >> + if (disk_devt) >> + kref_get(&disk_devt->kref); >> +} > > Given that we have a user-supplied release callack I'd much rather get > rid of the kref here, use a normal atomic_t and pass the disk_devt > structure to the release callback then a kref. I'm missing something... kref is just: struct kref { atomic_t refcount; }; ...so what do we gain by open coding kref_get() and kref_put()? -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
Hi Dan, this looks mostly fine to me. A few code comments below, but except for this there is another issue with it: We still have drivers that share a single request_queue for multiple gendisks, so I wonder Also I think you probably want one patch for the block framework, and one to switch SCSI over to it. > +struct disk_devt { > + struct kref kref; > + void (*release)(struct kref *); > +}; > + > +static inline void put_disk_devt(struct disk_devt *disk_devt) > +{ > + if (disk_devt) > + kref_put(&disk_devt->kref, disk_devt->release); > +} > + > +static inline void get_disk_devt(struct disk_devt *disk_devt) > +{ > + if (disk_devt) > + kref_get(&disk_devt->kref); > +} Given that we have a user-supplied release callack I'd much rather get rid of the kref here, use a normal atomic_t and pass the disk_devt structure to the release callback then a kref. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Sun, Jan 29, 2017 at 11:22 PM, Omar Sandoval wrote: > On Mon, Jan 30, 2017 at 08:05:52AM +0100, Hannes Reinecke wrote: >> On 01/29/2017 05:58 AM, Dan Williams wrote: >> > Warnings of the following form occur because scsi reuses a devt number >> > while the block layer still has it referenced as the name of the bdi >> > [1]: >> > >> > WARNING: CPU: 1 PID: 93 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80 >> > sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:192' >> > [..] >> > Call Trace: >> > dump_stack+0x86/0xc3 >> > __warn+0xcb/0xf0 >> > warn_slowpath_fmt+0x5f/0x80 >> > ? kernfs_path_from_node+0x4f/0x60 >> > sysfs_warn_dup+0x62/0x80 >> > sysfs_create_dir_ns+0x77/0x90 >> > kobject_add_internal+0xb2/0x350 >> > kobject_add+0x75/0xd0 >> > device_add+0x15a/0x650 >> > device_create_groups_vargs+0xe0/0xf0 >> > device_create_vargs+0x1c/0x20 >> > bdi_register+0x90/0x240 >> > ? lockdep_init_map+0x57/0x200 >> > bdi_register_owner+0x36/0x60 >> > device_add_disk+0x1bb/0x4e0 >> > ? __pm_runtime_use_autosuspend+0x5c/0x70 >> > sd_probe_async+0x10d/0x1c0 >> > async_run_entry_fn+0x39/0x170 >> > >> > This is a brute-force fix to pass the devt release information from >> > sd_probe() to the locations where we register the bdi, >> > device_add_disk(), and unregister the bdi, blk_cleanup_queue(). >> > >> > Thanks to Omar for the quick reproducer script [2]. This patch survives >> > where an unmodified kernel fails in a few seconds. >> > >> > [1]: https://marc.info/?l=linux-scsi&m=147116857810716&w=4 >> > [2]: http://marc.info/?l=linux-block&m=148554717109098&w=2 >> > >> > Cc: James Bottomley >> > Cc: Bart Van Assche >> > Cc: "Martin K. Petersen" >> > Cc: Christoph Hellwig >> > Cc: Jens Axboe >> > Reported-by: Omar Sandoval >> > Signed-off-by: Dan Williams >> > --- >> > block/blk-core.c |1 + >> > block/genhd.c |7 +++ >> > drivers/scsi/sd.c | 41 + >> > include/linux/blkdev.h |1 + >> > include/linux/genhd.h | 17 + >> > 5 files changed, 59 insertions(+), 8 deletions(-) >> > >> Please check the patchset from Jan Kara (cf 'BDI lifetime fix' on >> linux-block), which attempts to solve the same problem. > > Hi, Hannes, > > It's not the same problem. Jan's series fixes a bdi vs. inode lifetime > issue, this patch is for a bdi vs devt lifetime issue. Jan's series > doesn't fix the crashes caused by my reproducer script. Correct. In fact I was running Jan's patches in my baseline kernel that fails almost immediately. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On Mon, Jan 30, 2017 at 08:05:52AM +0100, Hannes Reinecke wrote: > On 01/29/2017 05:58 AM, Dan Williams wrote: > > Warnings of the following form occur because scsi reuses a devt number > > while the block layer still has it referenced as the name of the bdi > > [1]: > > > > WARNING: CPU: 1 PID: 93 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80 > > sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:192' > > [..] > > Call Trace: > > dump_stack+0x86/0xc3 > > __warn+0xcb/0xf0 > > warn_slowpath_fmt+0x5f/0x80 > > ? kernfs_path_from_node+0x4f/0x60 > > sysfs_warn_dup+0x62/0x80 > > sysfs_create_dir_ns+0x77/0x90 > > kobject_add_internal+0xb2/0x350 > > kobject_add+0x75/0xd0 > > device_add+0x15a/0x650 > > device_create_groups_vargs+0xe0/0xf0 > > device_create_vargs+0x1c/0x20 > > bdi_register+0x90/0x240 > > ? lockdep_init_map+0x57/0x200 > > bdi_register_owner+0x36/0x60 > > device_add_disk+0x1bb/0x4e0 > > ? __pm_runtime_use_autosuspend+0x5c/0x70 > > sd_probe_async+0x10d/0x1c0 > > async_run_entry_fn+0x39/0x170 > > > > This is a brute-force fix to pass the devt release information from > > sd_probe() to the locations where we register the bdi, > > device_add_disk(), and unregister the bdi, blk_cleanup_queue(). > > > > Thanks to Omar for the quick reproducer script [2]. This patch survives > > where an unmodified kernel fails in a few seconds. > > > > [1]: https://marc.info/?l=linux-scsi&m=147116857810716&w=4 > > [2]: http://marc.info/?l=linux-block&m=148554717109098&w=2 > > > > Cc: James Bottomley > > Cc: Bart Van Assche > > Cc: "Martin K. Petersen" > > Cc: Christoph Hellwig > > Cc: Jens Axboe > > Reported-by: Omar Sandoval > > Signed-off-by: Dan Williams > > --- > > block/blk-core.c |1 + > > block/genhd.c |7 +++ > > drivers/scsi/sd.c | 41 + > > include/linux/blkdev.h |1 + > > include/linux/genhd.h | 17 + > > 5 files changed, 59 insertions(+), 8 deletions(-) > > > Please check the patchset from Jan Kara (cf 'BDI lifetime fix' on > linux-block), which attempts to solve the same problem. Hi, Hannes, It's not the same problem. Jan's series fixes a bdi vs. inode lifetime issue, this patch is for a bdi vs devt lifetime issue. Jan's series doesn't fix the crashes caused by my reproducer script. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] scsi, block: fix duplicate bdi name registration crashes
On 01/29/2017 05:58 AM, Dan Williams wrote: > Warnings of the following form occur because scsi reuses a devt number > while the block layer still has it referenced as the name of the bdi > [1]: > > WARNING: CPU: 1 PID: 93 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80 > sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:192' > [..] > Call Trace: > dump_stack+0x86/0xc3 > __warn+0xcb/0xf0 > warn_slowpath_fmt+0x5f/0x80 > ? kernfs_path_from_node+0x4f/0x60 > sysfs_warn_dup+0x62/0x80 > sysfs_create_dir_ns+0x77/0x90 > kobject_add_internal+0xb2/0x350 > kobject_add+0x75/0xd0 > device_add+0x15a/0x650 > device_create_groups_vargs+0xe0/0xf0 > device_create_vargs+0x1c/0x20 > bdi_register+0x90/0x240 > ? lockdep_init_map+0x57/0x200 > bdi_register_owner+0x36/0x60 > device_add_disk+0x1bb/0x4e0 > ? __pm_runtime_use_autosuspend+0x5c/0x70 > sd_probe_async+0x10d/0x1c0 > async_run_entry_fn+0x39/0x170 > > This is a brute-force fix to pass the devt release information from > sd_probe() to the locations where we register the bdi, > device_add_disk(), and unregister the bdi, blk_cleanup_queue(). > > Thanks to Omar for the quick reproducer script [2]. This patch survives > where an unmodified kernel fails in a few seconds. > > [1]: https://marc.info/?l=linux-scsi&m=147116857810716&w=4 > [2]: http://marc.info/?l=linux-block&m=148554717109098&w=2 > > Cc: James Bottomley > Cc: Bart Van Assche > Cc: "Martin K. Petersen" > Cc: Christoph Hellwig > Cc: Jens Axboe > Reported-by: Omar Sandoval > Signed-off-by: Dan Williams > --- > block/blk-core.c |1 + > block/genhd.c |7 +++ > drivers/scsi/sd.c | 41 + > include/linux/blkdev.h |1 + > include/linux/genhd.h | 17 + > 5 files changed, 59 insertions(+), 8 deletions(-) > Please check the patchset from Jan Kara (cf 'BDI lifetime fix' on linux-block), which attempts to solve the same problem. Cheers, Hannes -- Dr. Hannes ReineckeTeamlead Storage & Networking h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html