xref: /freebsd/share/man/man4/geom.4 (revision fcdb1ffc497c96f7718c43e9c1716a0ead39275a)
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*fcdb1ffcSAndrey V. Elsukov.Dd June 8, 2015
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
55*fcdb1ffcSAndrey V. Elsukov.Cd options GEOM_MAP
569218a6ebSJoel Dahl.Cd options GEOM_MBR
579218a6ebSJoel Dahl.Cd options GEOM_MIRROR
589218a6ebSJoel Dahl.Cd options GEOM_MULTIPATH
599218a6ebSJoel Dahl.Cd options GEOM_NOP
609218a6ebSJoel Dahl.Cd options GEOM_PART_APM
619218a6ebSJoel Dahl.Cd options GEOM_PART_BSD
62*fcdb1ffcSAndrey V. Elsukov.Cd options GEOM_PART_BSD64
639218a6ebSJoel Dahl.Cd options GEOM_PART_EBR
649218a6ebSJoel Dahl.Cd options GEOM_PART_EBR_COMPAT
659218a6ebSJoel Dahl.Cd options GEOM_PART_GPT
669218a6ebSJoel Dahl.Cd options GEOM_PART_LDM
679218a6ebSJoel Dahl.Cd options GEOM_PART_MBR
689218a6ebSJoel Dahl.Cd options GEOM_PART_PC98
699218a6ebSJoel Dahl.Cd options GEOM_PART_VTOC8
709218a6ebSJoel Dahl.Cd options GEOM_PC98
719218a6ebSJoel Dahl.Cd options GEOM_RAID
729218a6ebSJoel Dahl.Cd options GEOM_RAID3
739218a6ebSJoel Dahl.Cd options GEOM_SHSEC
749218a6ebSJoel Dahl.Cd options GEOM_STRIPE
759218a6ebSJoel Dahl.Cd options GEOM_SUNLABEL
76*fcdb1ffcSAndrey V. Elsukov.Cd options GEOM_UNCOMPRESS
779218a6ebSJoel Dahl.Cd options GEOM_UZIP
789218a6ebSJoel Dahl.Cd options GEOM_VIRSTOR
799218a6ebSJoel Dahl.Cd options GEOM_VOL
809218a6ebSJoel Dahl.Cd options GEOM_ZERO
8127c74787SPoul-Henning Kamp.Sh DESCRIPTION
8278ad5421SRuslan ErmilovThe
8378ad5421SRuslan Ermilov.Nm
8478ad5421SRuslan Ermilovframework provides an infrastructure in which
8578ad5421SRuslan Ermilov.Dq classes
8627c74787SPoul-Henning Kampcan perform transformations on disk I/O requests on their path from
8727c74787SPoul-Henning Kampthe upper kernel to the device drivers and back.
8827c74787SPoul-Henning Kamp.Pp
8978ad5421SRuslan ErmilovTransformations in a
9078ad5421SRuslan Ermilov.Nm
9178ad5421SRuslan Ermilovcontext range from the simple geometric
92d773aebdSPoul-Henning Kampdisplacement performed in typical disk partitioning modules over RAID
9327c74787SPoul-Henning Kampalgorithms and device multipath resolution to full blown cryptographic
9427c74787SPoul-Henning Kampprotection of the stored data.
9527c74787SPoul-Henning Kamp.Pp
9678ad5421SRuslan ErmilovCompared to traditional
9778ad5421SRuslan Ermilov.Dq "volume management" ,
9878ad5421SRuslan Ermilov.Nm
9978ad5421SRuslan Ermilovdiffers from most
10027c74787SPoul-Henning Kampand in some cases all previous implementations in the following ways:
10127c74787SPoul-Henning Kamp.Bl -bullet
10227c74787SPoul-Henning Kamp.It
10378ad5421SRuslan Ermilov.Nm
10478ad5421SRuslan Ermilovis extensible.
1055203edcdSRuslan ErmilovIt is trivially simple to write a new class
1065203edcdSRuslan Ermilovof transformation and it will not be given stepchild treatment.
1075203edcdSRuslan ErmilovIf
10827c74787SPoul-Henning Kampsomeone for some reason wanted to mount IBM MVS diskpacks, a class
10927c74787SPoul-Henning Kamprecognizing and configuring their VTOC information would be a trivial
11027c74787SPoul-Henning Kampmatter.
11127c74787SPoul-Henning Kamp.It
11278ad5421SRuslan Ermilov.Nm
11378ad5421SRuslan Ermilovis topologically agnostic.
1145203edcdSRuslan ErmilovMost volume management implementations
11527c74787SPoul-Henning Kamphave very strict notions of how classes can fit together, very often
11678ad5421SRuslan Ermilovone fixed hierarchy is provided, for instance, subdisk - plex -
11727c74787SPoul-Henning Kampvolume.
11827c74787SPoul-Henning Kamp.El
11927c74787SPoul-Henning Kamp.Pp
12027c74787SPoul-Henning KampBeing extensible means that new transformations are treated no differently
12127c74787SPoul-Henning Kampthan existing transformations.
12227c74787SPoul-Henning Kamp.Pp
12327c74787SPoul-Henning KampFixed hierarchies are bad because they make it impossible to express
12427c74787SPoul-Henning Kampthe intent efficiently.
12578ad5421SRuslan ErmilovIn the fixed hierarchy above, it is not possible to mirror two
12656cf50adSPoul-Henning Kampphysical disks and then partition the mirror into subdisks, instead
12727c74787SPoul-Henning Kampone is forced to make subdisks on the physical volumes and to mirror
12878ad5421SRuslan Ermilovthese two and two, resulting in a much more complex configuration.
12978ad5421SRuslan Ermilov.Nm
13078ad5421SRuslan Ermilovon the other hand does not care in which order things are done,
13127c74787SPoul-Henning Kampthe only restriction is that cycles in the graph will not be allowed.
13278ad5421SRuslan Ermilov.Sh "TERMINOLOGY AND TOPOLOGY"
13378ad5421SRuslan Ermilov.Nm
13478ad5421SRuslan Ermilovis quite object oriented and consequently the terminology
13556cf50adSPoul-Henning Kampborrows a lot of context and semantics from the OO vocabulary:
13627c74787SPoul-Henning Kamp.Pp
13778ad5421SRuslan ErmilovA
13878ad5421SRuslan Ermilov.Dq class ,
13978ad5421SRuslan Ermilovrepresented by the data structure
14078ad5421SRuslan Ermilov.Vt g_class
14178ad5421SRuslan Ermilovimplements one
1425203edcdSRuslan Ermilovparticular kind of transformation.
1435203edcdSRuslan ErmilovTypical examples are MBR disk
14456cf50adSPoul-Henning Kamppartition, BSD disklabel, and RAID5 classes.
14527c74787SPoul-Henning Kamp.Pp
14678ad5421SRuslan ErmilovAn instance of a class is called a
14778ad5421SRuslan Ermilov.Dq geom
14878ad5421SRuslan Ermilovand represented by the data structure
14978ad5421SRuslan Ermilov.Vt g_geom .
15078ad5421SRuslan ErmilovIn a typical i386
15178ad5421SRuslan Ermilov.Fx
15278ad5421SRuslan Ermilovsystem, there
15327c74787SPoul-Henning Kampwill be one geom of class MBR for each disk.
15427c74787SPoul-Henning Kamp.Pp
15578ad5421SRuslan ErmilovA
15678ad5421SRuslan Ermilov.Dq provider ,
15778ad5421SRuslan Ermilovrepresented by the data structure
15878ad5421SRuslan Ermilov.Vt g_provider ,
15978ad5421SRuslan Ermilovis the front gate at which a geom offers service.
16078ad5421SRuslan ErmilovA provider is
16178ad5421SRuslan Ermilov.Do
16278ad5421SRuslan Ermilova disk-like thing which appears in
16378ad5421SRuslan Ermilov.Pa /dev
16478ad5421SRuslan Ermilov.Dc - a logical
16527c74787SPoul-Henning Kampdisk in other words.
16678ad5421SRuslan ErmilovAll providers have three main properties:
16778ad5421SRuslan Ermilov.Dq name ,
16878ad5421SRuslan Ermilov.Dq sectorsize
16978ad5421SRuslan Ermilovand
17078ad5421SRuslan Ermilov.Dq size .
17127c74787SPoul-Henning Kamp.Pp
17278ad5421SRuslan ErmilovA
17378ad5421SRuslan Ermilov.Dq consumer
17478ad5421SRuslan Ermilovis the backdoor through which a geom connects to another
17556cf50adSPoul-Henning Kampgeom provider and through which I/O requests are sent.
17627c74787SPoul-Henning Kamp.Pp
17727c74787SPoul-Henning KampThe topological relationship between these entities are as follows:
17827c74787SPoul-Henning Kamp.Bl -bullet
17927c74787SPoul-Henning Kamp.It
18027c74787SPoul-Henning KampA class has zero or more geom instances.
18127c74787SPoul-Henning Kamp.It
18227c74787SPoul-Henning KampA geom has exactly one class it is derived from.
18327c74787SPoul-Henning Kamp.It
18427c74787SPoul-Henning KampA geom has zero or more consumers.
18527c74787SPoul-Henning Kamp.It
18656cf50adSPoul-Henning KampA geom has zero or more providers.
18727c74787SPoul-Henning Kamp.It
18827c74787SPoul-Henning KampA consumer can be attached to zero or one providers.
18927c74787SPoul-Henning Kamp.It
19027c74787SPoul-Henning KampA provider can have zero or more consumers attached.
19127c74787SPoul-Henning Kamp.El
19227c74787SPoul-Henning Kamp.Pp
19356cf50adSPoul-Henning KampAll geoms have a rank-number assigned, which is used to detect and
1945203edcdSRuslan Ermilovprevent loops in the acyclic directed graph.
1955203edcdSRuslan ErmilovThis rank number is
19627c74787SPoul-Henning Kampassigned as follows:
19727c74787SPoul-Henning Kamp.Bl -enum
19827c74787SPoul-Henning Kamp.It
19978ad5421SRuslan ErmilovA geom with no attached consumers has rank=1.
20027c74787SPoul-Henning Kamp.It
20156cf50adSPoul-Henning KampA geom with attached consumers has a rank one higher than the
20227c74787SPoul-Henning Kamphighest rank of the geoms of the providers its consumers are
20327c74787SPoul-Henning Kampattached to.
20427c74787SPoul-Henning Kamp.El
20557bd0fc6SJens Schweikhardt.Sh "SPECIAL TOPOLOGICAL MANEUVERS"
20656cf50adSPoul-Henning KampIn addition to the straightforward attach, which attaches a consumer
20757bd0fc6SJens Schweikhardtto a provider, and detach, which breaks the bond, a number of special
20857bd0fc6SJens Schweikhardttopological maneuvers exists to facilitate configuration and to
20927c74787SPoul-Henning Kampimprove the overall flexibility.
21078ad5421SRuslan Ermilov.Bl -inset
21178ad5421SRuslan Ermilov.It Em TASTING
21256cf50adSPoul-Henning Kampis a process that happens whenever a new class or new provider
21378ad5421SRuslan Ermilovis created, and it provides the class a chance to automatically configure an
21416e88145SCeri Daviesinstance on providers which it recognizes as its own.
21556cf50adSPoul-Henning KampA typical example is the MBR disk-partition class which will look for
21678ad5421SRuslan Ermilovthe MBR table in the first sector and, if found and validated, will
21727c74787SPoul-Henning Kampinstantiate a geom to multiplex according to the contents of the MBR.
21827c74787SPoul-Henning Kamp.Pp
21956cf50adSPoul-Henning KampA new class will be offered to all existing providers in turn and a new
22027c74787SPoul-Henning Kampprovider will be offered to all classes in turn.
22127c74787SPoul-Henning Kamp.Pp
22227c74787SPoul-Henning KampExactly what a class does to recognize if it should accept the offered
22378ad5421SRuslan Ermilovprovider is not defined by
22478ad5421SRuslan Ermilov.Nm ,
22578ad5421SRuslan Ermilovbut the sensible set of options are:
22627c74787SPoul-Henning Kamp.Bl -bullet
22727c74787SPoul-Henning Kamp.It
22827c74787SPoul-Henning KampExamine specific data structures on the disk.
22927c74787SPoul-Henning Kamp.It
23078ad5421SRuslan ErmilovExamine properties like
23178ad5421SRuslan Ermilov.Dq sectorsize
23278ad5421SRuslan Ermilovor
23378ad5421SRuslan Ermilov.Dq mediasize
23478ad5421SRuslan Ermilovfor the provider.
23527c74787SPoul-Henning Kamp.It
23656cf50adSPoul-Henning KampExamine the rank number of the provider's geom.
23727c74787SPoul-Henning Kamp.It
23856cf50adSPoul-Henning KampExamine the method name of the provider's geom.
23927c74787SPoul-Henning Kamp.El
24078ad5421SRuslan Ermilov.It Em ORPHANIZATION
24127c74787SPoul-Henning Kampis the process by which a provider is removed while
24256cf50adSPoul-Henning Kampit potentially is still being used.
24327c74787SPoul-Henning Kamp.Pp
244c1c85751SPoul-Henning KampWhen a geom orphans a provider, all future I/O requests will
24578ad5421SRuslan Ermilov.Dq bounce
24678ad5421SRuslan Ermilovon the provider with an error code set by the geom.
2475203edcdSRuslan ErmilovAny
24827c74787SPoul-Henning Kampconsumers attached to the provider will receive notification about
249c1c85751SPoul-Henning Kampthe orphanization when the event loop gets around to it, and they
250d773aebdSPoul-Henning Kampcan take appropriate action at that time.
25127c74787SPoul-Henning Kamp.Pp
25256cf50adSPoul-Henning KampA geom which came into being as a result of a normal taste operation
25316e88145SCeri Daviesshould self-destruct unless it has a way to keep functioning whilst
25416e88145SCeri Davieslacking the orphaned provider.
25578ad5421SRuslan ErmilovGeoms like disk slicers should therefore self-destruct whereas
25616e88145SCeri DaviesRAID5 or mirror geoms will be able to continue as long as they do
25716e88145SCeri Daviesnot lose quorum.
25827c74787SPoul-Henning Kamp.Pp
259c1c85751SPoul-Henning KampWhen a provider is orphaned, this does not necessarily result in any
260c1c85751SPoul-Henning Kampimmediate change in the topology: any attached consumers are still
261c1c85751SPoul-Henning Kampattached, any opened paths are still open, any outstanding I/O
262c1c85751SPoul-Henning Kamprequests are still outstanding.
26327c74787SPoul-Henning Kamp.Pp
26478ad5421SRuslan ErmilovThe typical scenario is:
26578ad5421SRuslan Ermilov.Pp
266c1c85751SPoul-Henning Kamp.Bl -bullet -offset indent -compact
267c1c85751SPoul-Henning Kamp.It
268c1c85751SPoul-Henning KampA device driver detects a disk has departed and orphans the provider for it.
269c1c85751SPoul-Henning Kamp.It
270c1c85751SPoul-Henning KampThe geoms on top of the disk receive the orphanization event and
27116e88145SCeri Daviesorphan all their providers in turn.
27216e88145SCeri DaviesProviders which are not attached to will typically self-destruct
273c1c85751SPoul-Henning Kampright away.
274c1c85751SPoul-Henning KampThis process continues in a quasi-recursive fashion until all
27516e88145SCeri Daviesrelevant pieces of the tree have heard the bad news.
276c1c85751SPoul-Henning Kamp.It
277c1c85751SPoul-Henning KampEventually the buck stops when it reaches geom_dev at the top
278c1c85751SPoul-Henning Kampof the stack.
279c1c85751SPoul-Henning Kamp.It
28078ad5421SRuslan ErmilovGeom_dev will call
28178ad5421SRuslan Ermilov.Xr destroy_dev 9
28216e88145SCeri Daviesto stop any more requests from
283c1c85751SPoul-Henning Kampcoming in.
28416e88145SCeri DaviesIt will sleep until any and all outstanding I/O requests have
285c1c85751SPoul-Henning Kampbeen returned.
28678ad5421SRuslan ErmilovIt will explicitly close (i.e.: zero the access counts), a change
287c1c85751SPoul-Henning Kampwhich will propagate all the way down through the mesh.
288c1c85751SPoul-Henning KampIt will then detach and destroy its geom.
289c1c85751SPoul-Henning Kamp.It
29056b341a2SEdward Tomasz NapieralaThe geom whose provider is now detached will destroy the provider,
291c1c85751SPoul-Henning Kampdetach and destroy its consumer and destroy its geom.
292c1c85751SPoul-Henning Kamp.It
293c1c85751SPoul-Henning KampThis process percolates all the way down through the mesh, until
294c1c85751SPoul-Henning Kampthe cleanup is complete.
295c1c85751SPoul-Henning Kamp.El
29627c74787SPoul-Henning Kamp.Pp
29756cf50adSPoul-Henning KampWhile this approach seems byzantine, it does provide the maximum
298c1c85751SPoul-Henning Kampflexibility and robustness in handling disappearing devices.
299c1c85751SPoul-Henning Kamp.Pp
30016e88145SCeri DaviesThe one absolutely crucial detail to be aware of is that if the
301c1c85751SPoul-Henning Kampdevice driver does not return all I/O requests, the tree will
302d773aebdSPoul-Henning Kampnot unravel.
30378ad5421SRuslan Ermilov.It Em SPOILING
30427c74787SPoul-Henning Kampis a special case of orphanization used to protect
30527c74787SPoul-Henning Kampagainst stale metadata.
30627c74787SPoul-Henning KampIt is probably easiest to understand spoiling by going through
30727c74787SPoul-Henning Kampan example.
30827c74787SPoul-Henning Kamp.Pp
30978ad5421SRuslan ErmilovImagine a disk,
31016e88145SCeri Davies.Pa da0 ,
31178ad5421SRuslan Ermilovon top of which an MBR geom provides
31278ad5421SRuslan Ermilov.Pa da0s1
31378ad5421SRuslan Ermilovand
31478ad5421SRuslan Ermilov.Pa da0s2 ,
31578ad5421SRuslan Ermilovand on top of
31678ad5421SRuslan Ermilov.Pa da0s1
31778ad5421SRuslan Ermilova BSD geom provides
31878ad5421SRuslan Ermilov.Pa da0s1a
31978ad5421SRuslan Ermilovthrough
32078ad5421SRuslan Ermilov.Pa da0s1e ,
32116e88145SCeri Daviesand that both the MBR and BSD geoms have
32227c74787SPoul-Henning Kampautoconfigured based on data structures on the disk media.
32378ad5421SRuslan ErmilovNow imagine the case where
32478ad5421SRuslan Ermilov.Pa da0
32578ad5421SRuslan Ermilovis opened for writing and those
32678ad5421SRuslan Ermilovdata structures are modified or overwritten: now the geoms would
32727c74787SPoul-Henning Kampbe operating on stale metadata unless some notification system
32827c74787SPoul-Henning Kampcan inform them otherwise.
329d773aebdSPoul-Henning Kamp.Pp
33078ad5421SRuslan ErmilovTo avoid this situation, when the open of
33178ad5421SRuslan Ermilov.Pa da0
33278ad5421SRuslan Ermilovfor write happens,
33316e88145SCeri Daviesall attached consumers are told about this and geoms like
33478ad5421SRuslan ErmilovMBR and BSD will self-destruct as a result.
33578ad5421SRuslan ErmilovWhen
33678ad5421SRuslan Ermilov.Pa da0
33716e88145SCeri Daviesis closed, it will be offered for tasting again
33816e88145SCeri Daviesand, if the data structures for MBR and BSD are still there, new
33927c74787SPoul-Henning Kampgeoms will instantiate themselves anew.
34027c74787SPoul-Henning Kamp.Pp
34127c74787SPoul-Henning KampNow for the fine print:
34227c74787SPoul-Henning Kamp.Pp
34327c74787SPoul-Henning KampIf any of the paths through the MBR or BSD module were open, they
34416e88145SCeri Davieswould have opened downwards with an exclusive bit thus rendering it
34578ad5421SRuslan Ermilovimpossible to open
34678ad5421SRuslan Ermilov.Pa da0
34716e88145SCeri Daviesfor writing in that case.
34816e88145SCeri DaviesConversely,
34927c74787SPoul-Henning Kampthe requested exclusive bit would render it impossible to open a
35078ad5421SRuslan Ermilovpath through the MBR geom while
35178ad5421SRuslan Ermilov.Pa da0
35278ad5421SRuslan Ermilovis open for writing.
35327c74787SPoul-Henning Kamp.Pp
35427c74787SPoul-Henning KampFrom this it also follows that changing the size of open geoms can
355d773aebdSPoul-Henning Kamponly be done with their cooperation.
35627c74787SPoul-Henning Kamp.Pp
35727c74787SPoul-Henning KampFinally: the spoiling only happens when the write count goes from
35816e88145SCeri Davieszero to non-zero and the retasting happens only when the write count goes
359d773aebdSPoul-Henning Kampfrom non-zero to zero.
36078ad5421SRuslan Ermilov.It Em CONFIGURE
36127c74787SPoul-Henning Kampis the process where the administrator issues instructions
3625203edcdSRuslan Ermilovfor a particular class to instantiate itself.
3635203edcdSRuslan ErmilovThere are multiple
36416e88145SCeri Daviesways to express intent in this case - a particular provider may be
36516e88145SCeri Daviesspecified with a level of override forcing, for instance, a BSD
36627c74787SPoul-Henning Kampdisklabel module to attach to a provider which was not found palatable
36727c74787SPoul-Henning Kampduring the TASTE operation.
36827c74787SPoul-Henning Kamp.Pp
36916e88145SCeri DaviesFinally, I/O is the reason we even do this: it concerns itself with
37027c74787SPoul-Henning Kampsending I/O requests through the graph.
37116e88145SCeri Davies.It Em "I/O REQUESTS" ,
37278ad5421SRuslan Ermilovrepresented by
37378ad5421SRuslan Ermilov.Vt "struct bio" ,
37478ad5421SRuslan Ermilovoriginate at a consumer,
37516e88145SCeri Daviesare scheduled on its attached provider and, when processed, are returned
37627c74787SPoul-Henning Kampto the consumer.
37778ad5421SRuslan ErmilovIt is important to realize that the
37878ad5421SRuslan Ermilov.Vt "struct bio"
37978ad5421SRuslan Ermilovwhich enters through the provider of a particular geom does not
38078ad5421SRuslan Ermilov.Do
38178ad5421SRuslan Ermilovcome out on the other side
38278ad5421SRuslan Ermilov.Dc .
38327c74787SPoul-Henning KampEven simple transformations like MBR and BSD will clone the
38478ad5421SRuslan Ermilov.Vt "struct bio" ,
38578ad5421SRuslan Ermilovmodify the clone, and schedule the clone on their
38627c74787SPoul-Henning Kampown consumer.
38778ad5421SRuslan ErmilovNote that cloning the
38878ad5421SRuslan Ermilov.Vt "struct bio"
38978ad5421SRuslan Ermilovdoes not involve cloning the
39078ad5421SRuslan Ermilovactual data area specified in the I/O request.
39127c74787SPoul-Henning Kamp.Pp
39278ad5421SRuslan ErmilovIn total, four different I/O requests exist in
39378ad5421SRuslan Ermilov.Nm :
39478ad5421SRuslan Ermilovread, write, delete, and
39578ad5421SRuslan Ermilov.Dq "get attribute".
39627c74787SPoul-Henning Kamp.Pp
39756cf50adSPoul-Henning KampRead and write are self explanatory.
39827c74787SPoul-Henning Kamp.Pp
39927c74787SPoul-Henning KampDelete indicates that a certain range of data is no longer used
40027c74787SPoul-Henning Kampand that it can be erased or freed as the underlying technology
40127c74787SPoul-Henning Kampsupports.
40227c74787SPoul-Henning KampTechnologies like flash adaptation layers can arrange to erase
40327c74787SPoul-Henning Kampthe relevant blocks before they will become reassigned and
40456cf50adSPoul-Henning Kampcryptographic devices may want to fill random bits into the
40527c74787SPoul-Henning Kamprange to reduce the amount of data available for attack.
40627c74787SPoul-Henning Kamp.Pp
40727c74787SPoul-Henning KampIt is important to recognize that a delete indication is not a
40827c74787SPoul-Henning Kamprequest and consequently there is no guarantee that the data actually
40927c74787SPoul-Henning Kampwill be erased or made unavailable unless guaranteed by specific
4105203edcdSRuslan Ermilovgeoms in the graph.
41178ad5421SRuslan ErmilovIf
41278ad5421SRuslan Ermilov.Dq "secure delete"
41378ad5421SRuslan Ermilovsemantics are required, a
41427c74787SPoul-Henning Kampgeom should be pushed which converts delete indications into (a
41527c74787SPoul-Henning Kampsequence of) write requests.
41627c74787SPoul-Henning Kamp.Pp
41778ad5421SRuslan Ermilov.Dq "Get attribute"
41878ad5421SRuslan Ermilovsupports inspection and manipulation
41927c74787SPoul-Henning Kampof out-of-band attributes on a particular provider or path.
42078ad5421SRuslan ErmilovAttributes are named by
42178ad5421SRuslan Ermilov.Tn ASCII
42278ad5421SRuslan Ermilovstrings and they will be discussed in
42327c74787SPoul-Henning Kampa separate section below.
42478ad5421SRuslan Ermilov.El
42527c74787SPoul-Henning Kamp.Pp
42678ad5421SRuslan Ermilov(Stay tuned while the author rests his brain and fingers: more to come.)
427ba3eb872SScott Long.Sh DIAGNOSTICS
42878ad5421SRuslan ErmilovSeveral flags are provided for tracing
42978ad5421SRuslan Ermilov.Nm
43078ad5421SRuslan Ermilovoperations and unlocking
431ba3eb872SScott Longprotection mechanisms via the
432ba3eb872SScott Long.Va kern.geom.debugflags
433ba3eb872SScott Longsysctl.
434ba3eb872SScott LongAll of these flags are off by default, and great care should be taken in
435ba3eb872SScott Longturning them on.
43678ad5421SRuslan Ermilov.Bl -tag -width indent
4374f068961SRuslan Ermilov.It 0x01 Pq Dv G_T_TOPOLOGY
438ba3eb872SScott LongProvide tracing of topology change events.
4394f068961SRuslan Ermilov.It 0x02 Pq Dv G_T_BIO
440ba3eb872SScott LongProvide tracing of buffer I/O requests.
4414f068961SRuslan Ermilov.It 0x04 Pq Dv G_T_ACCESS
442ba3eb872SScott LongProvide tracing of access check controls.
443ba3eb872SScott Long.It 0x08 (unused)
444ba3eb872SScott Long.It 0x10 (allow foot shooting)
445ba3eb872SScott LongAllow writing to Rank 1 providers.
446ba3eb872SScott LongThis would, for example, allow the super-user to overwrite the MBR on the root
4474f068961SRuslan Ermilovdisk or write random sectors elsewhere to a mounted disk.
4484f068961SRuslan ErmilovThe implications are obvious.
4494f068961SRuslan Ermilov.It 0x40 Pq Dv G_F_DISKIOCTL
4508a3dce33SCeri DaviesThis is unused at this time.
4514f068961SRuslan Ermilov.It 0x80 Pq Dv G_F_CTLDUMP
452ba3eb872SScott LongDump contents of gctl requests.
453ba3eb872SScott Long.El
45456b341a2SEdward Tomasz Napierala.Sh SEE ALSO
455a7c13cccSEdward Tomasz Napierala.Xr libgeom 3 ,
45656b341a2SEdward Tomasz Napierala.Xr DECLARE_GEOM_CLASS 9 ,
457923544aaSBaptiste Daroussin.Xr disk 9 ,
45856b341a2SEdward Tomasz Napierala.Xr g_access 9 ,
45956b341a2SEdward Tomasz Napierala.Xr g_attach 9 ,
46056b341a2SEdward Tomasz Napierala.Xr g_bio 9 ,
46156b341a2SEdward Tomasz Napierala.Xr g_consumer 9 ,
46256b341a2SEdward Tomasz Napierala.Xr g_data 9 ,
46356b341a2SEdward Tomasz Napierala.Xr g_event 9 ,
46456b341a2SEdward Tomasz Napierala.Xr g_geom 9 ,
46556b341a2SEdward Tomasz Napierala.Xr g_provider 9 ,
46656b341a2SEdward Tomasz Napierala.Xr g_provider_by_name 9
46727c74787SPoul-Henning Kamp.Sh HISTORY
46878ad5421SRuslan ErmilovThis software was developed for the
46978ad5421SRuslan Ermilov.Fx
47078ad5421SRuslan ErmilovProject by
47178ad5421SRuslan Ermilov.An Poul-Henning Kamp
4724f068961SRuslan Ermilovand NAI Labs, the Security Research Division of Network Associates, Inc.\&
47378ad5421SRuslan Ermilovunder DARPA/SPAWAR contract N66001-01-C-8035
47478ad5421SRuslan Ermilov.Pq Dq CBOSS ,
47578ad5421SRuslan Ermilovas part of the
47627c74787SPoul-Henning KampDARPA CHATS research program.
47727c74787SPoul-Henning Kamp.Pp
47878ad5421SRuslan ErmilovThe first precursor for
47978ad5421SRuslan Ermilov.Nm
48078ad5421SRuslan Ermilovwas a gruesome hack to Minix 1.2 and was
4815203edcdSRuslan Ermilovnever distributed.
4825203edcdSRuslan ErmilovAn earlier attempt to implement a less general scheme
48378ad5421SRuslan Ermilovin
48478ad5421SRuslan Ermilov.Fx
48578ad5421SRuslan Ermilovnever succeeded.
48627c74787SPoul-Henning Kamp.Sh AUTHORS
4876c899950SBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
488