NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/46462: Hang trying to run a disklabel on an inserted USB flash drive



cyber%netbsd.org@localhost wrote:
> >Number:         46462
> >Category:       kern
> >Synopsis:       Hang trying to run a disklabel on an inserted USB flash
> >drive Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    kern-bug-people
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Thu May 17 22:35:00 +0000 2012
> >Originator:     Erik Berls
> <...>

OK, this thread is likely a problem:

> db> tr/t 0.59
> trace: pid 0 lid 59 at 0xffffa00049c1b770
> sleepq_block() at netbsd:sleepq_block+0xdd
> cv_wait() at netbsd:cv_wait+0xf1
> biowait() at netbsd:biowait+0x4f
> read_sector() at netbsd:read_sector+0x23
> scan_mbr() at netbsd:scan_mbr+0x40
> readdisklabel() at netbsd:readdisklabel+0xfb
> sdopen() at netbsd:sdopen+0x26a
> spec_open() at netbsd:spec_open+0x29a
> VOP_OPEN() at netbsd:VOP_OPEN+0x29
> dkwedge_discover() at netbsd:dkwedge_discover+0xee
> sdattach() at netbsd:sdattach+0x206
> config_attach_loc() at netbsd:config_attach_loc+0x15a
> scsi_probe_bus() at netbsd:scsi_probe_bus+0x4aa
> scsibus_config() at netbsd:scsibus_config+0x5d
> scsipi_completion_thread() at netbsd:scsipi_completion_thread+0x23

- scsipi_completion_thread()
        This asynchronous completion thread handles the event, which is
        in this case attaching of a new device.  Callbacks are performed
        under splbio().

-- [skipping] .. sdopen()
        Acquiring sd->sc_dk.dk_openlock here.  We are still at IPL_BIO.

--- [skipping] .. read_sector() -> disk_read_sectors()
        Invoking sdstrategy() and entering biowait().  However, since
        we are still at IPL_BIO, biodone() does not happen - thread has
        deadlocked against interrupt with sd->sc_dk.dk_openlock held.

> db> tr/t 0t3707
> trace: pid 3707 lid 1 at 0xffffa00048ebc860
> sleepq_block() at netbsd:sleepq_block+0xdd
> turnstile_block() at netbsd:turnstile_block+0x2a3
> mutex_vector_enter() at netbsd:mutex_vector_enter+0xf7
> sdopen() at netbsd:sdopen+0x99
> spec_open() at netbsd:spec_open+0x15e
> VOP_OPEN() at netbsd:VOP_OPEN+0x29
> vn_open() at netbsd:vn_open+0x13d
> sys_open() at netbsd:sys_open+0xeb
> syscall() at netbsd:syscall+0xb4
> db>

This thread merely tries to acquire sd->sc_dk.dk_openlock and waits in
the turnstile for deadlocked scsipi_completion_thread().

Fix: rework code to remove top-level splbio() in scsipi_completion_thread().
Long term fix: make scsipi subsystem MP-safe.

-- 
Mindaugas


Home | Main Index | Thread Index | Old Index