Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2012 16:42:17 +0300
From:      Alexander Motin <mav@FreeBSD.org>
To:        freebsd-scsi@freebsd.org, freebsd-geom@FreeBSD.org
Cc:        Kris Moore <kris@pcbsd.org>
Subject:   [RFC] CAM/GEOM media change notification
Message-ID:  <500D54B9.1010800@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Hi.

On PC-BSD developers request and sponsored by iXsystems, Inc, I've made 
patch for present FreeBSD 10-CURRENT implementing media change 
notification for DA and CD removable media devices, that I would like to 
be reviewed and tested. It includes three parts:
  1) Modifications to CAM to detect media media changes and report them 
to disk(9) layer. For modern SATA (and potentially UAS) devices it 
utilizes Asynchronous Notification mechanism to receive events from 
hardware. Active polling with TEST UNIT READY commands with 3 seconds 
period is used for incapable hardware. After that both CD and DA drivers 
work the same way, detecting two conditions: "NOT READY: Medium not 
present" after medium was detected previously, and "UNIT ATTENTION: Not 
ready to ready change, medium may have changed". First one reported to 
disk(9) as media removal, second as media insert/change. To reliably 
receive second event new AC_UNIT_ATTENTION async added to make UAs 
broadcasted to all periphs by generic error handling code.
  2) Modifications to GEOM core to handle media remove and change 
events. Media removal handled by spoiling all consumers attached to the 
provider. Media change event also schedules provider retaste after 
spoiling to probe new media. New flag G_CF_ORPHAN was added to consumers 
to reflect that consumer is in process of destruction. It allows retaste 
to create new geom instance of the same class, while previous one is 
still dying.
  3) Modifications to several major GEOM classes: DEV -- to report media 
change events to devd; VFS -- to handle spoiling same as orphan to 
prevent accessing replaced media. PART class already handles spoiling 
alike to orphan.

As result, such events are reported to devd for USB card reader:
  - on media inserted:
!system=DEVFS subsystem=CDEV type=MEDIACHANGE cdev=da3
!system=DEVFS subsystem=CDEV type=CREATE cdev=da3s1
!system=DEVFS subsystem=CDEV type=CREATE cdev=msdosfs/NIKON D7000
  - on media removed:
!system=DEVFS subsystem=CDEV type=DESTROY cdev=da3s1
!system=DEVFS subsystem=CDEV type=DESTROY cdev=msdosfs/NIKON D7000

Patch can be found here:
http://people.freebsd.org/~mav/mediachange8.patch

Any comments/objections/propositions?

-- 
Alexander Motin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?500D54B9.1010800>