Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/ld.c
RevisionDateAuthorComments
 1.118  04-Oct-2025  skrll Only report sc_physsecsize when it's non-zero.
 1.117  13-Apr-2025  jakllsch Add physical sector and alignment info to struct disk_geom and the
geometry plist, and handle in partutil.

Bump version for disk_geom addition.

Collect DIOCGSECTORALIGN handling into one place.
 1.116  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.115  12-Apr-2025  mlelstv ld sc_dump backend takes an 'int' as disk address, fail when the
disk address is outside the possible range of an int.
 1.114  05-Mar-2025  jakllsch ld(4): print physical sector information
 1.113  27-Feb-2025  jakllsch Implement DIOCGSECTORALIGN for ld(4)
 1.112  30-May-2021  riastradh branches: 1.112.18;
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.111  02-Aug-2020  riastradh branches: 1.111.6; 1.111.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.110  13-Apr-2020  maxv constify
 1.109  01-Mar-2020  riastradh branches: 1.109.4;
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.
 1.108  10-Feb-2020  mlelstv Reject open when attach didn't complete successfully.
 1.107  06-Oct-2019  mlelstv branches: 1.107.2;
Don't attach disks with sector sizes we cannot handle.
 1.106  19-Mar-2019  mlelstv branches: 1.106.4;
Let backend provide a disk type. The information can be queried through
drvctl(4).
 1.105  13-Oct-2018  mlelstv take kernel lock for ioctl calls when backend isn't tagged MPSAFE.
 1.104  28-Oct-2017  riastradh branches: 1.104.2; 1.104.4;
Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h".
 1.103  20-Aug-2017  mlelstv 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.102  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.101  27-Apr-2017  jdolecek branches: 1.101.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.100  27-Feb-2017  jdolecek branches: 1.100.4;
refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.99  26-Nov-2016  mlelstv branches: 1.99.2;
size routine returns -1 on error, not an error code.
 1.98  11-Oct-2016  jdolecek do not try to flush device when rebooting with RB_NOSYNC, so that machine
would still reboot if the device is wedged
 1.97  27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.96  19-Sep-2016  jdolecek fix DIOCCACHESYNC ioctl on ld(4) and raid(4) to work again; it got broken
when the code was switched over to dk_ioctl() - countrary to disk_ioctl(),
dk_ioctl() returns ENOTTY for ioctls it doesn't support, so must be called
as last resort, not first

bug was introduced in rev 1.83 (2015-05-02) for ld(4), and 1.335 (2016-01-03)
for raid(4)
 1.95  16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.94  27-Feb-2016  mlelstv branches: 1.94.2;
dk_ioctl already calls disk_ioctl.
Remove redundant return statement for a void function.
 1.93  28-Aug-2015  mlelstv move entropy gathering into dksubr.
 1.92  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.91  18-Aug-2015  mlelstv Use ENODEV to show that an operation is not supported.
 1.90  17-Aug-2015  jakllsch Add support for implementing discard functionality with ld(4)
 1.89  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.88  16-Aug-2015  mlelstv missed wakeup -> cv_broadcast conversion.
 1.87  16-Aug-2015  mlelstv use device_printf
 1.86  16-Aug-2015  mlelstv replace tsleep with condvar
 1.85  16-Aug-2015  mlelstv replace spl and tsleep with mutex and condvar.
 1.84  22-Jul-2015  skrll Trailing whitespace.
 1.83  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.82  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.81  02-Jan-2015  christos We have three sets of DTYPE_ constants in the kernel:
altq Drop Type
disklabel Disk Type
file Descriptor Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
 1.80  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.79  31-Dec-2014  christos Centralize wedge ioctls in disk_ioctl.
 1.78  04-Nov-2014  mlelstv branches: 1.78.2;
support DIOCMWEDGES ioctl.
 1.77  11-Oct-2014  mlelstv clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.
 1.76  05-Sep-2014  matt Don't use new as a variable name.
 1.75  10-Aug-2014  tls branches: 1.75.2;
Merge tls-earlyentropy branch into HEAD.
 1.74  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

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

