RE: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-09 Thread David Laight
From: loody ... but what it really do is read sector, not media_change or test_unit_ready. Maybe one of the programs that reads the mbr partition table can be persuaded to do a direct read? David

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-09 Thread loody
hi all: I try 2 methods today but there is no read command firing from usb host to device (I double check the existence of command by CATC protocol analyzer) appreciate all your kind suggestion. 1. use busybox like below command dd if=/dev/sda1 of=/dev/null bs=512 count=1 conv=sync my dd in

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-09 Thread loody
hi Bryn: 2014-07-08 0:25 GMT+08:00 Bryn M. Reeves b...@redhat.com: On Tue, Jul 08, 2014 at 12:15:54AM +0800, loody wrote: so sg_read will not hammer on the page cache like dd without iflags=direct thanks for your kind help, The sg_read program (and other programs in sg3_utils) sends a

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-09 Thread Alan Stern
On Wed, 9 Jul 2014, loody wrote: on that usb hard disk, no matter media_change or TEST_UNIT_READY, keep polling the device every 3mins. the disconnection still happen. So I am wondering, I can use the existence wheel, such as echo 4 /sys/block/sda/events_poll_ msecs. but what it

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-09 Thread Alan Stern
On Wed, 9 Jul 2014, loody wrote: hi all: I try 2 methods today but there is no read command firing from usb host to device (I double check the existence of command by CATC protocol analyzer) appreciate all your kind suggestion. 1. use busybox like below command dd if=/dev/sda1

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-08 Thread loody
hi Alan: 2014-07-08 1:02 GMT+08:00 Alan Stern st...@rowland.harvard.edu: On Tue, 8 Jul 2014, loody wrote: An alternative is to write a positive value, such as 24, to /sys/block/sdX/events_poll_msecs where X is replaced with the proper drive letter. (24 ms = 240 s =

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-08 Thread Alan Stern
On Tue, 8 Jul 2014, loody wrote: You are correct. i can see events_poll_msecs when I change my kernel to 3.8.0 But the device still disconnect. I have some question. 1. when I cat /sys/block/sdX/events, I get the answer as media_change. is there any events type we can choose, such as

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-08 Thread loody
hi Alan: 2014-07-09 0:00 GMT+08:00 Alan Stern st...@rowland.harvard.edu: On Tue, 8 Jul 2014, loody wrote: You are correct. i can see events_poll_msecs when I change my kernel to 3.8.0 But the device still disconnect. I have some question. 1. when I cat /sys/block/sdX/events, I get the

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-08 Thread Alan Stern
On Wed, 9 Jul 2014, loody wrote: there is one thing pop in my mind. if events_poll_msecs is used for media_change, shouldn't we wrap is READ10? No. Why should media change polling use READ(10)? TEST UNIT READY does a good job of detecting media changes. the difference seems 1. change

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-08 Thread loody
hi Alan: 2014-07-09 3:26 GMT+08:00 Alan Stern st...@rowland.harvard.edu: On Wed, 9 Jul 2014, loody wrote: there is one thing pop in my mind. if events_poll_msecs is used for media_change, shouldn't we wrap is READ10? No. Why should media change polling use READ(10)? TEST UNIT READY does

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Bryn M. Reeves
On Sun, Jul 06, 2014 at 01:18:03AM +0800, loody wrote: hi all: we met a USB Hard Disk that will go to suspend if host stop sending scsi command over 5mins. To save the IO, kernel will keep the file in page cache as much as he can and under this circumstances, the scsi command may

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread loody
hi Bryn: 2014-07-07 17:20 GMT+08:00 Bryn M. Reeves b...@redhat.com: On Sun, Jul 06, 2014 at 01:18:03AM +0800, loody wrote: hi all: we met a USB Hard Disk that will go to suspend if host stop sending scsi command over 5mins. To save the IO, kernel will keep the file in page cache as

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Lars Melin
On 2014-07-07 21:37, loody wrote: hi Bryn: 2014-07-07 17:20 GMT+08:00 Bryn M. Reeves b...@redhat.com: On Sun, Jul 06, 2014 at 01:18:03AM +0800, loody wrote: hi all: we met a USB Hard Disk that will go to suspend if host stop sending scsi command over 5mins. To save the IO, kernel

RE: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread David Laight
From: Lars Melin ... sgread is not included in BusyBox but you should have touch. Create a dummy file on the disk and let cron touch it every 4 minutes. You don't need 'touch' a shell redirect eg : file will do open(..., O_CREAT|O_TRUNC). However that still might not force an actual disc

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread loody
hi David: 2014-07-07 23:06 GMT+08:00 David Laight david.lai...@aculab.com: From: Lars Melin ... sgread is not included in BusyBox but you should have touch. Create a dummy file on the disk and let cron touch it every 4 minutes. You don't need 'touch' a shell redirect eg : file will do

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Lars Melin
On 2014-07-07 22:39, loody wrote: hi David: 2014-07-07 23:06 GMT+08:00 David Laight david.lai...@aculab.com: From: Lars Melin ... sgread is not included in BusyBox but you should have touch. Create a dummy file on the disk and let cron touch it every 4 minutes. You don't need 'touch' a shell

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Bryn M. Reeves
On Mon, Jul 07, 2014 at 11:39:05PM +0800, loody wrote: hi David: 2014-07-07 23:06 GMT+08:00 David Laight david.lai...@aculab.com: From: Lars Melin ... sgread is not included in BusyBox but you should have touch. Create a dummy file on the disk and let cron touch it every 4 minutes.

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Alan Stern
On Mon, 7 Jul 2014, loody wrote: hi Bryn: 2014-07-07 17:20 GMT+08:00 Bryn M. Reeves b...@redhat.com: On Sun, Jul 06, 2014 at 01:18:03AM +0800, loody wrote: hi all: we met a USB Hard Disk that will go to suspend if host stop sending scsi command over 5mins. To save the IO,

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread loody
hi Alan: E.g. issue an sg_read for one sector to the device every 4m: */4 * * * * sg_read count=1 if=/dev/disk Since my target platform arm embedded system, does that mean I should include sg_read in my Busybox or cross-compile sg_read from sg3_utils? An alternative is to write a

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread loody
hi Bryn: 2014-07-07 23:52 GMT+08:00 Bryn M. Reeves b...@redhat.com: On Mon, Jul 07, 2014 at 11:39:05PM +0800, loody wrote: hi David: 2014-07-07 23:06 GMT+08:00 David Laight david.lai...@aculab.com: From: Lars Melin ... sgread is not included in BusyBox but you should have touch.

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Bryn M. Reeves
On Tue, Jul 08, 2014 at 12:15:54AM +0800, loody wrote: so sg_read will not hammer on the page cache like dd without iflags=direct thanks for your kind help, The sg_read program (and other programs in sg3_utils) sends a command directly to the device using an SG_IO ioctl. This bypasses all the

Re: dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-07 Thread Alan Stern
On Tue, 8 Jul 2014, loody wrote: An alternative is to write a positive value, such as 24, to /sys/block/sdX/events_poll_msecs where X is replaced with the proper drive letter. (24 ms = 240 s = 4 m.) I'm not sure this will work, but it's worth a try. I cannot find

dummy scsi read or scsi command periodically for external USB Hard Disk

2014-07-05 Thread loody
hi all: we met a USB Hard Disk that will go to suspend if host stop sending scsi command over 5mins. To save the IO, kernel will keep the file in page cache as much as he can and under this circumstances, the scsi command may disappear for a while longer enough to cause the device suspend.