misc/68074: devstat: disappearing devices not properly removed

Hendrik Scholz hendrik at scholz.net
Fri Jun 18 11:21:09 GMT 2004


>Number:         68074
>Category:       misc
>Synopsis:       devstat: disappearing devices not properly removed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 18 11:20:10 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Hendrik Scholz
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD deimos.raisdorf.net 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Tue Jun 15 02:20:43 CEST 2004 hscholz at deimos.raisdorf.net:/usr/src/sys/i386/compile/DEIMOS i386


	
>Description:

When attaching USB or firewire mass storage devices (USB CF disk, iPod)
a new scsi disk gets created and a libdevstat struct devstat entry is
added. Once a device is unplugged and no longer available this entry
should be removed but still appears on -current.

>How-To-Repeat:

- check number of devices

$ sysctl kern.devstat.numdevs
kern.devstat.numdevs: 2

(ad0 and fd0 in this case - see systat -vm 1)

- attach USB umass device

umass0: SanDisk ImageMate CF, rev 2.00/1.19, addr 2
da0 at umass-sim0 bus 0 target 0 lun 0
da0: <Generic STORAGE DEVICE 0119> Removable Direct Access SCSI-0 device 
da0: 1.000MB/s transfers
da0: 246MB (503808 512 byte sectors: 64H 32S/T 246C)

- check number of devices

$ sysctl kern.devstat.numdevs
kern.devstat.numdevs: 4

ad0, fd0, da0, pass0

- detach device

umass0: at uhub0 port 2 (addr 2) disconnected
(da0:umass-sim0:0:0:0): lost device
(da0:umass-sim0:0:0:0): removing device entry
umass0: detached

- check number of devices

$ sysctl kern.devstat.numdevs
kern.devstat.numdevs: 4

This should be two again


NOTES:

	- only tested with one Sandisk USB 1.1/2.0 cardreader since
	  I didn't have anything else available on the flight
	- apparently the devices properly disappear from systat -vm and
	  sysctl on 5.2.1-REL-p6

dmesg:

