summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2016-09-07 04:19:32 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-09-14 20:58:48 -0700
commit613575ee7140e257d8f0265b719cbfc7c44a0297 (patch)
treebc5bc111e7d2da260c4989061bdab29bb1290555 /xlators/storage/posix/src/posix-helpers.c
parent73c6c2c307c8bcaac51aa94b1af518955f35d1b8 (diff)
storage/posix: Integrate important events with gf_event
BUG: 1371353 Change-Id: I9346ca16222caf9d97d999751577399ae6aacf72 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/15342 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Ravishankar N <ravishankar@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 75895136155..6162f2649e1 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -31,6 +31,7 @@
#include <alloca.h>
#endif /* GF_BSD_HOST_OS */
+#include <fnmatch.h>
#include "glusterfs.h"
#include "checksum.h"
#include "dict.h"
@@ -49,7 +50,7 @@
#include "glusterfs3-xdr.h"
#include "hashfn.h"
#include "glusterfs-acl.h"
-#include <fnmatch.h>
+#include "events.h"
char *marker_xattrs[] = {"trusted.glusterfs.quota.*",
"trusted.glusterfs.*.xtime",
@@ -1737,6 +1738,8 @@ posix_fs_health_check (xlator_t *this)
time_t time_sec = {0,};
char buff[64] = {0};
char file_path[PATH_MAX] = {0};
+ char *op = NULL;
+ int op_errno = 0;
GF_VALIDATE_OR_GOTO (this->name, this, out);
priv = this->private;
@@ -1752,16 +1755,14 @@ posix_fs_health_check (xlator_t *this)
fd = open (file_path, O_CREAT|O_RDWR, 0644);
if (fd == -1) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- P_MSG_HEALTHCHECK_FAILED,
- "open() on %s returned", file_path);
+ op_errno = errno;
+ op = "open";
goto out;
}
nofbytes = sys_write (fd, timestamp, timelen);
- if (nofbytes != timelen) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- P_MSG_HEALTHCHECK_FAILED,
- "write() on %s returned", file_path);
+ if (nofbytes < 0) {
+ op_errno = errno;
+ op = "write";
goto out;
}
/* Seek the offset to the beginning of the file, so that the offset for
@@ -1769,9 +1770,8 @@ posix_fs_health_check (xlator_t *this)
sys_lseek(fd, 0, SEEK_SET);
nofbytes = sys_read (fd, buff, timelen);
if (nofbytes == -1) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- P_MSG_HEALTHCHECK_FAILED,
- "read() on %s returned", file_path);
+ op_errno = errno;
+ op = "read";
goto out;
}
ret = 0;
@@ -1779,6 +1779,14 @@ out:
if (fd != -1) {
sys_close (fd);
}
+ if (ret && file_path[0]) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_HEALTHCHECK_FAILED,
+ "%s() on %s returned", op, file_path);
+ gf_event (EVENT_POSIX_HEALTH_CHECK_FAILED,
+ "op=%s;path=%s;error=%s;brick=%s:%s", op, file_path,
+ op_errno, priv->hostname, priv->base_path);
+ }
return ret;
}
@@ -1814,14 +1822,8 @@ posix_health_check_thread_proc (void *data)
/* Do the health-check.*/
ret = posix_fs_health_check (this);
-
- if (ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- P_MSG_HEALTHCHECK_FAILED,
- "health_check on %s returned",
- priv->base_path);
+ if (ret < 0)
goto abort;
- }
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
}
@@ -1841,6 +1843,7 @@ abort:
/* health-check failed */
gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED,
"health-check failed, going down");
+
xlator_notify (this->parents->xlator, GF_EVENT_CHILD_DOWN, this);
ret = sleep (30);