Wed Dec 4 16:55:30 2019 UTC ()
dm: Minor fixes/cleanups


(tkusumi)
diff -r1.43 -r1.44 src/sys/dev/dm/device-mapper.c
diff -r1.14 -r1.15 src/sys/dev/dm/dm_pdev.c

cvs diff -r1.43 -r1.44 src/sys/dev/dm/device-mapper.c (expand / switch to unified diff)

--- src/sys/dev/dm/device-mapper.c 2019/12/04 15:31:12 1.43
+++ src/sys/dev/dm/device-mapper.c 2019/12/04 16:55:30 1.44
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: device-mapper.c,v 1.43 2019/12/04 15:31:12 tkusumi Exp $ */ 1/* $NetBSD: device-mapper.c,v 1.44 2019/12/04 16:55:30 tkusumi Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Hamsik. 8 * by Adam Hamsik.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -606,33 +606,33 @@ dmstrategy(struct buf *bp) @@ -606,33 +606,33 @@ dmstrategy(struct buf *bp)
606 mutex_exit(&dmv->diskp_mtx); 606 mutex_exit(&dmv->diskp_mtx);
607 607
608 /* Select active table */ 608 /* Select active table */
609 tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE); 609 tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
610 610
611 /* Nested buffers count down to zero therefore I have 611 /* Nested buffers count down to zero therefore I have
612 to set bp->b_resid to maximal value. */ 612 to set bp->b_resid to maximal value. */
613 bp->b_resid = bp->b_bcount; 613 bp->b_resid = bp->b_bcount;
614 614
615 /* 615 /*
616 * Find out what tables I want to select. 616 * Find out what tables I want to select.
617 */ 617 */
618 SLIST_FOREACH(table_en, tbl, next) { 618 SLIST_FOREACH(table_en, tbl, next) {
619 /* I need need number of bytes not blocks. */ 619 /* I need number of bytes not blocks. */
620 table_start = table_en->start * DEV_BSIZE; 620 table_start = table_en->start * DEV_BSIZE;
621 /* 621 /*
622 * I have to sub 1 from table_en->length to prevent 622 * I have to sub 1 from table_en->length to prevent
623 * off by one error 623 * off by one error
624 */ 624 */
625 table_end = table_start + (table_en->length)* DEV_BSIZE; 625 table_end = table_start + table_en->length * DEV_BSIZE;
626 626
627 start = MAX(table_start, buf_start); 627 start = MAX(table_start, buf_start);
628 628
629 end = MIN(table_end, buf_start + buf_len); 629 end = MIN(table_end, buf_start + buf_len);
630 630
631 aprint_debug("----------------------------------------\n"); 631 aprint_debug("----------------------------------------\n");
632 aprint_debug("table_start %010" PRIu64", table_end %010" 632 aprint_debug("table_start %010" PRIu64", table_end %010"
633 PRIu64 "\n", table_start, table_end); 633 PRIu64 "\n", table_start, table_end);
634 aprint_debug("buf_start %010" PRIu64", buf_len %010" 634 aprint_debug("buf_start %010" PRIu64", buf_len %010"
635 PRIu64"\n", buf_start, buf_len); 635 PRIu64"\n", buf_start, buf_len);
636 aprint_debug("start-buf_start %010"PRIu64", end %010" 636 aprint_debug("start-buf_start %010"PRIu64", end %010"
637 PRIu64"\n", start - buf_start, end); 637 PRIu64"\n", start - buf_start, end);
638 aprint_debug("start %010" PRIu64" , end %010" 638 aprint_debug("start %010" PRIu64" , end %010"

cvs diff -r1.14 -r1.15 src/sys/dev/dm/dm_pdev.c (expand / switch to unified diff)

--- src/sys/dev/dm/dm_pdev.c 2019/12/04 15:31:12 1.14
+++ src/sys/dev/dm/dm_pdev.c 2019/12/04 16:55:30 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dm_pdev.c,v 1.14 2019/12/04 15:31:12 tkusumi Exp $ */ 1/* $NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Hamsik. 8 * by Adam Hamsik.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -19,41 +19,41 @@ @@ -19,41 +19,41 @@
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.14 2019/12/04 15:31:12 tkusumi Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $");
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/param.h> 35#include <sys/param.h>
36 36
37#include <sys/disk.h> 37#include <sys/disk.h>
38#include <sys/fcntl.h> 38#include <sys/fcntl.h>
39#include <sys/kmem.h> 39#include <sys/kmem.h>
40#include <sys/namei.h> 40#include <sys/namei.h>
41 41
42#include <dev/dkvar.h> 42#include <dev/dkvar.h>
43 43
44#include "dm.h" 44#include "dm.h"
45 45
46SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list; 46static SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list;
47 47
48static kmutex_t dm_pdev_mutex; 48static kmutex_t dm_pdev_mutex;
49 49
50static dm_pdev_t *dm_pdev_alloc(const char *); 50static dm_pdev_t *dm_pdev_alloc(const char *);
51static int dm_pdev_rem(dm_pdev_t *); 51static int dm_pdev_rem(dm_pdev_t *);
52static dm_pdev_t *dm_pdev_lookup_name(const char *); 52static dm_pdev_t *dm_pdev_lookup_name(const char *);
53 53
54/* 54/*
55* Find used pdev with name == dm_pdev_name. 55* Find used pdev with name == dm_pdev_name.
56*/ 56*/
57dm_pdev_t * 57dm_pdev_t *
58dm_pdev_lookup_name(const char *dm_pdev_name) 58dm_pdev_lookup_name(const char *dm_pdev_name)
59{ 59{