unkillable processes created when calling scsi cdrom ioctls

Aaron Passey (aaronp@ofb.net)
19 Feb 1998 03:06:49 GMT


The following program hangs waiting for the first forked process to
finish. After pressing ^C, the process created is unkillable and the cdrom is
unusable since that process is holding the file descriptor open. The whole
reason I even want to fork off a process is there are no non-blocking open and
close cdrom ioctls, which I need. Sadly, this is the simplest program I could
create that causes the unkillable process. Also, I couldn't find a test case
that uses only one cdrom.

Does anyone have any ideas as to what is happening? I'm not entirely
sure where to start debugging this. I am willing to do any experiments to
figure out the problem.

As another data point, running this same program on a computer with an
Adaptec 1542 causes repeated scsi bus resets until the whole computer grinds to
a halt.

This is with kernel 2.1.87. I also tried 2.1.86 (with the older
Buslogic driver) and 2.1.72. I put a bunch of info from /proc at the bottom of
the message.

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/cdrom.h>
#include <unistd.h>
#include <sys/wait.h>
#include <fcntl.h>

#include <stdio.h>

int main() {
int fd1 = open("/dev/scd1", O_RDONLY | O_NONBLOCK);
int fd3 = open("/dev/scd3", O_RDONLY | O_NONBLOCK);
int pid1, pid3;

printf("fd1 = %d, fd3 = %d\n", fd1, fd3);

printf("non-forking close /dev/scd3\n");
if(ioctl(fd3, CDROMCLOSETRAY) < 0) {
perror("parent: Couldn't close cdrom tray");
return -1;
}

printf("forking close /dev/scd1\n");
if(!(pid1 = fork())) {
if(ioctl(fd1, CDROMCLOSETRAY) < 0) {
perror("child: Couldn't close cdrom tray");
_exit(1);
}
_exit(0);
}
printf(" pid1 = %d\n", pid1);

printf("forking close /dev/scd3\n");
if(!(pid3 = fork())) {
if(ioctl(fd3, CDROMCLOSETRAY) < 0) {
perror("child: Couldn't close cdrom tray");
_exit(1);
}
_exit(0);
}
printf(" pid3 = %d\n", pid3);

printf("Waiting for /dev/scd1 to close pid1 = %d\n", pid1);
waitpid(pid1, 0, 0);

/* It crashes right here. waitpid() never returns. */

printf("Waiting for /dev/scd3 to open pid3 = %d\n", pid3);
waitpid(pid3, 0, 0);

printf("Done!\n");
return 0;
}

Here are the vital stats of my system:

% cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: SEAGATE Model: ST32272N Rev: 0784
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: CyberDrv Model: SCSI CD-ROM 120S Rev: 1.30
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
Vendor: CyberDrv Model: SCSI CD-ROM 120S Rev: 1.30
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 03 Lun: 00
Vendor: CyberDrv Model: SCSI CD-ROM 120S Rev: 1.30
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 04 Lun: 00
Vendor: CyberDrv Model: SCSI CD-ROM 120S Rev: 1.30
Type: CD-ROM ANSI SCSI revision: 02

% cat /proc/scsi/Buslogic/0
***** BusLogic SCSI Driver Version 2.0.11 of 31 January 1998 *****
Copyright 1995 by Leonard N. Zubkoff <lnz@dandelion.com>
Configuring BusLogic Model BT-930 PCI Ultra SCSI Host Adapter
Firmware Version: 5.02, I/O Address: 0xD800, IRQ Channel: 11/Level
PCI Bus: 0, Device: 10, Address: 0xE7000000, Host Adapter SCSI ID: 7
Parity Checking: Enabled, Extended Translation: Enabled
Synchronous Negotiation: Fast, Wide Negotiation: Disabled
Disconnect/Reconnect: Enabled, Tagged Queuing: Enabled
Driver Queue Depth: 255, Scatter/Gather Limit: 128 segments
Tagged Queue Depth: Automatic, Untagged Queue Depth: 3
Error Recovery Strategy: Default, SCSI Bus Reset: Enabled
SCSI Bus Termination: Disabled, SCAM: Disabled
*** BusLogic BT-930 Initialized Successfully ***

Target 0: Queue Depth 28, Synchronous at 10.0 MB/sec, offset 15
Target 1: Queue Depth 3, Synchronous at 10.0 MB/sec, offset 8
Target 2: Queue Depth 3, Synchronous at 10.0 MB/sec, offset 8
Target 3: Queue Depth 3, Synchronous at 10.0 MB/sec, offset 8
Target 4: Queue Depth 3, Synchronous at 10.0 MB/sec, offset 8

Current Driver Queue Depth: 255
Currently Allocated CCBs: 49

DATA TRANSFER STATISTICS

Target Tagged Queuing Queue Depth Active Attempted Completed
====== ============== =========== ====== ========= =========
0 Active 28 0 2842 2842
1 Not Supported 3 0 3 3
2 Not Supported 3 1 26 25
3 Not Supported 3 0 3 3
4 Not Supported 3 0 29 29

Target Read Commands Write Commands Total Bytes Read Total Bytes Written
====== ============= ============== =================== ===================
0 1985 853 7194624 1252352
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0

Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB
====== ======= ========= ========= ========= ========= =========
0 Read 0 1036 63 426 448
0 Write 0 661 142 40 10
1 Read 0 0 0 0 0
1 Write 0 0 0 0 0
2 Read 0 0 0 0 0
2 Write 0 0 0 0 0
3 Read 0 0 0 0 0
3 Write 0 0 0 0 0
4 Read 0 0 0 0 0
4 Write 0 0 0 0 0

Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+
====== ======= ========= ========= ========= ========= =========
0 Read 4 6 2 0 0
0 Write 0 0 0 0 0
1 Read 0 0 0 0 0
1 Write 0 0 0 0 0
2 Read 0 0 0 0 0
2 Write 0 0 0 0 0
3 Read 0 0 0 0 0
3 Write 0 0 0 0 0
4 Read 0 0 0 0 0
4 Write 0 0 0 0 0

ERROR RECOVERY STATISTICS

Command Aborts Bus Device Resets Host Adapter Resets
Target Requested Completed Requested Completed Requested Completed
ID \\\\ Attempted //// \\\\ Attempted //// \\\\ Attempted ////
====== ===== ===== ===== ===== ===== ===== ===== ===== =====
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0

External Host Adapter Resets: 0
Host Adapter Internal Errors: 0

% cat /proc/cpuinfo

processor : 0
cpu family : 5
model : Pentium MMX
vendor_id : GenuineIntel
stepping : 4
fdiv_bug : no
hlt_bug : no
sep_bug : no
f00f_bug : yes
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr mce cx8 mmx
bogomips : 299.01

Thanks for your help,

Aaron

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu