Re: dummy file read periodically for external USB Hard Disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi NeilBrown:
we use below c source but there is no read command firing from usb
host to device.
except O_DIRECT, is there any flag we need to use?
appreciate all your kind help,

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

char message[] = "/mnt/usb/4854344154343452/
test.txt";
int main()
{
   int fd;
   char buffer[5];
   int count = 0;
   char *buf="1234567890";
   if((fd=open(message,O_CREAT|O_TRUNC|O_RDWR|O_DIRECT, 0777))<0)
   {
       perror("open");
       return -1;
   }
   printf("fd=%d\n", fd);
   write(fd, buf, strlen(buf));
   while(1){
       lseek(fd,0,SEEK_SET);
       sleep(3);
       count = read(fd, buffer, 3);
       printf("count=%d,%x,%x,%x\n", count,buffer[0],buffer[1],buffer[2]);
   }

}

2014-07-08 11:01 GMT+08:00 NeilBrown <neilb@xxxxxxx>:
> On Mon, 7 Jul 2014 22:42:29 +0800 loody <miloody@xxxxxxxxx> wrote:
>
>> hi all:
>>     we met a USB Hard Disk that will go to suspend if host stop
>> sending scsi read 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 read command may disappear
>> for a while longer enough to cause the device suspend.
>>
>>     is there any kernel config or module parameter can do the dummy
>> read periodically, even the sector 0 (MBR) is fine.
>>     or is there any kernel api I can use to read sector 0(MBR) maybe
>> every 4mins?
>>
>> appreciate your help in advance,
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Open the device with O_DIRECT and read a block every 4 minutes.
> That should keep it awake.
>
> NeilBrown



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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux