summaryrefslogtreecommitdiff
path: root/sys/dev/vnd.c
AgeCommit message (Collapse)Author
2011-08-26Add a dmesg warning about sloppy disk I/O to vnd(4) devices to helpMatthew Dempsky
identify bad distrib scripts/tools. ok deraadt@
2011-07-18Revert vnd(4) to its older less strict behavior.Matthew Dempsky
Verified by deraadt@ to fix distrib/sgi/iso.
2011-07-12Range check vnd_secsize, vnd_ntracks, and vnd_nsectors so that later onTheo de Raadt
they do not get integer truncated on 64-bit machines. ok matthew
2011-07-08Ack, my last change used size_t for file offsets, but size_t is onlyMatthew Dempsky
32-bit on 32-bit architectures; we need off_t to support >4GB vnd(4) images. Discovered by, tested, and ok bluhm@
2011-07-08Refactor vnd(4) to use vn_rdwr() instead of setting up the uio/iovecMatthew Dempsky
structs and calling vn_lock+VOP_READ/WRITE+VOP_UNLOCK.
2011-07-08Validate DISKUNIT(dev) in vndstrategy() like we do in otherMatthew Dempsky
xxstrategy() methods, and punt in validating it in vndread() and vndwrite() (also like we do in other xx{read,write}() methods...).
2011-07-08Add a vndencryptbuf() function, and refactor vndstrategy() slightly toMatthew Dempsky
use it instead.
2011-07-06vndsize() can just return -1; we don't support swapping to vndMatthew Dempsky
anymore.
2011-07-06Compact the vnd sc_flags bits.Matthew Dempsky
ok krw@
2011-07-06Eliminate some sanity checks in vndstrategy() that are now handled byMatthew Dempsky
bounds_check_with_label().
2011-07-06vndstrategy() should fail if VNF_HAVELABEL isn't set. This simplifiesMatthew Dempsky
the logic slightly and makes vnd(4) more like any other disk driver. To avoid races, this means vndopen() can only set VNF_HAVELABEL if dk_openmask == 0. Otherwise, it's possible for userspace to open rvnd0c, call VNDIOCSET, open vnd0a, then while vndreaddisklabel() (via vndstrategy) is waiting for VOP_READ() to finish, you could issue a read or write on the still open rvnd0c and have VNF_HAVELABEL set but the disklabel might be in a weird state. Note that this makes VNF_HAVELABEL nicely analogous to sd(4)/cd(4)'s SDEV_MEDIA_LOADED flag, which is handled similarly in {sd,cd}{open,close,strategy}. ok dlg@, krw@, deraadt@
2011-07-06Eliminate redundant buf validation checks in xxstrategy() methods nowMatthew Dempsky
that they're implemented consistently in bounds_check_with_label(). Also, per krw's request, change bounds_check_with_label() to return 0 if the checks succeed, and change the drivers to test == -1 instead of <= 0. (Man page update to follow; intentionally omitting arch/vax/mba/hp.c from this commit because it doesn't even build currently and miod@ promises to kill it soon.) ok krw@
2011-07-04move the specfs code to a place people can see it; ok guenther thib krwTheo de Raadt
2011-07-03Cleanup vnd(4) a bit now that it only has one mode of operation andMatthew Dempsky
uses standard disk device numbering. ok deraadt@
2011-07-03Fix vnd(4) support for read-only files. We can't clear sc_flagsMatthew Dempsky
before closing the vnode, because VNDRW() checks for the VNF_READONLY bit and the vnode layer doesn't like it when you close a read-only vnode with FREAD|FWRITE. ok deraadt@
2011-06-30Refactor some common open/close/detach disk driver code intoMatthew Dempsky
subr_disk.c. For now just the MI disk drivers. ok deraadt@, krw@; jsing@ liked the approach too
2011-06-21looks like the disk_lock method actually does workTheo de Raadt
2011-06-20explicit_bzero for the crypto keyTed Unangst
2011-06-20for now, move back to a private rw_lock rather than the disk_lock.Theo de Raadt
we have problems with instantiating new disks ok matthew
2011-06-19Use disk_lock_nointr() in the xxclose() routines so that they cannotTheo de Raadt
be interrupted. ok matthew
2011-06-19Use disk_lock/disk_unlock directly and in the same way in these drivers,Theo de Raadt
rather than using various wrappings. Convert vnd to using the sc_dk rwlock instead of using one of its own. ok matthew
2011-06-19and in debug code, tooTheo de Raadt
2011-06-19stop trying to be clever with the softc nameTheo de Raadt
2011-06-09shorted code with a lovely gotoTheo de Raadt
ok matthew
2011-06-05Drop kernel support for the useless DIOCWLABEL ioctl and prune a lotMatthew Dempsky
of silly flag twiddling code in various disk drivers. ok deraadt@, miod@ N.B., users will need a -current disklabel(8) to be able to write new disklabels to disk now.
2011-06-03Get rid of the wlabel argument to bounds_check_with_label(). It'sMatthew Dempsky
never done anything in OpenBSD and just clutters disk drivers with silly flag handling. More cleanup to follow. ok deraadt@, millert@; no objections krw@
2011-06-02No need to set error to 0, when it is still 0 from the start of the function.Theo de Raadt
ok thib matthew
2011-06-02The vndbufpl is no longer used.Theo de Raadt
Spotted by matthew, verified by me.
2011-06-02Initialize the dv_xname at attach time, so that we don't have to doTheo de Raadt
this work later. Since the disk always has the same name (the different between svnd and vnd went away), we don't need to do this late anymore. Spotted with matthew.
2011-06-02In vndclear(), clear all the flag bits. Leaving around a VNF_WLABEL bitTheo de Raadt
is stupid (verified to be the case). Other flag bits might have lived longer than they should as well, with unknown consequences. Spotted with matthew, too.
2011-06-02Initialize the dv_unit, because disk_attach will want it later. BeforeTheo de Raadt
we were probably only ever reading labels off vnd0. Oops. Spotted by matthew
2011-06-02Do not bzero the softc when doing VNDIOCCLR, because that trashes theTheo de Raadt
rw_lock and the device_ref Discussed with thib and matthew
2011-06-02device_ref() by hand, since this is a pseudo-device and was not attachedTheo de Raadt
through config_attach() ok matthew jsing
2011-05-31Change a few of the more common disk drivers (sd, cd, wd, rd, and vnd)Matthew Dempsky
to return EBUSY if the user tries to modify an open partition's offset or size. Only sadness can result if a user tries this, and rejecting it prevents a race between sdstart() and sdstrategy(). Curiously, there was already code in the kernel and in disklabel(8) to detect/handle this, but it was effectively disabled because the disk drivers always used something like "/* sc->sc_dk.dk_openmask */ 0", and this commented out code has existed since even r1.1 in NetBSD. I had no problems building a release and messing around with disklabel(8) for a bit with this diff. Canarying the more common MI disk drivers until we gain confidence that there aren't any regressions, then we can switch the remaining drivers. "I am surprised you got me convinced that this stuff is safe" deraadt@ ok krw@
2011-05-30Remove vndshutdown. It is unused.Owain Ainsworth
``sure'' deraadt@
2011-04-25Remove backwards compatibility for svnd. All new operations must use theTheo de Raadt
vnd devices nodes, which impliment svnd functionality -- that being the only thing which vnd now supports. Confused? Don't worry, it is documented. ok krw thib
2011-04-23Remove now unused vndiodone(). ok deraadt@Miod Vallat
2011-04-23The previous code only prevented the vnd from being opened for write inJoel Sing
both simple and non-simple mode. Restore this behaviour by removing the openmask check.
2011-04-23backout the miod change since it is wrongTheo de Raadt
2011-04-22Fix regression in vndopen() behaviour introduced in previous commit.Miod Vallat
2011-04-18remove the old style by-pass-the-buffer-cache vnd code.Thordur I. Bjornsson
this will treat vndX the same as svndX. ok and gcc2 fixes from deraadt@
2011-04-02Remove bufqs from vnds, as the disk that houses the imageThordur I. Bjornsson
backing the vnd also has a bufq. So the buf is just passed between the vnd bufq and the disk bufq (almost immediately). Also see previous revision for more insight. OK deraadt@, dlg@
2011-02-15A vnd buf doesn't only go through the vnd bufq but also the bufqThordur I. Bjornsson
for the device on which the vnd image resides on, this has the effect that a bufq_done call is done in the context of the underlaying bufq, setting b_bq to NULL, meaning there is never a bufq_done call done for the vnd bufq so the outstanding count never decreses. Add one in vndiodone. This fixes the suspsend issues krw@ was running into. ok tedu@, krw@ nod from miod@ on the commit.
2011-01-06init and destory the bufq in the ioctl handler, asThordur I. Bjornsson
the softc is zero'ed when the vnd is unconfigured; otherwise we blow up when configuring a vnd the second time since the bufq structure is kaputt. found by and OK krw@
2011-01-05cut vnd over to using bufq's again.Thordur I. Bjornsson
OK dlg@, beck@, krw@.
2010-12-22When configuring a vnd(4) disk, populate the disk name based on the modeJoel Sing
in which it was configured. If this is a "safe" vnd disk the name should be "svndX" whereas a standard vnd disk should be named "vndX". ok deraadt@ todd@ thib@
2010-09-22All users of physio(9) now pass NULL as the buf pointer argument, soMatthew Dempsky
no point in keeping it around. "i like this" thib@ (a while back); ok krw@ and oga@; reminder to update the man page and tweaks jmc@
2010-09-08Store a struct device pointer within struct disk and populate this whenJoel Sing
disk_attach() is called by the device driver. We will be building on this shortly. ok deraadt@ krw@
2010-08-28Garbage collect struct dkdriver.Matthew Dempsky
ok miod@; "please go ahead" jsing@
2010-07-22Instead of trying to biowait on a buf that has errored, do theThordur I. Bjornsson
right thing, throw it away by marking it as B_INVAL and setting the B_ERROR flag and b_error to the errno that was returned. B_RAW doesn't matter there. Issue report my mlarkin@, this diff tested and confirmed to fix the issue by mlarkin also, thanks! OK krw@, beck@, deraadt@