Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/md.c
RevisionDateAuthorComments
 1.87  13-Jan-2023  hannken It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.

Reported-by: syzbot+318187e5124846542f8d@syzkaller.appspotmail.com
 1.86  24-Sep-2022  thorpej branches: 1.86.4;
malloc(9) -> kmem(9)
 1.85  14-May-2020  msaitoh Remove extra semicolon.
 1.84  13-Apr-2020  maxv constify
 1.83  18-Jan-2020  ad branches: 1.83.4;
Mark the cdev MPSAFE too.
 1.82  29-Aug-2019  hannken branches: 1.82.2;
Add "d_minphys" to "mddkdriver" to make physio() on wedges happy.
 1.81  26-May-2019  hannken Take "sc_lock" after calling disk_ioctl() to make GPT partitioning work.
 1.80  03-Mar-2018  christos branches: 1.80.4;
conditionally elide conditional for rump.
 1.79  28-Oct-2017  riastradh Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h".
 1.78  27-Jul-2016  pgoyette branches: 1.78.6;
Don't mutex_exit() if we didn't mutex_enter().

Pointed out by coypu. Thanks!
 1.77  27-Jul-2016  pgoyette If we're going to check for a NULL pointer, do the check before we
dereference it (to get the lock address).
 1.76  04-Jan-2016  hannken branches: 1.76.2;
Notify disk subsystem of the current geometry.

Ok: Michael van Elst
 1.75  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.74  26-Apr-2015  mlelstv Use C99-style initializers for struct dkdriver.
 1.73  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.72  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.71  25-Jul-2014  dholland branches: 1.71.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.70  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.69  16-Mar-2014  dholland branches: 1.69.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.68  13-Mar-2014  hannken No need to detach (and return EBUSY) if dk_openmask is non-zero.
 1.67  30-Jun-2012  tsutsui branches: 1.67.2; 1.67.4;
Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().

Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.

Should be pulled up to netbsd-6 (at least for atari).
 1.66  25-Nov-2010  hannken branches: 1.66.8; 1.66.14;
- Don't detach configured devices on last close.
- No kmem allocation and biodone() under lock (from rmind@netbsd.org).
 1.65  23-Nov-2010  hannken Make md(4) mp-safe.
 1.64  22-Nov-2010  pooka Don't have a COW (Compiler OW) in case there is no kernel_opt.
 1.63  11-Nov-2010  hannken Change md(4) to:
- create md devices on first open and destroy on last close.
- add enough disk label support to make DIOCGDINFO and DIOCGPART work.
- add disk_busy()/disk_unbusy() instrumentation.

Ok: David Young <dyoung@netbsd.org>
 1.62  21-Jan-2010  dyoung branches: 1.62.2; 1.62.4;
Take care not to dereference a NULL softc.
 1.61  22-Oct-2009  snj Drop 3rd and 4th clauses. OK gwr@ leo@ (copyright holders).
 1.60  28-Jul-2009  dyoung Make mdopen() and mdclose() maintain the openmask. md_detach()
depends on the openmask to know whether it should either return
EBUSY because the device is open, or tear the device down.

Alan Barrett reports that this fixes kern/41725, in part: it prevents
the UVM fault, and the kernel detaches /dev/md0a after unmounting
/ on /dev/md0a instead of before.
 1.59  19-May-2009  dyoung Add a detachment hook. Detach md(4) at shutdown.
 1.58  04-May-2009  manu TFTPROOT loads the RAMdisk through TFTP at boot time. It needs the
network to be functionnal, and therefore must be called after
config_finalize(). Unfortunately, config_finalize() attaches md0
through mdattach(), and when tftproot_getfile() attempts to attach it
later by calling mdattach() again, it gets a failure.

This change checks for the RAMdisk size in mdattach(). If it is zero, then
the RAMdisk has not been loaded yet, and nothing is done. It will be
attached later when tftproot_getfile() will call mdattach()
 1.57  13-Jan-2009  yamt branches: 1.57.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.56  16-Jun-2008  drochner branches: 1.56.4; 1.56.6; 1.56.12;
more cleanup: the sc_dev backpointer is unused, remove it
 1.55  13-Jun-2008  cegger register NULL pmf handlers. md(4) is supposed to not loose / change when resuming from S3.
 1.54  13-Jun-2008  cegger device_t/softc split
while here, remove unused variables and do some other cleanups
with feedback from cube
 1.53  11-Jun-2008  drochner Replace the weird method to create instances by config_attach_pseudo()
as everyone else does, and remove the private table of instances which
is replaced by the table in the cfdriver.
This could get more cleanup, and I didn't split device/softc yet.
 1.52  09-Apr-2008  cegger branches: 1.52.2; 1.52.4; 1.52.6; 1.52.8;
use aprint_*_dev and device_xname
 1.51  08-Oct-2007  ad branches: 1.51.18;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.50  29-Jul-2007  ad branches: 1.50.4; 1.50.6; 1.50.8; 1.50.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.49  15-Jul-2007  dsl branches: 1.49.2;
Default MEMORY_DISK_SERVER to 1 instead of using 'undefined' to mean 1.
 1.48  04-Mar-2007  christos branches: 1.48.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.47  16-Nov-2006  christos branches: 1.47.4;
__unused removal on arguments; approved by core.
 1.46  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.45  02-Sep-2006  christos branches: 1.45.2; 1.45.4;
add missing initializer
 1.44  28-Mar-2006  thorpej Use device_unit().
 1.43  11-Dec-2005  christos branches: 1.43.4; 1.43.6; 1.43.8; 1.43.10; 1.43.12;
merge ktrace-lwp.
 1.42  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.41  01-Apr-2005  yamt branches: 1.41.2;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.40  27-Feb-2005  perry nuke trailing whitespace
 1.39  28-Oct-2004  yamt branches: 1.39.4; 1.39.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.38  30-Aug-2004  thorpej Use ANSI function decls, sprinkle static.
 1.37  21-Apr-2004  itojun kill sprintf, use snprintf
 1.36  29-Jun-2003  fvdl branches: 1.36.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.35  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.34  13-May-2003  thorpej Use aprint_error() where appropriate.
 1.33  11-Dec-2002  atatat Add /* MEMORY_DISK_SERVER */ comments to the #endifs to match the #ifdefs.
 1.32  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.31  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.30  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.29  20-Jul-2002  hannken Convert to new device buffer queue interface.
 1.28  13-Jan-2002  tsutsui branches: 1.28.8;
Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.27  13-Nov-2001  lukem add RCSIDs
 1.26  07-Jul-2001  thorpej branches: 1.26.2; 1.26.4;
bcopy -> memcpy
bzero -> memset
 1.25  08-Feb-2001  tsutsui branches: 1.25.2;
Fix md_root.c path in comment.
 1.24  27-Jun-2000  mrg remove include of <vm/vm.h>
 1.23  26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.22  21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.21  21-Jan-2000  tsutsui - use the raw partition for ioctl; `control device' is gone.
- remove `sc_flags' member from md_softc
- add check code whether the md device is configured in mdread/mdwrite
 1.20  24-Mar-1999  mrg branches: 1.20.8; 1.20.14;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.19  07-Feb-1999  jonathan defopt MEMORY_DISK_{HOOKS,SERVER,IS_ROOT}.
 1.18  01-Sep-1998  enami Make this file compile again by removing no longer used `struct
cfdriver md_cd' and related code.
 1.17  13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.16  10-Feb-1998  mrg branches: 1.16.2;
- add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.15  05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly. :-)
 1.14  01-Aug-1997  leo Use DISKUNIT macro to encode md's unit in the minor number.
 1.13  23-May-1997  jeremy branches: 1.13.4;
Comment reference to ramdisk.h -> md.h
 1.12  11-Jan-1997  thorpej It's not safe to sleep in mdattach(), so don't pass WAITOK to malloc().
 1.11  28-Dec-1996  pk Rename this driver `md'.
 1.10  13-Oct-1996  christos backout kprintf changes
 1.9  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8  12-Apr-1996  leo Add some prototypes.
 1.7  22-Mar-1996  gwr The ramdisk is now a pseudo-device.
 1.6  17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.5  07-Mar-1996  leo Allow for a machine dependent match function - rd_match_hook()
 1.4  07-Jan-1996  thorpej New generic disk framework. Highlights:

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

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

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

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

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.3  17-Nov-1995  gwr get size of softc right
 1.2  26-Oct-1995  gwr Fix a comment
 1.1  08-Oct-1995  gwr branches: 1.1.2;
