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
Levin Zimmermann
go-fuse
Commits
4d9a8aee
Commit
4d9a8aee
authored
Jul 04, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let UnionFs expose 3 cache drop functions publically.
Test for behavior of deletion cache drop too.
parent
98b666ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
6 deletions
+55
-6
unionfs/unionfs.go
unionfs/unionfs.go
+13
-3
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+42
-3
No files found.
unionfs/unionfs.go
View file @
4d9a8aee
...
@@ -720,10 +720,17 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
...
@@ -720,10 +720,17 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
return
code
return
code
}
}
func
(
me
*
UnionFs
)
DropCaches
()
{
// TODO - a DropBranchCache which takes a list of names.
log
.
Println
(
"Forced cache drop on"
,
me
.
name
)
func
(
me
*
UnionFs
)
DropBranchCache
()
{
me
.
branchCache
.
DropAll
()
me
.
branchCache
.
DropAll
()
}
func
(
me
*
UnionFs
)
DropDeletionCache
()
{
me
.
deletionCache
.
DropCache
()
me
.
deletionCache
.
DropCache
()
}
func
(
me
*
UnionFs
)
DropSubFsCaches
()
{
for
_
,
fs
:=
range
me
.
fileSystems
{
for
_
,
fs
:=
range
me
.
fileSystems
{
a
,
code
:=
fs
.
GetAttr
(
_DROP_CACHE
)
a
,
code
:=
fs
.
GetAttr
(
_DROP_CACHE
)
if
code
.
Ok
()
&&
a
.
IsRegular
()
{
if
code
.
Ok
()
&&
a
.
IsRegular
()
{
...
@@ -739,7 +746,10 @@ func (me *UnionFs) DropCaches() {
...
@@ -739,7 +746,10 @@ func (me *UnionFs) DropCaches() {
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
if
name
==
_DROP_CACHE
{
if
name
==
_DROP_CACHE
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
me
.
DropCaches
()
log
.
Println
(
"Forced cache drop on"
,
me
.
name
)
me
.
DropBranchCache
()
me
.
DropDeletionCache
()
me
.
DropSubFsCaches
()
}
}
return
fuse
.
NewDevNullFile
(),
fuse
.
OK
return
fuse
.
NewDevNullFile
(),
fuse
.
OK
}
}
...
...
unionfs/unionfs_test.go
View file @
4d9a8aee
...
@@ -44,10 +44,12 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
...
@@ -44,10 +44,12 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
NewCachingFileSystem
(
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
),
0
))
NewCachingFileSystem
(
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
),
0
))
ufs
:=
NewUnionFs
(
"testFs"
,
fses
,
testOpts
)
ufs
:=
NewUnionFs
(
"testFs"
,
fses
,
testOpts
)
// We configure timeouts are smaller, so we can check for
// UnionFs's cache consistency.
opts
:=
&
fuse
.
FileSystemOptions
{
opts
:=
&
fuse
.
FileSystemOptions
{
EntryTimeout
:
entryTtl
,
EntryTimeout
:
.5
*
entryTtl
,
AttrTimeout
:
entryTtl
,
AttrTimeout
:
.5
*
entryTtl
,
NegativeTimeout
:
entryTtl
,
NegativeTimeout
:
.5
*
entryTtl
,
}
}
state
,
_
,
err
:=
fuse
.
MountFileSystem
(
wd
+
"/mount"
,
ufs
,
opts
)
state
,
_
,
err
:=
fuse
.
MountFileSystem
(
wd
+
"/mount"
,
ufs
,
opts
)
...
@@ -541,6 +543,43 @@ func Readdirnames(dir string) ([]string, os.Error) {
...
@@ -541,6 +543,43 @@ func Readdirnames(dir string) ([]string, os.Error) {
return
f
.
Readdirnames
(
-
1
)
return
f
.
Readdirnames
(
-
1
)
}
}
func
TestDropDeletionCache
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestDropDeletionCache"
)
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"bla"
),
0644
)
CheckSuccess
(
err
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
err
=
os
.
Remove
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/file"
)
if
fi
!=
nil
{
t
.
Fatal
(
"Lstat() should have failed"
,
fi
)
}
names
,
err
:=
Readdirnames
(
wd
+
"/rw/DELETIONS"
)
CheckSuccess
(
err
)
if
len
(
names
)
!=
1
{
t
.
Fatal
(
"unexpected names"
,
names
)
}
os
.
Remove
(
wd
+
"/rw/DELETIONS/"
+
names
[
0
])
fi
,
_
=
os
.
Lstat
(
wd
+
"/mount/file"
)
if
fi
!=
nil
{
t
.
Fatal
(
"Lstat() should have failed"
,
fi
)
}
// Expire kernel entry.
time
.
Sleep
(
0.6e9
*
entryTtl
)
err
=
ioutil
.
WriteFile
(
wd
+
"/mount/.drop_cache"
,
[]
byte
(
""
),
0644
)
CheckSuccess
(
err
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/file"
)
if
err
!=
nil
{
t
.
Fatal
(
"Lstat() should have succeeded"
,
err
)
}
}
func
TestDropCache
(
t
*
testing
.
T
)
{
func
TestDropCache
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestDropCache"
)
t
.
Log
(
"TestDropCache"
)
wd
,
clean
:=
setupUfs
(
t
)
wd
,
clean
:=
setupUfs
(
t
)
...
...
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