Add FuseID/Unique Op ID to OpContext
parent
bb43c71d6f
commit
702f658418
138
conversions.go
138
conversions.go
|
@ -53,13 +53,19 @@ func convertInMessage(
|
|||
o = &fuseops.LookUpInodeOp{
|
||||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(buf[:n-1]),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpGetattr:
|
||||
o = &fuseops.GetInodeAttributesOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpSetattr:
|
||||
|
@ -71,7 +77,10 @@ func convertInMessage(
|
|||
|
||||
to := &fuseops.SetInodeAttributesOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
o = to
|
||||
|
||||
|
@ -118,7 +127,10 @@ func convertInMessage(
|
|||
o = &fuseops.ForgetInodeOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
N: in.Nlookup,
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpBatchForget:
|
||||
|
@ -144,7 +156,10 @@ func convertInMessage(
|
|||
|
||||
o = &fuseops.BatchForgetOp{
|
||||
Entries: entries,
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpMkdir:
|
||||
|
@ -171,7 +186,10 @@ func convertInMessage(
|
|||
// opcode is mkdir. But we want the correct mode to go through, so ensure
|
||||
// that os.ModeDir is set.
|
||||
Mode: convertFileMode(in.Mode) | os.ModeDir,
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpMknod:
|
||||
|
@ -191,7 +209,10 @@ func convertInMessage(
|
|||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(name),
|
||||
Mode: convertFileMode(in.Mode),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpCreate:
|
||||
|
@ -211,7 +232,10 @@ func convertInMessage(
|
|||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(name),
|
||||
Mode: convertFileMode(in.Mode),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpSymlink:
|
||||
|
@ -230,7 +254,10 @@ func convertInMessage(
|
|||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(newName),
|
||||
Target: string(target),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpRename:
|
||||
|
@ -272,7 +299,10 @@ func convertInMessage(
|
|||
OldName: string(oldName),
|
||||
NewParent: fuseops.InodeID(in.Newdir),
|
||||
NewName: string(newName),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpUnlink:
|
||||
|
@ -285,7 +315,10 @@ func convertInMessage(
|
|||
o = &fuseops.UnlinkOp{
|
||||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(buf[:n-1]),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpRmdir:
|
||||
|
@ -298,7 +331,10 @@ func convertInMessage(
|
|||
o = &fuseops.RmDirOp{
|
||||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(buf[:n-1]),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpOpen:
|
||||
|
@ -311,13 +347,19 @@ func convertInMessage(
|
|||
o = &fuseops.OpenFileOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpenFlags: fusekernel.OpenFlags(in.Flags),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpOpendir:
|
||||
o = &fuseops.OpenDirOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpRead:
|
||||
|
@ -331,7 +373,10 @@ func convertInMessage(
|
|||
Handle: fuseops.HandleID(in.Fh),
|
||||
Offset: int64(in.Offset),
|
||||
Size: int64(in.Size),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
if !config.UseVectoredRead {
|
||||
// Use part of the incoming message storage as the read buffer
|
||||
|
@ -350,7 +395,10 @@ func convertInMessage(
|
|||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Handle: fuseops.HandleID(in.Fh),
|
||||
Offset: fuseops.DirOffset(in.Offset),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
o = to
|
||||
|
||||
|
@ -374,7 +422,10 @@ func convertInMessage(
|
|||
|
||||
o = &fuseops.ReleaseFileHandleOp{
|
||||
Handle: fuseops.HandleID(in.Fh),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpReleasedir:
|
||||
|
@ -386,7 +437,10 @@ func convertInMessage(
|
|||
|
||||
o = &fuseops.ReleaseDirHandleOp{
|
||||
Handle: fuseops.HandleID(in.Fh),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpWrite:
|
||||
|
@ -405,7 +459,10 @@ func convertInMessage(
|
|||
Handle: fuseops.HandleID(in.Fh),
|
||||
Data: buf,
|
||||
Offset: int64(in.Offset),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpFsync, fusekernel.OpFsyncdir:
|
||||
|
@ -418,7 +475,10 @@ func convertInMessage(
|
|||
o = &fuseops.SyncFileOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Handle: fuseops.HandleID(in.Fh),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpFlush:
|
||||
|
@ -431,13 +491,19 @@ func convertInMessage(
|
|||
o = &fuseops.FlushFileOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Handle: fuseops.HandleID(in.Fh),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpReadlink:
|
||||
o = &fuseops.ReadSymlinkOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpStatfs:
|
||||
|
@ -488,7 +554,10 @@ func convertInMessage(
|
|||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(name),
|
||||
Target: fuseops.InodeID(in.Oldnodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpRemovexattr:
|
||||
|
@ -501,7 +570,10 @@ func convertInMessage(
|
|||
o = &fuseops.RemoveXattrOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(buf[:n-1]),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
|
||||
case fusekernel.OpGetxattr:
|
||||
|
@ -521,7 +593,10 @@ func convertInMessage(
|
|||
to := &fuseops.GetXattrOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
Name: string(name),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
o = to
|
||||
|
||||
|
@ -549,7 +624,10 @@ func convertInMessage(
|
|||
|
||||
to := &fuseops.ListXattrOp{
|
||||
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid,
|
||||
},
|
||||
}
|
||||
o = to
|
||||
|
||||
|
@ -588,7 +666,9 @@ func convertInMessage(
|
|||
Name: string(name),
|
||||
Value: value,
|
||||
Flags: in.Flags,
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid},
|
||||
}
|
||||
case fusekernel.OpFallocate:
|
||||
type input fusekernel.FallocateIn
|
||||
|
@ -603,7 +683,9 @@ func convertInMessage(
|
|||
Offset: in.Offset,
|
||||
Length: in.Length,
|
||||
Mode: in.Mode,
|
||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||
OpContext: fuseops.OpContext{
|
||||
FuseID: inMsg.Header().Unique,
|
||||
Pid: inMsg.Header().Pid},
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -28,6 +28,9 @@ import (
|
|||
// OpContext contains extra context that may be needed by some file systems.
|
||||
// See https://libfuse.github.io/doxygen/structfuse__context.html as a reference.
|
||||
type OpContext struct {
|
||||
// FuseID is the Unique identifier for each operation from the kernel.
|
||||
FuseID uint64
|
||||
|
||||
// PID of the process that is invoking the operation.
|
||||
// Not filled in case of a writepage operation.
|
||||
Pid uint32
|
||||
|
|
Loading…
Reference in New Issue