kerneldump: remove physical from dump routines

It is unused, especially now that the underlying d_dumper methods do not
accept the argument.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35174
This commit is contained in:
Mitchell Horne 2022-05-13 10:40:05 -03:00
parent 489ba22236
commit db71383b88
11 changed files with 39 additions and 46 deletions

View File

@ -75,7 +75,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, dump_va, 0, fragsz); error = dump_append(di, dump_va, fragsz);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -128,7 +128,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
} }
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error) if (error)
return (error); return (error);
ptr += len; ptr += len;

View File

@ -70,7 +70,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, dump_va, 0, fragsz); error = dump_append(di, dump_va, fragsz);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -115,7 +115,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL); wdog_kern_pat(WD_LASTVAL);
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error) if (error)
return (error); return (error);
ptr += len; ptr += len;

View File

@ -75,7 +75,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, dump_va, 0, fragsz); error = dump_append(di, dump_va, fragsz);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -121,7 +121,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL); wdog_kern_pat(WD_LASTVAL);
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error) if (error)
return (error); return (error);
ptr += len; ptr += len;

View File

@ -248,7 +248,7 @@ textdump_writeblock(struct dumperinfo *di, off_t offset, char *buffer)
return (EIO); return (EIO);
if (offset < SIZEOF_METADATA) if (offset < SIZEOF_METADATA)
return (ENOSPC); return (ENOSPC);
textdump_error = dump_write(di, buffer, 0, offset + di->mediaoffset, textdump_error = dump_write(di, buffer, offset + di->mediaoffset,
TEXTDUMP_BLOCKSIZE); TEXTDUMP_BLOCKSIZE);
if (textdump_error) if (textdump_error)
printf("textdump_writeblock: offset %jd, error %d\n", (intmax_t)offset, printf("textdump_writeblock: offset %jd, error %d\n", (intmax_t)offset,
@ -501,7 +501,7 @@ textdump_dumpsys(struct dumperinfo *di)
* Terminate the dump, report any errors, and clear the pending flag. * Terminate the dump, report any errors, and clear the pending flag.
*/ */
if (textdump_error == 0) if (textdump_error == 0)
(void)dump_write(di, NULL, 0, 0, 0); (void)dump_write(di, NULL, 0, 0);
if (textdump_error == ENOSPC) if (textdump_error == ENOSPC)
printf("Textdump: Insufficient space on dump partition\n"); printf("Textdump: Insufficient space on dump partition\n");
else if (textdump_error != 0) else if (textdump_error != 0)

View File

@ -1416,10 +1416,8 @@ g_raid_subdisk_kerneldump(struct g_raid_subdisk *sd, void *virtual,
return (ENXIO); return (ENXIO);
if (sd->sd_disk->d_kd.di.dumper == NULL) if (sd->sd_disk->d_kd.di.dumper == NULL)
return (EOPNOTSUPP); return (EOPNOTSUPP);
return (dump_write(&sd->sd_disk->d_kd.di, return (dump_write(&sd->sd_disk->d_kd.di, virtual,
virtual, 0, sd->sd_disk->d_kd.di.mediaoffset + sd->sd_offset + offset, length));
sd->sd_disk->d_kd.di.mediaoffset + sd->sd_offset + offset,
length));
} }
static void static void

View File

@ -69,7 +69,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, dump_va, 0, fragsz); error = dump_append(di, dump_va, fragsz);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -112,7 +112,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL); wdog_kern_pat(WD_LASTVAL);
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error) if (error)
return (error); return (error);
ptr += len; ptr += len;

View File

@ -122,7 +122,7 @@ dumpsys_buf_seek(struct dumperinfo *di, size_t sz)
while (sz > 0) { while (sz > 0) {
nbytes = MIN(sz, sizeof(buf)); nbytes = MIN(sz, sizeof(buf));
error = dump_append(di, buf, 0, nbytes); error = dump_append(di, buf, nbytes);
if (error) if (error)
return (error); return (error);
sz -= nbytes; sz -= nbytes;
@ -146,7 +146,7 @@ dumpsys_buf_write(struct dumperinfo *di, char *ptr, size_t sz)
ptr += len; ptr += len;
sz -= len; sz -= len;
if (fragsz == di->blocksize) { if (fragsz == di->blocksize) {
error = dump_append(di, di->blockbuf, 0, di->blocksize); error = dump_append(di, di->blockbuf, di->blocksize);
if (error) if (error)
return (error); return (error);
fragsz = 0; fragsz = 0;
@ -163,7 +163,7 @@ dumpsys_buf_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, di->blockbuf, 0, di->blocksize); error = dump_append(di, di->blockbuf, di->blocksize);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -209,7 +209,7 @@ dumpsys_cb_dumpdata(struct dump_pa *mdp, int seqnr, void *arg)
dumpsys_map_chunk(pa, chunk, &va); dumpsys_map_chunk(pa, chunk, &va);
wdog_kern_pat(WD_LASTVAL); wdog_kern_pat(WD_LASTVAL);
error = dump_append(di, va, 0, sz); error = dump_append(di, va, sz);
dumpsys_unmap_chunk(pa, chunk, va); dumpsys_unmap_chunk(pa, chunk, va);
if (error) if (error)
break; break;

View File

@ -1081,8 +1081,7 @@ SYSCTL_PROC(_kern_shutdown, OID_AUTO, dumpdevname,
dumpdevname_sysctl_handler, "A", dumpdevname_sysctl_handler, "A",
"Device(s) for kernel dumps"); "Device(s) for kernel dumps");
static int _dump_append(struct dumperinfo *di, void *virtual, static int _dump_append(struct dumperinfo *di, void *virtual, size_t length);
vm_offset_t physical, size_t length);
#ifdef EKCD #ifdef EKCD
static struct kerneldumpcrypto * static struct kerneldumpcrypto *
@ -1495,8 +1494,8 @@ dump_encrypt(struct kerneldumpcrypto *kdc, uint8_t *buf, size_t size)
/* Encrypt data and call dumper. */ /* Encrypt data and call dumper. */
static int static int
dump_encrypted_write(struct dumperinfo *di, void *virtual, dump_encrypted_write(struct dumperinfo *di, void *virtual, off_t offset,
vm_offset_t physical, off_t offset, size_t length) size_t length)
{ {
static uint8_t buf[KERNELDUMP_BUFFER_SIZE]; static uint8_t buf[KERNELDUMP_BUFFER_SIZE];
struct kerneldumpcrypto *kdc; struct kerneldumpcrypto *kdc;
@ -1512,7 +1511,7 @@ dump_encrypted_write(struct dumperinfo *di, void *virtual,
if (dump_encrypt(kdc, buf, nbytes) != 0) if (dump_encrypt(kdc, buf, nbytes) != 0)
return (EIO); return (EIO);
error = dump_write(di, buf, physical, offset, nbytes); error = dump_write(di, buf, offset, nbytes);
if (error != 0) if (error != 0)
return (error); return (error);
@ -1543,7 +1542,7 @@ kerneldumpcomp_write_cb(void *base, size_t length, off_t offset, void *arg)
*/ */
rlength = rounddown(length, di->blocksize); rlength = rounddown(length, di->blocksize);
if (rlength != 0) { if (rlength != 0) {
error = _dump_append(di, base, 0, rlength); error = _dump_append(di, base, rlength);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -1553,7 +1552,7 @@ kerneldumpcomp_write_cb(void *base, size_t length, off_t offset, void *arg)
di->kdcomp->kdc_resid = resid; di->kdcomp->kdc_resid = resid;
return (EAGAIN); return (EAGAIN);
} }
return (_dump_append(di, base, 0, length)); return (_dump_append(di, base, length));
} }
/* /*
@ -1602,7 +1601,7 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh)
extent = dtoh64(kdh->dumpextent); extent = dtoh64(kdh->dumpextent);
#ifdef EKCD #ifdef EKCD
if (kdc != NULL) { if (kdc != NULL) {
error = dump_write(di, kdc->kdc_dumpkey, 0, error = dump_write(di, kdc->kdc_dumpkey,
di->mediaoffset + di->mediasize - di->blocksize - extent - di->mediaoffset + di->mediasize - di->blocksize - extent -
keysize, keysize); keysize, keysize);
if (error != 0) if (error != 0)
@ -1610,11 +1609,11 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh)
} }
#endif #endif
error = dump_write(di, buf, 0, error = dump_write(di, buf,
di->mediaoffset + di->mediasize - 2 * di->blocksize - extent - di->mediaoffset + di->mediasize - 2 * di->blocksize - extent -
keysize, di->blocksize); keysize, di->blocksize);
if (error == 0) if (error == 0)
error = dump_write(di, buf, 0, di->mediaoffset + di->mediasize - error = dump_write(di, buf, di->mediaoffset + di->mediasize -
di->blocksize, di->blocksize); di->blocksize, di->blocksize);
return (error); return (error);
} }
@ -1703,18 +1702,16 @@ dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh)
} }
static int static int
_dump_append(struct dumperinfo *di, void *virtual, vm_offset_t physical, _dump_append(struct dumperinfo *di, void *virtual, size_t length)
size_t length)
{ {
int error; int error;
#ifdef EKCD #ifdef EKCD
if (di->kdcrypto != NULL) if (di->kdcrypto != NULL)
error = dump_encrypted_write(di, virtual, physical, di->dumpoff, error = dump_encrypted_write(di, virtual, di->dumpoff, length);
length);
else else
#endif #endif
error = dump_write(di, virtual, physical, di->dumpoff, length); error = dump_write(di, virtual, di->dumpoff, length);
if (error == 0) if (error == 0)
di->dumpoff += length; di->dumpoff += length;
return (error); return (error);
@ -1726,8 +1723,7 @@ _dump_append(struct dumperinfo *di, void *virtual, vm_offset_t physical,
* when the compression stream's output buffer is full. * when the compression stream's output buffer is full.
*/ */
int int
dump_append(struct dumperinfo *di, void *virtual, vm_offset_t physical, dump_append(struct dumperinfo *di, void *virtual, size_t length)
size_t length)
{ {
void *buf; void *buf;
@ -1739,15 +1735,14 @@ dump_append(struct dumperinfo *di, void *virtual, vm_offset_t physical,
memmove(buf, virtual, length); memmove(buf, virtual, length);
return (compressor_write(di->kdcomp->kdc_stream, buf, length)); return (compressor_write(di->kdcomp->kdc_stream, buf, length));
} }
return (_dump_append(di, virtual, physical, length)); return (_dump_append(di, virtual, length));
} }
/* /*
* Write to the dump device at the specified offset. * Write to the dump device at the specified offset.
*/ */
int int
dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, dump_write(struct dumperinfo *di, void *virtual, off_t offset, size_t length)
off_t offset, size_t length)
{ {
int error; int error;
@ -1772,7 +1767,7 @@ dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh)
error = compressor_flush(di->kdcomp->kdc_stream); error = compressor_flush(di->kdcomp->kdc_stream);
if (error == EAGAIN) { if (error == EAGAIN) {
/* We have residual data in di->blockbuf. */ /* We have residual data in di->blockbuf. */
error = _dump_append(di, di->blockbuf, 0, di->blocksize); error = _dump_append(di, di->blockbuf, di->blocksize);
if (error == 0) if (error == 0)
/* Compensate for _dump_append()'s adjustment. */ /* Compensate for _dump_append()'s adjustment. */
di->dumpoff -= di->blocksize - di->kdcomp->kdc_resid; di->dumpoff -= di->blocksize - di->kdcomp->kdc_resid;
@ -1796,7 +1791,7 @@ dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh)
if (error != 0) if (error != 0)
return (error); return (error);
(void)dump_write(di, NULL, 0, 0, 0); (void)dump_write(di, NULL, 0, 0);
return (0); return (0);
} }

View File

@ -89,7 +89,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, crashdumpmap, 0, fragsz); error = dump_append(di, crashdumpmap, fragsz);
DBG(dumptotal += fragsz;) DBG(dumptotal += fragsz;)
fragsz = 0; fragsz = 0;
return (error); return (error);
@ -134,7 +134,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
dumpsys_pb_progress(len); dumpsys_pb_progress(len);
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error) if (error)
return (error); return (error);
DBG(dumptotal += len;) DBG(dumptotal += len;)

View File

@ -72,7 +72,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0) if (fragsz == 0)
return (0); return (0);
error = dump_append(di, dump_va, 0, fragsz); error = dump_append(di, dump_va, fragsz);
fragsz = 0; fragsz = 0;
return (error); return (error);
} }
@ -126,7 +126,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL); wdog_kern_pat(WD_LASTVAL);
if (ptr) { if (ptr) {
error = dump_append(di, ptr, 0, len); error = dump_append(di, ptr, len);
if (error != 0) if (error != 0)
return (error); return (error);
ptr += len; ptr += len;

View File

@ -376,8 +376,8 @@ void dumper_ddb_insert(struct dumperinfo *);
void dumper_ddb_remove(struct dumperinfo *); void dumper_ddb_remove(struct dumperinfo *);
int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh); int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh);
int dump_append(struct dumperinfo *, void *, vm_offset_t, size_t); int dump_append(struct dumperinfo *, void *, size_t);
int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); int dump_write(struct dumperinfo *, void *, off_t, size_t);
int dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh); int dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh);
void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh, void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh,
const char *magic, uint32_t archver, uint64_t dumplen); const char *magic, uint32_t archver, uint64_t dumplen);