127c74787SPoul-Henning Kamp.\" 227c74787SPoul-Henning Kamp.\" Copyright (c) 2002 Poul-Henning Kamp 327c74787SPoul-Henning Kamp.\" Copyright (c) 2002 Networks Associates Technology, Inc. 427c74787SPoul-Henning Kamp.\" All rights reserved. 527c74787SPoul-Henning Kamp.\" 627c74787SPoul-Henning Kamp.\" This software was developed for the FreeBSD Project by Poul-Henning Kamp 727c74787SPoul-Henning Kamp.\" and NAI Labs, the Security Research Division of Network Associates, Inc. 827c74787SPoul-Henning Kamp.\" under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 927c74787SPoul-Henning Kamp.\" DARPA CHATS research program. 1027c74787SPoul-Henning Kamp.\" 1127c74787SPoul-Henning Kamp.\" Redistribution and use in source and binary forms, with or without 1227c74787SPoul-Henning Kamp.\" modification, are permitted provided that the following conditions 1327c74787SPoul-Henning Kamp.\" are met: 1427c74787SPoul-Henning Kamp.\" 1. Redistributions of source code must retain the above copyright 1527c74787SPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer. 1627c74787SPoul-Henning Kamp.\" 2. Redistributions in binary form must reproduce the above copyright 1727c74787SPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer in the 1827c74787SPoul-Henning Kamp.\" documentation and/or other materials provided with the distribution. 1927c74787SPoul-Henning Kamp.\" 3. The names of the authors may not be used to endorse or promote 2027c74787SPoul-Henning Kamp.\" products derived from this software without specific prior written 2127c74787SPoul-Henning Kamp.\" permission. 2227c74787SPoul-Henning Kamp.\" 2327c74787SPoul-Henning Kamp.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2427c74787SPoul-Henning Kamp.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2527c74787SPoul-Henning Kamp.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2627c74787SPoul-Henning Kamp.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2727c74787SPoul-Henning Kamp.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2827c74787SPoul-Henning Kamp.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2927c74787SPoul-Henning Kamp.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3027c74787SPoul-Henning Kamp.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3127c74787SPoul-Henning Kamp.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3227c74787SPoul-Henning Kamp.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3327c74787SPoul-Henning Kamp.\" SUCH DAMAGE. 3427c74787SPoul-Henning Kamp.\" 3527c74787SPoul-Henning Kamp.\" $FreeBSD$ 3627c74787SPoul-Henning Kamp.\" 37*28ffa766SEdward Tomasz Napierala.Dd April 20, 2017 3827c74787SPoul-Henning Kamp.Dt GEOM 4 39aa12cea2SUlrich Spörlein.Os 4027c74787SPoul-Henning Kamp.Sh NAME 4127c74787SPoul-Henning Kamp.Nm GEOM 4278ad5421SRuslan Ermilov.Nd "modular disk I/O request transformation framework" 439218a6ebSJoel Dahl.Sh SYNOPSIS 449218a6ebSJoel Dahl.Cd options GEOM_AES 459218a6ebSJoel Dahl.Cd options GEOM_BDE 469218a6ebSJoel Dahl.Cd options GEOM_BSD 479218a6ebSJoel Dahl.Cd options GEOM_CACHE 489218a6ebSJoel Dahl.Cd options GEOM_CONCAT 499218a6ebSJoel Dahl.Cd options GEOM_ELI 509218a6ebSJoel Dahl.Cd options GEOM_FOX 519218a6ebSJoel Dahl.Cd options GEOM_GATE 529218a6ebSJoel Dahl.Cd options GEOM_JOURNAL 539218a6ebSJoel Dahl.Cd options GEOM_LABEL 549218a6ebSJoel Dahl.Cd options GEOM_LINUX_LVM 55fcdb1ffcSAndrey V. Elsukov.Cd options GEOM_MAP 569218a6ebSJoel Dahl.Cd options GEOM_MBR 579218a6ebSJoel Dahl.Cd options GEOM_MIRROR 58*28ffa766SEdward Tomasz Napierala.Cd options GEOM_MOUNTVER 599218a6ebSJoel Dahl.Cd options GEOM_MULTIPATH 609218a6ebSJoel Dahl.Cd options GEOM_NOP 619218a6ebSJoel Dahl.Cd options GEOM_PART_APM 629218a6ebSJoel Dahl.Cd options GEOM_PART_BSD 63fcdb1ffcSAndrey V. Elsukov.Cd options GEOM_PART_BSD64 649218a6ebSJoel Dahl.Cd options GEOM_PART_EBR 659218a6ebSJoel Dahl.Cd options GEOM_PART_EBR_COMPAT 669218a6ebSJoel Dahl.Cd options GEOM_PART_GPT 679218a6ebSJoel Dahl.Cd options GEOM_PART_LDM 689218a6ebSJoel Dahl.Cd options GEOM_PART_MBR 699218a6ebSJoel Dahl.Cd options GEOM_PART_VTOC8 709218a6ebSJoel Dahl.Cd options GEOM_RAID 719218a6ebSJoel Dahl.Cd options GEOM_RAID3 729218a6ebSJoel Dahl.Cd options GEOM_SHSEC 739218a6ebSJoel Dahl.Cd options GEOM_STRIPE 749218a6ebSJoel Dahl.Cd options GEOM_SUNLABEL 759218a6ebSJoel Dahl.Cd options GEOM_UZIP 769218a6ebSJoel Dahl.Cd options GEOM_VIRSTOR 779218a6ebSJoel Dahl.Cd options GEOM_VOL 789218a6ebSJoel Dahl.Cd options GEOM_ZERO 7927c74787SPoul-Henning Kamp.Sh DESCRIPTION 8078ad5421SRuslan ErmilovThe 8178ad5421SRuslan Ermilov.Nm 8278ad5421SRuslan Ermilovframework provides an infrastructure in which 8378ad5421SRuslan Ermilov.Dq classes 8427c74787SPoul-Henning Kampcan perform transformations on disk I/O requests on their path from 8527c74787SPoul-Henning Kampthe upper kernel to the device drivers and back. 8627c74787SPoul-Henning Kamp.Pp 8778ad5421SRuslan ErmilovTransformations in a 8878ad5421SRuslan Ermilov.Nm 8978ad5421SRuslan Ermilovcontext range from the simple geometric 90d773aebdSPoul-Henning Kampdisplacement performed in typical disk partitioning modules over RAID 9127c74787SPoul-Henning Kampalgorithms and device multipath resolution to full blown cryptographic 9227c74787SPoul-Henning Kampprotection of the stored data. 9327c74787SPoul-Henning Kamp.Pp 9478ad5421SRuslan ErmilovCompared to traditional 9578ad5421SRuslan Ermilov.Dq "volume management" , 9678ad5421SRuslan Ermilov.Nm 9778ad5421SRuslan Ermilovdiffers from most 9827c74787SPoul-Henning Kampand in some cases all previous implementations in the following ways: 9927c74787SPoul-Henning Kamp.Bl -bullet 10027c74787SPoul-Henning Kamp.It 10178ad5421SRuslan Ermilov.Nm 10278ad5421SRuslan Ermilovis extensible. 1035203edcdSRuslan ErmilovIt is trivially simple to write a new class 1045203edcdSRuslan Ermilovof transformation and it will not be given stepchild treatment. 1055203edcdSRuslan ErmilovIf 10627c74787SPoul-Henning Kampsomeone for some reason wanted to mount IBM MVS diskpacks, a class 10727c74787SPoul-Henning Kamprecognizing and configuring their VTOC information would be a trivial 10827c74787SPoul-Henning Kampmatter. 10927c74787SPoul-Henning Kamp.It 11078ad5421SRuslan Ermilov.Nm 11178ad5421SRuslan Ermilovis topologically agnostic. 1125203edcdSRuslan ErmilovMost volume management implementations 11327c74787SPoul-Henning Kamphave very strict notions of how classes can fit together, very often 11478ad5421SRuslan Ermilovone fixed hierarchy is provided, for instance, subdisk - plex - 11527c74787SPoul-Henning Kampvolume. 11627c74787SPoul-Henning Kamp.El 11727c74787SPoul-Henning Kamp.Pp 11827c74787SPoul-Henning KampBeing extensible means that new transformations are treated no differently 11927c74787SPoul-Henning Kampthan existing transformations. 12027c74787SPoul-Henning Kamp.Pp 12127c74787SPoul-Henning KampFixed hierarchies are bad because they make it impossible to express 12227c74787SPoul-Henning Kampthe intent efficiently. 12378ad5421SRuslan ErmilovIn the fixed hierarchy above, it is not possible to mirror two 12456cf50adSPoul-Henning Kampphysical disks and then partition the mirror into subdisks, instead 12527c74787SPoul-Henning Kampone is forced to make subdisks on the physical volumes and to mirror 12678ad5421SRuslan Ermilovthese two and two, resulting in a much more complex configuration. 12778ad5421SRuslan Ermilov.Nm 12878ad5421SRuslan Ermilovon the other hand does not care in which order things are done, 12927c74787SPoul-Henning Kampthe only restriction is that cycles in the graph will not be allowed. 13078ad5421SRuslan Ermilov.Sh "TERMINOLOGY AND TOPOLOGY" 13178ad5421SRuslan Ermilov.Nm 13278ad5421SRuslan Ermilovis quite object oriented and consequently the terminology 13356cf50adSPoul-Henning Kampborrows a lot of context and semantics from the OO vocabulary: 13427c74787SPoul-Henning Kamp.Pp 13578ad5421SRuslan ErmilovA 13678ad5421SRuslan Ermilov.Dq class , 13778ad5421SRuslan Ermilovrepresented by the data structure 13878ad5421SRuslan Ermilov.Vt g_class 13978ad5421SRuslan Ermilovimplements one 1405203edcdSRuslan Ermilovparticular kind of transformation. 1415203edcdSRuslan ErmilovTypical examples are MBR disk 14256cf50adSPoul-Henning Kamppartition, BSD disklabel, and RAID5 classes. 14327c74787SPoul-Henning Kamp.Pp 14478ad5421SRuslan ErmilovAn instance of a class is called a 14578ad5421SRuslan Ermilov.Dq geom 14678ad5421SRuslan Ermilovand represented by the data structure 14778ad5421SRuslan Ermilov.Vt g_geom . 14878ad5421SRuslan ErmilovIn a typical i386 14978ad5421SRuslan Ermilov.Fx 15078ad5421SRuslan Ermilovsystem, there 15127c74787SPoul-Henning Kampwill be one geom of class MBR for each disk. 15227c74787SPoul-Henning Kamp.Pp 15378ad5421SRuslan ErmilovA 15478ad5421SRuslan Ermilov.Dq provider , 15578ad5421SRuslan Ermilovrepresented by the data structure 15678ad5421SRuslan Ermilov.Vt g_provider , 15778ad5421SRuslan Ermilovis the front gate at which a geom offers service. 15878ad5421SRuslan ErmilovA provider is 15978ad5421SRuslan Ermilov.Do 16078ad5421SRuslan Ermilova disk-like thing which appears in 16178ad5421SRuslan Ermilov.Pa /dev 16278ad5421SRuslan Ermilov.Dc - a logical 16327c74787SPoul-Henning Kampdisk in other words. 16478ad5421SRuslan ErmilovAll providers have three main properties: 16578ad5421SRuslan Ermilov.Dq name , 16678ad5421SRuslan Ermilov.Dq sectorsize 16778ad5421SRuslan Ermilovand 16878ad5421SRuslan Ermilov.Dq size . 16927c74787SPoul-Henning Kamp.Pp 17078ad5421SRuslan ErmilovA 17178ad5421SRuslan Ermilov.Dq consumer 17278ad5421SRuslan Ermilovis the backdoor through which a geom connects to another 17356cf50adSPoul-Henning Kampgeom provider and through which I/O requests are sent. 17427c74787SPoul-Henning Kamp.Pp 17527c74787SPoul-Henning KampThe topological relationship between these entities are as follows: 17627c74787SPoul-Henning Kamp.Bl -bullet 17727c74787SPoul-Henning Kamp.It 17827c74787SPoul-Henning KampA class has zero or more geom instances. 17927c74787SPoul-Henning Kamp.It 18027c74787SPoul-Henning KampA geom has exactly one class it is derived from. 18127c74787SPoul-Henning Kamp.It 18227c74787SPoul-Henning KampA geom has zero or more consumers. 18327c74787SPoul-Henning Kamp.It 18456cf50adSPoul-Henning KampA geom has zero or more providers. 18527c74787SPoul-Henning Kamp.It 18627c74787SPoul-Henning KampA consumer can be attached to zero or one providers. 18727c74787SPoul-Henning Kamp.It 18827c74787SPoul-Henning KampA provider can have zero or more consumers attached. 18927c74787SPoul-Henning Kamp.El 19027c74787SPoul-Henning Kamp.Pp 19156cf50adSPoul-Henning KampAll geoms have a rank-number assigned, which is used to detect and 1925203edcdSRuslan Ermilovprevent loops in the acyclic directed graph. 1935203edcdSRuslan ErmilovThis rank number is 19427c74787SPoul-Henning Kampassigned as follows: 19527c74787SPoul-Henning Kamp.Bl -enum 19627c74787SPoul-Henning Kamp.It 19778ad5421SRuslan ErmilovA geom with no attached consumers has rank=1. 19827c74787SPoul-Henning Kamp.It 19956cf50adSPoul-Henning KampA geom with attached consumers has a rank one higher than the 20027c74787SPoul-Henning Kamphighest rank of the geoms of the providers its consumers are 20127c74787SPoul-Henning Kampattached to. 20227c74787SPoul-Henning Kamp.El 20357bd0fc6SJens Schweikhardt.Sh "SPECIAL TOPOLOGICAL MANEUVERS" 20456cf50adSPoul-Henning KampIn addition to the straightforward attach, which attaches a consumer 20557bd0fc6SJens Schweikhardtto a provider, and detach, which breaks the bond, a number of special 20657bd0fc6SJens Schweikhardttopological maneuvers exists to facilitate configuration and to 20727c74787SPoul-Henning Kampimprove the overall flexibility. 20878ad5421SRuslan Ermilov.Bl -inset 20978ad5421SRuslan Ermilov.It Em TASTING 21056cf50adSPoul-Henning Kampis a process that happens whenever a new class or new provider 21178ad5421SRuslan Ermilovis created, and it provides the class a chance to automatically configure an 21216e88145SCeri Daviesinstance on providers which it recognizes as its own. 21356cf50adSPoul-Henning KampA typical example is the MBR disk-partition class which will look for 21478ad5421SRuslan Ermilovthe MBR table in the first sector and, if found and validated, will 21527c74787SPoul-Henning Kampinstantiate a geom to multiplex according to the contents of the MBR. 21627c74787SPoul-Henning Kamp.Pp 21756cf50adSPoul-Henning KampA new class will be offered to all existing providers in turn and a new 21827c74787SPoul-Henning Kampprovider will be offered to all classes in turn. 21927c74787SPoul-Henning Kamp.Pp 22027c74787SPoul-Henning KampExactly what a class does to recognize if it should accept the offered 22178ad5421SRuslan Ermilovprovider is not defined by 22278ad5421SRuslan Ermilov.Nm , 22378ad5421SRuslan Ermilovbut the sensible set of options are: 22427c74787SPoul-Henning Kamp.Bl -bullet 22527c74787SPoul-Henning Kamp.It 22627c74787SPoul-Henning KampExamine specific data structures on the disk. 22727c74787SPoul-Henning Kamp.It 22878ad5421SRuslan ErmilovExamine properties like 22978ad5421SRuslan Ermilov.Dq sectorsize 23078ad5421SRuslan Ermilovor 23178ad5421SRuslan Ermilov.Dq mediasize 23278ad5421SRuslan Ermilovfor the provider. 23327c74787SPoul-Henning Kamp.It 23456cf50adSPoul-Henning KampExamine the rank number of the provider's geom. 23527c74787SPoul-Henning Kamp.It 23656cf50adSPoul-Henning KampExamine the method name of the provider's geom. 23727c74787SPoul-Henning Kamp.El 23878ad5421SRuslan Ermilov.It Em ORPHANIZATION 23927c74787SPoul-Henning Kampis the process by which a provider is removed while 24056cf50adSPoul-Henning Kampit potentially is still being used. 24127c74787SPoul-Henning Kamp.Pp 242c1c85751SPoul-Henning KampWhen a geom orphans a provider, all future I/O requests will 24378ad5421SRuslan Ermilov.Dq bounce 24478ad5421SRuslan Ermilovon the provider with an error code set by the geom. 2455203edcdSRuslan ErmilovAny 24627c74787SPoul-Henning Kampconsumers attached to the provider will receive notification about 247c1c85751SPoul-Henning Kampthe orphanization when the event loop gets around to it, and they 248d773aebdSPoul-Henning Kampcan take appropriate action at that time. 24927c74787SPoul-Henning Kamp.Pp 25056cf50adSPoul-Henning KampA geom which came into being as a result of a normal taste operation 25116e88145SCeri Daviesshould self-destruct unless it has a way to keep functioning whilst 25216e88145SCeri Davieslacking the orphaned provider. 25378ad5421SRuslan ErmilovGeoms like disk slicers should therefore self-destruct whereas 25416e88145SCeri DaviesRAID5 or mirror geoms will be able to continue as long as they do 25516e88145SCeri Daviesnot lose quorum. 25627c74787SPoul-Henning Kamp.Pp 257c1c85751SPoul-Henning KampWhen a provider is orphaned, this does not necessarily result in any 258c1c85751SPoul-Henning Kampimmediate change in the topology: any attached consumers are still 259c1c85751SPoul-Henning Kampattached, any opened paths are still open, any outstanding I/O 260c1c85751SPoul-Henning Kamprequests are still outstanding. 26127c74787SPoul-Henning Kamp.Pp 26278ad5421SRuslan ErmilovThe typical scenario is: 26378ad5421SRuslan Ermilov.Pp 264c1c85751SPoul-Henning Kamp.Bl -bullet -offset indent -compact 265c1c85751SPoul-Henning Kamp.It 266c1c85751SPoul-Henning KampA device driver detects a disk has departed and orphans the provider for it. 267c1c85751SPoul-Henning Kamp.It 268c1c85751SPoul-Henning KampThe geoms on top of the disk receive the orphanization event and 26916e88145SCeri Daviesorphan all their providers in turn. 27016e88145SCeri DaviesProviders which are not attached to will typically self-destruct 271c1c85751SPoul-Henning Kampright away. 272c1c85751SPoul-Henning KampThis process continues in a quasi-recursive fashion until all 27316e88145SCeri Daviesrelevant pieces of the tree have heard the bad news. 274c1c85751SPoul-Henning Kamp.It 275c1c85751SPoul-Henning KampEventually the buck stops when it reaches geom_dev at the top 276c1c85751SPoul-Henning Kampof the stack. 277c1c85751SPoul-Henning Kamp.It 27878ad5421SRuslan ErmilovGeom_dev will call 27978ad5421SRuslan Ermilov.Xr destroy_dev 9 28016e88145SCeri Daviesto stop any more requests from 281c1c85751SPoul-Henning Kampcoming in. 28216e88145SCeri DaviesIt will sleep until any and all outstanding I/O requests have 283c1c85751SPoul-Henning Kampbeen returned. 28478ad5421SRuslan ErmilovIt will explicitly close (i.e.: zero the access counts), a change 285c1c85751SPoul-Henning Kampwhich will propagate all the way down through the mesh. 286c1c85751SPoul-Henning KampIt will then detach and destroy its geom. 287c1c85751SPoul-Henning Kamp.It 28856b341a2SEdward Tomasz NapieralaThe geom whose provider is now detached will destroy the provider, 289c1c85751SPoul-Henning Kampdetach and destroy its consumer and destroy its geom. 290c1c85751SPoul-Henning Kamp.It 291c1c85751SPoul-Henning KampThis process percolates all the way down through the mesh, until 292c1c85751SPoul-Henning Kampthe cleanup is complete. 293c1c85751SPoul-Henning Kamp.El 29427c74787SPoul-Henning Kamp.Pp 29556cf50adSPoul-Henning KampWhile this approach seems byzantine, it does provide the maximum 296c1c85751SPoul-Henning Kampflexibility and robustness in handling disappearing devices. 297c1c85751SPoul-Henning Kamp.Pp 29816e88145SCeri DaviesThe one absolutely crucial detail to be aware of is that if the 299c1c85751SPoul-Henning Kampdevice driver does not return all I/O requests, the tree will 300d773aebdSPoul-Henning Kampnot unravel. 30178ad5421SRuslan Ermilov.It Em SPOILING 30227c74787SPoul-Henning Kampis a special case of orphanization used to protect 30327c74787SPoul-Henning Kampagainst stale metadata. 30427c74787SPoul-Henning KampIt is probably easiest to understand spoiling by going through 30527c74787SPoul-Henning Kampan example. 30627c74787SPoul-Henning Kamp.Pp 30778ad5421SRuslan ErmilovImagine a disk, 30816e88145SCeri Davies.Pa da0 , 30978ad5421SRuslan Ermilovon top of which an MBR geom provides 31078ad5421SRuslan Ermilov.Pa da0s1 31178ad5421SRuslan Ermilovand 31278ad5421SRuslan Ermilov.Pa da0s2 , 31378ad5421SRuslan Ermilovand on top of 31478ad5421SRuslan Ermilov.Pa da0s1 31578ad5421SRuslan Ermilova BSD geom provides 31678ad5421SRuslan Ermilov.Pa da0s1a 31778ad5421SRuslan Ermilovthrough 31878ad5421SRuslan Ermilov.Pa da0s1e , 31916e88145SCeri Daviesand that both the MBR and BSD geoms have 32027c74787SPoul-Henning Kampautoconfigured based on data structures on the disk media. 32178ad5421SRuslan ErmilovNow imagine the case where 32278ad5421SRuslan Ermilov.Pa da0 32378ad5421SRuslan Ermilovis opened for writing and those 32478ad5421SRuslan Ermilovdata structures are modified or overwritten: now the geoms would 32527c74787SPoul-Henning Kampbe operating on stale metadata unless some notification system 32627c74787SPoul-Henning Kampcan inform them otherwise. 327d773aebdSPoul-Henning Kamp.Pp 32878ad5421SRuslan ErmilovTo avoid this situation, when the open of 32978ad5421SRuslan Ermilov.Pa da0 33078ad5421SRuslan Ermilovfor write happens, 33116e88145SCeri Daviesall attached consumers are told about this and geoms like 33278ad5421SRuslan ErmilovMBR and BSD will self-destruct as a result. 33378ad5421SRuslan ErmilovWhen 33478ad5421SRuslan Ermilov.Pa da0 33516e88145SCeri Daviesis closed, it will be offered for tasting again 33616e88145SCeri Daviesand, if the data structures for MBR and BSD are still there, new 33727c74787SPoul-Henning Kampgeoms will instantiate themselves anew. 33827c74787SPoul-Henning Kamp.Pp 33927c74787SPoul-Henning KampNow for the fine print: 34027c74787SPoul-Henning Kamp.Pp 34127c74787SPoul-Henning KampIf any of the paths through the MBR or BSD module were open, they 34216e88145SCeri Davieswould have opened downwards with an exclusive bit thus rendering it 34378ad5421SRuslan Ermilovimpossible to open 34478ad5421SRuslan Ermilov.Pa da0 34516e88145SCeri Daviesfor writing in that case. 34616e88145SCeri DaviesConversely, 34727c74787SPoul-Henning Kampthe requested exclusive bit would render it impossible to open a 34878ad5421SRuslan Ermilovpath through the MBR geom while 34978ad5421SRuslan Ermilov.Pa da0 35078ad5421SRuslan Ermilovis open for writing. 35127c74787SPoul-Henning Kamp.Pp 35227c74787SPoul-Henning KampFrom this it also follows that changing the size of open geoms can 353d773aebdSPoul-Henning Kamponly be done with their cooperation. 35427c74787SPoul-Henning Kamp.Pp 35527c74787SPoul-Henning KampFinally: the spoiling only happens when the write count goes from 35616e88145SCeri Davieszero to non-zero and the retasting happens only when the write count goes 357d773aebdSPoul-Henning Kampfrom non-zero to zero. 35878ad5421SRuslan Ermilov.It Em CONFIGURE 35927c74787SPoul-Henning Kampis the process where the administrator issues instructions 3605203edcdSRuslan Ermilovfor a particular class to instantiate itself. 3615203edcdSRuslan ErmilovThere are multiple 36216e88145SCeri Daviesways to express intent in this case - a particular provider may be 36316e88145SCeri Daviesspecified with a level of override forcing, for instance, a BSD 36427c74787SPoul-Henning Kampdisklabel module to attach to a provider which was not found palatable 36527c74787SPoul-Henning Kampduring the TASTE operation. 36627c74787SPoul-Henning Kamp.Pp 36716e88145SCeri DaviesFinally, I/O is the reason we even do this: it concerns itself with 36827c74787SPoul-Henning Kampsending I/O requests through the graph. 36916e88145SCeri Davies.It Em "I/O REQUESTS" , 37078ad5421SRuslan Ermilovrepresented by 37178ad5421SRuslan Ermilov.Vt "struct bio" , 37278ad5421SRuslan Ermilovoriginate at a consumer, 37316e88145SCeri Daviesare scheduled on its attached provider and, when processed, are returned 37427c74787SPoul-Henning Kampto the consumer. 37578ad5421SRuslan ErmilovIt is important to realize that the 37678ad5421SRuslan Ermilov.Vt "struct bio" 37778ad5421SRuslan Ermilovwhich enters through the provider of a particular geom does not 37878ad5421SRuslan Ermilov.Do 37978ad5421SRuslan Ermilovcome out on the other side 38078ad5421SRuslan Ermilov.Dc . 38127c74787SPoul-Henning KampEven simple transformations like MBR and BSD will clone the 38278ad5421SRuslan Ermilov.Vt "struct bio" , 38378ad5421SRuslan Ermilovmodify the clone, and schedule the clone on their 38427c74787SPoul-Henning Kampown consumer. 38578ad5421SRuslan ErmilovNote that cloning the 38678ad5421SRuslan Ermilov.Vt "struct bio" 38778ad5421SRuslan Ermilovdoes not involve cloning the 38878ad5421SRuslan Ermilovactual data area specified in the I/O request. 38927c74787SPoul-Henning Kamp.Pp 39078ad5421SRuslan ErmilovIn total, four different I/O requests exist in 39178ad5421SRuslan Ermilov.Nm : 39278ad5421SRuslan Ermilovread, write, delete, and 39378ad5421SRuslan Ermilov.Dq "get attribute". 39427c74787SPoul-Henning Kamp.Pp 39556cf50adSPoul-Henning KampRead and write are self explanatory. 39627c74787SPoul-Henning Kamp.Pp 39727c74787SPoul-Henning KampDelete indicates that a certain range of data is no longer used 39827c74787SPoul-Henning Kampand that it can be erased or freed as the underlying technology 39927c74787SPoul-Henning Kampsupports. 40027c74787SPoul-Henning KampTechnologies like flash adaptation layers can arrange to erase 40127c74787SPoul-Henning Kampthe relevant blocks before they will become reassigned and 40256cf50adSPoul-Henning Kampcryptographic devices may want to fill random bits into the 40327c74787SPoul-Henning Kamprange to reduce the amount of data available for attack. 40427c74787SPoul-Henning Kamp.Pp 40527c74787SPoul-Henning KampIt is important to recognize that a delete indication is not a 40627c74787SPoul-Henning Kamprequest and consequently there is no guarantee that the data actually 40727c74787SPoul-Henning Kampwill be erased or made unavailable unless guaranteed by specific 4085203edcdSRuslan Ermilovgeoms in the graph. 40978ad5421SRuslan ErmilovIf 41078ad5421SRuslan Ermilov.Dq "secure delete" 41178ad5421SRuslan Ermilovsemantics are required, a 41227c74787SPoul-Henning Kampgeom should be pushed which converts delete indications into (a 41327c74787SPoul-Henning Kampsequence of) write requests. 41427c74787SPoul-Henning Kamp.Pp 41578ad5421SRuslan Ermilov.Dq "Get attribute" 41678ad5421SRuslan Ermilovsupports inspection and manipulation 41727c74787SPoul-Henning Kampof out-of-band attributes on a particular provider or path. 41878ad5421SRuslan ErmilovAttributes are named by 41978ad5421SRuslan Ermilov.Tn ASCII 42078ad5421SRuslan Ermilovstrings and they will be discussed in 42127c74787SPoul-Henning Kampa separate section below. 42278ad5421SRuslan Ermilov.El 42327c74787SPoul-Henning Kamp.Pp 42478ad5421SRuslan Ermilov(Stay tuned while the author rests his brain and fingers: more to come.) 425ba3eb872SScott Long.Sh DIAGNOSTICS 42678ad5421SRuslan ErmilovSeveral flags are provided for tracing 42778ad5421SRuslan Ermilov.Nm 42878ad5421SRuslan Ermilovoperations and unlocking 429ba3eb872SScott Longprotection mechanisms via the 430ba3eb872SScott Long.Va kern.geom.debugflags 431ba3eb872SScott Longsysctl. 432ba3eb872SScott LongAll of these flags are off by default, and great care should be taken in 433ba3eb872SScott Longturning them on. 43478ad5421SRuslan Ermilov.Bl -tag -width indent 4354f068961SRuslan Ermilov.It 0x01 Pq Dv G_T_TOPOLOGY 436ba3eb872SScott LongProvide tracing of topology change events. 4374f068961SRuslan Ermilov.It 0x02 Pq Dv G_T_BIO 438ba3eb872SScott LongProvide tracing of buffer I/O requests. 4394f068961SRuslan Ermilov.It 0x04 Pq Dv G_T_ACCESS 440ba3eb872SScott LongProvide tracing of access check controls. 441ba3eb872SScott Long.It 0x08 (unused) 442ba3eb872SScott Long.It 0x10 (allow foot shooting) 443ba3eb872SScott LongAllow writing to Rank 1 providers. 444ba3eb872SScott LongThis would, for example, allow the super-user to overwrite the MBR on the root 4454f068961SRuslan Ermilovdisk or write random sectors elsewhere to a mounted disk. 4464f068961SRuslan ErmilovThe implications are obvious. 4474f068961SRuslan Ermilov.It 0x40 Pq Dv G_F_DISKIOCTL 4488a3dce33SCeri DaviesThis is unused at this time. 4494f068961SRuslan Ermilov.It 0x80 Pq Dv G_F_CTLDUMP 450ba3eb872SScott LongDump contents of gctl requests. 451ba3eb872SScott Long.El 45256b341a2SEdward Tomasz Napierala.Sh SEE ALSO 453a7c13cccSEdward Tomasz Napierala.Xr libgeom 3 , 45456b341a2SEdward Tomasz Napierala.Xr DECLARE_GEOM_CLASS 9 , 455923544aaSBaptiste Daroussin.Xr disk 9 , 45656b341a2SEdward Tomasz Napierala.Xr g_access 9 , 45756b341a2SEdward Tomasz Napierala.Xr g_attach 9 , 45856b341a2SEdward Tomasz Napierala.Xr g_bio 9 , 45956b341a2SEdward Tomasz Napierala.Xr g_consumer 9 , 46056b341a2SEdward Tomasz Napierala.Xr g_data 9 , 46156b341a2SEdward Tomasz Napierala.Xr g_event 9 , 46256b341a2SEdward Tomasz Napierala.Xr g_geom 9 , 46356b341a2SEdward Tomasz Napierala.Xr g_provider 9 , 46456b341a2SEdward Tomasz Napierala.Xr g_provider_by_name 9 46527c74787SPoul-Henning Kamp.Sh HISTORY 46678ad5421SRuslan ErmilovThis software was developed for the 46778ad5421SRuslan Ermilov.Fx 46878ad5421SRuslan ErmilovProject by 46978ad5421SRuslan Ermilov.An Poul-Henning Kamp 4704f068961SRuslan Ermilovand NAI Labs, the Security Research Division of Network Associates, Inc.\& 47178ad5421SRuslan Ermilovunder DARPA/SPAWAR contract N66001-01-C-8035 47278ad5421SRuslan Ermilov.Pq Dq CBOSS , 47378ad5421SRuslan Ermilovas part of the 47427c74787SPoul-Henning KampDARPA CHATS research program. 47527c74787SPoul-Henning Kamp.Pp 47678ad5421SRuslan ErmilovThe first precursor for 47778ad5421SRuslan Ermilov.Nm 47878ad5421SRuslan Ermilovwas a gruesome hack to Minix 1.2 and was 4795203edcdSRuslan Ermilovnever distributed. 4805203edcdSRuslan ErmilovAn earlier attempt to implement a less general scheme 48178ad5421SRuslan Ermilovin 48278ad5421SRuslan Ermilov.Fx 48378ad5421SRuslan Ermilovnever succeeded. 48427c74787SPoul-Henning Kamp.Sh AUTHORS 4856c899950SBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org 486