Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
fc3e144a
Commit
fc3e144a
authored
Mar 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed simple cachingfs errors.
parent
cfc692da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
samples/cachingfs/caching_fs.go
samples/cachingfs/caching_fs.go
+24
-26
No files found.
samples/cachingfs/caching_fs.go
View file @
fc3e144a
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"time"
"time"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuse
util
"
"github.com/jacobsa/fuse/fuse
ops
"
"github.com/jacobsa/gcloud/syncutil"
"github.com/jacobsa/gcloud/syncutil"
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
...
@@ -42,12 +42,12 @@ const (
...
@@ -42,12 +42,12 @@ const (
// requests. It also exposes methods for renumbering inodes and updating mtimes
// requests. It also exposes methods for renumbering inodes and updating mtimes
// that are useful in testing that these durations are honored.
// that are useful in testing that these durations are honored.
type
CachingFS
interface
{
type
CachingFS
interface
{
fuse
.
FileSystem
fuse
.
Server
// Return the current inode ID of the file/directory with the given name.
// Return the current inode ID of the file/directory with the given name.
FooID
()
fuse
.
InodeID
FooID
()
fuse
ops
.
InodeID
DirID
()
fuse
.
InodeID
DirID
()
fuse
ops
.
InodeID
BarID
()
fuse
.
InodeID
BarID
()
fuse
ops
.
InodeID
// Cause the inode IDs to change to values that have never before been used.
// Cause the inode IDs to change to values that have never before been used.
RenumberInodes
()
RenumberInodes
()
...
@@ -72,7 +72,7 @@ type CachingFS interface {
...
@@ -72,7 +72,7 @@ type CachingFS interface {
func
NewCachingFS
(
func
NewCachingFS
(
lookupEntryTimeout
time
.
Duration
,
lookupEntryTimeout
time
.
Duration
,
getattrTimeout
time
.
Duration
)
(
fs
CachingFS
,
err
error
)
{
getattrTimeout
time
.
Duration
)
(
fs
CachingFS
,
err
error
)
{
roundUp
:=
func
(
n
fuse
.
InodeID
)
fuse
.
InodeID
{
roundUp
:=
func
(
n
fuse
ops
.
InodeID
)
fuseops
.
InodeID
{
return
numInodes
*
((
n
+
numInodes
-
1
)
/
numInodes
)
return
numInodes
*
((
n
+
numInodes
-
1
)
/
numInodes
)
}
}
...
@@ -99,8 +99,6 @@ const (
...
@@ -99,8 +99,6 @@ const (
)
)
type
cachingFS
struct
{
type
cachingFS
struct
{
fuseutil
.
NotImplementedFileSystem
/////////////////////////
/////////////////////////
// Constant data
// Constant data
/////////////////////////
/////////////////////////
...
@@ -120,7 +118,7 @@ type cachingFS struct {
...
@@ -120,7 +118,7 @@ type cachingFS struct {
// INVARIANT: baseID % numInodes == 0
// INVARIANT: baseID % numInodes == 0
//
//
// GUARDED_BY(mu)
// GUARDED_BY(mu)
baseID
fuse
.
InodeID
baseID
fuse
ops
.
InodeID
// GUARDED_BY(mu)
// GUARDED_BY(mu)
mtime
time
.
Time
mtime
time
.
Time
...
@@ -139,31 +137,31 @@ func (fs *cachingFS) checkInvariants() {
...
@@ -139,31 +137,31 @@ func (fs *cachingFS) checkInvariants() {
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
fooID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
fooID
()
fuse
ops
.
InodeID
{
return
fs
.
baseID
+
fooOffset
return
fs
.
baseID
+
fooOffset
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
dirID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
dirID
()
fuse
ops
.
InodeID
{
return
fs
.
baseID
+
dirOffset
return
fs
.
baseID
+
dirOffset
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
barID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
barID
()
fuse
ops
.
InodeID
{
return
fs
.
baseID
+
barOffset
return
fs
.
baseID
+
barOffset
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
rootAttrs
()
fuse
.
InodeAttributes
{
func
(
fs
*
cachingFS
)
rootAttrs
()
fuse
ops
.
InodeAttributes
{
return
fuse
.
InodeAttributes
{
return
fuse
ops
.
InodeAttributes
{
Mode
:
os
.
ModeDir
|
0777
,
Mode
:
os
.
ModeDir
|
0777
,
Mtime
:
fs
.
mtime
,
Mtime
:
fs
.
mtime
,
}
}
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
fooAttrs
()
fuse
.
InodeAttributes
{
func
(
fs
*
cachingFS
)
fooAttrs
()
fuse
ops
.
InodeAttributes
{
return
fuse
.
InodeAttributes
{
return
fuse
ops
.
InodeAttributes
{
Nlink
:
1
,
Nlink
:
1
,
Size
:
FooSize
,
Size
:
FooSize
,
Mode
:
0777
,
Mode
:
0777
,
...
@@ -172,8 +170,8 @@ func (fs *cachingFS) fooAttrs() fuse.InodeAttributes {
...
@@ -172,8 +170,8 @@ func (fs *cachingFS) fooAttrs() fuse.InodeAttributes {
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
dirAttrs
()
fuse
.
InodeAttributes
{
func
(
fs
*
cachingFS
)
dirAttrs
()
fuse
ops
.
InodeAttributes
{
return
fuse
.
InodeAttributes
{
return
fuse
ops
.
InodeAttributes
{
Nlink
:
1
,
Nlink
:
1
,
Mode
:
os
.
ModeDir
|
0777
,
Mode
:
os
.
ModeDir
|
0777
,
Mtime
:
fs
.
mtime
,
Mtime
:
fs
.
mtime
,
...
@@ -181,8 +179,8 @@ func (fs *cachingFS) dirAttrs() fuse.InodeAttributes {
...
@@ -181,8 +179,8 @@ func (fs *cachingFS) dirAttrs() fuse.InodeAttributes {
}
}
// LOCKS_REQUIRED(fs.mu)
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
barAttrs
()
fuse
.
InodeAttributes
{
func
(
fs
*
cachingFS
)
barAttrs
()
fuse
ops
.
InodeAttributes
{
return
fuse
.
InodeAttributes
{
return
fuse
ops
.
InodeAttributes
{
Nlink
:
1
,
Nlink
:
1
,
Size
:
BarSize
,
Size
:
BarSize
,
Mode
:
0777
,
Mode
:
0777
,
...
@@ -195,7 +193,7 @@ func (fs *cachingFS) barAttrs() fuse.InodeAttributes {
...
@@ -195,7 +193,7 @@ func (fs *cachingFS) barAttrs() fuse.InodeAttributes {
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// LOCKS_EXCLUDED(fs.mu)
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
FooID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
FooID
()
fuse
ops
.
InodeID
{
fs
.
mu
.
Lock
()
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
...
@@ -203,7 +201,7 @@ func (fs *cachingFS) FooID() fuse.InodeID {
...
@@ -203,7 +201,7 @@ func (fs *cachingFS) FooID() fuse.InodeID {
}
}
// LOCKS_EXCLUDED(fs.mu)
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
DirID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
DirID
()
fuse
ops
.
InodeID
{
fs
.
mu
.
Lock
()
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
...
@@ -211,7 +209,7 @@ func (fs *cachingFS) DirID() fuse.InodeID {
...
@@ -211,7 +209,7 @@ func (fs *cachingFS) DirID() fuse.InodeID {
}
}
// LOCKS_EXCLUDED(fs.mu)
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
BarID
()
fuse
.
InodeID
{
func
(
fs
*
cachingFS
)
BarID
()
fuse
ops
.
InodeID
{
fs
.
mu
.
Lock
()
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
...
@@ -255,8 +253,8 @@ func (fs *cachingFS) LookUpInode(
...
@@ -255,8 +253,8 @@ func (fs *cachingFS) LookUpInode(
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
// Find the ID and attributes.
// Find the ID and attributes.
var
id
fuse
.
InodeID
var
id
fuse
ops
.
InodeID
var
attrs
fuse
.
InodeAttributes
var
attrs
fuse
ops
.
InodeAttributes
switch
req
.
Name
{
switch
req
.
Name
{
case
"foo"
:
case
"foo"
:
...
@@ -313,7 +311,7 @@ func (fs *cachingFS) GetInodeAttributes(
...
@@ -313,7 +311,7 @@ func (fs *cachingFS) GetInodeAttributes(
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
// Figure out which inode the request is for.
// Figure out which inode the request is for.
var
attrs
fuse
.
InodeAttributes
var
attrs
fuse
ops
.
InodeAttributes
switch
{
switch
{
case
req
.
Inode
==
fuse
.
RootInodeID
:
case
req
.
Inode
==
fuse
.
RootInodeID
:
...
...
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