Commit Graph

650 Commits

Author SHA1 Message Date
phk
5a2388f470 constify g_sanity() 2003-06-01 13:30:39 +00:00
phk
305dd90d00 Use bcmp() to compare hash strings. 2003-06-01 09:18:49 +00:00
phk
cd37433ef9 Remove unused variable.
Remove unneeded return;

Found by:       FlexeLint
2003-05-31 19:41:33 +00:00
phk
70af1dfe88 Remove unused variables.
Found by:       FlexeLint
2003-05-31 19:40:43 +00:00
phk
dcb3c04301 Remove unused variables.
Rename struct h0h0 to g_hh01 in order to make it unique over files.

Found by:       FlexeLint
2003-05-31 19:37:21 +00:00
phk
23436c40b9 Remove unused variables.
Remove #ifdef notyet which will never become.

Found by:       FlexeLint
2003-05-31 19:30:52 +00:00
phk
f0f1321766 Remove unused variable.
Remove unneeded return.

Found by:       FlexeLint
2003-05-31 19:29:38 +00:00
phk
ef00c86fce Remove unused variable.
Found by:       FlexeLint
2003-05-31 19:28:53 +00:00
phk
926fff03bf Add a destroy_geom method to the slice "library".
If a slice class has no destroy_geom method, use this one.

This should allow all slicers to kldload.
2003-05-31 19:25:05 +00:00
phk
48e54f8060 Don't use & in front of arrays.
Found by:       FlexeLint
2003-05-31 19:23:11 +00:00
phk
c48dbf1758 Remove unused variable.
Found by:       FlexeLint
2003-05-31 19:08:23 +00:00
phk
b11f7951ec Remove unused variable.
Found by:       FlexeLint
2003-05-31 18:55:18 +00:00
phk
3325608f8f Introduce a init and fini member functions on a class.
Use ->init() and ->fini() to handle the mutex in geom_disk.c

Remove the g_add_class() function and replace it with a standardized
g_modevent() function.

This adds the basic infrastructure for loading/unloading GEOM classes
2003-05-31 18:13:07 +00:00
phk
e2298826ec Remove the G_CLASS_INITIALIZER, we do not need it anymore. 2003-05-31 16:59:27 +00:00
phk
9c455f6a96 Use le_uuid_dec() since GPT UUID's are always in LE format.
Tested by:      Marcel
2003-05-31 16:48:43 +00:00
phk
f716dc5d96 Don't do silly thing if the disk_create() event gets canceled.
Approved by:	re/scottl
2003-05-25 16:57:10 +00:00
phk
8539560193 Return ENXIO if the softc pointer is NULL, in all likelyhood the
disk is in the process of disappearing.

Approved by:	re/rwats*
2003-05-21 18:52:29 +00:00
phk
489ad07179 When a disk disappears, destroy the class from the event thread
to avoid race condtion.

Approved by:	re/rwatson
2003-05-12 20:15:28 +00:00
phk
8ece7cbc43 When a GEOM (/dev-)device is closed and we find that I/O requests are
still outstanding, give them a chance to complete.

If after 10 seconds we still find outstanding I/O requests, complete
the close with a console warning that the system is likely to panic
later on.

This is a workaround for umount -f not quite doing the right thing.

Approved by:    re/scottl
2003-05-09 21:25:28 +00:00
phk
4e002d7a93 Hide the "ENOMEM" notice messages behind bootverbose. They are still
a valuable debugging tool for certain kinds of problems.

