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)".
This commit is contained in:
tkusumi 2019-12-15 09:42:29 +00:00
parent d83f8a8ef1
commit 37b6bcc115
7 changed files with 20 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm.h,v 1.43 2019/12/15 09:22:28 tkusumi Exp $ */
/* $NetBSD: dm.h,v 1.44 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -193,6 +193,9 @@ typedef struct dm_target {
int (*strategy)(dm_table_entry_t *, struct buf *);
int (*sync)(dm_table_entry_t *);
int (*upcall)(dm_table_entry_t *, struct buf *);
/*
* Optional routines.
*/
int (*secsize)(dm_table_entry_t *, unsigned int *);
uint32_t version[3];
@ -298,13 +301,6 @@ int dm_pdev_destroy(void);
int dm_pdev_init(void);
dm_pdev_t* dm_pdev_insert(const char *);
/* XXX dummy */
static __inline int
dm_target_dummy_secsize(dm_table_entry_t *table_en, unsigned int *secsizep)
{
return 0;
}
#endif /*_KERNEL*/
#endif /*_DM_DEV_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_table.c,v 1.14 2019/12/15 09:22:28 tkusumi Exp $ */
/* $NetBSD: dm_table.c,v 1.15 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.14 2019/12/15 09:22:28 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.15 2019/12/15 09:42:29 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -248,7 +248,10 @@ dm_table_disksize(dm_table_head_t *head, uint64_t *numsecp, unsigned int *secsiz
secsize = 0;
SLIST_FOREACH(table_en, tbl, next) {
length += table_en->length;
if (table_en->target->secsize)
table_en->target->secsize(table_en, &tsecsize);
else
tsecsize = 0;
if (secsize < tsecsize)
secsize = tsecsize;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target.c,v 1.29 2019/12/15 05:56:02 tkusumi Exp $ */
/* $NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.29 2019/12/15 05:56:02 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -184,10 +184,6 @@ dm_target_insert(dm_target_t *dm_target)
printf("%s missing sync\n", dm_target->name);
return EINVAL;
}
if (dm_target->secsize == NULL) {
printf("%s missing secsize\n", dm_target->name);
return EINVAL;
}
mutex_enter(&dm_target_mutex);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target_error.c,v 1.21 2019/12/15 05:56:02 tkusumi Exp $ */
/* $NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.21 2019/12/15 05:56:02 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $");
/*
* This file implements initial version of device-mapper error target.
@ -88,7 +88,6 @@ dm_target_error_modcmd(modcmd_t cmd, void *arg)
dmt->deps = &dm_target_error_deps;
dmt->destroy = &dm_target_error_destroy;
dmt->upcall = &dm_target_error_upcall;
dmt->secsize = dm_target_dummy_secsize;
r = dm_target_insert(dmt);

View File

@ -1,4 +1,4 @@
/*$NetBSD: dm_target_mirror.c,v 1.20 2019/12/15 05:56:02 tkusumi Exp $*/
/*$NetBSD: dm_target_mirror.c,v 1.21 2019/12/15 09:42:29 tkusumi Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.20 2019/12/15 05:56:02 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.21 2019/12/15 09:42:29 tkusumi Exp $");
/*
* This file implements initial version of device-mapper mirror target.
@ -100,7 +100,6 @@ dm_target_mirror_modcmd(modcmd_t cmd, void *arg)
dmt->deps = &dm_target_mirror_deps;
dmt->destroy = &dm_target_mirror_destroy;
dmt->upcall = &dm_target_mirror_upcall;
dmt->secsize = dm_target_dummy_secsize;
r = dm_target_insert(dmt);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target_snapshot.c,v 1.32 2019/12/15 05:56:02 tkusumi Exp $ */
/* $NetBSD: dm_target_snapshot.c,v 1.33 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.32 2019/12/15 05:56:02 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.33 2019/12/15 09:42:29 tkusumi Exp $");
/*
* 1. Suspend my_data to temporarily stop any I/O while the snapshot is being
@ -163,7 +163,6 @@ dm_target_snapshot_modcmd(modcmd_t cmd, void *arg)
dmt->deps = &dm_target_snapshot_deps;
dmt->destroy = &dm_target_snapshot_destroy;
dmt->upcall = &dm_target_snapshot_upcall;
dmt->secsize = dm_target_dummy_secsize;
r = dm_target_insert(dmt);
@ -177,7 +176,6 @@ dm_target_snapshot_modcmd(modcmd_t cmd, void *arg)
dmt1->deps = &dm_target_snapshot_orig_deps;
dmt1->destroy = &dm_target_snapshot_orig_destroy;
dmt1->upcall = &dm_target_snapshot_orig_upcall;
dmt1->secsize = dm_target_dummy_secsize;
r = dm_target_insert(dmt1);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target_zero.c,v 1.23 2019/12/15 05:56:02 tkusumi Exp $ */
/* $NetBSD: dm_target_zero.c,v 1.24 2019/12/15 09:42:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.23 2019/12/15 05:56:02 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.24 2019/12/15 09:42:29 tkusumi Exp $");
/*
* This file implements initial version of device-mapper zero target.
@ -88,7 +88,6 @@ dm_target_zero_modcmd(modcmd_t cmd, void *arg)
dmt->deps = &dm_target_zero_deps;
dmt->destroy = &dm_target_zero_destroy;
dmt->upcall = &dm_target_zero_upcall;
dmt->secsize = dm_target_dummy_secsize;
r = dm_target_insert(dmt);
break;