summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/src/changelog-helpers.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-09 10:44:44 +0530
committerVenky Shankar <vshankar@redhat.com>2015-06-12 03:38:02 -0700
commite58b55ed9b2e802e6c3e908cbbad71c00f6c5b97 (patch)
tree173c3c7d5849a3e0a6da051ab36d0ecd56a7d5dc /xlators/features/changelog/src/changelog-helpers.c
parent6180d36ff30ecbe84c91b66b23734cf4f45249c5 (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: 1230015 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11150 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog/src/changelog-helpers.c')
-rw-r--r--xlators/features/changelog/src/changelog-helpers.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c
index dd09716d800..54a658f24a3 100644
--- a/xlators/features/changelog/src/changelog-helpers.c
+++ b/xlators/features/changelog/src/changelog-helpers.c
@@ -322,11 +322,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;
@@ -628,17 +638,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);
@@ -696,6 +710,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 */