From ef728f8af253bda07606be1102035c9474f5ae9c Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 22 Jun 2015 12:26:03 +1000 Subject: [PATCH] Set max readahead to a large value when mounting. For #10. --- mounted_file_system.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mounted_file_system.go b/mounted_file_system.go index 9335cd9..afecd6f 100644 --- a/mounted_file_system.go +++ b/mounted_file_system.go @@ -154,6 +154,26 @@ func (c *MountConfig) bazilfuseOptions() (opts []bazilfuse.MountOption) { opts = append(opts, bazilfuse.SetOption("noappledouble", "")) } + // Ask the Linux kernel for larger read requests. + // + // As of 2015-03-26, the behavior in the kernel is: + // + // * (http://goo.gl/bQ1f1i, http://goo.gl/HwBrR6) Set the local variable + // ra_pages to be init_response->max_readahead divided by the page size. + // + // * (http://goo.gl/gcIsSh, http://goo.gl/LKV2vA) Set + // backing_dev_info::ra_pages to the min of that value and what was sent + // in the request's max_readahead field. + // + // * (http://goo.gl/u2SqzH) Use backing_dev_info::ra_pages when deciding + // how much to read ahead. + // + // * (http://goo.gl/JnhbdL) Don't read ahead at all if that field is zero. + // + // Reading a page at a time is a drag. Ask for a larger size. + const maxReadahead = 1 << 20 + opts = append(opts, bazilfuse.MaxReadahead(maxReadahead)) + // Last but not least: other user-supplied options. for k, v := range c.Options { opts = append(opts, bazilfuse.SetOption(k, v))