Approved by:	re/scottl
2003-05-07 05:37:31 +00:00
phk
3cc52c15ec Fix the WARNING for wrong rawoffset, I tested incompatible units.
Approved by:	re/jhb
2003-05-06 19:36:13 +00:00
phk
410334cfe0 Avoid double-free panic.
Tripped up:	DougB
2003-05-05 15:52:11 +00:00
phk
3f2e0ad16d Re-order the the initialization slightly to improve structure. 2003-05-05 08:58:12 +00:00
phk
d6ece911bb Use a dedicated malloc(9) bucket for sector storage. 2003-05-05 08:37:07 +00:00
phk
0c30fa28a2 Don't warn if the rawoffset is zero, that is actually the best value it
could have.
2003-05-05 08:30:59 +00:00
phk
9f0560bebc Turn the check that rawoffset == mbroffset into a warning instead. 2003-05-05 06:46:49 +00:00
phk
aac4aea759 Only accept a rawoffset if it is identical to the mbroffset. 2003-05-04 19:26:31 +00:00
phk
aa1b7d74da Add a way to read the current mbroffset from a BSD label class. 2003-05-04 19:25:48 +00:00
phk
f1297dcac6 Add gctl_set_param() function. 2003-05-04 19:24:34 +00:00
phk
eb7e0cd5d2 Remove debugging printfs which should not have been committed. 2003-05-04 18:48:25 +00:00
phk
bbc021cef5 Add a OAM interface for changing the label and writing the boot code. 2003-05-03 08:01:34 +00:00
phk
3644496d4a remove unused variables.
Spotted by:	dougb
2003-05-03 07:12:15 +00:00
phk
2a47b08091 Make bsd_disklabel_le_enc calculate the checksum and fill it in.
(If there is a legitimate need to correctly encode and pack a
disklabel with an invalid checksum custom tools can be built for
that.)

Make bsd_disklabel_le_dec() validate the magics, number of partitions
(against a new parameter) and the checksum.

Vastly simplify the logic of the GEOM::BSD class implementation:

Let g_bsd_modify() always take a byte-stream label.

This simplifies all users, except the ioctl's which now have to
convert to a byte-stream first.  Their loss.

g_bsd_modify() is called with topology held now, and it returns
with it held.

Always update the md5sum in g_bsd_modify(), otherwise the check
is no use after the first modification of the label.  Make the
MD5 over the bytestream version of the label.

Move the rawoffset hack to g_bsd_modify() and remove all the
inram/ondisk conversions.

Don't configure hotspots in g_bsd_modify(), do it in taste instead,
we do not support moving the label to a different location on the
fly anyway.

This passes all current regression tests.
2003-05-02 22:46:13 +00:00
phk
3f52da0d28 Pull in bcopy() prototype from <string.h> when compiled in userland. 2003-05-02 19:53:55 +00:00
phk
d73072efd4 Considering that I did cast the arguments to (intmax_t) I must have
been sleepy since I used %qd instead of %jd.
2003-05-02 19:08:57 +00:00
phk
5ffbb6f148 Style improvement. 2003-05-02 12:57:40 +00:00
phk
3708ab2594 Use g_wither_geom() and plug memory leaks. 2003-05-02 12:52:51 +00:00
phk
637729fea0 Plug memory leaks. 2003-05-02 12:49:41 +00:00
phk
26f669a3c9 Use an uma-zone for allocation bio requests. 2003-05-02 12:36:12 +00:00
phk
94c69d48c9 Use g_slice_spoiled() instead of g_std_spoiled().
Add XXX comment about minor memory leak until I can fix it.
2003-05-02 08:33:26 +00:00
phk
7636503a41 Use g_slice_spoiled() instead of g_std_spoiled(). 2003-05-02 08:21:02 +00:00
phk
d2b42c6620 Use g_slice_spoiled().
Free buffer from g_read_data().
2003-05-02 08:13:03 +00:00
phk
055cf65eb1 Back out all the stuff that didn't belong in the last commit. 2003-05-02 06:42:59 +00:00
phk
4c52a206d2 Use g_slice_spoiled() rather than g_std_spoiled().
Remember to free the buffer we got from g_read_data().
2003-05-02 06:36:14 +00:00
phk
6b0e95eef5 Use g_slice_spoiled() not g_std_spoiled() 2003-05-02 06:34:51 +00:00
phk
0a7a0e5019 Use g_slice_spoiled() rather than g_std_spoiled() 2003-05-02 06:33:59 +00:00
phk
077126a4be Use g_slice_spoiled() rather than g_std_spoiled(). 2003-05-02 06:33:26 +00:00
phk
4ac5216f83 Use a more tailored spoil routine for slices, and take advantage of
g_wither_geom() to do most of the work for us.
2003-05-02 06:29:33 +00:00
phk
dfdb8ebb84 Style improvement. 2003-05-02 06:22:48 +00:00
phk
e39be99d04 Use g_wither_geom() for cleanup. 2003-05-02 06:22:32 +00:00
phk
098143e63b Rework the "withering" mechanism:
Introduce g_wither_geom() to do the work in one single place.
2003-05-02 06:15:27 +00:00
phk
cb4841eb7e Rename g_slice_init() to the more appropriate g_slice_alloc() and give
it a g_slice_free() partner function.
2003-05-02 05:33:27 +00:00
phk
47865226a5 style improvement. 2003-05-02 05:26:47 +00:00
phk
a49f8acd23 Get rid of trivial function g_destroy_event(). 2003-05-02 05:26:19 +00:00
phk
ea4d816aa1 Plug some memory-leaks. 2003-05-01 21:07:08 +00:00
phk
c51ae09b82 Remove the now obsolete geomidorname hack. 2003-05-01 20:32:24 +00:00
phk
26e81abf93 Add a new flag, EV_CANCELED, and use it to make g_waitfor_event() return
EAGAIN if an event got canceled.
2003-05-01 19:43:52 +00:00
phk
2ae9241429 When events on a reference is cancelled, check our doorstep first,
it might be an orphan.
2003-05-01 19:24:00 +00:00
phk
def0071c3d Remove now unneeded special case for "geom.ctl". 2003-05-01 18:18:14 +00:00
nyan
0ecbcb89a3 Remove DIOCGPC98 ioctl. 2003-05-01 14:40:16 +00:00
nyan
313e553205 - Move decoding pc98_partition function into geom_pc98_enc.c.
- Add encoding pc98_partition function.
2003-05-01 13:44:24 +00:00
marcel
d39162a421 Don't emulate a MBR by handling the MBR::type attribute. It is
not needed at all. The BSD class will attach to a GPT class without
it.
2003-05-01 01:51:28 +00:00
markm
6cc289554b Fix some easy, global, lint warnings. In most cases, this means
making some local variables static. In a couple of cases, this means
removing an unused variable.
2003-04-30 12:57:40 +00:00
phk
a43e2a0d8e Fix an obscure fencepost error in GBDE's sector mapping code:
For certain combinations of sectorsize, mediasize and random numbers
(used to define the mapping), a multisector read or write would ignore
some subset of the sectors past the first sector in the request because
those sectors would be mapped past the end of the parent device, and
normal "end of media" truncation would zap that part of the request.

