nfsv4

package
v0.0.0-...-ca77ec1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricsProgram

func NewMetricsProgram(base nfsv4.Nfs4Program) nfsv4.Nfs4Program

NewMetricsProgram creates a decorator for nfsv4.Nfs4Program that exposes Prometheus metrics for all compound operations called.

Right now it only provides counters for the number of operations called. Timing of operation is not exposed, as it can only be computed at the procedure level, which isn't meaningful in practice.

func NewMinorVersionFallbackProgram

func NewMinorVersionFallbackProgram(backends []nfsv4.Nfs4Program) nfsv4.Nfs4Program

NewMinorVersionFallbackProgram creates an NFSv4 server that forwards requests to a series of backends, until one of the listed servers accepts the minor version that is embedded in the request.

This decorator can be used to launch an NFSv4 server that is capable of processing both NFSv4.0 and NFSv4.1 requests.

func NewNFS40Program

func NewNFS40Program(rootDirectory virtual.Directory, openedFilesPool *OpenedFilesPool, randomNumberGenerator random.SingleThreadedGenerator, rebootVerifier nfsv4.Verifier4, stateIDOtherPrefix [stateIDOtherPrefixLength]byte, clock clock.Clock, enforcedLeaseTime, announcedLeaseTime time.Duration) nfsv4.Nfs4Program

NewNFS40Program creates an nfsv4.Nfs4Program that forwards all operations to a virtual file system. It implements most of the features of NFSv4.0.

func NewNFS41Program

func NewNFS41Program(rootDirectory virtual.Directory, openedFilesPool *OpenedFilesPool, serverOwner nfsv4.ServerOwner4, serverScope []byte, maxForeChanAttrs *nfsv4.ChannelAttrs4, randomNumberGenerator random.SingleThreadedGenerator, rebootVerifier nfsv4.Verifier4, clock clock.Clock, enforcedLeaseTime, announcedLeaseTime time.Duration) nfsv4.Nfs4Program

NewNFS41Program creates an nfsv4.Nfs4Program that forwards all operations to a virtual file system. It implements most of the features of NFSv4.1.

func NewSystemAuthenticator

func NewSystemAuthenticator(metadataExtractor *jmespath.JMESPath, maximumCacheSize int, evictionSet eviction.Set[SystemAuthenticatorCacheKey]) rpcserver.Authenticator

NewSystemAuthenticator is an RPCv2 Authenticator that requires that requests provide credentials of flavor AUTH_SYS, as described in RFC 5531, appendix A. The body of the credentials are converted to an AuthenticationMetadata object using a JMESPath expression. The resulting metadata is attached to the Context.

Types

type OpenedFile

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

OpenedFile contains the state that needs to be tracked for files that are opened at least once.

func (*OpenedFile) Close

func (of *OpenedFile) Close()

Close a file. If the reference count of the file drops to zero, all associated state is removed.

func (*OpenedFile) GetHandle

func (of *OpenedFile) GetHandle() nfsv4.NfsFh4

GetHandle returns the file handle that was originally provided when OpenedFilesPool.Open() was called.

func (*OpenedFile) GetLeaf

func (of *OpenedFile) GetLeaf() virtual.Leaf

GetLeaf returns the virtual file system node that was originally provided when OpenedFilesPool.Open() was called.

func (*OpenedFile) Lock

func (of *OpenedFile) Lock(lockOwner *nfsv4.LockOwner4, offset nfsv4.Offset4, length nfsv4.Length4, lockType nfsv4.NfsLockType4) (int, nfsv4.Lock4res)

Lock a byte range in the file. This method can be used to implement the LOCK operation.

Note that the provided lock-owner is stored by reference. Exactly the same memory address must to be provided to TestLock(), Unlock() and UnlockAll() to make these functions work as expected.

func (*OpenedFile) Unlock

func (of *OpenedFile) Unlock(lockOwner *nfsv4.LockOwner4, offset nfsv4.Offset4, length nfsv4.Length4) (int, nfsv4.Nfsstat4)

Unlock a byte range in the file. This method can be used to implement the LOCKU operation.

func (*OpenedFile) UnlockAll

func (of *OpenedFile) UnlockAll(lockOwner *nfsv4.LockOwner4) int

UnlockAll releases all byte-range locks in the file belonging to a given lock-owner. This method can be used in circumstances where locks need to be forcefully removed, such as the CLOSE operation, or when state of inactive clients is purged.

type OpenedFilesPool

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

OpenedFilesPool holds the state of files that are opened by one or more clients through an NFSv4 server. The purpose of this type is twofold:

  • To ensure that files that are opened are always resolvable by handle. This is needed to ensure that PUTFH for such files succeeds, even if they are no longer present in the file system. If this were not the case, it would be impossible to call CLOSE on them.

  • To keep track of any byte-range locks that are currently applied against opened files.

func NewOpenedFilesPool

func NewOpenedFilesPool(handleResolver virtual.HandleResolver) *OpenedFilesPool

NewOpenedFilesPool creates an OpenedFilesPool that is empty.

func (*OpenedFilesPool) Open

func (ofp *OpenedFilesPool) Open(handle nfsv4.NfsFh4, leaf virtual.Leaf) *OpenedFile

Open is invoked as part of the OPEN operation to either create new opened file state, or return a reference to existing opened file state.

func (*OpenedFilesPool) Resolve

Resolve the virtual file system node corresponding to a given file handle.

func (*OpenedFilesPool) TestLock

func (ofp *OpenedFilesPool) TestLock(handle nfsv4.NfsFh4, lockOwner *nfsv4.LockOwner4, offset nfsv4.Offset4, length nfsv4.Length4, lockType nfsv4.NfsLockType4) nfsv4.Lockt4res

TestLock returns whether a new byte-range lock can be acquired without conflicting with any of the locks that are already present. It can be used to implement the LOCKT operation.

type SystemAuthenticatorCacheKey

type SystemAuthenticatorCacheKey [sha256.Size]byte

SystemAuthenticatorCacheKey is the key type that's used by the system authenticato's eviction set.

Jump to

Keyboard shortcuts

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