History log of /netbsd-current/sys/dev/dksubr.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.114 11-Jul-2023 christos

Move the rnd_add_uint32 outside the lock and get rid of dk_done1() suggested
by riastradh@


Revision tags: netbsd-10-base bouyer-sunxi-drm-base thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base
# 1.113 15-Apr-2021 rin

dk_start(): retry device-dependent start() routine later, also when it
returns ENOMEM in addition to EAGAIN.

Device-dependent start() routine may allocate buffer directly, or via
bus_dma(9) API (some implementations for bus_dma(9) like alpha allocate
memory internally).

If these attempts fail with ENOMEM, this is not a disk error, therefore
we must retry later, as already done for EAGAIN.


Revision tags: thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406
# 1.112 01-Mar-2020 riastradh

branches: 1.112.8;
Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.111 08-Dec-2019 mlelstv

Drop now unused dk_lookup function.


Revision tags: phil-wifi-20191119
# 1.110 05-Oct-2019 mlelstv

Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.109 28-Jun-2019 jmcneill

branches: 1.109.2;
Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.113 15-Apr-2021 rin

dk_start(): retry device-dependent start() routine later, also when it
returns ENOMEM in addition to EAGAIN.

Device-dependent start() routine may allocate buffer directly, or via
bus_dma(9) API (some implementations for bus_dma(9) like alpha allocate
memory internally).

If these attempts fail with ENOMEM, this is not a disk error, therefore
we must retry later, as already done for EAGAIN.


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406
# 1.112 01-Mar-2020 riastradh

Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.111 08-Dec-2019 mlelstv

Drop now unused dk_lookup function.


Revision tags: phil-wifi-20191119
# 1.110 05-Oct-2019 mlelstv

Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.109 28-Jun-2019 jmcneill

branches: 1.109.2;
Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.112 01-Mar-2020 riastradh

Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.111 08-Dec-2019 mlelstv

Drop now unused dk_lookup function.


Revision tags: phil-wifi-20191119
# 1.110 05-Oct-2019 mlelstv

Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.109 28-Jun-2019 jmcneill

Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.111 08-Dec-2019 mlelstv

Drop now unused dk_lookup function.


Revision tags: phil-wifi-20191119
# 1.110 05-Oct-2019 mlelstv

Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.109 28-Jun-2019 jmcneill

Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.110 05-Oct-2019 mlelstv

Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


Revision tags: netbsd-9-base
# 1.109 28-Jun-2019 jmcneill

Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.109 28-Jun-2019 jmcneill

Store a reference to the CPU that submitted the I/O request with the
request itself.


Revision tags: phil-wifi-20190609
# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

branches: 1.102.2;
Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.108 21-Apr-2019 maya

wether -> whether


Revision tags: isaki-audio2-base
# 1.107 27-Mar-2019 martin

Add a disk ioctl DIOCRMWEDGES to remove all wedges of a given disk
(if not busy).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.106 07-Jan-2019 jdolecek

fix the disklabel sanity check coversion for case when both disklabel
and disk geometry are > DEV_BSIZE, such as fictitious cd(4) disklabel

still part of PR kern/53833


# 1.105 07-Jan-2019 jdolecek

convert the sector counts for label sanity checks to use same unit (DEV_BSIZE),
so that the check is meaningful if disklabel sector size and disk geometry
sector size differ - for example 512 disklabel vs 2048 for sparc cd(4)

conversion assumes that the sector sizes are multiples of DEV_BSIZE (512)

fixes kern/53833 by Andreas Gustafsson

Note: the checks are executed #ifdef DIAGNOSTIC, that's why nothing
is printed by 8.0 kernel, or anything built from release branches


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.104 24-Nov-2018 bouyer

rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.103 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.102 12-May-2018 mlelstv

Support dump on wedges.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.101 04-Dec-2017 jdolecek

branches: 1.101.2;
add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.101 04-Dec-2017 jdolecek

add KASSERT() just before setting sc_deferred, to ensure this does
not trigger problem in PR kern/52769


Revision tags: tls-maxphys-base-20171202
# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.100 29-Oct-2017 mlelstv

Use driver specific label code as fallback. This fixes the UDF label for CDs.


Revision tags: nick-nhusb-base-20170825
# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

branches: 1.97.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.99 24-Aug-2017 maya

Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.

reported by: GCC, but with different compile flags


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.98 13-Aug-2017 mlelstv

validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1
# 1.97 27-Apr-2017 jdolecek

do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 05-Mar-2017 mlelstv

branches: 1.96.4;
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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.97 27-Apr-2017 jdolecek

do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.96 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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

branches: 1.94.2;
Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.96 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.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.95 25-Feb-2017 mlelstv

pacify disklabel validation message


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 22-Dec-2016 mlelstv

Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.


# 1.94 22-Dec-2016 mlelstv

Fix race condition in dksubr, where a dk_start from another thread
or interrupt was ignored while the queue was processed.

Bump kernel revision for changed dk_softc.


# 1.93 08-Dec-2016 mlelstv

invoke optional d_label callback to give the driver the possibility
to adjust the label with driver specific data.


Revision tags: nick-nhusb-base-20161204
# 1.92 28-Nov-2016 mlelstv

Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


Revision tags: pgoyette-localcount-20161104
# 1.91 24-Oct-2016 jdolecek

revert 1.90 of dksubr.c and change sc_deferred back to simple pointer; the
global sc_busy flag guards against race so it's not actually necessary, and
this place is unlikely to need to be parallelized in near future

discussed with mlelstv@


# 1.90 22-Oct-2016 jdolecek

change sc_deferred to TAILQ (reusing bufq b_actq) to avoid possible buf leak
for MPSAFE drivers


Revision tags: nick-nhusb-base-20161004
# 1.89 14-Sep-2016 mlelstv

Set b_resid in error path.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.88 27-Jun-2016 christos

branches: 1.88.2;
CID 1362902: forward null
CID 136290{3,4}: missing break


# 1.87 26-Jun-2016 mlelstv

Avoid NULL deref in case no bufq has been set.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.86 04-Jan-2016 mlelstv

erase dangling pointer to prevent reuse


Revision tags: nick-nhusb-base-20151226
# 1.85 21-Dec-2015 mlelstv

support deferral of diskstart to a separate thread.


# 1.84 21-Dec-2015 mlelstv

more sanity checks


# 1.83 08-Dec-2015 christos

Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.


# 1.82 28-Nov-2015 mlelstv

bounds check requires consistent units, i.e. DEV_BSIZE.


# 1.81 23-Oct-2015 christos

remove extra quote


# 1.80 23-Oct-2015 christos

fix this differently.


# 1.79 23-Oct-2015 knakahara

fix build failure on i386.


# 1.78 22-Oct-2015 christos

fix constant name


# 1.77 21-Oct-2015 christos

Fix dumping code (dk_dump):
- set DKF_TAKEDUMP on attach, otherwise we can never dump
- add DKF_DUMP debugging
- use __func__ instead of hard-coding names
- only allow dumps on swap partitions


Revision tags: nick-nhusb-base-20150921
# 1.76 28-Aug-2015 mlelstv

move entropy gathering into dksubr.


# 1.75 28-Aug-2015 mlelstv

Prevent race condition where two threads can defer a buffer.


# 1.74 27-Aug-2015 mlelstv

Make dksubr use a spin-mutex again, since some drivers still call dk_done
from hardware interrupt. Instead, release mutex while calling start routine.

The buffer peek/use/get sequence which can no longer be atomic. So consume
the buffer directly and on error privately save and retry the buffer later.
The dk_drain function is used to flush such a deferred buffer together with
the buffer queue.
Adjust drivers to use dk_drain.

Fix an error path where dk_done was called while the lock was already held.


# 1.73 23-Aug-2015 mlelstv

An adaptive mutex is sufficient, the data structures are accessed
by regular threads and by the biodone softint.

This allows diskstart routines to sleep (like cgd).


# 1.72 18-Aug-2015 mlelstv

only touch b_resid on error.


# 1.71 16-Aug-2015 mlelstv

Two changes to the dksubr interface.

- d_diskstart callback now processes a single buffer only.
The new wrapper function dk_start processes the queue,
performs other buffer handling and also provides locking
for the the data structures.

- add d_discard callback to handle device specific function inside
the new dk_discard helper function.

Replace splbio with mutex to protect queue and disk structure.
Refactor common code in dk_strategy and dk_discard into dk_translate.

Adjust and simplify ld(4), cgd(4) and xbd(4) drivers accordingly.

ld(4) now becomes MP_SAFE.

Bump kernel version.


# 1.70 16-Aug-2015 mlelstv

require write access to delete a wedge


# 1.69 16-Aug-2015 mlelstv

move FWRITE checks to a common place


# 1.68 02-Aug-2015 mlelstv

fix diskerr message, it needs the driver name, not the device unit name.


# 1.67 22-Jul-2015 skrll

Trailing whitespace.


# 1.66 19-Jul-2015 mlelstv

Handle non-DEV_BSIZE sectors.


# 1.65 12-Jul-2015 mlelstv

remove duplicate variable initializations.


# 1.64 11-Jul-2015 mlelstv

Mark disklabel only invalid on the last close. Existing openers might see
temporarily invalid data while it is re-read.


Revision tags: nick-nhusb-base-20150606
# 1.63 09-May-2015 christos

CID 1297229: use strlcpy


# 1.62 09-May-2015 mlelstv

CID 1297229: Memory - illegal accesses (BUFFER_SIZE_WARNING)


# 1.61 05-May-2015 mlelstv

warn about labels only when built with DIAGNOSTIC


# 1.60 02-May-2015 mlelstv

Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.

bump kernel version to 7.99.14


# 1.59 01-May-2015 mlelstv

correctly return -1 on error in dk_size


Revision tags: nick-nhusb-base-20150406
# 1.58 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.57 31-Dec-2014 christos

Centralize wedge ioctls in disk_ioctl.


# 1.56 29-Dec-2014 mlelstv

Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.


# 1.55 29-Dec-2014 mlelstv

align dk_strategy with checks from ld.c


Revision tags: nick-nhusb-base
# 1.54 04-Nov-2014 mlelstv

branches: 1.54.2;
support DIOCMWEDGES ioctl.


# 1.53 11-Oct-2014 mlelstv

No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.


# 1.52 11-Oct-2014 mlelstv

clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.51 14-Jun-2014 hannken

branches: 1.51.2;
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.50 25-May-2014 bouyer

As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.49 28-Dec-2013 pgoyette

branches: 1.49.2;
Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.48 29-May-2013 christos

branches: 1.48.2;
eliminate sc_size and fix printf formats


# 1.47 29-May-2013 christos

eliminate dk_geom


# 1.46 29-May-2013 christos

phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10
# 1.45 29-May-2012 elric

branches: 1.45.2;
Fix 32/64 bit int truncation issue.


# 1.44 25-May-2012 elric

Revert a few lines of accidental commit.


# 1.43 25-May-2012 elric

Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework. And call this new functionality from cgd(4),
the consumer of dksubr.c. We do this to allow gpt(8) to be able
to label cgd(4) disks. We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.42 19-Nov-2010 dholland

branches: 1.42.8; 1.42.12; 1.42.14;
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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.41 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.40 13-Jan-2009 yamt

branches: 1.40.4; 1.40.6;
g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.39 11-Jan-2009 cegger

make this compile


# 1.38 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base christos-time_t-base
# 1.37 28-Apr-2008 martin

branches: 1.37.8;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.36 05-Apr-2008 cegger

branches: 1.36.2; 1.36.4;
Allow to pass device_xname() to dk_sc_init() without build error
OK joerg


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.35 21-Mar-2008 ad

branches: 1.35.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.34 30-Jan-2008 ad

branches: 1.34.6;
Remove code to prevent multiple open of block devices; it's no longer
needed.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-base jmcneill-pm-base
# 1.33 08-Dec-2007 pooka

Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase reinoud-bufcleanup-base
# 1.32 26-Nov-2007 pooka

branches: 1.32.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


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 1.31 29-Jul-2007 ad

branches: 1.31.4; 1.31.6; 1.31.12; 1.31.14;
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.30 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.29 26-Jun-2007 cube

branches: 1.29.2;
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.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.28 04-Mar-2007 christos

branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.27 16-Nov-2006 christos

branches: 1.27.2; 1.27.4; 1.27.8;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.26 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.25 04-Sep-2006 dan

branches: 1.25.2; 1.25.4;
typo in debug printf


Revision tags: yamt-pdpolicy-base8
# 1.24 27-Aug-2006 christos

Add horrible hack for wedges. Why is the block device of the wedges in use?


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.23 21-Jul-2006 ad

- Use the LWP cached credentials where sane.
- Minor cosmetic changes.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.22 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.21 26-Dec-2005 yamt

branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
- add ioctls to set/get disk bufq strategy.
- implement them for some drivers.


# 1.20 11-Dec-2005 rpaulo

More ktrace-lwp merge.


# 1.19 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.18 18-Oct-2005 yamt

dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it.


# 1.17 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.16 20-Aug-2005 yamt

add wedge support to xbd and cgd.


# 1.15 28-Jun-2005 drochner

branches: 1.15.2;
constification fallout


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.14 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.13 23-Aug-2004 thorpej

Sprinkle static in a few places.


# 1.12 19-Apr-2004 hannken

Redo dk_start(). If di->di_diskstart() runs synchronous its biodone() will
call dk_start() via dk_iodone() before the buffer gets removed from queue.

Approved by: Roland Dowdeswell <elric@netbsd.org>

Fixes PR #25240


Revision tags: netbsd-2-0-base
# 1.11 27-Mar-2004 elric

branches: 1.11.2;
Modified the dksubr routines to:

o expect the disk's start routine to return an int. If the
int is non-zero, we enqueue the request and try again
later.
o have a dk_start() routine which runs the request queue.
o have a dk_iodone() function which should be called by the
driver using the framwork from its iodone. dk_iodone will
retry the queue since presumably further progress may be
possible once a request is complete. It is required that
the underlying driver have the resources to keep at least
one transaction in flight at any time.

Modified cgd to:

o be able to keep one transaction in flight at any time
(almost) by keeping a buffer of size MAXPHYS in its softc
and use it.

We still need to make the cgd_cbufpool per device rather than global
and provide a low water mark for it.

Addresses PR: kern/24715
(at least according to the submitter.)


# 1.10 14-Jul-2003 lukem

add missing __KERNEL_RCSID()


# 1.9 29-Jun-2003 fvdl

branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.8 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.7 12-May-2003 atatat

make this compile again.


# 1.6 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.5 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.4 17-Dec-2002 elric

Memset disklabel area to zero before beginning when constructing default
labels. Problem noticed and tested by dan@.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.3 12-Oct-2002 elric

branches: 1.3.2;
We need to pass the dk_softc, not the osc.


# 1.2 09-Oct-2002 elric

We need to do biodone() if strategy is called on an unconfigured device.


# 1.1 04-Oct-2002 elric

A slight abstraction for disks. This is mainly [right now] in
support of the cryptographic disk which I'll be checking in shortly.