diff options
| author | Pranith Kumar K <pkarampu@redhat.com> | 2016-09-07 04:19:32 +0530 | 
|---|---|---|
| committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-09-14 21:18:56 -0700 | 
| commit | 37e48d7c298cbdaafe04efe4dde59ec878073e20 (patch) | |
| tree | 63928fb12a50adfc50095d08b35a00dfaa9da265 /xlators/storage/posix/src/posix-helpers.c | |
| parent | 31629c943597ab1ae05948f7ad1051b53d7577ab (diff) | |
storage/posix: Integrate important events with gf_event
        Backport of http://review.gluster.org/15342
BUG: 1375914
Change-Id: Icc23b22de02e45d2b0f8c6339ee628b439a4ffa8
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/15497
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
| -rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 39 | 
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);  | 
