Messages in this thread Patch in this message | | | From | "Adam J. Richter" <> | Date | Mon, 8 Jun 1998 21:37:19 -0700 | Subject | Bug in breada() read ahead calculation? |
| |
It looks like breada considers the number of blocks that it is asked to read as a minimum instead of a maximum. That is, if you tell breada that it is productive to read ahead another kilobyte (say, to the end of the file) and read_ahead[major_dev] is set to four kilobytes, it will read four kilobytes instead of one. I have attached a patch that should correct this problem.
By the way, adding readahead to part of the iso9660 filesystem and then increasing the default readahead count from the default 4kb to 32kB (the maximum for a 2kB block size) reduced the time it took to do a fairly complex boot process from CD from four minutes to three (saving 61 seconds, to be more precise). Tweaking the kernel to enable a readahead of 100kB only saved another two seconds, so it looks like the 32kB maximum readahead may be sufficient.
I will probably look at some additional adjustments to the readahead policies in the near future.
The attached patch is only a one line change, but I included 23 lines of context because I think that is necessary in this case to make it understable by itself.
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 205 adam@yggdrasil.com \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America fax +1 408 261-6631 "Free Software For The Rest Of Us." --------------------CUT HERE----------------------------------------- Index: linux/fs/buffer.c =================================================================== RCS file: /usr/src.repository/repository/linux/fs/buffer.c,v retrieving revision 1.1.1.14 diff -u -2 -3 -r1.1.1.14 buffer.c --- buffer.c 1998/06/07 02:10:01 1.1.1.14 +++ buffer.c 1998/06/09 04:17:17 @@ -1092,47 +1092,47 @@ struct buffer_head * breada(kdev_t dev, int block, int bufsize, unsigned int pos, unsigned int filesize) { struct buffer_head * bhlist[NBUF]; unsigned int blocks; struct buffer_head * bh; int index; int i, j; if (pos >= filesize) return NULL; if (block < 0 || !(bh = getblk(dev,block,bufsize))) return NULL; index = BUFSIZE_INDEX(bh->b_size); if (buffer_uptodate(bh)) return(bh); else ll_rw_block(READ, 1, &bh); blocks = (filesize - pos) >> (9+index); - if (blocks < (read_ahead[MAJOR(dev)] >> index)) + if (blocks > (read_ahead[MAJOR(dev)] >> index)) blocks = read_ahead[MAJOR(dev)] >> index; if (blocks > NBUF) blocks = NBUF; /* if (blocks) printk("breada (new) %d blocks\n",blocks); */ bhlist[0] = bh; j = 1; for(i=1; i<blocks; i++) { bh = getblk(dev,block+i,bufsize); if (buffer_uptodate(bh)) { brelse(bh); break; } else bhlist[j++] = bh; } /* Request the read for these buffers, and then release them. */ if (j>1) ll_rw_block(READA, (j-1), bhlist+1); for(i=1; i<j; i++) brelse(bhlist[i]); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |