All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Drive tester
       [not found]     ` <23E65EE4544D484CBE73B588E192C6D612D301CCCD@sc-vexch3.marvell.com>
@ 2009-07-23 22:31       ` Greg Freemyer
  2009-07-24  5:34         ` Robert Hancock
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Freemyer @ 2009-07-23 22:31 UTC (permalink / raw)
  To: Bill Weiler; +Cc: Kernelnewbies, IDE/ATA development list

cc'ing: linux-ide@vger.kernel.org

maybe they can help

On Thu, Jul 23, 2009 at 6:12 PM, Bill Weiler<weilerb@marvell.com> wrote:
>
>
> ________________________________________
> From: Greg Freemyer [greg.freemyer@gmail.com]
> Sent: Thursday, July 23, 2009 2:31 PM
> To: Bill Weiler
> Cc: Kernelnewbies
> Subject: Re: Drive tester
>
> On Wed, Jul 22, 2009 at 7:55 PM, Bill Weiler<weilerb@marvell.com> wrote:
>> I wanted to make an Application that could send scripted SCSI and SATA
>> commands to my drives. I have found my Fedora Linux to be too complex to
>> control the drives in this way. I have looked at minimal Linux but I think
>> this would have the same problem. Is there an easier Open Source OS, or an
>> embedded PC Linux that would be easier to modify?
>
> Bill,
>
> For sata drives, have you looked at the SG_IO interface?
>
> That is how hdparm interfaces with the kernel.  I know it sends a lot
> of low level ATA commands to the drive from user space.  I think most
> use the SG_IO interface.  How much simpler can it get?
>
> strace hdparm may give you an education as to how simple it is.
>
> fyi: I believe the kernel looks for dangerous ata commands and blocks
> them.  But I think those are the types of commands that cause data
> loss.  Not sure what the criteria is.
>
> I have studied hdparm and the SG_IO interface and delved into the scsi drivers and ata drivers.
>
> For example, I wanted to script a single NCQ and a single NCQ write. A normal read(fd,buf,4096) does 1 NCQ read but a write(fd,buf,4096) does dozens of NCQ reads before doing the 1 NCQ write. How do I get rid of these reads?
>
> Also, I need to do soft and hard resets and these are not exposed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Drive tester
  2009-07-23 22:31       ` Drive tester Greg Freemyer
@ 2009-07-24  5:34         ` Robert Hancock
  2009-07-30 20:23           ` Greg Freemyer
  2009-08-09 22:06           ` Gwendal Grignou
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Hancock @ 2009-07-24  5:34 UTC (permalink / raw)
  To: Greg Freemyer; +Cc: Bill Weiler, Kernelnewbies, IDE/ATA development list

On 07/23/2009 04:31 PM, Greg Freemyer wrote:
> cc'ing: linux-ide@vger.kernel.org
>
> maybe they can help
>
> On Thu, Jul 23, 2009 at 6:12 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>
>> ________________________________________
>> From: Greg Freemyer [greg.freemyer@gmail.com]
>> Sent: Thursday, July 23, 2009 2:31 PM
>> To: Bill Weiler
>> Cc: Kernelnewbies
>> Subject: Re: Drive tester
>>
>> On Wed, Jul 22, 2009 at 7:55 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>> I wanted to make an Application that could send scripted SCSI and SATA
>>> commands to my drives. I have found my Fedora Linux to be too complex to
>>> control the drives in this way. I have looked at minimal Linux but I think
>>> this would have the same problem. Is there an easier Open Source OS, or an
>>> embedded PC Linux that would be easier to modify?
>> Bill,
>>
>> For sata drives, have you looked at the SG_IO interface?
>>
>> That is how hdparm interfaces with the kernel.  I know it sends a lot
>> of low level ATA commands to the drive from user space.  I think most
>> use the SG_IO interface.  How much simpler can it get?
>>
>> strace hdparm may give you an education as to how simple it is.

The best way to issue arbitrary ATA commands is likely to issue them as 
ATA pass-through SCSI commands using SG_IO, yes.

>>
>> fyi: I believe the kernel looks for dangerous ata commands and blocks
>> them.  But I think those are the types of commands that cause data
>> loss.  Not sure what the criteria is.

If you're running as unprivileged user I believe we block things like 
could do things like brick the drive such as uploading firmware, etc. 
However, if you have read-write access to the device node you can still 
read and write sectors anywhere on the disk. A few commands are blocked 
even for root users, like SET FEATURES - XFER MODE as it will screw up 
the mode configuration, but it's mostly fair game.

>>
>> I have studied hdparm and the SG_IO interface and delved into the scsi drivers and ata drivers.
>>
>> For example, I wanted to script a single NCQ and a single NCQ write. A normal read(fd,buf,4096) does 1 NCQ read but a write(fd,buf,4096) does dozens of NCQ reads before doing the 1 NCQ write. How do I get rid of these reads?

Try opening the device node with O_DIRECT. That will prevent pagecache 
effects from changing the IO pattern. However, you can't get less than 
page-size (4K granularity) on requests, for that you'll need to issue 
SCSI or ATA commands directly.

>>
>> Also, I need to do soft and hard resets and these are not exposed.

Indeed, there's no way currently to trigger these other than as part of 
error handling (i.e. command errors, hotplug operations, etc.) There's 
likely no reason it couldn't be added, but obviously nobody's needed it 
enough to bother so far..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Drive tester
  2009-07-24  5:34         ` Robert Hancock
