Commit Graph

184 Commits

Author SHA1 Message Date
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
maya 2ff3c6f126 dm(8) doesn't cause problems on suspend, don't block it.
Tested by Matthias Petermann, thanks!
2020-01-16 07:18:08 +00:00
tkusumi 05e54a628c dm: Add "Copyright (c) 2015 The DragonFly Project." to dm-flakey
which I missed in my initial dm-flakey commit.
2020-01-05 08:11:10 +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 7b5209fa85 dm: Remove unnecessary inlining
These two don't really need to be inlined.
2019-12-31 10:30:30 +00:00
tkusumi d7c965d706 dm: Fix typo in comment dklinear -> linear 2019-12-28 15:38:16 +00:00
msaitoh e992133145 s/suport/support/ 2019-12-27 09:22:19 +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 9c30b6c561 dm: Make numsec/secsize arguments in dm_table_disksize() optional 2019-12-22 13:16:09 +00:00
tkusumi e31180cc71 dm: Add missing "ioctl called" debug prints 2019-12-22 12:28:54 +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 aecedc2e33 dm: Fix "table" output format of dm-linear and dm-stripe
The existing "table" output showing device file path of pdev is
not compatible with dm in Linux kernel (and also DragonFlyBSD).
It should be showing "major:minor" instead.

taken-from: DragonFlyBSD
2019-12-20 16:16:36 +00:00
tkusumi 3e0e126e35 dm: Minor dm_ioctl.c fixes (indentation/typo/type/etc) 2019-12-19 16:27:39 +00:00
tkusumi b0538cc5a1 dm: Refactor dmioctl()
More readable without dm_ioctl_switch() as a separate function.
2019-12-19 15:57:46 +00:00
tkusumi d2a4763044 dm: u_{int,long} -> unsigned {int,long} 2019-12-19 15:34:54 +00:00
tkusumi 945ce57bcf dm: Test # of args in target's ->init()
The # of args is part of target's spec.
Both Linux kernel and DragonFlyBSD test argc on ctr/init.
2019-12-18 14:31:35 +00:00
mlelstv cea9bbee01 Add error and zero targets to build. 2019-12-17 07:57:25 +00:00
tkusumi 46b8a4bca5 dm: Cleanup dm.h (remove unneeded comments, etc) 2019-12-16 15:59:04 +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 e4ac703578 dm: Rename dm specific atoi() to atoi64()
This is uint64_t version, not sys/lib/libsa/atoi.c.
2019-12-15 16:14:27 +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 c3c15a2869 dm: "unsigned" -> "unsigned int" for consistency
Use either one, but not both.
2019-12-15 09:22:28 +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 47e84ce6c8 dm: Don't try to implement "status" as subset of "table"
The way dm_table_status_ioctl() implements "status" and "table" is
not compatible with Linux kernel. Some targets have different outputs
that "status" can't be implemented as subset of "table".

Add ->info() handler to sync with "status" behavior in Linux kernel.
Some targets which currently exist in NetBSD (I think striped)
as well as some minor targets that I plan to port to NetBSD
can/should implement ->info(), but will do that in a different commit.

taken-from: DragonFlyBSD
2019-12-14 17:15:54 +00:00
tkusumi aa6dca195e dm: Make dm_dbg_print_flags() take uint32_t flag
which comes from prop_dictionary_get_uint32() result.
taken-from: DragonFlyBSD
2019-12-14 14:43:38 +00:00
tkusumi 5449798710 dm: Move extern declaration of global variables to dm.h 2019-12-14 11:20:51 +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 0d0a6d2316 dm: Remove unconditional debug prints in targets' ->strategy()
Having debug prints in ->strategy() by default just to tell ->strategy()
is called is overkill.
taken-from: DragonFlyBSD
2019-12-14 10:02:35 +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 e5fc44006e dm: Fix memory leak in dm_pdev_rem()
Need to free dmp regardless of dm_pdev_rem() return value.
taken-from: DragonFlyBSD
2019-12-13 15:49:22 +00:00
tkusumi d14bb027b6 dm: Make target's ->init() take parsed argc and argv
This gets rid of the same parser code in each target using strsep(3).
taken-from: DragonFlyBSD
2019-12-12 16:28:24 +00:00
tkusumi c8eaa1e89d dm: Revert "Fix error handling in dmioctl()" for now
This change seems to break "deps" in dm ioctl(2) for linear target.
Revert the change, will revisit later.
https://mail-index.netbsd.org/current-users/2019/12/11/msg037179.html
2019-12-11 14:03:37 +00:00
tkusumi cffbab3877 dm: Silence aprint_normal() in dm_target_linear_status()
dm_target_linear_status() shouldn't print this debug message by default
on dmsetup "table" ioctl/command.
2019-12-09 16:06:19 +00:00
tkusumi 3838da2c5a dm: Fix error handling in dmioctl()
Looks like cleanup_exit label is in a wrong place.
Should skip prop_dictionary_copyout_ioctl() on error.
2019-12-09 15:54:59 +00:00
tkusumi 943f37923f dm: Correct target name "stripe" -> "striped"
Sync with Linux kernel.
The file name is "stripe", but the target name is "striped".
DragonFlyBSD also follows this.
2019-12-09 15:30:42 +00:00
tkusumi a6ffbd97e4 dm: Add dummy target ->sync()/->secsize() to prevent panic on modload(8)
dm_target_insert() has assertions to ensure targets implement all handlers.
Adding dummy ones at least prevents panic on modload(8).
2019-12-08 14:59:42 +00:00
mlelstv 5a52f2af3d Switch to vn_bdev_open* functions. 2019-12-08 12:14:40 +00:00
tkusumi 837fc0447c dm: Move targets specific structs to .c files
These don't need to be defined and exposed in dm.h.
2019-12-08 10:50:21 +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 2cb93e573c dm: Refactor target's ->init() i/f
Take dm_table_entry_t* instead of void**.
Remove dm_dev_t* unneeded by target code.
No functional change, but for future changes.

taken-from: DragonFlyBSD
2019-12-08 04:41:02 +00:00
tkusumi 6847e6b09b dm: Fix indentation 2019-12-07 16:13:39 +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 997f839328 dm: Remove trailing whitespace 2019-12-06 16:46:14 +00:00
tkusumi 354a4ac470 dm: Fix typos in comments/messages
taken-from: DragonFlyBSD
2019-12-06 16:33:47 +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