From 0343da57b51c8b83ae59743740632ec058a0d333 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Thu, 25 Aug 2016 22:20:30 +0530 Subject: glusterd: Improve mountbroker logs When Mountbroker mount fails, it was just returning EPERM or EACCESS without logging exact failure. This patch improves the logging by logging exact failure. Change-Id: I3cd905f95865153f70dfcc3bf1fa4dd19af16455 BUG: 1346138 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/15319 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-mountbroker.c | 56 +++++++++++++++++++++--- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-mountbroker.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c index 7c069ced984..f992adcfd6d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c +++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c @@ -447,7 +447,7 @@ _arg_parse_uid (char *val, void *data) } static int -evaluate_mount_request (gf_mount_spec_t *mspec, dict_t *argdict) +evaluate_mount_request (xlator_t *this, gf_mount_spec_t *mspec, dict_t *argdict) { struct gf_set_descriptor sd = {{0,},}; int i = 0; @@ -476,8 +476,14 @@ evaluate_mount_request (gf_mount_spec_t *mspec, dict_t *argdict) if (mspec->patterns[i].negative) match = !match; - if (!match) + if (!match) { + gf_msg (this->name, GF_LOG_ERROR, EPERM, + GD_MSG_MNTBROKER_SPEC_MISMATCH, + "Mountbroker spec mismatch!!! SET: %d " + "COMPONENT: %d. Review the mount args passed", + mspec->patterns[i].condition, i); return -EPERM; + } } ret = seq_dict_foreach (argdict, _arg_parse_uid, &uid); @@ -526,6 +532,7 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) int ret = 0; xlator_t *this = THIS; mode_t orig_umask = 0; + gf_boolean_t found_label = _gf_false; priv = this->private; GF_ASSERT (priv); @@ -536,12 +543,19 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) if (dict_get_str (this->options, "mountbroker-root", &mountbroker_root) != 0) { *op_errno = ENOENT; + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "'option mountbroker-root' " + "missing in glusterd vol file"); goto out; } GF_ASSERT (label); if (!*label) { *op_errno = EINVAL; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_MNTBROKER_LABEL_MISS, + "label is NULL (%s)", + strerror (*op_errno)); goto out; } @@ -550,11 +564,20 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) speclist) { if (strcmp (mspec->label, label) != 0) continue; - uid = evaluate_mount_request (mspec, argdict); + + found_label = _gf_true; + uid = evaluate_mount_request (this, mspec, argdict); break; } if (uid < 0) { *op_errno = -uid; + if (!found_label) { + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_MNTBROKER_LABEL_MISS, + "Missing mspec: Check the corresponding option " + "in glusterd vol file for mountbroker user: %s", + label); + } goto out; } @@ -562,11 +585,17 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) seq_dict_foreach (argdict, _volname_get, &volname); if (!volname) { *op_errno = EINVAL; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_DICT_GET_FAILED, + "Dict get failed for the key 'volname'"); goto out; } if (glusterd_volinfo_find (volname, &vol) != 0 || !glusterd_is_volume_started (vol)) { *op_errno = ENOENT; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_MOUNT_REQ_FAIL, + "Either volume is not started or volinfo not found"); goto out; } @@ -596,22 +625,34 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) ret = 0; if (ret == -1) { *op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_SYSCALL_FAIL, + "Mountbroker User directory creation failed"); goto out; } ret = sys_lstat (mtptemp, &st); if (ret == -1) { *op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_SYSCALL_FAIL, + "stat on mountbroker user directory failed"); goto out; } if (!(S_ISDIR (st.st_mode) && (st.st_mode & ~S_IFMT) == 0700 && st.st_uid == uid && st.st_gid == 0)) { *op_errno = EACCES; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_MOUNT_REQ_FAIL, + "Incorrect mountbroker user directory attributes"); goto out; } *sla = '/'; if (!mkdtemp (mtptemp)) { *op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_SYSCALL_FAIL, + "Mountbroker mount directory creation failed"); goto out; } @@ -630,6 +671,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) umask(orig_umask); if (ret == -1) { *op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_SYSCALL_FAIL, + "Mountbroker cookie file creation failed"); goto out; } sys_close (ret); @@ -652,6 +696,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) *cookieswitch = '\0'; if (ret == -1) { *op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, *op_errno, + GD_MSG_SYSCALL_FAIL, + "symlink or rename failed"); goto out; } @@ -674,8 +721,7 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) ret = -1; gf_msg (this->name, GF_LOG_WARNING, *op_errno, GD_MSG_MOUNT_REQ_FAIL, - "unsuccessful mount request (%s)", - strerror (*op_errno)); + "unsuccessful mount request"); if (mtptemp) { *cookieswitch = '/'; sys_unlink (mtptemp); -- cgit