Commit Graph

114 Commits

Author SHA1 Message Date
jdolecek 5ad012e578 pass also DIOCGCACHE to underlying device, so that upper layers would be able
to get device cache properties without knowing the topology
2017-02-27 21:25:45 +00:00
kamil b837326c3b The cgd(4) module requires des and blowfish symbols
This has been exposed with the MODULAR kernel.

kobj_checksyms, 979: [cgd]: linker error: symbol `BF_set_key' not found
kobj_checksyms, 979: [cgd]: linker error: symbol `des_key_sched' not found
kobj_checksyms, 979: [cgd]: linker error: symbol `des_ede3_cbc_encrypt' not found
WARNING: module error: unable to affix module `cgd', error 8

Reviewed by <riastradh>
2016-12-22 20:57:33 +00:00
alnsn b21f21df5a Add XTS mode to cgd(4). 2016-12-11 00:20:49 +00:00
mlelstv f7dd6a088f Fix error handling in cgdstrategy().
- check cgd_softc != NULL, may happen in rare memory shortage situations.
- no longer test geometry, the same check is done in dk_strategy which
  knows to check for an uninitialized geometry.
2016-09-14 23:16:30 +00:00
pgoyette 106cffc32f Ignore return values when restoring what has just been undone. We're
really just putting back something that was there before, so we should
not get any errors, and a panic() would be rather severe.

This and the corresponding commit to vnd.c address newly reported
Coverity CID 1364761 and CID 1364760
2016-08-05 08:24:46 +00:00
pgoyette 9e4ecfb022 When initializing the rump cgd component, use the correct driver name
(as found in the devsw_conv[] table).  This will get us the "official"
major numbers for the cgd device.

After creating the rump file-space nodes for /dev/cgd* we then need to
detach the [bc]devsw's because normal module initialization will do its
own attachment, and we don't want that to fail.

While here, since we're doing the devsw_attach() twice, share the
results from the first call rather than starting from scratch.
2016-07-25 12:45:13 +00:00
riastradh de8d1fd320 Make kernel core dumps on cgd(4) work. 2016-07-10 17:40:23 +00:00
msaitoh 8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
mlelstv 174162494b Remove bogus dk_getdisklabel call.
- there is no need to read the label in the attach routine
- passing a (dev_t)0 may cause havoc.

This fixes PR 41704.
2015-11-28 21:06:30 +00:00
mlelstv 9c6a5e265b Inherit sector size from underlying disk to support disks with
sector sizes other than 512 bytes.

The CGD disk image depends on disk geometry as it encodes the block
number into each block. You cannot copy an image between disks
with different sector sizes.
2015-11-28 14:45:24 +00:00
mlelstv 7874349bce 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.
2015-08-27 05:51:50 +00:00
christos 0306f29940 don't allow STRATEGY if we are not inited. 2015-08-21 09:33:53 +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 20902f791f restart queue when a request completes 2015-08-19 20:15:20 +00:00
mlelstv 155f12a589 restore deleted lines that kept buffer fields resid,count and error consistent. 2015-08-18 21:24:19 +00:00
mlelstv 28e124faa7 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.
2015-08-16 18:00:03 +00:00
mlelstv 5f99165065 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
2015-05-02 08:00:08 +00:00
riastradh f6ff1e4bbc Use explicit_memset to zero key material. 2015-04-25 13:06:11 +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 429dd9f14e these call dk_ioctl, no need to call disk_ioctl anymore. 2015-01-02 01:13:00 +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 e0e2723470 return quickly from the GET ioctl to avoid playing with NULL. 2014-12-30 20:18:44 +00:00
mlelstv ddeda108d6 use disk_ioctl to provide DIOCGDISKINFO. 2014-12-29 18:23:57 +00:00
justin 1d1c6d781a devmajor_t not int 2014-10-02 21:01:38 +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
hannken 292a0c7f1d Change dk_lookup() to return an anonymous vnode not associated with
any file system.  Change all consumers of dk_lookup() to get the
device from "v_rdev" instead of VOP_GETATTR() as specfs does not
support VOP_GETATTR().  Devices obtained with dk_lookup() will no
longer disappear on forced unmounts.

Fix for PR kern/48849 (root mirror raid fails on shutdown)

