diff options
| author | Poul-Henning Kamp <phk@FreeBSD.org> | 2002-09-20 12:52:03 +0000 | 
|---|---|---|
| committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2002-09-20 12:52:03 +0000 | 
| commit | f90c382c0c6c8b94d43903c8df4b52b4574fadd8 (patch) | |
| tree | 1d367b627ceceea40420446ef7bb5ef0ae17c419 | |
| parent | 47fae43eab10c482074c64a399e3a07ea9375d9f (diff) | |
Notes
| -rw-r--r-- | sys/dev/aac/aac_disk.c | 8 | ||||
| -rw-r--r-- | sys/dev/aac/aacvar.h | 1 | ||||
| -rw-r--r-- | sys/dev/amr/amrvar.h | 1 | ||||
| -rw-r--r-- | sys/dev/ata/ata-disk.c | 10 | ||||
| -rw-r--r-- | sys/dev/fdc/fdc.c | 5 | ||||
| -rw-r--r-- | sys/dev/mlx/mlxvar.h | 1 | ||||
| -rw-r--r-- | sys/isa/fd.c | 5 | ||||
| -rw-r--r-- | sys/kern/subr_disk.c | 43 | ||||
| -rw-r--r-- | sys/kern/subr_disklabel.c | 57 | ||||
| -rw-r--r-- | sys/kern/subr_diskmbr.c | 11 | ||||
| -rw-r--r-- | sys/pc98/cbus/fdc.c | 4 | ||||
| -rw-r--r-- | sys/pc98/pc98/diskslice_machdep.c | 10 | ||||
| -rw-r--r-- | sys/pc98/pc98/fd.c | 4 | ||||
| -rw-r--r-- | sys/pc98/pc98/wd.c | 3 | ||||
| -rw-r--r-- | sys/sys/disk.h | 1 | ||||
| -rw-r--r-- | sys/sys/disklabel.h | 1 | ||||
| -rw-r--r-- | sys/sys/diskmbr.h | 1 | ||||
| -rw-r--r-- | sys/sys/diskpc98.h | 1 | ||||
| -rw-r--r-- | sys/sys/param.h | 2 | 
19 files changed, 72 insertions, 97 deletions
diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c index 000d8415f8f7..91ceee0985a8 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 d82f29edda64..0f615f10944c 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 4436b3c60584..ad08b67c5864 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 1211e0ad0494..b4a86562b387 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 8c94574b80b1..5e4d3812ba8a 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 84dad18eb403..f5b68e53afa9 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 8c94574b80b1..5e4d3812ba8a 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 8134d8cb8a1c..801eaaf8edc1 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 e10bc615dae9..a650e3a85393 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 40d5b2d4c630..2154f309d491 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 f71ae4b0a6e7..29ab7e3076e8 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 51228dc61a33..02ea80411d30 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 f71ae4b0a6e7..29ab7e3076e8 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 1ed9f1b54829..9c83b569a529 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 ffbd7868ef2b..43a1ae38e9ad 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 24cf5391cba5..a54684314614 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 24cf5391cba5..a54684314614 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 24cf5391cba5..a54684314614 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 8aa71fd0dc87..7eff561b3db4 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  | 
