Commit Graph

477 Commits

Author SHA1 Message Date
phk
bcf1d466fe NO_GEOM cleanup: Mark the last arg to disk_create() as unused. 2003-01-30 11:39:36 +00:00
phk
89099a65fb Add code to repsect the D_NOGIANT flag, should the disk device driver set it.
NO_GEOM cleanup:        remove ifdefs.

Still untested.
2003-01-29 19:47:25 +00:00
phk
15d50f061e Sort these functions as the author instructed. 2003-01-29 18:37:29 +00:00
phk
d12257b0f6 Mark some args unused so this compiles in userland. 2003-01-28 09:48:09 +00:00
phk
188cb3f63b Use a void * to carry the private data for return-call'ed ioctl requests.
Amongst other things this avoids a complex workaround in the userland
regression bits.
2003-01-28 09:47:50 +00:00
phk
f71e2dab31 Implement DIOCBSDBB ioctl which overwrites first BBSIZE bytes of BSD
labeled disk.

This is complicated by the fact that BBSIZE is greater than the
PAGE_SIZE limit ioctl inflicts on arguments which are automatically
copied in.

As long as we don't need access to userland memory (copyin/out) we
can deal with the ioctl using g_callme() which executes it from the
GEOM event thread.

Once we need copyin/out, we need to return the bio with EDIRIOCTL
in order to make geom_dev call us back in the original process context
where copyin will work.

Unfortunately, that results in us getting called with Giant, so
we have to DROP_GIANT/PICKUP_GIANT around the code where we diddle
GEOMs internals.

Sometimes you just can't win...

... But it does make geom_bsd.c an almost complete example of the
GEOM beastiarium.
2003-01-26 21:54:36 +00:00
alfred
bf8e8a6e8f Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
phk
dc9137bbd9 disk_dev_synth() is a NO_GEOM hack. 2003-01-20 11:29:07 +00:00
phk
9241d94016 Remove need for <sys/diskslice.h> but retain numerical compatibilty just in case. 2003-01-20 11:23:00 +00:00
phk
b9e99ecd32 Finally give CCD the disk mini-layer treatment:
CAUTION:

        Previously CCD would be different from all other disks in
        the system in that there were no "ccd0" device, only a
        "ccd0c" device.

        This is no longer so after this commit.  If you access a
        ccd device through the "/dev/ccd0c" device _and_ have not
        actually put a BSD disklabel on the device, you will have
        to use the name "/dev/ccd0".  If your CCD device contains
        a BSD disklabel there should be no difference.

        You need to recompile ccdconfig(8) using the changed
        src/sys/sys/ccdvar.h for the -g "show me" option to work.

        I have run the regression test I created before I started
        overhauling CCD and it flags no problems, but this code
        is mildly evil, so take care.  If you would cry if you lost
        what's on CCD, make a back before you upgrade.

Create separate cdevsw for the /dev/ccd.ctl device.

Remove the cloning function, the disk-minilayer will do all naming
for us.

Remove the ccdunit and ccdpart functions and carry the softc pointer
in the relevant dev_t's and structures.

Release all memory when a CCD device is unconfigured, previously
the softc would linger behind.

Remove all traces of BSD disklabel fiddling code.

Remove ccdpsize, the disk mini-layer does this for us.

Don't allocate memory with M_WAITOK in ccdstrategy().

Remove boundary checks which the disk mini-layer does for us.

Don't allocate space for more than 2 ccdbuf, RAID was never implemented.

NB: I have not tried to address any of the preexisting ailments of CCD.
2003-01-19 15:00:58 +00:00
phk
10e76c3f14 Unifdef -UDEBUG on the CCD driver. The debugging is mostly useless
and can be added back selectively, should anybody start to interest
themselves for the internal workings of ccd.

This commit will make the diffs for the following commits much more
readable.
2003-01-19 14:35:38 +00:00
phk
1a85c3746b Inline now trivial functions getccdbuf() and putccdbuf().
Fix another trivial memory-leak.
2003-01-18 12:23:49 +00:00
phk
5bbadf161c Fix minor memory-leak. 2003-01-18 11:33:06 +00:00
phk
d5b262df48 Use the M_CCD malloc bucket instead of M_DEVBUF.
Don't keep a private freelist of a low number of trivially small structures.
2003-01-18 11:04:41 +00:00
phk
577399eeab Inline trivial function ccdintr() into its one caller ccdiodone().
Only call ccdfind() once in ccdiodone() and cache the result.
2003-01-18 10:44:17 +00:00
phk
961794d713 Sanitize the copyright section a bit: We do not need two copies of the
four-clause BSD license in the file, one will do.
2003-01-18 10:08:27 +00:00
phk
62c9659f0c Find places to store the previously implicityly passed unit number in
the three configuration ioctls which need a unit number.

Add a "ccd.ctl" device for config operations.

Implement ioctls on ccd.ctl which rely on the explicityly passed
unit numbers.

Update ccdconfig to use the new ccd.ctl interface.

Add code to the kernel to detect old ccdconfig binaries, and whine
about it.

Add code to ccdconfig to detect old kernels, and whine about it.

These two compatibility measures will be retained only for a limited
period since they are in the way of GEOM'ification of ccd.
2003-01-17 14:53:53 +00:00
phk
e9184d11f9 Add a very simple but functional GEOM mirror class.
This is committed more as an instructive tool than as a production
facility, but this will change over time.
2003-01-14 22:44:48 +00:00
phk
aaa8136387 Now that we have non-geom_disk based drivers, we need to cover for those,
in case they return EOPNOTSUPP on an ioctl.

Found by:	jhb
2003-01-14 21:31:00 +00:00
phk
e67e97880d Always issue ioctls as BIO_GEATTR requests. The direction of data copies on
ioctls are no reliable indication of the ioctls "set" or "get" nature or if
such simplistic categories can even be applied.

MFC candidate:	boot0cfg issue.
2003-01-13 11:34:35 +00:00
phk
6ef829cd7d Remove g_silence(). It does not do anything anymore. 2003-01-13 08:46:32 +00:00
phk
672b19058d Fix typo. 2003-01-13 08:44:03 +00:00
phk
83f3fce109 Don't restrict MBR sectorsize to 512 bytes.
Test data provided by:	Andrey Koklin <aka@veco.ru>
2003-01-11 12:30:51 +00:00
jhb
03f0bdefde Output the fstype of each partition in a disklabel in the configuration
text similar to the way that the MBR module dumps its slice types.
2003-01-10 19:44:14 +00:00
phk
158843e06d BSD disklabels expose the controling label though the 'c' partition, and
some trick is necessary to prevent further BSD geoms from attaching to
that.  Our old trick was to make sure we don't attach to a geom from
the "BSD" class, but this doesn't work if an intermediary geom obscures
this fact.  Instead, calculate the MD5 checksum of the label we target
and ask if anybody below us loves that label.  If they do we don't.

Coded by:       gordon.
2003-01-06 20:10:41 +00:00
phk
d68eff9b1b In userland case include <errno.h>, not <err.h>. This is needed to make
the src/tools/regression/geom stuff compile.
2003-01-06 20:05:45 +00:00
nyan
864080610e Rename the dos_partition structure for pc98 to pc98_partition. 2003-01-04 08:50:48 +00:00
phk
dd55faeb5e Remove CCDF_SWAP and CCDF_PARITY, they have never been implemented. 2003-01-03 08:57:40 +00:00
nyan
fac5fc844d MFMBR: Add ioctls for writing an IPL and a boot menu. 2003-01-03 07:13:36 +00:00
phk
bfabff54fe Remove unused second argument from BIO_STRATEGY() 2003-01-03 05:51:11 +00:00
phk
bc7a07d94c Optimize the size of the work-items by letting the mapping function
decide the largest size which stays inside the zone and does not
collide with a lock sector.
2003-01-02 19:29:49 +00:00
phk
8fa3036bdb Update si_bsize_phys on open.
MFC candidate.
2003-01-02 09:38:22 +00:00
schweikh
86f7487fb6 Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.
2002-12-30 21:18:15 +00:00
phk
78a7deb4bb Implement ioctls for tampering with sector0. 2002-12-29 14:59:24 +00:00
phk
27cb79fe10 Remove the "ascii" attribute from the sysctls so that "sysctl -a" will
skip them.
2002-12-27 07:58:59 +00:00
phk
516da34ba8 white-space changes 2002-12-26 21:02:50 +00:00
phk
2e1375146e Use a mutex assert to document our locking circumstances. 2002-12-26 20:48:22 +00:00
phk
3d7762dd22 We should not need to hold Giant for sbuf operations any more. 2002-12-26 20:46:30 +00:00
phk
3e75022eb7 Add an XXX comment to explain the predicament. 2002-12-26 20:45:37 +00:00
phk
0989bb3e91 Don't forget our topology lock in the MBREXT case. 2002-12-19 12:01:19 +00:00
phk
790740dde5 Solve another bug in the mapping code: correctly skip lock sectors.
Make sure sector zero is protected if it contains metadata.

Lower WARNS for gbde to 3 on non-i386 archs.  rijndael-fst is evil
but appearntly does the right thing and passes the test-vectors.

MFC Candidate.
2002-12-18 22:11:54 +00:00
phk
761d063e80 Fix two blunders in the mapping functions which can lead to corrupt data,
for request sizes larger than the sectorsize or for multi-key setups.

See warning mailed to current@ for details of recovery.

Found by:	Marcus Reid <marcus@blazingdot.com>
2002-12-18 19:57:27 +00:00
phk
4052863334 Balk at unaligned requests.
MFC candidate.
2002-12-18 19:53:59 +00:00
phk
51c494ca74 Add a check for negative offset locations and return EINVAL for them. 2002-12-17 21:31:58 +00:00
phk
ebfad8464d Don't mangle geometry for pc98, this will happen in the ata driver. 2002-12-17 15:50:51 +00:00
phk
8a25281415 Remember to hold topology lock when we change things.
Spotted by:	kuriyama
2002-12-17 09:44:10 +00:00
phk
ef296549a5 Constify the dumpconf() function. 2002-12-17 07:22:48 +00:00
phk
3cf4280261 Get rid of g_slice_addslice() and use g_slice_config() instead.
Tested with:	i386 + src/tools/regression/geom
2002-12-16 23:08:48 +00:00
phk
cd9caf5281 Constification and some s/int/u_int/ changes. 2002-12-16 22:33:27 +00:00
phk
0d6813c06f Add a couple of KASSERTS, just in case. 2002-12-13 22:04:45 +00:00
phk
43d82ce26d Don't interpret the hotspots relative to all slices on a slicer, but
relative to the parent device.
2002-12-13 21:31:13 +00:00
phk
39fb253bb1 Fix spelling in comment. 2002-12-13 21:10:59 +00:00
sos
71edc5e4eb Add support for the PC98 platform to the ATA driver.
This mostly consists of functionality to serialize accesses to
the two ATA channels (which can also be used to "fix" certain
PCI based controllers).
Add support for Acard controllers.
Enable the ATA driver in PC98 GENERIC, and add device hints.
Update man page with latest support.

The PC98 core team has kindly provided me with a PC98
machine that made this all possible, thanks to all that
contributed to that effort, without that this would
probably newer have been possible..

Approved by: re@
2002-12-03 20:20:44 +00:00
phk
bf720d1bf7 Use the hotspot code to prevent people from overwriting their disklabel
with stuff which would ruin the day for any open parititons.

Approved by:	re
2002-12-02 20:23:54 +00:00
phk
7b3238944a Add a simplified version of the hot-spot code to enable us to protect
in-band disklabels from in-band vandalism.

Approve by:	re
2002-12-02 19:59:25 +00:00
phk
7c627ee994 Use more mnemonic argument names in the access functions.
Sponsored by:	DARPA & NAI Labs
Approved by:	re (blanket)
2002-12-01 15:54:39 +00:00
phk
f3c2bbdee1 Fix a cut&past-o.
Spotted by:	yar
Approved by:	re (blanket)
2002-12-01 15:53:31 +00:00
phk
d2f5accf6d Conceiveably, there may exist an algorithm which can tell if a sequence of bytes
are the output of AES/128/CBC or ARC4RANDOM.  Encrypt the random data with which
we wipe when we get a BIO_DELETE to make such an algorithm useful.

Sponsored by:	DARPA & NAI Labs
Approved by:	re (blanket)
2002-12-01 15:50:48 +00:00
phk
2e45221c26 Use unsigned for an index.
Sponsored by:	DARPA & NAI Labs.
Approved by:	re (blanket).
2002-12-01 15:47:49 +00:00
phk
8411a44a2f Remember to update the providers idea of its size when we reconfigure
a slice child.

Approved by:	re
2002-11-20 20:12:52 +00:00
phk
65d6c06a91 Do not call the dumpconf method unless there is one.
Compare pointers with NULL.

Partially submitted by:	Christian Carstensen <cc@gate5.de>
Approved by:	re
2002-11-20 18:10:42 +00:00
nyan
86cc001c1b Save a slice name on the disk and print it at g_pc98_dumpconf(). 2002-11-17 13:56:37 +00:00
phk
38900b3ee3 Remove harmless but irritating printf. 2002-11-08 15:35:16 +00:00
phk
875ed4eea7 Always recalculate the SRM checksum if the label is at 64 bytes offset.
Tested by:	jhb
2002-11-08 15:31:34 +00:00
nyan
bf0b83376e Fix to support pc98.
It is mostly merged from MBR specific part.

Reviewed by:	phk
2002-11-07 16:42:37 +00:00
phk
ad8a01f928 Straighten up the geom.ctl config interface definitions.
Sponsored by:	DARPA & NAI Labs
2002-11-06 20:05:15 +00:00
phk
a500538d00 Polish a bit here and there.
Reenable the geom.ctl device so people can play with gbde.

Sponsored by:	DARPA & NAI Labs
2002-11-04 09:31:02 +00:00
phk
16874ad923 Run a revision on the GBDE encryption facility.
Replace ARC4 with SHA2-512.
Change lock-structure encoding to use random ordering rather for obscurity.
Encrypt lock-structure with AES/256 instead of AES/128.
Change kkey derivation to be MD5 hash based.
Watch for malloc(M_NOWAIT) failures and ditch our cache when they happen.
Remove clause 3 of the license with NAI Labs consent.

Many thanks to "Lucky Green" <shamrock@cypherpunks.to> and "David
Wagner" <daw@cs.berkeley.edu>, for code reading, inputs and
suggestions.

This code has still not been stared at for 10 years by a gang of
hard-core cryptographers.  Discretion advised.

NB: These changes result in the on-disk format changing: dump/restore needed.

Sponsored by:   DARPA & NAI Labs.
2002-11-04 09:27:01 +00:00
phk
278d4201b7 Reject slices where begin == end.
Remove clause 3 from the license with NAI Labs consent.

Sponsored by:	DARPA & NAI Labs
2002-11-04 06:30:38 +00:00
phk
a5e8ff61bf Remove clause 3 in the license with NAI's consent.
Reject slices with type==0.
Diddle the bootverbose printfs.

Sponsored by:	DARPA & NAI Labs
2002-11-04 06:29:05 +00:00
marcel
b737405ed3 Remove the GEOM_GPT hack. We now check for partition type 0xEE and
skip those. This handles the Protective MBR (PMBR) which consists
of a single partition of type 0xEE that covers the whole disk and
as such protects the GPT partitioning. We allow other partitions to
be present besides partitions of type 0xEE and as such interpret
partition type 0xEE as a "hands-off" partition only.

While here, fix g_mbrext_dumpconf to test if indent is NULL and
dump the data in a form that libdisk can grok. Change the logic
in g_mbr_dumpconf to match that of g_mbrext_dumpconf. This does
not change the output, but prevents a NULL-pointer dereference
when indent == NULL && pp == NULL.
2002-11-02 12:01:12 +00:00
marcel
3ff7b03806 Fix dumpconf so libdisk can grok its output. We weren't checking
if indent was NULL. Consequently we always emitted the XML format.
2002-11-02 11:45:54 +00:00
phk
982f8bb0ad malloc(9) with M_NOWAIT seems to return NULL a lot more than I would have
expected under -current.  This is a problem for GEOM because the up/down
threads cannot sleep waiting for memory to become free.  The reason they
cannot sleep is that paging things out to disk may be the only way we can
clear up some RAM.  Nice catch-22 there.

Implement a rudimentary ENOMEM recovery strategy:  If an I/O request
fails with an error code of ENOMEM, schedule it for a retry, and
tell the down-thread to sleep hz/10 to get other parts of the system
a chance to free up some memory, in particular the up-path in GEOM.

All caches should probably start to monitor malloc(9) failures using the new
malloc_last_fail() function, and release when it indicates congestion.

Sponsored by:	DARPA & NAI Labs.
2002-11-02 11:08:07 +00:00
phk
e0f89bf346 Make this compile in the userland shims again.
Sponsored by:	DARPA & NAI Labs
2002-11-01 15:57:55 +00:00
phk
72c30b5844 Add KASSERT for bio_cmd validity here as well. Various hacks still
bypass specfs.
2002-11-01 15:56:26 +00:00
phk
594d92f0f9 Spruce up bootverbose output a bit.
Allow extended partitions to have flag=0x80
2002-10-31 22:18:49 +00:00
phk
c82a18684b Change the kkey generation cherry-picker to use MD5.
Sponsored by:	DARPA & NAI Labs
2002-10-30 22:13:54 +00:00
phk
36b357552e Add the remaning part of the new libdisk interaction.
WARNING:  This is not a published interface, it is a stopgap measure for
WARNING:  libdisk so we can get 5.0-R out of the door.

Sponsored by:	DARPA & NAI Labs
2002-10-28 22:43:54 +00:00
phk
bddb286f46 Add support for the new libdisk interaction.
Sponsored by:	DARPA & NAI Labs.
2002-10-28 22:42:20 +00:00
phk
35eae04ebb Fix a bug in the cherry-picker kkey generator routine.
WARNING:  You need to backup and restore the _unencrypted_ contents
WARNING:  of your GBDE disks when you take this update!

Sponsored by:	DARPA & NAI Labs.
2002-10-28 11:06:58 +00:00
phk
e3283252f9 Add more compatibility junk. 2002-10-28 07:50:47 +00:00
phk
4772146a86 Don't truncate on large disks. 2002-10-27 10:17:38 +00:00
phk
fe41e143c1 Make geom_mbr.c optional on PC98, use GEOM_MBR option to include it.
Disable check for supposedly magic "IPL1" string for PC98 labels, its
thaumaturgical power is in doubt.
2002-10-26 20:17:59 +00:00
phk
b7e23599cf Reduce the GEOM verbosity under bootverbose to something more sufferable.
This is not quite the set of information I would want, but the tree where
I have the "correct" version is messed up with conflicts.

Sponsored by:	DARPA & NAI Labs.
2002-10-25 20:09:45 +00:00
phk
1f3b3d6f9d Add a g_dev_print() function which prints all the /dev entries GEOM
know about.
2002-10-25 18:42:42 +00:00
phk
01399b8c20 Loose the g_dev_clone() noise. 2002-10-25 17:00:15 +00:00
phk
291992383a Use a better test to prevent tasting geom.ctl so we don't screw the
regression tests.
2002-10-24 21:32:49 +00:00
phk
75576547f2 Don't taste the first provider, it's /dev/geom.ctl and it's not going
to taste like anything we like anyway.
2002-10-24 19:20:28 +00:00
phk
b691eae4b5 No need to specify CTLTYPE_INT when we use SYSCTL_INT. 2002-10-20 22:46:50 +00:00
phk
af63f9546a Now that the sectorsize and mediasize are properties of the provider,
don't take the detour over the I/O path to discover them using getattr(),
we can just pick them out directly.

Do note though, that for now they are only valid after the first open
of the underlying disk device due compatibility with the old disk_create()
API.  This will change in the future so they will always be valid.

Sponsored by:   DARPA & NAI Labs.
2002-10-20 20:28:24 +00:00
phk
f0693daa1f The g_id*() functions are not needed in the userland test-suite so
#ifdef _KERNEL them rather than deal with a copyin simulation.

Sponsored by:	DARPA & NAI Labs
2002-10-20 20:08:44 +00:00
phk
5df21f9258 Make the sectorsize a property of providers so we can include it in the XML
output.

Sponsored by:	DARPA & NAI Labs
2002-10-20 19:18:07 +00:00
phk
536319e740 Use %jd instead of %lld now that we have it. 2002-10-20 18:48:12 +00:00
phk
6128ce4ca2 It makes more sense for the fwheads and fwsectors properties to be in
the provider stanza rather than the geom stanza.
2002-10-20 18:46:25 +00:00
phk
78bcfbf6c0 Include fwsectors and gfwheads in the XML output for the disks we know.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 18:09:01 +00:00
phk
bf02589863 Be consistent about functions being static.
Spotted by:	FlexeLint
2002-10-20 14:30:28 +00:00
phk
9c61841d19 Constify input to the arc4 seed function.
Implement the lockfile hunting in sector zero.

Sponsored by:	DARPA & NAI Labs.
2002-10-20 11:09:58 +00:00
phk
83404357e9 Don't track bio allocation in debug output.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 08:45:17 +00:00
phk
7105c422c0 Style(9) and english(9) fixes.
Submitted by:	schweikh
2002-10-20 08:43:56 +00:00
phk
fd0bad29ea Make it possible to specify also via geom_t ID in the geom.ctl config ioctl.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 08:42:18 +00:00
phk
1ca1d78db8 Fix a missing initialization. 2002-10-19 17:19:41 +00:00
phk
f4a1c1173b Add Geom Based Disk Encryption to the tree.
This is an encryption module designed for to secure denial of access
to the contents of "cold disks" with or without destruction activation.

Major features:

   * Based on AES, MD5 and ARC4 algorithms.
   * Four cryptographic barriers:
        1) Pass-phrase encrypts the master key.
        2) Pass-phrase + Lock data locates master key.
        3) 128 bit key derived from 2048 bit master key protects sector key.
        3) 128 bit random single-use sector keys protect data payload.
   * Up to four different changeable pass-phrases.
   * Blackening feature for provable destruction of master key material.
   * Isotropic disk contents offers no information about sector contents.
   * Configurable destination sector range allows steganographic deployment.

This commit adds the kernel part, separate commits will follow for the
userland utility and documentation.

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.

Many thanks to Robert Watson, CBOSS Principal Investigator for making this
possible.

Sponsored by:   DARPA & NAI Labs.
2002-10-19 17:02:17 +00:00
tmm
7c6a7904e8 The argument to the DIOCGMEDIASIZE ioctl() is an off_t, not an u_int.
Reviewed by:	phk
2002-10-19 15:40:39 +00:00
phk
c9d1c245f8 Be consistent and return the NUL at the end of kern.geom.conf{xml,dot}.
Spotted by:	sam
2002-10-17 21:39:06 +00:00
phk
e81bc2ce55 NUL terminate sysctl kern.disks 2002-10-17 19:27:02 +00:00
njl
45684fd185 Return an error if the drive reports heads/sectors that do not make sense.
This fixes a divide by zero in fdisk(8)

Reviewed by:	phk
2002-10-15 21:28:50 +00:00
phk
1fe14c44e9 Constification ? Yes, out that door, row on the left, one patch each.
Sponsored by:	DARPA & NAI Labs
2002-10-15 18:21:53 +00:00
phk
3e0c54e506 Remove a bogus local variable.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 21:22:23 +00:00
jake
121b5e9dc2 Moved geom class initialization to SI_SUB_DRIVERS from SI_SUB_PSEUDO.
This fixes mounting root from md(4) which calls disk_create() early.
2002-10-14 20:20:17 +00:00
phk
d855c32204 Implement the GEOMCONFIGGEOM ioctl which can be used to manually create
and configure an instance of a class on a give provider.

Sponsored by:	DARPA & NAI Labs
2002-10-14 10:05:23 +00:00
phk
8298a7f6ad Add more KASSERTS.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 10:02:24 +00:00
phk
1eafd1bc95 Add the outline of the "/dev/geom.ctl" handling code.
Sponsored by:	DARPA & NAI Labs.
2002-10-13 20:33:33 +00:00
phk
a95c8cfb24 Give GEOM modules a chance to specify their own init routine, in case they
have special requirements.

Sponsored by:	DARPA & NAI Labs.
2002-10-13 18:42:35 +00:00
phk
1a10e2f35a The CAM system has it's own ideas of what locks are to be held by whom.
So do GEOM.  Not a pretty sight.

Take all the interesting stuff out of GEOM::disk_create(), and leave just
the creation of the fake dev_t.  Schedule the topology munging to happen
in the g_event thread with g_call_me().

This makes disk_create() pretty lock-agnostic, almost lock-atheist.

Tripped over by:	peter
Sponsored by:	DARPA & NAI Labs
2002-10-11 20:52:44 +00:00
phk
08c1778957 Add support g_clone_bio() and g_std_done() to spawn multiple children
of a bio and correctly gather status when done.

Sponsored by:	DARPA & NAI Labs.
2002-10-09 07:11:59 +00:00
phk
865428f1db For now, don't wait for drives to stop returning EBUSY. There is too
much broken harware around it seems.

Sponsored by:	DARPA & NAI Labs.
2002-10-08 07:03:58 +00:00
phk
2490bca6ea Correctly deal with non-DEVBSIZE drives.
Allow BIO_DELETE through too.

This fixes swap-backed md(4) devices.

Sponsored by:   DARPA & NAI Labs.
2002-10-07 07:15:37 +00:00
phk
f290022d05 Put a printf under #ifdef DIAGNOSTIC.
Sponsored by: DARPA & NAI Labs.
2002-10-07 06:57:00 +00:00
phk
05568a1e18 Copyin and copyout are only possible from a process-native thread,
and therefore we need a way for ioctl handlers to run in that thread
in GEOM.  Rather than invent a complicated registration system to
recognize which ioctl handler to use for a given ioctl, we still
schedule all ioctls down the tree as bio transactions but add a
special return code that means "call me directly" and have the
geom_dev layer do that.

Use this for all ioctls that make it as far as a diskdriver to
avoid any backwards compatibility problems.

Requested by:   scottl
Sponsored by:   DARPA & NAI Labs
2002-10-07 06:25:26 +00:00
phk
45eae5f187 This patch got lost in my trees: Pass setattr down to device drivers
as well.

Detected by:	scottl
Sponsored by:	DARPA & NAI Labs.
2002-10-05 21:55:31 +00:00
phk
2d5202be2d Fix argument order mistake when decoding disklabels from on-disk format.
Detected by:	jhay
Sponsored by:	DARPA & NAI Labs.
2002-10-05 18:52:06 +00:00
phk
951c3e53b2 NB: This commit does *NOT* make GEOM the default in FreeBSD
NB: But it will enable it in all kernels not having options "NO_GEOM"

Put the GEOM related options into the intended order.

Add "options NO_GEOM" to all kernel configs apart from NOTES.

In some order of controlled fashion, the NO_GEOM options will be
removed, architecture by architecture in the coming days.

There are currently three known issues which may force people to
need the NO_GEOM option:

boot0cfg/fdisk:
        Tries to update the MBR while it is being used to control
        slices.  GEOM does not allow this as a direct operation.

SCSI floppy drives:
        Appearantly the scsi-da driver return "EBUSY" if no media
        is inserted.  This is wrong, it should return ENXIO.

PC98:
        It is unclear if GEOM correctly recognizes all variants of
        PC98 disklabels.  (Help Wanted!  I have neither docs nor HW)

These issues are all being worked.

Sponsored by:	DARPA & NAI Labs.
2002-10-05 16:35:33 +00:00
phk
614e9a7774 Properly isolate the locking domains of sysctl from the topology lock
for the sysctls which report the configuration.

Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:38:36 +00:00
phk
8891e95872 Implement the "kern.disks" sysctl in GEOM.
This makes "mdconfig -l" work again.

Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:15:26 +00:00
phk
8ce4f690c1 Properly conditionalize a debugging printf.
Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:06:19 +00:00
phk
097d50c720 Move GEOM's sysctls under kern.geom.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:51:02 +00:00
phk
1b32e38e4f Put some failing ioctl related printfs under a suitable debug flag.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:48:39 +00:00
phk
a2252944ee Use the canonical root:operator 0640 for GEOM disk devices.
Spotted by:	brooks
Sponsored by:	DARPA & NAI Labs.
2002-10-01 19:33:09 +00:00
phk
1cbad971e5 Don't restrict device drivers ability to sleep in the ioctl method, this
is actually entirely legal.

Do bio's with ioctls in them in a g_call_me() function.

