summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-09 10:44:44 +0530
committerVijay Bellur <vbellur@redhat.com>2015-06-12 11:37:43 -0700
commit1b7721817a7807bc0af51d89d61fbb723769b2d3 (patch)
tree89fbcf5768784e652535e5aa23f3001602b78e09 /xlators/features/changelog
parent36e3e0d92e0692c6565fba631c715654b712556d (diff)
features/changelog: Do htime setxattr without XATTR_REPLACE flag
HTIME_KEY marks the last changelog rolled over. The xattr is maintained on .glusterfs/changelog/htime/HTIME.TSTAMP file. On every rollover of the changelog file, the xattr is updated. It is being updated with XATTR_REPLACE flag as xattr gets created during changelog enable. But it is once found that the xattrs on the file is cleared and is not reproduced later on. This patch protects that case, if it happens by setting xattr without XATTR_REPLACE flag in failure case. The reason behind doing this in failure case is not to mask the actual cause of xattrs getting cleared. This provides the log message if the original issue still exists but the consequential effects are fixed. Also changed the log messages to depict the events happened during changelog enable. Change-Id: I699ed09a03667fd823d01d65c9c360fa7bc0e455 BUG: 1230694 Reviewed-On: http://review.gluster.org/#/c/11150/ Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11181 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/changelog')
-rw-r--r--xlators/features/changelog/src/changelog-helpers.c33
-rw-r--r--xlators/features/changelog/src/changelog.c3
2 files changed, 26 insertions, 10 deletions
diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c
index 7e518f1..2c0a645 100644
--- a/xlators/features/changelog/src/changelog-helpers.c
+++ b/xlators/features/changelog/src/changelog-helpers.c
@@ -327,11 +327,21 @@ htime_update (xlator_t *this,
sprintf (x_value,"%lu:%d",ts, priv->rollover_count);
if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value,
- strlen (x_value), XATTR_REPLACE)) {
+ strlen (x_value), XATTR_REPLACE)) {
gf_log (this->name, GF_LOG_ERROR,
- "Htime xattr updation failed, "
- "reason (%s)",strerror (errno));
- goto out;
+ "Htime xattr updation failed with XATTR_REPLACE "
+ "Changelog: %s Reason (%s)", changelog_path,
+ strerror (errno));
+
+ if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value,
+ strlen (x_value), 0)) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Htime xattr updation failed "
+ "Changelog: %s Reason (%s)", changelog_path,
+ strerror (errno));
+ ret = -1;
+ goto out;
+ }
}
priv->rollover_count +=1;
@@ -633,17 +643,21 @@ htime_open (xlator_t *this,
size = sys_fgetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname,
sizeof (ht_file_bname));
if (size < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Error extracting"
- " HTIME_CURRENT: %s.", strerror (errno));
-
/* If upgrade scenario, find the latest HTIME.TSTAMP file
* and use the same. If error, create a new HTIME.TSTAMP
* file.
*/
cnt = find_current_htime (ht_dir_fd, ht_dir_path,
ht_file_bname);
- if (cnt <= 0)
+ if (cnt <= 0) {
+ gf_log (this->name, GF_LOG_INFO,
+ "HTIME_CURRENT not found: %s. Changelog enabled"
+ " before init", strerror (errno));
return htime_create (this, priv, ts);
+ }
+
+ gf_log (this->name, GF_LOG_ERROR, "Error extracting"
+ " HTIME_CURRENT: %s.", strerror (errno));
}
gf_log (this->name, GF_LOG_INFO, "HTIME_CURRENT: %s", ht_file_bname);
@@ -701,6 +715,9 @@ htime_create (xlator_t *this,
char ht_file_bname[NAME_MAX + 1] = {0,};
int flags = 0;
+ gf_log (this->name, GF_LOG_INFO, "Changelog enable: Creating new "
+ "HTIME.%lu file", ts);
+
CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path);
/* get the htime file name in ht_file_path */
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
index bea7334..47696f4 100644
--- a/xlators/features/changelog/src/changelog.c
+++ b/xlators/features/changelog/src/changelog.c
@@ -2423,8 +2423,7 @@ reconfigure (xlator_t *this, dict_t *options)
if (active_now) {
if (!active_earlier) {
gf_log (this->name, GF_LOG_INFO,
- "Changelog enable: Creating new "
- "HTIME.TSTAMP file");
+ "Reconfigure: Changelog Enable");
if (gettimeofday(&tv, NULL) ) {
gf_log (this->name, GF_LOG_ERROR,
"unable to fetch htime");