Commit Graph

433 Commits

Author SHA1 Message Date
phk
6471cae560 Limit our requests to DFLTPHYS, this is generally a good idea for
memory-allocation purposes.  Right now it is also a very good idea
because we hit a Giant assertion in the free(9) processing if we
free something larger than 64k.
2003-03-07 19:09:46 +00:00
phk
21654c3b17 Initialize the second buffer for mirroring to point to itself and not its
partner.
2003-03-04 10:15:19 +00:00
phk
0ae911eb0e 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
phk
2fb7245efc NO_GEOM cleanup:
Remove cdevsw->d_psize() implementation, we don't need it any more.
2003-03-02 14:42:01 +00:00
phk
e8ab4a65e4 NO_GEOM cleanup:
Retire the "dev_t" centric version of the disk mini-layer.
Remove now unneeded linkage field in dev_t and struct disk.
2003-02-28 10:02:02 +00:00
mux
541937cf73 Cleanup of the d_mmap_t interface.
- Get rid of the useless atop() / pmap_phys_address() detour.  The
  device mmap handlers must now give back the physical address
  without atop()'ing it.
- Don't borrow the physical address of the mapping in the returned
  int.  Now we properly pass a vm_offset_t * and expect it to be
  filled by the mmap handler when the mapping was successful.  The
  mmap handler must now return 0 when successful, any other value
  is considered as an error.  Previously, returning -1 was the only
  way to fail.  This change thus accidentally fixes some devices
  which were bogusly returning errno constants which would have been
  considered as addresses by the device pager.
- Garbage collect the poorly named pmap_phys_address() now that it's
  no longer used.
- Convert all the d_mmap_t consumers to the new API.

I'm still not sure wheter we need a __FreeBSD_version bump for this,
since and we didn't guarantee API/ABI stability until 5.1-RELEASE.

Discussed with:		alc, phk, jake
Reviewed by:		peter
Compile-tested on:	LINT (i386), GENERIC (alpha and sparc64)
Runtime-tested on:	i386
2003-02-25 03:21:22 +00:00
grehan
c2c6624864 Drop down Apple Partition Map code that has been in use by some
ppc developers for a while.

OK'd by:  phk
2003-02-23 01:25:35 +00:00
phk
8f9640b59b NO_GEOM cleanup: Convert CCD(4) to be use "struct disk*" instead of "dev_t"
as "this" handle.
2003-02-21 23:25:43 +00:00
phk
02e550fabb NO_GEOM cleanup:
Retire the "d_dump_t" and use the "dumper_t" type instead.

Dumper_t takes a void * as first arg which is more general than the
dev_t taken by d_dump_t.  (Remember: we could have net-dumpers if
somebody wrote us one!)

Define the convention for GEOM controlled disk devices to be that the
first argument to the dumper function is the struct disk pointer.

Change device drivers accordingly.
2003-02-21 19:00:48 +00:00
phk
9aa946589d NO_GEOM cleanup:
Change the argument to disk_destroy() to be the same struct disk * as
disk_create() takes.

This enables drivers to ignore the (now) bogus dev_t which disk_create()
returns.
2003-02-21 15:13:26 +00:00
phk
05d8d6e23f Add M_WAITOK 2003-02-19 22:51:33 +00:00
imp
cf874b345d Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
tegge
4d5cb6df0d Correctly set bio_data in cloned children when cutting up large requests. 2003-02-12 16:30:46 +00:00
phk
ba1e23916c Implement a handle for efficient implementation of perforations in
lower extremities.

Setting bit 4 in debugflags (sysctl kern.geom.debugflags=16) will
allow any open to succeed on rank#1 providers.  This will generally
correspond to the physical disk devices: ad0, da0, md0 etc.

