Re: Read from CD-Rom -> crash

Andries.Brouwer@cwi.nl
Mon, 27 May 1996 20:31:15 +0200


Thomas Niederreiter:

: there is a quite critical bug in the CD-Rom-Code which caused for me
: some extreme heavy crashes. (Reset-Button only)

: The last 4 blocks (each 2048 bytes) can't be read in most cases.
: And here on kernel pre2.0.7 this causes the total blackout.
: 1.3.98 just reports a lot of sense-errors but recovers.

Yes. The (or at least a) problem is the read-ahead.

The SCSI (and other) drivers cannot handle hardware problems -
things used to be worse, but we are still very far from
a satisfactory situation.
This means that if the kernel tries to do readahead past
the end of the CD, it may crash, or get into a "resetting for
second half of retries ..." syndrome. Unpleasantness.

You can set readahead to 0 using the small "raset" utility
below, and this at least allows one to read the last few
blocks on the CD.

What really has to be done is to keep the information that
a request is not from the user but is readahead invented by the
kernel, so that no resetting and retrying is attempted when
readahead fails. I have some patches, but I think it would be
inappropriate to make radical changes in the SCSI code just
before 2.0.

Andries

------------ raset.c ---------------------------------
/*
* raset.c - aeb - set readahead
*/
#include <stdio.h>
#include <linux/fs.h>

main(int argc, char **argv) {
int fd;
long ra;

if(argc != 2 && argc != 3) {
fprintf(stderr, "call: raset device [read-ahead-count]\n");
exit(1);
}

fd = open(argv[1], 0);
if (fd < 0) {
perror(argv[1]);
fprintf(stderr, "cannot open %s\n", argv[1]);
exit(1);
}

if (ioctl(fd, BLKRAGET, &ra)) {
perror("BLKRAGET");
exit(1);
}

printf("current read-ahead: %ld\n", ra);

if (argc == 3) {
ra = atol(argv[2]);
printf("setting it to %ld\n", ra);

if (ioctl(fd, BLKRASET, ra)) {
perror("BLKRASET");
exit(1);
}
}

return 0;
}