@ 2009-07-30 20:23           ` Greg Freemyer
  2009-08-09 22:06           ` Gwendal Grignou
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Freemyer @ 2009-07-30 20:23 UTC (permalink / raw)
  To: Robert Hancock; +Cc: Bill Weiler, Kernelnewbies, IDE/ATA development list

On Fri, Jul 24, 2009 at 1:34 AM, Robert Hancock<hancockrwd@gmail.com> wrote:
> On 07/23/2009 04:31 PM, Greg Freemyer wrote:
>>
>> cc'ing: linux-ide@vger.kernel.org
>>
>> maybe they can help
>>
>> On Thu, Jul 23, 2009 at 6:12 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>>
>>> ________________________________________
>>> From: Greg Freemyer [greg.freemyer@gmail.com]
>>> Sent: Thursday, July 23, 2009 2:31 PM
>>> To: Bill Weiler
>>> Cc: Kernelnewbies
>>> Subject: Re: Drive tester
>>>
>>> On Wed, Jul 22, 2009 at 7:55 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>>>
>>>> I wanted to make an Application that could send scripted SCSI and SATA
>>>> commands to my drives. I have found my Fedora Linux to be too complex to
>>>> control the drives in this way. I have looked at minimal Linux but I
>>>> think
>>>> this would have the same problem. Is there an easier Open Source OS, or
>>>> an
>>>> embedded PC Linux that would be easier to modify?
>>>
>>> Bill,
>>>
>>> For sata drives, have you looked at the SG_IO interface?
>>>
>>> That is how hdparm interfaces with the kernel.  I know it sends a lot
>>> of low level ATA commands to the drive from user space.  I think most
>>> use the SG_IO interface.  How much simpler can it get?
>>>
>>> strace hdparm may give you an education as to how simple it is.
>
> The best way to issue arbitrary ATA commands is likely to issue them as ATA
> pass-through SCSI commands using SG_IO, yes.
>
>>>
>>> fyi: I believe the kernel looks for dangerous ata commands and blocks
>>> them.  But I think those are the types of commands that cause data
>>> loss.  Not sure what the criteria is.
>
> If you're running as unprivileged user I believe we block things like could
> do things like brick the drive such as uploading firmware, etc. However, if
> you have read-write access to the device node you can still read and write
> sectors anywhere on the disk. A few commands are blocked even for root
> users, like SET FEATURES - XFER MODE as it will screw up the mode
> configuration, but it's mostly fair game.
>
>>>
>>> I have studied hdparm and the SG_IO interface and delved into the scsi
>>> drivers and ata drivers.
>>>
>>> For example, I wanted to script a single NCQ and a single NCQ write. A
>>> normal read(fd,buf,4096) does 1 NCQ read but a write(fd,buf,4096) does
>>> dozens of NCQ reads before doing the 1 NCQ write. How do I get rid of these
>>> reads?
>
> Try opening the device node with O_DIRECT. That will prevent pagecache
> effects from changing the IO pattern. However, you can't get less than
> page-size (4K granularity) on requests, for that you'll need to issue SCSI
> or ATA commands directly.
>
>>>
>>> Also, I need to do soft and hard resets and these are not exposed.
>
> Indeed, there's no way currently to trigger these other than as part of
> error handling (i.e. command errors, hotplug operations, etc.) There's
> likely no reason it couldn't be added, but obviously nobody's needed it
> enough to bother so far..
>

Bill,

At this point are you only having issues with hard and soft resets?

If so, maybe Mark Lord could be talked into extending hdparm and the
kernel to support those.  Then you could leverage his work in your own
user space code.

Greg
-- 
Greg Freemyer
Head of EDD Tape Extraction and Processing team
Litigation Triage Solutions Specialist
http://www.linkedin.com/in/gregfreemyer
Preservation and Forensic processing of Exchange Repositories White Paper -
<http://www.norcrossgroup.com/forms/whitepapers/tng_whitepaper_fpe.html>

The Norcross Group
The Intersection of Evidence & Technology
http://www.norcrossgroup.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Drive tester
  2009-07-24  5:34         ` Robert Hancock
  2009-07-30 20:23           ` Greg Freemyer
@ 2009-08-09 22:06           ` Gwendal Grignou
  1 sibling, 0 replies; 4+ messages in thread
From: Gwendal Grignou @ 2009-08-09 22:06 UTC (permalink / raw)
  To: Robert Hancock
  Cc: Greg Freemyer, Bill Weiler, Kernelnewbies, IDE/ATA development list

On Thu, Jul 23, 2009 at 10:34 PM, Robert Hancock<hancockrwd@gmail.com> wrote:
> On 07/23/2009 04:31 PM, Greg Freemyer wrote:
>>
>> cc'ing: linux-ide@vger.kernel.org
>>
>> maybe they can help
>>
>> On Thu, Jul 23, 2009 at 6:12 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>>
>>> ________________________________________
>>> From: Greg Freemyer [greg.freemyer@gmail.com]
>>> Sent: Thursday, July 23, 2009 2:31 PM
>>> To: Bill Weiler
>>> Cc: Kernelnewbies
>>> Subject: Re: Drive tester
>>>
>>> On Wed, Jul 22, 2009 at 7:55 PM, Bill Weiler<weilerb@marvell.com>  wrote:
>>>>
>>>> I wanted to make an Application that could send scripted SCSI and SATA
>>>> commands to my drives. I have found my Fedora Linux to be too complex to
>>>> control the drives in this way. I have looked at minimal Linux but I
>>>> think
>>>> this would have the same problem. Is there an easier Open Source OS, or
>>>> an
>>>> embedded PC Linux that would be easier to modify?
>>>
>>> Bill,
>>>
>>> For sata drives, have you looked at the SG_IO interface?
>>>
>>> That is how hdparm interfaces with the kernel.  I know it sends a lot
>>> of low level ATA commands to the drive from user space.  I think most
>>> use the SG_IO interface.  How much simpler can it get?
>>>
>>> strace hdparm may give you an education as to how simple it is.
>
> The best way to issue arbitrary ATA commands is likely to issue them as ATA
> pass-through SCSI commands using SG_IO, yes.
>
>>>
>>> fyi: I believe the kernel looks for dangerous ata commands and blocks
>>> them.  But I think those are the types of commands that cause data
>>> loss.  Not sure what the criteria is.
>
> If you're running as unprivileged user I believe we block things like could
> do things like brick the drive such as uploading firmware, etc. However, if
> you have read-write access to the device node you can still read and write
> sectors anywhere on the disk. A few commands are blocked even for root
> users, like SET FEATURES - XFER MODE as it will screw up the mode
> configuration, but it's mostly fair game.
>
>>>
>>> I have studied hdparm and the SG_IO interface and delved into the scsi
>>> drivers and ata drivers.
>>>
>>> For example, I wanted to script a single NCQ and a single NCQ write. A
>>> normal read(fd,buf,4096) does 1 NCQ read but a write(fd,buf,4096) does
>>> dozens of NCQ reads before doing the 1 NCQ write. How do I get rid of these
>>> reads?
>
> Try opening the device node with O_DIRECT. That will prevent pagecache
> effects from changing the IO pattern. However, you can't get less than
> page-size (4K granularity) on requests, for that you'll need to issue SCSI
> or ATA commands directly.
>
>>>
>>> Also, I need to do soft and hard resets and these are not exposed.
>
> Indeed, there's no way currently to trigger these other than as part of
> error handling (i.e. command errors, hotplug operations, etc.) There's
> likely no reason it couldn't be added, but obviously nobody's needed it
> enough to bother so far..

We can trigger reset from user space using scsi scan interface.
hard/soft is decided by the interface driver, in particular if it has
access to SATA SCR registers or is working in IDE backward
compatibility mode.
Once you know the scsi location { host_id, channel_id, target_id,
lun_id } of you ATA disk, issue

echo <channel_id> <target_id> <lun_id> > /sys/class/scsi_host/host<host_id>/scan

For instance, on my system:
echo 0 0 0 > /sys/class/scsi_host/host5/scan

Will generate:
ata6: hard resetting link
ata6: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata6.00: configured for UDMA/133
ata6: EH complete

> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-09 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <9b0a5b990907162309j2ff4f872v47b18be74c7eeab9@mail.gmail.com>
     [not found] ` <23E65EE4544D484CBE73B588E192C6D612D3108FF0@sc-vexch3.marvell.com>
     [not found]   ` <87f94c370907231431p470874bax1155b88895cd97d5@mail.gmail.com>
     [not found]     ` <23E65EE4544D484CBE73B588E192C6D612D301CCCD@sc-vexch3.marvell.com>
2009-07-23 22:31       ` Drive tester Greg Freemyer
2009-07-24  5:34         ` Robert Hancock
2009-07-30 20:23           ` Greg Freemyer
2009-08-09 22:06           ` Gwendal Grignou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.