Fixed simple cachingfs errors.

geesefs-0-30-9
Aaron Jacobs 2015-03-24 16:09:29 +11:00
parent cfc692da07
commit fc3e144abf
1 changed files with 24 additions and 26 deletions

View File

@ -20,7 +20,7 @@ import (
"time" "time"
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil" "github.com/jacobsa/fuse/fuseops"
"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 (
// 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() fuseops.InodeID
DirID() fuse.InodeID DirID() fuseops.InodeID
BarID() fuse.InodeID BarID() fuseops.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 {
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 fuseops.InodeID) fuseops.InodeID {
return numInodes * ((n + numInodes - 1) / numInodes) return numInodes * ((n + numInodes - 1) / numInodes)
} }
@ -99,8 +99,6 @@ const (
) )
type cachingFS struct { type cachingFS struct {
fuseutil.NotImplementedFileSystem
///////////////////////// /////////////////////////
// Constant data // Constant data
///////////////////////// /////////////////////////
@ -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 fuseops.InodeID
// GUARDED_BY(mu) // GUARDED_BY(mu)
mtime time.Time mtime time.Time
@ -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() fuseops.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() fuseops.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() fuseops.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() fuseops.InodeAttributes {
return fuse.InodeAttributes{ return fuseops.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() fuseops.InodeAttributes {
return fuse.InodeAttributes{ return fuseops.InodeAttributes{
Nlink: 1, Nlink: 1,
Size: FooSize, Size: FooSize,
Mode: 0777, Mode: 0777,
@ -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() fuseops.InodeAttributes {
return fuse.InodeAttributes{ return fuseops.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 {
} }
// LOCKS_REQUIRED(fs.mu) // LOCKS_REQUIRED(fs.mu)
func (fs *cachingFS) barAttrs() fuse.InodeAttributes { func (fs *cachingFS) barAttrs() fuseops.InodeAttributes {
return fuse.InodeAttributes{ return fuseops.InodeAttributes{
Nlink: 1, Nlink: 1,
Size: BarSize, Size: BarSize,
Mode: 0777, Mode: 0777,
@ -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() fuseops.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 {
} }
// LOCKS_EXCLUDED(fs.mu) // LOCKS_EXCLUDED(fs.mu)
func (fs *cachingFS) DirID() fuse.InodeID { func (fs *cachingFS) DirID() fuseops.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 {
} }
// LOCKS_EXCLUDED(fs.mu) // LOCKS_EXCLUDED(fs.mu)
func (fs *cachingFS) BarID() fuse.InodeID { func (fs *cachingFS) BarID() fuseops.InodeID {
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()
@ -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 fuseops.InodeID
var attrs fuse.InodeAttributes var attrs fuseops.InodeAttributes
switch req.Name { switch req.Name {
case "foo": case "foo":
@ -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 fuseops.InodeAttributes
switch { switch {
case req.Inode == fuse.RootInodeID: case req.Inode == fuse.RootInodeID: