CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sun Jan 24 14:37:32 UTC 2021 Modified Files: src/usr.sbin/fstyp: exfat.c Log Message: fstyp: Fix exfat detection taken-from FreeBSD ddf61156132b610915325769cbb93ea11be0d433 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/exfat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/exfat.c diff -u src/usr.sbin/fstyp/exfat.c:1.3 src/usr.sbin/fstyp/exfat.c:1.4 --- src/usr.sbin/fstyp/exfat.c:1.3 Sat Feb 8 12:56:56 2020 +++ src/usr.sbin/fstyp/exfat.c Sun Jan 24 14:37:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $ */ +/* $NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $ */ /* * Copyright (c) 2017 Conrad Meyer @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ #include -__RCSID("$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $"); +__RCSID("$NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $"); #include #include @@ -327,15 +327,15 @@ fstyp_exfat(FILE *fp, char *label, size_ uint32_t chksum; int error; + error = 1; cksect = NULL; - ev = (struct exfat_vbr *)read_buf(fp, 0, 512); if (ev == NULL || strncmp(ev->ev_fsname, "EXFAT ", 8) != 0) - goto fail; + goto out; if (ev->ev_log_bytes_per_sect < 9 || ev->ev_log_bytes_per_sect > 12) { warnx("exfat: Invalid BytesPerSectorShift"); - goto done; + goto out; } bytespersec = (1u << ev->ev_log_bytes_per_sect); @@ -343,7 +343,7 @@ fstyp_exfat(FILE *fp, char *label, size_ error = exfat_compute_boot_chksum(fp, MAIN_BOOT_REGION_SECT, bytespersec, &chksum); if (error != 0) - goto done; + goto out; cksect = read_sect(fp, MAIN_BOOT_REGION_SECT + SUBREGION_CHKSUM_SECT, bytespersec); @@ -355,18 +355,15 @@ fstyp_exfat(FILE *fp, char *label, size_ if (chksum != le32toh(cksect[0])) { warnx("exfat: Found checksum 0x%08x != computed 0x%08x", le32toh(cksect[0]), chksum); - goto done; + error = 1; + goto out; } if (show_label) exfat_find_label(fp, ev, bytespersec, label, size); -done: +out: free(cksect); free(ev); - return (0); - -fail: - free(ev); - return (1); + return (error != 0); }
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sun Jan 10 12:38:41 UTC 2021 Modified Files: src/usr.sbin/fstyp: fstyp.h hammer.c hammer2.c hammer2_disk.h Log Message: fstyp: Sync HAMMER1/2 with DragonFly BSD taken-from: DragonFly BSD To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/fstyp/fstyp.h cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/hammer.c cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/fstyp/hammer2.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/hammer2_disk.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.8 src/usr.sbin/fstyp/fstyp.h:1.9 --- src/usr.sbin/fstyp/fstyp.h:1.8 Wed Jan 1 09:08:52 2020 +++ src/usr.sbin/fstyp/fstyp.h Sun Jan 10 12:38:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.8 2020/01/01 09:08:52 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.9 2021/01/10 12:38:40 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -74,5 +74,7 @@ int fstyp_zfs(FILE *, char *, size_t); int fsvtyp_hammer(const char *, char *, size_t); int fsvtyp_hammer_partial(const char *, char *, size_t); +int fsvtyp_hammer2(const char *, char *, size_t); +int fsvtyp_hammer2_partial(const char *, char *, size_t); #endif /* !FSTYP_H */ Index: src/usr.sbin/fstyp/hammer.c diff -u src/usr.sbin/fstyp/hammer.c:1.3 src/usr.sbin/fstyp/hammer.c:1.4 --- src/usr.sbin/fstyp/hammer.c:1.3 Wed Jan 15 15:30:46 2020 +++ src/usr.sbin/fstyp/hammer.c Sun Jan 10 12:38:40 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $ */ +/*$NetBSD: hammer.c,v 1.4 2021/01/10 12:38:40 tkusumi Exp $ */ /*- * Copyright (c) 2016-2019 The DragonFly Project @@ -27,13 +27,13 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.4 2021/01/10 12:38:40 tkusumi Exp $"); #include #include #include #include -#include +#include #include "fstyp.h" #include "hammer_disk.h" @@ -41,13 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1 static hammer_volume_ondisk_t read_ondisk(FILE *fp) { - hammer_volume_ondisk_t ondisk; - - ondisk = read_buf(fp, 0, sizeof(*ondisk)); - if (ondisk == NULL) - err(1, "failed to read ondisk"); - - return (ondisk); + return (read_buf(fp, 0, sizeof(struct hammer_volume_ondisk))); } static int @@ -61,32 +55,49 @@ test_ondisk(const hammer_volume_ondisk_t ondisk->vol_signature != HAMMER_FSBUF_VOLUME_REV) return (1); if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) - return (2); + return (1); if (ondisk->vol_no < 0 || ondisk->vol_no > HAMMER_MAX_VOLUMES - 1) - return (3); + return (1); if (ondisk->vol_count < 1 || ondisk->vol_count > HAMMER_MAX_VOLUMES) - return (4); + return (1); if (count == 0) { count = ondisk->vol_count; - assert(count != 0); + if (count == 0) + return (1); memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); strlcpy(label, ondisk->vol_label, sizeof(label)); } else { if (ondisk->vol_count != count) - return (5); - if (memcmp(&ondisk->vol_fsid, &fsid, sizeof(fsid))) - return (6); - if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) - return (7); + return (1); + if (!uuid_equal(&ondisk->vol_fsid, &fsid, NULL)) + return (1); + if (!uuid_equal(&ondisk->vol_fstype, &fstype, NULL)) + return (1); if (strcmp(ondisk->vol_label, label)) - return (8); + return (1); } return (0); } +static const char* +extract_device_name(const char *devpath) +{ + const char *p; + + p = strrchr(devpath, '/'); + if (p) { + p++; + if (*p == 0) + p = NULL; + } else { + p = devpath; + } + return (p); +} + int fstyp_hammer(FILE *fp, char *label, size_t size) { @@ -96,6 +107,8 @@ fstyp_hammer(FILE *fp, char *label, size const char *p; #endif ondisk = read_ondisk(fp); + if (!ondisk) + goto fail; if (ondisk->vol_no != HAMMER_ROOT_VOLNO) goto fail; if (ondisk->vol_count != 1) @@ -109,15 +122,11 @@ fstyp_hammer(FILE *fp, char *label, size */ #ifdef HAS_DEVPATH /* Add device name to help support multiple autofs -media mounts. */ - p = strrchr(devpath, '/'); - if (p) { - p++; - if (*p == 0) - strlcpy(label, ondisk->vol_label, size); - else - snprintf(label, size, "%s_%s", ondisk->vol_label, p); - } else - snprintf(label, size, "%s_%s", ondisk->vol_label, devpath); + p = extract_device_name(devpath); + if (p) + snprintf(label, size, "%s_%s", ondisk->vol_label, p); + else + strlcpy(label, ondisk->vol_label, size); #else strlcpy(label, ondisk->vol_label, size); #endif @@ -130,20 +139,23 @@ fail: static int test_volume(const char *volpath) { - hammer_volume_ondisk_t ondisk; + hammer_volume_ondisk_t ondisk = NULL; FILE *fp; int volno = -1; if ((fp = fopen(volpath, "r")) == NULL) - e
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Sep 23 14:39:23 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer2.c hammer2_disk.h Log Message: fstyp: Sync hammer2_disk.h with DragonFly BSD taken-from: DragonFly BSD To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/fstyp/hammer2.c cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/hammer2_disk.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.5 src/usr.sbin/fstyp/hammer2.c:1.6 --- src/usr.sbin/fstyp/hammer2.c:1.5 Fri Aug 14 18:35:57 2020 +++ src/usr.sbin/fstyp/hammer2.c Wed Sep 23 14:39:23 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.6 2020/09/23 14:39:23 tkusumi Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.6 2020/09/23 14:39:23 tkusumi Exp $"); #include #include @@ -79,10 +79,10 @@ read_media(FILE *fp, const hammer2_block } io_off = bref->data_off & ~HAMMER2_OFF_MASK_RADIX; - io_base = io_off & ~(hammer2_off_t)(HAMMER2_MINIOSIZE - 1); + io_base = io_off & ~(hammer2_off_t)(HAMMER2_LBUFSIZE - 1); boff = (size_t)(io_off - io_base); - io_bytes = HAMMER2_MINIOSIZE; + io_bytes = HAMMER2_LBUFSIZE; while (io_bytes + boff < bytes) io_bytes <<= 1; Index: src/usr.sbin/fstyp/hammer2_disk.h diff -u src/usr.sbin/fstyp/hammer2_disk.h:1.1 src/usr.sbin/fstyp/hammer2_disk.h:1.2 --- src/usr.sbin/fstyp/hammer2_disk.h:1.1 Wed Jan 1 08:56:41 2020 +++ src/usr.sbin/fstyp/hammer2_disk.h Wed Sep 23 14:39:23 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2_disk.h,v 1.1 2020/01/01 08:56:41 tkusumi Exp $ */ +/*$NetBSD: hammer2_disk.h,v 1.2 2020/09/23 14:39:23 tkusumi Exp $ */ /* * Copyright (c) 2011-2019 The DragonFly Project. All rights reserved. @@ -35,7 +35,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2_disk.h,v 1.1 2020/01/01 08:56:41 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2_disk.h,v 1.2 2020/09/23 14:39:23 tkusumi Exp $"); #ifndef _VFS_HAMMER2_DISK_H_ #define _VFS_HAMMER2_DISK_H_ @@ -96,15 +96,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk #define HAMMER2_RADIX_KEY 64 /* number of bits in key */ /* - * MINALLOCSIZE - The minimum allocation size. This can be smaller - * or larger than the minimum physical IO size. - * - * NOTE: Should not be larger than 1K since inodes - *are 1K. - * - * MINIOSIZE - The minimum IO size. This must be less than - * or equal to HAMMER2_LBUFSIZE. - * * HAMMER2_LBUFSIZE - Nominal buffer size for I/O rollups. * * HAMMER2_PBUFSIZE - Topological block size used by files for all @@ -122,12 +113,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk #define HAMMER2_LBUFRADIX 14 /* logical buf (1<<14) bytes */ #define HAMMER2_LBUFSIZE 16384 -/* - * Generally speaking we want to use 16K and 64K I/Os - */ -#define HAMMER2_MINIORADIX HAMMER2_LBUFRADIX -#define HAMMER2_MINIOSIZE HAMMER2_LBUFSIZE - #define HAMMER2_IND_BYTES_MIN 4096 #define HAMMER2_IND_BYTES_NOM HAMMER2_LBUFSIZE #define HAMMER2_IND_BYTES_MAX HAMMER2_PBUFSIZE @@ -149,9 +134,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk * resulting in highly efficient storage for files <= 512 bytes and for files * <= 512KB. Up to 4 directory entries can be referenced from a directory * without requiring an indirect block. - * - * Indirect blocks are typically either 4KB (64 blockrefs / ~4MB represented), - * or 64KB (1024 blockrefs / ~64MB represented). */ #define HAMMER2_SET_RADIX 2 /* radix 2 = 4 entries */ #define HAMMER2_SET_COUNT (1 << HAMMER2_SET_RADIX) @@ -171,10 +153,9 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk #define HAMMER2_UUID_STRING "5cbb9ad1-862d-11dc-a94d-01301bb8a9f5" /* - * A 4MB segment is reserved at the beginning of each 2GB zone. This segment + * A 4MB segment is reserved at the beginning of each 1GB. This segment * contains the volume header (or backup volume header), the free block - * table, and possibly other information in the future. A 4MB segment for - * freemap is reserved at the beginning of every 1GB. + * table, and possibly other information in the future. * * 4MB = 64 x 64K blocks. Each 4MB segment is broken down as follows: * @@ -286,7 +267,7 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk #define HAMMER2_VOLUME_ALIGN (8 * 1024 * 1024) #define HAMMER2_VOLUME_ALIGN64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGN) #define HAMMER2_VOLUME_ALIGNMASK (HAMMER2_VOLUME_ALIGN - 1) -#define HAMMER2_VOLUME_ALIGNMASK64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGNMASK) +#define HAMMER2_VOLUME_ALIGNMASK64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGNMASK) #define HAMMER2_NEWFS
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Fri Aug 14 18:35:57 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer2.c Log Message: fstyp: Fix incorrect pfs_type test for HAMMER2 inode taken-from: DragonFly BSD To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/fstyp/hammer2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.4 src/usr.sbin/fstyp/hammer2.c:1.5 --- src/usr.sbin/fstyp/hammer2.c:1.4 Wed Jan 15 15:32:05 2020 +++ src/usr.sbin/fstyp/hammer2.c Fri Aug 14 18:35:57 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $"); #include #include @@ -122,7 +122,7 @@ find_pfs(FILE *fp, const hammer2_blockre switch (bref->type) { case HAMMER2_BREF_TYPE_INODE: ipdata = media->ipdata; - if (ipdata.meta.pfs_type & HAMMER2_PFSTYPE_SUPROOT) { + if (ipdata.meta.pfs_type == HAMMER2_PFSTYPE_SUPROOT) { bscan = &ipdata.u.blockset.blockref[0]; bcount = HAMMER2_SET_COUNT; } else {
CVS commit: src/sys/fs/autofs
Module Name:src Committed By: tkusumi Date: Sun Apr 26 17:00:31 UTC 2020 Modified Files: src/sys/fs/autofs: autofs_vfsops.c Log Message: autofs: Silence down a warning which should really be a debug message taken-from: FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/fs/autofs/autofs_vfsops.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/fs/autofs/autofs_vfsops.c diff -u src/sys/fs/autofs/autofs_vfsops.c:1.10 src/sys/fs/autofs/autofs_vfsops.c:1.11 --- src/sys/fs/autofs/autofs_vfsops.c:1.10 Mon Mar 16 21:20:09 2020 +++ src/sys/fs/autofs/autofs_vfsops.c Sun Apr 26 17:00:31 2020 @@ -33,7 +33,7 @@ * */ #include -__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.10 2020/03/16 21:20:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.11 2020/04/26 17:00:31 tkusumi Exp $"); #include "autofs.h" @@ -194,7 +194,7 @@ autofs_unmount(struct mount *mp, int mnt flags |= FORCECLOSE; error = vflush(mp, NULL, flags); if (error) { - AUTOFS_WARN("vflush failed with error %d", error); + AUTOFS_DEBUG("vflush failed with error %d", error); return error; }
CVS commit: src/sys/fs/autofs
Module Name:src Committed By: tkusumi Date: Sat Mar 28 17:29:57 UTC 2020 Modified Files: src/sys/fs/autofs: autofs.c Log Message: autofs: Make autofs(5) timeout messages include affected process name and PID Sync warning message with FreeBSD and DragonFlyBSD. taken-from: FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/fs/autofs/autofs.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/fs/autofs/autofs.c diff -u src/sys/fs/autofs/autofs.c:1.4 src/sys/fs/autofs/autofs.c:1.5 --- src/sys/fs/autofs/autofs.c:1.4 Sat Dec 14 12:01:13 2019 +++ src/sys/fs/autofs/autofs.c Sat Mar 28 17:29:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $ */ +/* $NetBSD: autofs.c,v 1.5 2020/03/28 17:29:56 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.5 2020/03/28 17:29:56 tkusumi Exp $"); #include "autofs.h" @@ -376,8 +376,9 @@ autofs_trigger_one(struct autofs_node *a request_error = ar->ar_error; if (request_error) - AUTOFS_WARN("request for %s completed with error %d", - ar->ar_path, request_error); + AUTOFS_WARN("request for %s completed with error %d, " + "pid %d (%s)", ar->ar_path, request_error, + curproc->p_pid, curproc->p_comm); wildcards = ar->ar_wildcards;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Jan 21 16:27:53 UTC 2020 Modified Files: src/sys/dev/dm: dm.h dm_target.c dm_target_delay.c dm_target_error.c dm_target_flakey.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: #if0 target's ->upcall() handler This is part of NetBSD's dm design, but unimplemented (all handlers return 0) and also unused. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/dev/dm/dm.h cvs rdiff -u -r1.39 -r1.40 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/dm/dm_target_delay.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/dm/dm_target_flakey.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.54 src/sys/dev/dm/dm.h:1.55 --- src/sys/dev/dm/dm.h:1.54 Sun Jan 5 08:08:26 2020 +++ src/sys/dev/dm/dm.h Tue Jan 21 16:27:53 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.54 2020/01/05 08:08:26 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.55 2020/01/21 16:27:53 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -182,7 +182,7 @@ typedef struct dm_target { int (*destroy)(dm_table_entry_t *); int (*strategy)(dm_table_entry_t *, struct buf *); - int (*upcall)(dm_table_entry_t *, struct buf *); + //int (*upcall)(dm_table_entry_t *, struct buf *); /* * Optional routines. @@ -247,7 +247,7 @@ char *dm_target_linear_table(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); int dm_target_linear_destroy(dm_table_entry_t *); -int dm_target_linear_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_linear_upcall(dm_table_entry_t *, struct buf *); int dm_target_linear_secsize(dm_table_entry_t *, unsigned int *); /* dm_target_stripe.c */ @@ -257,20 +257,20 @@ char *dm_target_stripe_table(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); int dm_target_stripe_destroy(dm_table_entry_t *); -int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *); int dm_target_stripe_secsize(dm_table_entry_t *, unsigned int *); /* dm_target_error.c */ int dm_target_error_init(dm_table_entry_t*, int, char **); int dm_target_error_strategy(dm_table_entry_t *, struct buf *); int dm_target_error_destroy(dm_table_entry_t *); -int dm_target_error_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_error_upcall(dm_table_entry_t *, struct buf *); /* dm_target_zero.c */ int dm_target_zero_init(dm_table_entry_t *, int, char **); int dm_target_zero_strategy(dm_table_entry_t *, struct buf *); int dm_target_zero_destroy(dm_table_entry_t *); -int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); #if 0 /* dm_target_delay.c */ @@ -282,7 +282,7 @@ char *dm_target_delay_table(void *); int dm_target_delay_strategy(dm_table_entry_t *, struct buf *); int dm_target_delay_sync(dm_table_entry_t *); int dm_target_delay_destroy(dm_table_entry_t *); -int dm_target_delay_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_delay_upcall(dm_table_entry_t *, struct buf *); int dm_target_delay_secsize(dm_table_entry_t *, unsigned int *); /* dm_target_flakey.c */ @@ -291,7 +291,7 @@ char *dm_target_flakey_table(void *); int dm_target_flakey_strategy(dm_table_entry_t *, struct buf *); int dm_target_flakey_sync(dm_table_entry_t *); int dm_target_flakey_destroy(dm_table_entry_t *); -int dm_target_flakey_upcall(dm_table_entry_t *, struct buf *); +//int dm_target_flakey_upcall(dm_table_entry_t *, struct buf *); int dm_target_flakey_secsize(dm_table_entry_t *, unsigned int *); #endif Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.39 src/sys/dev/dm/dm_target.c:1.40 --- src/sys/dev/dm/dm_target.c:1.39 Sun Jan 5 08:08:26 2020 +++ src/sys/dev/dm/dm_target.c Tue Jan 21 16:27:53 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.39 2020/01/05 08:08:26 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.40 2020/01/21 16:27:53 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.39 2020/01/05 08:08:26 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.40 2020/01/2
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 15 15:32:05 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer2.c Log Message: fstyp: Remove redundant best_i check in HAMMER2 https://reviews.freebsd.org/D23159 taken-from: DragonFlyBSD originally from FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/hammer2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.3 src/usr.sbin/fstyp/hammer2.c:1.4 --- src/usr.sbin/fstyp/hammer2.c:1.3 Sat Jan 4 03:43:18 2020 +++ src/usr.sbin/fstyp/hammer2.c Wed Jan 15 15:32:05 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $"); #include #include @@ -225,10 +225,6 @@ read_label(FILE *fp, char *label, size_t best = broot; } } - if (best_i == -1) { - warnx("failed to find best zone"); - goto fail; - } bref = &vols[best_i]->voldata.sroot_blockset.blockref[0]; if (bref->type != HAMMER2_BREF_TYPE_INODE) {
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 15 15:30:46 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer.c Log Message: fstyp: Use strlcpy(3) for HAMMER1 https://reviews.freebsd.org/D23159 taken-from: DragonFlyBSD originally from FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/hammer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer.c diff -u src/usr.sbin/fstyp/hammer.c:1.2 src/usr.sbin/fstyp/hammer.c:1.3 --- src/usr.sbin/fstyp/hammer.c:1.2 Fri Jan 3 08:19:14 2020 +++ src/usr.sbin/fstyp/hammer.c Wed Jan 15 15:30:46 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $ */ +/*$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $ */ /*- * Copyright (c) 2016-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $"); #include #include @@ -72,7 +72,7 @@ test_ondisk(const hammer_volume_ondisk_t assert(count != 0); memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); - strncpy(label, ondisk->vol_label, sizeof(label)); + strlcpy(label, ondisk->vol_label, sizeof(label)); } else { if (ondisk->vol_count != count) return (5); @@ -80,7 +80,7 @@ test_ondisk(const hammer_volume_ondisk_t return (6); if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) return (7); - if (strncmp(ondisk->vol_label, label, sizeof(label))) + if (strcmp(ondisk->vol_label, label)) return (8); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Jan 5 08:11:10 UTC 2020 Modified Files: src/sys/dev/dm: dm_target_flakey.c Log Message: dm: Add "Copyright (c) 2015 The DragonFly Project." to dm-flakey which I missed in my initial dm-flakey commit. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/dm/dm_target_flakey.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_target_flakey.c diff -u src/sys/dev/dm/dm_target_flakey.c:1.1 src/sys/dev/dm/dm_target_flakey.c:1.2 --- src/sys/dev/dm/dm_target_flakey.c:1.1 Thu Jan 2 06:22:23 2020 +++ src/sys/dev/dm/dm_target_flakey.c Sun Jan 5 08:11:10 2020 @@ -1,7 +1,8 @@ -/*$NetBSD: dm_target_flakey.c,v 1.1 2020/01/02 06:22:23 tkusumi Exp $ */ +/*$NetBSD: dm_target_flakey.c,v 1.2 2020/01/05 08:11:10 tkusumi Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. + * Copyright (c) 2015 The DragonFly Project. All rights reserved. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -29,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_flakey.c,v 1.1 2020/01/02 06:22:23 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_flakey.c,v 1.2 2020/01/05 08:11:10 tkusumi Exp $"); #include #include
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Jan 5 08:08:26 UTC 2020 Modified Files: src/sys/dev/dm: dm.h dm_target.c Added Files: src/sys/dev/dm: dm_target_delay.c Log Message: dm: Add dm-delay target Ported from DragonFlyBSD, but this target had originally existed in Linux kernel. See below for details. https://www.kernel.org/doc/Documentation/device-mapper/delay.txt Due to "tick" in hz(9) not working (which results in dmdlthread spinning forever in _submit_queue() without dp extracted from delayed list and queued into submit list), this hasn't been hooked to dm.kmod yet. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/dev/dm/dm.h cvs rdiff -u -r1.38 -r1.39 src/sys/dev/dm/dm_target.c cvs rdiff -u -r0 -r1.1 src/sys/dev/dm/dm_target_delay.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.h diff -u src/sys/dev/dm/dm.h:1.53 src/sys/dev/dm/dm.h:1.54 --- src/sys/dev/dm/dm.h:1.53 Thu Jan 2 06:22:23 2020 +++ src/sys/dev/dm/dm.h Sun Jan 5 08:08:26 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.53 2020/01/02 06:22:23 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.54 2020/01/05 08:08:26 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -273,6 +273,18 @@ int dm_target_zero_destroy(dm_table_entr int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); #if 0 +/* dm_target_delay.c */ +void dm_target_delay_pool_create(void); +void dm_target_delay_pool_destroy(void); +int dm_target_delay_init(dm_table_entry_t *, int, char **); +char *dm_target_delay_info(void *); +char *dm_target_delay_table(void *); +int dm_target_delay_strategy(dm_table_entry_t *, struct buf *); +int dm_target_delay_sync(dm_table_entry_t *); +int dm_target_delay_destroy(dm_table_entry_t *); +int dm_target_delay_upcall(dm_table_entry_t *, struct buf *); +int dm_target_delay_secsize(dm_table_entry_t *, unsigned int *); + /* dm_target_flakey.c */ int dm_target_flakey_init(dm_table_entry_t *, int, char **); char *dm_target_flakey_table(void *); Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.38 src/sys/dev/dm/dm_target.c:1.39 --- src/sys/dev/dm/dm_target.c:1.38 Thu Jan 2 06:22:23 2020 +++ src/sys/dev/dm/dm_target.c Sun Jan 5 08:08:26 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.38 2020/01/02 06:22:23 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.39 2020/01/05 08:08:26 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.38 2020/01/02 06:22:23 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.39 2020/01/05 08:08:26 tkusumi Exp $"); #include #include @@ -238,7 +238,10 @@ dm_target_destroy(void) mutex_exit(&dm_target_mutex); mutex_destroy(&dm_target_mutex); - +#if 0 + /* Target specific module destroy routine. */ + dm_target_delay_pool_destroy(); +#endif return 0; } @@ -359,6 +362,22 @@ dm_target_init(void) if (dm_target_insert(dmt)) printf("Failed to insert zero\n"); #if 0 + dmt = dm_target_alloc("delay"); + dmt->version[0] = 1; + dmt->version[1] = 0; + dmt->version[2] = 0; + dmt->init = &dm_target_delay_init; + dmt->info = &dm_target_delay_info; + dmt->table = &dm_target_delay_table; + dmt->strategy = &dm_target_delay_strategy; + dmt->sync = &dm_target_delay_sync; + dmt->destroy = &dm_target_delay_destroy; + dmt->upcall = &dm_target_delay_upcall; + dmt->secsize = &dm_target_delay_secsize; + if (dm_target_insert(dmt)) + printf("Failed to insert delay\n"); + dm_target_delay_pool_create(); + dmt = dm_target_alloc("flakey"); dmt->version[0] = 1; dmt->version[1] = 0; Added files: Index: src/sys/dev/dm/dm_target_delay.c diff -u /dev/null src/sys/dev/dm/dm_target_delay.c:1.1 --- /dev/null Sun Jan 5 08:08:26 2020 +++ src/sys/dev/dm/dm_target_delay.c Sun Jan 5 08:08:26 2020 @@ -0,0 +1,513 @@ +/*$NetBSD: dm_target_delay.c,v 1.1 2020/01/05 08:08:26 tkusumi Exp $ */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * Copyright (c) 2015 The DragonFly Project. All rights reserved. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tomohiro Kusumi . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and t
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sat Jan 4 03:43:18 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer2.c Log Message: fstyp: Cleanup hammer2.c (sync with recent DragonFly commit) taken-from DragonFlyBSD 841ef9e93aea61adab688e9476604e7a03291ef0 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/hammer2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.2 src/usr.sbin/fstyp/hammer2.c:1.3 --- src/usr.sbin/fstyp/hammer2.c:1.2 Wed Jan 1 11:46:43 2020 +++ src/usr.sbin/fstyp/hammer2.c Sat Jan 4 03:43:18 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.2 2020/01/01 11:46:43 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.2 2020/01/01 11:46:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $"); #include #include @@ -74,7 +74,7 @@ read_media(FILE *fp, const hammer2_block *media_bytes = bytes; if (!bytes) { - warnx("Blockref has no data"); + warnx("blockref has no data"); return (NULL); } @@ -87,17 +87,17 @@ read_media(FILE *fp, const hammer2_block io_bytes <<= 1; if (io_bytes > sizeof(hammer2_media_data_t)) { - warnx("Invalid I/O bytes"); + warnx("invalid I/O bytes"); return (NULL); } if (fseek(fp, (long int)io_base, SEEK_SET) == -1) { - warnx("Failed to seek media"); + warnx("failed to seek media"); return (NULL); } media = read_buf(fp, (off_t)io_base, io_bytes); if (media == NULL) { - warnx("Failed to read media"); + warnx("failed to read media"); return (NULL); } if (boff) @@ -204,7 +204,7 @@ read_label(FILE *fp, char *label, size_t hammer2_media_data_t *vols[HAMMER2_NUM_VOLHDRS], *media; size_t bytes; bool res = false; - int i, best_i, error = 0; + int i, best_i, error = 1; const char *pfs; char *devname; @@ -226,22 +226,19 @@ read_label(FILE *fp, char *label, size_t } } if (best_i == -1) { - warnx("Failed to find best zone"); - error = 1; - goto done; + warnx("failed to find best zone"); + goto fail; } bref = &vols[best_i]->voldata.sroot_blockset.blockref[0]; if (bref->type != HAMMER2_BREF_TYPE_INODE) { - warnx("Blockref type is not inode"); - error = 1; - goto done; + warnx("blockref type is not inode"); + goto fail; } media = read_media(fp, bref, &bytes); if (media == NULL) { - error = 1; - goto done; + goto fail; } /* @@ -267,8 +264,7 @@ read_label(FILE *fp, char *label, size_t pfs++; if (strlen(pfs) > HAMMER2_INODE_MAXNAME) { - error = 1; - goto done; + goto fail; } devname = extract_device_name(devpath); #else @@ -295,7 +291,8 @@ read_label(FILE *fp, char *label, size_t if (devname) free(devname); free(media); -done: + error = 0; +fail: for (i = 0; i < HAMMER2_NUM_VOLHDRS; i++) free(vols[i]); @@ -310,10 +307,10 @@ fstyp_hammer2(FILE *fp, char *label, siz voldata = read_voldata(fp); if (test_voldata(voldata)) - goto done; + goto fail; error = read_label(fp, label, size); -done: +fail: free(voldata); return (error); }
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Fri Jan 3 08:19:14 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer.c Log Message: fstyp: Cleanup hammer.c (sync with recent DragonFly commit) taken-from DragonFlyBSD 8ca6d8ec5f97032765692d368db80159c97adea0 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/hammer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer.c diff -u src/usr.sbin/fstyp/hammer.c:1.1 src/usr.sbin/fstyp/hammer.c:1.2 --- src/usr.sbin/fstyp/hammer.c:1.1 Wed Jan 1 08:56:41 2020 +++ src/usr.sbin/fstyp/hammer.c Fri Jan 3 08:19:14 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $ */ +/*$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $ */ /*- * Copyright (c) 2016-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $"); #include #include @@ -97,11 +97,11 @@ fstyp_hammer(FILE *fp, char *label, size #endif ondisk = read_ondisk(fp); if (ondisk->vol_no != HAMMER_ROOT_VOLNO) - goto done; + goto fail; if (ondisk->vol_count != 1) - goto done; + goto fail; if (test_ondisk(ondisk)) - goto done; + goto fail; /* * fstyp_function in DragonFly takes an additional devpath argument @@ -122,7 +122,7 @@ fstyp_hammer(FILE *fp, char *label, size strlcpy(label, ondisk->vol_label, size); #endif error = 0; -done: +fail: free(ondisk); return (error); } @@ -140,10 +140,10 @@ test_volume(const char *volpath) ondisk = read_ondisk(fp); fclose(fp); if (test_ondisk(ondisk)) - goto done; + goto fail; volno = ondisk->vol_no; -done: +fail: free(ondisk); return (volno); } @@ -151,22 +151,28 @@ done: static int __fsvtyp_hammer(const char *blkdevs, char *label, size_t size, int partial) { - hammer_volume_ondisk_t ondisk; + hammer_volume_ondisk_t ondisk = NULL; FILE *fp; char *dup, *p, *volpath, x[HAMMER_MAX_VOLUMES]; int i, volno, error = 1; + if (!blkdevs) + goto fail; + memset(x, 0, sizeof(x)); dup = strdup(blkdevs); p = dup; volpath = NULL; + volno = -1; while (p) { volpath = p; if ((p = strchr(p, ':')) != NULL) *p++ = '\0'; if ((volno = test_volume(volpath)) == -1) break; + assert(volno >= 0); + assert(volno < HAMMER_MAX_VOLUMES); x[volno]++; } @@ -180,26 +186,26 @@ __fsvtyp_hammer(const char *blkdevs, cha free(dup); if (volno == -1) - goto done; + goto fail; if (partial) goto success; for (i = 0; i < HAMMER_MAX_VOLUMES; i++) if (x[i] > 1) - goto done; + goto fail; for (i = 0; i < HAMMER_MAX_VOLUMES; i++) if (x[i] == 0) break; if (ondisk->vol_count != i) - goto done; + goto fail; for (; i < HAMMER_MAX_VOLUMES; i++) if (x[i] != 0) - goto done; + goto fail; success: /* XXX autofs -media mount can't handle multiple mounts */ strlcpy(label, ondisk->vol_label, size); error = 0; -done: +fail: free(ondisk); return (error); }
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Thu Jan 2 08:52:42 UTC 2020 Modified Files: src/usr.sbin/fstyp: fstyp.c Log Message: fstyp: Fix "exfat: iconv_open UCS-2LE: Invalid argument" failure Fix below error for the time being. The removed code is only relevant to Capsicum. $ fstyp -l /dev/wd1 fstyp: exfat: iconv_open UCS-2LE: Invalid argument To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/fstyp/fstyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.11 src/usr.sbin/fstyp/fstyp.c:1.12 --- src/usr.sbin/fstyp/fstyp.c:1.11 Wed Jan 1 12:47:19 2020 +++ src/usr.sbin/fstyp/fstyp.c Thu Jan 2 08:52:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.11 2020/01/01 12:47:19 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.12 2020/01/02 08:52:42 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.11 2020/01/01 12:47:19 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.12 2020/01/02 08:52:42 tkusumi Exp $"); #include #include @@ -220,22 +220,6 @@ main(int argc, char **argv) if (setlocale(LC_CTYPE, "") == NULL) err(1, "setlocale"); - /* Cache iconv conversion data before entering capability mode. */ - if (show_label) { - for (i = 0; i < (int)__arraycount(fstypes); i++) { - iconv_t cd; - - if (fstypes[i].precache_encoding == NULL) -continue; - cd = iconv_open("", fstypes[i].precache_encoding); - if (cd == (iconv_t)-1) -err(1, "%s: iconv_open %s", fstypes[i].name, -fstypes[i].precache_encoding); - /* Iconv keeps a small cache of unused encodings. */ - iconv_close(cd); - } - } - /* * DragonFly: Filesystems may have syntax to decorate path. * Make a wild guess.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Jan 2 06:22:23 UTC 2020 Modified Files: src/sys/dev/dm: dm.h dm_target.c Added Files: src/sys/dev/dm: dm_target_flakey.c Log Message: dm: Add dm-flakey target Ported from DragonFlyBSD, but this target had originally existed in Linux kernel. See below for details. https://www.kernel.org/doc/Documentation/device-mapper/dm-flakey.txt Due to two technical issues, this hasn't been hooked to dm.kmod yet. 1) "tick" in hz(9) not working. 2) Unable to use ->b_private in nestiobuf callback when it's already used for mbp (see HAS_BUF_PRIV2). taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/dev/dm/dm.h cvs rdiff -u -r1.37 -r1.38 src/sys/dev/dm/dm_target.c cvs rdiff -u -r0 -r1.1 src/sys/dev/dm/dm_target_flakey.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.h diff -u src/sys/dev/dm/dm.h:1.52 src/sys/dev/dm/dm.h:1.53 --- src/sys/dev/dm/dm.h:1.52 Mon Dec 23 16:17:35 2019 +++ src/sys/dev/dm/dm.h Thu Jan 2 06:22:23 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.52 2019/12/23 16:17:35 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.53 2020/01/02 06:22:23 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -272,6 +272,17 @@ int dm_target_zero_strategy(dm_table_ent int dm_target_zero_destroy(dm_table_entry_t *); int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); +#if 0 +/* dm_target_flakey.c */ +int dm_target_flakey_init(dm_table_entry_t *, int, char **); +char *dm_target_flakey_table(void *); +int dm_target_flakey_strategy(dm_table_entry_t *, struct buf *); +int dm_target_flakey_sync(dm_table_entry_t *); +int dm_target_flakey_destroy(dm_table_entry_t *); +int dm_target_flakey_upcall(dm_table_entry_t *, struct buf *); +int dm_target_flakey_secsize(dm_table_entry_t *, unsigned int *); +#endif + /* dm_table.c */ #define DM_TABLE_ACTIVE 0 #define DM_TABLE_INACTIVE 1 Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.37 src/sys/dev/dm/dm_target.c:1.38 --- src/sys/dev/dm/dm_target.c:1.37 Mon Dec 23 16:17:35 2019 +++ src/sys/dev/dm/dm_target.c Thu Jan 2 06:22:23 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.38 2020/01/02 06:22:23 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.38 2020/01/02 06:22:23 tkusumi Exp $"); #include #include @@ -358,6 +358,20 @@ dm_target_init(void) dmt->upcall = &dm_target_zero_upcall; if (dm_target_insert(dmt)) printf("Failed to insert zero\n"); - +#if 0 + dmt = dm_target_alloc("flakey"); + dmt->version[0] = 1; + dmt->version[1] = 0; + dmt->version[2] = 0; + dmt->init = &dm_target_flakey_init; + dmt->table = &dm_target_flakey_table; + dmt->strategy = &dm_target_flakey_strategy; + dmt->sync = &dm_target_flakey_sync; + dmt->destroy = &dm_target_flakey_destroy; + dmt->upcall = &dm_target_flakey_upcall; + dmt->secsize = &dm_target_flakey_secsize; + if (dm_target_insert(dmt)) + printf("Failed to insert flakey\n"); +#endif return 0; } Added files: Index: src/sys/dev/dm/dm_target_flakey.c diff -u /dev/null src/sys/dev/dm/dm_target_flakey.c:1.1 --- /dev/null Thu Jan 2 06:22:23 2020 +++ src/sys/dev/dm/dm_target_flakey.c Thu Jan 2 06:22:23 2020 @@ -0,0 +1,518 @@ +/*$NetBSD: dm_target_flakey.c,v 1.1 2020/01/02 06:22:23 tkusumi Exp $ */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tomohiro Kusumi . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EX
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 1 12:47:19 UTC 2020 Modified Files: src/usr.sbin/fstyp: fstyp.c Log Message: fstyp: Consider '@' syntax in device file path for HAMMER2 though devpath is unsupported in NetBSD atm. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/fstyp/fstyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.10 src/usr.sbin/fstyp/fstyp.c:1.11 --- src/usr.sbin/fstyp/fstyp.c:1.10 Wed Jan 1 09:17:27 2020 +++ src/usr.sbin/fstyp/fstyp.c Wed Jan 1 12:47:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.11 2020/01/01 12:47:19 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,8 +35,9 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.11 2020/01/01 12:47:19 tkusumi Exp $"); +#include #include #include #include @@ -185,7 +186,9 @@ main(int argc, char **argv) int ch, error, i, nbytes; bool ignore_type = false, show_unmountable = false; char label[LABEL_LEN + 1], strvised[LABEL_LEN * 4 + 1]; - char *path; + char fdpath[MAXPATHLEN]; + char *p; + const char *path; const char *name = NULL; FILE *fp; fstyp_function fstyp_f; @@ -233,12 +236,28 @@ main(int argc, char **argv) } } - fp = fopen(path, "r"); - if (fp == NULL) - goto fsvtyp; /* DragonFly */ + /* + * DragonFly: Filesystems may have syntax to decorate path. + * Make a wild guess. + * XXX devpath is unsupported in NetBSD, but at least parse '@' for fp. + */ + strlcpy(fdpath, path, sizeof(fdpath)); + p = strchr(fdpath, '@'); + if (p) + *p = '\0'; + + fp = fopen(fdpath, "r"); + if (fp == NULL) { + if (strcmp(path, fdpath)) + fp = fopen(path, "r"); + if (fp == NULL) + goto fsvtyp; /* DragonFly */ + else + strlcpy(fdpath, path, sizeof(fdpath)); + } if (ignore_type == false) - type_check(path, fp); + type_check(fdpath, fp); memset(label, '\0', sizeof(label));
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 1 11:46:43 UTC 2020 Modified Files: src/usr.sbin/fstyp: hammer2.c Log Message: fstyp: Fix build failure on i386 http://releng.netbsd.org/b5reports/i386/commits-2020.01.html#2020.01.01.10.13.16 Explicitly cast to size_t. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/hammer2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.1 src/usr.sbin/fstyp/hammer2.c:1.2 --- src/usr.sbin/fstyp/hammer2.c:1.1 Wed Jan 1 08:56:41 2020 +++ src/usr.sbin/fstyp/hammer2.c Wed Jan 1 11:46:43 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.2 2020/01/01 11:46:43 tkusumi Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.2 2020/01/01 11:46:43 tkusumi Exp $"); #include #include @@ -80,7 +80,7 @@ read_media(FILE *fp, const hammer2_block io_off = bref->data_off & ~HAMMER2_OFF_MASK_RADIX; io_base = io_off & ~(hammer2_off_t)(HAMMER2_MINIOSIZE - 1); - boff = io_off - io_base; + boff = (size_t)(io_off - io_base); io_bytes = HAMMER2_MINIOSIZE; while (io_bytes + boff < bytes)
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 1 09:17:27 UTC 2020 Modified Files: src/usr.sbin/fstyp: fstyp.c Log Message: fstyp: Add HAMMER1 multi-volume support (missed in "fstyp: Add HAMMER1/2 support") taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/fstyp/fstyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.9 src/usr.sbin/fstyp/fstyp.c:1.10 --- src/usr.sbin/fstyp/fstyp.c:1.9 Wed Jan 1 09:08:52 2020 +++ src/usr.sbin/fstyp/fstyp.c Wed Jan 1 09:17:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $"); #include #include @@ -90,6 +90,8 @@ static struct { bool unmountable; const char *precache_encoding; } fsvtypes[] = { + { "hammer", &fsvtyp_hammer, false, NULL }, /* Must be before partial */ + { "hammer(partial)", &fsvtyp_hammer_partial, true, NULL }, { NULL, NULL, NULL, NULL } };
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Wed Jan 1 09:08:52 UTC 2020 Modified Files: src/usr.sbin/fstyp: fstyp.c fstyp.h Log Message: fstyp: Cleanup and minor sync up with FreeBSD/DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/fstyp/fstyp.c cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/fstyp/fstyp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.8 src/usr.sbin/fstyp/fstyp.c:1.9 --- src/usr.sbin/fstyp/fstyp.c:1.8 Wed Jan 1 08:56:41 2020 +++ src/usr.sbin/fstyp/fstyp.c Wed Jan 1 09:08:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.8 2020/01/01 08:56:41 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.8 2020/01/01 08:56:41 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $"); #include #include @@ -88,8 +88,9 @@ static struct { const char *name; fsvtyp_function function; bool unmountable; + const char *precache_encoding; } fsvtypes[] = { - { NULL, NULL, NULL } + { NULL, NULL, NULL, NULL } }; void * Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.7 src/usr.sbin/fstyp/fstyp.h:1.8 --- src/usr.sbin/fstyp/fstyp.h:1.7 Wed Jan 1 08:56:41 2020 +++ src/usr.sbin/fstyp/fstyp.h Wed Jan 1 09:08:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.7 2020/01/01 08:56:41 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.8 2020/01/01 09:08:52 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -58,11 +58,11 @@ void *read_buf(FILE *, off_t, size_t); char *checked_strdup(const char *); void rtrim(char *, size_t); -int fstyp_apfs(FILE *fp, char *label, size_t size); +int fstyp_apfs(FILE *, char *, size_t); int fstyp_cd9660(FILE *, char *, size_t); -int fstyp_exfat(FILE *fp, char *label, size_t size); +int fstyp_exfat(FILE *, char *, size_t); int fstyp_ext2fs(FILE *, char *, size_t); -int fstyp_hfsp(FILE *fp, char *label, size_t size); +int fstyp_hfsp(FILE *, char *, size_t); int fstyp_msdosfs(FILE *, char *, size_t); int fstyp_ntfs(FILE *, char *, size_t); int fstyp_ufs(FILE *, char *, size_t); @@ -72,7 +72,7 @@ int fstyp_hammer2(FILE *, char *, size_t int fstyp_zfs(FILE *, char *, size_t); #endif -int fsvtyp_hammer(const char *blkdevs, char *label, size_t size); -int fsvtyp_hammer_partial(const char *blkdevs, char *label, size_t size); +int fsvtyp_hammer(const char *, char *, size_t); +int fsvtyp_hammer_partial(const char *, char *, size_t); #endif /* !FSTYP_H */
CVS commit: src/usr.sbin/fstyp
t char *blkdevs, char *label, size_t size); +int fsvtyp_hammer_partial(const char *blkdevs, char *label, size_t size); + #endif /* !FSTYP_H */ Added files: Index: src/usr.sbin/fstyp/hammer.c diff -u /dev/null src/usr.sbin/fstyp/hammer.c:1.1 --- /dev/null Wed Jan 1 08:56:42 2020 +++ src/usr.sbin/fstyp/hammer.c Wed Jan 1 08:56:41 2020 @@ -0,0 +1,217 @@ +/*$NetBSD: hammer.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $ */ + +/*- + * Copyright (c) 2016-2019 The DragonFly Project + * Copyright (c) 2016-2019 Tomohiro Kusumi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.1 2020/01/01 08:56:41 tkusumi Exp $"); + +#include +#include +#include +#include +#include + +#include "fstyp.h" +#include "hammer_disk.h" + +static hammer_volume_ondisk_t +read_ondisk(FILE *fp) +{ + hammer_volume_ondisk_t ondisk; + + ondisk = read_buf(fp, 0, sizeof(*ondisk)); + if (ondisk == NULL) + err(1, "failed to read ondisk"); + + return (ondisk); +} + +static int +test_ondisk(const hammer_volume_ondisk_t ondisk) +{ + static int count = 0; + static hammer_uuid_t fsid, fstype; + static char label[64]; + + if (ondisk->vol_signature != HAMMER_FSBUF_VOLUME && + ondisk->vol_signature != HAMMER_FSBUF_VOLUME_REV) + return (1); + if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) + return (2); + if (ondisk->vol_no < 0 || ondisk->vol_no > HAMMER_MAX_VOLUMES - 1) + return (3); + if (ondisk->vol_count < 1 || ondisk->vol_count > HAMMER_MAX_VOLUMES) + return (4); + + if (count == 0) { + count = ondisk->vol_count; + assert(count != 0); + memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); + memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); + strncpy(label, ondisk->vol_label, sizeof(label)); + } else { + if (ondisk->vol_count != count) + return (5); + if (memcmp(&ondisk->vol_fsid, &fsid, sizeof(fsid))) + return (6); + if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) + return (7); + if (strncmp(ondisk->vol_label, label, sizeof(label))) + return (8); + } + + return (0); +} + +int +fstyp_hammer(FILE *fp, char *label, size_t size) +{ + hammer_volume_ondisk_t ondisk; + int error = 1; +#ifdef HAS_DEVPATH + const char *p; +#endif + ondisk = read_ondisk(fp); + if (ondisk->vol_no != HAMMER_ROOT_VOLNO) + goto done; + if (ondisk->vol_count != 1) + goto done; + if (test_ondisk(ondisk)) + goto done; + + /* + * fstyp_function in DragonFly takes an additional devpath argument + * which doesn't exist in FreeBSD and NetBSD. + */ +#ifdef HAS_DEVPATH + /* Add device name to help support multiple autofs -media mounts. */ + p = strrchr(devpath, '/'); + if (p) { + p++; + if (*p == 0) + strlcpy(label, ondisk->vol_label, size); + else + snprintf(label, size, "%s_%s", ondisk->vol_label, p); + } else + snprintf(label, size, "%s_%s", ondisk->vol_label, devpath); +#else + strlcpy(label, ondisk->vol_label, size); +#endif + error = 0; +done: + free(ondisk); + return (error); +} + +static int +test_volume(const char *volpath) +{ + hammer_volume_ondisk_t ondisk; + FILE *fp; + int volno = -1; + + if ((fp = fopen(volpath, "r")) == NULL) + err(1, "failed to open %s", volpath); + + ondisk = read_ondisk(fp); + fclose(fp); + if (test_ondisk(ondisk)) + goto done; + + volno = ondisk->vol_no; +done: + free(ondisk); + return (volno); +} + +static int +__fsvtyp_hammer(const char *blkdevs, char *label, size_t size, int partial) +{ + hammer_volume_ondisk_t ondisk; + FILE *fp; + char *dup, *p, *volpath, x[H
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 31 10:30:30 UTC 2019 Modified Files: src/sys/dev/dm: dm_dev.c dm_table.c Log Message: dm: Remove unnecessary inlining These two don't really need to be inlined. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.18 -r1.19 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. Modified files: Index: src/sys/dev/dm/dm_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.16 src/sys/dev/dm/dm_dev.c:1.17 --- src/sys/dev/dm/dm_dev.c:1.16 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_dev.c Tue Dec 31 10:30:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.16 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: dm_dev.c,v 1.17 2019/12/31 10:30:30 tkusumi 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.16 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.17 2019/12/31 10:30:30 tkusumi Exp $"); #include #include @@ -51,7 +51,7 @@ static struct dm_dev_head dm_dev_list = static kmutex_t dm_dev_mutex; /* dm_dev_mutex must be holdby caller before using disable_dev. */ -__inline static void +static void disable_dev(dm_dev_t *dmv) { Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.18 src/sys/dev/dm/dm_table.c:1.19 --- src/sys/dev/dm/dm_table.c:1.18 Sun Dec 22 13:16:09 2019 +++ src/sys/dev/dm/dm_table.c Tue Dec 31 10:30:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.19 2019/12/31 10:30:30 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.19 2019/12/31 10:30:30 tkusumi Exp $"); #include #include @@ -181,7 +181,7 @@ dm_table_destroy(dm_table_head_t *head, /* * Return length of active table in device. */ -static inline uint64_t +static uint64_t dm_table_size_impl(dm_table_head_t *head, int table) { dm_table_t *tbl;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 28 15:38:16 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_linear.c Log Message: dm: Fix typo in comment dklinear -> linear To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm_target_linear.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_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.35 src/sys/dev/dm/dm_target_linear.c:1.36 --- src/sys/dev/dm/dm_target_linear.c:1.35 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm_target_linear.c Sat Dec 28 15:38:16 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.36 2019/12/28 15:38:16 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,10 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.36 2019/12/28 15:38:16 tkusumi Exp $"); /* - * This file implements initial version of device-mapper dklinear target. + * This file implements initial version of device-mapper linear target. */ #include
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sat Dec 28 08:22:30 UTC 2019 Modified Files: src/usr.sbin/fstyp: fstyp.c fstyp.h ntfs.c Log Message: fstyp: Use iconv(3) to convert NTFS vol labels correctly taken-from: FreeBSD (freebsd/freebsd@23a4b310ffa90719eb9d11506bde1befab3c695f) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/fstyp/fstyp.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/fstyp/fstyp.h cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/ntfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.6 src/usr.sbin/fstyp/fstyp.c:1.7 --- src/usr.sbin/fstyp/fstyp.c:1.6 Sat Dec 28 08:00:08 2019 +++ src/usr.sbin/fstyp/fstyp.c Sat Dec 28 08:22:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.6 2019/12/28 08:00:08 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.7 2019/12/28 08:22:30 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.6 2019/12/28 08:00:08 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.7 2019/12/28 08:22:30 tkusumi Exp $"); #include #include @@ -74,7 +74,7 @@ static struct { { "ext2fs", &fstyp_ext2fs, false, NULL }, { "hfs+", &fstyp_hfsp, false, NULL }, { "msdosfs", &fstyp_msdosfs, false, NULL }, - { "ntfs", &fstyp_ntfs, false, NULL }, + { "ntfs", &fstyp_ntfs, false, NTFS_ENC }, { "ufs", &fstyp_ufs, false, NULL }, #ifdef HAVE_ZFS { "zfs", &fstyp_zfs, true, NULL }, Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.5 src/usr.sbin/fstyp/fstyp.h:1.6 --- src/usr.sbin/fstyp/fstyp.h:1.5 Sat Dec 28 08:00:08 2019 +++ src/usr.sbin/fstyp/fstyp.h Sat Dec 28 08:22:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.5 2019/12/28 08:00:08 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.6 2019/12/28 08:22:30 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -43,6 +43,11 @@ /* The spec doesn't seem to permit UTF-16 surrogates; definitely LE. */ #define EXFAT_ENC "UCS-2LE" +/* + * NTFS itself is agnostic to encoding; it just stores 255 u16 wchars. In + * practice, UTF-16 seems expected for NTFS. (Maybe also for exFAT.) + */ +#define NTFS_ENC "UTF-16LE" extern bool show_label; /* -l flag */ Index: src/usr.sbin/fstyp/ntfs.c diff -u src/usr.sbin/fstyp/ntfs.c:1.1 src/usr.sbin/fstyp/ntfs.c:1.2 --- src/usr.sbin/fstyp/ntfs.c:1.1 Tue Jan 9 03:31:15 2018 +++ src/usr.sbin/fstyp/ntfs.c Sat Dec 28 08:22:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs.c,v 1.1 2018/01/09 03:31:15 christos Exp $ */ +/* $NetBSD: ntfs.c,v 1.2 2019/12/28 08:22:30 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,8 +35,10 @@ * SUCH DAMAGE. */ #include -__RCSID("$NetBSD: ntfs.c,v 1.1 2018/01/09 03:31:15 christos Exp $"); +__RCSID("$NetBSD: ntfs.c,v 1.2 2019/12/28 08:22:30 tkusumi Exp $"); +#include +#include #include #include #include @@ -98,6 +100,38 @@ struct ntfs_bootfile { uint32_t bf_volsn; } __packed; +static void +convert_label(const void *label /* LE */, size_t labellen, char *label_out, +size_t label_sz) +{ + char *label_out_orig; + iconv_t cd; + size_t rc; + + /* dstname="" means convert to the current locale. */ + cd = iconv_open("", NTFS_ENC); + if (cd == (iconv_t)-1) { + warn("ntfs: Could not open iconv"); + return; + } + + label_out_orig = label_out; + + rc = iconv(cd, __UNCONST(&label), &labellen, &label_out, + &label_sz); + if (rc == (size_t)-1) { + warn("ntfs: iconv()"); + *label_out_orig = '\0'; + } else { + /* NUL-terminate result (iconv advances label_out). */ + if (label_sz == 0) + label_out--; + *label_out = '\0'; + } + + iconv_close(cd); +} + int fstyp_ntfs(FILE *fp, char *label, size_t size) { @@ -107,21 +141,22 @@ fstyp_ntfs(FILE *fp, char *label, size_t off_t voloff; char *filerecp, *ap; int8_t mftrecsz; - char vnchar; - size_t recsize, j; + size_t recsize; filerecp = NULL; bf = read_buf(fp, 0, 512); if (bf == NULL || strncmp((char*)bf->bf_sysid, "NTFS", 8) != 0) goto fail; + if (!show_label) + goto ok; mftrecsz = bf->bf_mftrecsz; recsize = mftrecsz > 0 ? (size_t)(mftrecsz * bf->bf_bps * bf->bf_spc) : (size_t)(1 << -mftrecsz); - voloff = (off_t)(bf->bf_mftcn * bf->bf_spc * bf->bf_bps + - recsize * NTFS_VOLUMEINO); + voloff = (off_t)((off_t)bf->bf_mftcn * bf->bf_spc * bf->bf_bps + + (off_t)recsize * NTFS_VOLUMEINO); filerecp = read_buf(fp, voloff, recsize); if (filerecp == NULL) @@ -134,29 +169,15 @@ fstyp_ntfs(FILE *fp, char *label, size_t for (ap = filerecp + fr->fr_attroff; atr = (struct ntfs_attr *)ap, (int)atr->a_type != -1; ap += atr->reclen) { - if (atr->a_type == NTFS_A_VOLUMENAME) { - if(atr->a_datalen >= size *2){ -goto fail; - } - /* - * UNICODE to ASCII. - * Should we need to use iconv(9)? - */ - for (j = 0; j < atr
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sat Dec 28 08:00:08 UTC 2019 Modified Files: src/usr.sbin/fstyp: exfat.c fstyp.c fstyp.h Log Message: fstyp: Show exFAT volume labels with -l flag taken-from: FreeBSD (freebsd/freebsd@73773fcda9f69ce7ee0c73292f273bab940223bf) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/exfat.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/fstyp/fstyp.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/fstyp/fstyp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/exfat.c diff -u src/usr.sbin/fstyp/exfat.c:1.1 src/usr.sbin/fstyp/exfat.c:1.2 --- src/usr.sbin/fstyp/exfat.c:1.1 Mon Nov 18 14:53:34 2019 +++ src/usr.sbin/fstyp/exfat.c Sat Dec 28 08:00:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: exfat.c,v 1.1 2019/11/18 14:53:34 tkusumi Exp $ */ +/* $NetBSD: exfat.c,v 1.2 2019/12/28 08:00:08 tkusumi Exp $ */ /* * Copyright (c) 2017 Conrad Meyer @@ -26,8 +26,16 @@ * SUCH DAMAGE. */ #include -__RCSID("$NetBSD: exfat.c,v 1.1 2019/11/18 14:53:34 tkusumi Exp $"); +__RCSID("$NetBSD: exfat.c,v 1.2 2019/12/28 08:00:08 tkusumi Exp $"); +#include +#include + +#include +#include +#include +#include +#include #include #include #include @@ -35,6 +43,10 @@ __RCSID("$NetBSD: exfat.c,v 1.1 2019/11/ #include "fstyp.h" +/* + * https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification + */ + struct exfat_vbr { char ev_jmp[3]; char ev_fsname[8]; @@ -56,19 +68,301 @@ struct exfat_vbr { uint8_t ev_percent_used; } __packed; +struct exfat_dirent { + uint8_t xde_type; +#define XDE_TYPE_INUSE_MASK 0x80 /* 1=in use */ +#define XDE_TYPE_INUSE_SHIFT 7 +#define XDE_TYPE_CATEGORY_MASK 0x40 /* 0=primary */ +#define XDE_TYPE_CATEGORY_SHIFT 6 +#define XDE_TYPE_IMPORTNC_MASK 0x20 /* 0=critical */ +#define XDE_TYPE_IMPORTNC_SHIFT 5 +#define XDE_TYPE_CODE_MASK 0x1f +/* InUse=0, ..., TypeCode=0: EOD. */ +#define XDE_TYPE_EOD 0x00 +#define XDE_TYPE_ALLOC_BITMAP (XDE_TYPE_INUSE_MASK | 0x01) +#define XDE_TYPE_UPCASE_TABLE (XDE_TYPE_INUSE_MASK | 0x02) +#define XDE_TYPE_VOL_LABEL (XDE_TYPE_INUSE_MASK | 0x03) +#define XDE_TYPE_FILE (XDE_TYPE_INUSE_MASK | 0x05) +#define XDE_TYPE_VOL_GUID (XDE_TYPE_INUSE_MASK | XDE_TYPE_IMPORTNC_MASK) +#define XDE_TYPE_STREAM_EXT (XDE_TYPE_INUSE_MASK | XDE_TYPE_CATEGORY_MASK) +#define XDE_TYPE_FILE_NAME (XDE_TYPE_INUSE_MASK | XDE_TYPE_CATEGORY_MASK | 0x01) +#define XDE_TYPE_VENDOR (XDE_TYPE_INUSE_MASK | XDE_TYPE_CATEGORY_MASK | XDE_TYPE_IMPORTNC_MASK) +#define XDE_TYPE_VENDOR_ALLOC (XDE_TYPE_INUSE_MASK | XDE_TYPE_CATEGORY_MASK | XDE_TYPE_IMPORTNC_MASK | 0x01) + union { + uint8_t xde_generic_[19]; + struct exde_primary { + /* + * Count of "secondary" dirents following this one. + * + * A single logical entity may be composed of a + * sequence of several dirents, starting with a primary + * one; the rest are secondary dirents. + */ + uint8_t xde_secondary_count_; + uint16_t xde_set_chksum_; + uint16_t xde_prim_flags_; + uint8_t xde_prim_generic_[14]; + } __packed xde_primary_; + struct exde_secondary { + uint8_t xde_sec_flags_; + uint8_t xde_sec_generic_[18]; + } __packed xde_secondary_; + } u; + uint32_t xde_first_cluster; + uint64_t xde_data_len; +} __packed; +#define xde_generic u.xde_generic_ +#define xde_secondary_count u.xde_primary_.xde_secondary_count +#define xde_set_chksum u.xde_primary_.xde_set_chksum_ +#define xde_prim_flags u.xde_primary_.xde_prim_flags_ +#define xde_sec_flags u.xde_secondary_.xde_sec_flags_ +_Static_assert(sizeof(struct exfat_dirent) == 32, "spec"); + +struct exfat_de_label { + uint8_t xdel_type; /* XDE_TYPE_VOL_LABEL */ + uint8_t xdel_char_cnt; /* Length of UCS-2 label */ + uint16_t xdel_vol_lbl[11]; + uint8_t xdel_reserved[8]; +} __packed; +_Static_assert(sizeof(struct exfat_de_label) == 32, "spec"); + +#define MAIN_BOOT_REGION_SECT 0 +#define BACKUP_BOOT_REGION_SECT 12 + +#define SUBREGION_CHKSUM_SECT 11 + +#define FIRST_CLUSTER 2 +#define BAD_BLOCK_SENTINEL 0xfff7u +#define END_CLUSTER_SENTINEL 0xu + +static inline void * +read_sectn(FILE *fp, off_t sect, unsigned count, unsigned bytespersec) +{ + return (read_buf(fp, sect * bytespersec, bytespersec * count)); +} + +static inline void * +read_sect(FILE *fp, off_t sect, unsigned bytespersec) +{ + return (read_sectn(fp, sect, 1, bytespersec)); +} + +/* + * Compute the byte-by-byte multi-sector checksum of the given boot region + * (MAIN or BACKUP), for a given bytespersec (typically 512 or 4096). + * + * Endian-safe; result is host endian. + */ +static int +exfat_compute_boot_chksum(FILE *fp, unsigned region, unsigned bytespersec, +uint32_t *result) +{ + unsigned char *sector; + unsigned n, sect; + uint32_t checksum; + + checksum = 0; + for (sect = 0; sect < 11; sect++) { + sector = read_sect(fp, region + sect, bytespersec); + if (sector == NULL)
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Fri Dec 27 11:15:06 UTC 2019 Modified Files: src/usr.sbin/fstyp: Makefile fstyp.c fstyp.h Added Files: src/usr.sbin/fstyp: apfs.c Log Message: fstyp: Add APFS support taken-from: FreeBSD (freebsd/freebsd@171bb54729d6d6554eb09c9a3507b184795f33e3) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/fstyp/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/fstyp/apfs.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/fstyp/fstyp.c cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/fstyp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/Makefile diff -u src/usr.sbin/fstyp/Makefile:1.7 src/usr.sbin/fstyp/Makefile:1.8 --- src/usr.sbin/fstyp/Makefile:1.7 Fri Dec 27 11:06:23 2019 +++ src/usr.sbin/fstyp/Makefile Fri Dec 27 11:15:06 2019 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.7 2019/12/27 11:06:23 tkusumi Exp $ +# $NetBSD: Makefile,v 1.8 2019/12/27 11:15:06 tkusumi Exp $ .include PROG= fstyp -SRCS= cd9660.c exfat.c ext2fs.c fstyp.c hfsplus.c msdosfs.c ntfs.c ufs.c +SRCS= apfs.c cd9660.c exfat.c ext2fs.c fstyp.c hfsplus.c msdosfs.c ntfs.c ufs.c .if (${MKZFS} != "no") SRCS+= zfs.c Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.4 src/usr.sbin/fstyp/fstyp.c:1.5 --- src/usr.sbin/fstyp/fstyp.c:1.4 Fri Dec 27 11:06:23 2019 +++ src/usr.sbin/fstyp/fstyp.c Fri Dec 27 11:15:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.4 2019/12/27 11:06:23 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.5 2019/12/27 11:15:06 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.4 2019/12/27 11:06:23 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.5 2019/12/27 11:15:06 tkusumi Exp $"); #include #include @@ -63,6 +63,7 @@ static struct { fstyp_function function; bool unmountable; } fstypes[] = { + { "apfs", &fstyp_apfs, true }, { "cd9660", &fstyp_cd9660, false }, { "exfat", &fstyp_exfat, false }, { "ext2fs", &fstyp_ext2fs, false }, Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.3 src/usr.sbin/fstyp/fstyp.h:1.4 --- src/usr.sbin/fstyp/fstyp.h:1.3 Fri Dec 27 11:06:23 2019 +++ src/usr.sbin/fstyp/fstyp.h Fri Dec 27 11:15:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.3 2019/12/27 11:06:23 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.4 2019/12/27 11:15:06 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -43,6 +43,7 @@ void *read_buf(FILE *, off_t, size_t); char *checked_strdup(const char *); void rtrim(char *, size_t); +int fstyp_apfs(FILE *fp, char *label, size_t size); int fstyp_cd9660(FILE *, char *, size_t); int fstyp_exfat(FILE *fp, char *label, size_t size); int fstyp_ext2fs(FILE *, char *, size_t); Added files: Index: src/usr.sbin/fstyp/apfs.c diff -u /dev/null src/usr.sbin/fstyp/apfs.c:1.1 --- /dev/null Fri Dec 27 11:15:06 2019 +++ src/usr.sbin/fstyp/apfs.c Fri Dec 27 11:15:06 2019 @@ -0,0 +1,107 @@ +/* $NetBSD: apfs.c,v 1.1 2019/12/27 11:15:06 tkusumi Exp $ */ +/* + * Copyright (c) 2019 Conrad Meyer . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +__RCSID("$NetBSD: apfs.c,v 1.1 2019/12/27 11:15:06 tkusumi Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fstyp.h" + +/* + * This really detects the container format, which might be best supported by + * geom_part or a special GEOM class. + * + * https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf + */ + +#define NX_CKSUM_SZ 8 + +typedef uint64_t nx_o
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Fri Dec 27 11:06:23 UTC 2019 Modified Files: src/usr.sbin/fstyp: Makefile fstyp.c fstyp.h Added Files: src/usr.sbin/fstyp: hfsplus.c Log Message: fstyp: Add HFS+ support taken-from: FreeBSD (freebsd/freebsd@b4d7ad9f787e74e712423def67de8bd76f71943a) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/fstyp/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/fstyp.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/fstyp.h cvs rdiff -u -r0 -r1.1 src/usr.sbin/fstyp/hfsplus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/Makefile diff -u src/usr.sbin/fstyp/Makefile:1.6 src/usr.sbin/fstyp/Makefile:1.7 --- src/usr.sbin/fstyp/Makefile:1.6 Mon Nov 18 14:53:34 2019 +++ src/usr.sbin/fstyp/Makefile Fri Dec 27 11:06:23 2019 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.6 2019/11/18 14:53:34 tkusumi Exp $ +# $NetBSD: Makefile,v 1.7 2019/12/27 11:06:23 tkusumi Exp $ .include PROG= fstyp -SRCS= cd9660.c exfat.c ext2fs.c fstyp.c msdosfs.c ntfs.c ufs.c +SRCS= cd9660.c exfat.c ext2fs.c fstyp.c hfsplus.c msdosfs.c ntfs.c ufs.c .if (${MKZFS} != "no") SRCS+= zfs.c Index: src/usr.sbin/fstyp/fstyp.c diff -u src/usr.sbin/fstyp/fstyp.c:1.3 src/usr.sbin/fstyp/fstyp.c:1.4 --- src/usr.sbin/fstyp/fstyp.c:1.3 Mon Nov 18 14:53:34 2019 +++ src/usr.sbin/fstyp/fstyp.c Fri Dec 27 11:06:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.c,v 1.3 2019/11/18 14:53:34 tkusumi Exp $ */ +/* $NetBSD: fstyp.c,v 1.4 2019/12/27 11:06:23 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * */ #include -__RCSID("$NetBSD: fstyp.c,v 1.3 2019/11/18 14:53:34 tkusumi Exp $"); +__RCSID("$NetBSD: fstyp.c,v 1.4 2019/12/27 11:06:23 tkusumi Exp $"); #include #include @@ -66,6 +66,7 @@ static struct { { "cd9660", &fstyp_cd9660, false }, { "exfat", &fstyp_exfat, false }, { "ext2fs", &fstyp_ext2fs, false }, + { "hfs+", &fstyp_hfsp, false }, { "msdosfs", &fstyp_msdosfs, false }, { "ntfs", &fstyp_ntfs, false }, { "ufs", &fstyp_ufs, false }, Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.2 src/usr.sbin/fstyp/fstyp.h:1.3 --- src/usr.sbin/fstyp/fstyp.h:1.2 Mon Nov 18 14:53:34 2019 +++ src/usr.sbin/fstyp/fstyp.h Fri Dec 27 11:06:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.2 2019/11/18 14:53:34 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.3 2019/12/27 11:06:23 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -46,6 +46,7 @@ void rtrim(char *, size_t); int fstyp_cd9660(FILE *, char *, size_t); int fstyp_exfat(FILE *fp, char *label, size_t size); int fstyp_ext2fs(FILE *, char *, size_t); +int fstyp_hfsp(FILE *fp, char *label, size_t size); int fstyp_msdosfs(FILE *, char *, size_t); int fstyp_ntfs(FILE *, char *, size_t); int fstyp_ufs(FILE *, char *, size_t); Added files: Index: src/usr.sbin/fstyp/hfsplus.c diff -u /dev/null src/usr.sbin/fstyp/hfsplus.c:1.1 --- /dev/null Fri Dec 27 11:06:23 2019 +++ src/usr.sbin/fstyp/hfsplus.c Fri Dec 27 11:06:23 2019 @@ -0,0 +1,125 @@ +/* $NetBSD: hfsplus.c,v 1.1 2019/12/27 11:06:23 tkusumi Exp $ */ +/* + * Copyright (c) 2019 Conrad Meyer . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +__RCSID("$NetBSD: hfsplus.c,v 1.1 2019/12/27 11:06:23 tkusumi Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fstyp.h" + +/* + * https://developer.apple.com/library/archive/technotes/tn/tn1150.html + */ + +#define VOL_HDR_OFF 1024 + +typedef uint32_t hfsp_cat_nodeid; + +typedef struct hfsp_e
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 23 16:17:36 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_target.c dm_target_error.c dm_target_zero.c Log Message: dm: Make target's ->table() optional Since ->info() (counter part of ->table() in the original dm design in Linux kernel in .status where both INFO and TABLE are optional) is an optional handler, make ->table() optional as well. Some targets don't have anything to do in ->table() just as in ->info(). taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/dm/dm.h cvs rdiff -u -r1.48 -r1.49 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.51 src/sys/dev/dm/dm.h:1.52 --- src/sys/dev/dm/dm.h:1.51 Sat Dec 21 16:00:29 2019 +++ src/sys/dev/dm/dm.h Mon Dec 23 16:17:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.52 2019/12/23 16:17:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -181,19 +181,19 @@ typedef struct dm_target { /* Destroy target_config area */ int (*destroy)(dm_table_entry_t *); - /* - * Info/table routine are called to get params string, which is target - * specific. When dm_table_status_ioctl is called with flag - * DM_STATUS_TABLE_FLAG I have to sent params string back. - */ - char *(*table)(void *); int (*strategy)(dm_table_entry_t *, struct buf *); int (*upcall)(dm_table_entry_t *, struct buf *); /* * Optional routines. */ + /* + * Info/table routine are called to get params string, which is target + * specific. When dm_table_status_ioctl is called with flag + * DM_STATUS_TABLE_FLAG I have to sent params string back. + */ char *(*info)(void *); + char *(*table)(void *); int (*sync)(dm_table_entry_t *); int (*secsize)(dm_table_entry_t *, unsigned int *); @@ -262,14 +262,12 @@ int dm_target_stripe_secsize(dm_table_en /* dm_target_error.c */ int dm_target_error_init(dm_table_entry_t*, int, char **); -char *dm_target_error_table(void *); int dm_target_error_strategy(dm_table_entry_t *, struct buf *); int dm_target_error_destroy(dm_table_entry_t *); int dm_target_error_upcall(dm_table_entry_t *, struct buf *); /* dm_target_zero.c */ int dm_target_zero_init(dm_table_entry_t *, int, char **); -char *dm_target_zero_table(void *); int dm_target_zero_strategy(dm_table_entry_t *, struct buf *); int dm_target_zero_destroy(dm_table_entry_t *); int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.48 src/sys/dev/dm/dm_ioctl.c:1.49 --- src/sys/dev/dm/dm_ioctl.c:1.48 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm_ioctl.c Mon Dec 23 16:17:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 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.48 2019/12/21 11:59:03 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -936,6 +936,7 @@ dm_table_status_ioctl(prop_dictionary_t SLIST_FOREACH(table_en, tbl, next) { char *params; + int is_table; target_dict = prop_dictionary_create(); aprint_debug("%016" PRIu64 ", length %016" PRIu64 @@ -960,10 +961,11 @@ dm_table_status_ioctl(prop_dictionary_t */ prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, ""); - if (flags & DM_STATUS_TABLE_FLAG) + is_table = (flags & DM_STATUS_TABLE_FLAG) ? 1 : 0; + if (is_table && table_en->target->table) params = table_en->target->table( table_en->target_config); - else if (table_en->target->info) + else if (!is_table && table_en->target->info) params = table_en->target->info( table_en->target_config); else Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.36 src/sys/dev/dm/dm_target.c:1.37 --- src/sys/dev/dm/dm_target.c:1.36 Sat Dec 21 16:00:29 2019 +++ src/sys/dev/dm/dm_target.c Mon Dec 23 16:17:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 22 13:16:10 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_table.c Log Message: dm: Make numsec/secsize arguments in dm_table_disksize() optional To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.17 -r1.18 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. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.58 src/sys/dev/dm/device-mapper.c:1.59 --- src/sys/dev/dm/device-mapper.c:1.58 Sun Dec 22 12:28:54 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 22 13:16:09 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.58 2019/12/22 12:28:54 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.59 2019/12/22 13:16:09 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -431,7 +431,6 @@ disk_ioctl_switch(dev_t dev, unsigned lo case DIOCGWEDGEINFO: { struct dkwedge_info *dkw = (void *) data; - unsigned int secsize; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; @@ -443,7 +442,7 @@ disk_ioctl_switch(dev_t dev, unsigned lo strlcpy(dkw->dkw_parent, dmv->name, 16); dkw->dkw_offset = 0; - dm_table_disksize(&dmv->table_head, &dkw->dkw_size, &secsize); + dm_table_disksize(&dmv->table_head, &dkw->dkw_size, NULL); strcpy(dkw->dkw_ptype, DKW_PTYPE_FFS); dm_dev_unbusy(dmv); @@ -494,7 +493,6 @@ disk_ioctl_switch(dev_t dev, unsigned lo } case DIOCGSECTORSIZE: { - uint64_t numsec; unsigned int secsize, *valp = data; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) @@ -502,7 +500,7 @@ disk_ioctl_switch(dev_t dev, unsigned lo aprint_debug("DIOCGSECTORSIZE ioctl called\n"); - dm_table_disksize(&dmv->table_head, &numsec, &secsize); + dm_table_disksize(&dmv->table_head, NULL, &secsize); *valp = secsize; dm_dev_unbusy(dmv); @@ -512,14 +510,13 @@ disk_ioctl_switch(dev_t dev, unsigned lo { off_t *valp = data; uint64_t numsec; - unsigned int secsize; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; aprint_debug("DIOCGMEDIASIZE ioctl called\n"); - dm_table_disksize(&dmv->table_head, &numsec, &secsize); + dm_table_disksize(&dmv->table_head, &numsec, NULL); *valp = numsec; dm_dev_unbusy(dmv); Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.17 src/sys/dev/dm/dm_table.c:1.18 --- src/sys/dev/dm/dm_table.c:1.17 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm_table.c Sun Dec 22 13:16:09 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.17 2019/12/21 11:59:03 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.17 2019/12/21 11:59:03 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 tkusumi Exp $"); #include #include @@ -262,8 +262,11 @@ dm_table_disksize(dm_table_head_t *head, if (secsize < tsecsize) secsize = tsecsize; } - *numsecp = secsize > 0 ? dbtob(length) / secsize : 0; - *secsizep = secsize; + + if (numsecp) + *numsecp = secsize > 0 ? dbtob(length) / secsize : 0; + if (secsizep) + *secsizep = secsize; dm_table_unbusy(head); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 22 12:28:54 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Add missing "ioctl called" debug prints To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 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.57 src/sys/dev/dm/device-mapper.c:1.58 --- src/sys/dev/dm/device-mapper.c:1.57 Thu Dec 19 15:57:46 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 22 12:28:54 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.57 2019/12/19 15:57:46 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.58 2019/12/22 12:28:54 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -456,6 +456,8 @@ disk_ioctl_switch(dev_t dev, unsigned lo if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; + aprint_debug("DIOCGDISKINFO ioctl called\n"); + if (dmv->diskp->dk_info == NULL) { dm_dev_unbusy(dmv); return ENOTSUP; @@ -474,6 +476,8 @@ disk_ioctl_switch(dev_t dev, unsigned lo if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; + aprint_debug("DIOCCACHESYNC ioctl called\n"); + /* Select active table */ tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 21 16:00:30 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_target.c dm_target_stripe.c Log Message: dm: Fix dm-stripe's "status" output format As mentioned in "dm: Don't try to implement "status" as subset of "table"", dm-stripe in NetBSD doesn't have correct "status" output format. Implement ->info() to sync with Linux kernel. Note that num_error for stripe device isn't implemented yet. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/dev/dm/dm.h cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.42 -r1.43 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. Modified files: Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.50 src/sys/dev/dm/dm.h:1.51 --- src/sys/dev/dm/dm.h:1.50 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm.h Sat Dec 21 16:00:29 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.50 2019/12/21 11:59:03 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -186,13 +186,14 @@ typedef struct dm_target { * specific. When dm_table_status_ioctl is called with flag * DM_STATUS_TABLE_FLAG I have to sent params string back. */ - char *(*info)(void *); char *(*table)(void *); int (*strategy)(dm_table_entry_t *, struct buf *); int (*upcall)(dm_table_entry_t *, struct buf *); + /* * Optional routines. */ + char *(*info)(void *); int (*sync)(dm_table_entry_t *); int (*secsize)(dm_table_entry_t *, unsigned int *); @@ -251,6 +252,7 @@ int dm_target_linear_secsize(dm_table_en /* dm_target_stripe.c */ int dm_target_stripe_init(dm_table_entry_t *, int, char **); +char *dm_target_stripe_info(void *); char *dm_target_stripe_table(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.35 src/sys/dev/dm/dm_target.c:1.36 --- src/sys/dev/dm/dm_target.c:1.35 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm_target.c Sat Dec 21 16:00:29 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $"); #include #include @@ -331,6 +331,7 @@ dm_target_init(void) dmt->version[1] = 0; dmt->version[2] = 3; dmt->init = &dm_target_stripe_init; + dmt->info = &dm_target_stripe_info; dmt->table = &dm_target_stripe_table; dmt->strategy = &dm_target_stripe_strategy; dmt->sync = &dm_target_stripe_sync; Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.42 src/sys/dev/dm/dm_target_stripe.c:1.43 --- src/sys/dev/dm/dm_target_stripe.c:1.42 Sat Dec 21 11:59:03 2019 +++ src/sys/dev/dm/dm_target_stripe.c Sat Dec 21 16:00:29 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -80,6 +80,7 @@ dm_target_stripe_modcmd(modcmd_t cmd, vo dmt->version[1] = 0; dmt->version[2] = 0; dmt->init = &dm_target_stripe_init; + dmt->info = &dm_target_stripe_info; dmt->table = &dm_target_stripe_table; dmt->strategy = &dm_target_stripe_strategy; dmt->sync = &dm_target_stripe_sync; @@ -179,6 +180,45 @@ dm_target_stripe_init(dm_table_entry_t * return 0; } +/* Info routine called to get params string. */ +char * +dm_target_stripe_info(void *target_config) +{ + dm_target_linear_config_t *tlc; + dm_target_stripe_config_t *tsc; + char *params, *ptr, buf[256]; + int ret, i = 0; + size_t len; + + tsc = target_config; + + len = DM_MAX_PARAMS_SIZE; + params = kmem_alloc(len, KM_SLEEP); + ptr = params; + + ret = snprintf(ptr, len, "%d ", tsc->stripe_num); + ptr += ret; + len -= ret; + + memset(buf, 0, sizeof(buf)); + TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) { + ret = snprintf(ptr, len, "%s ", tlc->pdev->udev_name); + if (0 /*tlc->num_error*/) + buf[i] = 'D'; + else + buf[i] = 'A'; + i++; + ptr += ret; + len -= ret; + } + + ret = snprintf(ptr, len, "1 %s", buf); +
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 21 11:59:03 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_table.c dm_target.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/dev/dm/dm.h cvs rdiff -u -r1.47 -r1.48 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/dm/dm_target.c \ src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.49 src/sys/dev/dm/dm.h:1.50 --- src/sys/dev/dm/dm.h:1.49 Fri Dec 20 16:16:36 2019 +++ src/sys/dev/dm/dm.h Sat Dec 21 11:59:03 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.49 2019/12/20 16:16:36 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.50 2019/12/21 11:59:03 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -65,6 +65,13 @@ extern const struct dkdriver dmdkdriver; extern uint32_t dm_dev_counter; +typedef struct dm_mapping { + union { + struct dm_pdev *pdev; + } data; + TAILQ_ENTRY(dm_mapping) next; +} dm_mapping_t; + /* * A device mapper table is a list of physical ranges plus the mapping target * applied to them. @@ -77,6 +84,8 @@ typedef struct dm_table_entry { struct dm_target *target; /* Link to table target. */ void *target_config; /* Target specific data. */ SLIST_ENTRY(dm_table_entry) next; + + TAILQ_HEAD(, dm_mapping) pdev_maps; } dm_table_entry_t; SLIST_HEAD(dm_table, dm_table_entry); @@ -172,7 +181,6 @@ typedef struct dm_target { /* Destroy target_config area */ int (*destroy)(dm_table_entry_t *); - int (*deps)(dm_table_entry_t *, prop_array_t); /* * Info/table routine are called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -237,7 +245,6 @@ int dm_target_linear_init(dm_table_entry char *dm_target_linear_table(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); -int dm_target_linear_deps(dm_table_entry_t *, prop_array_t); int dm_target_linear_destroy(dm_table_entry_t *); int dm_target_linear_upcall(dm_table_entry_t *, struct buf *); int dm_target_linear_secsize(dm_table_entry_t *, unsigned int *); @@ -247,7 +254,6 @@ int dm_target_stripe_init(dm_table_entry char *dm_target_stripe_table(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); -int dm_target_stripe_deps(dm_table_entry_t *, prop_array_t); int dm_target_stripe_destroy(dm_table_entry_t *); int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *); int dm_target_stripe_secsize(dm_table_entry_t *, unsigned int *); @@ -256,7 +262,6 @@ int dm_target_stripe_secsize(dm_table_en int dm_target_error_init(dm_table_entry_t*, int, char **); char *dm_target_error_table(void *); int dm_target_error_strategy(dm_table_entry_t *, struct buf *); -int dm_target_error_deps(dm_table_entry_t *, prop_array_t); int dm_target_error_destroy(dm_table_entry_t *); int dm_target_error_upcall(dm_table_entry_t *, struct buf *); @@ -265,7 +270,6 @@ int dm_target_zero_init(dm_table_entry_t char *dm_target_zero_table(void *); int dm_target_zero_strategy(dm_table_entry_t *, struct buf *); int d
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 20 16:16:36 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_pdev.c dm_target_linear.c dm_target_stripe.c Log Message: dm: Fix "table" output format of dm-linear and dm-stripe The existing "table" output showing device file path of pdev is not compatible with dm in Linux kernel (and also DragonFlyBSD). It should be showing "major:minor" instead. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/dev/dm/dm.h cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.40 -r1.41 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. Modified files: Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.48 src/sys/dev/dm/dm.h:1.49 --- src/sys/dev/dm/dm.h:1.48 Mon Dec 16 15:59:04 2019 +++ src/sys/dev/dm/dm.h Fri Dec 20 16:16:36 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.48 2019/12/16 15:59:04 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.49 2019/12/20 16:16:36 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -103,6 +103,7 @@ typedef struct dm_table_head { */ typedef struct dm_pdev { char name[MAX_DEV_NAME]; + char udev_name[MAX_DEV_NAME]; struct vnode *pdev_vnode; uint64_t pdev_numsec; Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.21 src/sys/dev/dm/dm_pdev.c:1.22 --- src/sys/dev/dm/dm_pdev.c:1.21 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_pdev.c Fri Dec 20 16:16:36 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.21 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.22 2019/12/20 16:16:36 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.21 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.22 2019/12/20 16:16:36 tkusumi Exp $"); #include #include @@ -127,6 +127,10 @@ dm_pdev_insert(const char *dev_name) getdisksize(dmp->pdev_vnode, &dmp->pdev_numsec, &dmp->pdev_secsize); dmp->ref_cnt = 1; + snprintf(dmp->udev_name, sizeof(dmp->udev_name), "%d:%d", + major(dmp->pdev_vnode->v_rdev), minor(dmp->pdev_vnode->v_rdev)); + aprint_debug("%s: %s %s\n", __func__, dev_name, dmp->udev_name); + SLIST_INSERT_HEAD(&dm_pdev_list, dmp, next_pdev); mutex_exit(&dm_pdev_mutex); Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.33 src/sys/dev/dm/dm_target_linear.c:1.34 --- src/sys/dev/dm/dm_target_linear.c:1.33 Wed Dec 18 14:31:35 2019 +++ src/sys/dev/dm/dm_target_linear.c Fri Dec 20 16:16:36 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.34 2019/12/20 16:16:36 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.34 2019/12/20 16:16:36 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -96,7 +96,7 @@ dm_target_linear_table(void *target_conf params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP); snprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64, - tlc->pdev->name, tlc->offset); + tlc->pdev->udev_name, tlc->offset); return params; } Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.40 src/sys/dev/dm/dm_target_stripe.c:1.41 --- src/sys/dev/dm/dm_target_stripe.c:1.40 Wed Dec 18 14:31:35 2019 +++ src/sys/dev/dm/dm_target_stripe.c Fri Dec 20 16:16:36 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.41 2019/12/20 16:16:36 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.41 2019/12/20 16:16:36 tkusumi Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -197,7 +197,7 @@ dm_target_stripe_table(void *target_conf TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) { snprintf(tmp, DM_MAX_PARAMS_SIZE, " %s %" PRIu64, - tlc->pdev->name, tlc->offset); + tlc->pdev->udev_name, tlc->offset); strcat(params, tmp); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 19 16:27:39 UTC 2019 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: dm: Minor dm_ioctl.c fixes (indentation/typo/type/etc) To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/dev/dm/dm_ioctl.c:1.47 --- src/sys/dev/dm/dm_ioctl.c:1.46 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_ioctl.c Thu Dec 19 16:27:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.46 2019/12/15 14:39:42 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.47 2019/12/19 16:27:39 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.46 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.47 2019/12/19 16:27:39 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -103,23 +103,23 @@ static struct cfdata dm_cfdata = { .cf_fstate = FSTATE_STAR, .cf_unit = 0 }; + #define DM_REMOVE_FLAG(flag, name) do { \ - prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \ - flag &= ~name; \ - prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ + prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \ + flag &= ~name; \ + prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ } while (/*CONSTCOND*/0) #define DM_ADD_FLAG(flag, name) do { \ - prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \ - flag |= name; \ - prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ + prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \ + flag |= name; \ + prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ } while (/*CONSTCOND*/0) -static int dm_dbg_print_flags(uint32_t); static int dm_table_init(dm_target_t *, dm_table_entry_t *, char *); /* - * Print flags sent to the kernel from libevmapper. + * Print flags sent to the kernel from libdevmapper. */ static int dm_dbg_print_flags(uint32_t flags) @@ -663,7 +663,6 @@ dm_table_deps_ioctl(prop_dictionary_t dm * * Load table to inactive slot table are switched in dm_device_resume_ioctl. * This simulates Linux behaviour better there should not be any difference. - * */ int dm_table_load_ioctl(prop_dictionary_t dm_dict) @@ -967,7 +966,7 @@ dm_table_status_ioctl(prop_dictionary_t int dm_check_version(prop_dictionary_t dm_dict) { - size_t i; + int i; uint32_t dm_version[3]; prop_array_t ver;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 19 15:57:46 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Refactor dmioctl() More readable without dm_ioctl_switch() as a separate function. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 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.56 src/sys/dev/dm/device-mapper.c:1.57 --- src/sys/dev/dm/device-mapper.c:1.56 Thu Dec 19 15:34:54 2019 +++ src/sys/dev/dm/device-mapper.c Thu Dec 19 15:57:46 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.56 2019/12/19 15:34:54 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.57 2019/12/19 15:57:46 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -67,7 +67,6 @@ static void dm_doinit(void); static int dm_cmd_to_fun(prop_dictionary_t); static int disk_ioctl_switch(dev_t, unsigned long, void *); -static int dm_ioctl_switch(unsigned long); static void dmminphys(struct buf *); /* CF attach/detach functions used for power management */ @@ -356,10 +355,15 @@ dmioctl(dev_t dev, const u_long cmd, voi if ((r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { struct plistref *pref = (struct plistref *)data; - /* Check if we were called with NETBSD_DM_IOCTL ioctl - otherwise quit. */ - if ((r = dm_ioctl_switch(cmd)) != 0) - return r; + switch(cmd) { + case NETBSD_DM_IOCTL: + aprint_debug("dm NETBSD_DM_IOCTL called\n"); + break; + default: + aprint_debug("dm unknown ioctl called\n"); + return ENOTTY; + break; /* NOT REACHED */ + } if ((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0) @@ -411,24 +415,6 @@ dm_cmd_to_fun(prop_dictionary_t dm_dict) return cmd_fn[i].fn(dm_dict); } -/* Call apropriate ioctl handler function. */ -static int -dm_ioctl_switch(unsigned long cmd) -{ - - switch(cmd) { - case NETBSD_DM_IOCTL: - aprint_debug("dm NETBSD_DM_IOCTL called\n"); - break; - default: - aprint_debug("dm unknown ioctl called\n"); - return ENOTTY; - break; /* NOT REACHED */ - } - - return 0; -} - /* * Check for disk specific ioctls. */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 19 15:34:54 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_target.c Log Message: dm: u_{int,long} -> unsigned {int,long} To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_target.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.55 src/sys/dev/dm/device-mapper.c:1.56 --- src/sys/dev/dm/device-mapper.c:1.55 Sun Dec 15 16:14:27 2019 +++ src/sys/dev/dm/device-mapper.c Thu Dec 19 15:34:54 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.55 2019/12/15 16:14:27 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.56 2019/12/19 15:34:54 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -66,8 +66,8 @@ static int dmdestroy(void); static void dm_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); +static int disk_ioctl_switch(dev_t, unsigned long, void *); +static int dm_ioctl_switch(unsigned long); static void dmminphys(struct buf *); /* CF attach/detach functions used for power management */ @@ -413,7 +413,7 @@ dm_cmd_to_fun(prop_dictionary_t dm_dict) /* Call apropriate ioctl handler function. */ static int -dm_ioctl_switch(u_long cmd) +dm_ioctl_switch(unsigned long cmd) { switch(cmd) { @@ -433,7 +433,7 @@ dm_ioctl_switch(u_long cmd) * Check for disk specific ioctls. */ static int -disk_ioctl_switch(dev_t dev, u_long cmd, void *data) +disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data) { dm_dev_t *dmv; @@ -504,9 +504,8 @@ disk_ioctl_switch(dev_t dev, u_long cmd, } case DIOCGSECTORSIZE: { - u_int *valp = data; uint64_t numsec; - unsigned int secsize; + unsigned int secsize, *valp = data; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.33 src/sys/dev/dm/dm_target.c:1.34 --- src/sys/dev/dm/dm_target.c:1.33 Mon Dec 16 14:26:23 2019 +++ src/sys/dev/dm/dm_target.c Thu Dec 19 15:34:54 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.34 2019/12/19 15:34:54 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.34 2019/12/19 15:34:54 tkusumi Exp $"); #include #include @@ -77,7 +77,7 @@ dm_target_t * dm_target_autoload(const char *dm_target_name) { char name[30]; - u_int gen; + unsigned int gen; dm_target_t *dmt; snprintf(name, sizeof(name), "dm_target_%s", dm_target_name);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Wed Dec 18 14:31:35 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_error.c dm_target_linear.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Test # of args in target's ->init() The # of args is part of target's spec. Both Linux kernel and DragonFlyBSD test argc on ctr/init. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_zero.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_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.25 src/sys/dev/dm/dm_target_error.c:1.26 --- src/sys/dev/dm/dm_target_error.c:1.25 Mon Dec 16 14:26:23 2019 +++ src/sys/dev/dm/dm_target_error.c Wed Dec 18 14:31:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.25 2019/12/16 14:26:23 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.26 2019/12/18 14:31:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.25 2019/12/16 14:26:23 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.26 2019/12/18 14:31:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -101,6 +101,11 @@ int dm_target_error_init(dm_table_entry_t *table_en, int argc, char **argv) { + if (argc != 0) { + printf("Error target takes 0 args, %d given\n", argc); + return EINVAL; + } + printf("Error target init function called!!\n"); table_en->target_config = NULL; Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.32 src/sys/dev/dm/dm_target_linear.c:1.33 --- src/sys/dev/dm/dm_target_linear.c:1.32 Sun Dec 15 16:14:27 2019 +++ src/sys/dev/dm/dm_target_linear.c Wed Dec 18 14:31:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.32 2019/12/15 16:14:27 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.32 2019/12/15 16:14:27 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -59,12 +59,10 @@ dm_target_linear_init(dm_table_entry_t * dm_target_linear_config_t *tlc; dm_pdev_t *dmp; - /* if (argc != 2) { - printf("Linear target takes 2 args\n"); + printf("Linear target takes 2 args, %d given\n", argc); return EINVAL; } - */ aprint_debug("Linear target init function called %s--%s!!\n", argv[0], argv[1]); Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.39 src/sys/dev/dm/dm_target_stripe.c:1.40 --- src/sys/dev/dm/dm_target_stripe.c:1.39 Sun Dec 15 16:14:27 2019 +++ src/sys/dev/dm/dm_target_stripe.c Wed Dec 18 14:31:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.39 2019/12/15 16:14:27 tkusumi Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.39 2019/12/15 16:14:27 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -139,12 +139,10 @@ dm_target_stripe_init(dm_table_entry_t * dm_target_stripe_config_t *tsc; int strpc, strpi; - /* - if (argc < 4) { - printf("Stripe target takes 4 or more args\n"); + if (argc < 2) { + printf("Stripe target takes at least 2 args, %d given\n", argc); return EINVAL; } - */ printf("Stripe target init function called!!\n"); printf("Stripe target chunk size %s number of stripes %s\n", Index: src/sys/dev/dm/dm_target_zero.c diff -u src/sys/dev/dm/dm_target_zero.c:1.27 src/sys/dev/dm/dm_target_zero.c:1.28 --- src/sys/dev/dm/dm_target_zero.c:1.27 Mon Dec 16 14:26:23 2019 +++ src/sys/dev/dm/dm_target_zero.c Wed Dec 18 14:31:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_zero.c,v 1.27 2019/12/16 14:26:23 tkusumi Exp $ */ +/*$NetBSD: dm_target_zero.c,v 1.28 2019/12/18 14:31:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.27 2019/12/16 14:26:23 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBS
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 16 15:59:05 UTC 2019 Modified Files: src/sys/dev/dm: dm.h Log Message: dm: Cleanup dm.h (remove unneeded comments, etc) To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/dm/dm.h 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.47 src/sys/dev/dm/dm.h:1.48 --- src/sys/dev/dm/dm.h:1.47 Mon Dec 16 14:26:23 2019 +++ src/sys/dev/dm/dm.h Mon Dec 16 15:59:04 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.47 2019/12/16 14:26:23 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.48 2019/12/16 15:59:04 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,14 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _DM_DEV_H_ -#define _DM_DEV_H_ - +#ifndef _DM_H_ +#define _DM_H_ #ifdef _KERNEL #include - #include #include #include @@ -45,7 +43,6 @@ #include #include #include - #include #include #include @@ -72,7 +69,6 @@ extern uint32_t dm_dev_counter; * A device mapper table is a list of physical ranges plus the mapping target * applied to them. */ - typedef struct dm_table_entry { struct dm_dev *dm_dev; /* backlink */ uint64_t start; @@ -90,10 +86,10 @@ typedef struct dm_table dm_table_t; typedef struct dm_table_head { /* Current active table is selected with this. */ int cur_active_table; - struct dm_table tables[2]; + dm_table_t tables[2]; kmutex_t table_mtx; - kcondvar_t table_cv; /*IO waiting cv */ + kcondvar_t table_cv; /* I/O waiting cv */ uint32_t io_cnt; } dm_table_head_t; @@ -105,7 +101,6 @@ typedef struct dm_table_head { * I need this because devices can be opened only once, but I can * have more than one device on one partition. */ - typedef struct dm_pdev { char name[MAX_DEV_NAME]; @@ -150,13 +145,7 @@ typedef struct dm_dev { TAILQ_ENTRY(dm_dev) next_devlist; /* Major device list. */ } dm_dev_t; -/* for zero, error : dm_target->target_config == NULL */ - -/* - * Target config is initiated with target_init function. - */ - -/* for linear : */ +/* For linear target. */ typedef struct target_linear_config { dm_pdev_t *pdev; uint64_t offset; @@ -182,7 +171,7 @@ typedef struct dm_target { /* Destroy target_config area */ int (*destroy)(dm_table_entry_t *); - int (*deps) (dm_table_entry_t *, prop_array_t); + int (*deps)(dm_table_entry_t *, prop_array_t); /* * Info/table routine are called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -205,8 +194,6 @@ typedef struct dm_target { TAILQ_ENTRY(dm_target) dm_target_next; } dm_target_t; -/* Interface structures */ - /* device-mapper */ void dmgetproperties(struct disk *, dm_table_head_t *); @@ -240,8 +227,6 @@ dm_target_t* dm_target_lookup(const char int dm_target_rem(const char *); void dm_target_unbusy(dm_target_t *); void dm_target_busy(dm_target_t *); - -/* XXX temporally add */ int dm_target_init(void); #define DM_MAX_PARAMS_SIZE 1024 @@ -319,4 +304,4 @@ dm_pdev_t* dm_pdev_insert(const char *); #endif /*_KERNEL*/ -#endif /*_DM_DEV_H_*/ +#endif /*_DM_H_*/
CVS commit: src/sys
Module Name:src Committed By: tkusumi Date: Mon Dec 16 14:26:23 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_target.c dm_target_error.c dm_target_zero.c src/sys/modules/dm: Makefile Log Message: dm: Enable dm-error and dm-zero target Add these two targets to dm.kmod. These are generally available in Linux and DragonFlyBSD, so enable them in NetBSD as well. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/dm/dm.h cvs rdiff -u -r1.32 -r1.33 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target_zero.c cvs rdiff -u -r1.7 -r1.8 src/sys/modules/dm/Makefile 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.46 src/sys/dev/dm/dm.h:1.47 --- src/sys/dev/dm/dm.h:1.46 Sun Dec 15 16:14:27 2019 +++ src/sys/dev/dm/dm.h Mon Dec 16 14:26:23 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.46 2019/12/15 16:14:27 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.47 2019/12/16 14:26:23 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -266,6 +266,22 @@ int dm_target_stripe_destroy(dm_table_en int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *); int dm_target_stripe_secsize(dm_table_entry_t *, unsigned int *); +/* dm_target_error.c */ +int dm_target_error_init(dm_table_entry_t*, int, char **); +char *dm_target_error_table(void *); +int dm_target_error_strategy(dm_table_entry_t *, struct buf *); +int dm_target_error_deps(dm_table_entry_t *, prop_array_t); +int dm_target_error_destroy(dm_table_entry_t *); +int dm_target_error_upcall(dm_table_entry_t *, struct buf *); + +/* dm_target_zero.c */ +int dm_target_zero_init(dm_table_entry_t *, int, char **); +char *dm_target_zero_table(void *); +int dm_target_zero_strategy(dm_table_entry_t *, struct buf *); +int dm_target_zero_destroy(dm_table_entry_t *); +int dm_target_zero_deps(dm_table_entry_t *, prop_array_t); +int dm_target_zero_upcall(dm_table_entry_t *, struct buf *); + /* dm_table.c */ #define DM_TABLE_ACTIVE 0 #define DM_TABLE_INACTIVE 1 Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.32 src/sys/dev/dm/dm_target.c:1.33 --- src/sys/dev/dm/dm_target.c:1.32 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_target.c Mon Dec 16 14:26:23 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.32 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.32 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 tkusumi Exp $"); #include #include @@ -312,14 +312,11 @@ dm_target_prop_list(void) int dm_target_init(void) { - dm_target_t *dmt, *dmt3; - int r; + dm_target_t *dmt; mutex_init(&dm_target_mutex, MUTEX_DEFAULT, IPL_NONE); dmt = dm_target_alloc("linear"); - dmt3 = dm_target_alloc("striped"); - dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 2; @@ -331,22 +328,49 @@ dm_target_init(void) dmt->destroy = &dm_target_linear_destroy; dmt->upcall = &dm_target_linear_upcall; dmt->secsize = &dm_target_linear_secsize; + if (dm_target_insert(dmt)) + printf("Failed to insert linear\n"); - r = dm_target_insert(dmt); + dmt = dm_target_alloc("striped"); + dmt->version[0] = 1; + dmt->version[1] = 0; + dmt->version[2] = 3; + dmt->init = &dm_target_stripe_init; + dmt->table = &dm_target_stripe_table; + dmt->strategy = &dm_target_stripe_strategy; + dmt->sync = &dm_target_stripe_sync; + dmt->deps = &dm_target_stripe_deps; + dmt->destroy = &dm_target_stripe_destroy; + dmt->upcall = &dm_target_stripe_upcall; + dmt->secsize = &dm_target_stripe_secsize; + if (dm_target_insert(dmt)) + printf("Failed to insert striped\n"); - dmt3->version[0] = 1; - dmt3->version[1] = 0; - dmt3->version[2] = 3; - dmt3->init = &dm_target_stripe_init; - dmt3->table = &dm_target_stripe_table; - dmt3->strategy = &dm_target_stripe_strategy; - dmt3->sync = &dm_target_stripe_sync; - dmt3->deps = &dm_target_stripe_deps; - dmt3->destroy = &dm_target_stripe_destroy; - dmt3->upcall = &dm_target_stripe_upcall; - dmt3->secsize = &dm_target_stripe_secsize; + dmt = dm_target_alloc("error"); + dmt->version[0] = 1; + dmt->version[1] = 0; + dmt->version[2] = 0; + dmt->init = &dm_target_error_init; + dmt->table = &dm_target_error_table; + dmt->strategy = &dm_target_error_strategy; + dmt->deps = &dm_target_error_deps; + dmt->destroy = &dm_target_error_destroy; + dmt->upcall = &dm_target_error_upcall; + if (dm_target_insert(dmt)) + printf("Failed to insert error\n"); - r = dm_target_insert(dmt3); + dmt = dm_target_alloc("zero"); + dmt->version[0] = 1; + dmt->versi
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 16:14:27 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h dm_target_linear.c dm_target_snapshot.c dm_target_stripe.c Log Message: dm: Rename dm specific atoi() to atoi64() This is uint64_t version, not sys/lib/libsa/atoi.c. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/dm/dm.h cvs rdiff -u -r1.31 -r1.32 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.38 -r1.39 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. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.54 src/sys/dev/dm/device-mapper.c:1.55 --- src/sys/dev/dm/device-mapper.c:1.54 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 15 16:14:27 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.54 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.55 2019/12/15 16:14:27 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -700,3 +700,23 @@ dmgetproperties(struct disk *disk, dm_ta disk_set_info(NULL, disk, "ESDI"); } + +/* + * Transform char s to uint64_t offset number. + */ +uint64_t +atoi64(const char *s) +{ + uint64_t n; + n = 0; + + while (*s != '\0') { + if (!isdigit(*s)) + break; + + n = (10 * n) + (*s - '0'); + s++; + } + + return n; +} Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.45 src/sys/dev/dm/dm.h:1.46 --- src/sys/dev/dm/dm.h:1.45 Sun Dec 15 10:12:45 2019 +++ src/sys/dev/dm/dm.h Sun Dec 15 16:14:27 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.45 2019/12/15 10:12:45 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.46 2019/12/15 16:14:27 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -210,6 +210,9 @@ typedef struct dm_target { /* device-mapper */ void dmgetproperties(struct disk *, dm_table_head_t *); +/* Generic function used to convert char to string */ +uint64_t atoi64(const char *); + /* dm_ioctl.c */ int dm_dev_create_ioctl(prop_dictionary_t); int dm_dev_list_ioctl(prop_dictionary_t); @@ -253,9 +256,6 @@ int dm_target_linear_destroy(dm_table_en int dm_target_linear_upcall(dm_table_entry_t *, struct buf *); int dm_target_linear_secsize(dm_table_entry_t *, unsigned int *); -/* Generic function used to convert char to string */ -uint64_t atoi(const char *); - /* dm_target_stripe.c */ int dm_target_stripe_init(dm_table_entry_t *, int, char **); char *dm_target_stripe_table(void *); Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.31 src/sys/dev/dm/dm_target_linear.c:1.32 --- src/sys/dev/dm/dm_target_linear.c:1.31 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_target_linear.c Sun Dec 15 16:14:27 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.31 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.32 2019/12/15 16:14:27 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.31 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.32 2019/12/15 16:14:27 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -75,7 +75,7 @@ dm_target_linear_init(dm_table_entry_t * tlc = kmem_alloc(sizeof(dm_target_linear_config_t), KM_SLEEP); tlc->pdev = dmp; - tlc->offset = atoi(argv[1]); + tlc->offset = atoi64(argv[1]); table_en->target_config = tlc; @@ -213,23 +213,3 @@ dm_target_linear_secsize(dm_table_entry_ return 0; } - -/* - * Transform char s to uint64_t offset number. - */ -uint64_t -atoi(const char *s) -{ - uint64_t n; - n = 0; - - while (*s != '\0') { - if (!isdigit(*s)) - break; - - n = (10 * n) + (*s - '0'); - s++; - } - - return n; -} Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.35 src/sys/dev/dm/dm_target_snapshot.c:1.36 --- src/sys/dev/dm/dm_target_snapshot.c:1.35 Sun Dec 15 14:39:42 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Sun Dec 15 16:14:27 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.35 2019/12/15 14:39:42 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.36 2019/12/15 16:14:27 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.35 2019/12/15 14:39:42 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.36 2019/12/15 16:14:27 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is be
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 14:39:43 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Style cleanups (no functional changes) To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_dev.c src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/dm/dm_target_zero.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.53 src/sys/dev/dm/device-mapper.c:1.54 --- src/sys/dev/dm/device-mapper.c:1.53 Sun Dec 15 10:12:45 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 15 14:39:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.53 2019/12/15 10:12:45 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.54 2019/12/15 14:39:42 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -35,7 +35,6 @@ #include #include - #include #include #include @@ -236,7 +235,7 @@ dm_match(device_t parent, cfdata_t match { /* Pseudo-device; always present. */ - return (1); + return 1; } /* @@ -247,10 +246,8 @@ dm_match(device_t parent, cfdata_t match static void dm_attach(device_t parent, device_t self, void *aux) { - return; } - /* * dm_detach: * @@ -291,6 +288,7 @@ dm_detach(device_t self, int flags) static void dm_doinit(void) { + dm_target_init(); dm_dev_init(); dm_pdev_init(); @@ -303,12 +301,11 @@ dmattach(int n) int error; error = config_cfattach_attach(dm_cd.cd_name, &dm_ca); - if (error) { + if (error) aprint_error("%s: unable to register cfattach\n", dm_cd.cd_name); - } else { + else dm_doinit(); - } } #ifdef _MODULE @@ -388,16 +385,14 @@ cleanup_exit: */ static int dm_cmd_to_fun(prop_dictionary_t dm_dict) - { +{ int i, r; prop_string_t command; - r = 0; - if ((command = prop_dictionary_get(dm_dict, DM_IOCTL_COMMAND)) == NULL) return EINVAL; - for(i = 0; cmd_fn[i].cmd != NULL; i++) + for (i = 0; cmd_fn[i].cmd != NULL; i++) if (prop_string_equals_cstring(command, cmd_fn[i].cmd)) break; @@ -412,9 +407,8 @@ dm_cmd_to_fun(prop_dictionary_t dm_dict) aprint_debug("ioctl %s called %p\n", cmd_fn[i].cmd, cmd_fn[i].fn); if (cmd_fn[i].fn == NULL) return 0; - r = cmd_fn[i].fn(dm_dict); - return r; + return cmd_fn[i].fn(dm_dict); } /* Call apropriate ioctl handler function. */ @@ -469,7 +463,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, dm_dev_unbusy(dmv); break; } - case DIOCGDISKINFO: { struct plistref *pref = (struct plistref *) data; @@ -487,7 +480,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, dm_dev_unbusy(dmv); break; } - case DIOCCACHESYNC: { dm_table_entry_t *table_en; @@ -510,7 +502,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, dm_dev_unbusy(dmv); break; } - case DIOCGSECTORSIZE: { u_int *valp = data; @@ -528,7 +519,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, dm_dev_unbusy(dmv); break; } - case DIOCGMEDIASIZE: { off_t *valp = data; @@ -546,7 +536,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, dm_dev_unbusy(dmv); break; } - default: aprint_debug("unknown disk_ioctl called\n"); return ENOTTY; @@ -563,7 +552,7 @@ static void dmstrategy(struct buf *bp) { dm_dev_t *dmv; - dm_table_t *tbl; + dm_table_t *tbl; dm_table_entry_t *table_en; struct buf *nestbuf; @@ -574,8 +563,6 @@ dmstrategy(struct buf *bp) buf_start = bp->b_blkno * DEV_BSIZE; buf_len = bp->b_bcount; - tbl = NULL; - table_end = 0; issued_len = 0; @@ -620,9 +607,7 @@ dmstrategy(struct buf *bp) * off by one error */ table_end = table_start + table_en->length * DEV_BSIZE; - start = MAX(table_start, buf_start); - end = MIN(table_end, buf_start + buf_len); aprint_debug("\n"); @@ -639,15 +624,11 @@ dmstrategy(struct buf *bp) if (start < end) { /* create nested buffer */ nestbuf = getiobuf(NULL, true); - nestiobuf_setup(bp, nestbuf, start - buf_start, - (end - start)); - + end - start); issued_len += end - start; - /* I need number of blocks. */ nestbuf->b_blkno = (start
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 10:12:45 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h dm_target.c dm_target_error.c dm_target_snapshot.c dm_target_zero.c Log Message: dm: Make targets' ->sync() optional Apparently some targets have nothing to sync, so make it optional. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.44 -r1.45 src/sys/dev/dm/dm.h cvs rdiff -u -r1.30 -r1.31 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/dm/dm_target_zero.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.52 src/sys/dev/dm/device-mapper.c:1.53 --- src/sys/dev/dm/device-mapper.c:1.52 Sun Dec 15 09:22:28 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 15 10:12:45 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.52 2019/12/15 09:22:28 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.53 2019/12/15 10:12:45 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -504,7 +504,8 @@ disk_ioctl_switch(dev_t dev, u_long cmd, * routine basically call DIOCCACHESYNC on underlying devices. */ SLIST_FOREACH(table_en, tbl, next) - table_en->target->sync(table_en); + if (table_en->target->sync) +table_en->target->sync(table_en); dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); dm_dev_unbusy(dmv); break; Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.44 src/sys/dev/dm/dm.h:1.45 --- src/sys/dev/dm/dm.h:1.44 Sun Dec 15 09:42:29 2019 +++ src/sys/dev/dm/dm.h Sun Dec 15 10:12:45 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.44 2019/12/15 09:42:29 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.45 2019/12/15 10:12:45 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -191,11 +191,11 @@ typedef struct dm_target { char *(*info)(void *); char *(*table)(void *); 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 (*sync)(dm_table_entry_t *); int (*secsize)(dm_table_entry_t *, unsigned int *); uint32_t version[3]; Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.30 src/sys/dev/dm/dm_target.c:1.31 --- src/sys/dev/dm/dm_target.c:1.30 Sun Dec 15 09:42:29 2019 +++ src/sys/dev/dm/dm_target.c Sun Dec 15 10:12:45 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.31 2019/12/15 10:12:45 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.31 2019/12/15 10:12:45 tkusumi Exp $"); #include #include @@ -180,10 +180,6 @@ dm_target_insert(dm_target_t *dm_target) printf("%s missing upcall\n", dm_target->name); return EINVAL; } - if (dm_target->sync == NULL) { - printf("%s missing sync\n", dm_target->name); - return EINVAL; - } mutex_enter(&dm_target_mutex); Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.22 src/sys/dev/dm/dm_target_error.c:1.23 --- src/sys/dev/dm/dm_target_error.c:1.22 Sun Dec 15 09:42:29 2019 +++ src/sys/dev/dm/dm_target_error.c Sun Dec 15 10:12:45 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.23 2019/12/15 10:12:45 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.23 2019/12/15 10:12:45 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_er int dm_target_error_init(dm_table_entry_t*, int, char **); char *dm_target_error_table(void *); int dm_target_error_strategy(dm_table_entry_t *, struct buf *); -int dm_target_error_sync(dm_table_entry_t *); int dm_target_error_deps(dm_table_entry_t *, prop_array_t); int dm_target_error_destroy(dm_table_entry_t *); int dm_target_error_upcall(dm_table_entry_t *, struct buf *); @@ -84,7 +83,6 @@ dm_target_error_modcmd(modcmd_t cmd, voi dmt->init = &dm_target_error_init; dmt->table = &dm_target_error_table; dmt->strategy = &dm_target_error_strategy; - dmt->sync = &dm_target_error_sync; dmt->deps
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 09:42:29 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_table.c dm_target.c dm_target_error.c dm_target_mirror.c dm_target_snapshot.c dm_target_zero.c Log Message: 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)". To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/dm/dm.h cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.43 src/sys/dev/dm/dm.h:1.44 --- src/sys/dev/dm/dm.h:1.43 Sun Dec 15 09:22:28 2019 +++ src/sys/dev/dm/dm.h Sun Dec 15 09:42:29 2019 @@ -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_*/ Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.14 src/sys/dev/dm/dm_table.c:1.15 --- src/sys/dev/dm/dm_table.c:1.14 Sun Dec 15 09:22:28 2019 +++ src/sys/dev/dm/dm_table.c Sun Dec 15 09:42:29 2019 @@ -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 -__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 #include @@ -248,7 +248,10 @@ dm_table_disksize(dm_table_head_t *head, secsize = 0; SLIST_FOREACH(table_en, tbl, next) { length += table_en->length; - table_en->target->secsize(table_en, &tsecsize); + if (table_en->target->secsize) + table_en->target->secsize(table_en, &tsecsize); + else + tsecsize = 0; if (secsize < tsecsize) secsize = tsecsize; } Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.29 src/sys/dev/dm/dm_target.c:1.30 --- src/sys/dev/dm/dm_target.c:1.29 Sun Dec 15 05:56:02 2019 +++ src/sys/dev/dm/dm_target.c Sun Dec 15 09:42:29 2019 @@ -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 -__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 #include @@ -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); Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.21 src/sys/dev/dm/dm_target_error.c:1.22 --- src/sys/dev/dm/dm_target_error.c:1.21 Sun Dec 15 05:56:02 2019 +++ src/sys/dev/dm/dm_target_error.c Sun Dec 15 09:42:29 2019 @@ -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 -__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_er
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 09:22:29 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h dm_table.c dm_target_linear.c dm_target_stripe.c Log Message: dm: "unsigned" -> "unsigned int" for consistency Use either one, but not both. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/dm/dm.h cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.36 -r1.37 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. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.51 src/sys/dev/dm/device-mapper.c:1.52 --- src/sys/dev/dm/device-mapper.c:1.51 Sat Dec 14 11:20:51 2019 +++ src/sys/dev/dm/device-mapper.c Sun Dec 15 09:22:28 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.51 2019/12/14 11:20:51 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.52 2019/12/15 09:22:28 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -451,7 +451,7 @@ disk_ioctl_switch(dev_t dev, u_long cmd, case DIOCGWEDGEINFO: { struct dkwedge_info *dkw = (void *) data; - unsigned secsize; + unsigned int secsize; if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) return ENODEV; @@ -703,7 +703,7 @@ void dmgetproperties(struct disk *disk, dm_table_head_t *head) { uint64_t numsec; - unsigned secsize; + unsigned int secsize; dm_table_disksize(head, &numsec, &secsize); Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.42 src/sys/dev/dm/dm.h:1.43 --- src/sys/dev/dm/dm.h:1.42 Sun Dec 15 05:56:02 2019 +++ src/sys/dev/dm/dm.h Sun Dec 15 09:22:28 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.42 2019/12/15 05:56:02 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.43 2019/12/15 09:22:28 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -111,7 +111,7 @@ typedef struct dm_pdev { struct vnode *pdev_vnode; uint64_t pdev_numsec; - unsigned pdev_secsize; + unsigned int pdev_secsize; int ref_cnt; /* reference counter for users ofthis pdev */ SLIST_ENTRY(dm_pdev) next_pdev; @@ -193,7 +193,7 @@ 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 *); - int (*secsize)(dm_table_entry_t *, unsigned *); + int (*secsize)(dm_table_entry_t *, unsigned int *); uint32_t version[3]; uint32_t ref_cnt; @@ -248,7 +248,7 @@ int dm_target_linear_sync(dm_table_entry int dm_target_linear_deps(dm_table_entry_t *, prop_array_t); int dm_target_linear_destroy(dm_table_entry_t *); int dm_target_linear_upcall(dm_table_entry_t *, struct buf *); -int dm_target_linear_secsize(dm_table_entry_t *, unsigned *); +int dm_target_linear_secsize(dm_table_entry_t *, unsigned int *); /* Generic function used to convert char to string */ uint64_t atoi(const char *); @@ -261,7 +261,7 @@ int dm_target_stripe_sync(dm_table_entry int dm_target_stripe_deps(dm_table_entry_t *, prop_array_t); int dm_target_stripe_destroy(dm_table_entry_t *); int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *); -int dm_target_stripe_secsize(dm_table_entry_t *, unsigned *); +int dm_target_stripe_secsize(dm_table_entry_t *, unsigned int *); /* dm_table.c */ #define DM_TABLE_ACTIVE 0 @@ -270,7 +270,7 @@ int dm_target_stripe_secsize(dm_table_en int dm_table_destroy(dm_table_head_t *, uint8_t); uint64_t dm_table_size(dm_table_head_t *); uint64_t dm_inactive_table_size(dm_table_head_t *); -void dm_table_disksize(dm_table_head_t *, uint64_t *, unsigned *); +void dm_table_disksize(dm_table_head_t *, uint64_t *, unsigned int *); dm_table_t *dm_table_get_entry(dm_table_head_t *, uint8_t); int dm_table_get_target_count(dm_table_head_t *, uint8_t); void dm_table_release(dm_table_head_t *, uint8_t s); @@ -300,7 +300,7 @@ dm_pdev_t* dm_pdev_insert(const char *); /* XXX dummy */ static __inline int -dm_target_dummy_secsize(dm_table_entry_t *table_en, unsigned *secsizep) +dm_target_dummy_secsize(dm_table_entry_t *table_en, unsigned int *secsizep) { return 0; } Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.13 src/sys/dev/dm/dm_table.c:1.14 --- src/sys/dev/dm/dm_table.c:1.13 Sat Dec 14 10:49:30 2019 +++ src/sys/dev/dm/dm_table.c Sun Dec 15 09:22:28 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.13 2019/12/14 10:49:30 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.14 2019/12/15 09:22:28 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.13 2019/12/14 10:49:30 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.14
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 15 05:56:02 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_target.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Rename targets' ->status() to ->table() given ->info() exists Since now that dm targets in NetBSD have ->info() for "status", ->status() should be renamed to ->table() for "table", given how dm target status was originally designed in Linux kernel. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/dm/dm.h cvs rdiff -u -r1.44 -r1.45 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm_target.c \ src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.41 src/sys/dev/dm/dm.h:1.42 --- src/sys/dev/dm/dm.h:1.41 Sat Dec 14 17:15:54 2019 +++ src/sys/dev/dm/dm.h Sun Dec 15 05:56:02 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.41 2019/12/14 17:15:54 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.42 2019/12/15 05:56:02 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -184,12 +184,12 @@ typedef struct dm_target { int (*deps) (dm_table_entry_t *, prop_array_t); /* - * Info/status routine are called to get params string, which is target + * Info/table routine are called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag * DM_STATUS_TABLE_FLAG I have to sent params string back. */ char *(*info)(void *); - char * (*status)(void *); + char *(*table)(void *); int (*strategy)(dm_table_entry_t *, struct buf *); int (*sync)(dm_table_entry_t *); int (*upcall)(dm_table_entry_t *, struct buf *); @@ -242,7 +242,7 @@ int dm_target_init(void); /* dm_target_linear.c */ int dm_target_linear_init(dm_table_entry_t *, int, char **); -char *dm_target_linear_status(void *); +char *dm_target_linear_table(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); int dm_target_linear_deps(dm_table_entry_t *, prop_array_t); @@ -255,7 +255,7 @@ uint64_t atoi(const char *); /* dm_target_stripe.c */ int dm_target_stripe_init(dm_table_entry_t *, int, char **); -char *dm_target_stripe_status(void *); +char *dm_target_stripe_table(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); int dm_target_stripe_deps(dm_table_entry_t *, prop_array_t); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.44 src/sys/dev/dm/dm_ioctl.c:1.45 --- src/sys/dev/dm/dm_ioctl.c:1.44 Sat Dec 14 17:15:54 2019 +++ src/sys/dev/dm/dm_ioctl.c Sun Dec 15 05:56:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.44 2019/12/14 17:15:54 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.45 2019/12/15 05:56:02 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.44 2019/12/14 17:15:54 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.45 2019/12/15 05:56:02 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -943,7 +943,7 @@ dm_table_status_ioctl(prop_dictionary_t prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, ""); if (flags & DM_STATUS_TABLE_FLAG) - params = table_en->target->status( + params = table_en->target->table( table_en->target_config); else if (table_en->target->info) params = table_en->target->info( Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.28 src/sys/dev/dm/dm_target.c:1.29 --- src/sys/dev/dm/dm_target.c:1.28 Sat Dec 14 10:49:30 2019 +++ src/sys/dev/dm/dm_target.c Sun Dec 15 05:56:02 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.28 2019/12/14 10:49:30 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.29 2019/12/15 05:56:02 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.28 2019/12/14 10:49:30 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.29 2019/12/15 05:56:02 tkusumi Exp $"); #include #include @@ -160,8 +160,8 @@ dm_target_insert(dm_target_t *dm_target) printf("%s missing init\n", dm_target->name); return EINVAL
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 14 17:15:54 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c Log Message: dm: Don't try to implement "status" as subset of "table" The way dm_table_status_ioctl() implements "status" and "table" is not compatible with Linux kernel. Some targets have different outputs that "status" can't be implemented as subset of "table". Add ->info() handler to sync with "status" behavior in Linux kernel. Some targets which currently exist in NetBSD (I think striped) as well as some minor targets that I plan to port to NetBSD can/should implement ->info(), but will do that in a different commit. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/dm/dm.h cvs rdiff -u -r1.43 -r1.44 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.h diff -u src/sys/dev/dm/dm.h:1.40 src/sys/dev/dm/dm.h:1.41 --- src/sys/dev/dm/dm.h:1.40 Sat Dec 14 11:20:51 2019 +++ src/sys/dev/dm/dm.h Sat Dec 14 17:15:54 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.40 2019/12/14 11:20:51 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.41 2019/12/14 17:15:54 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -184,10 +184,11 @@ typedef struct dm_target { int (*deps) (dm_table_entry_t *, prop_array_t); /* - * Status routine is called to get params string, which is target + * Info/status routine are called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag * DM_STATUS_TABLE_FLAG I have to sent params string back. */ + char *(*info)(void *); char * (*status)(void *); int (*strategy)(dm_table_entry_t *, struct buf *); int (*sync)(dm_table_entry_t *); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.43 src/sys/dev/dm/dm_ioctl.c:1.44 --- src/sys/dev/dm/dm_ioctl.c:1.43 Sat Dec 14 14:43:38 2019 +++ src/sys/dev/dm/dm_ioctl.c Sat Dec 14 17:15:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.43 2019/12/14 14:43:38 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.44 2019/12/14 17:15:54 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.43 2019/12/14 14:43:38 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.44 2019/12/14 17:15:54 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -942,17 +942,21 @@ dm_table_status_ioctl(prop_dictionary_t */ prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, ""); - if (flags & DM_STATUS_TABLE_FLAG) { - params = table_en->target->status - (table_en->target_config); - - if (params != NULL) { -prop_dictionary_set_cstring(target_dict, -DM_TABLE_PARAMS, params); + if (flags & DM_STATUS_TABLE_FLAG) + params = table_en->target->status( + table_en->target_config); + else if (table_en->target->info) + params = table_en->target->info( + table_en->target_config); + else + params = NULL; -kmem_free(params, DM_MAX_PARAMS_SIZE); - } + if (params != NULL) { + prop_dictionary_set_cstring(target_dict, + DM_TABLE_PARAMS, params); + kmem_free(params, DM_MAX_PARAMS_SIZE); } + prop_array_add(cmd_array, target_dict); prop_object_release(target_dict); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 14 14:43:38 UTC 2019 Modified Files: src/sys/dev/dm: dm_ioctl.c Log Message: dm: Make dm_dbg_print_flags() take uint32_t flag which comes from prop_dictionary_get_uint32() result. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/dev/dm/dm_ioctl.c:1.43 --- src/sys/dev/dm/dm_ioctl.c:1.42 Sat Dec 14 11:20:51 2019 +++ src/sys/dev/dm/dm_ioctl.c Sat Dec 14 14:43:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.42 2019/12/14 11:20:51 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.43 2019/12/14 14:43:38 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.42 2019/12/14 11:20:51 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.43 2019/12/14 14:43:38 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -116,14 +116,14 @@ static struct cfdata dm_cfdata = { prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \ } while (/*CONSTCOND*/0) -static int dm_dbg_print_flags(int); +static int dm_dbg_print_flags(uint32_t); static int dm_table_init(dm_target_t *, dm_table_entry_t *, char *); /* * Print flags sent to the kernel from libevmapper. */ static int -dm_dbg_print_flags(int flags) +dm_dbg_print_flags(uint32_t flags) { aprint_debug("dbg_print --- %d\n", flags);
CVS commit: src/sys/fs/autofs
Module Name:src Committed By: tkusumi Date: Sat Dec 14 12:01:13 UTC 2019 Modified Files: src/sys/fs/autofs: autofs.c Log Message: autofs: Make /dev/autofs cdevsw functions static Also less confusing since autofs vnops also has autofs_{open,close} in NetBSD. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/fs/autofs/autofs.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/fs/autofs/autofs.c diff -u src/sys/fs/autofs/autofs.c:1.3 src/sys/fs/autofs/autofs.c:1.4 --- src/sys/fs/autofs/autofs.c:1.3 Tue Jan 9 16:19:39 2018 +++ src/sys/fs/autofs/autofs.c Sat Dec 14 12:01:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $ */ +/* $NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $"); #include "autofs.h" @@ -78,9 +78,9 @@ __KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1 #include #include -dev_type_open(autofs_open); -dev_type_close(autofs_close); -dev_type_ioctl(autofs_ioctl); +static dev_type_open(autofs_open); +static dev_type_close(autofs_close); +static dev_type_ioctl(autofs_ioctl); const struct cdevsw autofs_cdevsw = { .d_open = autofs_open, @@ -519,7 +519,7 @@ autofs_ioctl_done(struct autofs_daemon_d return 0; } -int +static int autofs_open(dev_t dev, int flags, int mode, struct lwp *l) { @@ -543,7 +543,7 @@ autofs_open(dev_t dev, int flags, int mo return 0; } -int +static int autofs_close(dev_t dev, int flags, int mode, struct lwp *l) { @@ -555,7 +555,7 @@ autofs_close(dev_t dev, int flags, int m return 0; } -int +static int autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag, struct lwp *l) {
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 14 11:20:51 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h dm_ioctl.c Log Message: dm: Move extern declaration of global variables to dm.h To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/dm/dm.h cvs rdiff -u -r1.41 -r1.42 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.50 src/sys/dev/dm/device-mapper.c:1.51 --- src/sys/dev/dm/device-mapper.c:1.50 Sat Dec 14 10:49:30 2019 +++ src/sys/dev/dm/device-mapper.c Sat Dec 14 11:20:51 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.50 2019/12/14 10:49:30 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.51 2019/12/14 11:20:51 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -111,8 +111,6 @@ CFATTACH_DECL3_NEW(dm, 0, dm_match, dm_attach, dm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); -extern uint32_t dm_dev_counter; - /* * This structure is used to translate command sent to kernel driver in * command Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.39 src/sys/dev/dm/dm.h:1.40 --- src/sys/dev/dm/dm.h:1.39 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm.h Sat Dec 14 11:20:51 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.39 2019/12/12 16:28:24 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.40 2019/12/14 11:20:51 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -65,6 +65,9 @@ /*** Internal device-mapper structures ***/ +extern const struct dkdriver dmdkdriver; +extern uint32_t dm_dev_counter; + /* * A device mapper table is a list of physical ranges plus the mapping target * applied to them. Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.41 src/sys/dev/dm/dm_ioctl.c:1.42 --- src/sys/dev/dm/dm_ioctl.c:1.41 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm_ioctl.c Sat Dec 14 11:20:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.41 2019/12/12 16:28:24 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.42 2019/12/14 11:20:51 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.41 2019/12/12 16:28:24 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.42 2019/12/14 11:20:51 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -95,7 +95,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v #include "dm.h" static uint32_t sc_minor_num; -extern const struct dkdriver dmdkdriver; uint32_t dm_dev_counter; /* Generic cf_data for device-mapper driver */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 14 10:49:30 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_dev.c dm_table.c dm_target.c Log Message: dm: Remove void casts of function calls Use of void casts in dm is not consistent, just get rid of them. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target.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.49 src/sys/dev/dm/device-mapper.c:1.50 --- src/sys/dev/dm/device-mapper.c:1.49 Wed Dec 11 14:03:37 2019 +++ src/sys/dev/dm/device-mapper.c Sat Dec 14 10:49:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.49 2019/12/11 14:03:37 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.50 2019/12/14 10:49:30 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -282,7 +282,7 @@ dm_detach(device_t self, int flags) disk_destroy(dmv->diskp); /* Destroy device */ - (void)dm_dev_free(dmv); + dm_dev_free(dmv); /* Decrement device counter After removing device */ atomic_dec_32(&dm_dev_counter); @@ -505,9 +505,8 @@ disk_ioctl_switch(dev_t dev, u_long cmd, * Call sync target routine for all table entries. Target sync * routine basically call DIOCCACHESYNC on underlying devices. */ - SLIST_FOREACH(table_en, tbl, next) { - (void)table_en->target->sync(table_en); - } + SLIST_FOREACH(table_en, tbl, next) + table_en->target->sync(table_en); dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); dm_dev_unbusy(dmv); break; Index: src/sys/dev/dm/dm_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.14 src/sys/dev/dm/dm_dev.c:1.15 --- src/sys/dev/dm/dm_dev.c:1.14 Sat Dec 7 15:28:39 2019 +++ src/sys/dev/dm/dm_dev.c Sat Dec 14 10:49:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.14 2019/12/07 15:28:39 tkusumi Exp $ */ +/*$NetBSD: dm_dev.c,v 1.15 2019/12/14 10:49:30 tkusumi 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.14 2019/12/07 15:28:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.15 2019/12/14 10:49:30 tkusumi Exp $"); #include #include @@ -306,7 +306,7 @@ dm_dev_destroy(void) mutex_destroy(&dmv->dev_mtx); cv_destroy(&dmv->dev_cv); - (void)kmem_free(dmv, sizeof(dm_dev_t)); + kmem_free(dmv, sizeof(dm_dev_t)); } mutex_exit(&dm_dev_mutex); @@ -340,9 +340,9 @@ dm_dev_free(dm_dev_t *dmv) cv_destroy(&dmv->dev_cv); if (dmv->diskp != NULL) - (void)kmem_free(dmv->diskp, sizeof(struct disk)); + kmem_free(dmv->diskp, sizeof(struct disk)); - (void)kmem_free(dmv, sizeof(dm_dev_t)); + kmem_free(dmv, sizeof(dm_dev_t)); return 0; } Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.12 src/sys/dev/dm/dm_table.c:1.13 --- src/sys/dev/dm/dm_table.c:1.12 Sat Dec 7 15:28:39 2019 +++ src/sys/dev/dm/dm_table.c Sat Dec 14 10:49:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.12 2019/12/07 15:28:39 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.13 2019/12/14 10:49:30 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.12 2019/12/07 15:28:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.13 2019/12/14 10:49:30 tkusumi Exp $"); #include #include @@ -248,7 +248,7 @@ dm_table_disksize(dm_table_head_t *head, secsize = 0; SLIST_FOREACH(table_en, tbl, next) { length += table_en->length; - (void)table_en->target->secsize(table_en, &tsecsize); + table_en->target->secsize(table_en, &tsecsize); if (secsize < tsecsize) secsize = tsecsize; } Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.27 src/sys/dev/dm/dm_target.c:1.28 --- src/sys/dev/dm/dm_target.c:1.27 Fri Dec 13 16:15:54 2019 +++ src/sys/dev/dm/dm_target.c Sat Dec 14 10:49:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.28 2019/12/14 10:49:30 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.28 2019/12/14 10:49:30 tkusumi Exp $"); #include #include @@ -87,7 +87,7 @@ dm_target_autoload(const char *dm_target gen = module_gen; /* Try to autoload target module */ - (void)module_autoload(name, MODULE_CLASS_MISC); + module_autoload(n
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 14 10:02:35 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Remove unconditional debug prints in targets' ->strategy() Having debug prints in ->strategy() by default just to tell ->strategy() is called is overkill. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target_zero.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_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.19 src/sys/dev/dm/dm_target_error.c:1.20 --- src/sys/dev/dm/dm_target_error.c:1.19 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm_target_error.c Sat Dec 14 10:02:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.19 2019/12/12 16:28:24 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.20 2019/12/14 10:02:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.19 2019/12/12 16:28:24 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.20 2019/12/14 10:02:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -133,8 +133,6 @@ int dm_target_error_strategy(dm_table_entry_t *table_en, struct buf *bp) { - printf("Error target read function called!!\n"); - bp->b_error = EIO; bp->b_resid = 0; Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.27 src/sys/dev/dm/dm_target_linear.c:1.28 --- src/sys/dev/dm/dm_target_linear.c:1.27 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm_target_linear.c Sat Dec 14 10:02:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.27 2019/12/12 16:28:24 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.28 2019/12/14 10:02:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.27 2019/12/12 16:28:24 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.28 2019/12/14 10:02:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -114,15 +114,11 @@ dm_target_linear_strategy(dm_table_entry tlc = table_en->target_config; -/* printf("Linear target read function called %" PRIu64 "!!\n", - tlc->offset);*/ - bp->b_blkno += tlc->offset; VOP_STRATEGY(tlc->pdev->pdev_vnode, bp); return 0; - } /* Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.18 src/sys/dev/dm/dm_target_mirror.c:1.19 --- src/sys/dev/dm/dm_target_mirror.c:1.18 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm_target_mirror.c Sat Dec 14 10:02:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.18 2019/12/12 16:28:24 tkusumi Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.19 2019/12/14 10:02:35 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.18 2019/12/12 16:28:24 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.19 2019/12/14 10:02:35 tkusumi Exp $"); /* * This file implements initial version of device-mapper mirror target. @@ -149,8 +149,6 @@ int dm_target_mirror_strategy(dm_table_entry_t *table_en, struct buf *bp) { - printf("Mirror target read function called!!\n"); - bp->b_error = EIO; bp->b_resid = 0; Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.30 src/sys/dev/dm/dm_target_snapshot.c:1.31 --- src/sys/dev/dm/dm_target_snapshot.c:1.30 Thu Dec 12 16:28:24 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Sat Dec 14 10:02:35 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.30 2019/12/12 16:28:24 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.31 2019/12/14 10:02:35 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.30 2019/12/12 16:28:24 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.31 2019/12/14 10:02:35 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 13 16:15:54 UTC 2019 Modified Files: src/sys/dev/dm: dm_target.c Log Message: dm: Don't KASSERT() target handlers Having assertions here causes panic if target is missing anything as shown in "dm: Add dummy target ->sync()/->secsize() to prevent panic on modload(8)". Instead just return EINVAL if a handler(s) isn't implemented. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target.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_target.c diff -u src/sys/dev/dm/dm_target.c:1.26 src/sys/dev/dm/dm_target.c:1.27 --- src/sys/dev/dm/dm_target.c:1.26 Sun Dec 8 10:35:53 2019 +++ src/sys/dev/dm/dm_target.c Fri Dec 13 16:15:54 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.26 2019/12/08 10:35:53 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.26 2019/12/08 10:35:53 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 tkusumi Exp $"); #include #include @@ -156,14 +156,38 @@ dm_target_insert(dm_target_t *dm_target) dm_target_t *dmt; /* Sanity check for any missing function */ - KASSERT(dm_target->init != NULL); - KASSERT(dm_target->status != NULL); - KASSERT(dm_target->strategy != NULL); - KASSERT(dm_target->deps != NULL); - KASSERT(dm_target->destroy != NULL); - KASSERT(dm_target->upcall != NULL); - KASSERT(dm_target->sync != NULL); - KASSERT(dm_target->secsize != NULL); + if (dm_target->init == NULL) { + printf("%s missing init\n", dm_target->name); + return EINVAL; + } + if (dm_target->status == NULL) { + printf("%s missing status\n", dm_target->name); + return EINVAL; + } + if (dm_target->strategy == NULL) { + printf("%s missing strategy\n", dm_target->name); + return EINVAL; + } + if (dm_target->deps == NULL) { + printf("%s missing deps\n", dm_target->name); + return EINVAL; + } + if (dm_target->destroy == NULL) { + printf("%s missing destroy\n", dm_target->name); + return EINVAL; + } + if (dm_target->upcall == NULL) { + printf("%s missing upcall\n", dm_target->name); + return EINVAL; + } + if (dm_target->sync == NULL) { + 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);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 13 15:49:22 UTC 2019 Modified Files: src/sys/dev/dm: dm_pdev.c Log Message: dm: Fix memory leak in dm_pdev_rem() Need to free dmp regardless of dm_pdev_rem() return value. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 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. Modified files: Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.19 src/sys/dev/dm/dm_pdev.c:1.20 --- src/sys/dev/dm/dm_pdev.c:1.19 Sun Dec 8 12:14:40 2019 +++ src/sys/dev/dm/dm_pdev.c Fri Dec 13 15:49:22 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.19 2019/12/08 12:14:40 mlelstv Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.20 2019/12/13 15:49:22 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.19 2019/12/08 12:14:40 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.20 2019/12/13 15:49:22 tkusumi Exp $"); #include #include @@ -174,8 +174,10 @@ dm_pdev_rem(dm_pdev_t *dmp) if (dmp->pdev_vnode != NULL) { int error = vn_close(dmp->pdev_vnode, FREAD | FWRITE, FSCRED); - if (error != 0) + if (error != 0) { + kmem_free(dmp, sizeof(*dmp)); return error; + } } kmem_free(dmp, sizeof(*dmp));
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 12 16:28:24 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Make target's ->init() take parsed argc and argv This gets rid of the same parser code in each target using strsep(3). taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/dev/dm/dm.h cvs rdiff -u -r1.40 -r1.41 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.38 src/sys/dev/dm/dm.h:1.39 --- src/sys/dev/dm/dm.h:1.38 Sun Dec 8 14:59:42 2019 +++ src/sys/dev/dm/dm.h Thu Dec 12 16:28:24 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.38 2019/12/08 14:59:42 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.39 2019/12/12 16:28:24 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -174,7 +174,7 @@ typedef struct target_linear_devs dm_tar typedef struct dm_target { char name[DM_MAX_TYPE_NAME]; /* Initialize target_config area */ - int (*init)(dm_table_entry_t *, char *); + int (*init)(dm_table_entry_t *, int, char **); /* Destroy target_config area */ int (*destroy)(dm_table_entry_t *); @@ -193,6 +193,7 @@ typedef struct dm_target { uint32_t version[3]; uint32_t ref_cnt; + int max_argc; TAILQ_ENTRY(dm_target) dm_target_next; } dm_target_t; @@ -236,7 +237,7 @@ int dm_target_init(void); #define DM_MAX_PARAMS_SIZE 1024 /* dm_target_linear.c */ -int dm_target_linear_init(dm_table_entry_t *, char *); +int dm_target_linear_init(dm_table_entry_t *, int, char **); char *dm_target_linear_status(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); @@ -249,7 +250,7 @@ int dm_target_linear_secsize(dm_table_en uint64_t atoi(const char *); /* dm_target_stripe.c */ -int dm_target_stripe_init(dm_table_entry_t *, char *); +int dm_target_stripe_init(dm_table_entry_t *, int, char **); char *dm_target_stripe_status(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.40 src/sys/dev/dm/dm_ioctl.c:1.41 --- src/sys/dev/dm/dm_ioctl.c:1.40 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm_ioctl.c Thu Dec 12 16:28:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.40 2019/12/08 04:41:02 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.41 2019/12/12 16:28:24 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.40 2019/12/08 04:41:02 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.41 2019/12/12 16:28:24 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -118,6 +118,7 @@ static struct cfdata dm_cfdata = { } while (/*CONSTCOND*/0) static int dm_dbg_print_flags(int); +static int dm_table_init(dm_target_t *, dm_table_entry_t *, char *); /* * Print flags sent to the kernel from libevmapper. @@ -774,13 +775,7 @@ dm_table_load_ioctl(prop_dictionary_t dm else SLIST_INSERT_AFTER(last_table, table_en, next); - /* - * Params string is different for every target, - * therfore I have to pass it to target init - * routine and parse parameters there. - */ - - if ((ret = target->init(table_en, str)) != 0) { + if ((ret = dm_table_init(target, table_en, str)) != 0) { dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE); dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); free(str, M_TEMP); @@ -802,6 +797,41 @@ dm_table_load_ioctl(prop_dictionary_t dm return 0; } +static int +dm_table_init(dm_target_t *target, dm_table_entry_t *table_en, char *params) +{ + int i, n, ret, argc; + char **ap, **argv; + + if (params == NULL) + return EINVAL; + + n = target->max_argc; + if (n) + aprint_debug("Max argc %d for %s target\n", n, target->name); + else + n = 32; /* large enough for most targets */ + + argv = kmem_alloc(sizeof(*argv) * n, KM_SLEEP); + + for (ap = argv; + ap < &argv[n] && (*ap = strsep(¶ms, " \t")) != NULL;) { + if (**ap != '\0') + ap++; + } + argc = ap - argv; + + for (i = 0; i < argc; i++) + aprint_debug("DM: argv[%d] = \"%s\"\n", i, argv[i]); + + KASSERT(target->init
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Wed Dec 11 14:03:37 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Revert "Fix error handling in dmioctl()" for now This change seems to break "deps" in dm ioctl(2) for linear target. Revert the change, will revisit later. https://mail-index.netbsd.org/current-users/2019/12/11/msg037179.html To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 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.48 src/sys/dev/dm/device-mapper.c:1.49 --- src/sys/dev/dm/device-mapper.c:1.48 Mon Dec 9 15:54:59 2019 +++ src/sys/dev/dm/device-mapper.c Wed Dec 11 14:03:37 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.48 2019/12/09 15:54:59 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.49 2019/12/11 14:03:37 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -377,8 +377,8 @@ dmioctl(dev_t dev, const u_long cmd, voi if ((r = dm_cmd_to_fun(dm_dict_in)) != 0) goto cleanup_exit; - r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in); cleanup_exit: + r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in); prop_object_release(dm_dict_in); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 9 16:06:19 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_linear.c Log Message: dm: Silence aprint_normal() in dm_target_linear_status() dm_target_linear_status() shouldn't print this debug message by default on dmsetup "table" ioctl/command. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/dm/dm_target_linear.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_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.25 src/sys/dev/dm/dm_target_linear.c:1.26 --- src/sys/dev/dm/dm_target_linear.c:1.25 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm_target_linear.c Mon Dec 9 16:06:19 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.25 2019/12/08 04:41:02 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.26 2019/12/09 16:06:19 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.25 2019/12/08 04:41:02 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.26 2019/12/09 16:06:19 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -106,7 +106,6 @@ dm_target_linear_status(void *target_con aprint_debug("Linear target status function called\n"); params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP); - aprint_normal("%s %" PRIu64, tlc->pdev->name, tlc->offset); snprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64, tlc->pdev->name, tlc->offset);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 9 15:54:59 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Fix error handling in dmioctl() Looks like cleanup_exit label is in a wrong place. Should skip prop_dictionary_copyout_ioctl() on error. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 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.47 src/sys/dev/dm/device-mapper.c:1.48 --- src/sys/dev/dm/device-mapper.c:1.47 Sat Dec 7 16:13:39 2019 +++ src/sys/dev/dm/device-mapper.c Mon Dec 9 15:54:59 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.47 2019/12/07 16:13:39 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.48 2019/12/09 15:54:59 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -355,20 +355,18 @@ dmioctl(dev_t dev, const u_long cmd, voi int r; prop_dictionary_t dm_dict_in; - r = 0; - aprint_debug("dmioctl called\n"); KASSERT(data != NULL); if ((r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { - struct plistref *pref = (struct plistref *) data; + struct plistref *pref = (struct plistref *)data; /* Check if we were called with NETBSD_DM_IOCTL ioctl otherwise quit. */ if ((r = dm_ioctl_switch(cmd)) != 0) return r; - if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) + if ((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0) return r; @@ -379,8 +377,8 @@ dmioctl(dev_t dev, const u_long cmd, voi if ((r = dm_cmd_to_fun(dm_dict_in)) != 0) goto cleanup_exit; -cleanup_exit: r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in); +cleanup_exit: prop_object_release(dm_dict_in); }
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 9 15:30:42 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_stripe.c Log Message: dm: Correct target name "stripe" -> "striped" Sync with Linux kernel. The file name is "stripe", but the target name is "striped". DragonFlyBSD also follows this. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 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. Modified files: Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.32 src/sys/dev/dm/dm_target_stripe.c:1.33 --- src/sys/dev/dm/dm_target_stripe.c:1.32 Sun Dec 8 10:50:21 2019 +++ src/sys/dev/dm/dm_target_stripe.c Mon Dec 9 15:30:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.32 2019/12/08 10:50:21 tkusumi Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.33 2019/12/09 15:30:42 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.32 2019/12/08 10:50:21 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.33 2019/12/09 15:30:42 tkusumi Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -73,11 +73,11 @@ dm_target_stripe_modcmd(modcmd_t cmd, vo switch (cmd) { case MODULE_CMD_INIT: - if ((dmt = dm_target_lookup("stripe")) != NULL) { + if ((dmt = dm_target_lookup("striped")) != NULL) { dm_target_unbusy(dmt); return EEXIST; } - dmt = dm_target_alloc("stripe"); + dmt = dm_target_alloc("striped"); dmt->version[0] = 1; dmt->version[1] = 0; @@ -96,7 +96,7 @@ dm_target_stripe_modcmd(modcmd_t cmd, vo break; case MODULE_CMD_FINI: - r = dm_target_rem("stripe"); + r = dm_target_rem("striped"); break; case MODULE_CMD_STAT:
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 8 14:59:42 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_target_error.c dm_target_mirror.c dm_target_snapshot.c dm_target_zero.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/dev/dm/dm.h cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.37 src/sys/dev/dm/dm.h:1.38 --- src/sys/dev/dm/dm.h:1.37 Sun Dec 8 10:50:21 2019 +++ src/sys/dev/dm/dm.h Sun Dec 8 14:59:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.37 2019/12/08 10:50:21 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.38 2019/12/08 14:59:42 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -293,6 +293,13 @@ 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 *secsizep) +{ + return 0; +} + #endif /*_KERNEL*/ #endif /*_DM_DEV_H_*/ Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.17 src/sys/dev/dm/dm_target_error.c:1.18 --- src/sys/dev/dm/dm_target_error.c:1.17 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm_target_error.c Sun Dec 8 14:59:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.18 2019/12/08 14:59:42 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.18 2019/12/08 14:59:42 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -88,6 +88,7 @@ dm_target_error_modcmd(modcmd_t cmd, voi 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); Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.16 src/sys/dev/dm/dm_target_mirror.c:1.17 --- src/sys/dev/dm/dm_target_mirror.c:1.16 Sun Dec 8 10:50:21 2019 +++ src/sys/dev/dm/dm_target_mirror.c Sun Dec 8 14:59:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.17 2019/12/08 14:59:42 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.17 2019/12/08 14:59:42 tkusumi Exp $"); /* * This file implements initial version of device-mapper mirror target. @@ -100,6 +100,7 @@ dm_target_mirror_modcmd(modcmd_t cmd, vo 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); Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.28 src/sys/dev/dm/dm_target_snapshot.c:1.29 --- src/sys/dev/dm/dm_target_snapshot.c:1.28 Sun Dec 8 10:50:21 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Sun Dec 8 14:59:42 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.29 2019/12/08 14:59:42 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.29 2019/12/08 14:59:42 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@ -90,6 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_sn int dm_target_snapshot_init(dm_table_entry_t *, char *); char *dm_target_snapshot_status(void *); int dm_target_snapshot_strategy(dm_table_entry_t *, struct buf *); +int dm_target_snapshot_sync(dm_table_entry_t *); int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t); int dm_target_snapshot_destroy(dm
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 8 10:50:21 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c Log Message: dm: Move targets specific structs to .c files These don't need to be defined and exposed in dm.h. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm.h cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.31 -r1.32 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. Modified files: Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.36 src/sys/dev/dm/dm.h:1.37 --- src/sys/dev/dm/dm.h:1.36 Sun Dec 8 10:35:53 2019 +++ src/sys/dev/dm/dm.h Sun Dec 8 10:50:21 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.36 2019/12/08 10:35:53 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.37 2019/12/08 10:50:21 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -170,45 +170,6 @@ TAILQ_HEAD(target_linear_devs, target_li typedef struct target_linear_devs dm_target_linear_devs_t; -/* for stripe : */ -typedef struct target_stripe_config { -#define DM_STRIPE_DEV_OFFSET 2 - struct target_linear_devs stripe_devs; - uint8_t stripe_num; - uint64_t stripe_chunksize; - size_t params_len; -} dm_target_stripe_config_t; - -/* for mirror : */ -typedef struct target_mirror_config { -#define MAX_MIRROR_COPIES 4 - dm_pdev_t *orig; - dm_pdev_t *copies[MAX_MIRROR_COPIES]; - - /* copied blocks bitmaps administration etc*/ - dm_pdev_t *log_pdev; /* for administration */ - uint64_t log_regionsize; /* blocksize of mirror */ - - /* list of parts that still need copied etc.; run length encoded? */ -} dm_target_mirror_config_t; - - -/* for snapshot : */ -typedef struct target_snapshot_config { - dm_pdev_t *tsc_snap_dev; - /* cow dev is set only for persistent snapshot devices */ - dm_pdev_t *tsc_cow_dev; - - uint64_t tsc_chunk_size; - uint32_t tsc_persistent_dev; -} dm_target_snapshot_config_t; - -/* for snapshot-origin devices */ -typedef struct target_snapshot_origin_config { - dm_pdev_t *tsoc_real_dev; - /* list of snapshots ? */ -} dm_target_snapshot_origin_config_t; - /* constant dm_target structures for error, zero, linear, stripes etc. */ typedef struct dm_target { char name[DM_MAX_TYPE_NAME]; Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.15 src/sys/dev/dm/dm_target_mirror.c:1.16 --- src/sys/dev/dm/dm_target_mirror.c:1.15 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm_target_mirror.c Sun Dec 8 10:50:21 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.15 2019/12/08 04:41:02 tkusumi Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.15 2019/12/08 04:41:02 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.16 2019/12/08 10:50:21 tkusumi Exp $"); /* * This file implements initial version of device-mapper mirror target. @@ -50,6 +50,18 @@ int dm_target_mirror_deps(dm_table_entry int dm_target_mirror_destroy(dm_table_entry_t *); int dm_target_mirror_upcall(dm_table_entry_t *, struct buf *); +typedef struct target_mirror_config { +#define MAX_MIRROR_COPIES 4 + dm_pdev_t *orig; + dm_pdev_t *copies[MAX_MIRROR_COPIES]; + + /* copied blocks bitmaps administration etc*/ + dm_pdev_t *log_pdev; /* for administration */ + uint64_t log_regionsize; /* blocksize of mirror */ + + /* list of parts that still need copied etc.; run length encoded? */ +} dm_target_mirror_config_t; + #ifdef DM_TARGET_MODULE /* * Every target can be compiled directly to dm driver or as a Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.27 src/sys/dev/dm/dm_target_snapshot.c:1.28 --- src/sys/dev/dm/dm_target_snapshot.c:1.27 Sun Dec 8 10:35:53 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Sun Dec 8 10:50:21 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.28 2019/12/08 10:50:21 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@ -103,6 +103,20 @@ int dm_target_snapshot_orig_deps(dm_tabl int dm_target_snapshot_orig_destroy(dm_table_entry_t *); int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); +typed
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 8 10:35:53 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_target.c dm_target_snapshot.c Log Message: dm: Unbreak compilation of kernel modules The dm kernel modules (MK_DM_TARGETS enabled in sys/modules/dm/Makefile) have been broken. Unbreak the build. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm.h cvs rdiff -u -r1.25 -r1.26 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target_snapshot.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.h diff -u src/sys/dev/dm/dm.h:1.35 src/sys/dev/dm/dm.h:1.36 --- src/sys/dev/dm/dm.h:1.35 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm.h Sun Dec 8 10:35:53 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.35 2019/12/08 04:41:02 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.36 2019/12/08 10:35:53 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -265,7 +265,7 @@ int dm_target_destroy(void); int dm_target_insert(dm_target_t *); prop_array_t dm_target_prop_list(void); dm_target_t* dm_target_lookup(const char *); -int dm_target_rem(char *); +int dm_target_rem(const char *); void dm_target_unbusy(dm_target_t *); void dm_target_busy(dm_target_t *); Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.25 src/sys/dev/dm/dm_target.c:1.26 --- src/sys/dev/dm/dm_target.c:1.25 Sat Dec 7 15:28:39 2019 +++ src/sys/dev/dm/dm_target.c Sun Dec 8 10:35:53 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.25 2019/12/07 15:28:39 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.26 2019/12/08 10:35:53 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.25 2019/12/07 15:28:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.26 2019/12/08 10:35:53 tkusumi Exp $"); #include #include @@ -183,7 +183,7 @@ dm_target_insert(dm_target_t *dm_target) * Remove target from TAIL, target is selected with its name. */ int -dm_target_rem(char *dm_target_name) +dm_target_rem(const char *dm_target_name) { dm_target_t *dmt; Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.26 src/sys/dev/dm/dm_target_snapshot.c:1.27 --- src/sys/dev/dm/dm_target_snapshot.c:1.26 Sun Dec 8 04:41:02 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Sun Dec 8 10:35:53 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.26 2019/12/08 04:41:02 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.26 2019/12/08 04:41:02 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.27 2019/12/08 10:35:53 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@ -240,8 +240,6 @@ dm_target_snapshot_init(dm_table_entry_t table_en->target_config = tsc; - dmv->sec_size = dmp_snap->dmp_secsize; - return 0; } @@ -258,14 +256,13 @@ dm_target_snapshot_status(void *target_c uint32_t i; uint32_t count; size_t prm_len, cow_len; - char *params, *cow_name; + char *params; tsc = target_config; prm_len = 0; cow_len = 0; count = 0; - cow_name = NULL; printf("Snapshot target status function called\n");
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 8 04:41:02 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Refactor target's ->init() i/f Take dm_table_entry_t* instead of void**. Remove dm_dev_t* unneeded by target code. No functional change, but for future changes. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/dev/dm/dm.h cvs rdiff -u -r1.39 -r1.40 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_target_zero.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.h diff -u src/sys/dev/dm/dm.h:1.34 src/sys/dev/dm/dm.h:1.35 --- src/sys/dev/dm/dm.h:1.34 Sat Dec 7 15:28:39 2019 +++ src/sys/dev/dm/dm.h Sun Dec 8 04:41:02 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.34 2019/12/07 15:28:39 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.35 2019/12/08 04:41:02 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -213,7 +213,7 @@ typedef struct target_snapshot_origin_co typedef struct dm_target { char name[DM_MAX_TYPE_NAME]; /* Initialize target_config area */ - int (*init)(dm_dev_t *, void **, char *); + int (*init)(dm_table_entry_t *, char *); /* Destroy target_config area */ int (*destroy)(dm_table_entry_t *); @@ -275,7 +275,7 @@ int dm_target_init(void); #define DM_MAX_PARAMS_SIZE 1024 /* dm_target_linear.c */ -int dm_target_linear_init(dm_dev_t *, void**, char *); +int dm_target_linear_init(dm_table_entry_t *, char *); char *dm_target_linear_status(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); @@ -288,7 +288,7 @@ int dm_target_linear_secsize(dm_table_en uint64_t atoi(const char *); /* dm_target_stripe.c */ -int dm_target_stripe_init(dm_dev_t *, void**, char *); +int dm_target_stripe_init(dm_table_entry_t *, char *); char *dm_target_stripe_status(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.39 src/sys/dev/dm/dm_ioctl.c:1.40 --- src/sys/dev/dm/dm_ioctl.c:1.39 Fri Dec 6 16:33:47 2019 +++ src/sys/dev/dm/dm_ioctl.c Sun Dec 8 04:41:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.39 2019/12/06 16:33:47 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.40 2019/12/08 04:41:02 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.39 2019/12/06 16:33:47 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.40 2019/12/08 04:41:02 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -780,8 +780,7 @@ dm_table_load_ioctl(prop_dictionary_t dm * routine and parse parameters there. */ - if ((ret = target->init(dmv, &table_en->target_config, - str)) != 0) { + if ((ret = target->init(table_en, str)) != 0) { dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE); dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); free(str, M_TEMP); Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.16 src/sys/dev/dm/dm_target_error.c:1.17 --- src/sys/dev/dm/dm_target_error.c:1.16 Sat Dec 7 15:28:39 2019 +++ src/sys/dev/dm/dm_target_error.c Sun Dec 8 04:41:02 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.16 2019/12/07 15:28:39 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.16 2019/12/07 15:28:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.17 2019/12/08 04:41:02 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_er #include "dm.h" /* dm_target_error.c */ -int dm_target_error_init(dm_dev_t *, void**, char *); +int dm_target_error_init(dm_table_entry_t*, char *); char *dm_target_error_status(void *); int dm_target_error_strategy(dm_table_entry_t *, struct buf *); int dm_target_error_sync(dm_table_entry_t *); @@ -110,12 +110,12 @@ dm_target_error_modcmd(modcmd_t cmd, vo
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 7 16:13:39 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Fix indentation To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/dev/dm/device-mapper.c:1.47 --- src/sys/dev/dm/device-mapper.c:1.46 Fri Dec 6 16:33:47 2019 +++ src/sys/dev/dm/device-mapper.c Sat Dec 7 16:13:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.46 2019/12/06 16:33:47 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.47 2019/12/07 16:13:39 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -149,7 +149,7 @@ static const struct cmd_function { { .cmd = "reload", .fn = dm_table_load_ioctl,.allowed = 0 }, { .cmd = "status", .fn = dm_table_status_ioctl, .allowed = 1 }, { .cmd = "table", .fn = dm_table_status_ioctl, .allowed = 1 }, - { .cmd = NULL, .fn = NULL, .allowed = 0 } + { .cmd = NULL, .fn = NULL, .allowed = 0 }, }; #ifdef _MODULE @@ -431,18 +431,17 @@ dm_ioctl_switch(u_long cmd) aprint_debug("dm NETBSD_DM_IOCTL called\n"); break; default: - aprint_debug("dm unknown ioctl called\n"); - return ENOTTY; - break; /* NOT REACHED */ + aprint_debug("dm unknown ioctl called\n"); + return ENOTTY; + break; /* NOT REACHED */ } - return 0; + return 0; } - /* - * Check for disk specific ioctls. - */ - +/* + * Check for disk specific ioctls. + */ static int disk_ioctl_switch(dev_t dev, u_long cmd, void *data) {
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 7 15:28:39 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_dev.c dm_pdev.c dm_table.c dm_target.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c src/sys/dev/dm/doc: locking.txt Log Message: dm: Fix strange pointer declarations Should be "type *name" or "type* name", but not "type * name". taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm.h cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/dm_dev.c \ src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/dm_pdev.c \ src/sys/dev/dm/dm_target_zero.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/dm/dm_target.c \ src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.2 -r1.3 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.33 src/sys/dev/dm/dm.h:1.34 --- src/sys/dev/dm/dm.h:1.33 Thu Dec 5 15:52:39 2019 +++ src/sys/dev/dm/dm.h Sat Dec 7 15:28:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.33 2019/12/05 15:52:39 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.34 2019/12/07 15:28:39 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -276,7 +276,7 @@ int dm_target_init(void); /* dm_target_linear.c */ int dm_target_linear_init(dm_dev_t *, void**, char *); -char * dm_target_linear_status(void *); +char *dm_target_linear_status(void *); int dm_target_linear_strategy(dm_table_entry_t *, struct buf *); int dm_target_linear_sync(dm_table_entry_t *); int dm_target_linear_deps(dm_table_entry_t *, prop_array_t); @@ -289,7 +289,7 @@ uint64_t atoi(const char *); /* dm_target_stripe.c */ int dm_target_stripe_init(dm_dev_t *, void**, char *); -char * dm_target_stripe_status(void *); +char *dm_target_stripe_status(void *); int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *); int dm_target_stripe_sync(dm_table_entry_t *); int dm_target_stripe_deps(dm_table_entry_t *, prop_array_t); @@ -305,7 +305,7 @@ int dm_table_destroy(dm_table_head_t *, uint64_t dm_table_size(dm_table_head_t *); uint64_t dm_inactive_table_size(dm_table_head_t *); void dm_table_disksize(dm_table_head_t *, uint64_t *, unsigned *); -dm_table_t * dm_table_get_entry(dm_table_head_t *, uint8_t); +dm_table_t *dm_table_get_entry(dm_table_head_t *, uint8_t); int dm_table_get_target_count(dm_table_head_t *, uint8_t); void dm_table_release(dm_table_head_t *, uint8_t s); void dm_table_switch_tables(dm_table_head_t *); Index: src/sys/dev/dm/dm_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.13 src/sys/dev/dm/dm_dev.c:1.14 --- src/sys/dev/dm/dm_dev.c:1.13 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/dm_dev.c Sat Dec 7 15:28:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.13 2019/12/04 15:31:12 tkusumi Exp $ */ +/*$NetBSD: dm_dev.c,v 1.14 2019/12/07 15:28:39 tkusumi 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.13 2019/12/04 15:31:12 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.14 2019/12/07 15:28:39 tkusumi Exp $"); #include #include @@ -54,7 +54,7 @@ static kmutex_t dm_dev_mutex; /* dm_dev_mutex must be holdby caller before using disable_dev. */ __inline static void -disable_dev(dm_dev_t * dmv) +disable_dev(dm_dev_t *dmv) { TAILQ_REMOVE(&dm_dev_list, dmv, next_devlist); mutex_enter(&dmv->dev_mtx); @@ -175,7 +175,7 @@ dm_dev_lookup_uuid(const char *dm_dev_uu * Insert new device to the global list of devices. */ int -dm_dev_insert(dm_dev_t * dev) +dm_dev_insert(dm_dev_t *dev) { dm_dev_t *dmv; int r; @@ -331,7 +331,7 @@ dm_dev_alloc(void) * Freed device entry. */ int -dm_dev_free(dm_dev_t * dmv) +dm_dev_free(dm_dev_t *dmv) { KASSERT(dmv != NULL); @@ -348,7 +348,7 @@ dm_dev_free(dm_dev_t * dmv) } void -dm_dev_busy(dm_dev_t * dmv) +dm_dev_busy(dm_dev_t *dmv) { mutex_enter(&dmv->dev_mtx); dmv->ref_cnt++; @@ -356,7 +356,7 @@ dm_dev_busy(dm_dev_t * dmv) } void -dm_dev_unbusy(dm_dev_t * dmv) +dm_dev_unbusy(dm_dev_t *dmv) { KASSERT(dmv->ref_cnt != 0); Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.13 src/sys/dev/dm/dm_target_mirror.c:1.14 --- src/sys/dev/dm/dm_target_mirror.c:1.13 Fri Dec 6 16:11:59 2019 +++ src/sys/dev/dm/dm_target_mirror.c Sat Dec 7 15:28:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $*/ +/*$NetBSD:
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sat Dec 7 06:26:31 UTC 2019 Modified Files: src/sys/dev/dm: dm_pdev.c dm_table.c dm_target.c Log Message: dm: Simplify list eviction code taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target.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_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.16 src/sys/dev/dm/dm_pdev.c:1.17 --- src/sys/dev/dm/dm_pdev.c:1.16 Fri Dec 6 16:46:14 2019 +++ src/sys/dev/dm/dm_pdev.c Sat Dec 7 06:26:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $"); #include #include @@ -188,16 +188,16 @@ dm_pdev_rem(dm_pdev_t * dmp) int dm_pdev_destroy(void) { - dm_pdev_t *dm_pdev; + dm_pdev_t *dmp; mutex_enter(&dm_pdev_mutex); - while (!SLIST_EMPTY(&dm_pdev_list)) { /* List Deletion. */ - dm_pdev = SLIST_FIRST(&dm_pdev_list); - - SLIST_REMOVE_HEAD(&dm_pdev_list, next_pdev); - dm_pdev_rem(dm_pdev); + while ((dmp = SLIST_FIRST(&dm_pdev_list)) != NULL) { + SLIST_REMOVE(&dm_pdev_list, dmp, dm_pdev, next_pdev); + dm_pdev_rem(dmp); } + KASSERT(SLIST_EMPTY(&dm_pdev_list)); + mutex_exit(&dm_pdev_mutex); mutex_destroy(&dm_pdev_mutex); Index: src/sys/dev/dm/dm_table.c diff -u src/sys/dev/dm/dm_table.c:1.10 src/sys/dev/dm/dm_table.c:1.11 --- src/sys/dev/dm/dm_table.c:1.10 Thu Dec 5 16:59:43 2019 +++ src/sys/dev/dm/dm_table.c Sat Dec 7 06:26:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $"); #include #include @@ -160,15 +160,14 @@ dm_table_destroy(dm_table_head_t * head, tbl = &head->tables[id]; - while (!SLIST_EMPTY(tbl)) { /* List Deletion. */ - table_en = SLIST_FIRST(tbl); + while ((table_en = SLIST_FIRST(tbl)) != NULL) { + SLIST_REMOVE(tbl, table_en, dm_table_entry, next); if (table_en->target->destroy(table_en) == 0) table_en->target_config = NULL; - SLIST_REMOVE_HEAD(tbl, next); - kmem_free(table_en, sizeof(*table_en)); } + KASSERT(SLIST_EMPTY(tbl)); mutex_exit(&head->table_mtx); Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.23 src/sys/dev/dm/dm_target.c:1.24 --- src/sys/dev/dm/dm_target.c:1.23 Fri Dec 6 16:11:59 2019 +++ src/sys/dev/dm/dm_target.c Sat Dec 7 06:26:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $"); #include #include @@ -220,14 +220,13 @@ dm_target_destroy(void) dm_target_t *dm_target; mutex_enter(&dm_target_mutex); - while (TAILQ_FIRST(&dm_target_list) != NULL) { - dm_target = TAILQ_FIRST(&dm_target_list); - - TAILQ_REMOVE(&dm_target_list, TAILQ_FIRST(&dm_target_list), - dm_target_next); + while ((dm_target = TAILQ_FIRST(&dm_target_list)) != NULL) { + TAILQ_REMOVE(&dm_target_list, dm_target, dm_target_next); (void)kmem_free(dm_target, sizeof(dm_target_t)); } + KASSERT(TAILQ_EMPTY(&dm_target_list)); + mutex_exit(&dm_target_mutex); mutex_destroy(&dm_target_mutex);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 6 16:46:14 UTC 2019 Modified Files: src/sys/dev/dm: dm_pdev.c dm_target_linear.c dm_target_zero.c netbsd-dm.h Log Message: dm: Remove trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_target_zero.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/dm/netbsd-dm.h 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_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.15 src/sys/dev/dm/dm_pdev.c:1.16 --- src/sys/dev/dm/dm_pdev.c:1.15 Wed Dec 4 16:55:30 2019 +++ src/sys/dev/dm/dm_pdev.c Fri Dec 6 16:46:14 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $"); #include #include @@ -240,15 +240,14 @@ static int dm_pdev_dump_list(void) { dm_pdev_t *dmp; - + aprint_verbose("Dumping dm_pdev_list\n"); - + SLIST_FOREACH(dmp, &dm_pdev_list, next_pdev) { aprint_verbose("dm_pdev_name %s ref_cnt %d list_rf_cnt %d\n", dmp->name, dmp->ref_cnt, dmp->list_ref_cnt); } - + return 0; - } #endif Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.22 src/sys/dev/dm/dm_target_linear.c:1.23 --- src/sys/dev/dm/dm_target_linear.c:1.22 Thu Dec 5 16:59:43 2019 +++ src/sys/dev/dm/dm_target_linear.c Fri Dec 6 16:46:14 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.23 2019/12/06 16:46:14 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.23 2019/12/06 16:46:14 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -146,9 +146,9 @@ dm_target_linear_sync(dm_table_entry_t * tlc = table_en->target_config; cmd = 1; - + return VOP_IOCTL(tlc->pdev->pdev_vnode, DIOCCACHESYNC, &cmd, - FREAD|FWRITE, kauth_cred_get()); + FREAD|FWRITE, kauth_cred_get()); } /* Index: src/sys/dev/dm/dm_target_zero.c diff -u src/sys/dev/dm/dm_target_zero.c:1.16 src/sys/dev/dm/dm_target_zero.c:1.17 --- src/sys/dev/dm/dm_target_zero.c:1.16 Fri Dec 6 16:11:59 2019 +++ src/sys/dev/dm/dm_target_zero.c Fri Dec 6 16:46:14 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $ */ +/*$NetBSD: dm_target_zero.c,v 1.17 2019/12/06 16:46:14 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.17 2019/12/06 16:46:14 tkusumi Exp $"); /* * This file implements initial version of device-mapper zero target. @@ -84,7 +84,7 @@ dm_target_zero_modcmd(modcmd_t cmd, void dmt->init = &dm_target_zero_init; dmt->status = &dm_target_zero_status; dmt->strategy = &dm_target_zero_strategy; - dmt->sync = &dm_target_zero_sync; + dmt->sync = &dm_target_zero_sync; dmt->deps = &dm_target_zero_deps; dmt->destroy = &dm_target_zero_destroy; dmt->upcall = &dm_target_zero_upcall; Index: src/sys/dev/dm/netbsd-dm.h diff -u src/sys/dev/dm/netbsd-dm.h:1.9 src/sys/dev/dm/netbsd-dm.h:1.10 --- src/sys/dev/dm/netbsd-dm.h:1.9 Tue Dec 3 15:03:14 2019 +++ src/sys/dev/dm/netbsd-dm.h Fri Dec 6 16:46:14 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: netbsd-dm.h,v 1.9 2019/12/03 15:03:14 tkusumi Exp $ */ +/*$NetBSD: netbsd-dm.h,v 1.10 2019/12/06 16:46:14 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ * ... * * dev - * + * * * flags * @@ -110,7 +110,7 @@ */ /* - * DM_DEV_LIST == "names" + * DM_DEV_LIST == "names" * Request list of device-mapper created devices from kernel. * * @@ -128,7 +128,7 @@ */ /* - * DM_DEV_RENAME == "rename" + * DM_DEV_RENAME == "rename" * Rename device to string. * * @@ -138,14 +138,14 @@ */ /* - * DM_DEV_STATUS == "info, mknodes" + * DM_DEV_STATUS == "info, mknodes" * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary,
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 6 16:33:47 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_ioctl.c dm_target_stripe.c Log Message: dm: Fix typos in comments/messages taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.28 -r1.29 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. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.45 src/sys/dev/dm/device-mapper.c:1.46 --- src/sys/dev/dm/device-mapper.c:1.45 Thu Dec 5 15:52:39 2019 +++ src/sys/dev/dm/device-mapper.c Fri Dec 6 16:33:47 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.45 2019/12/05 15:52:39 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.46 2019/12/06 16:33:47 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -428,7 +428,7 @@ dm_ioctl_switch(u_long cmd) switch(cmd) { case NETBSD_DM_IOCTL: - aprint_debug("dm NetBSD_DM_IOCTL called\n"); + aprint_debug("dm NETBSD_DM_IOCTL called\n"); break; default: aprint_debug("dm unknown ioctl called\n"); @@ -637,9 +637,9 @@ dmstrategy(struct buf *bp) PRIu64"\n", buf_start, buf_len); aprint_debug("start-buf_start %010"PRIu64", end %010" PRIu64"\n", start - buf_start, end); - aprint_debug("start %010" PRIu64" , end %010" + aprint_debug("start %010" PRIu64", end %010" PRIu64"\n", start, end); - aprint_debug("\n\n"); + aprint_debug("\n"); if (start < end) { /* create nested buffer */ Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.38 src/sys/dev/dm/dm_ioctl.c:1.39 --- src/sys/dev/dm/dm_ioctl.c:1.38 Thu Dec 5 15:52:39 2019 +++ src/sys/dev/dm/dm_ioctl.c Fri Dec 6 16:33:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.38 2019/12/05 15:52:39 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.39 2019/12/06 16:33:47 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.38 2019/12/05 15:52:39 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.39 2019/12/06 16:33:47 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -131,10 +131,10 @@ dm_dbg_print_flags(int flags) aprint_debug("dbg_flags: DM_READONLY_FLAG set In/Out\n"); if (flags & DM_SUSPEND_FLAG) - aprint_debug("dbg_flags: DM_SUSPEND_FLAG set In/Out \n"); + aprint_debug("dbg_flags: DM_SUSPEND_FLAG set In/Out\n"); if (flags & DM_PERSISTENT_DEV_FLAG) - aprint_debug("db_flags: DM_PERSISTENT_DEV_FLAG set In\n"); + aprint_debug("dbg_flags: DM_PERSISTENT_DEV_FLAG set In\n"); if (flags & DM_STATUS_TABLE_FLAG) aprint_debug("dbg_flags: DM_STATUS_TABLE_FLAG set In\n"); Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.28 src/sys/dev/dm/dm_target_stripe.c:1.29 --- src/sys/dev/dm/dm_target_stripe.c:1.28 Fri Dec 6 16:11:59 2019 +++ src/sys/dev/dm/dm_target_stripe.c Fri Dec 6 16:33:47 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.29 2019/12/06 16:33:47 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.29 2019/12/06 16:33:47 tkusumi Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -241,11 +241,11 @@ dm_target_stripe_strategy(dm_table_entry blkoff = 0; num_blks = bp->b_resid / DEV_BSIZE; for (;;) { - /* blockno to strip piece nr */ + /* blockno to stripe piece nr */ stripe = blkno / tsc->stripe_chunksize; stripe_off = blkno % tsc->stripe_chunksize; - /* where we are inside the strip */ + /* where we are inside the stripe */ stripe_devnr = stripe % tsc->stripe_num; stripe_blknr = stripe / tsc->stripe_num;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Fri Dec 6 16:11:59 UTC 2019 Modified Files: src/sys/dev/dm: dm_target.c dm_target_error.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Don't ignore dm_target_alloc() argument dm_target_alloc() is supposed to be copying the name argument to its ->name. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_target_zero.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_target.c diff -u src/sys/dev/dm/dm_target.c:1.22 src/sys/dev/dm/dm_target.c:1.23 --- src/sys/dev/dm/dm_target.c:1.22 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/dm_target.c Fri Dec 6 16:11:59 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $ */ +/*$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $"); #include #include @@ -241,7 +241,16 @@ dm_target_destroy(void) dm_target_t * dm_target_alloc(const char *name) { - return kmem_zalloc(sizeof(dm_target_t), KM_SLEEP); + dm_target_t *dmt; + + dmt = kmem_zalloc(sizeof(dm_target_t), KM_SLEEP); + if (dmt == NULL) + return NULL; + + if (name) + strlcpy(dmt->name, name, sizeof(dmt->name)); + + return dmt; } /* @@ -298,7 +307,6 @@ dm_target_init(void) dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 2; - strlcpy(dmt->name, "linear", DM_MAX_TYPE_NAME); dmt->init = &dm_target_linear_init; dmt->status = &dm_target_linear_status; dmt->strategy = &dm_target_linear_strategy; @@ -313,7 +321,6 @@ dm_target_init(void) dmt3->version[0] = 1; dmt3->version[1] = 0; dmt3->version[2] = 3; - strlcpy(dmt3->name, "striped", DM_MAX_TYPE_NAME); dmt3->init = &dm_target_stripe_init; dmt3->status = &dm_target_stripe_status; dmt3->strategy = &dm_target_stripe_strategy; Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.14 src/sys/dev/dm/dm_target_error.c:1.15 --- src/sys/dev/dm/dm_target_error.c:1.14 Thu Dec 5 16:59:43 2019 +++ src/sys/dev/dm/dm_target_error.c Fri Dec 6 16:11:59 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -81,7 +81,6 @@ dm_target_error_modcmd(modcmd_t cmd, voi dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 0; - strlcpy(dmt->name, "error", DM_MAX_TYPE_NAME); dmt->init = &dm_target_error_init; dmt->status = &dm_target_error_status; dmt->strategy = &dm_target_error_strategy; Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.12 src/sys/dev/dm/dm_target_mirror.c:1.13 --- src/sys/dev/dm/dm_target_mirror.c:1.12 Thu Dec 5 16:59:43 2019 +++ src/sys/dev/dm/dm_target_mirror.c Fri Dec 6 16:11:59 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $"); /* * This file implements initial version of device-mapper mirror target. @@ -81,7 +81,6 @@ dm_target_mirror_modcmd(modcmd_t cmd, vo dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 0; - strlcpy(dmt->name, "mirror", DM_MAX_TYPE_NAME); dmt->init = &dm_target_mirror_init; dmt->status = &dm_target_mirror_status; dmt->strategy = &dm_target_mirror_strategy; Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.23 src/sys/dev/dm/dm_target_snapshot.c:1.24 --- src/sys/dev/dm/dm_target_sna
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 5 16:59:43 UTC 2019 Modified Files: src/sys/dev/dm: dm_table.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c Log Message: dm: Make dm core set config to NULL after destroy Just let dm core do this instead of having a comment expecting each target to do the right thing. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_target_zero.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_table.c diff -u src/sys/dev/dm/dm_table.c:1.9 src/sys/dev/dm/dm_table.c:1.10 --- src/sys/dev/dm/dm_table.c:1.9 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/dm_table.c Thu Dec 5 16:59:43 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_table.c,v 1.9 2019/12/04 15:31:12 tkusumi Exp $ */ +/*$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.9 2019/12/04 15:31:12 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $"); #include #include @@ -162,11 +162,8 @@ dm_table_destroy(dm_table_head_t * head, while (!SLIST_EMPTY(tbl)) { /* List Deletion. */ table_en = SLIST_FIRST(tbl); - /* - * Remove target specific config data. After successfull - * call table_en->target_config must be set to NULL. - */ - table_en->target->destroy(table_en); + if (table_en->target->destroy(table_en) == 0) + table_en->target_config = NULL; SLIST_REMOVE_HEAD(tbl, next); Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.13 src/sys/dev/dm/dm_target_error.c:1.14 --- src/sys/dev/dm/dm_target_error.c:1.13 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm_target_error.c Thu Dec 5 16:59:43 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.13 2019/12/01 06:53:31 tkusumi Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.13 2019/12/01 06:53:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -155,8 +155,6 @@ dm_target_error_sync(dm_table_entry_t * int dm_target_error_destroy(dm_table_entry_t * table_en) { - table_en->target_config = NULL; - /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.21 src/sys/dev/dm/dm_target_linear.c:1.22 --- src/sys/dev/dm/dm_target_linear.c:1.21 Tue Dec 3 15:47:38 2019 +++ src/sys/dev/dm/dm_target_linear.c Thu Dec 5 16:59:43 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.21 2019/12/03 15:47:38 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.21 2019/12/03 15:47:38 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -166,7 +166,6 @@ dm_target_linear_destroy(dm_table_entry_ goto out; dm_target_linear_config_t *tlc = table_en->target_config; - table_en->target_config = NULL; /* Decrement pdev ref counter if 0 remove it */ dm_pdev_decr(tlc->pdev); Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.11 src/sys/dev/dm/dm_target_mirror.c:1.12 --- src/sys/dev/dm/dm_target_mirror.c:1.11 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm_target_mirror.c Thu Dec 5 16:59:43 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.11 2019/12/01 06:53:31 tkusumi Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.11 2019/12/01 06:53:31 tkusumi Exp $"); +__KERNEL_R
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Thu Dec 5 15:52:39 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h dm_ioctl.c Log Message: dm: Remove unneeded dm_get_version_ioctl() "version" is implemented and handled in userspace, hence dm ioctl doesn't need to support it. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/dm/dm.h cvs rdiff -u -r1.37 -r1.38 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.44 src/sys/dev/dm/device-mapper.c:1.45 --- src/sys/dev/dm/device-mapper.c:1.44 Wed Dec 4 16:55:30 2019 +++ src/sys/dev/dm/device-mapper.c Thu Dec 5 15:52:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.44 2019/12/04 16:55:30 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.45 2019/12/05 15:52:39 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -134,7 +134,7 @@ static const struct cmd_function { int (*fn)(prop_dictionary_t); int allowed; } cmd_fn[] = { - { .cmd = "version", .fn = dm_get_version_ioctl, .allowed = 1 }, + { .cmd = "version", .fn = NULL, .allowed = 1 }, { .cmd = "targets", .fn = dm_list_versions_ioctl, .allowed = 1 }, { .cmd = "create", .fn = dm_dev_create_ioctl,.allowed = 0 }, { .cmd = "info",.fn = dm_dev_status_ioctl,.allowed = 1 }, @@ -413,7 +413,9 @@ dm_cmd_to_fun(prop_dictionary_t dm_dict) if (cmd_fn[i].cmd == NULL) return EINVAL; - aprint_debug("ioctl %s called\n", cmd_fn[i].cmd); + aprint_debug("ioctl %s called %p\n", cmd_fn[i].cmd, cmd_fn[i].fn); + if (cmd_fn[i].fn == NULL) + return 0; r = cmd_fn[i].fn(dm_dict); return r; Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.32 src/sys/dev/dm/dm.h:1.33 --- src/sys/dev/dm/dm.h:1.32 Wed Dec 4 16:54:03 2019 +++ src/sys/dev/dm/dm.h Thu Dec 5 15:52:39 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.32 2019/12/04 16:54:03 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.33 2019/12/05 15:52:39 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -251,7 +251,6 @@ int dm_dev_status_ioctl(prop_dictionary_ int dm_dev_suspend_ioctl(prop_dictionary_t); int dm_check_version(prop_dictionary_t); -int dm_get_version_ioctl(prop_dictionary_t); int dm_list_versions_ioctl(prop_dictionary_t); int dm_table_clear_ioctl(prop_dictionary_t); Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.37 src/sys/dev/dm/dm_ioctl.c:1.38 --- src/sys/dev/dm/dm_ioctl.c:1.37 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/dm_ioctl.c Thu Dec 5 15:52:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.37 2019/12/04 15:31:12 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.38 2019/12/05 15:52:39 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.37 2019/12/04 15:31:12 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.38 2019/12/05 15:52:39 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -161,17 +161,6 @@ dm_dbg_print_flags(int flags) } /* - * Get version ioctl call I do it as default therefore this - * function is unused now. - */ -int -dm_get_version_ioctl(prop_dictionary_t dm_dict) -{ - - return 0; -} - -/* * Get list of all available targets from global * target list and sent them back to libdevmapper. */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Wed Dec 4 16:55:30 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_pdev.c Log Message: dm: Minor fixes/cleanups To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.14 -r1.15 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. Modified files: Index: src/sys/dev/dm/device-mapper.c diff -u src/sys/dev/dm/device-mapper.c:1.43 src/sys/dev/dm/device-mapper.c:1.44 --- src/sys/dev/dm/device-mapper.c:1.43 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/device-mapper.c Wed Dec 4 16:55:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.43 2019/12/04 15:31:12 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.44 2019/12/04 16:55:30 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -616,13 +616,13 @@ dmstrategy(struct buf *bp) * Find out what tables I want to select. */ SLIST_FOREACH(table_en, tbl, next) { - /* I need need number of bytes not blocks. */ + /* I need number of bytes not blocks. */ table_start = table_en->start * DEV_BSIZE; /* * I have to sub 1 from table_en->length to prevent * off by one error */ - table_end = table_start + (table_en->length)* DEV_BSIZE; + table_end = table_start + table_en->length * DEV_BSIZE; start = MAX(table_start, buf_start); Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.14 src/sys/dev/dm/dm_pdev.c:1.15 --- src/sys/dev/dm/dm_pdev.c:1.14 Wed Dec 4 15:31:12 2019 +++ src/sys/dev/dm/dm_pdev.c Wed Dec 4 16:55:30 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.14 2019/12/04 15:31:12 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.14 2019/12/04 15:31:12 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $"); #include #include @@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v #include "dm.h" -SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list; +static SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list; static kmutex_t dm_pdev_mutex;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Wed Dec 4 16:54:03 UTC 2019 Modified Files: src/sys/dev/dm: dm.h Log Message: dm: Comment out unused dm_dev fields documented in sys/dev/dm/doc To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/dev/dm/dm.h 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.31 src/sys/dev/dm/dm.h:1.32 --- src/sys/dev/dm/dm.h:1.31 Tue Dec 3 16:09:13 2019 +++ src/sys/dev/dm/dm.h Wed Dec 4 16:54:03 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.31 2019/12/03 16:09:13 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.32 2019/12/04 16:54:03 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -137,12 +137,12 @@ typedef struct dm_dev { dm_table_head_t table_head; - struct dm_dev_head upcalls; + //struct dm_dev_head upcalls; struct disk *diskp; kmutex_t diskp_mtx; - TAILQ_ENTRY(dm_dev) next_upcall; /* LIST of mirrored, snapshoted devices. */ + //TAILQ_ENTRY(dm_dev) next_upcall; /* LIST of mirrored, snapshoted devices. */ TAILQ_ENTRY(dm_dev) next_devlist; /* Major device list. */ } dm_dev_t;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Wed Dec 4 15:31:12 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c Log Message: dm: style + whitespace + indentation fixes No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/dm/dm_table.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target.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.42 src/sys/dev/dm/device-mapper.c:1.43 --- src/sys/dev/dm/device-mapper.c:1.42 Tue Dec 3 15:36:00 2019 +++ src/sys/dev/dm/device-mapper.c Wed Dec 4 15:31:12 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.42 2019/12/03 15:36:00 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.43 2019/12/04 15:31:12 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -149,7 +149,7 @@ static const struct cmd_function { { .cmd = "reload", .fn = dm_table_load_ioctl,.allowed = 0 }, { .cmd = "status", .fn = dm_table_status_ioctl, .allowed = 1 }, { .cmd = "table", .fn = dm_table_status_ioctl, .allowed = 1 }, - { .cmd = NULL, .fn = NULL, .allowed = 0 } + { .cmd = NULL, .fn = NULL, .allowed = 0 } }; #ifdef _MODULE @@ -194,11 +194,8 @@ dm_modcmd(modcmd_t cmd, void *arg) config_cfdriver_detach(&dm_cd); break; } - dm_doinit(); - break; - case MODULE_CMD_FINI: /* * Disable unloading of dm module if there are any devices @@ -220,7 +217,6 @@ dm_modcmd(modcmd_t cmd, void *arg) break; case MODULE_CMD_STAT: return ENOTTY; - default: return ENOTTY; } @@ -364,7 +360,7 @@ dmioctl(dev_t dev, const u_long cmd, voi aprint_debug("dmioctl called\n"); KASSERT(data != NULL); - if (( r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { + if ((r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { struct plistref *pref = (struct plistref *) data; /* Check if we were called with NETBSD_DM_IOCTL ioctl @@ -429,7 +425,6 @@ dm_ioctl_switch(u_long cmd) { switch(cmd) { - case NETBSD_DM_IOCTL: aprint_debug("dm NetBSD_DM_IOCTL called\n"); break; @@ -511,8 +506,7 @@ disk_ioctl_switch(dev_t dev, u_long cmd, * Call sync target routine for all table entries. Target sync * routine basically call DIOCCACHESYNC on underlying devices. */ - SLIST_FOREACH(table_en, tbl, next) - { + SLIST_FOREACH(table_en, tbl, next) { (void)table_en->target->sync(table_en); } dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); @@ -556,7 +550,6 @@ disk_ioctl_switch(dev_t dev, u_long cmd, break; } - default: aprint_debug("unknown disk_ioctl called\n"); return ENOTTY; @@ -622,8 +615,7 @@ dmstrategy(struct buf *bp) /* * Find out what tables I want to select. */ - SLIST_FOREACH(table_en, tbl, next) - { + SLIST_FOREACH(table_en, tbl, next) { /* I need need number of bytes not blocks. */ table_start = table_en->start * DEV_BSIZE; /* @@ -672,8 +664,6 @@ dmstrategy(struct buf *bp) dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); dm_dev_unbusy(dmv); - - return; } @@ -697,15 +687,13 @@ dmsize(dev_t dev) dm_dev_t *dmv; uint64_t size; - size = 0; - if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) - return -ENOENT; + return -ENOENT; size = dm_table_size(&dmv->table_head); dm_dev_unbusy(dmv); - return size; + return size; } static void Index: src/sys/dev/dm/dm_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.12 src/sys/dev/dm/dm_dev.c:1.13 --- src/sys/dev/dm/dm_dev.c:1.12 Tue Dec 3 16:22:01 2019 +++ src/sys/dev/dm/dm_dev.c Wed Dec 4 15:31:12 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.12 2019/12/03 16:22:01 tkusumi Exp $ */ +/*$NetBSD: dm_dev.c,v 1.13 2019/12/04 15:31:12 tkusumi 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.12 2019/12/03 16:22:01 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.13 2019/12/04 15:31:12 tkusumi Exp $"); #include #include @@ -133,7 +133,6 @@ dm_dev_lookup_name(const char *dm_dev_na return NULL; TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { - dlen = strlen(dmv->name); if (slen != dlen) @@ -162,7 +161,6 @@ dm_dev_lookup_uuid(const char *dm_dev_uu return NULL; TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { - if (strlen(dmv->uuid) != len) continue; @@ -190,9 +188,7 @@ dm_dev_insert(dm_dev_t * dev) if (((dmv = dm_dev_lookup_uuid(dev->uuid)) == NULL) && ((dmv = dm_dev_lookup_name
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 3 16:22:01 UTC 2019 Modified Files: src/sys/dev/dm: dm_dev.c dm_pdev.c dm_target.c Log Message: dm: Make global dm locks static These are all per-file locks which protect dev/pdev/target structure. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_dev.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target.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_dev.c diff -u src/sys/dev/dm/dm_dev.c:1.11 src/sys/dev/dm/dm_dev.c:1.12 --- src/sys/dev/dm/dm_dev.c:1.11 Fri Jan 5 14:22:26 2018 +++ src/sys/dev/dm/dm_dev.c Tue Dec 3 16:22:01 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_dev.c,v 1.11 2018/01/05 14:22:26 christos Exp $ */ +/*$NetBSD: dm_dev.c,v 1.12 2019/12/03 16:22:01 tkusumi 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.11 2018/01/05 14:22:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.12 2019/12/03 16:22:01 tkusumi Exp $"); #include #include @@ -50,7 +50,7 @@ static dm_dev_t *dm_dev_lookup_minor(int static struct dm_dev_head dm_dev_list = TAILQ_HEAD_INITIALIZER(dm_dev_list); -kmutex_t dm_dev_mutex; +static kmutex_t dm_dev_mutex; /* dm_dev_mutex must be holdby caller before using disable_dev. */ __inline static void Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.12 src/sys/dev/dm/dm_pdev.c:1.13 --- src/sys/dev/dm/dm_pdev.c:1.12 Tue Dec 3 15:47:38 2019 +++ src/sys/dev/dm/dm_pdev.c Tue Dec 3 16:22:01 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.12 2019/12/03 15:47:38 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.13 2019/12/03 16:22:01 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.12 2019/12/03 15:47:38 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.13 2019/12/03 16:22:01 tkusumi Exp $"); #include #include @@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list; -kmutex_t dm_pdev_mutex; +static kmutex_t dm_pdev_mutex; static dm_pdev_t *dm_pdev_alloc(const char *); static int dm_pdev_rem(dm_pdev_t *); Index: src/sys/dev/dm/dm_target.c diff -u src/sys/dev/dm/dm_target.c:1.20 src/sys/dev/dm/dm_target.c:1.21 --- src/sys/dev/dm/dm_target.c:1.20 Fri Jan 5 14:22:26 2018 +++ src/sys/dev/dm/dm_target.c Tue Dec 3 16:22:01 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target.c,v 1.20 2018/01/05 14:22:26 christos Exp $ */ +/*$NetBSD: dm_target.c,v 1.21 2019/12/03 16:22:01 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.20 2018/01/05 14:22:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.21 2019/12/03 16:22:01 tkusumi Exp $"); #include #include @@ -48,7 +48,7 @@ TAILQ_HEAD(dm_target_head, dm_target); static struct dm_target_head dm_target_list = TAILQ_HEAD_INITIALIZER(dm_target_list); -kmutex_t dm_target_mutex; +static kmutex_t dm_target_mutex; /* * Called indirectly from dm_table_load_ioctl to mark target as used.
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 3 16:09:13 UTC 2019 Modified Files: src/sys/dev/dm: dm.h Log Message: dm: Remove unused macro MAX_TARGET_STRING_LEN that was added but never used in both NetBSD and DragonFlyBSD. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/dev/dm/dm.h 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.30 src/sys/dev/dm/dm.h:1.31 --- src/sys/dev/dm/dm.h:1.30 Tue Dec 3 15:47:38 2019 +++ src/sys/dev/dm/dm.h Tue Dec 3 16:09:13 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.30 2019/12/03 15:47:38 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.31 2019/12/03 16:09:13 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,11 +66,6 @@ /*** Internal device-mapper structures ***/ /* - * A table entry describes a physical range of the logical volume. - */ -#define MAX_TARGET_STRING_LEN 32 - -/* * A device mapper table is a list of physical ranges plus the mapping target * applied to them. */
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 3 15:47:38 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_pdev.c dm_target_linear.c dm_target_snapshot.c dm_target_stripe.c Log Message: dm: Include in dm.h dm.h already depends on vnode, so have dm.h include instead of other .c files. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm.h cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_pdev.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.25 -r1.26 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. Modified files: Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.29 src/sys/dev/dm/dm.h:1.30 --- src/sys/dev/dm/dm.h:1.29 Tue Dec 3 15:36:00 2019 +++ src/sys/dev/dm/dm.h Tue Dec 3 15:47:38 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.29 2019/12/03 15:36:00 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.30 2019/12/03 15:47:38 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -44,6 +44,7 @@ #include #include #include +#include #include #include Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.35 src/sys/dev/dm/dm_ioctl.c:1.36 --- src/sys/dev/dm/dm_ioctl.c:1.35 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm_ioctl.c Tue Dec 3 15:47:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.35 2019/12/01 06:53:31 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.36 2019/12/03 15:47:38 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.35 2019/12/01 06:53:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.36 2019/12/03 15:47:38 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -88,7 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v #include #include #include -#include #include Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.11 src/sys/dev/dm/dm_pdev.c:1.12 --- src/sys/dev/dm/dm_pdev.c:1.11 Sun Dec 1 16:33:33 2019 +++ src/sys/dev/dm/dm_pdev.c Tue Dec 3 15:47:38 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.11 2019/12/01 16:33:33 tkusumi Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.12 2019/12/03 15:47:38 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.11 2019/12/01 16:33:33 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.12 2019/12/03 15:47:38 tkusumi Exp $"); #include #include @@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v #include #include #include -#include #include Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.20 src/sys/dev/dm/dm_target_linear.c:1.21 --- src/sys/dev/dm/dm_target_linear.c:1.20 Mon Dec 2 16:10:34 2019 +++ src/sys/dev/dm/dm_target_linear.c Tue Dec 3 15:47:38 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.20 2019/12/02 16:10:34 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.21 2019/12/03 15:47:38 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.20 2019/12/02 16:10:34 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.21 2019/12/03 15:47:38 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -40,7 +40,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_li #include #include -#include #include #include Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.21 src/sys/dev/dm/dm_target_snapshot.c:1.22 --- src/sys/dev/dm/dm_target_snapshot.c:1.21 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm_target_snapshot.c Tue Dec 3 15:47:38 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_snapshot.c,v 1.21 2019/12/01 06:53:31 tkusumi Exp $ */ +/*$NetBSD: dm_target_snapshot.c,v 1.22 2019/12/03 15:47:38 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.21 2019/12/01 06:53:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.22 2019/12/03 15:47:38 tkusumi Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@ -83,7 +83,6 @@ __KERNEL_RCSID(0, "$NetBSD: dm_target_sn #include #include -#include #include "dm.h" Inde
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 3 15:36:00 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c dm.h Log Message: dm: Doesn't need to expose struct cmd_function in a header To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm.h 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.41 src/sys/dev/dm/device-mapper.c:1.42 --- src/sys/dev/dm/device-mapper.c:1.41 Mon Dec 2 15:17:43 2019 +++ src/sys/dev/dm/device-mapper.c Tue Dec 3 15:36:00 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.41 2019/12/02 15:17:43 tkusumi Exp $ */ +/*$NetBSD: device-mapper.c,v 1.42 2019/12/03 15:36:00 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -114,6 +114,13 @@ CFATTACH_DECL3_NEW(dm, 0, extern uint32_t dm_dev_counter; /* + * This structure is used to translate command sent to kernel driver in + * command + * + * to function which I can call, and if the command is allowed for + * non-superusers. + */ +/* * This array is used to translate cmd to function pointer. * * Interface between libdevmapper and lvm2tools uses different @@ -122,7 +129,11 @@ extern uint32_t dm_dev_counter; * ioctl to kernel but will do another things in userspace. * */ -static const struct cmd_function cmd_fn[] = { +static const struct cmd_function { + const char *cmd; + int (*fn)(prop_dictionary_t); + int allowed; +} cmd_fn[] = { { .cmd = "version", .fn = dm_get_version_ioctl, .allowed = 1 }, { .cmd = "targets", .fn = dm_list_versions_ioctl, .allowed = 1 }, { .cmd = "create", .fn = dm_dev_create_ioctl,.allowed = 0 }, Index: src/sys/dev/dm/dm.h diff -u src/sys/dev/dm/dm.h:1.28 src/sys/dev/dm/dm.h:1.29 --- src/sys/dev/dm/dm.h:1.28 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm.h Tue Dec 3 15:36:00 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.28 2019/12/01 06:53:31 tkusumi Exp $ */ +/*$NetBSD: dm.h,v 1.29 2019/12/03 15:36:00 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -242,19 +242,6 @@ typedef struct dm_target { /* Interface structures */ -/* - * This structure is used to translate command sent to kernel driver in - * command - * - * to function which I can call, and if the command is allowed for - * non-superusers. - */ -struct cmd_function { - const char *cmd; - int (*fn)(prop_dictionary_t); - int allowed; -}; - /* device-mapper */ void dmgetproperties(struct disk *, dm_table_head_t *);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Tue Dec 3 15:03:15 UTC 2019 Modified Files: src/sys/dev/dm: netbsd-dm.h Log Message: dm: Remove unused macro DM_CMD_LEN that was added but never used in both NetBSD and DragonFlyBSD. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/dm/netbsd-dm.h 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/netbsd-dm.h diff -u src/sys/dev/dm/netbsd-dm.h:1.8 src/sys/dev/dm/netbsd-dm.h:1.9 --- src/sys/dev/dm/netbsd-dm.h:1.8 Sun Jun 4 08:50:27 2017 +++ src/sys/dev/dm/netbsd-dm.h Tue Dec 3 15:03:14 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: netbsd-dm.h,v 1.8 2017/06/04 08:50:27 mbalmer Exp $ */ +/*$NetBSD: netbsd-dm.h,v 1.9 2019/12/03 15:03:14 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -35,8 +35,6 @@ #include #include -#define DM_CMD_LEN 16 - #define DM_IOCTL 0xfd #define DM_IOCTL_CMD 0
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 2 16:10:34 UTC 2019 Modified Files: src/sys/dev/dm: dm_target_linear.c Log Message: dm: Remove misleading comment on linear target arg The offset arg is mandatory. Remove code and comment that makes it sounds like it's optional. taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_linear.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_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.19 src/sys/dev/dm/dm_target_linear.c:1.20 --- src/sys/dev/dm/dm_target_linear.c:1.19 Sun Dec 1 06:53:31 2019 +++ src/sys/dev/dm/dm_target_linear.c Mon Dec 2 16:10:34 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.19 2019/12/01 06:53:31 tkusumi Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.20 2019/12/02 16:10:34 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.19 2019/12/01 06:53:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.20 2019/12/02 16:10:34 tkusumi Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -85,9 +85,6 @@ dm_target_linear_init(dm_dev_t * dmv, vo tlc = kmem_alloc(sizeof(dm_target_linear_config_t), KM_SLEEP); tlc->pdev = dmp; - tlc->offset = 0; /* default settings */ - - /* Check user input if it is not leave offset as 0. */ tlc->offset = atoi(argv[1]); *target_config = tlc;
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Mon Dec 2 15:17:43 UTC 2019 Modified Files: src/sys/dev/dm: device-mapper.c Log Message: dm: Add a comment on race window on unload There is a minor race window on unload vs device creation that can cause panic. https://github.com/DragonFlyBSD/DragonFlyBSD/commit/53a07f3ae7313aa58948a60f46428bfc2254dc3c taken-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/dev/dm/device-mapper.c:1.41 --- src/sys/dev/dm/device-mapper.c:1.40 Sat Oct 6 14:59:11 2018 +++ src/sys/dev/dm/device-mapper.c Mon Dec 2 15:17:43 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: device-mapper.c,v 1.40 2018/10/06 14:59:11 mlelstv Exp $ */ +/*$NetBSD: device-mapper.c,v 1.41 2019/12/02 15:17:43 tkusumi Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -197,6 +197,7 @@ dm_modcmd(modcmd_t cmd, void *arg) */ if (dm_dev_counter > 0) return EBUSY; + /* race window here */ error = dmdestroy(); if (error)
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 1 16:33:33 UTC 2019 Modified Files: src/sys/dev/dm: dm_pdev.c Log Message: dm: Fix race on pdev create List lookup and insert need to be atomic. https://github.com/DragonFlyBSD/DragonFlyBSD/commit/ac816675c8321309b49d6a335f95c5388036803f take-from: DragonFlyBSD To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 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. Modified files: Index: src/sys/dev/dm/dm_pdev.c diff -u src/sys/dev/dm/dm_pdev.c:1.10 src/sys/dev/dm/dm_pdev.c:1.11 --- src/sys/dev/dm/dm_pdev.c:1.10 Fri Jan 5 14:22:26 2018 +++ src/sys/dev/dm/dm_pdev.c Sun Dec 1 16:33:33 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_pdev.c,v 1.10 2018/01/05 14:22:26 christos Exp $ */ +/*$NetBSD: dm_pdev.c,v 1.11 2019/12/01 16:33:33 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.10 2018/01/05 14:22:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.11 2019/12/01 16:33:33 tkusumi Exp $"); #include #include @@ -103,15 +103,17 @@ dm_pdev_insert(const char *dev_name) mutex_exit(&dm_pdev_mutex); return dmp; } - mutex_exit(&dm_pdev_mutex); - if ((dmp = dm_pdev_alloc(dev_name)) == NULL) + if ((dmp = dm_pdev_alloc(dev_name)) == NULL) { + mutex_exit(&dm_pdev_mutex); return NULL; + } dev_pb = pathbuf_create(dev_name); if (dev_pb == NULL) { aprint_debug("%s: pathbuf_create on device: %s failed!\n", __func__, dev_name); + mutex_exit(&dm_pdev_mutex); kmem_free(dmp, sizeof(dm_pdev_t)); return NULL; } @@ -120,13 +122,13 @@ dm_pdev_insert(const char *dev_name) if (error) { aprint_debug("%s: dk_lookup on device: %s (error %d)\n", __func__, dev_name, error); + mutex_exit(&dm_pdev_mutex); kmem_free(dmp, sizeof(dm_pdev_t)); return NULL; } getdisksize(dmp->pdev_vnode, &dmp->pdev_numsec, &dmp->pdev_secsize); dmp->ref_cnt = 1; - mutex_enter(&dm_pdev_mutex); SLIST_INSERT_HEAD(&dm_pdev_list, dmp, next_pdev); mutex_exit(&dm_pdev_mutex);
CVS commit: src/sys/dev/dm
Module Name:src Committed By: tkusumi Date: Sun Dec 1 06:53:32 UTC 2019 Modified Files: src/sys/dev/dm: dm.h dm_ioctl.c dm_target_error.c dm_target_linear.c dm_target_mirror.c dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c src/sys/dev/dm/doc: locking.txt Log Message: dm: Remove unused dm_dev::dev_type Given OOP-like architecture of dm target device structure, dm_dev doesn't need to have self contained target type field, and in fact this is unused. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm.h cvs rdiff -u -r1.34 -r1.35 src/sys/dev/dm/dm_ioctl.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_target_error.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/dm/dm_target_zero.c cvs rdiff -u -r1.1 -r1.2 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.27 src/sys/dev/dm/dm.h:1.28 --- src/sys/dev/dm/dm.h:1.27 Thu Oct 2 21:58:16 2014 +++ src/sys/dev/dm/dm.h Sun Dec 1 06:53:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm.h,v 1.27 2014/10/02 21:58:16 justin Exp $ */ +/*$NetBSD: dm.h,v 1.28 2019/12/01 06:53:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -139,8 +139,6 @@ typedef struct dm_dev { uint32_t event_nr; uint32_t ref_cnt; - uint32_t dev_type; - dm_table_head_t table_head; struct dm_dev_head upcalls; @@ -153,19 +151,6 @@ typedef struct dm_dev { TAILQ_ENTRY(dm_dev) next_devlist; /* Major device list. */ } dm_dev_t; -/* Device types used for upcalls */ -#define DM_ZERO_DEV(1 << 0) -#define DM_ERROR_DEV (1 << 1) -#define DM_LINEAR_DEV (1 << 2) -#define DM_MIRROR_DEV (1 << 3) -#define DM_STRIPE_DEV (1 << 4) -#define DM_SNAPSHOT_DEV(1 << 5) -#define DM_SNAPSHOT_ORIG_DEV (1 << 6) -#define DM_SPARE_DEV (1 << 7) -/* Set this device type only during dev remove ioctl. */ -#define DM_DELETING_DEV(1 << 8) - - /* for zero, error : dm_target->target_config == NULL */ /* Index: src/sys/dev/dm/dm_ioctl.c diff -u src/sys/dev/dm/dm_ioctl.c:1.34 src/sys/dev/dm/dm_ioctl.c:1.35 --- src/sys/dev/dm/dm_ioctl.c:1.34 Sat Nov 30 05:35:57 2019 +++ src/sys/dev/dm/dm_ioctl.c Sun Dec 1 06:53:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.34 2019/11/30 05:35:57 tkusumi Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.35 2019/12/01 06:53:31 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.34 2019/11/30 05:35:57 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.35 2019/12/01 06:53:31 tkusumi Exp $"); /* * Locking is used to synchronise between ioctl calls and between dm_table's @@ -246,7 +246,6 @@ dm_dev_create_ioctl(prop_dictionary_t dm dmv->flags = 0; /* device flags are set when needed */ dmv->ref_cnt = 0; dmv->event_nr = 0; - dmv->dev_type = 0; dmv->devt = devt; dm_table_head_init(&dmv->table_head); Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.12 src/sys/dev/dm/dm_target_error.c:1.13 --- src/sys/dev/dm/dm_target_error.c:1.12 Fri Jan 5 14:22:26 2018 +++ src/sys/dev/dm/dm_target_error.c Sun Dec 1 06:53:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_error.c,v 1.12 2018/01/05 14:22:26 christos Exp $ */ +/*$NetBSD: dm_target_error.c,v 1.13 2019/12/01 06:53:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.12 2018/01/05 14:22:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.13 2019/12/01 06:53:31 tkusumi Exp $"); /* * This file implements initial version of device-mapper error target. @@ -118,8 +118,6 @@ dm_target_error_init(dm_dev_t * dmv, voi *target_config = NULL; - dmv->dev_type = DM_ERROR_DEV; - return 0; } Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.18 src/sys/dev/dm/dm_target_linear.c:1.19 --- src/sys/dev/dm/dm_target_linear.c:1.18 Tue Oct 15 00:13:53 2019 +++ src/sys/dev/dm/dm_target_linear.c Sun Dec 1 06:53:31 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_linear.c,v 1.18 2019/10/15 00:13:53 chs Exp $ */ +/*$NetBSD: dm_target_linear.c,v 1.19 2019/12/01 06:53:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0