Sponsored by:	DARPA & NAI Labs
2002-10-01 18:42:32 +00:00
phk
51b94ac147 Include <sys/diskmbr.h> instead of <sys/disklabel.h>
Sponsored by:	DARPA & NAI Labs.
2002-10-01 14:05:06 +00:00
phk
fa0965a0b0 Don the asbestos underwear and add the code which lets DIOCWDINFO
write modified disklabels back to disk.

Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:59:59 +00:00
phk
852521acba Retire g_io_fail() and let g_io_deliver() take an error argument instead.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:54:46 +00:00
phk
72d7c1eb0e Introduce g_write_data() function.
Sponsored by:	DARPA & NAI Labs
2002-09-30 08:50:47 +00:00
phk
a2bc7673e2 Add missing g_enc_le2().
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:47:46 +00:00
phk
02a0f0a003 Disable the g_sanity() check unless people ask for it in the debugflags.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:46:29 +00:00
phk
23e3bcb405 Make sure we don't loose our topology lock in a call_me() handler.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:27:29 +00:00
phk
45000db183 Zero the local-variable mutexes before we call mtx_init() on them,
failing to do this may lead mtx_init() to belive they have already
been initialized.

Detected by:	Marc Recht <marc@informatik.uni-bremen.de>
2002-09-28 19:38:29 +00:00
phk
6b59496dd8 Style, whitespace and lint fixes.
Sponsored by:	DARPA & NAI Labs.
2002-09-28 11:57:20 +00:00
phk
b5231fc7a7 Void functions cannot use return(foo) even if foo is also returning void.
Sponsored by:	DARPA & NAI Labs.
2002-09-28 11:43:20 +00:00
phk
19335151f1 First confirmed kill from my Flexelint license: Check return value
of g_clone_bio().

Detected by:	http://www.gimpel.com/html/flex.htm
Sponsored by:	DARPA & NAI Labs.
2002-09-28 08:16:50 +00:00
phk
f1d8f5aa08 Extensively rework the geom_bsd method, put a lot of comments in, betting
that this will make people use this for their future copy&paste operations.

Rework the detection of raw-disk offsets in disklabels.  This actually
unearthed a number of bugs in the (now) previous version.

Also accept labels which don't have a magic RAW_PART, provided they don't
confuse us too much.

Change the order of our sanity-checks on labels found on disks to be more
robust.

Check against MAXPARTITIONS in our sanity-check and reject disklabels
we cannot cope with.

Create new g_bsd_modify() function to implment disklabel modifying
ioctls.

Implement DIOCSDINFO and DIOCWDINFO with the provision that the latter
still not writes your change back to disk.  I didn't have the nerves
for that yet.

In the start routine, use g_call_me() for complex ioctls to prevent
sleeping.

Sponsored by:   DARPA & NAI Labs.
2002-09-27 21:54:37 +00:00
phk
bd4b849139 Add the new g_slice_config() call, which can add/delete/change a slice,
with support for trying, doing and forcing.

This will eventually replace g_slice_addslice() which gets changed from
grabbing topology to requing it in this commit as well.

Sponsored by:   DARPA & NAI Labs.
2002-09-27 21:37:11 +00:00
phk
577f8b1e73 Make the UP/DOWN threads hold on to their own private mutex while doing
work.

This prevents people from sleeping in the UP/DOWN I/O path by mistake
or design (doing so almost invariably result in deadlocks since it
stalls all I/O processing in the given direction.

Sponsored by:   DARPA & NAI Labs.
2002-09-27 21:24:40 +00:00
phk
891aee9210 Correctly en/decode MAXPARTITIONS partitions.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 21:19:47 +00:00
phk
3a17cc7881 Setattr should not retry on EBUSY, we could get EBUSY back because
a disklabel modification tries to change an open device, and no
counter-examples exists.

Be less facist about when we can do Setattr, the openmodes of devices
are so loosely managed that the "exclusive" count is almost useless.

Sponsored by:   DARPA & NAI Labs.
2002-09-27 21:12:47 +00:00
phk
f0a4656fe3 Various no-ops:
Add a __unused.

Make the 2byte decoder functions return 16 bits for the benefits
of picky lints.

No need to grab giant around a tsleep() when we have a timeout.

Sponsored by:	DARPA & NAI Labs.
2002-09-27 21:05:05 +00:00
phk
7f365f22fc Correctly calculate size of PC98 slices.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:56:21 +00:00
phk
0aade3f175 Allocate bio's with M_NOWAIT and let the caller deal with the problems.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:53:47 +00:00
phk
5002cfbb7e Add checks for g_clone_bio() returning NULL, it will be possible RSN.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:47:23 +00:00
phk
83aec680cb Implement g_call_me() as a way for geom methods to schedule operations
to be performed in the event-thread.

To do this, we need to lock the eventlist with g_eventlock (nee g_doorlock),
since g_call_me() being called from the UP/DOWN paths will not be able to
aquire g_topology_lock.

This also means that for now these events are not referenced on any
particular consumer/provider/geom.

For UP/DOWN path use, this will not become a problem since the access()
function will make sure we drain any bio's before we dismantle.

Sponsored by:   DARPA & NAI Labs.
2002-09-27 20:38:36 +00:00
phk
a09a7e0aa7 Ok, include also the two tests which actually does effect the claims
of the last commit message.

Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:30:27 +00:00
phk
85fb4b0590 Hook into the shutdown EVENTHANDLER and stop tasting things after we
get notified to make things settle a bit faster.

Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:23:35 +00:00
phk
582654c687 Rename the doorlock to eventlock, it gets to protect a bit more in the future.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:18:16 +00:00
jeff
76a1e2b647 - Use vrefcnt() instead of v_usecount. 2002-09-25 02:42:43 +00:00
phk
57a346a213 (This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)

If struct disklabel is the messenger: kill the messenger.

Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer).  This commit changes this communication to use four
explicit fields instead.

Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.

Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.

The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.

This concludes (modulus any mistakes) the series of disklabel related
commits.

I belive it all amounts to a NOP for all the rest of you :-)