This fundamentally violates the mechanics of GEOMs autoconfiguration,
and is only provided as a debugging facility, so obviously error
reports on GEOM where this bit is or has been set will not be
accepted.
2003-02-12 09:48:27 +00:00
phk
8bf75a2e40 Implement a bio-taskqueue to reduce number of context switches in
disk I/O processing.

        The intent is that the disk driver in its hardware interrupt
        routine will simply schedule the bio on the task queue with
        a routine to finish off whatever needs done.

        The g_up thread will then schedule this routine, the likely
        outcome of which is a biodone() which queues the bio on
        g_up's regular queue where it will be picked up and processed.

        Compared to the using the regular taskqueue, this saves one
        contextswitch.

Change our scheduling of the g_up and g_down queues to be water-tight,
at the cost of breaking the userland regression test-shims.

Input and ideas from:   scottl
2003-02-11 22:30:26 +00:00
phk
b098c0b196 Announce our ability to do MAXPHYS transfers. 2003-02-11 21:29:53 +00:00
phk
ef9a1b8601 Advertise MAXPHYS upwards, we will split as necessary before we get to the
bottom of things.
2003-02-11 21:24:25 +00:00
phk
9b781d6129 Check disk->d_maxsize/dev->si_iosize_max at open time rather than in strategy.
Printf a warning and use DFLTPHYS if the drive has not set a size.
2003-02-11 21:23:34 +00:00
phk
9c7fdcb565 Make a mutex to stop the race coming into geom_disk's done routine.
Cut up requests into smaller bits if they are longer than the drivers
disk->d_maxsize or dev->si_iosize_max.

Properly handle the race condition when using g_clone_bio() is used
without having the single-threadedness of g_down/g_up secure locking.
2003-02-11 18:32:31 +00:00
phk
75f224dcec Don't divide by zero if there is no stripewidth specified. 2003-02-11 15:23:41 +00:00
phk
dc511a8940 Typo in last commit. 2003-02-11 15:20:34 +00:00
phk
fd7ea6d48a Better names for struct disk elements: d_maxsize, d_stripeoffset
and d_stripesisze;

Introduce si_stripesize and si_stripeoffset in struct cdev so we
can make the visible to clustering code.

Add stripesize and stripeoffset to providers.

DTRT with stripesize and stripeoffset in various places in GEOM.
2003-02-11 14:57:34 +00:00
phk
b2fb118970 Propagate DISKFLAG_CANDELETE from struct disk to G_PF_CANDELETE on the
provider.
2003-02-11 14:12:06 +00:00
phk
8405552698 Wrap a long line. 2003-02-11 14:09:48 +00:00
phk
064989983a Don't short-circuit zero-length requests of they are BIO_[SG]ETATTR. 2003-02-11 13:13:10 +00:00
phk
ab4aed671a Use the SI_CANDELETE flag on the dev_t rather than the D_CANFREE flag
on the cdevsw to determine ability to handle the BIO_DELETE request.
2003-02-11 12:49:58 +00:00
phk
a61961945a Unconditionally make our provider with G_PF_CANDELETE. 2003-02-11 12:37:04 +00:00
phk
18e25b25db Propagate G_PF_CANDELETE to our own providers from the provider we attach to. 2003-02-11 12:36:33 +00:00
phk
41af143abe Introduce flag field and G_PF_CANDELETE field on providers. 2003-02-11 11:55:40 +00:00
phk
47f258f8be Remove another printf which does not say anything we didn't already know. 2003-02-11 11:02:27 +00:00
phk
89a4ec072e Turn the "updating" flag (back) into two sequence number fields at
either ends of the structure so we have a way to determine if a
snapshot is consistent.
2003-02-11 11:01:26 +00:00
phk
1ce699ee2a Remove a debugging printf. 2003-02-11 10:59:43 +00:00
phk
ee425616b7 Update the statistics collection code to track busy time instead of
idle time.

Statistics now default to "on" and can be turned off with
        sysctl kern.geom.collectstats=0

Performance impact of statistics collection is on the order of
800 nsec per consumer/provider set on a 700MHz Athlon.
2003-02-09 17:04:57 +00:00
phk
384af30f63 Put the name of the /dev entry in the .h file, userland will need it. 2003-02-08 14:50:27 +00:00
phk
04a4ba381f Move the g_stat struct to its own .h file, we will export it to other code.
Insted of embedding a struct g_stat in consumers and providers, merely
include a pointer.

Remove a couple of <sys/time.h> includes now unneeded.

Add a special allocator for struct g_stat.  This allocator will allocate
entire pages and hand out g_stat functions from there.  The "id" field
indicates free/used status.

Add "/dev/geom.stats" device driver whic exports the pages from the
allocator to userland with mmap(2) in read-only mode.

This mmap(2) interface should be considered a non-public interface and
the functions in libgeom (not yet committed) should be used to access
the statistics data.
2003-02-08 13:03:57 +00:00
phk
15f4f6a52b Move #defines of major/minor to internal header file so other bits can
share and coordinate with geom_dev.
2003-02-08 12:30:12 +00:00
phk
e8f2dea5dd Commit the correct copy of the g_stat structure.
Add debug.sizeof.g_stat sysctl.

Set the id field of the g_stat when we create consumers and providers.

Remove biocount from consumer, we will use the counters in the g_stat
structure instead.  Replace one field which will need to be atomically
manipulated with two fields which will not (stat.nop and stat.nend).

Change add companion field to bio_children: bio_inbed for the exact
same reason.

Don't output the biocount in the confdot output.

Fix KASSERT in g_io_request().

Add sysctl kern.geom.collectstats defaulting to off.

Collect the following raw statistics conditioned on this sysctl:

    for each consumer and provider {
        total number of operations started.
        total number of operations completed.
        time last operation completed.
        sum of idle-time.
        for each of BIO_READ, BIO_WRITE and BIO_DELETE {
            number of operations completed.
            number of bytes completed.
            number of ENOMEM errors.
            number of other errors.
            sum of transaction time.
        }
    }

API for getting hold of these statistics data not included yet.
2003-02-07 23:08:24 +00:00
phk
329bf7c30c Fix some sleep strings to make more sense. 2003-02-07 21:53:55 +00:00
phk
7a3625aca3 Add the new statistics structure, put one in consumers and providers.
include <sys/time.h> as necessary.
2003-02-07 21:43:34 +00:00
phk
0d87d64253 Rename bio_linkage to the more obvious bio_parent.
Add bio_t0 timestamp, and include <sys/time.h> where needed
2003-02-07 21:09:51 +00:00
gordon
56209777d7 Add some comments about the deficiencies of this module. I had hoped to get
around to addressing them some more, but Real Life (tm) has gotten in the
way.
2003-02-07 17:50:33 +00:00
phk
63f412ef74 Check return value of g_clone_bio(). 2003-02-06 22:00:47 +00:00
phk
84f57209a4 Experimentally don't let go of Giant in geom_disk's done.
We may actually be increasing Giant contention doing so because the
actual stuff we do is very cheap.

Also I am not convinced there is not a tiny window for a race here.
2003-02-06 21:50:39 +00:00
phk
ef9c55f6aa Put the checks we perform on a bio before calling ::start in their
own function, handle all validation and truncation at the time we
process the bio instead of when it gets scheduled.
2003-02-06 21:01:36 +00:00
phk
82db7fddb8 Implement the new "struct disk" centered API for device drivers.
This commit should not change anything as no device drivers use the
new API yet.
2003-02-05 21:13:08 +00:00
phk
9d6d3f1673 Pave the road to removing the fixed size limit on device nodes:
Change the si_name of dev_t's to be a char * and put a private buffer for
holding the name at then end of the struct.

Initialize si_name to point to the private buffer.

Put a KASSERT in geom_disk to prevent overrun on the fake dev_t we still
have to generate for the disk_drivers.
2003-02-04 10:32:40 +00:00
gordon
8329fa8951 Correct a comment. GEOM modules do not create /dev entries. They create
providers.

Pointed out by:	phk
2003-02-03 17:21:43 +00:00
gordon
7ec55e9926 Add the GEOM module that makes volume labels useful. A kernel compiled with
this will cause volume labels to be exposed in /dev/vol/<volname>. Currently,
there is no conflict resolution if more than one FS has the same volume name.

