summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
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 ce6978470ee..d339189edb8 100644
--- a/xlators/features/changetimerecorder/src/changetimerecorder.c
+++ b/xlators/features/changetimerecorder/src/changetimerecorder.c
@@ -107,7 +107,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*/
@@ -129,8 +128,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
@@ -334,8 +331,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
@@ -902,12 +898,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,
@@ -1077,7 +1071,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,
@@ -1394,7 +1388,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,
@@ -1485,7 +1479,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,
@@ -1567,8 +1561,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,
@@ -1881,7 +1874,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;
}
@@ -1955,7 +1948,6 @@ out:
/******************************************************************************/
-
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -1966,7 +1958,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,
@@ -1996,6 +1988,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 2b2dc3e17c7..486b9452eb4 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.h
+++ b/xlators/features/changetimerecorder/src/ctr-helper.h
@@ -97,8 +97,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)
@@ -159,8 +159,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*/
@@ -187,21 +185,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 593ae2aa833..f582009bb5b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -77,15 +77,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 */
@@ -133,6 +133,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
@@ -2444,6 +2507,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",