Commit Graph

222 Commits

Author SHA1 Message Date
Nate Lawson
02fcfac0ad 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
Poul-Henning Kamp
220aecb807 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
Poul-Henning Kamp
b775674772 Remove a bogus local variable.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 21:22:23 +00:00
Jake Burkholder
60e0e42e3c 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
Poul-Henning Kamp
6b4abfd6eb 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
Poul-Henning Kamp
d0e17c1b91 Add more KASSERTS.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 10:02:24 +00:00
Poul-Henning Kamp
3101ed1b7c Add the outline of the "/dev/geom.ctl" handling code.
Sponsored by:	DARPA & NAI Labs.
2002-10-13 20:33:33 +00:00
Poul-Henning Kamp
e970552d3a 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
Poul-Henning Kamp
8523987b73 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
Poul-Henning Kamp
3f521b6022 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
Poul-Henning Kamp
068088370c 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
Poul-Henning Kamp
b362694c3b 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
Poul-Henning Kamp
430e557d3d Put a printf under #ifdef DIAGNOSTIC.
Sponsored by: DARPA & NAI Labs.
2002-10-07 06:57:00 +00:00
Poul-Henning Kamp
adfa3213c7 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
Poul-Henning Kamp
1fc1a1ef2a 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
Poul-Henning Kamp
5f79a2e33a 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
Poul-Henning Kamp
3bd6561289 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
Poul-Henning Kamp
2874f1cf36 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
Poul-Henning Kamp
0cc3011d52 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
Poul-Henning Kamp
8be2bc5c6f Properly conditionalize a debugging printf.
Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:06:19 +00:00
Poul-Henning Kamp
29c211954b Move GEOM's sysctls under kern.geom.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:51:02 +00:00
Poul-Henning Kamp
a4319fd03d Put some failing ioctl related printfs under a suitable debug flag.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:48:39 +00:00
Poul-Henning Kamp
0a2ece0481 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
Poul-Henning Kamp
2fcf0b5c37 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
Poul-Henning Kamp
e9a848359b Include <sys/diskmbr.h> instead of <sys/disklabel.h>
Sponsored by:	DARPA & NAI Labs.
2002-10-01 14:05:06 +00:00
Poul-Henning Kamp
3a24c28f37 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
Poul-Henning Kamp
72840432e0 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
Poul-Henning Kamp
90b1cd5615 Introduce g_write_data() function.
Sponsored by:	DARPA & NAI Labs
2002-09-30 08:50:47 +00:00
Poul-Henning Kamp
5b3317e9e6 Add missing g_enc_le2().
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:47:46 +00:00
Poul-Henning Kamp
5dcf28b202 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
Poul-Henning Kamp
cd4f50fbb8 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
Poul-Henning Kamp
079a527a3d 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
Poul-Henning Kamp
4ae677009e Style, whitespace and lint fixes.
Sponsored by:	DARPA & NAI Labs.
2002-09-28 11:57:20 +00:00
Poul-Henning Kamp
eadf0ffdce 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
Poul-Henning Kamp
852f392456 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
Poul-Henning Kamp
3d3816e633 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
Poul-Henning Kamp
5a6baf5457 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
Poul-Henning Kamp
b1937dd1ca 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
Poul-Henning Kamp
8ac8480b86 Correctly en/decode MAXPARTITIONS partitions.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 21:19:47 +00:00
Poul-Henning Kamp
d4c4a6f165 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
Poul-Henning Kamp
9169e8004d 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
Poul-Henning Kamp
f3bbbfe2df Correctly calculate size of PC98 slices.
Sponsored by:	DARPA & NAI Labs.
2002-09-27 20:56:21 +00:00
Poul-Henning Kamp
a1bd3ee20c 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
Poul-Henning Kamp
beece77a2d 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
Poul-Henning Kamp
346cd5fe2d 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
Poul-Henning Kamp
e615b0fd93 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
Poul-Henning Kamp
ed0ff8e52d 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
Poul-Henning Kamp
903e43fe66 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 Roberson
37ab0e0d81 - Use vrefcnt() instead of v_usecount. 2002-09-25 02:42:43 +00:00
Poul-Henning Kamp
7812d86f03 (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