Documentation
¶
Index ¶
- Constants
- Variables
- type CompletionQueue
- type CompletionQueueRing
- type CompletionQueueRing16
- type CompletionQueueRing32
- type FileRegister
- type IOURing
- func (iour *IOURing) Close() error
- func (iour *IOURing) FileRegister() FileRegister
- func (iour *IOURing) GetFixedFileIndex(file *os.File) (int, bool)
- func (iour *IOURing) IsClosed() (closed bool)
- func (iour *IOURing) Pread(file *os.File, b []byte, offset uint64, ch chan<- Result) (Request, error)
- func (iour *IOURing) Pwrite(file *os.File, b []byte, offset uint64, ch chan<- Result) (Request, error)
- func (iour *IOURing) Read(file *os.File, b []byte, ch chan<- Result) (Request, error)
- func (iour *IOURing) RegisterBuffers(bs [][]byte) error
- func (iour *IOURing) RegisterFile(file *os.File) error
- func (iour *IOURing) RegisterFiles(files []*os.File) error
- func (iour *IOURing) Size() int
- func (iour *IOURing) SubmitHardLinkRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
- func (iour *IOURing) SubmitLinkRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
- func (iour *IOURing) SubmitRequest(request PrepRequest, ch chan<- Result) (Request, error)
- func (iour *IOURing) SubmitRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
- func (iour *IOURing) UnRegisterBuffers() error
- func (iour *IOURing) UnregisterFile(file *os.File) error
- func (iour *IOURing) UnregisterFiles(files []*os.File) error
- func (iour *IOURing) Write(file *os.File, b []byte, ch chan<- Result) (Request, error)
- type IOURingOption
- func WithAsync() IOURingOption
- func WithAttachWQ(iour *IOURing) IOURingOption
- func WithCQE32() IOURingOption
- func WithCQSize(size uint32) IOURingOption
- func WithDisableRing() IOURingOption
- func WithDrain() IOURingOption
- func WithParams(params *iouring_syscall.IOURingParams) IOURingOption
- func WithSQE128() IOURingOption
- func WithSQPoll() IOURingOption
- func WithSQPollThreadCPU(cpu uint32) IOURingOption
- func WithSQPollThreadIdle(idle time.Duration) IOURingOption
- type PrepRequest
- func Accept(sockfd int) PrepRequest
- func Accept4(sockfd int, flags int) PrepRequest
- func Close(fd int) PrepRequest
- func Connect(sockfd int, sa syscall.Sockaddr) (PrepRequest, error)
- func CountCompletionEvent(n uint64) PrepRequest
- func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) PrepRequest
- func Fallocate(fd int, mode uint32, off int64, length int64) PrepRequest
- func Fdatasync(fd int) PrepRequest
- func Fsync(fd int) PrepRequest
- func Linkat(targetDirFd int, targetPath string, linkDirFd int, linkPath string, flags int) (PrepRequest, error)
- func Madvise(b []byte, advice int) PrepRequest
- func Mkdirat(dirFd int, path string, mode uint32) (PrepRequest, error)
- func Nop() PrepRequest
- func Openat(dirfd int, path string, flags uint32, mode uint32) (PrepRequest, error)
- func Openat2(dirfd int, path string, how *unix.OpenHow) (PrepRequest, error)
- func Pread(fd int, b []byte, offset uint64) PrepRequest
- func Preadv(fd int, bs [][]byte, offset uint64) PrepRequest
- func Pwrite(fd int, b []byte, offset uint64) PrepRequest
- func Pwritev(fd int, bs [][]byte, offset int64) PrepRequest
- func Read(fd int, b []byte) PrepRequest
- func Readv(fd int, bs [][]byte) PrepRequest
- func Recv(sockfd int, b []byte, flags int) PrepRequest
- func Recvmsg(sockfd int, p, oob []byte, to syscall.Sockaddr, flags int) (PrepRequest, error)
- func RemoveTimeout(id uint64) PrepRequest
- func Renameat(oldDirFd int, oldPath string, newDirFd int, newPath string) (PrepRequest, error)
- func Renameat2(oldDirFd int, oldPath string, newDirFd int, newPath string, flags int) (PrepRequest, error)
- func Send(sockfd int, b []byte, flags int) PrepRequest
- func Sendmsg(sockfd int, p, oob []byte, to syscall.Sockaddr, flags int) (PrepRequest, error)
- func Statx(dirfd int, path string, flags uint32, mask int, stat *unix.Statx_t) (PrepRequest, error)
- func Symlinkat(target string, newDirFd int, linkPath string) (PrepRequest, error)
- func Timeout(t time.Duration) PrepRequest
- func TimeoutWithTime(t time.Time) (PrepRequest, error)
- func Unlinkat(fd int, path string, flags int32) (PrepRequest, error)
- func Write(fd int, b []byte) PrepRequest
- func Writev(fd int, bs [][]byte) PrepRequest
- type Request
- type RequestCallback
- type RequestSet
- type Result
- type ResultResolver
- type SubmissionQueue
- type SubmissionQueueRing
- type SubmissionQueueRing128
- type SubmissionQueueRing64
- type UserData
- func (data *UserData) Hold(vars ...interface{})
- func (data *UserData) SetRequestBuffer(b0, b1 []byte)
- func (data *UserData) SetRequestBuffers(bs [][]byte)
- func (data *UserData) SetRequestCallback(callback RequestCallback)
- func (data *UserData) SetRequestInfo(info interface{})
- func (data *UserData) SetResultResolver(resolver ResultResolver)
Constants ¶
const ( OpNop uint8 = iota OpReadv OpWritev OpFsync OpReadFixed OpWriteFixed OpPollAdd OpPollRemove OpSyncFileRange OpSendmsg OpRecvmsg OpTimeout OpTimeoutRemove OpAccept OpAsyncCancel OpLinkTimeout OpConnect OpFallocate OpOpenat OpClose OpFilesUpdate OpStatx OpRead OpWrite OpFadvise OpMadvise OpSend OpRecv OpOpenat2 OpEpollCtl OpSplice OpProvideBuffers OpRemoveBuffers OpTee OpShutdown OpRenameat OpUnlinkat OpMkdirat OpSymlinkat OpLinkat )
iouring operations
const ( RequestCanceledSuccessfully = 0 RequestMaybeCanceled = 1 )
cancel operation return value
const ( TimeoutExpiration = 0 CountCompletion = 1 )
timeout operation return value
Variables ¶
var ( ErrIOURingClosed = errors.New("iouring closed") ErrRequestCanceled = errors.New("request is canceled") ErrRequestNotFound = errors.New("request is not found") ErrRequestCompleted = errors.New("request has already been completed") ErrRequestNotCompleted = errors.New("request is not completed") ErrNoRequestCallback = errors.New("no request callback") ErrUnregisteredFile = errors.New("file is unregistered") )
Functions ¶
This section is empty.
Types ¶
type CompletionQueue ¶
type CompletionQueue struct {
// contains filtered or unexported fields
}
type CompletionQueueRing ¶
type CompletionQueueRing interface {
// contains filtered or unexported methods
}
type CompletionQueueRing16 ¶
type CompletionQueueRing16 struct {
// contains filtered or unexported fields
}
type CompletionQueueRing32 ¶
type CompletionQueueRing32 struct {
// contains filtered or unexported fields
}
type FileRegister ¶
type IOURing ¶
IOURing contains iouring_syscall submission and completion queue. It's safe for concurrent use by multiple goroutines.
func New ¶
func New(entries uint, opts ...IOURingOption) (*IOURing, error)
New return a IOURing instance by IOURingOptions
func (*IOURing) FileRegister ¶
func (iour *IOURing) FileRegister() FileRegister
func (*IOURing) GetFixedFileIndex ¶
func (*IOURing) RegisterBuffers ¶
func (*IOURing) SubmitHardLinkRequests ¶
func (iour *IOURing) SubmitHardLinkRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
func (*IOURing) SubmitLinkRequests ¶
func (iour *IOURing) SubmitLinkRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
func (*IOURing) SubmitRequest ¶
func (iour *IOURing) SubmitRequest(request PrepRequest, ch chan<- Result) (Request, error)
SubmitRequest by Request function and io result is notified via channel return request id, can be used to cancel a request
func (*IOURing) SubmitRequests ¶
func (iour *IOURing) SubmitRequests(requests []PrepRequest, ch chan<- Result) (RequestSet, error)
SubmitRequests by Request functions and io results are notified via channel
func (*IOURing) UnRegisterBuffers ¶
type IOURingOption ¶
type IOURingOption func(*IOURing)
func WithAsync ¶
func WithAsync() IOURingOption
func WithAttachWQ ¶
func WithAttachWQ(iour *IOURing) IOURingOption
WithAttachWQ new iouring instance being create will share the asynchronous worker thread backend of the specified io_uring ring, rather than create a new separate thread pool
func WithCQE32 ¶
func WithCQE32() IOURingOption
WithCQE32 every CQE will have 32B entry size to append IOCTL return data
func WithCQSize ¶
func WithCQSize(size uint32) IOURingOption
WithCQSize create the completion queue with size entries size must bue greater than entries
func WithDisableRing ¶
func WithDisableRing() IOURingOption
WithDisableRing the io_uring ring starts in a disabled state In this state, restrictions can be registered, but submissions are not allowed Available since 5.10
func WithDrain ¶
func WithDrain() IOURingOption
WithDrain every SQE will not be started before previously submitted SQEs have completed
func WithParams ¶
func WithParams(params *iouring_syscall.IOURingParams) IOURingOption
WithParams use params
func WithSQE128 ¶
func WithSQE128() IOURingOption
WithSQE128 every SQE will have 128B entry size to append IOCTL command
func WithSQPoll ¶
func WithSQPoll() IOURingOption
WithSQPoll a kernel thread is created to perform submission queue polling In Version 5.10 and later, allow using this as non-root, if the user has the CAP_SYS_NICE capability
func WithSQPollThreadCPU ¶
func WithSQPollThreadCPU(cpu uint32) IOURingOption
WithSQPollThreadCPU the poll thread will be bound to the cpu set, only meaningful when WithSQPoll option
func WithSQPollThreadIdle ¶
func WithSQPollThreadIdle(idle time.Duration) IOURingOption
type PrepRequest ¶
type PrepRequest func(sqe iouring_syscall.SubmissionQueueEntry, userData *UserData)
func Accept ¶
func Accept(sockfd int) PrepRequest
func Accept4 ¶
func Accept4(sockfd int, flags int) PrepRequest
func Close ¶
func Close(fd int) PrepRequest
func CountCompletionEvent ¶
func CountCompletionEvent(n uint64) PrepRequest
func EpollCtl ¶
func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) PrepRequest
func Fdatasync ¶
func Fdatasync(fd int) PrepRequest
func Fsync ¶
func Fsync(fd int) PrepRequest
func Madvise ¶
func Madvise(b []byte, advice int) PrepRequest
func Nop ¶
func Nop() PrepRequest
func Read ¶
func Read(fd int, b []byte) PrepRequest
func Readv ¶
func Readv(fd int, bs [][]byte) PrepRequest
func RemoveTimeout ¶
func RemoveTimeout(id uint64) PrepRequest
func Timeout ¶
func Timeout(t time.Duration) PrepRequest
func TimeoutWithTime ¶
func TimeoutWithTime(t time.Time) (PrepRequest, error)
func Write ¶
func Write(fd int, b []byte) PrepRequest
func Writev ¶
func Writev(fd int, bs [][]byte) PrepRequest
func (PrepRequest) WithCallback ¶
func (prepReq PrepRequest) WithCallback(callback RequestCallback) PrepRequest
func (PrepRequest) WithDrain ¶
func (prepReq PrepRequest) WithDrain() PrepRequest
func (PrepRequest) WithInfo ¶
func (prepReq PrepRequest) WithInfo(info interface{}) PrepRequest
WithInfo request with extra info
func (PrepRequest) WithTimeout ¶
func (prepReq PrepRequest) WithTimeout(timeout time.Duration) []PrepRequest
type RequestCallback ¶
type RequestSet ¶
type Result ¶
type Result interface { Fd() int Opcode() uint8 GetRequestBuffer() (b0, b1 []byte) GetRequestBuffers() [][]byte GetRequestInfo() interface{} FreeRequestBuffer() Err() error ReturnValue0() interface{} ReturnValue1() interface{} ReturnExtra1() uint64 ReturnExtra2() uint64 ReturnFd() (int, error) ReturnInt() (int, error) Callback() error }
type ResultResolver ¶
type ResultResolver func(req Request)
type SubmissionQueue ¶
type SubmissionQueue struct {
// contains filtered or unexported fields
}
type SubmissionQueueRing ¶
type SubmissionQueueRing interface {
// contains filtered or unexported methods
}
type SubmissionQueueRing128 ¶
type SubmissionQueueRing128 struct {
// contains filtered or unexported fields
}
type SubmissionQueueRing64 ¶
type SubmissionQueueRing64 struct {
// contains filtered or unexported fields
}
type UserData ¶
type UserData struct {
// contains filtered or unexported fields
}
func (*UserData) SetRequestBuffer ¶
func (*UserData) SetRequestBuffers ¶
func (*UserData) SetRequestCallback ¶
func (data *UserData) SetRequestCallback(callback RequestCallback)
func (*UserData) SetRequestInfo ¶
func (data *UserData) SetRequestInfo(info interface{})
func (*UserData) SetResultResolver ¶
func (data *UserData) SetResultResolver(resolver ResultResolver)