summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_event.c
Commit message (Collapse)AuthorAgeFilesLines
* Make g_wither_washer() to not loop by itself, but only when there was somemav2013-03-241-8/+3
| | | | | | | | | more topology change done that may require its attention. Add few missing g_do_wither() calls in respective places to signal it. This fixes potential infinite loop here when some provider is withered, but still opened or connected for some reason and so can not be destroyed. For example, see r227009 and r227510.
* Implement media change notification for DA and CD removable media devices.mav2012-07-291-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 in cam_periph_error(). 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 some 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. Reviewed by: silence on geom@ and scsi@ Tested by: avg Sponsored by: iXsystems, Inc. / PC-BSD MFC after: 2 months
* Workaround the problem introduced by combination of r162200 and r215687.mav2011-11-011-1/+1
| | | | | | | | | | | | | | | | r162200 delays provider orphanization until all running requests complete, to workaround broken orphan() method implementation in some classes. r215687 removes persistent periodic (10Hz) event thread wake ups. Together these changes can indefinitely delay orphanization until some other event wake up the event thread. One consequence of this is inability of CAM to destroy device disconnected when busy and, as consequence, create new one after reconnection. While the best solution would be to revert r162200, it is not easy, as some classes still look broken in that way. Instead conditionally wake up event thread if there are some providers waiting for orphanization. MFC after: 1 week
* Plumb device physical path reporting from CAM devices, through GEOM andgibbs2011-06-141-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DEVFS, and make it accessible via the diskinfo utility. Extend GEOM's generic attribute query mechanism into generic disk consumers. sys/geom/geom_disk.c: sys/geom/geom_disk.h: sys/cam/scsi/scsi_da.c: sys/cam/ata/ata_da.c: - Allow disk providers to implement a new method which can override the default BIO_GETATTR response, d_getattr(struct bio *). This function returns -1 if not handled, otherwise it returns 0 or an errno to be passed to g_io_deliver(). sys/cam/scsi/scsi_da.c: sys/cam/ata/ata_da.c: - Don't copy the serial number to dp->d_ident anymore, as the CAM XPT is now responsible for returning this information via d_getattr()->(a)dagetattr()->xpt_getatr(). sys/geom/geom_dev.c: - Implement a new ioctl, DIOCGPHYSPATH, which returns the GEOM attribute "GEOM::physpath", if possible. If the attribute request returns a zero-length string, ENOENT is returned. usr.sbin/diskinfo/diskinfo.c: - If the DIOCGPHYSPATH ioctl is successful, report physical path data when diskinfo is executed with the '-v' option. Submitted by: will Reviewed by: gibbs Sponsored by: Spectra Logic Corporation Add generic attribute change notification support to GEOM. sys/sys/geom/geom.h: Add a new attrchanged method field to both g_class and g_geom. sys/sys/geom/geom.h: sys/geom/geom_event.c: - Provide the g_attr_changed() function that providers can use to advertise attribute changes. - Perform delivery of attribute change notifications from a thread context via the standard GEOM event mechanism. sys/geom/geom_subr.c: Inherit the attrchanged method from class to geom (class instance). sys/geom/geom_disk.c: Provide disk_attr_changed() to provide g_attr_changed() access to consumers of the disk API. sys/cam/scsi/scsi_pass.c: sys/cam/scsi/scsi_da.c: sys/geom/geom_dev.c: sys/geom/geom_disk.c: Use attribute changed events to track updates to physical path information. sys/cam/scsi/scsi_da.c: Add AC_ADVINFO_CHANGED to the registered asynchronous CAM events for this driver. When this event occurs, and the updated buffer type references our physical path attribute, emit a GEOM attribute changed event via the disk_attr_changed() API. sys/cam/scsi/scsi_pass.c: Add AC_ADVINFO_CHANGED to the registered asynchronous CAM events for this driver. When this event occurs, update the physical patch devfs alias for this pass instance. Submitted by: gibbs Sponsored by: Spectra Logic Corporation
* Use g_eventlock to protect against losing wakeups in the g_event processjh2010-11-221-28/+35
| | | | | | | | | | | | | and replace tsleep(9) with msleep(9) which doesn't use a timeout. The previously used timeout caused the event process to wake up ten times per second on an idle system. one_event() is now called with the topology lock held and it returns with both the topology and event locks held when there are no more events in the queue. Reported by: mav, Marius NĂ¼nnerich Reviewed by: freebsd-geom
* Extend the g_eventlock mutex coverage in one_event() to include settingjh2010-11-031-4/+8
| | | | | | | | | of the EV_DONE flag and use the mutex to protect against losing wakeups in g_waitfor_event(). Reported by: davidxu Tested by: davidxu Discussed on: freebsd-current
* Try and narrow the gap in which you act on an event that has been canceled.mjacob2010-06-081-0/+10
| | | | | Obtained from: Jaako Heinonen MFC after: 1 month
* When orphaning a provider, cancel events related to it.pjd2007-09-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this change the following situation was possible: 1. Provider is orphaned from within class' access() method on last write close - orphan provider event is send. 2. GEOM detects last write close on a provider and sends new provider event. 3. g_orphan_register() is called, and calls all orphan methods of attached consumers. 4. New provider event is executed on orphaned provider, all classes can taste already orphaned provider, and some may attach consumers to it. Those consumers will never go away, because the g_orphan_register() was already called. We end up with a zombie provider. With this change, at step 3, we will cancel new provider event. How to repeat this problem: # mdconfig -a -t malloc -s 10m # geli init -i 0 md0 # geli attach md0 # newfs -L test /dev/md0.eli # mount /dev/ufs/test /mnt/tmp # geli detach -l md0.eli # umount /mnt/tmp # glabel status Name Status Components ufs/test N/A N/A Reviewed by: phk Approved by: re (kensmith)
* Delay an orphan event if provider has still in-flight I/O requests.pjd2006-09-101-1/+4
| | | | | | | | | | | This way GEOM classes can safely detach from provider when an orphan event is received. This fixes 'detach with active requests' panic for gstripe/gconcat under load. PR: kern/102766 Submitted by: mjacob OK'ed by: phk MFC after: 1 week
* Remove a race condition that could result in processes being stuckphk2005-09-041-24/+30
| | | | | | | | | | | | waiting for geom events to happen: Instead of maintaining a count of outstanding events, simply look if the queue is empty. Make sure to not remove events from the queue until they are executed in order to not open a new race. Much work by: pjd Tested by: kris MT6: yes, should be.
* Correct typo.pjd2005-05-181-1/+1
|
* Introduce g_waitidlelock() function which is simlar to g_waitidle(),pjd2004-11-091-0/+12
| | | | | | | but should be called with the topology lock held and returns with the topology lock held and empty event queue. Approved by: phk (sometime ago)
* Add a new per-thread private flag: TDP_GEOM.phk2004-10-231-1/+8
| | | | | | | | | | | | | | This flag gets set whenever the thread posts an event on the GEOM event queue, and if the flag is set when the thread is prepared to return to userland from the kernel, g_waitidle() will be called to make sure that the posted events have completed. This can replace an insufficient number of g_waitidle() calls in various other places, and has the advantage of being failsafe: Any system call which does a VOP_OPEN()/VOP_CLOSE will now correctly wait for any geom events it posted as part of spoils or tastes. Assert that topology and Giant is not held in g_waitidle().
* Make withering water tight.phk2004-07-081-0/+16
| | | | | | | | | When we orphan/wither a provider, an attached geom+consumer could end up being withered as a result and it may be in front of us in the normal object scanning order so we need to do multi-pass. On the other hand, there may be withering stuff we can't get rid off (yet), so we need to keep track of both the existence of withering stuff and if there is more we can do at this time.
* Rearrange some of the GEOM debugging tools to be more structured.phk2004-03-101-21/+6
| | | | | | | | | | | | | | | | | | Retire g_sanity() and corresponding debugflag (0x8) Retire g_{stall,release}_events(). Under #ifdef DIAGNOSTIC: Make g_valid_obj() an official function and have it return an an non-zero integer which indicates the kind of object when found. Implement G_VALID_{CLASS,GEOM,CONSUMER,PROVIDER}() macros based on g_valid_obj(). Sprinkle calls to these macros liberally over the infrastructure. Always check that we do not free a live object.
* Now we have g_topology_assert_not(), so use it to detect deadlocks.pjd2004-02-101-1/+1
| | | | Approved by: phk, scottl (mentor)
* Don't mingle malloc/g_event flags.phk2004-02-021-5/+8
| | | | Spotted by: pjd@
* Make sure to keep track of canceled events.phk2004-01-231-0/+2
| | | | Submitted by: Pawel Jakub Dawidek <nick@garage.freebsd.pl>
* Prevent withering of the provider we're orphaning from happening untilphk2003-12-231-1/+7
| | | | | | we do it ourselves. Nailed by: Simon Heath <heath@cng.fr>
* KASSERT against multiple orphanings of providers.phk2003-12-071-0/+4
|
* Fix a harmless bug and add a ')' in a debugging printf.phk2003-11-181-2/+2
| | | | Submitted by: "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
* Destroy providers maked with G_PF_WITHER when the last consumer has detached.phk2003-10-121-0/+2
|
* Use __FBSDID().obrien2003-06-111-2/+3
| | | | Approved by: phk
* Add missing va_end() calls.phk2003-06-071-4/+7
| | | | Noticed by: tmm
* Get rid of trivial function g_destroy_event().phk2003-05-021-10/+3
|
* Add a new flag, EV_CANCELED, and use it to make g_waitfor_event() returnphk2003-05-011-1/+5
| | | | EAGAIN if an event got canceled.
* When events on a reference is cancelled, check our doorstep first,phk2003-05-011-0/+7
| | | | it might be an orphan.
* Introduce a g_waitfor_event() function which posts an event and waits forphk2003-04-231-10/+63
| | | | it to be run (or cancelled) and use this instead of home-rolled versions.
* More of the event stuff can now be private to geom_event.cphk2003-04-231-1/+11
|
* Rename g_call_me() to g_post_event(), and give it a flagphk2003-04-231-4/+6
| | | | argument to determine if we can M_WAITOK in malloc.
* Remove the now unused hardcoded g_post_event() event support.phk2003-04-231-51/+4
|
* Turn EV_NEW_PROVIDER into a g_call_me() event.phk2003-04-231-22/+0
|
* Convert EV_SPOILED event to use g_call_me().phk2003-04-231-19/+1
|
* Turn the hardwired NEW_CLASS event into a g_call_me() event.phk2003-04-231-19/+1
|
* Move the shutdown eventhandler stuff to a more logical place.phk2003-04-231-11/+0
|
* Time has run from the "run GEOM in userland" harness, and the new regressionphk2003-04-131-13/+0
| | | | | | | test is built to test GEOM as running in the kernel. This commit is basically "unifdef -D_KERNEL" to remove the mainly #include related code to support the userland-harness.
* Fix a bug which resulted in orphanization getting confused every nowphk2003-04-121-1/+1
| | | | and then.
* Add handling for cancelled events in the g_call_me() methods.phk2003-04-021-0/+2
|
* Change events to have an array of "void *" references, and give thephk2003-04-021-62/+51
| | | | | | | | | | | event posting functions varargs to fill these. Attribute g_call_me() to appropriate g_geom's where necessary. Add a flag argument to g_call_me() methods which will be used to signal cancellation of events in the future. This commit should be a no-op.
* Save a lock: Grab the stall_events SX lock exclusively so it also serializephk2003-03-241-2/+2
| | | | OAM reqests.
* Introduce g_cancel_events() and use it a couple of places where it makesphk2003-03-231-0/+22
| | | | sense.
* Introduce an SX lock which allows us to stall event processingphk2003-03-231-0/+19
| | | | during OAM operations.
* #ifdef notyet a bit of code which needs not yet committed refcounting tophk2003-03-161-0/+2
| | | | work correctly.
* If we run out of consumers while orphaning them, and the provider's geomphk2003-03-101-0/+5
| | | | | | is withering, destroy the provider when done. This was exposed by the recent change to geom_dev's orphaning logic.
* Stamp out Danglish.phk2003-03-091-1/+1
|
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Remove g_silence(). It does not do anything anymore.phk2003-01-131-12/+1
|
* Polish a bit here and there.phk2002-11-041-7/+13
| | | | | | Reenable the geom.ctl device so people can play with gbde. Sponsored by: DARPA & NAI Labs
* Make sure we don't loose our topology lock in a call_me() handler.phk2002-09-301-0/+1
| | | | Sponsored by: DARPA & NAI Labs.
OpenPOWER on IntegriCloud