summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store_types.h6
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3_helper.c87
-rw-r--r--xlators/features/changetimerecorder/src/changetimerecorder.c8
-rw-r--r--xlators/features/changetimerecorder/src/ctr-helper.c5
-rw-r--r--xlators/features/changetimerecorder/src/ctr-helper.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c7
7 files changed, 88 insertions, 31 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_data_store_types.h b/libglusterfs/src/gfdb/gfdb_data_store_types.h
index 5bd95241f06..e460b15d063 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store_types.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store_types.h
@@ -288,6 +288,12 @@ typedef struct gfdb_db_record {
gfdb_time_t gfdb_unwind_change_time;
/* For crash consistancy 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 */
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c
index 4d925e95ef7..4b70b49419d 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c
@@ -10,6 +10,8 @@
#include "gfdb_sqlite3_helper.h"
+#define GFDB_SQL_STMT_SIZE 256
+
/*****************************************************************************
*
* Helper function to execute actual sql queries
@@ -297,15 +299,19 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn,
char *gfid,
char *pargfid,
char *basename,
- char *basepath)
+ char *basepath,
+ gf_boolean_t link_consistency)
{
int ret = -1;
sqlite3_stmt *insert_stmt = NULL;
- char *insert_str = "INSERT INTO "
+ char insert_str[GFDB_SQL_STMT_SIZE] = "";
+
+ sprintf (insert_str, "INSERT INTO "
GF_FILE_LINK_TABLE
" (GF_ID, GF_PID, FNAME, FPATH,"
" W_DEL_FLAG, LINK_UPDATE) "
- " VALUES (?, ?, ?, ?, 0, 1);";
+ " VALUES (?, ?, ?, ?, 0, %d);",
+ link_consistency);
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO (GFDB_STR_SQLITE3, gfid, out);
@@ -389,15 +395,19 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn,
char *basename,
char *basepath,
char *old_pargfid,
- char *old_basename)
+ char *old_basename,
+ gf_boolean_t link_consistency)
{
int ret = -1;
sqlite3_stmt *insert_stmt = NULL;
- char *insert_str = "INSERT INTO "
+ char insert_str[GFDB_SQL_STMT_SIZE] = "";
+
+ sprintf (insert_str, "INSERT INTO "
GF_FILE_LINK_TABLE
" (GF_ID, GF_PID, FNAME, FPATH,"
" W_DEL_FLAG, LINK_UPDATE) "
- " VALUES (? , ?, ?, ?, 0, 1);";
+ " VALUES (? , ?, ?, ?, 0, %d);",
+ link_consistency);
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO (GFDB_STR_SQLITE3, gfid, out);
@@ -746,13 +756,15 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn,
ret = gf_sql_insert_link(sql_conn,
gfid_str, pargfid_str,
gfdb_db_record->file_name,
- gfdb_db_record->file_path);
+ gfdb_db_record->file_path,
+ gfdb_db_record->link_consistency);
if (ret) {
gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
"Failed inserting link in DB");
goto out;
}
- gfdb_db_record->islinkupdate = _gf_true;
+ gfdb_db_record->islinkupdate = gfdb_db_record->
+ link_consistency;
/*
* Only for create/mknod insert wind time
@@ -783,26 +795,31 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn,
gfdb_db_record->file_name,
gfdb_db_record->file_path,
old_pargfid_str,
- gfdb_db_record->old_file_name);
+ gfdb_db_record->old_file_name,
+ gfdb_db_record->
+ link_consistency);
if (ret) {
gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
"Failed updating link");
goto out;
}
- gfdb_db_record->islinkupdate = _gf_true;
+ gfdb_db_record->islinkupdate = gfdb_db_record->
+ link_consistency;
}
/*link*/
else {
ret = gf_sql_insert_link (sql_conn,
gfid_str, pargfid_str,
gfdb_db_record->file_name,
- gfdb_db_record->file_path);
+ gfdb_db_record->file_path,
+ gfdb_db_record->link_consistency);
if (ret) {
gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
"Failed inserting link in DB");
goto out;
}
- gfdb_db_record->islinkupdate = _gf_true;
+ gfdb_db_record->islinkupdate = gfdb_db_record->
+ link_consistency;
}
}
}
@@ -901,7 +918,6 @@ gf_sql_update_delete_wind (gf_sql_connection_t *sql_conn,
gfdb_db_record_t *gfdb_db_record)
{
int ret = -1;
- gfdb_time_t *modtime = NULL;
char *gfid_str = NULL;
char *pargfid_str = NULL;
@@ -922,29 +938,17 @@ gf_sql_update_delete_wind (gf_sql_connection_t *sql_conn,
goto out;
}
- if (gfdb_db_record->do_record_times) {
- /*Update the wind write times*/
- modtime = &gfdb_db_record->gfdb_wind_change_time;
- ret = gf_update_time (sql_conn, gfid_str, modtime,
- gfdb_db_record->do_record_counters,
- _gf_true,
- isreadfop (gfdb_db_record->gfdb_fop_type));
+ if (gfdb_db_record->link_consistency) {
+ ret = gf_sql_update_link_flags (sql_conn, gfid_str, pargfid_str,
+ gfdb_db_record->file_name, 1,
+ _gf_false);
if (ret) {
gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
- "Failed update wind time in DB");
+ "Failed updating link flags in wind");
goto out;
}
}
- ret = gf_sql_update_link_flags (sql_conn, gfid_str, pargfid_str,
- gfdb_db_record->file_name, 1,
- _gf_false);
- if (ret) {
- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
- "Failed updating link flags in wind");
- goto out;
- }
-
ret = 0;
out:
GF_FREE (gfid_str);
@@ -985,6 +989,25 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn,
goto out;
}
+ /* Special performance case:
+ * Updating wind time in unwind for delete. This is done here
+ * as in the wind path we will not know whether its the last
+ * link or not. For a last link there is not use to update any
+ * wind or unwind time!*/
+ if (gfdb_db_record->do_record_times) {
+ /*Update the wind write times*/
+ modtime = &gfdb_db_record->gfdb_wind_change_time;
+ ret = gf_update_time (sql_conn, gfid_str, modtime,
+ gfdb_db_record->do_record_counters,
+ _gf_true,
+ isreadfop (gfdb_db_record->gfdb_fop_type));
+ if (ret) {
+ gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
+ "Failed update wind time in DB");
+ goto out;
+ }
+ }
+
modtime = &gfdb_db_record->gfdb_unwind_change_time;
ret = gf_sql_delete_link(sql_conn, gfid_str, pargfid_str,
@@ -1007,6 +1030,10 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn,
goto out;
}
}
+ } else {
+ gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,
+ "Invalid unlink option");
+ goto out;
}
ret = 0;
out:
diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c
index 42470a92ef9..fd57a445e08 100644
--- a/xlators/features/changetimerecorder/src/changetimerecorder.c
+++ b/xlators/features/changetimerecorder/src/changetimerecorder.c
@@ -958,6 +958,9 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("record-counters", _priv->ctr_record_counter, options,
bool, out);
+ GF_OPTION_RECONF ("ctr_link_consistency", _priv->ctr_link_consistency,
+ options, bool, out);
+
GF_OPTION_RECONF ("record-exit", _priv->ctr_record_unwind, options,
bool, out);
@@ -1154,6 +1157,11 @@ struct volume_options options[] = {
.value = {"on", "off"},
.default_value = "off"
},
+ { .key = {"ctr_link_consistency"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .value = {"on", "off"},
+ .default_value = "off"
+ },
{ .key = {"hot-brick"},
.type = GF_OPTION_TYPE_BOOL,
.value = {"on", "off"},
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c
index da5a3deed96..a2e2569818d 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.c
+++ b/xlators/features/changetimerecorder/src/ctr-helper.c
@@ -97,6 +97,7 @@ fill_db_record_for_wind (xlator_t *this,
ctr_wtime = &CTR_DB_REC(ctr_local).gfdb_wind_change_time;
CTR_DB_REC(ctr_local).gfdb_fop_path = ctr_inode_cx->fop_path;
CTR_DB_REC(ctr_local).gfdb_fop_type = ctr_inode_cx->fop_type;
+ CTR_DB_REC(ctr_local).link_consistency = _priv->ctr_link_consistency;
ret = gettimeofday (ctr_wtime, NULL);
if (ret) {
@@ -265,6 +266,10 @@ int extract_ctr_options (xlator_t *this, gf_ctr_private_t *_priv) {
GF_OPTION_INIT ("record-counters", _priv->ctr_record_counter, bool,
out);
+ /*Extract flag for link consistency*/
+ GF_OPTION_INIT ("ctr_link_consistency", _priv->ctr_link_consistency,
+ bool, out);
+
/*Extract flag for hot tier brick*/
GF_OPTION_INIT ("hot-brick", _priv->ctr_hot_brick, bool, out);
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h
index 6f4ad5cbe7a..85ee872fa33 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.h
+++ b/xlators/features/changetimerecorder/src/ctr-helper.h
@@ -37,6 +37,7 @@ typedef struct gf_ctr_private {
gf_boolean_t ctr_record_wind;
gf_boolean_t ctr_record_unwind;
gf_boolean_t ctr_record_counter;
+ gf_boolean_t ctr_link_consistency;
gfdb_db_type_t gfdb_db_type;
gfdb_sync_type_t gfdb_sync_type;
gfdb_conn_node_t *_db_conn;
@@ -380,6 +381,7 @@ ctr_insert_wind (call_frame_t *frame,
"WIND: Error filling ctr local");
goto out;
}
+
/*Insert the db record*/
ret = insert_record (_priv->_db_conn,
&ctr_local->gfdb_db_record);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index b6c0e4926d3..f8050c87124 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1689,6 +1689,10 @@ brick_graph_add_changetimerecorder (volgen_graph_t *graph,
if (ret)
goto out;
+ ret = xlator_set_option (xl, "ctr_link_consistency", "off");
+ if (ret)
+ goto out;
+
ret = xlator_set_option (xl, "record-entry", "on");
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 17f34e6f86d..c57840f0fde 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1730,8 +1730,13 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.option = "record-counters",
.op_version = GD_OP_VERSION_3_7_0
},
+ { .key = "features.ctr_link_consistency",
+ .voltype = "features/changetimerecorder",
+ .value = "off",
+ .option = "ctr_link_consistency",
+ .op_version = GD_OP_VERSION_3_7_0
+ },
#endif /* USE_GFDB */
-
{ .key = "locks.trace",
.voltype = "features/locks",
.type = NO_DOC,