On Sat, 27 Jan 2001, Ken Bass wrote:

> I am really stuck. I'm using the /dev/sg driver in cooperation with the
> /dev/st driver.
> I am using fwrite to the /dev/st device to write data to a tape. Every 10
> seconds, the same task, uses /dev/sg to request a LOG SENSE. I'm trying to
> monitor the data compression statistics, as well as the tape capacity pages.
> (Pages 0x39 and 0x31 and 0x07).
>
In general, it is not advisable to let two drivers try handling one device
at the same time. However, you should be able to read log pages and not to
disturb the tape driver if you do it in the correct way.

> When I fwrite to the /dev/sg. The task hangs and the SCSI bus is screwed up.
> I cannot kill -9 the task. Looking at ps, it appears WCHAN is stuck in
> scsi_allocate_device(). (It says scsi_a, I'm assuming its allocate_device
> from looking at the sg code).
>
> I have to reboot my system and suffer a long and excruciating fsck each
> time.
>
> Here is the odd thing. When I am using /dev/st RD_ONLY, I dont have this
> problem. I use the same routines to read the log pages and they work fine.
> It appears this is only happening with I'm using /dev/st WR_ONLY.
>
This gives a clue about what probably is happening. The asynchronous
writes are enabled in the tape driver by default. This means that there is
one SCSI command being executed while your program prepares more data to
write. Trying to send a command fails because the request structure is in
use.

There are a few ways to get rid of this problem. You can disable the
asynchronous writes in the tape driver (you can either edit the source or
use mt to do this). If you enable tagged queing for this device, you might
not see the problem because you have more than one request structures
available. However, it is preferable to disable asynchronous writes
because then you have sequenced the SCSI commands properly (i.e., the tape
driver has nothing going on while you use sg and vice versa).

In a later message you tell that you can read the log pages using
SCSI_IOCTL_SEND_COMMAND. The reason for this is that before doing this,
the tape driver waits for the write command to finish.

        Kai


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]

Reply via email to