Commit 94e31a27 authored by Aaron Jacobs's avatar Aaron Jacobs

Use the fuse ID in debug logs.

It's too confusing with a distinct set of IDs for logging.
parent c80811a7
...@@ -67,9 +67,6 @@ type Connection struct { ...@@ -67,9 +67,6 @@ type Connection struct {
// The context from which all op contexts inherit. // The context from which all op contexts inherit.
parentCtx context.Context parentCtx context.Context
// For logging purposes only.
nextOpID uint32
mu sync.Mutex mu sync.Mutex
// A map from fuse "unique" request ID (*not* the op ID for logging used // A map from fuse "unique" request ID (*not* the op ID for logging used
...@@ -89,7 +86,6 @@ type opState struct { ...@@ -89,7 +86,6 @@ type opState struct {
inMsg *buffer.InMessage inMsg *buffer.InMessage
outMsg *buffer.OutMessage outMsg *buffer.OutMessage
op interface{} op interface{}
opID uint32 // For logging
} }
// Create a connection wrapping the supplied file descriptor connected to the // Create a connection wrapping the supplied file descriptor connected to the
...@@ -171,7 +167,7 @@ func (c *Connection) Init() (err error) { ...@@ -171,7 +167,7 @@ func (c *Connection) Init() (err error) {
// Log information for an operation with the given ID. calldepth is the depth // Log information for an operation with the given ID. calldepth is the depth
// to use when recovering file:line information with runtime.Caller. // to use when recovering file:line information with runtime.Caller.
func (c *Connection) debugLog( func (c *Connection) debugLog(
opID uint32, fuseID uint64,
calldepth int, calldepth int,
format string, format string,
v ...interface{}) { v ...interface{}) {
...@@ -194,7 +190,7 @@ func (c *Connection) debugLog( ...@@ -194,7 +190,7 @@ func (c *Connection) debugLog(
// Format the actual message to be printed. // Format the actual message to be printed.
msg := fmt.Sprintf( msg := fmt.Sprintf(
"Op 0x%08x %24s] %v", "Op 0x%08x %24s] %v",
opID, fuseID,
fileLine, fileLine,
fmt.Sprintf(format, v...)) fmt.Sprintf(format, v...))
...@@ -387,10 +383,7 @@ func (c *Connection) ReadOp() (ctx context.Context, op interface{}, err error) { ...@@ -387,10 +383,7 @@ func (c *Connection) ReadOp() (ctx context.Context, op interface{}, err error) {
} }
// Choose an ID for this operation for the purposes of logging, and log it. // Choose an ID for this operation for the purposes of logging, and log it.
opID := c.nextOpID c.debugLog(inMsg.Header().Unique, 1, "<- %s", describeRequest(op))
c.nextOpID++
c.debugLog(opID, 1, "<- %s", describeRequest(op))
// Special case: handle interrupt requests inline. // Special case: handle interrupt requests inline.
if interruptOp, ok := op.(*interruptOp); ok { if interruptOp, ok := op.(*interruptOp); ok {
...@@ -400,7 +393,7 @@ func (c *Connection) ReadOp() (ctx context.Context, op interface{}, err error) { ...@@ -400,7 +393,7 @@ func (c *Connection) ReadOp() (ctx context.Context, op interface{}, err error) {
// Set up a context that remembers information about this op. // Set up a context that remembers information about this op.
ctx = c.beginOp(inMsg.Header().Opcode, inMsg.Header().Unique) ctx = c.beginOp(inMsg.Header().Opcode, inMsg.Header().Unique)
ctx = context.WithValue(ctx, contextKey, opState{inMsg, outMsg, op, opID}) ctx = context.WithValue(ctx, contextKey, opState{inMsg, outMsg, op})
// Special case: responding to statfs is required to make mounting work on // Special case: responding to statfs is required to make mounting work on
// OS X. We don't currently expose the capability for the file system to // OS X. We don't currently expose the capability for the file system to
...@@ -431,7 +424,7 @@ func (c *Connection) Reply(ctx context.Context, opErr error) { ...@@ -431,7 +424,7 @@ func (c *Connection) Reply(ctx context.Context, opErr error) {
op := state.op op := state.op
inMsg := state.inMsg inMsg := state.inMsg
outMsg := state.outMsg outMsg := state.outMsg
opID := state.opID fuseID := inMsg.Header().Unique
// Make sure we destroy the messages when we're done. // Make sure we destroy the messages when we're done.
defer c.putInMessage(inMsg) defer c.putInMessage(inMsg)
...@@ -443,9 +436,9 @@ func (c *Connection) Reply(ctx context.Context, opErr error) { ...@@ -443,9 +436,9 @@ func (c *Connection) Reply(ctx context.Context, opErr error) {
// Debug logging // Debug logging
if c.debugLogger != nil { if c.debugLogger != nil {
if opErr == nil { if opErr == nil {
c.debugLog(opID, 1, "-> OK: %s", describeResponse(op)) c.debugLog(fuseID, 1, "-> OK: %s", describeResponse(op))
} else { } else {
c.debugLog(opID, 1, "-> error: %v", opErr) c.debugLog(fuseID, 1, "-> error: %v", opErr)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment