From 439de31320315872d988720991e9baaead8712db Mon Sep 17 00:00:00 2001 From: Joseph Fernandes Date: Tue, 15 Dec 2015 18:29:06 +0530 Subject: 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. Change-Id: I2cb590451a6d244bc91fe66c6dbffe2c2059dfb8 BUG: 1293034 Signed-off-by: Joseph Fernandes Reviewed-on: http://review.gluster.org/12972 Reviewed-by: N Balachandran Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- .../changetimerecorder/src/changetimerecorder.c | 61 ++++++++++++++++------ .../features/changetimerecorder/src/ctr-helper.c | 4 -- .../features/changetimerecorder/src/ctr-helper.h | 11 ++-- 3 files changed, 47 insertions(+), 29 deletions(-) (limited to 'xlators/features/changetimerecorder') 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)\ -- cgit