summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2015-04-09 15:07:54 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-07 06:49:34 -0700
commit42a508fb008c4d2d90faf30616423cfbcba84a30 (patch)
tree16201d6366389628bcf5401bfc5b343f2a43f753 /libglusterfs
parent46d2b271a9b881f0f8131e38b332eef5589323a9 (diff)
ctr/libgfdb: Performance enhancer for unlink/create/rename/link fops
1) ctr_link_consistency option for ctr xaltor is provided so that the user can choose to switch it on or off. /* 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 */ 2) In delete the wind time recording is moved to unwind path. /* 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!*/ > http://review.gluster.org/#/c/10170/ > Cherry picked from commit 606d9734543208542afcf9df982bf2d560235ef6 > Change-Id: I209472fb816f939db4a868b97ba053b028f17ea6 > BUG: 1217786 > Signed-off-by: Joseph Fernandes <josferna@redhat.com> > Reviewed-on: http://review.gluster.org/10170 > Reviewed-by: Dan Lambright <dlambrig@redhat.com> > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Signed-off-by: Joseph Fernandes <josferna@redhat.com> Change-Id: I4a89ef80875f36cff91520f712e1f47fde258a63 BUG: 1219066 Signed-off-by: Joseph Fernandes <josferna@redhat.com> Reviewed-on: http://review.gluster.org/10170 Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Signed-off-by: Joseph Fernandes <josferna@redhat.com> Reviewed-on: http://review.gluster.org/10614 Tested-by: NetBSD Build System Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store_types.h6
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3_helper.c87
2 files changed, 63 insertions, 30 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: