From 73517fedf7840363b9f688183e604a617d934652 Mon Sep 17 00:00:00 2001 From: arao Date: Fri, 12 Jun 2015 16:35:53 +0530 Subject: dht: Adding log messages to the new logging framework Backported from: http://review.gluster.org/10021 > Change-Id: Ib3bb61c5223f409c23c68100f3fe884918d2dc3f > BUG: 1194640 > Reviewed-on: http://review.gluster.org/10021 > Reviewed-by: N Balachandran > Reviewed-by: Joseph Fernandes > Tested-by: Joseph Fernandes > Reviewed-by: Dan Lambright > Reviewed-by: Raghavendra G > Tested-by: Raghavendra G > Signed-off-by: arao BUG: 1217722 Change-Id: Ide79c6c1e6a466fb52f955c90a2b22711bec794a Signed-off-by: arao Signed-off-by: Anusha Rao Reviewed-on: http://review.gluster.org/11350 Tested-by: NetBSD Build System Reviewed-by: Raghavendra G Tested-by: Gluster Build System --- xlators/cluster/dht/src/dht-common.c | 301 ++++++++++++++++++++--------------- 1 file changed, 170 insertions(+), 131 deletions(-) (limited to 'xlators/cluster/dht/src/dht-common.c') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 4c36b3c822e..2a857f27021 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -48,7 +48,8 @@ dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) int64_t src_dir_count = 0; if (value == NULL) { - gf_log ("dht", GF_LOG_WARNING, "data value is NULL"); + gf_msg ("dht", GF_LOG_WARNING, 0, + DHT_MSG_DATA_NULL, "data value is NULL"); ret = -1; goto out; } @@ -58,7 +59,8 @@ dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) meta_dst = GF_CALLOC (1, sizeof (quota_meta_t), gf_common_quota_meta_t); if (meta_dst == NULL) { - gf_msg ("dht", GF_LOG_WARNING, 0, DHT_MSG_NO_MEMORY, + gf_msg ("dht", GF_LOG_WARNING, ENOMEM, + DHT_MSG_NO_MEMORY, "Memory allocation failed"); ret = -1; goto out; @@ -66,7 +68,8 @@ dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) ret = dict_set_bin (dst, key, meta_dst, sizeof (quota_meta_t)); if (ret < 0) { - gf_log ("dht", GF_LOG_WARNING, + gf_msg ("dht", GF_LOG_WARNING, EINVAL, + DHT_MSG_DICT_SET_FAILED, "dht aggregate dict set failed"); GF_FREE (meta_dst); ret = -1; @@ -116,8 +119,9 @@ dht_aggregate (dict_t *this, char *key, data_t *value, void *data) if (strcmp (key, QUOTA_SIZE_KEY) == 0) { ret = dht_aggregate_quota_xattr (dst, key, value); if (ret) { - gf_log ("dht", GF_LOG_WARNING, "Failed to " - "aggregate qutoa xattr"); + gf_msg ("dht", GF_LOG_WARNING, 0, + DHT_MSG_AGGREGATE_QUOTA_XATTR_FAILED, + "Failed to aggregate quota xattr"); goto out; } } else if (fnmatch (GF_XATTR_STIME_PATTERN, key, FNM_NOESCAPE) == 0) { @@ -383,10 +387,9 @@ dht_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "lookup of %s on %s returned error (%s)", - local->loc.path, prev->this->name, - strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "lookup of %s on %s returned error", + local->loc.path, prev->this->name); goto unlock; } @@ -578,10 +581,9 @@ dht_lookup_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "lookup of %s on %s returned error (%s)", - local->loc.path, prev->this->name, - strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "lookup of %s on %s returned error", + local->loc.path, prev->this->name); goto unlock; } @@ -705,10 +707,10 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, LOCK (&frame->lock); { - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, op_errno, "revalidate lookup of %s " - "returned with op_ret %d and op_errno %d", - local->loc.path, op_ret, op_errno); + "returned with op_ret %d", + local->loc.path, op_ret); if (op_ret == -1) { local->op_errno = op_errno; @@ -716,11 +718,12 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_errno != ENOTCONN) && (op_errno != ENOENT) && (op_errno != ESTALE)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, op_errno, + DHT_MSG_REVALIDATE_CBK_INFO, "Revalidate: subvolume %s for %s " - "(gfid = %s) returned -1 (%s)", + "(gfid = %s) returned -1", prev->this->name, local->loc.path, - gfid, strerror (op_errno)); + gfid); } if (op_errno == ESTALE) { /* propagate the ESTALE to parent. @@ -771,7 +774,8 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, conf->link_xattr_name); if (is_linkfile) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_REVALIDATE_CBK_INFO, "Revalidate: linkfile found %s, (gfid = %s)", local->loc.path, gfid); local->return_estale = 1; @@ -927,7 +931,7 @@ dht_lookup_linkfile_create_cbk (call_frame_t *frame, void *cookie, ret = dht_layout_preset (this, local->cached_subvol, local->loc.inode); if (ret < 0) { - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, EINVAL, "Failed to set layout for subvolume %s, " "(gfid = %s)", cached_subvol ? cached_subvol->name : "", @@ -980,7 +984,8 @@ dht_lookup_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = (dht_local_t*)frame->local; path = local->loc.path; - gf_log (this->name, GF_LOG_INFO, "lookup_unlink returned with " + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_UNLINK_LOOKUP_INFO, "lookup_unlink returned with " "op_ret -> %d and op-errno -> %d for %s", op_ret, op_errno, ((path == NULL)? "null" : path )); @@ -1005,7 +1010,8 @@ dht_lookup_unlink_of_false_linkto_cbk (call_frame_t *frame, void *cookie, local = (dht_local_t*)frame->local; path = local->loc.path; - gf_log (this->name, GF_LOG_INFO, "lookup_unlink returned with " + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_UNLINK_LOOKUP_INFO, "lookup_unlink returned with " "op_ret -> %d and op-errno -> %d for %s", op_ret, op_errno, ((path == NULL)? "null" : path )); @@ -1029,7 +1035,8 @@ dht_lookup_unlink_of_false_linkto_cbk (call_frame_t *frame, void *cookie, if (op_errno == EBUSY) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_UNLINK_FAILED, "Could not unlink the linkto file as " "either fd is open and/or linkto xattr " "is set for %s", @@ -1066,7 +1073,9 @@ dht_lookup_unlink_stale_linkto_cbk (call_frame_t *frame, void *cookie, if (local && local->loc.path) path = local->loc.path; - gf_log (this->name, GF_LOG_INFO, "Returned with op_ret %d and " + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_UNLINK_LOOKUP_INFO, + "Returned with op_ret %d and " "op_errno %d for %s", op_ret, op_errno, ((path==NULL)?"null":path)); @@ -1293,7 +1302,8 @@ dht_lookup_everywhere_done (call_frame_t *frame, xlator_t *this) ret = dht_layout_preset (this, cached_subvol, local->loc.inode); if (ret) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LAYOUT_PRESET_FAILED, "Could not set pre-set layout " "for subvolume %s", cached_subvol->name); @@ -1382,7 +1392,8 @@ preset_layout: local->op_errno = 0; layout = dht_layout_for_subvol (this, cached_subvol); if (!layout) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_SUBVOL_INFO, "%s: no pre-set layout for subvolume %s," " gfid = %s", local->loc.path, (cached_subvol ? @@ -1392,7 +1403,8 @@ preset_layout: ret = dht_layout_set (this, local->inode, layout); if (ret < 0) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_SUBVOL_INFO, "%s: failed to set layout for subvol %s, " "gfid = %s", local->loc.path, (cached_subvol ? @@ -1426,7 +1438,8 @@ preset_layout: ret = dht_layout_preset (frame->this, cached_subvol, local->inode); if (ret < 0) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LAYOUT_PRESET_FAILED, "Failed to set layout for subvol %s" ", gfid = %s", cached_subvol ? cached_subvol->name : @@ -1643,7 +1656,8 @@ unlock: dict_unref (dict_req); } else { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_SUBVOL_INFO, "attempting deletion of stale linkfile " "%s on %s (hashed subvol is %s)", loc->path, subvol->name, @@ -1741,10 +1755,10 @@ dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie, gf_uuid_unparse(loc->gfid, gfid); if (op_ret == -1) { - gf_log (this->name, GF_LOG_INFO, - "Lookup of %s on %s (following linkfile) failed (%s)" - ",gfid = %s", local->loc.path, subvol->name, - strerror (op_errno), gfid); + gf_msg (this->name, GF_LOG_INFO, op_errno, + DHT_MSG_LINK_FILE_LOOKUP_INFO, + "Lookup of %s on %s (following linkfile) failed " + ",gfid = %s", local->loc.path, subvol->name, gfid); /* If cached subvol returned ENOTCONN, do not do lookup_everywhere. We need to make sure linkfile does not get @@ -1758,14 +1772,16 @@ dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie, } if (check_is_dir (inode, stbuf, xattr)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LINK_FILE_LOOKUP_INFO, "Lookup of %s on %s (following linkfile) reached dir," " gfid = %s", local->loc.path, subvol->name, gfid); goto err; } if (check_is_linkfile (inode, stbuf, xattr, conf->link_xattr_name)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LINK_FILE_LOOKUP_INFO, "lookup of %s on %s (following linkfile) reached link," "gfid = %s", local->loc.path, subvol->name, gfid); goto err; @@ -1788,7 +1804,8 @@ dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie, ret = dht_layout_preset (this, prev->this, inode); if (ret < 0) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LAYOUT_PRESET_FAILED, "Failed to set layout for subvolume %s," "gfid = %s", prev->this->name, gfid); op_ret = -1; @@ -1905,9 +1922,9 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (!op_ret && gf_uuid_is_null (local->gfid)) memcpy (local->gfid, stbuf->ia_gfid, 16); - gf_msg_debug (this->name, 0, - "fresh_lookup returned for %s with op_ret %d and " - "op_errno %d", loc->path, op_ret, op_errno); + gf_msg_debug (this->name, op_errno, + "fresh_lookup returned for %s with op_ret %d", + loc->path, op_ret); if (!conf->vch_forced) { ret = dict_get_uint32 (xattr, conf->commithash_xattr_name, @@ -1933,13 +1950,13 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, (parent_layout->commit_hash != conf->vol_commit_hash)) { gf_msg_debug (this->name, 0, - "hashes don't match (ret - %d," - " parent_layout - %p, parent_hash - %x," - " vol_hash - %x), do global lookup", - ret, parent_layout, - (parent_layout ? - parent_layout->commit_hash : -1), - conf->vol_commit_hash); + "hashes don't match (ret - %d," + " parent_layout - %p, parent_hash - %x," + " vol_hash - %x), do global lookup", + ret, parent_layout, + (parent_layout ? + parent_layout->commit_hash : -1), + conf->vol_commit_hash); local->op_errno = ENOENT; dht_lookup_everywhere (frame, this, loc); return 0; @@ -1984,9 +2001,10 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } if (op_ret == -1) { - gf_msg_debug (this->name, 0, "Lookup of %s for subvolume" - " %s failed with error %s", loc->path, - prev->this->name, strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "Lookup of %s for subvolume" + " %s failed", loc->path, + prev->this->name); goto out; } @@ -1998,7 +2016,8 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ret = dht_layout_preset (this, prev->this, inode); if (ret < 0) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_LAYOUT_PRESET_FAILED, "could not set pre-set layout for subvolume %s", prev->this->name); op_ret = -1; @@ -2011,7 +2030,8 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, subvol = dht_linkfile_subvol (this, inode, stbuf, xattr); if (!subvol) { - gf_log (this->name, GF_LOG_INFO, "linkfile not having link " + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_SUBVOL_INFO, "linkfile not having link " "subvol for %s", loc->path); gf_msg_debug (this->name, 0, @@ -2069,7 +2089,7 @@ dht_check_and_set_acl_xattr_req (inode_t *inode, dict_t *xattr_req) if (!dict_get (xattr_req, POSIX_ACL_ACCESS_XATTR)) { ret = dict_set_int8 (xattr_req, POSIX_ACL_ACCESS_XATTR, 0); if (ret) - gf_msg (THIS->name, GF_LOG_WARNING, 0, + gf_msg (THIS->name, GF_LOG_WARNING, -ret, DHT_MSG_DICT_SET_FAILED, "Failed to set dictionary value:key = %s", POSIX_ACL_ACCESS_XATTR); @@ -2078,7 +2098,7 @@ dht_check_and_set_acl_xattr_req (inode_t *inode, dict_t *xattr_req) if (!dict_get (xattr_req, POSIX_ACL_DEFAULT_XATTR)) { ret = dict_set_int8 (xattr_req, POSIX_ACL_DEFAULT_XATTR, 0); if (ret) - gf_msg (THIS->name, GF_LOG_WARNING, 0, + gf_msg (THIS->name, GF_LOG_WARNING, -ret, DHT_MSG_DICT_SET_FAILED, "Failed to set dictionary value:key = %s", POSIX_ACL_DEFAULT_XATTR); @@ -2129,7 +2149,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this, /* check if loc_dup() is successful */ if (ret == -1) { op_errno = errno; - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, errno, "copying location failed for path=%s", loc->path); goto err; @@ -2349,9 +2369,9 @@ dht_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { local->op_ret = -1; local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "Unlink: subvolume %s returned -1 (%s)", - prev->this->name, strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "Unlink: subvolume %s returned -1", + prev->this->name); goto unlock; } @@ -2395,10 +2415,10 @@ dht_unlink_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret == -1) && !((op_errno == ENOENT) || (op_errno == ENOTCONN))) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, op_errno, "Unlink link: subvolume %s" - " returned -1 (%s)", - prev->this->name, strerror (op_errno)); + " returned -1", + prev->this->name); goto unlock; } @@ -2446,9 +2466,9 @@ dht_err_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { if (op_ret == -1) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "subvolume %s returned -1 (%s)", - prev->this->name, strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "subvolume %s returned -1", + prev->this->name); goto unlock; } @@ -2512,9 +2532,9 @@ dht_vgetxattr_alloc_and_fill (dht_local_t *local, dict_t *xattr, xlator_t *this, ret = dict_get_str (xattr, local->xsel, &value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Subvolume %s returned -1 (%s)", this->name, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_GET_XATTR_FAILED, + "Subvolume %s returned -1", this->name); local->op_ret = -1; local->op_errno = op_errno; goto out; @@ -2599,7 +2619,8 @@ dht_vgetxattr_fill_and_set (dht_local_t *local, dict_t **dict, xlator_t *this, (void) snprintf (xattr_buf, local->alloc_len, "%s", local->xattr_val); } else { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_GET_XATTR_FAILED, "Unknown local->xsel (%s)", local->xsel); GF_FREE (xattr_buf); goto out; @@ -2638,9 +2659,9 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { this_call_cnt = --local->call_cnt; if (op_ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "getxattr err (%s) for dir", - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_GET_XATTR_FAILED, + "getxattr err for dir"); local->op_ret = -1; local->op_errno = op_errno; goto unlock; @@ -2649,15 +2670,18 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ret = dict_get_str (xattr, local->xsel, &uuid_str); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "Failed to " - "get %s", local->xsel); + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_DICT_GET_FAILED, + "Failed to get %s", local->xsel); local->op_ret = -1; local->op_errno = EINVAL; goto unlock; } if (gf_uuid_parse (uuid_str, node_uuid)) { - gf_log (this->name, GF_LOG_ERROR, "Failed to parse uuid" + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_UUID_PARSE_ERROR, + "Failed to parse uuid" " failed for %s", prev->this->name); local->op_ret = -1; local->op_errno = EINVAL; @@ -2665,12 +2689,12 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } if (gf_uuid_compare (node_uuid, conf->defrag->node_uuid)) { - gf_log (this->name, GF_LOG_DEBUG, "subvol %s does not" + gf_msg_debug (this->name, 0, "subvol %s does not" "belong to this node", prev->this->name); } else { conf->local_subvols[(conf->local_subvols_cnt)++] = prev->this; - gf_log (this->name, GF_LOG_DEBUG, "subvol %s belongs to" + gf_msg_debug (this->name, 0, "subvol %s belongs to" " this node", prev->this->name); } } @@ -2714,9 +2738,9 @@ dht_vgetxattr_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, this_call_cnt = --local->call_cnt; if (op_ret < 0) { if (op_errno != ENOTCONN) { - gf_log (this->name, GF_LOG_ERROR, - "getxattr err (%s) for dir", - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_GET_XATTR_FAILED, + "getxattr err for dir"); local->op_ret = -1; local->op_errno = op_errno; } @@ -2727,7 +2751,8 @@ dht_vgetxattr_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ret = dht_vgetxattr_alloc_and_fill (local, xattr, this, op_errno); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_DICT_SET_FAILED, "alloc or fill failure"); } unlock: @@ -2774,9 +2799,10 @@ dht_vgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { local->op_ret = -1; local->op_errno = op_errno; - gf_log (this->name, GF_LOG_ERROR, - "vgetxattr: Subvolume %s returned -1 (%s)", - prev->this->name, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + DHT_MSG_GET_XATTR_FAILED, + "vgetxattr: Subvolume %s returned -1", + prev->this->name); goto unwind; } @@ -2935,7 +2961,8 @@ dht_getxattr_get_real_filename_cbk (call_frame_t *frame, void *cookie, local->op_ret = op_ret; local->op_errno = op_errno; - gf_log (this->name, GF_LOG_WARNING, "At least " + gf_msg (this->name, GF_LOG_WARNING, op_errno, + DHT_MSG_UPGRADE_BRICKS, "At least " "one of the bricks does not support " "this operation. Please upgrade all " "bricks."); @@ -2954,9 +2981,9 @@ dht_getxattr_get_real_filename_cbk (call_frame_t *frame, void *cookie, * down subvol and return a good result(if any) * from other subvol. */ - gf_log (this->name, GF_LOG_WARNING, - "Failed to get real filename. " - "error:%s", strerror (op_errno)); + gf_msg (this->name, GF_LOG_WARNING, op_errno, + DHT_MSG_GET_XATTR_FAILED, + "Failed to get real filename."); goto unlock; } @@ -2980,8 +3007,8 @@ dht_getxattr_get_real_filename_cbk (call_frame_t *frame, void *cookie, local->op_ret = op_ret; local->op_errno = 0; - gf_log (this->name, GF_LOG_DEBUG, "Found a matching " - "file."); + gf_msg_debug (this->name, 0, "Found a matching " + "file."); } unlock: UNLOCK (&frame->lock); @@ -3106,7 +3133,9 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, ret = gf_asprintf (&node_uuid_key, "%s", GF_XATTR_NODE_UUID_KEY); if (ret == -1 || !node_uuid_key) { - gf_log (this->name, GF_LOG_ERROR, "Failed to copy key"); + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_NO_MEMORY, + "Failed to copy key"); op_errno = ENOMEM; goto err; } @@ -3442,8 +3471,8 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this, DHT_IATT_IN_XDATA_KEY, "yes"); if (ret) { gf_msg_debug (this->name, 0, - "Failed to set dictionary key %s for fd=%p", - DHT_IATT_IN_XDATA_KEY, fd); + "Failed to set dictionary key %s for fd=%p", + DHT_IATT_IN_XDATA_KEY, fd); } STACK_WIND (frame, dht_file_setxattr_cbk, subvol, @@ -3719,13 +3748,12 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY); if (tmp) { - ret = dict_get_uint32(xattr, "new-commit-hash", &new_hash); if (ret == 0) { - gf_log (this->name, GF_LOG_DEBUG, - "updating commit hash for %s from %u to %u", - uuid_utoa(loc->gfid), - layout->commit_hash, new_hash); + gf_msg_debug (this->name, 0, + "updating commit hash for %s from %u to %u", + uuid_utoa(loc->gfid), + layout->commit_hash, new_hash); layout->commit_hash = new_hash; ret = dht_update_commit_hash_for_layout (frame); @@ -3736,7 +3764,8 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, return ret; } - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_FIX_LAYOUT_INFO, "fixing the layout of %s", loc->path); ret = dht_fix_directory_layout (frame, dht_common_setxattr_cbk, @@ -3766,7 +3795,8 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, } return ret; } - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_OPERATION_NOT_SUP, "wrong 'directory-spread-count' value (%s)", value); op_errno = ENOTSUP; goto err; @@ -3927,9 +3957,9 @@ dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { if (op_ret == -1) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "subvolume %s returned -1 (%s)", - prev->this->name, strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "subvolume %s returned -1", + prev->this->name); goto unlock; } @@ -4015,7 +4045,8 @@ dht_removexattr (call_frame_t *frame, xlator_t *this, ret = dict_set_dynstr_with_alloc (xdata, DHT_IATT_IN_XDATA_KEY, "yes"); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + DHT_MSG_DICT_SET_FAILED, "Failed to " "set dictionary key %s for %s", DHT_IATT_IN_XDATA_KEY, loc->path); } @@ -4103,7 +4134,8 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this, ret = dict_set_dynstr_with_alloc (xdata, DHT_IATT_IN_XDATA_KEY, "yes"); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + DHT_MSG_DICT_SET_FAILED, "Failed to " "set dictionary key %s for fd=%p", DHT_IATT_IN_XDATA_KEY, fd); } @@ -4141,9 +4173,9 @@ dht_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { if (op_ret == -1) { local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "subvolume %s returned -1 (%s)", - prev->this->name, strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "subvolume %s returned -1", + prev->this->name); goto unlock; } @@ -4235,7 +4267,9 @@ dht_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, break; default: - gf_log (this->name, GF_LOG_ERROR, "Encountered third " + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_INVALID_VALUE, + "Encountered third " "value for boolean variable %d", local->quota_deem_statfs); break; @@ -4650,7 +4684,7 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (!subvol || (subvol == prev->this)) { entry = gf_dirent_for_name (orig_entry->d_name); if (!entry) { - gf_msg (this->name, GF_LOG_ERROR, 0, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, DHT_MSG_NO_MEMORY, "Memory allocation failed "); goto unwind; @@ -4933,7 +4967,7 @@ dht_newfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ret = dht_layout_preset (this, prev, inode); if (ret < 0) { - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, EINVAL, "could not set pre-set layout for subvolume %s", prev? prev->name: NULL); op_ret = -1; @@ -5511,7 +5545,8 @@ dht_create (call_frame_t *frame, xlator_t *this, if (dht_filter_loc_subvol_key (this, loc, &local->loc, &subvol)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_SUBVOL_INFO, "creating %s on %s (got create on %s)", local->loc.path, subvol->name, loc->path); STACK_WIND (frame, dht_create_cbk, @@ -5863,11 +5898,11 @@ dht_rmdir_hashed_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } } - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, op_errno, "rmdir on %s for %s failed " - "(gfid = %s) (%s)", + "(gfid = %s)", prev->this->name, local->loc.path, - gfid, strerror (op_errno)); + gfid); goto unlock; } @@ -5943,11 +5978,11 @@ dht_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_uuid_unparse(local->loc.gfid, gfid); - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, op_errno, "rmdir on %s for %s failed." - "(gfid = %s) (%s)", + "(gfid = %s)", prev->this->name, local->loc.path, - gfid, strerror (op_errno)); + gfid); goto unlock; } @@ -6110,10 +6145,9 @@ dht_rmdir_linkfile_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this } else { main_local->op_ret = -1; main_local->op_errno = op_errno; - gf_msg_debug (this->name, 0, - "Unlink of %s on %s failed. (gfid = %s) (%s)", - local->loc.path, src->name, gfid, - strerror (op_errno)); + gf_msg_debug (this->name, op_errno, + "Unlink of %s on %s failed. (gfid = %s)", + local->loc.path, src->name, gfid); } this_call_cnt = dht_frame_return (main_frame); @@ -6155,7 +6189,8 @@ dht_rmdir_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_uuid_unparse(local->loc.gfid, gfid); - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_NOT_LINK_FILE_ERROR, "%s on %s is not a linkfile (type=0%o, gfid = %s)", local->loc.path, src->name, stbuf->ia_type, gfid); goto err; @@ -6200,7 +6235,8 @@ dht_rmdir_cached_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, main_local->op_ret = -1; main_local->op_errno = ENOTEMPTY; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_SUBVOL_ERROR, "%s found on cached subvol %s", local->loc.path, src->name); goto err; @@ -6212,7 +6248,8 @@ dht_rmdir_cached_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, xattrs = dict_new (); if (!xattrs) { - gf_log (this->name, GF_LOG_ERROR, "dict_new failed"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + DHT_MSG_NO_MEMORY, "dict_new failed"); goto err; } @@ -6281,7 +6318,8 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this, xattrs = dict_new (); if (!xattrs) { - gf_log (this->name, GF_LOG_ERROR, "dict_new failed"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + DHT_MSG_NO_MEMORY, "dict_new failed"); return -1; } @@ -6344,7 +6382,8 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this, subvol = dht_linkfile_subvol (this, NULL, &trav->d_stat, trav->dict); if (!subvol) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + DHT_MSG_INVALID_LINKFILE, "Linkfile does not have link subvolume. " "path = %s, gfid = %s", lookup_local->loc.path, gfid); @@ -6440,11 +6479,10 @@ dht_rmdir_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { gf_uuid_unparse(local->loc.gfid, gfid); - gf_msg_debug (this->name, 0, + gf_msg_debug (this->name, op_errno, "opendir on %s for %s failed, " - "gfid = %s, (%s)", - prev->this->name, local->loc.path, gfid, - strerror (op_errno)); + "gfid = %s,", + prev->this->name, local->loc.path, gfid); if ((op_errno != ENOENT) && (op_errno != ESTALE)) { local->op_ret = -1; local->op_errno = op_errno; @@ -6761,7 +6799,8 @@ dht_notify (xlator_t *this, int event, void *data, ...) subvol = data; if (conf->assert_no_child_down) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_CHILD_DOWN, "Received CHILD_DOWN. Exiting"); if (conf->defrag) { gf_defrag_stop (conf->defrag, -- cgit