File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 6969** etcetera .....
7070*/
7171#define MYMAGIC (unsigned int) 0xfeedbeef
72+ #define READAHEADOFF 22
73+ #define READAHEADSIZE (1 << READAHEADOFF)
7274
7375struct rawheader {
7476 unsigned int magic ;
@@ -514,6 +516,10 @@ rawread(void)
514516 }
515517 }
516518
519+ /* make the kernel readahead more effective, */
520+ if (isregular )
521+ posix_fadvise (rawfd , 0 , 0 , POSIX_FADV_SEQUENTIAL );
522+
517523 /*
518524 ** read the raw header and verify the magic
519525 */
@@ -644,8 +650,22 @@ rawread(void)
644650
645651 if (isregular )
646652 {
647- lseek (rawfd , rr .scomplen + rr .pcomplen ,
648- SEEK_CUR );
653+ static off_t curr_pos = -1 ;
654+ off_t next_pos ;
655+
656+ lastcmd = 1 ;
657+ next_pos = lseek (rawfd , rr .scomplen + rr .pcomplen , SEEK_CUR );
658+ if ((curr_pos >> READAHEADOFF ) != (next_pos >> READAHEADOFF ))
659+ {
660+ /* just read READAHEADSIZE bytes into page cache */
661+ char * buf = malloc (READAHEADSIZE );
662+ ptrverify (buf , "Malloc failed for readahead" );
663+ pread (rawfd , buf , READAHEADSIZE ,
664+ next_pos & ~(READAHEADSIZE - 1 ));
665+ free (buf );
666+ }
667+ curr_pos = next_pos ;
668+ continue ;
649669 }
650670 else // named pipe not seekable
651671 {
You can’t perform that action at this time.
0 commit comments