implement bdev_size(9) wrapper around d_psize() routine, so we can take

the device lock in relevant places.  avoid doing so while actually dumping.

tested i386 crash dumps still work, and that all touched files compile.

fixes PR#45705.
This commit is contained in:
mrg 2011-12-12 19:03:07 +00:00
parent 3a9ee24e6b
commit 9a4a666ff3
27 changed files with 119 additions and 269 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.335 2011/06/12 03:35:37 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.336 2011/12/12 19:03:07 mrg Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.335 2011/06/12 03:35:37 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.336 2011/12/12 19:03:07 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1165,19 +1165,11 @@ cpu_dump(void)
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;
@ -1241,7 +1233,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n",
major(dumpdev), minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.172 2011/12/04 16:24:13 chs Exp $ */
/* $NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.172 2011/12/04 16:24:13 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $");
/* #define XENDEBUG_LOW */
@ -1226,7 +1226,7 @@ dodumpsys(void)
(unsigned long long)major(dumpdev),
(unsigned long long)minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");
@ -1323,19 +1323,11 @@ failed:
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.235 2011/11/17 07:45:53 mlelstv Exp $ */
/* $NetBSD: machdep.c,v 1.236 2011/12/12 19:03:08 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -48,7 +48,7 @@
#include "opt_m68k_arch.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2011/11/17 07:45:53 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.236 2011/12/12 19:03:08 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -449,7 +449,6 @@ cpu_dumpconf(void)
{
cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
struct m68k_kcore_hdr *m = &h->un._m68k;
const struct bdevsw *bdev;
int nblks;
int i;
extern int end[];
@ -510,12 +509,12 @@ cpu_dumpconf(void)
m->ram_segs[1].size = memlist->m_seg[i].ms_size;
break;
}
if ((bdev = bdevsw_lookup(dumpdev)) == NULL) {
if (bdevsw_lookup(dumpdev) == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize != NULL) {
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks > 0) {
if (dumpsize > btoc(dbtob(nblks - dumplo)))
dumpsize = btoc(dbtob(nblks - dumplo));
else if (dumplo == 0)
@ -577,7 +576,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable.\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: stubs.c,v 1.22 2009/11/07 07:27:41 cegger Exp $ */
/* $NetBSD: stubs.c,v 1.23 2011/12/12 19:03:08 mrg Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.22 2009/11/07 07:27:41 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.23 2011/12/12 19:03:08 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -86,17 +86,11 @@ struct pcb dumppcb;
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL)
panic("dumpconf: bad dumpdev=0x%"PRIx64"", dumpdev);
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
return;
@ -248,7 +242,7 @@ dodumpsys(void)
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL || bdev->d_psize == NULL)
return;
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.172 2011/06/12 03:35:39 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.172 2011/06/12 03:35:39 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -393,7 +393,6 @@ long dumplo = 0; /* (disk blocks) */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, i;
for (i = dumpsize = 0; i < NMEM_SEGS; i++) {
@ -404,13 +403,8 @@ cpu_dumpconf(void)
dumpsize = btoc(dumpsize);
if (dumpdev != NODEV) {
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize != NULL) {
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks > 0) {
if (dumpsize > btoc(dbtob(nblks - dumplo)))
dumpsize = btoc(dbtob(nblks - dumplo));
else if (dumplo == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.60 2011/06/12 03:35:40 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.61 2011/12/12 19:03:09 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.60 2011/06/12 03:35:40 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.61 2011/12/12 19:03:09 mrg Exp $");
#include "opt_bufcache.h"
#include "opt_ddb.h"
@ -388,19 +388,11 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.223 2011/06/12 03:35:40 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.224 2011/12/12 19:03:09 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2011/06/12 03:35:40 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.224 2011/12/12 19:03:09 mrg Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -745,20 +745,12 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.39 2011/01/23 09:44:58 skrll Exp $ */
/* $NetBSD: autoconf.c,v 1.40 2011/12/12 19:03:09 mrg Exp $ */
/* $OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $ */
@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.39 2011/01/23 09:44:58 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.40 2011/12/12 19:03:09 mrg Exp $");
#include "opt_kgdb.h"
#include "opt_useleds.h"
@ -293,20 +293,12 @@ hp700_led_blinker(void *arg)
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
extern int dumpsize;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;
dumpblks = cpu_dumpsize();

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.101 2011/12/05 15:04:27 skrll Exp $ */
/* $NetBSD: machdep.c,v 1.102 2011/12/12 19:03:09 mrg Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.101 2011/12/05 15:04:27 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.102 2011/12/12 19:03:09 mrg Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@ -1809,7 +1809,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n",
major(dumpdev), minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: dumpsys.c,v 1.15 2011/11/20 18:41:12 yamt Exp $ */
/* $NetBSD: dumpsys.c,v 1.16 2011/12/12 19:03:09 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.15 2011/11/20 18:41:12 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.16 2011/12/12 19:03:09 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -177,7 +177,7 @@ dodumpsys(void)
(unsigned long long)major(dumpdev),
(unsigned long long)minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");
@ -274,19 +274,11 @@ failed:
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.88 2011/11/26 04:32:46 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.89 2011/12/12 19:03:10 mrg Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.88 2011/11/26 04:32:46 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.89 2011/12/12 19:03:10 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -536,20 +536,12 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.341 2011/06/12 03:35:43 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.342 2011/12/12 19:03:10 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.341 2011/06/12 03:35:43 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.342 2011/12/12 19:03:10 mrg Exp $");
#include "opt_adb.h"
#include "opt_ddb.h"
@ -639,7 +639,6 @@ cpu_dumpconf(void)
{
cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
struct m68k_kcore_hdr *m = &h->un._m68k;
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
int i;
@ -647,14 +646,7 @@ cpu_dumpconf(void)
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips_machdep.c,v 1.250 2011/10/29 18:56:49 jakllsch Exp $ */
/* $NetBSD: mips_machdep.c,v 1.251 2011/12/12 19:03:10 mrg Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -112,7 +112,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.250 2011/10/29 18:56:49 jakllsch Exp $");
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.251 2011/12/12 19:03:10 mrg Exp $");
#define __INTR_PRIVATE
#include "opt_cputype.h"
@ -1787,19 +1787,11 @@ cpu_dump(void)
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;
@ -1864,7 +1856,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.149 2011/06/12 03:35:44 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.150 2011/12/12 19:03:10 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.149 2011/06/12 03:35:44 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.150 2011/12/12 19:03:10 mrg Exp $");
#include "opt_ddb.h"
#include "opt_m060sp.h"
@ -837,19 +837,11 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks; /* size of dump area */
if (dumpdev == NODEV)
goto bad;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
goto bad;
}
if (bdev->d_psize == NULL)
goto bad;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
goto bad;
@ -909,7 +901,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n",
major(dumpdev), minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.97 2011/11/22 14:31:02 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.98 2011/12/12 19:03:11 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.97 2011/11/22 14:31:02 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98 2011/12/12 19:03:11 mrg Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -472,20 +472,12 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.105 2011/06/12 03:35:45 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.106 2011/12/12 19:03:11 mrg Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.105 2011/06/12 03:35:45 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.106 2011/12/12 19:03:11 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -621,20 +621,12 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: powerpc_machdep.c,v 1.60 2011/07/31 10:00:52 kiyohara Exp $ */
/* $NetBSD: powerpc_machdep.c,v 1.61 2011/12/12 19:03:11 mrg Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.60 2011/07/31 10:00:52 kiyohara Exp $");
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.61 2011/12/12 19:03:11 mrg Exp $");
#include "opt_altivec.h"
#include "opt_modular.h"
@ -280,20 +280,12 @@ long dumplo = -1; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks; /* size of dump device */
int skip;
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks <= ctod(1))
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.313 2011/07/17 23:29:10 dyoung Exp $ */
/* $NetBSD: machdep.c,v 1.314 2011/12/12 19:03:11 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.313 2011/07/17 23:29:10 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.314 2011/12/12 19:03:11 mrg Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_sunos.h"
@ -938,16 +938,11 @@ long dumplo = 0;
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks;
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL || bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
dumpblks = ctod(physmem) + pmap_dumpsize();
if (dumpblks > (nblks - ctod(1)))
@ -1019,7 +1014,7 @@ dumpsys(void)
printf("\ndumping to dev %u,%u offset %ld\n",
major(dumpdev), minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
printf("dump ");
if (psize == -1) {
printf("area unavailable\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.262 2011/10/08 08:49:07 nakayama Exp $ */
/* $NetBSD: machdep.c,v 1.263 2011/12/12 19:03:11 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.262 2011/10/08 08:49:07 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.263 2011/12/12 19:03:11 mrg Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -698,18 +698,12 @@ long dumplo = 0;
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks, dumpblks;
if (dumpdev == NODEV)
/* No usable dump device */
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL || bdev->d_psize == NULL)
/* No usable dump device */
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
dumpblks = ctod(physmem) + pmap_dumpsize();
if (dumpblks > (nblks - ctod(1)))
@ -784,7 +778,7 @@ dumpsys(void)
printf("\ndumping to dev %" PRId32 ",%" PRId32 " offset %ld\n",
major(dumpdev), minor(dumpdev), dumplo);
psize = (*bdev->d_psize)(dumpdev);
psize = bdev_size(dumpdev);
if (psize == -1) {
printf("dump area unavailable\n");
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.70 2011/06/12 03:35:47 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.71 2011/12/12 19:03:11 mrg Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -149,7 +149,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.70 2011/06/12 03:35:47 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.71 2011/12/12 19:03:11 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -566,23 +566,13 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int devblks; /* size of dump device in blocks */
int dumpblks; /* size of dump image in blocks */
int (*getsize)(dev_t);
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
getsize = bdev->d_psize;
if (getsize == NULL)
return;
devblks = (*getsize)(dumpdev);
devblks = bdev_size(dumpdev);
if (devblks <= ctod(1))
return;
devblks &= ~(ctod(1)-1);
@ -651,7 +641,7 @@ dumpsys(void)
}
savectx(&dumppcb);
psize = (*(dsw->d_psize))(dumpdev);
psize = bdev_size(dumpdev);
if (psize == -1) {
printf("dump area unavailable\n");
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.203 2011/06/14 15:23:19 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.204 2011/12/12 19:03:12 mrg Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.203 2011/06/14 15:23:19 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.204 2011/12/12 19:03:12 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -483,23 +483,13 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int devblks; /* size of dump device in blocks */
int dumpblks; /* size of dump image in blocks */
int (*getsize)(dev_t);
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
getsize = bdev->d_psize;
if (getsize == NULL)
return;
devblks = (*getsize)(dumpdev);
devblks = bdev_size(dumpdev);
if (devblks <= ctod(1))
return;
devblks &= ~(ctod(1)-1);
@ -568,7 +558,7 @@ dumpsys(void)
}
savectx(&dumppcb);
psize = (*(dsw->d_psize))(dumpdev);
psize = bdev_size(dumpdev);
if (psize == -1) {
printf("dump area unavailable\n");
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.130 2011/06/14 15:23:19 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.131 2011/12/12 19:03:12 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.130 2011/06/14 15:23:19 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.131 2011/12/12 19:03:12 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -473,23 +473,13 @@ long dumplo = 0; /* blocks */
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int devblks; /* size of dump device in blocks */
int dumpblks; /* size of dump image in blocks */
int (*getsize)(dev_t);
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
getsize = bdev->d_psize;
if (getsize == NULL)
return;
devblks = (*getsize)(dumpdev);
devblks = bdev_size(dumpdev);
if (devblks <= ctod(1))
return;
devblks &= ~(ctod(1) - 1);
@ -556,7 +546,7 @@ dumpsys(void)
}
savectx(&dumppcb);
psize = (*(dsw->d_psize))(dumpdev);
psize = bdev_size(dumpdev);
if (psize == -1) {
printf("dump area unavailable\n");
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.182 2011/07/03 02:18:21 matt Exp $ */
/* $NetBSD: machdep.c,v 1.183 2011/12/12 19:03:12 mrg Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.182 2011/07/03 02:18:21 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.183 2011/12/12 19:03:12 mrg Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -227,20 +227,15 @@ long dumplo = 0;
void
cpu_dumpconf(void)
{
const struct bdevsw *bdev;
int nblks;
int nblks;
/*
* XXX include the final RAM page which is not included in physmem.
*/
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL)
return;
dumpsize = physmem + 1;
if (bdev->d_psize != NULL) {
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
if (nblks > 0) {
if (dumpsize > btoc(dbtob(nblks - dumplo)))
dumpsize = btoc(dbtob(nblks - dumplo));
else if (dumplo == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.178 2011/06/12 03:35:49 rmind Exp $ */
/* $NetBSD: machdep.c,v 1.179 2011/12/12 19:03:12 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.178 2011/06/12 03:35:49 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.179 2011/12/12 19:03:12 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -585,21 +585,13 @@ cpu_dumpconf(void)
{
cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
struct m68k_kcore_hdr *m = &h->un._m68k;
const struct bdevsw *bdev;
int chdrsize; /* size of dump header */
int nblks; /* size of dump area */
int i;
if (dumpdev == NODEV)
return;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL) {
dumpdev = NODEV;
return;
}
if (bdev->d_psize == NULL)
return;
nblks = (*bdev->d_psize)(dumpdev);
nblks = bdev_size(dumpdev);
chdrsize = cpu_dumpsize();
dumpsize = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_devsw.c,v 1.28 2009/09/03 11:42:21 jmcneill Exp $ */
/* $NetBSD: subr_devsw.c,v 1.29 2011/12/12 19:03:12 mrg Exp $ */
/*-
* Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.28 2009/09/03 11:42:21 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.29 2011/12/12 19:03:12 mrg Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.28 2009/09/03 11:42:21 jmcneill Exp
#include <sys/tty.h>
#include <sys/cpu.h>
#include <sys/buf.h>
#include <sys/reboot.h>
#ifdef DEVSW_DEBUG
#define DPRINTF(x) printf x
@ -792,6 +793,28 @@ bdev_type(dev_t dev)
return d->d_flag & D_TYPEMASK;
}
int
bdev_size(dev_t dev)
{
const struct bdevsw *d;
int rv, mpflag = 0;
if ((d = bdevsw_lookup(dev)) == NULL ||
d->d_psize == NULL)
return -1;
/*
* Don't to try lock the device if we're dumping.
*/
if ((boothowto & RB_DUMP) == 0)
DEV_LOCK(d);
rv = (*d->d_psize)(dev);
if ((boothowto & RB_DUMP) == 0)
DEV_UNLOCK(d);
return rv;
}
int
cdev_open(dev_t dev, int flag, int devtype, lwp_t *l)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.140 2011/06/12 03:35:59 rmind Exp $ */
/* $NetBSD: conf.h,v 1.141 2011/12/12 19:03:12 mrg Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -166,6 +166,7 @@ dev_type_kqfilter(cdev_kqfilter);
int cdev_type(dev_t);
int bdev_type(dev_t);
int bdev_size(dev_t);
/* symbolic sleep message strings */
extern const char devopn[], devio[], devwait[], devin[], devout[];

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_swap.c,v 1.157 2011/09/02 22:25:08 dyoung Exp $ */
/* $NetBSD: uvm_swap.c,v 1.158 2011/12/12 19:03:13 mrg Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.157 2011/09/02 22:25:08 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.158 2011/12/12 19:03:13 mrg Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@ -819,7 +819,6 @@ swap_on(struct lwp *l, struct swapdev *sdp)
long addr;
vmem_addr_t result;
struct vattr va;
const struct bdevsw *bdev;
dev_t dev;
UVMHIST_FUNC("swap_on"); UVMHIST_CALLED(pdhist);
@ -858,9 +857,7 @@ swap_on(struct lwp *l, struct swapdev *sdp)
*/
switch (vp->v_type) {
case VBLK:
bdev = bdevsw_lookup(dev);
if (bdev == NULL || bdev->d_psize == NULL ||
(nblocks = (*bdev->d_psize)(dev)) == -1) {
if ((nblocks = bdev_size(dev)) == -1) {
error = ENXIO;
goto bad;
}