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 | |
| 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>
| -rw-r--r-- | events/eventskeygen.py | 4 | ||||
| -rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 39 | ||||
| -rw-r--r-- | xlators/storage/posix/src/posix.c | 76 | 
3 files changed, 73 insertions, 46 deletions
diff --git a/events/eventskeygen.py b/events/eventskeygen.py index 1e7b6b6958a..d2a137742db 100644 --- a/events/eventskeygen.py +++ b/events/eventskeygen.py @@ -139,9 +139,9 @@ keys = (      #posix events      "EVENT_POSIX_SAME_GFID",      "EVENT_POSIX_ALREADY_PART_OF_VOLUME", -    "EVENT_POSIX_INVALID_BRICK", +    "EVENT_POSIX_BRICK_NOT_IN_VOLUME",      "EVENT_POSIX_BRICK_VERIFICATION_FAILED", -    "EVENT_POSIX_ACL_NOTSUP", +    "EVENT_POSIX_ACL_NOT_SUPPORTED",      "EVENT_POSIX_HEALTH_CHECK_FAILED",      #afr events      "EVENT_AFR_QUORUM_MET", 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); diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 8478e64683e..d7b175c9434 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -56,6 +56,7 @@  #include "posix-aio.h"  #include "glusterfs-acl.h"  #include "posix-messages.h" +#include "events.h"  extern char *marker_xattrs[];  #define ALIGN_SIZE 4096 @@ -1485,6 +1486,12 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,                                  "and this can lead to inconsistencies.",                                  loc->path, uuid_utoa (uuid_req),                                  gfid_path ? gfid_path : "<NULL>"); + +                        gf_event (EVENT_POSIX_SAME_GFID, "gfid=%s;path=%s;" +                                  "newpath=%s;brick=%s:%s", +                                  uuid_utoa (uuid_req), +                                  gfid_path ? gfid_path : "<NULL>", loc->path, +                                  priv->hostname, priv->base_path);                  }          } else if (!uuid_req && frame->root->pid != GF_SERVER_PID_TRASH) {                  op_ret = -1; @@ -6844,6 +6851,31 @@ init (xlator_t *this)                  goto out;          } +        _private = GF_CALLOC (1, sizeof (*_private), +                              gf_posix_mt_posix_private); +        if (!_private) { +                ret = -1; +                goto out; +        } + +        _private->base_path = gf_strdup (dir_data->data); +        _private->base_path_length = strlen (_private->base_path); + +        ret = dict_get_str (this->options, "hostname", &_private->hostname); +        if (ret) { +                _private->hostname = GF_CALLOC (256, sizeof (char), +                                                gf_common_mt_char); +                if (!_private->hostname) { +                        goto out; +                } +                ret = gethostname (_private->hostname, 256); +                if (ret < 0) { +                        gf_msg (this->name, GF_LOG_WARNING, errno, +                                P_MSG_HOSTNAME_MISSING, +                                "could not find hostname "); +                } +        } +          /* Check for Extended attribute support, if not present, log it */          op_ret = sys_lsetxattr (dir_data->data,                                  "trusted.glusterfs.test", "working", 8, 0); @@ -6904,6 +6936,10 @@ init (xlator_t *this)                                          "mismatching volume-id (%s) received. "                                          "already is a part of volume %s ",                                          tmp_data->data, uuid_utoa (old_uuid)); +                                gf_event (EVENT_POSIX_ALREADY_PART_OF_VOLUME, +                                        "volume-id=%s;brick=%s:%s", +                                        uuid_utoa (old_uuid), +                                       _private->hostname, _private->base_path);                                  ret = -1;                                  goto out;                          } @@ -6913,12 +6949,18 @@ init (xlator_t *this)                                          P_MSG_VOLUME_ID_ABSENT,                                          "Extended attribute trusted.glusterfs."                                          "volume-id is absent"); +                                gf_event (EVENT_POSIX_BRICK_NOT_IN_VOLUME, +                                        "brick=%s:%s", +                                       _private->hostname, _private->base_path);                                  ret = -1;                                  goto out;                  }  else if ((size == -1) && (errno != ENODATA) &&                              (errno != ENOATTR)) {                          /* Wrong 'volume-id' is set, it should be error */ +                        gf_event (EVENT_POSIX_BRICK_VERIFICATION_FAILED, +                                "brick=%s:%s", +                                _private->hostname, _private->base_path);                          gf_msg (this->name, GF_LOG_WARNING, errno,                                  P_MSG_VOLUME_ID_FETCH_FAILED,                                  "%s: failed to fetch volume-id", @@ -6927,6 +6969,9 @@ init (xlator_t *this)                          goto out;                  } else {                          ret = -1; +                        gf_event (EVENT_POSIX_BRICK_VERIFICATION_FAILED, +                                "brick=%s:%s", +                                _private->hostname, _private->base_path);                          gf_msg (this->name, GF_LOG_ERROR, 0,                                  P_MSG_VOLUME_ID_FETCH_FAILED,                                  "failed to fetch proper volume id from export"); @@ -6977,24 +7022,18 @@ init (xlator_t *this)                  }          } +        ret = 0; +          size = sys_lgetxattr (dir_data->data, POSIX_ACL_ACCESS_XATTR,                                NULL, 0); -        if ((size < 0) && (errno == ENOTSUP)) +        if ((size < 0) && (errno == ENOTSUP)) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_ACL_NOTSUP,                          "Posix access control list is not supported."); - -        ret = 0; -        _private = GF_CALLOC (1, sizeof (*_private), -                              gf_posix_mt_posix_private); -        if (!_private) { -                ret = -1; -                goto out; +                gf_event (EVENT_POSIX_ACL_NOT_SUPPORTED, +                        "brick=%s:%s", _private->hostname, _private->base_path);          } -        _private->base_path = gf_strdup (dir_data->data); -        _private->base_path_length = strlen (_private->base_path); -          /*           * _XOPEN_PATH_MAX is the longest file path len we MUST           * support according to POSIX standard. When prepended @@ -7032,21 +7071,6 @@ init (xlator_t *this)          LOCK_INIT (&_private->lock); -        ret = dict_get_str (this->options, "hostname", &_private->hostname); -        if (ret) { -                _private->hostname = GF_CALLOC (256, sizeof (char), -                                                gf_common_mt_char); -                if (!_private->hostname) { -                        goto out; -                } -                ret = gethostname (_private->hostname, 256); -                if (ret < 0) { -                        gf_msg (this->name, GF_LOG_WARNING, errno, -                                P_MSG_HOSTNAME_MISSING, -                                "could not find hostname "); -                } -        } -          _private->export_statfs = 1;          tmp_data = dict_get (this->options, "export-statfs-size");          if (tmp_data) {  | 
