Added a flag for per-PID tracing.
parent
cecf227799
commit
2948c349e2
|
@ -15,6 +15,7 @@
|
||||||
package fuseops
|
package fuseops
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -24,6 +25,13 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var fPerPIDTracing = flag.Bool(
|
||||||
|
"fuse.per_pid_tracing",
|
||||||
|
false,
|
||||||
|
"Enable a hacky mode that uses reqtrace to group all ops from each "+
|
||||||
|
"individual PID. Not a good idea to use in production; races, bugs, and "+
|
||||||
|
"resource leaks likely lurk.")
|
||||||
|
|
||||||
// A helper for embedding common behavior.
|
// A helper for embedding common behavior.
|
||||||
type commonOp struct {
|
type commonOp struct {
|
||||||
opType string
|
opType string
|
||||||
|
@ -52,12 +60,27 @@ func describeOpType(t reflect.Type) (desc string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *commonOp) maybeTraceByPID(in context.Context) (out context.Context) {
|
||||||
|
// Is there anything to do?
|
||||||
|
if !*fPerPIDTracing {
|
||||||
|
out = in
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(jacobsa): Do something interesting.
|
||||||
|
out = in
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (o *commonOp) init(
|
func (o *commonOp) init(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
opType reflect.Type,
|
opType reflect.Type,
|
||||||
r bazilfuse.Request,
|
r bazilfuse.Request,
|
||||||
log func(int, string, ...interface{}),
|
log func(int, string, ...interface{}),
|
||||||
opsInFlight *sync.WaitGroup) {
|
opsInFlight *sync.WaitGroup) {
|
||||||
|
// Set up a context that reflects per-PID tracing if appropriate.
|
||||||
|
ctx = o.maybeTraceByPID(ctx)
|
||||||
|
|
||||||
// Initialize basic fields.
|
// Initialize basic fields.
|
||||||
o.opType = describeOpType(opType)
|
o.opType = describeOpType(opType)
|
||||||
o.r = r
|
o.r = r
|
||||||
|
|
Loading…
Reference in New Issue