nfs-ganesha 1.4
Classes | Defines | Typedefs | Enumerations | Functions

handle_mapping_db.c File Reference

#include "config.h"
#include "handle_mapping.h"
#include "handle_mapping_db.h"
#include "handle_mapping_internal.h"
#include "../fsal_internal.h"
#include <sqlite3.h>
#include <sys/types.h>
#include <dirent.h>
#include <fnmatch.h>
#include <pthread.h>

Go to the source code of this file.

Classes

struct  db_op_item__
struct  flusher_queue__
struct  db_thread_info__

Defines

#define CheckTable(_p_conn_, _code_, _msg_str_, _result_)
#define CheckCommand(_p_conn_, _code_, _msg_str_)
#define CheckPrepare(_p_conn_, _code_)
#define CheckBind(_p_conn_, _code_, _stmt_)
#define CheckStep(_p_conn_, _code_, _stmt_)
#define LOAD_ALL_STATEMENT   0
#define INSERT_STATEMENT   1
#define DELETE_STATEMENT   2
#define STATEMENT_COUNT   3

Typedefs

typedef struct db_op_item__ db_op_item_t
typedef struct flusher_queue__ flusher_queue_t
typedef struct db_thread_info__ db_thread_info_t

Enumerations

enum  db_op_type { LOAD = 1, INSERT, DELETE }

Functions

int handlemap_db_count (const char *dir)
unsigned int select_db_queue (const nfs23_map_handle_t *p_nfs23_digest)
int handlemap_db_init (const char *db_dir, const char *tmp_dir, unsigned int db_count, unsigned int nb_dbop_prealloc, int synchronous_insert)
int handlemap_db_reaload_all (hash_table_t *target_hash)
int handlemap_db_insert (nfs23_map_handle_t *p_in_nfs23_digest, fsal_handle_t *p_in_handle)
int handlemap_db_delete (nfs23_map_handle_t *p_in_nfs23_digest)
int handlemap_db_flush ()

Define Documentation

#define CheckBind (   _p_conn_,
  _code_,
  _stmt_ 
)
Value:
do { \
  if ( (_code_) != SQLITE_OK)                                                        \
    {                                                                                \
        LogCrit(COMPONENT_FSAL, "SQLite parameter binding failed in %s line %i", __FUNCTION__, __LINE__); \
        LogCrit(COMPONENT_FSAL, "%s (%d)", sqlite3_errmsg( _p_conn_ ), _code_ ); \
        sqlite3_clear_bindings( _stmt_ ); \
        return HANDLEMAP_DB_ERROR;  \
    }  \
  } while (0)

Definition at line 44 of file handle_mapping_db.c.

#define CheckCommand (   _p_conn_,
  _code_,
  _msg_str_ 
)
Value:
do { \
  if ( (_code_) != SQLITE_OK ) \
    {                                                                             \
        LogCrit(COMPONENT_FSAL, "SQLite command failed in %s line %i", __FUNCTION__, __LINE__); \
        LogCrit(COMPONENT_FSAL, "%s (%d)", (_msg_str_?_msg_str_:sqlite3_errmsg(_p_conn_)), _code_ ); \
        if (_msg_str_) {sqlite3_free( _msg_str_); _msg_str_ = NULL ; } \
        return HANDLEMAP_DB_ERROR;  \
    } \
  } while (0)

Definition at line 25 of file handle_mapping_db.c.

#define CheckPrepare (   _p_conn_,
  _code_ 
)
Value:
do { \
  if ( (_code_) != SQLITE_OK)                        \
    {                                                                             \
        LogCrit(COMPONENT_FSAL, "SQLite prepare statement failed in %s line %i", __FUNCTION__, __LINE__); \
        LogCrit(COMPONENT_FSAL, "%s (%d)", sqlite3_errmsg( _p_conn_ ), _code_ ); \
        return HANDLEMAP_DB_ERROR;  \
    } \
  } while (0)

Definition at line 35 of file handle_mapping_db.c.

#define CheckStep (   _p_conn_,
  _code_,
  _stmt_ 
)
Value:
do { \
  if ( (_code_) != SQLITE_OK  && (_code_) != SQLITE_ROW && (_code_) != SQLITE_DONE ) \
    {                                                                                \
        LogCrit(COMPONENT_FSAL, "SQLite command failed in %s line %i", __FUNCTION__, __LINE__); \
        LogCrit(COMPONENT_FSAL, "%s (%d)", sqlite3_errmsg( _p_conn_ ), _code_ ); \
        sqlite3_reset( _stmt_ );    \
        return HANDLEMAP_DB_ERROR;  \
    }  \
  } while (0)

Definition at line 54 of file handle_mapping_db.c.

#define CheckTable (   _p_conn_,
  _code_,
  _msg_str_,
  _result_ 
)
Value:
do { \
 if ( (_code_) != SQLITE_OK ) \
    {                                                                             \
        LogCrit(COMPONENT_FSAL, "SQLite command failed in %s line %i", __FUNCTION__, __LINE__); \
        LogCrit(COMPONENT_FSAL, "%s (%d)", (_msg_str_?_msg_str_:sqlite3_errmsg(_p_conn_)), _code_ ); \
        if (_msg_str_) { sqlite3_free( _msg_str_); _msg_str_ = NULL; }     \
        if (_result_) { sqlite3_free_table( _result_ ); _result_ = NULL; } \
        return HANDLEMAP_DB_ERROR;  \
    } \
  } while (0)

Definition at line 14 of file handle_mapping_db.c.

#define DELETE_STATEMENT   2

Definition at line 122 of file handle_mapping_db.c.

#define INSERT_STATEMENT   1

Definition at line 121 of file handle_mapping_db.c.

#define LOAD_ALL_STATEMENT   0

Definition at line 120 of file handle_mapping_db.c.

#define STATEMENT_COUNT   3

Definition at line 124 of file handle_mapping_db.c.


Typedef Documentation

typedef struct db_op_item__ db_op_item_t

Enumeration Type Documentation

enum db_op_type
Enumerator:
LOAD 
INSERT 
DELETE 

Definition at line 65 of file handle_mapping_db.c.


Function Documentation

int handlemap_db_count ( const char *  dir)

count the number of database instances in a given directory (this is used for checking that the number of db matches the number of threads)

Definition at line 609 of file handle_mapping_db.c.

int handlemap_db_delete ( nfs23_map_handle_t p_in_nfs23_digest)

Submit a db 'delete' request. The request is inserted in the appropriate db queue. (always asynchronous)

Definition at line 848 of file handle_mapping_db.c.

int handlemap_db_flush ( )

Wait for all queues to be empty and all current DB request to be done.

Definition at line 885 of file handle_mapping_db.c.

int handlemap_db_init ( const char *  db_dir,
const char *  tmp_dir,
unsigned int  db_count,
unsigned int  nb_dbop_prealloc,
int  synchronous_insert 
)

Initialize databases access

  • init DB queues
  • start threads
  • establish DB connections
  • create db schema if it was empty

Todo:
ici coller out_parameter->fs_specific_info.hdlmap_nb_db_op_prealloc

Definition at line 692 of file handle_mapping_db.c.

int handlemap_db_insert ( nfs23_map_handle_t p_in_nfs23_digest,
fsal_handle_t p_in_handle 
)

Submit a db 'insert' request. The request is inserted in the appropriate db queue.

Definition at line 804 of file handle_mapping_db.c.

int handlemap_db_reaload_all ( hash_table_t target_hash)

Gives the order to each DB thread to reload the content of its database and insert it to the hash table. The function blocks until all threads have loaded their data.

Definition at line 760 of file handle_mapping_db.c.

unsigned int select_db_queue ( const nfs23_map_handle_t p_nfs23_digest)

Definition at line 675 of file handle_mapping_db.c.