Use Connection.log for ops, too.
parent
d12e71f773
commit
1720b526fb
|
@ -85,7 +85,11 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
|||
}
|
||||
|
||||
// Convert it, if possible.
|
||||
if op = fuseops.Convert(bfReq, c.logger, &c.opsInFlight); op == nil {
|
||||
logForOp := func(format string, v ...interface{}) {
|
||||
c.log(opID, format, v)
|
||||
}
|
||||
|
||||
if op = fuseops.Convert(bfReq, logForOp, &c.opsInFlight); op == nil {
|
||||
c.log(opID, "Returning ENOSYS for unknown bazilfuse request: %v", bfReq)
|
||||
bfReq.RespondError(ENOSYS)
|
||||
continue
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package fuseops
|
||||
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -34,7 +33,7 @@ import (
|
|||
// be called by anyone else.
|
||||
func Convert(
|
||||
r bazilfuse.Request,
|
||||
logger *log.Logger,
|
||||
logForOp func(string, ...interface{}),
|
||||
opsInFlight *sync.WaitGroup) (o Op) {
|
||||
var co *commonOp
|
||||
|
||||
|
@ -218,7 +217,7 @@ func Convert(
|
|||
return
|
||||
}
|
||||
|
||||
co.init(reflect.TypeOf(o).String(), r, logger, opsInFlight)
|
||||
co.init(reflect.TypeOf(o).String(), r, logForOp, opsInFlight)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -271,19 +270,19 @@ type commonOp struct {
|
|||
opType string
|
||||
ctx context.Context
|
||||
r bazilfuse.Request
|
||||
logger *log.Logger
|
||||
log func(string, ...interface{})
|
||||
opsInFlight *sync.WaitGroup
|
||||
}
|
||||
|
||||
func (o *commonOp) init(
|
||||
opType string,
|
||||
r bazilfuse.Request,
|
||||
logger *log.Logger,
|
||||
log func(string, ...interface{}),
|
||||
opsInFlight *sync.WaitGroup) {
|
||||
o.opType = opType
|
||||
o.ctx = context.Background()
|
||||
o.r = r
|
||||
o.logger = logger
|
||||
o.log = log
|
||||
o.opsInFlight = opsInFlight
|
||||
}
|
||||
|
||||
|
@ -300,7 +299,7 @@ func (o *commonOp) Context() context.Context {
|
|||
}
|
||||
|
||||
func (o *commonOp) Logf(format string, v ...interface{}) {
|
||||
o.logger.Printf(format, v...)
|
||||
o.log(format, v...)
|
||||
}
|
||||
|
||||
func (o *commonOp) respondErr(err error) {
|
||||
|
@ -308,7 +307,7 @@ func (o *commonOp) respondErr(err error) {
|
|||
panic("Expect non-nil here.")
|
||||
}
|
||||
|
||||
o.logger.Printf(
|
||||
o.log(
|
||||
"Responding with error to %s: %v",
|
||||
o.opType,
|
||||
err)
|
||||
|
|
|
@ -107,7 +107,7 @@ func (o *InitOp) Respond(err error) {
|
|||
resp.MaxReadahead = o.maxReadahead
|
||||
|
||||
// Respond.
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.InitRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ func (o *LookUpInodeOp) Respond(err error) {
|
|||
resp := bazilfuse.LookupResponse{}
|
||||
convertChildInodeEntry(&o.Entry, &resp)
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.LookupRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ func (o *GetInodeAttributesOp) Respond(err error) {
|
|||
AttrValid: convertExpirationTime(o.AttributesExpiration),
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.GetattrRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ func (o *SetInodeAttributesOp) Respond(err error) {
|
|||
AttrValid: convertExpirationTime(o.AttributesExpiration),
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.SetattrRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ func (o *ForgetInodeOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to ForgetInodeOp")
|
||||
o.log("Responding OK to ForgetInodeOp")
|
||||
o.r.(*bazilfuse.ForgetRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ func (o *MkDirOp) Respond(err error) {
|
|||
resp := bazilfuse.MkdirResponse{}
|
||||
convertChildInodeEntry(&o.Entry, &resp.LookupResponse)
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.MkdirRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ func (o *CreateFileOp) Respond(err error) {
|
|||
}
|
||||
convertChildInodeEntry(&o.Entry, &resp.LookupResponse)
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.CreateRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ func (o *RmDirOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to RmDirOp")
|
||||
o.log("Responding OK to RmDirOp")
|
||||
o.r.(*bazilfuse.RemoveRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ func (o *UnlinkOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to UnlinkOp")
|
||||
o.log("Responding OK to UnlinkOp")
|
||||
o.r.(*bazilfuse.RemoveRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ func (o *OpenDirOp) Respond(err error) {
|
|||
Handle: bazilfuse.HandleID(o.Handle),
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.OpenRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ func (o *ReadDirOp) Respond(err error) {
|
|||
Data: o.Data,
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.ReadRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ func (o *ReleaseDirHandleOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to ReleaseDirHandleOp")
|
||||
o.log("Responding OK to ReleaseDirHandleOp")
|
||||
o.r.(*bazilfuse.ReleaseRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -676,7 +676,7 @@ func (o *OpenFileOp) Respond(err error) {
|
|||
Handle: bazilfuse.HandleID(o.Handle),
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.OpenRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -721,7 +721,7 @@ func (o *ReadFileOp) Respond(err error) {
|
|||
Data: o.Data,
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.ReadRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ func (o *WriteFileOp) Respond(err error) {
|
|||
Size: len(o.Data),
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding: %v", &resp)
|
||||
o.log("Responding: %v", &resp)
|
||||
o.r.(*bazilfuse.WriteRequest).Respond(&resp)
|
||||
}
|
||||
|
||||
|
@ -843,7 +843,7 @@ func (o *SyncFileOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to SyncFileOp")
|
||||
o.log("Responding OK to SyncFileOp")
|
||||
o.r.(*bazilfuse.FsyncRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -910,7 +910,7 @@ func (o *FlushFileOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to FlushFileOp")
|
||||
o.log("Responding OK to FlushFileOp")
|
||||
o.r.(*bazilfuse.FlushRequest).Respond()
|
||||
}
|
||||
|
||||
|
@ -939,6 +939,6 @@ func (o *ReleaseFileHandleOp) Respond(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
o.commonOp.logger.Printf("Responding OK to ReleaseFileHandleOp")
|
||||
o.log("Responding OK to ReleaseFileHandleOp")
|
||||
o.r.(*bazilfuse.ReleaseRequest).Respond()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue