Documentation ¶
Index ¶
- Constants
- func IsSymlink(o *gcs.Object) bool
- type BackObject
- type BucketOwnedDirInode
- type BucketOwnedInode
- type DirInode
- type ExplicitDirInode
- type FileInode
- func (f *FileInode) Attributes(ctx context.Context) (attrs fuseops.InodeAttributes, err error)
- func (f *FileInode) Bucket() gcsx.SyncerBucket
- func (f *FileInode) DecrementLookupCount(n uint64) (destroy bool)
- func (f *FileInode) Destroy() (err error)
- func (f *FileInode) ID() fuseops.InodeID
- func (f *FileInode) IncrementLookupCount()
- func (f *FileInode) Lock()
- func (f *FileInode) Name() Name
- func (f *FileInode) Read(ctx context.Context, dst []byte, offset int64) (n int, err error)
- func (f *FileInode) SetMtime(ctx context.Context, mtime time.Time) (err error)
- func (f *FileInode) Source() *gcs.Object
- func (f *FileInode) SourceGeneration() (g Generation)
- func (f *FileInode) SourceGenerationIsAuthoritative() bool
- func (f *FileInode) Sync(ctx context.Context) (err error)
- func (f *FileInode) Truncate(ctx context.Context, size int64) (err error)
- func (f *FileInode) Unlock()
- func (f *FileInode) Write(ctx context.Context, data []byte, offset int64) (err error)
- type Generation
- type GenerationBackedInode
- type Inode
- type Name
- type SymlinkInode
- func (s *SymlinkInode) Attributes(ctx context.Context) (attrs fuseops.InodeAttributes, err error)
- func (s *SymlinkInode) DecrementLookupCount(n uint64) (destroy bool)
- func (s *SymlinkInode) Destroy() (err error)
- func (s *SymlinkInode) ID() fuseops.InodeID
- func (s *SymlinkInode) IncrementLookupCount()
- func (s *SymlinkInode) Lock()
- func (s *SymlinkInode) Name() Name
- func (s *SymlinkInode) SourceGeneration() Generation
- func (s *SymlinkInode) Target() (target string)
- func (s *SymlinkInode) Unlock()
Constants ¶
const ConflictingFileNameSuffix = "\n"
A suffix that can be used to unambiguously tag a file system name. (Unambiguous because U+000A is not allowed in GCS object names.) This is used to refer to the file/symlink in a (file/symlink, directory) pair with conflicting object names.
See also the notes on DirInode.LookUpChild.
const FileMtimeMetadataKey = gcsx.MtimeMetadataKey
A GCS object metadata key for file mtimes. mtimes are UTC, and are stored in the format defined by time.RFC3339Nano.
const SymlinkMetadataKey = "gcsfuse_symlink_target"
When this custom metadata key is present in an object record, it is to be treated as a symlink. For use in testing only; other users should detect this with IsSymlink.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackObject ¶ added in v0.36.0
type BackObject struct { // The GCS bucket that owns the back object Bucket gcsx.SyncerBucket // The full name of the file or directory. // // Guaranteed to be present only if Exists(). FullName Name // The backing gcs object, if any. If the object is not found or exists only // as an implicit directory, or is the root directory of a bucket, this is // nil. Object *gcs.Object // Does the back object exist as a directory implicitly defined by its own // descendents? Meaningful only if Object is nil and implicit directories are // enabled for the parent inode. ImplicitDir bool }
BackObject is the object backing up the inode. A back object for a file inode must be a GCS object. A back object for a directory inode can be a GCS object or an implicit object deduced from other GCS objects.
func (BackObject) Exists ¶ added in v0.36.0
func (bo BackObject) Exists() bool
Exists returns true iff the back object exists implicitly or explicitly.
type BucketOwnedDirInode ¶ added in v0.31.0
type BucketOwnedDirInode interface { DirInode BucketOwnedInode }
An inode that represents a directory from a GCS bucket.
type BucketOwnedInode ¶ added in v0.31.0
type BucketOwnedInode interface { Inode // Return the gcs.Bucket which the dir or file belongs to. Bucket() gcsx.SyncerBucket }
An inode owned by a gcs bucket.
type DirInode ¶
type DirInode interface { Inode // Look up the direct child with the given relative name, returning // information about the object backing the child or whether it exists as an // implicit directory. If a file/symlink and a directory with the given name // both exist, the directory is preferred. Return a result with // !result.Exists() and a nil error if neither is found. // // Special case: if the name ends in ConflictingFileNameSuffix, we strip the // suffix, confirm that a conflicting directory exists, then return a result // for the file/symlink. // // If this inode was created with implicitDirs is set, this method will use // ListObjects to find child directories that are "implicitly" defined by the // existence of their own descendents. For example, if there is an object // named "foo/bar/baz" and this is the directory "foo", a child directory // named "bar" will be implied. In this case, result.ImplicitDir will be // true. LookUpChild( ctx context.Context, name string) (result BackObject, err error) // Read the children objects of this dir, recursively. The result count // is capped at the given limit. Internal caches are not refreshed from this // call. ReadDescendants( ctx context.Context, limit int) (descendants map[Name]BackObject, err error) // Read some number of objects from the directory, returning a continuation // token that can be used to pick up the read operation where it left off. // Supply the empty token on the first call. // // At the end of the directory, the returned continuation token will be // empty. Otherwise it will be non-empty. There is no guarantee about the // number of objects returned; it may be zero even with a non-empty // continuation token. ReadObjects( ctx context.Context, tok string) (files []BackObject, dirs []BackObject, newTok string, err error) // Read some number of entries from the directory, returning a continuation // token that can be used to pick up the read operation where it left off. // Supply the empty token on the first call. // // At the end of the directory, the returned continuation token will be // empty. Otherwise it will be non-empty. There is no guarantee about the // number of entries returned; it may be zero even with a non-empty // continuation token. // // The contents of the Offset and Inode fields for returned entries is // undefined. ReadEntries( ctx context.Context, tok string) (entries []fuseutil.Dirent, newTok string, err error) // Create an empty child file with the supplied (relative) name, failing with // *gcs.PreconditionError if a backing object already exists in GCS. // Return the full name of the child and the GCS object it backs up. CreateChildFile( ctx context.Context, name string) (result BackObject, err error) // Like CreateChildFile, except clone the supplied source object instead of // creating an empty object. // Return the full name of the child and the GCS object it backs up. CloneToChildFile( ctx context.Context, name string, src *gcs.Object) (result BackObject, err error) // Create a symlink object with the supplied (relative) name and the supplied // target, failing with *gcs.PreconditionError if a backing object already // exists in GCS. // Return the full name of the child and the GCS object it backs up. CreateChildSymlink( ctx context.Context, name string, target string) (result BackObject, err error) // Create a backing object for a child directory with the supplied (relative) // name, failing with *gcs.PreconditionError if a backing object already // exists in GCS. // Return the full name of the child and the GCS object it backs up. CreateChildDir( ctx context.Context, name string) (result BackObject, err error) // Delete the backing object for the child file or symlink with the given // (relative) name and generation number, where zero means the latest // generation. If the object/generation doesn't exist, no error is returned. // // metaGeneration may be set to a non-nil pointer giving a meta-generation // precondition, but need not be. DeleteChildFile( ctx context.Context, name string, generation int64, metaGeneration *int64) (err error) // Delete the backing object for the child directory with the given // (relative) name. DeleteChildDir( ctx context.Context, name string) (err error) }
An inode representing a directory, with facilities for listing entries, looking up children, and creating and deleting children. Must be locked for any method additional to the Inode interface.
func NewBaseDirInode ¶ added in v0.31.0
func NewBaseDirInode( id fuseops.InodeID, name Name, attrs fuseops.InodeAttributes, bm gcsx.BucketManager) (d DirInode)
NewBaseDirInode returns a baseDirInode that acts as the directory of buckets.
func NewDirInode ¶
func NewDirInode( id fuseops.InodeID, name Name, attrs fuseops.InodeAttributes, implicitDirs bool, typeCacheTTL time.Duration, bucket gcsx.SyncerBucket, mtimeClock timeutil.Clock, cacheClock timeutil.Clock) (d DirInode)
Create a directory inode for the name, representing the directory containing the objects for which it is an immediate prefix. For the root directory, this is the empty string.
If implicitDirs is set, LookUpChild will use ListObjects to find child directories that are "implicitly" defined by the existence of their own descendents. For example, if there is an object named "foo/bar/baz" and this is the directory "foo", a child directory named "bar" will be implied.
If typeCacheTTL is non-zero, a cache from child name to information about whether that name exists as a file/symlink and/or directory will be maintained. This may speed up calls to LookUpChild, especially when combined with a stat-caching GCS bucket, but comes at the cost of consistency: if the child is removed and recreated with a different type before the expiration, we may fail to find it.
The initial lookup count is zero.
REQUIRES: name.IsDir()
type ExplicitDirInode ¶
type ExplicitDirInode interface { DirInode SourceGeneration() Generation }
An inode representing a directory backed by an object in GCS with a specific generation.
func NewExplicitDirInode ¶
func NewExplicitDirInode( id fuseops.InodeID, name Name, o *gcs.Object, attrs fuseops.InodeAttributes, implicitDirs bool, typeCacheTTL time.Duration, bucket gcsx.SyncerBucket, mtimeClock timeutil.Clock, cacheClock timeutil.Clock) (d ExplicitDirInode)
Create an explicit dir inode backed by the supplied object. See notes on NewDirInode for more.
type FileInode ¶
type FileInode struct {
// contains filtered or unexported fields
}
func NewFileInode ¶
func NewFileInode( id fuseops.InodeID, name Name, o *gcs.Object, attrs fuseops.InodeAttributes, bucket gcsx.SyncerBucket, localFileCache bool, tempDir string, mtimeClock timeutil.Clock) (f *FileInode)
Create a file inode for the given object in GCS. The initial lookup count is zero.
REQUIRES: o != nil REQUIRES: o.Generation > 0 REQUIRES: o.MetaGeneration > 0 REQUIRES: len(o.Name) > 0 REQUIRES: o.Name[len(o.Name)-1] != '/'
func (*FileInode) Attributes ¶
LOCKS_REQUIRED(f.mu)
func (*FileInode) Bucket ¶ added in v0.31.0
func (f *FileInode) Bucket() gcsx.SyncerBucket
func (*FileInode) DecrementLookupCount ¶
LOCKS_REQUIRED(f.mu)
func (*FileInode) IncrementLookupCount ¶
func (f *FileInode) IncrementLookupCount()
LOCKS_REQUIRED(f.mu)
func (*FileInode) Read ¶
Serve a read for this file with semantics matching io.ReaderAt.
The caller may be better off reading directly from GCS when f.SourceGenerationIsAuthoritative() is true.
LOCKS_REQUIRED(f.mu)
func (*FileInode) SetMtime ¶ added in v0.10.0
Set the mtime for this file. May involve a round trip to GCS.
LOCKS_REQUIRED(f.mu)
func (*FileInode) Source ¶
Source returns a record for the GCS object from which this inode is branched. The record is guaranteed not to be modified, and users must not modify it.
LOCKS_REQUIRED(f.mu)
func (*FileInode) SourceGeneration ¶
func (f *FileInode) SourceGeneration() (g Generation)
Equivalent to the generation returned by f.Source().
LOCKS_REQUIRED(f)
func (*FileInode) SourceGenerationIsAuthoritative ¶
If true, it is safe to serve reads directly from the object given by f.Source(), rather than calling f.ReadAt. Doing so may be more efficient, because f.ReadAt may cause the entire object to be faulted in and requires the inode to be locked during the read.
LOCKS_REQUIRED(f.mu)
func (*FileInode) Sync ¶
Sync writes out contents to GCS. If this fails due to the generation having been clobbered, treat it as a non-error (simulating the inode having been unlinked).
After this method succeeds, SourceGeneration will return the new generation by which this inode should be known (which may be the same as before). If it fails, the generation will not change.
LOCKS_REQUIRED(f.mu)
type Generation ¶ added in v0.11.0
A particular generation of a GCS object, consisting of both a GCS object generation number and meta-generation number. Lexicographically ordered on the two.
Cf. https://cloud.google.com/storage/docs/generations-preconditions
func (Generation) Compare ¶ added in v0.11.0
func (g Generation) Compare(other Generation) int
Compare returns -1, 0, or 1 according to whether g is less than, equal to, or greater than other.
type GenerationBackedInode ¶ added in v0.11.0
type GenerationBackedInode interface { Inode // Requires the inode lock. SourceGeneration() Generation }
An inode that is backed by a particular generation of a GCS object.
type Inode ¶
type Inode interface { // All methods below require the lock to be held unless otherwise documented. sync.Locker // Return the ID assigned to the inode. // // Does not require the lock to be held. ID() fuseops.InodeID // Return the name of the GCS object backing the inode. // // Does not require the lock to be held. Name() Name // Increment the lookup count for the inode. For use in fuse operations where // the kernel expects us to remember the inode. IncrementLookupCount() // Return up to date attributes for this inode. Attributes(ctx context.Context) (fuseops.InodeAttributes, error) // Decrement the lookup count for the inode by the given amount. // // If this method returns true, the lookup count has hit zero and the // Destroy() method should be called to release any local resources, perhaps // after releasing locks that should not be held while blocking. DecrementLookupCount(n uint64) (destroy bool) // Clean up any local resources used by the inode, putting it into an // indeterminate state where no method should be called except Unlock. // // This method may block. Errors are for logging purposes only. Destroy() (err error) }
type Name ¶ added in v0.31.0
type Name struct {
// contains filtered or unexported fields
}
Name is the inode's name that can be interpreted in 2 ways:
(1) LocalName: the name of the inode in the local file system. (2) GcsObjectName: the name of its gcs object backed by the inode.
func NewDescendantName ¶ added in v0.36.0
NewDescendant creates a new inode name for an object as a descendant of another inode.
func NewDirName ¶ added in v0.31.0
NewDirName creates a new inode name for a directory.
func NewFileName ¶ added in v0.31.0
NewFileName creates a new inode name for a file.
func NewRootName ¶ added in v0.31.0
NewRootName creates a Name for the root directory of a gcs bucket
func (Name) GcsObjectName ¶ added in v0.31.0
GcsObjectName returns the name of the gcs object backed by the inode.
func (Name) IsBucketRoot ¶ added in v0.31.0
IsBucketRoot returns true if the name represents of a root directory of a GCS bucket.
func (Name) IsDirectChildOf ¶ added in v0.36.0
IsDirectChildOf returns true if the name is a direct child file or directory of another directory.
type SymlinkInode ¶
type SymlinkInode struct {
// contains filtered or unexported fields
}
func NewSymlinkInode ¶
func NewSymlinkInode( id fuseops.InodeID, name Name, o *gcs.Object, attrs fuseops.InodeAttributes) (s *SymlinkInode)
Create a symlink inode for the supplied object record.
REQUIRES: IsSymlink(o)
func (*SymlinkInode) Attributes ¶
func (s *SymlinkInode) Attributes( ctx context.Context) (attrs fuseops.InodeAttributes, err error)
func (*SymlinkInode) DecrementLookupCount ¶
func (s *SymlinkInode) DecrementLookupCount(n uint64) (destroy bool)
LOCKS_REQUIRED(s.mu)
func (*SymlinkInode) ID ¶
func (s *SymlinkInode) ID() fuseops.InodeID
func (*SymlinkInode) IncrementLookupCount ¶
func (s *SymlinkInode) IncrementLookupCount()
LOCKS_REQUIRED(s.mu)
func (*SymlinkInode) Lock ¶
func (s *SymlinkInode) Lock()
func (*SymlinkInode) Name ¶
func (s *SymlinkInode) Name() Name
func (*SymlinkInode) SourceGeneration ¶
func (s *SymlinkInode) SourceGeneration() Generation
SourceGeneration returns the object generation from which this inode was branched.
LOCKS_REQUIRED(s)
func (*SymlinkInode) Target ¶
func (s *SymlinkInode) Target() (target string)
Target returns the target of the symlink.
func (*SymlinkInode) Unlock ¶
func (s *SymlinkInode) Unlock()