svfs

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2016 License: BSD-3-Clause Imports: 18 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// SkipCreate is a flag indicating that new files should not be explicitely
	// created. File creation will only take place upon the first write(2) call.
	SkipCreate = 1 << 0
	// SkipMkdir is a flag indicating that directories should not be explicitely
	// created. Directory creation will only implicitely happen upon file creation
	// within this directory or one of its subdirectories.
	SkipMkdir = 1 << 1
	// SkipRmdir is a flag indicating that directory removal should not check
	// wether a directory is empty before removing it.
	SkipRmdir = 1 << 2
	// SkipOpenRead is a flag indicating that open(2) should not emit any read request.
	SkipOpenRead = 1 << 3
)
View Source
const (
	// HubicEndpoint is the HubiC API URL
	HubicEndpoint = "https://api.hubic.com"
)
View Source
const Version = "0.9.1"

Version is the current SVFS version

Variables

View Source
var (
	// CacheTimeout represents cache entries timeout.
	CacheTimeout time.Duration
	// CacheMaxEntries represents the cache size.
	CacheMaxEntries int64
	// CacheMaxAccess represents cache entries max access count.
	CacheMaxAccess int64
)
View Source
var (
	// SwiftConnection represents a connection to a swift provider.
	// It should be ready for authentication before initializing svfs.
	SwiftConnection = new(swift.Connection)
	// TargetContainer is an existing container ready to be served.
	TargetContainer string
	// StoragePolicy represents a storage policy configured by the
	// storage provider.
	StoragePolicy string
	// Attr represents base attributes fetching mode activation.
	Attr bool
	// Xattr represents extended attributes fetching mode activation.
	Xattr bool
	// HubicTimes represents the usage of hubiC synchronization clients
	// meta headers to read and store file times.
	HubicTimes bool
	// SegmentSize is the size of a segment in bytes.
	SegmentSize uint64
	// AllowRoot represents FUSE allow_root option.
	AllowRoot bool
	// AllowOther represents FUSE allow_other option.
	AllowOther bool
	// DefaultGID is the gid mapped to svfs files.
	DefaultGID uint64
	// DefaultUID is the uid mapped to svfs files.
	DefaultUID uint64
	// DefaultMode is the mode mapped to svfs files.
	DefaultMode uint64
	// DefaultPermissions are permissions mapped to svfs files.
	DefaultPermissions bool
	// BlockSize is the filesystem block size in bytes.
	BlockSize uint
	// ReadAheadSize is the filesystem readahead size in bytes.
	ReadAheadSize uint
	// ReadOnly represents the filesystem readonly access mode activation.
	ReadOnly bool
	// TransferMode represents a certain mode of operation defined by a combination
	// of flags. Each flag enables an optimization that can be used by storage
	// synchronization processes in order to reduce network access.
	TransferMode int
	// MountTime represents at what time the filesystem was mounted.
	MountTime time.Time
)
View Source
var (
	// HubicRefreshToken is the OAUTH2 refresh token.
	HubicRefreshToken string
	// HubicAuthorization is the basicAuth header used
	// within requests to Hubic OAUTH2 API.
	HubicAuthorization string
)
View Source
var (
	// ListerConcurrency represents how many objects can
	// be fetched concurrently while listing directory content.
	ListerConcurrency uint64
)

Functions

This section is empty.

Types

type Cache added in v0.2.6

type Cache struct {
	// contains filtered or unexported fields
}

Cache holds a map of cache entries. Its size can be configured as well as cache entries access limit and expiration time.

func NewCache added in v0.2.6

func NewCache() *Cache

NewCache creates a new cache

func (*Cache) AddAll added in v0.3.0

func (c *Cache) AddAll(container, path string, node Node, nodes map[string]Node)

AddAll creates a new cache entry with the key container:path and a map of nodes as a value. Node represents the parent node type. If the cache entry count limit is reached, it will be marked as temporary thus evicted after one read.

func (*Cache) Delete added in v0.2.6

func (c *Cache) Delete(container, path, name string)

Delete removes a node from cache.

func (*Cache) DeleteAll added in v0.3.0

func (c *Cache) DeleteAll(container, path string)

DeleteAll removes all nodes for the cache key container:path.

func (*Cache) Get added in v0.2.6

func (c *Cache) Get(container, path, name string) Node

Get retrieves a specific node from the cache. It returns nil if the cache key container:path is missing.

func (*Cache) GetAll added in v0.3.0

func (c *Cache) GetAll(container, path string) (Node, map[string]Node)

GetAll retrieves all nodes for the cache key container:path. It returns the parent node and its children nodes. If the cache entry is not found or expired or access count exceeds the limit, both values will be nil.

func (*Cache) Peek added in v0.3.0

func (c *Cache) Peek(container, path string) (Node, bool)

Peek checks if a valid cache entry belongs to container:path key without changing cache access count for this entry. Returns the parent node with the result.

