aboutsummaryrefslogtreecommitdiff
path: root/sys/geom/mirror/g_mirror.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement GEOM::rotation_rate for gmirrorAlan Somers2023-09-061-0/+1
| | | | | | | | | | | | If all of the mirror's children have the same rotation rate, report that. But if they have mixed rotation rates, or if any child has an unknown rotation rate, report "Unknown". Sponsored by: Axcient Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D39458 (cherry picked from commit 9309a460b23a8cda8d47c5f775da7fc6472d9925)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-251-1/+1
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* gmirror: Pre-allocate the timeout event structureMark Johnston2021-03-181-0/+1
| | | | | | | | | | | | We can't call malloc(M_WAITOK) in a callout handler. Reviewed by: imp Reported by: pho Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29223 (cherry picked from commit 2f1cfb7f63ca744e7a143896347bdc8606c291d6)
* GEOM: Reduce unnecessary log interleaving with sbufsConrad Meyer2019-08-071-22/+4
| | | | | | | | | | | | | | | Similar to what was done for device_printfs in r347229. Convert g_print_bio() to a thin shim around g_format_bio(), which acts on an sbuf; documented in g_bio.9. Reviewed by: markj Discussed with: rlibby Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21165 Notes: svn path=/head/; revision=350694
* gmirror: Relocate DEVICE_FLAGS to adjacent linesConrad Meyer2019-01-231-6/+6
| | | | | | | | | | | | | | gmirror's sc_flags is shared between some on-disk state and some runtime only state. There's no real reason for that and they could probably be split up. Until they are, locate all of the flags for the same field nearby each other in the source, for clarity. No functional change. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=343347
* gmirror: Evaluate mirror components against newest metadata copyConrad Meyer2018-12-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-apply r341665 with format strings fixed. If we happen to taste a stale mirror component first, don't reject valid, newer components that have differing metadata from the stale component (during STARTING). Instead, update our view of the most recent metadata as we taste components. Like mediasize beforehand, remove some checks from g_mirror_check_metadata which would evict valid components due to metadata that can change over a mirror's lifetime. g_mirror_check_metadata is invoked long before we check genid/syncid and decide which component(s) are newest and whether or not we have quorum. Before checking if we can enter RUNNING (i.e., we have quorum) after a NEW component is added, first remove any known stale or inconsistent disks from the mirrorset, rather than removing them *after* deciding we have quorum. Check if we have quorum after removing these components. Additionally, add a knob, kern.geom.mirror.launch_mirror_before_timeout, to force gmirrors to wait out the full timeout (kern.geom.mirror.timeout) before transitioning from STARTING to RUNNING. This is a kludge to help ensure all eligible, boot-time available mirror components are tasted before RUNNING a gmirror. Add a basic test case for STARTING -> RUNNING startup behavior around stale genids. PR: 232671, 232835 Submitted by: Cindy Yang <cyang AT isilon.com> (previous version) Reviewed by: markj (kernel portions) Discussed with: asomers, Cindy Yang Tested by: pho Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D18062 Notes: svn path=/head/; revision=341674
* Revert r341665 due to tinderbox breakageConrad Meyer2018-12-071-4/+0
| | | | | | | | I didn't notice that some format strings were non-portable. Will fix and re-commit later. Notes: svn path=/head/; revision=341672
* gmirror: Evaluate mirror components against newest metadata copyConrad Meyer2018-12-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we happen to taste a stale mirror component first, don't reject valid, newer components that have differing metadata from the stale component (during STARTING). Instead, update our view of the most recent metadata as we taste components. Like mediasize beforehand, remove some checks from g_mirror_check_metadata which would evict valid components due to metadata that can change over a mirror's lifetime. g_mirror_check_metadata is invoked long before we check genid/syncid and decide which component(s) are newest and whether or not we have quorum. Before checking if we can enter RUNNING (i.e., we have quorum) after a NEW component is added, first remove any known stale or inconsistent disks from the mirrorset, rather than removing them *after* deciding we have quorum. Check if we have quorum after removing these components. Additionally, add a knob, kern.geom.mirror.launch_mirror_before_timeout, to force gmirrors to wait out the full timeout (kern.geom.mirror.timeout) before transitioning from STARTING to RUNNING. This is a kludge to help ensure all eligible, boot-time available mirror components are tasted before RUNNING a gmirror. When we are instructed to forget mirror components, bump the generation id to avoid confusion with such stale components later. Add a basic test case for STARTING -> RUNNING startup behavior around stale genids. PR: 232671, 232835 Submitted by: Cindy Yang <cyang AT isilon.com> (previous version) Reviewed by: markj (kernel portions) Discussed with: asomers, Cindy Yang Tested by: pho Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D18062 Notes: svn path=/head/; revision=341665
* Clarify the use of the gmirror flag mask constants.Mark Johnston2018-01-101-0/+4
| | | | | | | | MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=327768
* Avoid using bioq_* in gmirror.Mark Johnston2017-12-191-9/+6
| | | | | | | | | | | | | | | | gmirror does not perform any sorting of I/O requests, so the bioq API doesn't provide any advantages over plain TAILQs. The API also does not provide operations needed by an upcoming change. No functional change intended. The diff shrinks the geom_mirror.ko text and the gmirror softc slightly. Tested by: pho (part of a larger patch) MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=326983
* Update gmirror metadata less frequently when synchronizing.Mark Johnston2017-11-301-0/+1
| | | | | | | | | | | | | | | | | We periodically record synchronization progress in the metadata block of the disk being synchronized; this allows an interrupted synchronization to be resumed. However, the frequency of these updates heavily pessimized synchronization time on some media. This change modifies gmirror to update metadata based on a time period, and adds a sysctl to control that period. The default value results in a much lower update frequency and increases the completion time for an interrupted rebuild only marginally. Reported by: Andre Albsmeier <andre@fbsd.e4m.org> MFC after: 3 weeks Notes: svn path=/head/; revision=326409
* sys/geom: adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326270
* Allow kern.geom.mirror.debug to be negative.Mark Johnston2017-11-231-1/+1
| | | | | | | | | | | A negative value can be used to suppress all prints from the gmirror kernel code, which can be useful when attempting to trigger race conditions using stress tests. MFC after: 1 week Notes: svn path=/head/; revision=326132
* gmirror: treat ENXIO as disk disconnect, not media errorAndriy Gapon2017-09-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In theory, all data access errors mean that a member is out of sync at most. But they were treated as more serious errors to avoid the situation where a flaky disk gets repeatedly disconnected, re-synchronized, reconnected and then disconnected again. ENXIO is a special error that means that the member disk disappeared, so it should get the same handling as the GEOM orphaning event. There is a better chance that when the disk is reconnected, it will be a good member again. When ENXIO happens on a read we use the exisiting G_MIRROR_BUMP_SYNCID mechanism which means that the mirror's syncid is increased as soon as there is a write to the mirror. That's because no data has got out of sync yet, but the problematic memeber is disconnected, so the future write will make it stale. When ENXIO happens on a write we use a new G_MIRROR_BUMP_SYNCID_NOW mechanism which means that we update the mirror metadata as soon as possible because the problematic memeber is already behind. Reviewed by: markj, imp MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9463 Notes: svn path=/head/; revision=323612
* Rename two gmirror state flags to make their meanings slightly clearer.Mark Johnston2017-04-141-2/+2
| | | | | | | | | | No functional change. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316869
* Add `gmirror create` subcommand, alike to gstripe, gconcat, etc.Alexander Motin2016-11-301-0/+8
| | | | | | | | | | | | It is quite specific mode of operation without storing on-disk metadata. It can be useful in some cases in combination with some external control tools handling mirror creation and disks hot-plug. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=309321
* Use providergone method to cover race between destroy and g_access().Alexander Motin2016-11-131-0/+1
| | | | | | | | | Reviewed by: markj MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=308608
* Fix possible geom destruction before final provider close.Alexander Motin2016-10-061-0/+1
| | | | | | | | | | | Introduce internal counter to track opens. Using provider's counters is not very successfull after calling g_wither_provider(). MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=306762
* Add an ability to stop gmirror and clear its metadata in one command.Andrey V. Elsukov2013-12-271-0/+1
| | | | | | | | | | | | | | | | | This fixes the problem, when gmirror starts again just after stop. The problem occurs when gmirror's component has geom label with equal size. E.g. gpt and gptid have the same size as partition, diskid has the same size as entire disk. When gmirror's geom has been destroyed, glabel creates its providers and this initiate retaste. Now "gmirror destroy" command is available. It destroys geom and also erases gmirror's metadata. MFC after: 2 weeks Notes: svn path=/head/; revision=259929
* Merge GEOM direct dispatch changes from the projects/camlock branch.Alexander Motin2013-10-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. The defined now safety requirements are: - caller should not hold any locks and should be reenterable; - callee should not depend on GEOM dual-threaded concurency semantics; - on the way down, if request is unmapped while callee doesn't support it, the context should be sleepable; - kernel thread stack usage should be below 50%. To keep compatibility with GEOM classes not meeting above requirements new provider and consumer flags added: - G_CF_DIRECT_SEND -- consumer code meets caller requirements (request); - G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done); - G_PF_DIRECT_SEND -- provider code meets caller requirements (done); - G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request). Capable GEOM class can set them, allowing direct dispatch in cases where it is safe. If any of requirements are not met, request is queued to g_up or g_down thread same as before. Such GEOM classes were reviewed and updated to support direct dispatch: CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE, VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL, MAP, FLASHMAP, etc). To declare direct completion capability disk(9) KPI got new flag equivalent to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk drivers got it set now thanks to earlier CAM locking work. This change more then twice increases peak block storage performance on systems with manu CPUs, together with earlier CAM locking changes reaching more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to 256 user-level threads). Sponsored by: iXsystems, Inc. MFC after: 2 months Notes: svn path=/head/; revision=256880
* Make geom_mirror more friendly to SSDs. To properly support TRIM,Gleb Smirnoff2012-07-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | we need to pass BIO_DELETE requests down to providers that support it. Also, we need to announce our support for BIO_DELETE to upper consumer. This requires: - In g_mirror_start() return true for "GEOM::candelete" request. - In g_mirror_init_disk() probe below provider for "GEOM::candelete" attribute, and mark disk with a flag if it does support BIO_DELETE. - In g_mirror_register_request() distribute BIO_DELETE requests only to those disks, that do support it. Note that we announce "GEOM::candelete" as true unconditionally of whether we have TRIM-capable media down below or not. This is made intentionally, because upper consumer (usually UFS) requests the attribite only once at mount time. And if user ever migrates his mirror from HDDs to SSDs, then he/she would get TRIM working without remounting filesystem. Reviewed by: pjd Notes: svn path=/head/; revision=237930
* Introduce new device flag G_MIRROR_DEVICE_FLAG_TASTING. It shouldAndrey V. Elsukov2012-05-181-0/+1
| | | | | | | | | | | protect geom from destroying while it is tasting. PR: kern/154860 Reviewed by: pjd MFC after: 1 week Notes: svn path=/head/; revision=235599
* Change 'load' balancing mode algorithm:Alexander Motin2009-12-031-2/+2
| | | | | | | | | | | | | | | | - Instead of measuring last request execution time for each drive and choosing one with smallest time, use averaged number of requests, running on each drive. This information is more accurate and timely. It allows to distribute load between drives in more even and predictable way. - For each drive track offset of the last submitted request. If new request offset matches previous one or close for some drive, prefer that drive. It allows to significantly speedup simultaneous sequential reads. PR: kern/113885 Reviewed by: sobomax Notes: svn path=/head/; revision=200086
* Now, that we have gjournal in the tree add possibility to configurePawel Jakub Dawidek2006-11-011-4/+10
| | | | | | | | | gmirror and graid3 in a way that it is not resynchronized after a power failure or system crash. It is safe when gjournal is running on top of gmirror/graid3. Notes: svn path=/head/; revision=163888
* Introduce and use delayed-destruction functionality from a pre-sync hook,Pawel Jakub Dawidek2006-04-101-1/+5
| | | | | | | | | | | | | which means that devices will be destroyed on last close. This fixes destruction order problems when, eg. RAID3 array is build on top of RAID1 arrays. Requested, reviewed and tested by: ru MFC after: 2 weeks Notes: svn path=/head/; revision=157630
* Update copyright for 2006.Pawel Jakub Dawidek2006-03-191-1/+1
| | | | Notes: svn path=/head/; revision=156878
* - Speed up synchronization process by using configurable number of I/OPawel Jakub Dawidek2006-03-131-5/+14
| | | | | | | | | | | | | | | | | | requests in parallel. + Add kern.geom.mirror.sync_requests tunable which defines how many parallel I/O requests should be used. + Retire kern.geom.mirror.reqs_per_sync and kern.geom.mirror.syncs_per_sec sysctls. - Fix race between regular and synchronization requests. - Reimplement mirror's data synchronization - do not use the topology lock for this purpose, as it may case deadlocks. - Stop synchronization from pre-sync hook. - Fix some other minor issues. MFC after: 3 days Notes: svn path=/head/; revision=156610
* - Add kern.geom.mirror.disconnect_on_failure sysctl/tunnable (default to 1Pawel Jakub Dawidek2006-02-111-0/+1
| | | | | | | | | | | | | | | | | | to preserve currect behaviour). When set to 0, components are not disconnected - gmirror will try to still use them (only first error will be logged). This is helpful when we have two broken components, but in different places, so actually all data is available. Such buggy component will be visible in 'gmirror list' output with flag BROKEN. - Never disconnect the last valid component. If we detect errors there we will just pass them up. This wasn't reasonable to deny access to the whole provider because of one broken sector. Prodded by: ru MFC after: 3 days Notes: svn path=/head/; revision=155545
* Mark array as CLEAN when there are no write requests inPawel Jakub Dawidek2006-02-111-0/+2
| | | | | | | | | | | kern.geom.mirror.idletime seconds. Write, not any requests. Mark array as clean immediatelly on last write close. Prodded by: ru MFC after: 3 days Notes: svn path=/head/; revision=155539
* Remove trailing spaces.Pawel Jakub Dawidek2006-02-011-1/+1
| | | | Notes: svn path=/head/; revision=155174
* Remove the hack which allowed to use gmirror for root file system,Pawel Jakub Dawidek2005-04-191-0/+2
| | | | | | | use root_mount KPI instead. Notes: svn path=/head/; revision=145305
* - Add md_provsize field to metadata, which will help withPawel Jakub Dawidek2005-02-271-3/+44
| | | | | | | | | | | | | | | | | | | | shared-last-sector problem. After this change, even if there is more than one provider with the same last sector, the proper one will be chosen based on its size. It still doesn't fix the 'c' partition problem (when da0s1 can be confused with da0s1c) and situation when 'a' partition starts at offset 0 (then da0s1a can be confused with da0s1 and da0s1c). One can use '-h' option there, when creating device or avoid sharing last sector. Actually, when providers share the same last sector and their size is equal, they provide exactly the same data, so the name (da0s1, da0s1a, da0s1c) isn't important at all. - Provide backward compatibility. - Update copyright's year. MFC after: 1 week Notes: svn path=/head/; revision=142727
* Update copyright in files changed this year.Pawel Jakub Dawidek2005-02-161-1/+1
| | | | Notes: svn path=/head/; revision=141994
* Spoiling is now not possible, because we keep consumers open for writingPawel Jakub Dawidek2005-01-041-7/+2
| | | | | | | | | all the time. Remove unused code then. MFC after: 4 days Notes: svn path=/head/; revision=139670
* Fix 'rebuild' command (we ignore retaste event now, so don't relay on it).Pawel Jakub Dawidek2005-01-031-0/+3
| | | | Notes: svn path=/head/; revision=139650
* - Add genid field to the metadata which will allow to improve reliability a bit.Pawel Jakub Dawidek2004-12-221-19/+88
| | | | | | | | | | | | | | | | | | | After this change, when component is disconnected because of an I/O error, it will not be connected and synchronized automatically, it will be logged as broken and skipped. Autosynchronization can occur, when component is disconnected (on orphan event) and connected again - there were no I/O error, so there is no need to not connected the component, but when there were writes while it wasn't connected, it will be synchronized. This fix cases, when component is disconnected because of I/O error and can be connected again and again. - Bump version number. - Add version change history. - Implement backward compatibility mechanism. After this change when metadata in old version is detected, it is automatically upgraded to the new (current) version. Notes: svn path=/head/; revision=139213
* MFp4:Pawel Jakub Dawidek2004-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | - Fix for good (I hope) force-stopping mirrors and some filure cases (e.g. the last good component dies when synchronization is in progress). Don't use ->nstart/->nend consumer's fields, as this could be racy, because those fields are used in g_down/g_up, use ->index consumer's field instead for tracking number of not finished requests. Reported by: marcel - After 5 seconds of idle time (this should be configurable) mark all dirty providers as clean, so when mirror is not used in 5 seconds and there will be power failure, no synchronization on boot is needed. Idea from: sorry, I can't find who suggested this - When there are no ACTIVE components and no NEW components destroy whole mirror, not only provider. - Fix one debug to show information about I/O request, before we change its command. Notes: svn path=/head/; revision=137248
* Just use MAXPHYS as maximum I/O request size, instead of using my ownPawel Jakub Dawidek2004-09-281-2/+0
| | | | | | | | #define for this purpose. No functional change. Notes: svn path=/head/; revision=135872
* Forgot to commit addition of ds_resync field.Pawel Jakub Dawidek2004-09-261-0/+1
| | | | Notes: svn path=/head/; revision=135834
* MFp4: Simplify code a bit:Pawel Jakub Dawidek2004-08-111-6/+6
| | | | | | | | | | | | | | - Remove kern.geom.mirror.sync_block_size sysctl. It is quite obvious that we want to use the biggest size possible. - Do not use UMA zone for sync data allocations. There could be only one synchronization request per synchronized disk at a time, so allocate memory for one request on whole synchronization process related to one disk. Tested by synchronizing one component (out of three) and by synchronizing two components (out of three) in parallel. Notes: svn path=/head/; revision=133530
* Actually, HARDCODED flag isn't stored in metadata, so don't botherPawel Jakub Dawidek2004-08-111-2/+0
| | | | | | | dumping it. Notes: svn path=/head/; revision=133528
* - Fix typo.Pawel Jakub Dawidek2004-08-111-1/+3
| | | | | | | - Dump HARDCODED flag. Notes: svn path=/head/; revision=133527
* - Introduce option for hardcoding providers' names into metadata.Pawel Jakub Dawidek2004-08-091-5/+10
| | | | | | | | | | | | | | | It allows to fix problems when last provider's sector is shared between few providers. - Bump version number for CONCAT and STRIPE and add code for backward compatibility. - Do not bump version number of MIRROR, as it wasn't officially introduced yet. Even if someone started to play with it, there is no big deal, because wrong MD5 sum of metadata will deny those providers. - Update manual pages. - Add version history to g_(stripe|concat).h files. Notes: svn path=/head/; revision=133373
* - Add two fields to bio structure: 'bio_cflags' which can be used byPawel Jakub Dawidek2004-08-041-0/+3
| | | | | | | | | | | | | | | consumer and 'bio_pflags' which can be used by provider. - Remove BIO_FLAG1 and BIO_FLAG2 flags. From now on new fields should be used for internal flags. - Update g_bio(9) manual page. - Update some comments. - Update GEOM_MIRROR, which was the only one using BIO_FLAGs. Idea from: phk Reviewed by: phk Notes: svn path=/head/; revision=133142
* - Add "prefer" balance algorithm. When used, only disk with the biggestPawel Jakub Dawidek2004-08-041-3/+6
| | | | | | | | priority will be used for reading. - Bump version number. Notes: svn path=/head/; revision=133115
* Remove unused field.Pawel Jakub Dawidek2004-07-311-1/+0
| | | | Notes: svn path=/head/; revision=132923
* Add GEOM_MIRROR class which provide RAID1 functionality and has many usefulPawel Jakub Dawidek2004-07-301-0/+350
features. The gmirror(8) utility should be used for control of this class. There is no manual page yet, but I'm working on it with keramida@. Many useful tests provided by: simon (thank you!) Some ideas from: scottl, simon, phk Notes: svn path=/head/; revision=132904