RE: System reboot hangs due to race against devices_kset->listtriggered by SCSI FC workqueue

From: Alan Stern
Date: Thu Mar 04 2010 - 14:22:41 EST


On Thu, 4 Mar 2010, Hugh Daschbach wrote:

> Apparently I still don't understand your original suggestion. I'd
> prefer to, especially if it leads to a simpler fix. The loop in
> device_shutdown() looks something like:
>
> struct device *dev, *devn;
>
> list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
> kobj.entry) {
> if (dev->bus && dev->bus->shutdown) {
> dev->bus->shutdown(dev);
> } else if (dev->driver && dev->driver->shutdown) {
> dev->driver->shutdown(dev);
> }
> }
>
> *dev gets delinked kobj_kset_leave() indirectly called from
> dev->*->shutdown(dev). This is protected by the spinlock.
>
> The secondary thread similarly calls kobj_kset_leave(). But when the
> secondary thread calls the shutdown routine for the device that devn
> points to, the loop hangs.
>
> Is there some way I can detect that devn no longer points to a valid
> device upon return from dev->*->shutdown(dev)? Or, where else can I
> look to better understand your suggestion?

Did you read the patch in my previous message? You didn't quote it.
It removes the devn variable, so the problem you're worried about
cannot occur.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/