func (*Cache) Set added in v0.2.6

func (c *Cache) Set(container, path, name string, node Node)

Set adds a specific node in cache, given a previous peek operation succeeded.

type CacheValue added in v0.3.0

type CacheValue struct {
	// contains filtered or unexported fields
}

CacheValue is the representation of a cache entry. It tracks expiration date, access count and holds a parent node with its children. It can be set as temporary, meaning that it will be stored within the cache but evicted on first access.

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

Directory represents a standard directory entry.

func (*Directory) Attr

func (d *Directory) Attr(ctx context.Context, a *fuse.Attr) error

Attr fills file attributes of a directory within the current context.

func (*Directory) Create

func (d *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)

Create makes a new object node represented by a file. It returns an object node and an opened file handle.

func (*Directory) Export

func (d *Directory) Export() fuse.Dirent

Export gives a direntry for the current directory node.

func (d *Directory) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (node fs.Node, err error)

Link creates a hard link between two nodes.

func (*Directory) Lookup

func (d *Directory) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error)

Lookup gets a children node if its name matches the requested direntry name. If the cache is empty for the current directory, it will fill it and try to match the requested direnty after this operation. It returns ENOENT if not found.

func (*Directory) Mkdir added in v0.2.0

func (d *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)

Mkdir creates a new directory node within the current directory. It is represented by an empty object ending with a slash in the Swift container.

func (*Directory) Name

func (d *Directory) Name() string

Name gets the direntry name

func (*Directory) ReadDirAll

func (d *Directory) ReadDirAll(ctx context.Context) (direntries []fuse.Dirent, err error)

ReadDirAll reads the content of a directory and returns a list of children nodes as direntries, using/filling the cache of nodes.

func (*Directory) Remove

func (d *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error

Remove deletes a direntry and relevant node. It is not supported on container nodes. It handles standard and segmented object deletion.

func (*Directory) Rename

func (d *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error

Rename moves a node from its current directory to a new directory and updates the cache.

func (*Directory) Setattr added in v0.5.2

func (d *Directory) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error

Setattr changes file attributes on the current object. Not supported on directories.

func (d *Directory) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fs.Node, error)

Symlink creates a new symbolic link to the specified target in the current directory.

type HubicAuth added in v0.5.0

type HubicAuth struct {
	// contains filtered or unexported fields
}

HubicAuth is a swift-compliant authenticatior for hubic.

func (*HubicAuth) CdnUrl added in v0.5.0

func (h *HubicAuth) CdnUrl() string

CdnUrl retrieves the CDN URL from the authentication response.

func (*HubicAuth) Request added in v0.5.0

func (h *HubicAuth) Request(*swift.Connection) (*http.Request, error)

Request constructs the authentication request.

func (*HubicAuth) Response added in v0.5.0

func (h *HubicAuth) Response(*http.Response) error

Response reads the authentication response.

func (*HubicAuth) StorageUrl added in v0.5.0

func (h *HubicAuth) StorageUrl(Internal bool) string

StorageUrl retrieves the swift's storage URL from the authentication response.

func (*HubicAuth) Token added in v0.5.0

func (h *HubicAuth) Token() string

Token retrieves keystone token from the authentication response.

type Lister added in v0.5.2

type Lister struct {
	// contains filtered or unexported fields
}

Lister is a concurrent processor of direntries. Its job is to get extra information about files.

func (*Lister) AddTask added in v0.5.2

func (dl *Lister) AddTask(n Node, rc chan Node)

AddTask asynchronously adds a new task to be processed. It returns immediately with no guarantee that the task has been added to the channel nor retrieved by a worker.

func (*Lister) Start added in v0.5.2

func (dl *Lister) Start()

Start spawns workers waiting for tasks. Once a task comes in the task channel, one worker will process it by opening a connection to swift and asking information about the current object.

type ListerTask added in v0.5.2

type ListerTask struct {
	// contains filtered or unexported fields
}

ListerTask represents a manifest ready to be processed by the Lister. Every task must provide a manifest object and a result channel to which retrieved information will be sent.

type Node

type Node interface {
	Name() string
	Export() fuse.Dirent
}

Node is the generic interface of an SVFS node.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object is a node representing a swift object. It belongs to a container and segmented objects are bound to a container of segments.

func (*Object) Attr

func (o *Object) Attr(ctx context.Context, a *fuse.Attr) (err error)

Attr fills the file attributes for an object node.

func (*Object) Export

func (o *Object) Export() fuse.Dirent

Export converts this object node as a direntry.

func (*Object) Fsync added in v0.9.0

func (o *Object) Fsync(ctx context.Context, req *fuse.FsyncRequest) error

Fsync synchronizes a file's in-core state with the storage device. This is a no-op since we are in a network, fully synchronous, filesystem.

func (*Object) Getxattr added in v0.9.0

func (o *Object) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error

Getxattr retrieves extended attributes of an object node.

func (*Object) Listxattr added in v0.9.0

func (o *Object) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error

Listxattr lists extended attributes associated with this object node.

func (*Object) Name

func (o *Object) Name() string

Name gets the name of the underlying swift object.

func (*Object) Open

func (o *Object) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)

Open returns the file handle associated with this object node.

func (*Object) Removexattr added in v0.9.0

func (o *Object) Removexattr(ctx context.Context, req *fuse.RemovexattrRequest) error

Removexattr removes an extended attribute on this object node.

func (*Object) Setattr added in v0.5.2

func (o *Object) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error

Setattr changes file attributes on the current node.

func (*Object) Setxattr added in v0.9.0

func (o *Object) Setxattr(ctx context.Context, req *fuse.SetxattrRequest) error

Setxattr changes an extended attribute on the current node.

type ObjectHandle

type ObjectHandle struct {
	// contains filtered or unexported fields
}

ObjectHandle represents an open object handle, similarly to file handles.

func (*ObjectHandle) Read

func (fh *ObjectHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) (err error)

Read gets a swift object data for a request within the current context. The request size is always honored. We open the file on the first write.

func (*ObjectHandle) Release

func (fh *ObjectHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release frees the file handle, closing all readers/writers in use.

func (*ObjectHandle) Write

func (fh *ObjectHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) (err error)

Write pushes data to a swift object. If we detect that we are writing more data than the configured segment size, then the first object we were writing to is moved to the segment container and named accordingly to DLO conventions. Remaining data will be split into segments sequentially until file handle release is called. If we are overwriting an object we handle segment deletion, and object creation.

type Root

type Root struct {
	*Directory
}

Root is a fake root node used to hold a list of container nodes.

func (*Root) Create

func (r *Root) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)

Create is not supported on a root node since we can only create directories (i.e. containers).

func (*Root) Lookup added in v0.2.5

func (r *Root) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error)

Lookup gets a container node if its name matches the request name within the current context.

func (*Root) Mkdir added in v0.2.0

func (r *Root) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)

Mkdir creates a new container.

func (*Root) ReadDirAll

func (r *Root) ReadDirAll(ctx context.Context) (direntries []fuse.Dirent, err error)

ReadDirAll retrieves all containers within the current Openstack tenant, as direntries. Segment containers are not shown and created if missing.

func (*Root) Remove

func (r *Root) Remove(ctx context.Context, req *fuse.RemoveRequest) error

Remove deletes a container.

func (*Root) Rename

func (r *Root) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error

Rename is not supported on a root node.

type SVFS

type SVFS struct{}

SVFS implements the Swift Virtual File System.

func (*SVFS) Init

func (s *SVFS) Init() (err error)

Init sets up the filesystem. It sets configuration settings, starts mandatory services and make sure authentication in Swift has succeeded.

func (*SVFS) Root

func (s *SVFS) Root() (fs.Node, error)

Root gets the root node of the filesystem. It can either be a fake root node filled with all the containers found for the given Openstack tenant or a container node if a container name have been specified in mount options.

func (*SVFS) Statfs added in v0.6.1

func (s *SVFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error

Statfs gets the filesystem meta information. It's notably used to report filesystem metrics to the host. If the target account is using quota it will be reported as the device size. If no quota was found the device size will be equal to the underlying type maximum value.

type SimpleCache added in v0.5.2

type SimpleCache struct {
	// contains filtered or unexported fields
}

SimpleCache is a simplistic caching implementation only relying on a hashmap with basic functions.

func NewSimpleCache added in v0.5.2

func NewSimpleCache() *SimpleCache

NewSimpleCache creates a new simplistic cache.

func (*SimpleCache) Add added in v0.5.2

func (c *SimpleCache) Add(container, path string, node Node)

Add pushes a new cache entry.

func (*SimpleCache) Exist added in v0.5.2

func (c *SimpleCache) Exist(container, path string) bool

Exist checks whether a cache key exist or not.

func (*SimpleCache) Get added in v0.5.2

func (c *SimpleCache) Get(container, path string) Node

Get retrieves a cache entry for the given key.

func (*SimpleCache) Remove added in v0.5.2

func (c *SimpleCache) Remove(container, path string)

Remove pops the cache entry at this key.

type Symlink struct {
	// contains filtered or unexported fields
}

Symlink represents a symbolic link to an object within a container.

func (*Symlink) Attr added in v0.6.2

func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error)

Attr fills the file attributes for a symlink node.

func (*Symlink) Export added in v0.6.2

func (s *Symlink) Export() fuse.Dirent

Export converts this symlink node to a direntry.

func (*Symlink) Name added in v0.6.2

func (s *Symlink) Name() string

Name gets the name of the underlying swift object.

func (s *Symlink) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error)

Readlink gets the symlink target path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL