diff options
author | Gaurav <gaurav@gluster.com> | 2011-01-31 04:25:38 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2011-02-04 00:39:26 -0800 |
commit | 5f8e2cab86eab7f5ee5b4bb9b649376e476c740c (patch) | |
tree | 2a40f4806584dbafe1e0c2d44dbb509de28cbeb4 | |
parent | f3648c88ebc6d58a10854d564d3fc2c82290ce13 (diff) |
Logging : Use of uuid_utoa and uuid_utoa_r.
Signed-off-by: Gaurav <gaurav@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 2308 (Threadsafe uuid to string conversion function)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2308
-rw-r--r-- | libglusterfs/src/inode.c | 8 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 46 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 29 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 18 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 8 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 43 | ||||
-rw-r--r-- | xlators/nfs/server/src/mount3.c | 5 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3-fh.c | 15 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3-helpers.c | 29 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 20 |
11 files changed, 81 insertions, 144 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 388485283ff..919f82143ae 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -202,7 +202,6 @@ __is_dentry_cyclic (dentry_t *dentry) { int ret = 0; inode_t *inode = NULL; - char uuidbuf[64]; char *name = "<nul>"; ret = __foreach_ancestor_dentry (dentry, __check_cycle, @@ -212,12 +211,11 @@ __is_dentry_cyclic (dentry_t *dentry) if (dentry->name) name = dentry->name; - uuid_unparse (inode->gfid, uuidbuf); gf_log (dentry->inode->table->name, GF_LOG_CRITICAL, "detected cyclic loop formation during inode linkage." " inode (%"PRId64"/%s) linking under itself as %s", - inode->ino, uuidbuf, name); + inode->ino, uuid_utoa (inode->gfid), name); } return ret; @@ -1438,7 +1436,6 @@ inode_dump (inode_t *inode, char *prefix) int ret = -1; xlator_t *xl = NULL; int i = 0; - char uuidbuf[256]; fd_t *fd = NULL; struct _inode_ctx *inode_ctx = NULL; struct fd_wrapper { @@ -1461,9 +1458,8 @@ inode_dump (inode_t *inode, char *prefix) } { - uuid_unparse (inode->gfid, uuidbuf); gf_proc_dump_build_key(key, prefix, "gfid"); - gf_proc_dump_write(key, "%s", uuidbuf); + gf_proc_dump_write(key, "%s", uuid_utoa (inode->gfid)); gf_proc_dump_build_key(key, prefix, "nlookup"); gf_proc_dump_write(key, "%ld", inode->nlookup); gf_proc_dump_build_key(key, prefix, "ref"); diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 9aca4bd4b55..aafae5dadfe 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -72,11 +72,9 @@ glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t uuid, glusterd_friend_req_ctx_t *ctx = NULL; char rhost[UNIX_PATH_MAX + 1] = {0}; uuid_t friend_uuid = {0}; - char uuid_str[50] = {0,}; dict_t *dict = NULL; - uuid_unparse (uuid, uuid_str); - uuid_parse (uuid_str, friend_uuid); + uuid_parse (uuid_utoa (uuid), friend_uuid); if (!port) port = GF_DEFAULT_BASE_PORT; @@ -246,7 +244,7 @@ glusterd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, GF_ASSERT (friends); snprintf (key, 256, "friend%d.uuid", count); - uuid_unparse (peerinfo->uuid, peerinfo->uuid_str); + uuid_utoa_r (peerinfo->uuid, peerinfo->uuid_str); ret = dict_set_str (friends, key, peerinfo->uuid_str); if (ret) goto out; @@ -409,7 +407,6 @@ glusterd_handle_cluster_lock (rpcsvc_request_t *req) { gd1_mgmt_cluster_lock_req lock_req = {{0},}; int32_t ret = -1; - char str[50] = {0,}; glusterd_op_lock_ctx_t *ctx = NULL; GF_ASSERT (req); @@ -419,10 +416,9 @@ glusterd_handle_cluster_lock (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - uuid_unparse (lock_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received LOCK from uuid: %s", str); + "Received LOCK from uuid: %s", uuid_utoa (lock_req.uuid)); ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t); @@ -447,7 +443,6 @@ int glusterd_handle_stage_op (rpcsvc_request_t *req) { int32_t ret = -1; - char str[50] = {0,}; gd1_mgmt_stage_op_req stage_req = {{0,}}; glusterd_op_stage_ctx_t *ctx = NULL; @@ -459,9 +454,8 @@ glusterd_handle_stage_op (rpcsvc_request_t *req) goto out; } - uuid_unparse (stage_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received stage op from uuid: %s", str); + "Received stage op from uuid: %s", uuid_utoa (stage_req.uuid)); ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_stage_ctx_t); @@ -496,7 +490,6 @@ int glusterd_handle_commit_op (rpcsvc_request_t *req) { int32_t ret = -1; - char str[50] = {0,}; gd1_mgmt_commit_op_req commit_req = {{0},}; glusterd_op_commit_ctx_t *ctx = NULL; @@ -508,10 +501,9 @@ glusterd_handle_commit_op (rpcsvc_request_t *req) goto out; } - uuid_unparse (commit_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received commit op from uuid: %s", str); + "Received commit op from uuid: %s", uuid_utoa (commit_req.uuid)); ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_commit_ctx_t); @@ -762,7 +754,6 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) char *free_ptr = NULL; char *trans_type = NULL; uuid_t volume_id = {0,}; - char volid[64] = {0,}; glusterd_brickinfo_t *tmpbrkinfo = NULL; glusterd_volinfo_t tmpvolinfo = {{0},}; @@ -833,8 +824,7 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) } uuid_generate (volume_id); - uuid_unparse (volume_id, volid); - free_ptr = gf_strdup (volid); + free_ptr = gf_strdup (uuid_utoa (volume_id)); ret = dict_set_dynstr (dict, "volume-id", free_ptr); if (ret) { gf_log ("", GF_LOG_ERROR, "unable to set volume-id"); @@ -1524,7 +1514,7 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) if ((volinfo->type == GF_CLUSTER_TYPE_NONE) || (volinfo->brick_count <= volinfo->sub_count)) continue; - + pos = 0; list_for_each_entry (tmp, &volinfo->bricks, brick_list) { @@ -2000,7 +1990,6 @@ glusterd_handle_cluster_unlock (rpcsvc_request_t *req) { gd1_mgmt_cluster_unlock_req unlock_req = {{0}, }; int32_t ret = -1; - char str[50] = {0, }; glusterd_op_lock_ctx_t *ctx = NULL; GF_ASSERT (req); @@ -2011,10 +2000,9 @@ glusterd_handle_cluster_unlock (rpcsvc_request_t *req) goto out; } - uuid_unparse (unlock_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received UNLOCK from uuid: %s", str); + "Received UNLOCK from uuid: %s", uuid_utoa (unlock_req.uuid)); ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t); @@ -2114,7 +2102,6 @@ glusterd_handle_incoming_friend_req (rpcsvc_request_t *req) { int32_t ret = -1; gd1_mgmt_friend_req friend_req = {{0},}; - char str[50] = {0,}; GF_ASSERT (req); if (!gd_xdr_to_mgmt_friend_req (req->msg[0], &friend_req)) { @@ -2122,10 +2109,9 @@ glusterd_handle_incoming_friend_req (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - uuid_unparse (friend_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received probe from uuid: %s", str); + "Received probe from uuid: %s", uuid_utoa (friend_req.uuid)); ret = glusterd_handle_friend_req (req, friend_req.uuid, friend_req.hostname, friend_req.port, &friend_req); @@ -2142,7 +2128,6 @@ glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) { int32_t ret = -1; gd1_mgmt_friend_req friend_req = {{0},}; - char str[50]; char remote_hostname[UNIX_PATH_MAX + 1] = {0,}; GF_ASSERT (req); @@ -2151,10 +2136,9 @@ glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - uuid_unparse (friend_req.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "Received unfriend from uuid: %s", str); + "Received unfriend from uuid: %s", uuid_utoa (friend_req.uuid)); ret = glusterd_remote_hostname_get (req, remote_hostname, sizeof (remote_hostname)); @@ -2224,7 +2208,6 @@ glusterd_handle_friend_update (rpcsvc_request_t *req) { int32_t ret = -1; gd1_mgmt_friend_update friend_req = {{0},}; - char str[50] = {0,}; glusterd_peerinfo_t *peerinfo = NULL; glusterd_conf_t *priv = NULL; xlator_t *this = NULL; @@ -2252,16 +2235,15 @@ glusterd_handle_friend_update (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - uuid_unparse (friend_req.uuid, str); ret = glusterd_friend_find (friend_req.uuid, NULL, &tmp); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Received friend update request " - "from unknown peer %s", str); + "from unknown peer %s", uuid_utoa (friend_req.uuid)); goto out; } gf_log ("glusterd", GF_LOG_NORMAL, - "Received friend update from uuid: %s", str); + "Received friend update from uuid: %s", uuid_utoa (friend_req.uuid)); if (friend_req.friends.friends_len) { /* Unserialize the dictionary */ @@ -2352,7 +2334,6 @@ int glusterd_handle_probe_query (rpcsvc_request_t *req) { int32_t ret = -1; - char str[50]; xlator_t *this = NULL; glusterd_conf_t *conf = NULL; gd1_mgmt_probe_req probe_req = {{0},}; @@ -2374,14 +2355,13 @@ glusterd_handle_probe_query (rpcsvc_request_t *req) this = THIS; conf = this->private; - uuid_unparse (probe_req.uuid, str); if (probe_req.port) port = probe_req.port; else port = GF_DEFAULT_BASE_PORT; gf_log ("glusterd", GF_LOG_NORMAL, - "Received probe from uuid: %s", str); + "Received probe from uuid: %s", uuid_utoa (probe_req.uuid)); ret = glusterd_remote_hostname_get (req, remote_hostname, sizeof (remote_hostname)); diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index fa67c23e979..f2e14b0b3ce 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -47,6 +47,7 @@ #include "glusterd1.h" #include "cli1.h" #include "rpc-clnt.h" +#include "common-utils.h" #include <sys/resource.h> #include <inttypes.h> @@ -381,9 +382,9 @@ glusterd_store_create_volume (glusterd_volinfo_t *volinfo) if (ret) goto out; - uuid_unparse (volinfo->volume_id, buf); ret = glusterd_store_save_value (volinfo->shandle, - GLUSTERD_STORE_KEY_VOL_ID, buf); + GLUSTERD_STORE_KEY_VOL_ID, + uuid_utoa (volinfo->volume_id)); if (ret) goto out; @@ -676,7 +677,6 @@ glusterd_store_handle_truncate (glusterd_store_handle_t *handle) int32_t glusterd_store_uuid () { - char str[GLUSTERD_UUID_LEN] = {0,}; glusterd_conf_t *priv = NULL; char path[PATH_MAX] = {0,}; int32_t ret = -1; @@ -684,8 +684,6 @@ glusterd_store_uuid () priv = THIS->private; - uuid_unparse (priv->uuid, str); - snprintf (path, PATH_MAX, "%s/%s", priv->workdir, GLUSTERD_INFO_FILE); @@ -702,7 +700,7 @@ glusterd_store_uuid () } ret = glusterd_store_save_value (priv->handle, GLUSTERD_STORE_UUID_KEY, - str); + uuid_utoa (priv->uuid)); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Storing uuid failed" @@ -874,7 +872,7 @@ glusterd_store_iter_get_matching (glusterd_store_iter_t *iter, } GF_FREE (tmp_key); GF_FREE (tmp_value); - ret = glusterd_store_iter_get_next (iter, &tmp_key, + ret = glusterd_store_iter_get_next (iter, &tmp_key, &tmp_value); } out: @@ -1224,9 +1222,9 @@ glusterd_store_update_volume (glusterd_volinfo_t *volinfo) if (ret) goto out; - uuid_unparse (volinfo->volume_id, buf); ret = glusterd_store_save_value (volinfo->shandle, - GLUSTERD_STORE_KEY_VOL_ID, buf); + GLUSTERD_STORE_KEY_VOL_ID, + uuid_utoa (volinfo->volume_id)); if (ret) goto out; @@ -1256,7 +1254,6 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo) glusterd_conf_t *priv = NULL; char peerdir[PATH_MAX] = {0,}; char filepath[PATH_MAX] = {0,}; - char str[512] = {0,}; char hostname_path[PATH_MAX] = {0,}; @@ -1280,9 +1277,9 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo) goto out; } } else { - uuid_unparse (peerinfo->uuid, str); - snprintf (filepath, PATH_MAX, "%s/%s", peerdir, str); + snprintf (filepath, PATH_MAX, "%s/%s", peerdir, + uuid_utoa (peerinfo->uuid)); snprintf (hostname_path, PATH_MAX, "%s/%s", peerdir, peerinfo->hostname); @@ -1313,7 +1310,6 @@ glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo) glusterd_conf_t *priv = NULL; char peerdir[PATH_MAX] = {0,}; char filepath[PATH_MAX] = {0,}; - char str[512] = {0,}; char buf[4096] = {0,}; char hostname_path[PATH_MAX] = {0,}; @@ -1345,9 +1341,9 @@ glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo) goto out; } } else { - uuid_unparse (peerinfo->uuid, str); - snprintf (filepath, PATH_MAX, "%s/%s", peerdir, str); + snprintf (filepath, PATH_MAX, "%s/%s", peerdir, + uuid_utoa (peerinfo->uuid)); snprintf (hostname_path, PATH_MAX, "%s/%s", peerdir, peerinfo->hostname); @@ -1374,7 +1370,8 @@ glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo) } ret = glusterd_store_save_value (peerinfo->shandle, - GLUSTERD_STORE_KEY_PEER_UUID, str); + GLUSTERD_STORE_KEY_PEER_UUID, + uuid_utoa (peerinfo->uuid)); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index db0b0b385c5..0fac9e3b402 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -224,15 +224,14 @@ glusterd_lock (uuid_t uuid) int ret = -1; GF_ASSERT (uuid); - uuid_unparse (uuid, new_owner_str); glusterd_get_lock_owner (&owner); if (!uuid_is_null (owner)) { - uuid_unparse (owner, owner_str); gf_log ("glusterd", GF_LOG_ERROR, "Unable to get lock" - " for uuid: %s, lock held by: %s", new_owner_str, - owner_str); + " for uuid: %s, lock held by: %s", + uuid_utoa_r (uuid, new_owner_str), + uuid_utoa_r (owner, owner_str)); goto out; } @@ -240,7 +239,7 @@ glusterd_lock (uuid_t uuid) if (!ret) { gf_log ("glusterd", GF_LOG_NORMAL, "Cluster lock held by" - " %s", new_owner_str); + " %s", uuid_utoa (uuid)); } out: @@ -257,7 +256,6 @@ glusterd_unlock (uuid_t uuid) int32_t ret = -1; GF_ASSERT (uuid); - uuid_unparse (uuid, new_owner_str); glusterd_get_lock_owner (&owner); @@ -269,9 +267,9 @@ glusterd_unlock (uuid_t uuid) ret = uuid_compare (uuid, owner); if (ret) { - uuid_unparse (owner, owner_str); gf_log ("glusterd", GF_LOG_ERROR, "Cluster lock held by %s" - " ,unlock req from %s!", owner_str, new_owner_str); + " ,unlock req from %s!", uuid_utoa_r (owner ,owner_str) + , uuid_utoa_r (uuid, new_owner_str)); goto out; } @@ -1224,7 +1222,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, char key[512] = {0,}; glusterd_brickinfo_t *brickinfo = NULL; int32_t i = 1; - char uuid_str[50] = {0,}; char *volume_id_str = NULL; glusterd_volopt_ctx_t ctx = {0}; @@ -1272,8 +1269,7 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - uuid_unparse (volinfo->volume_id, uuid_str); - volume_id_str = gf_strdup (uuid_str); + volume_id_str = gf_strdup (uuid_utoa (volinfo->volume_id)); if (!volume_id_str) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index a87d26f7921..bf3147738fa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1284,7 +1284,6 @@ build_nfs_graph (glusterfs_graph_t *graph, dict_t *mod_dict) char *skey = NULL; char *enable_ino32 = NULL; char *mem_factor = NULL; - char volume_id[64] = {0,}; int ret = 0; this = THIS; @@ -1336,8 +1335,7 @@ build_nfs_graph (glusterfs_graph_t *graph, dict_t *mod_dict) gf_log ("", GF_LOG_ERROR, "Out of memory"); goto out; } - uuid_unparse (voliter->volume_id, volume_id); - ret = xlator_set_option (nfsxl, skey, volume_id); + ret = xlator_set_option (nfsxl, skey, uuid_utoa (voliter->volume_id)); GF_FREE (skey); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index a0189662201..1d6517a4a72 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -44,6 +44,7 @@ #include "glusterd-op-sm.h" #include "glusterd-store.h" #include "glusterd-utils.h" +#include "common-utils.h" static uuid_t glusterd_uuid; extern struct rpcsvc_program glusterd1_mop_prog; @@ -73,7 +74,6 @@ static int glusterd_uuid_init (int flag) { int ret = -1; - char str[50] = {0,}; glusterd_conf_t *priv = NULL; priv = THIS->private; @@ -81,19 +81,17 @@ glusterd_uuid_init (int flag) if (!flag) { ret = glusterd_retrieve_uuid (); if (!ret) { - uuid_unparse (priv->uuid, str); uuid_copy (glusterd_uuid, priv->uuid); gf_log ("glusterd", GF_LOG_NORMAL, - "retrieved UUID: %s", str); + "retrieved UUID: %s", uuid_utoa (priv->uuid)); return 0; } } uuid_generate (glusterd_uuid); - uuid_unparse (glusterd_uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, - "generated UUID: %s",str); + "generated UUID: %s", uuid_utoa (glusterd_uuid)); uuid_copy (priv->uuid, glusterd_uuid); ret = glusterd_store_uuid (); diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index 09b6b175444..04ced866ab3 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -33,6 +33,7 @@ #include "glusterd.h" #include "protocol-common.h" #include "glusterd-utils.h" +#include "common-utils.h" #include <sys/uio.h> @@ -55,7 +56,6 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, gd1_mgmt_probe_rsp rsp = {{0},}; glusterd_conf_t *conf = NULL; int ret = 0; - char str[50] = {0,}; glusterd_peerinfo_t *peerinfo = NULL; glusterd_friend_sm_event_t *event = NULL; glusterd_probe_ctx_t *ctx = NULL; @@ -73,11 +73,10 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, //rsp.op_errno = EINVAL; goto out; } - uuid_unparse (rsp.uuid, str); gf_log ("glusterd", GF_LOG_NORMAL, "Received probe resp from uuid: %s, host: %s", - str, rsp.hostname); + uuid_utoa (rsp.uuid), rsp.hostname); if (rsp.op_ret != 0) { ctx = ((call_frame_t *)myframe)->local; ((call_frame_t *)myframe)->local = NULL; @@ -141,7 +140,6 @@ glusterd3_1_friend_add_cbk (struct rpc_req * req, struct iovec *iov, glusterd_friend_sm_event_t *event = NULL; glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; int32_t op_ret = -1; int32_t op_errno = -1; glusterd_probe_ctx_t *ctx = NULL; @@ -162,20 +160,19 @@ glusterd3_1_friend_add_cbk (struct rpc_req * req, struct iovec *iov, rsp.op_errno = EINVAL; goto out; } - uuid_unparse (rsp.uuid, str); op_ret = rsp.op_ret; op_errno = rsp.op_errno; gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s, host: %s, port: %d", - (op_ret)?"RJT":"ACC", str, rsp.hostname, rsp.port); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port); ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "received friend add response from" - " unknown peer uuid: %s", str); + " unknown peer uuid: %s", uuid_utoa (rsp.uuid)); goto out; } @@ -239,7 +236,6 @@ glusterd3_1_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, glusterd_friend_sm_event_t *event = NULL; glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; int32_t op_ret = -1; int32_t op_errno = -1; glusterd_probe_ctx_t *ctx = NULL; @@ -264,14 +260,13 @@ glusterd3_1_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, rsp.op_errno = EINVAL; goto respond; } - uuid_unparse (rsp.uuid, str); op_ret = rsp.op_ret; op_errno = rsp.op_errno; gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s, host: %s, port: %d", - (op_ret)?"RJT":"ACC", str, rsp.hostname, rsp.port); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port); inject: ret = glusterd_friend_find (rsp.uuid, ctx->hostname, &peerinfo); @@ -369,7 +364,6 @@ glusterd3_1_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, int32_t op_ret = -1; glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; GF_ASSERT (req); @@ -386,19 +380,18 @@ glusterd3_1_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, rsp.op_errno = EINVAL; goto out; } - uuid_unparse (rsp.uuid, str); op_ret = rsp.op_ret; gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s", - (op_ret)?"RJT":"ACC", str); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Lock response received from " - "unknown peer: %s", str); + "unknown peer: %s", uuid_utoa (rsp.uuid)); } if (op_ret) { @@ -429,7 +422,6 @@ glusterd3_1_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, int32_t op_ret = -1; glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; GF_ASSERT (req); @@ -447,19 +439,18 @@ glusterd3_1_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, rsp.op_errno = EINVAL; goto out; } - uuid_unparse (rsp.uuid, str); op_ret = rsp.op_ret; gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s", - (op_ret)?"RJT":"ACC", str); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Unlock response received from " - "unknown peer %s", str); + "unknown peer %s", uuid_utoa (rsp.uuid)); } if (op_ret) { @@ -547,7 +538,6 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, int32_t op_ret = -1; glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; dict_t *dict = NULL; GF_ASSERT (req); @@ -567,7 +557,6 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, rsp.op_errstr = "error"; goto out; } - uuid_unparse (rsp.uuid, str); if (rsp.dict.dict_len) { /* Unserialize the dictionary */ @@ -591,13 +580,13 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s", - (op_ret)?"RJT":"ACC", str); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Stage response received from " - "unknown peer: %s", str); + "unknown peer: %s", uuid_utoa (rsp.uuid)); } if (op_ret) { @@ -667,7 +656,6 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, int32_t op_ret = -1; glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; - char str[50] = {0,}; dict_t *dict = NULL; @@ -690,7 +678,6 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, event_type = GD_OP_EVENT_RCVD_RJT; goto out; } - uuid_unparse (rsp.uuid, str); if (rsp.dict.dict_len) { /* Unserialize the dictionary */ @@ -714,13 +701,13 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("glusterd", GF_LOG_NORMAL, "Received %s from uuid: %s", - (op_ret)?"RJT":"ACC", str); + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo); if (ret) { gf_log ("", GF_LOG_CRITICAL, "Commit response received from " - "unknown peer: %s", str); + "unknown peer: %s", uuid_utoa (rsp.uuid)); } if (op_ret) { @@ -957,7 +944,6 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, glusterd_friend_update_ctx_t *ctx = NULL; dict_t *friends = NULL; char key[100] = {0,}; - char uuid_buf[50] = {0,}; char *dup_buf = NULL; int32_t count = 0; char *dict_buf = NULL; @@ -987,9 +973,8 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, if (GD_FRIEND_UPDATE_ADD == ctx->op) { list_for_each_entry (peerinfo, &priv->peers, uuid_list) { count++; - uuid_unparse (peerinfo->uuid, uuid_buf); snprintf (key, sizeof (key), "friend%d.uuid", count); - dup_buf = gf_strdup (uuid_buf); + dup_buf = gf_strdup (uuid_utoa (peerinfo->uuid)); ret = dict_set_dynstr (friends, key, dup_buf); if (ret) goto out; diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 5f3a0a1a692..53282d9a191 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -38,6 +38,7 @@ #include "iatt.h" #include "nfs-mem-types.h" #include "nfs.h" +#include "common-utils.h" #include <errno.h> @@ -485,7 +486,6 @@ __mnt3_resolve_export_subdir_comp (mnt3_resolve_t *mres) char *nextcomp = NULL; int ret = -EFAULT; nfs_user_t nfu = {0, }; - char gfidstr[512]; uuid_t gfid = {0, }; if (!mres) @@ -501,9 +501,8 @@ __mnt3_resolve_export_subdir_comp (mnt3_resolve_t *mres) ret = nfs_entry_loc_fill (mres->exp->vol->itable, gfid, nextcomp, &mres->resolveloc, NFS_RESOLVE_CREATE); if ((ret < 0) && (ret != -2)) { - uuid_unparse (mres->resolveloc.inode->gfid, gfidstr); gf_log (GF_MNT, GF_LOG_ERROR, "Failed to resolve and create " - "inode: parent gfid %s, entry %s", gfidstr, nextcomp); + "inode: parent gfid %s, entry %s", uuid_utoa (mres->resolveloc.inode->gfid), nextcomp); ret = -EFAULT; goto err; } diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c index be5a3017c3b..971bea8a30a 100644 --- a/xlators/nfs/server/src/nfs3-fh.c +++ b/xlators/nfs/server/src/nfs3-fh.c @@ -31,6 +31,7 @@ #include "nfs3-fh.h" #include "nfs-common.h" #include "iatt.h" +#include "common-utils.h" int @@ -171,7 +172,6 @@ nfs3_fh_hash_entry (uuid_t gfid) } - void nfs3_fh_to_str (struct nfs3_fh *fh, char *str) { @@ -181,13 +181,11 @@ nfs3_fh_to_str (struct nfs3_fh *fh, char *str) if ((!fh) || (!str)) return; - uuid_unparse (fh->gfid, gfid); - uuid_unparse (fh->exportid, exportid); sprintf (str, "FH: hashcount %d, exportid %s, gfid %s", - fh->hashcount, exportid, gfid); + fh->hashcount, uuid_utoa_r (fh->exportid, exportid), + uuid_utoa_r (fh->gfid, gfid)); } - void nfs3_log_fh (struct nfs3_fh *fh) { @@ -198,10 +196,10 @@ nfs3_log_fh (struct nfs3_fh *fh) if (!fh) return; - uuid_unparse (fh->gfid, gfidstr); - uuid_unparse (fh->exportid, exportidstr); gf_log ("nfs3-fh", GF_LOG_TRACE, "filehandle: hashcount %d, exportid " - "0x%s, gfid 0x%s", fh->hashcount, exportidstr, gfidstr); + "0x%s, gfid 0x%s", fh->hashcount, + uuid_utoa_r (fh->exportid, exportidstr), + uuid_utoa_r (fh->gfid, gfidstr)); /* for (; x < fh->hashcount; ++x) gf_log ("FILEHANDLE", GF_LOG_TRACE, "Hash %d: %d", x, @@ -209,7 +207,6 @@ nfs3_log_fh (struct nfs3_fh *fh) */ } - int nfs3_fh_build_parent_fh (struct nfs3_fh *child, struct iatt *newstat, struct nfs3_fh *newfh) diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 8697487945e..cb7ba7cbb01 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -35,6 +35,7 @@ #include "nfs3-helpers.h" #include "nfs-mem-types.h" #include "iatt.h" +#include "common-utils.h" #include <string.h> extern int @@ -2542,7 +2543,6 @@ nfs3_fh_resolve_check_entry (struct nfs3_fh *fh, gf_dirent_t *candidate, struct iatt *ia = NULL; int ret = GF_NFS3_FHRESOLVE_NOTFOUND; nfs3_hash_entry_t entryhash = 0; - char gfidstr[512]; if ((!fh) || (!candidate)) return ret; @@ -2553,10 +2553,10 @@ nfs3_fh_resolve_check_entry (struct nfs3_fh *fh, gf_dirent_t *candidate, ia = &candidate->d_stat; if ((uuid_compare (candidate->d_stat.ia_gfid, fh->gfid)) == 0) { - uuid_unparse (candidate->d_stat.ia_gfid, gfidstr); gf_log (GF_NFS3, GF_LOG_TRACE, "Found entry: gfid: %s, " - "name: %s, hashcount %d", gfidstr, candidate->d_name, - hashidx); + "name: %s, hashcount %d", + uuid_utoa (candidate->d_stat.ia_gfid), + candidate->d_name, hashidx); ret = GF_NFS3_FHRESOLVE_FOUND; goto found_entry; } @@ -2854,7 +2854,6 @@ nfs3_fh_resolve_dir_hard (nfs3_call_state_t *cs, uuid_t dirgfid, char *entry) { int ret = -EFAULT; nfs_user_t nfu = {0, }; - char gfidstr[512]; if (!cs) return ret; @@ -2869,9 +2868,9 @@ nfs3_fh_resolve_dir_hard (nfs3_call_state_t *cs, uuid_t dirgfid, char *entry) } nfs_user_root_create (&nfu); - uuid_unparse (dirgfid, gfidstr); gf_log (GF_NFS3, GF_LOG_TRACE, "FH hard dir resolution: gfid: %s, " - "entry: %s, next hashcount: %d", gfidstr, entry, cs->hashidx); + "entry: %s, next hashcount: %d", uuid_utoa (dirgfid), entry, + cs->hashidx); ret = nfs_entry_loc_fill (cs->vol->itable, dirgfid, entry, &cs->resolvedloc, NFS_RESOLVE_CREATE); @@ -2948,7 +2947,6 @@ nfs3_fh_resolve_search_dir (nfs3_call_state_t *cs, gf_dirent_t *entries) gf_dirent_t *candidate = NULL; int ret = GF_NFS3_FHRESOLVE_NOTFOUND; off_t lastoff = 0; - char gfidstr[512]; if ((!cs) || (!entries)) return -EFAULT; @@ -2958,9 +2956,9 @@ nfs3_fh_resolve_search_dir (nfs3_call_state_t *cs, gf_dirent_t *entries) list_for_each_entry (candidate, &entries->list, list) { lastoff = candidate->d_off; - uuid_unparse (candidate->d_stat.ia_gfid, gfidstr); gf_log (GF_NFS3, GF_LOG_TRACE, "Candidate: %s, gfid: %s", - candidate->d_name, gfidstr); + candidate->d_name, + uuid_utoa (candidate->d_stat.ia_gfid)); ret = nfs3_fh_resolve_check_entry (&cs->resolvefh, candidate, cs->hashidx); if (ret != GF_NFS3_FHRESOLVE_NOTFOUND) @@ -3004,7 +3002,6 @@ nfs3_fh_resolve_inode_hard (nfs3_call_state_t *cs) { int ret = -EFAULT; nfs_user_t nfu = {0, }; - char gfidstr[512]; if (!cs) return ret; @@ -3019,9 +3016,9 @@ nfs3_fh_resolve_inode_hard (nfs3_call_state_t *cs) } nfs_user_root_create (&nfu); - uuid_unparse (cs->resolvefh.gfid, gfidstr); gf_log (GF_NFS3, GF_LOG_TRACE, "FH hard resolution for: gfid 0x%s" - ", hashcount: %d, current hashidx %d", gfidstr, + ", hashcount: %d, current hashidx %d", + uuid_utoa (cs->resolvefh.gfid), cs->resolvefh.hashcount, cs->hashidx); ret = nfs_root_loc_fill (cs->vol->itable, &cs->resolvedloc); @@ -3047,17 +3044,15 @@ nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs) { int ret = -EFAULT; nfs_user_t nfu = {0, }; - char gfidstr[512]; if (!cs) return ret; nfs_loc_wipe (&cs->resolvedloc); nfs_user_root_create (&nfu); - uuid_unparse (cs->resolvefh.gfid, gfidstr); gf_log (GF_NFS3, GF_LOG_TRACE, "FH hard resolution: gfid: %s " - ", entry: %s, hashidx: %d", gfidstr, cs->resolventry, - cs->hashidx); + ", entry: %s, hashidx: %d", uuid_utoa (cs->resolvefh.gfid), + cs->resolventry, cs->hashidx); ret = nfs_entry_loc_fill (cs->vol->itable, cs->resolvefh.gfid, cs->resolventry, &cs->resolvedloc, diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 1ef58fc10c8..0ae8ecec932 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -283,7 +283,6 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, struct _locker *locker = NULL, *tmp = NULL; int ret = -1; char *path = NULL; - char gfid [40] = {0, }; bound_xl = conn->bound_xl; INIT_LIST_HEAD (&inodelk_lockers); @@ -329,11 +328,11 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, "released on %s", path); GF_FREE (path); } else { - uuid_unparse (locker->fd->inode->gfid, gfid); gf_log (this->name, GF_LOG_INFO, "finodelk " "released on ino %"PRId64" with gfid %s", - locker->fd->inode->ino, gfid); + locker->fd->inode->ino, + uuid_utoa (locker->fd->inode->gfid)); } STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, @@ -377,7 +376,6 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, "released on %s", path); GF_FREE (path); } else { - uuid_unparse (locker->fd->inode->gfid, gfid); gf_log (this->name, GF_LOG_INFO, "fentrylk " "released on ino %lu", locker->fd->inode->ino); @@ -439,7 +437,6 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, call_frame_t *tmp_frame = NULL; xlator_t *bound_xl = NULL; char *path = NULL; - char gfid [40] = {0, }; bound_xl = conn->bound_xl; for (i = 0;i < fd_count; i++) { @@ -462,11 +459,11 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, "%s", path); GF_FREE (path); } else { - uuid_unparse (fd->inode->gfid, gfid); gf_log (this->name, GF_LOG_INFO, "fd cleanup on " "ino %"PRId64" with gfid %s", - fd->inode->ino, gfid); + fd->inode->ino, + uuid_utoa (fd->inode->gfid)); } tmp_frame->local = fd; @@ -579,7 +576,6 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) fdentry_t *fdentries = NULL; uint32_t fd_count = 0; char *path = NULL; - char gfid [40] = {0, }; if (conn == NULL) { ret = 0; @@ -641,11 +637,11 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) "released on %s", path); GF_FREE (path); } else { - uuid_unparse (locker->fd->inode->gfid, gfid); gf_log (this->name, GF_LOG_INFO, "finodelk " "released on ino %"PRId64 "with gfid %s", - locker->fd->inode->ino, gfid); + locker->fd->inode->ino, + uuid_utoa (locker->fd->inode->gfid)); } STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, @@ -689,11 +685,11 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) GF_FREE (path); } else { - uuid_unparse (locker->fd->inode->gfid, gfid); gf_log (this->name, GF_LOG_INFO, "fentrylk " "released on ino %"PRId64" and gfid= %s", - locker->fd->inode->ino, gfid); + locker->fd->inode->ino, + uuid_utoa (locker->fd->inode->gfid)); } STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, |