Commit Graph

58 Commits

Author SHA1 Message Date
Greg Lehey
d1cbfb622b free_vinum: Rearrange sequence of actions to avoid potential race
condition when shutting down.
2003-05-05 05:28:15 +00:00
Greg Lehey
60500a5ca2 Rewrite of startup code:
vinumattach: Move the startup code to vinum_scandisk.
2003-05-04 05:13:45 +00:00
Greg Lehey
47f9c49661 Rewrite minor number decoding. Now we have only three types of
object: subdisks, plexes and volumes.  The encoding for plexes and
subdisks no longer reflects the object to which they belong.  The
super devices are high-order volume numbers.  This gives vastly more
potential volumes (4 million instead of 256).

Remove an unnecessary goto.

vinumopen: Return EINVAL, not ENXIO, on an attempt to open a
referenced plex.
2003-05-01 01:28:42 +00:00
Poul-Henning Kamp
60794e0478 Centralize the devstat handling for all GEOM disk device drivers
in geom_disk.c.

As a side effect this makes a lot of #include <sys/devicestat.h>
lines not needed and some biofinish() calls can be reduced to
biodone() again.
2003-03-08 08:01:31 +00:00
Poul-Henning Kamp
7ac40f5f59 Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by:    re(scottl)
2003-03-03 12:15:54 +00:00
Poul-Henning Kamp
78b7591cc5 Format the cdevsw like all other drivers do it for improved grepability. 2003-03-02 15:32:03 +00:00
Poul-Henning Kamp
e8e018a984 NO_GEOM cleanup:
Remove cdevsw->d_psize() implementation.  It is no longer needed.
2003-03-02 14:42:52 +00:00
Joerg Wunsch
1e35598c3a Deregister the dev_clone event handler when unloading the module. Bad
things might happen otherwise.

Noticed by:	Michael Reifenberger <root@nihil.reifenberger.com>
2003-02-11 21:12:43 +00:00
Joerg Wunsch
e1df235292 Finally make vinum ready for the root filesystem in FreeBSD 5.x. (A
similar patch has been in 4.x for a while, but is more hacky there.)

For this to work, vinum has to be loaded early (e. g. from
boot/loader), for obvious reasons.  If the kernel env variable
(aka. loader variable) "vinum.autostart" is set, vinum then asks the
sysctl kern.disks for all available disks in the system, and scans
them for possible vinum headers.

For statically compiled kernels, this behaviour can be obtained even
without boot/loader by using "options VINUM_AUTOSTART" (though this is
not the recommended way).

Alternatively, the 4.x way to specify "vinum.drives" is also supported.

No further hacks (like the 4.x "vinum.root" variable) are needed,
since in 5.x, mountroot() asks back at the drivers to have them
resolve the name of the root FS into a dev_t (using the dev_clone
eventhandler).

(The MFC reminder below is for a partial MFC for vinum.autostart, the
rest is already there in 4.x.)

Timed out on:	grog
MFC after:	2 weeks
2003-02-05 21:02:56 +00:00
John Baldwin
44731cab3b Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API.  The entire API now consists of two functions
similar to the pre-KSE API.  The suser() function takes a thread pointer
as its only argument.  The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0.  The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on:	smp@
2002-04-01 21:31:13 +00:00
Poul-Henning Kamp
572a089e74 Remove bogus vinumdump(), if you can't dump, say so with nodump(). 2002-03-29 21:14:34 +00:00
Poul-Henning Kamp
90a13e1e9e Don't call cdevsw_{add,remove}(). 2001-11-04 11:55:19 +00:00
Julian Elischer
b40ce4165d KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after:    ha ha ha ha
2001-09-12 08:38:13 +00:00
Greg Lehey
bc55b89e25 Set flag VF_HASDEBUG in vinum_conf to indicate that the module was
compiled with debug support.  This can be used by userland programs to
recognize which ioctls the module supports.

As a result, remove the gross debug device/non-debug device hack used
to recognize whether the kernel module was in sync with the userland
module.

Replace explicit references to major/minor numbers of vinum
superdevice with the VINUM_SUPERDEV macro written for that purpose.
2001-05-23 05:25:45 +00:00
Greg Lehey
7e18e4ffbc free_vinum: Change some explicit struct member references to the SD,
PLEX and VOL.
2001-05-22 02:29:15 +00:00
Poul-Henning Kamp
f83880518b Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.
2001-03-26 12:41:29 +00:00
Peter Wemm
e793f3a0e0 By convention, the moduledata is static unless there is a reason for it
to not be.
2001-03-13 05:55:43 +00:00
Alfred Perlstein
729d4f1db0 Fix vinum for both devfs and non-devfs systems.
userland tool:

  Use the vfs.devfs.generation sysctl to test for devfs presense
  (thanks phk!) when devfs is active it will not try to create the
  device nodes in /dev and therefore will not complain about the
  failure to do so.

  Revert the change in the #define for VINUM_DIR in the kernel
  header so that vinum can find its device nodes.

  Replace perror() with vinum_perror() to print file/line when
  DEVBUG is defined (not defined by default).

kernel:

  Don't use the #define names for the "superdev" creation since
  they will be prepended by "/dev/" (based on VINUM_DIR), instead
  use string constants.

  Create both debug and non-debug "superdev" nodes in the devfs.

Problem noticed and fix tested by: Martin Blapp <mblapp@fuchur.lan.attic.ch>
2001-02-20 22:07:36 +00:00
Alfred Perlstein
d9ca06d2a3 Take a shot at making vinum devfs aware.
Adding make_dev() and destroy_dev() calls in (hopefully) the right
places.

This is done by calling make_dev() in each object constructor and
caching the dev_t's returned from make_dev() in each struct
'subdisk'(sd), 'plex' and 'volume' such that the 'object'_free()
functioncs can call destroy dev.

This change makes a subset of the old /dev/vinum appear under devfs.

Enough nodes appear such that I'm able to mount my striped volume.

There may be more work needed to get vinum configuration working
properly.
2001-02-20 11:37:04 +00:00
Poul-Henning Kamp
416282b562 Get rid of the last traces of ACTUALLY_LKM_NOT_KERNEL 2000-10-23 08:35:41 +00:00
Greg Lehey
7a7d8290f0 Change the startup sequence of the vinum volume from SI_SUB_DRIVERS
to SI_SUB_VINUM, thus making it possible for Vinum to access I/O
devices and start.

Replace the preprocessor variable names BDEV_MAJOR and CDEV_MAJOR with
VINUM_BDEV_MAJOR and VINUM_CDEV_MAJOR respectively.

Style fixes: replace NULL with 0 where appropriate.

Submitted-by: Charlie Root <root@sms-1.follo.net> (yup, that's all I
	      have to go on).

Approved-by:	jkh
2000-02-29 06:07:39 +00:00
Greg Lehey
18ba0ff290 Minor formatting changes (7th attempt) 1999-09-28 22:42:06 +00:00
Poul-Henning Kamp
d6a0e38a1b Remove five now unused fields from struct cdevsw. They should never
have been there in the first place.  A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags
1999-09-25 18:24:47 +00:00
Julian Elischer
85a219d201 Changes to centralise the default blocksize behaviour.
More likely to follow.

Submitted by: phk@freebsd.org
1999-09-09 19:08:44 +00:00
Julian Elischer
7012bab988 Revert a bunch of contraversial changes by PHK. After
a quick think and discussion among various people some form of some of
these changes will probably be recommitted.

The reversion requested was requested by dg while discussions proceed.
PHK has indicated that he can live with this, and it has been agreed
that some form of some of these changes may return shortly after further
discussion.
1999-09-03 05:16:59 +00:00
Julian Elischer
439a479b3b remove some out-of-scope DEVFS references..
(don't worry greg.. cosmetic only)
1999-09-03 05:08:05 +00:00
Poul-Henning Kamp
02e1576966 Make bdev userland access work like cdev userland access unless
the highly non-recommended option ALLOW_BDEV_ACCESS is used.

(bdev access is evil because you don't get write errors reported.)

Kill si_bsize_best before it kills Matt :-)

Use the specfs routines rather having cloned copies in devfs.
1999-08-30 07:56:23 +00:00
Greg Lehey
03705cdeb7 Initialize the si_bsize fields of the new dev structure. This fixes
some swapper problems analogous to those experienced with ccd.

This fix is a kludge: since we currently don't track the "sector size"
in a volume label, we guess a worst case (4 kB, as used by vnode
devices).  If the concept of sector size is here to stay, I'll make
some changes to track the "sector size" of a volume.  This will
probably be the maximum of the sector sizes of all component drives,
but things could get ugly if we start allowing non-standard sector
sizes such as 524 bytes.

Unkludged-version-submitted-by:	phk
1999-08-29 01:41:53 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Greg Lehey
8d9ef32fdd vinumclose: close raw plexes and subdisks. 1999-08-24 02:18:55 +00:00
Greg Lehey
466c1060d9 vinumopen: add code for opening raw plexes. Volume-related plex
devices will probably die a death soon (yes, DES, that's correct
usage).
1999-08-14 06:22:15 +00:00
Greg Lehey
b583bb9698 vinumopen: add code to open raw subdisks. This is now used to
initialize subdisks.  Probably the plex-related subdisk type will die
a death.

vinumconfig.c:

Accept (and ignore) kernel state information in userland config
files.  This saves a lot of error recovery and also makes it possible
to use the output of printconfig to create new configuration.

Remove checkdiskconfig().  It wasn't needed any more.

Start adding support for hot spare drives.  You can't put anything on
them (yet).

Change message formats from %lld to %qd.

get_empty_sd: Initialize size to -1.  Previously this was done in
config_subdisk, which is the wrong place.

start_config: set current drive, plex and volume to -1, thus stopping
  update configurations from taking their defaults from old configs.
1999-08-07 08:05:46 +00:00
Greg Lehey
aa30608b44 Modify device numbering method to work with latest -CURRENT. Briefly,
the device numbers are now minor number only, so that we can still
compare them after dev_t has turned into a blob.

Broken-by:	dev_t changes
Reported-by:	Vallo Kallaste <vallo@matti.ee>
		"Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk>
1999-07-22 08:40:37 +00:00
Greg Lehey
7d0e3c6f72 Correct type of intializer for (undocumented) cdevsw.d_parms.
Submitted-by:	peter
1999-06-29 04:07:55 +00:00
Greg Lehey
d884f7143f Modify to work with phk's latest mods to cdevsw. This is a temporary
fix; it doesn't address the problem of removing the module.  If you do
the following:

  vinum stop
  fsck /dev/vinum/VOLUME

you *will* get a system crash.  What we need is a cdevsw_remove
corresponding to cdevsw_add, but that hasn't been written yet.

Submitted-by: phk
1999-06-22 05:36:13 +00:00
Greg Lehey
e4d6d0216b Modify to work with new style dev_t.
With_copious_input_from:  peter
			  phk
1999-05-15 05:49:21 +00:00
Poul-Henning Kamp
46eede0058 Continue where Julian left off in July 1998:
Virtualize bdevsw[] from cdevsw.  bdevsw() is now an (inline)
        function.

        Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
        to the order of the cmaj/bmaj arguments!)

        Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
        (ditto!)

(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)
1999-05-07 10:11:40 +00:00
Greg Lehey
5b6d18c5e9 Convert to use physread() and physwrite().
Advertised-by: phk
1999-05-07 08:07:09 +00:00
Greg Lehey
560863926b Remove old grunge, including references to sys/disk.h (which is going
away).

Submitted-by:	phk
1999-05-07 01:35:29 +00:00
Greg Lehey
417f97c954 Get extern declarations right.
Change DEBUG_EXITFREE to DEBUG_WARNINGS.
1999-05-02 07:59:04 +00:00
Poul-Henning Kamp
f711d546d2 Suser() simplification:
1:
  s/suser/suser_xxx/

2:
  Add new function: suser(struct proc *), prototyped in <sys/proc.h>.

3:
  s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/

The remaining suser_xxx() calls will be scrutinized and dealt with
later.

There may be some unneeded #include <sys/cred.h>, but they are left
as an exercise for Bruce.

More changes to the suser() API will come along with the "jail" code.
1999-04-27 11:18:52 +00:00
Greg Lehey
cbeab55980 free_vinum: clear up a warning message. 1999-04-17 04:15:50 +00:00
Greg Lehey
599fbeb550 free_vinum: Clean out bdevsw entry before unloading kld.
Repeatedly-tripped-over-by: Vallo Kallaste <vallo@matti.ee>

		When VINUMDEBUG is set, free any memory found still
		allocated.

		Only log errors if DEBUG_EXITFREE is set.
1999-04-05 04:02:09 +00:00
Greg Lehey
f990bcd3db vinumattach: Remove some really old, dead cruft.
free_vinum:	Wait for daemon to stop by checking the
		vinum_conf.flags & VF_DAEMONOPEN.

vinum_modevent:
		When compiled with VINUMDEBUG, check if we have
		forgotten to free any memory, and log an error if we
		have.

vinumopen:	Allow open of an empty subdisk (otherwise we can't
		initialize it).
1999-03-31 08:41:18 +00:00
Greg Lehey
8c1e93bf98 Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used.  Now these fields are only informative,
and the <object>_allocated count is used for searches, etc.  This also
required checking the object state before doing things with the
presumed object.

Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
1999-03-30 04:59:32 +00:00
Greg Lehey
cec9815419 Remove longjmp declaration.
free_vinum:	Put a timeout on waiting for the daemon to die.
1999-03-28 08:52:33 +00:00
Greg Lehey
66c4363288 free_vinum: don't change loop bounds for deleting drives while in the loop.
This solved a problem where 'vinum resetconfig' only reset half
	    the drives.

Reported-by:  Brad Knowles <blk@skynet.be>
	      Karl Pielorz <kpielorz@tdx.co.uk>

Change the super device.  We now have three super devices:

  1.  The normal superdevice used by vinum(8).
  2.  The superdevice used by vinum(8) when compiled with debug support.
  3.  The superdevice used by the daemon.

This method allows vinum(8) to determine debug mismatches.  Also check
correctly for the device type.  The old code did not check all bits of
the minor number.

  Reported-by: a cast of thousands, most recently by Brad Knowles
               <blk@skynet.be>.
1999-03-19 07:08:40 +00:00
Greg Lehey
6f70e1c542 Modify to compile with egcs.
Prodded-by: obrien
1999-03-18 23:26:22 +00:00
Greg Lehey
e80e86a302 vinum_inactive: distinguish whether we care whether the config
is open or not.
1999-03-13 07:22:00 +00:00
Greg Lehey
571aa87170 Change printf() calls to log() calls.
vinumattach: Zero out tables after allocating them

Modify procedure at unload: if a vinum(8) has the superdev open, don't
close down.  If only the daemon has it open, send the daemon a stop
request and wait for it to close the superdev, then unload.

In order to do this, create a second superdev which is opened by the
daemon.  The open and close routines set a different bit in
vinum_conf.flags; otherwise the treatment is identical.

Remove opencount field in vol structure; replace by a flag bit, since
we can't count the number of opens.

Remove dead LKM grunge.
1999-03-02 06:52:11 +00:00