I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
 1.72  16-Mar-2014  dholland branches: 1.72.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.71  29-May-2013  christos branches: 1.71.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.
 1.70  27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.69  02-Feb-2012  tls branches: 1.69.6;
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.68  20-Sep-2010  kiyohara branches: 1.68.8; 1.68.12;
Check disk bounds, in RAW_PART.
 1.67  19-Aug-2010  jmcneill flush cache on suspend
 1.66  23-Jul-2009  dyoung branches: 1.66.2; 1.66.4;
Extract ldlastclose() and use it in ldclose(). At the top of
ldbegindetach(), call disk_begindetach(..., ldlastclose, ...).

Compiles. Not tested.
 1.65  07-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.64  13-Jan-2009  yamt branches: 1.64.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.63  09-Sep-2008  tron branches: 1.63.2;
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.62  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.61  01-Aug-2008  ws Destroy our mutex on detach in order to avoid
an "allocation contains active lock" panic
when halting a LOCKDEBUG kernel.
 1.60  06-Jul-2008  cube branches: 1.60.2;
Use device_private() where appropriate.

Noted by Paul Goyette in PR#39110.
 1.59  11-Jun-2008  tsutsui Use device_lookup_private() to get softc.
 1.58  28-Apr-2008  martin branches: 1.58.2; 1.58.4;
Remove clause 3 and 4 from TNF licenses
 1.57  09-Apr-2008  cegger branches: 1.57.2; 1.57.4;
use aprint_*_dev and device_xname
 1.56  09-Mar-2008  jmcneill Don't forget to deregister with PMF on detach.
 1.55  09-Mar-2008  jmcneill Replace shutdownhook with PMF power handler.
 1.54  04-Jan-2008  ad branches: 1.54.2; 1.54.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.53  05-Dec-2007  ad branches: 1.53.4;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.52  12-Nov-2007  xtraeme branches: 1.52.2;
Use sc_mutex (which runs at IPL_BIO) to protect the DIOC[GS]STRATEGY
ioctl ops, sorry didn't see it before.
 1.51  12-Nov-2007  xtraeme Implement DIOCGSTRATEGY and DIOCSSTRATEGY for dkctl <foo0> strategy.
 1.50  08-Oct-2007  ad branches: 1.50.2; 1.50.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.49  29-Jul-2007  ad branches: 1.49.4; 1.49.6; 1.49.8; 1.49.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.48  21-Jul-2007  ad Replace some uses of lockmgr().
 1.47  30-Apr-2007  tron branches: 1.47.2;
Reset error code if an ioctl() request is not handled by the generic
disk framework. This stops ld(4) from returning an error for various
ioctl() requests which actually *did* work. As a result fdisk(8) and
therefore also sysinst(8) work with ld(4) devices once again.

Based on a patch supplied by Todd Kover in PR kern/36244, successfully
tested with ld(4)@icp(4).
 1.46  04-Mar-2007  christos branches: 1.46.2; 1.46.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.45  22-Feb-2007  riz Defer dkwedge_discover() until after interrupts are enabled. This
allows a kernel with options DKWEDGE_AUTODISCOVER to boot
on a machine with a twa(4) card.

ok matt@
 1.44  09-Feb-2007  ad branches: 1.44.2;
Merge newlock2 to head.
 1.43  08-Feb-2007  riz Add disk-info properties to ld(4), based on Jason Thorpe's similar
code in wd(4).

OK ad, cube
 1.42  16-Nov-2006  christos branches: 1.42.2;
__unused removal on arguments; approved by core.
 1.41  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.40  28-Mar-2006  thorpej branches: 1.40.8; 1.40.10;
Use device_unit().
 1.39  11-Dec-2005  christos branches: 1.39.4; 1.39.6; 1.39.8; 1.39.10; 1.39.12;
merge ktrace-lwp.
 1.38  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.37  30-May-2005  christos branches: 1.37.2;
avoid variable shadowing.
 1.36  31-Mar-2005  yamt introduce a function to drain bufq and use it where appropriate.
 1.35  27-Feb-2005  perry branches: 1.35.2;
nuke trailing whitespace
 1.34  08-Feb-2005  briggs Use aprint_*() instead of printf() at attach time.
 1.33  28-Oct-2004  yamt branches: 1.33.4; 1.33.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.32  26-Oct-2004  thorpej Implement the DIOCCACHESYNC ioctl.
 1.31  17-Oct-2004  jdolecek ldioctl(): fix typo in check for lockmgr() return value introduced
with the wedge support, which caused premature return and left dk_openlock
locked, leading to lockmgr() panic on close; newfs of ld disk now works again
 1.30  25-Sep-2004  thorpej Add support for wedges to the logical disk driver.
 1.29  30-Aug-2004  thorpej Use ANSI function decls, sprinkle static.
 1.28  20-Jul-2004  dbj use uint64 instead of int for sc_secperunit
 1.27  22-Mar-2004  tls branches: 1.27.2;
Don't use BUFQ_FCFS. It degrades performance both for "smart" (Mylex
ExtremeRAID with NV cache) and "dumb" (3ware 6410) ld providers.

Instead, use the default buffer queue policy.

With the 3ware adapter, using the read priority strategy instead of FCFS,
for three extractions of pkgsrc, took 329 seconds instead of 331 -- but
with a dramatic improvement in perceived system response (latency for
I/O outside the main stream).

With the Mylex adapter, the improvement was dramatic: using read priority
instead of FCFS yielded an improvement from 381 seconds to 135 seconds!
There was a less-noticeable improvement in perceived latency as well.

The other disk drivers currently hard-wired to FCFS or another policy
should probably be changed as well.
 1.26  29-Jun-2003  fvdl branches: 1.26.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.25  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.24  13-Jun-2003  thorpej * Don't wait for commands to drain when adjusting the queue length.
Instead, wait when it's really needed, when detaching. Project
draining from spruious wakeups.
* Don't flush the controller's cache when detaching; we can't do it
reliably, as the controller probably things the array drive no
longer exists. The cache is already flushed in ldclose() so this
should be no problem.
 1.23  07-Jun-2003  thorpej Always queue transfers in the ld driver to prevent transient resource
shortages in the back-ends from aborting transfers.

Reviewed by ad@.
 1.22  17-May-2003  thorpej Add DIOCKLABEL support. Fixes PR kern/21605 (Luke Mewburn).
 1.21  16-May-2003  itojun use strlcpy
 1.20  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.19  27-Jan-2003  thorpej If the upper-layer provides a geometry, use it.
 1.18  01-Nov-2002  mrg implement separate read/write disk statistics:
- disk_unbusy() gets a new parameter to tell the IO direction.
- struct disk_sysctl gets 4 new members for read/write bytes/transfers.
when processing hw.diskstats, add the read&write bytes/transfers for
the old combined stats to attempt to keep backwards compatibility.

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

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

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

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

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

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.15  21-Jul-2002  hannken Rename bufq_init() to bufq_alloc().
Add bufq_free() to remove a buffer queue.
Avoid MALLOC while holding a spinlock.

From Chuck Silvers.
 1.14  20-Jul-2002  hannken Convert to new device buffer queue interface.
 1.13  08-May-2002  drochner branches: 1.13.2;
Since the minor numbers belonging to the partitions of a disk are not
contigous anymore, we can't call vdevgone() for the whole range at once.
(we should probably change the vdevgone() interface)
This also fixes some wrong use of DISKUNIT().
 1.12  13-Nov-2001  lukem add RCSIDs
 1.11  06-Sep-2001  thorpej branches: 1.11.2; 1.11.6;
Don't compare bp->b_dev against RAW_PART; use the `part' local variable
instead.
 1.10  24-Jul-2001  ad Pasto; found by tls.
 1.9  10-Jun-2001  ad branches: 1.9.2;
Centralise the geometry fudge.
 1.8  30-Apr-2001  lukem minor lint
 1.7  04-Feb-2001  ad branches: 1.7.2;
Allow for draining/adjusting the queue.
 1.6  08-Jan-2001  itojun "lp" must be defined reagardless from __HAVE_OLD_DISKLABEL
 1.5  08-Jan-2001  fvdl Return error in the case of using ODIOCGDINFO or ODIOCGDEFLABEL when
the number of partitions is > OLDMAXPARTITIONS. This is better
than silently truncating the label (don't want to silently throw
away partitions when using an old disklabel binary on a label with
> 8 partitions). From Enami Tsugutomo.
 1.4  07-Jan-2001  fvdl Adapt all disk devices in MI directories to handle ODIOC* calls
for ports that have bumped MAXPARTITIONS (and thus define
__HAVE_OLD_DISKLABEL).
 1.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.5  11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.4  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 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 ld.c was added on branch thorpej_scsipi on 2000-12-08 09:12:15 +0000
 1.7.2.8  11-Nov-2002  nathanw Catch up to -current
 1.7.2.7  17-Sep-2002  nathanw Catch up to -current.
 1.7.2.6  01-Aug-2002  nathanw Catch up to -current.
 1.7.2.5  20-Jun-2002  nathanw Catch up to -current.
 1.7.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.7.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.7.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.7.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.9.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.9.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.9.2.1  03-Aug-2001  lukem update to -current
 1.11.6.2  25-Oct-2001  he Pull up revisions 1.1-1.11 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.11.6.1  06-Sep-2001  he file ld.c was added on branch netbsd-1-5 on 2001-10-25 17:53:41 +0000
 1.11.2.3  01-Oct-2001  fvdl Catch up with -current.
 1.11.2.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.11.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.13.2.2  29-Aug-2002  gehenna catch up with -current.
 1.13.2.1  16-May-2002  gehenna Add the block/character device switches.
Replace the direct-access to devsw table with calling devsw API.
 1.26.2.11  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.10  01-Apr-2005  skrll Sync with HEAD.
 1.26.2.9  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.26.2.8  09-Feb-2005  skrll Sync with HEAD.
 1.26.2.7  02-Nov-2004  skrll Sync with HEAD.
 1.26.2.6  19-Oct-2004  skrll Sync with HEAD
 1.26.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.26.2.3  03-Sep-2004  skrll Sync with HEAD
 1.26.2.2  03-Aug-2004  skrll Sync with HEAD
 1.26.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.27.2.1  28-Jul-2004  tron Pull up revision 1.28 (requested by dbj in ticket #722):
use uint64 instead of int for sc_secperunit
 1.33.6.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.33.6.1  12-Feb-2005  yamt sync with head.
 1.33.4.1  29-Apr-2005  kent sync with -current
 1.35.2.1  06-Apr-2005  tron Pull up revision 1.36 (requested by yamt in ticket #112):
introduce a function to drain bufq and use it where appropriate.
 1.37.2.8  17-Mar-2008  yamt sync with head.
 1.37.2.7  21-Jan-2008  yamt sync with head
 1.37.2.6  07-Dec-2007  yamt sync with head
 1.37.2.5  15-Nov-2007  yamt sync with head.
 1.37.2.4  27-Oct-2007  yamt sync with head.
 1.37.2.3  03-Sep-2007  yamt sync with head.
 1.37.2.2  26-Feb-2007  yamt sync with head.
 1.37.2.1  21-Jun-2006  yamt sync with head.
 1.39.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.39.10.1  19-Apr-2006  elad sync with head.
 1.39.8.1  01-Apr-2006  yamt sync with head.
 1.39.6.1  22-Apr-2006  simonb Sync with head.
 1.39.4.1  09-Sep-2006  rpaulo sync with head
 1.40.10.2  10-Dec-2006  yamt sync with head.
 1.40.10.1  22-Oct-2006  yamt sync with head
 1.40.8.3  09-Feb-2007  ad Sync with HEAD.
 1.40.8.2  15-Jan-2007  ad Add just enough locking to make this useful for tests.
 1.40.8.1  18-Nov-2006  ad Sync with head.
 1.42.2.3  30-Apr-2007  bouyer Pull up following revision(s) (requested by tron in ticket #601):
sys/dev/ld.c: revision 1.47
Reset error code if an ioctl() request is not handled by the generic
disk framework. This stops ld(4) from returning an error for various
ioctl() requests which actually *did* work. As a result fdisk(8) and
therefore also sysinst(8) work with ld(4) devices once again.
Based on a patch supplied by Todd Kover in PR kern/36244, successfully
tested with ld(4)@icp(4).
 1.42.2.2  24-Feb-2007  bouyer Pull up following revision(s) (requested by riz in ticket #458):
sys/dev/ld.c: revision 1.45
Defer dkwedge_discover() until after interrupts are enabled. This
allows a kernel with options DKWEDGE_AUTODISCOVER to boot
on a machine with a twa(4) card.
ok matt@
 1.42.2.1  16-Feb-2007  tron Pull up following revision(s) (requested by riz in ticket #444):
sys/dev/ld.c: revision 1.43
Add disk-info properties to ld(4), based on Jason Thorpe's similar
code in wd(4).
OK ad, cube
 1.44.2.3  07-May-2007  yamt sync with head.
 1.44.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.44.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.46.4.1  11-Jul-2007  mjf Sync with head.
 1.46.2.4  20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.46.2.3  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.46.2.2  27-May-2007  ad Sync with head.
 1.46.2.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.47.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.49.10.2  29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.49.10.1  29-Jul-2007  ad file ld.c was added on branch matt-mips64 on 2007-07-29 12:50:19 +0000
 1.49.8.1  14-Oct-2007  yamt sync with head.
 1.49.6.3  23-Mar-2008  matt sync with HEAD
 1.49.6.2  09-Jan-2008  matt sync with HEAD
 1.49.6.1  06-Nov-2007  matt sync with HEAD
 1.49.4.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.49.4.2  14-Nov-2007  joerg Sync with HEAD.
 1.49.4.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.50.4.3  18-Feb-2008  mjf Sync with HEAD.
 1.50.4.2  08-Dec-2007  mjf Sync with HEAD.
 1.50.4.1  19-Nov-2007  mjf Sync with HEAD.
 1.50.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.52.2.1  08-Dec-2007  ad Sync with head.
 1.53.4.1  08-Jan-2008  bouyer Sync with HEAD
 1.54.6.8  17-Jan-2009  mjf - Fix a CVS merge breakage
- Catch up with some driver changes
 1.54.6.7  17-Jan-2009  mjf Sync with HEAD.
 1.54.6.6  28-Sep-2008  mjf Sync with HEAD.
 1.54.6.5  29-Jun-2008  mjf Sync with HEAD.
 1.54.6.4  02-Jun-2008  mjf Sync with HEAD.
 1.54.6.3  06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.54.6.2  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

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

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

- add a DEV_AUDIO type for devices.
 1.54.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.54.2.1  24-Mar-2008  keiichi sync with head.
 1.57.4.5  09-Oct-2010  yamt sync with head
 1.57.4.4  19-Aug-2009  yamt sync with head.
 1.57.4.3  16-May-2009  yamt sync with head
 1.57.4.2  04-May-2009  yamt sync with head.
 1.57.4.1  16-May-2008  yamt sync with head.
 1.57.2.2  17-Jun-2008  yamt sync with head.
 1.57.2.1  18-May-2008  yamt sync with head.
 1.58.4.4  18-Jul-2008  simonb Sync with head.
 1.58.4.3  18-Jun-2008  simonb Sync with head.
 1.58.4.2  11-Jun-2008  simonb Revert my suggested fix for kern/38655 - that shouldn't have snuck in
to this branch.
 1.58.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.58.2.3  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.58.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.58.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.60.2.1  19-Oct-2008  haad Sync with HEAD.
 1.63.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.64.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.66.4.1  05-Mar-2011  rmind sync with head
 1.66.2.1  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.68.12.1  18-Feb-2012  mrg merge to -current.
 1.68.8.3  22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.68.8.2  30-Oct-2012  yamt sync with head
 1.68.8.1  17-Apr-2012  yamt sync with head
 1.69.6.4  03-Dec-2017  jdolecek update from HEAD
 1.69.6.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.6.2  23-Jun-2013  tls resync from head
 1.69.6.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.71.2.1  18-May-2014  rmind sync with head
 1.72.2.2  10-Aug-2014  tls Rebase.
 1.72.2.1  07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.75.2.2  11-Nov-2014  martin Pull up following revision(s) (requested by mlelstv in ticket #202):
sys/dev/ccd.c: revision 1.153
sys/dev/ccd.c: revision 1.154
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.313
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.314
sys/dev/ld.c: revision 1.77
sys/dev/vnd.c: revision 1.233
sys/dev/dksubr.c: revision 1.52
sys/dev/dksubr.c: revision 1.53
clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.
No longer warn about differences bewteen disk size and total sector count
in disklabel when the latter is just clamped to the maximum.
 1.75.2.1  11-Nov-2014  martin Pull up following revision(s) (requested by mlelstv in ticket #201):
sbin/dkctl/dkctl.8: revision 1.24
sbin/dkctl/dkctl.8: revision 1.25
sys/dev/scsipi/sd.c: revision 1.310
sys/dev/ata/wd.c: revision 1.415
sbin/dkctl/dkctl.c: revision 1.21
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.315
sys/dev/ld.c: revision 1.78
sys/dev/vnd.c: revision 1.234
sys/dev/dksubr.c: revision 1.54
sys/sys/dkio.h: revision 1.20
sys/dev/dkwedge/dk.c: revision 1.74
Add ioctl to autodiscover wedges.
Implement DIOCMWEDGES ioctl that triggers wedge autodiscovery.
Also fix a reference counting bug and clean up some code.
support DIOCMWEDGES ioctl.
Add 'makewedges' option to autodiscover wedges from a changed label.
New sentence, new line. Bump date for previous.
 1.78.2.7  28-Aug-2017  skrll Sync with HEAD
 1.78.2.6  05-Dec-2016  skrll Sync with HEAD
 1.78.2.5  05-Oct-2016  skrll Sync with HEAD
 1.78.2.4  19-Mar-2016  skrll Sync with HEAD
 1.78.2.3  22-Sep-2015  skrll Sync with HEAD
 1.78.2.2  06-Jun-2015  skrll Sync with HEAD
 1.78.2.1  06-Apr-2015  skrll Sync with HEAD
 1.94.2.8  20-Mar-2017  pgoyette Sync with HEAD
 1.94.2.7  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.94.2.6  04-Nov-2016  pgoyette Sync with HEAD
 1.94.2.5  31-Jul-2016  pgoyette Use after initialization, not before
 1.94.2.4  27-Jul-2016  pgoyette Update a few more drivers for localcount(9)
 1.94.2.3  26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.94.2.2  19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.94.2.1  18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.99.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.100.4.3  02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.100.4.2  29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.100.4.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.101.2.3  11-Feb-2020  martin Pull up following revision(s) (requested by mlelstv in ticket #1500):

sys/dev/ld.c: revision 1.108

Reject open when attach didn't complete successfully.
 1.101.2.2  04-Dec-2018  martin Pull up following revision(s) (requested by mlelstv in ticket #1122):

sys/dev/ld.c: revision 1.105

take kernel lock for ioctl calls when backend isn't tagged MPSAFE.
 1.101.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.104.4.4  21-Apr-2020  martin Sync with HEAD
 1.104.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.104.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.104.4.1  10-Jun-2019  christos Sync with HEAD
 1.104.2.1  20-Oct-2018  pgoyette Sync with head
 1.106.4.3  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.106.4.2  21-Mar-2020  martin Pull up following revision(s) (requested by riastradh in ticket #795):

sys/dev/dksubr.c: revision 1.112
sys/arch/xen/xen/xbd_xenbus.c: revision 1.95
sys/dev/scsipi/sd.c: revision 1.328
sys/dev/dkvar.h: revision 1.32
sys/dev/ld.c: revision 1.109
sys/dev/cgd.c: revision 1.120
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.380
sys/dev/ata/wd.c: revision 1.458

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.
 1.106.4.1  11-Feb-2020  martin Pull up following revision(s) (requested by mlelstv in ticket #694):

sys/dev/ld.c: revision 1.108

Reject open when attach didn't complete successfully.
 1.107.2.1  29-Feb-2020  ad Sync with head.
 1.109.4.1  20-Apr-2020  bouyer Sync with HEAD
 1.111.8.1  31-May-2021  cjep sync with head
 1.111.6.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.112.18.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed