fusebridge

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package fusebridge maps FUSE operations onto the metadata engine and file I/O layer. It handles filesystem requests, cache invalidation and errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(b *Bridge, mountpoint string, opts *fuse.MountOptions, allowOther bool) (*fuse.Server, error)

Mount starts serving the bridge at mountpoint and returns the running server. The caller unmounts via server.Unmount(). opts may be nil.

allowOther appends the FUSE allow_other option so processes other than the mounting user (uid 0, the daemon) can access the mount. It is REQUIRED whenever non-root workloads use the filesystem — e.g. the CSI subdir-bind-mount model, where pods run as arbitrary uids — because without it the FUSE kernel denies every non-mounter uid with EACCES before default_permissions even evaluates.

Types

type Bridge

type Bridge struct {
	fuse.RawFileSystem // ENOSYS defaults for ops we don't implement
	// contains filtered or unexported fields
}

Bridge implements fuse.RawFileSystem over a metadata engine + data path.

func New

func New(m *meta.Engine, files *fileio.Files, flusher Flusher) *Bridge

New constructs a Bridge. flusher may be nil.

func (*Bridge) ApplyChange

func (b *Bridge) ApplyChange(ino uint64, op uint8, payload []byte)

ApplyChange invalidates the kernel caches affected by a peer's change so the next access on this mount re-reads fresh state from the shared metadata DB. It is best-effort: a not-cached target simply returns ENOENT, which we ignore. ino is the changed inode, op is a meta.Change* code, payload is the raw fs_changelog payload.

func (*Bridge) CopyFileRange

func (b *Bridge) CopyFileRange(cancel <-chan struct{}, in *fuse.CopyFileRangeIn) (uint32, fuse.Status)

CopyFileRange serves copy_file_range(2): it copies a byte range from one file to another. The data path shares the underlying chunks copy-on-write for any chunk-aligned portion (zero data movement, like reflink) and falls back to a read+write copy for misaligned head/tail bytes, so the result is always byte-correct. The kernel may issue this in several calls for a large copy.

func (*Bridge) Create

func (b *Bridge) Create(cancel <-chan struct{}, in *fuse.CreateIn, name string, out *fuse.CreateOut) (status fuse.Status)

func (*Bridge) Flush

func (b *Bridge) Flush(cancel <-chan struct{}, in *fuse.FlushIn) fuse.Status

func (*Bridge) Fsync

func (b *Bridge) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) (status fuse.Status)

func (*Bridge) GetAttr

func (b *Bridge) GetAttr(cancel <-chan struct{}, in *fuse.GetAttrIn, out *fuse.AttrOut) (status fuse.Status)

func (*Bridge) GetLk

func (b *Bridge) GetLk(cancel <-chan struct{}, in *fuse.LkIn, out *fuse.LkOut) fuse.Status

func (*Bridge) GetXAttr

func (b *Bridge) GetXAttr(cancel <-chan struct{}, h *fuse.InHeader, attr string, dest []byte) (uint32, fuse.Status)

func (*Bridge) Init

func (b *Bridge) Init(srv *fuse.Server)

Init captures the server handle (go-fuse calls it once at mount).

func (b *Bridge) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *fuse.EntryOut) fuse.Status

func (*Bridge) ListXAttr

func (b *Bridge) ListXAttr(cancel <-chan struct{}, h *fuse.InHeader, dest []byte) (uint32, fuse.Status)

func (*Bridge) Lookup

func (b *Bridge) Lookup(cancel <-chan struct{}, h *fuse.InHeader, name string, out *fuse.EntryOut) (status fuse.Status)

func (*Bridge) Mkdir

func (b *Bridge) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out *fuse.EntryOut) (status fuse.Status)

func (*Bridge) Mknod

func (b *Bridge) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out *fuse.EntryOut) fuse.Status

func (*Bridge) Open

func (b *Bridge) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status)

func (*Bridge) OpenDir

func (b *Bridge) OpenDir(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) fuse.Status

OpenDir snapshots the directory's ordered entry list (with attributes) into a handle table under a fresh Fh, so ReadDirPlus can page by stable offset even while the directory is concurrently mutated.

func (*Bridge) Read

func (b *Bridge) Read(cancel <-chan struct{}, in *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status)

func (*Bridge) ReadDir

func (b *Bridge) ReadDir(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status

ReadDir pages the OpenDir snapshot without filling attributes (the plain, non-plus variant). Shares the same stable offsets as ReadDirPlus.

func (*Bridge) ReadDirPlus

func (b *Bridge) ReadDirPlus(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
func (b *Bridge) Readlink(cancel <-chan struct{}, h *fuse.InHeader) ([]byte, fuse.Status)

func (*Bridge) Release

func (b *Bridge) Release(cancel <-chan struct{}, in *fuse.ReleaseIn)

Release drops the open handle; the last close of an unlinked file deletes it. If the kernel flagged a flock unlock for this release, drop the flock too.

func (*Bridge) ReleaseDir

func (b *Bridge) ReleaseDir(in *fuse.ReleaseIn)

ReleaseDir frees the directory snapshot allocated by OpenDir.

func (*Bridge) RemoveXAttr

func (b *Bridge) RemoveXAttr(cancel <-chan struct{}, h *fuse.InHeader, attr string) fuse.Status

func (*Bridge) Rename

func (b *Bridge) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName, newName string) fuse.Status

func (*Bridge) Rmdir

func (b *Bridge) Rmdir(cancel <-chan struct{}, h *fuse.InHeader, name string) fuse.Status

func (*Bridge) SetAttr

func (b *Bridge) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status

func (*Bridge) SetDefaultStoreClass

func (b *Bridge) SetDefaultStoreClass(class uint8)

SetDefaultStoreClass sets the compression class applied to a created file whose type is not recognized as a model/tensor. cmd/mlfs wires it from a flag: a model-store mount passes ClassUncompressed (so even unrecognized files stay uncompressed — range-readable + mmap-safe); a mixed-content mount leaves the default ClassDefault so generic data compresses. Call once before serving.

func (*Bridge) SetLk

func (b *Bridge) SetLk(cancel <-chan struct{}, in *fuse.LkIn) fuse.Status

func (*Bridge) SetLkw

func (b *Bridge) SetLkw(cancel <-chan struct{}, in *fuse.LkIn) fuse.Status

SetLkw is the blocking variant. The engine acquires non-blockingly (EAGAIN on conflict), so we implement true blocking in-process: attempt the acquire, and on EAGAIN park on the bridge's notify channel until some lock release wakes us (or the FUSE cancel channel fires → EINTR), then re-attempt. We grab the wait channel BEFORE each attempt so a release that races between the failed acquire and parking still wakes us. This blocks until the lock becomes grantable rather than giving up under sustained contention.

func (*Bridge) SetMetrics

func (b *Bridge) SetMetrics(m *metrics.Registry)

SetMetrics attaches the daemon's instrument registry; the virtual file renders from it. nil disables nothing structurally — the file still resolves and reads empty — but in practice the daemon always sets it.

func (*Bridge) SetXAttr

func (b *Bridge) SetXAttr(cancel <-chan struct{}, in *fuse.SetXAttrIn, attr string, data []byte) fuse.Status

func (*Bridge) StatFs

func (b *Bridge) StatFs(cancel <-chan struct{}, h *fuse.InHeader, out *fuse.StatfsOut) fuse.Status
func (b *Bridge) Symlink(cancel <-chan struct{}, h *fuse.InHeader, target, name string, out *fuse.EntryOut) fuse.Status
func (b *Bridge) Unlink(cancel <-chan struct{}, h *fuse.InHeader, name string) (status fuse.Status)

func (*Bridge) Write

func (b *Bridge) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (uint32, fuse.Status)

type Flusher

type Flusher interface {
	Flush(ctx context.Context) error
}

Flusher lets the bridge push buffered writes to durable backing on flush/fsync (the disk cache implements it). Optional.

Jump to

Keyboard shortcuts

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