summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-12-08 09:33:00 +0000
committerphk <phk@FreeBSD.org>1999-12-08 09:33:00 +0000
commit551bfa2f51cfd055117aec7f1a0f17294cfbc260 (patch)
tree50da86bbbf154ce5c4d4932b562730a10096f3ab /sys/kern
parent224ba89395ce157c152e89a1113bab7205c0dcf9 (diff)
downloadFreeBSD-src-551bfa2f51cfd055117aec7f1a0f17294cfbc260.zip
FreeBSD-src-551bfa2f51cfd055117aec7f1a0f17294cfbc260.tar.gz
Remove BAD144 support, it has already been disabled for some time.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_diskslice.c81
-rw-r--r--sys/kern/subr_dkbad.c160
2 files changed, 4 insertions, 237 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 2ffc869..09e1dd9 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -59,7 +59,6 @@
#endif
#include <sys/disklabel.h>
#include <sys/diskslice.h>
-#include <sys/dkbad.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/stat.h>
@@ -84,8 +83,6 @@ static void free_ds_labeldevs __P((struct diskslices *ssp, int slice));
#endif
static void partition_info __P((char *sname, int part, struct partition *pp));
static void slice_info __P((char *sname, struct diskslice *sp));
-static void set_ds_bad __P((struct diskslices *ssp, int slice,
- struct dkbad_intern *btp));
static void set_ds_label __P((struct diskslices *ssp, int slice,
struct disklabel *lp));
static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
@@ -143,7 +140,6 @@ clone_label(lp)
* if needed, and signal errors or early completion.
*
* XXX TODO:
- * o Do bad sector remapping. May need to split buffer.
* o Split buffers that are too big for the device.
* o Check for overflow.
* o Finish cleaning this up.
@@ -204,16 +200,6 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
pp = &lp->d_partitions[dkpart(bp->b_dev)];
endsecno = pp->p_size;
slicerel_secno = pp->p_offset + secno;
- if (sp->ds_bad != NULL && ds_debug) {
- daddr_t newsecno;
-
- newsecno = transbad144(sp->ds_bad, slicerel_secno);
- if (newsecno != slicerel_secno)
- printf(
- "dscheck(%s): should map bad sector %ld -> %ld\n",
- devtoname(bp->b_dev),
- (long)slicerel_secno, (long)newsecno);
- }
}
/* overwriting disk label ? */
@@ -358,10 +344,6 @@ dsgone(sspp)
for (slice = 0, ssp = *sspp; slice < ssp->dss_nslices; slice++) {
sp = &ssp->dss_slices[slice];
- if (sp->ds_bad != NULL) {
- free(sp->ds_bad, M_DEVBUF);
- set_ds_bad(ssp, slice, (struct dkbad_intern *)NULL);
- }
#ifdef DEVFS
if (sp->ds_bdev != NULL)
devfs_remove_dev(sp->ds_bdev);
@@ -375,7 +357,7 @@ dsgone(sspp)
}
/*
- * For the "write" commands (DIOCSBAD, DIOCSDINFO and DIOCWDINFO), this
+ * For the "write" commands (DIOCSDINFO and DIOCWDINFO), this
* is subject to the same restriction as dsopen().
*/
int
@@ -428,20 +410,6 @@ dsioctl(dev, cmd, data, flags, sspp)
(char *)ssp);
return (0);
- case DIOCSBAD:
- if ((ssp->dss_oflags & DSO_BAD144) == 0)
- return (ENODEV);
- if (slice == WHOLE_DISK_SLICE)
- return (ENODEV);
- if (!(flags & FWRITE))
- return (EBADF);
- if (lp == NULL)
- return (EINVAL);
- if (sp->ds_bad != NULL)
- free(sp->ds_bad, M_DEVBUF);
- set_ds_bad(ssp, slice, internbad144((struct dkbad *)data, lp));
- return (0);
-
case DIOCSDINFO:
if (slice == WHOLE_DISK_SLICE)
return (ENODEV);
@@ -699,7 +667,6 @@ dsopen(dev, mode, flags, sspp, lp)
struct diskslices **sspp;
struct disklabel *lp;
{
- struct dkbad *btp;
dev_t dev1;
int error;
struct disklabel *lp1;
@@ -831,29 +798,9 @@ dsopen(dev, mode, flags, sspp, lp)
continue;
}
if (lp1->d_flags & D_BADSECT) {
- if ((flags & DSO_BAD144) == 0) {
- log(LOG_ERR,
- "%s: bad sector table not supported\n",
- sname);
- continue;
- }
- btp = malloc(sizeof *btp, M_DEVBUF, M_WAITOK);
- TRACE(("readbad144\n"));
- msg = readbad144(dev1, lp1, btp);
- if (msg != NULL) {
- log(LOG_ERR,
- "%s: cannot find bad sector table (%s)\n",
- sname, msg);
- free(btp, M_DEVBUF);
- free(lp1, M_DEVBUF);
- continue;
- }
- set_ds_bad(ssp, slice, internbad144(btp, lp1));
- free(btp, M_DEVBUF);
- if (sp->ds_bad == NULL) {
- free(lp1, M_DEVBUF);
- continue;
- }
+ log(LOG_ERR, "%s: bad sector table not supported\n",
+ sname);
+ continue;
}
set_ds_label(ssp, slice, lp1);
set_ds_labeldevs(dev1, ssp);
@@ -1064,26 +1011,6 @@ slice_info(sname, sp)
sp->ds_offset, sp->ds_offset + sp->ds_size - 1, sp->ds_size);
}
-/*
- * Most changes to ds_bad, ds_label and ds_wlabel are made using the
- * following functions to ensure coherency of the compatibility slice
- * with the first BSD slice. The openmask fields are _not_ shared and
- * the other fields (ds_offset and ds_size) aren't changed after they
- * are initialized.
- */
-static void
-set_ds_bad(ssp, slice, btp)
- struct diskslices *ssp;
- int slice;
- struct dkbad_intern *btp;
-{
- ssp->dss_slices[slice].ds_bad = btp;
- if (slice == COMPATIBILITY_SLICE)
- ssp->dss_slices[ssp->dss_first_bsd_slice].ds_bad = btp;
- else if (slice == ssp->dss_first_bsd_slice)
- ssp->dss_slices[COMPATIBILITY_SLICE].ds_bad = btp;
-}
-
static void
set_ds_label(ssp, slice, lp)
struct diskslices *ssp;
diff --git a/sys/kern/subr_dkbad.c b/sys/kern/subr_dkbad.c
deleted file mode 100644
index d095418..0000000
--- a/sys/kern/subr_dkbad.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * Copyright (c) 1994 Bruce D. Evans.
- * All rights reserved.
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)wd.c 7.2 (Berkeley) 5/9/91
- * from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
- * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
- * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/conf.h>
-#include <sys/disklabel.h>
-#include <sys/dkbad.h>
-#include <sys/malloc.h>
-
-/*
- * Internalize the bad sector table.
- * TODO:
- * o Fix types.
- * Type long should be daddr_t since we compare with blkno's.
- * Sentinel -1 should be ((daddr_t)-1).
- * o Can remove explicit test for sentinel if it is a positive
- * (unsigned or not) value larger than all possible blkno's.
- * o Check that the table is sorted.
- * o Use faster searches.
- * o Use the internal table in wddump().
- * o Don't duplicate so much code.
- * o Do all bad block handing in a driver-independent file.
- * o Remove limit of 126 spare sectors.
- */
-struct dkbad_intern *
-internbad144(btp, lp)
- struct dkbad *btp;
- struct disklabel *lp;
-{
- struct dkbad_intern *bip;
- int i;
-
- bip = malloc(sizeof *bip, M_DEVBUF, M_WAITOK);
- /*
- * Spare sectors are allocated beginning with the last sector of
- * the second last track of the disk (the last track is used for
- * the bad sector list).
- */
- bip->bi_maxspare = lp->d_secperunit - lp->d_nsectors - 1;
- bip->bi_nbad = DKBAD_MAXBAD;
- i = 0;
- for (; i < DKBAD_MAXBAD && btp->bt_bad[i].bt_cyl != DKBAD_NOCYL; i++)
- bip->bi_bad[i] = btp->bt_bad[i].bt_cyl * lp->d_secpercyl
- + (btp->bt_bad[i].bt_trksec >> 8)
- * lp->d_nsectors
- + (btp->bt_bad[i].bt_trksec & 0x00ff);
- bip->bi_bad[i] = -1;
- return (bip);
-}
-
-char *
-readbad144(dev, lp, bdp)
- dev_t dev;
- struct disklabel *lp;
- struct dkbad *bdp;
-{
- struct buf *bp;
- struct dkbad *db;
- int i;
- char *msg;
-
- bp = geteblk((int)lp->d_secsize);
- i = 0;
- do {
- /* Read a bad sector table. */
- bp->b_dev = dev;
- bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
- if (lp->d_secsize > DEV_BSIZE)
- bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
- else
- bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags |= B_READ;
- bp->b_flags &= ~B_ERROR;
- BUF_STRATEGY(bp, 1);
-
- /* If successful, validate, otherwise try another. */
- if (biowait(bp) == 0) {
- db = (struct dkbad *)(bp->b_data);
- if (db->bt_mbz == 0 && db->bt_flag == DKBAD_MAGIC) {
- msg = NULL;
- *bdp = *db;
- break;
- }
- msg = "bad sector table corrupted";
- } else
- msg = "bad sector table I/O error";
- } while ((bp->b_flags & B_ERROR) && (i += 2) < 10 &&
- i < lp->d_nsectors);
- bp->b_flags |= B_INVAL | B_AGE;
- brelse(bp);
- return (msg);
-}
-
-daddr_t
-transbad144(bip, blkno)
- struct dkbad_intern *bip;
- daddr_t blkno;
-{
- int i;
-
- /*
- * List is sorted, so the search can terminate when it is past our
- * sector.
- */
- for (i = 0; bip->bi_bad[i] != -1 && bip->bi_bad[i] <= blkno; i++)
- if (bip->bi_bad[i] == blkno)
- /*
- * Spare sectors are allocated in decreasing order.
- */
- return (bip->bi_maxspare - i);
- return (blkno);
-}
OpenPOWER on IntegriCloud