nfs-ganesha 1.4
|
Management of the cached content layer. More...
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <time.h>
#include <pthread.h>
#include <dirent.h>
#include <sys/stat.h>
#include "LRU_List.h"
#include "HashData.h"
#include "HashTable.h"
#include "fsal.h"
#include "cache_inode.h"
Go to the source code of this file.
Management of the cached content layer.
cache_content.h : Management of the cached content layer
Definition in file cache_content.h.
#define CACHE_CONTENT_BAD_CACHE_INODE_ENTRY 3 |
Definition at line 213 of file cache_content.h.
#define CACHE_CONTENT_DIR_INITIALIZER NULL |
Definition at line 205 of file cache_content.h.
#define CACHE_CONTENT_ENTRY_EXISTS 4 |
Definition at line 214 of file cache_content.h.
#define CACHE_CONTENT_FLAGS_READ 0x0000001 |
Definition at line 83 of file cache_content.h.
#define CACHE_CONTENT_FLAGS_READ_WRITE 0x0000003 |
Definition at line 85 of file cache_content.h.
#define CACHE_CONTENT_FLAGS_WRITE 0x0000002 |
Definition at line 84 of file cache_content.h.
#define CACHE_CONTENT_FLUSH 5 |
Definition at line 78 of file cache_content.h.
#define CACHE_CONTENT_FSAL_ERROR 5 |
Definition at line 215 of file cache_content.h.
#define CACHE_CONTENT_INVALID_ARGUMENT 1 |
Definition at line 211 of file cache_content.h.
#define CACHE_CONTENT_LOCAL_CACHE_ERROR 6 |
Definition at line 216 of file cache_content.h.
#define CACHE_CONTENT_LOCAL_CACHE_NOT_FOUND 10 |
Definition at line 220 of file cache_content.h.
#define CACHE_CONTENT_LRU_ERROR 8 |
Definition at line 218 of file cache_content.h.
#define CACHE_CONTENT_MALLOC_ERROR 7 |
Definition at line 217 of file cache_content.h.
#define CACHE_CONTENT_NB_COMMAND 7 |
Definition at line 81 of file cache_content.h.
#define CACHE_CONTENT_NEW_ENTRY 0 |
Definition at line 73 of file cache_content.h.
#define CACHE_CONTENT_NOT_FOUND 9 |
Definition at line 219 of file cache_content.h.
#define cache_content_read | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
i | |||
) | cache_content_rdwr( a, CACHE_CONTENT_READ, b, c, d, e, f, g, h, i ) |
Definition at line 295 of file cache_content.h.
#define CACHE_CONTENT_READ_ENTRY 2 |
Definition at line 75 of file cache_content.h.
#define CACHE_CONTENT_REFRESH 6 |
Definition at line 79 of file cache_content.h.
#define CACHE_CONTENT_RELEASE_ENTRY 1 |
Definition at line 74 of file cache_content.h.
#define CACHE_CONTENT_SPEC_DATA_SIZE 400 |
Definition at line 118 of file cache_content.h.
#define CACHE_CONTENT_SUCCESS 0 |
Definition at line 210 of file cache_content.h.
#define CACHE_CONTENT_TOO_LARGE_FOR_CACHE 11 |
Definition at line 221 of file cache_content.h.
#define CACHE_CONTENT_TRUNCATE 4 |
Definition at line 77 of file cache_content.h.
#define CACHE_CONTENT_UNAPPROPRIATED_KEY 2 |
Definition at line 212 of file cache_content.h.
#define cache_content_write | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
i | |||
) | cache_content_rdwr( a, CACHE_CONTENT_WRITE, b, c, d, e, f, g, h, i ) |
Definition at line 296 of file cache_content.h.
#define CACHE_CONTENT_WRITE_ENTRY 3 |
Definition at line 76 of file cache_content.h.
#define CONF_LABEL_CACHE_CONTENT_CLIENT "FileContent_Client" |
Definition at line 70 of file cache_content.h.
#define CONF_LABEL_CACHE_CONTENT_GCPOL "FileContent_GC_Policy" |
Definition at line 69 of file cache_content.h.
#define CONF_LABEL_CACHE_CONTENT_PARAM "FileContent_Param" |
Definition at line 71 of file cache_content.h.
typedef struct cache_content_client_parameter__ cache_content_client_parameter_t |
typedef struct cache_content_client__ cache_content_client_t |
typedef struct cache_content_dirinfo__ cache_content_dirinfo_t |
typedef struct cache_content_entry__ cache_content_entry_t |
typedef struct cache_content_gc_policy__ cache_content_gc_policy_t |
typedef struct cache_content_internal_md__ cache_content_internal_md_t |
typedef struct cache_content_local_entry__ cache_content_local_entry_t |
typedef enum cache_content_nametype__ cache_content_nametype_t |
typedef enum cache_content_op__ cache_content_op_t |
typedef struct cache_content_opened_file__ cache_content_opened_file_t |
typedef enum cache_content_refresh_how__ cache_content_refresh_how_t |
typedef char cache_content_spec_data_t[CACHE_CONTENT_SPEC_DATA_SIZE] |
Definition at line 119 of file cache_content.h.
typedef struct cache_content_stat__ cache_content_stat_t |
typedef int cache_content_status_t |
Definition at line 57 of file cache_content.h.
typedef enum cache_content_sync_state__ cache_content_sync_state_t |
Definition at line 230 of file cache_content.h.
Definition at line 100 of file cache_content.h.
Definition at line 105 of file cache_content.h.
CACHE_CONTENT_UNASSIGNED | |
CACHE_CONTENT_DATA_FILE | |
CACHE_CONTENT_INDEX_FILE | |
CACHE_CONTENT_DIR |
Definition at line 223 of file cache_content.h.
enum cache_content_op__ |
Definition at line 178 of file cache_content.h.
Definition at line 236 of file cache_content.h.
Definition at line 93 of file cache_content.h.
cache_content_status_t cache_content_check_threshold | ( | char * | datacache_path, |
unsigned int | threshold_min, | ||
unsigned int | threshold_max, | ||
int * | p_bool_overflow, | ||
unsigned long * | p_blocks_to_lwm | ||
) |
cache_content_check_threshold: check datacache filesystem's threshold.
datacache_path | [IN] the datacache filesystem's path. |
threshold_min | [IN] the low watermark for the filesystem (in percent). |
threshold_max | [IN] the high watermark for the filesystem (in percent). |
p_bool_overflow | [OUT] boolean that indicates whether the FS overcomes the high watermark. |
p_blocks_to_lwm | [OUT] if bool_overflow is set to true, this indicates the number of blocks to be purged in order to reach the low watermark. |
Definition at line 482 of file cache_content_misc.c.
int cache_content_client_init | ( | cache_content_client_t * | pclient, |
cache_content_client_parameter_t | param, | ||
char * | name | ||
) |
cache_content_client_init: Init the ressource necessary for the cache content client.
Init the ressource necessary for the cache content client.
param | [IN] the parameter for this client |
pstatus | [OUT] pointer to buffer used to store the status for the operation. |
Definition at line 127 of file cache_content_init.c.
cache_content_status_t cache_content_close | ( | cache_content_entry_t * | pentry, |
cache_content_client_t * | pclient, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_close: closes the local fd on the cache.
Closes the local fd on the cache.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer whose content is to be accessed. |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 152 of file cache_content_rdwr.c.
cache_content_status_t cache_content_crash_recover | ( | unsigned short | exportid, |
unsigned int | index, | ||
unsigned int | mod, | ||
cache_content_client_t * | pclient_data, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_crash_recover: recovers the data cache and the associated inode after a crash.
[OUT] returned status.
Definition at line 71 of file cache_content_crash_recover.c.
cache_content_status_t cache_content_create_name | ( | char * | path, |
cache_content_nametype_t | type, | ||
fsal_op_context_t * | pcontext, | ||
cache_entry_t * | pentry_inode, | ||
cache_content_client_t * | pclient | ||
) |
cache_content_create_name: Creates a name in the local fs for a cached entry.
Creates a name in the local fs for a cached entry and creates the directories that whil contain this file.
path | [OUT] buffer to be used for storing the name. |
type | [IN] type of pathname to be created. |
pentry_inode | [OUT] Entry in Cache inode layer related to the file content entry. |
pclient | [IN] resources allocated for the file content client. |
Definition at line 111 of file cache_content_misc.c.
cache_content_status_t cache_content_emergency_flush | ( | char * | cachedir, |
cache_content_flush_behaviour_t | flushhow, | ||
unsigned int | lw_mark_trigger_flag, | ||
time_t | grace_period, | ||
unsigned int | index, | ||
unsigned int | mod, | ||
unsigned int * | p_nb_flushed, | ||
unsigned int * | p_nb_too_young, | ||
unsigned int * | p_nb_errors, | ||
unsigned int * | p_nb_orphans, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_emergency_flush: Flushes the content of a file in the local cache to the FSAL data.
Flushes the content of a file in the local cache to the FSAL data. This routine should be called only from the cache_inode layer.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
cachedir | [IN] cachedir the filesystem where the cache resides |
flushhow | [IN] should we delete local files or not ? |
lw_mark_trig | [IN] shpuld we purge until low water mark is reached ? |
grace_period | [IN] grace_period The grace period for a file before being considered for deletion |
p_nb_flushed | [INOUT] current flushed count |
p_nb_errors | [INOUT] current flush errors |
p_nb_orphans | [INOUT] current orphan files detected |
pcontext | [INOUT] pcontext the FSAL context for this operation |
pstatys | [OUT] the status of the operation. |
Definition at line 103 of file cache_content_emergency_flush.c.
cache_inode_status_t cache_content_error_convert | ( | cache_content_status_t | status | ) |
cache_content_error_convert: Converts a cache_content_status to a cache_inode_status.
Converts a cache_content_status to a cache_inode_status.
status | [IN] File content status to be converted. |
Definition at line 347 of file cache_content_misc.c.
cache_content_status_t cache_content_flush | ( | cache_content_entry_t * | pentry, |
cache_content_flush_behaviour_t | flushhow, | ||
cache_content_client_t * | pclient, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_flush: Flushes the content of a file in the local cache to the FSAL data.
Flushes the content of a file in the local cache to the FSAL data. This routine should be called only from the cache_inode layer.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer whose content is to be flushed. |
flushhow | [IN] should we delete the cached entry in local or not ? |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 78 of file cache_content_flush.c.
off_t cache_content_fsal_seek_convert | ( | fsal_seek_t | seek, |
cache_content_status_t * | pstatus | ||
) |
size_t cache_content_fsal_size_convert | ( | fsal_size_t | size, |
cache_content_status_t * | pstatus | ||
) |
cache_content_fsal_size_convert: converts a fsal_size_t to unix size.
Converts a fsal_seek_t to unix size.
seek | [IN] FSAL Seek descriptor. |
pstatus | [OUT] pointer to the status. |
Definition at line 405 of file cache_content_misc.c.
cache_content_status_t cache_content_gc | ( | cache_content_client_t * | pclient, |
cache_content_status_t * | pstatus | ||
) |
off_t cache_content_get_cached_size | ( | cache_content_entry_t * | pentry | ) |
cache_content_get_cached_size: recovers the size of a data cached file.
Recovers the size of a data cached file.
pentry | [IN] related pentry |
Definition at line 317 of file cache_content_misc.c.
int cache_content_get_datapath | ( | char * | basepath, |
u_int64_t | inum, | ||
char * | datapath | ||
) |
cache_content_get_datapath : recovers the path for a file of a specified inum.
basepath | [IN] path to the root of the directory in the cache for the related export entry |
inum | [IN] inode number for the file whose size is to be recovered. |
path | [OUT] the absolute path of the file (must be at least a MAXPATHLEN length string). |
Definition at line 254 of file cache_content_misc.c.
int cache_content_get_export_id | ( | char * | dirname | ) |
cache_content_get_export_id: gets an export id from an export dirname.
Gets an export id from an export dirname.
dirname | [IN] The dirname for the export_id dirname. |
Definition at line 192 of file cache_content_misc.c.
cache_content_gc_policy_t cache_content_get_gc_policy | ( | void | ) |
cache_content_get_gc_policy: Set the cache_content garbagge collecting policy.
Definition at line 91 of file cache_content_gc.c.
u_int64_t cache_content_get_inum | ( | char * | filename | ) |
cache_content_get_inum: gets an inode number fronm a cache filename.
Gets an inode number fronm a cache filename.
filename | [IN] The filename to be parsed. |
Definition at line 216 of file cache_content_misc.c.
int cache_content_init | ( | cache_content_client_parameter_t | param, |
cache_content_status_t * | pstatus | ||
) |
cache_inode_init: Init the ressource necessary for the cache inode management.
Init the ressource necessary for the cache inode management.
param | [IN] the parameter for this cache. |
pstatus | [OUT] pointer to buffer used to store the status for the operation. |
Definition at line 72 of file cache_content_init.c.
int cache_content_init_dir | ( | cache_content_client_parameter_t | param, |
unsigned short | export_id | ||
) |
cache_content_init_dir: Init the directory for caching entries from a given export id.
param | [IN] the parameter for this cache. |
export_id | [IN] export id for the entries to be cached. |
Definition at line 100 of file cache_content_init.c.
int cache_content_invalidate_flushed | ( | LRU_entry_t * | plru_entry, |
void * | addparam | ||
) |
void cache_content_local_cache_closedir | ( | cache_content_dirinfo_t * | directory | ) |
cache_content_local_cache_closedir: Close a local cache directory associated to an export entry.
directory[IN] | the handle to the directory to be closed |
Definition at line 868 of file cache_content_misc.c.
int cache_content_local_cache_dir_iter | ( | cache_content_dirinfo_t * | directory, |
struct dirent * | pdir_entry, | ||
unsigned int | index, | ||
unsigned int | mod | ||
) |
cache_content_local_cache_dir_iter: iterate on a local cache directory to get the entry one by one
directory | [IN] the directory to be read |
index | [IN] thread index for multithreaded flushes (first has index 0) |
mod | [IN] modulus for multithreaded flushes (number of threads) |
pdir_entry | [OUT] found dir_entry |
Definition at line 664 of file cache_content_misc.c.
int cache_content_local_cache_opendir | ( | char * | cache_dir, |
cache_content_dirinfo_t * | pdirectory | ||
) |
cache_content_local_cache_opendir: Open a local cache directory associated to an export entry.
cache_dir | [IN] the path to the directory associated with the export entry |
pdirectory | [OUT] pointer to trhe openend directory |
Definition at line 569 of file cache_content_misc.c.
cache_content_entry_t* cache_content_new_entry | ( | cache_entry_t * | pentry_inode, |
cache_content_spec_data_t * | pspecdata, | ||
cache_content_client_t * | pclient, | ||
cache_content_add_behaviour_t | how, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_new_entry: adds an entry to the file content cache.
Adds an entry to the file content cache. This routine should be called only from the cache_inode layer.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry_inode | [IN] entry in cache_inode layer for this file. |
pspecdata | [IN] pointer to the entry's specific data |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 80 of file cache_content_add_entry.c.
cache_content_status_t cache_content_open | ( | cache_content_entry_t * | pentry, |
cache_content_client_t * | pclient, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_open: opens the local fd on the cache.
Opens the local fd on the cache.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer whose content is to be accessed. |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 81 of file cache_content_rdwr.c.
void cache_content_print_conf_client_parameter | ( | FILE * | output, |
cache_content_client_parameter_t | param | ||
) |
cache_content_print_conf_client_parameter: prints the client parameter.
Prints the client parameters.
output | [IN] a descriptor to the IO for printing the data. |
param | [IN] structure to be printed. |
Definition at line 201 of file cache_content_read_conf.c.
void cache_content_print_conf_gc_policy | ( | FILE * | output, |
cache_content_gc_policy_t | gcpolicy | ||
) |
cache_content_print_gc_pol: prints the garbage collection policy.
Prints the garbage collection policy.
output | [IN] a descriptor to the IO for printing the data. |
param | [IN] structure to be printed. |
Definition at line 316 of file cache_content_read_conf.c.
cache_content_status_t cache_content_rdwr | ( | cache_content_entry_t * | pentry, |
cache_inode_io_direction_t | read_or_write, | ||
uint64_t | offset, | ||
size_t * | pio_size_in, | ||
size_t * | pio_size_out, | ||
void * | buffer, | ||
fsal_boolean_t * | p_fsal_eof, | ||
struct stat * | pbuffstat, | ||
cache_content_client_t * | pclient, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_rdwr: Reads/Writes through the cache layer.
Reads/Writes through the cache layer. This routine should be called only from the cache_inode layer.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer whose content is to be accessed. |
read_or_write | [IN] a flag of type cache_content_io_direction_t to tell if a read or write is to be done. |
offset | [IN] absolute position (in the FSAL file) where the IO will be done. |
pio_size_in | [IN] requested io size |
pio_size_out | [OUT] the size of the io that was successfully made. |
pbuffstat | [OUT] the 'stat' of entry in the data cache after the operation |
buffer | write:[IN] read:[OUT] the buffer for the data. |
pclient | [IN] ressource allocated by the client for the nfs management. |
pcontext | [IN] fsal credentials for the operation. [OUT] returned status. |
Definition at line 203 of file cache_content_rdwr.c.
cache_content_status_t cache_content_read_conf_client_parameter | ( | config_file_t | in_config, |
cache_content_client_parameter_t * | pparam | ||
) |
Definition at line 77 of file cache_content_read_conf.c.
cache_content_status_t cache_content_read_conf_gc_policy | ( | config_file_t | in_config, |
cache_content_gc_policy_t * | ppolicy | ||
) |
cache_content_read_conf_gc_policy: read the garbage collection policy in configuration file.
Reads the garbage collection policy in configuration file.
in_config | [IN] configuration file handle |
pparam | [OUT] read parameters |
Definition at line 224 of file cache_content_read_conf.c.
off_t cache_content_recover_size | ( | char * | basepath, |
u_int64_t | inum | ||
) |
cache_content_recover_size: recovers the size of a data cached file.
Recovers the size of a data cached file.
basepath | [IN] path to the root of the directory in the cache for the related export entry |
inum | [IN] inode number for the file whose size is to be recovered. |
Definition at line 284 of file cache_content_misc.c.
cache_content_status_t cache_content_refresh | ( | cache_content_entry_t * | pentry, |
cache_content_client_t * | pclient, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_refresh_how_t | how, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_refresh: Refreshes the whole content of a file in the local cache to the FSAL data.
Refreshes the whole content of a file in the local cache to the FSAL data. This routine should be called only from the cache_inode layer.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer whose content is to be flushed. |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 193 of file cache_content_flush.c.
cache_content_status_t cache_content_release_entry | ( | cache_content_entry_t * | pentry, |
cache_content_client_t * | pclient, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_release_entry: removes an entry from the cache and free the associated resources.
Removes an entry from the cache and free the associated resources.
No lock management is done in this layer: the related pentry in the cache inode layer is locked and will prevent from concurent accesses.
pentry | [IN] entry in file content layer for this file. |
pclient | [IN] ressource allocated by the client for the nfs management. [OUT] returned status. |
Definition at line 78 of file cache_content_release_entry.c.
void cache_content_set_gc_policy | ( | cache_content_gc_policy_t | policy | ) |
cache_content_set_gc_policy: Set the cache_content garbagge collecting policy.
policy | [IN] policy to be set. |
Definition at line 79 of file cache_content_gc.c.
cache_content_status_t cache_content_sync_all | ( | cache_content_client_t * | pclient, |
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
Definition at line 296 of file cache_content_flush.c.
cache_content_status_t cache_content_test_cached | ( | cache_entry_t * | pentry_inode, |
cache_content_client_t * | pclient, | ||
fsal_op_context_t * | pcontext, | ||
cache_content_status_t * | pstatus | ||
) |
cache_content_test_cached: Tests if a given pentry_inode has already an associated data cache
Tests if a given pentry_inode has already an associated data cache. This is useful to recover data from a data cache built by a former server instance.
pentry_inode | [IN] entry in cache_inode layer for this file. |
pclient | [IN] ressource allocated by the client for the nfs management. |
pcontext | [IN] the related FSAL Context [OUT] returned status. |
Definition at line 613 of file cache_content_misc.c.
cache_content_status_t cache_content_truncate | ( | cache_content_entry_t * | pentry, |
fsal_size_t | length, | ||
cache_content_client_t * | pclient, | ||
cache_content_status_t * | pstatus | ||
) |
Definition at line 60 of file cache_content_truncate.c.