From owner-freebsd-hackers Sat Jun 10 04:48:25 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id EAA11727 for hackers-outgoing; Sat, 10 Jun 1995 04:48:25 -0700 Received: from hda.com (hda.com [199.232.40.182]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id EAA11715 for ; Sat, 10 Jun 1995 04:48:18 -0700 Received: (dufault@localhost) by hda.com (8.6.11/8.3) id HAA20268; Sat, 10 Jun 1995 07:47:26 -0400 From: Peter Dufault Message-Id: <199506101147.HAA20268@hda.com> Subject: Re: Quantum bad && how to disable a sector To: guido@IAEhv.nl (Guido van Rooij) Date: Sat, 10 Jun 1995 07:47:26 -0400 (EDT) Cc: freebsd-hackers@freebsd.org In-Reply-To: <199506100942.LAA03929@iaehv.IAEhv.nl> from "Guido van Rooij" at Jun 10, 95 11:42:24 am X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 5992 Sender: hackers-owner@freebsd.org Precedence: bulk Guido van Rooij writes: > > Hi, > > > Lately I'm getting medium error on my only half a year old Quantum > empire 2100s. This is already the second time :-( > I think this is a bad choise for a disk. Check that the AWRE and ARRE (automatic write reallocation and automatic read reallocation) are enabled on the drive. You need 2.05 to do it. Edit mode page 1 using scsi: > scsi -f /dev/rsd0.ctl -m 1 -e And to save permanently: > scsi -f /dev/rsd0.ctl -m 1 -e -P 3 > Further: how can I disable that sector? Or can I easily find the inode > occupying it and clri it? Once read/write reallocation are on the sector will get mapped out when a read succeeds after retries or when a write fails. Writes will be transparent; for hard read failures you will have to (currently) write trash to that block, or use the following program to map out the sector. WARNING: I have not used this program recently. I tested and used it a lot in the past, and have no reason to believe that it doesn't work any longer, but please be sure you have backups. Run the program when the partition with the bogus sector in it is not mounted. You will need 2.05 for this to work. /* slipsec: Slip a sector using "reallocate block". * * "WARNING: I have not used this program recently. I tested and used it * a lot in the past, and have no reason to believe that it doesn't work * any longer, but please be sure you have backups." * * Copyright (C) 1995, HD Associates, Inc. * PO Box 276 * Pepperell, MA 01463 * 508 433 5266 * dufault@hda.com * * 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 HD Associates, Inc.. * 4. HD Associates name man not be used * to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES ``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 HD ASSOCIATES 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. * */ #include #include #include #include #include int main(int argc, char *argv[]) { scsireq_t *scsireq; int qualifier, type, rmb, modifier, iso, ecma, ansi; char vendor_id[17], product_id[17], revision[5]; int lba, len; int i; int fid; u_char *inq_buf = malloc(96), *lbas; u_long block = 0; int n; if (argc < 3) { fprintf(stderr, "Usage: %s device sector1 ... sectorn\n", argv[0]); exit(-1); } fid = scsi_open(argv[1], O_RDWR); if (fid == -1) { perror(argv[1]); exit(errno); } scsireq = scsireq_build(scsireq_new(), 96, inq_buf, SCCMD_READ, "12 0 0 0 v 0", 96); if (scsireq_enter(fid, scsireq) == -1) { scsi_debug(stderr, -1, scsireq); exit(errno); } scsireq_decode(scsireq, "b3 b5 b1 b7 b2 b3 b3 s8 z16 z16 z4", &qualifier, &type, &rmb, &modifier, &iso, &ecma, &ansi, vendor_id, product_id, revision); printf("%s %s %s\n", vendor_id, product_id, revision); if (type != 0) { printf("This is not a direct access device.\n"); exit(0); } switch(ansi) { case 0: printf("WARNING: This device might not comply to any standard.\n"); break; case 1: printf("This is a SCSI-1 device.\n"); break; case 2: printf("This is a SCSI-2 device.\n"); break; } /* How many blocks? */ if (scsireq_enter(fid, scsireq_build(scsireq, 8, inq_buf, SCCMD_READ, "25 0 0 0 0 0 0 0 0 0")) == -1) /* Read capacity */ { scsi_debug(stderr, -1, scsireq); exit(errno); } scsireq_decode(scsireq, "i4 i4", &lba, &len); printf("The device has %d %d byte blocks.\n", lba, len); fflush(stdout); /* Verify all blocks seem reasonable first: */ for (i = 2; i < argc; i++) { if ((block = strtoul(argv[i], 0, 0)) > lba) { fprintf(stderr, "Block at %ld outside of maximum %d.\n", block, lba); exit(-1); } } n = i - 2; len = 4 + 4 * n; if ( (lbas = malloc(len)) == 0 ) { perror("malloc"); exit(errno); } (void)scsireq_build(scsireq, len, lbas, SCCMD_WRITE, "07 0 0 0 0 0"); scsireq_encode(scsireq, "0 0 v:i2 ", 4 * n); for (i = 0; i < n; i++) scsireq_encode(scsireq, "sv v:i4 ", 4 + 4 * i, strtoul(argv[i + 2], 0, 0)); if (scsireq_enter(fid, scsireq) == -1) { perror("scsireq_enter"); exit(errno); } /* Did we get sense? */ if (scsireq->senselen_used) { int valid, code, key, info, asc, ascq; scsireq_buff_decode(scsireq->sense, scsireq->senselen_used, "b1 b7 *i1 *b4 b4 i4 s12 i1 i1", &valid, &code, &key, &info, &asc, &ascq); printf("Block %lx: valid %d code %02x sense key %02x info %x asc %02x ascq %02x\n", block, valid, code, key, info, asc, ascq); fflush(stdout); } exit(0); } -- Peter Dufault Real Time Machine Control and Simulation HD Associates, Inc. Voice: 508 433 6936 dufault@hda.com Fax: 508 433 5267