#include <misc/result.h>
#include <misc/malloc.h>
#include <misc/pool.h>
#include <misc/debug.h>
#include <core/buffer.h>
Go to the source code of this file.
Classes | |
struct | txc_buffermgr_s |
Functions | |
txc_result_t | txc_buffermgr_create (txc_buffermgr_t **buffermgrp) |
Creates a buffer manager. | |
void | txc_buffermgr_destroy (txc_buffermgr_t **buffermgrp) |
Destroys a buffer manager. | |
txc_result_t | txc_buffer_circular_init (txc_buffer_circular_t *buffer) |
Initializes an existing circular buffer. | |
txc_result_t | txc_buffer_circular_create (txc_buffermgr_t *buffermgr, txc_buffer_circular_t **bufferp) |
Creates and initializes a new circular buffer. | |
void | txc_buffer_circular_destroy (txc_buffer_circular_t **bufferp) |
Destroys a circular buffer. | |
txc_result_t | txc_buffer_linear_init (txc_buffer_linear_t *buffer) |
Initializes an existing linear buffer. | |
txc_result_t | txc_buffer_linear_create (txc_buffermgr_t *buffermgr, txc_buffer_linear_t **bufferp) |
Creates and initializes a new linear buffer. | |
void | txc_buffer_linear_destroy (txc_buffer_linear_t **bufferp) |
Destroys a linear buffer. | |
void * | txc_buffer_linear_malloc (txc_buffer_linear_t *buffer, unsigned int size) |
Allocates a linear region from a linear buffer. | |
void | txc_buffer_linear_free (txc_buffer_linear_t *buffer, unsigned int size) |
Deallocates a linear region previously allocated from a linear buffer. | |
Variables | |
txc_buffermgr_t * | txc_g_buffermgr |
This subsystem provides shared and private buffers to store data for deferred system calls and for in-place system calls that require compensation. Shared buffers store data when the kernel cannot undo a data-producing action, such as reading from a pipe. These buffers persist across transactions and may be accessed by any thread. Private buffers store data for deferred calls for compensating actions. For example, undoing a random file write replaces the data in the file with its original contents, which are stored in a private buffer. As private buffers are discarded when a transaction aborts, they are organized as a per-thread log (txc_buffer_linear_t
) to reduce fragmentation and bookkeeping overheads.
src/xcalls/x_read_pipe.c
and src/xcalls/x_sendmsg.c
into this file.Definition in file buffer.c.
txc_result_t txc_buffer_circular_create | ( | txc_buffermgr_t * | buffermgr, | |
txc_buffer_circular_t ** | bufferp | |||
) |
Creates and initializes a new circular buffer.
[in] | buffermgr | The buffer manager responsible for the buffer. |
[out] | bufferp | The newly created buffer. |
Definition at line 186 of file buffer.c.
References txc_buffermgr_s::pool_buffer_circular, txc_buffer_circular_init(), TXC_INTERNALERROR, txc_pool_object_alloc(), and TXC_R_SUCCESS.
Referenced by txc_koa_create().
void txc_buffer_circular_destroy | ( | txc_buffer_circular_t ** | bufferp | ) |
Destroys a circular buffer.
[in,out] | bufferp | The buffer to be destroyed. |
Definition at line 214 of file buffer.c.
References txc_buffermgr_s::pool_buffer_circular, and txc_pool_object_free().
Referenced by txc_koa_destroy().
txc_result_t txc_buffer_circular_init | ( | txc_buffer_circular_t * | buffer | ) |
Initializes an existing circular buffer.
[in] | buffer | The buffer to be initialized. |
Definition at line 166 of file buffer.c.
References txc_buffer_circular_s::primary_head, txc_buffer_circular_s::primary_tail, txc_buffer_circular_s::secondary_head, txc_buffer_circular_s::secondary_tail, txc_buffer_circular_s::state, and TXC_R_SUCCESS.
Referenced by txc_buffer_circular_create().
txc_result_t txc_buffer_linear_create | ( | txc_buffermgr_t * | buffermgr, | |
txc_buffer_linear_t ** | bufferp | |||
) |
Creates and initializes a new linear buffer.
[in] | buffermgr | The buffer manager responsible for the buffer. |
[out] | bufferp | The newly created buffer. |
Definition at line 255 of file buffer.c.
References txc_buffermgr_s::pool_buffer_linear, txc_buffer_linear_init(), TXC_INTERNALERROR, txc_pool_object_alloc(), and TXC_R_SUCCESS.
Referenced by txc_txmgr_create().
void txc_buffer_linear_destroy | ( | txc_buffer_linear_t ** | bufferp | ) |
Destroys a linear buffer.
[in,out] | bufferp | The buffer to be destroyed. |
Definition at line 283 of file buffer.c.
References txc_buffermgr_s::pool_buffer_linear, and txc_pool_object_free().
Referenced by txc_txmgr_destroy().
void txc_buffer_linear_free | ( | txc_buffer_linear_t * | buffer, | |
unsigned int | size | |||
) |
Deallocates a linear region previously allocated from a linear buffer.
Deallocation operations must be in the reverse order of the allocation operations.
[in] buffer The buffer from which the region was allocated. [in] size The size of the region to be allocated.
Definition at line 325 of file buffer.c.
References txc_buffer_linear_s::cur_len.
Referenced by x_lseek(), x_read(), x_sendmsg(), and x_write_pipe().
txc_result_t txc_buffer_linear_init | ( | txc_buffer_linear_t * | buffer | ) |
Initializes an existing linear buffer.
[in] | buffer | The buffer to be initialized. |
Definition at line 238 of file buffer.c.
References txc_buffer_linear_s::cur_len, txc_buffer_linear_s::state, and TXC_R_SUCCESS.
Referenced by txc_buffer_linear_create().
void* txc_buffer_linear_malloc | ( | txc_buffer_linear_t * | buffer, | |
unsigned int | size | |||
) |
Allocates a linear region from a linear buffer.
[in] | buffer | The buffer from which the region is allocated. |
[in] | size | The size of the region to be allocated. |
Definition at line 300 of file buffer.c.
References txc_buffer_linear_s::buf, txc_buffer_linear_s::cur_len, and txc_buffer_linear_s::size_max.
Referenced by x_close(), x_create(), x_dup(), x_fsync(), x_lseek(), x_open(), x_pipe(), x_pthread_mutex_lock(), x_pthread_mutex_unlock(), x_read(), x_rename(), x_sendmsg(), x_socket(), x_unlink(), and x_write_pipe().
txc_result_t txc_buffermgr_create | ( | txc_buffermgr_t ** | buffermgrp | ) |
Creates a buffer manager.
It preallocates a pool of circular and linear buffers to make allocation fast.
[out] | buffermgrp | The created buffer manager. |
Definition at line 73 of file buffer.c.
References FREE, MALLOC, TXC_BUFFER_CIRCULAR_NUM, TXC_BUFFER_CIRCULAR_SIZE, TXC_BUFFER_LINEAR_NUM, TXC_BUFFER_LINEAR_SIZE, txc_pool_create(), txc_pool_destroy(), TXC_R_NOMEMORY, and TXC_R_SUCCESS.
Referenced by _TXC_global_init().
void txc_buffermgr_destroy | ( | txc_buffermgr_t ** | buffermgrp | ) |
Destroys a buffer manager.
It deallocates all buffers that it manages.
[in,out] | buffermgrp | The buffer manager to be destroyed. |
Definition at line 115 of file buffer.c.
References FREE, and txc_pool_destroy().