Reviewed by:	phk
2003-02-03 17:14:29 +00:00
phk
53aec1a3a4 Add a bio_disk pointer for use between geom_disk and the device drivers. 2003-02-02 11:59:54 +00:00
phk
f9d517f0ed Eliminate the sc_openmask, ccdopen() and ccdclose() functions, we
can use the flag maintained by geom_disk.c

Having only a strategy method to intialize, don't waste space using
a cdevsw structure to do so.
2003-02-01 11:17:22 +00:00
phk
cfd92eb694 Move configuration of geom/providers into its own function in preparation
for adding on-the-fly config interface.
2003-02-01 08:28:43 +00:00
phk
b1d44eed4c Remove commented out g_enc_dos_partition(). We won't be needing it. 2003-01-31 21:18:41 +00:00
phk
9d1b9f3c00 Add a rudimentary class for slicing Apple partitioned disks.
More work is needed on this, stakeholders please contact me.

Not quite asked for by:	rwatson
2003-01-31 16:27:07 +00:00
phk
10368fffb1 Add some agility to the disk_create() API:
Make passing the methods in a cdevsw structure optional.

Move "CANFREE" and "NOGIANT" flags into struct disk instead of the
cdevsw which may or may not be there.

Rename CANFREE to CANDELETE to match BIO_DELETE operation.

Add "OPEN" flag so drivers don't have to provide open/close methods
just to maintain such a flag.

Add temporary stopgap include of <sys/conf.h> to <sys/disk.h> until
the files which have them in the other order are fixed.

Add KASSERTS to make sure we don't get fed too many NULL pointers.

Clear our geom's softc pointer before we wither.
2003-01-30 20:34:23 +00:00
phk
8fe9dd24e0 NO_GEOM cleanup: Remove sys/disklabel.h include. 2003-01-30 19:55:19 +00:00
phk
837e7af52d NO_GEOM cleanup: retire disk_invalidate() 2003-01-30 19:43:50 +00:00
phk
bcf1d466fe NO_GEOM cleanup: Mark the last arg to disk_create() as unused. 2003-01-30 11:39:36 +00:00
phk
89099a65fb Add code to repsect the D_NOGIANT flag, should the disk device driver set it.
NO_GEOM cleanup:        remove ifdefs.

Still untested.
2003-01-29 19:47:25 +00:00
phk
15d50f061e Sort these functions as the author instructed. 2003-01-29 18:37:29 +00:00
phk
d12257b0f6 Mark some args unused so this compiles in userland. 2003-01-28 09:48:09 +00:00
phk
188cb3f63b Use a void * to carry the private data for return-call'ed ioctl requests.
Amongst other things this avoids a complex workaround in the userland
regression bits.
2003-01-28 09:47:50 +00:00
phk
f71e2dab31 Implement DIOCBSDBB ioctl which overwrites first BBSIZE bytes of BSD
labeled disk.

This is complicated by the fact that BBSIZE is greater than the
PAGE_SIZE limit ioctl inflicts on arguments which are automatically
copied in.

As long as we don't need access to userland memory (copyin/out) we
can deal with the ioctl using g_callme() which executes it from the
GEOM event thread.

Once we need copyin/out, we need to return the bio with EDIRIOCTL
in order to make geom_dev call us back in the original process context
where copyin will work.

Unfortunately, that results in us getting called with Giant, so
we have to DROP_GIANT/PICKUP_GIANT around the code where we diddle
GEOMs internals.

Sometimes you just can't win...

... But it does make geom_bsd.c an almost complete example of the
GEOM beastiarium.
2003-01-26 21:54:36 +00:00
alfred
bf8e8a6e8f Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
phk
dc9137bbd9 disk_dev_synth() is a NO_GEOM hack. 2003-01-20 11:29:07 +00:00
phk
9241d94016 Remove need for <sys/diskslice.h> but retain numerical compatibilty just in case. 2003-01-20 11:23:00 +00:00
phk
b9e99ecd32 Finally give CCD the disk mini-layer treatment:
CAUTION:

        Previously CCD would be different from all other disks in
        the system in that there were no "ccd0" device, only a
        "ccd0c" device.

        This is no longer so after this commit.  If you access a
        ccd device through the "/dev/ccd0c" device _and_ have not
        actually put a BSD disklabel on the device, you will have
        to use the name "/dev/ccd0".  If your CCD device contains
        a BSD disklabel there should be no difference.

        You need to recompile ccdconfig(8) using the changed
        src/sys/sys/ccdvar.h for the -g "show me" option to work.

        I have run the regression test I created before I started
        overhauling CCD and it flags no problems, but this code
        is mildly evil, so take care.  If you would cry if you lost
        what's on CCD, make a back before you upgrade.

Create separate cdevsw for the /dev/ccd.ctl device.

Remove the cloning function, the disk-minilayer will do all naming
for us.

Remove the ccdunit and ccdpart functions and carry the softc pointer
in the relevant dev_t's and structures.

Release all memory when a CCD device is unconfigured, previously
the softc would linger behind.

Remove all traces of BSD disklabel fiddling code.

Remove ccdpsize, the disk mini-layer does this for us.

Don't allocate memory with M_WAITOK in ccdstrategy().

Remove boundary checks which the disk mini-layer does for us.

Don't allocate space for more than 2 ccdbuf, RAID was never implemented.

NB: I have not tried to address any of the preexisting ailments of CCD.
2003-01-19 15:00:58 +00:00
phk
10e76c3f14 Unifdef -UDEBUG on the CCD driver. The debugging is mostly useless
and can be added back selectively, should anybody start to interest
themselves for the internal workings of ccd.

This commit will make the diffs for the following commits much more
readable.
2003-01-19 14:35:38 +00:00
phk
1a85c3746b Inline now trivial functions getccdbuf() and putccdbuf().
Fix another trivial memory-leak.
2003-01-18 12:23:49 +00:00
phk
5bbadf161c Fix minor memory-leak. 2003-01-18 11:33:06 +00:00
phk
d5b262df48 Use the M_CCD malloc bucket instead of M_DEVBUF.
Don't keep a private freelist of a low number of trivially small structures.
2003-01-18 11:04:41 +00:00
phk
577399eeab Inline trivial function ccdintr() into its one caller ccdiodone().
Only call ccdfind() once in ccdiodone() and cache the result.
2003-01-18 10:44:17 +00:00
phk
961794d713 Sanitize the copyright section a bit: We do not need two copies of the
four-clause BSD license in the file, one will do.
2003-01-18 10:08:27 +00:00
phk
62c9659f0c Find places to store the previously implicityly passed unit number in
the three configuration ioctls which need a unit number.

Add a "ccd.ctl" device for config operations.

Implement ioctls on ccd.ctl which rely on the explicityly passed
unit numbers.

Update ccdconfig to use the new ccd.ctl interface.

Add code to the kernel to detect old ccdconfig binaries, and whine
about it.

Add code to ccdconfig to detect old kernels, and whine about it.

These two compatibility measures will be retained only for a limited
period since they are in the way of GEOM'ification of ccd.
2003-01-17 14:53:53 +00:00
phk
e9184d11f9 Add a very simple but functional GEOM mirror class.
This is committed more as an instructive tool than as a production
facility, but this will change over time.
2003-01-14 22:44:48 +00:00
phk
aaa8136387 Now that we have non-geom_disk based drivers, we need to cover for those,
in case they return EOPNOTSUPP on an ioctl.

Found by:	jhb
2003-01-14 21:31:00 +00:00
phk
e67e97880d Always issue ioctls as BIO_GEATTR requests. The direction of data copies on
ioctls are no reliable indication of the ioctls "set" or "get" nature or if
such simplistic categories can even be applied.

MFC candidate:	boot0cfg issue.
2003-01-13 11:34:35 +00:00
phk
6ef829cd7d Remove g_silence(). It does not do anything anymore. 2003-01-13 08:46:32 +00:00
phk
672b19058d Fix typo. 2003-01-13 08:44:03 +00:00
phk
83f3fce109 Don't restrict MBR sectorsize to 512 bytes.
Test data provided by:	Andrey Koklin <aka@veco.ru>
2003-01-11 12:30:51 +00:00
jhb
03f0bdefde Output the fstype of each partition in a disklabel in the configuration
text similar to the way that the MBR module dumps its slice types.
2003-01-10 19:44:14 +00:00
phk
158843e06d BSD disklabels expose the controling label though the 'c' partition, and
some trick is necessary to prevent further BSD geoms from attaching to
that.  Our old trick was to make sure we don't attach to a geom from
the "BSD" class, but this doesn't work if an intermediary geom obscures
this fact.  Instead, calculate the MD5 checksum of the label we target
and ask if anybody below us loves that label.  If they do we don't.

Coded by:       gordon.
2003-01-06 20:10:41 +00:00
phk
d68eff9b1b In userland case include <errno.h>, not <err.h>. This is needed to make
the src/tools/regression/geom stuff compile.
2003-01-06 20:05:45 +00:00
nyan
864080610e Rename the dos_partition structure for pc98 to pc98_partition. 2003-01-04 08:50:48 +00:00
phk
dd55faeb5e Remove CCDF_SWAP and CCDF_PARITY, they have never been implemented. 2003-01-03 08:57:40 +00:00
nyan
fac5fc844d MFMBR: Add ioctls for writing an IPL and a boot menu. 2003-01-03 07:13:36 +00:00
phk
bfabff54fe Remove unused second argument from BIO_STRATEGY() 2003-01-03 05:51:11 +00:00
phk
bc7a07d94c Optimize the size of the work-items by letting the mapping function
decide the largest size which stays inside the zone and does not
collide with a lock sector.
2003-01-02 19:29:49 +00:00
phk
8fa3036bdb Update si_bsize_phys on open.
MFC candidate.
2003-01-02 09:38:22 +00:00
schweikh
86f7487fb6 Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.
2002-12-30 21:18:15 +00:00
phk
78a7deb4bb Implement ioctls for tampering with sector0. 2002-12-29 14:59:24 +00:00
phk
27cb79fe10 Remove the "ascii" attribute from the sysctls so that "sysctl -a" will
skip them.
2002-12-27 07:58:59 +00:00
phk
516da34ba8 white-space changes 2002-12-26 21:02:50 +00:00
phk
2e1375146e Use a mutex assert to document our locking circumstances. 2002-12-26 20:48:22 +00:00
phk
3d7762dd22 We should not need to hold Giant for sbuf operations any more. 2002-12-26 20:46:30 +00:00
phk
3e75022eb7 Add an XXX comment to explain the predicament. 2002-12-26 20:45:37 +00:00
phk
0989bb3e91 Don't forget our topology lock in the MBREXT case. 2002-12-19 12:01:19 +00:00
phk
790740dde5 Solve another bug in the mapping code: correctly skip lock sectors.
Make sure sector zero is protected if it contains metadata.

Lower WARNS for gbde to 3 on non-i386 archs.  rijndael-fst is evil
but appearntly does the right thing and passes the test-vectors.

MFC Candidate.
2002-12-18 22:11:54 +00:00
phk
761d063e80 Fix two blunders in the mapping functions which can lead to corrupt data,
for request sizes larger than the sectorsize or for multi-key setups.

See warning mailed to current@ for details of recovery.

Found by:	Marcus Reid <marcus@blazingdot.com>
2002-12-18 19:57:27 +00:00
phk
4052863334 Balk at unaligned requests.
MFC candidate.
2002-12-18 19:53:59 +00:00
phk
51c494ca74 Add a check for negative offset locations and return EINVAL for them. 2002-12-17 21:31:58 +00:00