CVS commit: src/sys/dev/dm
Module Name:src Committed By: mlelstv Date: Sun Jan 14 07:56:53 UTC 2024 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: Avoid leaving a configured device without resources. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.56 src/sys/dev/dm/dm_ioctl.c:1.57 --- src/sys/dev/dm/dm_ioctl.c:1.56 Thu Oct 13 06:10:48 2022 +++ src/sys/dev/dm/dm_ioctl.c Sun Jan 14 07:56:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -209,18 +209,21 @@ dm_dev_create_ioctl(prop_dictionary_t dm dm_dev_unbusy(dmv); return EEXIST; } + + if ((dmv = dm_dev_alloc()) == NULL) + return ENOMEM; + cf = kmem_alloc(sizeof(*cf), KM_SLEEP); cf->cf_name = dm_cd.cd_name; cf->cf_atname = dm_ca.ca_name; cf->cf_unit = atomic_inc_32_nv(_minor_num); cf->cf_fstate = FSTATE_NOTFOUND; if ((devt = config_attach_pseudo(cf)) == NULL) { + dm_dev_free(dmv); kmem_free(cf, sizeof(*cf)); aprint_error("Unable to attach pseudo device dm/%s\n", name); return (ENOMEM); } - if ((dmv = dm_dev_alloc()) == NULL) - return ENOMEM; if (uuid) strncpy(dmv->uuid, uuid, DM_UUID_LEN); @@ -247,7 +250,7 @@ dm_dev_create_ioctl(prop_dictionary_t dm prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); - disk_init(dmv->diskp, dmv->name, ); + disk_init(dmv->diskp, device_xname(devt), ); disk_attach(dmv->diskp); dmv->diskp->dk_info = NULL;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: mlelstv Date: Sun Jan 14 07:56:53 UTC 2024 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: Avoid leaving a configured device without resources. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: andvar Date: Thu Oct 13 06:10:48 UTC 2022 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: s/exaple/example/ To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.55 src/sys/dev/dm/dm_ioctl.c:1.56 --- src/sys/dev/dm/dm_ioctl.c:1.55 Sat Aug 21 22:23:33 2021 +++ src/sys/dev/dm/dm_ioctl.c Thu Oct 13 06:10:48 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.55 2021/08/21 22:23:33 andvar Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.55 2021/08/21 22:23:33 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -74,7 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v * * Example: dm_table_get_entry * dm_table_destroy/dm_table_switch_tables - * This exaple will lead to deadlock situation because after dm_table_get_entry + * This example will lead to deadlock situation because after dm_table_get_entry * table reference counter is != 0 and dm_table_destroy have to wait on cv until * reference counter is 0. *
CVS commit: src/sys/dev/dm
Module Name:src Committed By: andvar Date: Thu Oct 13 06:10:48 UTC 2022 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: s/exaple/example/ To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: mlelstv Date: Mon Mar 28 10:38:00 UTC 2022 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Media size is in bytes (off_t), not sectors. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.62 src/sys/dev/dm/device-mapper.c:1.63 --- src/sys/dev/dm/device-mapper.c:1.62 Fri May 7 09:54:43 2021 +++ src/sys/dev/dm/device-mapper.c Mon Mar 28 10:38:00 2022 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.62 2021/05/07 09:54:43 hannken Exp $ */ +/*$NetBSD: device-mapper.c,v 1.63 2022/03/28 10:38:00 mlelstv Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -562,14 +562,15 @@ disk_ioctl_switch(dev_t dev, unsigned lo { off_t *valp = data; uint64_t numsec; + unsigned secsize; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; aprint_debug("DIOCGMEDIASIZE ioctl called\n"); - dm_table_disksize(>table_head, , NULL); - *valp = numsec; + dm_table_disksize(>table_head, , ); + *valp = (off_t) secsize * numsec; dm_dev_unbusy(dmv); break;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: mlelstv Date: Mon Mar 28 10:38:00 UTC 2022 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Media size is in bytes (off_t), not sectors. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: andvar Date: Sat Aug 21 22:23:33 UTC 2021 Modified Files: src/sys/dev/dm: dm.h dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c src/sys/dev/dm/doc: design.txt locking.txt Log Message: fix typos in sys/dev/dm code comments and documentation. also remove some trailing space in documentation. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/dev/dm/dm.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dm/doc/design.txt cvs rdiff -u -r1.3 -r1.4 src/sys/dev/dm/doc/locking.txt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: andvar Date: Sat Aug 21 22:23:33 UTC 2021 Modified Files: src/sys/dev/dm: dm.h dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c src/sys/dev/dm/doc: design.txt locking.txt Log Message: fix typos in sys/dev/dm code comments and documentation. also remove some trailing space in documentation. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/dev/dm/dm.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dm/doc/design.txt cvs rdiff -u -r1.3 -r1.4 src/sys/dev/dm/doc/locking.txt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.55 src/sys/dev/dm/dm.h:1.56 --- src/sys/dev/dm/dm.h:1.55 Tue Jan 21 16:27:53 2020 +++ src/sys/dev/dm/dm.h Sat Aug 21 22:23:33 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.55 2020/01/21 16:27:53 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.56 2021/08/21 22:23:33 andvar Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -117,7 +117,7 @@ typedef struct dm_pdev { struct vnode *pdev_vnode; uint64_t pdev_numsec; unsigned int pdev_secsize; - int ref_cnt; /* reference counter for users ofthis pdev */ + int ref_cnt; /* reference counter for users of this pdev */ SLIST_ENTRY(dm_pdev) next_pdev; } dm_pdev_t; @@ -137,7 +137,7 @@ typedef struct dm_dev { uint64_t minor; /* Device minor number */ uint32_t flags; /* store communication protocol flags */ - kmutex_t dev_mtx; /* mutex for generall device lock */ + kmutex_t dev_mtx; /* mutex for general device lock */ kcondvar_t dev_cv; /* cv for between ioctl synchronisation */ uint32_t event_nr; Index: src/sys/dev/dm/dm_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.18 src/sys/dev/dm/dm_dev.c:1.19 --- src/sys/dev/dm/dm_dev.c:1.18 Wed Jul 8 15:07:13 2020 +++ src/sys/dev/dm/dm_dev.c Sat Aug 21 22:23:33 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.18 2020/07/08 15:07:13 thorpej Exp $ */ +/*$NetBSD: dm_dev.c,v 1.19 2021/08/21 22:23:33 andvar Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.18 2020/07/08 15:07:13 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.19 2021/08/21 22:23:33 andvar Exp $"); #include #include @@ -270,7 +270,7 @@ dm_dev_rem(const char *dm_dev_name, cons /* * Destroy all devices created in device-mapper. Remove all tables - * free all allocated memmory. + * free all allocated memory. */ int dm_dev_destroy(void) Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.54 src/sys/dev/dm/dm_ioctl.c:1.55 --- src/sys/dev/dm/dm_ioctl.c:1.54 Fri Aug 20 20:25:27 2021 +++ src/sys/dev/dm/dm_ioctl.c Sat Aug 21 22:23:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.54 2021/08/20 20:25:27 andvar Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.55 2021/08/21 22:23:33 andvar Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.54 2021/08/20 20:25:27 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.55 2021/08/21 22:23:33 andvar Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -53,10 +53,10 @@ __KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v * on uint8_t argument. * * dm_table_release must be called for every table_entry from - * dm_table_get_entry. Between these to calls tables can'tbe switched + * dm_table_get_entry. Between these two calls tables can't be switched * or destroyed. * - * dm_table_head_init initialize talbe_entries SLISTS and io_cv. + * dm_table_head_init initialize table_entries SLISTS and io_cv. * * dm_table_head_destroy destroy cv. * @@ -265,7 +265,7 @@ dm_dev_create_ioctl(prop_dictionary_t dm } /* - * Get list of created device-mapper devices fromglobal list and + * Get list of created device-mapper devices from global list and * send it to kernel. * * Output dictionary: @@ -695,7 +695,7 @@ dm_table_deps(dm_table_entry_t *table_en /* * Load new table/tables to device. - * Call apropriate target init routine open all physical pdev's and + * Call appropriate target init routine to open all physical pdev's and * link them to device. For other targets mirror, strip, snapshot * etc. also add dependency devices to upcalls list. * Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.22 src/sys/dev/dm/dm_pdev.c:1.23 --- src/sys/dev/dm/dm_pdev.c:1.22 Fri Dec 20 16:16:36 2019 +++ src/sys/dev/dm/dm_pdev.c
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Nov 30 05:35:57 UTC 2019 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: dm: Always initialize target's status string Explicitly clear status string to prevent dmsetup(8) from printing binary junk to stdout. Similar change has been applied to DragonFlyBSD since 2015. https://github.com/DragonFlyBSD/DragonFlyBSD/commit/a6cf54187fd7c3e994c573215806ec03572c038e taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Nov 30 05:35:57 UTC 2019 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: dm: Always initialize target's status string Explicitly clear status string to prevent dmsetup(8) from printing binary junk to stdout. Similar change has been applied to DragonFlyBSD since 2015. https://github.com/DragonFlyBSD/DragonFlyBSD/commit/a6cf54187fd7c3e994c573215806ec03572c038e taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.33 src/sys/dev/dm/dm_ioctl.c:1.34 --- src/sys/dev/dm/dm_ioctl.c:1.33 Sun Nov 11 10:21:11 2018 +++ src/sys/dev/dm/dm_ioctl.c Sat Nov 30 05:35:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.33 2018/11/11 10:21:11 mlelstv Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.34 2019/11/30 05:35:57 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.33 2018/11/11 10:21:11 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.34 2019/11/30 05:35:57 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -927,6 +927,12 @@ dm_table_status_ioctl(prop_dictionary_t prop_dictionary_set_int32(target_dict, DM_TABLE_STAT, dmv->table_head.cur_active_table); + /* + * Explicitly clear DM_TABLE_PARAMS to prevent dmsetup(8) from + * printing junk when DM_TABLE_PARAMS was never initialized. + */ + prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, ""); + if (flags & DM_STATUS_TABLE_FLAG) { params = table_en->target->status (table_en->target_config);
Re: CVS commit: src/sys/dev/dm
Le 18/08/2014 19:16, Alistair G. Crooks a écrit : Module Name: src Committed By: agc Date: Mon Aug 18 17:16:42 UTC 2014 Modified Files: src/sys/dev/dm: dm_target_stripe.c Log Message: Avoid a memory leak - from maxv To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_stripe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. I have a doubt for this one. for (strpi = DM_STRIPE_DEV_OFFSET; strpi strpc; strpi += 2) { printf(Stripe target device name %s -- offset %s\n, argv[strpi], argv[strpi+1]); tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP); if ((tlc-pdev = dm_pdev_insert(argv[strpi])) == NULL) { kmem_free(tsc, sizeof(*tsc)); XXX kmem_free(tlc, sizeof(*tlc)); return ENOENT; } tlc-offset = atoi(argv[strpi+1]); /* Insert striping device to linked list. */ XXX TAILQ_INSERT_TAIL(tsc-stripe_devs, tlc, entries); } The tlc's inserted into the list are not freed, are they?
Re: CVS commit: src/sys/dev/dm
On Aug 19, 6:50am, Maxime Villard wrote: } Le 18/08/2014 19:16, Alistair G. Crooks a écrit : } } Module Name:src } Committed By: agc } Date: Mon Aug 18 17:16:42 UTC 2014 } } Modified Files: } src/sys/dev/dm: dm_target_stripe.c } } Log Message: } Avoid a memory leak - from maxv } } To generate a diff of this commit: } cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_stripe.c } } I have a doubt for this one. } } for (strpi = DM_STRIPE_DEV_OFFSET; strpi strpc; strpi += 2) { } printf(Stripe target device name %s -- offset %s\n, } argv[strpi], argv[strpi+1]); } } tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP); } if ((tlc-pdev = dm_pdev_insert(argv[strpi])) == NULL) { } kmem_free(tsc, sizeof(*tsc)); } XXX kmem_free(tlc, sizeof(*tlc)); } return ENOENT; } } } tlc-offset = atoi(argv[strpi+1]); } } /* Insert striping device to linked list. */ } XXX TAILQ_INSERT_TAIL(tsc-stripe_devs, tlc, entries); } } } } The tlc's inserted into the list are not freed, are they? Notice the return ENOENT after the two calls to kmem_free(). If the first XXX line is executed then the second XXX line won't be. }-- End of excerpt from Maxime Villard
Re: CVS commit: src/sys/dev/dm
Le 19/08/2014 10:31, John Nemeth a écrit : On Aug 19, 6:50am, Maxime Villard wrote: } Le 18/08/2014 19:16, Alistair G. Crooks a écrit : } } Module Name: src } Committed By: agc } Date: Mon Aug 18 17:16:42 UTC 2014 } } Modified Files: }src/sys/dev/dm: dm_target_stripe.c } } Log Message: } Avoid a memory leak - from maxv } } To generate a diff of this commit: } cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_stripe.c } } I have a doubt for this one. } } for (strpi = DM_STRIPE_DEV_OFFSET; strpi strpc; strpi += 2) { } printf(Stripe target device name %s -- offset %s\n, }argv[strpi], argv[strpi+1]); } } tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP); } if ((tlc-pdev = dm_pdev_insert(argv[strpi])) == NULL) { } kmem_free(tsc, sizeof(*tsc)); } XXX kmem_free(tlc, sizeof(*tlc)); } return ENOENT; } } } tlc-offset = atoi(argv[strpi+1]); } } /* Insert striping device to linked list. */ } XXX TAILQ_INSERT_TAIL(tsc-stripe_devs, tlc, entries); } } } } The tlc's inserted into the list are not freed, are they? Notice the return ENOENT after the two calls to kmem_free(). If the first XXX line is executed then the second XXX line won't be. Yes, but that's a loop. The second XXX line may be reached several times, before the first one returns ENOENT. And on that case the tlc's previously allocated are not freed. Unless I'm not reading clearly?
Re: CVS commit: src/sys/dev/dm
On Tue, May 18, 2010 at 03:10:41PM +, Adam Hamsik wrote: Log Message: Add support for DIOCCACHESYNC ioctl for dm devices. Add new sync function pointer to dm_target_t because that is the only part of dm which know real block device. disk_ioctl_switch parses whole device table and for every entry it calls particular sync routine which propagates DIOCCACHESYNC to real disk. What happens if a logical volume consists of two slice of one physical device? Will the physical device get flushed twice? Kind regards -- Matthias Scheler http://zhadum.org.uk/
Re: CVS commit: src/sys/dev/dm
On May,Tuesday 18 2010, at 5:42 PM, Matthias Scheler wrote: On Tue, May 18, 2010 at 03:10:41PM +, Adam Hamsik wrote: Log Message: Add support for DIOCCACHESYNC ioctl for dm devices. Add new sync function pointer to dm_target_t because that is the only part of dm which know real block device. disk_ioctl_switch parses whole device table and for every entry it calls particular sync routine which propagates DIOCCACHESYNC to real disk. What happens if a logical volume consists of two slice of one physical device? Will the physical device get flushed twice? Yes and there is no easy way how to not do that. Regards Adam.
Re: CVS commit: src/sys/dev/dm
On Mar,Tuesday 23 2010, at 4:09 PM, Jonathan A. Kollasch wrote: Module Name: src Committed By: jakllsch Date: Tue Mar 23 15:09:45 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Rework module/builtin code so it works in both cases. (Tested recently in the module case, slightly less recently as builtin.) haad [if it works] go for it now when we have built in case working, would you like to add pseudo-device dm to AMD64, i386 non-modular kernels ? I think that ALL MONOLITHIC *XEN* should be enough. What do you think about this ?(Sorry I have zero free time now, otherwise I would do it myself:() Regards Adam.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Fri Feb 26 23:52:43 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Use correct prototype for dmattach(). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.17 src/sys/dev/dm/device-mapper.c:1.18 --- src/sys/dev/dm/device-mapper.c:1.17 Thu Feb 25 23:37:39 2010 +++ src/sys/dev/dm/device-mapper.c Fri Feb 26 23:52:43 2010 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.17 2010/02/25 23:37:39 haad Exp $ */ +/*$NetBSD: device-mapper.c,v 1.18 2010/02/26 23:52:43 jakllsch Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -46,7 +46,6 @@ #include sys/ioccom.h #include sys/kmem.h #include sys/module.h -#include sys/once.h #include netbsd-dm.h #include dm.h @@ -60,9 +59,10 @@ static dev_type_size(dmsize); /* attach and detach routines */ -int dmattach(void); +void dmattach(int); int dmdestroy(void); +static int doinit(void); static int dm_cmd_to_fun(prop_dictionary_t); static int disk_ioctl_switch(dev_t, u_long, void *); static int dm_ioctl_switch(u_long); @@ -161,11 +161,9 @@ if (error) break; - error = dmattach(); + error = doinit(); if (error) { config_cfdriver_detach(dm_cd); - aprint_error(%s: unable to register cfattach\n, - dm_cd.cd_name); break; } @@ -278,7 +276,8 @@ error = config_cfattach_attach(dm_cd.cd_name, dm_ca); if (error) { - aprint_error(Unable to register cfattach for dm driver\n); + aprint_error(%s: unable to register cfattach\n, + dm_cd.cd_name); return error; } @@ -290,12 +289,10 @@ } /* attach routine */ -int -dmattach(void) +void +dmattach(int n) { - static ONCE_DECL(control); - - return RUN_ONCE(control, doinit); + doinit(); } /* Destroy routine */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Fri Feb 26 23:52:43 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Use correct prototype for dmattach(). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Sat Feb 27 00:31:57 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Use RUN_ONCE(9) again. (Everyone happy now?) To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Sat Feb 27 00:31:57 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Use RUN_ONCE(9) again. (Everyone happy now?) To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.18 src/sys/dev/dm/device-mapper.c:1.19 --- src/sys/dev/dm/device-mapper.c:1.18 Fri Feb 26 23:52:43 2010 +++ src/sys/dev/dm/device-mapper.c Sat Feb 27 00:31:57 2010 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.18 2010/02/26 23:52:43 jakllsch Exp $ */ +/*$NetBSD: device-mapper.c,v 1.19 2010/02/27 00:31:57 jakllsch Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -46,6 +46,7 @@ #include sys/ioccom.h #include sys/kmem.h #include sys/module.h +#include sys/once.h #include netbsd-dm.h #include dm.h @@ -62,7 +63,9 @@ void dmattach(int); int dmdestroy(void); +static ONCE_DECL(doinit_control); static int doinit(void); + static int dm_cmd_to_fun(prop_dictionary_t); static int disk_ioctl_switch(dev_t, u_long, void *); static int dm_ioctl_switch(u_long); @@ -161,7 +164,7 @@ if (error) break; - error = doinit(); + error = RUN_ONCE(doinit_control, doinit); if (error) { config_cfdriver_detach(dm_cd); break; @@ -292,7 +295,7 @@ void dmattach(int n) { - doinit(); + RUN_ONCE(doinit_control, doinit); } /* Destroy routine */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Thu Feb 25 20:48:59 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c dm_ioctl.c Log Message: Be sure to config_cfattach_attach() in dmattach(). Loosely based on patch from Brian Brombacher, with other inspriation from vnd(4). This should fix PR kern/42799. While here, a few prototype, style and namespace pollution-related changes. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: jakllsch Date: Thu Feb 25 20:48:59 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c dm_ioctl.c Log Message: Be sure to config_cfattach_attach() in dmattach(). Loosely based on patch from Brian Brombacher, with other inspriation from vnd(4). This should fix PR kern/42799. While here, a few prototype, style and namespace pollution-related changes. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.15 src/sys/dev/dm/device-mapper.c:1.16 --- src/sys/dev/dm/device-mapper.c:1.15 Fri Jan 8 00:27:48 2010 +++ src/sys/dev/dm/device-mapper.c Thu Feb 25 20:48:58 2010 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.15 2010/01/08 00:27:48 pooka Exp $ */ +/*$NetBSD: device-mapper.c,v 1.16 2010/02/25 20:48:58 jakllsch Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,9 +59,10 @@ static dev_type_size(dmsize); /* attach and detach routines */ -int dmattach(void); -int dmdestroy(void); +void dmattach(int); +void dmdestroy(void); +static void dm_init(void); static int dm_cmd_to_fun(prop_dictionary_t); static int disk_ioctl_switch(dev_t, u_long, void *); static int dm_ioctl_switch(u_long); @@ -112,7 +113,7 @@ extern struct cfdriver dm_cd; -extern uint64_t dev_counter; +extern uint64_t dm_dev_counter; /* * This array is used to translate cmd to function pointer. @@ -149,15 +150,15 @@ dm_modcmd(modcmd_t cmd, void *arg) { #ifdef _MODULE - int bmajor = -1, cmajor = -1; int error; + int bmajor, cmajor; error = 0; + bmajor = -1; + cmajor = -1; switch (cmd) { case MODULE_CMD_INIT: - dmattach(); - error = config_cfdriver_attach(dm_cd); if (error) break; @@ -165,13 +166,21 @@ error = config_cfattach_attach(dm_cd.cd_name, dm_ca); if (error) { config_cfdriver_detach(dm_cd); - aprint_error(Unable to register cfattach for dm driver\n); - + aprint_error(%s: unable to register cfattach\n, + dm_cd.cd_name); break; } - error = devsw_attach(dm, dm_bdevsw, bmajor, + error = devsw_attach(dm_cd.cd_name, dm_bdevsw, bmajor, dm_cdevsw, cmajor); + if (error) { + config_cfattach_detach(dm_cd.cd_name, dm_ca); + config_cfdriver_detach(dm_cd); + break; + } + + dm_init(); + break; case MODULE_CMD_FINI: @@ -181,7 +190,7 @@ * to disable auto-unload only if there is mounted dm device * present. */ - if (dev_counter 0) + if (dm_dev_counter 0) return EBUSY; dmdestroy(); @@ -270,25 +279,29 @@ (void)dm_dev_free(dmv); /* Decrement device counter After removing device */ - atomic_dec_64(dev_counter); + atomic_dec_64(dm_dev_counter); return 0; } /* attach routine */ -int -dmattach(void) +void +dmattach(int num) { + int error; - dm_target_init(); - dm_dev_init(); - dm_pdev_init(); + error = config_cfattach_attach(dm_cd.cd_name, dm_ca); + if (error) { + aprint_error(%s: unable to register cfattach\n, + dm_cd.cd_name); + return; + } - return 0; + dm_init(); } /* Destroy routine */ -int +void dmdestroy(void) { @@ -296,7 +309,6 @@ dm_pdev_destroy(); dm_target_destroy(); - return 0; } static int @@ -354,6 +366,14 @@ return r; } +static void +dm_init(void) +{ + dm_target_init(); + dm_dev_init(); + dm_pdev_init(); +} + /* * Translate command sent from libdevmapper to func. */ Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.20 src/sys/dev/dm/dm_ioctl.c:1.21 --- src/sys/dev/dm/dm_ioctl.c:1.20 Mon Jan 4 00:19:08 2010 +++ src/sys/dev/dm/dm_ioctl.c Thu Feb 25 20:48:58 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.20 2010/01/04 00:19:08 haad Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.21 2010/02/25 20:48:58 jakllsch Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ static uint64_t sc_minor_num; extern const struct dkdriver dmdkdriver; -uint64_t dev_counter; +uint64_t dm_dev_counter; /* Generic cf_data for device-mapper driver */ static struct cfdata dm_cfdata = { @@ -266,7 +266,7 @@ DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG); /* Increment device counter After creating device */ - atomic_inc_64(dev_counter); + atomic_inc_64(dm_dev_counter); return r; }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Thu Feb 25 23:37:39 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Fix device-mapper to work in builtin case. This commit fixes PR: 42799 REwork fix commited by jak@ to be more readable and remove unneeded ifdef _MODULE. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.16 src/sys/dev/dm/device-mapper.c:1.17 --- src/sys/dev/dm/device-mapper.c:1.16 Thu Feb 25 20:48:58 2010 +++ src/sys/dev/dm/device-mapper.c Thu Feb 25 23:37:39 2010 @@ -1,7 +1,7 @@ -/*$NetBSD: device-mapper.c,v 1.16 2010/02/25 20:48:58 jakllsch Exp $ */ +/*$NetBSD: device-mapper.c,v 1.17 2010/02/25 23:37:39 haad Exp $ */ /* - * Copyright (c) 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -46,6 +46,7 @@ #include sys/ioccom.h #include sys/kmem.h #include sys/module.h +#include sys/once.h #include netbsd-dm.h #include dm.h @@ -59,10 +60,9 @@ static dev_type_size(dmsize); /* attach and detach routines */ -void dmattach(int); -void dmdestroy(void); +int dmattach(void); +int dmdestroy(void); -static void dm_init(void); static int dm_cmd_to_fun(prop_dictionary_t); static int disk_ioctl_switch(dev_t, u_long, void *); static int dm_ioctl_switch(u_long); @@ -149,9 +149,7 @@ static int dm_modcmd(modcmd_t cmd, void *arg) { -#ifdef _MODULE - int error; - int bmajor, cmajor; + int error, bmajor, cmajor; error = 0; bmajor = -1; @@ -163,7 +161,7 @@ if (error) break; - error = config_cfattach_attach(dm_cd.cd_name, dm_ca); + error = dmattach(); if (error) { config_cfdriver_detach(dm_cd); aprint_error(%s: unable to register cfattach\n, @@ -178,9 +176,6 @@ config_cfdriver_detach(dm_cd); break; } - - dm_init(); - break; case MODULE_CMD_FINI: @@ -192,9 +187,8 @@ */ if (dm_dev_counter 0) return EBUSY; - dmdestroy(); - error = config_cfattach_detach(dm_cd.cd_name, dm_ca); + error = dmdestroy(); if (error) break; @@ -210,13 +204,6 @@ } return error; -#else - - if (cmd == MODULE_CMD_INIT) - return 0; - return ENOTTY; - -#endif /* _MODULE */ } @@ -284,31 +271,48 @@ return 0; } -/* attach routine */ -void -dmattach(int num) +static int +doinit(void) { int error; - + error = config_cfattach_attach(dm_cd.cd_name, dm_ca); if (error) { - aprint_error(%s: unable to register cfattach\n, - dm_cd.cd_name); - return; + aprint_error(Unable to register cfattach for dm driver\n); + return error; } + + dm_target_init(); + dm_dev_init(); + dm_pdev_init(); - dm_init(); + return 0; +} + +/* attach routine */ +int +dmattach(void) +{ + static ONCE_DECL(control); + + return RUN_ONCE(control, doinit); } /* Destroy routine */ -void +int dmdestroy(void) { + int error; + error = config_cfattach_detach(dm_cd.cd_name, dm_ca); + if (error) + return error; + dm_dev_destroy(); dm_pdev_destroy(); dm_target_destroy(); + return 0; } static int @@ -366,14 +370,6 @@ return r; } -static void -dm_init(void) -{ - dm_target_init(); - dm_dev_init(); - dm_pdev_init(); -} - /* * Translate command sent from libdevmapper to func. */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Thu Feb 25 23:37:39 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Fix device-mapper to work in builtin case. This commit fixes PR: 42799 REwork fix commited by jak@ to be more readable and remove unneeded ifdef _MODULE. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: pooka Date: Fri Jan 8 00:27:48 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Fix this for non-module (which, i guess, is only i386/ALL). XXX: autoconfusion vs. modules is an intolerable mess of stepping on each others' toes. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Sun Jan 3 12:53:00 UTC 2010 Modified Files: src/sys/dev/dm: dm_pdev.c Log Message: Replace aprint_Verbose with aprint_debug to shutup unnecessary logs. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dm/dm_pdev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Sun Jan 3 22:44:10 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: KNF police, remove unnecessary whitespaces and tabulators. Refactor dmioctl to not use prop_dictionary_copy* functions if NetBSD_DM_IOCTL command was not called on device. If disk_ioctl returms anything else then ENOTTY exit from dmioctl. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Sun Jan 3 22:55:26 UTC 2010 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: Refactor dmioctl to by cleaner and to copyout dictionary in case when something went wrong. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/device-mapper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Mon Jan 4 00:14:41 UTC 2010 Modified Files: src/sys/dev/dm: dm_target.c dm_target_linear.c dm_target_stripe.c Log Message: Indent files remove unnecessary blank lines, white spaces and KNFize code. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/dm/dm_target_linear.c \ src/sys/dev/dm/dm_target_stripe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: haad Date: Mon Jan 4 00:19:08 UTC 2010 Modified Files: src/sys/dev/dm: dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c Log Message: Indent files remove unnecessary blank lines, white spaces and KNFize code. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dm/dm_table.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.