2002-03-27 09:58:14 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2002 Poul-Henning Kamp
|
|
|
|
.\" Copyright (c) 2002 Networks Associates Technology, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This software was developed for the FreeBSD Project by Poul-Henning Kamp
|
|
|
|
.\" and NAI Labs, the Security Research Division of Network Associates, Inc.
|
|
|
|
.\" under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
|
|
|
.\" DARPA CHATS research program.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. The names of the authors may not be used to endorse or promote
|
|
|
|
.\" products derived from this software without specific prior written
|
|
|
|
.\" permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
|
|
|
.Dd March 27, 2002
|
2002-12-11 15:57:40 +00:00
|
|
|
.Os
|
2002-03-27 09:58:14 +00:00
|
|
|
.Dt GEOM 4
|
|
|
|
.Sh NAME
|
|
|
|
.Nm GEOM
|
|
|
|
.Nd modular disk I/O request transformation framework.
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The GEOM framework provides an infrastructure in which modules
|
|
|
|
can perform transformations on disk I/O requests on their path from
|
|
|
|
the upper kernel to the device drivers and back.
|
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
Transformations in a GEOM context range from the simple geometric
|
2002-03-27 09:58:14 +00:00
|
|
|
displacement performed in typical disklabel modules over RAID
|
|
|
|
algorithms and device multipath resolution to full blown cryptographic
|
|
|
|
protection of the stored data.
|
|
|
|
.Pp
|
|
|
|
Compared to traditional "volume management", GEOM differs from most
|
|
|
|
and in some cases all previous implementations in the following ways:
|
2002-03-28 12:57:48 +00:00
|
|
|
.Bl -bullet
|
2002-03-27 09:58:14 +00:00
|
|
|
.It
|
|
|
|
GEOM is extensible. It is trivially simple to write a new class
|
|
|
|
of transformation and it will not be given stepchild treatment. If
|
|
|
|
someone for some reason wanted to mount IBM MVS diskpacks, a class
|
|
|
|
recognizing and configuring their VTOC information would be a trivial
|
|
|
|
matter.
|
|
|
|
.It
|
|
|
|
GEOM is topologically agnostic. Most volume management implementations
|
|
|
|
have very strict notions of how classes can fit together, very often
|
|
|
|
one fixed hierarchy is provided for instance subdisk - plex -
|
|
|
|
volume.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Being extensible means that new transformations are treated no differently
|
|
|
|
than existing transformations.
|
|
|
|
.Pp
|
|
|
|
Fixed hierarchies are bad because they make it impossible to express
|
|
|
|
the intent efficiently.
|
|
|
|
In the fixed hierarchy above it is not possible to mirror two
|
2002-06-09 10:25:51 +00:00
|
|
|
physical disks and then partition the mirror into subdisks, instead
|
2002-03-27 09:58:14 +00:00
|
|
|
one is forced to make subdisks on the physical volumes and to mirror
|
|
|
|
these two and two resulting in a much more complex configuration.
|
|
|
|
GEOM on the other hand does not care in which order things are done,
|
|
|
|
the only restriction is that cycles in the graph will not be allowed.
|
|
|
|
.Pp
|
|
|
|
.Sh "TERMINOLOGY and TOPOLOGY"
|
|
|
|
Geom is quite object oriented and consequently the terminology
|
2002-06-09 10:25:51 +00:00
|
|
|
borrows a lot of context and semantics from the OO vocabulary:
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
A "class", represented by the data structure g_class implements one
|
|
|
|
particular kind of transformation. Typical examples are MBR disk
|
2002-06-09 10:25:51 +00:00
|
|
|
partition, BSD disklabel, and RAID5 classes.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
An instance of a class is called a "geom" and represented by the
|
2002-06-09 10:25:51 +00:00
|
|
|
data structure "g_geom". In a typical i386 FreeBSD system, there
|
2002-03-27 09:58:14 +00:00
|
|
|
will be one geom of class MBR for each disk.
|
|
|
|
.Pp
|
|
|
|
A "provider", represented by the data structure "g_provider", is
|
|
|
|
the front gate at which a geom offers service.
|
2002-06-09 10:25:51 +00:00
|
|
|
A provider is "a disk-like thing which appears in /dev" - a logical
|
2002-03-27 09:58:14 +00:00
|
|
|
disk in other words.
|
2002-06-09 10:25:51 +00:00
|
|
|
All providers have three main properties: name, sectorsize and size.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
A "consumer" is the backdoor through which a geom connects to another
|
2002-06-09 10:25:51 +00:00
|
|
|
geom provider and through which I/O requests are sent.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
The topological relationship between these entities are as follows:
|
|
|
|
.Bl -bullet
|
|
|
|
.It
|
|
|
|
A class has zero or more geom instances.
|
|
|
|
.It
|
|
|
|
A geom has exactly one class it is derived from.
|
|
|
|
.It
|
|
|
|
A geom has zero or more consumers.
|
|
|
|
.It
|
2002-06-09 10:25:51 +00:00
|
|
|
A geom has zero or more providers.
|
2002-03-27 09:58:14 +00:00
|
|
|
.It
|
|
|
|
A consumer can be attached to zero or one providers.
|
|
|
|
.It
|
|
|
|
A provider can have zero or more consumers attached.
|
|
|
|
.El
|
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
All geoms have a rank-number assigned, which is used to detect and
|
|
|
|
prevent loops in the acyclic directed graph. This rank number is
|
2002-03-27 09:58:14 +00:00
|
|
|
assigned as follows:
|
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
A geom with no attached consumers has rank=1
|
|
|
|
.It
|
2002-06-09 10:25:51 +00:00
|
|
|
A geom with attached consumers has a rank one higher than the
|
2002-03-27 09:58:14 +00:00
|
|
|
highest rank of the geoms of the providers its consumers are
|
|
|
|
attached to.
|
|
|
|
.El
|
2002-12-27 12:15:40 +00:00
|
|
|
.Sh "SPECIAL TOPOLOGICAL MANEUVERS"
|
2002-06-09 10:25:51 +00:00
|
|
|
In addition to the straightforward attach, which attaches a consumer
|
2002-12-27 12:15:40 +00:00
|
|
|
to a provider, and detach, which breaks the bond, a number of special
|
|
|
|
topological maneuvers exists to facilitate configuration and to
|
2002-03-27 09:58:14 +00:00
|
|
|
improve the overall flexibility.
|
|
|
|
.Pp
|
|
|
|
.Em TASTING
|
2002-06-09 10:25:51 +00:00
|
|
|
is a process that happens whenever a new class or new provider
|
2002-03-27 09:58:14 +00:00
|
|
|
is created and it is the class' chance to automatically configure an
|
2002-06-09 10:25:51 +00:00
|
|
|
instance on providers, which it recognize as its own.
|
|
|
|
A typical example is the MBR disk-partition class which will look for
|
2002-03-27 09:58:14 +00:00
|
|
|
the MBR table in the first sector and if found and validated it will
|
|
|
|
instantiate a geom to multiplex according to the contents of the MBR.
|
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
A new class will be offered to all existing providers in turn and a new
|
2002-03-27 09:58:14 +00:00
|
|
|
provider will be offered to all classes in turn.
|
|
|
|
.Pp
|
|
|
|
Exactly what a class does to recognize if it should accept the offered
|
|
|
|
provider is not defined by GEOM, but the sensible set of options are:
|
|
|
|
.Bl -bullet
|
|
|
|
.It
|
|
|
|
Examine specific data structures on the disk.
|
|
|
|
.It
|
|
|
|
Examine properties like sectorsize or mediasize for the provider.
|
|
|
|
.It
|
2002-06-09 10:25:51 +00:00
|
|
|
Examine the rank number of the provider's geom.
|
2002-03-27 09:58:14 +00:00
|
|
|
.It
|
2002-06-09 10:25:51 +00:00
|
|
|
Examine the method name of the provider's geom.
|
2002-03-27 09:58:14 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Em ORPHANIZATION
|
|
|
|
is the process by which a provider is removed while
|
2002-06-09 10:25:51 +00:00
|
|
|
it potentially is still being used.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
When a geom makes a provider an orphan, all future I/O requests will
|
2002-03-27 09:58:14 +00:00
|
|
|
"bounce" on the provider with an error code set by the geom. Any
|
|
|
|
consumers attached to the provider will receive notification about
|
|
|
|
the orphanization and need to take appropriate action.
|
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
A geom which came into being as a result of a normal taste operation
|
|
|
|
should selfdestruct unless it has a way to keep functioning. Geoms
|
2002-03-27 09:58:14 +00:00
|
|
|
like disklabels and stripes should therefore selfdestruct whereas
|
2002-06-09 10:25:51 +00:00
|
|
|
RAID5 or mirror geoms can continue to function as long as they do
|
2002-03-27 09:58:14 +00:00
|
|
|
not loose quorum.
|
|
|
|
.Pp
|
|
|
|
When a provider is orphaned, this does not result in any immediate
|
|
|
|
change in the topology, any attached consumers are still attached,
|
|
|
|
any opened paths are still open, it is the responsibility of the
|
2002-12-27 12:15:40 +00:00
|
|
|
geoms above to close and detach as soon as this can happen.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
The typical scenario is that a device driver notices a disk has
|
|
|
|
gone and orphans the provider for it.
|
|
|
|
The geoms on top receive the orphanization event and orphan all
|
|
|
|
their providers in turn.
|
2002-06-09 10:25:51 +00:00
|
|
|
Providers, which are not attached, are destroyed right away.
|
2002-03-27 09:58:14 +00:00
|
|
|
Eventually at the toplevel the geom which interfaces
|
|
|
|
to the DEVFS received an orphan event on its consumer and it
|
|
|
|
calls destroy_dev(9) and does an explicit close if the
|
2002-12-27 12:15:40 +00:00
|
|
|
device was open and then detaches its consumer.
|
2002-03-27 09:58:14 +00:00
|
|
|
The provider below is now no longer attached to and can be
|
2002-12-27 12:15:40 +00:00
|
|
|
destroyed, if the geom has no more providers it can detach
|
2002-03-27 09:58:14 +00:00
|
|
|
its consumer and selfdestruct and so the carnage passes back
|
2002-12-27 12:15:40 +00:00
|
|
|
down the tree, until the original provider is detached from
|
2002-03-27 09:58:14 +00:00
|
|
|
and it can be destroyed by the geom serving the device driver.
|
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
While this approach seems byzantine, it does provide the maximum
|
|
|
|
flexibility in handling disappearing devices.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
.Em SPOILING
|
|
|
|
is a special case of orphanization used to protect
|
|
|
|
against stale metadata.
|
|
|
|
It is probably easiest to understand spoiling by going through
|
|
|
|
an example.
|
|
|
|
.Pp
|
|
|
|
Imagine a disk, "da0" on top of which a MBR geom provides
|
|
|
|
"da0s1" and "da0s2" and on top of "da0s1" a BSD geom provides
|
|
|
|
"da0s1a" through "da0s1e", both the MBR and BSD geoms have
|
|
|
|
autoconfigured based on data structures on the disk media.
|
|
|
|
Now imagine the case where "da0" is opened for writing and those
|
|
|
|
data structures are modified or overwritten: Now the geoms would
|
|
|
|
be operating on stale metadata unless some notification system
|
|
|
|
can inform them otherwise.
|
|
|
|
To avoid this situation, when the open of "da0" for write happens,
|
|
|
|
all attached consumers are told about this, and geoms like
|
|
|
|
MBR and BSD will selfdestruct as a result.
|
|
|
|
When "da0" is closed again, it will be offered for tasting again
|
|
|
|
and if the data structures for MBR and BSD are still there, new
|
|
|
|
geoms will instantiate themselves anew.
|
|
|
|
.Pp
|
|
|
|
Now for the fine print:
|
|
|
|
.Pp
|
|
|
|
If any of the paths through the MBR or BSD module were open, they
|
|
|
|
would have opened downwards with an exclusive bit rendering it
|
|
|
|
impossible to open "da0" for writing in that case and conversely
|
|
|
|
the requested exclusive bit would render it impossible to open a
|
|
|
|
path through the MBR geom while "da0" is open for writing.
|
|
|
|
.Pp
|
|
|
|
From this it also follows that changing the size of open geoms can
|
|
|
|
only be done through their cooperation.
|
|
|
|
.Pp
|
|
|
|
Finally: the spoiling only happens when the write count goes from
|
|
|
|
zero to non-zero and the retasting only when the write count goes
|
|
|
|
back to zero.
|
|
|
|
.Pp
|
|
|
|
.Em INSERT/DELETE
|
|
|
|
are a very special operation which allows a new geom
|
|
|
|
to be instantiated between a consumer and a provider attached to
|
|
|
|
each other and to remove it again.
|
|
|
|
.Pp
|
|
|
|
To understand the utility of this, imagine a provider with
|
2002-12-12 17:26:04 +00:00
|
|
|
being mounted as a file system.
|
2002-03-27 09:58:14 +00:00
|
|
|
Between the DEVFS geoms consumer and its provider we insert
|
2002-06-09 10:25:51 +00:00
|
|
|
a mirror module which configures itself with one mirror
|
2002-03-27 09:58:14 +00:00
|
|
|
copy and consequently is transparent to the I/O requests
|
|
|
|
on the path.
|
|
|
|
We can now configure yet a mirror copy on the mirror geom,
|
2002-06-09 10:25:51 +00:00
|
|
|
request a synchronization, and finally drop the first mirror
|
2002-03-27 09:58:14 +00:00
|
|
|
copy.
|
2002-12-12 17:26:04 +00:00
|
|
|
We have now in essence moved a mounted file system from one
|
2002-03-27 09:58:14 +00:00
|
|
|
disk to another while it was being used.
|
|
|
|
At this point the mirror geom can be deleted from the path
|
|
|
|
again, it has served its purpose.
|
|
|
|
.Pp
|
|
|
|
.Em CONFIGURE
|
|
|
|
is the process where the administrator issues instructions
|
|
|
|
for a particular class to instantiate itself. There are multiple
|
|
|
|
ways to express intent in this case, a particular provider can be
|
|
|
|
specified with a level of override forcing for instance a BSD
|
|
|
|
disklabel module to attach to a provider which was not found palatable
|
|
|
|
during the TASTE operation.
|
|
|
|
.Pp
|
|
|
|
Finally IO is the reason we even do this: it concerns itself with
|
|
|
|
sending I/O requests through the graph.
|
|
|
|
.Pp
|
|
|
|
.Em "I/O REQUESTS
|
|
|
|
represented by struct bio, originate at a consumer,
|
2002-06-09 10:25:51 +00:00
|
|
|
are scheduled on its attached provider, and when processed, returned
|
2002-03-27 09:58:14 +00:00
|
|
|
to the consumer.
|
|
|
|
It is important to realize that the struct bio which
|
2002-12-27 12:15:40 +00:00
|
|
|
enters through the provider of a particular geom does not "come
|
2002-03-27 09:58:14 +00:00
|
|
|
out on the other side".
|
|
|
|
Even simple transformations like MBR and BSD will clone the
|
2002-06-09 10:25:51 +00:00
|
|
|
struct bio, modify the clone, and schedule the clone on their
|
2002-03-27 09:58:14 +00:00
|
|
|
own consumer.
|
|
|
|
Note that cloning the struct bio does not involve cloning the
|
|
|
|
actual data area specified in the IO request.
|
|
|
|
.Pp
|
|
|
|
In total five different IO requests exist in GEOM: read, write,
|
2002-06-09 10:25:51 +00:00
|
|
|
delete, format, get attribute, and set attribute.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
2002-06-09 10:25:51 +00:00
|
|
|
Read and write are self explanatory.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Pp
|
|
|
|
Delete indicates that a certain range of data is no longer used
|
|
|
|
and that it can be erased or freed as the underlying technology
|
|
|
|
supports.
|
|
|
|
Technologies like flash adaptation layers can arrange to erase
|
|
|
|
the relevant blocks before they will become reassigned and
|
2002-06-09 10:25:51 +00:00
|
|
|
cryptographic devices may want to fill random bits into the
|
2002-03-27 09:58:14 +00:00
|
|
|
range to reduce the amount of data available for attack.
|
|
|
|
.Pp
|
|
|
|
It is important to recognize that a delete indication is not a
|
|
|
|
request and consequently there is no guarantee that the data actually
|
|
|
|
will be erased or made unavailable unless guaranteed by specific
|
|
|
|
geoms in the graph. If "secure delete" semantics are required, a
|
|
|
|
geom should be pushed which converts delete indications into (a
|
|
|
|
sequence of) write requests.
|
|
|
|
.Pp
|
|
|
|
Get attribute and set attribute supports inspection and manipulation
|
|
|
|
of out-of-band attributes on a particular provider or path.
|
|
|
|
Attributes are named by ascii strings and they will be discussed in
|
|
|
|
a separate section below.
|
|
|
|
.Pp
|
|
|
|
(stay tuned while the author rests his brain and fingers: more to come.)
|
|
|
|
.Sh HISTORY
|
|
|
|
This software was developed for the FreeBSD Project by Poul-Henning Kamp
|
|
|
|
and NAI Labs, the Security Research Division of Network Associates, Inc.
|
|
|
|
under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
|
|
|
DARPA CHATS research program.
|
|
|
|
.Pp
|
|
|
|
The first precursor for GEOM was a gruesome hack to Minix 1.2 and was
|
2002-06-09 10:25:51 +00:00
|
|
|
never distributed. An earlier attempt to implement a less general scheme
|
|
|
|
in FreeBSD never succeeded.
|
2002-03-27 09:58:14 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An "Poul-Henning Kamp" Aq phk@FreeBSD.org
|