Sponsored by:   DARPA & NAI Labs.
2002-09-20 19:36:05 +00:00
phk
85723587cf Remove unneeded #include <sys/disklabel.h>
Sponsored by:	DARPA & NAI Labs.
2002-09-20 17:00:24 +00:00
phk
806dbaa1e8 Retire now unused DIOCGDVIRGIN kludge.
Sponsored by:	DARPA & NAI Labs.
2002-09-20 09:31:14 +00:00
phk
238e3d3255 "Fix" printf format issues by using %j
Sponsored by:	DARPA & NAI Labs.
2002-09-13 11:41:25 +00:00
phk
39330dc632 Use biowait() rather than DIY.
Sponsored by:	DARPA & NAI Labs
2002-09-13 11:39:11 +00:00
phk
0687f90dba Add a couple more of the big/little-endian conversion routines and make
them visible from userland, if need be.

I wish that the C language contained this as part of struct definintions,
but failing that, I would settle for an agreed upon set of functions for
packing/unpacking integers in various sizes from byte-streams which may
have unfriendly alignment.

This really belongs in <sys/endian.h> I guess.
2002-09-13 10:33:10 +00:00
mux
e48c2b8560 Fix another two printf() format errors which weren't warned
about because the bio_blknos were bogusly casted to long long.
2002-09-13 09:37:44 +00:00
mux
6a8cbc1cb1 Fix another printf() format error which wasn't warned about
because the bio_blkno was bogusly casted to an int.
2002-09-13 09:19:55 +00:00
mux
af171eef1b Fix a printf() format error on 64 bits architectures.
Also fix some style bugs on the same line.
2002-09-13 09:16:06 +00:00
phk
6030f30112 Deal with a new exteded MBR paritition type
Submitted by:	Michal Mertl <mime@traveller.cz>
2002-09-08 15:13:33 +00:00
phk
42ca888ae8 Remove "magicspace". It looks good on paper, it doesn't work in practice.
Sponsored by: DARPA & NAI Labs.
2002-09-06 08:50:28 +00:00
phk
8e45a811c4 Don't respect the O_EXCL flag, we don't get it back on close so we cannot
correctly track it.

Spotted by:	peter
Sponsored by:	DARPA & NAI Labs.
2002-09-06 07:57:29 +00:00
marcel
bf1e0a8b05 Use 'p' as the partition specifier instead of 's'. We continue to use
's' for compatibility partitions (ie partitions with a BSD disklabel).
Partition numbers continue to start with 1.
Example /etc/fstab:
	# Device        Mountpoint      FStype          Options	...
	/dev/da0p1      /efi            msdos           rw	...
	/dev/da0p2      /               ufs             rw	...
	/dev/da0p3      none            swap            sw	...
2002-08-24 22:42:16 +00:00
julian
5322498852 Don't use the static thread.. it is going away. 2002-06-29 07:47:20 +00:00
phk
6a65638bb3 Add two new submodes to the AES encryption method.
This method is now suitable for encrypting swap spaces.

Sponsored by:	DARPA & NAI Labs.
2002-06-28 21:25:15 +00:00
phk
c112e2f321 Put geom_gpt.c under the GEOM option instead of having a special GEOM_GPT
option for it.
2002-06-10 18:49:41 +00:00
phk
411db1de5a Improve some on the naming.
Submitted by:	iedowse
2002-06-09 10:57:34 +00:00
phk
7f7b291518 Change the registration of magic spaces so it does its own memory management.
Sponsored by: DARPA & NAI Labs.
2002-06-05 20:30:36 +00:00
marcel
05e39ee52e Add compile time asserts for the size of struct gpt_hdr and struct
gpt_ent. Use offsetof() for struct gpt_hdr to exclude padding.
2002-05-30 06:33:07 +00:00
phk
4383144a9a Add one copy of crc32() and crc32_tab[] in libkern, and remove it two other
places.

Comment out crc32 related definitions in zlib.h, we don't seem to have the
corresponding code in our kernel.
2002-05-29 20:24:09 +00:00
marcel
5fe0fdb432 Add support to GEOM for GUID Partition Tables (GPTs). The support
is currently conditional on both the GEOM and GEOM_GPT options to
avoid getting GPT by default and having the MBR and GPT classes
clash.
The correct behaviour of the MBR class would be to back-off (reject)
a MBR if it's a Protective MBR (a MBR with a single partition of type
0xEE that spans the whole disk (as far as the MBR is concerned).
The correct behaviour if the GPT class would be to back-off (reject)
a GPT if there's a MBR that's not a Protective MBR.

At this stage it's inconvenient to destroy a good MBR when working
with GPTs that it's more convenient to have the MBR class back-off
when it detects the GPT signature on disk and have the GPT class
ignore the MBR.

In sys/gpt.h UUIDs (GUIDs) for the following FreeBSD partitions
have been defined:

GPT_ENT_TYPE_FREEBSD
	FreeBSD slice with disklabel. This is the equivalent of
	the well-known FreeBSD MBR partition type.
GPT_ENT_TYPE_FREEBSD_{SWAP|UFS|UFS2|VINUM}
	FreeBSD partitions in the context of disklabel. This is
	speculating on the idea to use the GPT to hold partitions
	instead if slices and removing the fixed (and low) limits
	we have on the number of partitions.

This commit lacks a GPT image for the regression suite.
2002-05-28 09:04:48 +00:00
phk
d41562720e Add a proof-of-concept encryption class.
"The only hard problem in cryptography is key-management."

All sectors are encrypted with AES in CBC mode using a constant key,
currently compiled in and all zero.

To activate this module, write the magic header on the partition:

	echo "<<FreeBSD-GEOM-AES>>" | dd conv=sync of=/dev/md98

The encrypted device will be one sector shorter and have ".aes"
appended to its name.

Sponsored by: DARPA & NAI Labs.
2002-05-26 18:14:38 +00:00
phk
571d9aa442 Give the closet-dev_t we hand to the diskdrivers a name. 2002-05-26 17:35:14 +00:00
phk
8bb89b7b0c Only clear the spoiled flag if the class had no spoiled method, the spoiled
method may have deallocated the consumer already and modifying free()'ed
memory is bad style.

