Commit Graph

40 Commits

Author SHA1 Message Date
thorpej b5a91dc24a Adapt to proplib API chanages. 2020-07-08 15:07:13 +00:00
tkusumi 67de4a9395 dm: #if0 target's ->upcall() handler
This is part of NetBSD's dm design, but unimplemented
(all handlers return 0) and also unused.
2020-01-21 16:27:53 +00:00
tkusumi ea24dc8dcc dm: Add dm-delay target
Ported from DragonFlyBSD, but this target had originally existed in
Linux kernel. See below for details.
https://www.kernel.org/doc/Documentation/device-mapper/delay.txt

Due to "tick" in hz(9) not working (which results in dmdlthread spinning
forever in _submit_queue() without dp extracted from delayed list
and queued into submit list), this hasn't been hooked to dm.kmod yet.

taken-from: DragonFlyBSD
2020-01-05 08:08:26 +00:00
tkusumi 8dab45b63f dm: Add dm-flakey target
Ported from DragonFlyBSD, but this target had originally existed in
Linux kernel. See below for details.
https://www.kernel.org/doc/Documentation/device-mapper/dm-flakey.txt

Due to two technical issues, this hasn't been hooked to dm.kmod yet.
1) "tick" in hz(9) not working.
2) Unable to use ->b_private in nestiobuf callback when it's already
 used for mbp (see HAS_BUF_PRIV2).

taken-from: DragonFlyBSD
2020-01-02 06:22:23 +00:00
tkusumi a9ece8969c dm: Make target's ->table() optional
Since ->info() (counter part of ->table() in the original dm design
in Linux kernel in .status where both INFO and TABLE are optional)
is an optional handler, make ->table() optional as well. Some
targets don't have anything to do in ->table() just as in ->info().

taken-from: DragonFlyBSD
2019-12-23 16:17:35 +00:00
tkusumi c281327782 dm: Fix dm-stripe's "status" output format
As mentioned in "dm: Don't try to implement "status" as subset of "table"",
dm-stripe in NetBSD doesn't have correct "status" output format.
Implement ->info() to sync with Linux kernel.

Note that num_error for stripe device isn't implemented yet.

taken-from: DragonFlyBSD
2019-12-21 16:00:29 +00:00
tkusumi ee87a3cadb dm: Remove target's ->deps() by implementing deps in dm core
Retrieving device dependencies doesn't need to be target specific.
The reason it currently needs ->deps() is because dm core doesn't
have data structure that allows table to walk through target's
underlying devices. Add struct dm_mapping to be able to do this,
and remove ->deps()'s from targets which basically do the same thing.

    =====(A) before this commit
    table
        |                                     [dm core]
    -------------------------------------------------------
        |           pdev      pdev      pdev  [dm targets]
        v          ^         ^         ^
        target----/---------/---------/
        (void*)

    =====(B) this commit
    table---->mapping-->mapping-->mapping-->...
        |           |         |         |
        |           v         v         v     [dm core]
    -------------------------------------------------------
        |           pdev      pdev      pdev  [dm targets]
        v          ^         ^         ^
        target----/---------/---------/
        (void*)

taken-from: DragonFlyBSD
2019-12-21 11:59:03 +00:00
tkusumi d2a4763044 dm: u_{int,long} -> unsigned {int,long} 2019-12-19 15:34:54 +00:00
tkusumi 84d4520665 dm: Enable dm-error and dm-zero target
Add these two targets to dm.kmod.
These are generally available in Linux and DragonFlyBSD,
so enable them in NetBSD as well.
2019-12-16 14:26:23 +00:00
tkusumi 46f1475944 dm: Style cleanups (no functional changes) 2019-12-15 14:39:42 +00:00
tkusumi b83e697e45 dm: Make targets' ->sync() optional
Apparently some targets have nothing to sync, so make it optional.
2019-12-15 10:12:45 +00:00
tkusumi 37b6bcc115 dm: Make targets' ->secsize() optional
and make a caller assume secsize 0 if ->secsize not present.
This allows a dummy function to be removed which was added in
"dm: Add dummy target ->sync()/->secsize() to prevent panic on modload(8)".
2019-12-15 09:42:29 +00:00
tkusumi 8026110e0c dm: Rename targets' ->status() to ->table() given ->info() exists
Since now that dm targets in NetBSD have ->info() for "status",
->status() should be renamed to ->table() for "table",
given how dm target status was originally designed in Linux kernel.

taken-from: DragonFlyBSD
2019-12-15 05:56:02 +00:00
tkusumi d9c59a056c dm: Remove void casts of function calls
Use of void casts in dm is not consistent, just get rid of them.
2019-12-14 10:49:30 +00:00
tkusumi 9a83c98b6e dm: Don't KASSERT() target handlers
Having assertions here causes panic if target is missing anything
as shown in "dm: Add dummy target ->sync()/->secsize() to prevent panic on modload(8)".
Instead just return EINVAL if a handler(s) isn't implemented.

taken-from: DragonFlyBSD
2019-12-13 16:15:54 +00:00
tkusumi 1c486dc61c dm: Unbreak compilation of kernel modules
The dm kernel modules (MK_DM_TARGETS enabled in sys/modules/dm/Makefile)
have been broken. Unbreak the build.
2019-12-08 10:35:53 +00:00
tkusumi b794fcf3ad dm: Fix strange pointer declarations
Should be "type *name" or "type* name", but not "type * name".
taken-from: DragonFlyBSD
2019-12-07 15:28:39 +00:00
tkusumi 312beb0985 dm: Simplify list eviction code
taken-from: DragonFlyBSD
2019-12-07 06:26:31 +00:00
tkusumi 592bc73589 dm: Don't ignore dm_target_alloc() argument
dm_target_alloc() is supposed to be copying the name argument to its ->name.
taken-from: DragonFlyBSD
2019-12-06 16:11:59 +00:00
tkusumi 9dea69368e dm: style + whitespace + indentation fixes
No functional changes.
2019-12-04 15:31:12 +00:00
tkusumi 6664a499fc dm: Make global dm locks static
These are all per-file locks which protect dev/pdev/target structure.
taken-from: DragonFlyBSD
2019-12-03 16:22:01 +00:00
christos 249cf59313 use some size_t, add whitespace between functions, rcsids. 2018-01-05 14:22:26 +00:00
snj f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
ahoka 7cc3650740 readd assertions noew with the correct struct
im wondering why the module cflags didnt warn about this obvious typo
2011-08-28 07:22:48 +00:00
joerg c5a7423167 Revert last, assertions on undefined variables don't make sense. 2011-08-27 23:31:12 +00:00
ahoka 0239807a25 Add a sanity check for missing functions in dmt 2011-08-27 17:06:08 +00:00
mlelstv 75268cff3f make dm aware of physical sector sizes.
For aggregates of multiple disks we use the largest sector size from
all disks. For standard power-of-2 sizes this is the same as the least
common multiple. We still require proper alignment of the targets in
the mapping table.

ok by haad@
2010-12-23 14:58:13 +00:00
pgoyette 23d5409e7e Update the rest of the kernel to conform to the module subsystem's new
locking protocol.
2010-08-21 13:19:39 +00:00
haad fb8751aba4 Add support for DIOCCACHESYNC ioctl for dm devices. Add new sync function
pointer to dm_target_t because that is the only part of dm which know real
block device. disk_ioctl_switch parses whole device table and for every
entry it calls particular sync routine which propagates DIOCCACHESYNC
to real disk.

While I was here implement some KNF fixes and remove unneeded symbols from
dm.h.

Problem reported on port-xen@ by Hugo Silva.
2010-05-18 15:10:38 +00:00
haad 293fc00622 Indent files remove unnecessary blank lines, white spaces and KNFize code. 2010-01-04 00:12:22 +00:00
haad 76a0c0e7d2 Fix bug in kmem_alloc/kmem_free of params string. Params string was
allocated with length DM_MAX_PARAMS_SIZE and released with strlen + 1 size.

Disable KM_NOSLEEP allocation because we do not need them here there is
nothing critical in ioctl part of dm driver.

Bug reported by jak@.
2009-09-09 22:38:49 +00:00
yamt 83723a32c5 fix a comment typo. 2009-08-16 11:02:24 +00:00
haad e654dd3da2 Call dm_target_busy only on properly autoloaded module. 2009-02-20 11:14:11 +00:00
haad d624725a46 In NetBSD our target modules are called with prefix dm_target_. Add this
prefix to target module name when loading module, lvm2tools uses linux
target names e.g. zero not dm_target_zero.
2009-02-19 23:20:27 +00:00
haad 17599f37f3 Add support for autoloading of device-mapper targets modules. Add
dm_target_autoload function which tries to load target module. Fix two
deadlocks in dm_table_load_ioctl error path(I forgot to call dm_dev_unbusy).
2009-02-19 23:07:32 +00:00
haad 894d2ad3b7 Add stubs for mirror target, too. This target does nothing for now, but lvm
tools support mirror target and trying to create LV with mirrorred backend
caused panic in dm_table_load_ioctl.
2009-01-02 11:03:24 +00:00
haad 32013fd9f2 Add stripe target functions stubs. Stripe target must be present in dm driver
because without it lvm2tools will not create LVsi and eventualy panic system.

Problem reported by agc@.
2009-01-02 00:42:31 +00:00
haad cca8fb31f9 Add support for loading dm targets as separate modules. All targets except
linear can be loaded as module. Module is not loaded when there is target
with similar name already. Zero and error targets aresimple examples how
can be all future targets written to support dynamic loading. Target can't
be unloaded until there is at least one user.
2008-12-21 00:59:39 +00:00
haad 78284dcaf1 Add infrastructure needed to load device-mapper targets as modules.
Targets wasn't converted yet and at least snapshot target will be converted
in a near future.
2008-12-19 16:30:41 +00:00
haad c9d0c62a0c Merge the haad-dm branch to -current. This branch adds LVM functionality to
the base NetBSD system. It uses Linux LVM2 tools and our BSD licensed
device-mapper driver.

The device-mapper driver can be used to create virtual block devices which
maps virtual blocks to real with target mapping called target. Currently
these targets are available a linear, zero, error and a snapshot (this is
work in progress and doesn't work yet).

The lvm2tools adds lvm and dmsetup binary to based system, where the lvm
tool is used to manage and administer whole LVM and the dmestup is used to
communicate iwith device-mapper kernel driver. With these tools also
a libdevmapper library is instaled to the base system.

Building of tools and driver is currently disable and can be enabled with
MKLVM=yes in mk.conf. I will add sets lists and rc.d script soon.

Oked by agc@ and cube@.
2008-12-19 15:24:03 +00:00