From 4b1e4b55f94fd044b530a8955757a3a89b9c9f6f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 21:32:10 +1000 Subject: [PATCH 1/7] Embed the bazilfuse response object within ReadFileOp. This saves an allocation that is very much on the hot path in a read-heavy load. --- fuseops/ops.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fuseops/ops.go b/fuseops/ops.go index e0105f1..74144b1 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -653,6 +653,7 @@ func (o *OpenFileOp) toBazilfuseResponse() (bfResp interface{}) { // more. type ReadFileOp struct { commonOp + bfResp bazilfuse.ReadResponse // The file inode that we are reading, and the handle previously returned by // CreateFile or OpenFile when opening that inode. @@ -676,11 +677,8 @@ type ReadFileOp struct { } func (o *ReadFileOp) toBazilfuseResponse() (bfResp interface{}) { - resp := bazilfuse.ReadResponse{ - Data: o.Data, - } - bfResp = &resp - + o.bfResp.Data = o.Data + bfResp = &o.bfResp return } From f004d3ff4a95395f5ea3df9f26c8500bab3438e1 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 21:45:49 +1000 Subject: [PATCH 2/7] Avoid calling Logf on the hot path when logging is disabled. The call to commonOp.Logf in sendBazilfuseResponse is extremely hot for allocations, presumably because it needs to allocate an argument slice. It is normally not needed at all, so why pay for it? --- connection.go | 13 +++++++++++-- fuseops/common_op.go | 34 +++++++++++++++++++++++++--------- fuseops/convert.go | 2 ++ mounted_file_system.go | 18 ++---------------- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/connection.go b/connection.go index ba9e168..5ee1922 100644 --- a/connection.go +++ b/connection.go @@ -50,6 +50,8 @@ type Connection struct { // Responsibility for closing the wrapped connection is transferred to the // result. You must call c.close() eventually. +// +// The loggers may be nil. func newConnection( parentCtx context.Context, debugLogger *log.Logger, @@ -73,6 +75,10 @@ func (c *Connection) debugLog( calldepth int, format string, v ...interface{}) { + if c.debugLogger == nil { + return + } + // Get file:line info. var file string var line int @@ -239,8 +245,11 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) { // Set up op dependencies. opCtx := c.beginOp(bfReq) - debugLogForOp := func(calldepth int, format string, v ...interface{}) { - c.debugLog(opID, calldepth+1, format, v...) + var debugLogForOp func(int, string, ...interface{}) + if c.debugLogger != nil { + debugLogForOp = func(calldepth int, format string, v ...interface{}) { + c.debugLog(opID, calldepth+1, format, v...) + } } finished := func(err error) { c.finishOp(bfReq) } diff --git a/fuseops/common_op.go b/fuseops/common_op.go index 2ae773b..f82580b 100644 --- a/fuseops/common_op.go +++ b/fuseops/common_op.go @@ -49,9 +49,13 @@ type commonOp struct { // A function that can be used to log debug information about the op. The // first argument is a call depth. + // + // May be nil. debugLog func(int, string, ...interface{}) // A logger to be used for logging exceptional errors. + // + // May be nil. errorLogger *log.Logger // A function that is invoked with the error given to Respond, for use in @@ -116,6 +120,10 @@ func (o *commonOp) Context() context.Context { } func (o *commonOp) Logf(format string, v ...interface{}) { + if o.debugLog == nil { + return + } + const calldepth = 2 o.debugLog(calldepth, format, v...) } @@ -131,15 +139,19 @@ func (o *commonOp) Respond(err error) { } // Log the error. - o.Logf( - "-> (%s) error: %v", - o.op.ShortDesc(), - err) + if o.debugLog != nil { + o.Logf( + "-> (%s) error: %v", + o.op.ShortDesc(), + err) + } - o.errorLogger.Printf( - "(%s) error: %v", - o.op.ShortDesc(), - err) + if o.errorLogger != nil { + o.errorLogger.Printf( + "(%s) error: %v", + o.op.ShortDesc(), + err) + } // Send a response to the kernel. o.bazilReq.RespondError(err) @@ -157,11 +169,15 @@ func (o *commonOp) sendBazilfuseResponse(resp interface{}) { // Special case: handle successful ops with no response struct. if resp == nil { o.Logf("-> (%s) OK", o.op.ShortDesc()) + respond.Call([]reflect.Value{}) return } // Otherwise, send the response struct to the kernel. - o.Logf("-> %v", resp) + if o.debugLog != nil { + o.Logf("-> %v", resp) + } + respond.Call([]reflect.Value{reflect.ValueOf(resp)}) } diff --git a/fuseops/convert.go b/fuseops/convert.go index ab280e2..027b4b9 100644 --- a/fuseops/convert.go +++ b/fuseops/convert.go @@ -32,6 +32,8 @@ import ( // // It is guaranteed that o != nil. If the op is unknown, a special unexported // type will be used. +// +// The debug logging function and error logger may be nil. func Convert( opCtx context.Context, r bazilfuse.Request, diff --git a/mounted_file_system.go b/mounted_file_system.go index 1778638..580ea6b 100644 --- a/mounted_file_system.go +++ b/mounted_file_system.go @@ -16,7 +16,6 @@ package fuse import ( "fmt" - "io/ioutil" "log" "runtime" @@ -193,12 +192,6 @@ func Mount( dir string, server Server, config *MountConfig) (mfs *MountedFileSystem, err error) { - // Arrange for a non-nil debug logger. - debugLogger := config.DebugLogger - if debugLogger == nil { - debugLogger = log.New(ioutil.Discard, "", 0) - } - // Initialize the struct. mfs = &MountedFileSystem{ dir: dir, @@ -206,7 +199,6 @@ func Mount( } // Open a bazilfuse connection. - debugLogger.Println("Opening a bazilfuse connection.") bfConn, err := bazilfuse.Mount(mfs.dir, config.bazilfuseOptions()...) if err != nil { err = fmt.Errorf("bazilfuse.Mount: %v", err) @@ -219,17 +211,11 @@ func Mount( opContext = context.Background() } - // Create a /dev/null error logger if necessary. - errorLogger := config.ErrorLogger - if errorLogger == nil { - errorLogger = log.New(ioutil.Discard, "", 0) - } - // Create our own Connection object wrapping it. connection, err := newConnection( opContext, - debugLogger, - errorLogger, + config.DebugLogger, + config.ErrorLogger, bfConn) if err != nil { From aff2fc2f9e897196df5831339360fe89c4d8c00f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 22:19:49 +1000 Subject: [PATCH 3/7] Ripped out the toBazilfuseResponse logic from commonOp. --- fuseops/common_op.go | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/fuseops/common_op.go b/fuseops/common_op.go index f82580b..4b9064f 100644 --- a/fuseops/common_op.go +++ b/fuseops/common_op.go @@ -30,10 +30,8 @@ import ( type internalOp interface { Op - // Convert to a bazilfuse response compatible with the Respond method on the - // wrapped bazilfuse request. If that Respond method takes no arguments, - // return nil. - toBazilfuseResponse() interface{} + // Respond to the underlying bazilfuse request, successfully. + respond() } // A helper for embedding common behavior. @@ -134,7 +132,7 @@ func (o *commonOp) Respond(err error) { // If successful, we should respond to bazilfuse with the appropriate struct. if err == nil { - o.sendBazilfuseResponse(o.op.toBazilfuseResponse()) + o.op.respond() return } @@ -156,28 +154,3 @@ func (o *commonOp) Respond(err error) { // Send a response to the kernel. o.bazilReq.RespondError(err) } - -// Respond with the supplied response struct, which must be accepted by a -// method called Respond on o.bazilReq. -// -// Special case: nil means o.bazilReq.Respond accepts no parameters. -func (o *commonOp) sendBazilfuseResponse(resp interface{}) { - // Find the Respond method. - v := reflect.ValueOf(o.bazilReq) - respond := v.MethodByName("Respond") - - // Special case: handle successful ops with no response struct. - if resp == nil { - o.Logf("-> (%s) OK", o.op.ShortDesc()) - - respond.Call([]reflect.Value{}) - return - } - - // Otherwise, send the response struct to the kernel. - if o.debugLog != nil { - o.Logf("-> %v", resp) - } - - respond.Call([]reflect.Value{reflect.ValueOf(resp)}) -} From 2366f698e2d75143214d9da17bc1c3f47ca89d88 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 22:23:11 +1000 Subject: [PATCH 4/7] Added bfReq members. --- fuseops/ops.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fuseops/ops.go b/fuseops/ops.go index 74144b1..2af5dfc 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -61,6 +61,7 @@ type Op interface { // when resolving user paths to dentry structs, which are then cached. type LookUpInodeOp struct { commonOp + bfReq *bazilfuse.LookupRequest // The ID of the directory inode to which the child belongs. Parent InodeID @@ -103,6 +104,7 @@ func (o *LookUpInodeOp) toBazilfuseResponse() (bfResp interface{}) { // field of ChildInodeEntry, etc. type GetInodeAttributesOp struct { commonOp + bfReq *bazilfuse.GetattrRequest // The inode of interest. Inode InodeID @@ -129,6 +131,7 @@ func (o *GetInodeAttributesOp) toBazilfuseResponse() (bfResp interface{}) { // cases like ftrunctate(2). type SetInodeAttributesOp struct { commonOp + bfReq *bazilfuse.SetattrRequest // The inode of interest. Inode InodeID @@ -196,6 +199,7 @@ func (o *SetInodeAttributesOp) toBazilfuseResponse() (bfResp interface{}) { // implicitly decrementing all lookup counts to zero. type ForgetInodeOp struct { commonOp + bfReq *bazilfuse.ForgetRequest // The inode whose reference count should be decremented. Inode InodeID @@ -225,6 +229,7 @@ func (o *ForgetInodeOp) toBazilfuseResponse() (bfResp interface{}) { // Therefore the file system should return EEXIST if the name already exists. type MkDirOp struct { commonOp + bfReq *bazilfuse.MkdirRequest // The ID of parent directory inode within which to create the child. Parent InodeID @@ -266,6 +271,7 @@ func (o *MkDirOp) toBazilfuseResponse() (bfResp interface{}) { // Therefore the file system should return EEXIST if the name already exists. type CreateFileOp struct { commonOp + bfReq *bazilfuse.CreateRequest // The ID of parent directory inode within which to create the child file. Parent InodeID @@ -316,6 +322,7 @@ func (o *CreateFileOp) toBazilfuseResponse() (bfResp interface{}) { // return EEXIST (cf. the notes on CreateFileOp and MkDirOp). type CreateSymlinkOp struct { commonOp + bfReq *bazilfuse.SymlinkRequest // The ID of parent directory inode within which to create the child symlink. Parent InodeID @@ -394,6 +401,7 @@ func (o *CreateSymlinkOp) toBazilfuseResponse() (bfResp interface{}) { // type RenameOp struct { commonOp + bfReq *bazilfuse.RenameRequest // The old parent directory, and the name of the entry within it to be // relocated. @@ -419,6 +427,7 @@ func (o *RenameOp) toBazilfuseResponse() (bfResp interface{}) { // Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf) type RmDirOp struct { commonOp + bfReq *bazilfuse.RemoveRequest // The ID of parent directory inode, and the name of the directory being // removed within it. @@ -438,6 +447,7 @@ func (o *RmDirOp) toBazilfuseResponse() (bfResp interface{}) { // Sample implementation in ext2: ext2_unlink (http://goo.gl/hY6r6C) type UnlinkOp struct { commonOp + bfReq *bazilfuse.RemoveRequest // The ID of parent directory inode, and the name of the entry being removed // within it. @@ -461,6 +471,7 @@ func (o *UnlinkOp) toBazilfuseResponse() (bfResp interface{}) { // https://github.com/osxfuse/osxfuse/issues/199). type OpenDirOp struct { commonOp + bfReq *bazilfuse.OpenRequest // The ID of the inode to be opened. Inode InodeID @@ -491,6 +502,7 @@ func (o *OpenDirOp) toBazilfuseResponse() (bfResp interface{}) { // Read entries from a directory previously opened with OpenDir. type ReadDirOp struct { commonOp + bfReq *bazilfuse.ReadRequest // The directory inode that we are reading, and the handle previously // returned by OpenDir when opening that inode. @@ -597,6 +609,7 @@ func (o *ReadDirOp) toBazilfuseResponse() (bfResp interface{}) { // Errors from this op are ignored by the kernel (cf. http://goo.gl/RL38Do). type ReleaseDirHandleOp struct { commonOp + bfReq *bazilfuse.ReleaseRequest // The handle ID to be released. The kernel guarantees that this ID will not // be used in further calls to the file system (unless it is reissued by the @@ -620,6 +633,7 @@ func (o *ReleaseDirHandleOp) toBazilfuseResponse() (bfResp interface{}) { // (cf.https://github.com/osxfuse/osxfuse/issues/199). type OpenFileOp struct { commonOp + bfReq *bazilfuse.OpenRequest // The ID of the inode to be opened. Inode InodeID @@ -653,6 +667,7 @@ func (o *OpenFileOp) toBazilfuseResponse() (bfResp interface{}) { // more. type ReadFileOp struct { commonOp + bfReq *bazilfuse.ReadRequest bfResp bazilfuse.ReadResponse // The file inode that we are reading, and the handle previously returned by @@ -715,6 +730,7 @@ func (o *ReadFileOp) toBazilfuseResponse() (bfResp interface{}) { // concurrent requests".) type WriteFileOp struct { commonOp + bfReq *bazilfuse.WriteRequest // The file inode that we are modifying, and the handle previously returned // by CreateFile or OpenFile when opening that inode. @@ -779,6 +795,7 @@ func (o *WriteFileOp) toBazilfuseResponse() (bfResp interface{}) { // file (but which is not used in "real" file systems). type SyncFileOp struct { commonOp + bfReq *bazilfuse.FsyncRequest // The file and handle being sync'd. Inode InodeID @@ -838,6 +855,7 @@ func (o *SyncFileOp) toBazilfuseResponse() (bfResp interface{}) { // return any errors that occur. type FlushFileOp struct { commonOp + bfReq *bazilfuse.FlushRequest // The file and handle being flushed. Inode InodeID @@ -858,6 +876,7 @@ func (o *FlushFileOp) toBazilfuseResponse() (bfResp interface{}) { // Errors from this op are ignored by the kernel (cf. http://goo.gl/RL38Do). type ReleaseFileHandleOp struct { commonOp + bfReq *bazilfuse.ReleaseRequest // The handle ID to be released. The kernel guarantees that this ID will not // be used in further calls to the file system (unless it is reissued by the @@ -891,6 +910,7 @@ func (o *unknownOp) toBazilfuseResponse() (bfResp interface{}) { // Read the target of a symlink inode. type ReadSymlinkOp struct { commonOp + bfReq *bazilfuse.ReadlinkRequest // The symlink inode that we are reading. Inode InodeID From 2c1ba6d729e56c5d5a695fd9e035257c5506187b Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 22:23:47 +1000 Subject: [PATCH 5/7] LookUpInodeOp.respond --- fuseops/ops.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fuseops/ops.go b/fuseops/ops.go index 2af5dfc..b0ff446 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -89,12 +89,11 @@ func (o *LookUpInodeOp) ShortDesc() (desc string) { return } -func (o *LookUpInodeOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *LookUpInodeOp) respond() { resp := bazilfuse.LookupResponse{} - bfResp = &resp - convertChildInodeEntry(&o.Entry, &resp) + o.bfReq.Respond(&resp) return } From 422fe4db378e42ad53725df260771e0633e0b1c0 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 22:26:58 +1000 Subject: [PATCH 6/7] Implemented respond methods. --- fuseops/ops.go | 81 +++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/fuseops/ops.go b/fuseops/ops.go index b0ff446..70fb4a2 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -115,12 +115,12 @@ type GetInodeAttributesOp struct { AttributesExpiration time.Time } -func (o *GetInodeAttributesOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *GetInodeAttributesOp) respond() { resp := bazilfuse.GetattrResponse{ Attr: convertAttributes(o.Inode, o.Attributes, o.AttributesExpiration), } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -148,12 +148,12 @@ type SetInodeAttributesOp struct { AttributesExpiration time.Time } -func (o *SetInodeAttributesOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *SetInodeAttributesOp) respond() { resp := bazilfuse.SetattrResponse{ Attr: convertAttributes(o.Inode, o.Attributes, o.AttributesExpiration), } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -207,7 +207,8 @@ type ForgetInodeOp struct { N uint64 } -func (o *ForgetInodeOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *ForgetInodeOp) respond() { + o.bfReq.Respond() return } @@ -249,12 +250,11 @@ func (o *MkDirOp) ShortDesc() (desc string) { return } -func (o *MkDirOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *MkDirOp) respond() { resp := bazilfuse.MkdirResponse{} - bfResp = &resp - convertChildInodeEntry(&o.Entry, &resp.LookupResponse) + o.bfReq.Respond(&resp) return } @@ -304,16 +304,16 @@ func (o *CreateFileOp) ShortDesc() (desc string) { return } -func (o *CreateFileOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *CreateFileOp) respond() { resp := bazilfuse.CreateResponse{ OpenResponse: bazilfuse.OpenResponse{ Handle: bazilfuse.HandleID(o.Handle), }, } - bfResp = &resp convertChildInodeEntry(&o.Entry, &resp.LookupResponse) + o.bfReq.Respond(&resp) return } @@ -350,13 +350,11 @@ func (o *CreateSymlinkOp) ShortDesc() (desc string) { return } -func (o *CreateSymlinkOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *CreateSymlinkOp) respond() { resp := bazilfuse.SymlinkResponse{} - bfResp = &resp - convertChildInodeEntry(&o.Entry, &resp.LookupResponse) - return + o.bfReq.Respond(&resp) return } @@ -413,7 +411,8 @@ type RenameOp struct { NewName string } -func (o *RenameOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *RenameOp) respond() { + o.bfReq.Respond() return } @@ -434,7 +433,8 @@ type RmDirOp struct { Name string } -func (o *RmDirOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *RmDirOp) respond() { + o.bfReq.Respond() return } @@ -454,7 +454,8 @@ type UnlinkOp struct { Name string } -func (o *UnlinkOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *UnlinkOp) respond() { + o.bfReq.Respond() return } @@ -489,12 +490,12 @@ type OpenDirOp struct { Handle HandleID } -func (o *OpenDirOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *OpenDirOp) respond() { resp := bazilfuse.OpenResponse{ Handle: bazilfuse.HandleID(o.Handle), } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -589,12 +590,12 @@ type ReadDirOp struct { Data []byte } -func (o *ReadDirOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *ReadDirOp) respond() { resp := bazilfuse.ReadResponse{ Data: o.Data, } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -616,7 +617,8 @@ type ReleaseDirHandleOp struct { Handle HandleID } -func (o *ReleaseDirHandleOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *ReleaseDirHandleOp) respond() { + o.bfReq.Respond() return } @@ -650,12 +652,12 @@ type OpenFileOp struct { Handle HandleID } -func (o *OpenFileOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *OpenFileOp) respond() { resp := bazilfuse.OpenResponse{ Handle: bazilfuse.HandleID(o.Handle), } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -666,8 +668,7 @@ func (o *OpenFileOp) toBazilfuseResponse() (bfResp interface{}) { // more. type ReadFileOp struct { commonOp - bfReq *bazilfuse.ReadRequest - bfResp bazilfuse.ReadResponse + bfReq *bazilfuse.ReadRequest // The file inode that we are reading, and the handle previously returned by // CreateFile or OpenFile when opening that inode. @@ -690,9 +691,12 @@ type ReadFileOp struct { Data []byte } -func (o *ReadFileOp) toBazilfuseResponse() (bfResp interface{}) { - o.bfResp.Data = o.Data - bfResp = &o.bfResp +func (o *ReadFileOp) respond() { + resp := bazilfuse.ReadResponse{ + Data: o.Data, + } + + o.bfReq.Respond(&resp) return } @@ -767,12 +771,12 @@ type WriteFileOp struct { Data []byte } -func (o *WriteFileOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *WriteFileOp) respond() { resp := bazilfuse.WriteResponse{ Size: len(o.Data), } - bfResp = &resp + o.bfReq.Respond(&resp) return } @@ -801,7 +805,8 @@ type SyncFileOp struct { Handle HandleID } -func (o *SyncFileOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *SyncFileOp) respond() { + o.bfReq.Respond() return } @@ -861,7 +866,8 @@ type FlushFileOp struct { Handle HandleID } -func (o *FlushFileOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *FlushFileOp) respond() { + o.bfReq.Respond() return } @@ -883,7 +889,8 @@ type ReleaseFileHandleOp struct { Handle HandleID } -func (o *ReleaseFileHandleOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *ReleaseFileHandleOp) respond() { + o.bfReq.Respond() return } @@ -898,7 +905,7 @@ func (o *unknownOp) ShortDesc() (desc string) { return } -func (o *unknownOp) toBazilfuseResponse() (bfResp interface{}) { +func (o *unknownOp) respond() { panic(fmt.Sprintf("Should never get here for unknown op: %s", o.ShortDesc())) } @@ -918,7 +925,7 @@ type ReadSymlinkOp struct { Target string } -func (o *ReadSymlinkOp) toBazilfuseResponse() (bfResp interface{}) { - bfResp = o.Target +func (o *ReadSymlinkOp) respond() { + o.bfReq.Respond(o.Target) return } From 894e5ffba2be033f6a40971f07f869f3ca48cc63 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 22 Jul 2015 22:27:48 +1000 Subject: [PATCH 7/7] Fill in bfReq fields. --- fuseops/convert.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fuseops/convert.go b/fuseops/convert.go index 027b4b9..938a8c0 100644 --- a/fuseops/convert.go +++ b/fuseops/convert.go @@ -46,6 +46,7 @@ func Convert( switch typed := r.(type) { case *bazilfuse.LookupRequest: to := &LookUpInodeOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.Name, } @@ -54,6 +55,7 @@ func Convert( case *bazilfuse.GetattrRequest: to := &GetInodeAttributesOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), } io = to @@ -61,6 +63,7 @@ func Convert( case *bazilfuse.SetattrRequest: to := &SetInodeAttributesOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), } @@ -85,6 +88,7 @@ func Convert( case *bazilfuse.ForgetRequest: to := &ForgetInodeOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), N: typed.N, } @@ -93,6 +97,7 @@ func Convert( case *bazilfuse.MkdirRequest: to := &MkDirOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.Name, Mode: typed.Mode, @@ -102,6 +107,7 @@ func Convert( case *bazilfuse.CreateRequest: to := &CreateFileOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.Name, Mode: typed.Mode, @@ -112,6 +118,7 @@ func Convert( case *bazilfuse.SymlinkRequest: to := &CreateSymlinkOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.NewName, Target: typed.Target, @@ -121,6 +128,7 @@ func Convert( case *bazilfuse.RenameRequest: to := &RenameOp{ + bfReq: typed, OldParent: InodeID(typed.Header.Node), OldName: typed.OldName, NewParent: InodeID(typed.NewDir), @@ -132,6 +140,7 @@ func Convert( case *bazilfuse.RemoveRequest: if typed.Dir { to := &RmDirOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.Name, } @@ -139,6 +148,7 @@ func Convert( co = &to.commonOp } else { to := &UnlinkOp{ + bfReq: typed, Parent: InodeID(typed.Header.Node), Name: typed.Name, } @@ -149,6 +159,7 @@ func Convert( case *bazilfuse.OpenRequest: if typed.Dir { to := &OpenDirOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Flags: typed.Flags, } @@ -156,6 +167,7 @@ func Convert( co = &to.commonOp } else { to := &OpenFileOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Flags: typed.Flags, } @@ -166,6 +178,7 @@ func Convert( case *bazilfuse.ReadRequest: if typed.Dir { to := &ReadDirOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Handle: HandleID(typed.Handle), Offset: DirOffset(typed.Offset), @@ -175,6 +188,7 @@ func Convert( co = &to.commonOp } else { to := &ReadFileOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Handle: HandleID(typed.Handle), Offset: typed.Offset, @@ -187,12 +201,14 @@ func Convert( case *bazilfuse.ReleaseRequest: if typed.Dir { to := &ReleaseDirHandleOp{ + bfReq: typed, Handle: HandleID(typed.Handle), } io = to co = &to.commonOp } else { to := &ReleaseFileHandleOp{ + bfReq: typed, Handle: HandleID(typed.Handle), } io = to @@ -201,6 +217,7 @@ func Convert( case *bazilfuse.WriteRequest: to := &WriteFileOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Handle: HandleID(typed.Handle), Data: typed.Data, @@ -217,6 +234,7 @@ func Convert( co = &to.commonOp } else { to := &SyncFileOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Handle: HandleID(typed.Handle), } @@ -226,6 +244,7 @@ func Convert( case *bazilfuse.FlushRequest: to := &FlushFileOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), Handle: HandleID(typed.Handle), } @@ -234,6 +253,7 @@ func Convert( case *bazilfuse.ReadlinkRequest: to := &ReadSymlinkOp{ + bfReq: typed, Inode: InodeID(typed.Header.Node), } io = to