Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/ldvar.h
RevisionDateAuthorComments
 1.37  13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.36  27-Feb-2025  jakllsch Implement DIOCGSECTORALIGN for ld(4)
 1.35  30-May-2021  riastradh ld(4): Block requests while suspended until resumed.

Otherwise nothing stops us from continuing to feed I/O to the disk
controller when it expects that the queues are quiesced as it pokes
registers to change its power states. Fixes resume during disk
activity on my T480 with nvme.
 1.34  02-Aug-2020  riastradh branches: 1.34.6; 1.34.8;
Remove unnecessary wait in ldbegindetach.

Like disk_begindetach, ldbegindetach only commits to detaching but
doesn't wait for existing xfers to drain; it is up to the driver to
abort them, once we are committed, and then ldenddetach to wait for
them to drain.
 1.33  19-Mar-2019  mlelstv branches: 1.33.4;
Let backend provide a disk type. The information can be queried through
drvctl(4).
 1.32  20-Aug-2017  mlelstv branches: 1.32.4;
make the sc_discard interface for the ld backend asynchronous and
signal completion through new callback lddiscardend. Use a standard
struct buf to pass disk address and range instead of two off_t values.

make lddiscard synchronous again. This is a requirement of the current
ffs discard code.
 1.31  09-Aug-2017  mlelstv While ld(4) is MP safe, many backends are not.

Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.

Fixes PR 52462.
 1.30  27-Apr-2017  jdolecek branches: 1.30.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
 1.29  27-Feb-2017  jdolecek branches: 1.29.4;
refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.28  16-Sep-2016  jdolecek branches: 1.28.2;
modify ldattach() to have default strategy as a parameter
 1.27  28-Aug-2015  mlelstv branches: 1.27.2;
move entropy gathering into dksubr.
 1.26  17-Aug-2015  jakllsch Add support for implementing discard functionality with ld(4)
 1.25  16-Aug-2015  mlelstv replace spl and tsleep with mutex and condvar.
 1.24  26-Jul-2015  skrll Whitespace
 1.23  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.22  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.21  03-May-2012  bsh branches: 1.21.2; 1.21.16;
use uint64_t for sc_disksize512.
fixed the problem with ataraid volumes larger than 2 TiB.
 1.20  02-Feb-2012  tls branches: 1.20.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.19  19-Nov-2011  tls branches: 1.19.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.18  20-Sep-2010  kiyohara branches: 1.18.8;
Check disk bounds, in RAW_PART.
 1.17  18-Dec-2009  jakllsch branches: 1.17.2; 1.17.4;
Use "rnd.h" and <sys/rnd.h> to ensure that struct ld_softc
is always of consistent layout. Should prevent another
someone from spending a few hours trying to figure out why
their code crashes because they didn't realize they needed
to have "rnd.h" included already.
 1.16  07-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.15  09-Sep-2008  tron branches: 1.15.8;
Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
 1.14  11-Aug-2008  simonb Add a flags argument to the ld(4) flush handlers, and call these with a
"poll" flag when called from ld_shutdown().

This is the infrastructure part of kern/38655 - in itself it doesn't
fix the panic referenced in that PR.

XXX: At least ld_twa.c and perhaps ld_iop.c and ld_icp.c need to
check for this new poll flag and do something useful.
 1.13  28-Apr-2008  martin branches: 1.13.2; 1.13.4; 1.13.6;
Remove clause 3 and 4 from TNF licenses
 1.12  09-Feb-2007  ad branches: 1.12.6; 1.12.40; 1.12.42; 1.12.44;
Merge newlock2 to head.
 1.11  11-Dec-2005  christos branches: 1.11.20;
merge ktrace-lwp.
 1.10  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.9  25-Sep-2004  thorpej branches: 1.9.12;
Add support for wedges to the logical disk driver.
 1.8  20-Jul-2004  dbj use uint64 instead of int for sc_secperunit
 1.7  17-May-2003  thorpej branches: 1.7.2; 1.7.4;
Add DIOCKLABEL support. Fixes PR kern/21605 (Luke Mewburn).
 1.6  20-Jul-2002  hannken Convert to new device buffer queue interface.
 1.5  10-Jun-2001  ad branches: 1.5.2; 1.5.8; 1.5.16;
Centralise the geometry fudge.
 1.4  04-Feb-2001  ad branches: 1.4.2;
Allow for draining/adjusting the queue.
 1.3  03-Jan-2001  ad Make dumps work, and put the first part of detach into ld.c.
 1.2  03-Dec-2000  ad branches: 1.2.2;
Make it possible to detach ld devices.
 1.1  26-Nov-2000  ad lsu -> ld, by popular request.
 1.2.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.3  05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2  08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1  03-Dec-2000  bouyer file ldvar.h was added on branch thorpej_scsipi on 2000-12-08 09:12:15 +0000
 1.4.2.2  01-Aug-2002  nathanw Catch up to -current.
 1.4.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.5.16.1  29-Aug-2002  gehenna catch up with -current.
 1.5.8.2  25-Oct-2001  he Pull up revisions 1.1-1.5 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.5.8.1  10-Jun-2001  he file ldvar.h was added on branch netbsd-1-5 on 2001-10-25 17:53:44 +0000
 1.5.2.1  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.4.1  28-Jul-2004  tron Pull up revision 1.8 (requested by dbj in ticket #722):
use uint64 instead of int for sc_secperunit
 1.7.2.3  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.2  19-Oct-2004  skrll Sync with HEAD
 1.7.2.1  03-Aug-2004  skrll Sync with HEAD
 1.9.12.2  26-Feb-2007  yamt sync with head.
 1.9.12.1  21-Jun-2006  yamt sync with head.
 1.11.20.1  15-Jan-2007  ad Add just enough locking to make this useful for tests.
 1.12.44.5  09-Oct-2010  yamt sync with head
 1.12.44.4  11-Mar-2010  yamt sync with head
 1.12.44.3  16-May-2009  yamt sync with head
 1.12.44.2  04-May-2009  yamt sync with head.
 1.12.44.1  16-May-2008  yamt sync with head.
 1.12.42.1  18-May-2008  yamt sync with head.
 1.12.40.2  28-Sep-2008  mjf Sync with HEAD.
 1.12.40.1  02-Jun-2008  mjf Sync with HEAD.
 1.12.6.2  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.12.6.1  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.13.6.1  19-Oct-2008  haad Sync with HEAD.
 1.13.4.2  11-Jun-2008  simonb Revert my suggested fix for kern/38655 - that shouldn't have snuck in
to this branch.
 1.13.4.1  10-Jun-2008  simonb Initial commit of Wasabi System's WAPBL (Write Ahead Physical Block
Logging) journaling code. Originally written by Darrin B. Jewell
while at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

Still a number of issues - look in doc/BRANCHES for "simonb-wapbl"
for more info.
 1.13.2.2  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.13.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.15.8.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.4.1  05-Mar-2011  rmind sync with head
 1.17.2.1  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.18.8.2  23-May-2012  yamt sync with head.
 1.18.8.1  17-Apr-2012  yamt sync with head
 1.19.2.2  02-Jun-2012  mrg sync to latest -current.
 1.19.2.1  18-Feb-2012  mrg merge to -current.
 1.20.2.1  16-Jul-2012  riz Pull up following revision(s) (requested by nonaka in ticket #418):
sys/dev/ldvar.h: revision 1.21
use uint64_t for sc_disksize512.
fixed the problem with ataraid volumes larger than 2 TiB.
 1.21.16.4  28-Aug-2017  skrll Sync with HEAD
 1.21.16.3  05-Oct-2016  skrll Sync with HEAD
 1.21.16.2  22-Sep-2015  skrll Sync with HEAD
 1.21.16.1  06-Jun-2015  skrll Sync with HEAD
 1.21.2.1  03-Dec-2017  jdolecek update from HEAD
 1.27.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.27.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.28.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.29.4.1  02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.30.2.1  01-Sep-2017  martin Pull up following revision(s) (requested by mlelstv in ticket #261):
sys/dev/sdmmc/ld_sdmmc.c: revision 1.32
sys/dev/sdmmc/ld_sdmmc.c: revision 1.33
sys/dev/sdmmc/ld_sdmmc.c: revision 1.34
sys/dev/sdmmc/sdmmc_mem.c: revision 1.62
sys/dev/i2o/ld_iop.c: revision 1.39
sys/dev/ld.c: revision 1.102
sys/dev/ld.c: revision 1.103
sys/dev/dksubr.c: revision 1.98
sys/dev/dksubr.c: revision 1.99
sys/dev/sdmmc/sdmmcvar.h: revision 1.29
sys/dev/ic/ld_nvme.c: revision 1.17
sys/dev/ldvar.h: revision 1.31
sys/dev/ldvar.h: revision 1.32
sys/dev/ic/ld_cac.c: revision 1.31
sys/dev/pci/ld_virtio.c: revision 1.16
While ld(4) is MP safe, many backends are not.
Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.
Fixes PR 52462.
Defer sdmmc discard operations to the sdmmc task queue. Fixes a panic
introduced by ld.c r1.102.
validate length for discard operation and split operation when byte length
doesn't fit into 'int'.
make the sc_discard interface for the ld backend asynchronous and
signal completion through new callback lddiscardend. Use a standard
struct buf to pass disk address and range instead of two off_t values.
make lddiscard synchronous again. This is a requirement of the current
ffs discard code.
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.32.4.1  10-Jun-2019  christos Sync with HEAD
 1.33.4.1  21-Jun-2021  martin Pull up following revision(s) (requested by riastradh in ticket #1304):

sys/dev/ldvar.h: revision 1.35
sys/dev/ld.c: revision 1.112

ld(4): Block requests while suspended until resumed.

Otherwise nothing stops us from continuing to feed I/O to the disk
controller when it expects that the queues are quiesced as it pokes
registers to change its power states. Fixes resume during disk
activity on my T480 with nvme.
 1.34.8.1  31-May-2021  cjep sync with head
 1.34.6.1  17-Jun-2021  thorpej Sync w/ HEAD.

RSS XML Feed