Motr
M0
|
![]() |
Data Structures | |
struct | m0_net_bulk_mem_work_item |
struct | m0_net_bulk_mem_buffer_pvt |
struct | m0_net_bulk_mem_tm_pvt |
struct | m0_net_bulk_mem_end_point |
struct | m0_net_bulk_mem_ops |
struct | m0_net_bulk_mem_domain_pvt |
struct | mem_desc |
Typedefs | |
typedef void(* | m0_net_bulk_mem_work_fn_t) (struct m0_net_transfer_mc *tm, struct m0_net_bulk_mem_work_item *wi) |
Enumerations | |
enum | m0_net_bulk_mem_work_opcode { M0_NET_XOP_STATE_CHANGE =0, M0_NET_XOP_CANCEL_CB, M0_NET_XOP_MSG_RECV_CB, M0_NET_XOP_MSG_SEND, M0_NET_XOP_PASSIVE_BULK_CB, M0_NET_XOP_ACTIVE_BULK, M0_NET_XOP_ERROR_CB, M0_NET_XOP_NR } |
enum | m0_net_bulk_mem_tm_state { M0_NET_XTM_UNDEFINED = M0_NET_TM_UNDEFINED, M0_NET_XTM_INITIALIZED = M0_NET_TM_INITIALIZED, M0_NET_XTM_STARTING = M0_NET_TM_STARTING, M0_NET_XTM_STARTED = M0_NET_TM_STARTED, M0_NET_XTM_STOPPING = M0_NET_TM_STOPPING, M0_NET_XTM_STOPPED = M0_NET_TM_STOPPED, M0_NET_XTM_FAILED = M0_NET_TM_FAILED } |
enum | { M0_NET_BULK_MEM_MAX_SEGMENT_SIZE = (1 << 18), M0_NET_BULK_MEM_MAX_BUFFER_SEGMENTS = 16, M0_NET_BULK_MEM_MAX_BUFFER_SIZE = (1 << 22) } |
enum | { MEM_XO_TIMEOUT_SECS = 20 } |
enum | { M0_NET_BULK_MEM_XEP_ADDR_LEN = 36 } |
Variables | |
static struct m0_list | mem_domains |
static const struct m0_net_bulk_mem_ops | mem_xprt_methods |
static const struct m0_net_xprt_ops | mem_xo_xprt_ops |
const struct m0_net_xprt | m0_net_bulk_mem_xprt |
const struct m0_net_xprt | m0_net_bulk_mem_xprt |
This module provides a network transport with messaging and bulk data transfer across domains within a single process.
An end point address is a string with two tuples separated by a colon (:). The first tuple is the dotted decimal representation of an IPv4 address, and the second is an IP port number.
When used as a base for a derived transport, a third tuple representing an unsigned 32 bit service identifier is supported in the address.
This transport can be used directly for testing purposes. It permits the creation of multiple domains, each with multiple transfer machines, and provides support for message passing and bulk data transfer between transfer machines of different domains. Data is copied between buffers.
It uses a pool of background threads per transfer machine to provide the required threading semantics of the messaging API and the illusion of independent domains.
It can also serve as a "base" module for derived transports that wish to reuse the threading and buffer management support of this module. Derivation is done as follows:
See LNet Transport for an example of a derived transport.
typedef void(* m0_net_bulk_mem_work_fn_t) (struct m0_net_transfer_mc *tm, struct m0_net_bulk_mem_work_item *wi) |
Work functions are invoked from worker threads. There is one work function per work item opcode. Each function has a signature described by this typedef.
Definition at line 272 of file mem_xprt.h.
anonymous enum |
Enumerator | |
---|---|
M0_NET_BULK_MEM_MAX_SEGMENT_SIZE | |
M0_NET_BULK_MEM_MAX_BUFFER_SEGMENTS | |
M0_NET_BULK_MEM_MAX_BUFFER_SIZE | Max buffer size = max_seg_nr x max_seg_size |
Definition at line 38 of file mem_xprt_pvt.h.
anonymous enum |
Enumerator | |
---|---|
MEM_XO_TIMEOUT_SECS | Maximum time for condition to wait, avoids hung thread warning in kernel while TM is idle. |
Definition at line 165 of file mem_xprt_tm.c.
anonymous enum |
Enumerator | |
---|---|
M0_NET_BULK_MEM_XEP_ADDR_LEN | Max addr length, 3-tuple |
Definition at line 46 of file bulk_mem.h.
The internal state of transfer machine in this transport is described by this enumeration.
Note these are similar to but not the same as the external state of the transfer machine - the external state changes only through the state change callback.
Enumerator | |
---|---|
M0_NET_XTM_UNDEFINED | |
M0_NET_XTM_INITIALIZED | |
M0_NET_XTM_STARTING | |
M0_NET_XTM_STARTED | |
M0_NET_XTM_STOPPING | |
M0_NET_XTM_STOPPED | |
M0_NET_XTM_FAILED |
Definition at line 139 of file mem_xprt.h.
The worker threads associated with a transfer machine perform units of work described by the opcodes in this enumeration.
Definition at line 112 of file mem_xprt.h.
M0_INTERNAL void m0_mem_xprt_fini | ( | void | ) |
Transport finalization subroutine called from m0_fini().
Definition at line 59 of file mem_xprt_xo.c.
M0_INTERNAL int m0_mem_xprt_init | ( | void | ) |
Transport initialization subroutine called from m0_init().
Definition at line 47 of file mem_xprt_xo.c.
M0_INTERNAL size_t m0_net_bulk_mem_tm_get_num_threads | ( | const struct m0_net_transfer_mc * | tm | ) |
Return the number of threads used by a bulk in-memory transfer machine.
tm | Pointer to the transfer machine. |
Number-of-threads |
Definition at line 606 of file mem_xprt_xo.c.
M0_INTERNAL void m0_net_bulk_mem_tm_set_num_threads | ( | struct m0_net_transfer_mc * | tm, |
size_t | num | ||
) |
Set the number of worker threads used by a bulk in-memory transfer machine. This can be changed before the the transfer machine has started.
tm | Pointer to the transfer machine. |
num | Number of threads. |
Definition at line 594 of file mem_xprt_xo.c.
|
inlinestatic |
Function to indirectly invoke the mem_buffer_in_bounds subroutine via the domain function pointer, to support derived transports.
Definition at line 110 of file mem_xprt_pvt.h.
|
static |
Function to indirectly invoke the mem_desc_create subroutine via the domain function pointer, to support derived transports.
Definition at line 121 of file mem_xprt_pvt.h.
|
inlinestatic |
Function to indirectly invoke the mem_ep_create subroutine via the domain function pointer, to support derived transports.
Definition at line 96 of file mem_xprt_pvt.h.
|
static |
|
static |
|
static |
|
inlinestatic |
Recover the buffer private pointer from the buffer pointer.
Definition at line 202 of file mem_xprt.h.
|
inlinestatic |
Function to obtain the work item from a m0_net_buffer pointer.
bufferPointer |
WorkItemPointer | in buffer private data |
Definition at line 399 of file mem_xprt.h.
|
static |
|
static |
Create a network buffer descriptor from an in-memory end point.
The descriptor used by the in-memory transport is not encoded as it is never accessed out of the process.
ep | Remote end point allowed active access |
tm | Transfer machine holding the passive buffer |
qt | The queue type |
buflen | The amount data to transfer. |
buf_id | The buffer identifier. |
desc | Returns the descriptor |
Definition at line 205 of file mem_xprt_ep.c.
|
static |
Decodes a network buffer descriptor.
desc | Network buffer descriptor pointer. |
md | Returns the descriptor contents. The pointer does not allocate memory but instead points to within the network buffer descriptor, so don't free it. |
0 | On success |
-EINVAL | Invalid transfer descriptor |
Definition at line 242 of file mem_xprt_ep.c.
|
static |
Compares if two descriptors are equal.
Definition at line 255 of file mem_xprt_ep.c.
|
static |
|
inlinestatic |
Recover the domain private from a pointer to the domain.
Definition at line 375 of file mem_xprt.h.
|
inlinestatic |
Function to return the IP address of the end point.
ep | End point pointer |
address | In network byte order. |
Definition at line 410 of file mem_xprt.h.
|
static |
Allocate memory for a transport end point.
Definition at line 86 of file mem_xprt_ep.c.
|
static |
Internal implementation of mem_xo_end_point_create().
Definition at line 109 of file mem_xprt_ep.c.
|
static |
Compare an end point with a sockaddr_in for equality. The id field is not considered.
ep | End point |
sa | sockaddr_in pointer |
true | Match |
false | Do not match |
Definition at line 161 of file mem_xprt_ep.c.
|
static |
Free memory for a transport end point.
Definition at line 96 of file mem_xprt_ep.c.
|
static |
|
static |
|
inlinestatic |
Function to return the port number of the end point.
ep | End point pointer |
port | In network byte order. |
Definition at line 422 of file mem_xprt.h.
|
static |
create the printable representation
Definition at line 56 of file mem_xprt_ep.c.
|
inlinestatic |
Function to return the service id of the end point.
ep | End point pointer |
service | id in network byte order |
Definition at line 434 of file mem_xprt.h.
|
inlinestatic |
Recover the end point private from a pointer to the end point.
Definition at line 262 of file mem_xprt.h.
|
static |
Compare two end points for equality. Only the addresses are matched.
ep1 | First end point |
ep2 | Second end point |
true | Match |
false | Do not match |
Definition at line 179 of file mem_xprt_ep.c.
|
static |
Find a remote TM for a msg send or active buffer operation.
The m0_net_mutex will be obtained to traverse the list of domains. Each domain lock will be held to traverse the transfer machines in the domain. Once the correct transfer machine is found, its lock is obtained and the other locks released.
tm | Local TM |
match_ep | End point of remote TM |
p_dest_tm | Returns remote TM pointer, with TM mutex held. |
p_dest_ep | Returns end point in remote TM's domain, with local TM's address. Optional - only msg send requires this. The option exists because the end point object has to be created while holding the remote DOM's mutex. |
0 | On success |
-errno | On error |
Definition at line 67 of file mem_xprt_msg.c.
|
static |
|
static |
Support subroutine to send an error event.
tm | The transfer machine. |
status | The error code. |
Definition at line 151 of file mem_xprt_tm.c.
|
inlinestatic |
Function to compare two struct sockaddr_in structures.
sa1 | Pointer to first structure. |
sa2 | Pointer to second structure. |
Definition at line 446 of file mem_xprt.h.
|
static |
|
inlinestatic |
Recover the TM private pointer from a pointer to the TM.
Definition at line 231 of file mem_xprt.h.
|
static |
Perform a bulk data transfer, and invoke the completion callback on the active buffer.
tm | The active TM |
wi | The work item. |
Definition at line 56 of file mem_xprt_bulk.c.
|
static |
Deliver a callback during operation cancel.
Definition at line 107 of file mem_xprt_tm.c.
|
static |
Work function for the M0_NET_XOP_ERROR_CB work item.
tm | The corresponding transfer machine (unlocked). |
wi | The work item. This will be freed. |
Definition at line 129 of file mem_xprt_tm.c.
|
static |
|
static |
This item involves copying the buffer to the appropriate receive buffer (if available) of the target transfer machine in the destination domain, adding a M0_NET_XOP_MSG_RECV_CB item on that queue, and then invoking the completion callback on the send buffer. An end point object describing the sender's address will be referenced from the receiving buffer.
If a suitable transfer machine is not found then the message send fails.
Definition at line 166 of file mem_xprt_msg.c.
|
static |
Invoke the completion callback on a passive bulk transfer buffer.
Definition at line 33 of file mem_xprt_bulk.c.
|
static |
Work function for the M0_NET_XOP_STATE_CHANGE work item.
tm | the corresponding transfer machine |
wi | the work item, this will be freed |
Definition at line 35 of file mem_xprt_tm.c.
|
static |
|
static |
|
inlinestatic |
Function obtain the m0_net_buffer pointer from its related work item.
wi | Work item pointer in embedded buffer private data |
bufferPointer |
Definition at line 386 of file mem_xprt.h.
|
static |
This routine initiates processing of the buffer operation.
Definition at line 401 of file mem_xprt_xo.c.
|
static |
Cancel ongoing buffer operations. May also be invoked to time out a pending buffer operation by first setting the M0_NET_BUF_TIMED_OUT flag.
nb | Buffer pointer |
Definition at line 470 of file mem_xprt_xo.c.
|
static |
This routine releases references from the private data associated with the buffer, and frees the private data if the transport was used directly. Derived transports should free the private data upon return from this subroutine.
Definition at line 382 of file mem_xprt_xo.c.
|
static |
This routine initializes the private data associated with the buffer.
The private data is allocated here when the transport is used directly. Derived transports should allocate the buffer private data before invoking this method. The nb_xprt_private field should be set to point to this transports private data.
Definition at line 346 of file mem_xprt_xo.c.
|
static |
This subroutine releases references from the private data. If not derived, it will unlink the domain and free the private data. Derived transports should free the private data upon return from this subroutine.
Definition at line 245 of file mem_xprt_xo.c.
|
static |
This routine will allocate and initialize the private domain data and attach it to the domain. It will assume that the domains private pointer is allocated if not NULL. This allows for a derived transport to pre-allocate this structure before invoking the base method. The method will initialize the size and count fields as per the requirements of the in-memory module. If the private domain pointer was not allocated, the routine will assume that the domain is not derived, and will then link the domain in a private list to facilitate in-memory data transfers between transfer machines.
Definition at line 200 of file mem_xprt_xo.c.
|
static |
This routine will search for an existing end point in the domain, and if not found, will allocate and zero out space for a new end point using the xd_sizeof_ep field to determine the size. It will fill in the xep_address field with the IP and port number, and will link the end point to the domain link list.
Dynamic address assignment is not supported.
epp | Returns the pointer to the end point. |
dom | Domain pointer. |
addr | Address string in one of the following two formats:
|
Definition at line 290 of file mem_xprt_xo.c.
|
static |
End point release subroutine invoked when the reference count goes to 0. Unlinks the end point from the domain, and releases the memory. Must be called holding the domain mutex.
Definition at line 40 of file mem_xprt_ep.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Finalize a transfer machine. Derived transports should free the private data upon return from this subroutine.
tm | Transfer machine pointer |
Definition at line 562 of file mem_xprt_xo.c.
|
static |
Initialize a transfer machine.
The private data is allocated here if the transport is used directly. Derived transports should allocate their private data prior to calling this subroutine, and set the TM private pointer to point to the embedded private structure of this transport.
tm | Transfer machine pointer |
0 | on success |
-ENOMEM | if memory not available |
Definition at line 526 of file mem_xprt_xo.c.
|
static |
|
static |
|
static |
The entry point of the worker thread started when a transfer machine transitions from STARTING to STARTED. The thread runs its main loop until it the transfer machine state changes to X2_NET_XTM_STOPPED, at which time the function returns, causing the thread to exit.
tm | Transfer machine pointer |
Definition at line 180 of file mem_xprt_tm.c.
const struct m0_net_xprt m0_net_bulk_mem_xprt |
The bulk in-memory transport pointer to be used in m0_net_domain_init().
Definition at line 761 of file mem_xprt_xo.c.
const struct m0_net_xprt m0_net_bulk_mem_xprt |
The bulk in-memory transport pointer to be used in m0_net_domain_init().
Definition at line 761 of file mem_xprt_xo.c.
|
static |
List of in-memory network domains. Protected by struct m0_net_mutex.
Definition at line 39 of file mem_xprt_xo.c.
|
static |
Definition at line 738 of file mem_xprt_xo.c.
|
static |
Definition at line 42 of file mem_xprt_xo.c.