Welcome to 6.99.44
2014-06-14 07:39:00 +00:00
bouyer 2745b95e5c As proposed in
https://mail-index.netbsd.org/tech-kern/2014/05/21/msg017098.html
remove dk_start() and dk_iodone() from dksubr.c and move the related code
to the underlying driver.
This increase complexity only marginally: the underlying drivers have
to do the while() loop themselves, but this can now be done properly with
bufq_peek()/bufq_get(), removing the buffer from the queue at the right time.
This handle both the recursion and reordering issues (the reordering
issue is described here:
https://mail-index.netbsd.org/tech-kern/2014/05/19/msg017089.html
the recursion isssue is PR #25240).

Difference with the patch posted to tech-kern@: KASSERT() that the
buffer we remove with bufq_get() is the same as the one we bufq_peek()'d
just before.
Hopefully this will allow more disk drivers to use dksubr.c
2014-05-25 19:23:49 +00:00
christos 1b2d99ce97 create on attach needs destroy on detach. 2014-05-25 19:15:50 +00:00
skrll b7fe3a93a8 Remove a simplelock and replace with a kmutex 2014-03-18 15:44:37 +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 e5a29159a9 Make dksubr.c into a module, and make the cgd and dm modules depend on
it.

Now that cgd is completely modularized, descend into modules/cgd to
actually create the module.
2013-12-28 19:25:07 +00:00
martin 822c138d8c #ifdef variable declarations/initializations like their use 2013-09-12 12:28:49 +00:00
martin 0664111be5 Avoid dereferencing an uninitialized pointer 2013-05-30 08:28:13 +00:00
christos 1af75d448c eliminare dk_geom 2013-05-29 23:25:39 +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
christos 0f179f793d add cgdconfig -l like vnconfig -l 2012-12-05 02:23:20 +00:00
elric 99c563ccca Modify dksubr.c to add a function that sets the disk properties in
the drvctl framework.  And call this new functionality from cgd(4),
the consumer of dksubr.c.  We do this to allow gpt(8) to be able
to label cgd(4) disks.  We also add in some DIOCGSECTORSIZE logic
and we ensure that the WEDGE ioctls are not called on either
uninitialised disks or disks which have not been opened for write
access.
2012-05-25 10:53:46 +00:00
christos 9fc82cfc97 use getdisksize() instead of homebrew() 2011-11-13 23:03:24 +00:00
hannken 2cc7a01f10 Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock.  Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
2011-10-14 09:23:28 +00:00
jruoho b4a3a8f3ec Adjust the #ifdefs such that ccd(4) and cgd(4) show in
modstat(8) even if built into the kernel.
2011-06-21 06:23:38 +00:00
rmind e225b7bd09 Welcome to 5.99.53! Merge rmind-uvmplock branch:
- Reorganize locking in UVM and provide extra serialisation for pmap(9).
  New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
  the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
  Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
  kernel-lock on some ports).  Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
2011-06-12 03:35:36 +00:00
riastradh 1e0dbea92c Reject unaligned writes to cgd.
Fixes the following PRs:

PR kern/44515 (cgd dies on non-aligned writes to the raw device)
PR kern/44964 (cgd seems to panic on unaligned writes instead of giving EINVAL)

ok christos
2011-05-19 20:34:13 +00:00
dholland 8f6ed30d57 Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
2010-11-19 06:44:33 +00:00
joerg b6f836a257 Register with pmf. 2010-02-11 18:24:48 +00:00
bouyer 5d530cfdab struct buf::b_iodone is not called at splbio() any more.
Make sure non-MPsafe iodone callbacks raise the SPL as appropriate.
Fix buffer corruption issue I noticed in dk(4), and probable similar
issues in vnd(4) and cgd(4).
2010-01-23 18:31:04 +00:00
dyoung 146411a622 Cosmetic: get out of cgdioctl() early. Instead of
int ret;

        switch (...) {
        case ...:
                ret = ...;
                break;
        }
        return ret;

write:

        switch (...) {
        case ...:
                return ...;
        }
2010-01-20 19:00:47 +00:00
dyoung c95d6a20b9 Get out of cgd_detach() early on error. Do not call disk_destroy(9)
on error, that leaves the cgd_softc in an inconsistent state.

Fixes a crash during shutdown reported by Patrick Welche.  Thanks
to Patrick for reporting and for testing the fix.
2010-01-20 18:55:17 +00:00
dyoung 08d9aa56c1 Provide a more complete modules hook, cgd_modcmd(), derived from
vnd_modcmd().
2010-01-12 23:49:34 +00:00
dyoung 1b379d7ac4 Make cgd(4) into a detachable pseudo-device. Thanks, Jan Danielsson,
for the patches!

I've lightly tested the basics: create cgd0 on vnd0d, initialize with
zeros, newfs /dev/cgd0a, mount, copy files on, unmount, drvctl -d
cgd0.  Works fine.  I also shutdown with a cgd0 configured: detached as
expected.
2010-01-12 21:08:08 +00:00