Commit Graph

182 Commits

Author SHA1 Message Date
Poul-Henning Kamp
a6b1634eb2 Give ccd a cloning function. 2000-08-29 16:29:02 +00:00
Kirk McKusick
e6796b67d9 Move the truncation code out of vn_open and into the open system call
after the acquisition of any advisory locks. This fix corrects a case
in which a process tries to open a file with a non-blocking exclusive
lock. Even if it fails to get the lock it would still truncate the
file even though its open failed. With this change, the truncation
is done only after the lock is successfully acquired.

Obtained from:	 BSD/OS
2000-07-04 03:34:11 +00:00
Poul-Henning Kamp
9626b608de Separate the struct bio related stuff out of <sys/buf.h> into
<sys/bio.h>.

<sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall
not be made a nested include according to bdes teachings on the
subject of nested includes.

Diskdrivers and similar stuff below specfs::strategy() should no
longer need to include <sys/buf.> unless they need caching of data.

Still a few bogus uses of struct buf to track down.

Repocopy by:    peter
2000-05-05 09:59:14 +00:00
Poul-Henning Kamp
9d7f73695d Convert to struct bio instead of struct buf. 2000-05-01 13:36:43 +00:00
Poul-Henning Kamp
2c9b67a8df Remove unneeded #include <vm/vm_zone.h>
Generated by:	src/tools/tools/kerninclude
2000-04-30 18:52:11 +00:00
Poul-Henning Kamp
8177437d85 Complete the bio/buf divorce for all code below devfs::strategy
Exceptions:
        Vinum untouched.  This means that it cannot be compiled.
        Greg Lehey is on the case.

        CCD not converted yet, casts to struct buf (still safe)

        atapi-cd casts to struct buf to examine B_PHYS
2000-04-15 05:54:02 +00:00
Poul-Henning Kamp
c244d2de43 Move B_ERROR flag to b_ioflags and call it BIO_ERROR.
(Much of this done by script)

Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED.

Move b_pblkno and b_iodone_chain to struct bio while we transition, they
will be obsoleted once bio structs chain/stack.

Add bio_queue field for struct bio aware disksort.

Address a lot of stylistic issues brought up by bde.
2000-04-02 15:24:56 +00:00
Poul-Henning Kamp
b99c307a21 Rename the existing BUF_STRATEGY() to DEV_STRATEGY()
substitute BUF_WRITE(foo) for VOP_BWRITE(foo->b_vp, foo)

substitute BUF_STRATEGY(foo) for VOP_STRATEGY(foo->b_vp, foo)

This patch is machine generated except for the ccd.c and buf.h parts.
2000-03-20 11:29:10 +00:00
Poul-Henning Kamp
21144e3bf1 Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new
field in struct buf: b_iocmd.  The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue.  It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users:  Greg has not had time to test this yet, be careful.
2000-03-20 10:44:49 +00:00
Peter Wemm
0b5436a74a Remove #if NCCD > 0 - it's guaranteed to be true by config if ccd.c is
being compiled. (NCCD is used elsewhere though :-( )
2000-01-29 14:29:56 +00:00
Poul-Henning Kamp
af8862e4e6 Cleanup some remaining bdev fluff. 2000-01-16 09:25:10 +00:00
Poul-Henning Kamp
ba4ad1fcea Give vn_isdisk() a second argument where it can return a suitable errno.
Suggested by:	bde
2000-01-10 12:04:27 +00:00
Eivind Eklund
2046577307 Remove unused variable 1999-12-21 08:20:36 +00:00
Eivind Eklund
762e6b856c Introduce NDFREE (and remove VOP_ABORTOP) 1999-12-15 23:02:35 +00:00
Kenneth D. Merry
86b2c8466d Revamp the devstat priority system. All disks now have the same priority.
The same goes for CD drivers and tape drivers.  In systems with mixed IDE
and SCSI, devices in the same priority class will be sorted in attach
order.

Also, the 'CCD' priority is now the 'ARRAY' priority, and a number of
drivers have been modified to use that priority.

This includes the necessary changes to all drivers, except the ATA drivers.
Soren will modify those separately.

This does not include and does not require any change in the devstat
version number, since no known userland applications use the priority
enumerations.

Reviewed by:	msmith, sos, phk, jlemon, mjacob, bde
1999-12-08 04:45:23 +00:00
Poul-Henning Kamp
38224dcd59 Convert various pieces of code to use vn_isdisk() rather than checking
for vp->v_type == VBLK.

In ccd: we don't need to call VOP_GETATTR to find the type of a vnode.

Reviewed by:    sos
1999-11-22 10:33:55 +00:00
Poul-Henning Kamp
d53dedee55 Remove the devsw magic from DEV_MODULE() 1999-11-07 10:01:17 +00:00
Nick Hibma
3e2c6ca3b9 Removal of sys/device.h
- Move intrhook stuff into kernel.h
- Remove all occurrences of #device <device.h>
- Add kernel.h were necessary (nowhere)
- delete device.h

This file contained the structures for cfdata (old style config) and is no
longer used. It was included by most drivers.

It confuses the remote debugger as the definition of 'struct device' in
device.h is found before the one in bus_private.h.
1999-10-05 21:19:41 +00:00
Greg Lehey
1441456f23 Correct typo in comment. putccdbuf() releases a buffer, it doesn't allocate one. 1999-09-27 01:51:42 +00:00
Matthew Dillon
74427f90f2 Buffer locking code failed to use BUF_KERNPROC and BUF_UNLOCK and
BUF_LOCKFREE a buffer prior to physically freeing it.  While these
    bugs did not cause a crash, they might in the future.

    Added eof handling for unlabeled partitions.

Submitted by:	Tor.Egge@fast.no
1999-09-27 00:12:36 +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
Matthew Dillon
1464240ec4 Cleanup CCD quite a bit, including adding clarifying comments.
Enhance MIRROR code.  Add a few more sanity checks and implement
    a zone-based disk selector to make use of both disks when reading.

    Also implement a read fail-over.  If a read error occurs on one
    disk, the I/O is retried on the other.

    NOTE: CCD's mirroring support cannot deal with write errors properly
    in regards to recovery, meaning that 'old' data under a write error may
    be read non-deterministically if you reboot after a write error, and CCD
    certainly cannot deal with a disk changeout.  And it still can't.  Use
    vinum if you are really serious about mirroring.  CCD basically just
    implements a poor-man's mirror.
1999-09-23 09:25:05 +00:00
Matthew Dillon
25d1a00bc0 Fix ccdiodone code. The code was using cbp->cb_buf.b_bcount to
sum the total amount of I/O issued to determine when all the I/O
    has completed.  This fails when the EOF boundry occurs in the middle
    of an I/O.  Using cbp->cb_buf.b_bufsize works better.
1999-09-23 08:41:48 +00:00
Matthew Dillon
e322ec4cb4 Fix bug in pseudo-geometry calculation code that assumed a sector size
smaller then 1024 bytes.
1999-09-23 00:09:08 +00:00
Poul-Henning Kamp
2186cd9e8d Use devstat_end_transaction_buf() rather than Use devstat_end_transaction() 1999-09-18 21:30:27 +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
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
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Poul-Henning Kamp
9c93810d2d Initialize the dev->si_bsize fields.
Submitted by:	tegge
Reviewed by:	phk
1999-08-26 14:46:10 +00:00
Poul-Henning Kamp
49ff4debd3 Spring cleaning around strategy and disklabels/slices:
Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout.
please see comment in sys/conf.h about the flag argument.

Remove strategy argument from all the diskslice/label/bad144
implementations, it should be found from the dev_t.

Remove bogus and unused strategy1 routines.

Remove open/close arguments from dssize().  Pick them up from dev_t.

Remove unused and unfinished setgeom support from diskslice/label/bad144 code.
1999-08-14 11:40:51 +00:00
Poul-Henning Kamp
684adedee4 Use the vn_todev() function, rather than VOP_GETATTR 1999-07-18 14:31:01 +00:00
Poul-Henning Kamp
59c4226d5f Fix 2nd arg to udev2dev() call in ccd.c 1999-07-17 19:58:37 +00:00
Peter Wemm
b52ab6b545 Initialize and hold locks for ccd generated bufs..
Obtained from: Matt Dillon <dillon@backplane.com>
1999-06-27 09:28:43 +00:00
Poul-Henning Kamp
4e2f199e0c This commit should be a extensive NO-OP:
Reformat and initialize correctly all "struct cdevsw".

        Initialize the d_maj and d_bmaj fields.

        The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format.  Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.
1999-05-30 16:53:49 +00:00
Poul-Henning Kamp
bfbb9ce670 Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.

Provide functions to manipulate both types:
        major()         umajor()
        minor()         uminor()
        makedev()       umakedev()
        dev2udev()      udev2dev()

For now they're functions, they will become in-line functions
after one of the next two steps in this process.

Return major/minor/makedev to macro-hood for userland.

Register a name in cdevsw[] for the "filedescriptor" driver.

In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.

In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits.  This will essentially
replace the current "alias" check code (same buck, bigger bang).

A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference.  If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.

Without DEVT_FASCIST I belive this patch is a no-op.

Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.

Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +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
Poul-Henning Kamp
c48d17750f Introduce two functions: physread() and physwrite() and use these directly
in *devsw[] rather than the 46 local copies of the same functions.

(grog will do the same for vinum when he has time)
1999-05-07 07:03:47 +00:00
Poul-Henning Kamp
6cc5a7220c Don't use <sys/disk.h> 1999-05-06 19:19:30 +00:00
David Greenman
40969e381b Fixed variable overflow problem.
Obtained from:	NetBSD via Mark J. Taylor <mtaylor@cybernet.com>
1999-03-11 18:50:39 +00:00
Matt Jacob
21c3b31ead Don't forget to remove devstat entries when taking
down the CCD device.
1999-03-10 00:41:27 +00:00
Kenneth D. Merry
043653d4ff Set the devstat priority for ccd devices to DEVSTAT_PRIORITY_CCD
instead of DEVSTAT_PRIORITY_OTHER.
1999-02-18 21:11:53 +00:00
Kenneth D. Merry
2a888f938e Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed.  The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order.  So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers.  For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it.  Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by:	bde, obrien
1999-02-10 00:04:13 +00:00
Matthew Dillon
b4e36adf1c Fix warnings preparing for -Wall -Wcast-qual
Also disable one usb module in LINT due to fatal compilation errors,
    temporary.
1999-01-27 20:09:21 +00:00
Peter Wemm
b7b98418bd Convert ccd to a proper module vs. something started by PSEUDO_SET(). 1999-01-22 22:38:28 +00:00
Justin T. Gibbs
b2dfb1f906 Update system to new device statistics code.
Submitted by:	"Kenneth D. Merry" <ken@plutotech.com>
		mike@smith.net.au (Mike Smith)
1998-09-15 08:15:30 +00:00
Søren Schmidt
e620a1cbed Make struct buf->b_offset reflect the real byte offset which got
in via the uio struct. This enables device drivers to use != DEV_BSIZE
blocking on devices with wierd sector/block sizes (ie CDROM's).
1998-08-19 10:50:32 +00:00
Julian Elischer
f7ea2f55d1 There is no such thing any more as "struct bdevsw".
There is only cdevsw (which should be renamed in a later edit to deventry
or something). cdevsw contains the union of what were in both bdevsw an
cdevsw entries.  The bdevsw[] table stiff exists and is a second pointer
to the cdevsw entry of the device. it's major is in d_bmaj rather than
d_maj. some cleanup still to happen (e.g. dsopen now gets two pointers
to the same cdevsw struct instead of one to a bdevsw and one to a cdevsw).

rawread()/rawwrite() went away as part of this though it's not strictly
the same  patch, just that it involves all the same lines in the drivers.

cdroms no longer have write() entries (they did have rawwrite (?)).
tapes no longer have support for bdev operations.

Reviewed by: Eivind Eklund and Mike Smith
	Changes suggested by eivind.
1998-07-04 22:30:26 +00:00
Julian Elischer
fd5d1124e2 VOP_STRATEGY grows an (struct vnode *) argument
as the value in b_vp is often not really what you want.
(and needs to be frobbed). more cleanups will follow this.
Reviewed by: Bruce Evans <bde@freebsd.org>
1998-07-04 20:45:42 +00:00
Doug Rabson
ecbb00a262 This commit fixes various 64bit portability problems required for
FreeBSD/alpha.  The most significant item is to change the command
argument to ioctl functions from int to u_long.  This change brings us
inline with various other BSD versions.  Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.
1998-06-07 17:13:14 +00:00
Julian Elischer
19ab6a4071 Slightly more correct initialisation of the new buf struct for soft-updates.
Submitted by: Chris Csanady <ccsanady@friley585.res.iastate.edu>
Suggested by: Kirk McKusick
1998-03-09 20:39:26 +00:00
Jordan K. Hubbard
b5068bbbaf Properly bzero() structures after they're returned from getccdbuf().
Submitted by:	Chris Csanady <ccsanady@friley585.res.iastate.edu>
1998-02-22 10:01:23 +00:00
Jordan K. Hubbard
500117e484 Revert part of my previous patch - I don't see the *need*
to call splbio() from within an interrupt handler here. :-)
1998-02-15 08:28:26 +00:00
Jordan K. Hubbard
7d15435cb1 missing spl() call and off by one error in the handling of the partitions.
Submitted by:	Chris Csanady <ccsanady@friley585.res.iastate.edu>
Obtained from:	OpenBSD
1998-02-15 08:14:39 +00:00
Eivind Eklund
eaa22ef760 Remove unused devfs include. (Julian or Satoshi might want to add proper
DEVFS support here; just including the header file doesn't do any good, and
would make this depend on opt_devfs.h)
1998-01-31 03:19:06 +00:00
Poul-Henning Kamp
fdfcd4ae29 There is no ccdread() nor ccdwrite(). 1997-11-18 14:39:04 +00:00
Poul-Henning Kamp
e2738b4f1b Statizice. 1997-10-24 14:24:55 +00:00
Poul-Henning Kamp
f541e4a472 Remove a #ifndef __FreeBSD__ chunk. 1997-10-11 07:35:25 +00:00
Bruce Evans
958aaa7ef3 Removed unused #includes. 1997-06-14 13:56:12 +00:00
Søren Schmidt
e59f3105f6 Make ccd use the maxsecsize sector size as denominator, this
fixes ccd on != 512byte devices..
1997-05-01 19:18:40 +00:00
Bruce Evans
fce002fdef Don't include <sys/ioctl.h> in the kernel. Stage 1: don't include
it when it is not used.  In most cases, the reasons for including it
went away when the special ioctl headers became self-sufficient.
1997-03-24 11:25:10 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
Mike Pritchard
06bcc9e510 Make ccd compile again after the Lite2 merge.
VOP_UNLOCK was being called with the wrong number of arguments.
1997-02-10 16:24:33 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
John Dyson
c0b89506ba Fix CCD for bounced devices. 1997-01-10 04:09:13 +00:00
Poul-Henning Kamp
bfbb029d87 Remove devconf, it never grew up to be of any use. 1996-09-06 23:09:20 +00:00
Satoshi Asami
34f3521636 Fail when odd number of disks are specified with mirror flag. Memory
leak fixes.  Miscellaneous cleanup.

Partially submitted by:	Matt White <mwhite+@CMU.EDU>
1996-07-24 23:45:24 +00:00
Poul-Henning Kamp
cba8a5ddd3 Make a "DWIM" function for adding [bc]devsw entries for bdev drivers.
Saves about 280 butes of source per driver, 56 bytes in object size
and another 56 bytes moves from data to bss.

No functional change intended nor expected.

GENERIC should be about one k smaller now :-)
1996-07-23 21:52:43 +00:00
Poul-Henning Kamp
10bc064c3a Substitute raw{read|write} for ccd{read|write} 1996-07-21 09:28:03 +00:00
Gary Palmer
c23670e294 Clean up -Wunused warnings.
Reviewed by:		bde
1996-06-12 05:11:41 +00:00
Satoshi Asami
1af0e025c9 Add #ifndef/#endif around the "#define CCD_OFFSET 16", so you can override
it in your kernel config file.

Requested (in essence) by:	phk
1996-05-13 09:17:42 +00:00
Satoshi Asami
0d88ef072c Leave 16 lines in front of each component partition. It's now safe to
use sd87a or sd237e even if they start at the beginning of the slice.

You can also use sd85c if you prefer, although you need to change the
type field in the disklabel to "4.2BSD".
1996-05-13 08:38:15 +00:00
Satoshi Asami
52faebb233 Add missing "int" to static var. 1996-04-24 09:42:22 +00:00
Satoshi Asami
e73228724f Change how mirror writes are handled, according to the discussion on the
mailing list.

When initiating a write, ccdbuffer() returns two "struct ccdbuf *"s
linked together by the cb_mirror field.  "cb_pflags &
CCDPF_MIRROR_DONE" is set to 0 on both of them.

When a component returns to ccdiodone(), it checks if "cb_pflags &
CCDPF_MIRROR_DONE" is set or not.  If not, it sets the partner's
flag and returns.  If it is, it means its partner has already
returned, so it will go to the regular cleanup (which is in the
fallthrough code).

There should be no performance or functionality changes unless the
higher-level scsi driver does something with the resid value.  The change
is purely aesthetical and prepares us for the parity implementation.
1996-03-26 02:29:11 +00:00
Satoshi Asami
e2a13e8c60 Ported to 2.2-current. Uses [bc]devsw_add(), and is also now a proper
pseudo-device.

Doesn't use devfs correctly yet.
1996-03-21 04:13:25 +00:00
Satoshi Asami
b8e29b5517 Fix one warning and fix one bug found while looking at another warning (but
caused by a different reason):

. #ifndef __FreeBSD__ around check for negative size, FreeBSD size_t is
  unsigned

. Disable mirror/parity if interleave size is 0 (i.e., serial concatenation).
1996-01-31 11:25:46 +00:00
Satoshi Asami
3bc746be91 Mirror support. When CCDF_MIRROR is set:
(1) The reads are always done from the first n/2 disks.

(2) Each write is done twice, to the "data" disk (in the first half) and
    the "mirror" disk (in the second half).

ccdbuffer() now takes an extra argument (struct ccdbuf **) and stores
the pointer to ccdbuf in there.  In case of a mirrored write, it
allocates and stores two pointers.  The "residual" is also doubled
for mirrored writes so that ccdiodone() can correctly tell when all
the writes are done.
1996-01-31 03:28:21 +00:00
Satoshi Asami
09b5920411 Prepare for adding mirroring. Check for flags (mirror forces uniform),
reduce the size to half, etc.  Right now it only uses the first n/2 disks
for both read and write.
1996-01-30 22:34:53 +00:00
Satoshi Asami
7ecb65fa26 Prepare to add support for parity. Report the post-parity size,
allocate space around parity blocks.
1996-01-02 23:32:54 +00:00
Satoshi Asami
aa8bdaec2b Added $Id$. 1995-12-28 00:22:45 +00:00
Satoshi Asami
d8594dfb93 Changes to make it work on FreeBSD-2.1. 1995-12-27 10:53:21 +00:00
Satoshi Asami
a56bb8a5cc ccd.c and ccd.4 from NetBSD-current circa 12/25/95. 1995-12-27 10:49:19 +00:00