From 5dbc3bcd6139a36033c0b53954c219c5787fda8b Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Thu, 26 Mar 2015 16:10:07 +1100 Subject: [PATCH] Ask for large writes from the kernel. For googlecloudplatform/gcsfuse#27. --- fuseops/ops.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fuseops/ops.go b/fuseops/ops.go index 93ea326..5d65eb5 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -58,6 +58,26 @@ func (o *InitOp) Respond(err error) { resp := &bazilfuse.InitResponse{} + // Unconditionally enable large WriteFile ops from the kernel on Linux. + // + // As of 2015-03-26, the behavior in the kernel is: + // + // * (http://goo.gl/jMKHMZ, http://goo.gl/XTF4ZH) Cap the max write size at + // the maximum of 4096 and init_response->max_write. + // + // * (http://goo.gl/gEIvHZ) If FUSE_BIG_WRITES isn't set, don't return more + // than one page. + // + // * (http://goo.gl/4RLhxZ, http://goo.gl/hi0Cm2) Never write more than + // FUSE_MAX_PAGES_PER_REQ pages (128 KiB on x86). + // + // 4 KiB is crazy small. Ask for significantly more, and take what the kernel + // will give us. + const maxWrite = 1 << 21 + resp.Flags |= bazilfuse.InitBigWrites + resp.MaxWrite = maxWrite + + // Respond. o.commonOp.logger.Printf("Responding: %v", &resp) o.r.(*bazilfuse.InitRequest).Respond(resp) }