In readahead, sort by dev, block, inode.
Status: Beta
Brought to you by:
behdad
I adapted this patch from a patch in the Ubuntu
readahead package. I think the original patch was made
by Scott James Remnant <scott@ubuntu.com>.
readahead uses the same license as preload.
In readahead, the file list is sorted by device, block
and inode. That should decrease seeking.
Logged In: YES
user_id=47601
Thanks! When writing preload I tried to do something
similar, copying from Fedora's readahead package. That uses
ext2 libraries to do the same thing. However, a problem
still present in your patch is that you are sorting based on
the block position of the beginning of the file:
+ file->block = 0;
+ ioctl(fd, FIBMAP, &(file->block));
instead, you should set file->block based on file->offset
and ioctl(fd, FIGETBSZ, &blksize). See bmap.c here for example:
http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz
And I prefer to see stat information cached. They are being
cached right now, you just shouldn't call stat every time.
As for coding style, please keep map objects named "map",
not "file".
Thanks,
behdad