Machine-independent RAM-disk driver.
 1.1.2.1  17-Nov-1995  gwr sync with head
 1.13.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.16.2.1  30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.20.14.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.20.8.2  11-Feb-2001  bouyer Sync with HEAD.
 1.20.8.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.25.2.7  19-Dec-2002  thorpej Sync with HEAD.
 1.25.2.6  11-Nov-2002  nathanw Catch up to -current
 1.25.2.5  17-Sep-2002  nathanw Catch up to -current.
 1.25.2.4  01-Aug-2002  nathanw Catch up to -current.
 1.25.2.3  28-Feb-2002  nathanw Catch up to -current.
 1.25.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.25.2.1  24-Aug-2001  nathanw Catch up with -current.
 1.26.4.3  01-Oct-2001  fvdl Catch up with -current.
 1.26.4.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.26.4.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.26.2.4  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.26.2.3  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.26.2.2  11-Feb-2002  jdolecek Sync w/ -current.
 1.26.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.8.2  29-Aug-2002  gehenna catch up with -current.
 1.28.8.1  16-May-2002  gehenna Add the block/character device switches.
 1.36.2.9  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.36.2.8  01-Apr-2005  skrll Sync with HEAD.
 1.36.2.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.36.2.6  02-Nov-2004  skrll Sync with HEAD.
 1.36.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.36.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.36.2.3  03-Sep-2004  skrll Sync with HEAD
 1.36.2.2  03-Aug-2004  skrll Sync with HEAD
 1.36.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.39.6.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.39.6.1  25-Jan-2005  yamt convert to new apis.
 1.39.4.1  29-Apr-2005  kent sync with -current
 1.41.2.4  27-Oct-2007  yamt sync with head.
 1.41.2.3  03-Sep-2007  yamt sync with head.
 1.41.2.2  30-Dec-2006  yamt sync with head.
 1.41.2.1  21-Jun-2006  yamt sync with head.
 1.43.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.43.10.1  19-Apr-2006  elad sync with head.
 1.43.8.2  03-Sep-2006  yamt sync with head.
 1.43.8.1  01-Apr-2006  yamt sync with head.
 1.43.6.1  22-Apr-2006  simonb Sync with head.
 1.43.4.1  09-Sep-2006  rpaulo sync with head
 1.45.4.2  10-Dec-2006  yamt sync with head.
 1.45.4.1  22-Oct-2006  yamt sync with head
 1.45.2.1  18-Nov-2006  ad Sync with head.
 1.47.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.48.2.3  20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.48.2.2  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.48.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.49.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.50.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.50.10.1  29-Jul-2007  ad file md.c was added on branch matt-mips64 on 2007-07-29 12:50:19 +0000
 1.50.8.1  14-Oct-2007  yamt sync with head.
 1.50.6.1  06-Nov-2007  matt sync with HEAD
 1.50.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.51.18.5  17-Jan-2009  mjf Sync with HEAD.
 1.51.18.4  02-Jul-2008  mjf Sync with HEAD.
 1.51.18.3  29-Jun-2008  mjf Sync with HEAD.
 1.51.18.2  02-Jun-2008  mjf Sync with HEAD.
 1.51.18.1  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.52.8.1  18-Jun-2008  simonb Sync with head.
 1.52.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.4.5  11-Mar-2010  yamt sync with head
 1.52.4.4  19-Aug-2009  yamt sync with head.
 1.52.4.3  20-Jun-2009  yamt sync with head
 1.52.4.2  16-May-2009  yamt sync with head
 1.52.4.1  04-May-2009  yamt sync with head.
 1.52.2.1  17-Jun-2008  yamt sync with head.
 1.56.12.1  21-Apr-2010  matt sync to netbsd-5
 1.56.6.1  11-May-2009  bouyer Pull up following revision(s) (requested by manu in ticket #749):
sys/dev/md.c: revision 1.58
TFTPROOT loads the RAMdisk through TFTP at boot time. It needs the
network to be functionnal, and therefore must be called after
config_finalize(). Unfortunately, config_finalize() attaches md0
through mdattach(), and when tftproot_getfile() attempts to attach it
later by calling mdattach() again, it gets a failure.
This change checks for the RAMdisk size in mdattach(). If it is zero, then
the RAMdisk has not been loaded yet, and nothing is done. It will be
attached later when tftproot_getfile() will call mdattach()
 1.56.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.57.2.2  23-Jul-2009  jym Sync with HEAD.
 1.57.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.62.4.1  05-Mar-2011  rmind sync with head
 1.62.2.2  18-Nov-2010  uebayasi Implement XIP in md(4).
 1.62.2.1  18-Nov-2010  uebayasi Sync with HEAD.
 1.66.14.1  05-Jul-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #395):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.95
sys/arch/atari/atari/autoconf.c: revision 1.62
sys/dev/md.c: revision 1.67
Add a dirty hack for atari's ancient installation ramdisk:
Forcibly configure md0, md1, and md2 devices before setroot()
for atari's traditional "auto-load from floppy on open" md_root device
which loads installation ramdisk image from floppy.
md(4) has been changed dynamically configured at first open after 5.0
and md devices won't appear in "root device:" prompt without this hack.
Tested on TT030.
Should be pulled up to netbsd-6.
Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().
Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.
Should be pulled up to netbsd-6 (at least for atari).
Add a sanity check if secsize returned from getdisksize() isn't bogus.
This prevent possible panic "panic: buf mem pool index 23" later in
vfs_bio.c:buf_mempoolidx().
(I'm not sure if it's okay for getdisksize() to assume that
partinfo taken from DIOCGPART is properly initialized
on all disk(9) devices or not)
See also:
http://mail-index.NetBSD.org/source-changes/2012/06/30/msg035298.html
 1.66.8.2  22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.66.8.1  30-Oct-2012  yamt sync with head
 1.67.4.1  18-May-2014  rmind sync with head
 1.67.2.2  03-Dec-2017  jdolecek update from HEAD
 1.67.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.2.1  10-Aug-2014  tls Rebase.
 1.71.4.5  05-Oct-2016  skrll Sync with HEAD
 1.71.4.4  19-Mar-2016  skrll Sync with HEAD
 1.71.4.3  22-Sep-2015  skrll Sync with HEAD
 1.71.4.2  06-Jun-2015  skrll Sync with HEAD
 1.71.4.1  06-Apr-2015  skrll Sync with HEAD
 1.76.2.7  06-Aug-2016  pgoyette Sync with HEAD
 1.76.2.6  28-Jul-2016  pgoyette Since md(4) has a pointer from the softc back to the device_t, it is
OK for us to use device_lookup_private_acquire() rather than calling
device_lookup_acquire() followed by device_private().

So, redo earlier changes, which reduces diff to the original code at
the branch-point.
 1.76.2.5  27-Jul-2016  pgoyette Repair the inevitable tyops in previous.
 1.76.2.4  27-Jul-2016  pgoyette Update a few more drivers for localcount(9)
 1.76.2.3  26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.76.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.76.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.78.6.6  17-May-2017  pgoyette At suggestion of chuq@, modify config_attach_pseudo() to return with a
reference held on the device.

Adapt callers to expect the reference to exist, and to ensure that the
reference is released.
 1.78.6.5  14-May-2017  pgoyette Mark variable as __diagused to fix build-break
 1.78.6.4  29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.78.6.3  28-Apr-2017  pgoyette Introduce config_detach_release() which does all the work from the
former config_detach(). Now, config_detach() simply acquires a
reference to the device, which config_detach_release() can release!

This is needed because some drivers call config_detach() with a
reference, while other drivers have not been updated to use the
localcount reference mechanism. So we provide a shim to make
everyone equal.
 1.78.6.2  27-Apr-2017  pgoyette Don't reference a known-NULL pointer, and remove duplicated calls to
mutex_enter() and mutex_exit()
 1.78.6.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.80.4.4  21-Apr-2020  martin Sync with HEAD
 1.80.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.80.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.80.4.1  10-Jun-2019  christos Sync with HEAD
 1.82.2.1  25-Jan-2020  ad Sync with head.
 1.83.4.1  20-Apr-2020  bouyer Sync with HEAD
 1.86.4.1  20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #884):

sys/dev/md.c: revision 1.87

It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.

RSS XML Feed