Rev 1.19+1.20 of g_bde_work.c added the check which should have alerted
me to this happening.  This commit maps the request correctly and
adds KASSERTS to make sure things stay inside the parent device.

This does not change the on-disk layout of GBDE, there is no need to
backup/restore.
2003-04-29 19:46:42 +00:00
phk
df12452858 Typo in last commit: Do not press xZZ to leave vi(1). 2003-04-29 19:38:55 +00:00
phk
46e72efe59 When a bio comes back from below with a zero error code, check that
it wrote the full length.  The only case where this should be able
to happen is if we try to read/write past the end and the request
is truncated.  We obviously should never try to do that, so this
code should never activate.
2003-04-29 19:37:36 +00:00
kan
9468fdaf14 Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on:	standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
2003-04-29 13:36:06 +00:00
phk
647f79f459 I accidentally leaked this debugging tool in with my last commit.
Disable it with a direct warning.
2003-04-28 17:57:12 +00:00
phk
1b6624b999 Rename g_bde_get_sector() to g_bde_get_keysector() and pick up the
offset from the work packet.
2003-04-28 06:38:31 +00:00
phk
1adaf3d22c Only attempt total cache-purge once in case of failure. 2003-04-28 06:19:41 +00:00
phk
5299f69145 Better criteria for skipping disk reading BIO_READ work packets. 2003-04-28 06:15:39 +00:00
phk
600f5cf898 Explicitly set the sector state to JUNK if we encounter a read-error. 2003-04-28 06:10:35 +00:00
phk
cd6350ca83 Bail as soon as the first write request has failed, there is no point
in trying the second write if the first one went nowhere.
2003-04-26 21:40:26 +00:00
phk
da80cf8fcc Appearantly UFS no longer issues BIO_DELETE requests correctly, and
consequently trashes data.  Disable BIO_DELETE handling in gbde for now.
2003-04-26 21:39:33 +00:00
phk
876e7e7a6d Do an explicit retry after we have dumped the cache, rather than a
(potential) tail recursion.
2003-04-25 21:43:11 +00:00
phk
82e4f296ff If on a BIO_READ request, we failed to allocate the bio for reading
our key-sector, we would end up returning the read without an error,
despite the fact that the data was not correctly decrypted.

