diff options
author | Hari Gowtham <hgowtham@dhcp35-85.lab.eng.blr.redhat.com> | 2015-05-27 13:17:30 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-06-24 23:59:47 -0700 |
commit | 7b7e82f8770643e9edd5650340a387ea70e771f2 (patch) | |
tree | fba10fa9d5f0926ca24cb3320008d0e18dd18de5 /xlators/storage/posix/src/posix-handle.c | |
parent | 3e9bc0b4a00e006410521a78011a8feae0af9234 (diff) |
Porting new log messages for posix
Backport of http://review.gluster.org/#/c/9893/
Cherry picked from 59e1c79ac6953e552fbdc8c627f5dc1d02eeacc8
>Change-Id: I29bdeefb755805858e3cb1817b679cb6f9a476a9
>BUG: 1194640
>Signed-off-by: Hari Gowtham <hgowtham@dhcp35-85.lab.eng.blr.redhat.com>
>Reviewed-on: http://review.gluster.org/9893
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
Change-Id: I29bdeefb755805858e3cb1817b679cb6f9a476a9
BUG: 1217722
Signed-off-by: Hari Gowtham <hgowtham@dhcp35-85.lab.eng.blr.redhat.com>
Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
Reviewed-on: http://review.gluster.org/11279
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-handle.c')
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 178 |
1 files changed, 96 insertions, 82 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index 6182fd8a630..281d52fde71 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -25,6 +25,7 @@ #include "posix.h" #include "xlator.h" #include "syscall.h" +#include "posix-messages.h" #include "compat-errno.h" @@ -72,12 +73,8 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize, if (type & POSIX_ANCESTRY_DENTRY) { entry = gf_dirent_for_name (dir_name); - if (!entry) { - gf_log (THIS->name, GF_LOG_ERROR, - "could not create gf_dirent for entry %s: (%s)", - dir_name, strerror (errno)); + if (!entry) goto out; - } entry->d_stat = *iabuf; entry->inode = inode_ref (inode); @@ -152,9 +149,9 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, len = readlink (dir_handle, linkname, PATH_MAX); if (len < 0) { - gf_log (this->name, GF_LOG_ERROR, "could not read the link " - "from the gfid handle %s (%s)", dir_handle, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED, + "could not read the link from the gfid handle %s ", + dir_handle); goto out; } @@ -245,9 +242,9 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen, /* is a directory's symlink-handle */ ret = readlink (base_str, linkname, 512); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "internal readlink failed on %s (%s)", - base_str, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED, + "internal readlink failed on %s ", + base_str); goto err; } @@ -264,14 +261,14 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen, } if (ret < 50 || ret >= 512) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LINK_FAILED, "malformed internal link %s for %s", linkname, base_str); goto err; } if (memcmp (linkname, "../../", 6) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED, "malformed internal link %s for %s", linkname, base_str); goto err; @@ -282,7 +279,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen, (linkname[8] != '/') || (linkname[11] != '/') || (linkname[48] != '/')) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED, "malformed internal link %s for %s", linkname, base_str); goto err; @@ -292,7 +289,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen, (linkname[25] != '-') || (linkname[30] != '-') || (linkname[35] != '-')) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED, "malformed internal link %s for %s", linkname, base_str); goto err; @@ -301,7 +298,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen, blen = link_len - 48; if (len + blen >= maxlen) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED, "Unable to form handle path for %s (maxlen = %d)", buf, maxlen); goto err; @@ -461,7 +458,8 @@ posix_handle_init (xlator_t *this) ret = stat (priv->base_path, &exportbuf); if (ret || !S_ISDIR (exportbuf.st_mode)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_HANDLE_CREATE, "Not a directory: %s", priv->base_path); return -1; } @@ -477,21 +475,24 @@ posix_handle_init (xlator_t *this) if (errno == ENOENT) { ret = mkdir (handle_pfx, 0600); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "Creating directory %s failed: %s", - handle_pfx, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "Creating directory %s failed", + handle_pfx); return -1; } } else { - gf_log (this->name, GF_LOG_ERROR, - "Checking for %s failed: %s", - handle_pfx, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "Checking for %s failed", + handle_pfx); return -1; } break; case 0: if (!S_ISDIR (stbuf.st_mode)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_HANDLE_CREATE, "Not a directory: %s", handle_pfx); return -1; @@ -509,25 +510,26 @@ posix_handle_init (xlator_t *this) switch (ret) { case -1: if (errno != ENOENT) { - gf_log (this->name, GF_LOG_ERROR, - "%s: %s", priv->base_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "%s", priv->base_path); return -1; } ret = posix_handle_mkdir_hashes (this, rootstr); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "mkdir %s failed (%s)", - rootstr, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "mkdir %s failed", rootstr); return -1; } ret = symlink ("../../..", rootstr); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "symlink %s creation failed (%s)", - rootstr, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "symlink %s creation failed", + rootstr); return -1; } break; @@ -536,7 +538,8 @@ posix_handle_init (xlator_t *this) (exportbuf.st_dev == rootbuf.st_dev)) return 0; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_HANDLE_CREATE, "Different dirs %s (%lld/%lld) != %s (%lld/%lld)", priv->base_path, (long long) exportbuf.st_ino, (long long) exportbuf.st_dev, rootstr, @@ -578,18 +581,21 @@ posix_handle_new_trash_init (xlator_t *this, char *trash) if (errno == ENOENT) { ret = mkdir (trash, 0755); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "Creating directory %s failed: %s", - trash, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_TRASH_CREATE, + "Creating directory %s failed", + trash); } } else { - gf_log (this->name, GF_LOG_ERROR, "Checking for %s " - "failed: %s", trash, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_TRASH_CREATE, + "Checking for %s failed", trash); } break; case 0: if (!S_ISDIR (stbuf.st_mode)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_TRASH_CREATE, "Not a directory: %s", trash); ret = -1; } @@ -614,8 +620,9 @@ posix_mv_old_trash_into_new_trash (xlator_t *this, char *old, char *new) uuid_utoa (dest_name)); ret = rename (old, dest_old); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "Not able to move " - "%s -> %s (%s)", old, dest_old, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_TRASH_CREATE, + "Not able to move %s -> %s ", old, dest_old); } out: return ret; @@ -664,9 +671,9 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath) ret = mkdir (parpath, 0700); if (ret == -1 && errno != EEXIST) { - gf_log (this->name, GF_LOG_ERROR, - "error mkdir hash-1 %s (%s)", - parpath, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "error mkdir hash-1 %s ", parpath); return -1; } @@ -675,9 +682,9 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath) ret = mkdir (parpath, 0700); if (ret == -1 && errno != EEXIST) { - gf_log (this->name, GF_LOG_ERROR, - "error mkdir hash-2 %s (%s)", - parpath, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_HANDLE_CREATE, + "error mkdir hash-2 %s ", parpath); return -1; } @@ -697,41 +704,43 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat ret = lstat (newpath, &newbuf); if (ret == -1 && errno != ENOENT) { - gf_log (this->name, GF_LOG_WARNING, - "%s: %s", newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "%s", newpath); return -1; } if (ret == -1 && errno == ENOENT) { ret = posix_handle_mkdir_hashes (this, newpath); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "mkdir %s failed (%s)", - newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, "mkdir %s failed ", + newpath); return -1; } ret = sys_link (oldpath, newpath); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "link %s -> %s failed (%s)", - oldpath, newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, "link %s -> %s" + "failed ", oldpath, newpath); return -1; } ret = lstat (newpath, &newbuf); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "lstat on %s failed (%s)", - newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "lstat on %s failed", newpath); return -1; } } if (newbuf.st_ino != oldbuf->st_ino || newbuf.st_dev != oldbuf->st_dev) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_HANDLE_CREATE, "mismatching ino/dev between file %s (%lld/%lld) " "and handle %s (%lld/%lld)", oldpath, (long long) oldbuf->st_ino, (long long) oldbuf->st_dev, @@ -757,41 +766,43 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc, ret = lstat (newpath, &newbuf); if (ret == -1 && errno != ENOENT) { - gf_log (this->name, GF_LOG_WARNING, - "%s: %s", newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, "%s", newpath); return -1; } if (ret == -1 && errno == ENOENT) { ret = posix_handle_mkdir_hashes (this, newpath); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "mkdir %s failed (%s)", - newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "mkdir %s failed ", newpath); return -1; } ret = symlink (oldpath, newpath); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "symlink %s -> %s failed (%s)", - oldpath, newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "symlink %s -> %s failed", + oldpath, newpath); return -1; } ret = lstat (newpath, &newbuf); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "stat on %s failed (%s)", - newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "stat on %s failed ", newpath); return -1; } } ret = stat (real_path, &newbuf); if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "stat on %s failed (%s)", newpath, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "stat on %s failed ", newpath); return -1; } @@ -800,7 +811,8 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc, if (newbuf.st_ino != oldbuf->st_ino || newbuf.st_dev != oldbuf->st_dev) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_HANDLE_CREATE, "mismatching ino/dev between file %s (%lld/%lld) " "and handle %s (%lld/%lld)", oldpath, (long long) oldbuf->st_ino, (long long) oldbuf->st_dev, @@ -825,16 +837,16 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid) if (ret == -1) { if (errno != ENOENT) { - gf_log (this->name, GF_LOG_WARNING, - "%s: %s", path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_DELETE, "%s", path); } goto out; } ret = unlink (path); if (ret == -1) { - gf_log (this->name, GF_LOG_WARNING, - "unlink %s failed (%s)", path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_DELETE, "unlink %s failed ", path); } out: @@ -856,7 +868,8 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename) MAKE_HANDLE_PATH (path, this, gfid, basename); if (!path) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_HANDLE_DELETE, "Failed to create handle path for %s (%s)", basename, uuid_utoa(gfid)); return -1; @@ -865,8 +878,8 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename) ret = posix_istat (this, gfid, basename, &stat); if (ret == -1) { - gf_log (this->name, GF_LOG_WARNING, - "%s: %s", path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HANDLE_DELETE, "%s", path); return -1; } @@ -886,7 +899,8 @@ posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid, MAKE_HANDLE_PATH (newpath, this, gfid, NULL); if (!newpath) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_HANDLE_CREATE, "Failed to create handle path (%s)", uuid_utoa(gfid)); return ret; } |