summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2015-12-15 18:29:06 +0530
committerDan Lambright <dlambrig@redhat.com>2015-12-22 14:45:20 -0800
commita7de0cd095f799e3128f74fcccc57ac4d6fd0b6d (patch)
tree88c29606bcffa1252ac34f6f7a5ff52be1001c5b /xlators
parent7223062cdc1934a6694265cfd73b9cc5a8c4f377 (diff)
ctr/sql: Providing for vol set for sqlcachesize and sqlWALsize and skip recording path
1. Providing vol set option for cache size and wal autocheck point so that performance can be tuned. 2. Removed recording of file path in the db. Trimming database columns. Path need not be stored in the db, as PARGFID, GFID, Basename is suffice to derive the path during migration. Backport of http://review.gluster.org/12972 > Change-Id: I2cb590451a6d244bc91fe66c6dbffe2c2059dfb8 > BUG: 1293034 > Signed-off-by: Joseph Fernandes <josferna@redhat.com> > Reviewed-on: http://review.gluster.org/12972 > Reviewed-by: N Balachandran <nbalacha@redhat.com> > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Tested-by: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Dan Lambright <dlambrig@redhat.com> > Tested-by: Dan Lambright <dlambrig@redhat.com> Signed-off-by: Joseph Fernandes <josferna@redhat.com> Change-Id: Ia1c109983ec6ce75ed27b8c08f454f5b6283c31d BUG: 1293659 Reviewed-on: http://review.gluster.org/13067 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/changetimerecorder/src/changetimerecorder.c61
-rw-r--r--xlators/features/changetimerecorder/src/ctr-helper.c4
-rw-r--r--xlators/features/changetimerecorder/src/ctr-helper.h11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c99
4 files changed, 142 insertions, 33 deletions
diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c
index 04cd3145d95..de42c3f629b 100644
--- a/xlators/features/changetimerecorder/src/changetimerecorder.c
+++ b/xlators/features/changetimerecorder/src/changetimerecorder.c
@@ -106,7 +106,6 @@ ctr_lookup_wind(call_frame_t *frame,
goto out;
};
ctr_local = frame->local;
- ctr_local->client_pid = frame->root->pid;
/*Definately no internal fops will reach here*/
ctr_local->is_internal_fop = _gf_false;
/*Dont record counters*/
@@ -128,8 +127,6 @@ ctr_lookup_wind(call_frame_t *frame,
*((NEW_LINK_CX(ctr_inode_cx))->pargfid));
strcpy (CTR_DB_REC(ctr_local).file_name,
NEW_LINK_CX(ctr_inode_cx)->basename);
- strcpy (CTR_DB_REC(ctr_local).file_path,
- NEW_LINK_CX(ctr_inode_cx)->basepath);
/* Since we are in lookup we can ignore errors while
* Inserting in the DB, because there may be many
@@ -333,8 +330,7 @@ ctr_lookup (call_frame_t *frame, xlator_t *this,
goto out;
/*fill ctr link context*/
- FILL_CTR_LINK_CX(_link_cx, loc->parent->gfid, loc->name,
- loc->path, out);
+ FILL_CTR_LINK_CX(_link_cx, loc->parent->gfid, loc->name, out);
/* Fill ctr inode context*/
/* IA_IFREG : We assume its a file in the wind
@@ -901,12 +897,10 @@ ctr_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
CTR_IF_INTERNAL_FOP_THEN_GOTO (frame, xdata, out);
/*Fill old link context*/
- FILL_CTR_LINK_CX(_olink_cx, oldloc->pargfid, oldloc->name,
- oldloc->path, out);
+ FILL_CTR_LINK_CX(_olink_cx, oldloc->pargfid, oldloc->name, out);
/*Fill new link context*/
- FILL_CTR_LINK_CX(_nlink_cx, newloc->pargfid, newloc->name,
- newloc->path, out);
+ FILL_CTR_LINK_CX(_nlink_cx, newloc->pargfid, newloc->name, out);
/*Fill ctr inode context*/
FILL_CTR_INODE_CONTEXT(_inode_cx, oldloc->inode->ia_type,
@@ -1076,7 +1070,7 @@ ctr_unlink (call_frame_t *frame, xlator_t *this,
CTR_IS_DISABLED_THEN_GOTO(this, out);
/*Fill link context*/
- FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, loc->path, out);
+ FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, out);
/*Fill ctr inode context*/
FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type,
@@ -1393,7 +1387,7 @@ ctr_mknod (call_frame_t *frame, xlator_t *this,
gf_uuid_copy (gfid, uuid_req);
/*fill ctr link context*/
- FILL_CTR_LINK_CX (_link_cx, loc->pargfid, loc->name, loc->path, out);
+ FILL_CTR_LINK_CX (_link_cx, loc->pargfid, loc->name, out);
/*Fill ctr inode context*/
FILL_CTR_INODE_CONTEXT (_inode_cx, loc->inode->ia_type,
@@ -1484,7 +1478,7 @@ ctr_create (call_frame_t *frame, xlator_t *this,
gf_uuid_copy (gfid, uuid_req);
/*fill ctr link context*/
- FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, loc->path, out);
+ FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, out);
/*Fill ctr inode context*/
FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type,
@@ -1566,8 +1560,7 @@ ctr_link (call_frame_t *frame, xlator_t *this,
GF_ASSERT(frame->root);
/*fill ctr link context*/
- FILL_CTR_LINK_CX(_link_cx, newloc->pargfid, newloc->name,
- newloc->path, out);
+ FILL_CTR_LINK_CX(_link_cx, newloc->pargfid, newloc->name, out);
/*Fill ctr inode context*/
FILL_CTR_INODE_CONTEXT(_inode_cx, oldloc->inode->ia_type,
@@ -1880,7 +1873,7 @@ ctr_ipc_helper (xlator_t *this, dict_t *in_dict,
goto out;
}
- ret = get_db_setting (priv->_db_conn, db_param_key, &db_param);
+ ret = get_db_params (priv->_db_conn, db_param_key, &db_param);
if (ret == -1 || !db_param) {
goto out;
}
@@ -1954,7 +1947,6 @@ out:
/******************************************************************************/
-
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -1965,7 +1957,7 @@ reconfigure (xlator_t *this, dict_t *options)
priv = this->private;
if (dict_get_str(options, "changetimerecorder.frequency",
&temp_str)) {
- gf_msg(this->name, GF_LOG_INFO, 0, CTR_MSG_SET, "set!");
+ gf_msg(this->name, GF_LOG_INFO, 0, CTR_MSG_SET, "set");
}
GF_OPTION_RECONF ("ctr-enabled", priv->enabled, options,
@@ -1995,6 +1987,41 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("record-entry", priv->ctr_record_wind, options,
bool, out);
+
+
+
+ /* If database is sqlite */
+ if (priv->gfdb_db_type == GFDB_SQLITE3) {
+
+ /* AUTOCHECKPOINT */
+ if (dict_get_str (options, GFDB_SQL_PARAM_WAL_AUTOCHECK,
+ &temp_str) == 0) {
+ ret = set_db_params (priv->_db_conn,
+ "wal_autocheckpoint", temp_str);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED,
+ "Failed to set %s",
+ GFDB_SQL_PARAM_WAL_AUTOCHECK);
+ }
+ }
+
+ /* CACHE_SIZE */
+ if (dict_get_str (options, GFDB_SQL_PARAM_CACHE_SIZE, &temp_str)
+ == 0) {
+ ret = set_db_params (priv->_db_conn, "cache_size",
+ temp_str);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED,
+ "Failed to set %s",
+ GFDB_SQL_PARAM_CACHE_SIZE);
+ }
+ }
+ }
+
+ ret = 0;
+
out:
return ret;
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c
index 44abf7d5142..263eb58db6f 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.c
+++ b/xlators/features/changetimerecorder/src/ctr-helper.c
@@ -138,8 +138,6 @@ fill_db_record_for_wind (xlator_t *this,
*((NEW_LINK_CX(ctr_inode_cx))->pargfid));
strcpy (CTR_DB_REC(ctr_local).file_name,
NEW_LINK_CX(ctr_inode_cx)->basename);
- strcpy (CTR_DB_REC(ctr_local).file_path,
- NEW_LINK_CX(ctr_inode_cx)->basepath);
}
/*rename fop*/
if (OLD_LINK_CX(ctr_inode_cx)) {
@@ -147,8 +145,6 @@ fill_db_record_for_wind (xlator_t *this,
*((OLD_LINK_CX(ctr_inode_cx))->pargfid));
strcpy (CTR_DB_REC(ctr_local).old_file_name,
OLD_LINK_CX(ctr_inode_cx)->basename);
- strcpy (CTR_DB_REC(ctr_local).old_path,
- OLD_LINK_CX(ctr_inode_cx)->basepath);
}
}
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h
index 246468287f4..cf71337a8f5 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.h
+++ b/xlators/features/changetimerecorder/src/ctr-helper.h
@@ -102,8 +102,8 @@ do {\
0, sizeof(gfdb_time_t));\
gf_uuid_clear (ctr_local->gfdb_db_record.gfid);\
gf_uuid_clear (ctr_local->gfdb_db_record.pargfid);\
- memset(ctr_local->gfdb_db_record.file_name, 0, PATH_MAX);\
- memset(ctr_local->gfdb_db_record.old_file_name, 0, PATH_MAX);\
+ memset(ctr_local->gfdb_db_record.file_name, 0, GF_NAME_MAX + 1);\
+ memset(ctr_local->gfdb_db_record.old_file_name, 0, GF_NAME_MAX + 1);\
ctr_local->gfdb_db_record.gfdb_fop_type = GFDB_FOP_INVALID_OP;\
ctr_local->ia_inode_type = IA_INVAL;\
} while (0)
@@ -164,8 +164,6 @@ free_ctr_local (gf_ctr_local_t *ctr_local)
typedef struct gf_ctr_link_context {
uuid_t *pargfid;
const char *basename;
- /*basepath is redundent. Will go off*/
- const char *basepath;
} gf_ctr_link_context_t;
/*Context Carrier Structure for inodes*/
@@ -192,21 +190,18 @@ do {\
if (ctr_link_cx->pargfid)\
GF_ASSERT (*(ctr_link_cx->pargfid));\
GF_ASSERT (ctr_link_cx->basename);\
- GF_ASSERT (ctr_link_cx->basepath);\
};\
} while (0)
/*Clear and fill the ctr_link_context with values*/
-#define FILL_CTR_LINK_CX(ctr_link_cx, _pargfid, _basename, _basepath, label)\
+#define FILL_CTR_LINK_CX(ctr_link_cx, _pargfid, _basename, label)\
do {\
GF_VALIDATE_OR_GOTO ("ctr", ctr_link_cx, label);\
GF_VALIDATE_OR_GOTO ("ctr", _pargfid, label);\
GF_VALIDATE_OR_GOTO ("ctr", _basename, label);\
- GF_VALIDATE_OR_GOTO ("ctr", _basepath, label);\
memset (ctr_link_cx, 0, sizeof (*ctr_link_cx));\
ctr_link_cx->pargfid = &_pargfid;\
ctr_link_cx->basename = _basename;\
- ctr_link_cx->basepath = _basepath;\
} while (0)
#define NEW_LINK_CX(ctr_inode_cx)\
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index b3112ca75f5..54b24d87e70 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -82,15 +82,15 @@ validate_tier_counters (glusterd_volinfo_t *volinfo,
current_rt = get_tier_freq_threshold (volinfo,
"cluster.read-freq-threshold");
if (current_rt == -1) {
- snprintf (errstr, sizeof (errstr), " Failed to retrive value of"
- "cluster.read-freq-threshold");
+ snprintf (errstr, sizeof (errstr), " Failed to retrieve value"
+ " of cluster.read-freq-threshold");
goto out;
}
current_wt = get_tier_freq_threshold (volinfo,
"cluster.write-freq-threshold");
if (current_wt == -1) {
- snprintf (errstr, sizeof (errstr), " Failed to retrive value of"
- "cluster.write-freq-threshold");
+ snprintf (errstr, sizeof (errstr), " Failed to retrieve value "
+ "of cluster.write-freq-threshold");
goto out;
}
/* If record-counters is set to off */
@@ -138,6 +138,69 @@ out:
}
+
+/*
+ * Validation function for ctr sql params
+ * features.ctr-sql-db-cachesize (Range: 1000 to 262144 pages)
+ * features.ctr-sql-db-wal-autocheckpoint (Range: 1000 to 262144 pages)
+ * */
+static int
+validate_ctr_sql_params (glusterd_volinfo_t *volinfo,
+ dict_t *dict,
+ char *key,
+ char *value,
+ char **op_errstr)
+{
+ int ret = -1;
+ xlator_t *this = NULL;
+ char errstr[2048] = "";
+ int origin_val = -1;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+
+ ret = gf_string2int (value, &origin_val);
+ if (ret) {
+ snprintf (errstr, sizeof (errstr), "%s is not a compatible "
+ "value. %s expects an integer value.", value, key);
+ ret = -1;
+ goto out;
+ }
+
+ if (origin_val < 0) {
+ snprintf (errstr, sizeof (errstr), "%s is not a "
+ "compatible value. %s expects a positive"
+ "integer value.", value, key);
+ ret = -1;
+ goto out;
+ }
+
+ if (strstr (key, "sql-db-cachesize") ||
+ strstr (key, "sql-db-wal-autocheckpoint")) {
+ if ((origin_val < 1000) || (origin_val > 262144)) {
+ snprintf (errstr, sizeof (errstr), "%s is not a "
+ "compatible value. %s "
+ "expects a value between : "
+ "1000 to 262144.",
+ value, key);
+ ret = -1;
+ goto out;
+ }
+ }
+
+
+ ret = 0;
+out:
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr);
+ *op_errstr = gf_strdup (errstr);
+ }
+ return ret;
+}
+
+
/* Validation for tiering frequency thresholds
* If any of the frequency thresholds are set to a non-zero value,
* switch record-counters on, if not already on
@@ -2383,6 +2446,34 @@ struct volopt_map_entry glusterd_volopt_map[] = {
"hits an attempt to heal the database per "
"inode is done"
},
+ { .key = "features.ctr-sql-db-cachesize",
+ .voltype = "features/changetimerecorder",
+ .value = "1000",
+ .option = "sql-db-cachesize",
+ .validate_fn = validate_ctr_sql_params,
+ .op_version = GD_OP_VERSION_3_7_7,
+ .description = "Defines the cache size of the sqlite database of "
+ "changetimerecorder xlator."
+ "The input to this option is in pages."
+ "Each page is 4096 bytes. Default value is 1000 "
+ "pages i.e ~ 4 MB. "
+ "The max value is 262144 pages i.e 1 GB and "
+ "the min value is 1000 pages i.e ~ 4 MB. "
+ },
+ { .key = "features.ctr-sql-db-wal-autocheckpoint",
+ .voltype = "features/changetimerecorder",
+ .value = "1000",
+ .option = "sql-db-wal-autocheckpoint",
+ .validate_fn = validate_ctr_sql_params,
+ .op_version = GD_OP_VERSION_3_7_7,
+ .description = "Defines the autocheckpoint of the sqlite database of "
+ " changetimerecorder. "
+ "The input to this option is in pages. "
+ "Each page is 4096 bytes. Default value is 1000 "
+ "pages i.e ~ 4 MB."
+ "The max value is 262144 pages i.e 1 GB and "
+ "the min value is 1000 pages i.e ~4 MB."
+ },
#endif /* USE_GFDB */
{ .key = "locks.trace",
.voltype = "features/locks",