summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-09-20 12:52:03 +0000
committerphk <phk@FreeBSD.org>2002-09-20 12:52:03 +0000
commit1919170e9039df45d87abbe1d7b256cc0db1ed19 (patch)
tree1d367b627ceceea40420446ef7bb5ef0ae17c419
parentb003f2381fcadb1c640d68a8885d0a806a0e8d9c (diff)
downloadFreeBSD-src-1919170e9039df45d87abbe1d7b256cc0db1ed19.zip
FreeBSD-src-1919170e9039df45d87abbe1d7b256cc0db1ed19.tar.gz
Make FreeBSD "struct disklabel" agnostic, step 311 of 723:
Rename diskerr() to disk_err() for naming consistency. Drop the by now entirely useless struct disklabel argument. Add a flag argument for new-line termination. Fix a couple of printf-format-casts to %j instead of %l. Correctly print the name of all bio commands. Move the function from subr_disklabel.c to subr_disk.c, and from <sys/disklabel.h> to <sys/disk.h>. Use the new disk_err() throughout, #include <sys/disk.h> as needed. Bump __FreeBSD_version for the sake of the aac disk drivers #ifdefs. Remove unused disklabel members of softc for aac, amr and mlx, which seem to originally have been intended for diskerr() use, but which only rotted and got Copy&Pasted at least two times to many. Sponsored by: DARPA & NAI Labs.
-rw-r--r--sys/dev/aac/aac_disk.c8
-rw-r--r--sys/dev/aac/aacvar.h1
-rw-r--r--sys/dev/amr/amrvar.h1
-rw-r--r--sys/dev/ata/ata-disk.c10
-rw-r--r--sys/dev/fdc/fdc.c5
-rw-r--r--sys/dev/mlx/mlxvar.h1
-rw-r--r--sys/isa/fd.c5
-rw-r--r--sys/kern/subr_disk.c43
-rw-r--r--sys/kern/subr_disklabel.c57
-rw-r--r--sys/kern/subr_diskmbr.c11
-rw-r--r--sys/pc98/cbus/fdc.c4
-rw-r--r--sys/pc98/pc98/diskslice_machdep.c10
-rw-r--r--sys/pc98/pc98/fd.c4
-rw-r--r--sys/pc98/pc98/wd.c3
-rw-r--r--sys/sys/disk.h1
-rw-r--r--sys/sys/disklabel.h1
-rw-r--r--sys/sys/diskmbr.h1
-rw-r--r--sys/sys/diskpc98.h1
-rw-r--r--sys/sys/param.h2
19 files changed, 72 insertions, 97 deletions
diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c
index 000d841..91ceee0 100644
--- a/sys/dev/aac/aac_disk.c
+++ b/sys/dev/aac/aac_disk.c
@@ -305,7 +305,6 @@ void
aac_biodone(struct bio *bp)
{
struct aac_disk *sc;
- int blkno;
debug_called(4);
@@ -313,10 +312,15 @@ aac_biodone(struct bio *bp)
devstat_end_transaction_bio(&sc->ad_stats, bp);
if (bp->bio_flags & BIO_ERROR) {
+#if __FreeBSD_version > 500039
+ disk_err(bp, "hard error", -1, 1);
+#elif __FreeBSD_version > 500005
+ int blkno;
blkno = (sc->ad_label.d_nsectors) ? 0 : -1;
-#if __FreeBSD_version > 500005
diskerr(bp, (char *)bp->bio_driver1, blkno, &sc->ad_label);
#else
+ int blkno;
+ blkno = (sc->ad_label.d_nsectors) ? 0 : -1;
diskerr(bp, (char *)bp->bio_driver1, 0, blkno, &sc->ad_label);
#endif
}
diff --git a/sys/dev/aac/aacvar.h b/sys/dev/aac/aacvar.h
index d82f29e..0f615f1 100644
--- a/sys/dev/aac/aacvar.h
+++ b/sys/dev/aac/aacvar.h
@@ -120,7 +120,6 @@ struct aac_disk
struct aac_container *ad_container;
struct disk ad_disk;
struct devstat ad_stats;
- struct disklabel ad_label;
int ad_flags;
#define AAC_DISK_OPEN (1<<0)
int ad_cylinders;
diff --git a/sys/dev/amr/amrvar.h b/sys/dev/amr/amrvar.h
index 4436b3c..ad08b67 100644
--- a/sys/dev/amr/amrvar.h
+++ b/sys/dev/amr/amrvar.h
@@ -223,7 +223,6 @@ struct amrd_softc
struct amr_logdrive *amrd_drive;
struct disk amrd_disk;
struct devstat amrd_stats;
- struct disklabel amrd_label;
int amrd_unit;
int amrd_flags;
#define AMRD_OPEN (1<<0) /* drive is open (can't detach) */
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 1211e0a..b4a8656 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -563,19 +563,17 @@ ad_interrupt(struct ad_request *request)
/* do we have a corrected soft error ? */
if (adp->device->channel->status & ATA_S_CORR)
- diskerr(request->bp, "soft error (ECC corrected)",
- request->blockaddr + (request->donecount / DEV_BSIZE),
- &adp->disk.d_label);
+ disk_err(request->bp, "soft error (ECC corrected)",
+ request->blockaddr + (request->donecount / DEV_BSIZE), 1);
/* did any real errors happen ? */
if ((adp->device->channel->status & ATA_S_ERROR) ||
(request->flags & ADR_F_DMA_USED && dma_stat & ATA_BMSTAT_ERROR)) {
adp->device->channel->error =
ATA_INB(adp->device->channel->r_io, ATA_ERROR);
- diskerr(request->bp, (adp->device->channel->error & ATA_E_ICRC) ?
+ disk_err(request->bp, (adp->device->channel->error & ATA_E_ICRC) ?
"UDMA ICRC error" : "hard error",
- request->blockaddr + (request->donecount / DEV_BSIZE),
- &adp->disk.d_label);
+ request->blockaddr + (request->donecount / DEV_BSIZE), 1);
/* if this is a UDMA CRC error, reinject request */
if (request->flags & ADR_F_DMA_USED &&
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 8c94574..5e4d381 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -62,6 +62,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
+#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
#include <sys/fdcio.h>
@@ -2512,8 +2513,8 @@ retrier(struct fdc_data *fdc)
default:
fail:
if ((fd->options & FDOPT_NOERRLOG) == 0) {
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ disk_err(bp, "hard error",
+ fdc->fd->skip / DEV_BSIZE, 0);
if (fdc->flags & FDC_STAT_VALID) {
printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
diff --git a/sys/dev/mlx/mlxvar.h b/sys/dev/mlx/mlxvar.h
index 84dad18..f5b68e5 100644
--- a/sys/dev/mlx/mlxvar.h
+++ b/sys/dev/mlx/mlxvar.h
@@ -230,7 +230,6 @@ struct mlxd_softc
struct mlx_sysdrive *mlxd_drive;
struct disk mlxd_disk;
struct devstat mlxd_stats;
- struct disklabel mlxd_label;
int mlxd_unit;
int mlxd_flags;
#define MLXD_OPEN (1<<0) /* drive is open (can't shut down) */
diff --git a/sys/isa/fd.c b/sys/isa/fd.c
index 8c94574..5e4d381 100644
--- a/sys/isa/fd.c
+++ b/sys/isa/fd.c
@@ -62,6 +62,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
+#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
#include <sys/fdcio.h>
@@ -2512,8 +2513,8 @@ retrier(struct fdc_data *fdc)
default:
fail:
if ((fd->options & FDOPT_NOERRLOG) == 0) {
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ disk_err(bp, "hard error",
+ fdc->fd->skip / DEV_BSIZE, 0);
if (fdc->flags & FDC_STAT_VALID) {
printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 8134d8c..801eaaf 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -11,15 +11,16 @@
*/
#include "opt_geom.h"
-#ifndef GEOM
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
+#include <sys/stdint.h>
#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/disk.h>
+#ifndef GEOM
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <machine/md_var.h>
@@ -432,3 +433,39 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD,
0, sizeof(struct disk), "sizeof(struct disk)");
#endif
+
+/*-
+ * Disk error is the preface to plaintive error messages
+ * about failing disk transfers. It prints messages of the form
+ * "hp0g: BLABLABLA cmd=read fsbn 12345 of 12344-12347"
+ * blkdone should be -1 if the position of the error is unknown.
+ * The message is printed with printf.
+ */
+void
+disk_err(struct bio *bp, const char *what, int blkdone, int nl)
+{
+ daddr_t sn;
+
+ printf("%s: %s", devtoname(bp->bio_dev), what);
+ switch(bp->bio_cmd) {
+ case BIO_READ: printf("cmd=read"); break;
+ case BIO_WRITE: printf("cmd=write"); break;
+ case BIO_DELETE: printf("cmd=delete"); break;
+ case BIO_GETATTR: printf("cmd=getattr"); break;
+ case BIO_SETATTR: printf("cmd=setattr"); break;
+ default: printf("cmd=%x", bp->bio_cmd); break;
+ }
+ sn = bp->bio_blkno;
+ if (bp->bio_bcount <= DEV_BSIZE) {
+ printf("fsbn %jd%s", (intmax_t)sn, nl ? "\n" : "");
+ return;
+ }
+ if (blkdone >= 0) {
+ sn += blkdone;
+ printf("fsbn %jd of ", (intmax_t)sn);
+ }
+ printf("%jd-%jd", (intmax_t)bp->bio_blkno,
+ (intmax_t)(bp->bio_blkno + (bp->bio_bcount - 1) / DEV_BSIZE));
+ if (nl)
+ printf("\n");
+}
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c
index e10bc61..a650e3a 100644
--- a/sys/kern/subr_disklabel.c
+++ b/sys/kern/subr_disklabel.c
@@ -367,60 +367,3 @@ done:
brelse(bp);
return (error);
}
-
-/*
- * Disk error is the preface to plaintive error messages
- * about failing disk transfers. It prints messages of the form
-
-hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d)
-
- * if the offset of the error in the transfer and a disk label
- * are both available. blkdone should be -1 if the position of the error
- * is unknown; the disklabel pointer may be null from drivers that have not
- * been converted to use them. The message is printed with printf.
- * The message should be completed with at least a newline. There is no
- * trailing space.
- */
-void
-diskerr(bp, what, blkdone, lp)
- struct bio *bp;
- char *what;
- int blkdone;
- register struct disklabel *lp;
-{
- int part = dkpart(bp->bio_dev);
- char partname[2];
- char *sname;
- daddr_t sn;
-
- *partname = '\0';
- sname = bp->bio_dev->si_name;
- printf("%s%s: %s %sing fsbn ", sname, partname, what,
- bp->bio_cmd == BIO_READ ? "read" : "writ");
- sn = bp->bio_blkno;
- if (bp->bio_bcount <= DEV_BSIZE)
- printf("%jd", (intmax_t)sn);
- else {
- if (blkdone >= 0) {
- sn += blkdone;
- printf("%jd of ", (intmax_t)sn);
- }
- printf("%ld-%ld", (long)bp->bio_blkno,
- (long)(bp->bio_blkno + (bp->bio_bcount - 1) / DEV_BSIZE));
- }
- if (lp && (blkdone >= 0 || bp->bio_bcount <= lp->d_secsize)) {
- sn += lp->d_partitions[part].p_offset;
- /*
- * XXX should add slice offset and not print the slice,
- * but we don't know the slice pointer.
- * XXX should print bp->b_pblkno so that this will work
- * independent of slices, labels and bad sector remapping,
- * but some drivers don't set bp->b_pblkno.
- */
- printf(" (%s bn %jd; cn %jd", sname, (intmax_t)sn,
- (intmax_t)(sn / lp->d_secpercyl));
- sn %= lp->d_secpercyl;
- printf(" tn %ld sn %ld)", (long)(sn / lp->d_nsectors),
- (long)(sn % lp->d_nsectors));
- }
-}
diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c
index 40d5b2d..2154f30 100644
--- a/sys/kern/subr_diskmbr.c
+++ b/sys/kern/subr_diskmbr.c
@@ -47,6 +47,7 @@
#define PC98_ATCOMPAT
#define dsinit atcompat_dsinit
#endif
+#include <sys/disk.h>
#include <sys/disklabel.h>
#define DOSPTYP_EXTENDED 5
#define DOSPTYP_EXTENDEDX 15
@@ -214,9 +215,8 @@ reread_mbr:
bp->b_iocmd = BIO_READ;
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading primary partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading primary partition table: error",
+ 0, 1);
error = EIO;
goto done;
}
@@ -417,9 +417,8 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors,
bp->b_iocmd = BIO_READ;
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading extended partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading extended partition table: error",
+ 0, 1);
goto done;
}
diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c
index f71ae4b..29ab7e3 100644
--- a/sys/pc98/cbus/fdc.c
+++ b/sys/pc98/cbus/fdc.c
@@ -3054,8 +3054,8 @@ retrier(struct fdc_data *fdc)
default:
fail:
if ((fd->options & FDOPT_NOERRLOG) == 0) {
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ disk_err(bp, "hard error",
+ fdc->fd->skip / DEV_BSIZE, 0);
if (fdc->flags & FDC_STAT_VALID) {
printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
diff --git a/sys/pc98/pc98/diskslice_machdep.c b/sys/pc98/pc98/diskslice_machdep.c
index 51228dc..02ea804 100644
--- a/sys/pc98/pc98/diskslice_machdep.c
+++ b/sys/pc98/pc98/diskslice_machdep.c
@@ -250,9 +250,8 @@ reread_mbr:
#endif
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading primary partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading primary partition table: error",
+ 0, 1);
error = EIO;
goto done;
}
@@ -533,9 +532,8 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors,
bp->b_iocmd = BIO_READ;
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading extended partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading extended partition table: error",
+ 0, 1);
goto done;
}
diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c
index f71ae4b..29ab7e3 100644
--- a/sys/pc98/pc98/fd.c
+++ b/sys/pc98/pc98/fd.c
@@ -3054,8 +3054,8 @@ retrier(struct fdc_data *fdc)
default:
fail:
if ((fd->options & FDOPT_NOERRLOG) == 0) {
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ disk_err(bp, "hard error",
+ fdc->fd->skip / DEV_BSIZE, 0);
if (fdc->flags & FDC_STAT_VALID) {
printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
diff --git a/sys/pc98/pc98/wd.c b/sys/pc98/pc98/wd.c
index 1ed9f1b..9c83b56 100644
--- a/sys/pc98/pc98/wd.c
+++ b/sys/pc98/pc98/wd.c
@@ -1874,8 +1874,7 @@ wderror(struct bio *bp, struct softc *du, char *mesg)
if (bp == NULL)
printf("wd%d: %s", du->dk_lunit, mesg);
else
- diskerr(bp, mesg, du->dk_skip,
- dsgetlabel(bp->bio_dev, du->dk_slices));
+ disk_err(bp, mesg, du->dk_skip, 0);
printf(" (status %b error %b)\n",
du->dk_status, WDCS_BITS, du->dk_error, WDERR_BITS);
}
diff --git a/sys/sys/disk.h b/sys/sys/disk.h
index ffbd786..43a1ae3 100644
--- a/sys/sys/disk.h
+++ b/sys/sys/disk.h
@@ -43,6 +43,7 @@ struct disk {
dev_t disk_create(int unit, struct disk *disk, int flags, struct cdevsw *cdevsw, struct cdevsw *diskdevsw);
void disk_destroy(dev_t dev);
struct disk *disk_enumerate(struct disk *disk);
+void disk_err(struct bio *bp, const char *what, int blkdone, int nl);
void disk_invalidate(struct disk *disk);
#endif
diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h
index 24cf539..a546843 100644
--- a/sys/sys/disklabel.h
+++ b/sys/sys/disklabel.h
@@ -395,7 +395,6 @@ struct bio_queue_head;
int bounds_check_with_label(struct bio *bp, struct disklabel *lp,
int wlabel);
-void diskerr(struct bio *bp, char *what, int blkdone, struct disklabel *lp);
dev_t dkmodpart(dev_t dev, int part);
dev_t dkmodslice(dev_t dev, int slice);
u_int dkunit(dev_t dev);
diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h
index 24cf539..a546843 100644
--- a/sys/sys/diskmbr.h
+++ b/sys/sys/diskmbr.h
@@ -395,7 +395,6 @@ struct bio_queue_head;
int bounds_check_with_label(struct bio *bp, struct disklabel *lp,
int wlabel);
-void diskerr(struct bio *bp, char *what, int blkdone, struct disklabel *lp);
dev_t dkmodpart(dev_t dev, int part);
dev_t dkmodslice(dev_t dev, int slice);
u_int dkunit(dev_t dev);
diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h
index 24cf539..a546843 100644
--- a/sys/sys/diskpc98.h
+++ b/sys/sys/diskpc98.h
@@ -395,7 +395,6 @@ struct bio_queue_head;
int bounds_check_with_label(struct bio *bp, struct disklabel *lp,
int wlabel);
-void diskerr(struct bio *bp, char *what, int blkdone, struct disklabel *lp);
dev_t dkmodpart(dev_t dev, int part);
dev_t dkmodslice(dev_t dev, int slice);
u_int dkunit(dev_t dev);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 8aa71fd..7eff561 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -55,7 +55,7 @@
* doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 500039 /* Master, propagated to newvers */
+#define __FreeBSD_version 500040 /* Master, propagated to newvers */
#ifndef NULL
#define NULL 0
OpenPOWER on IntegriCloud