Commit Graph

83 Commits

Author SHA1 Message Date
Brian Feldman
6f299fa373 When loading GEOM modules, we expect the actual load process to be done
by the time that kldload(8) returns.  Satisfy that by making the GEOM
module load event -- only when the kernel is !cold -- wait until the
GEOM module init function has finished instead of returning immediately.

This is the other half of fixing md(8) (actually, "mfs" in fstab(5))
that is similar to r1.128 of src/sys/dev/md/md.c.  This bug would be
why RAM disks would often fail on boot and the first call to mdconfig(8)
would probably fail.

pjd has ideas for not requiring kldload(8) to work synchronously for
control devices that could make this obsolete.

Silence on:	-arch
2004-10-12 04:44:54 +00:00
Poul-Henning Kamp
5ae652c0ed For removable devices without media we set a zero mediasize but a non-zero
sectorsize in order to avoid a lot of checks around various divisions etc.

Enforce the sectorsize being > 0 with a KASSERT on successful open.

Fix scsi_cd.c to return 2k sectors when no media inserted.
2004-09-05 21:15:58 +00:00
Poul-Henning Kamp
07f076fe7a OK, now check geom class version numbers. 2004-08-08 08:34:46 +00:00
Poul-Henning Kamp
e232f70a75 OOps, that check was a bit premature. Allow zero versions as well. 2004-08-08 07:30:47 +00:00
Poul-Henning Kamp
dd66958e28 Give classes a version number and refuse to touch classes which are not
understood.  This makes room for additional binary compatibility in the
future.

Put fields in the class for the geom's methods and initialize the methods
of a new geom from these fields.  This saves some code in all classes.
2004-08-08 06:46:27 +00:00
Poul-Henning Kamp
539bec4042 Only detach consumers which are attached when we wither stuff away.
Pointed out by:	pjd
2004-07-09 14:06:17 +00:00
Poul-Henning Kamp
1b464bd889 Make withering water tight.
When we orphan/wither a provider, an attached geom+consumer could
end up being withered as a result and it may be in front of us in
the normal object scanning order so we need to do multi-pass.  On
the other hand, there may be withering stuff we can't get rid off
(yet), so we need to keep track of both the existence of withering
stuff and if there is more we can do at this time.
2004-07-08 16:17:14 +00:00
Poul-Henning Kamp
4fa0290fbf Fail normally rather than KASSERT if attempt to open a spoiled consumer. 2004-07-08 10:34:09 +00:00
Pawel Jakub Dawidek
950124e354 Move "is consumer attached?" check before G_VALID_PROVIDER() check,
because if consumer is not attached, its provider never will be valid,
so we never reach this check.

Approved by:	phk
2004-03-18 07:17:10 +00:00
Poul-Henning Kamp
e26bafdc25 Be more insistent on destroying geoms at unload time. Still not perfect,
but it will do (better) for now.

KASSERT that to have providers a class must have an access method.

Tag the new_provider event with the geom as well.
2004-03-11 08:16:23 +00:00
Poul-Henning Kamp
3d1d5bc3c3 Rearrange some of the GEOM debugging tools to be more structured.
Retire g_sanity() and corresponding debugflag (0x8)

  Retire g_{stall,release}_events().

  Under #ifdef DIAGNOSTIC:

    Make g_valid_obj() an official function and have it return an an
    non-zero integer which indicates the kind of object when found.

    Implement G_VALID_{CLASS,GEOM,CONSUMER,PROVIDER}() macros based
    on g_valid_obj().

    Sprinkle calls to these macros liberally over the infrastructure.

    Always check that we do not free a live object.
2004-03-10 08:49:08 +00:00
Poul-Henning Kamp
b07ef6c2db Don't panic on providers already withered when we wither a geom. 2004-03-07 17:33:15 +00:00
Poul-Henning Kamp
bfc37a5112 Add a KASSERT which checks that a class never fails a closing ->access()
call.
2004-02-14 17:58:57 +00:00
Poul-Henning Kamp
d2bae332d6 Remove the absolute count g_access_abs() function since experience has
shown that it is not useful.

Rename the relative count g_access_rel() function to g_access(), only
the name has changed.

Change all g_access_rel() calls in our CVS tree to call g_access() instead.

Add an #ifndef BURN_BRIDGES #define of g_access_rel() for source
code compatibility.
2004-02-12 22:42:11 +00:00
Poul-Henning Kamp
0ed4f6a180 Allow a GEOM class to unload if it has no geoms or a method function to
get rid of them.

Prodded by:	pjd
2004-02-02 19:49:41 +00:00
Pawel Jakub Dawidek
cff2ddaeb2 - Use proper names in KASSERTs.
- Typos.

Approved by:	phk, scottl (mentor)
2004-02-02 17:50:09 +00:00
Poul-Henning Kamp
799426f877 Add KASSERTS.
Submitted by:	Pawel Jakub Dawidek <nick@garage.freebsd.pl>
2004-01-23 21:02:49 +00:00
Poul-Henning Kamp
f5b3481451 Plug an insignificant memoryleak.
Submitted by:	Pawel Jakub Dawidek <nick@garage.freebsd.pl>
2004-01-23 20:40:25 +00:00
Poul-Henning Kamp
cbb650409c Print the correct pointer in a KASSERT.
Submitted by:	Pawel Jakub Dawidek <nick@garage.freebsd.pl>
2004-01-11 10:02:42 +00:00
Poul-Henning Kamp
cfa35456ca KASSERT against no-op access requests.
Submitted by:	Pawel Jakub Dawidek <nick@garage.freebsd.pl>
2004-01-09 16:10:32 +00:00
Poul-Henning Kamp
0ecc7670a9 Call class->init() an class->fini() while the class is hooked up,
rather than right before and right after.  This allows these routines
to manipulate the mesh.

KASSERT that nobody creates a geom on an alien class.

Assert topology in g_valid_obj().

Approved by:	re@
2003-11-18 18:17:39 +00:00
Poul-Henning Kamp
b3ecca4d0a This is a crude bandaid for 5.2 to protect against providers which disappear
while being tasted.  I can moderately easy trigger this with atapi-cd, but
I do not fully understand the circumstances.
2003-11-15 18:44:43 +00:00
Poul-Henning Kamp
90916ef730 Introduce a per provider wither flag 2003-10-06 09:05:44 +00:00
Poul-Henning Kamp
1f75de94ea Don't panic over the fact that unloading failed if we already knew that. 2003-08-22 11:00:54 +00:00
David E. O'Brien
50b1faef38 Use __FBSDID().
Approved by:	phk
2003-06-11 06:49:16 +00:00
Poul-Henning Kamp
df2c3922e9 Drop a memory-corruption debugging test-tool. 2003-06-07 10:55:48 +00:00
Poul-Henning Kamp
a1a9b44569 Add missing va_end() calls.
Noticed by:	tmm
2003-06-07 10:16:53 +00:00
Poul-Henning Kamp
d6c5e71627 Introduce g_provider_by_name() function, and use it. 2003-06-04 18:17:52 +00:00
Poul-Henning Kamp
ce64e0f2c9 Add a KASSERT to prevent the same GEOM class from being processed loaded
twice.

Enforce that classes should have different names while we are here.
2003-06-04 17:51:10 +00:00
Poul-Henning Kamp
a6c58fec6c constify g_sanity() 2003-06-01 13:30:39 +00:00
Poul-Henning Kamp
6c87f8d5ea 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
Poul-Henning Kamp
c4da4e46b2 Back out all the stuff that didn't belong in the last commit. 2003-05-02 06:42:59 +00:00
Poul-Henning Kamp
e65ab0f83f 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
Poul-Henning Kamp
d6227ae71f Rework the "withering" mechanism:
Introduce g_wither_geom() to do the work in one single place.
2003-05-02 06:15:27 +00:00
Poul-Henning Kamp
606402511a Remove the now obsolete geomidorname hack. 2003-05-01 20:32:24 +00:00
Poul-Henning Kamp
e931331eaa Remove now unneeded special case for "geom.ctl". 2003-05-01 18:18:14 +00:00
Poul-Henning Kamp
8cd1535a24 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
Poul-Henning Kamp
9ab3ea7841 Turn EV_NEW_PROVIDER into a g_call_me() event. 2003-04-23 20:16:13 +00:00
Poul-Henning Kamp
f2e9a09494 Convert EV_SPOILED event to use g_call_me(). 2003-04-23 20:06:38 +00:00
Poul-Henning Kamp
9972896c00 Turn the hardwired NEW_CLASS event into a g_call_me() event. 2003-04-23 19:34:38 +00:00
Poul-Henning Kamp
668ae29c71 Remove unused event pointers in object structures.
Remove KASSERTS which checked that they were unused.
2003-04-23 06:54:44 +00:00
Poul-Henning Kamp
3924ad705e 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
Poul-Henning Kamp
537d9274dc 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
Poul-Henning Kamp
afcbcfaed0 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
Poul-Henning Kamp
8f6da0e4ac Only orphan things if the open/close actually succeeded. 2003-04-02 13:10:40 +00:00
Poul-Henning Kamp
897af91bac g_class_by_name() was unused too. 2003-03-25 09:11:17 +00:00
Poul-Henning Kamp
77b63fb4b1 Remove unuse g_insert_geom(). 2003-03-25 09:07:35 +00:00
Poul-Henning Kamp
dddc28bfe0 Introduce g_cancel_events() and use it a couple of places where it makes
sense.
2003-03-23 23:01:40 +00:00
Poul-Henning Kamp
e24cbd9017 Retire the GEOM private statistics code and use devstat instead. 2003-03-18 09:42:33 +00:00
Poul-Henning Kamp
b4b138c27f Including <sys/stdint.h> is (almost?) universally only to be able to use
%j in printfs, so put a newsted include in <sys/systm.h> where the printf
prototype lives and save everybody else the trouble.
2003-03-18 08:45:25 +00:00