Copyright (c) 1992-2004 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 5.2-CURRENT #2: Tue Jun 15 02:20:43 CEST 2004
    hscholz at deimos.raisdorf.net:/usr/src/sys/i386/compile/DEIMOS
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0832000.
Preloaded elf module "/boot/kernel/acpi.ko" at 0xc08322bc.
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Mobile Intel(R) Pentium(R) III CPU - M  1000MHz (531.57-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6b4  Stepping = 4
  Features=0x383f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PA
T,PSE36,MMX,FXSR,SSE>
real memory  = 125304832 (119 MB)
avail memory = 112824320 (107 MB)
random: <entropy source, Software, Yarrow>
Pentium Pro MTRR support enabled
npx0: [FAST]
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <PTLTD   RSDT> on motherboard
acpi0: [GIANT-LOCKED]
pcibios: BIOS version 2.10
acpi0: Power Button (fixed)
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x8008-0x800b on acpi0
cpu0: <ACPI CPU (4 Cx states)> port 0x530-0x537 on acpi0
acpi_tz0: <Thermal Zone> port 0x530-0x537 on acpi0
acpi_acad0: <AC Adapter> on acpi0
acpi_cmbat0: <Control Method Battery> on acpi0
acpi_button0: <Power Button> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_button1: <Sleep Button> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pcib0: slot 2 INTA is routed to irq 10
pcib0: slot 29 INTA is routed to irq 10
pcib0: slot 29 INTB is routed to irq 11
pcib0: slot 29 INTC is routed to irq 11
pcib0: slot 31 INTB is routed to irq 10
pcib0: slot 31 INTB is routed to irq 10
pcib0: slot 31 INTB is routed to irq 10
agp0: <Intel 82830M (830M GMCH) SVGA controller> mem 0xe0000000-0xe007ffff,0xe80
00000-0xefffffff irq 10 at device 2.0 on pci0
agp0: Reserved 0x8000000 bytes for rid 0x10 type 3 at 0xe8000000
agp0: Reserved 0x80000 bytes for rid 0x14 type 3 at 0xe0000000
agp0: detected 8060k stolen memory
agp0: aperture size is 128M
pci0: <display> at device 2.1 (no driver attached)
uhci0: <Intel 82801CA/CAM (ICH3) USB controller USB-A> port 0x8c80-0x8c9f irq 10
 at device 29.0 on pci0
uhci0: Reserved 0x20 bytes for rid 0x20 type 4 at 0x8c80
uhci0: [GIANT-LOCKED]
usb0: <Intel 82801CA/CAM (ICH3) USB controller USB-A> on uhci0
usb0: USB revision 1.0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
umass0: SanDisk ImageMate CF, rev 2.00/1.19, addr 2
uhci1: <Intel 82801CA/CAM (ICH3) USB controller USB-B> port 0x8ca0-0x8cbf irq 11
 at device 29.1 on pci0
uhci1: Reserved 0x20 bytes for rid 0x20 type 4 at 0x8ca0
uhci1: [GIANT-LOCKED]
usb1: <Intel 82801CA/CAM (ICH3) USB controller USB-B> on uhci1
usb1: USB revision 1.0
uhub1: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
uhci2: <Intel 82801CA/CAM (ICH3) USB controller USB-C> port 0x8cc0-0x8cdf irq 11
 at device 29.2 on pci0
uhci2: Reserved 0x20 bytes for rid 0x20 type 4 at 0x8cc0
uhci2: [GIANT-LOCKED]
usb2: <Intel 82801CA/CAM (ICH3) USB controller USB-C> on uhci2
usb2: USB revision 1.0
uhub2: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub2: 2 ports with 2 removable, self powered
pcib1: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci2: <ACPI PCI bus> on pcib1
pcib1: slot 3 INTB is routed to irq 11
pcib1: slot 5 INTA is routed to irq 11
cbb0: <RF5C475 PCI-CardBus Bridge> at device 3.0 on pci2
cbb0: Lazy allocation of 0x1000 bytes rid 0x10 type 3 at 0xe0201000
cardbus0: <CardBus bus> on cbb0
pccard0: <16-bit PCCard bus> on cbb0
pcib1: slot 3 INTA is routed to irq 10
fwohci0: <Ricoh R5C551> mem 0xe0200000-0xe02007ff irq 11 at device 3.1 on pci2
fwohci0: Reserved 0x800 bytes for rid 0x10 type 3 at 0xe0200000
fwohci0: [GIANT-LOCKED]
fwohci0: OHCI version 1.0 (ROM=1)
fwohci0: No. of Isochronous channel is 4.
fwohci0: EUI64 00:00:f0:41:04:10:01:42
fwohci0: Phy 1394a available S400, 2 ports.
fwohci0: Link S400, max_rec 2048 bytes.
firewire0: <IEEE1394(FireWire) bus> on fwohci0
sbp0: <SBP-2/SCSI over FireWire> on firewire0
fwe0: <Ethernet over FireWire> on firewire0
if_fwe0: Fake Ethernet address: 02:00:f0:10:01:42
fwe0: Ethernet address: 02:00:f0:10:01:42
fwohci0: Initiate bus reset
fwohci0: node_id=0xc800ffc0, gen=1, CYCLEMASTER mode
firewire0: 1 nodes, maxhop <= 0, cable IRM = 0 (me)
firewire0: bus manager 0 (me)
xl0: <3Com 3c905C-TX Fast Etherlink XL> port 0xa000-0xa07f mem 0xe0200800-0xe020
087f irq 11 at device 5.0 on pci2
xl0: Reserved 0x80 bytes for rid 0x14 type 3 at 0xe0200800
miibus0: <MII bus> on xl0
ukphy0: <Generic IEEE 802.3u media interface> on miibus0
ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
xl0: Ethernet address: 00:00:f0:77:01:3e
xl0: [GIANT-LOCKED]
cbb1: <TI1410 PCI-CardBus Bridge> at device 7.0 on pci2
cbb1: Lazy allocation of 0x1000 bytes rid 0x10 type 3 at 0xe0202000
cardbus1: <CardBus bus> on cbb1
pccard1: <16-bit PCCard bus> on cbb1
pcib1: slot 7 INTA is routed to irq 5
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH3 UDMA100 controller> port 0x9000-0x900f,0x376,0x170-0x177,0x
3f6,0x1f0-0x1f7 at device 31.1 on pci0
atapci0: Reserved 0x10 bytes for rid 0x20 type 4 at 0x9000
atapci0: Reserved 0x8 bytes for rid 0x10 type 4 at 0x1f0
atapci0: Reserved 0x1 bytes for rid 0x14 type 4 at 0x3f6
ata0: at 0x1f0 irq 14 on atapci0
atapci0: Reserved 0x8 bytes for rid 0x18 type 4 at 0x170
atapci0: Reserved 0x1 bytes for rid 0x1c type 4 at 0x376
ata1: at 0x170 irq 15 on atapci0
pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
pcm0: <Intel ICH3 (82801CA)> port 0x80c0-0x80ff,0x8400-0x84ff irq 10 at device 3
1.5 on pci0
pcm0: Reserved 0x100 bytes for rid 0x10 type 4 at 0x8400
pcm0: Reserved 0x40 bytes for rid 0x14 type 4 at 0x80c0
pcm0: [GIANT-LOCKED]
pcm0: <Cirrus Logic CS4299 AC97 Codec>
pci0: <simple comms> at device 31.6 (no driver attached)
acpi_ec0: <Embedded Controller: GPE 0x18> port 0x66,0x62 on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Generic PS/2 mouse, device ID 0
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0 port 0x3f8-0x3ff irq 4 on acpi0
sio0: type 8250 or not responding
fdc0: <Enhanced floppy controller (i82077, NE72065 or clone)> port 0x3f7,0x3f0-0
x3f5 irq 6 drq 2 on acpi0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
orm0: <Option ROMs> at iomem 0xd4800-0xd4fff,0xd4000-0xd47ff on isa0
pmtimer0 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
Timecounter "TSC" frequency 531565302 Hz quality 800
Timecounters tick every 10.000 msec
IP Filter: v3.4.31 initialized.  Default = pass all, Logging = enabled
ad0: 28615MB <HITACHI_DK23EA-30> [58140/16/63] at ata0-master UDMA100
wi0: <Lucent Technologies WaveLAN/IEEE> at port 0xa080-0xa0bf irq 5 function 0 c
onfig 1 on pccard1
wi0: [GIANT-LOCKED]
wi0: using Lucent Embedded WaveLAN/IEEE
wi0: Lucent Firmware: Station (8.42.1)
wi0: Ethernet address: 00:02:2d:87:8e:4c
wi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
da0 at umass-sim0 bus 0 target 0 lun 0
da0: <Generic STORAGE DEVICE 0119> Removable Direct Access SCSI-0 device 
da0: 1.000MB/s transfers
da0: 246MB (503808 512 byte sectors: 64H 32S/T 246C)
Mounting root from ufs:/dev/ad0s1a


>Fix:

devstat_remove_entry() gets called in sys/cam/scsi/scsi_ch.c, scsi_pass.c,
scsi_pt.c and scsi_sa.c but not in scsi_da.c and scsi_cd.c.
This patch adds the appropriate calls for disks and cdroms.

	

--- scsi-devstat.diff begins here ---
--- sys/cam/scsi/scsi_cd.c.orig	Tue Jun 15 00:18:55 2004
+++ sys/cam/scsi/scsi_cd.c	Tue Jun 15 02:20:38 2004
@@ -422,6 +422,8 @@
 	xpt_print_path(periph->path);
 	printf("removing device entry\n");
 
+	devstat_remove_entry(softc->disk->d_devstat);
+
 	if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
 	    && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
 		xpt_print_path(periph->path);
--- sys/cam/scsi/scsi_da.c.orig	Tue Jun 15 00:14:05 2004
+++ sys/cam/scsi/scsi_da.c	Tue Jun 15 02:19:56 2004
@@ -754,6 +754,9 @@
 
 	xpt_print_path(periph->path);
 	printf("removing device entry\n");
+
+	devstat_remove_entry(softc->disk->d_devstat);
+
 	/*
 	 * If we can't free the sysctl tree, oh well...
 	 */
--- scsi-devstat.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list