diff --git a/kernel/fs/schfs/vfs.c b/kernel/fs/schfs/vfs.c index 1139932..e7aaac9 100644 --- a/kernel/fs/schfs/vfs.c +++ b/kernel/fs/schfs/vfs.c @@ -142,7 +142,18 @@ schfs_vfs_ifree(struct inode *ip) // the tree while a copyout could fault. One page at a time keeps that buffer // off the 4096-byte kernel stack -- it is kalloc'd -- and bounds how long the // volume lock is held. -#define BOUNCE 2048 +// +// One filesystem block, which is also one kalloc page: this said 2048 while +// the comment above it said one page, so half of every bounce buffer went +// unused and every read did twice the work it needed to. +// +// The chunk size is not a copy-size tuning knob. Each trip through the loop +// takes the volume sleeplock and builds a fresh B-tree cursor to find the +// extent for that offset, so this is really "how many tree descents per byte +// read". Measured on an 834 KB file: 417 descents at 2048, 209 at 4096. +// +// It must not exceed a page, because the buffer is a single kalloc(). +#define BOUNCE SCHFS_BLKSIZE static int schfs_vfs_read(struct inode *ip, int user_dst, uint64 dst, uint64 off, uint n)