Commit Graph

197 Commits

Author SHA1 Message Date
mlelstv 6ad9868b59 Avoid leaving a configured device without resources. 2024-01-14 07:56:53 +00:00
andvar adffd44b18 fix various typos in comments and documentation, mainly in word "between". 2023-10-14 08:05:25 +00:00
andvar 18c4b2092f s/exaple/example/ 2022-10-13 06:10:48 +00:00
pgoyette 97f8debd62 For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence.  This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

	devsw_attach()
	config_init_component() or config_cf*_attach()
	...
	config_fini_component() or config_cf*_detach()
	devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
	1. compile without build break
	2. no related test failures from atf
	3. modload/modunload work as well as
	   before.

No functional device testing done, since I don't have any
of these devices.  Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken;  see kern/56772.  This commit does not break
any additional modules (as far as I know).
2022-03-31 19:30:15 +00:00
mlelstv 80ddacac2c Media size is in bytes (off_t), not sectors. 2022-03-28 10:38:00 +00:00
andvar 369abe069b fix various typos, mainly s/prefered/preferred/ 2021-11-07 20:31:09 +00:00
andvar a70f355bc2 fix typos in sys/dev/dm code comments and documentation.
also remove some trailing space in documentation.
2021-08-21 22:23:33 +00:00
andvar ca7653601e fix various typos in comments and log messages. 2021-08-20 20:25:26 +00:00
andvar 7991f5a7b8 Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
2021-07-24 21:31:31 +00:00
christos 948b91748c fix proplib deprecation 2021-06-21 03:14:40 +00:00
hannken 7d26170aba Track the number of cdev and bdev opens and fail dm_detach()
on open devices unless detach is forced.

PR kern/54969 (Disk cache is no longer flushed on shutdown)
2021-05-07 09:54:43 +00:00
hannken 47c6510732 Make sure the unit number of device-mapper devices matches their minor number. 2021-05-07 09:53:39 +00:00
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
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