nfs-ganesha 1.4
|
00001 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*- 00002 * vim:expandtab:shiftwidth=4:tabstop=4: 00003 */ 00004 00005 #include "fsal_types.h" 00006 00007 #ifndef _POSIXDB_INTERNAL_H 00008 #define _POSIXDB_INTERNAL_H 00009 00010 #define MAX_HANDLEIDSTR_SIZE 21 // (size for "18446744073709551616" + 1 char for '\0') 00011 #define MAX_DEVICEIDSTR_SIZE 21 // (size for "18446744073709551616" + 1 char for '\0') 00012 #define MAX_INODESTR_SIZE 21 // (size for "18446744073709551616" + 1 char for '\0') 00013 #define MAX_HANDLETSSTR_SIZE 11 // (size for "4294967296" + 1 char for '\0') 00014 #define MAX_CTIMESTR_SIZE 11 00015 #define MAX_NLINKSTR_SIZE 11 00016 #define MAX_FTYPESTR_SIZE 11 00017 00018 #define ReturnCodeDB( _code_, _minor_ ) do { \ 00019 fsal_posixdb_status_t _struct_status_; \ 00020 if(isFullDebug(COMPONENT_FSAL)) \ 00021 { \ 00022 LogCrit(COMPONENT_FSAL, "Exiting %s ( %s:%i ) with status code = %i/%i\n", __FUNCTION__, __FILE__, __LINE__ - 2, _code_, _minor_ ); \ 00023 } \ 00024 (_struct_status_).major = (_code_) ; \ 00025 (_struct_status_).minor = (_minor_) ; \ 00026 return (_struct_status_); \ 00027 } while(0) 00028 00029 #define BeginTransaction( _conn_ ) db_exec_sql( _conn_, "BEGIN", NULL ) 00030 #define EndTransaction( _conn_ ) db_exec_sql( _conn_, "COMMIT", NULL ) 00031 #define RollbackTransaction( _conn_ ) db_exec_sql( _conn_, "ROLLBACK", NULL ) 00032 00033 /* result_handle type */ 00034 typedef MYSQL_RES *result_handle_t; 00035 00036 int db_is_retryable(int sql_err); 00037 00038 fsal_posixdb_status_t db_exec_sql(fsal_posixdb_conn * conn, const char *query, 00039 result_handle_t * p_result); 00040 00054 fsal_posixdb_status_t fsal_posixdb_buildOnePath(fsal_posixdb_conn * p_conn, /* IN */ 00055 posixfsal_handle_t * p_handle, /* IN */ 00056 fsal_path_t * p_path /* OUT */ ); 00057 00074 fsal_posixdb_status_t fsal_posixdb_recursiveDelete(fsal_posixdb_conn * p_conn, 00075 unsigned long long id, unsigned int ts, 00076 fsal_nodetype_t ftype); 00077 00100 fsal_posixdb_status_t fsal_posixdb_deleteParent(fsal_posixdb_conn * p_conn, /* IN */ 00101 unsigned long long id, /* IN */ 00102 unsigned int ts, /* IN */ 00103 unsigned long long idparent, /* IN */ 00104 unsigned int tsparent, /* IN */ 00105 char *filename, /* IN */ 00106 int nlink); /* IN */ 00107 00114 fsal_posixdb_status_t fsal_posixdb_internal_delete(fsal_posixdb_conn * p_conn, /* IN */ 00115 unsigned long long idparent, /* IN */ 00116 unsigned int tsparent, /* IN */ 00117 char *filename, /* IN */ 00118 fsal_posixdb_fileinfo_t * 00119 p_object_info /* IN */ ); 00120 00130 fsal_posixdb_status_t fsal_posixdb_initPreparedQueries(fsal_posixdb_conn * p_conn); 00131 00145 fsal_posixdb_status_t posixdb_internal_fillFileinfoFromStrValues(fsal_posixdb_fileinfo_t * 00146 p_info, char *devid_str, 00147 char *inode_str, 00148 char *nlink_str, 00149 char *ctime_str, 00150 char *ftype_str); 00151 00152 /* this manages a mini-cache for the last few handles handled 00153 * it is invalidated as soon has there is a modification in the database 00154 */ 00155 00156 /* enter an entry in cache path */ 00157 00158 void fsal_posixdb_CachePath(posixfsal_handle_t * p_handle, /* IN */ 00159 fsal_path_t * p_path /* IN */ ); 00160 00161 /* invalidate cache in case of a modification */ 00162 00163 void fsal_posixdb_InvalidateCache(); 00164 00165 /* get a path from the cache 00166 * return true if the entry is found, 00167 * false else. 00168 */ 00169 00170 int fsal_posixdb_GetPathCache(posixfsal_handle_t * p_handle, /* IN */ 00171 fsal_path_t * p_path /* OUT */ ); 00172 00173 /* update informations about a handle */ 00174 int fsal_posixdb_UpdateInodeCache(posixfsal_handle_t * p_handle); /* IN */ 00175 00176 /* retrieve last informations about a handle */ 00177 int fsal_posixdb_GetInodeCache(posixfsal_handle_t * p_handle); /* IN/OUT */ 00178 00179 #endif