summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/gfdb
diff options
context:
space:
mode:
authorGluster Ant <bugzilla-bot@gluster.org>2018-09-12 17:22:48 +0530
committerNigel Babu <nigelb@redhat.com>2018-09-12 17:22:48 +0530
commit45a71c0548b6fd2c757aa2e7b7671a1411948894 (patch)
tree2a5a9b73bae47ab53a41166fd041a06612587f48 /libglusterfs/src/gfdb
parentbe77dbbda692792335a8e9e7c02e0c281f003c40 (diff)
Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
Diffstat (limited to 'libglusterfs/src/gfdb')
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store.h230
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store_helper.h73
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store_types.h554
-rw-r--r--libglusterfs/src/gfdb/gfdb_mem-types.h7
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.h423
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3_helper.h32
6 files changed, 580 insertions, 739 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_data_store.h b/libglusterfs/src/gfdb/gfdb_data_store.h
index 93bdda813a9..59f7bd01ab3 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store.h
@@ -10,7 +10,6 @@
#ifndef __GFDB_DATA_STORE_H
#define __GFDB_DATA_STORE_H
-
#include "glusterfs.h"
#include "xlator.h"
#include "logging.h"
@@ -32,9 +31,6 @@
* */
typedef struct gfdb_conn_node_t gfdb_conn_node_t;
-
-
-
/*Libgfdb API Function: Used to initialize db connection
* Arguments:
* args : Dictionary containing database specific parameters
@@ -46,11 +42,8 @@ typedef struct gfdb_conn_node_t gfdb_conn_node_t;
gfdb_conn_node_t *
init_db(dict_t *arg, gfdb_db_type_t db_type);
-typedef gfdb_conn_node_t * (*init_db_t) (dict_t *args,
- gfdb_db_type_t gfdb_db_type);
-
-
-
+typedef gfdb_conn_node_t *(*init_db_t)(dict_t *args,
+ gfdb_db_type_t gfdb_db_type);
/*Libgfdb API Function: Used to terminate/de-initialize db connection
* (Destructor function for db connection object)
@@ -61,9 +54,7 @@ typedef gfdb_conn_node_t * (*init_db_t) (dict_t *args,
int
fini_db(gfdb_conn_node_t *);
-typedef int (*fini_db_t) (gfdb_conn_node_t *_conn_node);
-
-
+typedef int (*fini_db_t)(gfdb_conn_node_t *_conn_node);
/*Libgfdb API Function: Used to insert/updated records in the database
* NOTE: In current gfdb_sqlite plugin we use that
@@ -83,9 +74,6 @@ typedef int (*fini_db_t) (gfdb_conn_node_t *_conn_node);
int
insert_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
-
-
-
/*Libgfdb API Function: Used to delete record from the database
* NOTE: In the current gfdb_sqlite3 plugin
* implementation this function is dummy.
@@ -99,10 +87,6 @@ insert_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
int
delete_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
-
-
-
-
/*Libgfdb API Function: Query all the records from the database
* Arguments:
* _conn_node : GFDB Connection node
@@ -116,17 +100,13 @@ delete_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
*
* Returns : if successful return 0 or
* -ve value in case of failure*/
-int find_all(gfdb_conn_node_t *, gf_query_callback_t query_callback,
- void *_query_cbk_args,
- int query_limit);
-
-typedef int (*find_all_t) (gfdb_conn_node_t *,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- int query_limit);
-
-
+int
+find_all(gfdb_conn_node_t *, gf_query_callback_t query_callback,
+ void *_query_cbk_args, int query_limit);
+typedef int (*find_all_t)(gfdb_conn_node_t *,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args, int query_limit);
/*Libgfdb API Function: Query records/files that have not changed/accessed
* from a time in past to current time
@@ -140,17 +120,14 @@ typedef int (*find_all_t) (gfdb_conn_node_t *,
* changed/accessed
* Returns : if successful return 0 or
* -ve value in case of failure*/
-int find_unchanged_for_time(gfdb_conn_node_t *,
- gf_query_callback_t query_callback,
+int
+find_unchanged_for_time(gfdb_conn_node_t *, gf_query_callback_t query_callback,
void *_query_cbk_args, gfdb_time_t *for_time);
-typedef int (*find_unchanged_for_time_t) (gfdb_conn_node_t *_conn_node,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *for_time);
-
-
-
+typedef int (*find_unchanged_for_time_t)(gfdb_conn_node_t *_conn_node,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *for_time);
/*Libgfdb API Function: Query records/files that have changed/accessed from a
* time in past to current time
@@ -164,17 +141,15 @@ typedef int (*find_unchanged_for_time_t) (gfdb_conn_node_t *_conn_node,
* changed/accessed
* Returns : if successful return 0 or
* -ve value in case of failure*/
-int find_recently_changed_files(gfdb_conn_node_t *_conn,
- gf_query_callback_t query_callback, void *_query_cbk_args,
- gfdb_time_t *from_time);
-
-typedef int (*find_recently_changed_files_t) (gfdb_conn_node_t *_conn_node,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *from_time);
-
-
+int
+find_recently_changed_files(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *from_time);
+typedef int (*find_recently_changed_files_t)(gfdb_conn_node_t *_conn_node,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *from_time);
/*Libgfdb API Function: Query records/files that have not changed/accessed
* from a time in past to current time, with
@@ -193,24 +168,17 @@ typedef int (*find_recently_changed_files_t) (gfdb_conn_node_t *_conn_node,
* all files.
* Returns : if successful return 0 or
* -ve value in case of failure*/
-int find_unchanged_for_time_freq(gfdb_conn_node_t *_conn,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *for_time,
- int write_freq_thresold,
- int read_freq_thresold,
- gf_boolean_t _clear_counters);
-
-typedef int (*find_unchanged_for_time_freq_t) (gfdb_conn_node_t *_conn_node,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *for_time,
- int write_freq_thresold,
- int read_freq_thresold,
- gf_boolean_t _clear_counters);
-
-
+int
+find_unchanged_for_time_freq(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *for_time,
+ int write_freq_thresold, int read_freq_thresold,
+ gf_boolean_t _clear_counters);
+typedef int (*find_unchanged_for_time_freq_t)(
+ gfdb_conn_node_t *_conn_node, gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *for_time, int write_freq_thresold,
+ int read_freq_thresold, gf_boolean_t _clear_counters);
/*Libgfdb API Function: Query records/files that have changed/accessed from a
* time in past to current time, with
@@ -229,24 +197,20 @@ typedef int (*find_unchanged_for_time_freq_t) (gfdb_conn_node_t *_conn_node,
* all files.
* Returns : if successful return 0 or
* -ve value in case of failure*/
-int find_recently_changed_files_freq(gfdb_conn_node_t *_conn,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *from_time,
- int write_freq_thresold,
- int read_freq_thresold,
- gf_boolean_t _clear_counters);
-
-typedef int (*find_recently_changed_files_freq_t) (gfdb_conn_node_t *_conn_node,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *from_time,
- int write_freq_thresold,
- int read_freq_thresold,
- gf_boolean_t _clear_counters);
-
-typedef const
-char *(*get_db_path_key_t)();
+int
+find_recently_changed_files_freq(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *from_time,
+ int write_freq_thresold,
+ int read_freq_thresold,
+ gf_boolean_t _clear_counters);
+
+typedef int (*find_recently_changed_files_freq_t)(
+ gfdb_conn_node_t *_conn_node, gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *from_time, int write_freq_thresold,
+ int read_freq_thresold, gf_boolean_t _clear_counters);
+
+typedef const char *(*get_db_path_key_t)();
/*Libgfdb API Function: Clear the heat for all the files
*
@@ -257,11 +221,9 @@ char *(*get_db_path_key_t)();
* -ve value in case of failure
**/
int
-clear_files_heat (gfdb_conn_node_t *_conn_node);
-
-typedef int (*clear_files_heat_t) (gfdb_conn_node_t *_conn_node);
-
+clear_files_heat(gfdb_conn_node_t *_conn_node);
+typedef int (*clear_files_heat_t)(gfdb_conn_node_t *_conn_node);
/* Libgfdb API Function: Function to extract version of the db
* Arguments:
@@ -275,11 +237,9 @@ typedef int (*clear_files_heat_t) (gfdb_conn_node_t *_conn_node);
* On failure return -1
* */
int
-get_db_version (gfdb_conn_node_t *_conn_node, char **version);
-
-typedef int (*get_db_version_t)(gfdb_conn_node_t *_conn_node,
- char **version);
+get_db_version(gfdb_conn_node_t *_conn_node, char **version);
+typedef int (*get_db_version_t)(gfdb_conn_node_t *_conn_node, char **version);
/* Libgfdb API Function: Function to extract param from the db
* Arguments:
@@ -294,14 +254,11 @@ typedef int (*get_db_version_t)(gfdb_conn_node_t *_conn_node,
* On failure return -1
* */
int
-get_db_params (gfdb_conn_node_t *_conn_node,
- char *param_key,
- char **param_value);
-
-typedef int (*get_db_params_t)(gfdb_conn_node_t *db_conn,
- char *param_key,
- char **param_value);
+get_db_params(gfdb_conn_node_t *_conn_node, char *param_key,
+ char **param_value);
+typedef int (*get_db_params_t)(gfdb_conn_node_t *db_conn, char *param_key,
+ char **param_value);
/* Libgfdb API Function: Function to set db params
* Arguments:
@@ -313,13 +270,10 @@ typedef int (*get_db_params_t)(gfdb_conn_node_t *db_conn,
* On failure return -1
* */
int
-set_db_params (gfdb_conn_node_t *_conn_node,
- char *param_key,
- char *param_value);
+set_db_params(gfdb_conn_node_t *_conn_node, char *param_key, char *param_value);
-typedef int (*set_db_params_t)(gfdb_conn_node_t *db_conn,
- char *param_key,
- char *param_value);
+typedef int (*set_db_params_t)(gfdb_conn_node_t *db_conn, char *param_key,
+ char *param_value);
/*Libgfdb API Function: Compact the database.
*
@@ -330,48 +284,48 @@ typedef int (*set_db_params_t)(gfdb_conn_node_t *db_conn,
* Returns : if successful return 0 or
* -ve value in case of failure*/
int
-compact_db (gfdb_conn_node_t *_conn_node, gf_boolean_t _compact_active,
- gf_boolean_t _compact_mode_switched);
+compact_db(gfdb_conn_node_t *_conn_node, gf_boolean_t _compact_active,
+ gf_boolean_t _compact_mode_switched);
typedef int (*compact_db_t)(gfdb_conn_node_t *db_conn,
gf_boolean_t compact_active,
gf_boolean_t compact_mode_switched);
-
typedef struct gfdb_methods_s {
- init_db_t init_db;
- fini_db_t fini_db;
- find_all_t find_all;
- find_unchanged_for_time_t find_unchanged_for_time;
- find_recently_changed_files_t find_recently_changed_files;
- find_unchanged_for_time_freq_t find_unchanged_for_time_freq;
- find_recently_changed_files_freq_t find_recently_changed_files_freq;
- clear_files_heat_t clear_files_heat;
- get_db_version_t get_db_version;
- get_db_params_t get_db_params;
- set_db_params_t set_db_params;
- /* Do not expose dbpath directly. Expose it via an */
- /* access function: get_db_path_key(). */
- char *dbpath;
- get_db_path_key_t get_db_path_key;
-
- /* Query Record related functions */
- gfdb_query_record_new_t gfdb_query_record_new;
- gfdb_query_record_free_t gfdb_query_record_free;
- gfdb_add_link_to_query_record_t gfdb_add_link_to_query_record;
- gfdb_write_query_record_t gfdb_write_query_record;
- gfdb_read_query_record_t gfdb_read_query_record;
-
- /* Link info related functions */
- gfdb_link_info_new_t gfdb_link_info_new;
- gfdb_link_info_free_t gfdb_link_info_free;
-
- /* Compaction related functions */
- compact_db_t compact_db;
+ init_db_t init_db;
+ fini_db_t fini_db;
+ find_all_t find_all;
+ find_unchanged_for_time_t find_unchanged_for_time;
+ find_recently_changed_files_t find_recently_changed_files;
+ find_unchanged_for_time_freq_t find_unchanged_for_time_freq;
+ find_recently_changed_files_freq_t find_recently_changed_files_freq;
+ clear_files_heat_t clear_files_heat;
+ get_db_version_t get_db_version;
+ get_db_params_t get_db_params;
+ set_db_params_t set_db_params;
+ /* Do not expose dbpath directly. Expose it via an */
+ /* access function: get_db_path_key(). */
+ char *dbpath;
+ get_db_path_key_t get_db_path_key;
+
+ /* Query Record related functions */
+ gfdb_query_record_new_t gfdb_query_record_new;
+ gfdb_query_record_free_t gfdb_query_record_free;
+ gfdb_add_link_to_query_record_t gfdb_add_link_to_query_record;
+ gfdb_write_query_record_t gfdb_write_query_record;
+ gfdb_read_query_record_t gfdb_read_query_record;
+
+ /* Link info related functions */
+ gfdb_link_info_new_t gfdb_link_info_new;
+ gfdb_link_info_free_t gfdb_link_info_free;
+
+ /* Compaction related functions */
+ compact_db_t compact_db;
} gfdb_methods_t;
-void get_gfdb_methods (gfdb_methods_t *methods);
+void
+get_gfdb_methods(gfdb_methods_t *methods);
-typedef void (*get_gfdb_methods_t) (gfdb_methods_t *methods);
+typedef void (*get_gfdb_methods_t)(gfdb_methods_t *methods);
#endif
diff --git a/libglusterfs/src/gfdb/gfdb_data_store_helper.h b/libglusterfs/src/gfdb/gfdb_data_store_helper.h
index 7e81aab08a6..7b4b0ae6aa1 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store_helper.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store_helper.h
@@ -22,8 +22,7 @@
#include "byte-order.h"
#include "libglusterfs-messages.h"
-
-#define GFDB_DATA_STORE "gfdbdatastore"
+#define GFDB_DATA_STORE "gfdbdatastore"
/*******************************************************************************
*
@@ -39,71 +38,50 @@
/*Structure to hold the link information*/
typedef struct gfdb_link_info {
- uuid_t pargfid;
- char file_name[GF_NAME_MAX];
- struct list_head list;
+ uuid_t pargfid;
+ char file_name[GF_NAME_MAX];
+ struct list_head list;
} gfdb_link_info_t;
-
/*Structure used for querying purpose*/
typedef struct gfdb_query_record {
- uuid_t gfid;
- /*This is the hardlink list*/
- struct list_head link_list;
- int link_count;
+ uuid_t gfid;
+ /*This is the hardlink list*/
+ struct list_head link_list;
+ int link_count;
} gfdb_query_record_t;
/*Create a single link info structure*/
-gfdb_link_info_t *gfdb_link_info_new ();
-typedef gfdb_link_info_t *(*gfdb_link_info_new_t) ();
+gfdb_link_info_t *
+gfdb_link_info_new();
+typedef gfdb_link_info_t *(*gfdb_link_info_new_t)();
/*Destroy a link info structure*/
void
-gfdb_link_info_free (gfdb_link_info_t *gfdb_link_info);
-typedef void
-(*gfdb_link_info_free_t) (gfdb_link_info_t *gfdb_link_info);
+gfdb_link_info_free(gfdb_link_info_t *gfdb_link_info);
+typedef void (*gfdb_link_info_free_t)(gfdb_link_info_t *gfdb_link_info);
/* Function to create the query_record */
gfdb_query_record_t *
gfdb_query_record_new();
-typedef gfdb_query_record_t *
-(*gfdb_query_record_new_t)();
-
-
-
+typedef gfdb_query_record_t *(*gfdb_query_record_new_t)();
/* Function to add linkinfo to query record */
int
-gfdb_add_link_to_query_record (gfdb_query_record_t *gfdb_query_record,
- uuid_t pgfid,
- char *base_name);
-typedef int
-(*gfdb_add_link_to_query_record_t) (gfdb_query_record_t *, uuid_t, char *);
-
-
-
+gfdb_add_link_to_query_record(gfdb_query_record_t *gfdb_query_record,
+ uuid_t pgfid, char *base_name);
+typedef int (*gfdb_add_link_to_query_record_t)(gfdb_query_record_t *, uuid_t,
+ char *);
/*Function to destroy query record*/
void
-gfdb_query_record_free (gfdb_query_record_t *gfdb_query_record);
-typedef void
-(*gfdb_query_record_free_t) (gfdb_query_record_t *);
-
-
-
-
-
+gfdb_query_record_free(gfdb_query_record_t *gfdb_query_record);
+typedef void (*gfdb_query_record_free_t)(gfdb_query_record_t *);
/* Function to write query record to file */
int
-gfdb_write_query_record (int fd,
- gfdb_query_record_t *gfdb_query_record);
-typedef int
-(*gfdb_write_query_record_t) (int, gfdb_query_record_t *);
-
-
-
-
+gfdb_write_query_record(int fd, gfdb_query_record_t *gfdb_query_record);
+typedef int (*gfdb_write_query_record_t)(int, gfdb_query_record_t *);
/* Function to read query record from file.
* Allocates memory to query record and return 0 when successful
@@ -111,10 +89,7 @@ typedef int
* Return 0 when EOF.
* */
int
-gfdb_read_query_record (int fd,
- gfdb_query_record_t **gfdb_query_record);
-typedef int
-(*gfdb_read_query_record_t) (int, gfdb_query_record_t **);
-
+gfdb_read_query_record(int fd, gfdb_query_record_t **gfdb_query_record);
+typedef int (*gfdb_read_query_record_t)(int, gfdb_query_record_t **);
#endif \ No newline at end of file
diff --git a/libglusterfs/src/gfdb/gfdb_data_store_types.h b/libglusterfs/src/gfdb/gfdb_data_store_types.h
index f20ae4ded78..5ee050d4fab 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store_types.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store_types.h
@@ -16,70 +16,67 @@
* Helps in dynamically choosing log level
* */
static inline gf_loglevel_t
-_gfdb_log_level (gf_loglevel_t given_level,
- gf_boolean_t ignore_level)
+_gfdb_log_level(gf_loglevel_t given_level, gf_boolean_t ignore_level)
{
- return (ignore_level) ? GF_LOG_DEBUG : given_level;
+ return (ignore_level) ? GF_LOG_DEBUG : given_level;
}
typedef enum gf_db_operation {
- GFDB_INVALID_DB_OP = -1,
- /* Query DB OPS : All the Query DB_OP should be added */
- /* in between START and END */
- GFDB_QUERY_DB_OP_START, /* Start of Query DB_OP */
- GFDB_QUERY_DB_OP,
- GF_FTABLE_EXISTS_DB_OP,
- GFDB_QUERY_DB_OP_END, /* End of Query DB_OP */
- /* Non-Query DB OPS */
- GFDB_DB_CREATE_DB_OP,
- GFDB_GFID_EXIST_DB_OP,
- GFDB_W_INSERT_DB_OP,
- GFDB_WU_INSERT_DB_OP,
- GFDB_W_UPDATE_DB_OP,
- GFDB_WU_UPDATE_DB_OP,
- GFDB_W_DELETE_DB_OP,
- GFDB_UW_DELETE_DB_OP,
- GFDB_WFC_UPDATE_DB_OP,
- GFDB_RFC_UPDATE_DB_OP,
- GFDB_DB_COMPACT_DB_OP /* Added for VACUUM/manual compaction support */
+ GFDB_INVALID_DB_OP = -1,
+ /* Query DB OPS : All the Query DB_OP should be added */
+ /* in between START and END */
+ GFDB_QUERY_DB_OP_START, /* Start of Query DB_OP */
+ GFDB_QUERY_DB_OP,
+ GF_FTABLE_EXISTS_DB_OP,
+ GFDB_QUERY_DB_OP_END, /* End of Query DB_OP */
+ /* Non-Query DB OPS */
+ GFDB_DB_CREATE_DB_OP,
+ GFDB_GFID_EXIST_DB_OP,
+ GFDB_W_INSERT_DB_OP,
+ GFDB_WU_INSERT_DB_OP,
+ GFDB_W_UPDATE_DB_OP,
+ GFDB_WU_UPDATE_DB_OP,
+ GFDB_W_DELETE_DB_OP,
+ GFDB_UW_DELETE_DB_OP,
+ GFDB_WFC_UPDATE_DB_OP,
+ GFDB_RFC_UPDATE_DB_OP,
+ GFDB_DB_COMPACT_DB_OP /* Added for VACUUM/manual compaction support */
} gf_db_operation_t;
-
-#define GF_COL_MAX_NUM 2
-#define GF_COL_ALL " * "
+#define GF_COL_MAX_NUM 2
+#define GF_COL_ALL " * "
/* Column/fields names used in the DB.
* If any new field is added should be updated here*/
-#define GF_COL_GF_ID "GF_ID"
-#define GF_COL_GF_PID "GF_PID"
-#define GF_COL_FILE_NAME "FNAME"
-#define GF_COL_WSEC "W_SEC"
-#define GF_COL_WMSEC "W_MSEC"
-#define GF_COL_UWSEC "UW_SEC"
-#define GF_COL_UWMSEC "UW_MSEC"
-#define GF_COL_WSEC_READ "W_READ_SEC"
-#define GF_COL_WMSEC_READ "W_READ_MSEC"
-#define GF_COL_UWSEC_READ "UW_READ_SEC"
-#define GF_COL_UWMSEC_READ "UW_READ_MSEC"
-#define GF_COL_WDEL_FLAG "W_DEL_FLAG"
-#define GF_COL_WRITE_FREQ_CNTR "WRITE_FREQ_CNTR"
-#define GF_COL_READ_FREQ_CNTR "READ_FREQ_CNTR"
-#define GF_COL_LINK_UPDATE "LINK_UPDATE"
-
+#define GF_COL_GF_ID "GF_ID"
+#define GF_COL_GF_PID "GF_PID"
+#define GF_COL_FILE_NAME "FNAME"
+#define GF_COL_WSEC "W_SEC"
+#define GF_COL_WMSEC "W_MSEC"
+#define GF_COL_UWSEC "UW_SEC"
+#define GF_COL_UWMSEC "UW_MSEC"
+#define GF_COL_WSEC_READ "W_READ_SEC"
+#define GF_COL_WMSEC_READ "W_READ_MSEC"
+#define GF_COL_UWSEC_READ "UW_READ_SEC"
+#define GF_COL_UWMSEC_READ "UW_READ_MSEC"
+#define GF_COL_WDEL_FLAG "W_DEL_FLAG"
+#define GF_COL_WRITE_FREQ_CNTR "WRITE_FREQ_CNTR"
+#define GF_COL_READ_FREQ_CNTR "READ_FREQ_CNTR"
+#define GF_COL_LINK_UPDATE "LINK_UPDATE"
/***********************Time related********************************/
/*1 sec = 1000000 microsec*/
-#define GFDB_MICROSEC 1000000
+#define GFDB_MICROSEC 1000000
/*All the gfdb times are represented using this structure*/
-typedef struct timeval gfdb_time_t;
+typedef struct timeval gfdb_time_t;
/*Convert time into seconds*/
static inline uint64_t
gfdb_time_2_usec(gfdb_time_t *gfdb_time)
{
- GF_ASSERT(gfdb_time);
- return ((uint64_t) gfdb_time->tv_sec * GFDB_MICROSEC) + gfdb_time->tv_usec;
+ GF_ASSERT(gfdb_time);
+ return ((uint64_t)gfdb_time->tv_sec * GFDB_MICROSEC) + gfdb_time->tv_usec;
}
/******************************************************************************
@@ -91,82 +88,82 @@ gfdb_time_2_usec(gfdb_time_t *gfdb_time)
/*Indicated a generic synchronous write to the db
* This may or may not be implemented*/
typedef enum gfdb_sync_type {
- GFDB_INVALID_SYNC = -1,
- GFDB_DB_ASYNC,
- GFDB_DB_SYNC
+ GFDB_INVALID_SYNC = -1,
+ GFDB_DB_ASYNC,
+ GFDB_DB_SYNC
} gfdb_sync_type_t;
/*Strings related to the abvove sync type*/
-#define GFDB_STR_DB_ASYNC "async"
-#define GFDB_STR_DB_SYNC "sync"
+#define GFDB_STR_DB_ASYNC "async"
+#define GFDB_STR_DB_SYNC "sync"
/*To convert sync type from string to gfdb_sync_type_t*/
static inline int
-gf_string2gfdbdbsync (char *sync_option)
+gf_string2gfdbdbsync(char *sync_option)
{
- int ret = -1;
-
- if (!sync_option)
- goto out;
- if (strcmp(sync_option, GFDB_STR_DB_ASYNC) == 0) {
- ret = GFDB_DB_ASYNC;
- } else if (strcmp(sync_option, GFDB_STR_DB_SYNC) == 0) {
- ret = GFDB_DB_SYNC;
- }
+ int ret = -1;
+
+ if (!sync_option)
+ goto out;
+ if (strcmp(sync_option, GFDB_STR_DB_ASYNC) == 0) {
+ ret = GFDB_DB_ASYNC;
+ } else if (strcmp(sync_option, GFDB_STR_DB_SYNC) == 0) {
+ ret = GFDB_DB_SYNC;
+ }
out:
- return ret;
+ return ret;
}
/*Indicated different types of db*/
typedef enum gfdb_db_type {
- GFDB_INVALID_DB = -1,
- GFDB_HASH_FILE_STORE,
- GFDB_ROCKS_DB,
- GFDB_SQLITE3,
- GFDB_HYPERDEX,
- GFDB_DB_END /*Add DB type Entries above this only*/
+ GFDB_INVALID_DB = -1,
+ GFDB_HASH_FILE_STORE,
+ GFDB_ROCKS_DB,
+ GFDB_SQLITE3,
+ GFDB_HYPERDEX,
+ GFDB_DB_END /*Add DB type Entries above this only*/
} gfdb_db_type_t;
/*String related to the db types*/
-#define GFDB_STR_HASH_FILE_STORE "hashfile"
-#define GFDB_STR_ROCKS_DB "rocksdb"
-#define GFDB_STR_SQLITE3 "sqlite3"
-#define GFDB_STR_HYPERDEX "hyperdex"
+#define GFDB_STR_HASH_FILE_STORE "hashfile"
+#define GFDB_STR_ROCKS_DB "rocksdb"
+#define GFDB_STR_SQLITE3 "sqlite3"
+#define GFDB_STR_HYPERDEX "hyperdex"
/*Convert db type in string to gfdb_db_type_t*/
static inline int
-gf_string2gfdbdbtype (char *db_option)
+gf_string2gfdbdbtype(char *db_option)
{
- int ret = -1;
-
- if (!db_option)
- goto out;
- if (strcmp(db_option, GFDB_STR_HASH_FILE_STORE) == 0) {
- ret = GFDB_HASH_FILE_STORE;
- } else if (strcmp(db_option, GFDB_STR_ROCKS_DB) == 0) {
- ret = GFDB_ROCKS_DB;
- } else if (strcmp(db_option, GFDB_STR_SQLITE3) == 0) {
- ret = GFDB_SQLITE3;
- } else if (strcmp(db_option, GFDB_STR_HYPERDEX) == 0) {
- ret = GFDB_HYPERDEX;
- }
+ int ret = -1;
+
+ if (!db_option)
+ goto out;
+ if (strcmp(db_option, GFDB_STR_HASH_FILE_STORE) == 0) {
+ ret = GFDB_HASH_FILE_STORE;
+ } else if (strcmp(db_option, GFDB_STR_ROCKS_DB) == 0) {
+ ret = GFDB_ROCKS_DB;
+ } else if (strcmp(db_option, GFDB_STR_SQLITE3) == 0) {
+ ret = GFDB_SQLITE3;
+ } else if (strcmp(db_option, GFDB_STR_HYPERDEX) == 0) {
+ ret = GFDB_HYPERDEX;
+ }
out:
- return ret;
+ return ret;
}
/*Tells the path of the fop*/
typedef enum gfdb_fop_path {
- GFDB_FOP_INVALID = -1,
- /*Filler value for zero*/
- GFDB_FOP_PATH_ZERO = 0,
- /*have wind path below this*/
- GFDB_FOP_WIND = 1,
- GFDB_FOP_WDEL = 2,
- /*have unwind path below this*/
- GFDB_FOP_UNWIND = 4,
- /*Delete unwind path*/
- GFDB_FOP_UNDEL = 8,
- GFDB_FOP_UNDEL_ALL = 16
+ GFDB_FOP_INVALID = -1,
+ /*Filler value for zero*/
+ GFDB_FOP_PATH_ZERO = 0,
+ /*have wind path below this*/
+ GFDB_FOP_WIND = 1,
+ GFDB_FOP_WDEL = 2,
+ /*have unwind path below this*/
+ GFDB_FOP_UNWIND = 4,
+ /*Delete unwind path*/
+ GFDB_FOP_UNDEL = 8,
+ GFDB_FOP_UNDEL_ALL = 16
} gfdb_fop_path_t;
/*Strings related to the above fop path*/
#define GFDB_STR_FOP_INVALID "INVALID"
@@ -178,107 +175,104 @@ typedef enum gfdb_fop_path {
static inline gf_boolean_t
iswindpath(gfdb_fop_path_t gfdb_fop_path)
{
- return ((gfdb_fop_path == GFDB_FOP_WIND) ||
- (gfdb_fop_path == GFDB_FOP_WDEL)) ?
- _gf_true : _gf_false;
+ return ((gfdb_fop_path == GFDB_FOP_WIND) ||
+ (gfdb_fop_path == GFDB_FOP_WDEL))
+ ? _gf_true
+ : _gf_false;
}
static inline gf_boolean_t
isunwindpath(gfdb_fop_path_t gfdb_fop_path)
{
- return (gfdb_fop_path >= GFDB_FOP_UNWIND) ? _gf_true : _gf_false;
+ return (gfdb_fop_path >= GFDB_FOP_UNWIND) ? _gf_true : _gf_false;
}
/*Tell what type of fop it was
* Like whether a dentry fop or a inode fop
* Read fop or a write fop etc*/
typedef enum gfdb_fop_type {
- GFDB_FOP_INVALID_OP = -1,
- /*Filler value for zero*/
- GFDB_FOP_TYPE_ZERO = 0,
- GFDB_FOP_DENTRY_OP = 1,
- GFDB_FOP_DENTRY_CREATE_OP = 2,
- GFDB_FOP_INODE_OP = 4,
- GFDB_FOP_WRITE_OP = 8,
- GFDB_FOP_READ_OP = 16
+ GFDB_FOP_INVALID_OP = -1,
+ /*Filler value for zero*/
+ GFDB_FOP_TYPE_ZERO = 0,
+ GFDB_FOP_DENTRY_OP = 1,
+ GFDB_FOP_DENTRY_CREATE_OP = 2,
+ GFDB_FOP_INODE_OP = 4,
+ GFDB_FOP_WRITE_OP = 8,
+ GFDB_FOP_READ_OP = 16
} gfdb_fop_type_t;
-#define GFDB_FOP_INODE_WRITE\
- (GFDB_FOP_INODE_OP | GFDB_FOP_WRITE_OP)
+#define GFDB_FOP_INODE_WRITE (GFDB_FOP_INODE_OP | GFDB_FOP_WRITE_OP)
-#define GFDB_FOP_DENTRY_WRITE\
- (GFDB_FOP_DENTRY_OP | GFDB_FOP_WRITE_OP)
+#define GFDB_FOP_DENTRY_WRITE (GFDB_FOP_DENTRY_OP | GFDB_FOP_WRITE_OP)
-#define GFDB_FOP_CREATE_WRITE\
- (GFDB_FOP_DENTRY_CREATE_OP | GFDB_FOP_WRITE_OP)
+#define GFDB_FOP_CREATE_WRITE (GFDB_FOP_DENTRY_CREATE_OP | GFDB_FOP_WRITE_OP)
-#define GFDB_FOP_INODE_READ\
- (GFDB_FOP_INODE_OP | GFDB_FOP_READ_OP)
+#define GFDB_FOP_INODE_READ (GFDB_FOP_INODE_OP | GFDB_FOP_READ_OP)
static inline gf_boolean_t
isreadfop(gfdb_fop_type_t fop_type)
{
- return (fop_type & GFDB_FOP_READ_OP) ? _gf_true : _gf_false;
+ return (fop_type & GFDB_FOP_READ_OP) ? _gf_true : _gf_false;
}
static inline gf_boolean_t
isdentryfop(gfdb_fop_type_t fop_type)
{
- return ((fop_type & GFDB_FOP_DENTRY_OP) ||
- (fop_type & GFDB_FOP_DENTRY_CREATE_OP)) ? _gf_true : _gf_false;
+ return ((fop_type & GFDB_FOP_DENTRY_OP) ||
+ (fop_type & GFDB_FOP_DENTRY_CREATE_OP))
+ ? _gf_true
+ : _gf_false;
}
static inline gf_boolean_t
isdentrycreatefop(gfdb_fop_type_t fop_type)
{
- return (fop_type & GFDB_FOP_DENTRY_CREATE_OP) ?
- _gf_true : _gf_false;
+ return (fop_type & GFDB_FOP_DENTRY_CREATE_OP) ? _gf_true : _gf_false;
}
/*The structure that is used to send insert/update the databases
* using insert_db api*/
typedef struct gfdb_db_record {
- /* GFID */
- uuid_t gfid;
- /* Used during a rename refer ctr_rename() in changetimerecorder
- * xlator*/
- uuid_t old_gfid;
- /* Parent GFID */
- uuid_t pargfid;
- uuid_t old_pargfid;
- /* File names */
- char file_name[GF_NAME_MAX + 1];
- char old_file_name[GF_NAME_MAX + 1];
- /* FOP type and FOP path*/
- gfdb_fop_type_t gfdb_fop_type;
- gfdb_fop_path_t gfdb_fop_path;
- /*Time of change or access*/
- gfdb_time_t gfdb_wind_change_time;
- gfdb_time_t gfdb_unwind_change_time;
- /* For crash consistency while inserting/updating hard links */
- gf_boolean_t islinkupdate;
- /* For link consistency we do a double update i.e mark the link
- * during the wind and during the unwind we update/delete the link.
- * This has a performance hit. We give a choice here whether we need
- * link consistency to be spoton or not using link_consistency flag.
- * This will have only one link update */
- gf_boolean_t link_consistency;
- /* For dentry fops we can choose to ignore recording of unwind time */
- /* For inode fops "record_exit" volume option does the trick, */
- /* but for dentry fops we update the LINK_UPDATE, so an extra */
- /* flag is provided to ignore the recording of the unwind time. */
- gf_boolean_t do_record_uwind_time;
- /* Global flag to record or not record counters */
- gf_boolean_t do_record_counters;
- /* Global flag to Record/Not Record wind or wind time.
- * This flag will overrule do_record_uwind_time*/
- gf_boolean_t do_record_times;
- /* Ignoring errors while inserting.
- * */
- gf_boolean_t ignore_errors;
+ /* GFID */
+ uuid_t gfid;
+ /* Used during a rename refer ctr_rename() in changetimerecorder
+ * xlator*/
+ uuid_t old_gfid;
+ /* Parent GFID */
+ uuid_t pargfid;
+ uuid_t old_pargfid;
+ /* File names */
+ char file_name[GF_NAME_MAX + 1];
+ char old_file_name[GF_NAME_MAX + 1];
+ /* FOP type and FOP path*/
+ gfdb_fop_type_t gfdb_fop_type;
+ gfdb_fop_path_t gfdb_fop_path;
+ /*Time of change or access*/
+ gfdb_time_t gfdb_wind_change_time;
+ gfdb_time_t gfdb_unwind_change_time;
+ /* For crash consistency while inserting/updating hard links */
+ gf_boolean_t islinkupdate;
+ /* For link consistency we do a double update i.e mark the link
+ * during the wind and during the unwind we update/delete the link.
+ * This has a performance hit. We give a choice here whether we need
+ * link consistency to be spoton or not using link_consistency flag.
+ * This will have only one link update */
+ gf_boolean_t link_consistency;
+ /* For dentry fops we can choose to ignore recording of unwind time */
+ /* For inode fops "record_exit" volume option does the trick, */
+ /* but for dentry fops we update the LINK_UPDATE, so an extra */
+ /* flag is provided to ignore the recording of the unwind time. */
+ gf_boolean_t do_record_uwind_time;
+ /* Global flag to record or not record counters */
+ gf_boolean_t do_record_counters;
+ /* Global flag to Record/Not Record wind or wind time.
+ * This flag will overrule do_record_uwind_time*/
+ gf_boolean_t do_record_times;
+ /* Ignoring errors while inserting.
+ * */
+ gf_boolean_t ignore_errors;
} gfdb_db_record_t;
-
/*******************************************************************************
*
* Signatures for the plugin functions
@@ -289,8 +283,7 @@ typedef struct gfdb_db_record {
* ****************************************************************************/
/*Call back function for querying the database*/
-typedef int
-(*gf_query_callback_t)(gfdb_query_record_t *, void *);
+typedef int (*gf_query_callback_t)(gfdb_query_record_t *, void *);
/* Used to initialize db connection
* Arguments:
@@ -301,11 +294,7 @@ typedef int
* If call is unsuccessful will have NULL.
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_init_db_t)(dict_t *args, void **db_conn);
-
-
-
+typedef int (*gfdb_init_db_t)(dict_t *args, void **db_conn);
/* Used to terminate/de-initialize db connection
* (Destructor function for db connection object)
@@ -313,11 +302,7 @@ typedef int
* db_conn : plugin specific data base connection
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_fini_db_t)(void **db_conn);
-
-
-
+typedef int (*gfdb_fini_db_t)(void **db_conn);
/*Used to insert/updated records in the database
* Arguments:
@@ -325,12 +310,7 @@ typedef int
* gfdb_db_record : Record to be inserted/updated
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_insert_record_t)(void *db_conn,
- gfdb_db_record_t *db_record);
-
-
-
+typedef int (*gfdb_insert_record_t)(void *db_conn, gfdb_db_record_t *db_record);
/*Used to delete record from the database
* Arguments:
@@ -338,12 +318,7 @@ typedef int
* gfdb_db_record : Record to be deleted
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_delete_record_t)(void *db_conn,
- gfdb_db_record_t *db_record);
-
-
-
+typedef int (*gfdb_delete_record_t)(void *db_conn, gfdb_db_record_t *db_record);
/*Used to compact the database
* Arguments:
@@ -352,12 +327,8 @@ typedef int
* compact_mode_switched : Was the compaction switch flipped?
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_compact_db_t)(void *db_conn, gf_boolean_t compact_active,
- gf_boolean_t compact_mode_switched);
-
-
-
+typedef int (*gfdb_compact_db_t)(void *db_conn, gf_boolean_t compact_active,
+ gf_boolean_t compact_mode_switched);
/* Query all the records from the database
* Arguments:
@@ -373,14 +344,9 @@ typedef int
*
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_find_all_t)(void *db_conn,
+typedef int (*gfdb_find_all_t)(void *db_conn,
gf_query_callback_t query_callback,
- void *_cbk_args,
- int query_limit);
-
-
-
+ void *_cbk_args, int query_limit);
/* Query records/files that have not changed/accessed
* from a time in past to current time
@@ -394,13 +360,9 @@ typedef int
* changed/accessed
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_find_unchanged_for_time_t)(void *db_conn,
- gf_query_callback_t query_callback,
- void *_cbk_args,
- gfdb_time_t *_time);
-
-
+typedef int (*gfdb_find_unchanged_for_time_t)(
+ void *db_conn, gf_query_callback_t query_callback, void *_cbk_args,
+ gfdb_time_t *_time);
/* Query records/files that have changed/accessed from a
* time in past to current time
@@ -414,10 +376,9 @@ typedef int
* changed/accessed
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_find_recently_changed_files_t)(void *db_conn,
- gf_query_callback_t query_callback,
- void *_cbk_args, gfdb_time_t *_time);
+typedef int (*gfdb_find_recently_changed_files_t)(
+ void *db_conn, gf_query_callback_t query_callback, void *_cbk_args,
+ gfdb_time_t *_time);
/* Query records/files that have not changed/accessed
* from a time in past to current time, with
@@ -437,16 +398,10 @@ typedef int
* all files.
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_find_unchanged_for_time_freq_t)
- (void *db_conn,
- gf_query_callback_t query_callback,
- void *_cbk_args, gfdb_time_t *_time,
- int _write_freq, int _read_freq,
- gf_boolean_t _clear_counters);
-
-
-
+typedef int (*gfdb_find_unchanged_for_time_freq_t)(
+ void *db_conn, gf_query_callback_t query_callback, void *_cbk_args,
+ gfdb_time_t *_time, int _write_freq, int _read_freq,
+ gf_boolean_t _clear_counters);
/* Query records/files that have changed/accessed from a
* time in past to current time, with a desired frequency
@@ -464,47 +419,37 @@ typedef int
* all files.
* Returns : if successful return 0 or
* -ve value in case of failure*/
-typedef int
-(*gfdb_find_recently_changed_files_freq_t)(void *db_conn,
- gf_query_callback_t query_callback,
- void *_cbk_args, gfdb_time_t *_time,
- int _write_freq, int _read_freq,
- gf_boolean_t _clear_counters);
-
+typedef int (*gfdb_find_recently_changed_files_freq_t)(
+ void *db_conn, gf_query_callback_t query_callback, void *_cbk_args,
+ gfdb_time_t *_time, int _write_freq, int _read_freq,
+ gf_boolean_t _clear_counters);
typedef int (*gfdb_clear_files_heat_t)(void *db_conn);
-typedef int (*gfdb_get_db_version_t)(void *db_conn,
- char **version);
-
-typedef int (*gfdb_get_db_params_t)(void *db_conn,
- char *param_key,
- char **param_value);
-
-typedef int (*gfdb_set_db_params_t)(void *db_conn,
- char *param_key,
- char *param_value);
+typedef int (*gfdb_get_db_version_t)(void *db_conn, char **version);
+typedef int (*gfdb_get_db_params_t)(void *db_conn, char *param_key,
+ char **param_value);
+typedef int (*gfdb_set_db_params_t)(void *db_conn, char *param_key,
+ char *param_value);
/*Data structure holding all the above plugin function pointers*/
typedef struct gfdb_db_operations {
- gfdb_init_db_t init_db_op;
- gfdb_fini_db_t fini_db_op;
- gfdb_insert_record_t insert_record_op;
- gfdb_delete_record_t delete_record_op;
- gfdb_compact_db_t compact_db_op;
- gfdb_find_all_t find_all_op;
- gfdb_find_unchanged_for_time_t find_unchanged_for_time_op;
- gfdb_find_recently_changed_files_t find_recently_changed_files_op;
- gfdb_find_unchanged_for_time_freq_t
- find_unchanged_for_time_freq_op;
- gfdb_find_recently_changed_files_freq_t
- find_recently_changed_files_freq_op;
- gfdb_clear_files_heat_t clear_files_heat_op;
- gfdb_get_db_version_t get_db_version;
- gfdb_get_db_params_t get_db_params;
- gfdb_set_db_params_t set_db_params;
+ gfdb_init_db_t init_db_op;
+ gfdb_fini_db_t fini_db_op;
+ gfdb_insert_record_t insert_record_op;
+ gfdb_delete_record_t delete_record_op;
+ gfdb_compact_db_t compact_db_op;
+ gfdb_find_all_t find_all_op;
+ gfdb_find_unchanged_for_time_t find_unchanged_for_time_op;
+ gfdb_find_recently_changed_files_t find_recently_changed_files_op;
+ gfdb_find_unchanged_for_time_freq_t find_unchanged_for_time_freq_op;
+ gfdb_find_recently_changed_files_freq_t find_recently_changed_files_freq_op;
+ gfdb_clear_files_heat_t clear_files_heat_op;
+ gfdb_get_db_version_t get_db_version;
+ gfdb_get_db_params_t get_db_params;
+ gfdb_set_db_params_t set_db_params;
} gfdb_db_operations_t;
/*******************************************************************************
@@ -518,75 +463,70 @@ typedef struct gfdb_db_operations {
*
* ****************************************************************************/
-
typedef struct gfdb_connection {
- void *gf_db_connection;
- gfdb_db_operations_t gfdb_db_operations;
- gfdb_db_type_t gfdb_db_type;
+ void *gf_db_connection;
+ gfdb_db_operations_t gfdb_db_operations;
+ gfdb_db_type_t gfdb_db_type;
} gfdb_connection_t;
-
-
-
/*******************************************************************************
*
* Macros for get and set db options
*
* ****************************************************************************/
-
/*Set param_key : str_value into param_dict*/
-#define SET_DB_PARAM_TO_DICT(comp_name, params_dict, param_key,\
- str_value, ret, error)\
- do {\
- data_t *data = NULL;\
- data = str_to_data (str_value);\
- if (!data)\
- goto error;\
- ret = dict_add (params_dict, param_key, data);\
- if (ret) {\
- gf_msg (comp_name, GF_LOG_ERROR, 0,\
- LG_MSG_SET_PARAM_FAILED, "Failed setting %s "\
- "to params dictionary", param_key);\
- data_destroy (data);\
- goto error;\
- };\
- } while (0)
+#define SET_DB_PARAM_TO_DICT(comp_name, params_dict, param_key, str_value, \
+ ret, error) \
+ do { \
+ data_t *data = NULL; \
+ data = str_to_data(str_value); \
+ if (!data) \
+ goto error; \
+ ret = dict_add(params_dict, param_key, data); \
+ if (ret) { \
+ gf_msg(comp_name, GF_LOG_ERROR, 0, LG_MSG_SET_PARAM_FAILED, \
+ "Failed setting %s " \
+ "to params dictionary", \
+ param_key); \
+ data_destroy(data); \
+ goto error; \
+ }; \
+ } while (0)
/*get str_value of param_key from param_dict*/
-#define GET_DB_PARAM_FROM_DICT(comp_name, params_dict, param_key, str_value,\
- error)\
- do {\
- data_t *data = NULL;\
- data = dict_get (params_dict, param_key);\
- if (!data) {\
- gf_msg (comp_name, GF_LOG_ERROR, 0,\
- LG_MSG_GET_PARAM_FAILED, "Failed to retrieve "\
- "%s from params", param_key);\
- goto error;\
- } else {\
- str_value = data->data;\
- };\
- } while (0)
-
+#define GET_DB_PARAM_FROM_DICT(comp_name, params_dict, param_key, str_value, \
+ error) \
+ do { \
+ data_t *data = NULL; \
+ data = dict_get(params_dict, param_key); \
+ if (!data) { \
+ gf_msg(comp_name, GF_LOG_ERROR, 0, LG_MSG_GET_PARAM_FAILED, \
+ "Failed to retrieve " \
+ "%s from params", \
+ param_key); \
+ goto error; \
+ } else { \
+ str_value = data->data; \
+ }; \
+ } while (0)
/*get str_value of param_key from param_dict. if param_key is not present
* set _default_v to str_value */
-#define GET_DB_PARAM_FROM_DICT_DEFAULT(comp_name, params_dict, param_key,\
- str_value, _default_v)\
- do {\
- data_t *data = NULL;\
- data = dict_get (params_dict, param_key);\
- if (!data) {\
- str_value = _default_v;\
- gf_msg (comp_name, GF_LOG_TRACE, 0,\
- LG_MSG_GET_PARAM_FAILED, "Failed to retrieve "\
- "%s from params.Assigning default value: %s",\
- param_key, _default_v);\
- } else {\
- str_value = data->data;\
- };\
- } while (0)
-
+#define GET_DB_PARAM_FROM_DICT_DEFAULT(comp_name, params_dict, param_key, \
+ str_value, _default_v) \
+ do { \
+ data_t *data = NULL; \
+ data = dict_get(params_dict, param_key); \
+ if (!data) { \
+ str_value = _default_v; \
+ gf_msg(comp_name, GF_LOG_TRACE, 0, LG_MSG_GET_PARAM_FAILED, \
+ "Failed to retrieve " \
+ "%s from params.Assigning default value: %s", \
+ param_key, _default_v); \
+ } else { \
+ str_value = data->data; \
+ }; \
+ } while (0)
#endif
diff --git a/libglusterfs/src/gfdb/gfdb_mem-types.h b/libglusterfs/src/gfdb/gfdb_mem-types.h
index 2a84b47fcf5..0ea543b7ce1 100644
--- a/libglusterfs/src/gfdb/gfdb_mem-types.h
+++ b/libglusterfs/src/gfdb/gfdb_mem-types.h
@@ -8,15 +8,10 @@
cases as published by the Free Software Foundation.
*/
-
#ifndef __GFDB_MEM_TYPES_H__
#define __GFDB_MEM_TYPES_H__
#include "mem-types.h"
-enum gfdb_mem_types_ {
- gfdb_mtstart = gf_common_mt_end + 1,
- gfdb_mt_end
-};
+enum gfdb_mem_types_ { gfdb_mtstart = gf_common_mt_end + 1, gfdb_mt_end };
#endif
-
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.h b/libglusterfs/src/gfdb/gfdb_sqlite3.h
index 11bf3e82707..d8af800db3c 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.h
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.h
@@ -10,7 +10,6 @@
#ifndef __GFDB_SQLITE3_H
#define __GFDB_SQLITE3_H
-
/*Sqlite3 header file*/
#include <sqlite3.h>
@@ -19,271 +18,255 @@
#include "gfdb_mem-types.h"
#include "libglusterfs-messages.h"
-#define GF_STMT_SIZE_MAX 2048
+#define GF_STMT_SIZE_MAX 2048
-#define GF_DB_NAME "gfdb.db"
-#define GF_FILE_TABLE "GF_FILE_TB"
-#define GF_FILE_LINK_TABLE "GF_FLINK_TB"
-#define GF_MASTER_TABLE "sqlite_master"
+#define GF_DB_NAME "gfdb.db"
+#define GF_FILE_TABLE "GF_FILE_TB"
+#define GF_FILE_LINK_TABLE "GF_FLINK_TB"
+#define GF_MASTER_TABLE "sqlite_master"
/*Since we have multiple tables to be created we put it in a transaction*/
-#define GF_CREATE_STMT(out_str)\
-do {\
- sprintf (out_str , "BEGIN; CREATE TABLE IF NOT EXISTS "\
- GF_FILE_TABLE\
- "(GF_ID TEXT PRIMARY KEY NOT NULL, "\
- "W_SEC INTEGER NOT NULL DEFAULT 0, "\
- "W_MSEC INTEGER NOT NULL DEFAULT 0, "\
- "UW_SEC INTEGER NOT NULL DEFAULT 0, "\
- "UW_MSEC INTEGER NOT NULL DEFAULT 0, "\
- "W_READ_SEC INTEGER NOT NULL DEFAULT 0, "\
- "W_READ_MSEC INTEGER NOT NULL DEFAULT 0, "\
- "UW_READ_SEC INTEGER NOT NULL DEFAULT 0, "\
- "UW_READ_MSEC INTEGER NOT NULL DEFAULT 0, "\
- "WRITE_FREQ_CNTR INTEGER NOT NULL DEFAULT 1, "\
- "READ_FREQ_CNTR INTEGER NOT NULL DEFAULT 1); "\
- "CREATE TABLE IF NOT EXISTS "\
- GF_FILE_LINK_TABLE\
- "(GF_ID TEXT NOT NULL, "\
- "GF_PID TEXT NOT NULL, "\
- "FNAME TEXT NOT NULL, "\
- "W_DEL_FLAG INTEGER NOT NULL DEFAULT 0, "\
- "LINK_UPDATE INTEGER NOT NULL DEFAULT 0, "\
- "PRIMARY KEY ( GF_ID, GF_PID, FNAME) "\
- ");"\
- "COMMIT;"\
- );;\
-} while (0)
-
-#define GF_COL_TB_WSEC GF_FILE_TABLE "." GF_COL_WSEC
-#define GF_COL_TB_WMSEC GF_FILE_TABLE "." GF_COL_WMSEC
-#define GF_COL_TB_UWSEC GF_FILE_TABLE "." GF_COL_UWSEC
-#define GF_COL_TB_UWMSEC GF_FILE_TABLE "." GF_COL_UWMSEC
-#define GF_COL_TB_RWSEC GF_FILE_TABLE "." GF_COL_WSEC_READ
-#define GF_COL_TB_RWMSEC GF_FILE_TABLE "." GF_COL_WMSEC_READ
-#define GF_COL_TB_RUWSEC GF_FILE_TABLE "." GF_COL_UWSEC_READ
-#define GF_COL_TB_RUWMSEC GF_FILE_TABLE "." GF_COL_UWMSEC_READ
-#define GF_COL_TB_WFC GF_FILE_TABLE "." GF_COL_WRITE_FREQ_CNTR
-#define GF_COL_TB_RFC GF_FILE_TABLE "." GF_COL_READ_FREQ_CNTR
-
+#define GF_CREATE_STMT(out_str) \
+ do { \
+ sprintf(out_str, "BEGIN; CREATE TABLE IF NOT EXISTS " GF_FILE_TABLE \
+ "(GF_ID TEXT PRIMARY KEY NOT NULL, " \
+ "W_SEC INTEGER NOT NULL DEFAULT 0, " \
+ "W_MSEC INTEGER NOT NULL DEFAULT 0, " \
+ "UW_SEC INTEGER NOT NULL DEFAULT 0, " \
+ "UW_MSEC INTEGER NOT NULL DEFAULT 0, " \
+ "W_READ_SEC INTEGER NOT NULL DEFAULT 0, " \
+ "W_READ_MSEC INTEGER NOT NULL DEFAULT 0, " \
+ "UW_READ_SEC INTEGER NOT NULL DEFAULT 0, " \
+ "UW_READ_MSEC INTEGER NOT NULL DEFAULT 0, " \
+ "WRITE_FREQ_CNTR INTEGER NOT NULL DEFAULT 1, " \
+ "READ_FREQ_CNTR INTEGER NOT NULL DEFAULT 1); " \
+ "CREATE TABLE IF NOT EXISTS " GF_FILE_LINK_TABLE \
+ "(GF_ID TEXT NOT NULL, " \
+ "GF_PID TEXT NOT NULL, " \
+ "FNAME TEXT NOT NULL, " \
+ "W_DEL_FLAG INTEGER NOT NULL DEFAULT 0, " \
+ "LINK_UPDATE INTEGER NOT NULL DEFAULT 0, " \
+ "PRIMARY KEY ( GF_ID, GF_PID, FNAME) " \
+ ");" \
+ "COMMIT;"); \
+ ; \
+ } while (0)
+
+#define GF_COL_TB_WSEC GF_FILE_TABLE "." GF_COL_WSEC
+#define GF_COL_TB_WMSEC GF_FILE_TABLE "." GF_COL_WMSEC
+#define GF_COL_TB_UWSEC GF_FILE_TABLE "." GF_COL_UWSEC
+#define GF_COL_TB_UWMSEC GF_FILE_TABLE "." GF_COL_UWMSEC
+#define GF_COL_TB_RWSEC GF_FILE_TABLE "." GF_COL_WSEC_READ
+#define GF_COL_TB_RWMSEC GF_FILE_TABLE "." GF_COL_WMSEC_READ
+#define GF_COL_TB_RUWSEC GF_FILE_TABLE "." GF_COL_UWSEC_READ
+#define GF_COL_TB_RUWMSEC GF_FILE_TABLE "." GF_COL_UWMSEC_READ
+#define GF_COL_TB_WFC GF_FILE_TABLE "." GF_COL_WRITE_FREQ_CNTR
+#define GF_COL_TB_RFC GF_FILE_TABLE "." GF_COL_READ_FREQ_CNTR
/*******************************************************************************
-* SQLITE3 Connection details and PRAGMA
-* ****************************************************************************/
-
-#define GF_SQL_AV_NONE "none"
-#define GF_SQL_AV_FULL "full"
-#define GF_SQL_AV_INCR "incremental"
-
-#define GF_SQL_SYNC_OFF "off"
-#define GF_SQL_SYNC_NORMAL "normal"
-#define GF_SQL_SYNC_FULL "full"
-
-#define GF_SQL_JM_DELETE "delete"
-#define GF_SQL_JM_TRUNCATE "truncate"
-#define GF_SQL_JM_PERSIST "persist"
-#define GF_SQL_JM_MEMORY "memory"
-#define GF_SQL_JM_WAL "wal"
-#define GF_SQL_JM_OFF "off"
-
-#define GF_SQL_COMPACT_NONE 0
-#define GF_SQL_COMPACT_FULL 1
-#define GF_SQL_COMPACT_INCR 2
+ * SQLITE3 Connection details and PRAGMA
+ * ****************************************************************************/
+
+#define GF_SQL_AV_NONE "none"
+#define GF_SQL_AV_FULL "full"
+#define GF_SQL_AV_INCR "incremental"
+
+#define GF_SQL_SYNC_OFF "off"
+#define GF_SQL_SYNC_NORMAL "normal"
+#define GF_SQL_SYNC_FULL "full"
+
+#define GF_SQL_JM_DELETE "delete"
+#define GF_SQL_JM_TRUNCATE "truncate"
+#define GF_SQL_JM_PERSIST "persist"
+#define GF_SQL_JM_MEMORY "memory"
+#define GF_SQL_JM_WAL "wal"
+#define GF_SQL_JM_OFF "off"
+
+#define GF_SQL_COMPACT_NONE 0
+#define GF_SQL_COMPACT_FULL 1
+#define GF_SQL_COMPACT_INCR 2
#define GF_SQL_COMPACT_MANUAL 3
-#define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR
+#define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR
typedef enum gf_sql_auto_vacuum {
- gf_sql_av_none = 0,
- gf_sql_av_full,
- gf_sql_av_incr,
- gf_sql_av_invalid
+ gf_sql_av_none = 0,
+ gf_sql_av_full,
+ gf_sql_av_incr,
+ gf_sql_av_invalid
} gf_sql_auto_vacuum_t;
typedef enum gf_sql_sync {
- gf_sql_sync_off = 0,
- gf_sql_sync_normal,
- gf_sql_sync_full,
- gf_sql_sync_invalid
+ gf_sql_sync_off = 0,
+ gf_sql_sync_normal,
+ gf_sql_sync_full,
+ gf_sql_sync_invalid
} gf_sql_sync_t;
-
typedef enum gf_sql_journal_mode {
- gf_sql_jm_wal = 0,
- gf_sql_jm_delete,
- gf_sql_jm_truncate,
- gf_sql_jm_persist,
- gf_sql_jm_memory,
- gf_sql_jm_off,
- gf_sql_jm_invalid
+ gf_sql_jm_wal = 0,
+ gf_sql_jm_delete,
+ gf_sql_jm_truncate,
+ gf_sql_jm_persist,
+ gf_sql_jm_memory,
+ gf_sql_jm_off,
+ gf_sql_jm_invalid
} gf_sql_journal_mode_t;
-
typedef struct gf_sql_connection {
- char sqlite3_db_path[PATH_MAX];
- sqlite3 *sqlite3_db_conn;
- ssize_t cache_size;
- ssize_t page_size;
- ssize_t wal_autocheckpoint;
- gf_sql_journal_mode_t journal_mode;
- gf_sql_sync_t synchronous;
- gf_sql_auto_vacuum_t auto_vacuum;
+ char sqlite3_db_path[PATH_MAX];
+ sqlite3 *sqlite3_db_conn;
+ ssize_t cache_size;
+ ssize_t page_size;
+ ssize_t wal_autocheckpoint;
+ gf_sql_journal_mode_t journal_mode;
+ gf_sql_sync_t synchronous;
+ gf_sql_auto_vacuum_t auto_vacuum;
} gf_sql_connection_t;
-
-
-#define CHECK_SQL_CONN(sql_conn, out)\
-do {\
- GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, sql_conn, out);\
- if (!sql_conn->sqlite3_db_conn) {\
- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,\
- LG_MSG_CONNECTION_INIT_FAILED,\
- "sqlite3 connection not initialized");\
- goto out;\
- };\
-} while (0)
-
-#define GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, param_key, format, value,\
- ret, error)\
-do {\
- sprintf (sqlite3_config_str, "PRAGMA %s = " format , param_key,\
- value);\
- ret = sqlite3_exec (sql_conn->sqlite3_db_conn, sqlite3_config_str,\
- NULL, NULL, NULL);\
- if (ret != SQLITE_OK) {\
- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED,\
- "Failed executing: %s : %s",\
- sqlite3_config_str, sqlite3_errmsg\
- (sql_conn->sqlite3_db_conn));\
- ret = -1;\
- goto error;\
- };\
-} while (0)
+#define CHECK_SQL_CONN(sql_conn, out) \
+ do { \
+ GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, sql_conn, out); \
+ if (!sql_conn->sqlite3_db_conn) { \
+ gf_msg(GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, \
+ LG_MSG_CONNECTION_INIT_FAILED, \
+ "sqlite3 connection not initialized"); \
+ goto out; \
+ }; \
+ } while (0)
+
+#define GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, param_key, format, value, \
+ ret, error) \
+ do { \
+ sprintf(sqlite3_config_str, "PRAGMA %s = " format, param_key, value); \
+ ret = sqlite3_exec(sql_conn->sqlite3_db_conn, sqlite3_config_str, \
+ NULL, NULL, NULL); \
+ if (ret != SQLITE_OK) { \
+ gf_msg(GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, \
+ "Failed executing: %s : %s", sqlite3_config_str, \
+ sqlite3_errmsg(sql_conn->sqlite3_db_conn)); \
+ ret = -1; \
+ goto error; \
+ }; \
+ } while (0)
/************************SQLITE3 PARAMS KEYS***********************************/
-#define GFDB_SQL_PARAM_DBPATH "sql-db-path"
-#define GFDB_SQL_PARAM_CACHE_SIZE "sql-db-cachesize"
-#define GFDB_SQL_PARAM_PAGE_SIZE "sql-db-pagesize"
-#define GFDB_SQL_PARAM_JOURNAL_MODE "sql-db-journalmode"
-#define GFDB_SQL_PARAM_WAL_AUTOCHECK "sql-db-wal-autocheckpoint"
-#define GFDB_SQL_PARAM_SYNC "sql-db-sync"
-#define GFDB_SQL_PARAM_AUTO_VACUUM "sql-db-autovacuum"
-
-#define GF_SQL_DEFAULT_DBPATH ""
-#define GF_SQL_DEFAULT_PAGE_SIZE "4096"
-#define GF_SQL_DEFAULT_CACHE_SIZE "12500"
-#define GF_SQL_DEFAULT_WAL_AUTOCHECKPOINT "25000"
-#define GF_SQL_DEFAULT_JOURNAL_MODE GF_SQL_JM_WAL
-#define GF_SQL_DEFAULT_SYNC GF_SQL_SYNC_OFF
-#define GF_SQL_DEFAULT_AUTO_VACUUM GF_SQL_AV_NONE
-
+#define GFDB_SQL_PARAM_DBPATH "sql-db-path"
+#define GFDB_SQL_PARAM_CACHE_SIZE "sql-db-cachesize"
+#define GFDB_SQL_PARAM_PAGE_SIZE "sql-db-pagesize"
+#define GFDB_SQL_PARAM_JOURNAL_MODE "sql-db-journalmode"
+#define GFDB_SQL_PARAM_WAL_AUTOCHECK "sql-db-wal-autocheckpoint"
+#define GFDB_SQL_PARAM_SYNC "sql-db-sync"
+#define GFDB_SQL_PARAM_AUTO_VACUUM "sql-db-autovacuum"
+
+#define GF_SQL_DEFAULT_DBPATH ""
+#define GF_SQL_DEFAULT_PAGE_SIZE "4096"
+#define GF_SQL_DEFAULT_CACHE_SIZE "12500"
+#define GF_SQL_DEFAULT_WAL_AUTOCHECKPOINT "25000"
+#define GF_SQL_DEFAULT_JOURNAL_MODE GF_SQL_JM_WAL
+#define GF_SQL_DEFAULT_SYNC GF_SQL_SYNC_OFF
+#define GF_SQL_DEFAULT_AUTO_VACUUM GF_SQL_AV_NONE
/* Defines the indexs for sqlite params
* The order should be maintained*/
typedef enum sqlite_param_index {
- sql_dbpath_ix = 0,
- sql_pagesize_ix,
- sql_cachesize_ix,
- sql_journalmode_ix,
- sql_walautocheck_ix,
- sql_dbsync_ix,
- sql_autovacuum_ix,
- /*This should be in the end*/
- sql_index_max
+ sql_dbpath_ix = 0,
+ sql_pagesize_ix,
+ sql_cachesize_ix,
+ sql_journalmode_ix,
+ sql_walautocheck_ix,
+ sql_dbsync_ix,
+ sql_autovacuum_ix,
+ /*This should be in the end*/
+ sql_index_max
} sqlite_param_index_t;
/* Array to hold the sqlite param keys
* The order should be maintained as sqlite_param_index_t*/
static char *sqlite_params_keys[] = {
- GFDB_SQL_PARAM_DBPATH,
- GFDB_SQL_PARAM_PAGE_SIZE,
- GFDB_SQL_PARAM_CACHE_SIZE,
- GFDB_SQL_PARAM_JOURNAL_MODE,
- GFDB_SQL_PARAM_WAL_AUTOCHECK,
- GFDB_SQL_PARAM_SYNC,
- GFDB_SQL_PARAM_AUTO_VACUUM
-};
-
+ GFDB_SQL_PARAM_DBPATH, GFDB_SQL_PARAM_PAGE_SIZE,
+ GFDB_SQL_PARAM_CACHE_SIZE, GFDB_SQL_PARAM_JOURNAL_MODE,
+ GFDB_SQL_PARAM_WAL_AUTOCHECK, GFDB_SQL_PARAM_SYNC,
+ GFDB_SQL_PARAM_AUTO_VACUUM};
/* Array of default values for sqlite params
* The order should be maintained as sqlite_param_index_t*/
-static char *sqlite_params_default_value[] = {
- GF_SQL_DEFAULT_DBPATH,
- GF_SQL_DEFAULT_PAGE_SIZE,
- GF_SQL_DEFAULT_CACHE_SIZE,
- GF_SQL_DEFAULT_JOURNAL_MODE,
- GF_SQL_DEFAULT_WAL_AUTOCHECKPOINT,
- GF_SQL_DEFAULT_SYNC,
- GF_SQL_DEFAULT_AUTO_VACUUM
-};
+static char *sqlite_params_default_value[] = {GF_SQL_DEFAULT_DBPATH,
+ GF_SQL_DEFAULT_PAGE_SIZE,
+ GF_SQL_DEFAULT_CACHE_SIZE,
+ GF_SQL_DEFAULT_JOURNAL_MODE,
+ GF_SQL_DEFAULT_WAL_AUTOCHECKPOINT,
+ GF_SQL_DEFAULT_SYNC,
+ GF_SQL_DEFAULT_AUTO_VACUUM};
/*Extract sql params from page_size to auto_vacumm
* The dbpath is extracted in a different way*/
static inline int
gfdb_set_sql_params(char *comp_name, dict_t *from_dict, dict_t *to_dict)
{
- sqlite_param_index_t sql_index = sql_pagesize_ix;
- char *_val_str = NULL;
- int ret = -1;
-
- GF_ASSERT (comp_name);
- GF_ASSERT (from_dict);
- GF_ASSERT (to_dict);
-
- /*Extract and Set of the sql params from page_size*/
- for (sql_index = sql_pagesize_ix; sql_index < sql_index_max;
- sql_index++) {
- _val_str = NULL;
- GET_DB_PARAM_FROM_DICT_DEFAULT (comp_name, from_dict,
- sqlite_params_keys[sql_index], _val_str,
- sqlite_params_default_value[sql_index]);
- SET_DB_PARAM_TO_DICT (comp_name, to_dict,
- sqlite_params_keys[sql_index], _val_str, ret, out);
- }
+ sqlite_param_index_t sql_index = sql_pagesize_ix;
+ char *_val_str = NULL;
+ int ret = -1;
+
+ GF_ASSERT(comp_name);
+ GF_ASSERT(from_dict);
+ GF_ASSERT(to_dict);
+
+ /*Extract and Set of the sql params from page_size*/
+ for (sql_index = sql_pagesize_ix; sql_index < sql_index_max; sql_index++) {
+ _val_str = NULL;
+ GET_DB_PARAM_FROM_DICT_DEFAULT(comp_name, from_dict,
+ sqlite_params_keys[sql_index], _val_str,
+ sqlite_params_default_value[sql_index]);
+ SET_DB_PARAM_TO_DICT(comp_name, to_dict, sqlite_params_keys[sql_index],
+ _val_str, ret, out);
+ }
out:
- return ret;
+ return ret;
}
-
-
-
/*************************SQLITE3 GFDB PLUGINS*********************************/
/*Db init and fini modules*/
-int gf_sqlite3_fini (void **db_conn);
-int gf_sqlite3_init (dict_t *args, void **db_conn);
+int
+gf_sqlite3_fini(void **db_conn);
+int
+gf_sqlite3_init(dict_t *args, void **db_conn);
/*insert/update/delete modules*/
-int gf_sqlite3_insert (void *db_conn, gfdb_db_record_t *);
-int gf_sqlite3_delete (void *db_conn, gfdb_db_record_t *);
+int
+gf_sqlite3_insert(void *db_conn, gfdb_db_record_t *);
+int
+gf_sqlite3_delete(void *db_conn, gfdb_db_record_t *);
/*querying modules*/
-int gf_sqlite3_find_all (void *db_conn, gf_query_callback_t,
- void *_query_cbk_args,
- int query_limit);
-int gf_sqlite3_find_unchanged_for_time (void *db_conn,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *for_time);
-int gf_sqlite3_find_recently_changed_files (void *db_conn,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *from_time);
-int gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
+int
+gf_sqlite3_find_all(void *db_conn, gf_query_callback_t, void *_query_cbk_args,
+ int query_limit);
+int
+gf_sqlite3_find_unchanged_for_time(void *db_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *for_time);
+int
+gf_sqlite3_find_recently_changed_files(void *db_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *from_time);
+int
+gf_sqlite3_find_unchanged_for_time_freq(void *db_conn,
gf_query_callback_t query_callback,
void *_query_cbk_args,
gfdb_time_t *for_time,
- int write_freq_cnt,
- int read_freq_cnt,
- gf_boolean_t clear_counters);
-int gf_sqlite3_find_recently_changed_files_freq (void *db_conn,
- gf_query_callback_t query_callback,
- void *_query_cbk_args,
- gfdb_time_t *from_time,
- int write_freq_cnt,
- int read_freq_cnt,
+ int write_freq_cnt, int read_freq_cnt,
gf_boolean_t clear_counters);
+int
+gf_sqlite3_find_recently_changed_files_freq(
+ void *db_conn, gf_query_callback_t query_callback, void *_query_cbk_args,
+ gfdb_time_t *from_time, int write_freq_cnt, int read_freq_cnt,
+ gf_boolean_t clear_counters);
-int gf_sqlite3_clear_files_heat (void *db_conn);
+int
+gf_sqlite3_clear_files_heat(void *db_conn);
/* Function to extract version of sqlite db
* Input:
@@ -296,7 +279,8 @@ int gf_sqlite3_clear_files_heat (void *db_conn);
* extracted.
* On failure return -1
* */
-int gf_sqlite3_version (void *db_conn, char **version);
+int
+gf_sqlite3_version(void *db_conn, char **version);
/* Function to extract PRAGMA or setting from sqlite db
* Input:
@@ -310,7 +294,8 @@ int gf_sqlite3_version (void *db_conn, char **version);
* extracted.
* On failure return -1
* */
-int gf_sqlite3_pragma (void *db_conn, char *pragma_key, char **pragma_value);
+int
+gf_sqlite3_pragma(void *db_conn, char *pragma_key, char **pragma_value);
/* Function to set PRAGMA to sqlite db
* Input:
@@ -322,7 +307,7 @@ int gf_sqlite3_pragma (void *db_conn, char *pragma_key, char **pragma_value);
* On failure return -1
* */
int
-gf_sqlite3_set_pragma (void *db_conn, char *pragma_key, char *pragma_value);
+gf_sqlite3_set_pragma(void *db_conn, char *pragma_key, char *pragma_value);
/* Function to vacuum of sqlite db
* Input:
@@ -334,10 +319,10 @@ gf_sqlite3_set_pragma (void *db_conn, char *pragma_key, char *pragma_value);
* On failure return -1
* */
int
-gf_sqlite3_vacuum (void *db_conn, gf_boolean_t compact_active,
- gf_boolean_t compact_mode_switched);
-
-void gf_sqlite3_fill_db_operations (gfdb_db_operations_t *gfdb_db_ops);
+gf_sqlite3_vacuum(void *db_conn, gf_boolean_t compact_active,
+ gf_boolean_t compact_mode_switched);
+void
+gf_sqlite3_fill_db_operations(gfdb_db_operations_t *gfdb_db_ops);
#endif
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.h b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.h
index 0d222305d01..f19344a353c 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.h
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.h
@@ -10,7 +10,6 @@
#ifndef __GFDB_SQLITE3_HELPER_H
#define __GFDB_SQLITE3_HELPER_H
-
#include "gfdb_sqlite3.h"
/******************************************************************************
@@ -19,27 +18,21 @@
*
* ****************************************************************************/
-
int
-gf_sql_insert_wind (gf_sql_connection_t *sql_conn,
- gfdb_db_record_t *gfdb_db_record);
+gf_sql_insert_wind(gf_sql_connection_t *sql_conn,
+ gfdb_db_record_t *gfdb_db_record);
int
-gf_sql_insert_unwind (gf_sql_connection_t *sql_conn,
- gfdb_db_record_t *gfdb_db_record);
-
+gf_sql_insert_unwind(gf_sql_connection_t *sql_conn,
+ gfdb_db_record_t *gfdb_db_record);
int
-gf_sql_update_delete_wind (gf_sql_connection_t *sql_conn,
- gfdb_db_record_t *gfdb_db_record);
+gf_sql_update_delete_wind(gf_sql_connection_t *sql_conn,
+ gfdb_db_record_t *gfdb_db_record);
int
-gf_sql_delete_unwind (gf_sql_connection_t *sql_conn,
- gfdb_db_record_t *gfdb_db_record);
-
-
-
-
+gf_sql_delete_unwind(gf_sql_connection_t *sql_conn,
+ gfdb_db_record_t *gfdb_db_record);
/******************************************************************************
*
@@ -47,13 +40,12 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn,
*
* ****************************************************************************/
-
int
-gf_sql_query_function (sqlite3_stmt *prep_stmt,
- gf_query_callback_t query_callback,
- void *_query_cbk_args);
+gf_sql_query_function(sqlite3_stmt *prep_stmt,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args);
int
-gf_sql_clear_counters (gf_sql_connection_t *sql_conn);
+gf_sql_clear_counters(gf_sql_connection_t *sql_conn);
#endif