Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go-fuse
Commits
1ea7b36d
Commit
1ea7b36d
authored
Feb 08, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add status/debug to autounionfs.
This gives some insight into memory usage.
parent
7e97732d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
0 deletions
+69
-0
example/autounionfs/main.go
example/autounionfs/main.go
+3
-0
unionfs/autounion.go
unionfs/autounion.go
+54
-0
unionfs/autounion_test.go
unionfs/autounion_test.go
+12
-0
No files found.
example/autounionfs/main.go
View file @
1ea7b36d
...
...
@@ -59,5 +59,8 @@ func main() {
pathfs
.
Debug
=
*
debug
conn
.
Debug
=
*
debug
state
.
Debug
=
*
debug
gofs
.
SetMountState
(
state
)
state
.
Loop
()
}
unionfs/autounion.go
View file @
1ea7b36d
...
...
@@ -33,6 +33,8 @@ type AutoUnionFs struct {
nodeFs
*
fuse
.
PathNodeFs
options
*
AutoUnionFsOptions
mountState
*
fuse
.
MountState
}
type
AutoUnionFsOptions
struct
{
...
...
@@ -48,6 +50,7 @@ const (
_READONLY
=
"READONLY"
_STATUS
=
"status"
_CONFIG
=
"config"
_DEBUG
=
"debug"
_ROOT
=
"root"
_VERSION
=
"gounionfs_version"
_SCAN_CONFIG
=
".scan_config"
...
...
@@ -277,6 +280,14 @@ func (me *AutoUnionFs) GetAttr(path string, context *fuse.Context) (*fuse.Attr,
return
a
,
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_STATUS
,
_DEBUG
)
{
a
:=
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFREG
|
0644
,
Size
:
uint64
(
len
(
me
.
DebugData
())),
}
return
a
,
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_STATUS
,
_ROOT
)
{
a
:=
&
fuse
.
Attr
{
Mode
:
syscall
.
S_IFLNK
|
0644
,
...
...
@@ -314,6 +325,10 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
Name
:
_VERSION
,
Mode
:
fuse
.
S_IFREG
|
0644
,
}
stream
<-
fuse
.
DirEntry
{
Name
:
_DEBUG
,
Mode
:
fuse
.
S_IFREG
|
0644
,
}
stream
<-
fuse
.
DirEntry
{
Name
:
_ROOT
,
Mode
:
syscall
.
S_IFLNK
|
0644
,
...
...
@@ -323,7 +338,46 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
return
stream
,
fuse
.
OK
}
// SetMountState stores the MountState, which is necessary for
// retrieving debug data.
func
(
me
*
AutoUnionFs
)
SetMountState
(
state
*
fuse
.
MountState
)
{
me
.
mountState
=
state
}
func
(
me
*
AutoUnionFs
)
DebugData
()
string
{
if
me
.
mountState
==
nil
{
return
"AutoUnionFs.mountState not set"
}
setting
:=
me
.
mountState
.
KernelSettings
()
msg
:=
fmt
.
Sprintf
(
"Version: %v
\n
"
+
"Bufferpool: %v
\n
"
+
"Kernel: %v
\n
"
,
fuse
.
Version
(),
me
.
mountState
.
BufferPoolStats
(),
&
setting
)
lat
:=
me
.
mountState
.
Latencies
()
if
len
(
lat
)
>
0
{
msg
+=
fmt
.
Sprintf
(
"Latencies: %v
\n
"
,
lat
)
}
counts
:=
me
.
mountState
.
OperationCounts
()
if
len
(
counts
)
>
0
{
msg
+=
fmt
.
Sprintf
(
"Op counts: %v
\n
"
,
counts
)
}
return
msg
}
func
(
me
*
AutoUnionFs
)
Open
(
path
string
,
flags
uint32
,
context
*
fuse
.
Context
)
(
fuse
.
File
,
fuse
.
Status
)
{
if
path
==
filepath
.
Join
(
_STATUS
,
_DEBUG
)
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
return
nil
,
fuse
.
EPERM
}
return
fuse
.
NewDataFile
([]
byte
(
me
.
DebugData
())),
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_STATUS
,
_VERSION
)
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
return
nil
,
fuse
.
EPERM
...
...
unionfs/autounion_test.go
View file @
1ea7b36d
...
...
@@ -59,6 +59,18 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
}
}
func
TestDebug
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setup
(
t
)
defer
clean
()
c
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mnt/status/debug"
)
CheckSuccess
(
err
)
if
len
(
c
)
==
0
{
t
.
Fatal
(
"No debug found."
)
}
log
.
Println
(
"Found version:"
,
string
(
c
))
}
func
TestVersion
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setup
(
t
)
defer
clean
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment