Commit Graph

78 Commits

Author SHA1 Message Date
pgoyette
827e59d955 Don't mutex_exit() if we didn't mutex_enter().
Pointed out by coypu. Thanks!
2016-07-27 05:14:40 +00:00
pgoyette
2d03daa3b0 If we're going to check for a NULL pointer, do the check before we
dereference it (to get the lock address).
2016-07-27 01:09:44 +00:00
hannken
0d7df2cb48 Notify disk subsystem of the current geometry.
Ok: Michael van Elst
2016-01-04 16:24:52 +00:00
christos
e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
mlelstv
6f00c789e1 Use C99-style initializers for struct dkdriver. 2015-04-26 15:15:19 +00:00
christos
c182898b0d 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.
2015-01-02 19:42:05 +00:00
christos
c60db2e923 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.
2014-12-31 19:52:04 +00:00
dholland
f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland
8c70ef39af 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.
2014-07-25 08:02:18 +00:00
dholland
a68f9396b6 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.
2014-03-16 05:20:22 +00:00
hannken
e331e1e077 No need to detach (and return EBUSY) if dk_openmask is non-zero. 2014-03-13 10:22:35 +00:00
tsutsui
4403aae449 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).
2012-06-30 10:52:31 +00:00
hannken
83b532dd44 - Don't detach configured devices on last close.
- No kmem allocation and biodone() under lock (from rmind@netbsd.org).
2010-11-25 08:53:30 +00:00
hannken
cec7ede499 Make md(4) mp-safe. 2010-11-23 09:30:43 +00:00
pooka
22506639fc Don't have a COW (Compiler OW) in case there is no kernel_opt. 2010-11-22 21:10:10 +00:00
hannken
c7919375e5 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>
2010-11-11 11:07:06 +00:00
dyoung
975667d3ea Take care not to dereference a NULL softc. 2010-01-21 02:14:42 +00:00
snj
b094016798 Drop 3rd and 4th clauses. OK gwr@ leo@ (copyright holders). 2009-10-22 20:15:45 +00:00
dyoung
974833df66 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.
2009-07-28 17:55:27 +00:00
dyoung
9167c17dd5 Add a detachment hook. Detach md(4) at shutdown. 2009-05-19 20:25:41 +00:00
manu
c328d568d4 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()
2009-05-04 16:20:41 +00:00
yamt
70de973662 g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
drochner
c4003ef269 more cleanup: the sc_dev backpointer is unused, remove it 2008-06-16 10:27:47 +00:00
cegger
13a6ae7a5f register NULL pmf handlers. md(4) is supposed to not loose / change when resuming from S3. 2008-06-13 20:05:06 +00:00
cegger
9fca1f317d device_t/softc split
while here, remove unused variables and do some other cleanups
with feedback from cube
2008-06-13 19:55:26 +00:00
drochner
29fbb6a62e 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.
2008-06-11 10:38:44 +00:00
cegger
c1886a2781 use aprint_*_dev and device_xname 2008-04-09 05:47:19 +00:00
ad
2af68666da Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
2007-10-08 16:41:05 +00:00
ad
eb171eaaa7 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.
2007-07-29 12:50:17 +00:00
dsl
9a71120654 Default MEMORY_DISK_SERVER to 1 instead of using 'undefined' to mean 1. 2007-07-15 08:40:22 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
christos
168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos
a569a4d291 add missing initializer 2006-09-02 07:01:20 +00:00
thorpej
39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt
aec75b1cc6 - 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)
2005-10-15 17:29:10 +00:00
yamt
6b2d8b66a4 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.
2005-04-01 11:59:21 +00:00
perry
f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
yamt
05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
thorpej
b560f85cc5 Use ANSI function decls, sprinkle static. 2004-08-30 00:34:41 +00:00
itojun
d2f1c029b9 kill sprintf, use snprintf 2004-04-21 18:40:37 +00:00
fvdl
d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr
960df3c8d1 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
2003-06-28 14:20:43 +00:00
thorpej
50e0b3a100 Use aprint_error() where appropriate. 2003-05-13 02:56:13 +00:00
atatat
944cb6f8ff Add /* MEMORY_DISK_SERVER */ comments to the #endifs to match the #ifdefs. 2002-12-11 16:24:38 +00:00
jdolecek
e0cc03a09b 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
2002-10-23 09:10:23 +00:00
gehenna
77a6b82b27 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.
2002-09-06 13:18:43 +00:00
hannken
7de36862a8 Rename bufq_init() to bufq_alloc().
Add bufq_free() to remove a buffer queue.
Avoid MALLOC while holding a spinlock.

From Chuck Silvers.
2002-07-21 15:32:17 +00:00
hannken
96ea8912e6 Convert to new device buffer queue interface. 2002-07-20 11:28:07 +00:00