Bug 222007

Summary: Deadlock at shutdown time between zfs and usb when using usb stick as cache device
Product: Base System Reporter: Bertrand Petit <bsdpr>
Component: kernAssignee: freebsd-bugs mailing list <bugs>
Status: New ---    
Severity: Affects Only Me CC: bsdpr, hselasky, usb, zfs-devel
Priority: ---    
Version: 10.3-STABLE   
Hardware: Any   
OS: Any   

Description Bertrand Petit 2017-09-02 20:54:58 UTC
Situation: system is booting from a zfs pool configured with two usb sticks as L2 cache devices.

Observation: at shutdown time, after hard-disks are stoped and uptime duration is printed, usual usb shutdown messages are not printed and the system never powers itself off. When the same sticks are pluged in the same host but are not part of the root pool, the system goes to power off as usual.

I suppose there is a deadlock between zfs and usb: zfs keeps references to those two devices and usb waits for the devices to be liberated before winding down.
Comment 1 Hans Petter Selasky freebsd_committer 2017-09-04 20:44:54 UTC
USB will try to detach all USB devices before shutdown. --HPS
Comment 2 Andriy Gapon freebsd_committer 2017-09-05 06:33:53 UTC
ZFS winds down via shutdown_post_sync event hook.
Comment 3 Bertrand Petit 2017-09-05 16:24:57 UTC
I'm not cognizant of the zfs internals, I did a quick search of the zfs sources from which I came to the conclusion that the SPA part is managing the raw devices, am I right? Then I activated that subsystem's debug messages (vfs.zfs.debug set to 32). I expected to see messages when the devices are released but none were printed, not even for the SATA drives. Where should I search next?