This would result in data corruption on read, but intact data still
on the media.
2003-04-25 21:28:28 +00:00
phk
017246b9b8 Fix a problem and slightly improve the ENOMEM handling:
Give up the entire bio as soon as we detect a problem.

When we detect a problem, give up the bio by contributing the
remainder with ENOMEM, rather than kicking the bio back right
away.

If we failed on a non-first iteration we previously could end up
modifying fields in the bio after we delivered it.  This could
account for memory corruption (none directly reported) on machines
with GBDE.
2003-04-25 21:20:57 +00:00
phk
e2ee68d54b Don't count a sector in the cache unless we manage to create it. 2003-04-25 20:56:27 +00:00
phk
b2fdd2cc0f Rename g_bde_release_sector() to g_bde_release_keysector() and pick up
the sector from the work item.
2003-04-25 20:35:34 +00:00
phk
5b6422dcef Rename g_bde_read_sector() to g_bde_read_keysector() pick up the offset
in the work structure.
2003-04-25 20:16:59 +00:00
phk
ffd04bfbdd Introduce a g_waitfor_event() function which posts an event and waits for
it to be run (or cancelled) and use this instead of home-rolled versions.
2003-04-23 21:28:27 +00:00
phk
7a7d406136 More of the event stuff can now be private to geom_event.c 2003-04-23 20:54:42 +00:00
phk
3bbfe9f43b Rename g_call_me() to g_post_event(), and give it a flag
argument to determine if we can M_WAITOK in malloc.
2003-04-23 20:46:12 +00:00
phk
b4c26d2e1a Remove the now unused hardcoded g_post_event() event support. 2003-04-23 20:25:33 +00:00
phk
7c462ceb2b Turn EV_NEW_PROVIDER into a g_call_me() event. 2003-04-23 20:16:13 +00:00
phk
67a31a6107 Convert EV_SPOILED event to use g_call_me(). 2003-04-23 20:06:38 +00:00
phk
16bcc257a6 Turn the hardwired NEW_CLASS event into a g_call_me() event. 2003-04-23 19:34:38 +00:00
phk
51e68a1f27 Move the shutdown eventhandler stuff to a more logical place. 2003-04-23 19:15:27 +00:00
phk
15a332bfd6 Implement CONFIG_GEOM verbs "write label" and "write bootcode". 2003-04-23 08:23:01 +00:00
phk
2d7e7620e8 Introduce gctl_get_paraml() which gets a parameter only if it has the
right length.
2003-04-23 08:03:47 +00:00
phk
90684346d6 Make gctl_error() take printfline varargs. 2003-04-23 07:50:01 +00:00
phk
ee10d53986 Remove unused event pointers in object structures.
Remove KASSERTS which checked that they were unused.
2003-04-23 06:54:44 +00:00
phk
1e2ee18100 Change the locking so that the _modify function is called with topology
held.

The only place where we want to not hold topology is when we read
(or write) the label to disk: in the case of a disk error with a
long recovery time, holding topology would prevent open/close of
any disk device.
2003-04-22 21:29:58 +00:00
phk
5d4dba6264 We don't need to have a slice->start() function. 2003-04-22 21:24:37 +00:00
phk
13d95d603f Do not mandate that slicers have a private ->start(), they may not need
one.  KASSERT() that they have one if G_SLICE_HOT_START is used.
2003-04-22 21:19:17 +00:00
phk
c5dae9372b Implement handling of CONFIG_GEOM OAM request. 2003-04-22 21:01:46 +00:00
phk
02c40a0b9d Add "CONFIG_GEOM" operation to the OAM API. 2003-04-22 21:00:49 +00:00
phk
817cb6ca1f Collapse meta arguments into regular arguments, the distinction is
more trouble than it is worth.
2003-04-22 19:42:05 +00:00
phk
c99d9e1424 Implement a hotspot for the sunlabel.
This means that you can no longer trash your opened partitions by writing to
the sunlabel through another partition.  This is similar to the semantics
implemented for BSD labels.
2003-04-21 20:14:36 +00:00
phk
78e84f94ed Update GEOM::SUN to use the decoding functions in geom_sunlabel_enc.c
and #defines from sys/sun_disklabel.h.
2003-04-21 19:54:11 +00:00
phk
d5b1803a96 Use #defines from <sys/sun_disklabel.h> instead of private ones. 2003-04-21 19:42:36 +00:00
phk
9e9aeab27a Functions to encode and decode Sun Microsystems disk partitioning data
structures.

