Sun Dec 8 14:59:42 2019 UTC ()
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).


(tkusumi)
diff -r1.37 -r1.38 src/sys/dev/dm/dm.h
diff -r1.17 -r1.18 src/sys/dev/dm/dm_target_error.c
diff -r1.16 -r1.17 src/sys/dev/dm/dm_target_mirror.c
diff -r1.28 -r1.29 src/sys/dev/dm/dm_target_snapshot.c
diff -r1.19 -r1.20 src/sys/dev/dm/dm_target_zero.c

cvs diff -r1.37 -r1.38 src/sys/dev/dm/dm.h (expand / switch to unified diff)

--- src/sys/dev/dm/dm.h 2019/12/08 10:50:21 1.37
+++ src/sys/dev/dm/dm.h 2019/12/08 14:59:42 1.38
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dm.h,v 1.37 2019/12/08 10:50:21 tkusumi Exp $ */ 1/* $NetBSD: dm.h,v 1.38 2019/12/08 14:59:42 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.
@@ -283,16 +283,23 @@ int dm_dev_init(void); @@ -283,16 +283,23 @@ int dm_dev_init(void);
283int dm_dev_insert(dm_dev_t *); 283int dm_dev_insert(dm_dev_t *);
284dm_dev_t* dm_dev_lookup(const char *, const char *, int); 284dm_dev_t* dm_dev_lookup(const char *, const char *, int);
285prop_array_t dm_dev_prop_list(void); 285prop_array_t dm_dev_prop_list(void);
286dm_dev_t* dm_dev_rem(const char *, const char *, int); 286dm_dev_t* dm_dev_rem(const char *, const char *, int);
287/*int dm_dev_test_minor(int);*/ 287/*int dm_dev_test_minor(int);*/
288void dm_dev_unbusy(dm_dev_t *); 288void dm_dev_unbusy(dm_dev_t *);
289 289
290/* dm_pdev.c */ 290/* dm_pdev.c */
291int dm_pdev_decr(dm_pdev_t *); 291int dm_pdev_decr(dm_pdev_t *);
292int dm_pdev_destroy(void); 292int dm_pdev_destroy(void);
293int dm_pdev_init(void); 293int dm_pdev_init(void);
294dm_pdev_t* dm_pdev_insert(const char *); 294dm_pdev_t* dm_pdev_insert(const char *);
295 295
 296/* XXX dummy */
 297static __inline int
 298dm_target_dummy_secsize(dm_table_entry_t *table_en, unsigned *secsizep)
 299{
 300 return 0;
 301}
 302
296#endif /*_KERNEL*/ 303#endif /*_KERNEL*/
297 304
298#endif /*_DM_DEV_H_*/ 305#endif /*_DM_DEV_H_*/

cvs diff -r1.17 -r1.18 src/sys/dev/dm/dm_target_error.c (expand / switch to unified diff)

--- src/sys/dev/dm/dm_target_error.c 2019/12/08 04:41:02 1.17
+++ src/sys/dev/dm/dm_target_error.c 2019/12/08 14:59:42 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dm_target_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $ */ 1/* $NetBSD: dm_target_error.c,v 1.18 2019/12/08 14:59:42 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_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.18 2019/12/08 14:59:42 tkusumi Exp $");
33 33
34/* 34/*
35 * This file implements initial version of device-mapper error target. 35 * This file implements initial version of device-mapper error 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_error.c */ 44/* dm_target_error.c */
45int dm_target_error_init(dm_table_entry_t*, char *); 45int dm_target_error_init(dm_table_entry_t*, char *);
@@ -78,26 +78,27 @@ dm_target_error_modcmd(modcmd_t cmd, voi @@ -78,26 +78,27 @@ dm_target_error_modcmd(modcmd_t cmd, voi
78 } 78 }
79 dmt = dm_target_alloc("error"); 79 dmt = dm_target_alloc("error");
80 80
81 dmt->version[0] = 1; 81 dmt->version[0] = 1;
82 dmt->version[1] = 0; 82 dmt->version[1] = 0;
83 dmt->version[2] = 0; 83 dmt->version[2] = 0;
84 dmt->init = &dm_target_error_init; 84 dmt->init = &dm_target_error_init;
85 dmt->status = &dm_target_error_status; 85 dmt->status = &dm_target_error_status;
86 dmt->strategy = &dm_target_error_strategy; 86 dmt->strategy = &dm_target_error_strategy;
87 dmt->sync = &dm_target_error_sync; 87 dmt->sync = &dm_target_error_sync;
88 dmt->deps = &dm_target_error_deps; 88 dmt->deps = &dm_target_error_deps;
89 dmt->destroy = &dm_target_error_destroy; 89 dmt->destroy = &dm_target_error_destroy;
90 dmt->upcall = &dm_target_error_upcall; 90 dmt->upcall = &dm_target_error_upcall;
 91 dmt->secsize = dm_target_dummy_secsize;
91 92
92 r = dm_target_insert(dmt); 93 r = dm_target_insert(dmt);
93 94
94 break; 95 break;
95 96
96 case MODULE_CMD_FINI: 97 case MODULE_CMD_FINI:
97 r = dm_target_rem("error"); 98 r = dm_target_rem("error");
98 break; 99 break;
99 100
100 case MODULE_CMD_STAT: 101 case MODULE_CMD_STAT:
101 return ENOTTY; 102 return ENOTTY;
102 103
103 default: 104 default:

cvs diff -r1.16 -r1.17 src/sys/dev/dm/dm_target_mirror.c (expand / switch to unified diff)

--- src/sys/dev/dm/dm_target_mirror.c 2019/12/08 10:50:21 1.16
+++ src/sys/dev/dm/dm_target_mirror.c 2019/12/08 14:59:42 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/*$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $*/ 1/*$NetBSD: dm_target_mirror.c,v 1.17 2019/12/08 14:59:42 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,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_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.17 2019/12/08 14:59:42 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 */
45int dm_target_mirror_init(dm_table_entry_t *, char *); 45int dm_target_mirror_init(dm_table_entry_t *, char *);
@@ -90,26 +90,27 @@ dm_target_mirror_modcmd(modcmd_t cmd, vo @@ -90,26 +90,27 @@ dm_target_mirror_modcmd(modcmd_t cmd, vo
90 } 90 }
91 dmt = dm_target_alloc("mirror"); 91 dmt = dm_target_alloc("mirror");
92 92
93 dmt->version[0] = 1; 93 dmt->version[0] = 1;
94 dmt->version[1] = 0; 94 dmt->version[1] = 0;
95 dmt->version[2] = 0; 95 dmt->version[2] = 0;
96 dmt->init = &dm_target_mirror_init; 96 dmt->init = &dm_target_mirror_init;
97 dmt->status = &dm_target_mirror_status; 97 dmt->status = &dm_target_mirror_status;
98 dmt->strategy = &dm_target_mirror_strategy; 98 dmt->strategy = &dm_target_mirror_strategy;
99 dmt->sync = &dm_target_mirror_sync; 99 dmt->sync = &dm_target_mirror_sync;
100 dmt->deps = &dm_target_mirror_deps; 100 dmt->deps = &dm_target_mirror_deps;
101 dmt->destroy = &dm_target_mirror_destroy; 101 dmt->destroy = &dm_target_mirror_destroy;
102 dmt->upcall = &dm_target_mirror_upcall; 102 dmt->upcall = &dm_target_mirror_upcall;
 103 dmt->secsize = dm_target_dummy_secsize;
103 104
104 r = dm_target_insert(dmt); 105 r = dm_target_insert(dmt);
105 106
106 break; 107 break;
107 108
108 case MODULE_CMD_FINI: 109 case MODULE_CMD_FINI:
109 r = dm_target_rem("mirror"); 110 r = dm_target_rem("mirror");
110 break; 111 break;
111 112
112 case MODULE_CMD_STAT: 113 case MODULE_CMD_STAT:
113 return ENOTTY; 114 return ENOTTY;
114 115
115 default: 116 default:

cvs diff -r1.28 -r1.29 src/sys/dev/dm/dm_target_snapshot.c (expand / switch to unified diff)

--- src/sys/dev/dm/dm_target_snapshot.c 2019/12/08 10:50:21 1.28
+++ src/sys/dev/dm/dm_target_snapshot.c 2019/12/08 14:59:42 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $ */ 1/* $NetBSD: dm_target_snapshot.c,v 1.29 2019/12/08 14:59:42 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.28 2019/12/08 10:50:21 tkusumi Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.29 2019/12/08 14:59:42 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.
@@ -80,26 +80,27 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_sn @@ -80,26 +80,27 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_sn
80 */ 80 */
81#include <sys/types.h> 81#include <sys/types.h>
82#include <sys/param.h> 82#include <sys/param.h>
83 83
84#include <sys/buf.h> 84#include <sys/buf.h>
85#include <sys/kmem.h> 85#include <sys/kmem.h>
86 86
87#include "dm.h" 87#include "dm.h"
88 88
89/* dm_target_snapshot.c */ 89/* dm_target_snapshot.c */
90int dm_target_snapshot_init(dm_table_entry_t *, char *); 90int dm_target_snapshot_init(dm_table_entry_t *, char *);
91char *dm_target_snapshot_status(void *); 91char *dm_target_snapshot_status(void *);
92int dm_target_snapshot_strategy(dm_table_entry_t *, struct buf *); 92int dm_target_snapshot_strategy(dm_table_entry_t *, struct buf *);
 93int dm_target_snapshot_sync(dm_table_entry_t *);
93int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t); 94int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t);
94int dm_target_snapshot_destroy(dm_table_entry_t *); 95int dm_target_snapshot_destroy(dm_table_entry_t *);
95int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *); 96int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *);
96 97
97/* dm snapshot origin driver */ 98/* dm snapshot origin driver */
98int dm_target_snapshot_orig_init(dm_table_entry_t *, char *); 99int dm_target_snapshot_orig_init(dm_table_entry_t *, char *);
99char *dm_target_snapshot_orig_status(void *); 100char *dm_target_snapshot_orig_status(void *);
100int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *); 101int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *);
101int dm_target_snapshot_orig_sync(dm_table_entry_t *); 102int dm_target_snapshot_orig_sync(dm_table_entry_t *);
102int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t); 103int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t);
103int dm_target_snapshot_orig_destroy(dm_table_entry_t *); 104int dm_target_snapshot_orig_destroy(dm_table_entry_t *);
104int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); 105int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *);
105 106
@@ -148,42 +149,45 @@ dm_target_snapshot_modcmd(modcmd_t cmd,  @@ -148,42 +149,45 @@ dm_target_snapshot_modcmd(modcmd_t cmd,
148 if (((dmt = dm_target_lookup("snapshot-origin")) != NULL)) { 149 if (((dmt = dm_target_lookup("snapshot-origin")) != NULL)) {
149 dm_target_unbusy(dmt); 150 dm_target_unbusy(dmt);
150 return EEXIST; 151 return EEXIST;
151 } 152 }
152 dmt = dm_target_alloc("snapshot"); 153 dmt = dm_target_alloc("snapshot");
153 dmt1 = dm_target_alloc("snapshot-origin"); 154 dmt1 = dm_target_alloc("snapshot-origin");
154 155
155 dmt->version[0] = 1; 156 dmt->version[0] = 1;
156 dmt->version[1] = 0; 157 dmt->version[1] = 0;
157 dmt->version[2] = 5; 158 dmt->version[2] = 5;
158 dmt->init = &dm_target_snapshot_init; 159 dmt->init = &dm_target_snapshot_init;
159 dmt->status = &dm_target_snapshot_status; 160 dmt->status = &dm_target_snapshot_status;
160 dmt->strategy = &dm_target_snapshot_strategy; 161 dmt->strategy = &dm_target_snapshot_strategy;
 162 dmt->sync = &dm_target_snapshot_sync;
161 dmt->deps = &dm_target_snapshot_deps; 163 dmt->deps = &dm_target_snapshot_deps;
162 dmt->destroy = &dm_target_snapshot_destroy; 164 dmt->destroy = &dm_target_snapshot_destroy;
163 dmt->upcall = &dm_target_snapshot_upcall; 165 dmt->upcall = &dm_target_snapshot_upcall;
 166 dmt->secsize = dm_target_dummy_secsize;
164 167
165 r = dm_target_insert(dmt); 168 r = dm_target_insert(dmt);
166 169
167 dmt1->version[0] = 1; 170 dmt1->version[0] = 1;
168 dmt1->version[1] = 0; 171 dmt1->version[1] = 0;
169 dmt1->version[2] = 5; 172 dmt1->version[2] = 5;
170 dmt1->init = &dm_target_snapshot_orig_init; 173 dmt1->init = &dm_target_snapshot_orig_init;
171 dmt1->status = &dm_target_snapshot_orig_status; 174 dmt1->status = &dm_target_snapshot_orig_status;
172 dmt1->strategy = &dm_target_snapshot_orig_strategy; 175 dmt1->strategy = &dm_target_snapshot_orig_strategy;
173 dmt1->sync = &dm_target_snapshot_orig_sync; 176 dmt1->sync = &dm_target_snapshot_orig_sync;
174 dmt1->deps = &dm_target_snapshot_orig_deps; 177 dmt1->deps = &dm_target_snapshot_orig_deps;
175 dmt1->destroy = &dm_target_snapshot_orig_destroy; 178 dmt1->destroy = &dm_target_snapshot_orig_destroy;
176 dmt1->upcall = &dm_target_snapshot_orig_upcall; 179 dmt1->upcall = &dm_target_snapshot_orig_upcall;
 180 dmt1->secsize = dm_target_dummy_secsize;
177 181
178 r = dm_target_insert(dmt1); 182 r = dm_target_insert(dmt1);
179 break; 183 break;
180 184
181 case MODULE_CMD_FINI: 185 case MODULE_CMD_FINI:
182 /* 186 /*
183 * Try to remove snapshot target if it works remove snap-origin 187 * Try to remove snapshot target if it works remove snap-origin
184 * it is not possible to remove snapshot and do not remove 188 * it is not possible to remove snapshot and do not remove
185 * snap-origin because they are used together. 189 * snap-origin because they are used together.
186 */ 190 */
187 if ((r = dm_target_rem("snapshot")) == 0) 191 if ((r = dm_target_rem("snapshot")) == 0)
188 r = dm_target_rem("snapshot-origin"); 192 r = dm_target_rem("snapshot-origin");
189 193
@@ -309,26 +313,33 @@ int @@ -309,26 +313,33 @@ int
309dm_target_snapshot_strategy(dm_table_entry_t *table_en, struct buf *bp) 313dm_target_snapshot_strategy(dm_table_entry_t *table_en, struct buf *bp)
310{ 314{
311 315
312 printf("Snapshot target read function called!!\n"); 316 printf("Snapshot target read function called!!\n");
313 317
314 bp->b_error = EIO; 318 bp->b_error = EIO;
315 bp->b_resid = 0; 319 bp->b_resid = 0;
316 320
317 biodone(bp); 321 biodone(bp);
318 322
319 return 0; 323 return 0;
320} 324}
321 325
 326/* XXX dummy */
 327int
 328dm_target_snapshot_sync(dm_table_entry_t *table_en)
 329{
 330 return 0;
 331}
 332
322/* Doesn't do anything here. */ 333/* Doesn't do anything here. */
323int 334int
324dm_target_snapshot_destroy(dm_table_entry_t *table_en) 335dm_target_snapshot_destroy(dm_table_entry_t *table_en)
325{ 336{
326 337
327 /* 338 /*
328 * Destroy function is called for every target even if it 339 * Destroy function is called for every target even if it
329 * doesn't have target_config. 340 * doesn't have target_config.
330 */ 341 */
331 if (table_en->target_config == NULL) 342 if (table_en->target_config == NULL)
332 goto out; 343 goto out;
333 344
334 printf("Snapshot target destroy function called\n"); 345 printf("Snapshot target destroy function called\n");

cvs diff -r1.19 -r1.20 src/sys/dev/dm/dm_target_zero.c (expand / switch to unified diff)

--- src/sys/dev/dm/dm_target_zero.c 2019/12/08 04:41:02 1.19
+++ src/sys/dev/dm/dm_target_zero.c 2019/12/08 14:59:42 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dm_target_zero.c,v 1.19 2019/12/08 04:41:02 tkusumi Exp $ */ 1/* $NetBSD: dm_target_zero.c,v 1.20 2019/12/08 14:59:42 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_zero.c,v 1.19 2019/12/08 04:41:02 tkusumi Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.20 2019/12/08 14:59:42 tkusumi Exp $");
33 33
34/* 34/*
35 * This file implements initial version of device-mapper zero target. 35 * This file implements initial version of device-mapper zero 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_zero.c */ 44/* dm_target_zero.c */
45int dm_target_zero_init(dm_table_entry_t *, char *); 45int dm_target_zero_init(dm_table_entry_t *, char *);
@@ -78,26 +78,27 @@ dm_target_zero_modcmd(modcmd_t cmd, void @@ -78,26 +78,27 @@ dm_target_zero_modcmd(modcmd_t cmd, void
78 } 78 }
79 dmt = dm_target_alloc("zero"); 79 dmt = dm_target_alloc("zero");
80 80
81 dmt->version[0] = 1; 81 dmt->version[0] = 1;
82 dmt->version[1] = 0; 82 dmt->version[1] = 0;
83 dmt->version[2] = 0; 83 dmt->version[2] = 0;
84 dmt->init = &dm_target_zero_init; 84 dmt->init = &dm_target_zero_init;
85 dmt->status = &dm_target_zero_status; 85 dmt->status = &dm_target_zero_status;
86 dmt->strategy = &dm_target_zero_strategy; 86 dmt->strategy = &dm_target_zero_strategy;
87 dmt->sync = &dm_target_zero_sync; 87 dmt->sync = &dm_target_zero_sync;
88 dmt->deps = &dm_target_zero_deps; 88 dmt->deps = &dm_target_zero_deps;
89 dmt->destroy = &dm_target_zero_destroy; 89 dmt->destroy = &dm_target_zero_destroy;
90 dmt->upcall = &dm_target_zero_upcall; 90 dmt->upcall = &dm_target_zero_upcall;
 91 dmt->secsize = dm_target_dummy_secsize;
91 92
92 r = dm_target_insert(dmt); 93 r = dm_target_insert(dmt);
93 break; 94 break;
94 95
95 case MODULE_CMD_FINI: 96 case MODULE_CMD_FINI:
96 r = dm_target_rem("zero"); 97 r = dm_target_rem("zero");
97 98
98 break; 99 break;
99 100
100 case MODULE_CMD_STAT: 101 case MODULE_CMD_STAT:
101 return ENOTTY; 102 return ENOTTY;
102 103
103 default: 104 default: