Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/ccd.c
RevisionDateAuthorComments
 1.193  17-Aug-2025  mlelstv Clear error code so that successful local ioctls won't return
EPASSTHROUGH (seen as ENOTTY in userland).
 1.192  08-Jan-2025  andvar s/componets/components/ in comment.
 1.191  12-Apr-2024  pgoyette branches: 1.191.2;
Repair handling of ccd sysctls to not use newp as an index.

This is a work-around for kern/58051. It is not a complete fix.
 1.190  31-Mar-2024  hannken Using a ccd(4) with GPT (dk* at ccd*) the disk framework will call
ccdstrategy() -> ccdstart() -> ccdbuffer() from softint context.
Allocating the buffer with PR_WAITOK here is forbidden.

Change ccdstart() / ccdbuffer() to report failure back to caller and
pass PR_WAITOK / PR_NOWAIT as an additional argument.

Call ccdstart() with PR_NOPWAIT from ccdstrategy() and on error defer
to the kthread. Call ccdstart() with PR_WAITOK from kthread so requests
from kthread always succeed to allocate the buffers.

Remove the (non working) throttling on low memory as it is no longer needed.

Fixes PR kern/58043 "kernel crash in assert_sleepable() in -current,
dk(4) driver?"
 1.189  28-Mar-2022  riastradh branches: 1.189.4;
sys/dev/ccd.c: Restore historic RCS id.

This got munged accidentally by `git cvsexportcommit -k' -- taking
that option out of my commitbomb script!
 1.188  28-Mar-2022  riastradh driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this. (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back. To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
 1.187  12-Mar-2022  riastradh ccd(4): Only pathbuf_destroy if pathbuf_copyin succeeded.

Reported-by: syzbot+a46aadc788a80afc8742@syzkaller.appspotmail.com
 1.186  11-Feb-2022  riastradh ccd(4): Fix typo in comment.
 1.185  06-Oct-2020  mlelstv Fix ioctl locking. Add dkdriver.
 1.184  11-Jun-2020  ad uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched. It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
 1.183  31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.182  21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.181  08-Dec-2019  mlelstv Switch to vn_bdev_open* functions.
 1.180  07-Aug-2019  pgoyette Many years ago someone created a new __link_set_sysctl_funcs to hold
the list of routines that need to be called for setting up sysctl
variables. This worked great for all code included in the kernel
itself, but didn't deal with modules that want to create their own
sysctl data. So, we ended up with a lot of #ifdef _MODULE blocks
so modules could explicitly call their setup functions when loaded
as non-built-in modules.

So today, we complete the task that was started so many years ago.

When modules are loaded, after we've called xxx_modcmd(INIT...) we
check if the module contains its own __link_set_sysctl_funcs, and
if so we call the functions listed. We add a struct sysctllog member
to the struct module so we can call sysctl_teardown() when the module
gets unloaded. (The sequence of events ensures that the sysctl stuff
doesn't get created until the rest of the module's init code does any
required memory allocation.)

So, no more need to explicitly call the sysctl setup routines when
built as a loadable module.
 1.179  27-Mar-2019  martin branches: 1.179.4;
Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).
 1.178  01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.177  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.176  18-Mar-2018  christos branches: 1.176.2;
factor out the ccd COMPAT_60 code.
 1.175  23-Jan-2018  pgoyette branches: 1.175.2;
Add "bufq_fcfs" requirement to all those driver modules that explicitly
request it in their calls to bufq_alloc().
 1.174  19-Dec-2017  pgoyette Ooppss, need an ampersand call calling LIST_EMPTY() macro
 1.173  19-Dec-2017  pgoyette There is currently a counter nactive which tracks the INSERT and REMOVE
of entries in the ccds LIST.

Since the counter is checked only when the ccd module is being unloaded,
remove the counter completely and just check for LIST_EMPTY(ccds).

No functional change intended.
 1.172  01-Jun-2017  chs branches: 1.172.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.171  05-Apr-2017  jdolecek branches: 1.171.4;
introduce DKCACHE_COMBINE() macro - it combines the flags in a way that
all common flags are retained, and flags regarding write cache are preserved
if either of the devices has it; callers can thus rely on write cache not
being possible to be used when both flags are missing

use the new macro for ccd(4)
 1.170  30-Mar-2017  jdolecek support DIOCGCACHE - result is intersection of flags returned by underlying
devices; devices can't be added or removed, so the feature flags remain
static

add support for DIOCGSTRATEGY while here, mainly to make dkctl(8) output neater
 1.169  05-Mar-2017  mlelstv Enhance disk metrics by calculating a weighted sum that is incremented
by the number of concurrent I/O requests. Also introduce a new disk_wait()
function to measure requests waiting in a bufq.
iostat -y now reports data about waiting and active requests.

So far only drivers using dksubr and dk, ccd, wd and xbd collect data about
waiting requests.
 1.168  20-Nov-2016  pgoyette branches: 1.168.2;
Avoid calling bufq_free() from critical section.
 1.167  07-Aug-2016  pgoyette Create the kern.ccd sysctl sub-tree when built as a module. Even though
the contents of the sub-tree are all structures, and thus not displayed
via sysctl(8), the info is potentially useful to programs. (For example,
ccdconfig could use this to determine how many units are available.)

The sub-tree is already available when the module is included as built-in
module.
 1.166  08-Dec-2015  christos branches: 1.166.2;
Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.165  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.164  21-Jul-2015  skrll Trailing whitespace.
 1.163  18-Jun-2015  christos initialized sc_unit (from Riastradh)
XXX: pullup-7
 1.162  02-Jan-2015  christos We have three sets of DTYPE_ constants in the kernel:
altq Drop Type
disklabel Disk Type
file Descriptor Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
 1.161  31-Dec-2014  christos make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
 1.160  31-Dec-2014  christos Centralize wedge ioctls in disk_ioctl.
 1.159  30-Dec-2014  christos destroy the pool and the mutex when detaching.
 1.158  30-Dec-2014  christos - only create ccd's when we ask them to be created.
- keep track of the number of active ccd's so that we don't modunload and
crash
- fix formatting.
- don't attach 4, the argument is not used.
 1.157  30-Dec-2014  mlelstv Fix locking error.
Clear EPASSTHROUGH return value from disk_ioctl.
Add missing wedge ioctls.
 1.156  30-Dec-2014  jnemeth Slowly bring this thing kicking and screaming into the 21st century:

- use struct disk_geom
- add wedge support
 1.155  30-Dec-2014  christos call disk_ioctl.
 1.154  11-Oct-2014  mlelstv branches: 1.154.2;
No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.
 1.153  11-Oct-2014  mlelstv clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.
 1.152  16-Aug-2014  sborrill Switch size_t to uint64_t in appropriate places to ensure that ccd(4) works
with component and total sizes of > 2TB.
Add COMPAT_60 code for platforms where this alters userland-accessible
structures.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
 1.151  25-Jul-2014  dholland branches: 1.151.2;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.150  25-Jul-2014  dholland Add d_discard to all struct bdevsw instances I could find.

I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
 1.149  14-Jun-2014  hannken Change dk_lookup() to return an anonymous vnode not associated with
any file system. Change all consumers of dk_lookup() to get the
device from "v_rdev" instead of VOP_GETATTR() as specfs does not
support VOP_GETATTR(). Devices obtained with dk_lookup() will no
longer disappear on forced unmounts.

Fix for PR kern/48849 (root mirror raid fails on shutdown)

Welcome to 6.99.44
 1.148  06-Apr-2014  joerg Don't destroy locked mutex. Don't access freed memory.
 1.147  25-Feb-2014  pooka branches: 1.147.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.146  28-Dec-2013  pgoyette ccd module also needs dk_subr
 1.145  12-Sep-2013  martin #ifdef a few variable declarations/initializations to match their use
 1.144  27-Apr-2013  christos branches: 1.144.4;
- no limit on the number of ccd devices.
- provide sysctl for getting information.
 1.143  13-Nov-2011  christos branches: 1.143.6; 1.143.10;
use getdisksize
 1.142  14-Oct-2011  hannken branches: 1.142.2;
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
 1.141  04-Jul-2011  joerg Fix memset usage.
 1.140  21-Jun-2011  jruoho Adjust the #ifdefs such that ccd(4) and cgd(4) show in
modstat(8) even if built into the kernel.
 1.139  12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.138  08-Feb-2011  rmind branches: 1.138.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.137  19-Nov-2010  dholland branches: 1.137.2; 1.137.4;
Fix previous, was all wrong. noticed by enami.
 1.136  19-Nov-2010  dholland Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.135  14-Nov-2010  uebayasi Include uvm/uvm_extern.h to access uvmexp. gtmpsc.c doesn't need
uvm(9) API at all.
 1.134  05-Jun-2009  haad branches: 1.134.4;
Add work in support for compiling ccd and cgd drivers as a modules. I forgot
to committ when I have written device module autoloading stuff.
 1.133  04-Apr-2009  ad Fix problems with ccd:

- Pending async I/O was tossed on unconfigure (should not happen, but..)
- It could exhaust memory under heavy I/O load.
- If memory allocation failed, disk transfers could stall.
- v_numoutput was updated without v_interlock held.

Additionally:

- Make it MPSAFE.
- Use kmem_alloc().
 1.132  13-Jan-2009  yamt branches: 1.132.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.131  11-Jan-2009  cegger make this compile
 1.130  11-Jan-2009  christos merge christos-time_t
 1.129  28-Apr-2008  martin branches: 1.129.8; 1.129.10;
Remove clause 3 and 4 from TNF licenses
 1.128  21-Mar-2008  ad branches: 1.128.2; 1.128.4; 1.128.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.127  02-Feb-2008  hannken branches: 1.127.6;
ccdbuffer(): add missing initialization of new bufs b_objlock.
 1.126  02-Jan-2008  ad Merge vmlocking2 to head.
 1.125  05-Dec-2007  ad branches: 1.125.4;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.124  26-Nov-2007  pooka branches: 1.124.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.123  08-Oct-2007  ad branches: 1.123.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.122  29-Jul-2007  ad branches: 1.122.4; 1.122.6; 1.122.8; 1.122.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.121  09-Jul-2007  ad branches: 1.121.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.120  26-Jun-2007  cube Change dk_lookup() to accept an additional argument of the type enum uio_seg
that tells whether the given path is in user space or kernel space, so it
can tell NDINIT().

While the raidframe calls were ok, both ccd(4) and cgd(4) were passing
pointers to user space data, which leads to strange error on i386, as
reported by Jukka Salmi on current-users.

The issue has been there since last august, I'm actually a bit surprised
that no one in the meantime has used ccd(4) or cgd(4) on an arch where it
would have simply faulted.
 1.119  12-Mar-2007  ad branches: 1.119.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.118  04-Mar-2007  christos branches: 1.118.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.117  15-Feb-2007  ad branches: 1.117.2;
Replace some uses of lockmgr() / simplelocks.
 1.116  16-Nov-2006  christos branches: 1.116.2; 1.116.4;
__unused removal on arguments; approved by core.
 1.115  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.114  29-Sep-2006  christos Coverity CID 3801: Plug memory leak (from Arnaud Lacombe)
 1.113  27-Aug-2006  christos branches: 1.113.2; 1.113.4;
Use dk_lookup.
 1.112  21-Jul-2006  ad - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.111  12-Jun-2006  christos don't allocate > 1K on the stack.
 1.110  14-May-2006  elad branches: 1.110.2;
integrate kauth.
 1.109  24-Apr-2006  jld Make ccdioctl work without a process context; fixes xbdback-on-ccd.
Run by tech-kern on 2006-04-24; with approval and advice from wrstuden@.
 1.108  16-Feb-2006  lukem branches: 1.108.2; 1.108.4; 1.108.6;
* The kernel's struct ccd_softc has extra structure members over the
userland version; provide another ccd global variable (ccd_softc_elemsize)
containing the kernel's size, and use that it ccdconfig(8) to convert the
kernel's ccd_softc into userland versions.
Fixes 'ccdconfig -g'.
* Use DISKUNIT() instead of home-grown cruft to determine the `N' of "ccdN".
Fixes 'ccdconfig -g ccd1'.
* Use (void *) instead of (char *) in the calls to kvm_read().

XXX: ccd could be converted from nlist to sysctl. "Someone else's yak shave".
 1.107  11-Dec-2005  christos branches: 1.107.2; 1.107.4; 1.107.6;
merge ktrace-lwp.
 1.106  15-Oct-2005  yamt - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
from sys/bufq.h to sys/bufq_impl.h.
(is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c. (not tested)
 1.105  20-Aug-2005  yamt use pseudo_disk_{init,attach,detach} where appropriate.
 1.104  22-May-2005  christos branches: 1.104.2;
No 0x in front of %p...
 1.103  31-Mar-2005  yamt introduce a function to drain bufq and use it where appropriate.
 1.102  27-Feb-2005  perry branches: 1.102.2;
nuke trailing whitespace
 1.101  28-Oct-2004  yamt branches: 1.101.4; 1.101.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.100  26-Oct-2004  thorpej Implement the DIOCCACHESYNC ioctl; we simply pass it through to each
underlying component.
 1.99  18-Sep-2004  yamt change some members of struct buf from long to int.
ride on 2.0H.
 1.98  23-Aug-2004  thorpej Remove a comment that doesn't really make sense.
 1.97  23-Aug-2004  thorpej Use ANSI function decls and more use of static.
 1.96  21-Apr-2004  itojun kill sprintf, use snprintf
 1.95  25-Jan-2004  hannken Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.

VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp) Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp) Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
 1.94  10-Jan-2004  yamt store a i/o priority hint in struct buf for buffer queue discipline.
 1.93  26-Oct-2003  chs don't print an uninitialized variable.
 1.92  17-Oct-2003  lukem Add user flag CCDF_NOLABEL to prevent the on-disk label from being read
during CCDIOCSET.
Use this when creating a new ccd to ignore any existing disklabel
which is probably wrong.
 1.91  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.90  29-Jun-2003  fvdl branches: 1.90.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.89  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.88  17-May-2003  thorpej Use a buffer queue. Primary advantage here is robustness in the face
of temporary resource shortages.
 1.87  17-May-2003  thorpej Add DIOCKLABEL support. Fixes PR kern/21605 (Luke Mewburn).
 1.86  10-May-2003  thorpej Change bounds_check_with_label() to take a pointer to the disk structure,
rather than the label itself. This paves the way for some future changes.
 1.85  02-May-2003  dsl Change return type of readdisklabel() to const char *
I hope I've found all the correct places!
 1.84  21-Mar-2003  dsl Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
 1.83  25-Feb-2003  thorpej Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.
 1.82  05-Feb-2003  pk Make the buffer cache code MP-safe.
 1.81  25-Jan-2003  kleink Fix further printf format warnings for DEBUG, in the wake of daddr_t
having changed.
 1.80  01-Nov-2002  mrg implement separate read/write disk statistics:
- disk_unbusy() gets a new parameter to tell the IO direction.
- struct disk_sysctl gets 4 new members for read/write bytes/transfers.
when processing hw.diskstats, add the read&write bytes/transfers for
the old combined stats to attempt to keep backwards compatibility.

unfortunately, due to multiple bugs, this will cause new kernels and old
vmstat/iostat/systat programs to fail. however, the next time this is
change it will not fail again.

this is just the kernel portion.
 1.79  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.78  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.77  01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.76  08-Mar-2002  thorpej branches: 1.76.6;
Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map). Try to deal with this:

* Group all information about the backend allocator for a pool in a
separate structure. The pool references this structure, rather than
the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
to become available, but will still fail if it cannot callocate KVA
space for the pages. If this happens, carefully drain all pools using
the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
some pages, and use that information to make draining easier and more
efficient.
* Get rid of PR_URGENT. There was only one use of it, and it could be
dealt with by the caller.

From art@openbsd.org.
 1.75  13-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.74  13-Nov-2001  lukem add RCSIDs
 1.73  05-Aug-2001  jdolecek branches: 1.73.2;
change ccio_ndisks and sc_nccdisks of struct ccd_ioctl from int to u_int
introduce hard limit on number of disks which can be contcatenated togetger,
CCD_MAXNDISKS
 1.72  07-Jul-2001  thorpej branches: 1.72.2;
bcopy -> memcpy
bzero -> memset
 1.71  08-Jan-2001  fvdl branches: 1.71.2;
Return error in the case of using ODIOCGDINFO or ODIOCGDEFLABEL when
the number of partitions is > OLDMAXPARTITIONS. This is better
than silently truncating the label (don't want to silently throw
away partitions when using an old disklabel binary on a label with
> 8 partitions). From Enami Tsugutomo.
 1.70  07-Jan-2001  fvdl Adapt all disk devices in MI directories to handle ODIOC* calls
for ports that have bumped MAXPARTITIONS (and thus define
__HAVE_OLD_DISKLABEL).
 1.69  05-Apr-2000  enami branches: 1.69.4;
Introduce new filesystem type FS_CCD so that an operator can mark the
ccd component partition. Note that the ccd driver still allows partitions
of any types as components since an on-disk BSD disklabel isn't available
on some port.
 1.68  30-Mar-2000  augustss Remove register declarations.
 1.67  16-Mar-2000  enami On initialization failure, free all the storage allocated to store
component pathnames rather than the last one.
 1.66  08-Feb-2000  enami Since we now only allocate this one, no longer necessary to check and free().
 1.65  15-Nov-1999  fvdl Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O
 1.64  03-Nov-1999  chs from jason:
avoid biodone()ing the original buf twice when a component buf
gets an error. fixes PR 8704.
 1.63  11-Aug-1999  thorpej branches: 1.63.2; 1.63.4; 1.63.6;
We really only need *one* componenet buffer pool...
 1.62  04-Mar-1999  mjacob branches: 1.62.2;
a kindler gentler fix
 1.61  04-Mar-1999  mjacob adjust format args for compiler changes
 1.60  12-Feb-1999  thorpej Fix some printf format problems on Alpha.
 1.59  21-Jan-1999  thorpej Fix a st00p1d bug I introduced in rev 1.57, which would cause any activity
on non-0 CCD units to crash the system.
 1.58  12-Jan-1999  christos Make this compile again with -DDEBUG
 1.57  12-Jan-1999  thorpej Whole lotta cleanup wrt. how configuration data is stored internally, and
just lockmgr(), not our home-grown locking functions.
 1.56  13-Nov-1998  thorpej Handle the case where ccdbuffer() fails due to memory shortage. Build
a fifo of component buffers, and free them if ccdbuffer() fails. Once
all component buffers are build, run through the fifo and fire off the
requests to the components.
 1.55  13-Nov-1998  thorpej Simplify calling of ccdbuffer() now that the mirroring code is nuked.
 1.54  13-Nov-1998  thorpej Return EINVAL if invalid flags are passed.
 1.53  13-Nov-1998  thorpej Nuke the mirroring code. RAIDframe is about to go in, and is a much
better mirroring solution.

The ccd driver will stay, even in the presence of RAIDframe, for applications
where just RAID-0 is needed (much smaller code footprint).
 1.52  12-Nov-1998  thorpej Must use PR_NOWAIT when allocating component buffers.
 1.51  31-Jul-1998  thorpej Use the pool allocator for component buffer headers.
 1.50  09-Jul-1998  thorpej branches: 1.50.2;
Fix int32_t overflow with large serially concatenated components,
from Noriyuki SODA <soda@sra.co.jp>, PR #5729.
 1.49  01-Mar-1998  ross Sweep up some miscellaneous leftover lite2 integration shrapnel.
 1.48  22-Feb-1998  enami Fix message printed in case (b) in last commit; what actually shouldn't
exceeds is not a size of partition but end of partition.
 1.47  22-Feb-1998  enami Check disklabel just read from disk and warn if:
(a) total sector size is different from the size of ccd, or
(b) size of a partition exceeds the size of ccd.
 1.46  06-Feb-1998  thorpej Allow a ccd component to be on any partition type.
 1.45  09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.44  08-Oct-1997  thorpej Implement DIOCGDEFLABEL.
 1.43  04-Aug-1997  fair %x -> 0x%x
 1.42  26-Jun-1997  kleink branches: 1.42.4;
Leftover from last commit: require us to be initialized when a DIOCGDINFO
ioctl(2) is issued; the uninitialized disklabel pointer might get dereferenced
otherwise.
 1.41  26-Jun-1997  thorpej In ccdioctl(), consolidate checks for "open for writes" and "initialized".
 1.40  23-Jun-1997  thorpej Two changes to ccdsize():
- If the partition was previously open, don't do the open/close steps.
(Sync with other disk drivers.)
- foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
 1.39  12-Mar-1997  mycroft Remove bogus use of splhigh(), and apparently unneeded bzero().
 1.38  30-Jan-1997  thorpej A performance optimization, inspired by a conversation with Thor Simon:

- Keep a freelist of component buffer headers, defaulting
to 8 headers per component (tunable with the CCDNBUF
kernel compile option).
- When allocating a component buffer, try to pull a header
off the freelist first, falling back on MALLOC() if the
freelist is empty. Use MALLOC() rather than malloc(),
because it will attempt to short-cut the allocation before
actually making a full-blown malloc() call.
- Keep statistics on how many component buffer headers have
been allocated and how many of those allocations have
resulted in freelist misses.

With these changes, I observed measurable decreases in system and
wall clock time on operations on an 8G ccd, as well as a measurable
drop in the time spent in ccdbuffer() (measured with kernel profiling).
 1.37  30-Jan-1997  thorpej Fix OBOB in ccdopen() partition range check.
From Klaus Klein <kleink@layla.inka.de>, PR #3161.
 1.36  18-Dec-1996  thorpej Compute the componet number properly so that error reporting is somewhat
meaningful. Bug noticed by Marshall Midden <m4@nts.umn.edu>.
 1.35  13-Oct-1996  christos backout kprintf changes
 1.34  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.33  05-May-1996  thorpej Fix bogus return value in ccdopen(); it failed to indicate an error
condition if:
- ccd was not initialized
- partition did not exist
 1.32  22-Apr-1996  christos remove sys/cpu.h
 1.31  30-Mar-1996  christos Remove dependencies to dev_conf.h and the file itself.
 1.30  24-Mar-1996  mrg %d -> %ld in a few places...
 1.29  07-Mar-1996  christos prototypes for ccd audio and ncr5380
 1.28  28-Feb-1996  thorpej Copyright assigned to The NetBSD Foundation.
 1.27  11-Feb-1996  thorpej Avoid deref'ing a bad pointer in ccdopen(). This could happen if
any partition other than RAW_PART is opened before configuring the
ccd. Bug pointed out by Matthew Green.
 1.26  10-Feb-1996  hpeyerl detatch this spelling mistake from this source file.
 1.25  06-Feb-1996  thorpej Fix typo, from Thorsten Frueauf <frueauf@ira.uka.de>.
 1.24  01-Feb-1996  thorpej Add experimental data mirroring support, derived from code written by
Satoshi Asami and Nisha Talagala. For details on using data mirroring,
see the ccd(4) manual page.
 1.23  07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.22  08-Dec-1995  thorpej When unconfiguring a ccd, only free as many interleave indices as
were allocated, which may not be the same as the number of components
in the ccd. From Don Lewis <gdonl@gv.ssi1.com>. Fixes PR #1820.
 1.21  06-Nov-1995  thorpej Fix a race condition where if a process is asleep waiting on an
exclusive lock of a ccd device while another process is unconfiguring
that same device, the first process would never awaken (unless interrupted).
 1.20  03-Nov-1995  thorpej In ccdstart(), only translate the block number from partition-relative
to absolute if part != RAW_PART.
 1.19  12-Oct-1995  thorpej Fix bad pointer deref, memory leak, and geometry calculation, pointed
out by Jochen Pohl in PR #1588. Change the interleave index to an
array of ints rather than an array of chars to avoid losing in the event
one has more than 127 components.
 1.18  09-Oct-1995  thorpej branches: 1.18.2;
Batting 1.000: fix a potential panic situation in ccdioctl() that can occur
if ccdinit() fails.
 1.17  09-Oct-1995  thorpej Fix up a couple of comments.
 1.16  09-Oct-1995  thorpej Add the partition offset to the block number in ccdstart() as opposed
to ccdstrategy(), and do it in a way that doesn't corrupt the block number
for residuals. (What was I _thinking_?!)
 1.15  09-Oct-1995  thorpej Implement a simple locking mechanism and use it, for sanity's sake.
