Commit Graph

269 Commits

Author SHA1 Message Date
mlelstv
4ceeb5eaf7 Use IO_DIRECT for file I/O to reduce buffer cache contention.
Restore old behaviour to flush pages only when usage exceeds 1MB.

No longer use PGO_SYNCIO, regular writes to the device do not require
the data to reach stable storage, the DIOCCACHESYNC ioctl is used
for that.
2018-10-07 12:00:07 +00:00
mlelstv
eff8919f63 Calculate a missing cylinder count in the geometry spec from image size. 2018-10-07 11:54:14 +00:00
mlelstv
803c93c66f Add flag to enforce file I/O even when bmap/strategy would be possible.
This makes it easier to compare both modes, it also allows coherent
operation between vnd device and image file.
2018-10-07 11:51:26 +00:00
hannken
fef73d22c5 Bring back three state file system suspension:
NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)
2018-10-05 09:51:55 +00:00
mlelstv
289f3a91a7 getdisksize only operates on device vnodes. Use the ioctl on the underlying
device instead.
2018-09-20 07:18:38 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
riastradh
1f73c3c78a Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h". 2017-10-28 03:47:24 +00:00
riastradh
49e522ca87 Appease toxic bullshit warning from gcc.
If you have a better way to write a useful bounds check that happens
to always pass on LP64 but doesn't always on LP32, without making it
fail to compile on LP64 or making it an #ifdef conditional on LP32,
please put it in here instead.
2017-07-28 16:30:41 +00:00
riastradh
c22f09e921 Fix indentation. u_intN_t -> uintN_t. ntohl -> be32toh.
No functional change intended.
2017-07-28 16:22:01 +00:00
riastradh
f92d8e549d Put in a litany of judicious bounds checks around vnd headers.
Thought I was done with this crap after I rewrote vndcompress(1)!

From Ilja Van Sprundel.
2017-07-28 16:19:20 +00:00
pgoyette
4714fa2a1d Don't display step-by-step detailed error messages unless DIAGNOSTIC.
Among other things, this avoids expected "error messages" when the
module is being auto-unloaded while one or more units are still in
use.
2017-03-25 07:00:33 +00:00
pgoyette
c8a6580a87 Ignore return values when backing out of a "finish" sequence. There
really shouldn't be any errors here (we're just putting something back
that previously existed), and a panic() would be rather drastic.
2016-08-05 08:21:24 +00:00
pgoyette
7ea3f07f30 When calling devsw_attach() we need to use the expected/official driver
name (as listed in the devsw_conv[] table) to get the expected device
majors.  Once rump initialization is finished (ie, it has created its
required device nodes), we need to detach the [bc]devsw so the module
initialization code doesn't get EEXIST.
2016-07-26 01:49:48 +00:00
christos
8d10f96266 Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
2015-12-08 20:36:14 +00:00
mlelstv
3972fec404 Fall back to VOP_READ/VOP_WRITE if the simulated disk has smaller
sectors than the underlying filesystem and VOP_STRATEGY would fail.
2015-11-30 06:04:47 +00:00
christos
2a5df0a68f Use the new DK_DEV_BSIZE_OK() macro. 2015-11-12 15:28:07 +00:00
christos
799fe5d0c9 fix incorrect memset. 2015-11-12 02:06:36 +00:00
christos
b1528c6989 explain why the int cast works (suggested by kre) 2015-11-09 17:52:59 +00:00
christos
f095feefbc Return ENXIO if the get ioctl exceeds the number of configured devices.
XXX: pullup-7
2015-11-09 17:41:24 +00:00
christos
09d8214348 disable debugging 2015-11-09 16:54:26 +00:00
christos
646ed23fbb Simplify ioctl handling a little. 2015-11-09 16:52:09 +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
6297339c02 use dk_openlock when accessing openmask. 2015-08-02 11:40:41 +00:00
prlw1
43f47764df Print vndattach error 2015-07-28 13:12:47 +00:00
prlw1
4b3129d595 typo 2015-05-25 21:02:37 +00:00
prlw1
bc27eabab7 whitespace police 2015-05-25 20:57:18 +00:00
mlelstv
6f00c789e1 Use C99-style initializers for struct dkdriver. 2015-04-26 15:15:19 +00:00
mlelstv
e3844e18d1 Make DIOCKLABEL work. Set default to keep the disklabel after close to
not change current behaviour.
2015-04-06 12:02:08 +00:00
bouyer
f131b692ba Fix typo in comment 2015-01-28 16:27:43 +00:00
bouyer
c761b66141 As discussed in
http://mail-index.netbsd.org/tech-kern/2015/01/24/msg018339.html
don't bump v_numoutput if we need to vn_lock() the vnode before queuing
the corresponding I/O, because this may deadlock with genfs_do_putpages()
when called with the vnode locked (as can happen with fsync(2)).
Instead bump is just before the last VOP_STRATEGY(), or before calling
nestiobuf_done().
Thanks to Taylor R Campbell for review.
2015-01-28 15:08:12 +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
christos
3be6bb2414 Centralize wedge ioctls in disk_ioctl. 2014-12-31 17:06:48 +00:00
mlelstv
bdddf44518 disk_blocksize and disk_set_info relay the same information
to the disk subsystem.

Make disk_set_info also set blocksize shift values.
Remove every call to disk_blocksize.

Keep disk_blocksize for ABI compatibility, make it also set dg_secsize.
2014-12-31 08:24:50 +00:00
mlelstv
8e4ce8bea0 Fix default label for non-standard sector size.
Avoid integer overflow in sanity check.
2014-12-29 13:13:20 +00:00
mlelstv
64c07f5206 support DIOCMWEDGES ioctl. 2014-11-04 07:51:54 +00:00
mlelstv
53385cb9cd clamp total number of sectors to UINT32_MAX instead of providing the
lower 32bit of the 64bit number.
2014-10-11 12:01:27 +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
pooka
533f74815a Fix MODULE() dependencies to account for VND_COMPRESSION 2014-07-22 13:32:59 +00:00
prlw1
33609e8501 DIOCGDISKINFO support for vnd
Reviewed by apb@ and christos@
2014-03-22 16:08:51 +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
pgoyette
1b0023ef9a Modularize net/zlib so it can be used by the vnd module (and, eventually,
by an opencrypto module).
2013-12-29 08:09:44 +00:00
martin
7dbdb14bec Remove unused variable 2013-09-15 15:57:26 +00:00
christos
a6933efe77 Never return ENXIO in ioctl anymore. We don't have a fixed number of vnd's
configured.
2013-06-09 13:26:25 +00:00
christos
2fa09f799a widen the operation on the RHS as suggested in the PR. 2013-06-03 21:01:18 +00:00
christos
417a118725 PR/47879: Takahiro HAYASHI: vnd cannot handle disk image larger than 2TiB
change size_t to uint64_t where needed.
2013-06-03 16:42:32 +00:00
christos
7b845fa9dc phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
	  n useless copies of it.
2013-05-29 00:47:48 +00:00
mlelstv
b416153514 autodiscover wedges 2012-06-09 06:20:45 +00:00
hannken
68e229c7e8 When backed by a sparse file limit the number of pending requests.
Should fix PR #45829: "writing to vnd on sparse file blocks on pager_map"
where the pager_map gets exhausted by requests enqueued on a vnd
device and the device worker thread blocks on putpages() needing the map.

While here always sync the underlying vnode before calling biodone().

XXX: vnd should be converted to mutex/condvar.
2012-03-26 16:28:08 +00:00