rcserver

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rcserver binds the RC session server (rdma/librcserver.a) that implements the hipobj-rc-v2 two-phase transfer protocol.

The gateway owns routing, authentication, and the object backend; the C side owns the session state machine, QP/CQ/MR lifetimes, the data phase, and session reaping. Every cgo call is synchronous from the request goroutine.

Index

Constants

View Source
const (
	StatusOK           = C.RC_OK
	StatusErrArg       = C.RC_E_ARG
	StatusErrState     = C.RC_E_STATE
	StatusErrSession   = C.RC_E_SESSION
	StatusErrStale     = C.RC_E_STALE
	StatusErrNoSession = C.RC_E_NO_SESSION
	StatusErrDouble    = C.RC_E_DOUBLE
	StatusErrWire      = C.RC_E_WIRE
	StatusErrShort     = C.RC_E_SHORT
	StatusErrTrunc     = C.RC_E_TRUNC
	StatusErrLimit     = C.RC_E_LIMIT
	StatusErrInternal  = C.RC_E_INTERNAL
)

Status codes mirrored from rc_server_abi.h.

View Source
const (
	ReadyOK         = C.RC_READY_OK
	ReadyBusy       = C.RC_READY_BUSY
	ReadyTimeout    = C.RC_READY_TIMEOUT
	ReadyVerifyFail = C.RC_READY_VERIFY_FAIL
	ReadyWireFail   = C.RC_READY_WIRE_FAIL
)

Ready outcome detail codes (rc_ready_resp.outcome).

Variables

View Source
var (
	ErrArg       = errors.New("rcserver: invalid argument")
	ErrState     = errors.New("rcserver: wrong session state")
	ErrSession   = errors.New("rcserver: owner mismatch")
	ErrStale     = errors.New("rcserver: stale handle or session")
	ErrNoSession = errors.New("rcserver: no such session")
	ErrDouble    = errors.New("rcserver: duplicate borrow")
	ErrWire      = errors.New("rcserver: verbs transfer failure")
	ErrShort     = errors.New("rcserver: short transfer")
	ErrTrunc     = errors.New("rcserver: value too long")
	ErrLimit     = errors.New("rcserver: resource limit")
	ErrInternal  = errors.New("rcserver: internal error")
)

Sentinel errors matched by errors.Is for each ABI status.

Functions

This section is empty.

Types

type DeviceOpts

type DeviceOpts struct {
	// GidHint selects the device whose GID starts with this dotted
	// prefix; empty picks the first verbs device.
	GidHint string
	Port    uint8
	GidIdx  int
	// Global limits.
	MaxSessions         uint32
	MaxStagingBytes     uint64
	MaxQPs              uint32
	MaxUserSessions     uint32
	MaxUserStagingBytes uint64
	MaxUserQPs          uint32
	// Timeouts in milliseconds.
	TPrepMs uint64
	TExecMs uint64
	// Concurrency slots (0 picks the C-side default 64/32).
	MaxReadySlots uint32
	MaxStageSlots uint32
}

DeviceOpts configures device selection and resource limits.

type Handle

type Handle struct {
	Epoch uint64
	Nonce uint64
}

Handle is an opaque consume-once lease identifier.

type PrepareRequest

type PrepareRequest struct {
	Principal   PrincipalID
	Op          uint8 // 0 = GET, 1 = PUT
	Target      string
	Offset      uint64
	Size        uint64
	ClientPsn   uint32
	Cookie      uint32
	ClientToken string // 88-hex, optional
}

PrepareRequest carries the PREPARE wire parameters.

type PrepareResponse

type PrepareResponse struct {
	SessionID   string
	ServerQpn   uint32
	ServerPsn   uint32
	StagingAddr uint64
	StagingRkey uint32
	ReplyToken  string
}

PrepareResponse is the PREPARE reply.

type PrincipalID

type PrincipalID [32]byte

PrincipalID is the SHA-256 digest identifying the requester.

type PutView

type PutView struct {
	Buf    []byte
	Len    int
	Handle Handle
}

PutView is a borrowed PUT data view. The caller must return it with FinishPut exactly once.

type RCSvc

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

RCSvc owns the RC session server. Handlers must call TryEnter before any session call and Leave when the request completes (defer). Close stops admissions, cancels the service context (bound to every handler's backend I/O so in-flight requests unblock), waits for every entered call to leave, then tears the server down; it is idempotent and safe from any goroutine.

func Init

func Init(opts DeviceOpts) (*RCSvc, error)

Init opens the verbs device and returns a service.

func (*RCSvc) BorrowStaging

func (s *RCSvc) BorrowStaging(sessionID string) (*StagingLease, error)

BorrowStaging borrows the GET staging buffer.

func (*RCSvc) Cancel

func (s *RCSvc) Cancel(sessionID string, who PrincipalID) error

Cancel cancels a session (owner-checked).

func (*RCSvc) Close

func (s *RCSvc) Close()

Close shuts the service down: it stops admissions, marks every session for reaping, waits for all in-flight handlers to finish, and destroys the server. Safe to call multiple times.

Convergence: every blocking call an RC handler makes after TryEnter is bounded - GET staging, PUT commit, and the bucket-ACL lookup run under the service context and unblock on the cancel below; and the authorization helpers (VerifyAccess, CheckObjectAccess) consume the fiber request context, which the gateway shuts down before RunVersityGW returns - and Close runs after RunVersityGW returns in every current caller - so those calls are cancelled by the fiber shutdown that precedes Close.

func (*RCSvc) Context

func (s *RCSvc) Context() context.Context

Context returns the service-lifetime context. Handlers bind their backend calls to it so Close unblocks in-flight I/O.

func (*RCSvc) FinishFinal

func (s *RCSvc) FinishFinal(sessionID string) error

FinishFinal marks the FINAL response committed.

func (*RCSvc) FinishPrepare

func (s *RCSvc) FinishPrepare(sessionID string, committed bool) error

FinishPrepare commits or aborts a PREPARE.

func (*RCSvc) FinishPut

func (s *RCSvc) FinishPut(view PutView, committed bool,
	etag, versionID string) error

FinishPut returns a PUT data view with the commit outcome.

func (*RCSvc) FinishStaging

func (s *RCSvc) FinishStaging(lease StagingLease, ok bool,
	written int, etag, versionID string) error

FinishStaging returns a staging lease (GET).

func (*RCSvc) GetPutData

func (s *RCSvc) GetPutData(sessionID string) (*PutView, error)

GetPutData borrows the PUT data view.

func (*RCSvc) Leave

func (s *RCSvc) Leave()

Leave releases a TryEnter admission.

func (*RCSvc) Prepare

func (s *RCSvc) Prepare(req PrepareRequest) (*PrepareResponse, error)

Prepare creates a session (PREPARE).

func (*RCSvc) ReadyTransfer

func (s *RCSvc) ReadyTransfer(req ReadyRequest) (*ReadyResponse, error)

ReadyTransfer runs the data phase (READY).

func (*RCSvc) SessionInfo

func (s *RCSvc) SessionInfo(sessionID string, who PrincipalID) (*SessionInfo, error)

SessionInfo looks up a session's op and target (READY auth).

func (*RCSvc) TryEnter

func (s *RCSvc) TryEnter() bool

TryEnter admits a request into the service. It returns false once Close has begun; the caller must not touch the service then.

type ReadyRequest

type ReadyRequest struct {
	Principal    PrincipalID
	SessionID    string
	Cookie       uint32
	ClientQpn    uint32
	ClientMrAddr uint64
	ClientMrRkey uint32
}

ReadyRequest carries the READY wire parameters.

type ReadyResponse

type ReadyResponse struct {
	BytesTransferred uint64
	CookieEcho       uint32
	// Outcome mirrors the RC_READY_* enum: returned atomically
	// with the transfer result so a concurrent READY cannot
	// rewrite it between the transfer and the read.
	Outcome   int
	Etag      string
	VersionID string
}

ReadyResponse is the READY reply.

type SessionInfo

type SessionInfo struct {
	Op     uint8 // 0 = GET, 1 = PUT
	Target string
}

SessionInfo describes a session for READY re-authorization.

type StagingLease

type StagingLease struct {
	Buf      []byte
	Capacity int
	Handle   Handle
}

StagingLease is a borrowed GET staging buffer. The caller must return it with FinishStaging exactly once.

Jump to

Keyboard shortcuts

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