From 7163c9c1fc72b6c11746304914180fa8563e627e Mon Sep 17 00:00:00 2001 From: scottl Date: Fri, 15 Feb 2008 06:26:25 +0000 Subject: [PATCH] Teach the dump and minidump code to respect the maxioszie attribute of the disk; the hard-coded assumption of 64K doesn't work in all cases. --- sys/amd64/amd64/dump_machdep.c | 8 ++++++-- sys/amd64/amd64/minidump_machdep.c | 8 ++++++-- sys/geom/geom_disk.c | 1 + sys/i386/i386/dump_machdep.c | 8 ++++++-- sys/i386/i386/minidump_machdep.c | 8 ++++++-- sys/sys/conf.h | 1 + 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/dump_machdep.c b/sys/amd64/amd64/dump_machdep.c index 9130139049a..e80489ff755 100644 --- a/sys/amd64/amd64/dump_machdep.c +++ b/sys/amd64/amd64/dump_machdep.c @@ -177,6 +177,7 @@ cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg) uint64_t pgs; size_t counter, sz, chunk; int i, c, error, twiddle; + u_int maxdumppgs; error = 0; /* catch case in which chunk size is 0 */ counter = 0; /* Update twiddle every 16MB */ @@ -184,13 +185,16 @@ cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg) va = 0; pgs = mdp->md_size / PAGE_SIZE; pa = mdp->md_start; + maxdumppgs = di->maxiosize / PAGE_SIZE; + if (maxdumppgs == 0) /* seatbelt */ + maxdumppgs = 1; printf(" chunk %d: %ldMB (%ld pages)", seqnr, PG2MB(pgs), pgs); while (pgs) { chunk = pgs; - if (chunk > MAXDUMPPGS) - chunk = MAXDUMPPGS; + if (chunk > maxdumppgs) + chunk = maxdumppgs; sz = chunk << PAGE_SHIFT; counter += sz; if (counter >> 24) { diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index 943c5e66a55..4c3333dc097 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -122,7 +122,11 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) { size_t len; int error, i, c; + u_int maxdumpsz; + maxdumpsz = di->maxiosize; + if (maxdumpsz == 0) /* seatbelt */ + maxdumpsz = PAGE_SIZE; error = 0; if ((sz % PAGE_SIZE) != 0) { printf("size not page aligned\n"); @@ -143,7 +147,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) return (error); } while (sz) { - len = (MAXDUMPPGS * PAGE_SIZE) - fragsz; + len = maxdumpsz - fragsz; if (len > sz) len = sz; counter += len; @@ -165,7 +169,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) fragsz += len; pa += len; sz -= len; - if (fragsz == (MAXDUMPPGS * PAGE_SIZE)) { + if (fragsz == maxdumpsz) { error = blk_flush(di); if (error) return (error); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 725a7d0dc35..c39c03894cc 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -179,6 +179,7 @@ g_disk_kerneldump(struct bio *bp, struct disk *dp) di.dumper = dp->d_dump; di.priv = dp; di.blocksize = dp->d_sectorsize; + di.maxiosize = dp->d_maxsize; di.mediaoffset = gkd->offset; if ((gkd->offset + gkd->length) > dp->d_mediasize) gkd->length = dp->d_mediasize - gkd->offset; diff --git a/sys/i386/i386/dump_machdep.c b/sys/i386/i386/dump_machdep.c index 5081051b013..e7cf38c29f5 100644 --- a/sys/i386/i386/dump_machdep.c +++ b/sys/i386/i386/dump_machdep.c @@ -177,6 +177,7 @@ cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg) uint64_t pgs; size_t counter, sz, chunk; int i, c, error, twiddle; + u_int maxdumppgs; error = 0; /* catch case in which chunk size is 0 */ counter = 0; /* Update twiddle every 16MB */ @@ -184,13 +185,16 @@ cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg) va = 0; pgs = mdp->md_size / PAGE_SIZE; pa = mdp->md_start; + maxdumppgs = di->maxiosize / PAGE_SIZE; + if (maxdumppgs == 0) /* seatbelt */ + maxdumppgs = 1; printf(" chunk %d: %lldMB (%lld pages)", seqnr, PG2MB(pgs), pgs); while (pgs) { chunk = pgs; - if (chunk > MAXDUMPPGS) - chunk = MAXDUMPPGS; + if (chunk > maxdumppgs) + chunk = maxdumppgs; sz = chunk << PAGE_SHIFT; counter += sz; if (counter >> 24) { diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c index 826a74454a4..0fc6ba81061 100644 --- a/sys/i386/i386/minidump_machdep.c +++ b/sys/i386/i386/minidump_machdep.c @@ -120,7 +120,11 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) { size_t len; int error, i, c; + u_int maxdumpsz; + maxdumpsz = di->maxiosize; + if (maxdumpsz == 0) /* seatbelt */ + maxdumpsz = PAGE_SIZE; error = 0; if ((sz % PAGE_SIZE) != 0) { printf("size not page aligned\n"); @@ -141,7 +145,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) return (error); } while (sz) { - len = (MAXDUMPPGS * PAGE_SIZE) - fragsz; + len = maxdumpsz - fragsz; if (len > sz) len = sz; counter += len; @@ -163,7 +167,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) fragsz += len; pa += len; sz -= len; - if (fragsz == (MAXDUMPPGS * PAGE_SIZE)) { + if (fragsz == maxdumpsz) { error = blk_flush(di); if (error) return (error); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 97eea5c74a8..9f1d2530750 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -299,6 +299,7 @@ struct dumperinfo { dumper_t *dumper; /* Dumping function. */ void *priv; /* Private parts. */ u_int blocksize; /* Size of block in bytes. */ + u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ }; -- 2.45.0