nfs-ganesha 1.4
Defines | Functions | Variables

cache_content_misc.c File Reference

Management of the file content cache: miscellaneous functions. More...

#include "fsal.h"
#include "LRU_List.h"
#include "log.h"
#include "HashData.h"
#include "HashTable.h"
#include "cache_inode.h"
#include "cache_content.h"
#include "nfs_exports.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <time.h>
#include <pthread.h>
#include <string.h>
#include <libgen.h>

Go to the source code of this file.

Defines

#define ALPHABET_LEN   16
#define PRIME_16BITS   65521

Functions

short HashFileID4 (u_int64_t fileid4)
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)
int cache_content_get_export_id (char *dirname)
u_int64_t cache_content_get_inum (char *filename)
int cache_content_get_datapath (char *basepath, u_int64_t inum, char *datapath)
off_t cache_content_recover_size (char *basepath, u_int64_t inum)
off_t cache_content_get_cached_size (cache_content_entry_t *pentry)
cache_inode_status_t cache_content_error_convert (cache_content_status_t status)
size_t cache_content_fsal_size_convert (fsal_size_t size, cache_content_status_t *pstatus)
cache_content_status_t cache_content_prepare_directories (exportlist_t *pexportlist, char *cache_dir, cache_content_status_t *pstatus)
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)
int cache_content_local_cache_opendir (char *cache_dir, cache_content_dirinfo_t *pdirectory)
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)
int cache_content_local_cache_dir_iter (cache_content_dirinfo_t *directory, struct dirent *pdir_entry, unsigned int index, unsigned int mod)
void cache_content_local_cache_closedir (cache_content_dirinfo_t *directory)

Variables

unsigned int cache_content_dir_errno

Detailed Description

Management of the file content cache: miscellaneous functions.

Author:
Author:
leibovic
Date:
Date:
2006/01/18 07:29:11
Version:
Revision:
1.14

cache_content_misc.c : Management of the file content cache, miscellaneous functions.

Definition in file cache_content_misc.c.


Define Documentation

#define ALPHABET_LEN   16
#define PRIME_16BITS   65521

Function Documentation

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.

Parameters:
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.
Returns:
CACHE_CONTENT_SUCCESS if successful
CACHE_CONTENT_INVALID_ARGUMENT if some argument has an unexpected value
CACHE_CONTENT_LOCAL_CACHE_ERROR if an error occured while getting informations from datacache filesystem.

Definition at line 482 of file cache_content_misc.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.

Parameters:
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.
Returns:
CACHE_CONTENT_SUCCESS if operation is a success, other values show an error.

Definition at line 111 of file cache_content_misc.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.

Parameters:
status[IN] File content status to be converted.
Returns:
a cache_inode_status_t resulting from the conversion.

Definition at line 347 of file cache_content_misc.c.

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.

Parameters:
seek[IN] FSAL Seek descriptor.
pstatus[OUT] pointer to the status.
Returns:
the converted value.

Definition at line 405 of file cache_content_misc.c.

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.

Parameters:
pentry[IN] related pentry
Returns:
the recovered size (as a off_t) or -1 is failed.

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.

Parameters:
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).
Returns:
0 if OK, or -1 is failed.

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.

Parameters:
dirname[IN] The dirname for the export_id dirname.
Returns:
-1 if failed, the export_id if successfull.

Definition at line 192 of file cache_content_misc.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.

Parameters:
filename[IN] The filename to be parsed.
Returns:
0 if failed, the inum if successfull.

Definition at line 216 of file cache_content_misc.c.

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.

Parameters:
directory[IN]the handle to the directory to be closed
Returns:
nothing (void function)

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

Parameters:
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
Returns:
TRUE if OK, FALSE if NOK.

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.

Parameters:
cache_dir[IN] the path to the directory associated with the export entry
pdirectory[OUT] pointer to trhe openend directory
Returns:
the handle to the directory or NULL is failed

Definition at line 569 of file cache_content_misc.c.

cache_content_status_t cache_content_prepare_directories ( exportlist_t pexportlist,
char *  cache_dir,
cache_content_status_t pstatus 
)

cache_content_prepare_directories: do the mkdir to set the data cache directories

do the mkdir to set the data cache directories.

Parameters:
pexportlist[IN] export list
pstatus[OUT] pointer to the status.
Returns:
the status for the operation

Definition at line 427 of file cache_content_misc.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.

Parameters:
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.
Returns:
the recovered size (as a off_t) or -1 is failed.

Definition at line 284 of file cache_content_misc.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.

Parameters:
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.
Returns:
CACHE_CONTENT_SUCCESS if entry is found, CACHE_CONTENT_NOT_FOUND if not found

Definition at line 613 of file cache_content_misc.c.

short HashFileID4 ( u_int64_t  fileid4)

Definition at line 80 of file cache_content_misc.c.


Variable Documentation

Definition at line 74 of file cache_content_misc.c.