Mostly by:	jake
2003-04-21 18:41:12 +00:00
phk
db4d21ffaf Make more of the "hotspot" stuff generic:
Give the class a way to specify the necessary action for read/delete/write:
ALLOW, DENY, START or CALL.

Update geom_bsd to use this.
2003-04-19 10:14:39 +00:00
phk
a41f716e91 Create a dedicated structure for holding hotspot information rather than
using slice structures for it.
2003-04-19 10:00:22 +00:00
phk
52a551e4c5 These two files fell off during my previous commit: put the encoding
decoding functions for struct disklabel in a separate .c file.
2003-04-17 08:41:08 +00:00
phk
c10cd4d964 More correct patch: Only call biofinish if we have not already sent
any children down the mesh.
2003-04-14 08:49:54 +00:00
phk
e27444e997 Call biofinish() also when we get a malloc() failure. 2003-04-14 08:08:17 +00:00
phk
03b1ca36ba Time has run from the "run GEOM in userland" harness, and the new regression
test is built to test GEOM as running in the kernel.

This commit is basically "unifdef -D_KERNEL" to remove the mainly #include
related code to support the userland-harness.
2003-04-13 09:02:06 +00:00
phk
2e8ebbf548 If we hit access ahead of a spoil event, we should have negative
delta access-counts and proceed.
2003-04-12 17:04:34 +00:00
phk
bef7fcb806 Fix a bug which resulted in orphanization getting confused every now
and then.
2003-04-12 16:36:19 +00:00
phk
708a319e8e Retire the experimental bio_taskqueue(), it was not quite as usable as
hoped.  It can be revived from here, should other drivers be able to
use it.
2003-04-12 09:13:01 +00:00
phk
b08878d5ab Retire the "frontstuff" record keeping, it was no match for the
in-band meta-data of BSD labels and a more complex solution will be needed.
2003-04-12 08:41:26 +00:00
phk
e9d1c65d22 Move the functions for encoding decoding struct dos_partition into
a separate .c file so they can be used from userland as well.
2003-04-12 08:34:40 +00:00
phk
4a8ff05f17 Only be verbose if (bootverbose) 2003-04-09 13:52:40 +00:00
phk
b62dc48437 With the magic sequence checks removed this class is downright dangerous
to have in your kernel since it indiscriminately attaches to anything
it is offered with a range of bogus partitions.

Stop this from happening by rejecting any label with negative numbers in
it.
2003-04-09 13:08:36 +00:00
phk
1cbd421154 Correctly split cyl/sects bytes when we print them. 2003-04-09 09:21:33 +00:00
phk
3faf153e04 Style issue: use do {...} while(0); for multi-exit section. 2003-04-09 08:56:26 +00:00
phk
ffdec08c2c Retire the DIOCGMBR ioctl before anybody starts to use it. 2003-04-03 19:37:40 +00:00
phk
cbe207a30e Remove all references to BIO_SETATTR. We will not be using it. 2003-04-03 19:19:36 +00:00
phk
aba0028d27 Update the initializer for GEOM_MBREXT, I overlooked it previously. 2003-04-03 19:05:03 +00:00
phk
3288c86f74 Add #define for DOSPTYP_PMBR, and use it. 2003-04-03 18:55:16 +00:00
phk
9e2f75eb24 #include <sys/endian.h> as needed. 2003-04-03 11:56:10 +00:00
phk
f14c63f8a8 Remove geom_enc.c, a superset of these functions are now available in
<sys/endian.h>
2003-04-03 11:40:06 +00:00
phk
25c7685ca9 Use <sys/endian.h> instead of geom_enc.c for endianess-agnostification. 2003-04-03 11:36:53 +00:00
phk
34a3abe946 Use sys/endian.h instead of geom_enc.c for endian-agnostfication. 2003-04-03 11:33:51 +00:00
phk
7d796a935a Make sure we don't ignore error codes. 2003-04-03 11:19:24 +00:00
phk
39cbb43bab Add handling for cancelled events in the g_call_me() methods. 2003-04-02 21:10:04 +00:00
phk
cedf04c475 Change events to have an array of "void *" references, and give the
event posting functions varargs to fill these.

