atom feed37 messages in org.freebsd.freebsd-hackersRe: Frustration with SCSI system
FromSent OnAttachments
Rick HamellSep 19, 2000 5:35 am 
Rick HamellSep 19, 2000 8:42 am 
Alfred PerlsteinSep 20, 2000 12:51 pm 
Edward ElhaugeSep 20, 2000 12:58 pm 
Wilko BulteSep 20, 2000 12:59 pm 
Marc TardifSep 20, 2000 1:08 pm 
Wilko BulteSep 20, 2000 1:18 pm 
David ScheidtSep 20, 2000 1:20 pm 
Alfred PerlsteinSep 20, 2000 1:23 pm 
Edward ElhaugeSep 20, 2000 1:24 pm 
Fred CliftSep 20, 2000 1:34 pm 
Bernd WalterSep 20, 2000 1:43 pm 
Alfred PerlsteinSep 20, 2000 1:47 pm 
Nick RognessSep 20, 2000 1:48 pm 
Matthew JacobSep 20, 2000 1:55 pm 
Bernd WalterSep 20, 2000 2:26 pm 
Aleksandr A.BabaylovSep 20, 2000 2:55 pm 
Warner LoshSep 20, 2000 3:01 pm 
Warner LoshSep 20, 2000 3:02 pm 
David ScheidtSep 20, 2000 3:28 pm 
Aleksandr A.BabaylovSep 20, 2000 3:50 pm 
Sergey BabkinSep 20, 2000 5:47 pm 
MikeSep 20, 2000 6:09 pm 
David ScheidtSep 20, 2000 6:50 pm 
Aleksandr A.BabaylovSep 20, 2000 8:58 pm 
Keith KempSep 21, 2000 3:28 pm 
Douglas SwarinSep 21, 2000 4:23 pm 
Warner LoshSep 21, 2000 4:44 pm 
Sergey BabkinSep 21, 2000 5:08 pm 
Joe GrecoSep 21, 2000 7:32 pm 
Joe GrecoSep 21, 2000 7:37 pm 
Douglas SwarinSep 21, 2000 10:26 pm 
jdb-...@layer8.netSep 21, 2000 11:55 pm 
Adrian ChaddSep 22, 2000 7:23 am 
Wes PetersSep 22, 2000 10:41 pm 
Warner LoshSep 23, 2000 8:21 am 
Andreas KlemmOct 3, 2000 11:18 am 
Subject:Re: Frustration with SCSI system
From:Joe Greco (jgr@ns.sol.net)
Date:Sep 21, 2000 7:37:24 pm
List:org.freebsd.freebsd-hackers

Whoops, sorry about the previous misfire...

In message <2000@ns2.uncanny.net> Edward Elhauge writes: : to autorecover on bad sectors, but every system that I've had to recover : seems to be in a state where the bad sectors aren't remapping. I've tried

I've often wanted to write a bad block remapper. While SCSI is supposed to do this automatically, I've found that a scan on any adaptec controller will remap these blocks (forces the remapping).

I've got a program which attempts to read all blocks and may be able to rewrite bad blocks. It's nothing fancy. Only works if you've got auto-reallocate turned on in the drive.

% cat diskscan.c #include <stdio.h> #include <unistd.h> #include <errno.h> #include <fcntl.h>

int fixup(off, fd) off_t off; int fd; { char buffer[512]; int i, rval;

for (i = 0; i < 65536; i += 512) { if (lseek(fd, off + i, SEEK_SET) < 0) { doerror("lseek", off + i, 0); } if ((rval = read(fd, buffer, sizeof(buffer))) != sizeof(buffer)) { if (errno) { if (lseek(fd, off + i, SEEK_SET) < 0) { doerror("lseek", off + i, 0); } write(fd, buffer, sizeof(buffer)); } } } }

int doerror(str, off, type) char *str; off_t off; int type; { static int ign = 0; char buffer[80];

fprintf(stderr, "\nError at %qx, ", (quad_t) off); perror(str); if (! ign) { if (type) { fprintf(stderr, "Attempt to correct? (y/n/a) "); } else { fprintf(stderr, "Press 'y' to continue: "); } while (! ign) { fgets(buffer, sizeof(buffer), stdin); if (*buffer == 'y') { return(0); } if (*buffer == 'n') { return(1); } if (*buffer == 'a') { ign++; return(0); } } } return(0); }

int main(argc, argv) int argc; char *argv[]; { int fd, rval; char buffer[65536]; off_t off = 0; int eof = 0; int count = 0;

if (argc != 2) { fprintf(stderr, "usage: diskscan <dev>\n"); exit(1); } if ((fd = open(argv[1], O_RDWR, 0644)) < 0) { perror(argv[1]); } while (! eof) { if (! count) { fprintf(stderr, "%qx, ", (quad_t) off); } count++; count %= 8;

if (lseek(fd, off, SEEK_SET) < 0) { doerror("lseek", off, 0); } if ((rval = read(fd, buffer, sizeof(buffer))) != sizeof(buffer)) { if (errno) { if (! doerror("read", off, 1)) { fixup(off, fd); } } } off += sizeof(buffer); } }

I don't even guarantee that it's correct, but I do use it with some success... vinum takes an entire drive offline when it sees an error, and I use this to scan for and fix errors before turning the drive back on.

To Unsubscribe: send mail to majo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message