mountlock

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: 7 Imported by: 0

Documentation

Overview

Package mountlock provides a single-node "is a daemon live?" guard built on a PID lock file in the data directory. The mlfs daemon writes the file on mount and removes it on clean shutdown; offline tools (mlfs-admin fsck/gc) refuse to run while a matching live daemon holds it, because those tools assume a quiesced filesystem — run against a LIVE mount they race the daemon and can reap a legitimately open-but-unlinked inode (sustained only in the daemon's memory), losing data.

Single-node scope: there is exactly one mount per data-dir, so one PID file is sufficient. Multi-node coordination is a later phase.

Index

Constants

View Source
const FileName = "mlfs.lock"

FileName is the lock file's name, placed at the top level of the data directory. The "mlfs." prefix and the data-dir top level keep it clear of casstore's own contents under data/.

Variables

This section is empty.

Functions

func CheckQuiesced

func CheckQuiesced(dataDir string, force bool, warn func(string)) error

CheckQuiesced verifies no live daemon holds the data-dir lock and returns an error if one does. Behavior:

  • No lock file: quiesced, returns nil (warn is not called).
  • Lock file present, PID alive: returns *LiveError (refuse).
  • Lock file present but unparseable, or PID dead: stale; warn is called with a human-readable reason and nil is returned (the caller proceeds and may rewrite/remove the file).

warn may be nil. force, when true, downgrades a live holder to a warning and returns nil — for operators who know the daemon is not actually running.

func Path

func Path(dataDir string) string

Path returns the lock file path for a given data directory.

func Remove

func Remove(dataDir string) error

Remove deletes the lock file. The daemon calls this on clean shutdown. A missing file is not an error (it may have already been removed or never written).

func Write

func Write(dataDir string) error

Write records the current process's PID in the data-dir lock file, creating the directory if needed. The daemon calls this once after a successful mount.

Types

type LiveError

type LiveError struct {
	Path string
	PID  int
}

LiveError describes a refusal: a live daemon holds the data-dir lock.

func (*LiveError) Error

func (e *LiveError) Error() string

Jump to

Keyboard shortcuts

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