Removing a USB stick locks up GEOM

From: Joe Marcus Clarke <marcus_at_FreeBSD.org>
Date: Sun, 13 Sep 2009 13:56:25 -0400
If I insert a USB stick with a FAT FS, and mount it, then remove it
without unmounting, trying to retrieve kern.geom.conftxt will result in
a live lock of the system.  Yes, I know this is not a good thing to do,
but I thought one of the goals of new USB was to avoid problems with
doing such bad things.  I'm conducting tests with:

FreeBSD lasagna.marcuscom.com 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Sat
Sep 12 20:51:29 EDT 2009
marcus_at_lasagna.marcuscom.com:/usr/obj/usr/src/sys/LASAGNA  amd64

The biggest impact of this is hal causes the system to become unusable
since hal uses this sysctl to obtain disk information.  As soon as hald
receives the devd event saying the disk is gone, it tries to refresh its
disk list, and then hangs with this stack trace:

#0  sched_switch (td=0xffffff0001a15a80, newtd=0xffffff0001374380,
flags=Variable "flags" is not available.
)
    at /usr/src/sys/kern/sched_ule.c:1864
#1  0xffffffff802f370f in mi_switch (flags=260, newtd=0x0)
    at /usr/src/sys/kern/kern_synch.c:449
#2  0xffffffff80325bd2 in sleepq_timedwait (wchan=0xffffff00250d7100,
pri=76)
    at /usr/src/sys/kern/subr_sleepqueue.c:623
#3  0xffffffff802f3c88 in _sleep (ident=0xffffff00250d7100, lock=0x0,
priority=Variable "priority" is not available.

) at /usr/src/sys/kern/kern_synch.c:230
#4  0xffffffff8028c11a in g_waitfor_event (func=Variable "func" is not
available.
)
    at /usr/src/sys/geom/geom_event.c:359
#5  0xffffffff8028d739 in sysctl_kern_geom_conftxt (oidp=Variable "oidp"
is not available.
)
    at /usr/src/sys/geom/geom_kern.c:184
#6  0xffffffff802f4e58 in sysctl_root (oidp=Variable "oidp" is not
available.
)
    at /usr/src/sys/kern/kern_sysctl.c:1418
#7  0xffffffff802f6101 in userland_sysctl (td=0x0,
name=0xffffff804d278aa0, 
    namelen=3, old=0x0, oldlenp=Variable "oldlenp" is not available.
) at /usr/src/sys/kern/kern_sysctl.c:1522
#8  0xffffffff802f62da in __sysctl (td=0xffffff0001a15a80, 
    uap=0xffffff804d278bf0) at /usr/src/sys/kern/kern_sysctl.c:1448

This problem isn't 100% reproducible with hal, and I have yet to be able
to reproduce it without hal.  I suspect a timing issue.  And it wouldn't
be hard to add a sleep between the devd event and the sysctl poll, but I
was hoping someone might have an idea of how to fix this in the kernel.

Joe

-- 
Joe Marcus Clarke
FreeBSD GNOME Team      ::      gnome_at_FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome

Received on Sun Sep 13 2009 - 15:56:23 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:55 UTC