summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_disk.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r264320:bdrewery2014-04-211-1/+1
| | | | Fix spelling error in g_trace() call.
* MFC r258683:mav2014-01-091-11/+21
| | | | Escape special XML chars, returned by some devices, confusing XML parsers.
* MFC Alexander Motin's GEOM direct dispatch work:scottl2014-01-071-16/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r256603: Introduce new function devstat_end_transaction_bio_bt(), adding new argument to specify present time. Use this function to move binuptime() out of lock, substantially reducing lock congestion when slow timecounter is used. r256606: Move g_io_deliver() out of the lock, as required for direct dispatch. Move g_destroy_bio() out too to reduce lock scope even more. r256607: Fix passing uninitialized bio_resid argument to g_trace(). r256610: Add unmapped I/O support to GEOM RAID. r256830: Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping temporary mapped buffer. That fixes double unmap if biodone() called twice for the same BIO (but with different done methods). r256880: Merge GEOM direct dispatch changes from the projects/camlock branch. When safety requirements are met, it allows to avoid passing I/O requests to GEOM g_up/g_down thread, executing them directly in the caller context. That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid several context switches per I/O. r259247: Fix bug introduced at r256607. We have to recalculate bp_resid here since sizes of original and completed requests may differ due to end of media. Testing of the stable/10 merge was done by Netflix, but all of the credit goes to Alexander and iX Systems. Submitted by: mav Sponsored by: iX Systems
* Add new attribute lunname to report only textual LUN-specific device IDs.mav2013-08-241-0/+6
| | | | | While lunid attribute prefers to report numeric ones, having both may be useful in some situations.
* Bump disk(9) ABI version to signify the addition of d_delmaxsize by r249940.smh2013-07-031-8/+6
| | | | | | | | | | | Ensure that d_delmaxsize is always set, removing init to 0 which could cause future issues if use cases change. Allow kern.cam.da.X.delete_max (which maps to d_delmaxsize) to be increased up to the calculated max after being reduced. MFC after: 1 day X-MFC-With: r249940
* Make CAM return and GEOM DISK pass through new GEOM::lunid attribute.mav2013-06-121-1/+24
| | | | | | | | | | | | | | | | | | SPC-4 specification states that serial number may be property of device, but not a specific logical unit. People reported about FC storages using serial number in that way, making it unusable for purposes of LUN multipath detection. SPC-4 states that designators associated with logical unit from the VPD page 83h "Device Identification" should be used for that purpose. Report first of them in the new attribute in such preference order: NAA, EUI-64, T10 and SCSI name string. While there, make GEOM DISK properly report GEOM::ident in XML output also using d_getattr() method, if available. This fixes serial numbers reporting for SCSI disks in `geom disk list` output and confxml. Discussed with: gibbs, ken Sponsored by: iXsystems, Inc. MFC after: 2 weeks
* Don't update provider properties and don't set DISKFLAG_OPEN if d_open()mav2013-06-111-0/+2
| | | | | disk method call returned error. GEOM considers devices in such case as still closed, and won't call symmetric d_close() for them.
* Teach GEOM and CAM about the difference between the max "size" of r/w and deletesmh2013-04-261-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | requests. sys/geom/geom_disk.h: - Added d_delmaxsize which represents the maximum size of individual device delete requests in bytes. This can be used by devices to inform geom of their size limitations regarding delete operations which are generally different from the read / write limits as data is not usually transferred from the host to physical device. sys/geom/geom_disk.c: - Use new d_delmaxsize to calculate the size of chunks passed through to the underlying strategy during deletes instead of using read / write optimised values. This defaults to d_maxsize if unset (0). - Moved d_maxsize default up so it can be used to default d_delmaxsize sys/cam/ata/ata_da.c: - Added d_delmaxsize calculations for TRIM and CFA sys/cam/scsi/scsi_da.c: - Added re-calculation of d_delmaxsize whenever delete_method is set. - Added kern.cam.da.X.delete_max sysctl which allows the max size for delete requests to be limited. This is useful in preventing timeouts on devices who's delete methods are slow. It should be noted that this limit is reset then the device delete method is changed and that it can only be lowered not increased from the device max. Reviewed by: mav Approved by: pjd (mentor)
* Introduce a symbol for the GEOM class name instead of using the ad-hoc stringivoras2013-04-151-1/+1
| | | | constant.
* Following r241022, replace iteration over the provider list on media eventsmav2013-04-051-2/+10
| | | | | | by taking first one and asserting that there is no others. MFC after: 1 week
* In GEOM DISK:mav2013-03-251-56/+28
| | | | | | | - Replace single done mutex with per-disk ones. On system with several disks on several HBAs that removes small, but measurable lock congestion. - Modify disk destruction process to not destroy the mutex prematurely. - Remove some extra pointer derefences.
* A flag for the geom disk driver to indicate that it accepts thekib2013-03-191-1/+19
| | | | | | | unmapped i/o requests. Sponsored by: The FreeBSD Foundation Tested by: pho
* Fix locking problem in disk_resize(); previously it would run withouttrasz2012-10-291-21/+15
| | | | | | topology lock, resulting in assertion when running with DIAGNOSTIC. Reviewed by: mav (earlier version)
* Remove the topology lock from disk_gone(), it might be called with regularpjd2012-09-281-3/+5
| | | | | | | | | | | | | | mutexes held and the topology lock is an sx lock. The topology lock was there to protect traversing through the list of providers of disk's geom, but it seems that disk's geom has always exactly one provider. Change the code to call g_wither_provider() for this one provider, which is safe to do without holding the topology lock and assert that there is indeed only one provider. Discussed with: ken MFC after: 1 week
* Use the topology lock to protect list of providers while withering them.pjd2012-09-221-1/+4
| | | | | | | | | It is possible that provider is destroyed while we are iterating over the list. Reported by: Brian Parkison <parkison@panzura.com> Discussed with: phk MFC after: 1 week
* g_disk_flushcache definitely should not be traced under G_T_TOPOLOGYavg2012-09-181-1/+1
| | | | | | ... use G_T_BIO instead MFC after: 1 week
* Remove unneeded G_PF_CANDELETE flag.ed2012-08-281-6/+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-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 disk_resize(), to make it possible for the disk drivers such as da(4)trasz2012-07-071-0/+42
| | | | | | | to notify GEOM about LUN size change. Reviewed by: mav (earlier version) Sponsored by: FreeBSD Foundation
* In g_disk_providergone(), don't continue if the softc is NULL. This may beken2012-06-271-0/+8
| | | | | | | the case if we've already gone through g_disk_destroy(). Reported by: Michael Butler <imb@protected-networks.net> MFC after: 3 days
* Fix a bug which causes a panic in daopen(). The panic is caused byken2012-06-241-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.ed2011-11-071-1/+2
| | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static.
* Allow upper layers to discover than BIO_DELETE and/or BIO_FLUSH is notpjd2011-10-251-3/+3
| | | | | | supported by returning EOPNOTSUPP instead of 0 or ENODEV. MFC after: 3 days
* Improve style a bit.pjd2011-10-251-5/+7
| | | | MFC after: 3 days
* Simplify disk_alloc().pjd2011-10-251-4/+2
| | | | MFC after: 3 days
* Include sys/sbuf.h directly.ae2011-07-111-0/+1
| | | | Reviewed by: pjd
* Plumb device physical path reporting from CAM devices, through GEOM andgibbs2011-06-141-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update disk's stripesize and stripeoffset parameters on provider open.mav2011-06-031-0/+6
| | | | | | | | | They are media-dependent and may change in run-time, same as sectorsize and/or mediasize. SCSI devices return physical sector size and offset via READ CAPACITY(16) command and so can not report it until media inserted or at least until probe sequence completed. UNMAP support is also reported there.
* MFgraid/head r218212, r218257:mav2011-03-241-9/+90
| | | | | | | | | | | Introduce new type of BIO_GETATTR -- GEOM::setstate, used to inform lower GEOM about state of it's providers from the point of upper layers. Make geom_disk use led(4) subsystem to illuminate states in such fashion: FAILED - "1" (on), REBUILD - "f5" (slow blink), RESYNC - "f1" (fast blink), ACTIVE - "0" (off). LED name should be set for each disk via kern.geom.disk.%s.led sysctl. Later disk API could be extended to allow disk driver to report this info in custom way via it's own facilities.
* MFgraid/head r217827:mav2011-03-241-12/+8
| | | | | | | Change BIO_GETATTR("GEOM::kerneldump") API to make set_dumper() called by consumer (geom_dev) instead of provider (geom_disk). This allows any geom insert it's code into the dump call chain, implementing more sophisticated functionality then just disk partitioning.
* Add the disk ident and a human-meaningful description (here, the disk modelnwhitehorn2011-02-261-0/+2
| | | | | | | string) to the geom_disk config XML so that they are easily accessible from userland. MFC after: 1 week
* Remove the CTLFLAG_NOLOCK as it seems to be both unused andmdf2011-01-261-1/+2
| | | | | | | | | | | | unfunctional. Wiring the user buffer has only been done explicitly since r101422. Mark the kern.disks sysctl as MPSAFE since it is and it seems to have been mis-using the NOLOCK flag. Partially break the KPI (but not the KBI) for the sysctl_req 'lock' field since this member should be private and the "REQ_LOCKED" state seems meaningless now.
* Add reporting of GEOM::candelete BIO_GETATTR for md(4) and geom_disk(4).kib2010-12-291-1/+5
| | | | | | | | Non-zero value of attribute means that device supports BIO_DELETE. Suggested and reviewed by: pjd Tested by: pho MFC after: 1 week
* Export PCI IDs of ATA/SATA controllers through CAM and ata(4) layers tomav2010-07-251-0/+12
| | | | | GEOM. This information needed for proper soft-RAID's on-disk metadata reading and writing.
* Simplify g_disk_ident_adjust() function and allow any printable characterpjd2009-09-041-28/+15
| | | | | | | in serial number. Discussed with: trasz Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl)
* Revert r190676,190677thompsa2009-04-101-2/+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/+2
| | | | | | | provider tasting. This is needed for disk attachments that happen after threads are running in the boot process. Tested by: rnoland
* Revert r184136. Instead, push the check for crashdumpmap overflow into thekib2008-10-311-1/+1
| | | | | | | | MD i386 and amd64 dump code. Requested by: jhb Retested by: pho MFC after: 3 days (+ 176304 + 184136)
* Do not overflow crashdumpmap.kib2008-10-211-1/+1
| | | | | | Reported and tested by: pho Reviewed by: jhb MFC after: 1 week
* Add sbuf_new_auto as a shortcut for the very common case of creating ades2008-08-091-1/+1
| | | | | | | completely dynamic sbuf. Obtained from: Varnish MFC after: 2 weeks
* Teach the dump and minidump code to respect the maxioszie attribute ofscottl2008-02-151-0/+1
| | | | the disk; the hard-coded assumption of 64K doesn't work in all cases.
* Allow to use ':' in d_ident, which is quite handy character.pjd2007-05-051-1/+2
|
* Because there are many strange hardware out there, allow to use onlypjd2007-05-051-0/+39
| | | | [a-zA-Z0-9-_@#%.] characters in d_ident field.
* - Extend disk structure to allow to store disk's serial number, which can bepjd2007-05-051-1/+3
| | | | | | | retrieved via GEOM::ident attribute. - Bump disk(9) ABI version. OK'ed by: phk
* Reduce the noise when plugging in (USB) mass storage devices, like a 4 portn_hibma2007-02-211-1/+1
| | | | | | | | | flash card reader. Also remove an 'Opened da0 -> <random number>' which is not needed on a daily basis (available through bootverbose). Reviewed by: phk, ken MFC after: 1 week
* Add a new disk flag - DISKFLAG_CANFLUSHCACHE, which indicates that the diskpjd2006-10-311-1/+21
| | | | | | can handle BIO_FLUSH requests. Sponsored by: home.pl
* Add g_wither_provider() to abstract the details of destroying amarcel2006-04-101-1/+1
| | | | | | 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-0/+12
| | | | | | | | | | | | | | | | | | | | | | | 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
* Move some devstat collection to below where large IO operations are choppedtegge2005-09-301-3/+3
| | | | | | | up. This make iostat report operations passed down to the device driver instead of operations passed down to GEOM disk. The transfer size limit imposed by the device driver is no longer hidden, improving the correlation between iostat output and device driver workload.
* After rejecting the bio request early, return instead of panicing.phk2005-03-181-1/+3
| | | | Found by: Coverity (ID#450)
OpenPOWER on IntegriCloud