summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_subr.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce a kern.geom.notaste sysctl that can be used to temporarilydes2013-09-241-1/+3
| | | | | | | | | | disable GEOM tasting to avoid the "bouncing GEOM" problem where, when you shut down the consumer of a provider which can be viewed in multiple ways (typically a mirror whose members are labeled partitions), GEOM will immediately taste that provider's alter ego and reattach the consumer. Approved by: re (glebius)
* Make g_wither_washer() to not loop by itself, but only when there was somemav2013-03-241-20/+9
| | | | | | | | | 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.
* Allow to pass providers with /dev/ prefix to g_provider_by_name().pjd2012-09-011-0/+8
| | | | MFC after: 3 days
* Remove unneeded G_PF_CANDELETE flag.ed2012-08-281-1/+0
| | | | | This flag is only used by GEOM so it can be propagated to the character device's SI_CANDELETE. Unfortunately, SI_CANDELETE seems to do nothing.
* Implement media change notification for DA and CD removable media devices.mav2012-07-291-19/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add missing free.trasz2012-07-181-0/+1
|
* The resize GEOM event has no references, thus cannot be canceled.trasz2012-07-161-2/+0
|
* Add a new GEOM method, resize(), which is called after provider size changes.trasz2012-07-071-3/+76
| | | | | | | | Add a new routine, g_resize_provider(), to use to notify GEOM about provider change. Reviewed by: mav Sponsored by: FreeBSD Foundation
* Fix a bug which causes a panic in daopen(). The panic is caused byken2012-06-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a da(4) instance going away while GEOM is still probing it. In this case, the GEOM disk class instance has been created by disk_create(), and the taste of the disk is queued in the GEOM event queue. While that event is queued, the da(4) instance goes away. When the open call comes into the da(4) driver, it dereferences the freed (but non-NULL) peripheral pointer provided by GEOM, which results in a panic. The solution is to add a callback to the GEOM disk code that is called when all of its resources are cleaned up. This is implemented inside GEOM by adding an optional callback that is called when all consumers have detached from a provider, and the provider is about to be deleted. scsi_cd.c, scsi_da.c: In the register routine for the cd(4) and da(4) routines, acquire a reference to the CAM peripheral instance just before we call disk_create(). Use the new GEOM disk d_gone() callback to register a callback (dadiskgonecb()/cddiskgonecb()) that decrements the peripheral reference count once GEOM has finished cleaning up its resources. In the cd(4) driver, clean up open and close behavior slightly. GEOM makes sure we only get one open() and one close call, so there is no need to set an open flag and decrement the reference count if we are not the first open. In the cd(4) driver, use cam_periph_release_locked() in a couple of error scenarios to avoid extra mutex calls. geom.h: Add a new, optional, providergone callback that is called when a provider is about to be deleted. geom_disk.h: Add a new d_gone() callback to the GEOM disk interface. Bump the DISK_VERSION to version 2. This probably should have been done after a couple of previous changes, especially the addition of the d_getattr() callback. geom_disk.c: Add a providergone callback for the disk class, g_disk_providergone(), that calls the user's d_gone() callback if it exists. Bump the DISK_VERSION to 2. geom_subr.c: In g_destroy_provider(), call the providergone callback if it has been provided. In g_new_geomf(), propagate the class's providergone callback to the new geom instance. blkfront.c: Callers of disk_create() are supposed to pass in DISK_VERSION, not an explicit disk API version number. Update the blkfront driver to do that. disk.9: Update the disk(9) man page to include information on the new d_gone() callback, as well as the previously added d_getattr() callback, d_descr field, and HBA PCI ID fields. MFC after: 5 days
* Plumb device physical path reporting from CAM devices, through GEOM andgibbs2011-06-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement relaxed comparision for hardcoded provider names to make itmav2011-04-271-0/+37
| | | | | ignore adX/adaY difference in both directions to simplify migration to the CAM-based ATA or back.
* Fix deadlock between GEOM class unloading and withering. Withering can'tjh2010-05-051-47/+51
| | | | | | | | | proceed while g_unload_class() blocks the event thread. Fix this by not running g_unload_class() as a GEOM event and dropping the topology lock when withering needs to proceed. PR: kern/139847 Silence on: freebsd-geom
* Fix ddb(4) "show geom addr" command when INVARIANTS is enabled. Don'tjh2010-04-191-7/+13
| | | | | | | assert that the topology lock is held when g_valid_obj() is called from debugger. MFC after: 1 week
* Log attach just like we log detach.pjd2010-02-181-0/+1
|
* Fix a panic which (reportedly) can happen when unmounting a filesystemtrasz2009-07-011-0/+2
| | | | | | | | | with I/O requests in flight on kernels compiled with "options INVARIANTS". Also, make it obvious it's not right to call g_valid_obj() (and macros using it, e.g. G_VALID_CONSUMER()) without topology lock held. Approved by: re (kib) Reported by: pho
* Simplify.pjd2009-06-051-4/+2
|
* - Unbreak 64 bit platforms by casting off_t to intmax.lulf2009-05-261-3/+3
|
* - Fix wrong print on BIO_DONE.lulf2009-05-261-46/+46
| | | | | | | - Use db_printf instead of printf. While here, apply this to other ddb commands as well. Pointed out by: pjd
* - Add 'show bio' DDB command.lulf2009-05-261-0/+70
| | | | MFC after: 3 weeks
* Revert r190676,190677thompsa2009-04-101-5/+0
| | | | | | | The geom and CAM changes for root_hold are the wrong solution for USB design quirks. Requested by: scottl
* Add interleaving root hold tokens from the CAM probe to disk_create and geomthompsa2009-04-031-0/+5
| | | | | | | provider tasting. This is needed for disk attachments that happen after threads are running in the boot process. Tested by: rnoland
* In g_handleattr(), set bp->bio_completed also for the casemarcel2009-02-031-1/+2
| | | | | where len is 0. Otherwise g_getattr() will never succeed when it is handled by g_handleattr_str().
* Constify val in g_handleattr() and str in g_handleattr_str().marcel2009-02-011-2/+2
| | | | This allows passing string constants to g_handleattr_str().
* - Add missing word in comment.lulf2008-12-081-1/+1
|
* Add sbuf_new_auto as a shortcut for the very common case of creating ades2008-08-091-2/+2
| | | | | | | completely dynamic sbuf. Obtained from: Varnish MFC after: 2 weeks
* - Assert that we don't send new provider event for a provider which haspjd2008-05-181-1/+3
| | | | | G_PF_WITHER flag set. - Fix typo in assertion condition (sorry, but I forgot who report that).
* Play nice with DDB pager.pjd2008-05-181-4/+18
| | | | Educated by: jhb's BSDCan presentation
* When retasting, wither any existing GEOMs of the same class. Thismarcel2008-03-281-1/+7
| | | | | | | | | | | allows the class to create a different GEOM for the same provider as well as avoid that we end up with multiple GEOMs of the same class with the same name. For example, when a disk contains a PC98 partition table but only MBR is supported, then the partition table can be treated as a MBR. If support for PC98 is later loaded as a module, the MBR scheme is pre-empted for the PC98 scheme as expected.
* Add g_retaste(), which given a class will present all non-open providersmarcel2008-03-231-0/+60
| | | | | | | | | | to it for tasting. This is useful when the class, through means outside the scope of GEOM, can claim providers previously unclaimed. The g_retaste() function posts an event which is handled by the g_retaste_event(). Event suggested by: phk
* - Implement helper g_handleattr_str() function for string attributespjd2007-05-051-7/+22
| | | | | | | handling. - Extend g_handleattr() to treat attribute as string when len=0. OK'ed by: phk
* Add 'show geom [addr]' ddb(4) command, which prints entire GEOM topology ifpjd2006-09-151-1/+212
| | | | | | | no additional argument is given or details about the given GEOM object (class, geom, provider or consumer). Approved by: phk
* Add g_wither_provider() to abstract the details of destroying amarcel2006-04-101-0/+12
| | | | | | particular provider. Use this function where g_orphan_provider() is being called so that the flags are updated correctly and g_orphan_provider() is called only when allowed.
* Fix a bug that caused some /dev entries to continue to exist afterjdp2005-11-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | the underlying drive had been hot-unplugged from the system. Here is a specific example. Filesystem code had opened /dev/da1s1e. Subsequently, the drive was hot-unplugged. This (correctly) caused all of the associated /dev/da1* entries to be deleted. When the filesystem later realized that the drive was gone it closed the device, reducing the write-access counts to 0 on the geom providers for da1s1e, da1s1, and da1. This caused geom to re-taste the providers, resulting in the devices being created again. When the drive was hot-plugged back in, it resulted in duplicate /dev entries for da1s1e, da1s1, and da1. This fix adds a new disk_gone() function which is called by CAM when a drive goes away. It orphans all of the providers associated with the drive, setting an error condition of ENXIO in each one. In addition, we prevent a re-taste on last close for writing if an error condition has been set in the provider. Sponsored by: Isilon Systems Reviewed by: phk MFC after: 1 week
* fix a "modify after free" bug which is practically impossible tophk2005-03-261-5/+8
| | | | | | experience. Found by: Coverity (id #540 #541)
* Add g_wither_geom_close() function.phk2004-10-291-0/+17
|
* Don't call g_waitidle(), it happens automagically now.phk2004-10-231-1/+0
|
* - Turn KASSERT()s into warning printf()'s in the g_class_load() routine.arr2004-10-221-10/+26
| | | | | | | This removes a panic that will occur if you build with GENERIC and attempt to kldload a GEOM module that is already in the kernel. Reviewed by: phk
* When loading GEOM modules, we expect the actual load process to be donegreen2004-10-121-1/+9
| | | | | | | | | | | | | | | | by the time that kldload(8) returns. Satisfy that by making the GEOM module load event -- only when the kernel is !cold -- wait until the GEOM module init function has finished instead of returning immediately. This is the other half of fixing md(8) (actually, "mfs" in fstab(5)) that is similar to r1.128 of src/sys/dev/md/md.c. This bug would be why RAM disks would often fail on boot and the first call to mdconfig(8) would probably fail. pjd has ideas for not requiring kldload(8) to work synchronously for control devices that could make this obsolete. Silence on: -arch
* For removable devices without media we set a zero mediasize but a non-zerophk2004-09-051-0/+3
| | | | | | | | sectorsize in order to avoid a lot of checks around various divisions etc. Enforce the sectorsize being > 0 with a KASSERT on successful open. Fix scsi_cd.c to return 2k sectors when no media inserted.
* OK, now check geom class version numbers.phk2004-08-081-1/+1
|
* OOps, that check was a bit premature. Allow zero versions as well.phk2004-08-081-1/+1
|
* Give classes a version number and refuse to touch classes which are notphk2004-08-081-0/+14
| | | | | | | | understood. This makes room for additional binary compatibility in the future. Put fields in the class for the geom's methods and initialize the methods of a new geom from these fields. This saves some code in all classes.
* Only detach consumers which are attached when we wither stuff away.phk2004-07-091-1/+2
| | | | Pointed out by: pjd
* Make withering water tight.phk2004-07-081-25/+59
| | | | | | | | | 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.
* Fail normally rather than KASSERT if attempt to open a spoiled consumer.phk2004-07-081-5/+3
|
* Move "is consumer attached?" check before G_VALID_PROVIDER() check,pjd2004-03-181-1/+1
| | | | | | | because if consumer is not attached, its provider never will be valid, so we never reach this check. Approved by: phk
* Be more insistent on destroying geoms at unload time. Still not perfect,phk2004-03-111-2/+8
| | | | | | | | but it will do (better) for now. KASSERT that to have providers a class must have an access method. Tag the new_provider event with the geom as well.
* Rearrange some of the GEOM debugging tools to be more structured.phk2004-03-101-57/+42
| | | | | | | | | | | | | | | | | | 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.
* Don't panic on providers already withered when we wither a geom.phk2004-03-071-1/+2
|
* Add a KASSERT which checks that a class never fails a closing ->access()phk2004-02-141-0/+3
| | | | call.
OpenPOWER on IntegriCloud