In ccdopen(), don't update the disklabel if any partition is already open.
Prevents race bewteen ccdstrategy() and ccdgetdisklabel().
 1.14  06-Sep-1995  thorpej Fix misplaced #ifdef.
 1.13  29-Aug-1995  thorpej Wrap dk stats stuff in `#ifdef WORKING_DISK_STATISTICS'. Takes care
of PR #1388 until such time as dk stats works on all ports. XXX !!
 1.12  21-Aug-1995  thorpej Fix typo, pointed out by cross@va.pubnix.com (Chris P. Ross).
 1.11  17-Aug-1995  thorpej New version of ccd. Allows dynamic run-time configuration and
unconfiguration and supports disklabels.
 1.10  04-Jul-1995  mycroft Make each disk and tape driver define its own read and write functions.
Deprecate rawread() and rawwrite() completely. Remove d_strategy from cdevsw to
force the abstraction barrier.
 1.9  26-Jun-1995  cgd make dump stubs consistent
 1.8  09-Mar-1995  cgd spaces -> tab
 1.7  02-Mar-1995  cgd from jason thorpe: add ccdclose(), make it work with the MI scsi code,
and add knowledge of i386 disk device names (XXX).
 1.6  02-Mar-1995  cgd don't overload buffer structs; allocate and use a 'super-struct' instead.
 1.5  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.4  14-Aug-1994  mycroft ccdevsw --> cdevsw
 1.3  02-Jul-1994  hpeyerl branches: 1.3.2;
These should have been the 4.4Lite versions. duh.
 1.2  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.1  24-Jun-1994  hpeyerl Concat disk driver moved from hp300/dev to here.
 1.3.2.1  14-Aug-1994  mycroft update from trunk
 1.18.2.2  03-Nov-1995  thorpej Update from trunk; don't translate block number if part != RAW_PART.
 1.18.2.1  12-Oct-1995  thorpej Update from trunk: Fix bad pointer deref, memory leak, and geometry
calculation, pointed out by Jochen Pohl in PR #1588. Change the interleave
index to an array of ints rather than an array of chars to avoid losing in
the event one has more than 127 components.
 1.42.4.2  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.42.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.50.2.1  08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.62.2.1  05-Nov-1999  cgd pull up rev 1.64 from trunk (requested by chs):
Fix a dobule-biodone() panic when ccd component buffers have errors.
 1.63.6.2  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.63.6.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.63.4.2  15-Nov-1999  fvdl Sync with -current
 1.63.4.1  19-Oct-1999  fvdl Bring in Kirk McKusick's FFS softdep code on a branch.
 1.63.2.2  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.63.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.69.4.2  16-Aug-2001  tv Pullup [jdolecek]:

sys/dev/ccd.c 1.73
sys/dev/ccdvar.h 1.20

Provide hard limit on the number of concatenated disks, and bounds
check against that limit.
 1.69.4.1  01-May-2001  he Pull up revisions 1.70-1.71 (requested by fvdl):
Increase the number of BSD disklabel partitions on i386 to 16.
 1.71.2.9  11-Nov-2002  nathanw Catch up to -current
 1.71.2.8  17-Sep-2002  nathanw Catch up to -current.
 1.71.2.7  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.71.2.6  20-Jun-2002  nathanw Catch up to -current.
 1.71.2.5  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.71.2.4  28-Feb-2002  nathanw Catch up to -current.
 1.71.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.71.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.71.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.72.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.72.2.5  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.72.2.4  16-Mar-2002  jdolecek Catch up with -current.
 1.72.2.3  11-Feb-2002  jdolecek Sync w/ -current.
 1.72.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.72.2.1  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.73.2.3  01-Oct-2001  fvdl Catch up with -current.
 1.73.2.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.73.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.76.6.2  20-Jun-2002  gehenna catch up with -current.
 1.76.6.1  16-May-2002  gehenna Add the block/character device switches.
 1.90.2.10  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.90.2.9  01-Apr-2005  skrll Sync with HEAD.
 1.90.2.8  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.90.2.7  02-Nov-2004  skrll Sync with HEAD.
 1.90.2.6  24-Sep-2004  skrll Sync with HEAD.
 1.90.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.90.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.90.2.3  25-Aug-2004  skrll Sync with HEAD.
 1.90.2.2  03-Aug-2004  skrll Sync with HEAD
 1.90.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.101.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.101.4.1  29-Apr-2005  kent sync with -current
 1.102.2.2  20-Feb-2006  tron Pull up following revision(s) (requested by lukem in ticket #1178):
sys/dev/ccd.c: revision 1.108
sbin/ccdconfig/ccdconfig.c: revision 1.42
* The kernel's struct ccd_softc has extra structure members over the
userland version; provide another ccd global variable (ccd_softc_elemsize)
containing the kernel's size, and use that it ccdconfig(8) to convert the
kernel's ccd_softc into userland versions.
Fixes 'ccdconfig -g'.
* Use DISKUNIT() instead of home-grown cruft to determine the `N' of "ccdN".
Fixes 'ccdconfig -g ccd1'.
* Use (void *) instead of (char *) in the calls to kvm_read().
XXX: ccd could be converted from nlist to sysctl. "Someone else's yak shave".
 1.102.2.1  06-Apr-2005  tron Pull up revision 1.103 (requested by yamt in ticket #112):
introduce a function to drain bufq and use it where appropriate.
 1.104.2.9  24-Mar-2008  yamt sync with head.
 1.104.2.8  04-Feb-2008  yamt sync with head.
 1.104.2.7  21-Jan-2008  yamt sync with head
 1.104.2.6  07-Dec-2007  yamt sync with head
 1.104.2.5  27-Oct-2007  yamt sync with head.
 1.104.2.4  03-Sep-2007  yamt sync with head.
 1.104.2.3  26-Feb-2007  yamt sync with head.
 1.104.2.2  30-Dec-2006  yamt sync with head.
 1.104.2.1  21-Jun-2006  yamt sync with head.
 1.107.6.2  01-Jun-2006  kardel Sync with head.
 1.107.6.1  22-Apr-2006  simonb Sync with head.
 1.107.4.1  09-Sep-2006  rpaulo sync with head
 1.107.2.1  18-Feb-2006  yamt sync with head.
 1.108.6.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.108.4.4  12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.108.4.3  11-May-2006  elad sync with head
 1.108.4.2  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.108.4.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.108.2.4  03-Sep-2006  yamt sync with head.
 1.108.2.3  11-Aug-2006  yamt sync with head
 1.108.2.2  26-Jun-2006  yamt sync with head.
 1.108.2.1  24-May-2006  yamt sync with head.
 1.110.2.1  19-Jun-2006  chap Sync with head.
 1.113.4.2  10-Dec-2006  yamt sync with head.
 1.113.4.1  22-Oct-2006  yamt sync with head
 1.113.2.1  18-Nov-2006  ad Sync with head.
 1.116.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.116.2.1  01-Jul-2007  bouyer Pull up following revision(s) (requested by cube in ticket #748):
sys/dev/dksubr.c: revision 1.29
sys/dev/ccd.c: revision 1.120
sys/dev/raidframe/rf_disks.c: revision 1.66
sys/dev/raidframe/rf_reconstruct.c: revision 1.96
sys/dev/cgd.c: revision 1.45
sys/dev/dkvar.h: revision 1.11
sys/dev/raidframe/rf_copyback.c: revision 1.38
Change dk_lookup() to accept an additional argument of the type enum uio_seg
that tells whether the given path is in user space or kernel space, so it
can tell NDINIT().
While the raidframe calls were ok, both ccd(4) and cgd(4) were passing
pointers to user space data, which leads to strange error on i386, as
reported by Jukka Salmi on current-users.
 1.117.2.2  24-Mar-2007  yamt sync with head.
 1.117.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.118.2.8  24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.118.2.7  20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.118.2.6  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.118.2.5  15-Jul-2007  ad Sync with head.
 1.118.2.4  17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.118.2.3  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.118.2.2  13-Apr-2007  ad - Make the devsw interface MP safe, and add some comments.
- Allow individual block/character drivers to be marked MP safe.
- Provide wrappers around the device methods that look up the
device, returning ENXIO if it's not found, and acquire the
kernel lock if needed.
 1.118.2.1  13-Mar-2007  ad Sync with head.
 1.119.2.1  11-Jul-2007  mjf Sync with head.
 1.121.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.122.10.2  29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.122.10.1  29-Jul-2007  ad file ccd.c was added on branch matt-mips64 on 2007-07-29 12:50:18 +0000
 1.122.8.1  14-Oct-2007  yamt sync with head.
 1.122.6.3  23-Mar-2008  matt sync with HEAD
 1.122.6.2  09-Jan-2008  matt sync with HEAD
 1.122.6.1  06-Nov-2007  matt sync with HEAD
 1.122.4.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.122.4.2  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.122.4.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.123.4.2  18-Feb-2008  mjf Sync with HEAD.
 1.123.4.1  08-Dec-2007  mjf Sync with HEAD.
 1.124.2.2  08-Dec-2007  ad Sync with head.
 1.124.2.1  04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.125.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.127.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.127.6.3  02-Jun-2008  mjf Sync with HEAD.
 1.127.6.2  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.127.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.128.6.3  20-Jun-2009  yamt sync with head
 1.128.6.2  04-May-2009  yamt sync with head.
 1.128.6.1  16-May-2008  yamt sync with head.
 1.128.4.1  18-May-2008  yamt sync with head.
 1.128.2.2  01-Nov-2008  christos Sync with head.
 1.128.2.1  29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.129.10.2  27-Aug-2014  msaitoh Pull up following revision(s) (requested by sborrill in ticket #1919):
sbin/ccdconfig/ccdconfig.c 1.54 via patch
sys/dev/ccd.c 1.152 via patch
sys/dev/ccdvar.h 1.34 via patch

Switch size_t to uint64_t in appropriate places to ensure that ccd(4)
works with component and total sizes of > 2TB.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
 1.129.10.1  04-Apr-2009  snj Pull up following revision(s) (requested by ad in ticket #658):
sys/dev/ccd.c: revision 1.133 via patch
sys/dev/ccdvar.h: revision 1.31
Fix problems with ccd:
- Pending async I/O was tossed on unconfigure (should not happen, but..)
- It could exhaust memory under heavy I/O load.
- If memory allocation failed, disk transfers could stall.
- v_numoutput was updated without v_interlock held.
Additionally:
- Make it MPSAFE.
- Use kmem_alloc().
 1.129.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.129.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.132.2.2  23-Jul-2009  jym Sync with HEAD.
 1.132.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.134.4.2  05-Mar-2011  rmind sync with head
 1.134.4.1  16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.137.4.1  17-Feb-2011  bouyer Sync with HEAD
 1.137.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.138.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.142.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.142.2.1  17-Apr-2012  yamt sync with head
 1.143.10.4  03-Dec-2017  jdolecek update from HEAD
 1.143.10.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.143.10.2  23-Jun-2013  tls resync from head
 1.143.10.1  02-Dec-2012  tls Don't pass NULL struct dkdriver to disk_init. That's seriously bogus.
 1.143.6.1  27-Aug-2014  msaitoh Pull up following revision(s) (requested by sborrill in ticket #1113):
sbin/ccdconfig/ccdconfig.c 1.54 via patch
sys/dev/ccd.c 1.152 via patch
sys/dev/ccdvar.h 1.34 via patch

Switch size_t to uint64_t in appropriate places to ensure that ccd(4)
works with component and total sizes of > 2TB.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
 1.144.4.1  18-May-2014  rmind sync with head
 1.147.2.1  10-Aug-2014  tls Rebase.
 1.151.2.3  31-Jul-2015  snj Pull up following revision(s) (requested by christos in ticket #924):
sys/dev/ccd.c: revision 1.163
initialized sc_unit (from Riastradh)
XXX: pullup-7
 1.151.2.2  11-Nov-2014  martin Pull up following revision(s) (requested by mlelstv in ticket #202):
sys/dev/ccd.c: revision 1.153
sys/dev/ccd.c: revision 1.154
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.313
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.314
sys/dev/ld.c: revision 1.77
sys/dev/vnd.c: revision 1.233
sys/dev/dksubr.c: revision 1.52
sys/dev/dksubr.c: revision 1.53
clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.
No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.
 1.151.2.1  18-Aug-2014  martin Pull up following revision(s) (requested by sborrill in ticket #38):
sys/dev/ccd.c: revision 1.152
sbin/ccdconfig/ccdconfig.c: revision 1.54
sbin/ccdconfig/ccdconfig.c: revision 1.55
sys/dev/ccdvar.h: revision 1.34
Switch size_t to uint64_t in appropriate places to ensure that ccd(4) works
with component and total sizes of > 2TB.
Add COMPAT_60 code for platforms where this alters userland-accessible
structures.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
Don't print ccd_size with %zu; it no longer has type size_t.
Instead, cast to uintmax_t and print with %ju.
 1.154.2.6  28-Aug-2017  skrll Sync with HEAD
 1.154.2.5  05-Dec-2016  skrll Sync with HEAD
 1.154.2.4  05-Oct-2016  skrll Sync with HEAD
 1.154.2.3  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.154.2.2  22-Sep-2015  skrll Sync with HEAD
 1.154.2.1  06-Apr-2015  skrll Sync with HEAD
 1.166.2.3  26-Apr-2017  pgoyette Sync with HEAD
 1.166.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.166.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.168.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.171.4.2  29-Apr-2017  pgoyette Remove explicit inclusion of <sys/localcount.h> since there is no
explicit usage of localcounts here. <sys/conf.h> will take care of
including as needed.
 1.171.4.1  29-Apr-2017  pgoyette Add DEVSW_MODULE_INIT to existing device-driver modules, so that they
willl have a localcount defined and thus be permitted to load. Without
a localcount, loading the module will return EINVAL.

XXX the dtrace and drm stuff might need to be fed back upstream?
 1.172.2.1  05-Apr-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1223):
sys/sys/dkio.h: revision 1.25
sys/kern/subr_disk.c: revision 1.123
sys/dev/dksubr.c: revision 1.107
sys/dev/ccd.c: revision 1.179
sys/dev/ofw/ofdisk.c: revision 1.53
Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).
 1.175.2.12  22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.175.2.11  18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.175.2.10  14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.175.2.9  13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.175.2.8  29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.175.2.7  18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.175.2.6  18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.175.2.5  16-Sep-2018  pgoyette Yay - we got the ccd_ioctl_60 stuff to build!

Now we can use that as a template for cleaning up all the others.
 1.175.2.4  23-Mar-2018  pgoyette Remove definition of compat_ccd_ioctl_60() - this is now defined in
sys/kern/compat_stub.c (sync/merge botch)
 1.175.2.3  22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.175.2.2  20-Mar-2018  pgoyette Initial implementation of sys/kern/kern_stup.c as discussed on tech-kern

For now, we only handle the dev/ccd and NTP needs; more to follow.
 1.175.2.1  18-Mar-2018  pgoyette Import compat_60 changes for dev/ccd
 1.176.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.176.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.176.2.1  10-Jun-2019  christos Sync with HEAD
 1.179.4.1  11-Oct-2020  martin Pull up following revision(s) (requested by mlelstv in ticket #1110):

sys/dev/dkwedge/dk.c: revision 1.102
sys/dev/ccd.c: revision 1.185
sbin/ccdconfig/ccdconfig.c: revision 1.58

Use raw device for configuring units. This is necessary as
having a block device opened prevents autodiscovery of wedges.

Fix ioctl locking. Add dkdriver.

Check dkdriver before calling a driver function.
 1.189.4.1  18-Apr-2024  martin Pull up following revision(s) (requested by hannken in ticket #669):

sys/dev/ccd.c: revision 1.190

Using a ccd(4) with GPT (dk* at ccd*) the disk framework will call
ccdstrategy() -> ccdstart() -> ccdbuffer() from softint context.

Allocating the buffer with PR_WAITOK here is forbidden.

Change ccdstart() / ccdbuffer() to report failure back to caller and
pass PR_WAITOK / PR_NOWAIT as an additional argument.

Call ccdstart() with PR_NOPWAIT from ccdstrategy() and on error defer
to the kthread. Call ccdstart() with PR_WAITOK from kthread so requests
from kthread always succeed to allocate the buffers.

Remove the (non working) throttling on low memory as it is no longer needed.

Fixes PR kern/58043 "kernel crash in assert_sleepable() in -current,
dk(4) driver?"
 1.191.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed