File descriptor group utility functions. More...
Macros | |
#define | SPDK_FD_GROUP_ADD(fgrp, efd, fn, arg) spdk_fd_group_add(fgrp, efd, fn, arg, #fn) |
Typedefs | |
typedef int(* | spdk_fd_fn) (void *ctx) |
Callback function registered for the event source file descriptor. | |
Functions | |
int | spdk_fd_group_create (struct spdk_fd_group **fgrp) |
Initialize one fd_group. | |
void | spdk_fd_group_destroy (struct spdk_fd_group *fgrp) |
Release all resources associated with this fgrp. | |
int | spdk_fd_group_wait (struct spdk_fd_group *fgrp, int timeout) |
Wait for new events generated inside fgrp, and process them with their registered spdk_fd_fn. | |
int | spdk_fd_group_get_fd (struct spdk_fd_group *fgrp) |
Return the internal epoll_fd of specific fd_group. | |
int | spdk_fd_group_nest (struct spdk_fd_group *parent, struct spdk_fd_group *child) |
Nest the child fd_group in the parent fd_group. | |
int | spdk_fd_group_unnest (struct spdk_fd_group *parent, struct spdk_fd_group *child) |
Remove the nested child from the parent. | |
int | spdk_fd_group_add (struct spdk_fd_group *fgrp, int efd, spdk_fd_fn fn, void *arg, const char *name) |
Register SPDK_INTERRUPT_EVENT_IN event source to specified fgrp. | |
int | spdk_fd_group_add_for_events (struct spdk_fd_group *fgrp, int efd, uint32_t events, spdk_fd_fn fn, void *arg, const char *name) |
Register one event source to specified fgrp with specific event types. | |
void | spdk_fd_group_remove (struct spdk_fd_group *fgrp, int efd) |
Unregister one event source from one fgrp. | |
int | spdk_fd_group_event_modify (struct spdk_fd_group *fgrp, int efd, int event_types) |
Change the event notification types associated with the event source. | |
int | spdk_fd_group_get_epoll_event (struct epoll_event *event) |
Copies the epoll(7) event that caused a callback function to execute. | |
File descriptor group utility functions.
typedef int(* spdk_fd_fn) (void *ctx) |
Callback function registered for the event source file descriptor.
ctx | Context passed as arg to spdk_fd_group_add(). |
int spdk_fd_group_add | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
spdk_fd_fn | fn, | ||
void * | arg, | ||
const char * | name ) |
Register SPDK_INTERRUPT_EVENT_IN event source to specified fgrp.
Use spdk_fd_group_add_for_events() for other event types.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
fn | Called each time there are events in event source. |
arg | Function argument for fn. |
name | Name of the event source. |
int spdk_fd_group_add_for_events | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
uint32_t | events, | ||
spdk_fd_fn | fn, | ||
void * | arg, | ||
const char * | name ) |
Register one event source to specified fgrp with specific event types.
Event types argument is a bit mask composed by ORing together enum spdk_interrupt_event_types values.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
events | Event notification types. |
fn | Called each time there are events in event source. |
arg | Function argument for fn. |
name | Name of the event source. |
int spdk_fd_group_create | ( | struct spdk_fd_group ** | fgrp | ) |
Initialize one fd_group.
fgrp | A pointer to return the initialized fgrp. |
void spdk_fd_group_destroy | ( | struct spdk_fd_group * | fgrp | ) |
Release all resources associated with this fgrp.
Users need to remove all event sources from the fgrp before destroying it.
fgrp | The fgrp to destroy. |
int spdk_fd_group_event_modify | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
int | event_types ) |
Change the event notification types associated with the event source.
Modules like nbd, need this api to add EPOLLOUT when having data to send, and remove EPOLLOUT if no data to send.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
event_types | The event notification types. |
int spdk_fd_group_get_epoll_event | ( | struct epoll_event * | event | ) |
Copies the epoll(7) event that caused a callback function to execute.
This function can only be called by the callback function, doing otherwise results in undefined behavior.
event | pointer to an epoll(7) event to copy to |
int spdk_fd_group_get_fd | ( | struct spdk_fd_group * | fgrp | ) |
Return the internal epoll_fd of specific fd_group.
fgrp | The pointer of specified fgrp. |
int spdk_fd_group_nest | ( | struct spdk_fd_group * | parent, |
struct spdk_fd_group * | child ) |
Nest the child fd_group in the parent fd_group.
After this operation completes, calling spdk_fd_group_wait() on the parent will include events from the child.
parent | The parent fd_group. |
child | The child fd_group. |
void spdk_fd_group_remove | ( | struct spdk_fd_group * | fgrp, |
int | efd ) |
Unregister one event source from one fgrp.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
int spdk_fd_group_unnest | ( | struct spdk_fd_group * | parent, |
struct spdk_fd_group * | child ) |
Remove the nested child from the parent.
parent | The parent fd_group. |
child | The child fd_group. |
int spdk_fd_group_wait | ( | struct spdk_fd_group * | fgrp, |
int | timeout ) |
Wait for new events generated inside fgrp, and process them with their registered spdk_fd_fn.
fgrp | The fgrp to wait and process. |
timeout | Specifies the number of milliseconds that will block. -1 causes indefinitely blocking; 0 causes immediately return. |