Bug in SCSI ioctl? (Was: OT - Journaling File Systems?)
Edwards, Scott (MED, Kelly IT Resouces)
James.Edwards at med.ge.com
Tue May 11 18:02:29 UTC 2004
I am still trying to switch off the write cache on the serial ATA drives. I
first tried removing the scsi check from hdparms to allow the -W flag to be
passed to a scsi device. I got a "Invalid Argument" error back from it.
I then tried the sg_utils and I couldn't get them to work either (I can't
remember now how they failed).
So finally I took some code from both the hdparm and sg_utils and made the
following little program (note I left out the #includes):
int main()
{
int fd;
int result;
unsigned char args[4] = {WIN_SETFEATURES,0,0x82,0};
fd = open("/dev/sda", O_RDONLY|O_NONBLOCK);
if (fd < 0) {
perror("/dev/sda");
exit(errno);
}
result = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, &args);
if (result) {
perror(" SCSI_IOCTL_SEND_COMMAND(setcache) failed");
}
else {
printf("OK!");
}
close(fd);
return result;
}
When I run it I get the same result as with hdparms: "Invalid Argument". So
I started digging further into the problem and I have found where it fails
and gets rejected. It's in the /usr/src/linux/drivers/block/scsi_ioctl.c
file. In the scsi_cmd_ioctl routine, in the SCSI_IOCTL_SEND_COMMAND case it
casts the arguments to (Scsi_Ioctl_Command *) and passes it to the
sg_scsi_ioctl routine (which is also in the same scsi_ioctl.c file).
One of the first things that sg_scsi_ioctl does is read the inlen and outlen
from the Scsi_Ioctl_Command structure and verifies they are smaller than the
page size. It appears to me that the arguments are not a Scsi_Ioctl_Command
structure. I printk'ed out the inlen and outlen that is read and they are 8
and 5 some odd megabytes. So then I did a copy_from_user and printed the
arguments and they are the original args that I passed in: { EF, 00, 82, 00,
... }. My guess is that casting those arguments to Scsi_Ioctl_Command is
wrong. But then I could be completely wrong, I don't have the big picture.
I know this is all off topic for this list, but I don't know how to proceed
from here. Since I don't understand what all should be happening in the
code, I don't know if I should start stirring around trying to get it to
work? Is there a kernel list that I should post to?
Thanks
-Scott
-----Original Message-----
From: fedora-test-list-bounces at redhat.com
[mailto:fedora-test-list-bounces at redhat.com]On Behalf Of Alan Cox
Sent: Tuesday, April 27, 2004 3:05 PM
To: For testers of Fedora Core development releases
Subject: Re: OT - Journaling File Systems?
On Tue, Apr 27, 2004 at 03:50:28PM -0500, Edwards, Scott (MED, Kelly IT
Resouces) wrote:
>
> Unfortunately the drive I have right now is a Serial ATA so FC2
> treats it as a SCSI drive and hdparm won't let me change the
> write cache. I'm trying to dig up a regular IDE drive to test
> it on. Is there any way to change it on a SCSI drive?
Some of the scsi generic tools using /dev/sg can set the mode page
bits that control caching. Nothing Fedora ships however. Also some scsi
controllers can set it at bios time.
--
fedora-test-list mailing list
fedora-test-list at redhat.com
To unsubscribe:
http://www.redhat.com/mailman/listinfo/fedora-test-list
More information about the fedora-test-list
mailing list