diff options
| author | tkusumi <tkusumi@NetBSD.org> | 2019-12-21 11:59:03 +0000 |
|---|---|---|
| committer | tkusumi <tkusumi@NetBSD.org> | 2019-12-21 11:59:03 +0000 |
| commit | 87d1de18f98b3e78b5d086567959f7431f8fc42a (patch) | |
| tree | 3d1f4c2ef558d31594cae4d74558e53cc1bf680c /sys/dev/dm/dm_ioctl.c | |
| parent | 7a94ebcb188dcd4da56810d8d5686b9cacac2127 (diff) | |
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
Diffstat (limited to 'sys/dev/dm/dm_ioctl.c')
| -rw-r--r-- | sys/dev/dm/dm_ioctl.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/sys/dev/dm/dm_ioctl.c b/sys/dev/dm/dm_ioctl.c index c64e76c40f4..a4aacad3209 100644 --- a/sys/dev/dm/dm_ioctl.c +++ b/sys/dev/dm/dm_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.47 2019/12/19 16:27:39 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 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_ioctl.c,v 1.47 2019/12/19 16:27:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -116,6 +116,7 @@ static struct cfdata dm_cfdata = { prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ } while (/*CONSTCOND*/0) +static int dm_table_deps(dm_table_entry_t *, prop_array_t); static int dm_table_init(dm_target_t *, dm_table_entry_t *, char *); /* @@ -644,7 +645,7 @@ dm_table_deps_ioctl(prop_dictionary_t dm_dict) tbl = dm_table_get_entry(&dmv->table_head, table_type); SLIST_FOREACH(table_en, tbl, next) - table_en->target->deps(table_en, cmd_array); + dm_table_deps(table_en, cmd_array); dm_table_release(&dmv->table_head, table_type); dm_dev_unbusy(dmv); @@ -655,6 +656,36 @@ dm_table_deps_ioctl(prop_dictionary_t dm_dict) return 0; } +static int +dm_table_deps(dm_table_entry_t *table_en, prop_array_t array) +{ + dm_mapping_t *map; + int i, size; + uint64_t rdev, tmp; + + size = prop_array_count(array); + + TAILQ_FOREACH(map, &table_en->pdev_maps, next) { + rdev = map->data.pdev->pdev_vnode->v_rdev; + for (i = 0; i < size; i++) { + if (prop_array_get_uint64(array, i, &tmp) == true) + if (rdev == tmp) + break; /* exists */ + } + /* + * Ignore if the device has already been added by + * other tables. + */ + if (i == size) { + prop_array_add_uint64(array, rdev); + aprint_debug("%s: %d:%d\n", __func__, major(rdev), + minor(rdev)); + } + } + + return 0; +} + /* * Load new table/tables to device. * Call apropriate target init routine open all physical pdev's and @@ -746,6 +777,7 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) table_en->target = target; table_en->dm_dev = dmv; table_en->target_config = NULL; + TAILQ_INIT(&table_en->pdev_maps); /* * There is a parameter string after dm_target_spec |
