dm: Move targets specific structs to .c files These don't need to be defined and exposed in dm.h.diff -r1.36 -r1.37 src/sys/dev/dm/dm.h
(tkusumi)
--- src/sys/dev/dm/dm.h 2019/12/08 10:35:53 1.36
+++ src/sys/dev/dm/dm.h 2019/12/08 10:50:21 1.37
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dm.h,v 1.36 2019/12/08 10:35:53 tkusumi Exp $ */ | 1 | /* $NetBSD: dm.h,v 1.37 2019/12/08 10:50:21 tkusumi Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Adam Hamsik. | 8 | * by Adam Hamsik. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -160,65 +160,26 @@ typedef struct target_linear_config { | @@ -160,65 +160,26 @@ typedef struct target_linear_config { | |||
160 | TAILQ_ENTRY(target_linear_config) entries; | 160 | TAILQ_ENTRY(target_linear_config) entries; | |
161 | } dm_target_linear_config_t; | 161 | } dm_target_linear_config_t; | |
162 | 162 | |||
163 | /* | 163 | /* | |
164 | * Striping devices are stored in a linked list, this might be inefficient | 164 | * Striping devices are stored in a linked list, this might be inefficient | |
165 | * for more than 8 striping devices and can be changed to something more | 165 | * for more than 8 striping devices and can be changed to something more | |
166 | * scalable. | 166 | * scalable. | |
167 | * TODO: look for other options than linked list. | 167 | * TODO: look for other options than linked list. | |
168 | */ | 168 | */ | |
169 | TAILQ_HEAD(target_linear_devs, target_linear_config); | 169 | TAILQ_HEAD(target_linear_devs, target_linear_config); | |
170 | 170 | |||
171 | typedef struct target_linear_devs dm_target_linear_devs_t; | 171 | typedef struct target_linear_devs dm_target_linear_devs_t; | |
172 | 172 | |||
173 | /* for stripe : */ | |||
174 | typedef struct target_stripe_config { | |||
175 | #define DM_STRIPE_DEV_OFFSET 2 | |||
176 | struct target_linear_devs stripe_devs; | |||
177 | uint8_t stripe_num; | |||
178 | uint64_t stripe_chunksize; | |||
179 | size_t params_len; | |||
180 | } dm_target_stripe_config_t; | |||
181 | ||||
182 | /* for mirror : */ | |||
183 | typedef struct target_mirror_config { | |||
184 | #define MAX_MIRROR_COPIES 4 | |||
185 | dm_pdev_t *orig; | |||
186 | dm_pdev_t *copies[MAX_MIRROR_COPIES]; | |||
187 | ||||
188 | /* copied blocks bitmaps administration etc*/ | |||
189 | dm_pdev_t *log_pdev; /* for administration */ | |||
190 | uint64_t log_regionsize; /* blocksize of mirror */ | |||
191 | ||||
192 | /* list of parts that still need copied etc.; run length encoded? */ | |||
193 | } dm_target_mirror_config_t; | |||
194 | ||||
195 | ||||
196 | /* for snapshot : */ | |||
197 | typedef struct target_snapshot_config { | |||
198 | dm_pdev_t *tsc_snap_dev; | |||
199 | /* cow dev is set only for persistent snapshot devices */ | |||
200 | dm_pdev_t *tsc_cow_dev; | |||
201 | ||||
202 | uint64_t tsc_chunk_size; | |||
203 | uint32_t tsc_persistent_dev; | |||
204 | } dm_target_snapshot_config_t; | |||
205 | ||||
206 | /* for snapshot-origin devices */ | |||
207 | typedef struct target_snapshot_origin_config { | |||
208 | dm_pdev_t *tsoc_real_dev; | |||
209 | /* list of snapshots ? */ | |||
210 | } dm_target_snapshot_origin_config_t; | |||
211 | ||||
212 | /* constant dm_target structures for error, zero, linear, stripes etc. */ | 173 | /* constant dm_target structures for error, zero, linear, stripes etc. */ | |
213 | typedef struct dm_target { | 174 | typedef struct dm_target { | |
214 | char name[DM_MAX_TYPE_NAME]; | 175 | char name[DM_MAX_TYPE_NAME]; | |
215 | /* Initialize target_config area */ | 176 | /* Initialize target_config area */ | |
216 | int (*init)(dm_table_entry_t *, char *); | 177 | int (*init)(dm_table_entry_t *, char *); | |
217 | 178 | |||
218 | /* Destroy target_config area */ | 179 | /* Destroy target_config area */ | |
219 | int (*destroy)(dm_table_entry_t *); | 180 | int (*destroy)(dm_table_entry_t *); | |
220 | 181 | |||
221 | int (*deps) (dm_table_entry_t *, prop_array_t); | 182 | int (*deps) (dm_table_entry_t *, prop_array_t); | |
222 | /* | 183 | /* | |
223 | * Status routine is called to get params string, which is target | 184 | * Status routine is called to get params string, which is target | |
224 | * specific. When dm_table_status_ioctl is called with flag | 185 | * specific. When dm_table_status_ioctl is called with flag |
--- src/sys/dev/dm/dm_target_mirror.c 2019/12/08 04:41:02 1.15
+++ src/sys/dev/dm/dm_target_mirror.c 2019/12/08 10:50:21 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /*$NetBSD: dm_target_mirror.c,v 1.15 2019/12/08 04:41:02 tkusumi Exp $*/ | 1 | /*$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $*/ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Adam Hamsik. | 8 | * by Adam Hamsik. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -19,47 +19,59 @@ | @@ -19,47 +19,59 @@ | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.15 2019/12/08 04:41:02 tkusumi Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $"); | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * This file implements initial version of device-mapper mirror target. | 35 | * This file implements initial version of device-mapper mirror target. | |
36 | */ | 36 | */ | |
37 | #include <sys/types.h> | 37 | #include <sys/types.h> | |
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | 39 | |||
40 | #include <sys/buf.h> | 40 | #include <sys/buf.h> | |
41 | 41 | |||
42 | #include "dm.h" | 42 | #include "dm.h" | |
43 | 43 | |||
44 | /* dm_target_mirror.c */ | 44 | /* dm_target_mirror.c */ | |
45 | int dm_target_mirror_init(dm_table_entry_t *, char *); | 45 | int dm_target_mirror_init(dm_table_entry_t *, char *); | |
46 | char *dm_target_mirror_status(void *); | 46 | char *dm_target_mirror_status(void *); | |
47 | int dm_target_mirror_strategy(dm_table_entry_t *, struct buf *); | 47 | int dm_target_mirror_strategy(dm_table_entry_t *, struct buf *); | |
48 | int dm_target_mirror_sync(dm_table_entry_t *); | 48 | int dm_target_mirror_sync(dm_table_entry_t *); | |
49 | int dm_target_mirror_deps(dm_table_entry_t *, prop_array_t); | 49 | int dm_target_mirror_deps(dm_table_entry_t *, prop_array_t); | |
50 | int dm_target_mirror_destroy(dm_table_entry_t *); | 50 | int dm_target_mirror_destroy(dm_table_entry_t *); | |
51 | int dm_target_mirror_upcall(dm_table_entry_t *, struct buf *); | 51 | int dm_target_mirror_upcall(dm_table_entry_t *, struct buf *); | |
52 | 52 | |||
53 | typedef struct target_mirror_config { | |||
54 | #define MAX_MIRROR_COPIES 4 | |||
55 | dm_pdev_t *orig; | |||
56 | dm_pdev_t *copies[MAX_MIRROR_COPIES]; | |||
57 | ||||
58 | /* copied blocks bitmaps administration etc*/ | |||
59 | dm_pdev_t *log_pdev; /* for administration */ | |||
60 | uint64_t log_regionsize; /* blocksize of mirror */ | |||
61 | ||||
62 | /* list of parts that still need copied etc.; run length encoded? */ | |||
63 | } dm_target_mirror_config_t; | |||
64 | ||||
53 | #ifdef DM_TARGET_MODULE | 65 | #ifdef DM_TARGET_MODULE | |
54 | /* | 66 | /* | |
55 | * Every target can be compiled directly to dm driver or as a | 67 | * Every target can be compiled directly to dm driver or as a | |
56 | * separate module this part of target is used for loading targets | 68 | * separate module this part of target is used for loading targets | |
57 | * to dm driver. | 69 | * to dm driver. | |
58 | * Target can be unloaded from kernel only if there are no users of | 70 | * Target can be unloaded from kernel only if there are no users of | |
59 | * it e.g. there are no devices which uses that target. | 71 | * it e.g. there are no devices which uses that target. | |
60 | */ | 72 | */ | |
61 | #include <sys/kernel.h> | 73 | #include <sys/kernel.h> | |
62 | #include <sys/module.h> | 74 | #include <sys/module.h> | |
63 | 75 | |||
64 | MODULE(MODULE_CLASS_MISC, dm_target_mirror, "dm"); | 76 | MODULE(MODULE_CLASS_MISC, dm_target_mirror, "dm"); | |
65 | 77 |
--- src/sys/dev/dm/dm_target_snapshot.c 2019/12/08 10:35:53 1.27
+++ src/sys/dev/dm/dm_target_snapshot.c 2019/12/08 10:50:21 1.28
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $ */ | 1 | /* $NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Adam Hamsik. | 8 | * by Adam Hamsik. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $"); | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being | 35 | * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being | |
36 | * activated. | 36 | * activated. | |
37 | * dmsetup suspend my_data | 37 | * dmsetup suspend my_data | |
38 | * | 38 | * | |
39 | * 2. Create the snapshot-origin device with no table. | 39 | * 2. Create the snapshot-origin device with no table. | |
40 | * dmsetup create my_data_org | 40 | * dmsetup create my_data_org | |
41 | * | 41 | * | |
42 | * 3. Read the table from my_data and load it into my_data_org. | 42 | * 3. Read the table from my_data and load it into my_data_org. | |
43 | * dmsetup table my_data | dmsetup load my_data_org | 43 | * dmsetup table my_data | dmsetup load my_data_org | |
44 | * | 44 | * | |
45 | * 4. Resume this new table. | 45 | * 4. Resume this new table. | |
@@ -93,26 +93,40 @@ int dm_target_snapshot_strategy(dm_table | @@ -93,26 +93,40 @@ int dm_target_snapshot_strategy(dm_table | |||
93 | int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t); | 93 | int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t); | |
94 | int dm_target_snapshot_destroy(dm_table_entry_t *); | 94 | int dm_target_snapshot_destroy(dm_table_entry_t *); | |
95 | int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *); | 95 | int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *); | |
96 | 96 | |||
97 | /* dm snapshot origin driver */ | 97 | /* dm snapshot origin driver */ | |
98 | int dm_target_snapshot_orig_init(dm_table_entry_t *, char *); | 98 | int dm_target_snapshot_orig_init(dm_table_entry_t *, char *); | |
99 | char *dm_target_snapshot_orig_status(void *); | 99 | char *dm_target_snapshot_orig_status(void *); | |
100 | int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *); | 100 | int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *); | |
101 | int dm_target_snapshot_orig_sync(dm_table_entry_t *); | 101 | int dm_target_snapshot_orig_sync(dm_table_entry_t *); | |
102 | int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t); | 102 | int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t); | |
103 | int dm_target_snapshot_orig_destroy(dm_table_entry_t *); | 103 | int dm_target_snapshot_orig_destroy(dm_table_entry_t *); | |
104 | int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); | 104 | int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); | |
105 | 105 | |||
106 | typedef struct target_snapshot_config { | |||
107 | dm_pdev_t *tsc_snap_dev; | |||
108 | /* cow dev is set only for persistent snapshot devices */ | |||
109 | dm_pdev_t *tsc_cow_dev; | |||
110 | ||||
111 | uint64_t tsc_chunk_size; | |||
112 | uint32_t tsc_persistent_dev; | |||
113 | } dm_target_snapshot_config_t; | |||
114 | ||||
115 | typedef struct target_snapshot_origin_config { | |||
116 | dm_pdev_t *tsoc_real_dev; | |||
117 | /* list of snapshots ? */ | |||
118 | } dm_target_snapshot_origin_config_t; | |||
119 | ||||
106 | #ifdef DM_TARGET_MODULE | 120 | #ifdef DM_TARGET_MODULE | |
107 | /* | 121 | /* | |
108 | * Every target can be compiled directly to dm driver or as a | 122 | * Every target can be compiled directly to dm driver or as a | |
109 | * separate module this part of target is used for loading targets | 123 | * separate module this part of target is used for loading targets | |
110 | * to dm driver. | 124 | * to dm driver. | |
111 | * Target can be unloaded from kernel only if there are no users of | 125 | * Target can be unloaded from kernel only if there are no users of | |
112 | * it e.g. there are no devices which uses that target. | 126 | * it e.g. there are no devices which uses that target. | |
113 | */ | 127 | */ | |
114 | #include <sys/kernel.h> | 128 | #include <sys/kernel.h> | |
115 | #include <sys/module.h> | 129 | #include <sys/module.h> | |
116 | 130 | |||
117 | MODULE(MODULE_CLASS_MISC, dm_target_snapshot, "dm"); | 131 | MODULE(MODULE_CLASS_MISC, dm_target_snapshot, "dm"); | |
118 | 132 |
--- src/sys/dev/dm/dm_target_stripe.c 2019/12/08 04:41:02 1.31
+++ src/sys/dev/dm/dm_target_stripe.c 2019/12/08 10:50:21 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /*$NetBSD: dm_target_stripe.c,v 1.31 2019/12/08 04:41:02 tkusumi Exp $*/ | 1 | /*$NetBSD: dm_target_stripe.c,v 1.32 2019/12/08 10:50:21 tkusumi Exp $*/ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Adam Hamsik. | 8 | * by Adam Hamsik. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -19,40 +19,48 @@ | @@ -19,40 +19,48 @@ | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.31 2019/12/08 04:41:02 tkusumi Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.32 2019/12/08 10:50:21 tkusumi Exp $"); | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * This file implements initial version of device-mapper stripe target. | 35 | * This file implements initial version of device-mapper stripe target. | |
36 | */ | 36 | */ | |
37 | #include <sys/types.h> | 37 | #include <sys/types.h> | |
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | 39 | |||
40 | #include <sys/buf.h> | 40 | #include <sys/buf.h> | |
41 | #include <sys/kmem.h> | 41 | #include <sys/kmem.h> | |
42 | #include <sys/lwp.h> | 42 | #include <sys/lwp.h> | |
43 | 43 | |||
44 | #include "dm.h" | 44 | #include "dm.h" | |
45 | 45 | |||
46 | typedef struct target_stripe_config { | |||
47 | #define DM_STRIPE_DEV_OFFSET 2 | |||
48 | struct target_linear_devs stripe_devs; | |||
49 | uint8_t stripe_num; | |||
50 | uint64_t stripe_chunksize; | |||
51 | size_t params_len; | |||
52 | } dm_target_stripe_config_t; | |||
53 | ||||
46 | #ifdef DM_TARGET_MODULE | 54 | #ifdef DM_TARGET_MODULE | |
47 | /* | 55 | /* | |
48 | * Every target can be compiled directly to dm driver or as a | 56 | * Every target can be compiled directly to dm driver or as a | |
49 | * separate module this part of target is used for loading targets | 57 | * separate module this part of target is used for loading targets | |
50 | * to dm driver. | 58 | * to dm driver. | |
51 | * Target can be unloaded from kernel only if there are no users of | 59 | * Target can be unloaded from kernel only if there are no users of | |
52 | * it e.g. there are no devices which uses that target. | 60 | * it e.g. there are no devices which uses that target. | |
53 | */ | 61 | */ | |
54 | #include <sys/kernel.h> | 62 | #include <sys/kernel.h> | |
55 | #include <sys/module.h> | 63 | #include <sys/module.h> | |
56 | 64 | |||
57 | MODULE(MODULE_CLASS_MISC, dm_target_stripe, NULL); | 65 | MODULE(MODULE_CLASS_MISC, dm_target_stripe, NULL); | |
58 | 66 |