Attribute g_call_me() to appropriate g_geom's where necessary.

Add a flag argument to g_call_me() methods which will be used to signal
cancellation of events in the future.

This commit should be a no-op.
2003-04-02 20:41:18 +00:00
phk
a47b0e4a84 Only orphan things if the open/close actually succeeded. 2003-04-02 13:10:40 +00:00
phk
3cfb76c317 Properly handle races between open/close and orphan.
KASSERT the race between close and strategy, it is an error in the upper
echelons if this happens,

Add XXX: comment explaining why the ioctl/orphan race is not closed.
2003-04-02 13:09:50 +00:00
phk
af778aa48a Include <geom/geom_disk.h> not <sys/disk.h> 2003-04-01 18:57:14 +00:00
phk
c235e25328 Use bioq_flush() to drain a bio queue with a specific error code.
Retain the mistake of not updating the devstat API for now.

Spell bioq_disksort() consistently with the remaining bioq_*().

#include <geom/geom_disk.h> where this is more appropriate.
2003-04-01 15:06:26 +00:00
phk
8be523e927 Start to split the GEOM/diskdriver specific bits into geom/geom_disk.h 2003-04-01 13:19:14 +00:00
phk
80780d2ba2 Remove the old config interface, the new OAM is sufficiently functional
now.
2003-04-01 07:33:56 +00:00
phk
85edc96041 Remove the old config interface now that the new OAM is functional. 2003-04-01 07:33:17 +00:00
phk
5b75c05966 Remove some debugging in the new OAM[*] and add a debug flag for other
parts of it.

[*] I've been asked what "OAM" means:  It's an acronym used in the
telecom industry, "Operations And Maintenance", and there it covers
anything from a single unlabeled led on the frontpanel the the full
nightmare of CMIP for SS7.
2003-03-31 18:35:37 +00:00
phk
15c9ea202d Fix a bug in the ENOMEM pacing code which probably made it panic systems
after a lot of ENOMEM errors.
2003-03-29 22:34:37 +00:00
phk
cdc67e7072 Add create_geom and destroy_geom methods. 2003-03-29 22:14:21 +00:00
phk
2d56ed957a Run a revision on the OAM api.
Use prefix gctl_ systematically.
Add flag with access perms for each argument.
Add ro/rw versions of argument building functions.
General cleanup.
2003-03-27 14:35:00 +00:00
phk
5447a01760 Check return value of g_call_me() 2003-03-27 14:32:52 +00:00
phk
192c308033 g_class_by_name() was unused too. 2003-03-25 09:11:17 +00:00
phk
45e43ab0e8 Remove unuse g_insert_geom(). 2003-03-25 09:07:35 +00:00
phk
87ed6d02e4 Forward compatibility: NULL check the passed in meta argument. 2003-03-25 09:02:41 +00:00
phk
639a37daa0 Premptively change initializations of struct g_class to use C99
sparse struct initializations before we extend the struct with
new OAM related member functions.
2003-03-24 19:30:15 +00:00
phk
063b352331 Turn /dev/geom.ctl from a GEOM class into a plain character device driver
instead, it will never see a disk-I/O transaction, so this is a lot simpler.
2003-03-24 13:37:15 +00:00
phk
dc9d8429c2 Save a lock: Grab the stall_events SX lock exclusively so it also serialize
OAM reqests.
2003-03-24 13:35:06 +00:00
phk
8e76f1cefa Introduce g_cancel_events() and use it a couple of places where it makes
sense.
2003-03-23 23:01:40 +00:00
phk
3e8d794231 Introduce an SX lock which allows us to stall event processing
during OAM operations.
2003-03-23 21:58:09 +00:00
phk
0e60b8dd4b I forgot the evil ioctl census scripts: #include <geom/geom_ctl.h> 2003-03-23 11:05:44 +00:00
phk
35c6fd6e4d Marshalling stuff for OAM API. 2003-03-23 10:16:14 +00:00