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
8a4e3f24
Commit
8a4e3f24
authored
Mar 17, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked inode numbering.
parent
064452dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
12 deletions
+46
-12
samples/cachingfs/caching_fs.go
samples/cachingfs/caching_fs.go
+46
-12
No files found.
samples/cachingfs/caching_fs.go
View file @
8a4e3f24
...
...
@@ -15,14 +15,20 @@
package
cachingfs
import
(
"sync"
"time"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/gcloud/syncutil"
"golang.org/x/net/context"
)
const
(
// Sizes of the files according to the file system.
FooSize
=
123
BarSize
=
456
)
// A file system with a fixed structure that looks like this:
//
// foo
...
...
@@ -64,32 +70,60 @@ type CachingFS interface {
func
NewCachingFS
(
lookupEntryTimeout
time
.
Duration
,
getattrTimeout
time
.
Duration
)
(
fs
CachingFS
,
err
error
)
{
fs
=
&
cachingFS
{
inodeIDBase
:
fuse
.
RootInodeID
+
1
,
mtime
:
time
.
Now
(),
cfs
:
=
&
cachingFS
{
fooID
:
((
fuse
.
RootInodeID
+
1
+
numInodes
-
1
)
/
numInodes
)
+
fooOffset
,
mtime
:
time
.
Now
(),
}
cfs
.
mu
=
syncutil
.
NewInvariantMutex
(
cfs
.
checkInvariants
)
fs
=
cfs
return
}
const
(
// Inode IDs are issued such that "foo" always receives an ID that is
// congruent to fooOffset modulo numInodes, etc.
fooOffset
=
iota
dirOffset
barOffset
numInodes
)
type
cachingFS
struct
{
fuseutil
.
NotImplementedFileSystem
mu
sync
.
Mutex
mu
syncutil
.
InvariantMutex
// The current ID of foo.
//
// INVARIANT: FooID() > fuse.RootInodeID
// INVARIANT: DirID() > fuse.RootInodeID
// INVARIANT: BarID() > fuse.RootInodeID
//
// INVARIANT: FooID() % numInodes == fooOffset
// INVARIANT: DirID() % numInodes == dirOffset
// INVARIANT: BarID() % numInodes == barOffset
//
// GUARDED_BY(mu)
inodeIDBase
fuse
.
InodeID
fooID
fuse
.
InodeID
// GUARDED_BY(mu)
mtime
time
.
Time
}
func
(
fs
*
cachingFS
)
checkInvariants
()
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
RenumberInodes
(
base
fuse
.
InodeID
)
{
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
func
(
fs
*
cachingFS
)
FooID
()
fuse
.
InodeID
fs
.
inodeIDBase
=
base
}
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
DirID
()
fuse
.
InodeID
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
BarID
()
fuse
.
InodeID
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
RenumberInodes
()
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
SetMtime
(
mtime
time
.
Time
)
{
...
...
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