Sponsored by: DARPA & NAI Labs.
2002-05-26 17:17:25 +00:00
bde
aa68d84998 Fixed printf format errors. Most of them are 64-bit daddr_t casualties.
Printing daddr_t's using %d format was always an error, but gcc's
warning about it was ignored for supported 64-bit arches and not printed
for supported 32-bit arches.  Hundreds if not thousands thousands of
previously "fixed" daddr_t printings are now broken on 32-bit machines
by casting daddr_t's to longs.  daddr_t's should be printed using %jd
format, but this fix uses %lld since %j is not implemented in the
kernel yet.

Fixed some nearby format printf errors (style bugs).
2002-05-25 11:05:07 +00:00
phk
476ca0197f Introduce the concept of "magic spaces", and implement them in most of
the relevant classes.

Some methods may implement various "magic spaces", this is reserved
or magic areas on the disk, set a side for various and sundry purposes.
A good example is the BSD disklabel and boot code on i386 which occupies
a total of four magic spaces: boot1, the disklabel, the padding behind
the disklabel and boot2.  The reason we don't simply tell people to
write the appropriate stuff on the underlying device is that (some of)
the magic spaces might be real-time modifiable.  It is for instance
possible to change a disklabel while partitions are open, provided
the open partitions do not get trampled in the process.

Sponsored by:	DARPA & NAI Labs.
2002-05-21 20:33:49 +00:00
phk
8623a7bc17 Remove the "-class" suffix from classes, they will not be ambiguous.
Sponsored by:	DARPA & NAI Labs.
2002-05-21 19:50:04 +00:00
phk
0d0d0abc10 Don't grab Giant around malloc(9) and free(9).
Don't grab Giant around wakeup(9).
Don't print verbose messages about each device found in geom_dev.
Various cleanups.

Sponsored by: DARPA & NAI Labs.
2002-05-20 10:03:15 +00:00
phk
c9901ea470 Generalize a bit: we don't need separate functions to find the i386 and
alpha disklabels, just one function which is told where to look.

Sponsored by: DARPA & NAI Labs.
2002-05-19 19:00:25 +00:00
phk
c98504cdac Include needed #include for regression tests.
Sponsored by: DARPA & NAI Labs.
2002-05-19 18:59:39 +00:00
phk
02fe70f68e Retire the bogus uses of the disklabel field d_sbsize and begin to
initialize it to zero so we don't have to have everbody and their
aunt including FFS specific header files.

Sponsored by: DARPA & NAI Labs.
2002-05-12 20:49:41 +00:00
phk
3cc313c2e5 Fix a {} bug which doesn't have any effect yet.
Spotted by:	jake
2002-04-27 07:07:37 +00:00
phk
3a1c16f2bc Improve the cross-references in the XML output.
Explained by:	des
Sponsored by:	DARPA & NAI Labs.
2002-04-24 21:02:28 +00:00
phk
5ec8e881ee Make specific provisions for the kernel simulator used in the regression
tests, other userland programs may need to include <geom/geom.h>.

Sponsored by:	DARPA & NAI Labs.
2002-04-24 12:53:12 +00:00
phk
4ca7562a61 Implement the GEOMGETCONF ioctl which returns vital stats for the
current device in XML in an sbuf.

Sponsored by:	DARPA & NAI Labs
2002-04-23 19:54:02 +00:00
phk
07bfe3bc16 All in a days work: make a function static. 2002-04-23 19:03:03 +00:00
phk
90094c67a1 Introduce some serious paranoia to try to catch a memory overwrite problem
as early as possible.

Sponsored by:	DARPA & NAI Labs
2002-04-23 11:48:45 +00:00
phk
ab6dc20b52 Protect against multitple #includes of this file. 2002-04-22 19:54:17 +00:00
phk
4509f96cc5 Make kernel dumps work with GEOM.
Notice that if the device on which the dump is set is destroyed for
any reason, the dump setting is lost.  This in particular will
happen in the case of spoilage.  For instance if you set dump on
ad0s1b and open ad0 for writing, ad0s* will be spoilt and the dump
setting lost.  See geom(4) for more about spoiling.

Sponsored by: DARPA & NAI Labs.
2002-04-19 09:24:12 +00:00
phk
a274092cf6 Make life easier for reference-vector generatorts in tools/regression/geom
by including a FreeBSD friendly CVS identifier in the XML output.

Sponsored by: DARPA & NAI Labs.
2002-04-19 09:21:27 +00:00
phk
a90e28ebbb Implement DIOCGFRONTSTUFF ioctl which reports how many bytes from the start
of the device magic stuff might occupy.

Sponsored by: DARPA & NAI Labs.
2002-04-09 15:43:32 +00:00
phk
c2f17d16c7 Various stylistic nit picking.
Sponsored by: DARPA & NAI Labs.
2002-04-09 15:17:59 +00:00
phk
7071088894 Introduce the convenience function g_getattr() and make it DWIM.
Sponsored by: DARPA & NAI Labs.
2002-04-09 15:13:42 +00:00
phk
6ec0e5c95f Constifixation of attribute argument to g_io_[gs]etattr()
Sponsored by:	DARPA & NAI Labs
2002-04-09 15:12:05 +00:00
phk
33405073ec Move generic disk ioctls from <sys/disklabel.h> to <sys/disk.h>.
Sponsored by:	DARPA & NAI Labs
2002-04-08 09:20:07 +00:00
phk
28a8eb54ff In reverence of the 3rd X11 development rule:
3.The only thing worse than generalizing from one example
	is generalizing from no examples at all.

Remove the fwcylinders attribute before anybody gets the idea that we
alone have squared the circle.

Sponsored by:	DARPA & NAI Labs.
2002-04-08 08:00:40 +00:00