diff --git a/.gitignore b/.gitignore index fd8dfcb..129987a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/glusterfs-3.6.0.29.tar.gz +SOURCES/glusterfs-3.7.1.tar.gz diff --git a/.glusterfs.metadata b/.glusterfs.metadata index 0ecc87e..c33e4e0 100644 --- a/.glusterfs.metadata +++ b/.glusterfs.metadata @@ -1 +1 @@ -266514d8196bf31576e8e165f9cf10fb9cda77bf SOURCES/glusterfs-3.6.0.29.tar.gz +02e99a642e659b9c4232d12bff849d360a89c6fd SOURCES/glusterfs-3.7.1.tar.gz diff --git a/SOURCES/0002-features-quota-Do-unwind-if-postbuf-is-NULL.patch b/SOURCES/0002-features-quota-Do-unwind-if-postbuf-is-NULL.patch new file mode 100644 index 0000000..2e0d267 --- /dev/null +++ b/SOURCES/0002-features-quota-Do-unwind-if-postbuf-is-NULL.patch @@ -0,0 +1,42 @@ +From 35a5ef27ba8a8da2b78e6d58a7385d4d443445bd Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Mon, 25 May 2015 11:07:27 +0530 +Subject: [PATCH 02/18] features/quota : Do unwind if postbuf is NULL + +If postbuf in quota_writev_cbk is NULL directly +an unwind should be done. Trying to dereference +it will lead to a crash. + +Change-Id: Idba6ce3cd1bbf37ede96c7f17d01007d6c07057a +BUG: 1224225 +Reviewed-on: http://review.gluster.org/10898 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: http://review.gluster.org/11040 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/49889 +Reviewed-by: Sachin Pandit +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index d8bacb7..a649df8 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -1500,7 +1500,7 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + local = frame->local; + +- if ((op_ret < 0) || (local == NULL)) { ++ if ((op_ret < 0) || (local == NULL) || (postbuf == NULL)) { + goto out; + } + +-- +1.9.3 + diff --git a/SOURCES/0003-features-quota-Make-quota-deem-statfs-option-on-by-d.patch b/SOURCES/0003-features-quota-Make-quota-deem-statfs-option-on-by-d.patch new file mode 100644 index 0000000..7091a02 --- /dev/null +++ b/SOURCES/0003-features-quota-Make-quota-deem-statfs-option-on-by-d.patch @@ -0,0 +1,83 @@ +From 52f101118fb06e850a9ef4ed1955bc7bedfeee39 Mon Sep 17 00:00:00 2001 +From: Sachin Pandit +Date: Mon, 20 Apr 2015 10:08:03 +0530 +Subject: [PATCH 03/18] features/quota : Make "quota-deem-statfs" option "on" + by default, when quota is enabled + +As of now it is expected from user to set deem-statfs to "on" when +quota is enabled. Better to turn it "on" by default when quota is enabled. + +Change-Id: I85e0b919b1bdb74ac21e256073eebcb55bcb8e2a +BUG: 1027710 +Signed-off-by: Sachin Pandit +Reviewed-on: http://review.gluster.org/10299 +Tested-by: Gluster Build System +Reviewed-by: Vijaikumar Mallikarjuna +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Signed-off-by: Sachin Pandit +Reviewed-on: http://review.gluster.org/11000 +Tested-by: NetBSD Build System +Signed-off-by: Sachin Pandit +Reviewed-on: https://code.engineering.redhat.com/gerrit/49894 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + ...213364-disable-deem-statfs-when-quota-disable.t | 24 ++++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-quota.c | 9 ++++++++ + 2 files changed, 33 insertions(+) + create mode 100644 tests/bugs/quota/bug-1213364-disable-deem-statfs-when-quota-disable.t + +diff --git a/tests/bugs/quota/bug-1213364-disable-deem-statfs-when-quota-disable.t b/tests/bugs/quota/bug-1213364-disable-deem-statfs-when-quota-disable.t +new file mode 100644 +index 0000000..aaf4a31 +--- /dev/null ++++ b/tests/bugs/quota/bug-1213364-disable-deem-statfs-when-quota-disable.t +@@ -0,0 +1,24 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2}; ++EXPECT 'Created' volinfo_field $V0 'Status'; ++ ++TEST $CLI volume start $V0; ++EXPECT 'Started' volinfo_field $V0 'Status'; ++ ++TEST $CLI volume quota $V0 enable ++EXPECT 'on' volinfo_field $V0 'features.quota' ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume quota $V0 disable ++EXPECT 'off' volinfo_field $V0 'features.quota' ++EXPECT '' volinfo_field $V0 'features.quota-deem-statfs' ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c +index ff6ece9..7238032 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quota.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quota.c +@@ -456,6 +456,15 @@ glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr, + goto out; + } + ++ ret = dict_set_dynstr_with_alloc (volinfo->dict, ++ "features.quota-deem-statfs", ++ "on"); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "setting quota-deem-statfs" ++ "in volinfo failed"); ++ goto out; ++ } ++ + *crawl = _gf_true; + + ret = glusterd_store_quota_config (volinfo, NULL, NULL, +-- +1.9.3 + diff --git a/SOURCES/0004-features-quota-prevent-statfs-frame-loss-when-an-err.patch b/SOURCES/0004-features-quota-prevent-statfs-frame-loss-when-an-err.patch new file mode 100644 index 0000000..8424103 --- /dev/null +++ b/SOURCES/0004-features-quota-prevent-statfs-frame-loss-when-an-err.patch @@ -0,0 +1,110 @@ +From 296d280c75299a5271ab8e88bf99f731986fd0e5 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 30 Apr 2015 12:35:40 +0530 +Subject: [PATCH 04/18] features/quota: prevent statfs frame loss when an error + happens during ancestry building + +This is a backport of http://review.gluster.org/#/c/9380/ + +> We do quota_build_ancestry in function 'quota_get_limit_dir', +> suppose if quota_build_ancestry fails, then we don't have a +> frame saved to continue the statfs FOP and client can hang. +> +> Change-Id: I92e25c1510d09444b9d4810afdb6b2a69dcd92c0 +> BUG: 1178619 +> Signed-off-by: Raghavendra G +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/9380 +> Tested-by: Gluster Build System + +Change-Id: I998f417d62d6ea4f57f237f547243d44c2da438c +BUG: 1226162 +Signed-off-by: vmallika +Reviewed-on: http://review.gluster.org/11025 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Tested-by: Raghavendra G +Reviewed-by: Raghavendra G +Signed-off-by: Sachin Pandit +Reviewed-on: https://code.engineering.redhat.com/gerrit/49896 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 29 ++++++++++++++--------------- + 1 file changed, 14 insertions(+), 15 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index a649df8..621e849 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -4272,16 +4272,9 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode) + quota_local_t *local = frame->local; + int ret = -1; + +- stub = fop_statfs_stub (frame, quota_statfs_helper, +- &local->loc, local->xdata); +- if (!stub) +- goto err; +- + LOCK (&local->lock); + { + local->inode = inode_ref (inode); +- local->link_count = 1; +- local->stub = stub; + } + UNLOCK (&local->lock); + +@@ -4289,12 +4282,6 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode) + quota_statfs_validate_cbk); + if (0 > ret) + quota_handle_validate_error (local, -1, -ret); +- return; +- +-err: +- QUOTA_STACK_UNWIND (statfs, frame, -1, ENOMEM, NULL, NULL); +- +- return; + } + + void +@@ -4361,6 +4348,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + int8_t ignore_deem_statfs = 0; + quota_priv_t *priv = NULL; + quota_local_t *local = NULL; ++ call_stub_t *stub = NULL; + + priv = this->private; + GF_ASSERT (loc); +@@ -4380,6 +4368,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + op_errno = ENOMEM; + goto err; + } ++ frame->local = local; + + ret = loc_copy (&local->loc, loc); + if (-1 == ret) { +@@ -4390,9 +4379,19 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + if (xdata) + local->xdata = dict_ref (xdata); + +- local->link_count = 1; ++ stub = fop_statfs_stub (frame, quota_statfs_helper, ++ &local->loc, local->xdata); ++ if (!stub) { ++ op_errno = ENOMEM; ++ goto err; ++ } + +- frame->local = local; ++ LOCK (&local->lock); ++ { ++ local->link_count = 1; ++ local->stub = stub; ++ } ++ UNLOCK (&local->lock); + + quota_get_limit_dir (frame, loc->inode, this); + +-- +1.9.3 + diff --git a/SOURCES/0005-quota-retry-connecting-to-quotad-on-ENOTCONN-error.patch b/SOURCES/0005-quota-retry-connecting-to-quotad-on-ENOTCONN-error.patch new file mode 100644 index 0000000..51f2ebc --- /dev/null +++ b/SOURCES/0005-quota-retry-connecting-to-quotad-on-ENOTCONN-error.patch @@ -0,0 +1,291 @@ +From 062e8379096aa228767518869f213661dca5f275 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Tue, 14 Apr 2015 10:44:13 +0530 +Subject: [PATCH 05/18] quota: retry connecting to quotad on ENOTCONN error + +This is a backport of http://review.gluster.org/#/c/10230/ + +> Suppose if there are two volumes vol1 and vol2, +> and quota is enabled and limit is set on vol1. +> Now if IO is happening on vol1 and quota is enabled/disabled +> on vol2, quotad gets restarted and client will receive +> ENOTCONN in the IO path of vol1. +> +> This patch will retry connecting to quotad upto 60sec +> in a interval of 5sec (12 retries) +> If not able to connect with 12 retries, then return ENOTCONN +> +> Change-Id: Ie7f5d108633ec68ba9cc3a6a61d79680485193e8 +> BUG: 1211220 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/10230 +> Tested-by: Gluster Build System +> Reviewed-by: Raghavendra G +> Tested-by: Raghavendra G + +Change-Id: I94d8d4a814a73d69e934f3e77e989e5f3bf2e65a +BUG: 1039674 +Signed-off-by: vmallika +Reviewed-on: http://review.gluster.org/11024 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Signed-off-by: Sachin Pandit +Reviewed-on: https://code.engineering.redhat.com/gerrit/49897 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota-enforcer-client.c | 118 +++++++++++++++++---- + xlators/features/quota/src/quota.c | 6 +- + xlators/features/quota/src/quota.h | 12 ++- + 3 files changed, 111 insertions(+), 25 deletions(-) + +diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c +index 01cc447..55e700c 100644 +--- a/xlators/features/quota/src/quota-enforcer-client.c ++++ b/xlators/features/quota/src/quota-enforcer-client.c +@@ -120,22 +120,26 @@ int + quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov, + int count, void *myframe) + { +- quota_local_t *local = NULL; +- call_frame_t *frame = NULL; +- int ret = 0; +- gfs3_lookup_rsp rsp = {0,}; +- struct iatt stbuf = {0,}; +- struct iatt postparent = {0,}; +- int op_errno = EINVAL; +- dict_t *xdata = NULL; +- inode_t *inode = NULL; +- xlator_t *this = NULL; ++ quota_local_t *local = NULL; ++ call_frame_t *frame = NULL; ++ int ret = 0; ++ gfs3_lookup_rsp rsp = {0,}; ++ struct iatt stbuf = {0,}; ++ struct iatt postparent = {0,}; ++ int op_errno = EINVAL; ++ dict_t *xdata = NULL; ++ inode_t *inode = NULL; ++ xlator_t *this = NULL; ++ quota_priv_t *priv = NULL; ++ struct timespec retry_delay = {0,}; ++ gf_timer_t *timer = NULL; + + this = THIS; + + frame = myframe; + local = frame->local; + inode = local->validate_loc.inode; ++ priv = this->private; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; +@@ -177,6 +181,48 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov, + + out: + rsp.op_errno = op_errno; ++ ++ /* We need to retry connecting to quotad on ENOTCONN error. ++ * Suppose if there are two volumes vol1 and vol2, ++ * and quota is enabled and limit is set on vol1. ++ * Now if IO is happening on vol1 and quota is enabled/disabled ++ * on vol2, quotad gets restarted and client will receive ++ * ENOTCONN in the IO path of vol1 ++ */ ++ if (rsp.op_ret == -1 && rsp.op_errno == ENOTCONN) { ++ if (local->quotad_conn_retry >= 12) { ++ priv->quotad_conn_status = 1; ++ gf_log (this->name, GF_LOG_WARNING, "failed to connect " ++ "to quotad after retry count %d)", ++ local->quotad_conn_retry); ++ } else { ++ local->quotad_conn_retry++; ++ } ++ ++ if (priv->quotad_conn_status == 0) { ++ /* retry connecting after 5secs for 12 retries ++ * (upto 60sec). ++ */ ++ gf_log (this->name, GF_LOG_DEBUG, "retry connecting to " ++ "quotad (retry count %d)", ++ local->quotad_conn_retry); ++ ++ retry_delay.tv_sec = 5; ++ retry_delay.tv_nsec = 0; ++ timer = gf_timer_call_after (this->ctx, retry_delay, ++ _quota_enforcer_lookup, ++ (void *) frame); ++ if (timer == NULL) { ++ gf_log (this->name, GF_LOG_WARNING, "failed to " ++ "set quota_enforcer_lookup with timer"); ++ } else { ++ goto clean; ++ } ++ } ++ } else { ++ priv->quotad_conn_status = 0; ++ } ++ + if (rsp.op_ret == -1) { + /* any error other than ENOENT */ + if (rsp.op_errno != ENOENT) +@@ -189,11 +235,15 @@ out: + gf_log (this->name, GF_LOG_TRACE, + "not found on remote node"); + ++ } else if (local->quotad_conn_retry) { ++ gf_log (this->name, GF_LOG_DEBUG, "connected to quotad after " ++ "retry count %d", local->quotad_conn_retry); + } + + local->validate_cbk (frame, NULL, this, rsp.op_ret, rsp.op_errno, inode, + &stbuf, xdata, &postparent); + ++clean: + if (xdata) + dict_unref (xdata); + +@@ -202,21 +252,22 @@ out: + return 0; + } + +-int +-quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, +- dict_t *xdata, fop_lookup_cbk_t validate_cbk) ++void ++_quota_enforcer_lookup (void *data) + { + quota_local_t *local = NULL; + gfs3_lookup_req req = {{0,},}; + int ret = 0; + int op_errno = ESTALE; + quota_priv_t *priv = NULL; ++ call_frame_t *frame = NULL; ++ loc_t *loc = NULL; ++ xlator_t *this = NULL; + +- if (!frame || !this || !loc) +- goto unwind; +- ++ frame = data; + local = frame->local; +- local->validate_cbk = validate_cbk; ++ this = local->this; ++ loc = &local->validate_loc; + + priv = this->private; + +@@ -228,8 +279,8 @@ quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + else + memcpy (req.gfid, loc->gfid, 16); + +- if (xdata) { +- GF_PROTOCOL_DICT_SERIALIZE (this, xdata, ++ if (local->validate_xdata) { ++ GF_PROTOCOL_DICT_SERIALIZE (this, local->validate_xdata, + (&req.xdata.xdata_val), + req.xdata.xdata_len, + op_errno, unwind); +@@ -253,13 +304,38 @@ quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + + GF_FREE (req.xdata.xdata_val); + +- return 0; ++ return; + + unwind: +- validate_cbk (frame, NULL, this, -1, op_errno, NULL, NULL, NULL, NULL); ++ local->validate_cbk (frame, NULL, this, -1, op_errno, NULL, NULL, NULL, ++ NULL); + + GF_FREE (req.xdata.xdata_val); + ++ return; ++} ++ ++int ++quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, dict_t *xdata, ++ fop_lookup_cbk_t validate_cbk) ++{ ++ quota_local_t *local = NULL; ++ ++ if (!frame || !this) ++ goto unwind; ++ ++ local = frame->local; ++ local->this = this; ++ local->validate_cbk = validate_cbk; ++ local->validate_xdata = dict_ref (xdata); ++ ++ _quota_enforcer_lookup (frame); ++ ++ return 0; ++ ++unwind: ++ validate_cbk (frame, NULL, this, -1, ESTALE, NULL, NULL, NULL, NULL); ++ + return 0; + } + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index 621e849..6d05273 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -171,6 +171,9 @@ quota_local_cleanup (xlator_t *this, quota_local_t *local) + if (local->xdata) + dict_unref (local->xdata); + ++ if (local->validate_xdata) ++ dict_unref (local->validate_xdata); ++ + if (local->stub) + call_stub_destroy (local->stub); + +@@ -884,8 +887,7 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this, + goto err; + } + +- ret = quota_enforcer_lookup (frame, this, &local->validate_loc, xdata, +- cbk_fn); ++ ret = quota_enforcer_lookup (frame, this, xdata, cbk_fn); + if (ret < 0) { + ret = -ENOTCONN; + goto err; +diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h +index 183f8c1..566302c 100644 +--- a/xlators/features/quota/src/quota.h ++++ b/xlators/features/quota/src/quota.h +@@ -214,6 +214,9 @@ struct quota_local { + quota_ancestry_built_t ancestry_cbk; + void *ancestry_data; + dict_t *xdata; ++ dict_t *validate_xdata; ++ int32_t quotad_conn_retry; ++ xlator_t *this; + }; + typedef struct quota_local quota_local_t; + +@@ -232,12 +235,17 @@ struct quota_priv { + inode_table_t *itable; + char *volume_uuid; + uint64_t validation_count; ++ int32_t quotad_conn_status; + }; + typedef struct quota_priv quota_priv_t; + + int +-quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, +- dict_t *xdata, fop_lookup_cbk_t cbk); ++quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, dict_t *xdata, ++ fop_lookup_cbk_t cbk); ++ ++void ++_quota_enforcer_lookup (void *data); ++ + struct rpc_clnt * + quota_enforcer_init (xlator_t *this, dict_t *options); + +-- +1.9.3 + diff --git a/SOURCES/0006-snapshot-scheduler-Return-proper-error-code-in-case-.patch b/SOURCES/0006-snapshot-scheduler-Return-proper-error-code-in-case-.patch new file mode 100644 index 0000000..22d0d24 --- /dev/null +++ b/SOURCES/0006-snapshot-scheduler-Return-proper-error-code-in-case-.patch @@ -0,0 +1,569 @@ +From 475b0ff983f3eece51641bb49983295e54187599 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Fri, 29 May 2015 18:11:01 +0530 +Subject: [PATCH 06/18] snapshot/scheduler: Return proper error code in case of + failure + + Backport of http://review.gluster.org/#/c/11005/ + +ENUM RETCODE ERROR +---------------------------------------------------------- +INTERNAL_ERROR 2 Internal Error +SHARED_STORAGE_DIR_DOESNT_EXIST 3 Shared Storage Dir + does not exist +SHARED_STORAGE_NOT_MOUNTED 4 Shared storage is not mounted +ANOTHER_TRANSACTION_IN_PROGRESS 5 Another transaction is in progress +INIT_FAILED 6 Initialisation failed +SCHEDULING_ALREADY_DISABLED 7 Scheduler is already disabled +SCHEDULING_ALREADY_ENABLED 8 Scheduler is already enabled +NODE_NOT_INITIALISED 9 Node not initialised +ANOTHER_SCHEDULER_ACTIVE 10 Another scheduler is active +JOB_ALREADY_EXISTS 11 Job already exists +JOB_NOT_FOUND 12 Job not found +INVALID_JOBNAME 13 Jobname is invalid +INVALID_VOLNAME 14 Volname is invalid +INVALID_SCHEDULE 15 Schedule is invalid +INVALID_ARG 16 Argument is invalid + +Change-Id: Ia1da166659099f4c951fcdb4d755529e41167b80 +BUG: 1223206 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/50090 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/snap_scheduler.py | 142 ++++++++++++++++++-------------- + 1 file changed, 81 insertions(+), 61 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index e7c1791..1c5f938 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -38,6 +38,21 @@ tasks = {} + longest_field = 12 + current_scheduler = "" + ++INTERNAL_ERROR = 2 ++SHARED_STORAGE_DIR_DOESNT_EXIST = 3 ++SHARED_STORAGE_NOT_MOUNTED = 4 ++ANOTHER_TRANSACTION_IN_PROGRESS = 5 ++INIT_FAILED = 6 ++SCHEDULING_ALREADY_DISABLED = 7 ++SCHEDULING_ALREADY_ENABLED = 8 ++NODE_NOT_INITIALISED = 9 ++ANOTHER_SCHEDULER_ACTIVE = 10 ++JOB_ALREADY_EXISTS = 11 ++JOB_NOT_FOUND = 12 ++INVALID_JOBNAME = 13 ++INVALID_VOLNAME = 14 ++INVALID_SCHEDULE = 15 ++INVALID_ARG = 16 + + def output(msg): + print("%s: %s" % (SCRIPT_NAME, msg)) +@@ -66,7 +81,7 @@ def initLogger(): + + + def scheduler_status(): +- success = False ++ ret = INTERNAL_ERROR + global scheduler_enabled + try: + f = os.path.realpath(GCRON_TASKS) +@@ -76,33 +91,32 @@ def scheduler_status(): + else: + log.info("Snapshot scheduler is currently enabled.") + scheduler_enabled = True +- success = True ++ ret = 0 + except: + log.error("Failed to enable snapshot scheduling. Error: " + "Failed to check the status of %s.", GCRON_DISABLED) + +- return success ++ return ret + + def enable_scheduler(): + ret = scheduler_status() +- if ret: ++ if ret == 0: + if not scheduler_enabled: + + # Check if another scheduler is active. + ret = get_current_scheduler() +- if ret: ++ if ret == 0: + if (current_scheduler != "none"): + print_str = "Failed to enable snapshot scheduling. " \ + "Error: Another scheduler is active." + log.error(print_str) + output(print_str) +- ret = False ++ ret = ANOTHER_SCHEDULER_ACTIVE + return ret + else: + print_str = "Failed to get current scheduler info." + log.error(print_str) + output(print_str) +- ret = False + return ret + + log.info("Enabling snapshot scheduler.") +@@ -118,23 +132,24 @@ def enable_scheduler(): + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + GCRON_ENABLED, strerror) +- ret = False ++ ret = INTERNAL_ERROR + return ret + os.symlink(GCRON_ENABLED, GCRON_TASKS) + update_current_scheduler("cli") + log.info("Snapshot scheduling is enabled") + output("Snapshot scheduling is enabled") ++ ret = 0 + except IOError as (errno, strerror): + print_str = "Failed to enable snapshot scheduling. Error: "+strerror + log.error(print_str) + output(print_str) +- ret = False ++ ret = INTERNAL_ERROR + else: + print_str = "Failed to enable snapshot scheduling. " \ + "Error: Snapshot scheduling is already enabled." + log.error(print_str) + output(print_str) +- ret = False ++ ret = SCHEDULING_ALREADY_ENABLED + else: + print_str = "Failed to enable snapshot scheduling. " \ + "Error: Failed to check scheduler status." +@@ -146,14 +161,14 @@ def enable_scheduler(): + + def disable_scheduler(): + ret = scheduler_status() +- if ret: ++ if ret == 0: + if scheduler_enabled: + log.info("Disabling snapshot scheduler.") + try: + # Check if another scheduler is active. If not, then + # update current scheduler to "none". Else do nothing. + ret = get_current_scheduler() +- if ret: ++ if ret == 0: + if (current_scheduler == "cli"): + update_current_scheduler("none") + else: +@@ -161,7 +176,6 @@ def disable_scheduler(): + "Error: Failed to get current scheduler info." + log.error(print_str) + output(print_str) +- ret = False + return ret + + if os.path.exists(GCRON_DISABLED): +@@ -173,22 +187,24 @@ def disable_scheduler(): + os.symlink(GCRON_DISABLED, GCRON_TASKS) + log.info("Snapshot scheduling is disabled") + output("Snapshot scheduling is disabled") ++ ret = 0 + except IOError as (errno, strerror): + print_str = "Failed to disable snapshot scheduling. Error: "+strerror + log.error(print_str) + output(print_str) +- ret = False ++ ret = INTERNAL_ERROR + else: + print_str = "Failed to disable scheduling. " \ + "Error: Snapshot scheduling is already disabled." + log.error(print_str) + output(print_str) +- ret = False ++ ret = SCHEDULING_ALREADY_DISABLED + else: + print_str = "Failed to disable snapshot scheduling. " \ + "Error: Failed to check scheduler status." + log.error(print_str) + output(print_str) ++ ret = INTERNAL_ERROR + + return ret + +@@ -211,10 +227,10 @@ def load_tasks_from_file(): + len(schedule)) + tasks[jobname] = schedule+":"+volname + f.close() +- ret = True ++ ret = 0 + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", GCRON_ENABLED, strerror) +- ret = False ++ ret = INTERNAL_ERROR + + return ret + +@@ -225,10 +241,10 @@ def get_current_scheduler(): + with open(CURRENT_SCHEDULER, 'r') as f: + current_scheduler = f.readline().rstrip('\n') + f.close() +- ret = True ++ ret = 0 + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", CURRENT_SCHEDULER, strerror) +- ret = False ++ ret = INTERNAL_ERROR + + return ret + +@@ -236,7 +252,7 @@ def get_current_scheduler(): + def list_schedules(): + log.info("Listing snapshot schedules.") + ret = load_tasks_from_file() +- if ret: ++ if ret == 0: + if len(tasks) == 0: + output("No snapshots scheduled") + else: +@@ -255,6 +271,7 @@ def list_schedules(): + longest_field + 5) + operation = "Snapshot Create".ljust(longest_field+5) + print(jobname+schedule+operation+volname) ++ ret = 0 + else: + print_str = "Failed to list snapshot schedules. " \ + "Error: Failed to load tasks from "+GCRON_ENABLED +@@ -265,7 +282,6 @@ def list_schedules(): + + + def write_tasks_to_file(): +- ret = False + try: + with open(TMP_FILE, "w", 0644) as f: + # If tasks is empty, just create an empty tmp file +@@ -282,16 +298,15 @@ def write_tasks_to_file(): + f.close() + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", TMP_FILE, strerror) +- ret = False ++ ret = INTERNAL_ERROR + return ret + + shutil.move(TMP_FILE, GCRON_ENABLED) +- ret = True ++ ret = 0 + + return ret + + def update_current_scheduler(data): +- ret = False + try: + with open(TMP_FILE, "w", 0644) as f: + f.write("%s" % data) +@@ -300,11 +315,11 @@ def update_current_scheduler(data): + f.close() + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", TMP_FILE, strerror) +- ret = False ++ ret = INTERNAL_ERROR + return ret + + shutil.move(TMP_FILE, CURRENT_SCHEDULER) +- ret = True ++ ret = 0 + + return ret + +@@ -312,17 +327,17 @@ def update_current_scheduler(data): + def add_schedules(jobname, schedule, volname): + log.info("Adding snapshot schedules.") + ret = load_tasks_from_file() +- if ret: ++ if ret == 0: + if jobname in tasks: + print_str = ("%s already exists in schedule. Use " + "'edit' to modify %s" % (jobname, jobname)) + log.error(print_str) + output(print_str) +- ret = False ++ ret = JOB_ALREADY_EXISTS + else: + tasks[jobname] = schedule + ":" + volname + ret = write_tasks_to_file() +- if ret: ++ if ret == 0: + # Create a LOCK_FILE for the job + job_lockfile = LOCK_FILE_DIR + jobname + try: +@@ -331,10 +346,11 @@ def add_schedules(jobname, schedule, volname): + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + job_lockfile, strerror) +- ret = False ++ ret = INTERNAL_ERROR + return ret + log.info("Successfully added snapshot schedule %s" % jobname) + output("Successfully added snapshot schedule") ++ ret = 0 + else: + print_str = "Failed to add snapshot schedule. " \ + "Error: Failed to load tasks from "+GCRON_ENABLED +@@ -347,11 +363,11 @@ def add_schedules(jobname, schedule, volname): + def delete_schedules(jobname): + log.info("Delete snapshot schedules.") + ret = load_tasks_from_file() +- if ret: ++ if ret == 0: + if jobname in tasks: + del tasks[jobname] + ret = write_tasks_to_file() +- if ret: ++ if ret == 0: + # Delete the LOCK_FILE for the job + job_lockfile = LOCK_FILE_DIR+jobname + try: +@@ -359,15 +375,18 @@ def delete_schedules(jobname): + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + job_lockfile, strerror) ++ ret = INTERNAL_ERROR ++ return ret + log.info("Successfully deleted snapshot schedule %s" + % jobname) + output("Successfully deleted snapshot schedule") ++ ret = 0 + else: + print_str = ("Failed to delete %s. Error: No such " + "job scheduled" % jobname) + log.error(print_str) + output(print_str) +- ret = False ++ ret = JOB_NOT_FOUND + else: + print_str = "Failed to delete snapshot schedule. " \ + "Error: Failed to load tasks from "+GCRON_ENABLED +@@ -380,11 +399,11 @@ def delete_schedules(jobname): + def edit_schedules(jobname, schedule, volname): + log.info("Editing snapshot schedules.") + ret = load_tasks_from_file() +- if ret: ++ if ret == 0: + if jobname in tasks: + tasks[jobname] = schedule+":"+volname + ret = write_tasks_to_file() +- if ret: ++ if ret == 0: + log.info("Successfully edited snapshot schedule %s" % jobname) + output("Successfully edited snapshot schedule") + else: +@@ -392,7 +411,7 @@ def edit_schedules(jobname, schedule, volname): + "job scheduled" % jobname) + log.error(print_str) + output(print_str) +- ret = False ++ ret = JOB_NOT_FOUND + else: + print_str = "Failed to edit snapshot schedule. " \ + "Error: Failed to load tasks from "+GCRON_ENABLED +@@ -413,7 +432,7 @@ def initialise_scheduler(): + f.close() + except IOError as (errno, strerror): + log.error("Failed to open /tmp/crontab. Error: %s.", strerror) +- ret = False ++ ret = INIT_FAILED + return ret + + shutil.move("/tmp/crontab", GCRON_UPDATE_TASK) +@@ -424,7 +443,7 @@ def initialise_scheduler(): + f.close() + except IOError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", GCRON_TASKS, strerror) +- ret = False ++ ret = INIT_FAILED + return ret + + if os.path.lexists(GCRON_CROND_TASK): +@@ -435,22 +454,22 @@ def initialise_scheduler(): + log.info("Successfully inited snapshot scheduler for this node") + output("Successfully inited snapshot scheduler for this node") + +- ret = True ++ ret = 0 + return ret + + + def syntax_checker(args): +- ret = False +- + if hasattr(args, 'jobname'): + if (len(args.jobname.split()) != 1): + output("Invalid Jobname. Jobname should not be empty and should not contain \" \" character.") ++ ret = INVALID_JOBNAME + return ret + args.jobname=args.jobname.strip() + + if hasattr(args, 'volname'): + if (len(args.volname.split()) != 1): + output("Invalid Volname. Volname should not be empty and should not contain \" \" character.") ++ ret = INVALID_VOLNAME + return ret + args.volname=args.volname.strip() + +@@ -464,26 +483,25 @@ def syntax_checker(args): + print ("| | +-------- Day of the Month (range: 1-31)") + print ("| +---------- Hour (range: 0-23)") + print ("+------------ Minute (range: 0-59)") ++ ret = INVALID_SCHEDULE + return ret + +- ret = True ++ ret = 0 + return ret + + + def perform_operation(args): +- ret = False +- + # Initialise snapshot scheduler on local node + if args.action == "init": + ret = initialise_scheduler() +- if not ret: ++ if ret != 0: + output("Failed to initialise snapshot scheduling") + return ret + + # Disable snapshot scheduler + if args.action == "disable_force": + ret = disable_scheduler() +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + +@@ -495,12 +513,13 @@ def perform_operation(args): + "the snap scheduler for the local node.") + log.error(print_str) + output(print_str) ++ ret = NODE_NOT_INITIALISED + return ret + + # Check status of snapshot scheduler. + if args.action == "status": + ret = scheduler_status() +- if ret: ++ if ret == 0: + if scheduler_enabled: + output("Snapshot scheduling status: Enabled") + else: +@@ -512,14 +531,14 @@ def perform_operation(args): + # Enable snapshot scheduler + if args.action == "enable": + ret = enable_scheduler() +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + + # Disable snapshot scheduler + if args.action == "disable": + ret = disable_scheduler() +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + +@@ -531,33 +550,34 @@ def perform_operation(args): + # Add snapshot schedules + if args.action == "add": + ret = syntax_checker(args) +- if not ret: ++ if ret != 0: + return ret + ret = add_schedules(args.jobname, args.schedule, args.volname) +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + + # Delete snapshot schedules + if args.action == "delete": + ret = syntax_checker(args) +- if not ret: ++ if ret != 0: + return ret + ret = delete_schedules(args.jobname) +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + + # Edit snapshot schedules + if args.action == "edit": + ret = syntax_checker(args) +- if not ret: ++ if ret != 0: + return ret + ret = edit_schedules(args.jobname, args.schedule, args.volname) +- if ret: ++ if ret == 0: + subprocess.Popen(["touch", "-h", GCRON_TASKS]) + return ret + ++ ret = INVALID_ARG + return ret + + +@@ -601,11 +621,11 @@ def main(): + + if not os.path.exists(SHARED_STORAGE_DIR): + output("Failed: "+SHARED_STORAGE_DIR+" does not exist.") +- return ret ++ return SHARED_STORAGE_DIR_DOESNT_EXIST + + if not os.path.ismount(SHARED_STORAGE_DIR): + output("Failed: Shared storage is not mounted at "+SHARED_STORAGE_DIR) +- return ret ++ return SHARED_STORAGE_NOT_MOUNTED + + if not os.path.exists(SHARED_STORAGE_DIR+"/snaps/"): + try: +@@ -615,6 +635,7 @@ def main(): + log.error("Failed to create %s : %s", SHARED_STORAGE_DIR+"/snaps/", strerror) + output("Failed to create %s. Error: %s" + % (SHARED_STORAGE_DIR+"/snaps/", strerror)) ++ return INTERNAL_ERROR + + if not os.path.exists(GCRON_ENABLED): + f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK, 0644) +@@ -628,6 +649,7 @@ def main(): + log.error("Failed to create %s : %s", LOCK_FILE_DIR, strerror) + output("Failed to create %s. Error: %s" + % (LOCK_FILE_DIR, strerror)) ++ return INTERNAL_ERROR + + if not os.path.exists(CURRENT_SCHEDULER): + update_current_scheduler("none") +@@ -637,19 +659,17 @@ def main(): + try: + fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) + ret = perform_operation(args) +- if not ret: +- ret = 1 +- else: +- ret = 0 + fcntl.flock(f, fcntl.LOCK_UN) + except IOError as (errno, strerror): + log.info("%s is being processed by another agent.", LOCK_FILE) + output("Another snap_scheduler command is running. " + "Please try again after some time.") ++ return ANOTHER_TRANSACTION_IN_PROGRESS + os.close(f) + except IOError as (errno, strerror): + log.error("Failed to open %s : %s", LOCK_FILE, strerror) + output("Failed to open %s. Error: %s" % (LOCK_FILE, strerror)) ++ return INTERNAL_ERROR + + return ret + +-- +1.9.3 + diff --git a/SOURCES/0007-glusterd-do-not-show-pid-of-brick-in-volume-status-i.patch b/SOURCES/0007-glusterd-do-not-show-pid-of-brick-in-volume-status-i.patch new file mode 100644 index 0000000..683c96f --- /dev/null +++ b/SOURCES/0007-glusterd-do-not-show-pid-of-brick-in-volume-status-i.patch @@ -0,0 +1,54 @@ +From eedc3bf07a6ce161ef65e17459c2ce440b498f30 Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Thu, 21 May 2015 17:13:54 +0530 +Subject: [PATCH 07/18] glusterd: do not show pid of brick in volume status if + brick is down. + +glusterd is currently showing pid of brick in volume status if brick +goes down. + +It should not show pid of brick if brick is down. + +BUG: 1223715 +Change-Id: I65fd5a20a8f60159a71e00914a72ece99168ed9c +Signed-off-by: Gaurav Kumar Garg +upstream-review-url: Reviewed-on: http://review.gluster.org/11080 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50098 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-utils.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index f90abc19..86b22f8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -5170,12 +5170,12 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, + + int ret = -1; + int32_t pid = -1; +- int32_t brick_online = -1; + char key[1024] = {0}; + char base_key[1024] = {0}; + char pidfile[PATH_MAX] = {0}; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; ++ gf_boolean_t brick_online = _gf_false; + + GF_ASSERT (volinfo); + GF_ASSERT (brickinfo); +@@ -5230,7 +5230,9 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, + + GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); + +- brick_online = gf_is_service_running (pidfile, &pid); ++ if (glusterd_is_brick_started (brickinfo)) { ++ brick_online = gf_is_service_running (pidfile, &pid); ++ } + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s.pid", base_key); +-- +1.9.3 + diff --git a/SOURCES/0008-glusterd-Buffer-overflow-causing-crash-for-glusterd.patch b/SOURCES/0008-glusterd-Buffer-overflow-causing-crash-for-glusterd.patch new file mode 100644 index 0000000..4d21e8e --- /dev/null +++ b/SOURCES/0008-glusterd-Buffer-overflow-causing-crash-for-glusterd.patch @@ -0,0 +1,43 @@ +From 4b3a43a2fd2a9daa2870d7422f124dec2480c4a3 Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Thu, 4 Jun 2015 22:37:11 +0530 +Subject: [PATCH 08/18] glusterd: Buffer overflow causing crash for glusterd + +Problem: In GLUSTERD_GET_DEFRAG_PROCESS we are using PATH_MAX (4096) +as the max size of the input for target path, but we have allocated +NAME_MAX (255) size of buffer for the target. + +Now this crash is not seen with source, but seen with RPMS. +The reason is _foritfy_fail. This check happens when _FORTIFY_SOURCE +flag is enabled. This option tries to figure out possible +overflow scenarios like the bug here and does crash the process. + +BUG: 1228541 +Change-Id: I0df5d1546761ba73e88ccbf135cb49307aa9145e +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/50095 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/mgmt/glusterd/src/glusterd.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index bca7697..ab62952 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -599,9 +599,9 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args); + + #define GLUSTERD_GET_DEFRAG_PROCESS(path, volinfo) do { \ + if (volinfo->rebal.defrag_cmd == GF_DEFRAG_CMD_START_TIER) \ +- snprintf (path, PATH_MAX, "tier"); \ ++ snprintf (path, NAME_MAX, "tier"); \ + else \ +- snprintf (path, PATH_MAX, "rebalance"); \ ++ snprintf (path, NAME_MAX, "rebalance"); \ + } while (0) + + #define GLUSTERD_GET_DEFRAG_DIR(path, volinfo, priv) do { \ +-- +1.9.3 + diff --git a/SOURCES/0009-glusterd-shared_storage-Provide-a-volume-set-option-.patch b/SOURCES/0009-glusterd-shared_storage-Provide-a-volume-set-option-.patch new file mode 100644 index 0000000..d3c3293 --- /dev/null +++ b/SOURCES/0009-glusterd-shared_storage-Provide-a-volume-set-option-.patch @@ -0,0 +1,1159 @@ +From f8c28163309870048415cf58668c06a6ba2d700d Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Thu, 14 May 2015 15:00:59 +0530 +Subject: [PATCH 09/18] glusterd/shared_storage: Provide a volume set option to + create and mount the shared storage + + Backport of http://review.gluster.org/#/c/10793/ + +Introducing a global volume set option(cluster.enable-shared-storage) +which helps create and set-up the shared storage meta volume. + +gluster volume set all cluster.enable-shared-storage enable + +On enabling this option, the system analyzes the number of peers +in the cluster, which are currently connected, and chooses three +such peers(including the node the command is issued from). From these +peers a volume(gluster_shared_storage) is created. Depending on the +number of peers available the volume is either a replica 3 +volume(if there are 3 connected peers), or a replica 2 volume(if there +are 2 connected peers). "/var/run/gluster/ss_brick" serves as the +brick path on each node for the shared storage volume. We also mount +the shared storage at "/var/run/gluster/shared_storage" on all the nodes +in the cluster as part of enabling this option. If there is only one node +in the cluster, or only one node is up then the command will fail + +Once the volume is created, and mounted the maintainance of the +volume like adding-bricks, removing bricks etc., is expected to +be the onus of the user. + +On disabling the option, we provide the user a warning, and on +affirmation from the user we stop the shared storage volume, and unmount +it from all the nodes in the cluster. + +gluster volume set all cluster.enable-shared-storage disable + +Change-Id: Idd92d67b93f444244f99ede9f634ef18d2945dbc +BUG: 1223201 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/50103 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + cli/src/cli-cmd-parser.c | 56 ++++-- + cli/src/cli-cmd-volume.c | 51 +++++- + cli/src/cli-cmd.h | 2 + + cli/src/cli.h | 4 +- + extras/hook-scripts/set/post/Makefile.am | 2 +- + .../set/post/S32gluster_enable_shared_storage.sh | 124 +++++++++++++ + glusterfs.spec.in | 4 + + libglusterfs/src/globals.h | 2 + + xlators/mgmt/glusterd/src/glusterd-hooks.c | 40 ++++- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 196 ++++++++++++++++++++- + xlators/mgmt/glusterd/src/glusterd-op-sm.h | 4 + + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 9 + + xlators/mgmt/glusterd/src/glusterd-sm.c | 12 ++ + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 6 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 31 ++++ + xlators/mgmt/glusterd/src/glusterd-utils.h | 2 + + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 6 + + xlators/mgmt/glusterd/src/glusterd.c | 107 +++++++---- + xlators/mgmt/glusterd/src/glusterd.h | 3 + + 19 files changed, 588 insertions(+), 73 deletions(-) + create mode 100755 extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 2390822..caa3191 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -1406,17 +1406,19 @@ out: + } + + int32_t +-cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, +- char **op_errstr) ++cli_cmd_volume_set_parse (struct cli_state *state, const char **words, ++ int wordcount, dict_t **options, char **op_errstr) + { +- dict_t *dict = NULL; +- char *volname = NULL; +- int ret = -1; +- int count = 0; +- char *key = NULL; +- char *value = NULL; +- int i = 0; +- char str[50] = {0,}; ++ dict_t *dict = NULL; ++ char *volname = NULL; ++ int ret = -1; ++ int count = 0; ++ char *key = NULL; ++ char *value = NULL; ++ int i = 0; ++ char str[50] = {0,}; ++ const char *question = NULL; ++ gf_answer_t answer = GF_ANSWER_NO; + + GF_ASSERT (words); + GF_ASSERT (options); +@@ -1438,6 +1440,22 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, + if (ret) + goto out; + ++ if (!strcmp (volname, "all")) { ++ ret = dict_set_str (dict, "globalname", "All"); ++ if (ret) { ++ gf_log (THIS->name, GF_LOG_ERROR, ++ "dict set on global key failed."); ++ goto out; ++ } ++ ++ ret = dict_set_int32 (dict, "hold_global_locks", _gf_true); ++ if (ret) { ++ gf_log (THIS->name, GF_LOG_ERROR, ++ "dict set on global key failed."); ++ goto out; ++ } ++ } ++ + if ((!strcmp (volname, "help") || !strcmp (volname, "help-xml")) + && wordcount == 3 ) { + ret = dict_set_str (dict, volname, volname); +@@ -1507,6 +1525,24 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, + + if (ret) + goto out; ++ ++ if ((!strcmp (key, "cluster.enable-shared-storage")) && ++ (!strcmp (value, "disable"))) { ++ question = "Disabling cluster.enable-shared-storage " ++ "will delete the shared storage volume" ++ "(gluster_shared_storage), which is used " ++ "by snapshot scheduler, geo-replication " ++ "and NFS-Ganesha. Do you still want to " ++ "continue?"; ++ answer = cli_cmd_get_confirmation (state, question); ++ if (GF_ANSWER_NO == answer) { ++ gf_log ("cli", GF_LOG_ERROR, "Operation " ++ "cancelled, exiting"); ++ *op_errstr = gf_strdup ("Aborted by user."); ++ ret = -1; ++ goto out; ++ } ++ } + } + + ret = dict_set_int32 (dict, "count", wordcount-3); +diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c +index da6603c..6dd3058 100644 +--- a/cli/src/cli-cmd-volume.c ++++ b/cli/src/cli-cmd-volume.c +@@ -286,22 +286,28 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word, + goto out; + } + +- answer = cli_cmd_get_confirmation (state, question); +- +- if (GF_ANSWER_NO == answer) { +- ret = 0; +- goto out; +- } +- + volname = (char *)words[2]; + + ret = dict_set_str (dict, "volname", volname); +- + if (ret) { + gf_log (THIS->name, GF_LOG_WARNING, "dict set failed"); + goto out; + } + ++ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { ++ question = "Deleting the shared storage volume" ++ "(gluster_shared_storage), will affect features " ++ "like snapshot scheduler, geo-replication " ++ "and NFS-Ganesha. Do you still want to " ++ "continue?"; ++ } ++ ++ answer = cli_cmd_get_confirmation (state, question); ++ if (GF_ANSWER_NO == answer) { ++ ret = 0; ++ goto out; ++ } ++ + CLI_LOCAL_INIT (local, words, frame, dict); + + if (proc->fn) { +@@ -473,6 +479,14 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, + goto out; + } + ++ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { ++ question = "Stopping the shared storage volume" ++ "(gluster_shared_storage), will affect features " ++ "like snapshot scheduler, geo-replication " ++ "and NFS-Ganesha. Do you still want to " ++ "continue?"; ++ } ++ + if (wordcount == 4) { + if (!strcmp("force", words[3])) { + flags |= GF_CLI_FLAG_OP_FORCE; +@@ -483,6 +497,7 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, + goto out; + } + } ++ + ret = dict_set_int32 (dict, "flags", flags); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, +@@ -732,7 +747,8 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, + if (!frame) + goto out; + +- ret = cli_cmd_volume_set_parse (words, wordcount, &options, &op_errstr); ++ ret = cli_cmd_volume_set_parse (state, words, wordcount, ++ &options, &op_errstr); + if (ret) { + if (op_errstr) { + cli_err ("%s", op_errstr); +@@ -1612,6 +1628,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, + int parse_error = 0; + int need_question = 0; + cli_local_t *local = NULL; ++ char *volname = NULL; + + const char *question = "Removing brick(s) can result in data loss. " + "Do you want to Continue?"; +@@ -1628,6 +1645,22 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, + goto out; + } + ++ ret = dict_get_str (options, "volname", &volname); ++ if (ret || !volname) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to fetch volname"); ++ ret = -1; ++ goto out; ++ } ++ ++ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { ++ question = "Removing brick from the shared storage volume" ++ "(gluster_shared_storage), will affect features " ++ "like snapshot scheduler, geo-replication " ++ "and NFS-Ganesha. Do you still want to " ++ "continue?"; ++ need_question = _gf_true; ++ } ++ + if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { + /* we need to ask question only in case of 'commit or force' */ + answer = cli_cmd_get_confirmation (state, question); +diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h +index 94fa3e9..3a689c4 100644 +--- a/cli/src/cli-cmd.h ++++ b/cli/src/cli-cmd.h +@@ -20,6 +20,8 @@ + #include "cli.h" + #include "list.h" + ++#define GLUSTER_SHARED_STORAGE "gluster_shared_storage" ++ + #define CLI_LOCAL_INIT(local, words, frame, dictionary) \ + do { \ + local = cli_local_get (); \ +diff --git a/cli/src/cli.h b/cli/src/cli.h +index c9283b5..6c0fbce 100644 +--- a/cli/src/cli.h ++++ b/cli/src/cli.h +@@ -248,8 +248,8 @@ int32_t + cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **opt); + + int32_t +-cli_cmd_volume_set_parse (const char **words, int wordcount, +- dict_t **options, char **op_errstr); ++cli_cmd_volume_set_parse (struct cli_state *state, const char **words, ++ int wordcount, dict_t **options, char **op_errstr); + int32_t + cli_cmd_ganesha_parse (struct cli_state *state, const char **words, + int wordcount, dict_t **options, char **op_errstr); +diff --git a/extras/hook-scripts/set/post/Makefile.am b/extras/hook-scripts/set/post/Makefile.am +index 3ec25d9..99dfaa3 100644 +--- a/extras/hook-scripts/set/post/Makefile.am ++++ b/extras/hook-scripts/set/post/Makefile.am +@@ -1 +1 @@ +-EXTRA_DIST = S30samba-set.sh S31ganesha-set.sh ++EXTRA_DIST = S30samba-set.sh S31ganesha-set.sh S32gluster_enable_shared_storage.sh +diff --git a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +new file mode 100755 +index 0000000..28fa0e5 +--- /dev/null ++++ b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +@@ -0,0 +1,124 @@ ++#!/bin/bash ++ ++key=`echo $3 | cut -d '=' -f 1` ++val=`echo $3 | cut -d '=' -f 2` ++if [ "$key" != "cluster.enable-shared-storage" ]; then ++ exit; ++fi ++if [ "$val" != 'enable' ]; then ++ if [ "$val" != 'disable' ]; then ++ exit; ++ fi ++fi ++ ++option=$val ++ ++key_val_pair1=`echo $4 | cut -d ',' -f 1` ++key_val_pair2=`echo $4 | cut -d ',' -f 2` ++ ++key=`echo $key_val_pair1 | cut -d '=' -f 1` ++val=`echo $key_val_pair1 | cut -d '=' -f 2` ++if [ "$key" != "is_originator" ]; then ++ exit; ++fi ++is_originator=$val; ++ ++key=`echo $key_val_pair2 | cut -d '=' -f 1` ++val=`echo $key_val_pair2 | cut -d '=' -f 2` ++if [ "$key" != "local_node_hostname" ]; then ++ exit; ++fi ++local_node_hostname=$val; ++ ++# Read gluster peer status to find the peers ++# which are in 'Peer in Cluster' mode and ++# are connected. ++ ++number_of_connected_peers=0 ++while read -r line ++do ++ # Already got two connected peers. Including the current node ++ # we have 3 peers which is enough to create a shared storage ++ # with replica 3 ++ if [ "$number_of_connected_peers" == "2" ]; then ++ break; ++ fi ++ ++ key=`echo $line | cut -d ':' -f 1` ++ if [ "$key" == "Hostname" ]; then ++ hostname=`echo $line | cut -d ':' -f 2 | xargs` ++ fi ++ ++ if [ "$key" == "State" ]; then ++ peer_state=`echo $line | cut -d ':' -f 2 | cut -d '(' -f 1 | xargs` ++ conn_state=`echo $line | cut -d '(' -f 2 | cut -d ')' -f 1 | xargs` ++ ++ if [ "$peer_state" == "Peer in Cluster" ]; then ++ if [ "$conn_state" == "Connected" ]; then ++ ((number_of_connected_peers++)) ++ connected_peer[$number_of_connected_peers]=$hostname ++ fi ++ fi ++ fi ++ ++done < <(gluster peer status) ++ ++# Include current node in connected peer list ++((number_of_connected_peers++)) ++connected_peer[$number_of_connected_peers]=$local_node_hostname ++ ++# forming the create vol command ++create_cmd="gluster --mode=script --wignore volume create \ ++ gluster_shared_storage replica $number_of_connected_peers" ++ ++# Adding the brick names in the command ++for i in "${connected_peer[@]}" ++do ++ create_cmd=$create_cmd" "$i:/var/run/gluster/ss_brick ++done ++ ++if [ "$option" == "disable" ]; then ++ # Unmount the volume on all the nodes ++ umount /var/run/gluster/shared_storage ++fi ++ ++if [ "$is_originator" == 1 ]; then ++ if [ "$option" == "enable" ]; then ++ # Create and start the volume ++ $create_cmd ++ gluster --mode=script --wignore volume start gluster_shared_storage ++ fi ++ ++ if [ "$option" == "disable" ]; then ++ # Stop and delete the volume ++ gluster --mode=script --wignore volume stop gluster_shared_storage ++ gluster --mode=script --wignore volume delete gluster_shared_storage ++ fi ++fi ++ ++function check_volume_status() ++{ ++ status=`gluster volume info gluster_shared_storage | grep Status | cut -d ':' -f 2 | xargs` ++ echo $status ++} ++ ++mount_cmd="mount -t glusterfs "$local_node_hostname":/gluster_shared_storage \ ++ /var/run/gluster/shared_storage" ++ ++if [ "$option" == "enable" ]; then ++ retry=0; ++ # Wait for volume to start before mounting ++ status=$(check_volume_status) ++ while [ "$status" != "Started" ]; do ++ sleep 5; ++ ((retry++)) ++ if [ "$retry" == 3 ]; then ++ break; ++ fi ++ status = check_volume_status; ++ done ++ # Mount the volume on all the nodes ++ umount /var/run/gluster/shared_storage ++ mkdir -p /var/run/gluster/shared_storage ++ $mount_cmd ++fi +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 0ec8201..a5a884f 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1115,6 +1115,7 @@ fi + %config %{_sharedstatedir}/glusterd/hooks/1/add-brick/pre/S28Quota-enable-root-xattr-heal.sh + %config %{_sharedstatedir}/glusterd/hooks/1/set/post/S30samba-set.sh + %config %{_sharedstatedir}/glusterd/hooks/1/set/post/S31ganesha-set.sh ++%config %{_sharedstatedir}/glusterd/hooks/1/set/post/S32gluster_enable_shared_storage.sh + %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S29CTDBsetup.sh + %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S30samba-start.sh + %config %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S30samba-stop.sh +@@ -1208,6 +1209,9 @@ fi + * Sat May 31 2015 Aravinda VK + - Added stop-all-gluster-processes.sh in glusterfs-server section (#1225331) + ++* Tue May 19 2015 Avra Sengupta ++- Added S32gluster_enable_shared_storage.sh as volume set hook script (#1222013) ++ + * Fri May 29 2015 Anand Nekkunti + - glusterd.socket file cleanup during post run upgrade (#1222869) + +diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h +index b9eaf8a..ed1bb7c 100644 +--- a/libglusterfs/src/globals.h ++++ b/libglusterfs/src/globals.h +@@ -43,6 +43,8 @@ + + #define GD_OP_VERSION_3_7_0 30700 /* Op-version for GlusterFS 3.7.0 */ + ++#define GD_OP_VERSION_3_7_1 30701 /* Op-version for GlusterFS 3.7.1 */ ++ + #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 + + #include "xlator.h" +diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c +index 569f274..3e3f189 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-hooks.c ++++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c +@@ -162,6 +162,34 @@ glusterd_hooks_add_hooks_version (runner_t* runner) + runner_argprintf (runner, "--version=%d", GLUSTERD_HOOK_VER); + } + ++static void ++glusterd_hooks_add_custom_args (dict_t *dict, runner_t *runner) ++{ ++ char *hooks_args = NULL; ++ int32_t ret = -1; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, dict, out); ++ GF_VALIDATE_OR_GOTO (this->name, runner, out); ++ ++ ret = dict_get_str (dict, "hooks_args", &hooks_args); ++ if (ret) ++ gf_log (this->name, GF_LOG_DEBUG, ++ "No Hooks Arguments."); ++ else ++ gf_log (this->name, GF_LOG_DEBUG, ++ "Hooks Args = %s", hooks_args); ++ ++ if (hooks_args) ++ runner_argprintf (runner, "%s", hooks_args); ++ ++out: ++ return; ++} ++ ++ + int + glusterd_hooks_set_volume_args (dict_t *dict, runner_t *runner) + { +@@ -196,6 +224,8 @@ glusterd_hooks_set_volume_args (dict_t *dict, runner_t *runner) + runner_argprintf (runner, "%s=%s", key, value); + } + ++ glusterd_hooks_add_custom_args (dict, runner); ++ + ret = 0; + out: + return ret; +@@ -263,15 +293,7 @@ glusterd_hooks_add_op_args (runner_t *runner, glusterd_op_t op, + break; + + case GD_OP_GSYNC_CREATE: +- ret = dict_get_str (op_ctx, "hooks_args", &hooks_args); +- if (ret) +- gf_log ("", GF_LOG_DEBUG, +- "No Hooks Arguments."); +- else +- gf_log ("", GF_LOG_DEBUG, +- "Hooks Args = %s", hooks_args); +- if (hooks_args) +- runner_argprintf (runner, "%s", hooks_args); ++ glusterd_hooks_add_custom_args (op_ctx, runner); + break; + + case GD_OP_ADD_BRICK: +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 326968e..9b9684e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -55,11 +55,36 @@ + #include + #include + ++extern char ss_brick_path[PATH_MAX]; ++extern char local_node_hostname[PATH_MAX]; ++static int ++glusterd_set_shared_storage (dict_t *dict, char *key, char *value, ++ char **op_errstr); ++ ++/* Valid options for all volumes to be listed in the * ++ * valid_all_vol_opts table. To add newer options to * ++ * all volumes, we can just add more entries to this * ++ * table * ++ */ ++glusterd_all_vol_opts valid_all_vol_opts[] = { ++ { GLUSTERD_QUORUM_RATIO_KEY }, ++ { GLUSTERD_SHARED_STORAGE_KEY }, ++ { NULL }, ++}; ++ + #define ALL_VOLUME_OPTION_CHECK(volname, key, ret, op_errstr, label) \ + do { \ +- gf_boolean_t _all = !strcmp ("all", volname); \ +- gf_boolean_t _ratio = !strcmp (key, \ +- GLUSTERD_QUORUM_RATIO_KEY); \ ++ gf_boolean_t _all = !strcmp ("all", volname); \ ++ gf_boolean_t _ratio = _gf_false; \ ++ int32_t i = 0; \ ++ \ ++ for (i = 0; valid_all_vol_opts[i].option; i++) { \ ++ if (!strcmp (key, valid_all_vol_opts[i].option)) { \ ++ _ratio = _gf_true; \ ++ break; \ ++ } \ ++ } \ ++ \ + if (_all && !_ratio) { \ + ret = -1; \ + *op_errstr = gf_strdup ("Not a valid option for all " \ +@@ -682,6 +707,71 @@ out: + } + + static int ++glusterd_validate_shared_storage (char *key, char *value, char *errstr) ++{ ++ int32_t ret = -1; ++ int32_t exists = -1; ++ int32_t count = -1; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, key, out); ++ GF_VALIDATE_OR_GOTO (this->name, value, out); ++ GF_VALIDATE_OR_GOTO (this->name, errstr, out); ++ ++ ret = 0; ++ ++ if (strcmp (key, GLUSTERD_SHARED_STORAGE_KEY)) { ++ goto out; ++ } ++ ++ if ((strcmp (value, "enable")) && ++ (strcmp (value, "disable"))) { ++ snprintf (errstr, PATH_MAX, ++ "Invalid option(%s). Valid options " ++ "are 'enable' and 'disable'", value); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ ret = -1; ++ goto out; ++ } ++ ++ if (strcmp (value, "enable")) { ++ goto out; ++ } ++ ++ exists = glusterd_check_volume_exists (GLUSTER_SHARED_STORAGE); ++ if (exists) { ++ snprintf (errstr, PATH_MAX, ++ "Shared storage volume("GLUSTER_SHARED_STORAGE ++ ") already exists."); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ ret = -1; ++ goto out; ++ } ++ ++ ret = glusterd_count_connected_peers (&count); ++ if (ret) { ++ snprintf (errstr, PATH_MAX, ++ "Failed to calculate number of connected peers."); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ goto out; ++ } ++ ++ if (count <= 1) { ++ snprintf (errstr, PATH_MAX, ++ "More than one node should " ++ "be up/present in the cluster to enable this option"); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ ret = -1; ++ goto out; ++ } ++ ++out: ++ return ret; ++} ++ ++static int + glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + { + int ret = -1; +@@ -696,7 +786,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + int trash_path_len = 0; + int count = 0; + int dict_count = 0; +- char errstr[2048] = {0, }; ++ char errstr[PATH_MAX] = {0, }; + glusterd_volinfo_t *volinfo = NULL; + glusterd_brickinfo_t *brickinfo = NULL; + dict_t *val_dict = NULL; +@@ -1000,6 +1090,14 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + } + } + ++ ret = glusterd_validate_shared_storage (key, value, errstr); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to validate shared " ++ "storage volume options"); ++ goto out; ++ } ++ + if (!strcmp(key, "features.trash-dir") && trash_enabled) { + if (strchr (value, '/')) { + snprintf (errstr, sizeof (errstr), +@@ -1918,7 +2016,8 @@ out: + } + + static int +-glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict) ++glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, ++ char **op_errstr) + { + char *key = NULL; + char *key_fixed = NULL; +@@ -1942,6 +2041,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict) + "invalid key,value pair in 'volume set'"); + goto out; + } ++ + ret = glusterd_check_option_exists (key, &key_fixed); + if (ret <= 0) { + gf_log (this->name, GF_LOG_ERROR, "Invalid key %s", key); +@@ -1952,6 +2052,13 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict) + if (key_fixed) + key = key_fixed; + ++ ret = glusterd_set_shared_storage (dict, key, value, op_errstr); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to set shared storage option"); ++ goto out; ++ } ++ + /* If the key is cluster.op-version, set conf->op_version to the value + * if needed and save it. + */ +@@ -2030,6 +2137,82 @@ out: + } + + static int ++glusterd_set_shared_storage (dict_t *dict, char *key, char *value, ++ char **op_errstr) ++{ ++ int32_t ret = -1; ++ int32_t exists = -1; ++ int32_t count = -1; ++ char hooks_args[PATH_MAX] = {0, }; ++ char errstr[PATH_MAX] = {0, }; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, dict, out); ++ GF_VALIDATE_OR_GOTO (this->name, key, out); ++ GF_VALIDATE_OR_GOTO (this->name, value, out); ++ GF_VALIDATE_OR_GOTO (this->name, op_errstr, out); ++ ++ ret = 0; ++ ++ if (strcmp (key, GLUSTERD_SHARED_STORAGE_KEY)) { ++ goto out; ++ } ++ ++ /* Re-create the brick path so as to be * ++ * able to re-use it * ++ */ ++ ret = recursive_rmdir (ss_brick_path); ++ if (ret) { ++ snprintf (errstr, PATH_MAX, ++ "Failed to remove shared " ++ "storage brick(%s). " ++ "Reason: %s", ss_brick_path, ++ strerror (errno)); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ ret = -1; ++ goto out; ++ } ++ ++ ret = mkdir_p (ss_brick_path, 0777, _gf_true); ++ if (-1 == ret) { ++ snprintf (errstr, PATH_MAX, ++ "Failed to create shared " ++ "storage brick(%s). " ++ "Reason: %s", ss_brick_path, ++ strerror (errno)); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ goto out; ++ } ++ ++ if (is_origin_glusterd (dict)) { ++ snprintf(hooks_args, sizeof(hooks_args), ++ "is_originator=1,local_node_hostname=%s", ++ local_node_hostname); ++ } else { ++ snprintf(hooks_args, sizeof(hooks_args), ++ "is_originator=0,local_node_hostname=%s", ++ local_node_hostname); ++ } ++ ++ ret = dict_set_dynstr_with_alloc (dict, "hooks_args", hooks_args); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to set" ++ " hooks_args in dict."); ++ goto out; ++ } ++ ++out: ++ if (ret && strlen(errstr)) { ++ *op_errstr = gf_strdup (errstr); ++ } ++ ++ return ret; ++} ++ ++ ++static int + glusterd_op_set_volume (dict_t *dict, char **errstr) + { + int ret = 0; +@@ -2083,7 +2266,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + } + + if (strcasecmp (volname, "all") == 0) { +- ret = glusterd_op_set_all_volume_options (this, dict); ++ ret = glusterd_op_set_all_volume_options (this, dict, ++ &op_errstr); + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h +index 6a1baa4..368bb04 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h +@@ -168,6 +168,10 @@ typedef enum cli_cmd_type_ { + ALL_HEAL_XL, + } cli_cmd_type; + ++typedef struct glusterd_all_volume_options { ++ char *option; ++} glusterd_all_vol_opts; ++ + int + glusterd_op_sm_new_event (glusterd_op_sm_event_type_t event_type, + glusterd_op_sm_event_t **new_event); +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 415d04f..dcd257c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -1472,6 +1472,15 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + goto out; + } + ++ ret = dict_set_dynstr_with_alloc (peer_data, ++ "hostname_in_cluster", ++ peerinfo->hostname); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Unable to add hostname of the peer"); ++ goto out; ++ } ++ + if (priv->op_version >= GD_OP_VERSION_3_6_0) { + ret = glusterd_add_missed_snaps_to_export_dict (peer_data); + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index f8228b0..0d8654a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -38,6 +38,8 @@ + #include "glusterd-snapshot-utils.h" + #include "glusterd-server-quorum.h" + ++char local_node_hostname[PATH_MAX] = {0, }; ++ + static struct cds_list_head gd_friend_sm_queue; + + static char *glusterd_friend_sm_state_names[] = { +@@ -733,6 +735,7 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + int32_t op_ret = -1; + int32_t op_errno = 0; + xlator_t *this = NULL; ++ char *hostname = NULL; + + this = THIS; + GF_ASSERT (this); +@@ -837,6 +840,15 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + + new_event->ctx = new_ev_ctx; + ++ ret = dict_get_str (ev_ctx->vols, "hostname_in_cluster", ++ &hostname); ++ if (ret || !hostname) { ++ gf_log (this->name, GF_LOG_DEBUG, ++ "Unable to fetch local hostname from peer"); ++ } else ++ strncpy (local_node_hostname, hostname, ++ sizeof(local_node_hostname)); ++ + glusterd_friend_sm_inject_event (new_event); + new_event = NULL; + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index fec7494..e5a7cac 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -66,7 +66,7 @@ + + #include "lvm-defaults.h" + +-char snap_mount_folder[PATH_MAX]; ++char snap_mount_dir[PATH_MAX]; + struct snap_create_args_ { + xlator_t *this; + dict_t *dict; +@@ -4558,7 +4558,7 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo, + GF_ASSERT (brickinfo); + + snprintf (snap_brick_mount_path, sizeof (snap_brick_mount_path), +- "%s/%s/brick%d", snap_mount_folder, snap_volinfo->volname, ++ "%s/%s/brick%d", snap_mount_dir, snap_volinfo->volname, + brick_count + 1); + + ret = mkdir_p (snap_brick_mount_path, 0777, _gf_true); +@@ -4748,7 +4748,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict, + * //snap-brick-dir * + */ + snprintf (snap_brick_path, sizeof(snap_brick_path), +- "%s/%s/brick%d%s", snap_mount_folder, ++ "%s/%s/brick%d%s", snap_mount_dir, + snap_vol->volname, brick_count+1, + snap_brick_dir); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 86b22f8..0721110 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -9763,3 +9763,34 @@ glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + out: + return ret; + } ++ ++int32_t ++glusterd_count_connected_peers (int32_t *count) ++{ ++ glusterd_peerinfo_t *peerinfo = NULL; ++ glusterd_conf_t *conf = NULL; ++ int32_t ret = -1; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ conf = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, conf, out); ++ GF_VALIDATE_OR_GOTO (this->name, count, out); ++ ++ *count = 1; ++ ++ rcu_read_lock (); ++ cds_list_for_each_entry_rcu (peerinfo, &conf->peers, uuid_list) { ++ /* Find peer who is connected and is a friend */ ++ if ((peerinfo->connected) && ++ (peerinfo->state.state == GD_FRIEND_STATE_BEFRIENDED)) { ++ (*count)++; ++ } ++ } ++ rcu_read_unlock (); ++ ++ ret = 0; ++out: ++ return ret; ++} +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h +index 246d3ed..d617f60 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.h +@@ -663,5 +663,7 @@ glusterd_defrag_rpc_put (glusterd_defrag_info_t *defrag); + int + glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + int cmd); ++int32_t ++glusterd_count_connected_peers (int32_t *count); + + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 02d59ed..b8ca6be 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1740,6 +1740,12 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/trash", + .op_version = GD_OP_VERSION_3_7_0, + }, ++ { .key = GLUSTERD_SHARED_STORAGE_KEY, ++ .voltype = "mgmt/glusterd", ++ .value = "disable", ++ .type = GLOBAL_DOC, ++ .op_version = GD_OP_VERSION_3_7_1, ++ }, + + #if USE_GFDB /* no GFDB means tiering is disabled */ + /* tier translator - global tunables */ +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 3735c62..54a5fbd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -66,7 +66,8 @@ extern struct rpcsvc_program gd_svc_cli_trusted_progs; + extern struct rpc_clnt_program gd_brick_prog; + extern struct rpcsvc_program glusterd_mgmt_hndsk_prog; + +-extern char snap_mount_folder[PATH_MAX]; ++extern char snap_mount_dir[PATH_MAX]; ++char ss_brick_path[PATH_MAX]; + + rpcsvc_cbk_program_t glusterd_cbk_prog = { + .progname = "Gluster Callback", +@@ -1119,18 +1120,18 @@ glusterd_stop_uds_listener (xlator_t *this) + } + + static int +-glusterd_init_snap_folder (xlator_t *this) ++glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir) + { + int ret = -1; + struct stat buf = {0,}; + +- GF_ASSERT (this); ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, var_run_dir, out); + +- /* Snapshot volumes are mounted under /var/run/gluster/snaps folder. +- * But /var/run is normally a symbolic link to /run folder, which ++ /* /var/run is normally a symbolic link to /run dir, which + * creates problems as the entry point in the mtab for the mount point + * and glusterd maintained entry point will be different. Therefore +- * identify the correct run folder and use it for snap volume mounting. ++ * identify the correct run dir and use it + */ + ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf); + if (ret != 0) { +@@ -1140,20 +1141,38 @@ glusterd_init_snap_folder (xlator_t *this) + goto out; + } + +- /* If /var/run is symlink then use /run folder */ ++ /* If /var/run is symlink then use /run dir */ + if (S_ISLNK (buf.st_mode)) { +- strcpy (snap_mount_folder, GLUSTERD_RUN_DIR); ++ strcpy (var_run_dir, GLUSTERD_RUN_DIR); + } else { +- strcpy (snap_mount_folder, GLUSTERD_VAR_RUN_DIR); ++ strcpy (var_run_dir, GLUSTERD_VAR_RUN_DIR); + } + +- strcat (snap_mount_folder, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); ++ ret = 0; ++out: ++ return ret; ++} ++ ++static int ++glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, ++ char *dir_to_be_created) ++{ ++ int ret = -1; ++ struct stat buf = {0,}; ++ char abs_path[PATH_MAX] = {0, }; ++ ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, var_run_dir, out); ++ GF_VALIDATE_OR_GOTO (this->name, dir_to_be_created, out); ++ ++ snprintf (abs_path, sizeof(abs_path), "%s%s", ++ var_run_dir, dir_to_be_created); + +- ret = stat (snap_mount_folder, &buf); ++ ret = stat (abs_path, &buf); + if ((ret != 0) && (ENOENT != errno)) { + gf_log (this->name, GF_LOG_ERROR, + "stat fails on %s, exiting. (errno = %d)", +- snap_mount_folder, errno); ++ abs_path, errno); + ret = -1; + goto out; + } +@@ -1161,19 +1180,19 @@ glusterd_init_snap_folder (xlator_t *this) + if ((!ret) && (!S_ISDIR(buf.st_mode))) { + gf_log (this->name, GF_LOG_CRITICAL, + "Provided snap path %s is not a directory," +- "exiting", snap_mount_folder); ++ "exiting", abs_path); + ret = -1; + goto out; + } + + if ((-1 == ret) && (ENOENT == errno)) { +- /* Create missing folders */ +- ret = mkdir_p (snap_mount_folder, 0777, _gf_true); ++ /* Create missing dirs */ ++ ret = mkdir_p (abs_path, 0777, _gf_true); + + if (-1 == ret) { + gf_log (this->name, GF_LOG_CRITICAL, + "Unable to create directory %s" +- " ,errno = %d", snap_mount_folder, errno); ++ " ,errno = %d", abs_path, errno); + goto out; + } + } +@@ -1250,21 +1269,22 @@ out: + int + init (xlator_t *this) + { +- int32_t ret = -1; +- rpcsvc_t *rpc = NULL; +- rpcsvc_t *uds_rpc = NULL; +- glusterd_conf_t *conf = NULL; +- data_t *dir_data = NULL; +- struct stat buf = {0,}; +- char storedir [PATH_MAX] = {0,}; +- char workdir [PATH_MAX] = {0,}; +- char cmd_log_filename [PATH_MAX] = {0,}; +- int first_time = 0; +- char *mountbroker_root = NULL; +- int i = 0; +- int total_transport = 0; +- char *valgrind_str = NULL; +- char *transport_type = NULL; ++ int32_t ret = -1; ++ rpcsvc_t *rpc = NULL; ++ rpcsvc_t *uds_rpc = NULL; ++ glusterd_conf_t *conf = NULL; ++ data_t *dir_data = NULL; ++ struct stat buf = {0,}; ++ char storedir[PATH_MAX] = {0,}; ++ char workdir[PATH_MAX] = {0,}; ++ char cmd_log_filename[PATH_MAX] = {0,}; ++ int first_time = 0; ++ char *mountbroker_root = NULL; ++ int i = 0; ++ int total_transport = 0; ++ char *valgrind_str = NULL; ++ char *transport_type = NULL; ++ char var_run_dir[PATH_MAX] = {0,}; + + #ifndef GF_DARWIN_HOST_OS + { +@@ -1326,14 +1346,35 @@ init (xlator_t *this) + gf_log (this->name, GF_LOG_INFO, "Using %s as working directory", + workdir); + +- ret = glusterd_init_snap_folder (this); ++ ret = glusterd_find_correct_var_run_dir (this, var_run_dir); ++ if (ret) { ++ gf_log (this->name, GF_LOG_CRITICAL, "Unable to find " ++ "the correct var run dir"); ++ exit (1); ++ } ++ ++ ret = glusterd_init_var_run_dirs (this, var_run_dir, ++ GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); ++ if (ret) { ++ gf_log (this->name, GF_LOG_CRITICAL, "Unable to create " ++ "snap backend dir"); ++ exit (1); ++ } + ++ snprintf (snap_mount_dir, sizeof(snap_mount_dir), "%s%s", ++ var_run_dir, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); ++ ++ ret = glusterd_init_var_run_dirs (this, var_run_dir, ++ GLUSTER_SHARED_STORAGE_BRICK_DIR); + if (ret) { + gf_log (this->name, GF_LOG_CRITICAL, "Unable to create " +- "snap backend folder"); ++ "shared storage brick"); + exit (1); + } + ++ snprintf (ss_brick_path, sizeof(ss_brick_path), "%s%s", ++ var_run_dir, GLUSTER_SHARED_STORAGE_BRICK_DIR); ++ + snprintf (cmd_log_filename, PATH_MAX, "%s/cmd_history.log", + DEFAULT_LOG_FILE_DIRECTORY); + ret = gf_cmd_log_init (cmd_log_filename); +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index ab62952..5b5edfd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -52,6 +52,8 @@ + #define GEO_CONF_MAX_OPT_VALS 6 + #define GLUSTERD_CREATE_HOOK_SCRIPT "/hooks/1/gsync-create/post/" \ + "S56glusterd-geo-rep-create-post.sh" ++#define GLUSTER_SHARED_STORAGE "gluster_shared_storage" ++#define GLUSTERD_SHARED_STORAGE_KEY "cluster.enable-shared-storage" + + #define GANESHA_HA_CONF CONFDIR "/ganesha-ha.conf" + #define GLUSTERD_SNAPS_MAX_HARD_LIMIT 256 +@@ -512,6 +514,7 @@ typedef enum { + #define GLUSTERD_VOL_SNAP_DIR_PREFIX "snaps" + + #define GLUSTERD_DEFAULT_SNAPS_BRICK_DIR "/gluster/snaps" ++#define GLUSTER_SHARED_STORAGE_BRICK_DIR "/gluster/ss_brick" + #define GLUSTERD_VAR_RUN_DIR "/var/run" + #define GLUSTERD_RUN_DIR "/run" + +-- +1.9.3 + diff --git a/SOURCES/0010-dht-rebalance-Fixed-rebalance-failure.patch b/SOURCES/0010-dht-rebalance-Fixed-rebalance-failure.patch new file mode 100644 index 0000000..51b1d19 --- /dev/null +++ b/SOURCES/0010-dht-rebalance-Fixed-rebalance-failure.patch @@ -0,0 +1,93 @@ +From 68d405c9cc702965217ad781ff33bbf4736ebbbb Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Fri, 5 Jun 2015 15:28:19 +0530 +Subject: [PATCH 10/18] dht/rebalance : Fixed rebalance failure + +The rebalance process determines the local subvols for the +node it is running on and only acts on files in those subvols. +If a dist-rep or dist-disperse volume is created on 2 nodes by +dividing the bricks equally across the nodes, one process might +determine it has no local_subvols. + +When trying to update the commit hash, the function attempts to +lock all local subvols. On the node with no local_subvols the dht +inode lock operation fails, in turn causing the rebalance to fail. + +In a dist-rep volume with 2 nodes, if brick 0 of each replica +set is on node1 and brick 1 is on node2, node2 will find that it has +no local subvols. + +Change-Id: I7d73b5b4bf1c822eae6df2e6f79bd6a1606f4d1c +BUG: 1227262 +Signed-off-by: Nithya Balachandran +Reviewed-on: http://review.gluster.org/10786 +Reviewed-by: Shyamsundar Ranganathan +Reviewed-by: Susant Palai +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/50105 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 5 +++-- + xlators/cluster/dht/src/dht-rebalance.c | 15 ++++++++++++++- + 2 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index ca68e60..e2749c9 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -3535,8 +3535,6 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, + + tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY); + if (tmp) { +- gf_log (this->name, GF_LOG_INFO, +- "fixing the layout of %s", loc->path); + + ret = dict_get_uint32(xattr, "new-commit-hash", &new_hash); + if (ret == 0) { +@@ -3554,6 +3552,9 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, + return ret; + } + ++ gf_log (this->name, GF_LOG_INFO, ++ "fixing the layout of %s", loc->path); ++ + ret = dht_fix_directory_layout (frame, dht_common_setxattr_cbk, + layout); + if (ret) { +diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c +index 6ba9dd1..3ab73d4 100644 +--- a/xlators/cluster/dht/src/dht-rebalance.c ++++ b/xlators/cluster/dht/src/dht-rebalance.c +@@ -2341,7 +2341,7 @@ gf_defrag_settle_hash (xlator_t *this, gf_defrag_info_t *defrag, + loc_t *loc, dict_t *fix_layout) + { + int ret; +- ++ dht_conf_t *conf = NULL; + /* + * Now we're ready to update the directory commit hash for the volume + * root, so that hash miscompares and broadcast lookups can stop. +@@ -2355,6 +2355,19 @@ gf_defrag_settle_hash (xlator_t *this, gf_defrag_info_t *defrag, + return 0; + } + ++ conf = this->private; ++ if (!conf) { ++ /*Uh oh ++ */ ++ return -1; ++ } ++ ++ if (conf->local_subvols_cnt == 0) { ++ /* Commit hash updates are only done on local subvolumes ++ */ ++ return 0; ++ } ++ + ret = dict_set_uint32 (fix_layout, "new-commit-hash", + defrag->new_commit_hash); + if (ret) { +-- +1.9.3 + diff --git a/SOURCES/0011-cluster-dht-Fix-dht_setxattr-to-follow-files-under-m.patch b/SOURCES/0011-cluster-dht-Fix-dht_setxattr-to-follow-files-under-m.patch new file mode 100644 index 0000000..870c1c2 --- /dev/null +++ b/SOURCES/0011-cluster-dht-Fix-dht_setxattr-to-follow-files-under-m.patch @@ -0,0 +1,929 @@ +From ae6d9662536d2c6fdb0a26491d1aca50dfd358ef Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Fri, 5 Jun 2015 14:39:29 +0530 +Subject: [PATCH 11/18] cluster/dht: Fix dht_setxattr to follow files under + migration + +If a file is under migration, any xattrs created on it +are lost post migration of the file. This is because +the xattrs are set only on the cached subvol of the source +and as the source is under migration, it becomes a linkto file +post migration. + +Change-Id: Ib8e233b519cf954e7723c6e26b38fa8f9b8c85c0 +BUG: 1047481 +Signed-off-by: Nithya Balachandran +Reviewed-on: http://review.gluster.org/10212 +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/50101 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glusterfs.h | 5 +- + tests/bugs/distribute/bug-1193636.c | 70 +++++++ + tests/bugs/distribute/bug-1193636.t | 72 +++++++ + xlators/cluster/dht/src/dht-common.c | 391 +++++++++++++++++++++++++++++++++-- + xlators/cluster/ec/src/ec-combine.c | 1 + + xlators/storage/posix/src/posix.c | 123 +++++++++-- + 6 files changed, 631 insertions(+), 31 deletions(-) + create mode 100644 tests/bugs/distribute/bug-1193636.c + create mode 100644 tests/bugs/distribute/bug-1193636.t + +diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h +index 9ed02e5..6f20185 100644 +--- a/libglusterfs/src/glusterfs.h ++++ b/libglusterfs/src/glusterfs.h +@@ -230,8 +230,9 @@ + #define DHT_LINKFILE_STR "linkto" + #define DHT_COMMITHASH_STR "commithash" + +-#define DHT_SKIP_NON_LINKTO_UNLINK "unlink-only-if-dht-linkto-file" +-#define DHT_SKIP_OPEN_FD_UNLINK "dont-unlink-for-open-fd" ++#define DHT_SKIP_NON_LINKTO_UNLINK "unlink-only-if-dht-linkto-file" ++#define DHT_SKIP_OPEN_FD_UNLINK "dont-unlink-for-open-fd" ++#define DHT_IATT_IN_XDATA_KEY "dht-get-iatt-in-xattr" + + /*CTR requires inode dentry link count from posix*/ + #define CTR_RESPONSE_LINK_COUNT_XDATA "ctr_response_link_count" +diff --git a/tests/bugs/distribute/bug-1193636.c b/tests/bugs/distribute/bug-1193636.c +new file mode 100644 +index 0000000..eae9078 +--- /dev/null ++++ b/tests/bugs/distribute/bug-1193636.c +@@ -0,0 +1,70 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++ ++#define MY_XATTR_NAME "user.ftest" ++#define MY_XATTR_VAL "ftestval" ++ ++ ++void usage (void) ++{ ++ printf ("Usage : bug-1193636 \n"); ++ printf (" op : 0 - set, 1 - remove\n"); ++} ++ ++ ++int main (int argc, char **argv) ++{ ++ int fd; ++ int err = 0; ++ char *xattr_name = NULL; ++ int op = 0; ++ ++ if (argc != 4) { ++ usage (); ++ exit (1); ++ } ++ ++ op = atoi (argv[3]); ++ ++ if ((op != 0) && (op != 1)) { ++ printf ("Invalid operation specified.\n"); ++ usage (); ++ exit (1); ++ } ++ ++ xattr_name = argv[2]; ++ ++ fd = open(argv[1], O_RDWR); ++ if (fd == -1) { ++ printf ("Failed to open file %s\n", argv[1]); ++ exit (1); ++ } ++ ++ if (!op) { ++ err = fsetxattr (fd, xattr_name, MY_XATTR_VAL, ++ strlen (MY_XATTR_VAL) + 1, XATTR_CREATE); ++ ++ if (err) { ++ printf ("Failed to set xattr %s: %m\n", xattr_name); ++ exit (1); ++ } ++ ++ } else { ++ err = fremovexattr (fd, xattr_name); ++ ++ if (err) { ++ printf ("Failed to remove xattr %s: %m\n", xattr_name); ++ exit (1); ++ } ++ } ++ ++ close (fd); ++ ++ return 0; ++} ++ +diff --git a/tests/bugs/distribute/bug-1193636.t b/tests/bugs/distribute/bug-1193636.t +new file mode 100644 +index 0000000..ccde02e +--- /dev/null ++++ b/tests/bugs/distribute/bug-1193636.t +@@ -0,0 +1,72 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++ ++checksticky () { ++ i=0; ++ while [ ! -k $1 ]; do ++ sleep 1 ++ i=$((i+1)); ++ if [[ $i == 10 ]]; then ++ return $i ++ fi ++ echo "Waiting... $i" ++ done ++ echo "done ...got out @ $i" ++ return 0 ++} ++ ++cleanup; ++ ++#Basic checks ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume info ++ ++#Create a distributed volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; ++TEST $CLI volume start $V0 ++ ++# Mount FUSE ++TEST glusterfs -s $H0 --volfile-id $V0 $M0 ++ ++TEST mkdir $M0/dir1 ++ ++# Create a large file (1GB), so that rebalance takes time ++dd if=/dev/zero of=$M0/dir1/FILE2 bs=64k count=10240 ++ ++# Rename the file to create a linkto, for rebalance to ++# act on the file ++TEST mv $M0/dir1/FILE2 $M0/dir1/FILE1 ++ ++build_tester $(dirname $0)/bug-1193636.c ++ ++TEST $CLI volume rebalance $V0 start force ++ ++TEST checksticky $B0/${V0}3/dir1/FILE1 ++ ++TEST setfattr -n "user.test1" -v "test1" $M0/dir1/FILE1 ++TEST setfattr -n "user.test2" -v "test1" $M0/dir1/FILE1 ++TEST setfattr -n "user.test3" -v "test1" $M0/dir1/FILE1 ++ ++TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fsetx 0 ++TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 0 ++ ++TEST getfattr -n "user.fremx" $M0/dir1/FILE1 ++TEST setfattr -x "user.test2" $M0/dir1/FILE1 ++ ++ ++TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 1 ++ ++EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 ++ ++TEST getfattr -n "user.fsetx" $M0/dir1/FILE1 ++TEST getfattr -n "user.test1" $M0/dir1/FILE1 ++TEST ! getfattr -n "user.test2" $M0/dir1/FILE1 ++TEST ! getfattr -n "user.fremx" $M0/dir1/FILE1 ++TEST getfattr -n "user.test3" $M0/dir1/FILE1 ++ ++ ++cleanup; +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index e2749c9..8e78746 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -32,6 +32,13 @@ + int dht_link2 (xlator_t *this, call_frame_t *frame, int op_ret); + + int ++dht_removexattr2 (xlator_t *this, call_frame_t *frame, int op_ret); ++ ++int ++dht_setxattr2 (xlator_t *this, call_frame_t *frame, int op_ret); ++ ++ ++int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) + { + int ret = -1; +@@ -96,6 +103,8 @@ out: + return ret; + } + ++ ++ + int + dht_aggregate (dict_t *this, char *key, data_t *value, void *data) + { +@@ -3265,6 +3274,78 @@ err: + } + + int ++dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int op_ret, int op_errno, dict_t *xdata) ++{ ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; ++ xlator_t *subvol = NULL; ++ ++ ++ local = frame->local; ++ prev = cookie; ++ ++ local->op_errno = op_errno; ++ ++ if ((op_ret == -1) && !dht_inode_missing (op_errno)) { ++ gf_msg_debug (this->name, op_errno, ++ "subvolume %s returned -1.", ++ prev->this->name); ++ goto out; ++ } ++ ++ if (local->call_cnt != 1) ++ goto out; ++ ++ ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **) &stbuf); ++ ++ if ((!op_ret) && !stbuf) { ++ goto out; ++ } ++ ++ local->op_ret = 0; ++ ++ local->rebalance.target_op_fn = dht_setxattr2; ++ ++ /* Phase 2 of migration */ ++ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) { ++ ret = dht_rebalance_complete_check (this, frame); ++ if (!ret) ++ return 0; ++ } ++ ++ /* Phase 1 of migration */ ++ if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { ++ inode = (local->fd) ? local->fd->inode : local->loc.inode; ++ dht_inode_ctx_get1 (this, inode, &subvol); ++ if (subvol) { ++ dht_setxattr2 (this, frame, 0); ++ return 0; ++ } ++ ret = dht_rebalance_in_progress_check (this, frame); ++ if (!ret) ++ return 0; ++ } ++ ++out: ++ if (local->rebalance.xdata) ++ dict_unref (local->rebalance.xdata); ++ ++ if (local->fop == GF_FOP_SETXATTR) { ++ DHT_STACK_UNWIND (setxattr, frame, op_ret, op_errno, NULL); ++ } else { ++ DHT_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, NULL); ++ } ++ ++ return 0; ++} ++ ++ ++ ++int + dht_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *xattr, int flags, dict_t *xdata) + { +@@ -3272,6 +3353,10 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this, + dht_local_t *local = NULL; + int op_errno = EINVAL; + dht_conf_t *conf = NULL; ++ dht_layout_t *layout = NULL; ++ int ret = -1; ++ int call_cnt = 0; ++ int i = 0; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); +@@ -3299,11 +3384,47 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this, + goto err; + } + +- local->call_cnt = 1; ++ layout = local->layout; ++ if (!layout) { ++ gf_msg_debug (this->name, 0, ++ "no layout for fd=%p", fd); ++ op_errno = EINVAL; ++ goto err; ++ } ++ ++ local->call_cnt = call_cnt = layout->cnt; ++ ++ if (IA_ISDIR (fd->inode->ia_type)) { ++ for (i = 0; i < call_cnt; i++) { ++ STACK_WIND (frame, dht_err_cbk, ++ layout->list[i].xlator, ++ layout->list[i].xlator->fops->fsetxattr, ++ fd, xattr, flags, NULL); ++ } ++ ++ } else { ++ ++ local->call_cnt = 1; ++ local->rebalance.xdata = dict_ref (xattr); ++ local->rebalance.flags = flags; ++ ++ xdata = xdata ? dict_ref (xdata) : dict_new (); ++ if (xdata) ++ ret = dict_set_dynstr_with_alloc (xdata, ++ 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); ++ } + +- STACK_WIND (frame, dht_err_cbk, subvol, subvol->fops->fsetxattr, +- fd, xattr, flags, NULL); ++ STACK_WIND (frame, dht_file_setxattr_cbk, subvol, ++ subvol->fops->fsetxattr, fd, xattr, flags, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); + ++ } + return 0; + + err: +@@ -3324,6 +3445,7 @@ dht_common_setxattr_cbk (call_frame_t *frame, void *cookie, + return 0; + } + ++ + int + dht_checking_pathinfo_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xattr, +@@ -3365,6 +3487,55 @@ out: + + } + ++ ++int ++dht_setxattr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++{ ++ dht_local_t *local = NULL; ++ xlator_t *subvol = NULL; ++ int op_errno = EINVAL; ++ inode_t *inode = NULL; ++ ++ local = frame->local; ++ ++ inode = (local->fd) ? local->fd->inode : local->loc.inode; ++ ++ dht_inode_ctx_get1 (this, inode, &subvol); ++ ++ /* In phase2, dht_migration_complete_check_task will ++ * reset inode_ctx_reset1 and update local->cached_subvol ++ * with the dst subvol. ++ */ ++ if (!subvol) ++ subvol = local->cached_subvol; ++ ++ if (!subvol) { ++ op_errno = EINVAL; ++ goto err; ++ } ++ ++ local->call_cnt = 2; /* This is the second attempt */ ++ ++ if (local->fop == GF_FOP_SETXATTR) { ++ STACK_WIND (frame, dht_file_setxattr_cbk, subvol, ++ subvol->fops->setxattr, &local->loc, ++ local->rebalance.xdata, local->rebalance.flags, ++ NULL); ++ } else { ++ STACK_WIND (frame, dht_file_setxattr_cbk, subvol, ++ subvol->fops->fsetxattr, local->fd, ++ local->rebalance.xdata, local->rebalance.flags, ++ NULL); ++ } ++ ++ return 0; ++ ++err: ++ DHT_STACK_UNWIND (setxattr, frame, local->op_ret, op_errno, NULL); ++ return 0; ++} ++ ++ + int + dht_setxattr (call_frame_t *frame, xlator_t *this, + loc_t *loc, dict_t *xattr, int flags, dict_t *xdata) +@@ -3588,11 +3759,32 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, + goto err; + } + +- for (i = 0; i < call_cnt; i++) { +- STACK_WIND (frame, dht_err_cbk, +- layout->list[i].xlator, +- layout->list[i].xlator->fops->setxattr, ++ if (IA_ISDIR (loc->inode->ia_type)) { ++ ++ for (i = 0; i < call_cnt; i++) { ++ STACK_WIND (frame, dht_err_cbk, ++ layout->list[i].xlator, ++ layout->list[i].xlator->fops->setxattr, ++ loc, xattr, flags, xdata); ++ } ++ ++ } else { ++ ++ local->rebalance.xdata = dict_ref (xattr); ++ local->rebalance.flags = flags; ++ local->call_cnt = 1; ++ ++ xdata = xdata ? dict_ref (xdata) : dict_new (); ++ if (xdata) ++ ret = dict_set_dynstr_with_alloc (xdata, ++ DHT_IATT_IN_XDATA_KEY, "yes"); ++ ++ STACK_WIND (frame, dht_file_setxattr_cbk, ++ subvol, subvol->fops->setxattr, + loc, xattr, flags, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); + } + + return 0; +@@ -3605,6 +3797,123 @@ err: + } + + ++ ++ ++int ++dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int op_ret, int op_errno, dict_t *xdata) ++{ ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; ++ xlator_t *subvol = NULL; ++ ++ ++ local = frame->local; ++ prev = cookie; ++ ++ local->op_errno = op_errno; ++ ++ if ((op_ret == -1) && !dht_inode_missing (op_errno)) { ++ gf_msg_debug (this->name, op_errno, ++ "subvolume %s returned -1", ++ prev->this->name); ++ goto out; ++ } ++ ++ if (local->call_cnt != 1) ++ goto out; ++ ++ ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **) &stbuf); ++ ++ if ((!op_ret) && !stbuf) { ++ goto out; ++ } ++ ++ local->op_ret = 0; ++ ++ local->rebalance.target_op_fn = dht_removexattr2; ++ ++ /* Phase 2 of migration */ ++ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) { ++ ret = dht_rebalance_complete_check (this, frame); ++ if (!ret) ++ return 0; ++ } ++ ++ /* Phase 1 of migration */ ++ if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { ++ inode = (local->fd) ? local->fd->inode : local->loc.inode; ++ dht_inode_ctx_get1 (this, inode, &subvol); ++ if (subvol) { ++ dht_removexattr2 (this, frame, 0); ++ return 0; ++ } ++ ret = dht_rebalance_in_progress_check (this, frame); ++ if (!ret) ++ return 0; ++ } ++ ++out: ++ if (local->fop == GF_FOP_REMOVEXATTR) { ++ DHT_STACK_UNWIND (removexattr, frame, op_ret, op_errno, NULL); ++ } else { ++ DHT_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, NULL); ++ } ++ return 0; ++ ++} ++ ++int ++dht_removexattr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++{ ++ dht_local_t *local = NULL; ++ xlator_t *subvol = NULL; ++ int op_errno = EINVAL; ++ inode_t *inode = NULL; ++ ++ local = frame->local; ++ ++ inode = (local->fd) ? local->fd->inode : local->loc.inode; ++ ++ dht_inode_ctx_get1 (this, inode, &subvol); ++ ++ /* In phase2, dht_migration_complete_check_task will ++ * reset inode_ctx_reset1 and update local->cached_subvol ++ * with the dst subvol. ++ */ ++ if (!subvol) ++ subvol = local->cached_subvol; ++ ++ if (!subvol) { ++ op_errno = EINVAL; ++ goto err; ++ ++ } ++ ++ ++ local->call_cnt = 2; /* This is the second attempt */ ++ ++ if (local->fop == GF_FOP_REMOVEXATTR) { ++ STACK_WIND (frame, dht_file_removexattr_cbk, subvol, ++ subvol->fops->removexattr, &local->loc, ++ local->key, NULL); ++ } else { ++ STACK_WIND (frame, dht_file_removexattr_cbk, subvol, ++ subvol->fops->fremovexattr, local->fd, ++ local->key, NULL); ++ } ++ ++ return 0; ++ ++err: ++ DHT_STACK_UNWIND (removexattr, frame, local->op_ret, op_errno, NULL); ++ return 0; ++} ++ ++ + int + dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) +@@ -3631,6 +3940,8 @@ dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + unlock: + UNLOCK (&frame->lock); + ++ ++ + this_call_cnt = dht_frame_return (frame); + if (is_last_call (this_call_cnt)) { + DHT_STACK_UNWIND (removexattr, frame, local->op_ret, +@@ -3652,6 +3963,7 @@ dht_removexattr (call_frame_t *frame, xlator_t *this, + int call_cnt = 0; + dht_conf_t *conf = NULL; + int i; ++ int ret = 0; + + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (this->private, err); +@@ -3689,11 +4001,33 @@ dht_removexattr (call_frame_t *frame, xlator_t *this, + local->call_cnt = call_cnt = layout->cnt; + local->key = gf_strdup (key); + +- for (i = 0; i < call_cnt; i++) { +- STACK_WIND (frame, dht_removexattr_cbk, +- layout->list[i].xlator, +- layout->list[i].xlator->fops->removexattr, +- loc, key, NULL); ++ if (IA_ISDIR (loc->inode->ia_type)) { ++ for (i = 0; i < call_cnt; i++) { ++ STACK_WIND (frame, dht_removexattr_cbk, ++ layout->list[i].xlator, ++ layout->list[i].xlator->fops->removexattr, ++ loc, key, NULL); ++ } ++ ++ } else { ++ ++ local->call_cnt = 1; ++ xdata = xdata ? dict_ref (xdata) : dict_new (); ++ if (xdata) ++ ret = dict_set_dynstr_with_alloc (xdata, ++ DHT_IATT_IN_XDATA_KEY, "yes"); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ "set dictionary key %s for %s", ++ DHT_IATT_IN_XDATA_KEY, loc->path); ++ } ++ ++ STACK_WIND (frame, dht_file_removexattr_cbk, ++ subvol, subvol->fops->removexattr, ++ loc, key, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); + } + + return 0; +@@ -3715,6 +4049,7 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this, + dht_layout_t *layout = NULL; + int call_cnt = 0; + dht_conf_t *conf = 0; ++ int ret = 0; + + int i; + +@@ -3754,11 +4089,33 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this, + local->call_cnt = call_cnt = layout->cnt; + local->key = gf_strdup (key); + +- for (i = 0; i < call_cnt; i++) { +- STACK_WIND (frame, dht_removexattr_cbk, +- layout->list[i].xlator, +- layout->list[i].xlator->fops->fremovexattr, +- fd, key, NULL); ++ if (IA_ISDIR (fd->inode->ia_type)) { ++ for (i = 0; i < call_cnt; i++) { ++ STACK_WIND (frame, dht_removexattr_cbk, ++ layout->list[i].xlator, ++ layout->list[i].xlator->fops->fremovexattr, ++ fd, key, NULL); ++ } ++ ++ } else { ++ ++ local->call_cnt = 1; ++ xdata = xdata ? dict_ref (xdata) : dict_new (); ++ if (xdata) ++ ret = dict_set_dynstr_with_alloc (xdata, ++ DHT_IATT_IN_XDATA_KEY, "yes"); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ "set dictionary key %s for fd=%p", ++ DHT_IATT_IN_XDATA_KEY, fd); ++ } ++ ++ STACK_WIND (frame, dht_file_removexattr_cbk, ++ subvol, subvol->fops->fremovexattr, ++ fd, key, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); + } + + return 0; +diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c +index 6395b22..a8cfabc 100644 +--- a/xlators/cluster/ec/src/ec-combine.c ++++ b/xlators/cluster/ec/src/ec-combine.c +@@ -246,6 +246,7 @@ ec_value_ignore (char *key) + (strcmp(key, GLUSTERFS_ENTRYLK_COUNT) == 0) || + (strncmp(key, GF_XATTR_CLRLK_CMD, + strlen (GF_XATTR_CLRLK_CMD)) == 0) || ++ (strcmp(key, DHT_IATT_IN_XDATA_KEY) == 0) || + (strncmp(key, EC_QUOTA_PREFIX, strlen(EC_QUOTA_PREFIX)) == 0) || + (fnmatch(MARKER_XATTR_PREFIX ".*." XTIME, key, 0) == 0) || + (fnmatch(GF_XATTR_MARKER_KEY ".*", key, 0) == 0) || +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index fbbeacd..71b83c2 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3239,6 +3239,31 @@ map_xattr_flags(int flags) + } + #endif + ++static ++int32_t posix_set_iatt_in_dict (dict_t *dict, struct iatt *in_stbuf) ++{ ++ int ret = -1; ++ struct iatt *stbuf = NULL; ++ int32_t len = sizeof(struct iatt); ++ ++ if (!dict || !in_stbuf) ++ return ret; ++ ++ stbuf = GF_CALLOC (1, len, gf_common_mt_char); ++ if (!stbuf) ++ return ret; ++ ++ memcpy (stbuf, in_stbuf, len); ++ ++ ret = dict_set_bin (dict, DHT_IATT_IN_XDATA_KEY, stbuf, len); ++ if (ret) ++ GF_FREE (stbuf); ++ ++ return ret; ++} ++ ++ ++ + int32_t + posix_setxattr (call_frame_t *frame, xlator_t *this, + loc_t *loc, dict_t *dict, int flags, dict_t *xdata) +@@ -3246,7 +3271,9 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + int32_t op_ret = -1; + int32_t op_errno = 0; + char * real_path = NULL; +- ++ struct iatt stbuf = {0}; ++ int32_t ret = 0; ++ dict_t *xattr = NULL; + posix_xattr_filler_t filler = {0,}; + + DECLARE_OLD_FS_ID_VAR; +@@ -3265,6 +3292,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + } + + op_ret = -1; ++ + dict_del (dict, GFID_XATTR_KEY); + dict_del (dict, GF_XATTR_VOL_ID_KEY); + +@@ -3280,12 +3308,31 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + if (op_ret < 0) { + op_errno = -op_ret; + op_ret = -1; ++ goto out; + } + ++/* ++ * FIXFIX: Send the stbuf info in the xdata for now ++ * This is used by DHT to redirect FOPs if the file is being migrated ++ * Ignore errors for now ++ */ ++ if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ ret = posix_pstat(this, loc->gfid, real_path, &stbuf); ++ if (ret) ++ goto out; ++ ++ xattr = dict_new(); ++ if (!xattr) ++ goto out; ++ ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } + out: + SET_TO_OLD_FS_ID (); + +- STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL); ++ STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xattr); ++ ++ if (xattr) ++ dict_unref(xattr); + + return 0; + } +@@ -4313,13 +4360,14 @@ int32_t + posix_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, int flags, dict_t *xdata) + { +- int32_t op_ret = -1; +- int32_t op_errno = 0; +- struct posix_fd * pfd = NULL; +- int _fd = -1; +- int ret = -1; +- +- posix_xattr_filler_t filler = {0,}; ++ int32_t op_ret = -1; ++ int32_t op_errno = 0; ++ struct posix_fd *pfd = NULL; ++ int _fd = -1; ++ int ret = -1; ++ struct iatt stbuf = {0,}; ++ dict_t *xattr = NULL; ++ posix_xattr_filler_t filler = {0,}; + + DECLARE_OLD_FS_ID_VAR; + SET_FS_ID (frame->root->uid, frame->root->gid); +@@ -4366,10 +4414,28 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, + } + } + ++ if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ ret = posix_fdstat (this, pfd->fd, &stbuf); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "fsetxattr (fstat) failed on fd=%p: %s", ++ fd, strerror (op_errno)); ++ goto out; ++ } ++ ++ xattr = dict_new (); ++ if (!xattr) ++ goto out; ++ ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } ++ + out: + SET_TO_OLD_FS_ID (); + +- STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL); ++ STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, xattr); ++ ++ if (xattr) ++ dict_unref (xattr); + + return 0; + } +@@ -4429,7 +4495,10 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, + { + int32_t op_ret = -1; + int32_t op_errno = 0; ++ int32_t ret = -1; + char * real_path = NULL; ++ struct iatt stbuf = {0}; ++ dict_t *xattr = NULL; + posix_xattr_filler_t filler = {0,}; + + DECLARE_OLD_FS_ID_VAR; +@@ -4485,12 +4554,26 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, + goto out; + } + ++ if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ ret = posix_pstat(this, loc->gfid, real_path, &stbuf); ++ if (ret) ++ goto out; ++ xattr = dict_new(); ++ if (!xattr) ++ goto out; ++ ++ ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } + op_ret = 0; + + out: + SET_TO_OLD_FS_ID (); + +- STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, NULL); ++ STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, xattr); ++ ++ if (xattr) ++ dict_unref (xattr); ++ + return 0; + } + +@@ -4501,6 +4584,8 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, + int32_t op_ret = -1; + int32_t op_errno = 0; + struct posix_fd * pfd = NULL; ++ struct iatt stbuf = {0,}; ++ dict_t *xattr = NULL; + int _fd = -1; + int ret = -1; + +@@ -4541,12 +4626,26 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, + goto out; + } + ++ if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ ret = posix_fdstat (this, pfd->fd, &stbuf); ++ if (ret) ++ goto out; ++ xattr = dict_new(); ++ if (!xattr) ++ goto out; ++ ++ ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } + op_ret = 0; + + out: + SET_TO_OLD_FS_ID (); + +- STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, NULL); ++ STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, xattr); ++ ++ if (xattr) ++ dict_unref (xattr); ++ + return 0; + } + +-- +1.9.3 + diff --git a/SOURCES/0012-cluster-dht-Don-t-rely-on-linkto-xattr-to-find-desti.patch b/SOURCES/0012-cluster-dht-Don-t-rely-on-linkto-xattr-to-find-desti.patch new file mode 100644 index 0000000..83c24df --- /dev/null +++ b/SOURCES/0012-cluster-dht-Don-t-rely-on-linkto-xattr-to-find-desti.patch @@ -0,0 +1,223 @@ +From 52341e3c2b836e5b9815a546fa5364ab8c091364 Mon Sep 17 00:00:00 2001 +From: Raghavendra G +Date: Wed, 13 May 2015 19:56:47 +0530 +Subject: [PATCH 12/18] cluster/dht: Don't rely on linkto xattr to find + destination subvol during phase 2 of migration. + +linkto xattr on source file cannot be relied to find where the data +file currently resides. This can happen if there are multiple +migrations before phase 2 detection by a client. For eg., + +* migration (M1, node1, node2) starts. +* application writes some data. DHT correctly stores the state in + inode context that phase-1 of migration is in progress +* migration M1 completes +* migration (M2, node2, node3) is triggered and completed +* application resumes writes to the file. DHT identifies it as phase-2 + of migration. However, linkto xattr on node1 points to node2, but + the file is on node3. A lookup correctly identifies node3 as cached + subvol + +TBD: + When we identify phase-2 of a previous migration (say M1), there + might be a migration in progress - say (M3, node3, node4). In this + case we need to send writes to both (node3, node4) not just + node3. Also, the inode state needs to correctly indicate that its in + phase-1 of migration. I'll send this as a different patch. + +Change-Id: I1a861f766258170af2f6c0935468edb6be687b95 +BUG: 1140506 +Signed-off-by: Raghavendra G +Reviewed-on: http://review.gluster.org/10805 +Reviewed-on: http://review.gluster.org/10965 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50188 +Reviewed-by: Nithya Balachandran +--- + xlators/cluster/dht/src/dht-helper.c | 132 ++++++++--------------------------- + 1 file changed, 31 insertions(+), 101 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index 3127171..1b5ad41 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -835,10 +835,9 @@ dht_migration_complete_check_task (void *data) + { + int ret = -1; + xlator_t *src_node = NULL; +- xlator_t *dst_node = NULL; ++ xlator_t *dst_node = NULL, *linkto_target = NULL; + dht_local_t *local = NULL; + dict_t *dict = NULL; +- dht_layout_t *layout = NULL; + struct iatt stbuf = {0,}; + xlator_t *this = NULL; + call_frame_t *frame = NULL; +@@ -890,120 +889,50 @@ dht_migration_complete_check_task (void *data) + } + + if (!ret) +- dst_node = dht_linkfile_subvol (this, NULL, NULL, dict); +- +- if (ret) { +- if (!dht_inode_missing(-ret) || (!local->loc.inode)) { +- local->op_errno = -ret; +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to get the 'linkto' xattr %s", +- local->loc.path, strerror (-ret)); +- ret = -1; +- goto out; +- } +- +- /* Need to do lookup on hashed subvol, then get the file */ +- ret = syncop_lookup (this, &local->loc, &stbuf, NULL, +- NULL, NULL); +- if (ret) { +- local->op_errno = -ret; +- ret = -1; +- goto out; +- } +- +- dst_node = dht_subvol_get_cached (this, local->loc.inode); +- } +- +- if (!dst_node) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to get the destination node", +- local->loc.path); +- ret = -1; +- local->op_errno = EINVAL; +- goto out; +- } ++ linkto_target = dht_linkfile_subvol (this, NULL, NULL, dict); + +- /* lookup on dst */ + if (local->loc.inode) { +- ret = syncop_lookup (dst_node, &local->loc, &stbuf, NULL, +- NULL, NULL); +- +- if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to lookup the file on %s", +- local->loc.path, dst_node->name); +- local->op_errno = -ret; +- ret = -1; +- goto out; +- } +- +- if (gf_uuid_compare (stbuf.ia_gfid, local->loc.inode->gfid)) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- DHT_MSG_GFID_MISMATCH, +- "%s: gfid different on the target file on %s", +- local->loc.path, dst_node->name); +- ret = -1; +- local->op_errno = EIO; +- goto out; +- } ++ loc_copy (&tmp_loc, &local->loc); + } else { +- tmp_loc.inode = inode; ++ tmp_loc.inode = inode_ref (inode); + gf_uuid_copy (tmp_loc.gfid, inode->gfid); +- ret = syncop_lookup (dst_node, &tmp_loc, &stbuf, 0, 0, 0); +- if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to lookup the file on %s", +- tmp_loc.path, dst_node->name); +- local->op_errno = -ret; +- ret = -1; +- goto out; +- } +- +- if (gf_uuid_compare (stbuf.ia_gfid, tmp_loc.inode->gfid)) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- DHT_MSG_GFID_MISMATCH, +- "%s: gfid different on the target file on %s", +- tmp_loc.path, dst_node->name); +- ret = -1; +- local->op_errno = EIO; +- goto out; +- } + } + +- /* update inode ctx (the layout) */ +- dht_layout_unref (this, local->layout); +- +- ret = dht_layout_preset (this, dst_node, inode); +- if (ret != 0) { +- gf_msg_debug (this->name, 0, +- "%s: could not set preset layout " +- "for subvol %s", local->loc.path, +- dst_node->name); +- ret = -1; +- local->op_errno = EINVAL; ++ ret = syncop_lookup (this, &tmp_loc, &stbuf, 0, 0, 0); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "%s: failed to lookup the file on %s (%s)", ++ tmp_loc.path, this->name, strerror (-ret)); ++ local->op_errno = -ret; ++ ret = -1; + goto out; + } + +- layout = dht_layout_for_subvol (this, dst_node); +- if (!layout) { +- gf_log (this->name, GF_LOG_INFO, +- "%s: no pre-set layout for subvolume %s", +- local->loc.path, dst_node ? dst_node->name : ""); ++ if (gf_uuid_compare (stbuf.ia_gfid, tmp_loc.inode->gfid)) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_GFID_MISMATCH, ++ "%s: gfid different on the target file on %s", ++ tmp_loc.path, dst_node->name); + ret = -1; +- local->op_errno = EINVAL; ++ local->op_errno = EIO; + goto out; + } + +- ret = dht_layout_set (this, inode, layout); +- if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to set the new layout", +- local->loc.path); +- local->op_errno = EINVAL; +- goto out; ++ dst_node = dht_subvol_get_cached (this, tmp_loc.inode); ++ if (linkto_target && dst_node != linkto_target) { ++ gf_log (this->name, GF_LOG_WARNING, "linkto target (%s) is " ++ "different from cached-subvol (%s). Treating %s as " ++ "destination subvol", linkto_target->name, ++ dst_node->name, dst_node->name); + } + ++ /* update local. A layout is set in inode-ctx in lookup already */ ++ ++ dht_layout_unref (this, local->layout); ++ ++ local->layout = dht_layout_get (frame->this, inode); + local->cached_subvol = dst_node; ++ + ret = 0; + + /* once we detect the migration complete, the inode-ctx2 is no more +@@ -1046,7 +975,6 @@ dht_migration_complete_check_task (void *data) + ret = -1; + } + } +- GF_FREE (path); + + SYNCTASK_SETID (frame->root->uid, frame->root->gid); + +@@ -1057,6 +985,8 @@ dht_migration_complete_check_task (void *data) + ret = 0; + out: + ++ loc_wipe (&tmp_loc); ++ + return ret; + } + +-- +1.9.3 + diff --git a/SOURCES/0013-afr-honour-selfheal-enable-disable-volume-set-option.patch b/SOURCES/0013-afr-honour-selfheal-enable-disable-volume-set-option.patch new file mode 100644 index 0000000..3bce88e --- /dev/null +++ b/SOURCES/0013-afr-honour-selfheal-enable-disable-volume-set-option.patch @@ -0,0 +1,173 @@ +From 56077a61e19d01452f95aaa8406cf24faa55d044 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Fri, 5 Jun 2015 12:20:04 +0530 +Subject: [PATCH 13/18] afr: honour selfheal enable/disable volume set options + +Patch URL in upstream master branch :http://review.gluster.org/#/c/11012/ +Patch URL in upstream 3.7 branch : http://review.gluster.org/#/c/11062/ + +afr-v1 had the following volume set options that are used to enable/ disable +self-heals from happening in AFR xlator when loaded in the client graph: +cluster.metadata-self-heal +cluster.data-self-heal +cluster.entry-self-heal + +In afr-v2, these 3 heals can happen from the client if there is an inode +refresh. This patch allows such heals to proceed only if the corresponding +volume set options are set to true. + +Change-Id: Iba83102fe5cea109bc4fc8c3b711a711929313f8 +BUG: 1228518 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/50094 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/basic/afr/client-side-heal.t | 86 ++++++++++++++++++++++++++ + xlators/cluster/afr/src/afr-common.c | 3 + + xlators/cluster/afr/src/afr-self-heal-common.c | 11 +++- + 3 files changed, 97 insertions(+), 3 deletions(-) + create mode 100644 tests/basic/afr/client-side-heal.t + +diff --git a/tests/basic/afr/client-side-heal.t b/tests/basic/afr/client-side-heal.t +new file mode 100644 +index 0000000..c9b3e35 +--- /dev/null ++++ b/tests/basic/afr/client-side-heal.t +@@ -0,0 +1,86 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume set $V0 cluster.self-heal-daemon off ++TEST $CLI volume set $V0 cluster.entry-self-heal off ++TEST $CLI volume set $V0 cluster.data-self-heal off ++TEST $CLI volume set $V0 cluster.metadata-self-heal off ++ ++TEST $CLI volume start $V0 ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++echo "some data" > $M0/datafile ++EXPECT 0 echo $? ++TEST touch $M0/mdatafile ++TEST mkdir $M0/dir ++ ++#Kill a brick and perform I/O to have pending heals. ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" afr_child_up_status $V0 0 ++ ++#pending data heal ++echo "some more data" >> $M0/datafile ++EXPECT 0 echo $? ++ ++#pending metadata heal ++TEST chmod +x $M0/mdatafile ++ ++#pending entry heal. Also causes pending metadata/data heals on file{1..5} ++TEST touch $M0/dir/file{1..5} ++ ++EXPECT 8 afr_get_pending_heal_count $V0 ++ ++#After brick comes back up, access from client should not trigger heals ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++ ++#Medatada heal via explicit lookup must not happen ++TEST ls $M0/mdatafile ++ ++#Inode refresh must not trigger data and entry heals. ++#To trigger inode refresh for sure, the volume is unmounted and mounted each time. ++#Check that data heal does not happen. ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++TEST cat $M0/datafile ++#Check that entry heal does not happen. ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++TEST ls $M0/dir ++ ++#No heal must have happened ++EXPECT 8 afr_get_pending_heal_count $V0 ++ ++#Enable heal client side heal options and trigger heals ++TEST $CLI volume set $V0 cluster.data-self-heal on ++TEST $CLI volume set $V0 cluster.metadata-self-heal on ++TEST $CLI volume set $V0 cluster.entry-self-heal on ++ ++#Metadata heal is triggered by lookup without need for inode refresh. ++TEST ls $M0/mdatafile ++EXPECT 7 afr_get_pending_heal_count $V0 ++ ++#Inode refresh must trigger data and entry heals. ++#To trigger inode refresh for sure, the volume is unmounted and mounted each time. ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++TEST cat $M0/datafile ++ ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++TEST ls $M0/dir ++EXPECT 5 afr_get_pending_heal_count $V0 ++ ++TEST cat $M0/dir/file1 ++TEST cat $M0/dir/file2 ++TEST cat $M0/dir/file3 ++TEST cat $M0/dir/file4 ++TEST cat $M0/dir/file5 ++ ++EXPECT 0 afr_get_pending_heal_count $V0 ++cleanup; +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index f478fea..410d31d 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -1757,6 +1757,9 @@ afr_can_start_metadata_self_heal(call_frame_t *frame, xlator_t *this) + replies = local->replies; + priv = this->private; + ++ if (!priv->metadata_self_heal) ++ return _gf_false; ++ + for (i = 0; i < priv->child_count; i++) { + if(!replies[i].valid || replies[i].op_ret == -1) + continue; +diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c +index f3d1f8b..207e9b9 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-common.c ++++ b/xlators/cluster/afr/src/afr-self-heal-common.c +@@ -1308,6 +1308,11 @@ afr_selfheal_do (call_frame_t *frame, xlator_t *this, uuid_t gfid) + gf_boolean_t data_selfheal = _gf_false; + gf_boolean_t metadata_selfheal = _gf_false; + gf_boolean_t entry_selfheal = _gf_false; ++ afr_private_t *priv = NULL; ++ gf_boolean_t dataheal_enabled = _gf_false; ++ ++ priv = this->private; ++ gf_string2boolean (priv->data_self_heal, &dataheal_enabled); + + ret = afr_selfheal_unlocked_inspect (frame, this, gfid, &inode, + &data_selfheal, +@@ -1321,13 +1326,13 @@ afr_selfheal_do (call_frame_t *frame, xlator_t *this, uuid_t gfid) + goto out; + } + +- if (data_selfheal) ++ if (data_selfheal && dataheal_enabled) + data_ret = afr_selfheal_data (frame, this, inode); + +- if (metadata_selfheal) ++ if (metadata_selfheal && priv->metadata_self_heal) + metadata_ret = afr_selfheal_metadata (frame, this, inode); + +- if (entry_selfheal) ++ if (entry_selfheal && priv->entry_self_heal) + entry_ret = afr_selfheal_entry (frame, this, inode); + + or_ret = (data_ret | metadata_ret | entry_ret); +-- +1.9.3 + diff --git a/SOURCES/0014-cluster-ec-EC_XATTR_DIRTY-doesn-t-come-in-response.patch b/SOURCES/0014-cluster-ec-EC_XATTR_DIRTY-doesn-t-come-in-response.patch new file mode 100644 index 0000000..a60c4c2 --- /dev/null +++ b/SOURCES/0014-cluster-ec-EC_XATTR_DIRTY-doesn-t-come-in-response.patch @@ -0,0 +1,144 @@ +From 17cb0e4782f47339dd1e4edc2e166ff2422da750 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Thu, 4 Jun 2015 09:52:51 +0530 +Subject: [PATCH 14/18] cluster/ec: EC_XATTR_DIRTY doesn't come in response + + Backport of http://review.gluster.com/11084 + +Problem: +ec_update_size_version expects all the keys it did xattrop with to come in +response so that it can set the values again in ec_update_size_version_done. +But EC_XATTR_DIRTY is not combined so the value won't be present in the +response. So ctx->post/pre_dirty are not updated in +ec_update_size_version_done. So these values are still non-zero. When +ec_unlock_now is called as part of flush's unlock phase it again tries to +perform same xattrop for EC_XATTR_DIRTY. But ec_update_size_version is not +expected to be called in unlock phase of flush because ec_flush_size_version +should have reset everything to zero and unlock is never invoked from +ec_update_size_version_done for flush/fsync/fsyncdir. This leads to stale lock +which leads to hang. + +Fix: +EC_XATTR_DIRTY is removed in ex_xattrop_cbk and is never combined with other +answers. So remove handling of this in the response. + +BUG: 1227649 +Change-Id: I657efca6e706e7acb541f98f526943f67562da9f +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/49909 +--- + xlators/cluster/ec/src/ec-common.c | 32 ++++++++------------------------ + xlators/cluster/ec/src/ec-data.h | 4 +--- + 2 files changed, 9 insertions(+), 27 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index ba81fc7..062754b 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -884,14 +884,6 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, + + ctx->have_version = _gf_true; + +- if (ec_dict_del_array(dict, EC_XATTR_DIRTY, ctx->pre_dirty, +- EC_VERSION_SIZE) == 0) { +- ctx->post_dirty[0] += ctx->pre_dirty[0]; +- ctx->post_dirty[1] += ctx->pre_dirty[1]; +- +- ctx->have_dirty = _gf_true; +- } +- + if (lock->loc.inode->ia_type == IA_IFREG) { + if (ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size) != 0) { + gf_log(this->name, GF_LOG_ERROR, "Unable to get size xattr"); +@@ -1107,14 +1099,12 @@ void ec_clear_inode_info(ec_fop_data_t *fop, inode_t *inode) + ctx->have_config = _gf_false; + ctx->have_version = _gf_false; + ctx->have_size = _gf_false; +- ctx->have_dirty = _gf_false; + + memset(&ctx->config, 0, sizeof(ctx->config)); + memset(ctx->pre_version, 0, sizeof(ctx->pre_version)); + memset(ctx->post_version, 0, sizeof(ctx->post_version)); + ctx->pre_size = ctx->post_size = 0; +- memset(ctx->pre_dirty, 0, sizeof(ctx->pre_dirty)); +- memset(ctx->post_dirty, 0, sizeof(ctx->post_dirty)); ++ memset(ctx->dirty, 0, sizeof(ctx->dirty)); + + unlock: + UNLOCK(&inode->lock); +@@ -1472,13 +1462,6 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie, + + ctx->have_size = _gf_true; + } +- if (ec_dict_del_array(xattr, EC_XATTR_DIRTY, ctx->post_dirty, +- EC_VERSION_SIZE) == 0) { +- ctx->pre_dirty[0] = ctx->post_dirty[0]; +- ctx->pre_dirty[1] = ctx->post_dirty[1]; +- +- ctx->have_dirty = _gf_true; +- } + if ((ec_dict_del_config(xdata, EC_XATTR_CONFIG, &ctx->config) == 0) && + ec_config_check(fop->parent, &ctx->config)) { + ctx->have_config = _gf_true; +@@ -1541,7 +1524,7 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version, + + /* If we don't have dirty information or it has been modified, we update + * it. */ +- if (!ctx->have_dirty || (dirty[0] != 0) || (dirty[1] != 0)) { ++ if ((dirty[0] != 0) || (dirty[1] != 0)) { + if (ec_dict_set_array(dict, EC_XATTR_DIRTY, dirty, + EC_VERSION_SIZE) != 0) { + goto out; +@@ -1606,9 +1589,10 @@ ec_update_info(ec_lock_link_t *link) + + size = ctx->post_size - ctx->pre_size; + +- /* pre_dirty[*] will be 0 if have_dirty is false */ +- dirty[0] = ctx->post_dirty[0] - ctx->pre_dirty[0]; +- dirty[1] = ctx->post_dirty[1] - ctx->pre_dirty[1]; ++ dirty[0] = ctx->dirty[0]; ++ dirty[1] = ctx->dirty[1]; ++ /*Dirty is not combined so just reset it right here*/ ++ memset(ctx->dirty, 0, sizeof(ctx->dirty)); + + if ((version[0] != 0) || (version[1] != 0) || + (dirty[0] != 0) || (dirty[1] != 0)) { +@@ -1817,13 +1801,13 @@ void ec_lock_reuse(ec_fop_data_t *fop) + if (link->update[0]) { + ctx->post_version[0]++; + if (ec->node_mask & ~fop->mask) { +- ctx->post_dirty[0]++; ++ ctx->dirty[0]++; + } + } + if (link->update[1]) { + ctx->post_version[1]++; + if (ec->node_mask & ~fop->mask) { +- ctx->post_dirty[1]++; ++ ctx->dirty[1]++; + } + } + } +diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h +index 8204cf0..8f6d5de 100644 +--- a/xlators/cluster/ec/src/ec-data.h ++++ b/xlators/cluster/ec/src/ec-data.h +@@ -72,14 +72,12 @@ struct _ec_inode + gf_boolean_t have_config; + gf_boolean_t have_version; + gf_boolean_t have_size; +- gf_boolean_t have_dirty; + ec_config_t config; + uint64_t pre_version[2]; + uint64_t post_version[2]; + uint64_t pre_size; + uint64_t post_size; +- uint64_t pre_dirty[2]; +- uint64_t post_dirty[2]; ++ uint64_t dirty[2]; + struct list_head heal; + }; + +-- +1.9.3 + diff --git a/SOURCES/0015-glusterd-Bump-op-version-and-max-op-version-for-3.7..patch b/SOURCES/0015-glusterd-Bump-op-version-and-max-op-version-for-3.7..patch new file mode 100644 index 0000000..040e64f --- /dev/null +++ b/SOURCES/0015-glusterd-Bump-op-version-and-max-op-version-for-3.7..patch @@ -0,0 +1,53 @@ +From ed2b44cd5e9ece62562a56056ab911e8568d9d4b Mon Sep 17 00:00:00 2001 +From: Shyam +Date: Wed, 3 Jun 2015 13:43:39 -0400 +Subject: [PATCH 15/18] glusterd: Bump op version and max op version for 3.7.2 + +As 3.7.1 is released, and a DHT configuration option needs higher +op version, bumping the gluster op-version to 3.7.2 (or 30702). + +Change-Id: Iaed9e49b86a195653ddca55994e2c2398b2ee3bc +BUG: 1228266 +Signed-off-by: Shyam +Reviewed-Upstream-on: http://review.gluster.org/11071 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50236 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + libglusterfs/src/globals.h | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h +index ed1bb7c..3ef18ce 100644 +--- a/libglusterfs/src/globals.h ++++ b/libglusterfs/src/globals.h +@@ -25,6 +25,8 @@ + * 3.5.1 - 30501 + * 3.6.0 - 30600 + * 3.7.0 - 30700 ++ * 3.7.1 - 30701 ++ * 3.7.2 - 30702 + * + * Starting with Gluster v3.6, the op-version will be multi-digit integer values + * based on the Glusterfs version, instead of a simply incrementing integer +@@ -35,7 +37,7 @@ + */ + #define GD_OP_VERSION_MIN 1 /* MIN is the fresh start op-version, mostly + should not change */ +-#define GD_OP_VERSION_MAX 30700 /* MAX VERSION is the maximum count in VME ++#define GD_OP_VERSION_MAX 30702 /* MAX VERSION is the maximum count in VME + table, should keep changing with + introduction of newer versions */ + +@@ -45,6 +47,8 @@ + + #define GD_OP_VERSION_3_7_1 30701 /* Op-version for GlusterFS 3.7.1 */ + ++#define GD_OP_VERSION_3_7_2 30702 /* Op-version for GlusterFS 3.7.2 */ ++ + #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 + + #include "xlator.h" +-- +1.9.3 + diff --git a/SOURCES/0016-build-remove-ghost-directory-entries.patch b/SOURCES/0016-build-remove-ghost-directory-entries.patch new file mode 100644 index 0000000..3d90b97 --- /dev/null +++ b/SOURCES/0016-build-remove-ghost-directory-entries.patch @@ -0,0 +1,131 @@ +From 066cf007f2f6ac3f2f1037c035504c37da5d31b3 Mon Sep 17 00:00:00 2001 +From: "Bala.FA" +Date: Mon, 7 Apr 2014 15:24:10 +0530 +Subject: [PATCH 16/18] build: remove ghost directory entries + +ovirt requires hook directories for gluster management and ghost +directories are no more ghost entries + +Label: DOWNSTREAM ONLY + +Change-Id: Iaf1066ba0655619024f87eaaa039f0010578c567 +Signed-off-by: Bala.FA +--- + glusterfs.spec.in | 71 +++++++------------------------------------------------ + 1 file changed, 9 insertions(+), 62 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index a5a884f..d60a618 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -695,7 +695,6 @@ install -D -p -m 0644 extras/glusterfs-logrotate \ + %{buildroot}%{_sysconfdir}/logrotate.d/glusterfs + + %if ( 0%{!?_without_georeplication:1} ) +-# geo-rep ghosts + mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/geo-replication + touch %{buildroot}%{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf + install -D -p -m 0644 extras/glusterfs-georep-logrotate \ +@@ -719,41 +718,13 @@ install -D -p -m 0644 extras/logger.conf.example \ + %endif + %endif + +-# the rest of the ghosts + touch %{buildroot}%{_sharedstatedir}/glusterd/glusterd.info + touch %{buildroot}%{_sharedstatedir}/glusterd/options +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1 +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/stop +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/stop/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/stop/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/start +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/start/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/start/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/reset +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/reset/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/reset/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/remove-brick +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/remove-brick/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/remove-brick/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/add-brick +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/add-brick/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/add-brick/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/set +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/set/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/set/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/create +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/create/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/create/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file/pre +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create/post +-mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create/pre ++subdirs=("add-brick" "create" "copy-file" "delete" "gsync-create" "remove-brick" "reset" "set" "start" "stop") ++for dir in ${subdirs[@]} ++do ++mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/"$dir"/{pre,post} ++done + mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/glustershd + mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/peers + mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/vols +@@ -1051,11 +1022,7 @@ fi + %{_libexecdir}/glusterfs/set_geo_rep_pem_keys.sh + %{_libexecdir}/glusterfs/peer_gsec_create + %{_libexecdir}/glusterfs/peer_mountbroker +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/geo-replication +-%dir %{_sharedstatedir}/glusterd/hooks +-%dir %{_sharedstatedir}/glusterd/hooks/1 +-%dir %{_sharedstatedir}/glusterd/hooks/1/gsync-create +-%dir %{_sharedstatedir}/glusterd/hooks/1/gsync-create/post ++%dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/geo-replication + %{_sharedstatedir}/glusterd/hooks/1/gsync-create/post/S56glusterd-geo-rep-create-post.sh + %{_datadir}/glusterfs/scripts/get-gfid.sh + %{_datadir}/glusterfs/scripts/slave-upgrade.sh +@@ -1104,7 +1071,7 @@ fi + %if 0%{?_tmpfilesdir:1} + %{_tmpfilesdir}/gluster.conf + %endif +-%dir %{_sharedstatedir}/glusterd ++%{_sharedstatedir}/glusterd/* + %dir %{_sharedstatedir}/glusterd/groups + %config(noreplace) %{_sharedstatedir}/glusterd/groups/virt + # Legacy configs +@@ -1170,28 +1137,8 @@ fi + + %ghost %attr(0644,-,-) %config(noreplace) %{_sharedstatedir}/glusterd/glusterd.info + %ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/options +-# This is really ugly, but I have no idea how to mark these directories in +-# any other way. They should belong to the glusterfs-server package, but +-# don't exist after installation. They are generated on the first start... +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/post +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/pre +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick/post +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick/pre +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/set/pre +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create/post +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create/pre +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete/post +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete/pre +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/glustershd +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/vols +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/peers +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs +-%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/nfs-server.vol +-%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs/run +-%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/run/nfs.pid ++%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/nfs-server.vol ++%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/run/nfs.pid + + # Extra utility script + %{_datadir}/glusterfs/scripts/stop-all-gluster-processes.sh +-- +1.9.3 + diff --git a/SOURCES/0017-build-add-RHGS-specific-changes.patch b/SOURCES/0017-build-add-RHGS-specific-changes.patch new file mode 100644 index 0000000..7f6142e --- /dev/null +++ b/SOURCES/0017-build-add-RHGS-specific-changes.patch @@ -0,0 +1,802 @@ +From ff8624a0f0f953c853f6fbffede02cae2e04bf45 Mon Sep 17 00:00:00 2001 +From: "Bala.FA" +Date: Fri, 28 Feb 2014 15:28:44 +0530 +Subject: [PATCH 17/18] build: add RHGS specific changes + +Label: DOWNSTREAM ONLY + +Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1074947 +Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1097782 +Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1115267 +Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1221743 +Change-Id: I08333334745adf2350e772c6454ffcfe9c08cb89 +Reviewed-on: https://code.engineering.redhat.com/gerrit/24983 +Reviewed-on: https://code.engineering.redhat.com/gerrit/25451 +Reviewed-on: https://code.engineering.redhat.com/gerrit/25518 +Reviewed-on: https://code.engineering.redhat.com/gerrit/25983 +Signed-off-by: Bala.FA +--- + glusterfs.spec.in | 565 +++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 562 insertions(+), 3 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index d60a618..dc87e83 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -72,6 +72,23 @@ + %define _without_qemu_block --disable-qemu-block + %endif + ++# if you wish not to build server rpms, compile like this. ++# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --without server ++ ++%global _build_server 1 ++%if "%{?_without_server}" ++%global _build_server 0 ++%endif ++ ++%if ( "%{?dist}" == ".el6rhs" ) || ( "%{?dist}" == ".el7rhs" ) || ( "%{?dist}" == ".el7rhgs" ) ++%global _build_server 1 ++%else ++%global _build_server 0 ++%endif ++ ++%global _without_extra_xlators 1 ++%global _without_regression_tests 1 ++ + ##----------------------------------------------------------------------------- + ## All %global definitions should be placed here and keep them sorted + ## +@@ -161,8 +178,8 @@ Vendor: Fedora Project + %else + Name: @PACKAGE_NAME@ + Version: @PACKAGE_VERSION@ +-Release: 0.@PACKAGE_RELEASE@%{?dist} +-Vendor: glusterfs.org ++Release: @PACKAGE_RELEASE@%{?dist} ++ExclusiveArch: x86_64 aarch64 + %endif + License: GPLv2 or LGPLv3+ + Group: System Environment/Base +@@ -292,7 +309,9 @@ Summary: Development Libraries + Group: Development/Libraries + Requires: %{name} = %{version}-%{release} + # Needed for the Glupy examples to work ++%if ( 0%{!?_without_extra_xlators:1} ) + Requires: %{name}-extra-xlators = %{version}-%{release} ++%endif + + %description devel + GlusterFS is a distributed file-system capable of scaling to several +@@ -305,6 +324,7 @@ is in user space and easily manageable. + + This package provides the development libraries and include files. + ++%if ( 0%{!?_without_extra_xlators:1} ) + %package extra-xlators + Summary: Extra Gluster filesystem Translators + Group: Applications/File +@@ -324,6 +344,7 @@ is in user space and easily manageable. + + This package provides extra filesystem Translators, such as Glupy, + for GlusterFS. ++%endif + + %package fuse + Summary: Fuse client +@@ -349,6 +370,7 @@ is in user space and easily manageable. + This package provides support to FUSE based clients and inlcudes the + glusterfs(d) binary. + ++%if ( 0%{?_build_server} ) + %package ganesha + Summary: NFS-Ganesha configuration + Group: Applications/File +@@ -368,7 +390,9 @@ is in user space and easily manageable. + + This package provides the configuration and related files for using + NFS-Ganesha as the NFS server using GlusterFS ++%endif + ++%if ( 0%{?_build_server} ) + %if ( 0%{!?_without_georeplication:1} ) + %package geo-replication + Summary: GlusterFS Geo-replication +@@ -388,6 +412,7 @@ is in userspace and easily manageable. + + This package provides support to geo-replication. + %endif ++%endif + + %package libs + Summary: GlusterFS common libraries +@@ -450,6 +475,8 @@ is in user space and easily manageable. + This package provides support to ib-verbs library. + %endif + ++%if ( 0%{?_build_server} ) ++%if ( 0%{!?_without_regression_tests:1} ) + %package regression-tests + Summary: Development Tools + Group: Development/Tools +@@ -465,7 +492,10 @@ Requires: nfs-utils xfsprogs yajl + %description regression-tests + The Gluster Test Framework, is a suite of scripts used for + regression testing of Gluster. ++%endif ++%endif + ++%if ( 0%{?_build_server} ) + %if ( 0%{!?_without_ocf:1} ) + %package resource-agents + Summary: OCF Resource Agents for GlusterFS +@@ -498,7 +528,9 @@ This package provides the resource agents which plug glusterd into + Open Cluster Framework (OCF) compliant cluster resource managers, + like Pacemaker. + %endif ++%endif + ++%if ( 0%{?_build_server} ) + %package server + Summary: Clustered file-system server + Group: System Environment/Daemons +@@ -547,6 +579,7 @@ called Translators from GNU Hurd kernel. Much of the code in GlusterFS + is in user space and easily manageable. + + This package provides the glusterfs server daemon. ++%endif + + %package client-xlators + Summary: GlusterFS client-side translators +@@ -569,7 +602,7 @@ This package provides the translators needed on any GlusterFS client. + %build + # For whatever reason, install-sh is sometimes missing. When this gets fixed, + # there is no need to run ./autogen or have a BuildRequires for automake. +-[ -e 'install-sh' -o -e 'install.sh' ] || ./autogen.sh ++./autogen.sh + %configure \ + %{?_with_tmpfilesdir} \ + %{?_without_rdma} \ +@@ -774,6 +807,7 @@ rm -rf %{buildroot} + modprobe fuse + %endif + ++%if ( 0%{?_build_server} ) + %if ( 0%{!?_without_georeplication:1} ) + %post geo-replication + #restart glusterd. +@@ -781,14 +815,19 @@ if [ $1 -ge 1 ]; then + %_init_restart glusterd + fi + %endif ++%endif + + %post libs + /sbin/ldconfig + ++%if ( 0%{?_build_server} ) + %post server + # Legacy server + %_init_enable glusterd ++# fix bz#1110715 ++if [ -f %_init_glusterfsd ]; then + %_init_enable glusterfsd ++fi + # ".cmd_log_history" is renamed to "cmd_history.log" in GlusterFS-3.7 . + # While upgrading glusterfs-server package form GlusterFS version <= 3.6 to + # GlusterFS version 3.7, ".cmd_log_history" should be renamed to +@@ -848,10 +887,12 @@ else + #rpm_script_t context. + rm -rf /var/run/glusterd.socket + fi ++%endif + + ##----------------------------------------------------------------------------- + ## All %preun should be placed here and keep them sorted + ## ++%if ( 0%{?_build_server} ) + %preun server + if [ $1 -eq 0 ]; then + if [ -f %_init_glusterfsd ]; then +@@ -869,6 +910,7 @@ if [ $1 -ge 1 ]; then + fi + %_init_restart glusterd + fi ++%endif + + ##----------------------------------------------------------------------------- + ## All %postun should be placed here and keep them sorted +@@ -891,6 +933,80 @@ fi + ## All files should be placed here and keep them grouped + ## + %files ++# exclude extra-xlators files ++%if ( ! 0%{!?_without_extra_xlators:1} ) ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/mac-compat.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_client.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_dht.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_server.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quiesce.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/features/template.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache.so ++%exclude %{python_sitelib}/* ++%endif ++# exclude regression-tests files ++%if ( ! 0%{!?_without_regression_tests:1} ) ++%exclude %{_prefix}/share/glusterfs/run-tests.sh ++%exclude %{_prefix}/share/glusterfs/tests/* ++%endif ++%if ( ! 0%{?_build_server} ) ++# exclude ganesha files ++%exclude %{_sysconfdir}/ganesha/* ++%exclude %{_libexecdir}/ganesha/* ++%exclude %{_prefix}/lib/ocf/* ++# exclude geo-replication files ++%exclude %{_sysconfdir}/logrotate.d/glusterfs-georep ++%exclude %{_libexecdir}/glusterfs/* ++%exclude %{_sbindir}/gfind_missing_files ++%exclude %{_datadir}/glusterfs/scripts/get-gfid.sh ++%exclude %{_datadir}/glusterfs/scripts/slave-upgrade.sh ++%exclude %{_datadir}/glusterfs/scripts/gsync-upgrade.sh ++%exclude %{_datadir}/glusterfs/scripts/generate-gfid-file.sh ++%exclude %{_datadir}/glusterfs/scripts/gsync-sync-gfid ++%exclude %{_sharedstatedir}/glusterd/* ++# exclude server files ++%exclude %{_sysconfdir}/glusterfs ++%exclude %{_sysconfdir}/glusterfs/glusterd.vol ++%exclude %{_sysconfdir}/glusterfs/glusterfs-georep-logrotate ++%exclude %{_sysconfdir}/glusterfs/glusterfs-logrotate ++%exclude %{_sysconfdir}/glusterfs/gluster-rsyslog-5.8.conf ++%exclude %{_sysconfdir}/glusterfs/gluster-rsyslog-7.2.conf ++%exclude %{_sysconfdir}/glusterfs/group-virt.example ++%exclude %{_sysconfdir}/glusterfs/logger.conf.example ++%exclude %_init_glusterd ++%exclude %{_sysconfdir}/sysconfig/glusterd ++%exclude %{_bindir}/glusterfind ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/snapview-server.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/marker.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quota* ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/trash.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/upcall.so ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mgmt* ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* ++%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* ++%exclude %{_libdir}/libgfdb.so.* ++%exclude %{_sbindir}/gcron.py ++%exclude %{_sbindir}/glfsheal ++%exclude %{_sbindir}/glusterd ++%exclude %{_sbindir}/snap_scheduler.py ++%exclude %{_datadir}/glusterfs/scripts/stop-all-gluster-processes.sh ++#/usr/share/doc/glusterfs-server-3.7.0beta2/clear_xattrs.sh ++%exclude %{_localstatedir}/run/gluster ++%if 0%{?_tmpfilesdir:1} ++%exclude %{_tmpfilesdir}/gluster.conf ++%endif ++%endif + %doc ChangeLog COPYING-GPLV2 COPYING-LGPLV3 INSTALL README.md THANKS + %if ( 0%{!?_without_syslog:1} ) + %if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 6 ) +@@ -975,6 +1091,7 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/qemu-block.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/client.so + ++%if ( 0%{!?_without_extra_xlators:1} ) + %files extra-xlators + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy.so +@@ -991,6 +1108,7 @@ fi + %if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) ) + %{python_sitelib}/glusterfs_glupy*.egg-info + %endif ++%endif + + %files fuse + # glusterfs is a symlink to glusterfsd, -server depends on -fuse. +@@ -1008,11 +1126,14 @@ fi + %endif + %endif + ++%if ( 0%{?_build_server} ) + %files ganesha + %{_sysconfdir}/ganesha/* + %attr(0755,-,-) %{_libexecdir}/ganesha/* + %attr(0755,-,-) %{_prefix}/lib/ocf/resource.d/heartbeat/* ++%endif + ++%if ( 0%{?_build_server} ) + %if ( 0%{!?_without_georeplication:1} ) + %files geo-replication + %config(noreplace) %{_sysconfdir}/logrotate.d/glusterfs-georep +@@ -1035,6 +1156,7 @@ fi + %exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyo + %exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyc + %endif ++%endif + + %files libs + %{_libdir}/*.so.* +@@ -1052,18 +1174,26 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/rpc-transport/rdma* + %endif + ++%if ( 0%{?_build_server} ) ++%if ( 0%{!?_without_regression_tests:1} ) + %files regression-tests + %{_prefix}/share/glusterfs/run-tests.sh + %{_prefix}/share/glusterfs/tests + %exclude %{_prefix}/share/glusterfs/tests/basic/rpm.t ++%endif ++%endif + ++%if ( 0%{?_build_server} ) + %if ( 0%{!?_without_ocf:1} ) + %files resource-agents + # /usr/lib is the standard for OCF, also on x86_64 + %{_prefix}/lib/ocf/resource.d/glusterfs + %endif ++%endif + ++%if ( 0%{?_build_server} ) + %files server ++%exclude %{_sharedstatedir}/glusterd/hooks/1/gsync-create/post/S56glusterd-geo-rep-create-post.sh + %doc extras/clear_xattrs.sh + %config(noreplace) %{_sysconfdir}/sysconfig/glusterd + %config(noreplace) %{_sysconfdir}/glusterfs +@@ -1071,6 +1201,7 @@ fi + %if 0%{?_tmpfilesdir:1} + %{_tmpfilesdir}/gluster.conf + %endif ++%dir %{_sharedstatedir}/glusterd + %{_sharedstatedir}/glusterd/* + %dir %{_sharedstatedir}/glusterd/groups + %config(noreplace) %{_sharedstatedir}/glusterd/groups/virt +@@ -1147,7 +1278,435 @@ fi + %{_libexecdir}/glusterfs/glusterfind + %{_bindir}/glusterfind + %{_libexecdir}/glusterfs/peer_add_secret_pub ++%endif ++ ++ ++##----------------------------------------------------------------------------- ++## All %pretrans should be placed here and keep them sorted ++## ++%if 0%{?_build_server} ++%pretrans -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ echo "ERROR: Distribute volumes detected. In-service rolling upgrade requires distribute volume(s) to be stopped." ++ echo "ERROR: Please stop distribute volume(s) before proceeding... exiting!" ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ echo "WARNING: Updating glusterfs requires its processes to be killed. This action does NOT incur downtime." ++ echo "WARNING: Ensure to wait for the upgraded server to finish healing before proceeding." ++ echo "WARNING: Refer upgrade section of install guide for more details" ++ echo "Please run # service glusterd stop; pkill glusterfs; pkill glusterfsd; pkill gsyncd.py;" ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%pretrans api -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] + ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-api_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%pretrans api-devel -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-api-devel_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%pretrans devel -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%pretrans fuse -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%if 0%{?_can_georeplicate} ++%if ( 0%{!?_without_georeplication:1} ) ++%pretrans geo-replication -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++%endif ++%endif ++ ++ ++ ++%pretrans libs -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ ++%if ( 0%{!?_without_rdma:1} ) ++%pretrans rdma -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++%endif ++ ++ ++ ++%if ( 0%{!?_without_ocf:1} ) ++%pretrans resource-agents -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++%endif ++ ++ ++ ++%pretrans server -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++%endif + + %changelog + * Sun May 31 2015 Milind Changire +-- +1.9.3 + diff --git a/SOURCES/0018-secalert-remove-setuid-bit-for-fusermount-glusterfs.patch b/SOURCES/0018-secalert-remove-setuid-bit-for-fusermount-glusterfs.patch new file mode 100644 index 0000000..4a07fd4 --- /dev/null +++ b/SOURCES/0018-secalert-remove-setuid-bit-for-fusermount-glusterfs.patch @@ -0,0 +1,33 @@ +From 17c6cbb239189e1057fd4a0219168517bd5807d6 Mon Sep 17 00:00:00 2001 +From: "Bala.FA" +Date: Thu, 22 May 2014 08:37:27 +0530 +Subject: [PATCH 18/18] secalert: remove setuid bit for fusermount-glusterfs + +glusterfs-fuse: File /usr/bin/fusermount-glusterfs on x86_64 is setuid +root but is not on the setxid whitelist + +Label: DOWNSTREAM ONLY + +Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=989480 +Change-Id: Icf6e5db72ae15ccc60b02be6713fb6c4f4c8a15f +Signed-off-by: Bala.FA +Reviewed-on: https://code.engineering.redhat.com/gerrit/25453 +Signed-off-by: Bala.FA +--- + contrib/fuse-util/Makefile.am | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/contrib/fuse-util/Makefile.am b/contrib/fuse-util/Makefile.am +index abbc10e..a071c81 100644 +--- a/contrib/fuse-util/Makefile.am ++++ b/contrib/fuse-util/Makefile.am +@@ -9,6 +9,5 @@ AM_CFLAGS = -Wall $(GF_CFLAGS) + + install-exec-hook: + -chown root $(DESTDIR)$(bindir)/fusermount-glusterfs +- chmod u+s $(DESTDIR)$(bindir)/fusermount-glusterfs + + CLEANFILES = +-- +1.9.3 + diff --git a/SOURCES/0019-dht-Add-lookup-optimize-configuration-option-for-DHT.patch b/SOURCES/0019-dht-Add-lookup-optimize-configuration-option-for-DHT.patch new file mode 100644 index 0000000..0449ec2 --- /dev/null +++ b/SOURCES/0019-dht-Add-lookup-optimize-configuration-option-for-DHT.patch @@ -0,0 +1,270 @@ +From ede515d765e55744bcbaa199a9ed703d265aa88b Mon Sep 17 00:00:00 2001 +From: Shyam +Date: Fri, 15 May 2015 15:50:42 -0400 +Subject: [PATCH 19/57] dht: Add lookup-optimize configuration option for DHT + +Currently with commit 4eaaf5 a mixed version cluster would +have issues if lookup-uhashed is set to auto, as older clients +would fail to validate the layouts if newer clients (i.e 3.7 or +upwards) create directories. Also, in a mixed version cluster +rebalance daemon would set commit hash for some subvolumes and +not for the others. + +This commit fixes this problem by moving the enabling of the +functionality introduced in the above mentioned commit to a +new dht option. This option also has a op_version of 3_7_1 +thereby preventing it from being set in a mixed version +cluster. It brings in the following changes, +- Option can be set only if min version of the cluster is +3.7.1 or more +- Rebalance and mkdir update the layout with the commit hashes +only if this option is set, hence ensuring rebalance works in a +mixed version cluster, and also directories created by newer +clients do not cause layout errors when read by older clients +- This option also supersedes lookup-unhased, to enable the +optimization for lookups more deterministic and not conflict +with lookup-unhashed settings. + +Option added is cluster.lookup-optimize, which is a boolean. + +Usage: # gluster volume set VOLNAME cluster.lookup-optimize on + +Change-Id: Ifd1d4ce3f6438fcbcd60ffbfdbfb647355ea1ae0 +BUG: 1222053 +Signed-off-by: Shyam +Reviewed-on: https://code.engineering.redhat.com/gerrit/50238 +Reviewed-by: Nithya Balachandran +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + tests/features/unhashed-auto.t | 28 ++++++++++- + xlators/cluster/dht/src/dht-common.c | 62 +++++++++++++++++----- + xlators/cluster/dht/src/dht-common.h | 1 + + xlators/cluster/dht/src/dht-rebalance.c | 6 ++- + xlators/cluster/dht/src/dht-shared.c | 13 +++++ + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 ++ + 6 files changed, 98 insertions(+), 17 deletions(-) + +diff --git a/tests/features/unhashed-auto.t b/tests/features/unhashed-auto.t +index 97663c2..cba5b77 100755 +--- a/tests/features/unhashed-auto.t ++++ b/tests/features/unhashed-auto.t +@@ -39,6 +39,11 @@ get_xattr () { + $cmd $1 | od -tx1 -An | tr -d ' ' + } + ++get_xattr_hash () { ++ cmd="getfattr --absolute-names --only-values -n trusted.glusterfs.dht" ++ $cmd $1 | od -tx1 -An | awk '{printf("%s%s%s%s\n", $1, $2, $3, $4);}' ++} ++ + cleanup + + TEST glusterd +@@ -49,7 +54,7 @@ TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2} + EXPECT "$V0" volinfo_field $V0 'Volume Name' + EXPECT 'Created' volinfo_field $V0 'Status' + +-TEST $CLI volume set $V0 cluster.lookup-unhashed auto ++TEST $CLI volume set $V0 cluster.lookup-optimize ON + + TEST $CLI volume start $V0 + EXPECT 'Started' volinfo_field $V0 'Status' +@@ -96,4 +101,25 @@ TEST wait_for_rebalance + new_val=$(get_xattr $B0/${V0}1/dir) + TEST [ ! x"$old_val" = x"$new_val" ] + ++# Force an anomoly on an existing layout and heal it ++## The healed layout should not carry a commit-hash (or should carry 1 in the ++## commit-hash) ++TEST setfattr -x trusted.glusterfs.dht $B0/${V0}1/dir ++TEST $GFS -s $H0 --volfile-id $V0 $M0 ++TEST [ -d $M0/dir ] ++new_hash=$(get_xattr_hash $B0/${V0}1/dir) ++TEST [ x"$new_hash" = x"00000001" ] ++new_hash=$(get_xattr_hash $B0/${V0}2/dir) ++TEST [ x"$new_hash" = x"00000001" ] ++ ++# Unset the option and check that newly created directories get 1 in the ++# disk layout ++TEST $CLI volume reset $V0 cluster.lookup-optimize ++TEST mkdir $M0/dir1 ++new_hash=$(get_xattr_hash $B0/${V0}1/dir1) ++TEST [ x"$new_hash" = x"00000001" ] ++new_hash=$(get_xattr_hash $B0/${V0}2/dir1) ++TEST [ x"$new_hash" = x"00000001" ] ++ ++ + cleanup +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 8e78746..48a003c 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -1923,25 +1923,51 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + "Entry %s missing on subvol %s", + loc->path, prev->this->name); + +- if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_ON) { +- local->op_errno = ENOENT; +- dht_lookup_everywhere (frame, this, loc); +- return 0; +- } +- if ((conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO) && +- (loc->parent)) { ++ /* lookup-optimize supercedes lookup-unhashed settings, ++ * - so if it is set, do not process search_unhashed ++ * - except, in the case of rebalance deamon, we want to ++ * force the lookup_everywhere behavior */ ++ if (!conf->defrag && conf->lookup_optimize && loc->parent) { + ret = dht_inode_ctx_layout_get (loc->parent, this, + &parent_layout); +- if (ret || !parent_layout) +- goto out; +- if (parent_layout->commit_hash +- != conf->vol_commit_hash) { +- gf_log (this->name, GF_LOG_DEBUG, +- "hashes don't match, do global lookup"); ++ if (ret || !parent_layout || ++ (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); ++ local->op_errno = ENOENT; ++ dht_lookup_everywhere (frame, this, loc); ++ return 0; ++ } ++ } else { ++ if (conf->search_unhashed == ++ GF_DHT_LOOKUP_UNHASHED_ON) { + local->op_errno = ENOENT; + dht_lookup_everywhere (frame, this, loc); + return 0; + } ++ ++ if ((conf->search_unhashed == ++ GF_DHT_LOOKUP_UNHASHED_AUTO) && ++ (loc->parent)) { ++ ret = dht_inode_ctx_layout_get (loc->parent, ++ this, ++ &parent_layout); ++ if (ret || !parent_layout) ++ goto out; ++ if (parent_layout->search_unhashed) { ++ local->op_errno = ENOENT; ++ dht_lookup_everywhere (frame, this, ++ loc); ++ return 0; ++ } ++ } + } + } + +@@ -5800,7 +5826,15 @@ dht_mkdir (call_frame_t *frame, xlator_t *this, + goto err; + } + +- local->layout->commit_hash = conf->vol_commit_hash; ++ /* set the newly created directory hash to the commit hash ++ * if the configuration option is set. If configuration option ++ * is not set, the older clients may still be connecting to the ++ * volume and hence we need to preserve the 1 in disk[0] part of the ++ * layout xattr */ ++ if (conf->lookup_optimize) ++ local->layout->commit_hash = conf->vol_commit_hash; ++ else ++ local->layout->commit_hash = DHT_LAYOUT_HASH_INVALID; + + STACK_WIND (frame, dht_mkdir_hashed_cbk, + hashed_subvol, +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 7a5d40f..4b6531c 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -398,6 +398,7 @@ struct dht_conf { + dht_layout_t **file_layouts; + dht_layout_t **dir_layouts; + gf_boolean_t search_unhashed; ++ gf_boolean_t lookup_optimize; + int gen; + dht_du_t *du_stats; + double min_free_disk; +diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c +index 3ab73d4..89cc3a8 100644 +--- a/xlators/cluster/dht/src/dht-rebalance.c ++++ b/xlators/cluster/dht/src/dht-rebalance.c +@@ -2362,8 +2362,10 @@ gf_defrag_settle_hash (xlator_t *this, gf_defrag_info_t *defrag, + return -1; + } + +- if (conf->local_subvols_cnt == 0) { +- /* Commit hash updates are only done on local subvolumes ++ if (conf->local_subvols_cnt == 0 || !conf->lookup_optimize) { ++ /* Commit hash updates are only done on local subvolumes and ++ * only when lookup optmization is needed (for older client ++ * support) + */ + return 0; + } +diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c +index a1f72a8..456d831 100644 +--- a/xlators/cluster/dht/src/dht-shared.c ++++ b/xlators/cluster/dht/src/dht-shared.c +@@ -431,6 +431,9 @@ dht_reconfigure (xlator_t *this, dict_t *options) + } + } + ++ GF_OPTION_RECONF ("lookup-optimize", conf->lookup_optimize, options, ++ bool, out); ++ + GF_OPTION_RECONF ("min-free-disk", conf->min_free_disk, options, + percent_or_size, out); + /* option can be any one of percent or bytes */ +@@ -667,6 +670,8 @@ dht_init (xlator_t *this) + conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_AUTO; + } + ++ GF_OPTION_INIT ("lookup-optimize", conf->lookup_optimize, bool, err); ++ + GF_OPTION_INIT ("unhashed-sticky-bit", conf->unhashed_sticky_bit, bool, + err); + +@@ -838,6 +843,14 @@ struct volume_options options[] = { + "from the hash subvolume. If set to OFF, it does not do a lookup " + "on the remaining subvolumes." + }, ++ { .key = {"lookup-optimize"}, ++ .type = GF_OPTION_TYPE_BOOL, ++ .default_value = "off", ++ .description = "This option if set to ON enables the optimization " ++ "of -ve lookups, by not doing a lookup on non-hashed subvolumes for " ++ "files, in case the hashed subvolume does not return any result. " ++ "This option disregards the lookup-unhashed setting, when enabled." ++ }, + { .key = {"min-free-disk"}, + .type = GF_OPTION_TYPE_PERCENT_OR_SIZET, + .default_value = "10%", +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index b8ca6be..65cbfc0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -333,6 +333,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .op_version = 1, + .flags = OPT_FLAG_CLIENT_OPT + }, ++ { .key = "cluster.lookup-optimize", ++ .voltype = "cluster/distribute", ++ .op_version = GD_OP_VERSION_3_7_2, ++ .flags = OPT_FLAG_CLIENT_OPT ++ }, + { .key = "cluster.min-free-disk", + .voltype = "cluster/distribute", + .op_version = 1, +-- +1.7.1 + diff --git a/SOURCES/0020-features-quota-Fix-ref-leak.patch b/SOURCES/0020-features-quota-Fix-ref-leak.patch new file mode 100644 index 0000000..62583c3 --- /dev/null +++ b/SOURCES/0020-features-quota-Fix-ref-leak.patch @@ -0,0 +1,41 @@ +From cb49857a7bc2f478c32d87a65605d87b2a8a0a0d Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 2 Jun 2015 17:58:00 +0530 +Subject: [PATCH 20/57] features/quota: Fix ref-leak + +This is a backport of http://review.gluster.org/#/c/11045/ + +> Change-Id: I0b44b70f07be441e044d9dfc5c2b64bd5b4cac18 +> BUG: 1207735 +> Signed-off-by: Pranith Kumar K +> Reviewed-on: http://review.gluster.org/11045 +> Tested-by: Gluster Build System +> Reviewed-by: Raghavendra G +> Tested-by: Raghavendra G +> Signed-off-by: vmallika + +Change-Id: I77cfcf978fdbcfdba912349eb02ed0210b0861e9 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/50223 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index 6d05273..569b3c0 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -385,6 +385,7 @@ check_ancestory (call_frame_t *frame, inode_t *inode) + if (!parent) { + quota_build_ancestry (cur_inode, + check_ancestory_continue, frame); ++ inode_unref (cur_inode); + return; + } + inode_unref (cur_inode); +-- +1.7.1 + diff --git a/SOURCES/0021-worm-Let-lock-zero-xattrop-calls-succeed.patch b/SOURCES/0021-worm-Let-lock-zero-xattrop-calls-succeed.patch new file mode 100644 index 0000000..4d616ce --- /dev/null +++ b/SOURCES/0021-worm-Let-lock-zero-xattrop-calls-succeed.patch @@ -0,0 +1,153 @@ +From 5311950675dee5588d5eaae5e064e4fd06216343 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Sat, 9 May 2015 23:11:15 +0530 +Subject: [PATCH 21/57] worm: Let lock, zero xattrop calls succeed + + Backport of http://review.gluster.org/10727 + +Locks can be taken just to inspect the data as well, so allow them. +Xattrops are internal fops so we can allow them as well as longs as +it doesn't change the xattr value, i.e. All-zero xattrop. + +BUG: 1227172 +Change-Id: I9e72806e0605ab2938348a87935966909f1a721f +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50311 +--- + xlators/features/read-only/src/read-only-common.c | 74 ++++++++++++--------- + 1 files changed, 42 insertions(+), 32 deletions(-) + +diff --git a/xlators/features/read-only/src/read-only-common.c b/xlators/features/read-only/src/read-only-common.c +index 39937d1..24e9903 100644 +--- a/xlators/features/read-only/src/read-only-common.c ++++ b/xlators/features/read-only/src/read-only-common.c +@@ -30,11 +30,29 @@ is_readonly_or_worm_enabled (xlator_t *this) + return readonly_or_worm_enabled; + } + ++static int ++_check_key_is_zero_filled (dict_t *d, char *k, data_t *v, ++ void *tmp) ++{ ++ if (mem_0filled ((const char *)v->data, v->len)) { ++ /* -1 means, no more iterations, treat as 'break' */ ++ return -1; ++ } ++ return 0; ++} ++ + int32_t + ro_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) ++ gf_boolean_t allzero = _gf_false; ++ int ret = 0; ++ ++ ret = dict_foreach (dict, _check_key_is_zero_filled, NULL); ++ if (ret == 0) ++ allzero = _gf_true; ++ ++ if (is_readonly_or_worm_enabled (this) && !allzero) + STACK_UNWIND_STRICT (xattrop, frame, -1, EROFS, NULL, xdata); + else + STACK_WIND_TAIL (frame, FIRST_CHILD (this), +@@ -47,7 +65,14 @@ int32_t + ro_fxattrop (call_frame_t *frame, xlator_t *this, + fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) ++ gf_boolean_t allzero = _gf_false; ++ int ret = 0; ++ ++ ret = dict_foreach (dict, _check_key_is_zero_filled, NULL); ++ if (ret == 0) ++ allzero = _gf_true; ++ ++ if (is_readonly_or_worm_enabled (this) && !allzero) + STACK_UNWIND_STRICT (fxattrop, frame, -1, EROFS, NULL, xdata); + else + STACK_WIND_TAIL (frame, FIRST_CHILD (this), +@@ -62,12 +87,9 @@ ro_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, + loc_t *loc, const char *basename, entrylk_cmd cmd, + entrylk_type type, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) +- STACK_UNWIND_STRICT (entrylk, frame, -1, EROFS, xdata); +- else +- STACK_WIND_TAIL (frame, FIRST_CHILD (this), +- FIRST_CHILD(this)->fops->entrylk, +- volume, loc, basename, cmd, type, xdata); ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD(this)->fops->entrylk, ++ volume, loc, basename, cmd, type, xdata); + + return 0; + } +@@ -77,12 +99,9 @@ ro_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, + fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, + dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) +- STACK_UNWIND_STRICT (fentrylk, frame, -1, EROFS, xdata); +- else +- STACK_WIND_TAIL (frame, FIRST_CHILD (this), +- FIRST_CHILD(this)->fops->fentrylk, +- volume, fd, basename, cmd, type, xdata); ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD(this)->fops->fentrylk, ++ volume, fd, basename, cmd, type, xdata); + + return 0; + } +@@ -91,12 +110,9 @@ int32_t + ro_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, + loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) +- STACK_UNWIND_STRICT (inodelk, frame, -1, EROFS, xdata); +- else +- STACK_WIND_TAIL (frame, FIRST_CHILD (this), +- FIRST_CHILD(this)->fops->inodelk, +- volume, loc, cmd, lock, xdata); ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD(this)->fops->inodelk, ++ volume, loc, cmd, lock, xdata); + + return 0; + } +@@ -105,12 +121,9 @@ int32_t + ro_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, + fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) +- STACK_UNWIND_STRICT (finodelk, frame, -1, EROFS, xdata); +- else +- STACK_WIND_TAIL (frame, FIRST_CHILD (this), +- FIRST_CHILD(this)->fops->finodelk, +- volume, fd, cmd, lock, xdata); ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD(this)->fops->finodelk, ++ volume, fd, cmd, lock, xdata); + + return 0; + } +@@ -119,12 +132,9 @@ int32_t + ro_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd, + struct gf_flock *flock, dict_t *xdata) + { +- if (is_readonly_or_worm_enabled (this)) +- STACK_UNWIND_STRICT (lk, frame, -1, EROFS, NULL, xdata); +- else +- STACK_WIND_TAIL (frame, FIRST_CHILD (this), +- FIRST_CHILD(this)->fops->lk, fd, cmd, flock, +- xdata); ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD(this)->fops->lk, fd, cmd, flock, ++ xdata); + + return 0; + } +-- +1.7.1 + diff --git a/SOURCES/0022-glusterd-snapshot-Return-correct-errno-in-events-of-.patch b/SOURCES/0022-glusterd-snapshot-Return-correct-errno-in-events-of-.patch new file mode 100644 index 0000000..25ea67d --- /dev/null +++ b/SOURCES/0022-glusterd-snapshot-Return-correct-errno-in-events-of-.patch @@ -0,0 +1,1486 @@ +From 54ea9d74c5459e93608b16c7d3f762b1bc4096f3 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Tue, 5 May 2015 18:08:25 +0530 +Subject: [PATCH 22/57] glusterd/snapshot: Return correct errno in events of failure - PATCH 2 + + Backport of http://review.gluster.org/#/c/10588/ + +ENUM RETCODE ERROR +------------------------------------------------------------- +EG_INTRNL 30800 Internal Error +EG_OPNOTSUP 30801 Gluster Op Not Supported +EG_ANOTRANS 30802 Another Transaction in Progress +EG_BRCKDWN 30803 One or more brick is down +EG_NODEDWN 30804 One or more node is down +EG_HRDLMT 30805 Hard Limit is reached +EG_NOVOL 30806 Volume does not exist +EG_NOSNAP 30807 Snap does not exist +EG_RBALRUN 30808 Rebalance is running +EG_VOLRUN 30809 Volume is running +EG_VOLSTP 30810 Volume is not running +EG_VOLEXST 30811 Volume exists +EG_SNAPEXST 30812 Snapshot exists +EG_ISSNAP 30813 Volume is a snap volume +EG_GEOREPRUN 30814 Geo-Replication is running +EG_NOTTHINP 30815 Bricks are not thinly provisioned + +Change-Id: I49a170cdfd77df11fe677e09f4e063d99b159275 +BUG: 1186216 +Signed-off-by: Avra Sengupta +(cherry picked from commit 2df57ab7dc7b9d7deb0eebad96036149760d607b) +Reviewed-on: https://code.engineering.redhat.com/gerrit/50359 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + tests/basic/op_errnos.t | 38 +++++ + xlators/mgmt/glusterd/src/glusterd-errno.h | 18 ++- + xlators/mgmt/glusterd/src/glusterd-locks.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c | 29 ++-- + xlators/mgmt/glusterd/src/glusterd-mgmt.c | 48 ++++-- + xlators/mgmt/glusterd/src/glusterd-mgmt.h | 6 +- + .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 31 +++- + .../mgmt/glusterd/src/glusterd-snapshot-utils.h | 6 +- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 176 +++++++++++++++----- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 5 +- + xlators/mgmt/glusterd/src/glusterd.h | 5 +- + 11 files changed, 272 insertions(+), 92 deletions(-) + create mode 100755 tests/basic/op_errnos.t + +diff --git a/tests/basic/op_errnos.t b/tests/basic/op_errnos.t +new file mode 100755 +index 0000000..8b16267 +--- /dev/null ++++ b/tests/basic/op_errnos.t +@@ -0,0 +1,38 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../include.rc ++. $(dirname $0)/../snapshot.rc ++ ++function get-op_errno-xml() ++{ ++ $CLI $1 --xml | xmllint --format - | grep opErrno | sed 's/\(\|<\/opErrno>\)//g' ++} ++ ++cleanup; ++TEST verify_lvm_version; ++TEST glusterd; ++TEST pidof glusterd; ++ ++TEST setup_lvm 1 ++ ++TEST $CLI volume create $V0 $H0:$L1 ++TEST $CLI volume start $V0 ++TEST $CLI volume create $V1 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; ++TEST $CLI volume start $V1 ++ ++EXPECT 0 get-op_errno-xml "snapshot create snap1 $V0 no-timestamp" ++EXPECT 30806 get-op_errno-xml "snapshot create snap1 imaginary_volume" ++EXPECT 30807 get-op_errno-xml "snapshot delete imaginary_snap" ++EXPECT 30809 get-op_errno-xml "snapshot restore snap1" ++TEST $CLI volume stop $V0 ++EXPECT 30810 get-op_errno-xml "snapshot create snap1 $V0" ++TEST $CLI volume start $V0 ++EXPECT 30811 get-op_errno-xml "snapshot clone $V0 snap1" ++EXPECT 30812 get-op_errno-xml "snapshot create snap1 $V0 no-timestamp" ++EXPECT 30815 get-op_errno-xml "snapshot create snap2 $V1 no-timestamp" ++ ++EXPECT 0 get-op_errno-xml "snapshot delete snap1" ++TEST $CLI volume stop $V0 ++TEST $CLI volume stop $V1 ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-errno.h b/xlators/mgmt/glusterd/src/glusterd-errno.h +index 435b050..55d44a5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-errno.h ++++ b/xlators/mgmt/glusterd/src/glusterd-errno.h +@@ -11,8 +11,22 @@ + #define _GLUSTERD_ERRNO_H + + enum glusterd_op_errno { +- EINTRNL = 30800, /* Internal Error */ +- EANOTRANS = 30801, /* Another Transaction in Progress */ ++ EG_INTRNL = 30800, /* Internal Error */ ++ EG_OPNOTSUP = 30801, /* Gluster Op Not Supported */ ++ EG_ANOTRANS = 30802, /* Another Transaction in Progress */ ++ EG_BRCKDWN = 30803, /* One or more brick is down */ ++ EG_NODEDWN = 30804, /* One or more node is down */ ++ EG_HRDLMT = 30805, /* Hard Limit is reached */ ++ EG_NOVOL = 30806, /* Volume does not exist */ ++ EG_NOSNAP = 30807, /* Snap does not exist */ ++ EG_RBALRUN = 30808, /* Rebalance is running */ ++ EG_VOLRUN = 30809, /* Volume is running */ ++ EG_VOLSTP = 30810, /* Volume is not running */ ++ EG_VOLEXST = 30811, /* Volume exists */ ++ EG_SNAPEXST = 30812, /* Snapshot exists */ ++ EG_ISSNAP = 30813, /* Volume is a snap volume */ ++ EG_GEOREPRUN = 30814, /* Geo-Replication is running */ ++ EG_NOTTHINP = 30815, /* Bricks are not thinly provisioned */ + }; + + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c +index 0f9c2b2..bafdc53 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-locks.c ++++ b/xlators/mgmt/glusterd/src/glusterd-locks.c +@@ -554,7 +554,7 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + "Lock for %s held by %s", + name, uuid_utoa (owner)); + ret = -1; +- *op_errno = EANOTRANS; ++ *op_errno = EG_ANOTRANS; + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c +index 9ebaf00..5b7f0fa 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c +@@ -232,8 +232,9 @@ out: + + static int + glusterd_mgmt_v3_pre_validate_send_resp (rpcsvc_request_t *req, +- int32_t op, int32_t status, +- char *op_errstr, dict_t *rsp_dict) ++ int32_t op, int32_t status, ++ char *op_errstr, dict_t *rsp_dict, ++ uint32_t op_errno) + { + gd1_mgmt_v3_pre_val_rsp rsp = {{0},}; + int ret = -1; +@@ -246,6 +247,7 @@ glusterd_mgmt_v3_pre_validate_send_resp (rpcsvc_request_t *req, + rsp.op_ret = status; + glusterd_get_uuid (&rsp.uuid); + rsp.op = op; ++ rsp.op_errno = op_errno; + if (op_errstr) + rsp.op_errstr = op_errstr; + else +@@ -274,11 +276,12 @@ static int + glusterd_handle_pre_validate_fn (rpcsvc_request_t *req) + { + int32_t ret = -1; +- gd1_mgmt_v3_pre_val_req op_req = {{0},}; ++ gd1_mgmt_v3_pre_val_req op_req = {{0},}; + xlator_t *this = NULL; + char *op_errstr = NULL; + dict_t *dict = NULL; + dict_t *rsp_dict = NULL; ++ uint32_t op_errno = 0; + + this = THIS; + GF_ASSERT (this); +@@ -326,8 +329,7 @@ glusterd_handle_pre_validate_fn (rpcsvc_request_t *req) + } + + ret = gd_mgmt_v3_pre_validate_fn (op_req.op, dict, &op_errstr, +- rsp_dict); +- ++ rsp_dict, &op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_PRE_VALIDATION_FAIL, +@@ -336,8 +338,8 @@ glusterd_handle_pre_validate_fn (rpcsvc_request_t *req) + } + + ret = glusterd_mgmt_v3_pre_validate_send_resp (req, op_req.op, +- ret, op_errstr, +- rsp_dict); ++ ret, op_errstr, ++ rsp_dict, op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_OP_RESP_FAIL, +@@ -497,8 +499,9 @@ out: + + static int + glusterd_mgmt_v3_commit_send_resp (rpcsvc_request_t *req, +- int32_t op, int32_t status, +- char *op_errstr, dict_t *rsp_dict) ++ int32_t op, int32_t status, ++ char *op_errstr, uint32_t op_errno, ++ dict_t *rsp_dict) + { + gd1_mgmt_v3_commit_rsp rsp = {{0},}; + int ret = -1; +@@ -511,6 +514,7 @@ glusterd_mgmt_v3_commit_send_resp (rpcsvc_request_t *req, + rsp.op_ret = status; + glusterd_get_uuid (&rsp.uuid); + rsp.op = op; ++ rsp.op_errno = op_errno; + if (op_errstr) + rsp.op_errstr = op_errstr; + else +@@ -543,6 +547,7 @@ glusterd_handle_commit_fn (rpcsvc_request_t *req) + char *op_errstr = NULL; + dict_t *dict = NULL; + dict_t *rsp_dict = NULL; ++ uint32_t op_errno = 0; + + this = THIS; + GF_ASSERT (this); +@@ -589,7 +594,7 @@ glusterd_handle_commit_fn (rpcsvc_request_t *req) + } + + ret = gd_mgmt_v3_commit_fn (op_req.op, dict, &op_errstr, +- rsp_dict); ++ &op_errno, rsp_dict); + + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -599,8 +604,8 @@ glusterd_handle_commit_fn (rpcsvc_request_t *req) + } + + ret = glusterd_mgmt_v3_commit_send_resp (req, op_req.op, +- ret, op_errstr, +- rsp_dict); ++ ret, op_errstr, ++ op_errno, rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_OP_RESP_FAIL, +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +index 954ff03..f8e65ac 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +@@ -144,7 +144,8 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, + + int32_t + gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, +- char **op_errstr, dict_t *rsp_dict) ++ char **op_errstr, dict_t *rsp_dict, ++ uint32_t *op_errno) + { + int32_t ret = -1; + xlator_t *this = NULL; +@@ -154,11 +155,12 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, + GF_ASSERT (dict); + GF_ASSERT (op_errstr); + GF_ASSERT (rsp_dict); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + switch (op) { + case GD_OP_SNAP: + ret = glusterd_snapshot_prevalidate (dict, op_errstr, +- rsp_dict); ++ rsp_dict, op_errno); + + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, +@@ -216,7 +218,8 @@ out: + + int32_t + gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, +- char **op_errstr, dict_t *rsp_dict) ++ char **op_errstr, uint32_t *op_errno, ++ dict_t *rsp_dict) + { + int32_t ret = -1; + xlator_t *this = NULL; +@@ -225,12 +228,14 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + GF_ASSERT (rsp_dict); + + switch (op) { + case GD_OP_SNAP: + { +- ret = glusterd_snapshot (dict, op_errstr, rsp_dict); ++ ret = glusterd_snapshot (dict, op_errstr, ++ op_errno, rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_COMMIT_OP_FAIL, +@@ -683,7 +688,7 @@ out: + + int + glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, +- char **op_errstr, ++ char **op_errstr, uint32_t *op_errno, + uint32_t txn_generation) + { + int32_t ret = -1; +@@ -702,6 +707,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, + + GF_ASSERT (req_dict); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + rsp_dict = dict_new (); + if (!rsp_dict) { +@@ -713,7 +719,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, + + /* Pre Validation on local node */ + ret = gd_mgmt_v3_pre_validate_fn (op, req_dict, op_errstr, +- rsp_dict); ++ rsp_dict, op_errno); + + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -790,6 +796,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, + } + + ret = args.op_ret; ++ *op_errno = args.op_errno; + + gf_msg_debug (this->name, 0, "Sent pre valaidation req for %s " + "to %d peers. Returning %d", gd_op_list[op], peer_cnt, ret); +@@ -1191,7 +1198,8 @@ out: + + int + glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, +- char **op_errstr, uint32_t txn_generation) ++ char **op_errstr, uint32_t *op_errno, ++ uint32_t txn_generation) + { + int32_t ret = -1; + int32_t peer_cnt = 0; +@@ -1210,6 +1218,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + GF_ASSERT (op_ctx); + GF_ASSERT (req_dict); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + rsp_dict = dict_new (); + if (!rsp_dict) { +@@ -1221,7 +1230,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + + /* Commit on local node */ + ret = gd_mgmt_v3_commit_fn (op, req_dict, op_errstr, +- rsp_dict); ++ op_errno, rsp_dict); + + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -1298,6 +1307,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + } + + ret = args.op_ret; ++ *op_errno = args.op_errno; + + gf_msg_debug (this->name, 0, "Sent commit req for %s to %d " + "peers. Returning %d", gd_op_list[op], peer_cnt, ret); +@@ -1801,7 +1811,7 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op, + + /* PRE-COMMIT VALIDATE PHASE */ + ret = glusterd_mgmt_v3_pre_validate (op, req_dict, &op_errstr, +- txn_generation); ++ &op_errno, txn_generation); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_PRE_VALIDATION_FAIL, "Pre Validation Failed"); +@@ -1810,7 +1820,7 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op, + + /* COMMIT OP PHASE */ + ret = glusterd_mgmt_v3_commit (op, dict, req_dict, &op_errstr, +- txn_generation); ++ &op_errno, txn_generation); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_COMMIT_OP_FAIL, "Commit Op Failed"); +@@ -1850,8 +1860,8 @@ out: + } + } + +- if (ret && (op_errno == 0)) +- op_errno = EINTRNL; ++ if (op_ret && (op_errno == 0)) ++ op_errno = EG_INTRNL; + + /* SEND CLI RESPONSE */ + glusterd_op_send_cli_response (op, op_ret, op_errno, req, +@@ -2035,7 +2045,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, + + /* PRE-COMMIT VALIDATE PHASE */ + ret = glusterd_mgmt_v3_pre_validate (op, req_dict, &op_errstr, +- txn_generation); ++ &op_errno, txn_generation); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_PRE_VALIDATION_FAIL, "Pre Validation Failed"); +@@ -2043,7 +2053,8 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, + } + + /* quorum check of the volume is done here */ +- ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr); ++ ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr, ++ &op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_QUORUM_CHECK_FAIL, "Volume quorum check failed"); +@@ -2095,7 +2106,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, + } + + ret = glusterd_mgmt_v3_commit (op, dict, req_dict, &op_errstr, +- txn_generation); ++ &op_errno, txn_generation); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_COMMIT_OP_FAIL, "Commit Op Failed"); +@@ -2134,7 +2145,8 @@ unbarrier: + /*Do a quorum check if the commit phase is successful*/ + if (success) { + //quorum check of the snapshot volume +- ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr); ++ ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr, ++ &op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_QUORUM_CHECK_FAIL, +@@ -2189,8 +2201,8 @@ out: + } + } + +- if (ret && (op_errno == 0)) +- op_errno = EINTRNL; ++ if (op_ret && (op_errno == 0)) ++ op_errno = EG_INTRNL; + + /* SEND CLI RESPONSE */ + glusterd_op_send_cli_response (op, op_ret, op_errno, req, +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-mgmt.h +index 894bd19..a9812a4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.h +@@ -21,7 +21,8 @@ void gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, + + int32_t + gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, +- char **op_errstr, dict_t *rsp_dict); ++ char **op_errstr, dict_t *rsp_dict, ++ uint32_t *op_errno); + + int32_t + gd_mgmt_v3_brick_op_fn (glusterd_op_t op, dict_t *dict, +@@ -29,7 +30,8 @@ gd_mgmt_v3_brick_op_fn (glusterd_op_t op, dict_t *dict, + + int32_t + gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, +- char **op_errstr, dict_t *rsp_dict); ++ char **op_errstr, uint32_t *op_errno, ++ dict_t *rsp_dict); + + int32_t + gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +index f666d4c..294758b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +@@ -33,6 +33,7 @@ + #include "glusterd-snapshot-utils.h" + #include "glusterd-server-quorum.h" + #include "glusterd-messages.h" ++#include "glusterd-errno.h" + + /* + * glusterd_snap_geo_rep_restore: +@@ -2620,7 +2621,8 @@ gf_boolean_t + glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict, + int down_count, gf_boolean_t first_brick_on, + int8_t snap_force, int quorum_count, +- char *quorum_type, char **op_errstr) ++ char *quorum_type, char **op_errstr, ++ uint32_t *op_errno) + { + gf_boolean_t quorum_met = _gf_false; + char err_str[PATH_MAX] = {0, }; +@@ -2629,6 +2631,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict, + + this = THIS; + GF_ASSERT (this); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!volinfo || !dict) { + gf_msg (this->name, GF_LOG_WARNING, 0, +@@ -2647,6 +2650,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_DISCONNECTED, "%s", err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_BRCKDWN; + goto out; + } + +@@ -2678,6 +2682,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_BRCKDWN; + } + + out: +@@ -2688,7 +2693,8 @@ int32_t + glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index, + dict_t *dict, char *key_prefix, + int8_t snap_force, int quorum_count, +- char *quorum_type, char **op_errstr) ++ char *quorum_type, char **op_errstr, ++ uint32_t *op_errno) + { + int ret = 0; + xlator_t *this = NULL; +@@ -2707,6 +2713,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index, + GF_ASSERT (this); + priv = this->private; + GF_ASSERT (priv); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!volinfo || !dict) { + gf_msg (this->name, GF_LOG_WARNING, 0, +@@ -2734,6 +2741,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index, + 0, GD_MSG_SERVER_QUORUM_NOT_MET, "%s", + err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_BRCKDWN; + goto out; + } + } +@@ -2770,7 +2778,8 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index, + snap_force, + quorum_count, + quorum_type, +- op_errstr); ++ op_errstr, ++ op_errno); + /* goto out if quorum is not met */ + if (!quorum_met) { + ret = -1; +@@ -2794,7 +2803,7 @@ out: + + int32_t + glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, +- char **op_errstr) ++ char **op_errstr, uint32_t *op_errno) + { + int8_t snap_force = 0; + int32_t force = 0; +@@ -2815,6 +2824,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, + + this = THIS; + GF_ASSERT (this); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!dict) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -2855,6 +2865,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_NODEDWN; + ret = -1; + goto out; + } else +@@ -2978,7 +2989,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, + snap_force, + quorum_count, + quorum_type, +- op_errstr); ++ op_errstr, ++ op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_VOL_NOT_FOUND, "volume %s " +@@ -2992,7 +3004,7 @@ out: + + int32_t + glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, +- char **op_errstr) ++ char **op_errstr, uint32_t *op_errno) + { + int32_t ret = -1; + xlator_t *this = NULL; +@@ -3001,6 +3013,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, + + this = THIS; + GF_ASSERT (this); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!dict) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -3008,7 +3021,6 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, + goto out; + } + +- + ret = dict_get_int32 (dict, "type", &snap_command); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -3020,7 +3032,8 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, + switch (snap_command) { + case GF_SNAP_OPTION_TYPE_CREATE: + ret = glusterd_snap_quorum_check_for_create (dict, snap_volume, +- op_errstr); ++ op_errstr, ++ op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_QUORUM_CHECK_FAIL, "Quorum check" +@@ -3038,6 +3051,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, + GD_MSG_SERVER_QUORUM_NOT_MET, "%s", + err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_NODEDWN; + goto out; + } + +@@ -3054,6 +3068,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, + GD_MSG_SERVER_QUORUM_NOT_MET, "%s", + err_str); + *op_errstr = gf_strdup (err_str); ++ *op_errno = EG_NODEDWN; + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h +index 68906dc..ce8d7d4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h +@@ -120,11 +120,7 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, + + int32_t + glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, +- char **op_errstr); +- +-int32_t +-glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, +- char **op_errstr); ++ char **op_errstr, uint32_t *op_errno); + + int32_t + glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index e5a7cac..668c26e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -20,6 +20,7 @@ + #include + #include + #include "glusterd-messages.h" ++#include "glusterd-errno.h" + + #if defined(GF_LINUX_HOST_OS) + #include +@@ -932,7 +933,7 @@ out: + */ + int32_t + glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ uint32_t *op_errno, dict_t *rsp_dict) + { + int ret = -1; + int32_t i = 0; +@@ -952,6 +953,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + GF_ASSERT (rsp_dict); + + ret = dict_get_str (dict, "snapname", &snapname); +@@ -966,6 +968,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, + if (NULL == snap) { + ret = gf_asprintf (op_errstr, "Snapshot (%s) does not exist", + snapname); ++ *op_errno = EG_SNAPEXST; + if (ret < 0) { + goto out; + } +@@ -1021,6 +1024,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, + if (ret) { + ret = gf_asprintf (op_errstr, "Volume (%s) " + "does not exist", volname); ++ *op_errno = EG_NOVOL; + if (ret < 0) { + goto out; + } +@@ -1034,6 +1038,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, + ret = gf_asprintf (op_errstr, "Volume (%s) has been " + "started. Volume needs to be stopped before restoring " + "a snapshot.", volname); ++ *op_errno = EG_VOLRUN; + if (ret < 0) { + goto out; + } +@@ -1214,7 +1219,8 @@ out: + } + + int +-glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) ++glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr, ++ uint32_t *op_errno) + { + char *volname = NULL; + glusterd_volinfo_t *volinfo = NULL; +@@ -1237,6 +1243,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + conf = this->private; + +@@ -1260,6 +1267,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + if (ret) { + snprintf (err_str, sizeof (err_str), + "Volume (%s) does not exist.", volname); ++ *op_errno = EG_NOVOL; + goto out; + } + } +@@ -1278,6 +1286,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_HARD_LIMIT_SET_FAIL, + "snap-max-hard-limit validation failed."); ++ *op_errno = EINVAL; + goto out; + } + } +@@ -1290,6 +1299,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + "snap-max-soft-limit ""%" + PRIu64 ". Expected range 1 - %"PRIu64, + soft_limit, max_limit); ++ *op_errno = EINVAL; + goto out; + } + } +@@ -1307,6 +1317,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + ret = -1; + snprintf (err_str, sizeof (err_str), "Please enter a " + "valid boolean value for auto-delete"); ++ *op_errno = EINVAL; + goto out; + } + +@@ -1324,6 +1335,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + else + snprintf (err_str, sizeof (err_str), + "auto-delete is already disabled"); ++ *op_errno = EINVAL; + goto out; + } + } else if (dict_get(dict, GLUSTERD_STORE_KEY_SNAP_ACTIVATE)) { +@@ -1334,6 +1346,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + ret = -1; + snprintf (err_str, sizeof (err_str), "Please enter a " + "valid boolean value for activate-on-create"); ++ *op_errno = EINVAL; + goto out; + } + +@@ -1351,11 +1364,13 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) + else + snprintf (err_str, sizeof (err_str), + "activate-on-create is already disabled"); ++ *op_errno = EINVAL; + goto out; + } + } else { + ret = -1; + snprintf (err_str, sizeof (err_str), "Invalid option"); ++ *op_errno = EINVAL; + goto out; + } + +@@ -1871,7 +1886,7 @@ out: + * @return _gf_true if LV is thin else _gf_false + */ + gf_boolean_t +-glusterd_is_thinp_brick (char *device) ++glusterd_is_thinp_brick (char *device, uint32_t *op_errno) + { + int ret = -1; + char msg [1024] = ""; +@@ -1885,6 +1900,7 @@ glusterd_is_thinp_brick (char *device) + + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + GF_VALIDATE_OR_GOTO (this->name, device, out); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + snprintf (msg, sizeof (msg), "Get thin pool name for device %s", + device); +@@ -1929,14 +1945,21 @@ glusterd_is_thinp_brick (char *device) + } + + out: ++ if (!is_thin) ++ *op_errno = EG_NOTTHINP; ++ + return is_thin; + } + + int + glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, +- char *snapname, char *err_str, char *snap_volname, int64_t volcount, +- glusterd_volinfo_t *volinfo, gf_loglevel_t *loglevel, int clone) { +- ++ char *snapname, char *err_str, ++ char *snap_volname, ++ int64_t volcount, ++ glusterd_volinfo_t *volinfo, ++ gf_loglevel_t *loglevel, ++ int clone, uint32_t *op_errno) ++{ + char *device = NULL; + char key[PATH_MAX] = ""; + int ret = -1; +@@ -1950,6 +1973,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, + this = THIS; + conf = this->private; + GF_ASSERT (conf); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!snapname || !volinfo) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, +@@ -1996,6 +2020,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, + "and then issue snapshot clone " + "command "); + } ++ *op_errno = EG_BRCKDWN; + ret = -1; + goto out; + } +@@ -2012,7 +2037,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, + goto out; + } + if (!clone) { +- if (!glusterd_is_thinp_brick (device)) { ++ if (!glusterd_is_thinp_brick (device, op_errno)) { + snprintf (err_str, PATH_MAX, + "Snapshot is supported only for " + "thin provisioned LV. Ensure that " +@@ -2138,7 +2163,7 @@ out: + + int + glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ dict_t *rsp_dict, uint32_t *op_errno) + { + char *clonename = NULL; + char *snapname = NULL; +@@ -2155,6 +2180,7 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr, + this = THIS; + GF_ASSERT (op_errstr); + GF_ASSERT (dict); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + ret = dict_get_str (dict, "clonename", &clonename); + if (ret) { +@@ -2173,6 +2199,7 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr, + ret = -1; + snprintf (err_str, sizeof (err_str), "Volume with name:%s " + "already exists", clonename); ++ *op_errno = EG_VOLEXST; + goto out; + } + /* need to find snap volinfo*/ +@@ -2205,14 +2232,19 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr, + goto out; + } + +- + /* Adding snap bricks mount paths to the dict */ + ret = glusterd_snap_create_clone_common_prevalidate (rsp_dict, 0, +- snapname, err_str, clonename, 1, snap_vol, +- &loglevel, 1); ++ snapname, err_str, ++ clonename, 1, ++ snap_vol, ++ &loglevel, ++ 1, op_errno); + if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PRE_VALIDATION_FAIL, "Failed to pre validate"); + goto out; + } ++ + ret = dict_set_int64 (rsp_dict, "volcount", volcount); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -2236,7 +2268,7 @@ out: + + int + glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ dict_t *rsp_dict, uint32_t *op_errno) + { + char *volname = NULL; + char *snapname = NULL; +@@ -2259,6 +2291,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + GF_ASSERT (op_errstr); + conf = this->private; + GF_ASSERT (conf); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + ret = dict_get_int64 (dict, "volcount", &volcount); + if (ret) { +@@ -2290,6 +2323,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + ret = -1; + snprintf (err_str, sizeof (err_str), "Snapshot %s already " + "exists", snapname); ++ *op_errno = EG_SNAPEXST; + goto out; + } + +@@ -2305,6 +2339,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + if (ret) { + snprintf (err_str, sizeof (err_str), + "Volume (%s) does not exist ", volname); ++ *op_errno = EG_NOVOL; + goto out; + } + +@@ -2313,6 +2348,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + snprintf (err_str, sizeof (err_str), "volume %s is " + "not started", volinfo->volname); + loglevel = GF_LOG_WARNING; ++ *op_errno = EG_VOLSTP; + goto out; + } + +@@ -2321,6 +2357,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + "rebalance process is running for the " + "volume %s", volname); + loglevel = GF_LOG_WARNING; ++ *op_errno = EG_RBALRUN; + goto out; + } + +@@ -2331,6 +2368,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + "stopped before taking a snapshot.", + volname); + loglevel = GF_LOG_WARNING; ++ *op_errno = EG_GEOREPRUN; + goto out; + } + +@@ -2338,6 +2376,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + snprintf (err_str, sizeof (err_str), + "Volume %s is a snap volume", volname); + loglevel = GF_LOG_WARNING; ++ *op_errno = EG_ISSNAP; + goto out; + } + +@@ -2369,6 +2408,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + "snapshots before taking further snapshots.", + effective_max_limit, volname); + loglevel = GF_LOG_WARNING; ++ *op_errno = EG_HRDLMT; + goto out; + } + +@@ -2387,8 +2427,14 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, + GLUSTERD_GET_UUID_NOHYPHEN (snap_volname, *snap_volid); + + ret = glusterd_snap_create_clone_common_prevalidate (rsp_dict, +- flags, snapname, err_str, snap_volname, i, +- volinfo, &loglevel, 0); ++ flags, ++ snapname, ++ err_str, ++ snap_volname, ++ i, ++ volinfo, ++ &loglevel, ++ 0, op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_PRE_VALIDATION_FAIL, +@@ -3718,7 +3764,8 @@ out: + + int + glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, +- dict_t *dict, char *err_str, size_t len) ++ dict_t *dict, char *err_str, size_t len, ++ uint32_t *op_errno) + { + int ret = -1; + char *volname = NULL; +@@ -3729,6 +3776,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, + + GF_VALIDATE_OR_GOTO (this->name, req, out); + GF_VALIDATE_OR_GOTO (this->name, dict, out); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + /* Ignore error for getting volname as it is optional */ + ret = dict_get_str (dict, "volname", &volname); +@@ -3749,6 +3797,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_VOL_NOT_FOUND, + "%s", err_str); ++ *op_errno = EG_NOVOL; + goto out; + } + +@@ -4183,7 +4232,8 @@ out: + */ + int + glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op, +- dict_t *dict, char *err_str, size_t len) ++ dict_t *dict, char *err_str, ++ uint32_t *op_errno, size_t len) + { + int ret = -1; + char *snapname = NULL; +@@ -4216,6 +4266,7 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op, + if (!snap) { + snprintf (err_str, len, "Snapshot (%s) does not exist", + snapname); ++ *op_errno = EG_NOSNAP; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_SNAP_NOT_FOUND, "%s", err_str); + ret = -1; +@@ -5153,7 +5204,10 @@ out: + * */ + int + glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict, +- char **op_errstr, dict_t *rsp_dict, gf_boolean_t is_op_activate) ++ char **op_errstr, ++ uint32_t *op_errno, ++ dict_t *rsp_dict, ++ gf_boolean_t is_op_activate) + { + int32_t ret = -1; + char *snapname = NULL; +@@ -5166,6 +5220,8 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict, + int flags = 0; + + this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!dict || !op_errstr) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -5185,6 +5241,7 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict, + if (!snap) { + snprintf (err_str, sizeof (err_str), "Snapshot (%s) does not " + "exist.", snapname); ++ *op_errno = EG_NOSNAP; + ret = -1; + goto out; + } +@@ -5231,11 +5288,13 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict, + snprintf (err_str, sizeof (err_str), + "Snapshot %s is already activated.", + snapname); ++ *op_errno = EINVAL; + ret = -1; + } + } else { + snprintf (err_str, sizeof (err_str), + "Snapshot %s is already deactivated.", snapname); ++ *op_errno = EINVAL; + ret = -1; + } + goto out; +@@ -5253,7 +5312,8 @@ out: + } + + int32_t +-glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, int len) ++glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, ++ uint32_t *op_errno, int len) + { + int32_t ret = -1; + int32_t i = 0; +@@ -5267,6 +5327,7 @@ glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, int len) + this = THIS; + GF_ASSERT (this); + GF_ASSERT (dict); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +@@ -5279,6 +5340,7 @@ glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, int len) + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + snprintf (err_str, len, "Volume (%s) does not exist", volname); ++ *op_errno = EG_NOVOL; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_VOL_NOT_FOUND, "Failed to get volinfo of " + "volume %s", volname); +@@ -5354,7 +5416,7 @@ int32_t + glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req, + glusterd_op_t op, + dict_t *dict, char *err_str, +- size_t len) ++ uint32_t *op_errno, size_t len) + { + int32_t ret = -1; + int64_t volcount = 0; +@@ -5384,6 +5446,7 @@ glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req, + if (!snap) { + snprintf (err_str, len, "Snapshot (%s) does not exist", + snapname); ++ *op_errno = EG_NOSNAP; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_SNAP_NOT_FOUND, "%s", err_str); + ret = -1; +@@ -5448,7 +5511,8 @@ out : + */ + int + glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, +- dict_t *dict, char *err_str, size_t len) ++ dict_t *dict, char *err_str, ++ uint32_t *op_errno, size_t len) + { + int ret = -1; + xlator_t *this = NULL; +@@ -5461,6 +5525,7 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, + GF_ASSERT (req); + GF_ASSERT (dict); + GF_ASSERT (err_str); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + ret = dict_get_int32 (dict, "delete-cmd", &delete_cmd); + if (ret) { +@@ -5472,7 +5537,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, + switch (delete_cmd) { + case GF_SNAP_DELETE_TYPE_SNAP: + ret = glusterd_handle_snapshot_delete_type_snap (req, op, dict, +- err_str, len); ++ err_str, ++ op_errno, len); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SNAP_REMOVE_FAIL, "Failed to handle " +@@ -5492,7 +5558,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, + break; + + case GF_SNAP_DELETE_TYPE_VOL: +- ret = glusterd_handle_snapshot_delete_vol (dict, err_str, len); ++ ret = glusterd_handle_snapshot_delete_vol (dict, err_str, ++ op_errno, len); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SNAP_REMOVE_FAIL, "Failed to handle " +@@ -5502,6 +5569,7 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, + break; + + default: ++ *op_errno = EINVAL; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_INVALID_ENTRY, "Wrong snapshot delete type"); + break; +@@ -5525,7 +5593,7 @@ out: + + int + glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ uint32_t *op_errno, dict_t *rsp_dict) + { + int32_t ret = -1; + char *snapname = NULL; +@@ -5533,6 +5601,8 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr, + glusterd_snap_t *snap = NULL; + + this = THIS; ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + if (!dict || !op_errstr) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -5553,6 +5623,7 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr, + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_SNAP_NOT_FOUND, + "Snapshot (%s) does not exist", snapname); ++ *op_errno = EG_NOSNAP; + ret = -1; + goto out; + } +@@ -5574,7 +5645,7 @@ out: + + int + glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ uint32_t *op_errno, dict_t *rsp_dict) + { + int ret = -1; + char *snapname = NULL; +@@ -5587,9 +5658,10 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, + this = THIS; + GF_ASSERT (this); + conf = this->private; +- + GF_ASSERT (conf); + GF_ASSERT (op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); ++ + if (!dict) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Input dict is NULL"); +@@ -5622,6 +5694,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, + if (!glusterd_find_snap_by_name (snapname)) { + ret = gf_asprintf (op_errstr, "Snapshot (%s) " + "does not exist", snapname); ++ *op_errno = EG_NOSNAP; + if (ret < 0) { + goto out; + } +@@ -5648,6 +5721,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, + if (ret) { + ret = gf_asprintf (op_errstr, "Volume (%s) " + "does not exist", volname); ++ *op_errno = EG_NOVOL; + if (ret < 0) { + goto out; + } +@@ -5664,6 +5738,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, + { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_COMMAND_NOT_FOUND, "Invalid command"); ++ *op_errno = EINVAL; + break; + } + } +@@ -6440,7 +6515,7 @@ out: + + int32_t + glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ uint32_t *op_errno, dict_t *rsp_dict) + { + int ret = -1; + int64_t i = 0; +@@ -6461,6 +6536,7 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr, + GF_ASSERT(this); + GF_ASSERT(dict); + GF_ASSERT(op_errstr); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + GF_ASSERT(rsp_dict); + priv = this->private; + GF_ASSERT(priv); +@@ -7859,7 +7935,8 @@ out: + } + + int32_t +-glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ++glusterd_snapshot (dict_t *dict, char **op_errstr, ++ uint32_t *op_errno, dict_t *rsp_dict) + { + + xlator_t *this = NULL; +@@ -7874,6 +7951,7 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (rsp_dict); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + priv = this->private; + GF_ASSERT (priv); +@@ -7890,7 +7968,7 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + case (GF_SNAP_OPTION_TYPE_CREATE): + ret = glusterd_snapshot_create_commit (dict, op_errstr, +- rsp_dict); ++ op_errno, rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SNAP_CREATION_FAIL, "Failed to " +@@ -8120,7 +8198,7 @@ out: + + int + glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict) ++ dict_t *rsp_dict, uint32_t *op_errno) + { + int snap_command = 0; + xlator_t *this = NULL; +@@ -8131,6 +8209,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (rsp_dict); ++ GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + + ret = dict_get_int32 (dict, "type", &snap_command); + if (ret) { +@@ -8143,7 +8222,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + switch (snap_command) { + case (GF_SNAP_OPTION_TYPE_CREATE): + ret = glusterd_snapshot_create_prevalidate (dict, op_errstr, +- rsp_dict); ++ rsp_dict, op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_CREATION_FAIL, "Snapshot create " +@@ -8154,7 +8233,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + + case (GF_SNAP_OPTION_TYPE_CLONE): + ret = glusterd_snapshot_clone_prevalidate (dict, op_errstr, +- rsp_dict); ++ rsp_dict, op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_CLONE_PREVAL_FAILED, +@@ -8166,7 +8245,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + + + case (GF_SNAP_OPTION_TYPE_CONFIG): +- ret = glusterd_snapshot_config_prevalidate (dict, op_errstr); ++ ret = glusterd_snapshot_config_prevalidate (dict, op_errstr, ++ op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_CONFIG_FAIL, "Snapshot config " +@@ -8177,6 +8257,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + + case GF_SNAP_OPTION_TYPE_RESTORE: + ret = glusterd_snapshot_restore_prevalidate (dict, op_errstr, ++ op_errno, + rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, +@@ -8188,7 +8269,10 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + + case GF_SNAP_OPTION_TYPE_ACTIVATE: + ret = glusterd_snapshot_activate_deactivate_prevalidate (dict, +- op_errstr, rsp_dict, _gf_true); ++ op_errstr, ++ op_errno, ++ rsp_dict, ++ _gf_true); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_ACTIVATE_FAIL, "Snapshot activate " +@@ -8198,7 +8282,10 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + break; + case GF_SNAP_OPTION_TYPE_DEACTIVATE: + ret = glusterd_snapshot_activate_deactivate_prevalidate (dict, +- op_errstr, rsp_dict, _gf_false); ++ op_errstr, ++ op_errno, ++ rsp_dict, ++ _gf_false); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_DEACTIVATE_FAIL, +@@ -8208,7 +8295,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + break; + case GF_SNAP_OPTION_TYPE_DELETE: + ret = glusterd_snapshot_remove_prevalidate (dict, op_errstr, +- rsp_dict); ++ op_errno, rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_REMOVE_FAIL, "Snapshot remove " +@@ -8219,7 +8306,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + + case GF_SNAP_OPTION_TYPE_STATUS: + ret = glusterd_snapshot_status_prevalidate (dict, op_errstr, +- rsp_dict); ++ op_errno, rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_STATUS_FAIL, "Snapshot status " +@@ -8231,6 +8318,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, + default: + gf_msg (this->name, GF_LOG_WARNING, EINVAL, + GD_MSG_COMMAND_NOT_FOUND, "invalid snap command"); ++ *op_errno = EINVAL; + goto out; + } + +@@ -8709,6 +8797,7 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + char *host_uuid = NULL; + char err_str[2048] = {0,}; + xlator_t *this = NULL; ++ uint32_t op_errno = 0; + + GF_ASSERT (req); + +@@ -8768,6 +8857,7 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + snprintf (err_str, sizeof (err_str), "Cluster operating version" + " is lesser than the supported version " + "for a snapshot"); ++ op_errno = EG_OPNOTSUP; + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNSUPPORTED_VERSION, + "%s (%d < %d)", err_str, +@@ -8816,7 +8906,8 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + + case GF_SNAP_OPTION_TYPE_RESTORE: + ret = glusterd_handle_snapshot_restore (req, cli_op, dict, +- err_str, sizeof (err_str)); ++ err_str, &op_errno, ++ sizeof (err_str)); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_RESTORE_FAIL, +@@ -8835,7 +8926,8 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + break; + case GF_SNAP_OPTION_TYPE_LIST: + ret = glusterd_handle_snapshot_list (req, cli_op, dict, +- err_str, sizeof (err_str)); ++ err_str, sizeof (err_str), ++ &op_errno); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_LIST_GET_FAIL, +@@ -8853,7 +8945,7 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + break; + case GF_SNAP_OPTION_TYPE_DELETE: + ret = glusterd_handle_snapshot_delete (req, cli_op, dict, +- err_str, ++ err_str, &op_errno, + sizeof (err_str)); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, +@@ -8901,7 +8993,11 @@ out: + if (err_str[0] == '\0') + snprintf (err_str, sizeof (err_str), + "Operation failed"); +- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, ++ ++ if (ret && (op_errno == 0)) ++ op_errno = EG_INTRNL; ++ ++ ret = glusterd_op_send_cli_response (cli_op, ret, op_errno, req, + dict, err_str); + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index d7d75bb..da12cba 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -22,6 +22,7 @@ + #include "glusterd-locks.h" + #include "glusterd-snapshot-utils.h" + #include "glusterd-messages.h" ++#include "glusterd-errno.h" + + extern glusterd_op_info_t opinfo; + +@@ -1883,8 +1884,8 @@ out: + uuid_utoa (*txn_id)); + } + +- if (ret && (op_errno == 0)) +- op_errno = -1; ++ if (op_ret && (op_errno == 0)) ++ op_errno = EG_INTRNL; + + glusterd_op_send_cli_response (op, op_ret, op_errno, req, + op_ctx, op_errstr); +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index 5b5edfd..59234bc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -1096,11 +1096,12 @@ glusterd_find_snap_by_id (uuid_t snap_id); + + int + glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr, +- dict_t *rsp_dict); ++ dict_t *rsp_dict, uint32_t *op_errno); + int + glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict); + int +-glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict); ++glusterd_snapshot (dict_t *dict, char **op_errstr, ++ uint32_t *op_errno, dict_t *rsp_dict); + int + glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr, + dict_t *rsp_dict); +-- +1.7.1 + diff --git a/SOURCES/0023-snapshot-Fix-finding-brick-mount-path-logic.patch b/SOURCES/0023-snapshot-Fix-finding-brick-mount-path-logic.patch new file mode 100644 index 0000000..1d45e25 --- /dev/null +++ b/SOURCES/0023-snapshot-Fix-finding-brick-mount-path-logic.patch @@ -0,0 +1,173 @@ +From 9ca7f82bed06ec521295de2d78abd688143d15a9 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 3 Jun 2015 15:18:08 +0530 +Subject: [PATCH 23/57] snapshot: Fix finding brick mount path logic + + Backport of http://review.gluster.org/#/c/11060/ + +Previously while finding brick mount paths +of snap volume's bricks, we were taking brick order +into consideration. This logic fails when a brick is +removed or a tier is added. + +Hence modifying the logic to look for the first +occurence of the word "brick" in the brick path. +From there we iterate till we find a '/'. The string +till the first '/' after we encounter the word brick +is the brick mount path. + +Change-Id: Ic85983c4e975e701cdfd4e13f8e276ac391a3e49 +BUG: 1224175 +Signed-off-by: Avra Sengupta +(cherry picked from commit bf3a6dcdf3c8a8a64e7c864b56c4d9be60fca8e6) +Reviewed-on: https://code.engineering.redhat.com/gerrit/50360 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + tests/bugs/snapshot/bug-1227646.t | 32 +++++++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 1 - + xlators/mgmt/glusterd/src/glusterd-store.c | 22 +++++++--------- + xlators/mgmt/glusterd/src/glusterd-utils.h | 4 +- + 4 files changed, 44 insertions(+), 15 deletions(-) + create mode 100644 tests/bugs/snapshot/bug-1227646.t + +diff --git a/tests/bugs/snapshot/bug-1227646.t b/tests/bugs/snapshot/bug-1227646.t +new file mode 100644 +index 0000000..643d814 +--- /dev/null ++++ b/tests/bugs/snapshot/bug-1227646.t +@@ -0,0 +1,32 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../snapshot.rc ++. $(dirname $0)/../../include.rc ++ ++cleanup; ++ ++TEST init_n_bricks 3; ++TEST setup_lvm 3; ++ ++TEST glusterd; ++TEST pidof glusterd; ++ ++#TEST $CLI volume create $V0 $H0:$L1 $H0:$L2 $H0:$L3; ++TEST $CLI volume create $V0 $H0:$L2 $H0:$L3; ++TEST $CLI volume start $V0; ++ ++TEST $CLI snapshot create snap1 $V0 no-timestamp; ++TEST $CLI volume stop $V0 ++TEST $CLI snapshot restore snap1; ++TEST $CLI volume start $V0 ++TEST $CLI volume attach-tier $V0 $H0:$L1 $H0:$L2 ++ ++TEST pkill gluster ++TEST glusterd ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status' ++ ++TEST $CLI volume stop $V0 ++ ++cleanup ; ++ +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 668c26e..0ea3935 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -2721,7 +2721,6 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol) + + /* Fetch the brick mount path from the brickinfo->path */ + ret = glusterd_find_brick_mount_path (brickinfo->path, +- brick_count + 1, + &brick_mount_path); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index cb312ae..ee279d3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -2972,11 +2972,10 @@ out: + + /* Figure out the brick mount path, from the brick path */ + int32_t +-glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, +- char **brick_mount_path) ++glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path) + { +- char brick_num[PATH_MAX] = ""; + char *ptr = NULL; ++ char *save_ptr = NULL; + int32_t ret = -1; + xlator_t *this = NULL; + +@@ -2991,12 +2990,10 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, + goto out; + } + +- snprintf (brick_num, sizeof(brick_num), "brick%d", brick_count); +- + /* Finding the pointer to the end of + * /var/run/gluster/snaps/ + */ +- ptr = strstr (*brick_mount_path, brick_num); ++ ptr = strstr (*brick_mount_path, "brick"); + if (!ptr) { + /* Snapshot bricks must have brick num as part + * of the brickpath +@@ -3011,8 +3008,13 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, + * /var/run/gluster/snaps// + * and assigning '\0' to it. + */ +- ptr += strlen(brick_num); +- *ptr = '\0'; ++ while ((*ptr != '\0') && (*ptr != '/')) ++ ptr++; ++ ++ if (*ptr == '/') { ++ ptr++; ++ *ptr = '\0'; ++ } + + ret = 0; + out: +@@ -3096,15 +3098,12 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, + char *brick_mount_path = NULL; + glusterd_brickinfo_t *brickinfo = NULL; + int32_t ret = -1; +- int32_t brick_count = -1; + struct stat st_buf = {0, }; + + GF_ASSERT (this); + GF_ASSERT (volinfo); + +- brick_count = 0; + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { +- brick_count++; + /* If the brick is not of this node, or its + * snapshot is pending, or the brick is not + * a snapshotted brick, we continue +@@ -3116,7 +3115,6 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, + + /* Fetch the brick mount path from the brickinfo->path */ + ret = glusterd_find_brick_mount_path (brickinfo->path, +- brick_count, + &brick_mount_path); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h +index d617f60..27c51fa 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.h +@@ -582,8 +582,8 @@ int + glusterd_unlink_file (char *sock_file_path); + + int32_t +-glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, +- char **brick_mount_path); ++glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path); ++ + /* + * Function to retrieve list of snap volnames and their uuids + */ +-- +1.7.1 + diff --git a/SOURCES/0024-bitrot-glusterd-scrub-option-should-be-disabled-once.patch b/SOURCES/0024-bitrot-glusterd-scrub-option-should-be-disabled-once.patch new file mode 100644 index 0000000..7f79289 --- /dev/null +++ b/SOURCES/0024-bitrot-glusterd-scrub-option-should-be-disabled-once.patch @@ -0,0 +1,53 @@ +From ed87ccca25f1119726b47fed6766a1403e9b18ab Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Wed, 27 May 2015 14:36:24 +0530 +Subject: [PATCH 24/57] bitrot/glusterd: scrub option should be disabled once bitrot option is reset + +Scrubber options should be disabled from the dictionary if user reset +bitrot option. + +BUG: 1224161 +Change-Id: I2a74497dce40a17dc64367a3d3f039fb414262e1 +Signed-off-by: Gaurav Kumar Garg +upstream-review-url: http://review.gluster.org/#/c/10936/ +Reviewed-on: https://code.engineering.redhat.com/gerrit/50099 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 7 +++++++ + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 1 + + 2 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 9b9684e..e304cb0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -1696,6 +1696,13 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data) + gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s", + key, value->data); + dict_del (this, key); ++ /**Delete scrubber (pause/resume) option from the dictionary if bitrot ++ * option is going to be reset ++ * */ ++ if (!strncmp (key, VKEY_FEATURES_BITROT, ++ strlen (VKEY_FEATURES_BITROT))) { ++ dict_del (this, VKEY_FEATURES_SCRUB); ++ } + out: + return 0; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 65cbfc0..9b9f544 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1857,6 +1857,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/bitrot", + .option = "scrubber", + .op_version = GD_OP_VERSION_3_7_0, ++ .flags = OPT_FLAG_FORCE, + .type = NO_DOC, + }, + /* Upcall translator options */ +-- +1.7.1 + diff --git a/SOURCES/0025-glusterd-fix-repeated-connection-to-nfssvc-failed-ms.patch b/SOURCES/0025-glusterd-fix-repeated-connection-to-nfssvc-failed-ms.patch new file mode 100644 index 0000000..81e936a --- /dev/null +++ b/SOURCES/0025-glusterd-fix-repeated-connection-to-nfssvc-failed-ms.patch @@ -0,0 +1,115 @@ +From 33509513fc32c010b81716128fb3d0d19d7731c6 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Tue, 19 May 2015 14:48:01 +0530 +Subject: [PATCH 25/57] glusterd: fix repeated connection to nfssvc failed msgs + +... and disable reconnect timer on rpc_clnt_disconnect. + +Root Cause +---------- + +gluster-NFS service wouldn't be started if there are no +started volumes that have nfs service enabled for them. +Before this fix we would initiate a connect even when +the gluster-NFS service wasn't (re)started. Compounding +that glusterd_conn_disconnect doesn't disable reconnect +timer. So, it is possible that the reconnect timer was +in execution when the timer event was attempted to be +removed. + +Change-Id: Iadcb5cff9eafefa95eaf3a1a9413eeb682d3aaac +BUG: 1227179 +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: http://review.gluster.org/10830 +Reviewed-by: Atin Mukherjee +Reviewed-by: Gaurav Kumar Garg +Reviewed-by: Kaushal M +Reviewed-on: http://review.gluster.org/10963 +Reviewed-by: Emmanuel Dreyfus +Reviewed-on: https://code.engineering.redhat.com/gerrit/50387 +Tested-by: Atin Mukherjee +--- + rpc/rpc-lib/src/rpc-clnt.c | 6 ++++++ + xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c | 1 - + xlators/mgmt/glusterd/src/glusterd-nfs-svc.c | 20 ++++++++------------ + 3 files changed, 14 insertions(+), 13 deletions(-) + +diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c +index 264a312..db99484 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.c ++++ b/rpc/rpc-lib/src/rpc-clnt.c +@@ -1108,6 +1108,11 @@ rpc_clnt_start (struct rpc_clnt *rpc) + + conn = &rpc->conn; + ++ pthread_mutex_lock (&conn->lock); ++ { ++ rpc->disabled = 0; ++ } ++ pthread_mutex_unlock (&conn->lock); + rpc_clnt_reconnect (conn); + + return 0; +@@ -1758,6 +1763,7 @@ rpc_clnt_disconnect (struct rpc_clnt *rpc) + + pthread_mutex_lock (&conn->lock); + { ++ rpc->disabled = 1; + if (conn->timer) { + gf_timer_call_cancel (rpc->ctx, conn->timer); + conn->timer = NULL; +diff --git a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +index da8c909..fca9323 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +@@ -80,7 +80,6 @@ out: + int + glusterd_conn_term (glusterd_conn_t *conn) + { +- rpc_clnt_disable (conn->rpc); + rpc_clnt_unref (conn->rpc); + return 0; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +index 49b1b56..cb08a20 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +@@ -164,18 +164,15 @@ glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags) + { + int ret = -1; + +- if (glusterd_are_all_volumes_stopped ()) { +- ret = svc->stop (svc, SIGKILL); +- +- } else { +- ret = glusterd_nfssvc_create_volfile (); +- if (ret) +- goto out; ++ ret = svc->stop (svc, SIGKILL); ++ if (ret) ++ goto out; + +- ret = svc->stop (svc, SIGKILL); +- if (ret) +- goto out; ++ ret = glusterd_nfssvc_create_volfile (); ++ if (ret) ++ goto out; + ++ if (glusterd_nfssvc_need_start ()) { + ret = svc->start (svc, flags); + if (ret) + goto out; +@@ -193,8 +190,7 @@ out: + int + glusterd_nfssvc_start (glusterd_svc_t *svc, int flags) + { +- if (glusterd_nfssvc_need_start ()) +- return glusterd_svc_start (svc, flags, NULL); ++ return glusterd_svc_start (svc, flags, NULL); + + return 0; + } +-- +1.7.1 + diff --git a/SOURCES/0026-rpc-call-transport_unref-only-on-non-NULL-transport.patch b/SOURCES/0026-rpc-call-transport_unref-only-on-non-NULL-transport.patch new file mode 100644 index 0000000..f3a5ad2 --- /dev/null +++ b/SOURCES/0026-rpc-call-transport_unref-only-on-non-NULL-transport.patch @@ -0,0 +1,45 @@ +From a3b6076b0ce30db7e9fdf42950f83f18a59c682b Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Tue, 2 Jun 2015 15:01:53 +0530 +Subject: [PATCH 26/57] rpc: call transport_unref only on non-NULL transport + +BUG: 1222785 +Change-Id: Ifac4dd8c633081483e4eba9d7e5a89837b2a453a +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: http://review.gluster.org/11041 +Reviewed-by: Raghavendra G +Reviewed-on: http://review.gluster.org/11102 +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50388 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-lib/src/rpc-clnt.c | 10 ++++++++-- + 1 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c +index db99484..2878372 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.c ++++ b/rpc/rpc-lib/src/rpc-clnt.c +@@ -1635,10 +1635,16 @@ rpc_clnt_trigger_destroy (struct rpc_clnt *rpc) + if (!rpc) + return; + ++ /* reading conn->trans outside conn->lock is OK, since this is the last ++ * ref*/ + conn = &rpc->conn; + trans = conn->trans; +- rpc_clnt_disable (rpc); +- rpc_transport_unref (trans); ++ rpc_clnt_disconnect (rpc); ++ ++ /* This is to account for rpc_clnt_disable that might have been called ++ * before rpc_clnt_unref */ ++ if (trans) ++ rpc_transport_unref (trans); + } + + static void +-- +1.7.1 + diff --git a/SOURCES/0027-socket-throttle-only-connected-transport.patch b/SOURCES/0027-socket-throttle-only-connected-transport.patch new file mode 100644 index 0000000..fac7674 --- /dev/null +++ b/SOURCES/0027-socket-throttle-only-connected-transport.patch @@ -0,0 +1,49 @@ +From ba7a80d22d4664bcbe420bd011ea60ee00d15ab1 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Fri, 22 May 2015 00:37:58 +0530 +Subject: [PATCH 27/57] socket: throttle only connected transport + +BUG: 1203901 +Change-Id: I2352c6661ae5aee8cf06e572ec0462b76901d46f +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: http://review.gluster.org/10887 +Reviewed-by: Raghavendra G +Reviewed-by: Shyam Ranganathan +Reviewed-on: https://code.engineering.redhat.com/gerrit/50386 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-transport/socket/src/socket.c | 17 +++++++++++++++-- + 1 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c +index 82a84dd..e30e231 100644 +--- a/rpc/rpc-transport/socket/src/socket.c ++++ b/rpc/rpc-transport/socket/src/socket.c +@@ -3572,8 +3572,21 @@ socket_throttle (rpc_transport_t *this, gf_boolean_t onoff) + will never read() any more data until throttling + is turned off. + */ +- priv->idx = event_select_on (this->ctx->event_pool, priv->sock, +- priv->idx, (int) !onoff, -1); ++ pthread_mutex_lock (&priv->lock); ++ { ++ ++ /* Throttling is useless on a disconnected transport. In fact, ++ * it's dangerous since priv->idx and priv->sock are set to -1 ++ * on a disconnected transport, which breaks epoll's event to ++ * registered fd mapping. */ ++ ++ if (priv->connected == 1) ++ priv->idx = event_select_on (this->ctx->event_pool, ++ priv->sock, ++ priv->idx, (int) !onoff, ++ -1); ++ } ++ pthread_mutex_unlock (&priv->lock); + return 0; + } + +-- +1.7.1 + diff --git a/SOURCES/0028-cluster-dht-pass-a-destination-subvol-to-fop2-varian.patch b/SOURCES/0028-cluster-dht-pass-a-destination-subvol-to-fop2-varian.patch new file mode 100644 index 0000000..e48b489 --- /dev/null +++ b/SOURCES/0028-cluster-dht-pass-a-destination-subvol-to-fop2-varian.patch @@ -0,0 +1,928 @@ +From 5408885124731a65d3a0d571b26f4c6cadcdae1e Mon Sep 17 00:00:00 2001 +From: Raghavendra G +Date: Wed, 27 May 2015 17:19:30 +0530 +Subject: [PATCH 28/57] cluster/dht: pass a destination subvol to fop2 variants to avoid races. + +The destination subvol used in the fop2 variants is either stored in +inode-ctx1 or local->cached_subvol. However, it is not guaranteed that +a value stored in these locations before invocation of fop2 is still +present after the invocation as these locations are shared among +different concurrent operations. So, to preserve the atomicity of +"check dst-subvol and invoke fop2 variant if dst-subvol found", we +pass down the dst-subvol to fop2 variant. + +This patch also fixes error handling in some fop2 variants. + +Change-Id: Icc226228a246d3f223e3463519736c4495b364d2 +BUG: 1140506 +Signed-off-by: Raghavendra G +Reviewed-on: http://review.gluster.org/10966 +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/50191 +Reviewed-by: Nithya Balachandran +--- + xlators/cluster/dht/src/dht-common.c | 112 ++++++-------------- + xlators/cluster/dht/src/dht-common.h | 6 +- + xlators/cluster/dht/src/dht-helper.c | 41 ++++++- + xlators/cluster/dht/src/dht-inode-read.c | 96 +++++++++-------- + xlators/cluster/dht/src/dht-inode-write.c | 164 +++++++++++++++++------------ + 5 files changed, 222 insertions(+), 197 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 48a003c..acad4da 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -29,14 +29,13 @@ + #include + #include + +-int dht_link2 (xlator_t *this, call_frame_t *frame, int op_ret); ++int dht_link2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); + + int +-dht_removexattr2 (xlator_t *this, call_frame_t *frame, int op_ret); ++dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + + int +-dht_setxattr2 (xlator_t *this, call_frame_t *frame, int op_ret); +- ++dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + + int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) +@@ -3303,14 +3302,13 @@ int + dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { +- int ret = -1; +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- struct iatt *stbuf = NULL; +- inode_t *inode = NULL; ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; + xlator_t *subvol = NULL; + +- + local = frame->local; + prev = cookie; + +@@ -3346,11 +3344,13 @@ dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Phase 1 of migration */ + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { + inode = (local->fd) ? local->fd->inode : local->loc.inode; +- dht_inode_ctx_get1 (this, inode, &subvol); ++ ++ ret = dht_inode_ctx_get1 (this, inode, &subvol); + if (subvol) { +- dht_setxattr2 (this, frame, 0); ++ dht_setxattr2 (this, subvol, frame); + return 0; + } ++ + ret = dht_rebalance_in_progress_check (this, frame); + if (!ret) + return 0; +@@ -3515,30 +3515,15 @@ out: + + + int +-dht_setxattr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; + int op_errno = EINVAL; +- inode_t *inode = NULL; +- +- local = frame->local; +- +- inode = (local->fd) ? local->fd->inode : local->loc.inode; + +- dht_inode_ctx_get1 (this, inode, &subvol); +- +- /* In phase2, dht_migration_complete_check_task will +- * reset inode_ctx_reset1 and update local->cached_subvol +- * with the dst subvol. +- */ +- if (!subvol) +- subvol = local->cached_subvol; +- +- if (!subvol) { +- op_errno = EINVAL; ++ if (!frame || !frame->local || !subvol) + goto err; +- } ++ ++ local = frame->local; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -3557,7 +3542,7 @@ dht_setxattr2 (xlator_t *this, call_frame_t *frame, int op_ret) + return 0; + + err: +- DHT_STACK_UNWIND (setxattr, frame, local->op_ret, op_errno, NULL); ++ DHT_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + return 0; + } + +@@ -3829,14 +3814,13 @@ int + dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { +- int ret = -1; +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- struct iatt *stbuf = NULL; +- inode_t *inode = NULL; ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; + xlator_t *subvol = NULL; + +- + local = frame->local; + prev = cookie; + +@@ -3872,11 +3856,12 @@ dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Phase 1 of migration */ + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { + inode = (local->fd) ? local->fd->inode : local->loc.inode; +- dht_inode_ctx_get1 (this, inode, &subvol); ++ ret = dht_inode_ctx_get1 (this, inode, &subvol); + if (subvol) { +- dht_removexattr2 (this, frame, 0); ++ dht_removexattr2 (this, subvol, frame); + return 0; + } ++ + ret = dht_rebalance_in_progress_check (this, frame); + if (!ret) + return 0; +@@ -3893,32 +3878,15 @@ out: + } + + int +-dht_removexattr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; + int op_errno = EINVAL; +- inode_t *inode = NULL; +- +- local = frame->local; + +- inode = (local->fd) ? local->fd->inode : local->loc.inode; +- +- dht_inode_ctx_get1 (this, inode, &subvol); +- +- /* In phase2, dht_migration_complete_check_task will +- * reset inode_ctx_reset1 and update local->cached_subvol +- * with the dst subvol. +- */ +- if (!subvol) +- subvol = local->cached_subvol; +- +- if (!subvol) { +- op_errno = EINVAL; ++ if (!frame || !frame->local || !subvol) + goto err; + +- } +- ++ local = frame->local; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -3935,11 +3903,10 @@ dht_removexattr2 (xlator_t *this, call_frame_t *frame, int op_ret) + return 0; + + err: +- DHT_STACK_UNWIND (removexattr, frame, local->op_ret, op_errno, NULL); ++ DHT_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL); + return 0; + } + +- + int + dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) +@@ -5268,7 +5235,7 @@ dht_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (!ret) + return 0; + } else { +- dht_link2 (this, frame, 0); ++ dht_link2 (this, subvol, frame); + return 0; + } + } +@@ -5277,7 +5244,7 @@ dht_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { + ret = dht_inode_ctx_get1 (this, local->loc.inode, &subvol); + if (subvol) { +- dht_link2 (this, frame, 0); ++ dht_link2 (this, subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -5295,10 +5262,9 @@ out: + + + int +-dht_link2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_link2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { + dht_local_t *local = NULL; +- xlator_t *subvol = NULL; + int op_errno = EINVAL; + + local = frame->local; +@@ -5306,16 +5272,8 @@ dht_link2 (xlator_t *this, call_frame_t *frame, int op_ret) + goto err; + + op_errno = local->op_errno; +- if (op_ret == -1) ++ if (subvol == NULL) { + goto err; +- +- dht_inode_ctx_get1 (this, local->loc.inode, &subvol); +- if (!subvol) { +- subvol = local->cached_subvol; +- if (!subvol) { +- op_errno = EINVAL; +- goto err; +- } + } + + /* Second call to create link file could result in EEXIST as the +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 4b6531c..eebc13b 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -39,9 +39,9 @@ + typedef int (*dht_selfheal_dir_cbk_t) (call_frame_t *frame, void *cookie, + xlator_t *this, + int32_t op_ret, int32_t op_errno, +- dict_t *xdata); +-typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, call_frame_t *frame, +- int ret); ++ dict_t *xdata); ++typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, xlator_t *dst_node, ++ call_frame_t *frame); + + + struct dht_layout { +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index 1b5ad41..ee99b99 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -820,11 +820,23 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf) + static int + dht_migration_complete_check_done (int op_ret, call_frame_t *frame, void *data) + { +- dht_local_t *local = NULL; ++ dht_local_t *local = NULL; ++ xlator_t *subvol = NULL; + + local = frame->local; + +- local->rebalance.target_op_fn (THIS, frame, op_ret); ++ if (op_ret == -1) ++ goto out; ++ ++ if (local->cached_subvol == NULL) { ++ local->op_errno = EINVAL; ++ goto out; ++ } ++ ++ subvol = local->cached_subvol; ++ ++out: ++ local->rebalance.target_op_fn (THIS, subvol, frame); + + return 0; + } +@@ -1003,13 +1015,30 @@ dht_rebalance_complete_check (xlator_t *this, call_frame_t *frame) + + /* During 'in-progress' state, both nodes should have the file */ + static int +-dht_inprogress_check_done (int op_ret, call_frame_t *sync_frame, void *data) ++dht_inprogress_check_done (int op_ret, call_frame_t *frame, void *data) + { +- dht_local_t *local = NULL; ++ dht_local_t *local = NULL; ++ xlator_t *subvol = NULL; ++ inode_t *inode = NULL; + +- local = sync_frame->local; ++ local = frame->local; ++ ++ if (op_ret == -1) ++ goto out; ++ ++ inode = local->loc.inode ? local->loc.inode : local->fd->inode; ++ ++ dht_inode_ctx_get1 (THIS, inode, &subvol); ++ if (!subvol) { ++ subvol = dht_subvol_get_cached (THIS, inode); ++ if (!subvol) { ++ local->op_errno = EINVAL; ++ goto out; ++ } ++ } + +- local->rebalance.target_op_fn (THIS, sync_frame, op_ret); ++out: ++ local->rebalance.target_op_fn (THIS, subvol, frame); + + return 0; + } +diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c +index 78e3ef4..46df5b6 100644 +--- a/xlators/cluster/dht/src/dht-inode-read.c ++++ b/xlators/cluster/dht/src/dht-inode-read.c +@@ -15,13 +15,13 @@ + + #include "dht-common.h" + +-int dht_access2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_readv2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_attr2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_open2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_flush2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_lk2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_fsync2 (xlator_t *this, call_frame_t *frame, int ret); ++int dht_access2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_readv2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_attr2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_open2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_flush2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_lk2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); ++int dht_fsync2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame); + + int + dht_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +@@ -58,22 +58,21 @@ out: + } + + int +-dht_open2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_open2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; + int op_errno = EINVAL; + +- local = frame->local; +- if (!local) ++ if (!frame || !frame->local) + goto out; + ++ local = frame->local; + op_errno = ENOENT; +- if (op_ret) ++ ++ if (subvol == NULL) + goto out; + + local->call_cnt = 2; +- subvol = local->cached_subvol; + + STACK_WIND (frame, dht_open_cbk, subvol, subvol->fops->open, + &local->loc, local->rebalance.flags, local->fd, +@@ -169,7 +168,7 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } else { + /* value is already set in fd_ctx, that means no need + to check for whether its complete or not. */ +- dht_attr2 (this, frame, 0); ++ dht_attr2 (this, subvol, frame); + return 0; + } + } +@@ -182,10 +181,9 @@ err: + } + + int +-dht_attr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_attr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; + int op_errno = EINVAL; + + local = frame->local; +@@ -193,10 +191,9 @@ dht_attr2 (xlator_t *this, call_frame_t *frame, int op_ret) + goto out; + + op_errno = local->op_errno; +- if (op_ret == -1) ++ if (subvol == NULL) + goto out; + +- subvol = local->cached_subvol; + local->call_cnt = 2; + + if (local->fop == GF_FOP_FSTAT) { +@@ -206,6 +203,7 @@ dht_attr2 (xlator_t *this, call_frame_t *frame, int op_ret) + STACK_WIND (frame, dht_file_attr_cbk, subvol, + subvol->fops->stat, &local->loc, NULL); + } ++ + return 0; + + out: +@@ -413,7 +411,7 @@ dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } else { + /* value is already set in fd_ctx, that means no need + to check for whether its complete or not. */ +- dht_readv2 (this, frame, 0); ++ dht_readv2 (this, subvol, frame); + return 0; + } + } +@@ -427,10 +425,9 @@ out: + } + + int +-dht_readv2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_readv2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { + dht_local_t *local = NULL; +- xlator_t *subvol = NULL; + int op_errno = EINVAL; + + local = frame->local; +@@ -438,11 +435,10 @@ dht_readv2 (xlator_t *this, call_frame_t *frame, int op_ret) + goto out; + + op_errno = local->op_errno; +- if (op_ret == -1) ++ if (subvol == NULL) + goto out; + + local->call_cnt = 2; +- subvol = local->cached_subvol; + + STACK_WIND (frame, dht_readv_cbk, subvol, subvol->fops->readv, + local->fd, local->rebalance.size, local->rebalance.offset, +@@ -547,10 +543,9 @@ out: + } + + int +-dht_access2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_access2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; + int op_errno = EINVAL; + + local = frame->local; +@@ -558,11 +553,10 @@ dht_access2 (xlator_t *this, call_frame_t *frame, int op_ret) + goto out; + + op_errno = local->op_errno; +- if (op_ret == -1) ++ if (subvol == NULL) + goto out; + + local->call_cnt = 2; +- subvol = local->cached_subvol; + + STACK_WIND (frame, dht_access_cbk, subvol, subvol->fops->access, + &local->loc, local->rebalance.flags, NULL); +@@ -636,7 +630,7 @@ dht_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* If context is set, then send flush() it to the destination */ + dht_inode_ctx_get1 (this, inode, &subvol); + if (subvol) { +- dht_flush2 (this, frame, 0); ++ dht_flush2 (this, subvol, frame); + return 0; + } + +@@ -647,17 +641,20 @@ out: + } + + int +-dht_flush2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_flush2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; ++ ++ if ((frame == NULL) || (frame->local == NULL)) ++ goto out; + + local = frame->local; + +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -665,6 +662,10 @@ dht_flush2 (xlator_t *this, call_frame_t *frame, int op_ret) + subvol, subvol->fops->flush, local->fd, NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (flush, frame, -1, op_errno, NULL); ++ return 0; + } + + +@@ -758,7 +759,7 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + if (!ret) + return 0; + } else { +- dht_fsync2 (this, frame, 0); ++ dht_fsync2 (this, subvol, frame); + return 0; + } + +@@ -772,16 +773,19 @@ out: + } + + int +-dht_fsync2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_fsync2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; ++ ++ if ((frame == NULL) || (frame->local == NULL)) ++ goto out; + + local = frame->local; ++ op_errno = local->op_errno; + +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -789,6 +793,10 @@ dht_fsync2 (xlator_t *this, call_frame_t *frame, int op_ret) + local->fd, local->rebalance.flags, NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + int +diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c +index 7d04376..57ce89c 100644 +--- a/xlators/cluster/dht/src/dht-inode-write.c ++++ b/xlators/cluster/dht/src/dht-inode-write.c +@@ -16,12 +16,12 @@ + + #include "dht-common.h" + +-int dht_writev2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_truncate2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_setattr2 (xlator_t *this, call_frame_t *frame, int ret); +-int dht_fallocate2(xlator_t *this, call_frame_t *frame, int op_ret); +-int dht_discard2(xlator_t *this, call_frame_t *frame, int op_ret); +-int dht_zerofill2(xlator_t *this, call_frame_t *frame, int op_ret); ++int dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); ++int dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); ++int dht_setattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); ++int dht_fallocate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); ++int dht_discard2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); ++int dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + + int + dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +@@ -69,7 +69,7 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = dht_inode_ctx_get1 (this, local->fd->inode, &subvol); + if (subvol) { +- dht_writev2 (this, frame, 0); ++ dht_writev2 (this, subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -88,17 +88,19 @@ out: + } + + int +-dht_writev2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; + +- local = frame->local; ++ if ((frame == NULL) || (frame->local == NULL)) ++ goto out; + +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); ++ local = frame->local; ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -109,6 +111,11 @@ dht_writev2 (xlator_t *this, call_frame_t *frame, int op_ret) + local->rebalance.iobref, NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL); ++ ++ return 0; + } + + int +@@ -216,7 +223,7 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode = (local->fd) ? local->fd->inode : local->loc.inode; + dht_inode_ctx_get1 (this, inode, &subvol); + if (subvol) { +- dht_truncate2 (this, frame, 0); ++ dht_truncate2 (this, subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -235,19 +242,19 @@ err: + + + int +-dht_truncate2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; +- inode_t *inode = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; + +- local = frame->local; ++ if (!frame || !frame->local) ++ goto out; + +- inode = local->fd ? local->fd->inode : local->loc.inode; ++ local = frame->local; ++ op_errno = local->op_errno; + +- dht_inode_ctx_get1 (this, inode, &subvol); +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -262,6 +269,10 @@ dht_truncate2 (xlator_t *this, call_frame_t *frame, int op_ret) + } + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + int +@@ -399,7 +410,7 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); + dht_inode_ctx_get1 (this, local->fd->inode, &subvol); + if (subvol) { +- dht_fallocate2 (this, frame, 0); ++ dht_fallocate2 (this, subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -417,17 +428,19 @@ err: + } + + int +-dht_fallocate2(xlator_t *this, call_frame_t *frame, int op_ret) ++dht_fallocate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; + +- local = frame->local; ++ if (!frame || !frame->local) ++ goto out; + +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); ++ local = frame->local; ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -436,6 +449,10 @@ dht_fallocate2(xlator_t *this, call_frame_t *frame, int op_ret) + local->rebalance.size, NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + int +@@ -533,7 +550,7 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); + dht_inode_ctx_get1 (this, local->fd->inode, &subvol); + if (subvol) { +- dht_discard2 (this, frame, 0); ++ dht_discard2 (this, subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -551,17 +568,19 @@ err: + } + + int +-dht_discard2(xlator_t *this, call_frame_t *frame, int op_ret) ++dht_discard2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; + +- local = frame->local; ++ if (!frame || !frame->local) ++ goto out; + +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); ++ local = frame->local; ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -570,6 +589,10 @@ dht_discard2(xlator_t *this, call_frame_t *frame, int op_ret) + NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (discard, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + int +@@ -619,9 +642,10 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata) + { +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ int ret = -1; ++ xlator_t *subvol = NULL; + + GF_VALIDATE_OR_GOTO ("dht", frame, err); + GF_VALIDATE_OR_GOTO ("dht", this, out); +@@ -659,11 +683,12 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (postbuf)) { + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); +- ret = fd_ctx_get (local->fd, this, NULL); +- if (!ret) { +- dht_zerofill2 (this, frame, 0); ++ dht_inode_ctx_get1 (this, local->fd->inode, &subvol); ++ if (subvol) { ++ dht_zerofill2 (this, subvol, frame); + return 0; + } ++ + ret = dht_rebalance_in_progress_check (this, frame); + if (!ret) + return 0; +@@ -679,22 +704,20 @@ err: + } + + int +-dht_zerofill2(xlator_t *this, call_frame_t *frame, int op_ret) ++dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; +- uint64_t tmp_subvol = 0; +- int ret = -1; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; ++ ++ if (!frame || !frame->local) ++ goto out; + + local = frame->local; + +- if (local->fd) +- ret = fd_ctx_get (local->fd, this, &tmp_subvol); +- if (!ret) +- subvol = (xlator_t *)(long)tmp_subvol; ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -703,6 +726,10 @@ dht_zerofill2(xlator_t *this, call_frame_t *frame, int op_ret) + NULL); + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (zerofill, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + int +@@ -796,20 +823,19 @@ out: + } + + int +-dht_setattr2 (xlator_t *this, call_frame_t *frame, int op_ret) ++dht_setattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; +- inode_t *inode = NULL; +- +- local = frame->local; ++ dht_local_t *local = NULL; ++ int32_t op_errno = EINVAL; + +- inode = (local->fd) ? local->fd->inode : local->loc.inode; ++ if (!frame || !frame->local) ++ goto out; + +- dht_inode_ctx_get1 (this, inode, &subvol); ++ local = frame->local; ++ op_errno = local->op_errno; + +- if (!subvol) +- subvol = local->cached_subvol; ++ if (subvol == NULL) ++ goto out; + + local->call_cnt = 2; /* This is the second attempt */ + +@@ -826,6 +852,10 @@ dht_setattr2 (xlator_t *this, call_frame_t *frame, int op_ret) + } + + return 0; ++ ++out: ++ DHT_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL, NULL); ++ return 0; + } + + +-- +1.7.1 + diff --git a/SOURCES/0029-cluster-ec-Prevent-double-unwind.patch b/SOURCES/0029-cluster-ec-Prevent-double-unwind.patch new file mode 100644 index 0000000..bdc03b1 --- /dev/null +++ b/SOURCES/0029-cluster-ec-Prevent-double-unwind.patch @@ -0,0 +1,171 @@ +From 2b70ebb3c1094a968aeadfb8185cfcaca3fdf58e Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Sun, 7 Jun 2015 10:24:08 +0530 +Subject: [PATCH 29/57] cluster/ec: Prevent double unwind + +Problem: +1) ec_access/ec_readlink_/ec_readdir[p] _cbks are trying to recover only from +ENOTCONN. +2) When the fop succeeds it unwinds right away. But when its +ec_fop_manager resumes, if the number of bricks that are up is less than +ec->fragments, the the state machine will resume with -EC_STATE_REPORT which +unwinds again. This will lead to crashes. + +Fix: +- If fop fails retry on other subvols, as ESTALE/ENOENT/EBADFD etc are also +recoverable. +- unwind success/failure in _cbks + + >Change-Id: I2cac3c2f9669a4e6160f1ff4abc39f0299303222 + >BUG: 1228952 + >Signed-off-by: Pranith Kumar K + >Reviewed-on: http://review.gluster.org/11111 + >Reviewed-by: Xavier Hernandez + >Tested-by: Gluster Build System + +Change-Id: Ia630274a967684db4dcf0cb6b229e93d4062662f +BUG: 1228529 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50403 +--- + xlators/cluster/ec/src/ec-common.c | 6 ++---- + xlators/cluster/ec/src/ec-common.h | 3 +-- + xlators/cluster/ec/src/ec-dir-read.c | 8 +++++--- + xlators/cluster/ec/src/ec-inode-read.c | 8 ++++---- + 4 files changed, 12 insertions(+), 13 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 062754b..46c9eec 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -535,11 +535,9 @@ void ec_dispatch_one(ec_fop_data_t * fop) + } + } + +-int32_t ec_dispatch_one_retry(ec_fop_data_t * fop, int32_t idx, int32_t op_ret, +- int32_t op_errno) ++int32_t ec_dispatch_one_retry(ec_fop_data_t *fop, int32_t idx, int32_t op_ret) + { +- if ((op_ret < 0) && (op_errno == ENOTCONN)) +- { ++ if (op_ret < 0) { + return (ec_dispatch_next(fop, idx) >= 0); + } + +diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h +index c0db021..e3f01ca 100644 +--- a/xlators/cluster/ec/src/ec-common.h ++++ b/xlators/cluster/ec/src/ec-common.h +@@ -75,8 +75,7 @@ typedef enum { + #define EC_STATE_HEAL_POST_INODELK_UNLOCK 217 + #define EC_STATE_HEAL_DISPATCH 218 + +-int32_t ec_dispatch_one_retry(ec_fop_data_t * fop, int32_t idx, int32_t op_ret, +- int32_t op_errno); ++int32_t ec_dispatch_one_retry(ec_fop_data_t *fop, int32_t idx, int32_t op_ret); + int32_t ec_dispatch_next(ec_fop_data_t * fop, int32_t idx); + + void ec_complete(ec_fop_data_t * fop); +diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c +index 354c63d..7821878 100644 +--- a/xlators/cluster/ec/src/ec-dir-read.c ++++ b/xlators/cluster/ec/src/ec-dir-read.c +@@ -361,7 +361,7 @@ int32_t ec_readdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_adjust_readdir(fop->xl->private, idx, entries); + } + +- if (!ec_dispatch_one_retry(fop, idx, op_ret, op_errno)) ++ if (!ec_dispatch_one_retry(fop, idx, op_ret)) + { + if (fop->cbks.readdir != NULL) + { +@@ -429,6 +429,8 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + + if (fop->offset != 0) + { ++ /* Non-zero offset is irrecoverable error as the offset may not be ++ * valid on other bricks*/ + int32_t idx = -1; + + idx = ec_deitransform (fop->xl, fop->offset); +@@ -448,7 +450,6 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_REPORT; + + case -EC_STATE_INIT: +- case -EC_STATE_REPORT: + if (fop->id == GF_FOP_READDIR) + { + if (fop->cbks.readdir != NULL) +@@ -467,6 +468,7 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + } + + case EC_STATE_REPORT: ++ case -EC_STATE_REPORT: + return EC_STATE_END; + + default: +@@ -564,7 +566,7 @@ int32_t ec_readdirp_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_adjust_readdir(fop->xl->private, idx, entries); + } + +- if (!ec_dispatch_one_retry(fop, idx, op_ret, op_errno)) ++ if (!ec_dispatch_one_retry(fop, idx, op_ret)) + { + if (fop->cbks.readdirp != NULL) + { +diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c +index ae02e96..ef2170f 100644 +--- a/xlators/cluster/ec/src/ec-inode-read.c ++++ b/xlators/cluster/ec/src/ec-inode-read.c +@@ -35,7 +35,7 @@ int32_t ec_access_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_trace("CBK", fop, "idx=%d, frame=%p, op_ret=%d, op_errno=%d", idx, + frame, op_ret, op_errno); + +- if (!ec_dispatch_one_retry(fop, idx, op_ret, op_errno)) ++ if (!ec_dispatch_one_retry(fop, idx, op_ret)) + { + if (fop->cbks.access != NULL) + { +@@ -73,13 +73,13 @@ int32_t ec_manager_access(ec_fop_data_t * fop, int32_t state) + return EC_STATE_REPORT; + + case -EC_STATE_INIT: +- case -EC_STATE_REPORT: + if (fop->cbks.access != NULL) + { + fop->cbks.access(fop->req_frame, fop, fop->xl, -1, fop->error, + NULL); + } + ++ case -EC_STATE_REPORT: + case EC_STATE_REPORT: + return EC_STATE_END; + +@@ -968,7 +968,7 @@ int32_t ec_readlink_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_iatt_rebuild(fop->xl->private, buf, 1, 1); + } + +- if (!ec_dispatch_one_retry(fop, idx, op_ret, op_errno)) ++ if (!ec_dispatch_one_retry(fop, idx, op_ret)) + { + if (fop->cbks.readlink != NULL) + { +@@ -1006,7 +1006,6 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state) + return EC_STATE_REPORT; + + case -EC_STATE_INIT: +- case -EC_STATE_REPORT: + if (fop->cbks.readlink != NULL) + { + fop->cbks.readlink(fop->req_frame, fop, fop->xl, -1, +@@ -1014,6 +1013,7 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state) + } + + case EC_STATE_REPORT: ++ case -EC_STATE_REPORT: + return EC_STATE_END; + + default: +-- +1.7.1 + diff --git a/SOURCES/0030-Upcall-cache-invalidation-Ignore-fops-with-frame-roo.patch b/SOURCES/0030-Upcall-cache-invalidation-Ignore-fops-with-frame-roo.patch new file mode 100644 index 0000000..1bae94d --- /dev/null +++ b/SOURCES/0030-Upcall-cache-invalidation-Ignore-fops-with-frame-roo.patch @@ -0,0 +1,184 @@ +From 1dde7f9f6a555c7e461ec67ce4f9858ef7decc8d Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Thu, 4 Jun 2015 11:25:35 +0530 +Subject: [PATCH 30/57] Upcall/cache-invalidation: Ignore fops with frame->root->client not set + +This is a backport of the fix reviewed upstream on - +http://review.gluster.org/10909 + +Server-side internally generated fops like 'quota/marker' will +not have any client associated with the frame. Hence we need a +check for clients to be valid before processing for upcall cache +invalidation. Also fixed an issue with initializing reaper-thread. + +Added a testcase to test the fix. + +BUG: 1224183 +Change-Id: I5042238cf52380e06c69adb3bee874df9b445f95 +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/10909 +Reviewed-by: Kaleb KEITHLEY +Reviewed-by: jiffin tony Thottan +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50369 +Reviewed-by: Jiffin Thottan +Tested-by: Niels de Vos +--- + tests/bugs/upcall/bug-1227204.t | 29 +++++++++++++++++++++++ + xlators/features/upcall/src/upcall-internal.c | 25 +++++++++++++++---- + xlators/features/upcall/src/upcall.c | 4 ++- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 2 +- + 4 files changed, 53 insertions(+), 7 deletions(-) + create mode 100755 tests/bugs/upcall/bug-1227204.t + +diff --git a/tests/bugs/upcall/bug-1227204.t b/tests/bugs/upcall/bug-1227204.t +new file mode 100755 +index 0000000..fc393b1 +--- /dev/null ++++ b/tests/bugs/upcall/bug-1227204.t +@@ -0,0 +1,29 @@ ++#!/bin/bash ++ ++# This regression test tries to ensure that quota limit-usage set work with ++# features.cache-invalidation on. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4,5,6}; ++TEST $CLI volume start $V0; ++ ++TEST $CLI volume set $V0 features.cache-invalidation on; ++TEST $CLI volume quota $V0 enable; ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST mkdir -p $M0/1/2; ++TEST $CLI volume quota $V0 limit-usage /1/2 100MB 70%; ++ ++TEST $CLI volume status $V0 ++TEST $CLI volume stop $V0 ++ ++cleanup; +diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c +index 19c9f9e..e13097c 100644 +--- a/xlators/features/upcall/src/upcall-internal.c ++++ b/xlators/features/upcall/src/upcall-internal.c +@@ -206,10 +206,13 @@ __upcall_inode_ctx_set (inode_t *inode, xlator_t *this) + INIT_LIST_HEAD (&inode_ctx->client_list); + inode_ctx->destroy = 0; + +- ret = __inode_ctx_set (inode, this, (uint64_t *) inode_ctx); +- if (ret) ++ ctx = (long) inode_ctx; ++ ret = __inode_ctx_set (inode, this, &ctx); ++ if (ret) { + gf_log (this->name, GF_LOG_DEBUG, + "failed to set inode ctx (%p)", inode); ++ goto out; ++ } + + /* add this inode_ctx to the global list */ + LOCK (&priv->inode_ctx_lk); +@@ -241,7 +244,7 @@ __upcall_inode_ctx_get (inode_t *inode, xlator_t *this) + goto out; + } + +- inode_ctx = (upcall_inode_ctx_t *)(long) ctx; ++ inode_ctx = (upcall_inode_ctx_t *) (long) (ctx); + + out: + return inode_ctx; +@@ -377,10 +380,10 @@ upcall_cleanup_inode_ctx (xlator_t *this, inode_t *inode) + } + pthread_mutex_unlock (&inode_ctx->client_list_lock); + +- pthread_mutex_destroy (&inode_ctx->client_list_lock); +- + /* Mark the inode_ctx to be destroyed */ + inode_ctx->destroy = 1; ++ gf_msg_debug ("upcall", 0, "set upcall_inode_ctx (%p) to destroy mode", ++ inode_ctx); + } + + out: +@@ -422,8 +425,12 @@ upcall_reaper_thread (void *data) + LOCK (&priv->inode_ctx_lk); + { + /* client list would have been cleaned up*/ ++ gf_msg_debug ("upcall", 0, "Freeing upcall_inode_ctx (%p)", ++ inode_ctx); + list_del_init (&inode_ctx->inode_ctx_list); ++ pthread_mutex_destroy (&inode_ctx->client_list_lock); + GF_FREE (inode_ctx); ++ inode_ctx = NULL; + } + UNLOCK (&priv->inode_ctx_lk); + } +@@ -474,6 +481,14 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, + if (!is_cache_invalidation_enabled(this)) + return; + ++ /* server-side generated fops like quota/marker will not have any ++ * client associated with them. Ignore such fops. ++ */ ++ if (!client) { ++ gf_msg_debug ("upcall", 0, "Internal fop - client NULL"); ++ return; ++ } ++ + up_inode_ctx = ((upcall_local_t *)frame->local)->upcall_inode_ctx; + + if (!up_inode_ctx) +diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c +index 5f6c29e..331db52 100644 +--- a/xlators/features/upcall/src/upcall.c ++++ b/xlators/features/upcall/src/upcall.c +@@ -1581,8 +1581,8 @@ upcall_local_wipe (xlator_t *this, upcall_local_t *local) + { + if (local) { + inode_unref (local->inode); +- mem_put (local); + loc_wipe (&local->rename_oldloc); ++ mem_put (local); + } + } + +@@ -1634,6 +1634,7 @@ reconfigure (xlator_t *this, dict_t *options) + " Disabling cache_invalidation", + strerror(errno)); + } ++ priv->reaper_init_done = 1; + } + + out: +@@ -1680,6 +1681,7 @@ init (xlator_t *this) + " Disabling cache_invalidation", + strerror(errno)); + } ++ priv->reaper_init_done = 1; + } + out: + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 9b9f544..8dea069 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1863,7 +1863,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + /* Upcall translator options */ + { .key = "features.cache-invalidation", + .voltype = "features/upcall", +- .value = "off", ++ .value = "off", + .op_version = GD_OP_VERSION_3_7_0, + }, + { .key = "features.cache-invalidation-timeout", +-- +1.7.1 + diff --git a/SOURCES/0031-cli-Fix-incorrect-parse-logic-for-volume-heal-comman.patch b/SOURCES/0031-cli-Fix-incorrect-parse-logic-for-volume-heal-comman.patch new file mode 100644 index 0000000..2c7754c --- /dev/null +++ b/SOURCES/0031-cli-Fix-incorrect-parse-logic-for-volume-heal-comman.patch @@ -0,0 +1,42 @@ +From 1bd63bb65888416fb28095aa2b7e5288cc670b59 Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Wed, 13 May 2015 15:29:57 +0530 +Subject: [PATCH 31/57] cli: Fix incorrect parse logic for volume heal commands + +heal-op was being incorrectly set to +GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE. + +Change-Id: I4d4461c7737feae30102e82f7788083017485669 +BUG:1223746 +Reviewed-on: http://review.gluster.org/10771 +Reviewed-on: http://review.gluster.org/11043 +Reviewed-by: Ravishankar N +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Pranith Kumar Karampuri +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/49906 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Pranith Kumar Karampuri +--- + cli/src/cli-cmd-parser.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index caa3191..917be53 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -3364,8 +3364,8 @@ heal_command_type_get (const char *command) + [GF_SHD_OP_STATISTICS] = "statistics", + [GF_SHD_OP_STATISTICS_HEAL_COUNT] = NULL, + [GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA] = NULL, +- [GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE] = "split-brain", +- [GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK] = "split-brain", ++ [GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE] = NULL, ++ [GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK] = NULL, + [GF_SHD_OP_HEAL_ENABLE] = "enable", + [GF_SHD_OP_HEAL_DISABLE] = "disable", + }; +-- +1.7.1 + diff --git a/SOURCES/0032-nfs-allocate-and-return-the-hashkey-for-the-auth_cac.patch b/SOURCES/0032-nfs-allocate-and-return-the-hashkey-for-the-auth_cac.patch new file mode 100644 index 0000000..7fdf4fc --- /dev/null +++ b/SOURCES/0032-nfs-allocate-and-return-the-hashkey-for-the-auth_cac.patch @@ -0,0 +1,133 @@ +From 8448e56a36348bba791544bbf0a74f642c51f00c Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Tue, 9 Jun 2015 19:12:52 +0200 +Subject: [PATCH 32/57] nfs: allocate and return the hashkey for the auth_cache_entry + +The allocation of the hashkey was never returned to the calling +function. + +Allocating it with alloca() puts it on the stack, returning from the +function makes the pointer invalid. Functions that are annotated with +"inline" and call alloca(), will not always be inlined. Returning a +pointer allocated with alloca() is in those cases not correct. One such +confirmation was provided by GCC developer Alexandre Oliva: + - http://gcc.gnu.org/ml/gcc-help/2004-04/msg00158.html + +It is more correct to call GF_MALLOC() and GF_FREE() for the hashkey. If +this would result in preformance hit, we can always think of using +alloca() again and turn make_hashkey() into a macro (yuck). + +Cherry picked from commit cccd1e3cce7873e873c7266af703f4f77ff4c679: +> Cherry picked from commit b8b59fea7822f9ab1e10d7a3f730354fe82a6097: +> > Change-Id: Ia86a1f79d33240af4713bfb92f702b0ee6e87eb7 +> > BUG: 1226714 +> > Signed-off-by: Niels de Vos +> > Reviewed-on: http://review.gluster.org/11019 +> > Reviewed-by: Kaleb KEITHLEY +> > Reviewed-by: jiffin tony Thottan +> > Reviewed-by: soumya k +> > Tested-by: Gluster Build System +> +> Change-Id: Ia86a1f79d33240af4713bfb92f702b0ee6e87eb7 +> BUG: 1227916 +> Signed-off-by: Niels de Vos +> Reviewed-on: http://review.gluster.org/11075 +> Tested-by: Gluster Build System +> Reviewed-by: jiffin tony Thottan + +BUG: 1227918 +Change-Id: I1652540056731412bebf5b98eed62659c610fd90 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50371 +Reviewed-by: Soumya Koduri +Reviewed-by: Jiffin Thottan +--- + xlators/nfs/server/src/auth-cache.c | 32 +++++++++++++++++++++++++------- + 1 files changed, 25 insertions(+), 7 deletions(-) + +diff --git a/xlators/nfs/server/src/auth-cache.c b/xlators/nfs/server/src/auth-cache.c +index 848eed5..b0cb7bf 100644 +--- a/xlators/nfs/server/src/auth-cache.c ++++ b/xlators/nfs/server/src/auth-cache.c +@@ -27,12 +27,12 @@ struct auth_cache_entry { + struct export_item *item; + }; + +-/* Given a filehandle and an ip, creates a colon delimited hashkey that is +- * allocated on the stack. ++/* Given a filehandle and an ip, creates a colon delimited hashkey. + */ +-static inline void +-make_hashkey(char *hashkey, struct nfs3_fh *fh, const char *host) ++static char* ++make_hashkey(struct nfs3_fh *fh, const char *host) + { ++ char *hashkey = NULL; + char exportid[256] = {0, }; + char gfid[256] = {0, }; + char mountid[256] = {0, }; +@@ -41,11 +41,17 @@ make_hashkey(char *hashkey, struct nfs3_fh *fh, const char *host) + gf_uuid_unparse (fh->exportid, exportid); + gf_uuid_unparse (fh->gfid, gfid); + gf_uuid_unparse (fh->mountid, mountid); ++ + nbytes = strlen (exportid) + strlen (gfid) + strlen (host) + + strlen (mountid) + 5; +- hashkey = alloca (nbytes); ++ hashkey = GF_MALLOC (nbytes, gf_common_mt_char); ++ if (!hashkey) ++ return NULL; ++ + snprintf (hashkey, nbytes, "%s:%s:%s:%s", exportid, gfid, + mountid, host); ++ ++ return hashkey; + } + + /** +@@ -127,7 +133,11 @@ auth_cache_lookup (struct auth_cache *cache, struct nfs3_fh *fh, + GF_VALIDATE_OR_GOTO (GF_NFS, timestamp, out); + GF_VALIDATE_OR_GOTO (GF_NFS, can_write, out); + +- make_hashkey (hashkey, fh, host_addr); ++ hashkey = make_hashkey (fh, host_addr); ++ if (!hashkey) { ++ ret = -ENOMEM; ++ goto out; ++ } + + entry_data = dict_get (cache->cache_dict, hashkey); + if (!entry_data) { +@@ -155,6 +165,8 @@ auth_cache_lookup (struct auth_cache *cache, struct nfs3_fh *fh, + + ret = ENTRY_FOUND; + out: ++ GF_FREE (hashkey); ++ + return ret; + } + +@@ -277,7 +289,11 @@ cache_nfs_fh (struct auth_cache *cache, struct nfs3_fh *fh, + goto out; + } + +- make_hashkey (hashkey, fh, host_addr); ++ hashkey = make_hashkey (fh, host_addr); ++ if (!hashkey) { ++ ret = -ENOMEM; ++ goto out; ++ } + + entry = auth_cache_entry_init (); + if (!entry) { +@@ -305,5 +321,7 @@ cache_nfs_fh (struct auth_cache *cache, struct nfs3_fh *fh, + gf_msg_trace (GF_NFS, 0, "Caching file-handle (%s)", host_addr); + ret = 0; + out: ++ GF_FREE (hashkey); ++ + return ret; + } +-- +1.7.1 + diff --git a/SOURCES/0033-features-marker-Cleanup-loc-in-case-of-errors.patch b/SOURCES/0033-features-marker-Cleanup-loc-in-case-of-errors.patch new file mode 100644 index 0000000..73acd7d --- /dev/null +++ b/SOURCES/0033-features-marker-Cleanup-loc-in-case-of-errors.patch @@ -0,0 +1,53 @@ +From ad97c25ea8678a486c464b76e23cf319f8119c43 Mon Sep 17 00:00:00 2001 +From: Vijay Bellur +Date: Wed, 3 Jun 2015 23:43:55 +0530 +Subject: [PATCH 33/57] features/marker: Cleanup loc in case of errors + +This is a backport of http://review.gluster.org/#/c/11074/ + +> Missing loc_wipe() for error paths in mq_readdir_cbk() can +> cause memory leaks. loc_wipe() is now done for both happy +> and unhappy paths. +> +> Change-Id: I882aa5dcca06e25b56a828767fb2b91a1efaf83b +> BUG: 1227904 +> Signed-off-by: Vijay Bellur +> Reviewed-on: http://review.gluster.org/11074 +> Reviewed-by: Sachin Pandit +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Vijaikumar Mallikarjuna +> Reviewed-by: Raghavendra G +> Tested-by: Raghavendra G + +Change-Id: I9da333b701eaace7f492280386e7ded4459f442f +BUG: 1229612 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/50309 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 4 +--- + 1 files changed, 1 insertions(+), 3 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index e9351ed..ef70236 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -665,12 +665,10 @@ mq_readdir_cbk (call_frame_t *frame, + &loc, dict); + + offset = entry->d_off; +- +- loc_wipe (&loc); +- + newframe = NULL; + + out: ++ loc_wipe (&loc); + if (dict) { + dict_unref (dict); + dict = NULL; +-- +1.7.1 + diff --git a/SOURCES/0034-ec-Changing-log-level-to-DEBUG-in-case-of-ENOENT.patch b/SOURCES/0034-ec-Changing-log-level-to-DEBUG-in-case-of-ENOENT.patch new file mode 100644 index 0000000..9c3b2b2 --- /dev/null +++ b/SOURCES/0034-ec-Changing-log-level-to-DEBUG-in-case-of-ENOENT.patch @@ -0,0 +1,38 @@ +From 7e281cb0253b5a58e405fecbbbb88dc7e9719991 Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Thu, 14 May 2015 17:06:25 +0530 +Subject: [PATCH 34/57] ec : Changing log level to DEBUG in case of ENOENT + + Backport of http://review.gluster.org/10784 + +Change-Id: I264e47ca679d8b57cd8c80306c07514e826f92d8 +BUG: 1224123 + +Signed-off-by: Ashish Pandey +Change-Id: Ice06e50185a092b35ca4150b86ada5381bdae0d5 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50431 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/ec/src/ec-common.c | 5 +++-- + 1 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 46c9eec..f33384b 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -1440,8 +1440,9 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie, + ec_inode_t *ctx; + + if (op_ret < 0) { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Failed to update version and " +- "size (error %d)", op_errno); ++ gf_log(fop->xl->name, fop_log_level (fop->id, op_errno), ++ "Failed to update version and" ++ " size (error %d)", op_errno); + } else { + fop->parent->mask &= fop->good; + link = fop->data; +-- +1.7.1 + diff --git a/SOURCES/0035-protocol-server-Changing-log-level-from-Warning-to-D.patch b/SOURCES/0035-protocol-server-Changing-log-level-from-Warning-to-D.patch new file mode 100644 index 0000000..f8591fa --- /dev/null +++ b/SOURCES/0035-protocol-server-Changing-log-level-from-Warning-to-D.patch @@ -0,0 +1,37 @@ +From 6e10c4107dd368617ae5dbda300ce248c01cb160 Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Fri, 29 May 2015 14:16:56 +0530 +Subject: [PATCH 35/57] protocol/server : Changing log level from Warning to Debug + + Backport of http://review.gluster.com/10829 + +Change-Id: Ie9bf338802e3f1c59c92d2749a1f8bc745dc5455 +BUG: 1224136 + +Signed-off-by: Ashish Pandey +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Pranith Kumar Karampuri +Change-Id: Id9bcec9bf8334880cc93974dd3c333e5a13fec5e +Reviewed-on: https://code.engineering.redhat.com/gerrit/50425 +Tested-by: Pranith Kumar Karampuri +--- + xlators/protocol/server/src/server-resolve.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c +index 3c3dcfe..461884d 100644 +--- a/xlators/protocol/server/src/server-resolve.c ++++ b/xlators/protocol/server/src/server-resolve.c +@@ -420,7 +420,7 @@ out: + inode_unref (inode); + + if (ret != 0) +- gf_log ("server", GF_LOG_WARNING, "inode for the gfid (%s) is " ++ gf_log ("server", GF_LOG_DEBUG, "inode for the gfid (%s) is " + "not found. anonymous fd creation failed", + uuid_utoa (resolve->gfid)); + return ret; +-- +1.7.1 + diff --git a/SOURCES/0036-glusterd-Stop-tcp-ip-listeners-during-glusterd-exit.patch b/SOURCES/0036-glusterd-Stop-tcp-ip-listeners-during-glusterd-exit.patch new file mode 100644 index 0000000..ebee5ef --- /dev/null +++ b/SOURCES/0036-glusterd-Stop-tcp-ip-listeners-during-glusterd-exit.patch @@ -0,0 +1,107 @@ +From 4319e82ca0823c6e62f37fe27cff4e8e26d29522 Mon Sep 17 00:00:00 2001 +From: anand +Date: Fri, 10 Apr 2015 16:41:25 +0530 +Subject: [PATCH 36/57] glusterd: Stop tcp/ip listeners during glusterd exit + +Problem : Because of race between exit thread and rpc thread +causing the glusterd crash while glusterd exiting/stoping. + +Fix : Stop tcp/ip socket listeners in cleanup_and_exit to +avoid new rpc events. + +Backport of : +>Change-Id: Ie9280c8c9d7c350a176529375d861432f3de94ac +>BUG: 1209461 +>Signed-off-by: anand +>Reviewed-on: http://review.gluster.org/10197 +>Reviewed-by: Atin Mukherjee +>Tested-by: NetBSD Build System +>Reviewed-by: Kaushal M + +Change-Id: Ia209927c61c1eeb0542a2e59ea60e48f74e3ca80 +BUG: 1230195 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/50436 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd.c | 48 +++++++++++++++++++++++++++++++-- + 1 files changed, 45 insertions(+), 3 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 54a5fbd..39160c0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -1113,8 +1113,38 @@ glusterd_stop_uds_listener (xlator_t *this) + } + unlink (sockfile); + +- GF_FREE (conf->uds_rpc); +- conf->uds_rpc = NULL; ++ return; ++} ++ ++ ++void ++glusterd_stop_listener (xlator_t *this) ++{ ++ glusterd_conf_t *conf = NULL; ++ rpcsvc_listener_t *listener = NULL; ++ rpcsvc_listener_t *next = NULL; ++ int i = 0; ++ ++ GF_VALIDATE_OR_GOTO ("glusterd", this, out); ++ conf = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, conf, out); ++ ++ gf_log (this->name, GF_LOG_DEBUG, ++ "%s function called ", __func__); ++ ++ for (i = 0; i < gd_inet_programs_count; i++) { ++ rpcsvc_program_unregister (conf->rpc, gd_inet_programs[i]); ++ } ++ ++ list_for_each_entry_safe (listener, next, &conf->rpc->listeners, list) { ++ rpcsvc_listener_destroy (listener); ++ } ++ ++ (void) rpcsvc_unregister_notify (conf->rpc, ++ glusterd_rpcsvc_notify, ++ this); ++ ++out: + + return; + } +@@ -1743,8 +1773,19 @@ fini (xlator_t *this) + + conf = this->private; + +- glusterd_stop_uds_listener (this); ++ glusterd_stop_uds_listener (this); /*stop unix socket rpc*/ ++ glusterd_stop_listener (this); /*stop tcp/ip socket rpc*/ + ++#if 0 ++ /* Running threads might be using these resourses, we have to cancel/stop ++ * running threads before deallocating the memeory, but we don't have ++ * control over the running threads to do pthread_cancel(). ++ * So memeory freeing handover to kernel. ++ */ ++ /*TODO: cancel/stop the running threads*/ ++ ++ GF_FREE (conf->uds_rpc); ++ GF_FREE (conf->rpc); + FREE (conf->pmap); + if (conf->handle) + gf_store_handle_destroy (conf->handle); +@@ -1754,6 +1795,7 @@ fini (xlator_t *this) + GF_FREE (conf); + + this->private = NULL; ++#endif + out: + return; + } +-- +1.7.1 + diff --git a/SOURCES/0037-libglusterfs-Enabling-the-fini-in-cleanup_and_exit.patch b/SOURCES/0037-libglusterfs-Enabling-the-fini-in-cleanup_and_exit.patch new file mode 100644 index 0000000..72e908a --- /dev/null +++ b/SOURCES/0037-libglusterfs-Enabling-the-fini-in-cleanup_and_exit.patch @@ -0,0 +1,104 @@ +From 491a5a60132eb5bc143b75f0e94201a3ac15bd0e Mon Sep 17 00:00:00 2001 +From: anand +Date: Fri, 22 May 2015 18:18:11 +0530 +Subject: [PATCH 37/57] libglusterfs: Enabling the fini() in cleanup_and_exit() + +Problem 1 : glusterd was crashing due to race between clean up thread and rpc event thread. + +Scenario: +As we can observed, X thread is in the process of exiting the process. It has already +run the exit handlers, which cleanup things that require cleaning up. This includes +liburcu resources. By the time Y thread called rcu_bp_register(), the liburcu resources +have been cleaned up. rcu_bp_register() tries to access these non-existent resources, +which leads to the segmentation fault. + +Note1: +Crash happen when the process is almost at the point of stopping(exiting), it doesn't have any +serious impact to functionality apart from creating the core dump file and the log message. + +Fix .Do proper clean up before calling exit(). + +Note2: Other xlator have clean up issues,so only glusterd clean up function invoked. + +Note3: This patch also solve the selinux issue. + +Problem 2 : glusterd runs as rpm_script_t when it's executed from the rpm scriptlet,files created +in this context are set as rpm_script_t, so glusterd unable to access these files when it runs +in glusterd_t context. + +Fix: Fini clean up the files while glusterd exiting, so files are recreated by glusterd while +starting with proper SElinux context label. + +Backport of : +>Change-Id: Idcfd087f51c18a729bdf44a146f9d294e2fca5e2 +>BUG: 1209461 +>Signed-off-by: anand +>Reviewed-on: http://review.gluster.org/10894 +>Tested-by: Gluster Build System +>Reviewed-by: Atin Mukherjee +>Tested-by: NetBSD Build System +>Reviewed-by: Raghavendra Bhat +>Reviewed-by: Vijay Bellur + +Change-Id: I4b582f794a915c0bf380eaae3d23b8f075ce43fa +BUG: 1230195 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/50437 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + glusterfsd/src/glusterfsd.c | 27 +++++++++++++++++---------- + 1 files changed, 17 insertions(+), 10 deletions(-) + +diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c +index 61ae4e4..ffd1eb4 100644 +--- a/glusterfsd/src/glusterfsd.c ++++ b/glusterfsd/src/glusterfsd.c +@@ -1246,7 +1246,6 @@ cleanup_and_exit (int signum) + + glusterfs_pidfile_cleanup (ctx); + +- exit (0); + #if 0 + /* TODO: Properly do cleanup_and_exit(), with synchronization */ + if (ctx->mgmt) { +@@ -1254,19 +1253,27 @@ cleanup_and_exit (int signum) + rpc_clnt_connection_cleanup (&ctx->mgmt->conn); + rpc_clnt_unref (ctx->mgmt); + } ++#endif + + /* call fini() of each xlator */ +- trav = NULL; +- if (ctx->active) +- trav = ctx->active->top; +- while (trav) { +- if (trav->fini) { +- THIS = trav; +- trav->fini (trav); ++ ++ /*call fini for glusterd xlator */ ++ /* TODO : Invoke fini for rest of the xlators */ ++ if (ctx->process_mode == GF_GLUSTERD_PROCESS) { ++ ++ trav = NULL; ++ if (ctx->active) ++ trav = ctx->active->top; ++ while (trav) { ++ if (trav->fini) { ++ THIS = trav; ++ trav->fini (trav); ++ } ++ trav = trav->next; + } +- trav = trav->next; ++ + } +-#endif ++ exit(0); + } + + +-- +1.7.1 + diff --git a/SOURCES/0038-glusterd-disable-ping-timer.patch b/SOURCES/0038-glusterd-disable-ping-timer.patch new file mode 100644 index 0000000..e3a8f12 --- /dev/null +++ b/SOURCES/0038-glusterd-disable-ping-timer.patch @@ -0,0 +1,30 @@ +From bcf653e2819535e067807a06af77378d4c9674cd Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Wed, 10 Jun 2015 17:48:25 +0530 +Subject: [PATCH 38/57] glusterd: disable ping timer + +Change-Id: I21af57bcae0f6f9ec81bd701549b77585f0d7b7a +BUG: 1230186 +Signed-off-by: Atin Mukherjee +Reviewed-on: https://code.engineering.redhat.com/gerrit/50430 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + extras/glusterd.vol.in | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/extras/glusterd.vol.in b/extras/glusterd.vol.in +index 690dbe7..6de5e3b 100644 +--- a/extras/glusterd.vol.in ++++ b/extras/glusterd.vol.in +@@ -5,6 +5,6 @@ volume management + option transport.socket.keepalive-time 10 + option transport.socket.keepalive-interval 2 + option transport.socket.read-fail-log off +- option ping-timeout 30 ++ option ping-timeout 0 + # option base-port 49152 + end-volume +-- +1.7.1 + diff --git a/SOURCES/0039-cluster-ec-Wind-unlock-fops-at-all-cost.patch b/SOURCES/0039-cluster-ec-Wind-unlock-fops-at-all-cost.patch new file mode 100644 index 0000000..ffea194 --- /dev/null +++ b/SOURCES/0039-cluster-ec-Wind-unlock-fops-at-all-cost.patch @@ -0,0 +1,145 @@ +From 41a1392633c23a1e5a6f3963d5e3c337ad0ec518 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Wed, 10 Jun 2015 10:30:03 +0530 +Subject: [PATCH 39/57] cluster/ec: Wind unlock fops at all cost + + Backport of http://review.gluster.org/11152 + +Problem: +While files are being created if more than redundancy number of bricks +go down, then unlock for these fops do not go to the bricks. This will +lead to stale locks leading to hangs. + +Fix: +Wind unlock fops at all costs. + +BUG: 1224160 +Change-Id: I3312b0fe1694ad02af5307bcbaf233ac63058846 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50467 +--- + xlators/cluster/ec/src/ec-common.c | 27 ++++++++++++++++++++++++--- + xlators/cluster/ec/src/ec.c | 26 +++++++++++++++++++++----- + 2 files changed, 45 insertions(+), 8 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index f33384b..d9f3442 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -1421,7 +1421,7 @@ void ec_unlock_lock(ec_lock_link_t *link) + ec_trace("UNLOCK_INODELK", fop, "lock=%p, inode=%p", lock, + lock->loc.inode); + +- ec_inodelk(fop->frame, fop->xl, lock->mask, EC_MINIMUM_ALL, ++ ec_inodelk(fop->frame, fop->xl, lock->mask, EC_MINIMUM_ONE, + ec_unlocked, link, fop->xl->name, &lock->loc, F_SETLK, + &lock->flock, NULL); + } else { +@@ -1834,6 +1834,24 @@ void ec_lock_reuse(ec_fop_data_t *fop) + } + } + ++/* There could be already granted locks sitting on the bricks, unlock for which ++ * must be wound at all costs*/ ++static gf_boolean_t ++ec_must_wind (ec_fop_data_t *fop) ++{ ++ if ((fop->id == GF_FOP_INODELK) || (fop->id == GF_FOP_FINODELK) || ++ (fop->id == GF_FOP_LK)) { ++ if (fop->flock.l_type == F_UNLCK) ++ return _gf_true; ++ } else if ((fop->id == GF_FOP_ENTRYLK) || ++ (fop->id == GF_FOP_FENTRYLK)) { ++ if (fop->entrylk_cmd == ENTRYLK_UNLOCK) ++ return _gf_true; ++ } ++ ++ return _gf_false; ++} ++ + void __ec_manager(ec_fop_data_t * fop, int32_t error) + { + ec_t *ec = fop->xl->private; +@@ -1841,9 +1859,12 @@ void __ec_manager(ec_fop_data_t * fop, int32_t error) + do { + ec_trace("MANAGER", fop, "error=%d", error); + +- if (ec->xl_up_count < ec->fragments) { +- error = ENOTCONN; ++ if (!ec_must_wind (fop)) { ++ if (ec->xl_up_count < ec->fragments) { ++ error = ENOTCONN; ++ } + } ++ + if (error != 0) { + fop->error = error; + fop->state = -fop->state; +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index 4028aa4..797c390 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -625,7 +625,10 @@ int32_t ec_gf_entrylk(call_frame_t * frame, xlator_t * this, + const char * volume, loc_t * loc, const char * basename, + entrylk_cmd cmd, entrylk_type type, dict_t * xdata) + { +- ec_entrylk(frame, this, -1, EC_MINIMUM_ALL, default_entrylk_cbk, NULL, ++ int32_t minimum = EC_MINIMUM_ALL; ++ if (cmd == ENTRYLK_UNLOCK) ++ minimum = EC_MINIMUM_ONE; ++ ec_entrylk(frame, this, -1, minimum, default_entrylk_cbk, NULL, + volume, loc, basename, cmd, type, xdata); + + return 0; +@@ -635,7 +638,10 @@ int32_t ec_gf_fentrylk(call_frame_t * frame, xlator_t * this, + const char * volume, fd_t * fd, const char * basename, + entrylk_cmd cmd, entrylk_type type, dict_t * xdata) + { +- ec_fentrylk(frame, this, -1, EC_MINIMUM_ALL, default_fentrylk_cbk, NULL, ++ int32_t minimum = EC_MINIMUM_ALL; ++ if (cmd == ENTRYLK_UNLOCK) ++ minimum = EC_MINIMUM_ONE; ++ ec_fentrylk(frame, this, -1, minimum, default_fentrylk_cbk, NULL, + volume, fd, basename, cmd, type, xdata); + + return 0; +@@ -772,7 +778,11 @@ int32_t ec_gf_inodelk(call_frame_t * frame, xlator_t * this, + const char * volume, loc_t * loc, int32_t cmd, + struct gf_flock * flock, dict_t * xdata) + { +- ec_inodelk(frame, this, -1, EC_MINIMUM_ALL, default_inodelk_cbk, NULL, ++ int32_t minimum = EC_MINIMUM_ALL; ++ if (flock->l_type == F_UNLCK) ++ minimum = EC_MINIMUM_ONE; ++ ++ ec_inodelk(frame, this, -1, minimum, default_inodelk_cbk, NULL, + volume, loc, cmd, flock, xdata); + + return 0; +@@ -782,7 +792,10 @@ int32_t ec_gf_finodelk(call_frame_t * frame, xlator_t * this, + const char * volume, fd_t * fd, int32_t cmd, + struct gf_flock * flock, dict_t * xdata) + { +- ec_finodelk(frame, this, -1, EC_MINIMUM_ALL, default_finodelk_cbk, NULL, ++ int32_t minimum = EC_MINIMUM_ALL; ++ if (flock->l_type == F_UNLCK) ++ minimum = EC_MINIMUM_ONE; ++ ec_finodelk(frame, this, -1, minimum, default_finodelk_cbk, NULL, + volume, fd, cmd, flock, xdata); + + return 0; +@@ -800,7 +813,10 @@ int32_t ec_gf_link(call_frame_t * frame, xlator_t * this, loc_t * oldloc, + int32_t ec_gf_lk(call_frame_t * frame, xlator_t * this, fd_t * fd, + int32_t cmd, struct gf_flock * flock, dict_t * xdata) + { +- ec_lk(frame, this, -1, EC_MINIMUM_ALL, default_lk_cbk, NULL, fd, cmd, ++ int32_t minimum = EC_MINIMUM_ALL; ++ if (flock->l_type == F_UNLCK) ++ minimum = EC_MINIMUM_ONE; ++ ec_lk(frame, this, -1, minimum, default_lk_cbk, NULL, fd, cmd, + flock, xdata); + + return 0; +-- +1.7.1 + diff --git a/SOURCES/0040-build-fix-compiling-on-older-distributions.patch b/SOURCES/0040-build-fix-compiling-on-older-distributions.patch new file mode 100644 index 0000000..37ac35d --- /dev/null +++ b/SOURCES/0040-build-fix-compiling-on-older-distributions.patch @@ -0,0 +1,452 @@ +From 1397ddaf3a9c75717677b6ee7ca2c7ec096e7f66 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Wed, 10 Jun 2015 10:09:02 +0200 +Subject: [PATCH 40/57] build: fix compiling on older distributions + +data-tiering is disabled on RHEL-5 because it depends on a too new +SQLite version. + +This change also prevents installing some of files that are used by +geo-replication, which is also not available on RHEL-5. geo-replication +depends on a too recent version of Python. + +Due to an older version of OpenSSL, some of the newer functions can not +be used. A fallback to previous functions is done. Unfortunately RHEL-5 +does not seem to have TLSv1.2 support, so only older versions can be +used. + +Backport of the upstream commits from http://review.gluster.org/11096: +> Cherry picked from commit 0209b18fd65f9df5ebd0a8764ebf864d0d392998: +> > Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913 +> > BUG: 1222317 +> > Signed-off-by: Niels de Vos +> > Reviewed-on: http://review.gluster.org/10803 +> > Tested-by: NetBSD Build System +> > Tested-by: Gluster Build System +> > Reviewed-by: Kaleb KEITHLEY +> > Reviewed-by: Vijay Bellur +> +> Also including the changes from http://review.gluster.org/11140: +> +> > build: improve detection of new OpenSSL features +> > +> > Building on Mac OS X revealed that the current check for +> > CRYPTO_THREADID_set_callback() availability in OpenSSL is not correct. +> > +> > There also does not seem to be a guarantee that TLSv1_2_method() is +> > available when TLS1_2_VERSION is #define'd. +> > +> > Change-Id: I21508065fc181a1c74bee4fd6d23bb5bdf7cea7a +> > BUG: 1222317 +> > Reviewed-on: http://review.gluster.org/11140 +> > Original-author: Kaleb KEITHLEY +> > Signed-off-by: Niels de Vos +> +> Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913 +> BUG: 1228510 +> Signed-off-by: Niels de Vos + +Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913 +BUG: 1230114 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50445 +Reviewed-by: Atin Mukherjee +--- + Makefile.am | 5 ++- + configure.ac | 50 ++++++++++++++++++++------------ + extras/Makefile.am | 4 +- + extras/geo-rep/Makefile.am | 2 +- + extras/hook-scripts/Makefile.am | 2 + + geo-replication/src/Makefile.am | 2 +- + glusterfs.spec.in | 47 +++++++++++++++++++++++++------ + rpc/rpc-transport/socket/src/socket.c | 18 ++++++++++++ + 8 files changed, 97 insertions(+), 33 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 82175ee..628bc48 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -15,7 +15,10 @@ SUBDIRS = $(ARGP_STANDALONE_DIR) libglusterfs rpc api xlators glusterfsd \ + @UMOUNTD_SUBDIR@ tools + + pkgconfigdir = @pkgconfigdir@ +-pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc libgfdb.pc ++pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc ++if USE_GFDB ++pkgconfig_DATA += libgfdb.pc ++endif + + CLEANFILES = + CONFIG_CLEAN_FILES = $(CONTRIB_BUILDDIR)/uuid/uuid_types.h +diff --git a/configure.ac b/configure.ac +index 1a09854..a93c1cd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -388,14 +388,7 @@ AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sy + AC_CHECK_HEADERS([sys/extattr.h]) + + dnl Math library +-case $host_os in +- linux*) +- MATH_LIB='' +- ;; +- *) +- MATH_LIB='-lm' +- ;; +-esac ++AC_CHECK_LIB([m], [pow], [MATH_LIB='-lm'], [MATH_LIB='']) + AC_SUBST(MATH_LIB) + + dnl use libuuid.so or fall-back to contrib/uuid +@@ -406,6 +399,16 @@ PKG_CHECK_MODULES([UUID], [uuid], + [HAVE_LIBUUID=no + UUID_CFLAGS='-I$(CONTRIBDIR)/uuid']) + AM_CONDITIONAL([HAVE_LIBUUID], [test x$HAVE_LIBUUID = xyes]) ++ ++dnl older version of libuuid (from e2fsprogs) require including uuid/uuid.h ++saved_CFLAGS=${CFLAGS} ++CFLAGS="${CFLAGS} ${UUID_CFLAGS}" ++AC_CHECK_HEADER([uuid.h], [], [AC_CHECK_HEADER([uuid/uuid.h])]) ++CFLAGS=${saved_CFLAGS} ++if test "x$ac_cv_header_uuid_uuid_h" = "xyes"; then ++ UUID_CFLAGS="${UUID_CFLAGS} -I$(pkg-config --variable=includedir uuid)/uuid" ++fi ++ + dnl libglusterfs needs uuid.h, practically everything depends on it + GF_CPPFLAGS="${GF_CPPFLAGS} ${UUID_CFLAGS}" + dnl PKGCONFIG_UUID is used for the dependency in *.pc.in files +@@ -530,6 +533,11 @@ fi + + AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes]) + ++dnl check for old openssl ++AC_CHECK_LIB([crypto], CRYPTO_THREADID_set_callback, [AC_DEFINE([HAVE_CRYPTO_THREADID], [1], [use new OpenSSL functions])]) ++ ++AC_CHECK_LIB([ssl], TLSv1_2_method, [AC_DEFINE([HAVE_TLSV1_2_METHOD], [1], [use new OpenSSL functions])]) ++ + # start encryption/crypt section + + AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no]) +@@ -705,6 +713,7 @@ if test "x$enable_georeplication" != "xno"; then + GEOREP_EXTRAS_SUBDIR=geo-rep + fi + AC_SUBST(GEOREP_EXTRAS_SUBDIR) ++AM_CONDITIONAL(USE_GEOREP, test "x$enable_georeplication" != "xno") + + # CDC xlator - check if libz is present if so enable HAVE_LIB_Z + BUILD_CDC=yes +@@ -808,11 +817,8 @@ AC_SUBST(HAVE_BACKTRACE) + + if test "x${have_backtrace}" != "xyes"; then + AC_TRY_COMPILE([#include ], [double x=0.0; x=ceil(0.0);], +- [have_math_h=yes], ++ [], + AC_MSG_ERROR([need math library for libexecinfo])) +-if test "x${have_math_h}" = "xyes"; then +- LIBS="$LIBS -lm" +-fi + fi + + dnl glusterfs prints memory usage to stderr by sending it SIGUSR1 +@@ -905,26 +911,29 @@ GF_HOST_OS="" + GF_LDFLAGS="-rdynamic" + + dnl check for gcc -Werror=format-security +-saved_GF_CFLAGS="-Wformat -Werror=format-security" ++saved_CFLAGS=$CFLAGS ++CFLAGS="-Wformat -Werror=format-security" + AC_MSG_CHECKING([whether $CC accepts -Werror=format-security]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no]) + echo $cc_werror_format_security + if test "x$cc_werror_format_security" = "xno"; then +- GF_CFLAGS="$GF_CFLAGS" ++ CFLAGS="$saved_CFLAGS" + else +- GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS" ++ CFLAGS="$saved_CFLAGS $CFLAGS" ++ GF_CFLAGS="$GF_CFLAGS $CFLAGS" + fi + + dnl check for gcc -Werror=implicit-function-declaration +-saved_GF_CFLAGS=$GF_CFLAGS +-GF_CFLAGS="-Werror=implicit-function-declaration" ++saved_CFLAGS=$CFLAGS ++CFLAGS="-Werror=implicit-function-declaration" + AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no]) + echo $cc_werror_implicit + if test "x$cc_werror_implicit" = "xno"; then +- GF_CFLAGS="$saved_GF_CFLAGS" ++ CFLAGS="$saved_CFLAGS" + else +- GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS" ++ CFLAGS="$saved_CFLAGS $CFLAGS" ++ GF_CFLAGS="$GF_CFLAGS $CFLAGS" + fi + + dnl clang is mostly GCC-compatible, but its version is much lower, +@@ -1242,6 +1251,9 @@ AC_SUBST(UNITTEST_LDFLAGS) + AC_SUBST(CFLAGS) + # end enable debug section + ++dnl libglusterfs.so uses math functions ++GF_LDADD="${GF_LDADD} ${MATH_LIB}" ++ + AC_SUBST(GF_HOST_OS) + AC_SUBST(GF_CFLAGS) + AC_SUBST(GF_LDFLAGS) +diff --git a/extras/Makefile.am b/extras/Makefile.am +index d54f750..ba2bef3 100644 +--- a/extras/Makefile.am ++++ b/extras/Makefile.am +@@ -1,5 +1,5 @@ +-gsyncddir = $(libexecdir)/glusterfs +-gsyncd_SCRIPTS = peer_add_secret_pub ++addonexecdir = $(libexecdir)/glusterfs ++addonexec_SCRIPTS = peer_add_secret_pub + + EditorModedir = $(docdir) + EditorMode_DATA = glusterfs-mode.el glusterfs.vim +diff --git a/extras/geo-rep/Makefile.am b/extras/geo-rep/Makefile.am +index e0aab77..7ebede3 100644 +--- a/extras/geo-rep/Makefile.am ++++ b/extras/geo-rep/Makefile.am +@@ -5,7 +5,7 @@ scripts_DATA = gsync-upgrade.sh generate-gfid-file.sh get-gfid.sh \ + scripts_PROGRAMS = gsync-sync-gfid + gsync_sync_gfid_CFLAGS = $(GF_CFLAGS) -Wall -I$(top_srcdir)/libglusterfs/src + gsync_sync_gfid_LDFLAGS = $(GF_LDFLAGS) +-gsync_sync_gfid_LDADD = $(GF_LIBS) $(top_builddir)/libglusterfs/src/libglusterfs.la ++gsync_sync_gfid_LDADD = $(GF_LDADD) $(top_builddir)/libglusterfs/src/libglusterfs.la + gsync_sync_gfid_SOURCES = gsync-sync-gfid.c + gsync_sync_gfid_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/extras/hook-scripts/Makefile.am b/extras/hook-scripts/Makefile.am +index fa126f9..771b37e 100644 +--- a/extras/hook-scripts/Makefile.am ++++ b/extras/hook-scripts/Makefile.am +@@ -2,4 +2,6 @@ EXTRA_DIST = S40ufo-stop.py S56glusterd-geo-rep-create-post.sh + SUBDIRS = add-brick set start stop reset + + scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/gsync-create/post/ ++if USE_GEOREP + scripts_SCRIPTS = S56glusterd-geo-rep-create-post.sh ++endif +diff --git a/geo-replication/src/Makefile.am b/geo-replication/src/Makefile.am +index e9d6bc1..1572698 100644 +--- a/geo-replication/src/Makefile.am ++++ b/geo-replication/src/Makefile.am +@@ -11,7 +11,7 @@ gsyncd_PROGRAMS = gsyncd + + gsyncd_SOURCES = gsyncd.c procdiggy.c + +-gsyncd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la ++gsyncd_LDADD = $(GF_LDADD) $(top_builddir)/libglusterfs/src/libglusterfs.la + + gsyncd_LDFLAGS = $(GF_LDFLAGS) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index dc87e83..0e69bc6 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -89,6 +89,11 @@ + %global _without_extra_xlators 1 + %global _without_regression_tests 1 + ++# Disable data-tiering on EL5, sqlite is too old ++%if ( 0%{?rhel} && 0%{?rhel} < 6 ) ++%global _without_tiering --disable-tiering ++%endif ++ + ##----------------------------------------------------------------------------- + ## All %global definitions should be placed here and keep them sorted + ## +@@ -213,11 +218,17 @@ BuildRequires: libaio-devel libacl-devel + BuildRequires: python-devel + BuildRequires: python-ctypes + BuildRequires: userspace-rcu-devel >= 0.7 ++%if ( 0%{?rhel} && 0%{?rhel} <= 5 ) ++BuildRequires: e2fsprogs-devel ++%else + BuildRequires: libuuid-devel ++%endif + %if ( 0%{?_with_cmocka:1} ) + BuildRequires: libcmocka-devel >= 1.0.1 + %endif ++%if ( 0%{!?_without_tiering:1} ) + BuildRequires: sqlite-devel ++%endif + %if ( 0%{!?_without_systemtap:1} ) + BuildRequires: systemtap-sdt-devel + %endif +@@ -604,17 +615,19 @@ This package provides the translators needed on any GlusterFS client. + # there is no need to run ./autogen or have a BuildRequires for automake. + ./autogen.sh + %configure \ ++./autogen.sh && %configure \ ++ %{?_with_cmocka} \ + %{?_with_tmpfilesdir} \ +- %{?_without_rdma} \ ++ %{?_without_bd} \ + %{?_without_epoll} \ + %{?_without_fusermount} \ + %{?_without_georeplication} \ + %{?_without_ocf} \ +- %{?_without_syslog} \ +- %{?_without_bd} \ + %{?_without_qemu_block} \ ++ %{?_without_rdma} \ ++ %{?_without_syslog} \ + %{?_without_systemtap} \ +- %{?_with_cmocka} ++ %{?_without_tiering} + + # fix hardening and remove rpath in shlibs + %if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) +@@ -1032,7 +1045,10 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/error-gen.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/io-stats.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/trace.so ++%if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) ) ++# RHEL-5 based distributions have a too old openssl + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/crypt.so ++%endif + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/access-control.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/barrier.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/cdc.so +@@ -1063,8 +1079,6 @@ fi + + %files api-devel + %{_libdir}/pkgconfig/glusterfs-api.pc +-%{_libdir}/pkgconfig/libgfchangelog.pc +-%{_libdir}/pkgconfig/libgfdb.pc + %{_libdir}/libgfapi.so + %{_includedir}/glusterfs/api/* + +@@ -1083,12 +1097,18 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/debug-trace.* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/helloworld.* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/negative.* ++%{_libdir}/pkgconfig/libgfchangelog.pc ++%if ( 0%{!?_without_tiering:1} ) ++%{_libdir}/pkgconfig/libgfdb.pc ++%endif + + %files client-xlators + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/*.so + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/ganesha.so ++%if ( 0%{!?_without_qemu_block:1} ) + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/qemu-block.so ++%endif + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/client.so + + %if ( 0%{!?_without_extra_xlators:1} ) +@@ -1151,18 +1171,18 @@ fi + %{_datadir}/glusterfs/scripts/generate-gfid-file.sh + %{_datadir}/glusterfs/scripts/gsync-sync-gfid + %ghost %attr(0644,-,-) %{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf ++%endif + %{_libexecdir}/glusterfs/gfind_missing_files + %{_sbindir}/gfind_missing_files +-%exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyo +-%exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyc +-%endif + %endif + + %files libs + %{_libdir}/*.so.* + %exclude %{_libdir}/libgfapi.* ++%if ( 0%{!?_without_tiering:1} ) + # libgfdb is only needed server-side + %exclude %{_libdir}/libgfdb.* ++%endif + + %files -n python-gluster + # introducing glusterfs module in site packages. +@@ -1234,7 +1254,9 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so ++%if ( 0%{!?_without_tiering:1} ) + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so ++%endif + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* +@@ -1247,7 +1269,9 @@ fi + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* ++%if ( 0%{!?_without_tiering:1} ) + %{_libdir}/libgfdb.so.* ++%endif + + #snap_scheduler + %{_sbindir}/snap_scheduler.py +@@ -1709,6 +1733,11 @@ end + %endif + + %changelog ++* Wed Jun 10 2015 Niels de Vos ++- Fix building on RHEL-5 based distributions ++ ++* Wed Jun 3 2015 Kaleb S. KEITHLEY ++- move libgf{db,changelog}.pc from -api-devel to -devel (#1223390) + * Sun May 31 2015 Milind Changire + - Move file peer_add_secret_pub to the server RPM to support glusterfind (#1225552) + +diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c +index e30e231..a39c16d 100644 +--- a/rpc/rpc-transport/socket/src/socket.c ++++ b/rpc/rpc-transport/socket/src/socket.c +@@ -3714,6 +3714,7 @@ locking_func (int mode, int type, const char *file, int line) + } + } + ++#if HAVE_CRYPTO_THREADID + static void + threadid_func (CRYPTO_THREADID *id) + { +@@ -3729,6 +3730,14 @@ threadid_func (CRYPTO_THREADID *id) + */ + CRYPTO_THREADID_set_numeric (id, (unsigned long)pthread_self()); + } ++#else /* older openssl */ ++static unsigned long ++legacy_threadid_func (void) ++{ ++ /* See comments above, it applies here too. */ ++ return (unsigned long)pthread_self(); ++} ++#endif + + static void __attribute__((constructor)) + init_openssl_mt (void) +@@ -3743,7 +3752,11 @@ init_openssl_mt (void) + pthread_mutex_init (&lock_array[i], NULL); + } + CRYPTO_set_locking_callback (locking_func); ++#if HAVE_CRYPTO_THREADID + CRYPTO_THREADID_set_callback (threadid_func); ++#else /* older openssl */ ++ CRYPTO_set_id_callback (legacy_threadid_func); ++#endif + constructor_ok = _gf_true; + } + +@@ -3992,7 +4005,12 @@ socket_init (rpc_transport_t *this) + goto err; + } + ++#if HAVE_TLSV1_2_METHOD + priv->ssl_meth = (SSL_METHOD *)TLSv1_2_method(); ++#else /* old openssl */ ++#warning TLSv1.2 is not available, using insecure TLSv1 support ++ priv->ssl_meth = (SSL_METHOD *)TLSv1_method(); ++#endif + priv->ssl_ctx = SSL_CTX_new(priv->ssl_meth); + + if (SSL_CTX_set_cipher_list(priv->ssl_ctx, cipher_list) == 0) { +-- +1.7.1 + diff --git a/SOURCES/0041-rpm-correct-date-and-order-of-entries-in-the-changel.patch b/SOURCES/0041-rpm-correct-date-and-order-of-entries-in-the-changel.patch new file mode 100644 index 0000000..e3bb2eb --- /dev/null +++ b/SOURCES/0041-rpm-correct-date-and-order-of-entries-in-the-changel.patch @@ -0,0 +1,58 @@ +From 96bcc9bdf016b5298bb1d1f7989441c3dc4875a2 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Tue, 9 Jun 2015 19:02:42 +0200 +Subject: [PATCH 41/57] rpm: correct date and order of entries in the %changelog + +When modern versions of "rpmbuild" are used to produse src.rpms, an +error will be reported when the %changelog has incorrect days/dates and +entries are not sorted correctly. + +Cherry picked from commit f7c1eeadcd047e423f6abef2090db6a1b1a9ec42: +> BUG: 1228510 +> Change-Id: I3156787d051d7878323c1847b95da196646787b6 +> Signed-off-by: Niels de Vos +> Reviewed-on: http://review.gluster.org/11142 +> Reviewed-by: Kaleb KEITHLEY +> Tested-by: NetBSD Build System + +BUG: 1230114 +Change-Id: Ibf4919dc0a633fea5d04744317b3f477a97ea0a4 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50446 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + glusterfs.spec.in | 9 +++++---- + 1 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 0e69bc6..2225f19 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1738,18 +1738,19 @@ end + + * Wed Jun 3 2015 Kaleb S. KEITHLEY + - move libgf{db,changelog}.pc from -api-devel to -devel (#1223390) ++ + * Sun May 31 2015 Milind Changire + - Move file peer_add_secret_pub to the server RPM to support glusterfind (#1225552) + +-* Sat May 31 2015 Aravinda VK ++* Sun May 31 2015 Aravinda VK + - Added stop-all-gluster-processes.sh in glusterfs-server section (#1225331) + +-* Tue May 19 2015 Avra Sengupta +-- Added S32gluster_enable_shared_storage.sh as volume set hook script (#1222013) +- + * Fri May 29 2015 Anand Nekkunti + - glusterd.socket file cleanup during post run upgrade (#1222869) + ++* Tue May 19 2015 Avra Sengupta ++- Added S32gluster_enable_shared_storage.sh as volume set hook script (#1222013) ++ + * Fri May 08 2015 Niels de Vos + - Introduce glusterfs-client-xlators to reduce dependencies (#1219089) + +-- +1.7.1 + diff --git a/SOURCES/0042-nfs-ganesha-HA-fix-race-between-setting-grace-and-vi.patch b/SOURCES/0042-nfs-ganesha-HA-fix-race-between-setting-grace-and-vi.patch new file mode 100644 index 0000000..17a3492 --- /dev/null +++ b/SOURCES/0042-nfs-ganesha-HA-fix-race-between-setting-grace-and-vi.patch @@ -0,0 +1,74 @@ +From c8d1751014bc34d33dfe6db1820174ef7e733404 Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Fri, 5 Jun 2015 10:56:25 -0400 +Subject: [PATCH 42/57] nfs-ganesha: HA, fix race between setting grace and virt IP fail-over + +upstream BZs: 1227028 (release-3.7), 1219485 (main), 1216039 + +Change-Id: I17eb2f7a5eae677123f12ab7eaf650fbf4d07682 +BUG: 1224618 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/50134 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + extras/ganesha/ocf/ganesha_mon | 24 ++++++++++++++---------- + 1 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon +index 6ba7178..47943f8 100644 +--- a/extras/ganesha/ocf/ganesha_mon ++++ b/extras/ganesha/ocf/ganesha_mon +@@ -36,6 +36,8 @@ else + . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + fi + ++GRACE_DELAY=7 ++ + ganesha_meta_data() { + cat < +@@ -98,13 +100,7 @@ ganesha_mon_monitor() + + if [ -e /var/run/ganesha.nfsd.pid -a \ + -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then +- # logger "note: ganesha_mon_monitor() pcs resource delete ${short_host}-dead_ip-1" +- pcs resource delete ${short_host}-dead_ip-1 +- # if [ $? -ne 0 ]; then +- # logger "warning: pcs resource delete ${short_host}-dead_ip-1" +- # fi +- +- sleep 1 ++ ( pcs resource delete ${short_host}-dead_ip-1 > /dev/null 2>&1 ) + + attrd_updater -n ganesha-active -v 1 + if [ $? -ne 0 ]; then +@@ -112,13 +108,21 @@ ganesha_mon_monitor() + fi + + else +- # logger "note: ganesha_mon_montor(), pcs resource create ${short_host}-dead_ip-1 ocf:heartbeat:Dummy" +- pcs resource create ${short_host}-dead_ip-1 ocf:heartbeat:Dummy ++ ( pcs resource create ${short_host}-dead_ip-1 ocf:heartbeat:Dummy > /dev/null 2>&1 ) + if [ $? -ne 0 ]; then + logger "warning: pcs resource create ${short_host}-dead_ip-1 ocf:heartbeat:Dummy failed" + fi + +- sleep 1 ++ # The ${this-node}-dead_ip-1 resource is used to indicate ++ # that this ganesha.nfsd has died. ++ # VIP fail-over is then triggered by clearing the ++ # ganesha-active node attribute on this node. ++ # ++ # Meanwhile the ganesha_grace monitor() runs every 5 ++ # seconds. We need to allow time for it to run and put ++ # the remaining ganesha.nfsds into grace before initiating ++ # the VIP fail-over. ++ sleep ${GRACE_DELAY} + + attrd_updater -D -n ganesha-active + if [ $? -ne 0 ]; then +-- +1.7.1 + diff --git a/SOURCES/0043-logging-log-Stale-filehandle-on-the-client-as-Debug.patch b/SOURCES/0043-logging-log-Stale-filehandle-on-the-client-as-Debug.patch new file mode 100644 index 0000000..5cca004 --- /dev/null +++ b/SOURCES/0043-logging-log-Stale-filehandle-on-the-client-as-Debug.patch @@ -0,0 +1,66 @@ +From d5ec5956a627bdff35e9a92b55226be79b10fc6a Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Thu, 11 Jun 2015 01:10:08 +0200 +Subject: [PATCH 43/57] logging: log "Stale filehandle" on the client as Debug + +There are valid use-cases where a "Stale filehandle" is expected. One of +these is deleting a file through NFS-Ganesha. When the "filename" is +deleted, Ganesha will stat the file-handle to update its attributes. The +file-handle would still be valid in the case where there are hardlinks. + +There is no need to log "Stale filehandle" as Warning. It is perfectly +fine to have this logged as Debug. + +Backported from http://review.gluster.org/11169: +> Cherry picked from commit ec7d0c3de11cbee1470308dcc10ec9f02e7fdfff: +> > Change-Id: Ib9006d95a5d1f7dd394bf5d5994ad70740ad4ab2 +> > BUG: 1228731 +> > Signed-off-by: Niels de Vos +> > Reviewed-on: http://review.gluster.org/11107 +> > Reviewed-by: Kaleb KEITHLEY +> > Tested-by: Gluster Build System +> > Reviewed-by: soumya k +> > Reviewed-by: jiffin tony Thottan +> +> Change-Id: Ib9006d95a5d1f7dd394bf5d5994ad70740ad4ab2 +> BUG: 1228729 +> Signed-off-by: Niels de Vos + +Change-Id: Ib9006d95a5d1f7dd394bf5d5994ad70740ad4ab2 +BUG: 1224215 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50478 +Reviewed-by: Jiffin Thottan +Reviewed-by: Soumya Koduri +--- + xlators/protocol/client/src/client-rpc-fops.c | 7 +++++-- + 1 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c +index d4021f5..e5912bd 100644 +--- a/xlators/protocol/client/src/client-rpc-fops.c ++++ b/xlators/protocol/client/src/client-rpc-fops.c +@@ -476,7 +476,6 @@ client3_3_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, + xlator_t *this = NULL; + dict_t *xdata = NULL; + +- + this = THIS; + + frame = myframe; +@@ -504,7 +503,11 @@ client3_3_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ /* stale filehandles are possible during normal operations, no ++ * need to spam the logs with these */ ++ gf_log (this->name, ++ rsp.op_errno == ESTALE ? GF_LOG_DEBUG : GF_LOG_WARNING, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + +-- +1.7.1 + diff --git a/SOURCES/0044-snapshot-scheduler-Handle-OSError-in-os.-callbacks.patch b/SOURCES/0044-snapshot-scheduler-Handle-OSError-in-os.-callbacks.patch new file mode 100644 index 0000000..11ba9fc --- /dev/null +++ b/SOURCES/0044-snapshot-scheduler-Handle-OSError-in-os.-callbacks.patch @@ -0,0 +1,99 @@ +From 44b0118984991c73e6552c267a35c4f0e2d4ea88 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Thu, 4 Jun 2015 17:17:13 +0530 +Subject: [PATCH 44/57] snapshot/scheduler: Handle OSError in os. callbacks + + Backport of http://review.gluster.org/#/c/11087/ + +Handle OSError and not IOError in os. callbacks. + +Change-Id: I2b5bfb629bacbd2d2e410d96034b4e2c11c4931e +BUG: 1224249 +Signed-off-by: Avra Sengupta +(cherry picked from commit d835219a30327ede60e4ef28210914ab30bd0712) +Reviewed-on: https://code.engineering.redhat.com/gerrit/50512 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/snap_scheduler.py | 16 ++++++++-------- + 1 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index 1c5f938..b692980 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -129,7 +129,7 @@ def enable_scheduler(): + f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK, + 0644) + os.close(f) +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + GCRON_ENABLED, strerror) + ret = INTERNAL_ERROR +@@ -139,7 +139,7 @@ def enable_scheduler(): + log.info("Snapshot scheduling is enabled") + output("Snapshot scheduling is enabled") + ret = 0 +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + print_str = "Failed to enable snapshot scheduling. Error: "+strerror + log.error(print_str) + output(print_str) +@@ -188,7 +188,7 @@ def disable_scheduler(): + log.info("Snapshot scheduling is disabled") + output("Snapshot scheduling is disabled") + ret = 0 +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + print_str = "Failed to disable snapshot scheduling. Error: "+strerror + log.error(print_str) + output(print_str) +@@ -343,7 +343,7 @@ def add_schedules(jobname, schedule, volname): + try: + f = os.open(job_lockfile, os.O_CREAT | os.O_NONBLOCK, 0644) + os.close(f) +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + job_lockfile, strerror) + ret = INTERNAL_ERROR +@@ -372,7 +372,7 @@ def delete_schedules(jobname): + job_lockfile = LOCK_FILE_DIR+jobname + try: + os.remove(job_lockfile) +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + log.error("Failed to open %s. Error: %s.", + job_lockfile, strerror) + ret = INTERNAL_ERROR +@@ -630,7 +630,7 @@ def main(): + if not os.path.exists(SHARED_STORAGE_DIR+"/snaps/"): + try: + os.makedirs(SHARED_STORAGE_DIR+"/snaps/") +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + if errno != EEXIST: + log.error("Failed to create %s : %s", SHARED_STORAGE_DIR+"/snaps/", strerror) + output("Failed to create %s. Error: %s" +@@ -644,7 +644,7 @@ def main(): + if not os.path.exists(LOCK_FILE_DIR): + try: + os.makedirs(LOCK_FILE_DIR) +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + if errno != EEXIST: + log.error("Failed to create %s : %s", LOCK_FILE_DIR, strerror) + output("Failed to create %s. Error: %s" +@@ -666,7 +666,7 @@ def main(): + "Please try again after some time.") + return ANOTHER_TRANSACTION_IN_PROGRESS + os.close(f) +- except IOError as (errno, strerror): ++ except OSError as (errno, strerror): + log.error("Failed to open %s : %s", LOCK_FILE, strerror) + output("Failed to open %s. Error: %s" % (LOCK_FILE, strerror)) + return INTERNAL_ERROR +-- +1.7.1 + diff --git a/SOURCES/0045-snapshot-scheduler-Check-if-GCRON_TASKS-exists-befor.patch b/SOURCES/0045-snapshot-scheduler-Check-if-GCRON_TASKS-exists-befor.patch new file mode 100644 index 0000000..f8eb1c3 --- /dev/null +++ b/SOURCES/0045-snapshot-scheduler-Check-if-GCRON_TASKS-exists-befor.patch @@ -0,0 +1,37 @@ +From 3d87db3f042c5e9e436e598d781eb9f8c33a9129 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Tue, 9 Jun 2015 17:49:23 +0530 +Subject: [PATCH 45/57] snapshot/scheduler: Check if GCRON_TASKS exists before + accessing it's mtime + + Backport of http://review.gluster.org/#/c/11138/ + +Change-Id: I873c83d21620527b20d7de428d11582c5499d1af +BUG: 1228164 +Signed-off-by: Avra Sengupta +(cherry picked from commit 5b05d3e376e984f00528f5bf2f0febd0220ca91f) +Reviewed-on: https://code.engineering.redhat.com/gerrit/50513 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/gcron.py | 4 ++++ + 1 files changed, 4 insertions(+), 0 deletions(-) + +diff --git a/extras/snap_scheduler/gcron.py b/extras/snap_scheduler/gcron.py +index e67e48c..a21c40f 100755 +--- a/extras/snap_scheduler/gcron.py ++++ b/extras/snap_scheduler/gcron.py +@@ -120,6 +120,10 @@ def main(): + initLogger(script_name) + global start_time + if sys.argv[1] == "--update": ++ if not os.path.exists(GCRON_TASKS): ++ return ++ if not os.path.exists(GCRON_CROND_TASK): ++ return + if os.lstat(GCRON_TASKS).st_mtime > \ + os.lstat(GCRON_CROND_TASK).st_mtime: + try: +-- +1.7.1 + diff --git a/SOURCES/0046-storage-posix-Handle-MAKE_INODE_HANDLE-failures.patch b/SOURCES/0046-storage-posix-Handle-MAKE_INODE_HANDLE-failures.patch new file mode 100644 index 0000000..eae8bcc --- /dev/null +++ b/SOURCES/0046-storage-posix-Handle-MAKE_INODE_HANDLE-failures.patch @@ -0,0 +1,38 @@ +From 07e29eabdf3fc3cede375a2ac63635dc5dbc385a Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Mon, 1 Jun 2015 13:34:33 +0530 +Subject: [PATCH 46/57] storage/posix: Handle MAKE_INODE_HANDLE failures + + Backport of http://review.gluster.com/11028 + +Change-Id: Ia176ccd4cac82c66ba50e3896fbe72c2da860c20 +BUG: 1228496 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50506 +--- + xlators/storage/posix/src/posix.c | 8 +++++++- + 1 files changed, 7 insertions(+), 1 deletions(-) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 71b83c2..2a1df28 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -4921,8 +4921,14 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + _fd = pfd->fd; + } + +- if (loc && !gf_uuid_is_null (loc->gfid)) ++ if (loc && !gf_uuid_is_null (loc->gfid)) { + MAKE_INODE_HANDLE (real_path, this, loc, NULL); ++ if (!real_path) { ++ op_ret = -1; ++ op_errno = ESTALE; ++ goto out; ++ } ++ } + + if (real_path) { + inode = loc->inode; +-- +1.7.1 + diff --git a/SOURCES/0047-snapshot-scheduler-Reload-etc-cron.d-glusterfs_snap_.patch b/SOURCES/0047-snapshot-scheduler-Reload-etc-cron.d-glusterfs_snap_.patch new file mode 100644 index 0000000..5c7c3b4 --- /dev/null +++ b/SOURCES/0047-snapshot-scheduler-Reload-etc-cron.d-glusterfs_snap_.patch @@ -0,0 +1,79 @@ +From 6220dbf7cf45946eb1474a2da5113c90244cebcc Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Tue, 9 Jun 2015 18:00:57 +0530 +Subject: [PATCH 47/57] snapshot/scheduler: Reload /etc/cron.d/glusterfs_snap_cron_tasks when shared storage is available + + Backport of http://review.gluster.org/#/c/11139/ + +If shared storage is not accessible, create a flag in /var/run/gluster/ +So that when /etc/cron.d/glusterfs_snap_cron_tasks is +available again, the flag will tell us, to reload +/etc/cron.d/glusterfs_snap_cron_tasks + +Change-Id: I41b19f57ff0b8f7e0b820eaf592b0fdedb0a5d86 +BUG: 1223205 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/50514 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/gcron.py | 33 +++++++++++++++++++++++++++++++++ + 1 files changed, 33 insertions(+), 0 deletions(-) + +diff --git a/extras/snap_scheduler/gcron.py b/extras/snap_scheduler/gcron.py +index a21c40f..d720578 100755 +--- a/extras/snap_scheduler/gcron.py ++++ b/extras/snap_scheduler/gcron.py +@@ -21,6 +21,7 @@ import fcntl + + GCRON_TASKS = "/var/run/gluster/shared_storage/snaps/glusterfs_snap_cron_tasks" + GCRON_CROND_TASK = "/etc/cron.d/glusterfs_snap_cron_tasks" ++GCRON_RELOAD_FLAG = "/var/run/gluster/crond_task_reload_flag" + LOCK_FILE_DIR = "/var/run/gluster/shared_storage/snaps/lock_files/" + log = logging.getLogger("gcron-logger") + start_time = 0.0 +@@ -121,9 +122,41 @@ def main(): + global start_time + if sys.argv[1] == "--update": + if not os.path.exists(GCRON_TASKS): ++ # Create a flag in /var/run/gluster which indicates that this nodes ++ # doesn't have access to GCRON_TASKS right now, so that ++ # when the mount is available and GCRON_TASKS is available ++ # the flag will tell this routine to reload GCRON_CROND_TASK ++ try: ++ f = os.open(GCRON_RELOAD_FLAG, os.O_CREAT | os.O_NONBLOCK, 0644) ++ os.close(f) ++ except OSError as (errno, strerror): ++ if errno != EEXIST: ++ log.error("Failed to create %s : %s", ++ GCRON_RELOAD_FLAG, strerror) ++ output("Failed to create %s. Error: %s" ++ % (GCRON_RELOAD_FLAG, strerror)) + return ++ + if not os.path.exists(GCRON_CROND_TASK): + return ++ ++ # As GCRON_TASKS exists now, we should check if GCRON_RELOAD_FLAG ++ # also exists. If so we should touch GCRON_CROND_TASK and remove ++ # the GCRON_RELOAD_FLAG ++ if os.path.exists(GCRON_RELOAD_FLAG): ++ try: ++ os.remove(GCRON_RELOAD_FLAG); ++ process = subprocess.Popen(["touch", "-h", GCRON_CROND_TASK], ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ out, err = process.communicate() ++ if process.returncode != 0: ++ log.error("Failed to touch %s. Error: %s.", ++ GCRON_CROND_TASK, err) ++ except (IOError, OSError) as (errno, strerror): ++ log.error("Failed to touch %s. Error: %s.", ++ GCRON_CROND_TASK, strerror) ++ return + if os.lstat(GCRON_TASKS).st_mtime > \ + os.lstat(GCRON_CROND_TASK).st_mtime: + try: +-- +1.7.1 + diff --git a/SOURCES/0048-build-packaging-corrections-for-RHEL-5.patch b/SOURCES/0048-build-packaging-corrections-for-RHEL-5.patch new file mode 100644 index 0000000..bafff5d --- /dev/null +++ b/SOURCES/0048-build-packaging-corrections-for-RHEL-5.patch @@ -0,0 +1,78 @@ +From 82a8ee250b7fe7f7917b86bd75380677e3ec0156 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Wed, 10 Jun 2015 16:16:47 +0200 +Subject: [PATCH 48/57] build: packaging corrections for RHEL-5 + +Because the RHEL-5 version of these packages do not contain the -server +bits, some additional changes for the .spec are needed. These changes +are not applicable upstream. + +Label: DOWNSTREAM ONLY + +BUG: 1230114 +Change-Id: I3c4237bd986617f42b725efd75d1128a69e5dbe3 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50447 +Reviewed-by: Balamurugan Arumugam +--- + glusterfs.spec.in | 18 ++++++++++-------- + 1 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 2225f19..33d0e7e 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -84,6 +84,7 @@ + %global _build_server 1 + %else + %global _build_server 0 ++%global _without_georeplication --disable-georeplication + %endif + + %global _without_extra_xlators 1 +@@ -969,17 +970,14 @@ fi + %exclude %{_sysconfdir}/ganesha/* + %exclude %{_libexecdir}/ganesha/* + %exclude %{_prefix}/lib/ocf/* +-# exclude geo-replication files +-%exclude %{_sysconfdir}/logrotate.d/glusterfs-georep ++# exclude incrementalapi + %exclude %{_libexecdir}/glusterfs/* + %exclude %{_sbindir}/gfind_missing_files +-%exclude %{_datadir}/glusterfs/scripts/get-gfid.sh +-%exclude %{_datadir}/glusterfs/scripts/slave-upgrade.sh +-%exclude %{_datadir}/glusterfs/scripts/gsync-upgrade.sh +-%exclude %{_datadir}/glusterfs/scripts/generate-gfid-file.sh +-%exclude %{_datadir}/glusterfs/scripts/gsync-sync-gfid +-%exclude %{_sharedstatedir}/glusterd/* ++%exclude %{_libexecdir}/glusterfs/glusterfind ++%exclude %{_bindir}/glusterfind ++%exclude %{_libexecdir}/glusterfs/peer_add_secret_pub + # exclude server files ++%exclude %{_sharedstatedir}/glusterd/* + %exclude %{_sysconfdir}/glusterfs + %exclude %{_sysconfdir}/glusterfs/glusterd.vol + %exclude %{_sysconfdir}/glusterfs/glusterfs-georep-logrotate +@@ -995,7 +993,9 @@ fi + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so ++%if ( 0%{!?_without_tiering:1} ) + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so ++%endif + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* +@@ -1008,7 +1008,9 @@ fi + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* + %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* ++%if ( 0%{!?_without_tiering:1} ) + %exclude %{_libdir}/libgfdb.so.* ++%endif + %exclude %{_sbindir}/gcron.py + %exclude %{_sbindir}/glfsheal + %exclude %{_sbindir}/glusterd +-- +1.7.1 + diff --git a/SOURCES/0049-features-marker-Pass-along-xdata-to-lower-translator.patch b/SOURCES/0049-features-marker-Pass-along-xdata-to-lower-translator.patch new file mode 100644 index 0000000..08d0003 --- /dev/null +++ b/SOURCES/0049-features-marker-Pass-along-xdata-to-lower-translator.patch @@ -0,0 +1,50 @@ +From e1a3bc4b131ea76790ef95be9d6e2ef3092ee0b1 Mon Sep 17 00:00:00 2001 +From: Sachin Pandit +Date: Thu, 4 Jun 2015 11:01:38 +0530 +Subject: [PATCH 49/57] features/marker : Pass along xdata to lower translator + +The problem was in marker xlator, where during +rename a NULL value is passed during STACK_WIND. +Marker needs to pass the xdata un-modified to next +translator if marker does not rely on that. + +Change-Id: I9e47e504fd241263987645abfed7ca13c0d54a80 +BUG: 1228173 +Signed-off-by: Sachin Pandit +Reviewed-on: http://review.gluster.org/11089 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Signed-off-by: Sachin Pandit +Reviewed-on: https://code.engineering.redhat.com/gerrit/50532 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c +index 9e064ef..414177a 100644 +--- a/xlators/features/marker/src/marker.c ++++ b/xlators/features/marker/src/marker.c +@@ -1339,7 +1339,7 @@ marker_do_rename (call_frame_t *frame, void *cookie, xlator_t *this, + + STACK_WIND (frame, marker_rename_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rename, &oplocal->loc, +- &local->loc, NULL); ++ &local->loc, local->xdata); + + return 0; + +@@ -1596,6 +1596,8 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; + ++ local->xdata = dict_ref (xdata); ++ + STACK_WIND (frame, + marker_rename_inodelk_cbk, + FIRST_CHILD(this), +-- +1.7.1 + diff --git a/SOURCES/0050-cluster-dht-fix-incorrect-dst-subvol-info-in-inode_c.patch b/SOURCES/0050-cluster-dht-fix-incorrect-dst-subvol-info-in-inode_c.patch new file mode 100644 index 0000000..30815f6 --- /dev/null +++ b/SOURCES/0050-cluster-dht-fix-incorrect-dst-subvol-info-in-inode_c.patch @@ -0,0 +1,582 @@ +From 01ad467806e8cbcc53347aa5665795f42a16df9e Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Wed, 10 Jun 2015 19:09:58 +0530 +Subject: [PATCH 50/57] cluster/dht: fix incorrect dst subvol info in inode_ctx + +Stashing additional information in the inode_ctx to help +decide whether the migration information is stale, which could +happen if a file was migrated several times but FOPs only detected +the P1 migration phase. If no FOP detects the P2 phase, the inode +ctx1 is never reset. +We now save the src subvol as well as the dst subvol in the +inode ctx. The src subvol is the subvol on which the FOP was sent +when the mig info was set in the inode ctx. This information is +considered stale if: +1. The subvol on which the current FOP is sent is the same as +the dst subvol in the ctx +2. The subvol on which the current FOP is sent is not the same +as the src subvol in the ctx + +This does not handle the case where the same file might have been +renamed such that the src subvol is the same but the dst subvol +is different. However, that is unlikely to happen very often. + +Change-Id: I05a2e9b107ee64750c7ca629aee03b03a02ef75f +BUG: 1140506 +Signed-off-by: Nithya Balachandran +Reviewed-on: http://review.gluster.org/10834 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Signed-off-by: Nithya Balachandran +Reviewed-on: https://code.engineering.redhat.com/gerrit/50452 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 47 ++++++----- + xlators/cluster/dht/src/dht-common.h | 11 ++- + xlators/cluster/dht/src/dht-helper.c | 129 +++++++++++++++++++++-------- + xlators/cluster/dht/src/dht-inode-read.c | 13 ++-- + xlators/cluster/dht/src/dht-inode-write.c | 64 +++++++++----- + xlators/cluster/dht/src/dht-mem-types.h | 1 + + 6 files changed, 179 insertions(+), 86 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index acad4da..a3a48ea 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -3302,12 +3302,12 @@ int + dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { +- int ret = -1; +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- struct iatt *stbuf = NULL; +- inode_t *inode = NULL; +- xlator_t *subvol = NULL; ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; ++ xlator_t *subvol1 = NULL, *subvol2 = NULL; + + local = frame->local; + prev = cookie; +@@ -3345,9 +3345,11 @@ dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { + inode = (local->fd) ? local->fd->inode : local->loc.inode; + +- ret = dht_inode_ctx_get1 (this, inode, &subvol); +- if (subvol) { +- dht_setxattr2 (this, subvol, frame); ++ ret = dht_inode_ctx_get_mig_info (this, inode, ++ &subvol1, &subvol2); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ subvol1, subvol2)) { ++ dht_setxattr2 (this, subvol2, frame); + return 0; + } + +@@ -3814,12 +3816,12 @@ int + dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { +- int ret = -1; +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- struct iatt *stbuf = NULL; +- inode_t *inode = NULL; +- xlator_t *subvol = NULL; ++ int ret = -1; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ struct iatt *stbuf = NULL; ++ inode_t *inode = NULL; ++ xlator_t *subvol1 = NULL, *subvol2 = NULL; + + local = frame->local; + prev = cookie; +@@ -3856,9 +3858,12 @@ dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Phase 1 of migration */ + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { + inode = (local->fd) ? local->fd->inode : local->loc.inode; +- ret = dht_inode_ctx_get1 (this, inode, &subvol); +- if (subvol) { +- dht_removexattr2 (this, subvol, frame); ++ ++ ret = dht_inode_ctx_get_mig_info (this, inode, ++ &subvol1, &subvol2); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ subvol1, subvol2)) { ++ dht_removexattr2 (this, subvol2, frame); + return 0; + } + +@@ -5228,7 +5233,8 @@ dht_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + local->rebalance.target_op_fn = dht_link2; + /* Check if the rebalance phase2 is true */ + if (IS_DHT_MIGRATION_PHASE2 (stbuf)) { +- ret = dht_inode_ctx_get1 (this, local->loc.inode, &subvol); ++ ret = dht_inode_ctx_get_mig_info (this, local->loc.inode, NULL, ++ &subvol); + if (!subvol) { + /* Phase 2 of migration */ + ret = dht_rebalance_complete_check (this, frame); +@@ -5242,7 +5248,8 @@ dht_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + /* Check if the rebalance phase1 is true */ + if (IS_DHT_MIGRATION_PHASE1 (stbuf)) { +- ret = dht_inode_ctx_get1 (this, local->loc.inode, &subvol); ++ ret = dht_inode_ctx_get_mig_info (this, local->loc.inode, NULL, ++ &subvol); + if (subvol) { + dht_link2 (this, subvol, frame); + return 0; +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index eebc13b..0351819 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -503,6 +503,11 @@ struct dir_dfmeta { + int *fetch_entries; + }; + ++typedef struct dht_migrate_info { ++ xlator_t *src_subvol; ++ xlator_t *dst_subvol; ++} dht_migrate_info_t; ++ + #define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT) + + #define is_revalidate(loc) (dht_inode_ctx_layout_get (loc->inode, this, NULL) == 0) +@@ -978,7 +983,11 @@ int32_t + dht_inodectx_dump (xlator_t *this, inode_t *inode); + + int +-dht_inode_ctx_get1 (xlator_t *this, inode_t *inode, xlator_t **subvol); ++dht_inode_ctx_get_mig_info (xlator_t *this, inode_t *inode, ++ xlator_t **src_subvol, xlator_t **dst_subvol); ++gf_boolean_t ++dht_mig_info_is_invalid (xlator_t *current, xlator_t *src_subvol, ++ xlator_t *dst_subvol); + + int + dht_subvol_status (dht_conf_t *conf, xlator_t *subvol); +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index ee99b99..ac2f794 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -20,27 +20,81 @@ + #include "dht-helper.h" + + static inline int +-dht_inode_ctx_set1 (xlator_t *this, inode_t *inode, xlator_t *subvol) ++dht_inode_ctx_set_mig_info (xlator_t *this, inode_t *inode, ++ xlator_t *src_subvol, xlator_t *dst_subvol) + { +- uint64_t tmp_subvol = 0; ++ dht_migrate_info_t *miginfo = NULL; ++ uint64_t value = 0; ++ int ret = -1; + +- tmp_subvol = (long)subvol; +- return inode_ctx_set1 (inode, this, &tmp_subvol); ++ miginfo = GF_CALLOC (1, sizeof (*miginfo), gf_dht_mt_miginfo_t); ++ if (miginfo == NULL) ++ goto out; ++ ++ miginfo->src_subvol = src_subvol; ++ miginfo->dst_subvol = dst_subvol; ++ ++ value = (uint64_t) miginfo; ++ ++ ret = inode_ctx_set1 (inode, this, &value); ++ if (ret < 0) { ++ GF_FREE (miginfo); ++ } ++ ++out: ++ return ret; + } + ++ + int +-dht_inode_ctx_get1 (xlator_t *this, inode_t *inode, xlator_t **subvol) ++dht_inode_ctx_get_mig_info (xlator_t *this, inode_t *inode, ++ xlator_t **src_subvol, xlator_t **dst_subvol) + { +- int ret = -1; +- uint64_t tmp_subvol = 0; ++ int ret = -1; ++ uint64_t tmp_miginfo = 0; ++ dht_migrate_info_t *miginfo = NULL; + +- ret = inode_ctx_get1 (inode, this, &tmp_subvol); +- if (tmp_subvol && subvol) +- *subvol = (xlator_t *)tmp_subvol; ++ ret = inode_ctx_get1 (inode, this, &tmp_miginfo); ++ if ((ret < 0) || (tmp_miginfo == 0)) ++ goto out; ++ ++ miginfo = (dht_migrate_info_t *)tmp_miginfo; ++ ++ if (src_subvol) ++ *src_subvol = miginfo->src_subvol; + ++ if (dst_subvol) ++ *dst_subvol = miginfo->dst_subvol; ++ ++out: + return ret; + } + ++gf_boolean_t ++dht_mig_info_is_invalid (xlator_t *current, xlator_t *src_subvol, ++ xlator_t *dst_subvol) ++{ ++ ++/* Not set ++ */ ++ if (!src_subvol || !dst_subvol) ++ return _gf_true; ++ ++/* Invalid scenarios: ++ * The src_subvol does not match the subvol on which the current op was sent ++ * so the cached subvol has changed between the last mig_info_set and now. ++ * src_subvol == dst_subvol. The file was migrated without any FOP detecting ++ * a P2 so the old dst is now the current subvol. ++ * ++ * There is still one scenario where the info could be outdated - if ++ * file has undergone multiple migrations and ends up on the same src_subvol ++ * on which the mig_info was first set. ++ */ ++ if ((current == dst_subvol) || (current != src_subvol)) ++ return _gf_true; ++ ++ return _gf_false; ++} + + int + dht_frame_return (call_frame_t *frame) +@@ -845,20 +899,20 @@ out: + int + dht_migration_complete_check_task (void *data) + { +- int ret = -1; +- xlator_t *src_node = NULL; +- xlator_t *dst_node = NULL, *linkto_target = NULL; +- dht_local_t *local = NULL; +- dict_t *dict = NULL; +- struct iatt stbuf = {0,}; +- xlator_t *this = NULL; +- call_frame_t *frame = NULL; +- loc_t tmp_loc = {0,}; +- char *path = NULL; +- dht_conf_t *conf = NULL; +- inode_t *inode = NULL; +- fd_t *iter_fd = NULL; +- uint64_t tmp_subvol = 0; ++ int ret = -1; ++ xlator_t *src_node = NULL; ++ xlator_t *dst_node = NULL, *linkto_target = NULL; ++ dht_local_t *local = NULL; ++ dict_t *dict = NULL; ++ struct iatt stbuf = {0,}; ++ xlator_t *this = NULL; ++ call_frame_t *frame = NULL; ++ loc_t tmp_loc = {0,}; ++ char *path = NULL; ++ dht_conf_t *conf = NULL; ++ inode_t *inode = NULL; ++ fd_t *iter_fd = NULL; ++ uint64_t tmp_miginfo = 0; + int open_failed = 0; + + this = THIS; +@@ -950,9 +1004,11 @@ dht_migration_complete_check_task (void *data) + /* once we detect the migration complete, the inode-ctx2 is no more + required.. delete the ctx and also, it means, open() already + done on all the fd of inode */ +- ret = inode_ctx_reset1 (inode, this, &tmp_subvol); +- if (tmp_subvol) ++ ret = inode_ctx_reset1 (inode, this, &tmp_miginfo); ++ if (tmp_miginfo) { ++ GF_FREE ((void *)tmp_miginfo); + goto out; ++ } + + if (list_empty (&inode->fd_list)) + goto out; +@@ -1011,15 +1067,15 @@ dht_rebalance_complete_check (xlator_t *this, call_frame_t *frame) + dht_migration_complete_check_done, + frame, frame); + return ret; +-} + ++} + /* During 'in-progress' state, both nodes should have the file */ + static int + dht_inprogress_check_done (int op_ret, call_frame_t *frame, void *data) + { +- dht_local_t *local = NULL; +- xlator_t *subvol = NULL; +- inode_t *inode = NULL; ++ dht_local_t *local = NULL; ++ xlator_t *dst_subvol = NULL, *src_subvol = NULL; ++ inode_t *inode = NULL; + + local = frame->local; + +@@ -1028,17 +1084,18 @@ dht_inprogress_check_done (int op_ret, call_frame_t *frame, void *data) + + inode = local->loc.inode ? local->loc.inode : local->fd->inode; + +- dht_inode_ctx_get1 (THIS, inode, &subvol); +- if (!subvol) { +- subvol = dht_subvol_get_cached (THIS, inode); +- if (!subvol) { ++ dht_inode_ctx_get_mig_info (THIS, inode, &src_subvol, &dst_subvol); ++ if (dht_mig_info_is_invalid (local->cached_subvol, ++ src_subvol, dst_subvol)) { ++ dst_subvol = dht_subvol_get_cached (THIS, inode); ++ if (!dst_subvol) { + local->op_errno = EINVAL; + goto out; + } + } + + out: +- local->rebalance.target_op_fn (THIS, subvol, frame); ++ local->rebalance.target_op_fn (THIS, dst_subvol, frame); + + return 0; + } +@@ -1170,7 +1227,7 @@ dht_rebalance_inprogress_task (void *data) + } + + done: +- ret = dht_inode_ctx_set1 (this, inode, dst_node); ++ ret = dht_inode_ctx_set_mig_info (this, inode, src_node, dst_node); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "%s: failed to set inode-ctx target file at %s", +diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c +index 46df5b6..5dd055a 100644 +--- a/xlators/cluster/dht/src/dht-inode-read.c ++++ b/xlators/cluster/dht/src/dht-inode-read.c +@@ -158,7 +158,7 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Check if the rebalance phase2 is true */ + if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) { + inode = (local->fd) ? local->fd->inode : local->loc.inode; +- ret = dht_inode_ctx_get1 (this, inode, &subvol); ++ ret = dht_inode_ctx_get_mig_info (this, inode, NULL, &subvol); + if (!subvol) { + /* Phase 2 of migration */ + local->rebalance.target_op_fn = dht_attr2; +@@ -382,7 +382,6 @@ dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + { + dht_local_t *local = NULL; + int ret = 0; +- inode_t *inode = NULL; + xlator_t *subvol = 0; + + local = frame->local; +@@ -402,7 +401,8 @@ dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + local->op_errno = op_errno; + if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) { + /* File would be migrated to other node */ +- ret = dht_inode_ctx_get1 (this, inode, &subvol); ++ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL, ++ &subvol); + if (!subvol) { + local->rebalance.target_op_fn = dht_readv2; + ret = dht_rebalance_complete_check (this, frame); +@@ -617,7 +617,6 @@ dht_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { + dht_local_t *local = NULL; +- inode_t *inode = NULL; + xlator_t *subvol = 0; + + local = frame->local; +@@ -628,7 +627,7 @@ dht_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + + /* If context is set, then send flush() it to the destination */ +- dht_inode_ctx_get1 (this, inode, &subvol); ++ dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL, &subvol); + if (subvol) { + dht_flush2 (this, subvol, frame); + return 0; +@@ -653,6 +652,7 @@ dht_flush2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) + + op_errno = local->op_errno; + ++ dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL, &subvol); + if (subvol == NULL) + goto out; + +@@ -740,7 +740,8 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + } + + local->op_errno = op_errno; +- dht_inode_ctx_get1 (this, inode, &subvol); ++ inode = local->fd->inode; ++ dht_inode_ctx_get_mig_info (this, inode, NULL, &subvol); + if (!subvol) { + local->rebalance.target_op_fn = dht_fsync2; + +diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c +index 57ce89c..85102a3 100644 +--- a/xlators/cluster/dht/src/dht-inode-write.c ++++ b/xlators/cluster/dht/src/dht-inode-write.c +@@ -30,7 +30,8 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + { + dht_local_t *local = NULL; + int ret = -1; +- xlator_t *subvol = NULL; ++ xlator_t *subvol1 = NULL; ++ xlator_t *subvol2 = NULL; + + if (op_ret == -1 && !dht_inode_missing(op_errno)) { + goto out; +@@ -67,9 +68,11 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); + +- ret = dht_inode_ctx_get1 (this, local->fd->inode, &subvol); +- if (subvol) { +- dht_writev2 (this, subvol, frame); ++ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode, ++ &subvol1, &subvol2); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ subvol1, subvol2)) { ++ dht_writev2 (this, subvol2, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -177,7 +180,8 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + int ret = -1; +- xlator_t *subvol = NULL; ++ xlator_t *src_subvol = NULL; ++ xlator_t *dst_subvol = NULL; + inode_t *inode = NULL; + + GF_VALIDATE_OR_GOTO ("dht", frame, err); +@@ -221,9 +225,12 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); + inode = (local->fd) ? local->fd->inode : local->loc.inode; +- dht_inode_ctx_get1 (this, inode, &subvol); +- if (subvol) { +- dht_truncate2 (this, subvol, frame); ++ ++ dht_inode_ctx_get_mig_info (this, inode, &src_subvol, ++ &dst_subvol); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ src_subvol, dst_subvol)) { ++ dht_truncate2 (this, dst_subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -368,7 +375,8 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + int ret = -1; +- xlator_t *subvol = NULL; ++ xlator_t *src_subvol = NULL; ++ xlator_t *dst_subvol = NULL; + + GF_VALIDATE_OR_GOTO ("dht", frame, err); + GF_VALIDATE_OR_GOTO ("dht", this, out); +@@ -408,9 +416,12 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (postbuf)) { + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); +- if (subvol) { +- dht_fallocate2 (this, subvol, frame); ++ ++ dht_inode_ctx_get_mig_info (this, local->fd->inode, &src_subvol, ++ &dst_subvol); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ src_subvol, dst_subvol)) { ++ dht_fallocate2 (this, dst_subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -508,7 +519,8 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + int ret = -1; +- xlator_t *subvol = NULL; ++ xlator_t *src_subvol = NULL; ++ xlator_t *dst_subvol = NULL; + + GF_VALIDATE_OR_GOTO ("dht", frame, err); + GF_VALIDATE_OR_GOTO ("dht", this, out); +@@ -548,9 +560,12 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (postbuf)) { + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); +- if (subvol) { +- dht_discard2 (this, subvol, frame); ++ ++ dht_inode_ctx_get_mig_info (this, local->fd->inode, &src_subvol, ++ &dst_subvol); ++ if (!dht_mig_info_is_invalid(local->cached_subvol, ++ src_subvol, dst_subvol)) { ++ dht_discard2 (this, dst_subvol, frame); + return 0; + } + ret = dht_rebalance_in_progress_check (this, frame); +@@ -642,10 +657,10 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata) + { +- dht_local_t *local = NULL; +- call_frame_t *prev = NULL; +- int ret = -1; +- xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; ++ int ret = -1; ++ xlator_t *subvol1 = NULL, *subvol2 = NULL; + + GF_VALIDATE_OR_GOTO ("dht", frame, err); + GF_VALIDATE_OR_GOTO ("dht", this, out); +@@ -683,9 +698,12 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if (IS_DHT_MIGRATION_PHASE1 (postbuf)) { + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); + dht_iatt_merge (this, &local->prebuf, prebuf, NULL); +- dht_inode_ctx_get1 (this, local->fd->inode, &subvol); +- if (subvol) { +- dht_zerofill2 (this, subvol, frame); ++ ++ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode, ++ &subvol1, &subvol2); ++ if (!dht_mig_info_is_invalid (local->cached_subvol, ++ subvol1, subvol2)) { ++ dht_zerofill2 (this, subvol2, frame); + return 0; + } + +diff --git a/xlators/cluster/dht/src/dht-mem-types.h b/xlators/cluster/dht/src/dht-mem-types.h +index 46028e6..85e5bae 100644 +--- a/xlators/cluster/dht/src/dht-mem-types.h ++++ b/xlators/cluster/dht/src/dht-mem-types.h +@@ -33,6 +33,7 @@ enum gf_dht_mem_types_ { + gf_dht_mt_dirent_t, + gf_dht_mt_container_t, + gf_dht_mt_octx_t, ++ gf_dht_mt_miginfo_t, + gf_dht_mt_end + }; + #endif +-- +1.7.1 + diff --git a/SOURCES/0051-build-introduce-security-hardening-flags-in-gluster.patch b/SOURCES/0051-build-introduce-security-hardening-flags-in-gluster.patch new file mode 100644 index 0000000..575228c --- /dev/null +++ b/SOURCES/0051-build-introduce-security-hardening-flags-in-gluster.patch @@ -0,0 +1,70 @@ +From fb419e813d9cd707e98888cbe1c1d0bd327e72cb Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Wed, 3 Jun 2015 11:09:21 +0530 +Subject: [PATCH 51/57] build: introduce security hardening flags in gluster + +This patch introduces two of the security hardening compiler flags RELRO & PIE +in gluster codebase. Using _hardened_build as 1 doesn't guarantee the existance +of these flags in the compilation as different versions of RHEL have different +redhat-rpm-config macro. So the idea is to export these flags at spec file +level. + +Label: DOWNSTREAM ONLY + +Change-Id: I0a1a56d0a8f54f110d306ba5e55e39b1b073dc84 +BUG: 1200815 +Signed-off-by: Atin Mukherjee +Reviewed-on: https://code.engineering.redhat.com/gerrit/49780 +Reviewed-by: Balamurugan Arumugam +Tested-by: Balamurugan Arumugam +--- + glusterfs.spec.in | 26 ++++++++++++++++++++++---- + 1 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 33d0e7e..3fcc00e 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -612,10 +612,25 @@ This package provides the translators needed on any GlusterFS client. + %setup -q -n %{name}-%{version}%{?prereltag} + + %build +-# For whatever reason, install-sh is sometimes missing. When this gets fixed, +-# there is no need to run ./autogen or have a BuildRequires for automake. +-./autogen.sh +-%configure \ ++# In RHEL7 few hardening flags are available by default, however the RELRO ++# default behaviour is partial, convert to full ++%if ( 0%{?rhel} && 0%{?rhel} >= 7 ) ++LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now" ++export LDFLAGS ++%else ++%if ( 0%{?rhel} && 0%{?rhel} == 6 ) ++CFLAGS="$RPM_OPT_FLAGS -fPIE -DPIE" ++LDFLAGS="$RPM_LD_FLAGS -pie -Wl,-z,relro,-z,now" ++%else ++#It appears that with gcc-4.1.2 in RHEL5 there is an issue using both -fPIC and ++ # -fPIE that makes -z relro not work; -fPIE seems to undo what -fPIC does ++CFLAGS="$RPM_OPT_FLAGS" ++LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now" ++%endif ++export CFLAGS ++export LDFLAGS ++%endif ++ + ./autogen.sh && %configure \ + %{?_with_cmocka} \ + %{?_with_tmpfilesdir} \ +@@ -1735,6 +1750,9 @@ end + %endif + + %changelog ++* Thu Jun 11 2015 Atin Mukherjee ++- Security hardening flags inclusion (#1200815) ++ + * Wed Jun 10 2015 Niels de Vos + - Fix building on RHEL-5 based distributions + +-- +1.7.1 + diff --git a/SOURCES/0052-glusterd-Display-status-of-Self-Heal-Daemon-for-disp.patch b/SOURCES/0052-glusterd-Display-status-of-Self-Heal-Daemon-for-disp.patch new file mode 100644 index 0000000..b29b39a --- /dev/null +++ b/SOURCES/0052-glusterd-Display-status-of-Self-Heal-Daemon-for-disp.patch @@ -0,0 +1,134 @@ +From 34dac73cafee0cca75ad5b3c819a903b1d35420a Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Wed, 13 May 2015 14:48:42 +0530 +Subject: [PATCH 52/57] glusterd : Display status of Self Heal Daemon for disperse volume + + Problem : Status of Self Heal Daemon is not + displayed in "gluster volume status" + + As disperse volumes are self heal compatible, + show the status of self heal daemon in gluster + volume status command + Review link for master - + http://review.gluster.org/#/c/10764/ + +Change-Id: I83d3e6a2fd122b171f15cfd76ce8e6b6e00f92e2 +BUG: 1224195 +Signed-off-by: Ashish Pandey +Reviewed-on: https://code.engineering.redhat.com/gerrit/50434 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 38 ++++++++++++++++----------- + 1 files changed, 22 insertions(+), 16 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index e304cb0..877e9ac 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -39,6 +39,7 @@ + #include "glusterd-volgen.h" + #include "glusterd-locks.h" + #include "glusterd-messages.h" ++#include "glusterd-utils.h" + #include "syscall.h" + #include "cli1-xdr.h" + #include "common-utils.h" +@@ -50,7 +51,7 @@ + #include "glusterd-nfs-svc.h" + #include "glusterd-quotad-svc.h" + #include "glusterd-server-quorum.h" +- ++#include "glusterd-volgen.h" + #include + #include + #include +@@ -1420,13 +1421,14 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) + char msg[2048] = {0,}; + char *volname = NULL; + char *brick = NULL; ++ char *shd_key = NULL; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + glusterd_brickinfo_t *brickinfo = NULL; + glusterd_volinfo_t *volinfo = NULL; + dict_t *vol_opts = NULL; + gf_boolean_t nfs_disabled = _gf_false; +- gf_boolean_t shd_enabled = _gf_true; ++ gf_boolean_t shd_enabled = _gf_false; + + GF_ASSERT (dict); + this = THIS; +@@ -1498,17 +1500,18 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) + goto out; + } + } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { +- if (!glusterd_is_volume_replicate (volinfo)) { ++ if (glusterd_is_shd_compatible_volume (volinfo)) { ++ shd_key = volgen_get_shd_key(volinfo); ++ shd_enabled = dict_get_str_boolean (vol_opts, ++ shd_key, ++ _gf_true); ++ } else { + ret = -1; + snprintf (msg, sizeof (msg), +- "Volume %s is not of type replicate", +- volname); ++ "Volume %s is not Self-heal compatible", ++ volname); + goto out; + } +- +- shd_enabled = dict_get_str_boolean (vol_opts, +- "cluster.self-heal-daemon", +- _gf_true); + if (!shd_enabled) { + ret = -1; + snprintf (msg, sizeof (msg), +@@ -2869,13 +2872,14 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + uint32_t cmd = 0; + char *volname = NULL; + char *brick = NULL; ++ char *shd_key = NULL; + xlator_t *this = NULL; + glusterd_volinfo_t *volinfo = NULL; + glusterd_brickinfo_t *brickinfo = NULL; + glusterd_conf_t *priv = NULL; + dict_t *vol_opts = NULL; + gf_boolean_t nfs_disabled = _gf_false; +- gf_boolean_t shd_enabled = _gf_true; ++ gf_boolean_t shd_enabled = _gf_false; + gf_boolean_t origin_glusterd = _gf_false; + + this = THIS; +@@ -3039,12 +3043,13 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + other_count++; + node_count++; + } +- +- shd_enabled = dict_get_str_boolean +- (vol_opts, "cluster.self-heal-daemon", +- _gf_true); +- if (glusterd_is_volume_replicate (volinfo) +- && shd_enabled) { ++ if (glusterd_is_shd_compatible_volume (volinfo)) { ++ shd_key = volgen_get_shd_key (volinfo); ++ shd_enabled = dict_get_str_boolean (vol_opts, ++ shd_key, ++ _gf_true); ++ } ++ if (shd_enabled) { + ret = glusterd_add_node_to_dict + (priv->shd_svc.name, rsp_dict, + other_index, vol_opts); +@@ -3054,6 +3059,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + node_count++; + other_index++; + } ++ + if (glusterd_is_volume_quota_enabled (volinfo)) { + ret = glusterd_add_node_to_dict + (priv->quotad_svc.name, +-- +1.7.1 + diff --git a/SOURCES/0053-cluster-dht-maintain-start-state-of-rebalance-daemon.patch b/SOURCES/0053-cluster-dht-maintain-start-state-of-rebalance-daemon.patch new file mode 100644 index 0000000..0d2433b --- /dev/null +++ b/SOURCES/0053-cluster-dht-maintain-start-state-of-rebalance-daemon.patch @@ -0,0 +1,66 @@ +From 67b8b290c6a46dcc0dc20e3589f9c1f58110f332 Mon Sep 17 00:00:00 2001 +From: Dan Lambright +Date: Tue, 2 Jun 2015 14:46:46 -0400 +Subject: [PATCH 53/57] cluster/dht: maintain start state of rebalance daemon across graph switch + +This is a backport of 10977 + +When we did a graph switch on a rebalance daemon, a second call +to gf_degrag_start() was done. This lead to multiple threads +doing migration. When multiple threads try to move the same +file there can be deadlocks. + +> Change-Id: I931ca7fe600022f245e3dccaabb1ad004f732c56 +> BUG: 1226005 +> Signed-off-by: Dan Lambright +> Reviewed-on: http://review.gluster.org/10977 +> Tested-by: NetBSD Build System +> Reviewed-by: Shyamsundar Ranganathan + +Change-Id: I7797492cc6f32c0bf155b542d51184eb9a84a53d +BUG: 1227469 +Signed-off-by: Dan Lambright +Reviewed-on: https://code.engineering.redhat.com/gerrit/49748 +Reviewed-by: Joseph Fernandes +Tested-by: Joseph Fernandes +Reviewed-by: Shyam Ranganathan +--- + xlators/cluster/dht/src/dht-common.c | 12 ++++++++++-- + 1 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index a3a48ea..6d70f82 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -37,6 +37,9 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + int + dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + ++int run_defrag = 0; ++ ++ + int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) + { +@@ -6895,11 +6898,16 @@ unlock: + } + } + +- /* rebalance is started with assert_no_child_down. So we do ++ /* Rebalance is started with assert_no_child_down. So we do + * not need to handle CHILD_DOWN event here. ++ * ++ * If there is a graph switch, we should not restart the ++ * rebalance daemon. Use 'run_defrag' to indicate if the ++ * thread has already started. + */ +- if (conf->defrag) { ++ if (conf->defrag && !run_defrag) { + if (methods->migration_needed(this)) { ++ run_defrag = 1; + ret = gf_thread_create(&conf->defrag->th, + NULL, + gf_defrag_start, this); +-- +1.7.1 + diff --git a/SOURCES/0054-cluster-tier-account-for-reordered-layouts.patch b/SOURCES/0054-cluster-tier-account-for-reordered-layouts.patch new file mode 100644 index 0000000..b9d6f88 --- /dev/null +++ b/SOURCES/0054-cluster-tier-account-for-reordered-layouts.patch @@ -0,0 +1,167 @@ +From 3ca2971df5aeb8f67a39f5fa2866e68a54fdd9ce Mon Sep 17 00:00:00 2001 +From: Dan Lambright +Date: Thu, 11 Jun 2015 10:50:41 -0400 +Subject: [PATCH 54/57] cluster/tier: account for reordered layouts + +This is a backport of fix 11092. + +> For a tiered volume the cold subvolume is always at a fixed +> position in the graph. DHT's layout array, on the other hand, +> may have the cold subvolume in either the first or second +> index, therefore code cannot make any assumptions. The fix +> searches the layout for the correct position dynamically +> rather than statically. + +> The bug manifested itself in NFS, in which a newly attached +> subvolume had not received an existing directory. This case +> is a "stale entry" and marked as such in the layout for +> that directory. The code did not see this, because it +> looked at the wrong index in the layout array. + +> The fix also adds the check for decomissioned bricks, and +> fixes a problem in detach tier related to starting the +> rebalance process: we never received the right defrag +> command and it did not get directed to the tier translator. + +> Change-Id: I77cdf9fbb0a777640c98003188565a79be9d0b56 +> BUG: 1214289 +> Signed-off-by: Dan Lambright +> Signed-off-by: Dan Lambright + +Change-Id: I402105623c8fe0af416c4b7e22ed77f1b95d9847 +BUG: 1228643 +Signed-off-by: Dan Lambright +Reviewed-on: https://code.engineering.redhat.com/gerrit/50560 +Tested-by: Joseph Fernandes +Reviewed-by: Joseph Fernandes +Reviewed-by: Shyam Ranganathan +--- + xlators/cluster/dht/src/dht-common.c | 3 +- + xlators/cluster/dht/src/tier.c | 43 ++++++++++++++++------- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 6 +++- + 3 files changed, 37 insertions(+), 15 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 6d70f82..8870a30 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -7089,7 +7089,8 @@ int32_t dht_migration_needed(xlator_t *this) + + defrag = conf->defrag; + +- if (defrag->cmd != GF_DEFRAG_CMD_START_TIER) ++ if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER) && ++ (defrag->cmd != GF_DEFRAG_CMD_START_DETACH_TIER)) + ret = 1; + + out: +diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c +index 0a9c073..cef4f5c 100644 +--- a/xlators/cluster/dht/src/tier.c ++++ b/xlators/cluster/dht/src/tier.c +@@ -916,7 +916,8 @@ tier_migration_needed (xlator_t *this) + + defrag = conf->defrag; + +- if (defrag->cmd == GF_DEFRAG_CMD_START_TIER) ++ if ((defrag->cmd == GF_DEFRAG_CMD_START_TIER) || ++ (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER)) + ret = 1; + out: + return ret; +@@ -958,9 +959,11 @@ tier_search (xlator_t *this, dht_layout_t *layout, const char *name) + { + xlator_t *subvol = NULL; + void *value; +- int search_first_subvol = 0; ++ int search_subvol = 0; + dht_conf_t *conf = NULL; + gf_defrag_info_t *defrag = NULL; ++ int layout_cold = 0; ++ int layout_hot = 1; + + GF_VALIDATE_OR_GOTO("tier", this, out); + GF_VALIDATE_OR_GOTO(this->name, layout, out); +@@ -969,28 +972,42 @@ tier_search (xlator_t *this, dht_layout_t *layout, const char *name) + + conf = this->private; + ++ /* The first subvolume in the graph is always cold. */ ++ /* Find the position of the cold subvolume in the layout. */ ++ layout_cold = 0; ++ layout_hot = 1; ++ if (conf->subvolumes[0] != layout->list[0].xlator) { ++ layout_cold = 1; ++ layout_hot = 0; ++ } ++ ++ search_subvol = layout_hot; ++ + defrag = conf->defrag; + if (defrag && defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) +- search_first_subvol = 1; ++ search_subvol = layout_cold; + ++ /* "decommission_subvols_cnt" can only be non-zero on detach. */ ++ /* This will change once brick add/remove is supported for */ ++ /* tiered volumes. */ ++ else if (conf->decommission_subvols_cnt) { ++ search_subvol = layout_cold; ++ } + else if (!dict_get_ptr (this->options, "rule", &value) && +- !strcmp(layout->list[0].xlator->name, value)) { +- search_first_subvol = 1; ++ !strcmp(layout->list[layout_cold].xlator->name, value)) { ++ search_subvol = layout_cold; + } + +- if ((layout->list[0].err > 0) && (layout->list[0].err != ENOTCONN)) +- search_first_subvol = 0; ++ if ((layout->list[search_subvol].err > 0) && ++ (layout->list[search_subvol].err != ENOTCONN)) ++ search_subvol = layout_cold; + +- if (search_first_subvol) +- subvol = layout->list[0].xlator; +- else +- subvol = layout->list[1].xlator; ++ subvol = layout->list[search_subvol].xlator; ++ out: + +-out: + return subvol; + } + +- + dht_methods_t tier_methods = { + .migration_get_dst_subvol = tier_migration_get_dst, + .migration_other = tier_start, +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index 0af86f5..aa3a6c9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -2039,6 +2039,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + char *brick_tmpstr = NULL; + int start_remove = 0; + uint32_t commit_hash = 0; ++ int defrag_cmd = 0; + + this = THIS; + GF_ASSERT (this); +@@ -2309,9 +2310,12 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + volinfo->rebal.commit_hash = commit_hash; + } + /* perform the rebalance operations */ ++ defrag_cmd = GF_DEFRAG_CMD_START_FORCE; ++ if (cmd == GF_OP_CMD_DETACH_START) ++ defrag_cmd = GF_DEFRAG_CMD_START_DETACH_TIER; + ret = glusterd_handle_defrag_start + (volinfo, err_str, sizeof (err_str), +- GF_DEFRAG_CMD_START_FORCE, ++ defrag_cmd, + glusterd_remove_brick_migrate_cbk, GD_OP_REMOVE_BRICK); + + if (!ret) +-- +1.7.1 + diff --git a/SOURCES/0055-cluster-tier-make-attach-detach-work-with-new-rebala.patch b/SOURCES/0055-cluster-tier-make-attach-detach-work-with-new-rebala.patch new file mode 100644 index 0000000..027c0c5 --- /dev/null +++ b/SOURCES/0055-cluster-tier-make-attach-detach-work-with-new-rebala.patch @@ -0,0 +1,129 @@ +From c12fb1731b7990f951d360bafe9eca49c27f5dcb Mon Sep 17 00:00:00 2001 +From: Dan Lambright +Date: Tue, 2 Jun 2015 18:48:19 -0400 +Subject: [PATCH 55/57] cluster/tier: make attach/detach work with new rebalance logic + +This is a backport of 10795 + +The new rebalance performance improvements added new +datastructures which were not initialized in the +tier case. Function dht_find_local_subvol_cbk() needs +to accept a list built by lower level DHT translators +in order to build the local subvolumes list. + +> Change-Id: Iab03fc8e7fadc22debc08cd5bc781b9e3e270497 +> BUG: 1222088 +> Signed-off-by: Dan Lambright +> Reviewed-on: http://review.gluster.org/10795 +> Tested-by: NetBSD Build System +> Reviewed-by: Shyamsundar Ranganathan + +Change-Id: Id1fde62dce51bb91358214721b3c04ad2224c439 +Signed-off-by: Dan Lambright +Reviewed-on: https://code.engineering.redhat.com/gerrit/49749 +Tested-by: Joseph Fernandes +Reviewed-by: Joseph Fernandes +Reviewed-by: Shyam Ranganathan +--- + xlators/cluster/dht/src/dht-common.c | 42 +++++++++++++++++++----------- + xlators/cluster/dht/src/dht-rebalance.c | 9 +----- + 2 files changed, 28 insertions(+), 23 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 8870a30..868cd79 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -2627,6 +2627,9 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int this_call_cnt = 0; + int ret = 0; + char *uuid_str = NULL; ++ char *uuid_list = NULL; ++ char *next_uuid_str = NULL; ++ char *saveptr = NULL; + uuid_t node_uuid = {0,}; + + +@@ -2649,7 +2652,7 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto unlock; + } + +- ret = dict_get_str (xattr, local->xsel, &uuid_str); ++ ret = dict_get_str (xattr, local->xsel, &uuid_list); + + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "Failed to " +@@ -2659,22 +2662,29 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto unlock; + } + +- if (gf_uuid_parse (uuid_str, node_uuid)) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to parse uuid" +- " failed for %s", prev->this->name); +- local->op_ret = -1; +- local->op_errno = EINVAL; +- goto unlock; +- } ++ for (uuid_str = strtok_r (uuid_list, " ", &saveptr); ++ uuid_str; ++ uuid_str = next_uuid_str) { + +- if (gf_uuid_compare (node_uuid, conf->defrag->node_uuid)) { +- gf_log (this->name, GF_LOG_DEBUG, "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" +- " this node", prev->this->name); ++ next_uuid_str = strtok_r (NULL, " ", &saveptr); ++ if (gf_uuid_parse (uuid_str, node_uuid)) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to parse uuid" ++ " failed for %s", prev->this->name); ++ local->op_ret = -1; ++ local->op_errno = EINVAL; ++ goto unlock; ++ } ++ ++ if (gf_uuid_compare (node_uuid, conf->defrag->node_uuid)) { ++ gf_log (this->name, GF_LOG_DEBUG, "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" ++ " this node", prev->this->name); ++ break; ++ } + } + } + +diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c +index 89cc3a8..38db3a1 100644 +--- a/xlators/cluster/dht/src/dht-rebalance.c ++++ b/xlators/cluster/dht/src/dht-rebalance.c +@@ -2691,8 +2691,7 @@ gf_defrag_start_crawl (void *data) + goto out; + } + +- if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER) && +- (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX)) { ++ if (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX) { + migrate_data = dict_new (); + if (!migrate_data) { + defrag->total_failures++; +@@ -2789,11 +2788,7 @@ gf_defrag_start_crawl (void *data) + } + methods->migration_other(this, defrag); + if (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) { +- migrate_data = dict_new (); +- if (!migrate_data) { +- ret = -1; +- goto out; +- } ++ + ret = dict_set_str (migrate_data, + GF_XATTR_FILE_MIGRATE_KEY, + "force"); +-- +1.7.1 + diff --git a/SOURCES/0056-tier-dht-Fixing-non-atomic-promotion-demotion-w.r.t-.patch b/SOURCES/0056-tier-dht-Fixing-non-atomic-promotion-demotion-w.r.t-.patch new file mode 100644 index 0000000..ff78c46 --- /dev/null +++ b/SOURCES/0056-tier-dht-Fixing-non-atomic-promotion-demotion-w.r.t-.patch @@ -0,0 +1,229 @@ +From 5d67d0a79a0986b3b547a80d6ebc3db5d70a7b77 Mon Sep 17 00:00:00 2001 +From: Dan Lambright +Date: Thu, 11 Jun 2015 14:45:52 -0400 +Subject: [PATCH 56/57] tier/dht: Fixing non atomic promotion/demotion w.r.t to frequency period + +This is a backport of 11110 + +> This fixes the ping-pong issue i.e files getting demoted immediately +> after promition, caused by off-sync promotion/demotion processes. +> The solution is do promotion/demotion refering to the system time. +> To have the fix working all the file serving nodes should have +> thier system time synchronized with each other either manually or +> using a NTP Server. + +> NOTE: The ping-pong issue can re-appear even with this fix, if the admin +> have different promotion freq period and demotion freq period, but this +> would be under the control of the admin. + +> Change-Id: I1b33a5881d0cac143662ddb48e5b7b653aeb1271 +> BUG: 1218717 +> Signed-off-by: Joseph Fernandes +> Reviewed-on: http://review.gluster.org/11110 +> Reviewed-by: Dan Lambright + +Change-Id: I27aa58017b75e5ba8977967176802bfb52ead656 +BUG: 1229268 +Signed-off-by: Dan Lambright +Reviewed-on: https://code.engineering.redhat.com/gerrit/50581 +Reviewed-by: Joseph Fernandes +Tested-by: Joseph Fernandes +Reviewed-by: Shyam Ranganathan +--- + xlators/cluster/dht/src/tier.c | 100 +++++++++++++++++++++++++-------------- + 1 files changed, 64 insertions(+), 36 deletions(-) + +diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c +index cef4f5c..7b4890c 100644 +--- a/xlators/cluster/dht/src/tier.c ++++ b/xlators/cluster/dht/src/tier.c +@@ -734,7 +734,7 @@ tier_get_bricklist (xlator_t *xl, dict_t *bricklist) + if (!db_path) { + gf_msg ("tier", GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_STATUS, +- "Failed to allocate memory for bricklist"); ++ "Faile. to allocate memory for bricklist"); + goto out; + } + +@@ -763,9 +763,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + dict_t *bricklist_cold = NULL; + dict_t *bricklist_hot = NULL; + dht_conf_t *conf = NULL; +- int tick = 0; +- int next_demote = 0; +- int next_promote = 0; ++ gfdb_time_t current_time; + int freq_promote = 0; + int freq_demote = 0; + promotion_args_t promotion_args = { 0 }; +@@ -775,6 +773,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + int ret = 0; + pthread_t promote_thread; + pthread_t demote_thread; ++ gf_boolean_t is_promotion_triggered = _gf_false; ++ gf_boolean_t is_demotion_triggered = _gf_false; + + conf = this->private; + +@@ -789,16 +789,9 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + tier_get_bricklist (conf->subvolumes[0], bricklist_cold); + tier_get_bricklist (conf->subvolumes[1], bricklist_hot); + +- freq_promote = defrag->tier_promote_frequency; +- freq_demote = defrag->tier_demote_frequency; +- +- next_promote = defrag->tier_promote_frequency % TIMER_SECS; +- next_demote = defrag->tier_demote_frequency % TIMER_SECS; +- +- + gf_msg (this->name, GF_LOG_INFO, 0, +- DHT_MSG_LOG_TIER_STATUS, "Begin run tier promote %d demote %d", +- next_promote, next_demote); ++ DHT_MSG_LOG_TIER_STATUS, "Begin run tier promote %d" ++ " demote %d", freq_promote, freq_demote); + + defrag->defrag_status = GF_DEFRAG_STATUS_STARTED; + +@@ -806,9 +799,6 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + + sleep(1); + +- ret_promotion = -1; +- ret_demotion = -1; +- + if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) { + ret = 1; + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -820,7 +810,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + + if (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) { + ret = 0; +- defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE; ++ defrag->defrag_status = ++ GF_DEFRAG_STATUS_COMPLETE; + gf_msg (this->name, GF_LOG_DEBUG, 0, + DHT_MSG_LOG_TIER_ERROR, + "defrag->defrag_cmd == " +@@ -828,43 +819,75 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + goto out; + } + +- tick = (tick + 1) % TIMER_SECS; +- if ((next_demote != tick) && (next_promote != tick)) ++ freq_promote = defrag->tier_promote_frequency; ++ freq_demote = defrag->tier_demote_frequency; ++ ++ /* To have proper synchronization amongst all ++ * brick holding nodes, so that promotion and demotions ++ * start atomicly w.r.t promotion/demotion frequency ++ * period, all nodes should have thier system time ++ * in-sync with each other either manually set or ++ * using a NTP server*/ ++ ret = gettimeofday (¤t_time, NULL); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to get current time"); ++ goto out; ++ } ++ ++ is_demotion_triggered = ((current_time.tv_sec % ++ freq_demote) == 0) ? _gf_true : ++ _gf_false; ++ is_promotion_triggered = ((current_time.tv_sec % ++ freq_promote) == 0) ? _gf_true : ++ _gf_false; ++ ++ /* If no promotion and no demotion is ++ * scheduled/triggered skip a iteration */ ++ if (!is_promotion_triggered && !is_demotion_triggered) + continue; + +- if (next_demote >= tick) { ++ ret_promotion = -1; ++ ret_demotion = -1; ++ ++ if (is_demotion_triggered) { ++ + demotion_args.this = this; + demotion_args.brick_list = bricklist_hot; + demotion_args.defrag = defrag; + demotion_args.freq_time = freq_demote; +- ret_demotion = pthread_create (&demote_thread, NULL, +- &tier_demote, &demotion_args); ++ ret_demotion = pthread_create (&demote_thread, ++ NULL, &tier_demote, ++ &demotion_args); ++ + if (ret_demotion) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_ERROR, +- "Failed starting Demotion thread!"); ++ "Failed starting Demotion " ++ "thread!"); ++ + } +- freq_demote = defrag->tier_demote_frequency; +- next_demote = (tick + freq_demote) % TIMER_SECS; + } + +- if (next_promote >= tick) { ++ if (is_promotion_triggered) { + promotion_args.this = this; + promotion_args.brick_list = bricklist_cold; + promotion_args.defrag = defrag; + promotion_args.freq_time = freq_promote; +- ret_promotion = pthread_create (&promote_thread, NULL, +- &tier_promote, &promotion_args); ++ ret_promotion = pthread_create (&promote_thread, ++ NULL, &tier_promote, ++ &promotion_args); ++ + if (ret_promotion) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_ERROR, +- "Failed starting Promotion thread!"); ++ "Failed starting Promotion " ++ "thread!"); ++ + } +- freq_promote = defrag->tier_promote_frequency; +- next_promote = (tick + freq_promote) % TIMER_SECS; + } + +- if (ret_demotion == 0) { ++ if (is_promotion_triggered && (ret_demotion == 0)) { + pthread_join (demote_thread, NULL); + if (demotion_args.return_value) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -874,7 +897,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + ret_demotion = demotion_args.return_value; + } + +- if (ret_promotion == 0) { ++ if (is_demotion_triggered && (ret_promotion == 0)) { + pthread_join (promote_thread, NULL); + if (promotion_args.return_value) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -884,10 +907,15 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + ret_promotion = promotion_args.return_value; + } + +- /*Collect previous and current cummulative status */ +- ret = ret | ret_demotion | ret_promotion; ++ /* Collect previous and current cummulative status */ ++ /* If demotion was not triggered just pass 0 to ret */ ++ ret = (is_demotion_triggered) ? ret_demotion : 0; ++ /* If promotion was not triggered just pass 0 to ret */ ++ ret = ret | (is_promotion_triggered) ? ++ ret_promotion : 0; + +- /*reseting promotion and demotion arguments for next iteration*/ ++ /* reseting promotion and demotion arguments for ++ * next iteration*/ + memset (&demotion_args, 0, sizeof(demotion_args_t)); + memset (&promotion_args, 0, sizeof(promotion_args_t)); + +-- +1.7.1 + diff --git a/SOURCES/0057-cluster-ec-Prevent-Null-dereference-in-dht-rename.patch b/SOURCES/0057-cluster-ec-Prevent-Null-dereference-in-dht-rename.patch new file mode 100644 index 0000000..1af34d6 --- /dev/null +++ b/SOURCES/0057-cluster-ec-Prevent-Null-dereference-in-dht-rename.patch @@ -0,0 +1,58 @@ +From 9314a67565dc891186845d9af0cdf4ed09d5f009 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Thu, 11 Jun 2015 14:44:48 +0530 +Subject: [PATCH 57/57] cluster/ec: Prevent Null dereference in dht-rename + + Backport of http://review.gluster.com/11178 + +BUG: 1230522 +Change-Id: I708d4d84b1341fb7cb515808836721735dc63f14 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50510 +--- + tests/basic/ec/dht-rename.t | 19 +++++++++++++++++++ + xlators/cluster/ec/src/ec-common.c | 2 +- + 2 files changed, 20 insertions(+), 1 deletions(-) + create mode 100644 tests/basic/ec/dht-rename.t + +diff --git a/tests/basic/ec/dht-rename.t b/tests/basic/ec/dht-rename.t +new file mode 100644 +index 0000000..81b41ff +--- /dev/null ++++ b/tests/basic/ec/dht-rename.t +@@ -0,0 +1,19 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++# This test checks notify part of ec ++ ++cleanup ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0..5} ++TEST $CLI volume start $V0 ++ ++TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 ++ ++TEST touch $M0/1 ++TEST mv $M0/1 $M0/10 ++cleanup +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index d9f3442..a158637 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -1143,7 +1143,7 @@ void ec_get_real_size(ec_lock_link_t *link) + ec_fop_data_t *fop; + dict_t *xdata; + +- if (link->base == NULL) { ++ if (link->base == NULL || link->base->inode == NULL) { + return; + } + +-- +1.7.1 + diff --git a/SOURCES/0058-features-changelog-Avoid-setattr-fop-logging-during-.patch b/SOURCES/0058-features-changelog-Avoid-setattr-fop-logging-during-.patch new file mode 100644 index 0000000..dd53489 --- /dev/null +++ b/SOURCES/0058-features-changelog-Avoid-setattr-fop-logging-during-.patch @@ -0,0 +1,161 @@ +From fe73255f5283baec514cc7f6a31f042d34bca0fa Mon Sep 17 00:00:00 2001 +From: Saravanakumar Arumugam +Date: Tue, 9 Jun 2015 17:49:58 +0530 +Subject: [PATCH 58/73] features/changelog: Avoid setattr fop logging during rename + +Problem: + When a file is renamed and the (renamed)file's Hashing +falls into a different brick, DHT creates a special file(linkto file) +in the brick(Hashed subvolume) and carries out setattr operation +on that file. + +Currently, Changelog records this(setattr) operation in Hashed +subvolume. glusterfind in turn records this operation +as MODIFY operation. + +So, there is a NEW entry in Cached subvolume and MODIFY entry +in Hashed subvolume for the same file. + +Solution: + Avoid logging setattr operation carried out, by +marking the operation as internal fop using xdata. + +In changelog translator, check whether setattr is set +as internal fop and skip accordingly. + +Change-Id: I21b09afb5a638b88a4ccb822442216680b7b74fd +BUG: 1226889 +Reviewed-On: http://review.gluster.org/c/10984 +Reviewed-On: http://review.gluster.org/c/11183 +Signed-off-by: Saravanakumar Arumugam +Reviewed-on: https://code.engineering.redhat.com/gerrit/50535 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.h | 18 ++++++++++++++++++ + xlators/cluster/dht/src/dht-linkfile.c | 23 ++++++++++++++++------- + xlators/cluster/dht/src/dht-rename.c | 16 ---------------- + xlators/features/changelog/src/changelog.c | 2 ++ + 4 files changed, 36 insertions(+), 23 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 0351819..c04e85d 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -582,6 +582,24 @@ typedef struct dht_migrate_info { + } while (0) + + #define is_greater_time(a, an, b, bn) (((a) < (b)) || (((a) == (b)) && ((an) < (bn)))) ++ ++#define DHT_MARK_FOP_INTERNAL(xattr) do { \ ++ int tmp = -1; \ ++ if (!xattr) { \ ++ xattr = dict_new (); \ ++ if (!xattr) \ ++ break; \ ++ } \ ++ tmp = dict_set_str (xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \ ++ if (tmp) { \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ DHT_MSG_DICT_SET_FAILED, \ ++ "Failed to set dictionary value: key = %s," \ ++ " path = %s", GLUSTERFS_INTERNAL_FOP_KEY, \ ++ local->loc.path); \ ++ } \ ++ } while (0) ++ + dht_layout_t *dht_layout_new (xlator_t *this, int cnt); + dht_layout_t *dht_layout_get (xlator_t *this, inode_t *inode); + dht_layout_t *dht_layout_for_subvol (xlator_t *this, xlator_t *subvol); +diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c +index 14df318..923dde0 100644 +--- a/xlators/cluster/dht/src/dht-linkfile.c ++++ b/xlators/cluster/dht/src/dht-linkfile.c +@@ -312,12 +312,13 @@ dht_linkfile_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int + dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this) + { +- int ret = -1; +- call_frame_t *copy = NULL; +- dht_local_t *local = NULL; +- dht_local_t *copy_local = NULL; +- xlator_t *subvol = NULL; +- struct iatt stbuf = {0,}; ++ int ret = -1; ++ call_frame_t *copy = NULL; ++ dht_local_t *local = NULL; ++ dht_local_t *copy_local = NULL; ++ xlator_t *subvol = NULL; ++ struct iatt stbuf = {0,}; ++ dict_t *xattr = NULL; + + local = frame->local; + +@@ -327,6 +328,8 @@ dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this) + if (local->stbuf.ia_type == IA_INVAL) + return 0; + ++ DHT_MARK_FOP_INTERNAL (xattr); ++ + gf_uuid_copy (local->loc.gfid, local->stbuf.ia_gfid); + + copy = copy_frame (frame); +@@ -348,8 +351,14 @@ dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this) + + STACK_WIND (copy, dht_linkfile_setattr_cbk, subvol, + subvol->fops->setattr, ©_local->loc, +- &stbuf, (GF_SET_ATTR_UID | GF_SET_ATTR_GID), NULL); ++ &stbuf, (GF_SET_ATTR_UID | GF_SET_ATTR_GID), xattr); + ret = 0; + out: ++ if ((ret < 0) && (copy)) ++ DHT_STACK_DESTROY (copy); ++ ++ if (xattr) ++ dict_unref (xattr); ++ + return ret; + } +diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c +index 4e4e986..097ae9a 100644 +--- a/xlators/cluster/dht/src/dht-rename.c ++++ b/xlators/cluster/dht/src/dht-rename.c +@@ -369,22 +369,6 @@ dht_rename_track_for_changelog (xlator_t *this, dict_t *xattr, + } + + +-#define DHT_MARK_FOP_INTERNAL(xattr) do { \ +- int tmp = -1; \ +- if (!xattr) { \ +- xattr = dict_new (); \ +- if (!xattr) \ +- break; \ +- } \ +- tmp = dict_set_str (xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \ +- if (tmp) { \ +- gf_msg (this->name, GF_LOG_ERROR, 0, \ +- DHT_MSG_DICT_SET_FAILED, \ +- "Failed to set dictionary value: key = %s," \ +- " path = %s", GLUSTERFS_INTERNAL_FOP_KEY, \ +- local->loc.path); \ +- } \ +- }while (0) + + #define DHT_MARKER_DONT_ACCOUNT(xattr) do { \ + int tmp = -1; \ +diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c +index ed58979..bea7334 100644 +--- a/xlators/features/changelog/src/changelog.c ++++ b/xlators/features/changelog/src/changelog.c +@@ -1220,6 +1220,8 @@ changelog_setattr (call_frame_t *frame, + priv = this->private; + CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); + ++ CHANGELOG_IF_INTERNAL_FOP_THEN_GOTO (frame, xdata, wind); ++ + CHANGELOG_OP_BOUNDARY_CHECK (frame, wind); + + CHANGELOG_INIT (this, frame->local, +-- +1.7.1 + diff --git a/SOURCES/0059-tools-glusterfind-verifying-volume-presence.patch b/SOURCES/0059-tools-glusterfind-verifying-volume-presence.patch new file mode 100644 index 0000000..925556c --- /dev/null +++ b/SOURCES/0059-tools-glusterfind-verifying-volume-presence.patch @@ -0,0 +1,52 @@ +From 61521f2be99ec0a799efe02939cabce19a4510f6 Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Thu, 11 Jun 2015 20:39:36 +0530 +Subject: [PATCH 59/73] tools/glusterfind: verifying volume presence + +An invalid volume name passed to "pre", "post" and "delete" +operations throws up unfriendly errors. This patch presents +friendly error messages. + +Change-Id: Ifa7e99d8bf9c54a818408640909d1531b2b66056 +Signed-off-by: Milind Changire +Reviewed-On: http://review.gluster.org/#/c/10989/ +Reviewed-On: http://review.gluster.org/#/c/10945/ +BUG: 1224046 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50563 +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/main.py | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index d9936ee..ccd2d22 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -179,6 +179,11 @@ def get_nodes(volume): + logger=logger) + tree = etree.fromstring(data) + ++ # Test to check if volume has been deleted after session creation ++ count_el = tree.find('volInfo/volumes/count') ++ if int(count_el.text) == 0: ++ fail("Unable to get volume details", logger=logger) ++ + nodes = [] + volume_el = tree.find('volInfo/volumes/volume') + try: +@@ -506,6 +511,11 @@ def main(): + if not os.path.exists(session_dir) and args.mode not in ["create", "list"]: + fail("Invalid session %s" % args.session) + ++ vol_dir = os.path.join(session_dir, args.volume) ++ if not os.path.exists(vol_dir) and args.mode not in ["create", "list"]: ++ fail("Session %s not created with volume %s" % ++ (args.session, args.volume)) ++ + mkdirp(os.path.join(conf.get_opt("log_dir"), args.session, args.volume), + exit_on_err=True) + log_file = os.path.join(conf.get_opt("log_dir"), +-- +1.7.1 + diff --git a/SOURCES/0060-geo-rep-ignore-symlink-and-harlink-errors-in-geo-rep.patch b/SOURCES/0060-geo-rep-ignore-symlink-and-harlink-errors-in-geo-rep.patch new file mode 100644 index 0000000..1803dcf --- /dev/null +++ b/SOURCES/0060-geo-rep-ignore-symlink-and-harlink-errors-in-geo-rep.patch @@ -0,0 +1,68 @@ +From 80da8d75218552f2f78c37369a295be151cdc1f8 Mon Sep 17 00:00:00 2001 +From: Saravanakumar Arumugam +Date: Thu, 28 May 2015 11:54:04 +0530 +Subject: [PATCH 60/73] geo-rep: ignore symlink and harlink errors in geo-rep + +Ignore logging in case of symlink and hardlink creation +errors, as these are safe errors with respect to +geo-replication. + +Change-Id: I3b863fb03ae23dbea907e4dd9477ff85feecad70 +BUG: 1224662 +Reviewed-On: http://review.gluster.org/10957 +Reviewed-On: http://review.gluster.org/10984 +Signed-off-by: Saravanakumar Arumugam +Reviewed-on: https://code.engineering.redhat.com/gerrit/50523 +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + xlators/protocol/client/src/client-rpc-fops.c | 26 ++++++++++++++---------- + 1 files changed, 15 insertions(+), 11 deletions(-) + +diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c +index e5912bd..e8e3cdf 100644 +--- a/xlators/protocol/client/src/client-rpc-fops.c ++++ b/xlators/protocol/client/src/client-rpc-fops.c +@@ -163,13 +163,15 @@ client3_3_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- /* no need to print the gfid, because it will be null, since +- * symlink operation failed. +- */ +- gf_log (this->name, GF_LOG_WARNING, +- "remote operation failed: %s. Path: (%s to %s)", +- strerror (gf_error_to_errno (rsp.op_errno)), +- local->loc.path, local->loc2.path); ++ if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { ++ /* no need to print the gfid, because it will be null, ++ * since symlink operation failed. ++ */ ++ gf_log (this->name, GF_LOG_WARNING, ++ "remote operation failed: %s. Path: (%s to %s)", ++ strerror (gf_error_to_errno (rsp.op_errno)), ++ local->loc.path, local->loc2.path); ++ } + } + + CLIENT_STACK_UNWIND (symlink, frame, rsp.op_ret, +@@ -2668,10 +2670,12 @@ client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "remote operation failed: %s (%s -> %s)", +- strerror (gf_error_to_errno (rsp.op_errno)), +- local->loc.path, local->loc2.path); ++ if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "remote operation failed: %s (%s -> %s)", ++ strerror (gf_error_to_errno (rsp.op_errno)), ++ local->loc.path, local->loc2.path); ++ } + } + + CLIENT_STACK_UNWIND (link, frame, rsp.op_ret, +-- +1.7.1 + diff --git a/SOURCES/0061-spec-fix-add-pre-transaction-scripts-for-geo-rep-and.patch b/SOURCES/0061-spec-fix-add-pre-transaction-scripts-for-geo-rep-and.patch new file mode 100644 index 0000000..8276f3e --- /dev/null +++ b/SOURCES/0061-spec-fix-add-pre-transaction-scripts-for-geo-rep-and.patch @@ -0,0 +1,98 @@ +From 7c15202eaf63ad33d59bc40f23f77f071560e846 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Wed, 22 Apr 2015 15:39:59 +0200 +Subject: [PATCH 61/73] spec: fix/add pre-transaction scripts for geo-rep and cli packages + +The cli subpackage never had a %pretrans script, this has been added +now. + +The %pretrans script for ge-repliaction was never included in the RPM +package because it was disable by a undefined macro (_can_georeplicate). +This macro is not used/set anywhere else and _without_georeplication +should take care of it anyway. + +Note: This is a Red Hat Gluster Storage specific patch. Upstream + packaging guidelines do not allow these kind of 'features'. + +Label: DOWNSTREAM ONLY + +BUG: 1211839 +Change-Id: I16aab5bba72f1ed178f3bcac47f9d8ef767cfcef +Signed-off-by: Niels de Vos +Signed-off-by: Bala.FA +Reviewed-on: https://code.engineering.redhat.com/gerrit/50491 +--- + glusterfs.spec.in | 43 +++++++++++++++++++++++++++++++++++++++++-- + 1 files changed, 41 insertions(+), 2 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 3fcc00e..4b02f85 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1455,6 +1455,47 @@ end + + + ++%pretrans cli -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ + %pretrans devel -p + if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd +@@ -1537,7 +1578,6 @@ end + + + +-%if 0%{?_can_georeplicate} + %if ( 0%{!?_without_georeplication:1} ) + %pretrans geo-replication -p + if not posix.access("/bin/bash", "x") then +@@ -1578,7 +1618,6 @@ if not (ok == 0) then + error("Detected running glusterfs processes", ok) + end + %endif +-%endif + + + +-- +1.7.1 + diff --git a/SOURCES/0062-tools-glusterfind-Fix-GFID-to-Path-conversion-for-di.patch b/SOURCES/0062-tools-glusterfind-Fix-GFID-to-Path-conversion-for-di.patch new file mode 100644 index 0000000..5526fbf --- /dev/null +++ b/SOURCES/0062-tools-glusterfind-Fix-GFID-to-Path-conversion-for-di.patch @@ -0,0 +1,35 @@ +From 472cc15722c0bfbae73001c2472ff87f8f13e234 Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Wed, 10 Jun 2015 15:26:47 +0530 +Subject: [PATCH 62/73] tools/glusterfind: Fix GFID to Path conversion for dir + +For Directories, GFID to Path conversion was fine, but wrong +filter was used while updating to db. + +Change-Id: Id588adbb25ff5fd357f8cc2d5485bd2eb4a52b65 +Signed-off-by: Aravinda VK +Reviewed-on: http://review.gluster.org/11158 +Reviewed-on: http://review.gluster.org/11184 +BUG: 1228597 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50550 +Reviewed-by: Saravanakumar Arumugam +--- + tools/glusterfind/src/changelog.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py +index b5f71c7..fd2384b 100644 +--- a/tools/glusterfind/src/changelog.py ++++ b/tools/glusterfind/src/changelog.py +@@ -101,7 +101,7 @@ def populate_pgfid_and_inodegfid(brick, changelog_data): + path = output_path_prepare(path, args.output_prefix) + + changelog_data.gfidpath_update({"path1": path}, +- {"gfid": row[0]}) ++ {"gfid": gfid}) + else: + try: + # INODE and GFID to inodegfid table +-- +1.7.1 + diff --git a/SOURCES/0063-tools-glusterfind-Cleanup-glusterfind-dir-after-a-vo.patch b/SOURCES/0063-tools-glusterfind-Cleanup-glusterfind-dir-after-a-vo.patch new file mode 100644 index 0000000..1d6bcf9 --- /dev/null +++ b/SOURCES/0063-tools-glusterfind-Cleanup-glusterfind-dir-after-a-vo.patch @@ -0,0 +1,138 @@ +From 4992f2f8f3deb837e18d111013367be5d5fff0a6 Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Thu, 11 Jun 2015 18:37:16 +0530 +Subject: [PATCH 63/73] tools/glusterfind: Cleanup glusterfind dir after a volume delete + +If `glusterfind delete` command was not run before volume delete, stale +session directories exists in /var/lib/glusterd/glusterfind directories. + +Also shows these sessions in `glusterfind list` + +When Volume is deleted, Post hook will be run which cleans up the stale +session directories + +BUG: 1224880 +Change-Id: I54c46c30313e92c1bb4cb07918ed2029b375462c +Signed-off-by: Aravinda VK +Reviewed-On: http://review.gluster.org/10944 +Reviewed-On: http://review.gluster.org/11186 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50541 +Reviewed-by: Saravanakumar Arumugam +--- + extras/hook-scripts/Makefile.am | 7 ++- + extras/hook-scripts/S57glusterfind-delete-post.py | 60 +++++++++++++++++++++ + glusterfs.spec.in | 6 ++ + 3 files changed, 72 insertions(+), 1 deletions(-) + create mode 100755 extras/hook-scripts/S57glusterfind-delete-post.py + +diff --git a/extras/hook-scripts/Makefile.am b/extras/hook-scripts/Makefile.am +index 771b37e..b5e2ae6 100644 +--- a/extras/hook-scripts/Makefile.am ++++ b/extras/hook-scripts/Makefile.am +@@ -1,7 +1,12 @@ +-EXTRA_DIST = S40ufo-stop.py S56glusterd-geo-rep-create-post.sh ++EXTRA_DIST = S40ufo-stop.py S56glusterd-geo-rep-create-post.sh \ ++ S57glusterfind-delete-post.py ++ + SUBDIRS = add-brick set start stop reset + + scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/gsync-create/post/ + if USE_GEOREP + scripts_SCRIPTS = S56glusterd-geo-rep-create-post.sh + endif ++ ++deletehookscriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/delete/post/ ++deletehookscripts_SCRIPTS = S57glusterfind-delete-post.py +diff --git a/extras/hook-scripts/S57glusterfind-delete-post.py b/extras/hook-scripts/S57glusterfind-delete-post.py +new file mode 100755 +index 0000000..70edb56 +--- /dev/null ++++ b/extras/hook-scripts/S57glusterfind-delete-post.py +@@ -0,0 +1,60 @@ ++#!/usr/bin/python ++import os ++import shutil ++from errno import ENOENT ++from subprocess import Popen, PIPE ++from argparse import ArgumentParser ++ ++ ++DEFAULT_GLUSTERD_WORKDIR = "/var/lib/glusterd" ++ ++ ++def handle_rm_error(func, path, exc_info): ++ if exc_info[1].errno == ENOENT: ++ return ++ ++ raise exc_info[1] ++ ++ ++def get_glusterd_workdir(): ++ p = Popen(["gluster", "system::", "getwd"], ++ stdout=PIPE, stderr=PIPE) ++ ++ out, _ = p.communicate() ++ ++ if p.returncode == 0: ++ return out.strip() ++ else: ++ return DEFAULT_GLUSTERD_WORKDIR ++ ++ ++def get_args(): ++ parser = ArgumentParser(description="Volume delete post hook script") ++ parser.add_argument("--volname") ++ return parser.parse_args() ++ ++ ++def main(): ++ args = get_args() ++ glusterfind_dir = os.path.join(get_glusterd_workdir(), "glusterfind") ++ ++ # Check all session directories, if any directory found for ++ # the deleted volume, cleanup all the session directories ++ for session in os.listdir(glusterfind_dir): ++ # Possible session directory ++ volume_session_path = os.path.join(glusterfind_dir, ++ session, ++ args.volname) ++ if os.path.exists(volume_session_path): ++ shutil.rmtree(volume_session_path, onerror=handle_rm_error) ++ ++ # Try to Remove directory, if any other dir exists for different ++ # volume, then rmdir will fail with ENOTEMPTY which is fine ++ try: ++ os.rmdir(os.path.join(glusterfind_dir, session)) ++ except (OSError, IOError): ++ pass ++ ++ ++if __name__ == "__main__": ++ main() +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 4b02f85..aadfe70 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -991,6 +991,9 @@ fi + %exclude %{_libexecdir}/glusterfs/glusterfind + %exclude %{_bindir}/glusterfind + %exclude %{_libexecdir}/glusterfs/peer_add_secret_pub ++%{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.py ++%exclude %{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.pyc ++%exclude %{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.pyo + # exclude server files + %exclude %{_sharedstatedir}/glusterd/* + %exclude %{_sysconfdir}/glusterfs +@@ -1789,6 +1792,9 @@ end + %endif + + %changelog ++* Thu Jun 11 2015 Aravinda VK ++- Added post hook for volume delete as part of glusterfind (#1225551) ++ + * Thu Jun 11 2015 Atin Mukherjee + - Security hardening flags inclusion (#1200815) + +-- +1.7.1 + diff --git a/SOURCES/0064-geo-rep-Validate-use_meta_volume-option.patch b/SOURCES/0064-geo-rep-Validate-use_meta_volume-option.patch new file mode 100644 index 0000000..93e805d --- /dev/null +++ b/SOURCES/0064-geo-rep-Validate-use_meta_volume-option.patch @@ -0,0 +1,42 @@ +From 6997510c8ee9703b88206b57017fa5c78ec74b0e Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Wed, 10 Jun 2015 14:14:25 +0530 +Subject: [PATCH 64/73] geo-rep: Validate use_meta_volume option + +Added validation for use_meta_volume option. + +Change-Id: I64cd9cb4bf383c7267638cab3837fd0cf89071c7 +Signed-off-by: Aravinda VK +Reviewed-on: http://review.gluster.org/11156/ +BUG: 1227618 +Reviewed-on: http://review.gluster.org/11180 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50542 +Reviewed-by: Saravanakumar Arumugam +--- + xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +index b5020b7..de14664 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c ++++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +@@ -56,6 +56,16 @@ struct gsync_config_opt_vals_ gsync_confopt_vals[] = { + .case_sensitive = _gf_false, + .values = {"true", "false", "0", "1", "yes", "no"} + }, ++ {.op_name = "use_meta_volume", ++ .no_of_pos_vals = 6, ++ .case_sensitive = _gf_false, ++ .values = {"true", "false", "0", "1", "yes", "no"} ++ }, ++ {.op_name = "use-meta-volume", ++ .no_of_pos_vals = 6, ++ .case_sensitive = _gf_false, ++ .values = {"true", "false", "0", "1", "yes", "no"} ++ }, + {.op_name = NULL, + }, + }; +-- +1.7.1 + diff --git a/SOURCES/0065-tools-glusterfind-Cleanup-session-dir-after-delete.patch b/SOURCES/0065-tools-glusterfind-Cleanup-session-dir-after-delete.patch new file mode 100644 index 0000000..0b53467 --- /dev/null +++ b/SOURCES/0065-tools-glusterfind-Cleanup-session-dir-after-delete.patch @@ -0,0 +1,84 @@ +From c8a6868907e88f9f47705248ee32fc4601e99e4b Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Wed, 10 Jun 2015 14:47:21 +0530 +Subject: [PATCH 65/73] tools/glusterfind: Cleanup session dir after delete + +Sessions directories are created in +/var/lib/glusterd/glusterfind//, only +dir is created since same session name can exists for two volumes. + +Now cleanup is added, dir will be removed if +contains only one Volume. + +Change-Id: I236393659e63eb98342570e0255739f4adea4491 +Signed-off-by: Aravinda VK +BUG: 1229623 +Reviewed-on: http://review.gluster.org/11157 +Reviewed-on: http://review.gluster.org/11185 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50547 +Reviewed-by: Saravanakumar Arumugam +--- + tools/glusterfind/src/main.py | 11 ++++++++++- + tools/glusterfind/src/nodeagent.py | 10 ++++++++++ + 2 files changed, 20 insertions(+), 1 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index ccd2d22..4c1686c 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -9,7 +9,7 @@ + # cases as published by the Free Software Foundation. + + import sys +-from errno import ENOENT ++from errno import ENOENT, ENOTEMPTY + import time + from multiprocessing import Process + import os +@@ -440,6 +440,15 @@ def mode_delete(session_dir, args): + shutil.rmtree(os.path.join(session_dir, args.volume), + onerror=handle_rm_error) + ++ # If the session contains only this volume, then cleanup the ++ # session directory. If a session contains multiple volumes ++ # then os.rmdir will fail with ENOTEMPTY ++ try: ++ os.rmdir(session_dir) ++ except OSError as e: ++ if not e.errno == ENOTEMPTY: ++ logger.warn("Failed to delete session directory: %s" % e) ++ + + def mode_list(session_dir, args): + """ +diff --git a/tools/glusterfind/src/nodeagent.py b/tools/glusterfind/src/nodeagent.py +index 2e8c2fc..e7ba4af 100644 +--- a/tools/glusterfind/src/nodeagent.py ++++ b/tools/glusterfind/src/nodeagent.py +@@ -14,6 +14,7 @@ import os + import logging + from argparse import ArgumentParser, RawDescriptionHelpFormatter + import urllib ++from errno import ENOTEMPTY + + from utils import setup_logger, mkdirp, handle_rm_error + import conf +@@ -78,6 +79,15 @@ def mode_delete(args): + shutil.rmtree(os.path.join(session_dir, args.volume), + onerror=handle_rm_error) + ++ # If the session contains only this volume, then cleanup the ++ # session directory. If a session contains multiple volumes ++ # then os.rmdir will fail with ENOTEMPTY ++ try: ++ os.rmdir(session_dir) ++ except OSError as e: ++ if not e.errno == ENOTEMPTY: ++ logger.warn("Failed to delete session directory: %s" % e) ++ + + def _get_args(): + parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, +-- +1.7.1 + diff --git a/SOURCES/0066-tools-glusterfind-verifying-volume-is-online.patch b/SOURCES/0066-tools-glusterfind-verifying-volume-is-online.patch new file mode 100644 index 0000000..0eef3c4 --- /dev/null +++ b/SOURCES/0066-tools-glusterfind-verifying-volume-is-online.patch @@ -0,0 +1,77 @@ +From 6532c7d13f43748bed51f28e6a03e0e6605b76fd Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Fri, 12 Jun 2015 15:24:11 +0530 +Subject: [PATCH 66/73] tools/glusterfind: verifying volume is online + +Volume needs to be online (Started) to perform meaningful +operations i.e. for "create" and "pre". This is now verified. + +Change-Id: I4677780e22ad35ae82eae0765feb605cba69e437 +BUG: 1224236 +Reviewed-on: http://review.gluster.org/#/c/10955/ +Reviewed-on: http://review.gluster.org/#/c/11187/ +Signed-off-by: Milind Changire +Reviewed-on: https://code.engineering.redhat.com/gerrit/50619 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/main.py | 14 ++++++++++++++ + 1 files changed, 14 insertions(+), 0 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 4c1686c..850024b 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -31,6 +31,7 @@ ParseError = etree.ParseError if hasattr(etree, 'ParseError') else SyntaxError + + logger = logging.getLogger() + node_outfiles = [] ++vol_statusStr = "Stopped" + + + class StoreAbsPath(Action): +@@ -87,6 +88,10 @@ def run_cmd_nodes(task, args, **kwargs): + "tmp_output_%s" % num) + + if task == "pre": ++ if vol_statusStr == "Stopped": ++ fail("Volume %s is in stopped state" % args.volume, ++ logger=logger) ++ + # If Full backup is requested or start time is zero, use brickfind + change_detector = conf.get_change_detector("changelog") + if args.full: +@@ -123,6 +128,10 @@ def run_cmd_nodes(task, args, **kwargs): + args.session, + args.volume] + (["--debug"] if args.debug else []) + elif task == "create": ++ if vol_statusStr == "Stopped": ++ fail("Volume %s is in stopped state" % args.volume, ++ logger=logger) ++ + # When glusterfind create, create session directory in + # each brick nodes + cmd = [conf.get_opt("nodeagent"), +@@ -173,6 +182,8 @@ def get_nodes(volume): + Get the gluster volume info xml output and parse to get + the brick details. + """ ++ global vol_statusStr; ++ + cmd = ["gluster", 'volume', 'info', volume, "--xml"] + _, data, _ = execute(cmd, + exit_msg="Failed to Run Gluster Volume Info", +@@ -184,6 +195,9 @@ def get_nodes(volume): + if int(count_el.text) == 0: + fail("Unable to get volume details", logger=logger) + ++ # this status is used in caller: run_cmd_nodes ++ vol_statusStr = tree.find('volInfo/volumes/volume/statusStr').text ++ + nodes = [] + volume_el = tree.find('volInfo/volumes/volume') + try: +-- +1.7.1 + diff --git a/SOURCES/0067-features-changelog-Do-htime-setxattr-without-XATTR_R.patch b/SOURCES/0067-features-changelog-Do-htime-setxattr-without-XATTR_R.patch new file mode 100644 index 0000000..fbbc24f --- /dev/null +++ b/SOURCES/0067-features-changelog-Do-htime-setxattr-without-XATTR_R.patch @@ -0,0 +1,119 @@ +From ea8c08c0da93e71cca3d90849c0aa4f9c7eace95 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Tue, 9 Jun 2015 10:44:44 +0530 +Subject: [PATCH 67/73] features/changelog: Do htime setxattr without XATTR_REPLACE flag + +HTIME_KEY marks the last changelog rolled over. The xattr is +maintained on .glusterfs/changelog/htime/HTIME.TSTAMP file. +On every rollover of the changelog file, the xattr is updated. +It is being updated with XATTR_REPLACE flag as xattr gets +created during changelog enable. But it is once found that +the xattrs on the file is cleared and is not reproduced later +on. This patch protects that case, if it happens by setting +xattr without XATTR_REPLACE flag in failure case. + +The reason behind doing this in failure case is not to mask +the actual cause of xattrs getting cleared. This provides +the log message if the original issue still exists but the +consequential effects are fixed. + +Also changed the log messages to depict the events happened +during changelog enable. + +Change-Id: I699ed09a03667fd823d01d65c9c360fa7bc0e455 +BUG: 1228495 +Reviewed-On: http://review.gluster.org/#/c/11150/ +Reviewed-On: http://review.gluster.org/#/c/11181/ +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/50530 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + xlators/features/changelog/src/changelog-helpers.c | 33 +++++++++++++++----- + xlators/features/changelog/src/changelog.c | 3 +- + 2 files changed, 26 insertions(+), 10 deletions(-) + +diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c +index 7e518f1..2c0a645 100644 +--- a/xlators/features/changelog/src/changelog-helpers.c ++++ b/xlators/features/changelog/src/changelog-helpers.c +@@ -327,11 +327,21 @@ htime_update (xlator_t *this, + sprintf (x_value,"%lu:%d",ts, priv->rollover_count); + + if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, +- strlen (x_value), XATTR_REPLACE)) { ++ strlen (x_value), XATTR_REPLACE)) { + gf_log (this->name, GF_LOG_ERROR, +- "Htime xattr updation failed, " +- "reason (%s)",strerror (errno)); +- goto out; ++ "Htime xattr updation failed with XATTR_REPLACE " ++ "Changelog: %s Reason (%s)", changelog_path, ++ strerror (errno)); ++ ++ if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, ++ strlen (x_value), 0)) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Htime xattr updation failed " ++ "Changelog: %s Reason (%s)", changelog_path, ++ strerror (errno)); ++ ret = -1; ++ goto out; ++ } + } + + priv->rollover_count +=1; +@@ -633,17 +643,21 @@ htime_open (xlator_t *this, + size = sys_fgetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, + sizeof (ht_file_bname)); + if (size < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Error extracting" +- " HTIME_CURRENT: %s.", strerror (errno)); +- + /* If upgrade scenario, find the latest HTIME.TSTAMP file + * and use the same. If error, create a new HTIME.TSTAMP + * file. + */ + cnt = find_current_htime (ht_dir_fd, ht_dir_path, + ht_file_bname); +- if (cnt <= 0) ++ if (cnt <= 0) { ++ gf_log (this->name, GF_LOG_INFO, ++ "HTIME_CURRENT not found: %s. Changelog enabled" ++ " before init", strerror (errno)); + return htime_create (this, priv, ts); ++ } ++ ++ gf_log (this->name, GF_LOG_ERROR, "Error extracting" ++ " HTIME_CURRENT: %s.", strerror (errno)); + } + + gf_log (this->name, GF_LOG_INFO, "HTIME_CURRENT: %s", ht_file_bname); +@@ -701,6 +715,9 @@ htime_create (xlator_t *this, + char ht_file_bname[NAME_MAX + 1] = {0,}; + int flags = 0; + ++ gf_log (this->name, GF_LOG_INFO, "Changelog enable: Creating new " ++ "HTIME.%lu file", ts); ++ + CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path); + + /* get the htime file name in ht_file_path */ +diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c +index bea7334..47696f4 100644 +--- a/xlators/features/changelog/src/changelog.c ++++ b/xlators/features/changelog/src/changelog.c +@@ -2423,8 +2423,7 @@ reconfigure (xlator_t *this, dict_t *options) + if (active_now) { + if (!active_earlier) { + gf_log (this->name, GF_LOG_INFO, +- "Changelog enable: Creating new " +- "HTIME.TSTAMP file"); ++ "Reconfigure: Changelog Enable"); + if (gettimeofday(&tv, NULL) ) { + gf_log (this->name, GF_LOG_ERROR, + "unable to fetch htime"); +-- +1.7.1 + diff --git a/SOURCES/0068-snapshot-scheduler-Modified-main-function-to-take-ar.patch b/SOURCES/0068-snapshot-scheduler-Modified-main-function-to-take-ar.patch new file mode 100644 index 0000000..a8d2a14 --- /dev/null +++ b/SOURCES/0068-snapshot-scheduler-Modified-main-function-to-take-ar.patch @@ -0,0 +1,55 @@ +From beb674f81646116365ee7126266027d10e2ba8da Mon Sep 17 00:00:00 2001 +From: nnDarshan +Date: Tue, 12 May 2015 17:57:46 +0530 +Subject: [PATCH 68/73] snapshot/scheduler: Modified main() function to take arguments. + +Modified the main function to take script arguments, so that this +script can be used as a module by other programs . + +Change-Id: I902f0bc7ddfbf0d335cc087f51b1a7af4b7157fc +BUG: 1231078 +Signed-off-by: n Darshan +Reviewed-on: http://review.gluster.org/10760 +Reviewed-on: http://review.gluster.org/10997 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Aravinda VK +Reviewed-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/50614 +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Krishnan Parthasarathi +--- + extras/snap_scheduler/snap_scheduler.py | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index b692980..09015c5 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -581,7 +581,7 @@ def perform_operation(args): + return ret + + +-def main(): ++def main(argv): + initLogger() + ret = -1 + parser = argparse.ArgumentParser() +@@ -617,7 +617,7 @@ def main(): + parser_edit.add_argument("schedule", help="Schedule") + parser_edit.add_argument("volname", help="Volume Name") + +- args = parser.parse_args() ++ args = parser.parse_args(argv) + + if not os.path.exists(SHARED_STORAGE_DIR): + output("Failed: "+SHARED_STORAGE_DIR+" does not exist.") +@@ -675,4 +675,4 @@ def main(): + + + if __name__ == "__main__": +- sys.exit(main()) ++ sys.exit(main(sys.argv[1:])) +-- +1.7.1 + diff --git a/SOURCES/0069-glusterd-fix-op-versions-for-RHS-backwards-compatabi.patch b/SOURCES/0069-glusterd-fix-op-versions-for-RHS-backwards-compatabi.patch new file mode 100644 index 0000000..16d1196 --- /dev/null +++ b/SOURCES/0069-glusterd-fix-op-versions-for-RHS-backwards-compatabi.patch @@ -0,0 +1,1335 @@ +From dc34ee3b1962e51b5793ccaba71a1cf24062f598 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Thu, 11 Jun 2015 18:21:17 +0530 +Subject: [PATCH 69/73] glusterd: fix op-versions for RHS backwards compatability + +This change fixes the op-version of different features and checks to +maintain backwards compatability with RHS-3.0 and before. + +Change-Id: Ic8fb452d06b753b4e55496981069575e3b25d792 +BUG: 1230764 +Signed-off-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/50555 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + libglusterfs/src/globals.h | 45 +++-- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-handler.c | 12 +- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 16 +- + xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-rebalance.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 6 +- + xlators/mgmt/glusterd/src/glusterd-sm.c | 2 +- + .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 12 +- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-store.c | 25 ++-- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 11 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 12 +- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 186 ++++++++++---------- + 16 files changed, 187 insertions(+), 176 deletions(-) + +diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h +index 3ef18ce..07185a8 100644 +--- a/libglusterfs/src/globals.h ++++ b/libglusterfs/src/globals.h +@@ -17,23 +17,28 @@ + #define GD_MIN_OP_VERSION_KEY "minimum-operating-version" + #define GD_MAX_OP_VERSION_KEY "maximum-operating-version" + +-/* Gluster versions - OP-VERSION mapping ++/* RHS versions - OP-VERSION mapping + * +- * 3.3.x - 1 +- * 3.4.x - 2 +- * 3.5.0 - 3 +- * 3.5.1 - 30501 +- * 3.6.0 - 30600 +- * 3.7.0 - 30700 +- * 3.7.1 - 30701 +- * 3.7.2 - 30702 ++ * RHS-2.0 Z - 1 ++ * RHS-2.1 Z - 2 ++ * RHS-2.1 u5 - 20105 ++ * RHS-3.0 - 30000 ++ * RHS-3.0.4 - 30004 ++ * RHGS-3.1 - 30702 + * +- * Starting with Gluster v3.6, the op-version will be multi-digit integer values +- * based on the Glusterfs version, instead of a simply incrementing integer +- * value. The op-version for a given X.Y.Z release will be an integer XYZ, with +- * Y and Z 2 digit always 2 digits wide and padded with 0 when needed. This +- * should allow for some gaps between two Y releases for backports of features +- * in Z releases. ++ * ++ * NOTE: ++ * Starting with RHS-3.0, the op-version will be multi-digit integer values ++ * based on the RHS version, instead of a simply incrementing integer value. The ++ * op-version for a given RHS X(Major).Y(Minor).Z(Update) release will be an ++ * integer with digits XYZ. The Y and Z values will be 2 digits wide always ++ * padded with 0 as needed. This should allow for some gaps between two Y ++ * releases for backports of features in Z releases. ++ * ++ * NOTE: ++ * Starting with RHGS-3.1, the op-version will be the same as the upstream ++ * GlusterFS op-versions. This is to allow proper access to upstream clients of ++ * version 3.7.x or greater, proper access to the RHGS volumes. + */ + #define GD_OP_VERSION_MIN 1 /* MIN is the fresh start op-version, mostly + should not change */ +@@ -41,7 +46,13 @@ + table, should keep changing with + introduction of newer versions */ + +-#define GD_OP_VERSION_3_6_0 30600 /* Op-Version for GlusterFS 3.6.0 */ ++#define GD_OP_VERSION_RHS_3_0 30000 /* Op-Version of RHS 3.0 */ ++ ++#define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_RHS_3_0 ++ ++#define GD_OP_VERSION_RHS_2_1_5 20105 /* RHS 2.1 update 5 */ ++ ++#define GD_OP_VERSION_RHS_3_0_4 30004 /* Op-Version of RHS 3.0.4 */ + + #define GD_OP_VERSION_3_7_0 30700 /* Op-version for GlusterFS 3.7.0 */ + +@@ -49,8 +60,6 @@ + + #define GD_OP_VERSION_3_7_2 30702 /* Op-version for GlusterFS 3.7.2 */ + +-#define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 +- + #include "xlator.h" + + /* THIS */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index aa3a6c9..49bd887 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -1196,7 +1196,7 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (conf->op_version >= GD_OP_VERSION_3_6_0) { ++ if (conf->op_version >= GD_OP_VERSION_RHS_3_0) { + brick_mount_dir = NULL; + + snprintf (key, sizeof(key), "brick%d.mount_dir", i); +@@ -1528,7 +1528,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (conf->op_version >= GD_OP_VERSION_3_6_0) { ++ if (conf->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = glusterd_get_brick_mount_dir + (brickinfo->path, brickinfo->hostname, + brickinfo->mount_dir); +@@ -1707,12 +1707,12 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + } + + /* Check if the connected clients are all of version +- * glusterfs-3.6 and higher. This is needed to prevent some data ++ * RHS-2.1u5 and higher. This is needed to prevent some data + * loss issues that could occur when older clients are connected + * when rebalance is run. + */ + ret = glusterd_check_client_op_version_support +- (volname, GD_OP_VERSION_3_6_0, NULL); ++ (volname, GD_OP_VERSION_RHS_2_1_5, NULL); + if (ret) { + ret = gf_asprintf (op_errstr, "Volume %s has one or " + "more connected clients of a version" +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 564d787..9c922e3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -668,7 +668,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + } + + /* Based on the op_version, acquire a cluster or mgmt_v3 lock */ +- if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) { + ret = glusterd_lock (MY_UUID); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +@@ -715,7 +715,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + local_locking_done: + /* If no volname is given as a part of the command, locks will + * not be held, hence sending stage event. */ +- if (volname || (priv->op_version < GD_OP_VERSION_3_6_0)) ++ if (volname || (priv->op_version < GD_OP_VERSION_RHS_3_0)) + event_type = GD_OP_EVENT_START_LOCK; + else { + txn_op_info.state.state = GD_OP_STATE_LOCK_SENT; +@@ -745,7 +745,7 @@ out: + if (locked && ret) { + /* Based on the op-version, we release the + * cluster or mgmt_v3 lock */ +- if (priv->op_version < GD_OP_VERSION_3_6_0) ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) + glusterd_unlock (MY_UUID); + else { + ret = glusterd_mgmt_v3_unlock (volname, MY_UUID, +@@ -4069,11 +4069,11 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) + } + + if ((cmd & GF_CLI_STATUS_SNAPD) && +- (conf->op_version < GD_OP_VERSION_3_6_0)) { ++ (conf->op_version < GD_OP_VERSION_RHS_3_0)) { + snprintf (err_str, sizeof (err_str), "The cluster is operating " + "at a lesser version than %d. Getting the status of " + "snapd is not allowed in this state", +- GD_OP_VERSION_3_6_0); ++ GD_OP_VERSION_RHS_3_0); + ret = -1; + goto out; + } +@@ -4814,7 +4814,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + glusterd_friend_sm_state_name_get (peerinfo->state.state)); + + if (peerinfo->connected) { +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + glusterd_get_lock_owner (&uuid); + if (!gf_uuid_is_null (uuid) && + !gf_uuid_compare (peerinfo->uuid, uuid)) +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 877e9ac..6cf200d 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -197,7 +197,7 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id) + if (!*txn_id) + goto out; + +- if (priv->op_version < GD_OP_VERSION_3_6_0) ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) + gf_uuid_copy (**txn_id, priv->global_txn_id); + else + gf_uuid_generate (**txn_id); +@@ -1453,11 +1453,11 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) + } + + if ((cmd & GF_CLI_STATUS_SNAPD) && +- (priv->op_version < GD_OP_VERSION_3_6_0)) { ++ (priv->op_version < GD_OP_VERSION_RHS_3_0)) { + snprintf (msg, sizeof (msg), "The cluster is operating at " + "version less than %d. Getting the " + "status of snapd is not allowed in this state.", +- GD_OP_VERSION_3_6_0); ++ GD_OP_VERSION_RHS_3_0); + ret = -1; + goto out; + } +@@ -3203,7 +3203,7 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) + continue; + + /* Based on the op_version, acquire a cluster or mgmt_v3 lock */ +- if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) { + proc = &peerinfo->mgmt->proctable + [GLUSTERD_MGMT_CLUSTER_LOCK]; + if (proc->fn) { +@@ -3302,7 +3302,7 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx) + continue; + /* Based on the op_version, + * release the cluster or mgmt_v3 lock */ +- if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) { + proc = &peerinfo->mgmt->proctable + [GLUSTERD_MGMT_CLUSTER_UNLOCK]; + if (proc->fn) { +@@ -4263,7 +4263,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + count = brick_index_max + other_count + 1; + + /* +- * a glusterd lesser than version 3.7 will be sending the ++ * a glusterd lesser than version RHS-3.0.4 will be sending the + * rdma port in older key. Changing that value from here + * to support backward compatibility + */ +@@ -4272,7 +4272,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + goto out; + + glusterd_volinfo_find (volname, &volinfo); +- if (conf->op_version < GD_OP_VERSION_3_7_0 && ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0_4 && + volinfo->transport_type == GF_TRANSPORT_RDMA) { + ret = glusterd_op_modify_port_key (op_ctx, + brick_index_max); +@@ -4820,7 +4820,7 @@ glusterd_op_txn_complete (uuid_t *txn_id) + glusterd_op_clear_errstr (); + + /* Based on the op-version, we release the cluster or mgmt_v3 lock */ +- if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ if (priv->op_version < GD_OP_VERSION_RHS_3_0) { + ret = glusterd_unlock (MY_UUID); + /* unlock cant/shouldnt fail here!! */ + if (ret) +diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +index 9a05941..6df1dae 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +@@ -522,7 +522,7 @@ out: + * @prefix. All the parameters are compulsory. + * + * The complete address list is added to the dict only if the cluster op-version +- * is >= GD_OP_VERSION_3_6_0 ++ * is >= GD_OP_VERSION_3_7_0 + */ + int + gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, +@@ -573,7 +573,7 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, + goto out; + } + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_3_7_0) { + ret = 0; + goto out; + } +@@ -759,7 +759,7 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + GF_FREE (peerinfo->hostname); + peerinfo->hostname = gf_strdup (hostname); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_3_7_0) { + ret = 0; + goto out; + } +@@ -867,7 +867,7 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + conf = this->private; + GF_VALIDATE_OR_GOTO (this->name, (conf != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_3_7_0) { + ret = 0; + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +index f2708f0..0367df3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +@@ -602,13 +602,13 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + case GF_DEFRAG_CMD_START_LAYOUT_FIX: + case GF_DEFRAG_CMD_START_TIER: + /* Check if the connected clients are all of version +- * glusterfs-3.6 and higher. This is needed to prevent some data ++ * RHS-2.1u5 and higher. This is needed to prevent some data + * loss issues that could occur when older clients are connected + * when rebalance is run. This check can be bypassed by using + * 'force' + */ + ret = glusterd_check_client_op_version_support +- (volname, GD_OP_VERSION_3_6_0, NULL); ++ (volname, GD_OP_VERSION_RHS_2_1_5, NULL); + if (ret) { + ret = gf_asprintf (op_errstr, "Volume %s has one or " + "more connected clients of a version" +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index cb9c67c..9806556 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -410,7 +410,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + if (ret) + goto out; + +- } else if (priv->op_version >= GD_OP_VERSION_3_6_0) { ++ } else if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +@@ -618,7 +618,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo, + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (conf->op_version >= GD_OP_VERSION_3_6_0) { ++ if (conf->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = dict_get_str (dict, "brick1.mount_dir", &brick_mount_dir); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index dcd257c..2f9bac8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -288,11 +288,11 @@ __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, + * we need to add the new hostname to the peer. + * + * This addition should only be done for cluster op-version >= +- * GD_OP_VERSION_3_6_0 as address lists are only supported from then on. ++ * GD_OP_VERSION_3_7_0 as address lists are only supported from then on. + * Also, this update should only be done when an explicit CLI probe + * command was used to begin the probe process. + */ +- if ((conf->op_version >= GD_OP_VERSION_3_6_0) && ++ if ((conf->op_version >= GD_OP_VERSION_3_7_0) && + (gf_uuid_compare (rsp.uuid, peerinfo->uuid) == 0)) { + ctx = ((call_frame_t *)myframe)->local; + /* Presence of ctx->req implies this probe was started by a cli +@@ -1481,7 +1481,7 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (priv->op_version >= GD_OP_VERSION_3_6_0) { ++ if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = glusterd_add_missed_snaps_to_export_dict (peer_data); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 0d8654a..6f41b7b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -789,7 +789,7 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + /* Compare missed_snapshot list with the peer * + * if volume comparison is successful */ + if ((op_ret == 0) && +- (conf->op_version >= GD_OP_VERSION_3_6_0)) { ++ (conf->op_version >= GD_OP_VERSION_RHS_3_0)) { + ret = glusterd_import_friend_missed_snap_list (ev_ctx->vols); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +index 294758b..6e4b363 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +@@ -383,7 +383,7 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix, + GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); + GF_VALIDATE_OR_GOTO (this->name, (brickinfo != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -465,7 +465,7 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix, + GF_VALIDATE_OR_GOTO (this->name, (volinfo != NULL), out); + GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -793,7 +793,7 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix, + GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); + GF_VALIDATE_OR_GOTO (this->name, (brickinfo != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -853,8 +853,8 @@ out: + * Imports the snapshot details of a volume if required and available + * + * Snapshot details will be imported only if cluster.op_version is greater than +- * or equal to GD_OP_VERSION_3_6_0, the op-version from which volume snapshot is +- * supported. ++ * or equal to GD_OP_VERSION_RHS_3_0, the op-version from which volume snapshot ++ * is supported. + */ + int + gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, +@@ -876,7 +876,7 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, + GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); + GF_VALIDATE_OR_GOTO (this->name, (volname != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 0ea3935..f779bff 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -8852,7 +8852,7 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + goto out; + } + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + snprintf (err_str, sizeof (err_str), "Cluster operating version" + " is lesser than the supported version " + "for a snapshot"); +@@ -8860,7 +8860,7 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNSUPPORTED_VERSION, + "%s (%d < %d)", err_str, +- conf->op_version, GD_OP_VERSION_3_6_0); ++ conf->op_version, GD_OP_VERSION_RHS_3_0); + ret = -1; + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index ee279d3..ae87e9a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -305,7 +305,7 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) + GF_VALIDATE_OR_GOTO (this->name, (fd > 0), out); + GF_VALIDATE_OR_GOTO (this->name, (brickinfo != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -771,7 +771,7 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo) + GF_VALIDATE_OR_GOTO (this->name, (fd > 0), out); + GF_VALIDATE_OR_GOTO (this->name, (volinfo != NULL), out); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -2075,7 +2075,7 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo) + conf = THIS->private; + GF_ASSERT (volinfo); + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = 0; + goto out; + } +@@ -2083,15 +2083,16 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo) + /* + * This is needed for upgrade situations. Say a volume is created with + * older version of glusterfs and upgraded to a glusterfs version equal +- * to or greater than GD_OP_VERSION_3_6_0. The older glusterd would not +- * have created the snapd.info file related to snapshot daemon for user +- * serviceable snapshots. So as part of upgrade when the new glusterd +- * starts, as part of restore (restoring the volume to be precise), it +- * tries to snapd related info from snapd.info file. But since there was +- * no such file till now, the restore operation fails. Thus, to prevent +- * it from happening check whether user serviceable snapshots features +- * is enabled before restoring snapd. If its disbaled, then simply +- * exit by returning success (without even checking for the snapd.info). ++ * to or greater than GD_OP_VERSION_RHS_3_0. The older glusterd would ++ * not have created the snapd.info file related to snapshot daemon for ++ * user serviceable snapshots. So as part of upgrade when the new ++ * glusterd starts, as part of restore (restoring the volume to be ++ * precise), it tries to snapd related info from snapd.info file. But ++ * since there was no such file till now, the restore operation fails. ++ * Thus, to prevent it from happening check whether user serviceable ++ * snapshots features is enabled before restoring snapd. If its ++ * disbaled, then simply exit by returning success (without even ++ * checking for the snapd.info). + */ + + if (!dict_get_str_boolean (volinfo->dict, "features.uss", _gf_false)) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index da12cba..a006afa 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -1164,7 +1164,7 @@ gd_lock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx, + continue; + + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + /* Reset lock status */ + peerinfo->locked = _gf_false; + gd_syncop_mgmt_lock (peerinfo, &args, +@@ -1481,7 +1481,7 @@ gd_unlock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, int *op_ret, + synctask_barrier_init((&args)); + peer_cnt = 0; + +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + rcu_read_lock (); + cds_list_for_each_entry_rcu (peerinfo, &conf->peers, + uuid_list) { +@@ -1567,7 +1567,7 @@ out: + * and clear the op */ + + glusterd_op_clear_op (op); +- if (conf->op_version < GD_OP_VERSION_3_6_0) ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) + glusterd_unlock (MY_UUID); + else { + if (type) { +@@ -1760,7 +1760,7 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + } + + /* Based on the op_version, acquire a cluster or mgmt_v3 lock */ +- if (conf->op_version < GD_OP_VERSION_3_6_0) { ++ if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = glusterd_lock (MY_UUID); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, +@@ -1829,7 +1829,8 @@ local_locking_done: + + /* If no volname is given as a part of the command, locks will + * not be held */ +- if (volname || (conf->op_version < GD_OP_VERSION_3_6_0) || is_global) { ++ if (volname || (conf->op_version < GD_OP_VERSION_RHS_3_0) || ++ is_global) { + ret = gd_lock_op_phase (conf, op, op_ctx, &op_errstr, *txn_id, + &txn_opinfo); + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 0721110..82b2e57 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -8809,10 +8809,10 @@ gd_update_volume_op_versions (glusterd_volinfo_t *volinfo) + } + + if (volinfo->type == GF_CLUSTER_TYPE_DISPERSE) { +- if (volinfo->op_version < GD_OP_VERSION_3_6_0) +- volinfo->op_version = GD_OP_VERSION_3_6_0; +- if (volinfo->client_op_version < GD_OP_VERSION_3_6_0) +- volinfo->client_op_version = GD_OP_VERSION_3_6_0; ++ if (volinfo->op_version < GD_OP_VERSION_3_7_0) ++ volinfo->op_version = GD_OP_VERSION_3_7_0; ++ if (volinfo->client_op_version < GD_OP_VERSION_3_7_0) ++ volinfo->client_op_version = GD_OP_VERSION_3_7_0; + } + + return; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 1d29d50..ea8bf13 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -1137,7 +1137,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (priv->op_version >= GD_OP_VERSION_3_6_0) { ++ if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = glusterd_get_brick_mount_dir + (brick_info->path, brick_info->hostname, + brick_info->mount_dir); +@@ -1390,7 +1390,7 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (priv->op_version >= GD_OP_VERSION_3_6_0) { ++ if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + if (strlen(brickinfo->mount_dir) < 1) { + ret = glusterd_get_brick_mount_dir + (brickinfo->path, brickinfo->hostname, +@@ -2029,9 +2029,9 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + "redundancy count for volume %s", volname); + goto out; + } +- if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ if (priv->op_version < GD_OP_VERSION_3_7_0) { + gf_log (this->name, GF_LOG_ERROR, "Disperse volume " +- "needs op-version 3.6.0 or higher"); ++ "needs op-version 30700 or higher"); + ret = -1; + goto out; + } +@@ -2127,7 +2127,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (priv->op_version >= GD_OP_VERSION_3_6_0) { ++ if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + brick_mount_dir = NULL; + snprintf (key, sizeof(key), "brick%d.mount_dir", i); + ret = dict_get_str (dict, key, &brick_mount_dir); +@@ -2287,7 +2287,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + /* A bricks mount dir is required only by snapshots which were + * introduced in gluster-3.6.0 + */ +- if (conf->op_version >= GD_OP_VERSION_3_6_0) { ++ if (conf->op_version >= GD_OP_VERSION_RHS_3_0) { + cds_list_for_each_entry (brickinfo, &volinfo->bricks, + brick_list) { + brick_count++; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 8dea069..39bf82f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -356,7 +356,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "cluster.subvols-per-directory", + .voltype = "cluster/distribute", + .option = "directory-layout-spread", +- .op_version = 2, ++ .op_version = 1, + .validate_fn = validate_subvols_per_directory, + .flags = OPT_FLAG_CLIENT_OPT + }, +@@ -368,27 +368,27 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "cluster.rsync-hash-regex", + .voltype = "cluster/distribute", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.extra-hash-regex", + .voltype = "cluster/distribute", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.dht-xattr-name", + .voltype = "cluster/distribute", + .option = "xattr-name", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.randomize-hash-range-by-gfid", + .voltype = "cluster/distribute", + .option = "randomize-hash-range-by-gfid", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_3_7_0, + .flags = OPT_FLAG_CLIENT_OPT, + }, + { .key = "cluster.rebal-throttle", +@@ -410,12 +410,12 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "cluster/nufa", + .option = "local-volume-name", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.weighted-rebalance", + .voltype = "cluster/distribute", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_3_7_0, + }, + + /* Switch xlator options (Distribute special case) */ +@@ -423,14 +423,14 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "cluster/distribute", + .option = "!switch", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.switch-pattern", + .voltype = "cluster/switch", + .option = "pattern.switch.case", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + +@@ -550,18 +550,18 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "cluster.readdir-failover", + .voltype = "cluster/replicate", +- .op_version = 2, ++ .op_version = 1, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.ensure-durability", + .voltype = "cluster/replicate", +- .op_version = 3, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.consistent-metadata", + .voltype = "cluster/replicate", + .type = DOC, +- .op_version = GD_OP_VERSION_3_7_0, ++ .op_version = GD_OP_VERSION_RHS_3_0_4, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "cluster.stripe-block-size", +@@ -621,45 +621,45 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "diagnostics.brick-logger", + .voltype = "debug/io-stats", + .option = "!logger", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "diagnostics.client-logger", + .voltype = "debug/io-stats", + .option = "!logger", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "diagnostics.brick-log-format", + .voltype = "debug/io-stats", + .option = "!log-format", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "diagnostics.client-log-format", + .voltype = "debug/io-stats", + .option = "!log-format", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "diagnostics.brick-log-buf-size", + .voltype = "debug/io-stats", + .option = "!log-buf-size", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "diagnostics.client-log-buf-size", + .voltype = "debug/io-stats", + .option = "!log-buf-size", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "diagnostics.brick-log-flush-timeout", + .voltype = "debug/io-stats", + .option = "!log-flush-timeout", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "diagnostics.client-log-flush-timeout", + .voltype = "debug/io-stats", + .option = "!log-flush-timeout", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + +@@ -724,7 +724,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "performance.least-rate-limit", + .voltype = "performance/io-threads", +- .op_version = 2 ++ .op_version = 1 + }, + + /* Other perf xlators' options */ +@@ -743,7 +743,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "performance.nfs.flush-behind", + .voltype = "performance/write-behind", + .option = "flush-behind", +- .op_version = 1, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.write-behind-window-size", +@@ -755,43 +755,43 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "performance.nfs.write-behind-window-size", + .voltype = "performance/write-behind", + .option = "cache-size", +- .op_version = 1, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.strict-o-direct", + .voltype = "performance/write-behind", + .option = "strict-O_DIRECT", +- .op_version = 2, ++ .op_version = 1, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.nfs.strict-o-direct", + .voltype = "performance/write-behind", + .option = "strict-O_DIRECT", +- .op_version = 2, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.strict-write-ordering", + .voltype = "performance/write-behind", + .option = "strict-write-ordering", +- .op_version = 2, ++ .op_version = 1, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.nfs.strict-write-ordering", + .voltype = "performance/write-behind", + .option = "strict-write-ordering", +- .op_version = 2, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.lazy-open", + .voltype = "performance/open-behind", + .option = "lazy-open", +- .op_version = 3, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.read-after-open", + .voltype = "performance/open-behind", + .option = "read-after-open", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "performance.read-ahead-page-count", +@@ -813,7 +813,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "encryption/crypt", + .option = "!feat", + .value = "off", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .description = "enable/disable client-side encryption for " + "the volume.", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT +@@ -821,17 +821,17 @@ struct volopt_map_entry glusterd_volopt_map[] = { + + { .key = "encryption.master-key", + .voltype = "encryption/crypt", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "encryption.data-key-size", + .voltype = "encryption/crypt", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "encryption.block-size", + .voltype = "encryption/crypt", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .flags = OPT_FLAG_CLIENT_OPT + }, + +@@ -873,7 +873,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "network.remote-dio", + .voltype = "protocol/client", + .option = "filter-O_DIRECT", +- .op_version = 2, ++ .op_version = 1, + .flags = OPT_FLAG_CLIENT_OPT + }, + { .key = "client.own-thread", +@@ -884,7 +884,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "client.event-threads", + .voltype = "protocol/client", +- .op_version = GD_OP_VERSION_3_7_0, ++ .op_version = GD_OP_VERSION_RHS_3_0_4, + }, + + /* Server xlator options */ +@@ -928,17 +928,17 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "server.root-squash", + .voltype = "protocol/server", + .option = "root-squash", +- .op_version = 2 ++ .op_version = 1 + }, + { .key = "server.anonuid", + .voltype = "protocol/server", + .option = "anonuid", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "server.anongid", + .voltype = "protocol/server", + .option = "anongid", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "server.statedump-path", + .voltype = "protocol/server", +@@ -949,7 +949,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "protocol/server", + .option = "rpc.outstanding-rpc-limit", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "features.lock-heal", + .voltype = "protocol/server", +@@ -974,20 +974,20 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .option = "!ssl-allow", + .value = "*", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_3_7_0, + }, + { .key = "server.manage-gids", + .voltype = "protocol/server", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "client.send-gids", + .voltype = "protocol/client", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "server.gid-timeout", + .voltype = "protocol/server", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "server.own-thread", + .voltype = "protocol/server", +@@ -997,19 +997,19 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "server.event-threads", + .voltype = "protocol/server", +- .op_version = GD_OP_VERSION_3_7_0, ++ .op_version = GD_OP_VERSION_RHS_3_0_4, + }, + + /* Generic transport options */ + { .key = SSL_CERT_DEPTH_OPT, + .voltype = "rpc-transport/socket", + .option = "!ssl-cert-depth", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_3_7_0, + }, + { .key = SSL_CIPHER_LIST_OPT, + .voltype = "rpc-transport/socket", + .option = "!ssl-cipher-list", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_3_7_0, + }, + + /* Performance xlators enable/disbable options */ +@@ -1034,7 +1034,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "performance/readdir-ahead", + .option = "!perf", + .value = "off", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .description = "enable/disable readdir-ahead translator in the volume.", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT + }, +@@ -1143,7 +1143,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/qemu-block", + .option = "!feat", + .value = "off", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .description = "enable/disable file-snapshot feature in the " + "volume.", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT +@@ -1151,7 +1151,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + + { .key = "features.uss", + .voltype = "features/snapview-server", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .value = "off", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT, + .validate_fn = validate_uss, +@@ -1161,7 +1161,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + + { .key = "features.snapshot-directory", + .voltype = "features/snapview-client", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .value = ".snaps", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT, + .description = "Entry point directory for entering snapshot world" +@@ -1169,7 +1169,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + + { .key = "features.show-snapshot-directory", + .voltype = "features/snapview-client", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .value = "off", + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT, + .description = "show entry point in readdir output of " +@@ -1184,35 +1184,35 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/cdc", + .option = "!feat", + .value = "off", +- .op_version = 3, ++ .op_version = GD_OP_VERSION_RHS_3_0, + .description = "enable/disable network compression translator", + .flags = OPT_FLAG_XLATOR_OPT + }, + { .key = "network.compression.window-size", + .voltype = "features/cdc", + .option = "window-size", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "network.compression.mem-level", + .voltype = "features/cdc", + .option = "mem-level", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "network.compression.min-size", + .voltype = "features/cdc", + .option = "min-size", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "network.compression.compression-level", + .voltype = "features/cdc", + .option = "compression-level", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "network.compression.debug", + .voltype = "features/cdc", + .option = "debug", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + #endif + +@@ -1235,25 +1235,25 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/quota", + .option = "default-soft-limit", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + }, + { .key = "features.soft-timeout", + .voltype = "features/quota", + .option = "soft-timeout", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + }, + { .key = "features.hard-timeout", + .voltype = "features/quota", + .option = "hard-timeout", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + }, + { .key = "features.alert-time", + .voltype = "features/quota", + .option = "alert-time", + .type = NO_DOC, +- .op_version = 3, ++ .op_version = 2, + }, + { .key = "features.quota-deem-statfs", + .voltype = "features/quota", +@@ -1368,25 +1368,25 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "debug/error-gen", + .option = "failure", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "debug.error-number", + .voltype = "debug/error-gen", + .option = "error-no", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "debug.random-failure", + .voltype = "debug/error-gen", + .option = "random-failure", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "debug.error-fops", + .voltype = "debug/error-gen", + .option = "enable", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + + +@@ -1437,7 +1437,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "nfs/server", + .option = "rpc.outstanding-rpc-limit", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "nfs.port", + .voltype = "nfs/server", +@@ -1512,7 +1512,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "nfs/server", + .option = "nfs.acl", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "nfs.mount-udp", + .voltype = "nfs/server", +@@ -1530,13 +1530,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "nfs/server", + .option = "nfs.rpc-statd", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "nfs.log-level", + .voltype = "nfs/server", + .option = "nfs.log-level", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "nfs.server-aux-gids", + .voltype = "nfs/server", +@@ -1548,31 +1548,31 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "nfs/server", + .option = "nfs.drc", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 1 + }, + { .key = "nfs.drc-size", + .voltype = "nfs/server", + .option = "nfs.drc-size", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 1 + }, + { .key = "nfs.read-size", + .voltype = "nfs/server", + .option = "nfs3.read-size", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "nfs.write-size", + .voltype = "nfs/server", + .option = "nfs3.write-size", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "nfs.readdir-size", + .voltype = "nfs/server", + .option = "nfs3.readdir-size", + .type = GLOBAL_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + + /* Cli options for Export authentication on nfs mount */ +@@ -1599,7 +1599,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = "features.read-only", + .voltype = "features/read-only", + .option = "read-only", +- .op_version = 1, ++ .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT + }, + { .key = "features.worm", +@@ -1615,15 +1615,15 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "storage.batch-fsync-mode", + .voltype = "storage/posix", +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "storage.batch-fsync-delay-usec", + .voltype = "storage/posix", +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "storage.xattr-user-namespace-mode", + .voltype = "storage/posix", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "storage.owner-uid", + .voltype = "storage/posix", +@@ -1637,20 +1637,20 @@ struct volopt_map_entry glusterd_volopt_map[] = { + }, + { .key = "storage.node-uuid-pathinfo", + .voltype = "storage/posix", +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "storage.health-check-interval", + .voltype = "storage/posix", +- .op_version = 3 ++ .op_version = 2 + }, + { .option = "update-link-count-parent", + .key = "storage.build-pgfid", + .voltype = "storage/posix", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "storage.bd-aio", + .voltype = "storage/bd", +- .op_version = 3 ++ .op_version = GD_OP_VERSION_RHS_3_0 + }, + { .key = "config.memory-accounting", + .voltype = "configuration", +@@ -1666,43 +1666,43 @@ struct volopt_map_entry glusterd_volopt_map[] = { + { .key = GLUSTERD_QUORUM_TYPE_KEY, + .voltype = "mgmt/glusterd", + .value = "off", +- .op_version = 2 ++ .op_version = 1 + }, + { .key = GLUSTERD_QUORUM_RATIO_KEY, + .voltype = "mgmt/glusterd", + .value = "0", +- .op_version = 2 ++ .op_version = 1 + }, + /* changelog translator - global tunables */ + { .key = "changelog.changelog", + .voltype = "features/changelog", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "changelog.changelog-dir", + .voltype = "features/changelog", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "changelog.encoding", + .voltype = "features/changelog", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "changelog.rollover-time", + .voltype = "features/changelog", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "changelog.fsync-interval", + .voltype = "features/changelog", + .type = NO_DOC, +- .op_version = 3 ++ .op_version = 2 + }, + { .key = "changelog.changelog-barrier-timeout", + .voltype = "features/changelog", + .value = BARRIER_TIMEOUT, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "changelog.capture-del-path", + .voltype = "features/changelog", +@@ -1713,16 +1713,16 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/barrier", + .value = "disable", + .type = NO_DOC, +- .op_version = GD_OP_VERSION_3_7_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "features.barrier-timeout", + .voltype = "features/barrier", + .value = BARRIER_TIMEOUT, +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + { .key = "cluster.op-version", + .voltype = "mgmt/glusterd", +- .op_version = GD_OP_VERSION_3_6_0, ++ .op_version = GD_OP_VERSION_RHS_3_0, + }, + /*Trash translator options */ + { .key = "features.trash", +-- +1.7.1 + diff --git a/SOURCES/0070-tools-glusterfind-ignoring-deleted-files.patch b/SOURCES/0070-tools-glusterfind-ignoring-deleted-files.patch new file mode 100644 index 0000000..4c5afa2 --- /dev/null +++ b/SOURCES/0070-tools-glusterfind-ignoring-deleted-files.patch @@ -0,0 +1,152 @@ +From bb5ed3d9ddd7e64b0ea99e231192c0f3f73a3729 Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Fri, 12 Jun 2015 16:38:43 +0530 +Subject: [PATCH 70/73] tools/glusterfind: ignoring deleted files + +OSError and IOError exceptions were being thrown if files +were deleted after session was created and a subsequent +glusterfind pre was attmepted. glusterfind now detects +this scenario and safely ignores these changes to the +file-system. We also avoid recording deleted file paths +into database in the case where gfid to path resolution +cannot be performed for deleted files. + +Also, we now turn on volume option to capture delete paths. + +Reviewed-on: http://review.gluster.org/#/c/11199/ +Reviewed-on: http://review.gluster.org/#/c/11194/ +Change-Id: I4637172fd41c8c3e52f38046babd51dbcff03afb +BUG: 1228017 +Signed-off-by: Milind Changire +Reviewed-on: https://code.engineering.redhat.com/gerrit/50626 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/changelog.py | 60 +++++++++++++++++++++-------------- + tools/glusterfind/src/main.py | 7 ++++ + 2 files changed, 43 insertions(+), 24 deletions(-) + +diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py +index fd2384b..5939d48 100644 +--- a/tools/glusterfind/src/changelog.py ++++ b/tools/glusterfind/src/changelog.py +@@ -61,10 +61,13 @@ def pgfid_to_path(brick, changelog_data): + if row[0] == "": + continue + +- path = symlink_gfid_to_path(brick, row[0]) +- path = output_path_prepare(path, args.output_prefix) +- +- changelog_data.gfidpath_set_path1(path, row[0]) ++ try: ++ path = symlink_gfid_to_path(brick, row[0]) ++ path = output_path_prepare(path, args.output_prefix) ++ changelog_data.gfidpath_set_path1(path, row[0]) ++ except (IOError, OSError) as e: ++ logger.warn("Error converting to path: %s" % e) ++ continue + + # pgfid2 to path2 in case of RENAME + for row in changelog_data.gfidpath_get_distinct("pgfid2", +@@ -74,13 +77,14 @@ def pgfid_to_path(brick, changelog_data): + if row[0] == "": + continue + +- path = symlink_gfid_to_path(brick, row[0]) +- if path == "": ++ try: ++ path = symlink_gfid_to_path(brick, row[0]) ++ path = output_path_prepare(path, args.output_prefix) ++ changelog_data.gfidpath_set_path2(path, row[0]) ++ except (IOError, OSError) as e: ++ logger.warn("Error converting to path: %s" % e) + continue + +- path = output_path_prepare(path, args.output_prefix) +- changelog_data.gfidpath_set_path2(path, row[0]) +- + + def populate_pgfid_and_inodegfid(brick, changelog_data): + """ +@@ -94,14 +98,14 @@ def populate_pgfid_and_inodegfid(brick, changelog_data): + p = os.path.join(brick, ".glusterfs", gfid[0:2], gfid[2:4], gfid) + if os.path.islink(p): + # It is a Directory if GFID backend path is symlink +- path = symlink_gfid_to_path(brick, gfid) +- if path == "": ++ try: ++ path = symlink_gfid_to_path(brick, gfid) ++ path = output_path_prepare(path, args.output_prefix) ++ changelog_data.gfidpath_update({"path1": path}, ++ {"gfid": gfid}) ++ except (IOError, OSError) as e: ++ logger.warn("Error converting to path: %s" % e) + continue +- +- path = output_path_prepare(path, args.output_prefix) +- +- changelog_data.gfidpath_update({"path1": path}, +- {"gfid": gfid}) + else: + try: + # INODE and GFID to inodegfid table +@@ -161,12 +165,16 @@ def gfid_to_path_using_pgfid(brick, changelog_data, args): + conf.get_opt("brick_ignore_dirs").split(",")] + + for row in changelog_data.pgfid_get(): +- path = symlink_gfid_to_path(brick, row[0]) +- find(os.path.join(brick, path), +- callback_func=output_callback, +- filter_func=inode_filter, +- ignore_dirs=ignore_dirs, +- subdirs_crawl=False) ++ try: ++ path = symlink_gfid_to_path(brick, row[0]) ++ find(os.path.join(brick, path), ++ callback_func=output_callback, ++ filter_func=inode_filter, ++ ignore_dirs=ignore_dirs, ++ subdirs_crawl=False) ++ except (IOError, OSError) as e: ++ logger.warn("Error converting to path: %s" % e) ++ continue + + + def gfid_to_path_using_batchfind(brick, changelog_data): +@@ -291,8 +299,12 @@ def get_changes(brick, hash_dir, log_file, start, end, args): + # again in list + if change.endswith(".%s" % start): + continue +- parse_changelog_to_db(changelog_data, change) +- libgfchangelog.cl_history_done(change) ++ try: ++ parse_changelog_to_db(changelog_data, change) ++ libgfchangelog.cl_history_done(change) ++ except IOError as e: ++ logger.warn("Error parsing changelog file %s: %s" % ++ (change, e)) + + changelog_data.commit() + except libgfchangelog.ChangelogException as e: +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 850024b..5d5058f 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -352,6 +352,13 @@ def mode_create(session_dir, args): + logger.info("Volume option set %s, changelog.changelog on" + % args.volume) + ++ execute(["gluster", "volume", "set", ++ args.volume, "changelog.capture-del-path", "on"], ++ exit_msg="Failed to set volume option " ++ "changelog.capture-del-path on", logger=logger) ++ logger.info("Volume option set %s, changelog.capture-del-path on" ++ % args.volume) ++ + # Add Rollover time to current time to make sure changelogs + # will be available if we use this time as start time + time_to_update = int(time.time()) + get_changelog_rollover_time( +-- +1.7.1 + diff --git a/SOURCES/0071-spec-geo-rep-Add-rsync-as-dependency-for-georeplicat.patch b/SOURCES/0071-spec-geo-rep-Add-rsync-as-dependency-for-georeplicat.patch new file mode 100644 index 0000000..a805690 --- /dev/null +++ b/SOURCES/0071-spec-geo-rep-Add-rsync-as-dependency-for-georeplicat.patch @@ -0,0 +1,44 @@ +From 613633d53f0bb88f30af4d2b83b3f49ffcea4880 Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Fri, 12 Jun 2015 17:43:22 +0530 +Subject: [PATCH 71/73] spec/geo-rep: Add rsync as dependency for georeplication rpm + +If rsync is not installed, Geo-rep will go faulty on started. +Added rsync as dependency for georep rpm + +Change-Id: I49614957ccde47645185a65191d6d7baf1cc826c +Signed-off-by: Aravinda VK +BUG: 1230607 +Reviewed-on: http://review.gluster.org/11201 +Reviewed-on: http://review.gluster.org/11203 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50627 +Reviewed-by: Saravanakumar Arumugam +--- + glusterfs.spec.in | 4 ++++ + 1 files changed, 4 insertions(+), 0 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index aadfe70..29a1ac4 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -412,6 +412,7 @@ Group: Applications/File + Requires: %{name} = %{version}-%{release} + Requires: %{name}-server = %{version}-%{release} + Requires: python python-ctypes ++Requires: rsync + + %description geo-replication + GlusterFS is a distributed file-system capable of scaling to several +@@ -1792,6 +1793,9 @@ end + %endif + + %changelog ++* Fri Jun 12 2015 Aravinda VK ++- Added rsync as dependency to georeplication rpm (#1231213) ++ + * Thu Jun 11 2015 Aravinda VK + - Added post hook for volume delete as part of glusterfind (#1225551) + +-- +1.7.1 + diff --git a/SOURCES/0072-tools-glusterfind-print-message-for-good-cases.patch b/SOURCES/0072-tools-glusterfind-print-message-for-good-cases.patch new file mode 100644 index 0000000..9ab9bfa --- /dev/null +++ b/SOURCES/0072-tools-glusterfind-print-message-for-good-cases.patch @@ -0,0 +1,105 @@ +From 1db921d548904e2382e52c67538928d8ea6d66d3 Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Thu, 11 Jun 2015 20:58:00 +0530 +Subject: [PATCH 72/73] tools/glusterfind: print message for good cases + +Added messages for printing status of good or default cases +for 'create', 'list', 'post' and 'delete' commands + +Change-Id: I86d8aeacc8e3729256d76608e6c006e763f56511 +BUG: 1229674 +Reviewed-On: http://review.gluster.org/11208 +Reviewed-On: http://review.gluster.org/11189 +Signed-off-by: Milind Changire +Reviewed-on: https://code.engineering.redhat.com/gerrit/50570 +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/main.py | 22 ++++++++++++++++------ + 1 files changed, 16 insertions(+), 6 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 5d5058f..29fa28b 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -90,7 +90,7 @@ def run_cmd_nodes(task, args, **kwargs): + if task == "pre": + if vol_statusStr == "Stopped": + fail("Volume %s is in stopped state" % args.volume, +- logger=logger) ++ logger=logger) + + # If Full backup is requested or start time is zero, use brickfind + change_detector = conf.get_change_detector("changelog") +@@ -130,7 +130,7 @@ def run_cmd_nodes(task, args, **kwargs): + elif task == "create": + if vol_statusStr == "Stopped": + fail("Volume %s is in stopped state" % args.volume, +- logger=logger) ++ logger=logger) + + # When glusterfind create, create session directory in + # each brick nodes +@@ -182,7 +182,7 @@ def get_nodes(volume): + Get the gluster volume info xml output and parse to get + the brick details. + """ +- global vol_statusStr; ++ global vol_statusStr + + cmd = ["gluster", 'volume', 'info', volume, "--xml"] + _, data, _ = execute(cmd, +@@ -370,6 +370,9 @@ def mode_create(session_dir, args): + with open(status_file, "w", buffering=0) as f: + f.write(str(time_to_update)) + ++ sys.stdout.write("Session %s created with volume %s\n" % ++ (args.session, args.volume)) ++ + sys.exit(0) + + +@@ -451,6 +454,8 @@ def mode_post(session_dir, args): + if os.path.exists(status_file_pre): + run_cmd_nodes("post", args) + os.rename(status_file_pre, status_file) ++ sys.stdout.write("Session %s with volume %s updated\n" % ++ (args.session, args.volume)) + sys.exit(0) + else: + fail("Pre script is not run", logger=logger) +@@ -460,6 +465,8 @@ def mode_delete(session_dir, args): + run_cmd_nodes("delete", args) + shutil.rmtree(os.path.join(session_dir, args.volume), + onerror=handle_rm_error) ++ sys.stdout.write("Session %s with volume %s deleted\n" % ++ (args.session, args.volume)) + + # If the session contains only this volume, then cleanup the + # session directory. If a session contains multiple volumes +@@ -524,8 +531,11 @@ def mode_list(session_dir, args): + volname.ljust(25), + sess_time.ljust(25))) + +- if not output and (args.session or args.volume): +- fail("Invalid Session", logger=logger) ++ if not output: ++ if args.session or args.volume: ++ fail("Invalid Session", logger=logger) ++ else: ++ sys.stdout.write("No sessions found\n") + + + def main(): +@@ -544,7 +554,7 @@ def main(): + vol_dir = os.path.join(session_dir, args.volume) + if not os.path.exists(vol_dir) and args.mode not in ["create", "list"]: + fail("Session %s not created with volume %s" % +- (args.session, args.volume)) ++ (args.session, args.volume)) + + mkdirp(os.path.join(conf.get_opt("log_dir"), args.session, args.volume), + exit_on_err=True) +-- +1.7.1 + diff --git a/SOURCES/0073-common-ha-handle-long-node-names-and-node-names-with.patch b/SOURCES/0073-common-ha-handle-long-node-names-and-node-names-with.patch new file mode 100644 index 0000000..f4f7768 --- /dev/null +++ b/SOURCES/0073-common-ha-handle-long-node-names-and-node-names-with.patch @@ -0,0 +1,196 @@ +From a7f114c31d475e4f748b956d1f28da9bd47a4e0c Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Thu, 11 Jun 2015 16:28:06 -0400 +Subject: [PATCH 73/73] common-ha: handle long node names and node names with '-' and '.' in them + +sourcing the /etc/ganesha/ganesha-ha.conf file seemed like a simple and +elegant solution for reading config params, but bash variable names do +not allow '-' and '.' in them. also fix incorrect path to shared volume + +Change-Id: I7d05ac04034c4d829916ff06472dbe9f86a10525 +BUG: 1225507 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/50591 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + extras/ganesha/config/ganesha-ha.conf.sample | 26 +++++++--- + extras/ganesha/ocf/ganesha_nfsd | 4 +- + extras/ganesha/scripts/ganesha-ha.sh | 70 +++++++++++++++----------- + 3 files changed, 60 insertions(+), 40 deletions(-) + +diff --git a/extras/ganesha/config/ganesha-ha.conf.sample b/extras/ganesha/config/ganesha-ha.conf.sample +index f8536d3..24054ab 100644 +--- a/extras/ganesha/config/ganesha-ha.conf.sample ++++ b/extras/ganesha/config/ganesha-ha.conf.sample +@@ -1,12 +1,22 @@ + # Name of the HA cluster created. ++# must be unique within the subnet + HA_NAME="ganesha-ha-360" +-# The server from which you intend to mount +-# the shared volume. ++# ++# The gluster server from which to mount the shared data volume. + HA_VOL_SERVER="server1" +-# The subset of nodes of the Gluster Trusted Pool +-# that forms the ganesha HA cluster. IP/Hostname +-# is specified. ++# ++# N.B. you may use short names or long names; you may not use IP addrs. ++# Once you select one, stay with it as it will be mildly unpleasant to ++# clean up if you switch later on. Ensure that all names - short and/or ++# long - are in DNS or /etc/hosts on all machines in the cluster. ++# ++# The subset of nodes of the Gluster Trusted Pool that form the ganesha ++# HA cluster. Hostname is specified. + HA_CLUSTER_NODES="server1,server2,..." +-# Virtual IPs of each of the nodes specified above. +-VIP_server1="10.x.x.x" +-VIP_server2="10.x.x.x" ++#HA_CLUSTER_NODES="server1.lab.redhat.com,server2.lab.redhat.com,..." ++# ++# Virtual IPs for each of the nodes specified above. ++VIP_server1="10.0.2.1" ++VIP_server2="10.0.2.2" ++#VIP_server1.lab.redhat.com="10.0.2.1" ++#VIP_server2.lab.redhat.com="10.0.2.2" +diff --git a/extras/ganesha/ocf/ganesha_nfsd b/extras/ganesha/ocf/ganesha_nfsd +index d69b9f4..e064183 100644 +--- a/extras/ganesha/ocf/ganesha_nfsd ++++ b/extras/ganesha/ocf/ganesha_nfsd +@@ -105,9 +105,9 @@ ganesha_nfsd_stop() + + if [ -d /var/lib/nfs ]; then + mv /var/lib/nfs /var/lib/nfs.backup +- ln -s $OCF_RESKEY_ha_vol_mnt/${long_host}/nfs /var/lib/nfs ++ ln -s $OCF_RESKEY_ha_vol_mnt/nfs-ganesha/${long_host}/nfs /var/lib/nfs + if [ $? -ne 0 ]; then +- logger "warning: ln -s $OCF_RESKEY_ha_vol_mnt/${long_host}/nfs /var/lib/nfs failed" ++ logger "warning: ln -s $OCF_RESKEY_ha_vol_mnt/nfs-ganesha/${long_host}/nfs /var/lib/nfs failed" + fi + + fi +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 79a99c4..bd344fa 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -363,10 +363,7 @@ setup_create_resources() + + while [[ ${1} ]]; do + +- # ipaddr=$(grep ^${1} ${HA_CONFIG_FILE} | cut -d = -f 2) +- ipaddrx="VIP_${1//-/_}" +- +- ipaddr=${!ipaddrx} ++ ipaddr=$(grep "^VIP_${1}=" ${HA_CONFDIR}/ganesha-ha.conf | cut -d = -f 2) + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +@@ -460,9 +457,7 @@ recreate_resources() + local cibfile=${1}; shift + + while [[ ${1} ]]; do +- ipaddrx="VIP_${1//-/_}" +- +- ipaddr=${!ipaddrx} ++ ipaddr=$(grep "VIP_${1}=" ${HA_CONFDIR}/ganesha-ha.conf | cut -d = -f 2) + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +@@ -679,43 +674,52 @@ setup_state_volume() + local longname="" + local shortname="" + local dname="" ++ local dirname="" + + longname=$(hostname) + dname=${longname#$(hostname -s)} + + while [[ ${1} ]]; do +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname} ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname} ++ ++ if [[ ${1} == *${dname} ]]; then ++ dirname=${1} ++ else ++ dirname=${1}${dname} ++ fi ++ ++ ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname} ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname} + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd + fi +- touch ${mnt}/nfs-ganesha/${1}${dname}/nfs/state +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha/v4recov ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha/v4recov ++ touch ${mnt}/nfs-ganesha/${dirname}/nfs/state ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha/v4old ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha/v4old ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4old ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4old + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/sm ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/sm ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/sm.bak ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/sm.bak ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak + fi +- if [ ! -d ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/state ]; then +- mkdir ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/state ++ if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state ]; then ++ mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state + fi + for server in ${HA_SERVERS} ; do +- if [ ${server} != ${1}${dname} ]; then +- ln -s ${mnt}/nfs-ganesha/${server}/nfs/ganesha ${mnt}/nfs-ganesha/${1}${dname}/nfs/ganesha/${server} +- ln -s ${mnt}/nfs-ganesha/${server}/nfs/statd ${mnt}/nfs-ganesha/${1}${dname}/nfs/statd/${server} ++ if [ ${server} != ${dirname} ]; then ++ ln -s ${mnt}/nfs-ganesha/${server}/nfs/ganesha ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/${server} ++ ln -s ${mnt}/nfs-ganesha/${server}/nfs/statd ${mnt}/nfs-ganesha/${dirname}/nfs/statd/${server} + fi + done + shift +@@ -728,10 +732,16 @@ main() + { + local cmd=${1}; shift + HA_CONFDIR=${1}; shift ++ local ha_conf=${HA_CONFDIR}/ganesha-ha.conf + local node="" + local vip="" + +- . ${HA_CONFDIR}/ganesha-ha.conf ++ ha_name=$(grep ^HA_NAME= ${ha_conf} | cut -d = -f 2) ++ HA_NAME=${ha_name//\"/} ++ ha_vol_server=$(grep ^HA_VOL_SERVER= ${ha_conf} | cut -d = -f 2) ++ HA_VOL_SERVER=${ha_vol_server//\"/} ++ ha_cluster_nodes=$(grep ^HA_CLUSTER_NODES= ${ha_conf} | cut -d = -f 2) ++ HA_CLUSTER_NODES=${ha_cluster_nodes//\"/} + + if [ -e /etc/os-release ]; then + RHEL6_PCS_CNAME_OPTION="" +-- +1.7.1 + diff --git a/SOURCES/0074-common-ha-Clean-up-persistent-cib-state.patch b/SOURCES/0074-common-ha-Clean-up-persistent-cib-state.patch new file mode 100644 index 0000000..2c56b98 --- /dev/null +++ b/SOURCES/0074-common-ha-Clean-up-persistent-cib-state.patch @@ -0,0 +1,38 @@ +From c07c6e01a4236b8a48474627572ff798b1837870 Mon Sep 17 00:00:00 2001 +From: Meghana Madhusudhan +Date: Fri, 12 Jun 2015 12:19:16 +0530 +Subject: [PATCH 074/101] common-ha : Clean up persistent cib state + +Pacemaker saves old configurations in the +directory, "/var/lib/pacemaker/cib". It's +good to clean up this directory during teardown so that +old data doesn't show up the next time. + +Change-Id: Ib2f52e17b37d8230706b4347511ae9fc13ff8d39 +BUG: 1227709 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/50603 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + extras/ganesha/scripts/ganesha-ha.sh | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index bd344fa..40705e0 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -246,7 +246,8 @@ teardown_clean_etccluster() + if [ -e /var/lib/glusterd/nfs/secret.pem ]; then + while [[ ${1} ]]; do + if [ ${short_host} != ${1} ]; then +- ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/nfs/secret.pem ${1} rm -f /etc/cluster/cluster.* ++ ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/nfs/secret.pem ${1} \ ++rm -f /etc/cluster/cluster.* rm -f /var/lib/pacemaker/cib/* + if [ $? -ne 0 ]; then + logger "warning: ssh ${1} rm -f /etc/cluster/cluster.* failed" + fi +-- +1.7.1 + diff --git a/SOURCES/0075-glusterd-subvol_count-value-for-replicate-volume-sho.patch b/SOURCES/0075-glusterd-subvol_count-value-for-replicate-volume-sho.patch new file mode 100644 index 0000000..3a3ece3 --- /dev/null +++ b/SOURCES/0075-glusterd-subvol_count-value-for-replicate-volume-sho.patch @@ -0,0 +1,107 @@ +From 07694012378770a13146b721e3493bbc56301408 Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Wed, 10 Jun 2015 15:11:39 +0530 +Subject: [PATCH 075/101] glusterd: subvol_count value for replicate volume should be calculate correctly + +glusterd was crashing while trying to remove bricks from replica set +after shrinking nx3 replica to nx2 replica to nx1 replica. + +This is because volinfo->subvol_count is calculating value from old +replica count value. + +BUG: 1230101 +Change-Id: Id5bc5363f2d2a6e337150d1e9c4c067d8cb5bf89 +Signed-off-by: Gaurav Kumar Garg +upstream patch url: http://review.gluster.com/#/c/11165/ +Reviewed-on: https://code.engineering.redhat.com/gerrit/50731 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + .../bug-1230121-replica_subvol_count_correct_cal.t | 52 ++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 4 +- + 2 files changed, 54 insertions(+), 2 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t + +diff --git a/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t b/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t +new file mode 100644 +index 0000000..71d98e1 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t +@@ -0,0 +1,52 @@ ++#!/bin/bash ++ ++## Test case for BZ:1230121 glusterd crashed while trying to remove a bricks ++## one selected from each replica set - after shrinking nX3 to nX2 to nX1 ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup; ++ ++## Start a 2 node virtual cluster ++TEST launch_cluster 2; ++TEST pidof glusterd ++ ++## Peer probe server 2 from server 1 cli ++TEST $CLI_1 peer probe $H2; ++ ++EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count ++ ++## Creating a 2x3 replicate volume ++TEST $CLI_1 volume create $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick2 \ ++ $H1:$B1/brick3 $H2:$B2/brick4 \ ++ $H1:$B1/brick5 $H2:$B2/brick6 ++ ++## Start the volume ++TEST $CLI_1 volume start $V0 ++ ++ ++## Shrinking volume replica 2x3 to 2x2 by performing remove-brick operation. ++TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick1 $H2:$B2/brick6 force ++ ++## Shrinking volume replica 2x2 to 1x2 by performing remove-brick operation ++TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force ++ ++## Shrinking volume replica from 1x2 to 1x1 by performing remove-brick operation ++TEST $CLI_1 volume remove-brick $V0 replica 1 $H1:$B1/brick5 force ++ ++ ++ ++### Expanding volume replica by performing add-brick operation. ++ ++## Expend volume replica from 1x1 to 1x2 by performing add-brick operation ++TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick5 force ++ ++## Expend volume replica from 1x2 to 2x2 by performing add-brick operation ++TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force ++ ++## Expend volume replica from 2x2 to 2x3 by performing add-brick operation ++TEST $CLI_1 volume add-brick $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick6 force ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index 49bd887..b4bef6e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -2244,8 +2244,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + if (start_remove) + volinfo->rebal.dict = dict_ref (bricks_dict); + +- volinfo->subvol_count = (volinfo->brick_count / +- volinfo->dist_leaf_count); + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (!ret) { + gf_log (this->name, GF_LOG_INFO, +@@ -2274,6 +2272,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + } + } + } ++ volinfo->subvol_count = (volinfo->brick_count / ++ volinfo->dist_leaf_count); + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +-- +1.7.1 + diff --git a/SOURCES/0076-upcall-prevent-busy-loop-in-reaper-thread.patch b/SOURCES/0076-upcall-prevent-busy-loop-in-reaper-thread.patch new file mode 100644 index 0000000..66b244d --- /dev/null +++ b/SOURCES/0076-upcall-prevent-busy-loop-in-reaper-thread.patch @@ -0,0 +1,57 @@ +From 24bcca8e65c5c0f7274f552bf54cfe58a9548c47 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Mon, 15 Jun 2015 11:25:36 +0200 +Subject: [PATCH 076/101] upcall: prevent busy loop in reaper thread + +http://review.gluster.org/10342 introduced a cleanup thread for expired +client entries. When enabling the 'features.cache-invalidation' volume +option, the brick process starts to run in a busy-loop. Obviously this +is not intentional, and a process occupying 100% of the cycles on a CPU +or core is not wanted. + +Cherry picked from commit a367d4c6965e1f0da36f17ab6c5fdbd37925ebdd: +> Change-Id: I453c612d72001f4d8bbecdd5ac07aaed75b43914 +> BUG: 1200267 +> Signed-off-by: Niels de Vos +> Reviewed-on: http://review.gluster.org/11198 +> Reviewed-by: soumya k +> Reviewed-by: Kaleb KEITHLEY +> Tested-by: Gluster Build System + +BUG: 1231651 +Change-Id: Ic2c9f91971f7476dea441928da7096e2b1eb9a50 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50718 +Reviewed-by: Kaleb Keithley +Reviewed-by: Soumya Koduri +Tested-by: Soumya Koduri +--- + xlators/features/upcall/src/upcall-internal.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c +index e13097c..cd4abb6 100644 +--- a/xlators/features/upcall/src/upcall-internal.c ++++ b/xlators/features/upcall/src/upcall-internal.c +@@ -402,6 +402,7 @@ upcall_reaper_thread (void *data) + upcall_inode_ctx_t *inode_ctx = NULL; + upcall_inode_ctx_t *tmp = NULL; + xlator_t *this = NULL; ++ time_t timeout = 0; + + this = (xlator_t *)data; + GF_ASSERT (this); +@@ -434,6 +435,10 @@ upcall_reaper_thread (void *data) + } + UNLOCK (&priv->inode_ctx_lk); + } ++ ++ /* don't do a very busy loop */ ++ timeout = get_cache_invalidation_timeout (this); ++ sleep (timeout / 2); + } + + return NULL; +-- +1.7.1 + diff --git a/SOURCES/0077-common-ha-Clean-up-cib-state-completely.patch b/SOURCES/0077-common-ha-Clean-up-cib-state-completely.patch new file mode 100644 index 0000000..848ae49 --- /dev/null +++ b/SOURCES/0077-common-ha-Clean-up-cib-state-completely.patch @@ -0,0 +1,66 @@ +From 4bc3fe695e52b81d19548bc65e7564edf814919f Mon Sep 17 00:00:00 2001 +From: Meghana Madhusudhan +Date: Mon, 15 Jun 2015 16:42:21 +0530 +Subject: [PATCH 077/101] common-ha : Clean up cib state completely + +Clean up cluster state on all the machines during tear down. + +Change-Id: I71706d2a43cc2cfe3fdcb14443536f7fe84a54c9 +BUG: 1227709 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/50760 +Reviewed-by: Kaleb Keithley +Reviewed-by: Soumya Koduri +Tested-by: Soumya Koduri +--- + extras/ganesha/scripts/ganesha-ha.sh | 24 +----------------------- + 1 files changed, 1 insertions(+), 23 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 40705e0..9d73cf9 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -235,31 +235,10 @@ cleanup_ganesha_config () + rm -rf ${HA_CONFDIR}/exports/*.conf + rm -rf ${HA_CONFDIR}/.export_added + rm -rf /etc/cluster/cluster.conf* ++ rm -rf /var/lib/pacemaker/cib/* + sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' $CONF + } + +- +-teardown_clean_etccluster() +-{ +- local short_host=$(hostname -s) +- +- if [ -e /var/lib/glusterd/nfs/secret.pem ]; then +- while [[ ${1} ]]; do +- if [ ${short_host} != ${1} ]; then +- ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/nfs/secret.pem ${1} \ +-rm -f /etc/cluster/cluster.* rm -f /var/lib/pacemaker/cib/* +- if [ $? -ne 0 ]; then +- logger "warning: ssh ${1} rm -f /etc/cluster/cluster.* failed" +- fi +- fi +- shift +- done +- else +- logger "warning: ssh ${1} rm -f /etc/cluster/cluster.* failed" +- fi +-} +- +- + do_create_virt_ip_constraints() + { + local cibfile=${1}; shift +@@ -783,7 +762,6 @@ main() + + teardown_cluster ${HA_NAME} + +- teardown_clean_etccluster ${HA_SERVERS} + ;; + + cleanup | --cleanup) +-- +1.7.1 + diff --git a/SOURCES/0078-NFS-Ganesha-Return-corect-return-value.patch b/SOURCES/0078-NFS-Ganesha-Return-corect-return-value.patch new file mode 100644 index 0000000..ae880c7 --- /dev/null +++ b/SOURCES/0078-NFS-Ganesha-Return-corect-return-value.patch @@ -0,0 +1,38 @@ +From 84348ad9b22be14841451191313614585da7777b Mon Sep 17 00:00:00 2001 +From: Meghana Madhusudhan +Date: Fri, 12 Jun 2015 19:25:26 +0530 +Subject: [PATCH 078/101] NFS-Ganesha : Return corect return value + +When any of the nodes in the trusted pool is not listed +in the cluster node list, it receives a wrong return +value. And commit fails on that host. Fixing the same. + +Change-Id: Iaa6efe23bade15efe38c4bcc7244ff1538fc30f2 +BUG: 1225010 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/50761 +Reviewed-by: Kaleb Keithley +Tested-by: Soumya Koduri +Reviewed-by: Soumya Koduri +--- + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +index d4ab77c..40a74cd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c ++++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +@@ -671,7 +671,9 @@ pre_setup (char **op_errstr) + goto out; + } + +- if (check_host_list()) { ++ ret = check_host_list(); ++ ++ if (ret) { + ret = setup_cluster(); + if (ret == -1) + gf_asprintf (op_errstr, "Failed to set up HA " +-- +1.7.1 + diff --git a/SOURCES/0079-contrib-timer-wheel-fix-deadlock-in-del_timer.patch b/SOURCES/0079-contrib-timer-wheel-fix-deadlock-in-del_timer.patch new file mode 100644 index 0000000..9bc2985 --- /dev/null +++ b/SOURCES/0079-contrib-timer-wheel-fix-deadlock-in-del_timer.patch @@ -0,0 +1,40 @@ +From d765d8885dabbb83baee26bef90b820978ec45cc Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Tue, 2 Jun 2015 21:49:13 +0530 +Subject: [PATCH 079/101] contrib/timer-wheel: fix deadlock in del_timer() + + Backport of http://review.gluster.org/11050 + +commit eaf3bfa added mod_timers() and successfully screwed up +del_timer() by incorrectly wrapping it within double lock +blocks. + +del_timer() was included before the above commit for the sake of +timer API completion, thankfully noone used it till now. + +Change-Id: I07a454a216cf09dbb84777a23630e74a1e7f2830 +BUG: 1231026 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/50713 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + contrib/timer-wheel/timer-wheel.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/contrib/timer-wheel/timer-wheel.c b/contrib/timer-wheel/timer-wheel.c +index df8bb31..d9b2ccd 100644 +--- a/contrib/timer-wheel/timer-wheel.c ++++ b/contrib/timer-wheel/timer-wheel.c +@@ -225,7 +225,7 @@ void gf_tw_del_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) + if (timer_pending (timer)) + __gf_tw_detach_timer (timer); + } +- pthread_spin_lock (&base->lock); ++ pthread_spin_unlock (&base->lock); + } + + int gf_tw_mod_timer_pending (struct tvec_base *base, +-- +1.7.1 + diff --git a/SOURCES/0080-libglusterfs-update-glfs-messages-header-for-reserve.patch b/SOURCES/0080-libglusterfs-update-glfs-messages-header-for-reserve.patch new file mode 100644 index 0000000..6d9c191 --- /dev/null +++ b/SOURCES/0080-libglusterfs-update-glfs-messages-header-for-reserve.patch @@ -0,0 +1,79 @@ +From e62ec83e51ef6c4f7701a710201605f4bc6e75b1 Mon Sep 17 00:00:00 2001 +From: Humble Devassy Chirammal +Date: Mon, 27 Apr 2015 12:48:07 +0530 +Subject: [PATCH 080/101] libglusterfs: update glfs-messages header for reserved segments + +all the logging patches will be dependent on this segment allocation. +Sending this change as a seperate one to avoid the conflicts. + +Change-Id: Iedd72ab6dc3526f1a6b01828807b5e6b9edcba90 +BUG: 1231792 +Signed-off-by: Humble Devassy Chirammal +Reviewed-on: http://review.gluster.org/10400 +Tested-by: Gluster Build System +Reviewed-by: Vijay Bellur +Reviewed-on: https://code.engineering.redhat.com/gerrit/50902 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glfs-message-id.h | 36 ++++++++++++++++++++++++++++++++---- + 1 files changed, 32 insertions(+), 4 deletions(-) + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 45ac8ef..e28327d 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -39,11 +39,11 @@ + #define GLFS_MSGID_COMP_RPC_LIB_END GLFS_MSGID_COMP_RPC_LIB + \ + GLFS_MSGID_SEGMENT + +-#define GLFS_MSGID_COMP_RPC_TRANSPORT GLFS_MSGID_COMP_RPC_LIB_END +-#define GLFS_MSGID_COMP_RPC_TRANSPORT_END GLFS_MSGID_COMP_RPC_TRANSPORT + \ +- GLFS_MSGID_SEGMENT ++#define GLFS_MSGID_COMP_RPC_TRANS_RDMA GLFS_MSGID_COMP_RPC_LIB_END ++#define GLFS_MSGID_COMP_RPC_TRANS_RDMA_END (GLFS_MSGID_COMP_RPC_TRANS_RDMA + \ ++ GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_API GLFS_MSGID_COMP_RPC_TRANSPORT_END ++#define GLFS_MSGID_COMP_API GLFS_MSGID_COMP_RPC_TRANS_RDMA_END + #define GLFS_MSGID_COMP_API_END GLFS_MSGID_COMP_API + \ + GLFS_MSGID_SEGMENT + +@@ -80,6 +80,34 @@ + #define GLFS_MSGID_COMP_NFS_END (GLFS_MSGID_COMP_NFS +\ + GLFS_MSGID_SEGMENT) + ++#define GLFS_MSGID_COMP_POSIX GLFS_MSGID_COMP_NFS_END ++#define GLFS_MSGID_COMP_POSIX_END (GLFS_MSGID_COMP_POSIX +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_PC GLFS_MSGID_COMP_POSIX_END ++#define GLFS_MSGID_COMP_PC_END (GLFS_MSGID_COMP_PC +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_PS GLFS_MSGID_COMP_PC_END ++#define GLFS_MSGID_COMP_PS_END (GLFS_MSGID_COMP_PS +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_PERF GLFS_MSGID_COMP_PS_END ++#define GLFS_MSGID_COMP_PERF_END (GLFS_MSGID_COMP_PERF +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_CHANGELOG GLFS_MSGID_COMP_PERF_END ++#define GLFS_MSGID_COMP_CHANGELOG_END (GLFS_MSGID_COMP_CHANGELOG +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_BITROT GLFS_MSGID_COMP_CHANGELOG_END ++#define GLFS_MSGID_COMP_BITROT_END (GLFS_MSGID_COMP_BITROT +\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_RPC_TRANS_SOCKET GLFS_MSGID_COMP_BITROT_END ++#define GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END (GLFS_MSGID_COMP_RPC_TRANS_SOCKET + \ ++ GLFS_MSGID_SEGMENT) ++ + /* --- new segments for messages goes above this line --- */ + + #endif /* !_GLFS_MESSAGE_ID_H_ */ +-- +1.7.1 + diff --git a/SOURCES/0081-protocol-client-porting-log-messages-to-new-framewor.patch b/SOURCES/0081-protocol-client-porting-log-messages-to-new-framewor.patch new file mode 100644 index 0000000..01cdfd5 --- /dev/null +++ b/SOURCES/0081-protocol-client-porting-log-messages-to-new-framewor.patch @@ -0,0 +1,4241 @@ +From 37391a05f78b099bc02f84e555cf173409538346 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Mon, 6 Apr 2015 16:21:43 +0530 +Subject: [PATCH 081/101] protocol/client : porting log messages to new framework + +Change-Id: I9bf2ca08fef969e566a64475d0f7a16d37e66eeb +BUG: 1231775 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: http://review.gluster.org/10042 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/50886 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/protocol/client/src/Makefile.am | 2 +- + xlators/protocol/client/src/client-callback.c | 16 +- + xlators/protocol/client/src/client-handshake.c | 330 +++++++------ + xlators/protocol/client/src/client-helpers.c | 17 +- + xlators/protocol/client/src/client-lk.c | 23 +- + xlators/protocol/client/src/client-messages.h | 624 ++++++++++++++++++++++++ + xlators/protocol/client/src/client-rpc-fops.c | 593 +++++++++++++++-------- + xlators/protocol/client/src/client.c | 243 ++++----- + xlators/protocol/client/src/client.h | 3 +- + 9 files changed, 1346 insertions(+), 505 deletions(-) + create mode 100644 xlators/protocol/client/src/client-messages.h + +diff --git a/xlators/protocol/client/src/Makefile.am b/xlators/protocol/client/src/Makefile.am +index cf89d42..fcdf5e3 100644 +--- a/xlators/protocol/client/src/Makefile.am ++++ b/xlators/protocol/client/src/Makefile.am +@@ -11,7 +11,7 @@ client_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + client_la_SOURCES = client.c client-helpers.c client-rpc-fops.c \ + client-handshake.c client-callback.c client-lk.c + +-noinst_HEADERS = client.h client-mem-types.h ++noinst_HEADERS = client.h client-mem-types.h client-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) \ + -I$(top_srcdir)/libglusterfs/src \ +diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c +index 78b9cef..d36a64b 100644 +--- a/xlators/protocol/client/src/client-callback.c ++++ b/xlators/protocol/client/src/client-callback.c +@@ -16,11 +16,12 @@ + #include "client.h" + #include "rpc-clnt.h" + #include "defaults.h" ++#include "client-messages.h" + + int + client_cbk_null (struct rpc_clnt *rpc, void *mydata, void *data) + { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, + "this function should not be called"); + return 0; + } +@@ -28,7 +29,7 @@ client_cbk_null (struct rpc_clnt *rpc, void *mydata, void *data) + int + client_cbk_fetchspec (struct rpc_clnt *rpc, void *mydata, void *data) + { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, + "this function should not be called"); + return 0; + } +@@ -36,7 +37,7 @@ client_cbk_fetchspec (struct rpc_clnt *rpc, void *mydata, void *data) + int + client_cbk_ino_flush (struct rpc_clnt *rpc, void *mydata, void *data) + { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, + "this function should not be called"); + return 0; + } +@@ -51,7 +52,7 @@ client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data) + struct gf_upcall_cache_invalidation ca_data = {0,}; + gfs3_cbk_cache_invalidation_req ca_req = {0,}; + +- gf_log (THIS->name, GF_LOG_TRACE, "Upcall callback is called"); ++ gf_msg_trace (THIS->name, 0, "Upcall callback is called"); + + if (!rpc || !mydata || !data) + goto out; +@@ -61,7 +62,8 @@ client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data) + (xdrproc_t)xdr_gfs3_cbk_cache_invalidation_req); + + if (ret < 0) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, -ret, ++ PC_MSG_CACHE_INVALIDATION_FAIL, + "XDR decode of cache_invalidation failed."); + goto out; + } +@@ -69,8 +71,8 @@ client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data) + upcall_data.data = &ca_data; + gf_proto_cache_invalidation_to_upcall (&ca_req, &upcall_data); + +- gf_log (THIS->name, GF_LOG_TRACE, "Upcall gfid = %s, ret = %d", +- ca_req.gfid, ret); ++ gf_msg_trace (THIS->name, 0, "Upcall gfid = %s, ret = %d", ++ ca_req.gfid, ret); + + default_notify (THIS, GF_EVENT_UPCALL, &upcall_data); + +diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c +index b4c4604..457fa25 100644 +--- a/xlators/protocol/client/src/client-handshake.c ++++ b/xlators/protocol/client/src/client-handshake.c +@@ -24,6 +24,7 @@ + #include "glusterfs3.h" + #include "portmap-xdr.h" + #include "rpc-common-xdr.h" ++#include "client-messages.h" + + #define CLIENT_REOPEN_MAX_ATTEMPTS 1024 + extern rpc_clnt_prog_t clnt3_3_fop_prog; +@@ -52,15 +53,16 @@ client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, + frame = myframe; + + if (!frame || !frame->this) { +- gf_log (THIS->name, GF_LOG_ERROR, "frame not found with the request, " +- "returning EINVAL"); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, PC_MSG_INVALID_ENTRY, ++ "frame not found with the request, returning EINVAL"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + if (-1 == req->rpc_status) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "received RPC status error, returning ENOTCONN"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " ++ "returning ENOTCONN"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; +@@ -68,7 +70,8 @@ client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_ERROR, ++ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, + "XDR decoding failed, returning EINVAL"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; +@@ -76,8 +79,9 @@ client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + + if (-1 == rsp.op_ret) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "failed to get the 'volume file' from server"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_VOL_FILE_NOT_FOUND, "failed to get the 'volume " ++ "file' from server"); + goto out; + } + +@@ -113,7 +117,7 @@ int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data) + (xdrproc_t)xdr_gf_getspec_req); + + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_SEND_REQ_FAIL, + "failed to send the request"); + } + +@@ -133,8 +137,9 @@ client_notify_parents_child_up (xlator_t *this) + conf = this->private; + ret = client_notify_dispatch (this, GF_EVENT_CHILD_UP, NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, +- "notify of CHILD_UP failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_UP_NOTIFY_FAILED, "notify of CHILD_UP " ++ "failed"); + + return 0; + } +@@ -173,17 +178,18 @@ client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov, + GF_VALIDATE_OR_GOTO ("client", fr, out); + + if (req->rpc_status == -1) { +- gf_log (fr->this->name, GF_LOG_WARNING, +- "received RPC status error"); ++ gf_msg (fr->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error"); + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_set_lk_ver_rsp); + if (ret < 0) +- gf_log (fr->this->name, GF_LOG_WARNING, +- "xdr decoding failed"); ++ gf_msg (fr->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_XDR_DECODING_FAILED, "xdr decoding failed"); + else +- gf_log (fr->this->name, GF_LOG_INFO, ++ gf_msg (fr->this->name, GF_LOG_INFO, 0, ++ PC_MSG_LOCK_VERSION_SERVER, + "Server lk version = %d", rsp.lk_ver); + + ret = 0; +@@ -226,7 +232,7 @@ client_set_lk_version (xlator_t *this) + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Sending SET_LK_VERSION"); ++ gf_msg_debug (this->name, 0, "Sending SET_LK_VERSION"); + + ret = client_submit_request (this, &req, frame, + conf->handshake, +@@ -238,7 +244,7 @@ out: + GF_FREE (req.uid); + return ret; + err: +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_SET_LK_VERSION_ERROR, + "Failed to send SET_LK_VERSION to server"); + + return ret; +@@ -461,19 +467,21 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov, + conf = (clnt_conf_t *) this->private; + + if (req->rpc_status == -1) { +- gf_log ("client", GF_LOG_WARNING, ++ gf_msg ("client", GF_LOG_WARNING, 0, PC_MSG_CLIENT_REQ_FAIL, + "request failed at rpc"); + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lk_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + goto out; + } + + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "lock request failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_LOCK_REQ_FAIL, ++ "lock request failed"); + ret = -1; + goto out; + } +@@ -482,10 +490,10 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov, + + gf_proto_flock_to_flock (&rsp.flock, &lock); + +- gf_log (this->name, GF_LOG_DEBUG, "%s type lock reacquired on file " +- "with gfid %s from %"PRIu64 " to %"PRIu64, +- get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid), +- lock.l_start, lock.l_start + lock.l_len); ++ gf_msg_debug (this->name, 0, "%s type lock reacquired on file " ++ "with gfid %s from %"PRIu64 " to %"PRIu64, ++ get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid), ++ lock.l_start, lock.l_start + lock.l_len); + + if (!clnt_fd_lk_local_error_status (this, local) && + clnt_fd_lk_local_unref (this, local) == 0) { +@@ -531,9 +539,9 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) + + local = clnt_fd_lk_local_create (fdctx); + if (!local) { +- gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create " +- "failed, aborting reacquring of locks on %s.", +- uuid_utoa (fdctx->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_LOCK_ERROR, ++ "clnt_fd_lk_local_create failed, aborting reacquring " ++ "of locks on %s.", uuid_utoa (fdctx->gfid)); + clnt_reacquire_lock_error (this, fdctx, conf); + goto out; + } +@@ -546,9 +554,9 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) + /* to avoid frame being blocked if lock cannot be granted. */ + ret = client_cmd_to_gf_cmd (F_SETLK, &gf_cmd); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "client_cmd_to_gf_cmd failed, " +- "aborting reacquiring of locks"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_LOCK_ERROR, "client_cmd_to_gf_cmd " ++ "failed, aborting reacquiring of locks"); + break; + } + +@@ -576,8 +584,9 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_lk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "reacquiring locks failed on file with gfid %s", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_LOCK_REACQUIRE, "reacquiring locks " ++ "failed on file with gfid %s", + uuid_utoa (fdctx->gfid)); + break; + } +@@ -602,8 +611,8 @@ client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) + GF_VALIDATE_OR_GOTO (this->name, fdctx, out); + + if (client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "fd lock list is empty"); ++ gf_msg_debug (this->name, 0, ++ "fd lock list is empty"); + fdctx->reopen_done (fdctx, this); + } else { + lk_ctx = fdctx->lk_ctx; +@@ -665,7 +674,7 @@ client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) + + client_reopen_done (fdctx, this); + if (fd_count == 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY, + "last fd open'd/lock-self-heal'd - notifying CHILD-UP"); + client_set_lk_version (this); + client_notify_parents_child_up (this); +@@ -692,8 +701,9 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, + fdctx = local->fdctx; + + if (-1 == req->rpc_status) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "received RPC status error, returning ENOTCONN"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " ++ "returning ENOTCONN"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; +@@ -701,20 +711,21 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_open_rsp); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (rsp.op_ret < 0) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "reopen on %s failed (%s)", ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed (%s)", + local->loc.path, strerror (rsp.op_errno)); + } else { +- gf_log (frame->this->name, GF_LOG_DEBUG, +- "reopen on %s succeeded (remote-fd = %"PRId64")", +- local->loc.path, rsp.fd); ++ gf_msg_debug (frame->this->name, 0, ++ "reopen on %s succeeded (remote-fd = %"PRId64")", ++ local->loc.path, rsp.fd); + } + + if (rsp.op_ret == -1) { +@@ -741,13 +752,14 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, + if (attempt_lock_recovery) { + /* Delay decrementing the reopen fd count until all the + locks corresponding to this fd are acquired.*/ +- gf_log (this->name, GF_LOG_DEBUG, "acquiring locks " +- "on %s", local->loc.path); ++ gf_msg_debug (this->name, 0, "acquiring locks " ++ "on %s", local->loc.path); + ret = client_reacquire_lock (frame->this, local->fdctx); + if (ret) { + clnt_reacquire_lock_error (this, local->fdctx, conf); +- gf_log (this->name, GF_LOG_WARNING, "acquiring locks " +- "failed on %s", local->loc.path); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_LOCK_ERROR, "acquiring locks failed " ++ "on %s", local->loc.path); + } + } + +@@ -781,8 +793,9 @@ client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + + if (-1 == req->rpc_status) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "received RPC status error, returning ENOTCONN"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " ++ "returning ENOTCONN"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; +@@ -790,20 +803,21 @@ client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_opendir_rsp); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (rsp.op_ret < 0) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "reopendir on %s failed (%s)", ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_DIR_OP_FAILED, "reopendir on %s failed (%s)", + local->loc.path, strerror (rsp.op_errno)); + } else { +- gf_log (frame->this->name, GF_LOG_INFO, +- "reopendir on %s succeeded (fd = %"PRId64")", +- local->loc.path, rsp.fd); ++ gf_msg (frame->this->name, GF_LOG_INFO, 0, ++ PC_MSG_DIR_OP_SUCCESS, "reopendir on %s succeeded " ++ "(fd = %"PRId64")", local->loc.path, rsp.fd); + } + + if (-1 == rsp.op_ret) { +@@ -858,8 +872,8 @@ protocol_client_reopendir (clnt_fd_ctx_t *fdctx, xlator_t *this) + + memcpy (req.gfid, fdctx->gfid, 16); + +- gf_log (frame->this->name, GF_LOG_DEBUG, +- "attempting reopen on %s", local->loc.path); ++ gf_msg_debug (frame->this->name, 0, ++ "attempting reopen on %s", local->loc.path); + + frame->local = local; + +@@ -869,7 +883,7 @@ protocol_client_reopendir (clnt_fd_ctx_t *fdctx, xlator_t *this) + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_opendir_req); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, + "failed to send the re-opendir request"); + } + +@@ -920,15 +934,15 @@ protocol_client_reopenfile (clnt_fd_ctx_t *fdctx, xlator_t *this) + req.flags = gf_flags_from_flags (fdctx->flags); + req.flags = req.flags & (~(O_TRUNC|O_CREAT|O_EXCL)); + +- gf_log (frame->this->name, GF_LOG_DEBUG, +- "attempting reopen on %s", local->loc.path); ++ gf_msg_debug (frame->this->name, 0, ++ "attempting reopen on %s", local->loc.path); + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_OPEN, client3_3_reopen_cbk, NULL, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_open_req); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, + "failed to send the re-open request"); + } + +@@ -1037,9 +1051,9 @@ client_post_handshake (call_frame_t *frame, xlator_t *this) + /* Delay notifying CHILD_UP to parents + until all locks are recovered */ + if (count > 0) { +- gf_log (this->name, GF_LOG_INFO, +- "%d fds open - Delaying child_up until they are re-opened", +- count); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_UP_NOTIFY_DELAY, "%d fds open - Delaying " ++ "child_up until they are re-opened", count); + client_save_number_fds (conf, count); + + list_for_each_entry_safe (fdctx, tmp, &reopen_head, sfd_pos) { +@@ -1048,8 +1062,9 @@ client_post_handshake (call_frame_t *frame, xlator_t *this) + protocol_client_reopen (fdctx, this); + } + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "No fds to open - notifying all parents child up"); ++ gf_msg_debug (this->name, 0, ++ "No fds to open - notifying all parents child " ++ "up"); + client_set_lk_version (this); + client_notify_parents_child_up (this); + } +@@ -1079,23 +1094,24 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + conf = this->private; + + if (-1 == req->rpc_status) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "received RPC status error"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error"); + op_ret = -1; + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_setvolume_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + op_ret = -1; + goto out; + } + op_ret = rsp.op_ret; + op_errno = gf_error_to_errno (rsp.op_errno); + if (-1 == rsp.op_ret) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "failed to set the volume (%s)", ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_VOL_SET_FAIL, "failed to set the volume (%s)", + (op_errno)? strerror (op_errno) : "--"); + } + +@@ -1107,26 +1123,29 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + ret = dict_unserialize (rsp.dict.dict_val, + rsp.dict.dict_len, &reply); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "failed to unserialize buffer to dict"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_DICT_UNSERIALIZE_FAIL, "failed to " ++ "unserialize buffer to dict"); + goto out; + } + } + + ret = dict_get_str (reply, "ERROR", &remote_error); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "failed to get ERROR string from reply dict"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_DICT_GET_FAILED, "failed to get ERROR " ++ "string from reply dict"); + } + + ret = dict_get_str (reply, "process-uuid", &process_uuid); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "failed to get 'process-uuid' from reply dict"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_DICT_GET_FAILED, "failed to get " ++ "'process-uuid' from reply dict"); + } + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_SETVOLUME_FAIL, + "SETVOLUME on remote-host failed: %s", + remote_error ? remote_error : strerror (op_errno)); + errno = op_errno; +@@ -1140,7 +1159,8 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + GF_EVENT_VOLFILE_MODIFIED, + NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_VOLFILE_NOTIFY_FAILED, + "notify of VOLFILE_MODIFIED failed"); + } + goto out; +@@ -1149,20 +1169,21 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + ret = dict_get_str (this->options, "remote-subvolume", + &remote_subvol); + if (ret || !remote_subvol) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_GET_FAILED, + "failed to find key 'remote-subvolume' in the options"); + goto out; + } + + ret = dict_get_uint32 (reply, "clnt-lk-version", &lk_ver); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_GET_FAILED, + "failed to find key 'clnt-lk-version' in the options"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "clnt-lk-version = %d, " +- "server-lk-version = %d", client_get_lk_ver (conf), lk_ver); ++ gf_msg_debug (this->name, 0, "clnt-lk-version = %d, " ++ "server-lk-version = %d", client_get_lk_ver (conf), ++ lk_ver); + /* TODO: currently setpeer path is broken */ + /* + if (process_uuid && req->conn && +@@ -1187,7 +1208,7 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + + conf->client_id = glusterfs_leaf_position(this); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_REMOTE_VOL_CONNECTED, + "Connected to %s, attached to remote volume '%s'.", + conf->rpc->conn.name, + remote_subvol); +@@ -1199,27 +1220,30 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + conf->connected = 1; + + if (lk_ver != client_get_lk_ver (conf)) { +- gf_log (this->name, GF_LOG_INFO, "Server and Client " +- "lk-version numbers are not same, reopening the fds"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_LOCK_MISMATCH, ++ "Server and Client lk-version numbers are not same, " ++ "reopening the fds"); + client_mark_fd_bad (this); + client_post_handshake (frame, frame->this); + } else { + /*TODO: Traverse the saved fd list, and send + release to the server on fd's that were closed + during grace period */ +- gf_log (this->name, GF_LOG_INFO, "Server and Client " +- "lk-version numbers are same, no need to " +- "reopen the fds"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_LOCK_MATCH, ++ "Server and Client lk-version numbers are same, no " ++ "need to reopen the fds"); + client_notify_parents_child_up (frame->this); + } + + out: + if (auth_fail) { +- gf_log (this->name, GF_LOG_INFO, "sending AUTH_FAILED event"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_AUTH_FAILED, ++ "sending AUTH_FAILED event"); + ret = client_notify_dispatch (this, GF_EVENT_AUTH_FAILED, NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, +- "notify of AUTH_FAILED failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_AUTH_FAILED_NOTIFY_FAILED, "notify of " ++ "AUTH_FAILED failed"); + conf->connecting = 0; + conf->connected = 0; + ret = -1; +@@ -1229,11 +1253,14 @@ out: + * background, for now, don't hang here, + * tell the parents that i am all ok.. + */ +- gf_log (this->name, GF_LOG_INFO, "sending CHILD_CONNECTING event"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_CONNECTING_EVENT, "sending " ++ "CHILD_CONNECTING event"); + ret = client_notify_dispatch (this, GF_EVENT_CHILD_CONNECTING, + NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_CONNECTING_NOTIFY_FAILED, + "notify of CHILD_CONNECTING failed"); + conf->connecting= 1; + ret = 0; +@@ -1267,8 +1294,9 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + ret = dict_set_int32 (options, "fops-version", + conf->fops->prognum); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "failed to set version-fops(%d) in handshake msg", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_SET_FAILED, "failed to set " ++ "version-fops(%d) in handshake msg", + conf->fops->prognum); + goto fail; + } +@@ -1277,8 +1305,9 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + if (conf->mgmt) { + ret = dict_set_int32 (options, "mgmt-version", conf->mgmt->prognum); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "failed to set version-mgmt(%d) in handshake msg", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_SET_FAILED, "failed to set " ++ "version-mgmt(%d) in handshake msg", + conf->mgmt->prognum); + goto fail; + } +@@ -1303,14 +1332,15 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + this->ctx->process_uuid, this->name, + this->graph->id, counter_str); + if (-1 == ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "asprintf failed while setting process_uuid"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_PROCESS_UUID_SET_FAIL, "asprintf failed while " ++ "setting process_uuid"); + goto fail; + } + + ret = dict_set_dynstr (options, "process-uuid", process_uuid_xl); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED, + "failed to set process-uuid(%s) in handshake msg", + process_uuid_xl); + goto fail; +@@ -1318,7 +1348,7 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + + ret = dict_set_str (options, "client-version", PACKAGE_VERSION); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, + "failed to set client-version(%s) in handshake msg", + PACKAGE_VERSION); + } +@@ -1328,27 +1358,29 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + ret = dict_set_str (options, "volfile-key", + this->ctx->cmd_args.volfile_id); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, +- "failed to set 'volfile-key'"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_SET_FAILED, "failed to " ++ "set 'volfile-key'"); + } + ret = dict_set_uint32 (options, "volfile-checksum", + this->graph->volfile_checksum); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, +- "failed to set 'volfile-checksum'"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_SET_FAILED, "failed to set " ++ "'volfile-checksum'"); + } + + ret = dict_set_int16 (options, "clnt-lk-version", + client_get_lk_ver (conf)); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "failed to set clnt-lk-version(%"PRIu32") in handshake msg", +- client_get_lk_ver (conf)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, ++ "failed to set clnt-lk-version(%"PRIu32") in handshake " ++ "msg", client_get_lk_ver (conf)); + } + + ret = dict_serialized_length (options); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_ERROR, + "failed to get serialized length of dict"); + ret = -1; + goto fail; +@@ -1358,8 +1390,9 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) + gf_client_mt_clnt_req_buf_t); + ret = dict_serialize (options, req.dict.dict_val); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "failed to serialize dictionary"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_SERIALIZE_FAIL, "failed to serialize " ++ "dictionary"); + goto fail; + } + +@@ -1386,7 +1419,7 @@ select_server_supported_programs (xlator_t *this, gf_prog_detail *prog) + int ret = -1; + + if (!this || !prog) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND, + "xlator not found OR RPC program not found"); + goto out; + } +@@ -1399,16 +1432,16 @@ select_server_supported_programs (xlator_t *this, gf_prog_detail *prog) + if ((clnt3_3_fop_prog.prognum == trav->prognum) && + (clnt3_3_fop_prog.progver == trav->progver)) { + conf->fops = &clnt3_3_fop_prog; +- gf_log (this->name, GF_LOG_INFO, +- "Using Program %s, Num (%"PRId64"), " +- "Version (%"PRId64")", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_VERSION_INFO, "Using Program %s, " ++ "Num (%"PRId64"), Version (%"PRId64")", + trav->progname, trav->prognum, trav->progver); + ret = 0; + } + if (ret) { +- gf_log (this->name, GF_LOG_TRACE, +- "%s (%"PRId64") not supported", trav->progname, +- trav->progver); ++ gf_msg_trace (this->name, 0, ++ "%s (%"PRId64") not supported", ++ trav->progname, trav->progver); + } + trav = trav->next; + } +@@ -1425,7 +1458,7 @@ server_has_portmap (xlator_t *this, gf_prog_detail *prog) + int ret = -1; + + if (!this || !prog) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND, + "xlator not found OR RPC program not found"); + goto out; + } +@@ -1435,8 +1468,8 @@ server_has_portmap (xlator_t *this, gf_prog_detail *prog) + while (trav) { + if ((trav->prognum == GLUSTER_PMAP_PROGRAM) && + (trav->progver == GLUSTER_PMAP_VERSION)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "detected portmapper on server"); ++ gf_msg_debug (this->name, 0, ++ "detected portmapper on server"); + ret = 0; + break; + } +@@ -1460,32 +1493,43 @@ client_query_portmap_cbk (struct rpc_req *req, struct iovec *iov, int count, voi + + frame = myframe; + if (!frame || !frame->this || !frame->this->private) { +- gf_log (THIS->name, GF_LOG_WARNING, +- "frame not found with rpc request"); ++ gf_msg (THIS->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "frame not found with rpc " ++ "request"); + goto out; + } + this = frame->this; + conf = frame->this->private; + + if (-1 == req->rpc_status) { +- gf_log (this->name, GF_LOG_WARNING, +- "received RPC status error, try again later"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " ++ "try again later"); + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + goto out; + } + + if (-1 == rsp.op_ret) { + ret = -1; +- gf_log (this->name, ((!conf->portmap_err_logged) ? +- GF_LOG_ERROR : GF_LOG_DEBUG), +- "failed to get the port number for remote subvolume. " +- "Please run 'gluster volume status' on server to see " +- "if brick process is running."); ++ if (!conf->portmap_err_logged) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_PORT_NUM_ERROR, "failed to get the " ++ "port number for remote subvolume. Please run " ++ "'gluster volume status' on server to see if " ++ "brick process is running."); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "failed to get the port number for " ++ "remote subvolume. Please run 'gluster " ++ "volume status' on server to see " ++ "if brick process is running."); ++ } + conf->portmap_err_logged = 1; + goto out; + } +@@ -1529,7 +1573,7 @@ client_query_portmap (xlator_t *this, struct rpc_clnt *rpc) + + ret = dict_get_str (options, "remote-subvolume", &remote_subvol); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_VOL_SET_FAIL, + "remote-subvolume not set in volfile"); + goto fail; + } +@@ -1576,19 +1620,21 @@ client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, + conf = frame->this->private; + + if (-1 == req->rpc_status) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "received RPC status error"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, ++ PC_MSG_RPC_STATUS_ERROR, "received RPC status error"); + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + goto out; + } + if (-1 == rsp.op_ret) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "failed to get the 'versions' from server"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PC_MSG_VERSION_ERROR, "failed to get the 'versions' " ++ "from server"); + goto out; + } + +@@ -1601,8 +1647,9 @@ client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, + /* Reply in "Name:Program-Number:Program-Version,..." format */ + ret = select_server_supported_programs (frame->this, rsp.prog); + if (ret) { +- gf_log (frame->this->name, GF_LOG_ERROR, +- "server doesn't support the version"); ++ gf_msg (frame->this->name, GF_LOG_ERROR, 0, ++ PC_MSG_VERSION_ERROR, "server doesn't support the " ++ "version"); + goto out; + } + +@@ -1638,7 +1685,8 @@ client_handshake (xlator_t *this, struct rpc_clnt *rpc) + + conf = this->private; + if (!conf->handshake) { +- gf_log (this->name, GF_LOG_WARNING, "handshake program not found"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND, ++ "handshake program not found"); + goto out; + } + +diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c +index be5e7b5..62fbc6c 100644 +--- a/xlators/protocol/client/src/client-helpers.c ++++ b/xlators/protocol/client/src/client-helpers.c +@@ -15,6 +15,7 @@ + + #include "client.h" + #include "fd.h" ++#include "client-messages.h" + + int + client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock) +@@ -94,22 +95,26 @@ this_fd_set_ctx (fd_t *file, xlator_t *this, loc_t *loc, clnt_fd_ctx_t *ctx) + ret = fd_ctx_get (file, this, &oldaddr); + if (ret >= 0) { + if (loc) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_FD_DUPLICATE_TRY, + "%s (%s): trying duplicate remote fd set. ", + loc->path, uuid_utoa (loc->inode->gfid)); + else +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_FD_DUPLICATE_TRY, + "%p: trying duplicate remote fd set. ", file); + } + + ret = fd_ctx_set (file, this, (uint64_t)(unsigned long)ctx); + if (ret < 0) { + if (loc) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_FD_SET_FAIL, + "%s (%s): failed to set remote fd", + loc->path, uuid_utoa (loc->inode->gfid)); + else +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_FD_SET_FAIL, + "%p: failed to set remote fd", file); + } + out: +@@ -225,9 +230,9 @@ unserialize_rsp_direntp (xlator_t *this, fd_t *fd, + ret = dict_unserialize (buf, trav->dict.dict_len, + &entry->dict); + if (ret < 0) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_DICT_UNSERIALIZE_FAIL, + "failed to unserialize xattr dict"); +- errno = EINVAL; + goto out; + } + entry->dict->extra_free = buf; +diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c +index b3c36a4..0cf2be3 100644 +--- a/xlators/protocol/client/src/client-lk.c ++++ b/xlators/protocol/client/src/client-lk.c +@@ -12,6 +12,7 @@ + #include "xlator.h" + #include "client.h" + #include "lkowner.h" ++#include "client-messages.h" + + static void + __insert_and_merge (clnt_fd_ctx_t *fdctx, client_posix_lock_t *lock); +@@ -23,7 +24,7 @@ __dump_client_lock (client_posix_lock_t *lock) + + this = THIS; + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_CLIENT_LOCK_INFO, + "{fd=%p}" + "{%s lk-owner:%s %"PRId64" - %"PRId64"}" + "{start=%"PRId64" end=%"PRId64"}", +@@ -225,7 +226,8 @@ subtract_locks (client_posix_lock_t *big, client_posix_lock_t *small) + } + else { + /* LOG-TODO : decide what more info is required here*/ +- gf_log ("client-protocol", GF_LOG_CRITICAL, ++ gf_msg ("client-protocol", GF_LOG_CRITICAL, 0, ++ PC_MSG_LOCK_ERROR, + "Unexpected case in subtract_locks. Please send " + "a bug report to gluster-devel@gluster.org"); + } +@@ -363,8 +365,8 @@ delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner) + this = THIS; + fdctx = this_fd_get_ctx (fd, this); + if (!fdctx) { +- gf_log (this->name, GF_LOG_WARNING, +- "fdctx not valid"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_FD_CTX_INVALID, "fdctx not valid"); + ret = -1; + goto out; + } +@@ -387,8 +389,8 @@ delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner) + } + + /* FIXME: Need to actually print the locks instead of count */ +- gf_log (this->name, GF_LOG_TRACE, +- "Number of locks cleared=%d", count); ++ gf_msg_trace (this->name, 0, ++ "Number of locks cleared=%d", count); + + out: + return ret; +@@ -421,8 +423,8 @@ delete_granted_locks_fd (clnt_fd_ctx_t *fdctx) + } + + /* FIXME: Need to actually print the locks instead of count */ +- gf_log (this->name, GF_LOG_TRACE, +- "Number of locks cleared=%d", count); ++ gf_msg_trace (this->name, 0, ++ "Number of locks cleared=%d", count); + + return ret; + } +@@ -516,7 +518,7 @@ client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock, + pthread_mutex_unlock (&conf->lock); + + if (!fdctx) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FD_GET_FAIL, + "failed to get fd context. sending EBADFD"); + ret = -EBADFD; + goto out; +@@ -551,7 +553,8 @@ client_dump_locks (char *name, inode_t *inode, + + ret = dict_set_dynstr(new_dict, CLIENT_DUMP_LOCKS, dict_string); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ PC_MSG_DICT_SET_FAILED, + "could not set dict with %s", CLIENT_DUMP_LOCKS); + goto out; + } +diff --git a/xlators/protocol/client/src/client-messages.h b/xlators/protocol/client/src/client-messages.h +new file mode 100644 +index 0000000..9239176 +--- /dev/null ++++ b/xlators/protocol/client/src/client-messages.h +@@ -0,0 +1,624 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _PC_MESSAGES_H__ ++#define _PC_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/*! \file client-messages.h ++ * \brief Protocol client log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for readability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_PC_BASE GLFS_MSGID_COMP_PC ++#define GLFS_PC_NUM_MESSAGES 63 ++#define GLFS_PC_MSGID_END (GLFS_PC_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_PC_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++#define PC_MSG_TIMER_EXPIRED (GLFS_PC_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DIR_OP_FAILED (GLFS_PC_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FILE_OP_FAILED (GLFS_PC_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_TIMER_REG (GLFS_PC_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_GRACE_TIMER_CANCELLED (GLFS_PC_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DICT_SET_FAILED (GLFS_PC_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DICT_GET_FAILED (GLFS_PC_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_NO_MEMORY (GLFS_PC_BASE + 8) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_CBK_FAILED (GLFS_PC_BASE + 9) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FUNCTION_CALL_ERROR (GLFS_PC_BASE + 10) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_INITED_ALREADY (GLFS_PC_BASE + 11) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_INIT (GLFS_PC_BASE + 12) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_DESTROY (GLFS_PC_BASE + 13) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_INVALID_CALL (GLFS_PC_BASE + 14) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_INVALID_ENTRY (GLFS_PC_BASE + 15) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_HANDSHAKE_RETURN (GLFS_PC_BASE + 16) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_UP_NOTIFY_FAILED (GLFS_PC_BASE + 17) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CLIENT_DISCONNECTED (GLFS_PC_BASE + 18) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_DOWN_NOTIFY_FAILED (GLFS_PC_BASE + 19) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_PARENT_UP (GLFS_PC_BASE + 20) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_PARENT_DOWN (GLFS_PC_BASE + 21) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_INIT_FAILED (GLFS_PC_BASE + 22) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_NOTIFY_FAILED (GLFS_PC_BASE + 23) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FD_DUPLICATE_TRY (GLFS_PC_BASE + 24) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FD_SET_FAIL (GLFS_PC_BASE + 25) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DICT_UNSERIALIZE_FAIL (GLFS_PC_BASE + 26) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FD_GET_FAIL (GLFS_PC_BASE + 27) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FD_CTX_INVALID (GLFS_PC_BASE + 28) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_FOP_SEND_FAILED (GLFS_PC_BASE + 29) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_XDR_DECODING_FAILED (GLFS_PC_BASE + 30) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_REMOTE_OP_FAILED (GLFS_PC_BASE + 31) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_RPC_STATUS_ERROR (GLFS_PC_BASE + 32) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_VOL_FILE_NOT_FOUND (GLFS_PC_BASE + 33) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_SEND_REQ_FAIL (GLFS_PC_BASE + 34) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_VERSION_SERVER (GLFS_PC_BASE + 35) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_SET_LK_VERSION_ERROR (GLFS_PC_BASE + 36) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_REQ_FAIL (GLFS_PC_BASE + 37) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CLIENT_REQ_FAIL (GLFS_PC_BASE + 38) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_ERROR (GLFS_PC_BASE + 39) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_REACQUIRE (GLFS_PC_BASE + 40) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_UP_NOTIFY (GLFS_PC_BASE + 41) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_UP_NOTIFY_DELAY (GLFS_PC_BASE + 42) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_VOL_SET_FAIL (GLFS_PC_BASE + 43) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_SETVOLUME_FAIL (GLFS_PC_BASE + 44) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_VOLFILE_NOTIFY_FAILED (GLFS_PC_BASE + 45) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_REMOTE_VOL_CONNECTED (GLFS_PC_BASE + 46) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_MISMATCH (GLFS_PC_BASE + 47) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_LOCK_MATCH (GLFS_PC_BASE + 48) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_AUTH_FAILED (GLFS_PC_BASE + 49) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_AUTH_FAILED_NOTIFY_FAILED (GLFS_PC_BASE + 50) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_CONNECTING_EVENT (GLFS_PC_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CHILD_CONNECTING_NOTIFY_FAILED (GLFS_PC_BASE + 52) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_PROCESS_UUID_SET_FAIL (GLFS_PC_BASE + 53) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DICT_ERROR (GLFS_PC_BASE + 54) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DICT_SERIALIZE_FAIL (GLFS_PC_BASE + 55) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_PGM_NOT_FOUND (GLFS_PC_BASE + 56) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_VERSION_INFO (GLFS_PC_BASE + 57) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_PORT_NUM_ERROR (GLFS_PC_BASE + 58) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_VERSION_ERROR (GLFS_PC_BASE + 59) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_DIR_OP_SUCCESS (GLFS_PC_BASE + 60) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_BAD_FD (GLFS_PC_BASE + 61) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CLIENT_LOCK_INFO (GLFS_PC_BASE + 62) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PC_MSG_CACHE_INVALIDATION_FAIL (GLFS_PC_BASE + 63) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_PC_MESSAGES_H_ */ +diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c +index e8e3cdf..223a60d 100644 +--- a/xlators/protocol/client/src/client-rpc-fops.c ++++ b/xlators/protocol/client/src/client-rpc-fops.c +@@ -18,6 +18,7 @@ + #include "glusterfs3-xdr.h" + #include "glusterfs3.h" + #include "compat-errno.h" ++#include "client-messages.h" + + int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data); + rpc_clnt_prog_t clnt3_3_fop_prog; +@@ -56,16 +57,18 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, + if (iobref != NULL) { + ret = iobref_merge (new_iobref, iobref); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot merge iobref passed from caller " +- "into new_iobref"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ PC_MSG_NO_MEMORY, "cannot merge " ++ "iobref passed from caller into " ++ "new_iobref"); + } + } + + ret = iobref_add (new_iobref, iobuf); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot add iobuf into iobref"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ PC_MSG_NO_MEMORY, "cannot add iobuf into " ++ "iobref"); + goto unwind; + } + +@@ -89,7 +92,7 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, + payload, payloadcnt, new_iobref, frame, NULL, 0, + NULL, 0, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, "rpc_clnt_submit failed"); ++ gf_msg_debug (this->name, 0, "rpc_clnt_submit failed"); + } + + if (new_iobref) +@@ -144,7 +147,8 @@ client3_3_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_symlink_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -167,7 +171,8 @@ out: + /* no need to print the gfid, because it will be null, + * since symlink operation failed. + */ +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s. Path: (%s to %s)", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path, local->loc2.path); +@@ -217,7 +222,8 @@ client3_3_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_mknod_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -237,8 +243,9 @@ client3_3_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1 && + GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { +- gf_log (this->name, fop_log_level (GF_FOP_MKNOD, ++ gf_msg (this->name, fop_log_level (GF_FOP_MKNOD, + gf_error_to_errno (rsp.op_errno)), ++ rsp.op_errno, PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s. Path: %s", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path); +@@ -285,7 +292,8 @@ client3_3_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_mkdir_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -305,8 +313,9 @@ client3_3_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1 && + GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { +- gf_log (this->name, fop_log_level (GF_FOP_MKDIR, +- gf_error_to_errno (rsp.op_errno)), ++ gf_msg (this->name, fop_log_level (GF_FOP_MKDIR, ++ gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s. Path: %s", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path); +@@ -426,7 +435,8 @@ client3_3_open_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_open_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -448,8 +458,9 @@ client3_3_open_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_OPEN, +- gf_error_to_errno (rsp.op_errno)), ++ gf_msg (this->name, fop_log_level (GF_FOP_OPEN, ++ gf_error_to_errno (rsp.op_errno)), ++ rsp.op_errno, PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s. Path: %s (%s)", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path, loc_gfid_utoa (&local->loc)); +@@ -489,7 +500,8 @@ client3_3_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_stat_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -507,10 +519,17 @@ out: + if (rsp.op_ret == -1) { + /* stale filehandles are possible during normal operations, no + * need to spam the logs with these */ +- gf_log (this->name, +- rsp.op_errno == ESTALE ? GF_LOG_DEBUG : GF_LOG_WARNING, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ if (rsp.op_errno == ESTALE) { ++ gf_msg_debug (this->name, 0, ++ "remote operation failed: %s", ++ strerror (gf_error_to_errno ++ (rsp.op_errno))); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", ++ strerror (gf_error_to_errno (rsp.op_errno))); ++ } + } + + CLIENT_STACK_UNWIND (stat, frame, rsp.op_ret, +@@ -547,7 +566,8 @@ client3_3_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_readlink_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -563,9 +583,16 @@ client3_3_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, (gf_error_to_errno(rsp.op_errno) == ENOENT)? +- GF_LOG_DEBUG:GF_LOG_WARNING, "remote operation failed:" +- " %s", strerror (gf_error_to_errno (rsp.op_errno))); ++ if (gf_error_to_errno(rsp.op_errno) == ENOENT) { ++ gf_msg_debug (this->name, 0, "remote operation failed:" ++ " %s", strerror ++ (gf_error_to_errno (rsp.op_errno))); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s", strerror ++ (gf_error_to_errno (rsp.op_errno))); ++ } + } + + CLIENT_STACK_UNWIND (readlink, frame, rsp.op_ret, +@@ -608,7 +635,8 @@ client3_3_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_unlink_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -625,11 +653,17 @@ client3_3_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, +- ((gf_error_to_errno (rsp.op_errno) == ENOENT) +- ? GF_LOG_DEBUG : GF_LOG_WARNING), +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ if (gf_error_to_errno(rsp.op_errno) == ENOENT) { ++ gf_msg_debug (this->name, 0, "remote operation failed:" ++ " %s", strerror ++ (gf_error_to_errno (rsp.op_errno))); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, ++ rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s", strerror ++ (gf_error_to_errno (rsp.op_errno))); ++ } + } + + CLIENT_STACK_UNWIND (unlink, frame, rsp.op_ret, +@@ -668,7 +702,8 @@ client3_3_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_rmdir_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -685,7 +720,8 @@ client3_3_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (rmdir, frame, rsp.op_ret, +@@ -725,7 +761,8 @@ client3_3_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_truncate_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -742,7 +779,9 @@ client3_3_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (truncate, frame, rsp.op_ret, +@@ -781,7 +820,8 @@ client3_3_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_statfs_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -797,7 +837,9 @@ client3_3_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (statfs, frame, rsp.op_ret, +@@ -839,7 +881,8 @@ client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_write_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -856,7 +899,9 @@ client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) +@@ -897,7 +942,8 @@ client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -906,9 +952,9 @@ client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, + if (rsp.op_ret >= 0 && !fd_is_anonymous (local->fd)) { + /* Delete all saved locks of the owner issuing flush */ + ret = delete_granted_locks_owner (local->fd, &local->owner); +- gf_log (this->name, GF_LOG_TRACE, +- "deleting locks of owner (%s) returned %d", +- lkowner_utoa (&local->owner), ret); ++ gf_msg_trace (this->name, 0, ++ "deleting locks of owner (%s) returned %d", ++ lkowner_utoa (&local->owner), ret); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), +@@ -917,8 +963,10 @@ client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_FLUSH, +- gf_error_to_errno (rsp.op_errno)), ++ gf_msg (this->name, fop_log_level (GF_FOP_FLUSH, ++ gf_error_to_errno (rsp.op_errno)), ++ rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } +@@ -958,7 +1006,8 @@ client3_3_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fsync_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -975,7 +1024,9 @@ client3_3_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fsync, frame, rsp.op_ret, +@@ -1013,7 +1064,8 @@ client3_3_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1026,11 +1078,16 @@ client3_3_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + op_errno = gf_error_to_errno (rsp.op_errno); + if (rsp.op_ret == -1) { +- gf_log (this->name, ((op_errno == ENOTSUP) ? +- GF_LOG_DEBUG : GF_LOG_WARNING), +- "remote operation failed: %s", +- strerror (op_errno)); ++ if (op_errno == ENOTSUP) { ++ gf_msg_debug (this->name, 0, "remote operation failed:" ++ " %s", strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s", strerror (op_errno)); ++ } + } ++ + CLIENT_STACK_UNWIND (setxattr, frame, rsp.op_ret, op_errno, xdata); + + free (rsp.xdata.xdata_val); +@@ -1068,7 +1125,8 @@ client3_3_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_getxattr_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + op_errno = EINVAL; + goto out; +@@ -1088,15 +1146,22 @@ client3_3_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, (((op_errno == ENOTSUP) || +- (op_errno == ENODATA) || +- (op_errno == ESTALE) || +- (op_errno == ENOENT)) ? +- GF_LOG_DEBUG : GF_LOG_WARNING), +- "remote operation failed: %s. Path: %s (%s). Key: %s", +- strerror (op_errno), +- local->loc.path, loc_gfid_utoa (&local->loc), +- (local->name) ? local->name : "(null)"); ++ if ((op_errno == ENOTSUP) || (op_errno == ENODATA) || ++ (op_errno == ESTALE) || (op_errno == ENOENT)) { ++ gf_msg_debug (this->name, 0, ++ "remote operation failed: %s. Path: %s " ++ "(%s). Key: %s", strerror (op_errno), ++ local->loc.path, ++ loc_gfid_utoa (&local->loc), ++ (local->name) ? local->name : "(null)"); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s. Path: %s (%s). Key: %s", ++ strerror (op_errno), local->loc.path, ++ loc_gfid_utoa (&local->loc), ++ (local->name) ? local->name : "(null)"); ++ } + } + + CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict, xdata); +@@ -1141,7 +1206,8 @@ client3_3_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fgetxattr_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + op_errno = EINVAL; + goto out; +@@ -1160,13 +1226,16 @@ client3_3_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, (((op_errno == ENOTSUP) || +- (op_errno == ERANGE) || +- (op_errno == ENODATA) || +- (op_errno == ENOENT)) ? +- GF_LOG_DEBUG : GF_LOG_WARNING), ++ if ((op_errno == ENOTSUP) || (op_errno == ERANGE) || ++ (op_errno == ENODATA) || (op_errno == ENOENT)) { ++ gf_msg_debug (this->name, 0, + "remote operation failed: %s", + strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s", strerror (op_errno)); ++ } + } + + CLIENT_STACK_UNWIND (fgetxattr, frame, rsp.op_ret, op_errno, dict, xdata); +@@ -1207,7 +1276,8 @@ client3_3_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1220,11 +1290,13 @@ client3_3_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + if ((ENODATA == rsp.op_errno) || (ENOATTR == rsp.op_errno)) +- loglevel = GF_LOG_DEBUG; ++ loglevel = 0; + else + loglevel = GF_LOG_WARNING; + +- gf_log (this->name, loglevel, "remote operation failed: %s", ++ gf_msg (this->name, loglevel, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + +@@ -1262,7 +1334,8 @@ client3_3_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1274,7 +1347,9 @@ client3_3_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fremovexattr, frame, rsp.op_ret, +@@ -1310,7 +1385,8 @@ client3_3_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1322,7 +1398,9 @@ client3_3_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fsyncdir, frame, rsp.op_ret, +@@ -1358,7 +1436,8 @@ client3_3_access_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1370,7 +1449,9 @@ client3_3_access_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (access, frame, rsp.op_ret, +@@ -1409,7 +1490,8 @@ client3_3_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_ftruncate_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1426,7 +1508,9 @@ client3_3_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (ftruncate, frame, rsp.op_ret, +@@ -1464,7 +1548,8 @@ client3_3_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fstat_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1480,7 +1565,9 @@ client3_3_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fstat, frame, rsp.op_ret, +@@ -1517,7 +1604,8 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1529,10 +1617,10 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_INODELK, +- gf_error_to_errno (rsp.op_errno)), +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_msg (this->name, fop_log_level (GF_FOP_INODELK, ++ gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " ++ "%s", strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1568,7 +1656,8 @@ client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1580,10 +1669,10 @@ client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_FINODELK, +- gf_error_to_errno (rsp.op_errno)), +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_msg (this->name, fop_log_level (GF_FOP_FINODELK, ++ gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " ++ "%s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); +@@ -1621,7 +1710,8 @@ client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1633,10 +1723,10 @@ client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_ENTRYLK, +- gf_error_to_errno (rsp.op_errno)), +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_msg (this->name, fop_log_level (GF_FOP_ENTRYLK, ++ gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " ++ "%s", strerror (gf_error_to_errno (rsp.op_errno))); + } + + CLIENT_STACK_UNWIND (entrylk, frame, rsp.op_ret, +@@ -1672,7 +1762,8 @@ client3_3_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1685,7 +1776,9 @@ client3_3_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if ((rsp.op_ret == -1) && + (EAGAIN != gf_error_to_errno (rsp.op_errno))) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + +@@ -1726,7 +1819,8 @@ client3_3_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_xattrop_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + op_errno = EINVAL; + goto out; +@@ -1746,8 +1840,9 @@ client3_3_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "remote operation failed: %s. Path: %s (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " ++ "%s. Path: %s (%s)", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path, loc_gfid_utoa (&local->loc)); + } +@@ -1796,7 +1891,8 @@ client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + if (ret < 0) { + rsp.op_ret = -1; + op_errno = EINVAL; +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + goto out; + } + op_errno = rsp.op_errno; +@@ -1814,7 +1910,8 @@ client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (op_errno))); + } else if (rsp.op_ret == 0) { +@@ -1859,7 +1956,8 @@ client3_3_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1872,10 +1970,14 @@ client3_3_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + op_errno = gf_error_to_errno (rsp.op_errno); + if (rsp.op_ret == -1) { +- gf_log (this->name, ((op_errno == ENOTSUP) ? +- GF_LOG_DEBUG : GF_LOG_WARNING), +- "remote operation failed: %s", +- strerror (op_errno)); ++ if (op_errno == ENOTSUP) { ++ gf_msg_debug (this->name, 0, "remote operation failed:" ++ " %s", strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s", strerror (op_errno)); ++ } + } + + CLIENT_STACK_UNWIND (fsetxattr, frame, rsp.op_ret, op_errno, xdata); +@@ -1912,7 +2014,8 @@ client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fsetattr_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1929,7 +2032,9 @@ client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fsetattr, frame, rsp.op_ret, +@@ -1968,7 +2073,8 @@ client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fallocate_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -1985,7 +2091,9 @@ client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret, +@@ -2023,7 +2131,8 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_discard_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2040,7 +2149,9 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (discard, frame, rsp.op_ret, +@@ -2078,7 +2189,8 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_zerofill_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2095,7 +2207,8 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } +@@ -2132,7 +2245,8 @@ client3_3_ipc_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_ipc_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2144,7 +2258,8 @@ client3_3_ipc_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } +@@ -2185,7 +2300,8 @@ client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_setattr_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2202,7 +2318,9 @@ client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (setattr, frame, rsp.op_ret, +@@ -2248,7 +2366,8 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_create_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2275,7 +2394,8 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s. Path: %s", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path); +@@ -2317,7 +2437,8 @@ client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_rchecksum_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2329,7 +2450,9 @@ client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (rchecksum, frame, rsp.op_ret, +@@ -2377,7 +2500,8 @@ client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lk_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2408,7 +2532,8 @@ client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if ((rsp.op_ret == -1) && + (EAGAIN != gf_error_to_errno (rsp.op_errno))) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } +@@ -2451,7 +2576,8 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_readdir_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2469,7 +2595,8 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s remote_fd = %d", + strerror (gf_error_to_errno (rsp.op_errno)), + local->cmd); +@@ -2517,7 +2644,8 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_readdirp_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2534,7 +2662,8 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } +@@ -2582,7 +2711,8 @@ client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_rename_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2604,7 +2734,9 @@ client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (rename, frame, rsp.op_ret, +@@ -2651,7 +2783,8 @@ client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_link_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2671,7 +2804,8 @@ client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s (%s -> %s)", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path, local->loc2.path); +@@ -2720,7 +2854,8 @@ client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_opendir_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2742,9 +2877,10 @@ client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, fop_log_level (GF_FOP_OPENDIR, +- gf_error_to_errno (rsp.op_errno)), +- "remote operation failed: %s. Path: %s (%s)", ++ gf_msg (this->name, fop_log_level (GF_FOP_OPENDIR, ++ gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " ++ "%s. Path: %s (%s)", + strerror (gf_error_to_errno (rsp.op_errno)), + local->loc.path, loc_gfid_utoa (&local->loc)); + } +@@ -2789,7 +2925,8 @@ client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lookup_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + op_errno = EINVAL; + goto out; +@@ -2810,8 +2947,8 @@ client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, + + if ((!gf_uuid_is_null (inode->gfid)) + && (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) { +- gf_log (frame->this->name, GF_LOG_DEBUG, +- "gfid changed for %s", local->loc.path); ++ gf_msg_debug (frame->this->name, 0, ++ "gfid changed for %s", local->loc.path); + + rsp.op_ret = -1; + op_errno = ESTALE; +@@ -2829,12 +2966,14 @@ out: + /* any error other than ENOENT */ + if (!(local->loc.name && rsp.op_errno == ENOENT) && + !(rsp.op_errno == ESTALE)) +- gf_log (this->name, GF_LOG_WARNING, +- "remote operation failed: %s. Path: %s (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, "remote operation " ++ "failed: %s. Path: %s (%s)", + strerror (rsp.op_errno), local->loc.path, + loc_gfid_utoa (&local->loc)); + else +- gf_log (this->name, GF_LOG_TRACE, "not found on remote node"); ++ gf_msg_trace (this->name, 0, "not found on remote " ++ "node"); + + } + +@@ -2878,7 +3017,8 @@ client3_3_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_read_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -2903,7 +3043,8 @@ client3_3_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_REMOTE_OP_FAILED, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { +@@ -2958,7 +3099,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) + conf = (clnt_conf_t *) this->private; + + if (fdctx->remote_fd == -1) { +- gf_log (this->name, GF_LOG_DEBUG, "not a valid fd"); ++ gf_msg_debug (this->name, 0, "not a valid fd"); + goto out; + } + +@@ -2988,7 +3129,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) + if (fdctx->is_dir) { + gfs3_releasedir_req req = {{0,},}; + req.fd = fdctx->remote_fd; +- gf_log (this->name, GF_LOG_TRACE, "sending releasedir on fd"); ++ gf_msg_trace (this->name, 0, "sending releasedir on fd"); + client_submit_request (this, &req, fr, &clnt3_3_fop_prog, + GFS3_OP_RELEASEDIR, + client3_3_releasedir_cbk, +@@ -2997,7 +3138,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) + } else { + gfs3_release_req req = {{0,},}; + req.fd = fdctx->remote_fd; +- gf_log (this->name, GF_LOG_TRACE, "sending release on fd"); ++ gf_msg_trace (this->name, 0, "sending release on fd"); + client_submit_request (this, &req, fr, &clnt3_3_fop_prog, + GFS3_OP_RELEASE, + client3_3_release_cbk, NULL, +@@ -3194,7 +3335,8 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this, + (xdrproc_t)xdr_gfs3_lookup_req); + + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3251,7 +3393,8 @@ client3_3_stat (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_stat_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3305,7 +3448,8 @@ client3_3_truncate (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_truncate_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3353,7 +3497,8 @@ client3_3_ftruncate (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_ftruncate_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3407,7 +3552,8 @@ client3_3_access (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_access_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3493,7 +3639,8 @@ client3_3_readlink (call_frame_t *frame, xlator_t *this, + local->iobref, + (xdrproc_t)xdr_gfs3_readlink_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3552,7 +3699,8 @@ client3_3_unlink (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_unlink_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3605,7 +3753,8 @@ client3_3_rmdir (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_rmdir_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + GF_FREE (req.xdata.xdata_val); + +@@ -3671,7 +3820,8 @@ client3_3_symlink (call_frame_t *frame, xlator_t *this, + NULL, NULL, 0, NULL, + 0, NULL, (xdrproc_t)xdr_gfs3_symlink_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3736,7 +3886,8 @@ client3_3_rename (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_rename_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3812,7 +3963,8 @@ client3_3_link (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_link_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -3879,7 +4031,8 @@ client3_3_mknod (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_mknod_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + GF_FREE (req.xdata.xdata_val); + +@@ -3947,7 +4100,8 @@ client3_3_mkdir (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_mkdir_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + GF_FREE (req.xdata.xdata_val); + +@@ -4017,7 +4171,8 @@ client3_3_create (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_create_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4085,7 +4240,8 @@ client3_3_open (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_open_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4159,7 +4315,7 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, + rsp_iobuf = NULL; + + if (args->size > rsp_vec.iov_len) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, + "read-size (%lu) is bigger than iobuf size (%lu)", + (unsigned long)args->size, + (unsigned long)rsp_vec.iov_len); +@@ -4180,7 +4336,8 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, + (xdrproc_t)xdr_gfs3_read_req); + if (ret) { + //unwind is done in the cbk +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4253,7 +4410,8 @@ client3_3_writev (call_frame_t *frame, xlator_t *this, void *data) + * do the unwind for us (see rpc_clnt_submit), so don't unwind + * here in such cases. + */ +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4312,7 +4470,8 @@ client3_3_flush (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_flush_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4361,7 +4520,8 @@ client3_3_fsync (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fsync_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + + } + +@@ -4409,7 +4569,8 @@ client3_3_fstat (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fstat_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4474,7 +4635,8 @@ client3_3_opendir (call_frame_t *frame, xlator_t *this, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_opendir_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4525,7 +4687,8 @@ client3_3_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) + NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_fsyncdir_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4581,7 +4744,8 @@ client3_3_statfs (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_statfs_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4642,7 +4806,8 @@ client3_3_setxattr (call_frame_t *frame, xlator_t *this, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_setxattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + GF_FREE (req.dict.dict_val); + +@@ -4699,7 +4864,8 @@ client3_3_fsetxattr (call_frame_t *frame, xlator_t *this, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_fsetxattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.dict.dict_val); +@@ -4795,7 +4961,8 @@ client3_3_fgetxattr (call_frame_t *frame, xlator_t *this, + NULL, 0, local->iobref, + (xdrproc_t)xdr_gfs3_fgetxattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -4908,8 +5075,9 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this, + args->loc->inode, + dict); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "Client dump locks failed"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "Client dump " ++ "locks failed"); + op_errno = EINVAL; + } + +@@ -4930,7 +5098,8 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this, + NULL, 0, local->iobref, + (xdrproc_t)xdr_gfs3_getxattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5038,7 +5207,8 @@ client3_3_xattrop (call_frame_t *frame, xlator_t *this, + NULL, 0, local->iobref, + (xdrproc_t)xdr_gfs3_xattrop_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.dict.dict_val); +@@ -5141,7 +5311,8 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this, + NULL, 0, local->iobref, + (xdrproc_t)xdr_gfs3_fxattrop_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.dict.dict_val); +@@ -5205,7 +5376,8 @@ client3_3_removexattr (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_removexattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5255,7 +5427,8 @@ client3_3_fremovexattr (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_fremovexattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5300,8 +5473,8 @@ client3_3_lk (call_frame_t *frame, xlator_t *this, + ret = client_cmd_to_gf_cmd (args->cmd, &gf_cmd); + if (ret) { + op_errno = EINVAL; +- gf_log (this->name, GF_LOG_WARNING, +- "Unknown cmd (%d)!", gf_cmd); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd); + goto unwind; + } + +@@ -5336,7 +5509,8 @@ client3_3_lk (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_lk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5384,8 +5558,8 @@ client3_3_inodelk (call_frame_t *frame, xlator_t *this, + else if (args->cmd == F_SETLKW || args->cmd == F_SETLKW64) + gf_cmd = GF_LK_SETLKW; + else { +- gf_log (this->name, GF_LOG_WARNING, +- "Unknown cmd (%d)!", gf_cmd); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd); + op_errno = EINVAL; + goto unwind; + } +@@ -5418,7 +5592,8 @@ client3_3_inodelk (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_inodelk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5466,8 +5641,8 @@ client3_3_finodelk (call_frame_t *frame, xlator_t *this, + else if (args->cmd == F_SETLKW || args->cmd == F_SETLKW64) + gf_cmd = GF_LK_SETLKW; + else { +- gf_log (this->name, GF_LOG_WARNING, +- "Unknown cmd (%d)!", gf_cmd); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd); + goto unwind; + } + +@@ -5499,7 +5674,8 @@ client3_3_finodelk (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_finodelk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5558,7 +5734,8 @@ client3_3_entrylk (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_entrylk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5613,7 +5790,8 @@ client3_3_fentrylk (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fentrylk_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5661,7 +5839,8 @@ client3_3_rchecksum (call_frame_t *frame, xlator_t *this, + 0, NULL, + (xdrproc_t)xdr_gfs3_rchecksum_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5759,7 +5938,8 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this, + (xdrproc_t)xdr_gfs3_readdir_req); + + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5864,7 +6044,8 @@ client3_3_readdirp (call_frame_t *frame, xlator_t *this, + 0, rsp_iobref, + (xdrproc_t)xdr_gfs3_readdirp_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.dict.dict_val); +@@ -5924,7 +6105,8 @@ client3_3_setattr (call_frame_t *frame, xlator_t *this, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_setattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -5969,7 +6151,8 @@ client3_3_fsetattr (call_frame_t *frame, xlator_t *this, void *data) + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fsetattr_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -6016,7 +6199,8 @@ client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data) + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fallocate_req); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); +@@ -6061,7 +6245,8 @@ client3_3_discard(call_frame_t *frame, xlator_t *this, void *data) + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_discard_req); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + +@@ -6107,7 +6292,8 @@ client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_zerofill_req); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + +@@ -6146,7 +6332,8 @@ client3_3_ipc (call_frame_t *frame, xlator_t *this, void *data) + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_ipc_req); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, ++ "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + +diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c +index 5745de0..fb45128 100644 +--- a/xlators/protocol/client/src/client.c ++++ b/xlators/protocol/client/src/client.c +@@ -25,6 +25,7 @@ + #include "xdr-rpc.h" + #include "glusterfs3.h" + #include "gf-dirent.h" ++#include "client-messages.h" + + extern rpc_clnt_prog_t clnt_handshake_prog; + extern rpc_clnt_prog_t clnt_dump_prog; +@@ -168,7 +169,7 @@ client_grace_timeout (void *data) + } + pthread_mutex_unlock (&conf->lock); + +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_TIMER_EXPIRED, + "client grace timer expired, updating " + "the lk-version to %d", ver); + +@@ -188,12 +189,12 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf) + pthread_mutex_lock (&conf->lock); + { + if (conf->grace_timer || !conf->grace_timer_needed) { +- gf_log (this->name, GF_LOG_TRACE, +- "Client grace timer is already set " +- "or a grace-timer has already time out, " +- "not registering a new timer"); ++ gf_msg_trace (this->name, 0, ++ "Client grace timer is already set " ++ "or a grace-timer has already time " ++ "out, not registering a new timer"); + } else { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_TIMER_REG, + "Registering a grace timer"); + + conf->grace_timer_needed = _gf_false; +@@ -247,8 +248,8 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, + (procnum == GF_HNDSK_SETVOLUME))))) { + /* This particular error captured/logged in + functions calling this */ +- gf_log (this->name, GF_LOG_DEBUG, +- "connection in disconnected state"); ++ gf_msg_debug (this->name, 0, ++ "connection in disconnected state"); + goto out; + } + +@@ -267,16 +268,18 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, + if (iobref != NULL) { + ret = iobref_merge (new_iobref, iobref); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot merge iobref passed from caller " +- "into new_iobref"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ PC_MSG_NO_MEMORY, "cannot merge " ++ "iobref passed from caller into " ++ "new_iobref"); + } + } + + ret = iobref_add (new_iobref, iobuf); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot add iobuf into iobref"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ PC_MSG_NO_MEMORY, "cannot add iobuf into " ++ "iobref"); + goto out; + } + +@@ -314,7 +317,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, + rsp_payload, rsp_payload_count, rsp_iobref); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, "rpc_clnt_submit failed"); ++ gf_msg_debug (this->name, 0, "rpc_clnt_submit failed"); + } + + if (!conf->send_gids) { +@@ -371,14 +374,13 @@ client_releasedir (xlator_t *this, fd_t *fd) + args.fd = fd; + + proc = &conf->fops->proctable[GF_FOP_RELEASEDIR]; +- + if (proc->fn) { + ret = proc->fn (NULL, this, &args); + } + out: + if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "releasedir fop failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_DIR_OP_FAILED, "releasedir fop failed"); + return 0; + } + +@@ -396,13 +398,12 @@ client_release (xlator_t *this, fd_t *fd) + + args.fd = fd; + proc = &conf->fops->proctable[GF_FOP_RELEASE]; +- + if (proc->fn) { + ret = proc->fn (NULL, this, &args); + } + out: + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FILE_OP_FAILED, + "release fop failed"); + return 0; + } +@@ -425,7 +426,6 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_LOOKUP]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -454,7 +454,6 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_STAT]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -483,7 +482,6 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_TRUNCATE]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -513,7 +511,6 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FTRUNCATE]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -543,7 +540,6 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_ACCESS]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -574,7 +570,6 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_READLINK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -605,7 +600,6 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_MKNOD]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -636,7 +630,6 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_MKDIR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -667,7 +660,6 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.flags = xflag; + + proc = &conf->fops->proctable[GF_FOP_UNLINK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -696,7 +688,6 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_RMDIR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -728,7 +719,6 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_SYMLINK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -759,7 +749,6 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_RENAME]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -790,7 +779,6 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_LINK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -828,7 +816,6 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + args.flags = (flags & ~O_DIRECT); + + proc = &conf->fops->proctable[GF_FOP_CREATE]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -864,7 +851,6 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.flags = (flags & ~O_DIRECT); + + proc = &conf->fops->proctable[GF_FOP_OPEN]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + +@@ -897,7 +883,6 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_READ]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + +@@ -936,7 +921,6 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_WRITE]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -963,7 +947,6 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FLUSH]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -993,7 +976,6 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FSYNC]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1021,7 +1003,6 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FSTAT]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1051,7 +1032,6 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_OPENDIR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1080,7 +1060,6 @@ client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, d + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FSYNCDIR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1108,7 +1087,6 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_STATFS]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1126,13 +1104,13 @@ is_client_rpc_init_command (dict_t *dict, xlator_t *this, + int dict_ret = -1; + + if (!strstr (this->name, "replace-brick")) { +- gf_log (this->name, GF_LOG_TRACE, "name is !replace-brick"); ++ gf_msg_trace (this->name, 0, "name is !replace-brick"); + goto out; + } + dict_ret = dict_get_str (dict, CLIENT_CMD_CONNECT, value); + if (dict_ret) { +- gf_log (this->name, GF_LOG_TRACE, "key %s not present", +- CLIENT_CMD_CONNECT); ++ gf_msg_trace (this->name, 0, "key %s not present", ++ CLIENT_CMD_CONNECT); + goto out; + } + +@@ -1151,14 +1129,14 @@ is_client_rpc_destroy_command (dict_t *dict, xlator_t *this) + char *dummy = NULL; + + if (strncmp (this->name, "replace-brick", 13)) { +- gf_log (this->name, GF_LOG_TRACE, "name is !replace-brick"); ++ gf_msg_trace (this->name, 0, "name is !replace-brick"); + goto out; + } + + dict_ret = dict_get_str (dict, CLIENT_CMD_DISCONNECT, &dummy); + if (dict_ret) { +- gf_log (this->name, GF_LOG_TRACE, "key %s not present", +- CLIENT_CMD_DISCONNECT); ++ gf_msg_trace (this->name, 0, "key %s not present", ++ CLIENT_CMD_DISCONNECT); + goto out; + } + +@@ -1188,8 +1166,9 @@ client_set_remote_options (char *value, xlator_t *this) + remote_port_str = strtok_r (NULL, ":", &tmp); + + if (!subvol) { +- gf_log (this->name, GF_LOG_WARNING, +- "proper value not passed as subvolume"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "proper value not passed as " ++ "subvolume"); + goto out; + } + +@@ -1200,7 +1179,7 @@ client_set_remote_options (char *value, xlator_t *this) + + ret = dict_set_dynstr (this->options, "remote-host", host_dup); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, + "failed to set remote-host with %s", host); + goto out; + } +@@ -1212,7 +1191,7 @@ client_set_remote_options (char *value, xlator_t *this) + + ret = dict_set_dynstr (this->options, "remote-subvolume", subvol_dup); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, + "failed to set remote-host with %s", host); + goto out; + } +@@ -1223,7 +1202,7 @@ client_set_remote_options (char *value, xlator_t *this) + ret = dict_set_int32 (this->options, "remote-port", + remote_port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED, + "failed to set remote-port to %d", remote_port); + goto out; + } +@@ -1252,7 +1231,8 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + + if (is_client_rpc_init_command (dict, this, &value) == _gf_true) { + GF_ASSERT (value); +- gf_log (this->name, GF_LOG_INFO, "client rpc init command"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_RPC_INIT, ++ "client rpc init command"); + ret = client_set_remote_options (value, this); + if (ret) { + (void) client_destroy_rpc (this); +@@ -1268,7 +1248,8 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + } + + if (is_client_rpc_destroy_command (dict, this) == _gf_true) { +- gf_log (this->name, GF_LOG_INFO, "client rpc destroy command"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_RPC_DESTROY, ++ "client rpc destroy command"); + ret = client_destroy_rpc (this); + if (ret) { + op_ret = 0; +@@ -1291,7 +1272,6 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_SETXATTR]; +- + if (proc->fn) { + ret = proc->fn (frame, this, &args); + if (ret) { +@@ -1326,7 +1306,6 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FSETXATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1357,7 +1336,6 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FGETXATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1387,7 +1365,6 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_GETXATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1418,7 +1395,6 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_XATTROP]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1449,7 +1425,6 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FXATTROP]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1479,7 +1454,6 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_REMOVEXATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1507,7 +1481,6 @@ client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1536,7 +1509,6 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_LK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1567,7 +1539,6 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_INODELK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1599,7 +1570,6 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FINODELK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1632,7 +1602,6 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_ENTRYLK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1666,7 +1635,6 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FENTRYLK]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1696,7 +1664,6 @@ client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_RCHECKSUM]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1728,7 +1695,6 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_READDIR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1761,7 +1727,6 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = dict; + + proc = &conf->fops->proctable[GF_FOP_READDIRP]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1791,7 +1756,6 @@ client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_SETATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1820,7 +1784,6 @@ client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FSETATTR]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1850,7 +1813,6 @@ client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FALLOCATE]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1879,7 +1841,6 @@ client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_DISCARD]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1908,7 +1869,6 @@ client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_ZEROFILL]; +- + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1936,12 +1896,6 @@ client_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_IPC]; +- if (!proc) { +- gf_log (this->name, GF_LOG_ERROR, +- "rpc procedure not found for %s", +- gf_fop_list[GF_FOP_IPC]); +- goto out; +- } + if (proc->fn) + ret = proc->fn (frame, this, &args); + out: +@@ -1970,7 +1924,6 @@ client_getspec (call_frame_t *frame, xlator_t *this, const char *key, + + /* For all other xlators, getspec is an fop, hence its in fops table */ + proc = &conf->fops->proctable[GF_FOP_GETSPEC]; +- + if (proc->fn) { + /* But at protocol level, this is handshake */ + ret = proc->fn (frame, this, &args); +@@ -2015,7 +1968,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + + this = mydata; + if (!this || !this->private) { +- gf_log ("client", GF_LOG_ERROR, ++ gf_msg ("client", GF_LOG_ERROR, EINVAL, PC_MSG_INVALID_ENTRY, + (this != NULL) ? + "private structure of the xlator is NULL": + "xlator is NULL"); +@@ -2032,20 +1985,22 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + ret = dict_get_str (this->options, "disable-handshake", + &handshake); + +- gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); ++ gf_msg_debug (this->name, 0, "got RPC_CLNT_CONNECT"); + + if ((ret < 0) || (strcasecmp (handshake, "on"))) { + ret = client_handshake (this, rpc); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "handshake msg returned %d", ret); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_HANDSHAKE_RETURN, "handshake " ++ "msg returned %d", ret); + } else { + //conf->rpc->connected = 1; + ret = client_notify_dispatch_uniq (this, + GF_EVENT_CHILD_UP, + NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_UP_NOTIFY_FAILED, + "CHILD_UP notify failed"); + } + +@@ -2055,7 +2010,8 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + conf->grace_timer_needed = _gf_true; + + if (conf->grace_timer) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_GRACE_TIMER_CANCELLED, + "Cancelling the grace timer"); + + gf_timer_call_cancel (this->ctx, +@@ -2076,19 +2032,26 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + + if (!conf->skip_notify) { + if (conf->connected) { +- gf_log (this->name, +- ((!conf->disconnect_err_logged) +- ? GF_LOG_INFO : GF_LOG_DEBUG), +- "disconnected from %s. Client process " +- "will keep trying to connect to " +- "glusterd until brick's port is " +- "available", +- conf->rpc->conn.name); +- ++ if (!conf->disconnect_err_logged) { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CLIENT_DISCONNECTED, ++ "disconnected from %s. Client " ++ "process will keep trying to " ++ "connect to glusterd until " ++ "brick's port is available", ++ conf->rpc->conn.name); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "disconnected from %s. " ++ "Client process will keep" ++ " trying to connect to " ++ "glusterd until brick's " ++ "port is available", ++ conf->rpc->conn.name); ++ } + if (conf->portmap_err_logged) + conf->disconnect_err_logged = 1; + } +- + /* If the CHILD_DOWN event goes to parent xlator + multiple times, the logic of parent xlator notify + may get screwed up.. (eg. CHILD_MODIFIED event in +@@ -2098,13 +2061,14 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + GF_EVENT_CHILD_DOWN, + NULL); + if (ret) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PC_MSG_CHILD_DOWN_NOTIFY_FAILED, + "CHILD_DOWN notify failed"); + + } else { + if (conf->connected) +- gf_log (this->name, GF_LOG_DEBUG, +- "disconnected (skipped notify)"); ++ gf_msg_debug (this->name, 0, ++ "disconnected (skipped notify)"); + } + + conf->connected = 0; +@@ -2126,8 +2090,8 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + break; + + default: +- gf_log (this->name, GF_LOG_TRACE, +- "got some other RPC event %d", event); ++ gf_msg_trace (this->name, 0, ++ "got some other RPC event %d", event); + + break; + } +@@ -2149,7 +2113,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + switch (event) { + case GF_EVENT_PARENT_UP: + { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_UP, + "parent translators are ready, attempting connect " + "on transport"); + +@@ -2158,7 +2122,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + } + + case GF_EVENT_PARENT_DOWN: +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_DOWN, + "current graph is no longer active, destroying " + "rpc_client "); + +@@ -2172,8 +2136,8 @@ notify (xlator_t *this, int32_t event, void *data, ...) + break; + + default: +- gf_log (this->name, GF_LOG_DEBUG, +- "got %d, calling default_notify ()", event); ++ gf_msg_debug (this->name, 0, ++ "got %d, calling default_notify ()", event); + + default_notify (this, event, data); + conf->last_sent_event = event; +@@ -2191,20 +2155,23 @@ client_check_remote_host (xlator_t *this, dict_t *options) + + ret = dict_get_str (options, "remote-host", &remote_host); + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, "Remote host is not set. " +- "Assuming the volfile server as remote host."); ++ gf_msg (this->name, GF_LOG_INFO, EINVAL, ++ PC_MSG_DICT_GET_FAILED, "Remote host is not set. " ++ "Assuming the volfile server as remote host"); + + if (!this->ctx->cmd_args.volfile_server) { +- gf_log (this->name, GF_LOG_ERROR, +- "No remote host to connect."); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_DICT_GET_FAILED, "No remote host to " ++ "connect."); + goto out; + } + + ret = dict_set_str (options, "remote-host", + this->ctx->cmd_args.volfile_server); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to set the remote host"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PC_MSG_DICT_GET_FAILED, "Failed to set the " ++ "remote host"); + goto out; + } + } +@@ -2234,7 +2201,8 @@ build_client_config (xlator_t *this, clnt_conf_t *conf) + GF_OPTION_INIT ("remote-subvolume", conf->opt.remote_subvolume, + path, out); + if (!conf->opt.remote_subvolume) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, + "option 'remote-subvolume' not given"); + + GF_OPTION_INIT ("filter-O_DIRECT", conf->filter_o_direct, +@@ -2265,8 +2233,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_client_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + +@@ -2289,12 +2257,12 @@ client_destroy_rpc (xlator_t *this) + + conf->rpc = rpc_clnt_unref (conf->rpc); + ret = 0; +- gf_log (this->name, GF_LOG_DEBUG, +- "Client rpc conn destroyed"); ++ gf_msg_debug (this->name, 0, ++ "Client rpc conn destroyed"); + goto out; + } + +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INVALID_CALL, + "RPC destroy called on already destroyed " + "connection"); + +@@ -2311,21 +2279,24 @@ client_init_rpc (xlator_t *this) + conf = this->private; + + if (conf->rpc) { +- gf_log (this->name, GF_LOG_WARNING, +- "client rpc already init'ed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PC_MSG_RPC_INITED_ALREADY, "client rpc already " ++ "init'ed"); + ret = -1; + goto out; + } + + conf->rpc = rpc_clnt_new (this->options, this->ctx, this->name, 0); + if (!conf->rpc) { +- gf_log (this->name, GF_LOG_ERROR, "failed to initialize RPC"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_INIT_FAILED, ++ "failed to initialize RPC"); + goto out; + } + + ret = rpc_clnt_register_notify (conf->rpc, client_rpc_notify, this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to register notify"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_NOTIFY_FAILED, ++ "failed to register notify"); + goto out; + } + +@@ -2335,14 +2306,14 @@ client_init_rpc (xlator_t *this) + ret = rpcclnt_cbk_program_register (conf->rpc, &gluster_cbk_prog, + this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_CBK_FAILED, + "failed to register callback program"); + goto out; + } + + ret = 0; + +- gf_log (this->name, GF_LOG_DEBUG, "client init successful"); ++ gf_msg_debug (this->name, 0, "client init successful"); + out: + return ret; + } +@@ -2367,8 +2338,8 @@ client_init_grace_timer (xlator_t *this, dict_t *options, + if (!ret) + gf_string2boolean (lk_heal, &conf->lk_heal); + +- gf_log (this->name, GF_LOG_DEBUG, "lk-heal = %s", +- (conf->lk_heal) ? "on" : "off"); ++ gf_msg_debug (this->name, 0, "lk-heal = %s", ++ (conf->lk_heal) ? "on" : "off"); + + ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); + if (!ret) +@@ -2380,8 +2351,8 @@ client_init_grace_timer (xlator_t *this, dict_t *options, + + gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec, + gf_timefmt_s); +- gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout value = %s", +- timestr); ++ gf_msg_debug (this->name, 0, "Client grace timeout value = %s", ++ timestr); + + ret = 0; + out: +@@ -2482,15 +2453,15 @@ init (xlator_t *this) + clnt_conf_t *conf = NULL; + + if (this->children) { +- gf_log (this->name, GF_LOG_ERROR, +- "FATAL: client protocol translator cannot have any " +- "subvolumes"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PC_MSG_INVALID_ENTRY, "FATAL: client protocol " ++ "translator cannot have any subvolumes"); + goto out; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, +- "Volume is dangling. "); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PC_MSG_INVALID_ENTRY, "Volume is dangling. "); + } + + conf = GF_CALLOC (1, sizeof (*conf), gf_client_mt_clnt_conf_t); +@@ -2540,7 +2511,7 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (clnt_local_t, 64); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY, + "failed to create local_t's memory pool"); + goto out; + } +diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h +index 40200b6..38f34d5 100644 +--- a/xlators/protocol/client/src/client.h ++++ b/xlators/protocol/client/src/client.h +@@ -48,7 +48,8 @@ typedef enum { + goto label; \ + } \ + if (remote_fd == -1) { \ +- gf_log (xl->name, GF_LOG_WARNING, " (%s) " \ ++ gf_msg (xl->name, GF_LOG_WARNING, EBADFD, \ ++ PC_MSG_BAD_FD, " (%s) " \ + "remote_fd is -1. EBADFD", \ + uuid_utoa (fd->inode->gfid)); \ + op_errno = EBADFD; \ +-- +1.7.1 + diff --git a/SOURCES/0082-protocol-server-port-log-messages-to-new-framework.patch b/SOURCES/0082-protocol-server-port-log-messages-to-new-framework.patch new file mode 100644 index 0000000..638844f --- /dev/null +++ b/SOURCES/0082-protocol-server-port-log-messages-to-new-framework.patch @@ -0,0 +1,2797 @@ +From 3c0a03459e08568339195d14ffd2fef9acb89607 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Wed, 11 Mar 2015 20:11:09 +0530 +Subject: [PATCH 082/101] protocol/server : port log messages to new framework + +Change-Id: I7901f55d06716161cc31d2b79a600a16b5ec2ef8 +BUG: 1231776 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: http://review.gluster.org/9874 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/50889 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/protocol/server/src/Makefile.am | 3 +- + xlators/protocol/server/src/authenticate.c | 29 +- + xlators/protocol/server/src/server-handshake.c | 152 +++--- + xlators/protocol/server/src/server-helpers.c | 107 ++-- + xlators/protocol/server/src/server-messages.h | 796 ++++++++++++++++++++++++ + xlators/protocol/server/src/server-resolve.c | 64 ++- + xlators/protocol/server/src/server-rpc-fops.c | 208 ++++--- + xlators/protocol/server/src/server.c | 137 +++-- + 8 files changed, 1202 insertions(+), 294 deletions(-) + create mode 100644 xlators/protocol/server/src/server-messages.h + +diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am +index 6a18bf0..c62d24f 100644 +--- a/xlators/protocol/server/src/Makefile.am ++++ b/xlators/protocol/server/src/Makefile.am +@@ -10,7 +10,8 @@ server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + server_la_SOURCES = server.c server-resolve.c server-helpers.c \ + server-rpc-fops.c server-handshake.c authenticate.c + +-noinst_HEADERS = server.h server-helpers.h server-mem-types.h authenticate.h ++noinst_HEADERS = server.h server-helpers.h server-mem-types.h authenticate.h \ ++ server-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) \ + -I$(top_srcdir)/libglusterfs/src \ +diff --git a/xlators/protocol/server/src/authenticate.c b/xlators/protocol/server/src/authenticate.c +index d8d138a..8b45c41 100644 +--- a/xlators/protocol/server/src/authenticate.c ++++ b/xlators/protocol/server/src/authenticate.c +@@ -23,6 +23,7 @@ + #include + #include + #include "authenticate.h" ++#include "server-messages.h" + + static int + init (dict_t *this, char *key, data_t *value, void *data) +@@ -38,9 +39,9 @@ init (dict_t *this, char *key, data_t *value, void *data) + error = data; + + if (!strncasecmp (key, "ip", strlen ("ip"))) { +- gf_log ("authenticate", GF_LOG_ERROR, +- "AUTHENTICATION MODULE \"IP\" HAS BEEN REPLACED " +- "BY \"ADDR\""); ++ gf_msg ("authenticate", GF_LOG_ERROR, 0, ++ PS_MSG_AUTHENTICATE_ERROR, "AUTHENTICATION MODULE " ++ "\"IP\" HAS BEEN REPLACED BY \"ADDR\""); + dict_set (this, key, data_from_dynptr (NULL, 0)); + /* TODO: 1.3.x backword compatibility */ + // *error = -1; +@@ -57,7 +58,8 @@ init (dict_t *this, char *key, data_t *value, void *data) + + handle = dlopen (auth_file, RTLD_LAZY); + if (!handle) { +- gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n", ++ gf_msg ("authenticate", GF_LOG_ERROR, 0, ++ PS_MSG_AUTHENTICATE_ERROR, "dlopen(%s): %s\n", + auth_file, dlerror ()); + dict_set (this, key, data_from_dynptr (NULL, 0)); + GF_FREE (auth_file); +@@ -68,8 +70,9 @@ init (dict_t *this, char *key, data_t *value, void *data) + + authenticate = dlsym (handle, "gf_auth"); + if (!authenticate) { +- gf_log ("authenticate", GF_LOG_ERROR, +- "dlsym(gf_auth) on %s\n", dlerror ()); ++ gf_msg ("authenticate", GF_LOG_ERROR, 0, ++ PS_MSG_AUTHENTICATE_ERROR, "dlsym(gf_auth) on %s\n", ++ dlerror ()); + dict_set (this, key, data_from_dynptr (NULL, 0)); + dlclose (handle); + *error = -1; +@@ -95,8 +98,8 @@ init (dict_t *this, char *key, data_t *value, void *data) + } + auth_handle->vol_opt->given_opt = dlsym (handle, "options"); + if (auth_handle->vol_opt->given_opt == NULL) { +- gf_log ("authenticate", GF_LOG_DEBUG, +- "volume option validation not specified"); ++ gf_msg_debug ("authenticate", 0, "volume option validation " ++ "not specified"); + } + + auth_handle->authenticate = authenticate; +@@ -135,8 +138,9 @@ _gf_auth_option_validate (dict_t *d, char *k, data_t *v, void *tmp) + ret = xlator_options_validate_list (xl, xl->options, + handle->vol_opt, NULL); + if (ret) { +- gf_log ("authenticate", GF_LOG_ERROR, +- "volume option validation failed"); ++ gf_msg ("authenticate", GF_LOG_ERROR, 0, ++ PS_MSG_VOL_VALIDATE_FAILED, "volume option validation " ++ "failed"); + return -1; + } + return 0; +@@ -155,7 +159,8 @@ gf_auth_init (xlator_t *xl, dict_t *auth_modules) + + out: + if (ret) { +- gf_log (xl->name, GF_LOG_ERROR, "authentication init failed"); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, PS_MSG_AUTH_INIT_FAILED, ++ "authentication init failed"); + dict_foreach (auth_modules, fini, &ret); + ret = -1; + } +@@ -234,7 +239,7 @@ gf_authenticate (dict_t *input_params, + name = peerinfo_data->data; + } + +- gf_log ("auth", GF_LOG_ERROR, ++ gf_msg ("auth", GF_LOG_ERROR, 0, PS_MSG_REMOTE_CLIENT_REFUSED, + "no authentication module is interested in " + "accepting remote-client %s", name); + result = AUTH_REJECT; +diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c +index 262df6a..556b0e2 100644 +--- a/xlators/protocol/server/src/server-handshake.c ++++ b/xlators/protocol/server/src/server-handshake.c +@@ -21,6 +21,7 @@ + #include "compat-errno.h" + #include "glusterfs3.h" + #include "authenticate.h" ++#include "server-messages.h" + + struct __get_xl_struct { + const char *name; +@@ -94,7 +95,7 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum) + } + + if (temp_volfile->checksum != checksum) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_REMOUNT_CLIENT_REQD, + "the volume file was modified between a prior access " + "and now. This may lead to inconsistency between " + "clients, you are advised to remount client"); +@@ -122,7 +123,7 @@ getspec_build_volfile_path (xlator_t *this, const char *key, char *path, + ret = dict_get_str (this->options, "client-volume-filename", + &filename); + if (ret == 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PS_MSG_DEFAULTING_FILE, + "option 'client-volume-filename' is changed to " + "'volume-filename.' which now takes 'key' as an " + "option to choose/fetch different files from server. " +@@ -137,8 +138,9 @@ getspec_build_volfile_path (xlator_t *this, const char *key, char *path, + if (ret < 0) { + /* Make sure that key doesn't contain "../" in path */ + if ((gf_strstr (key, "/", "..")) == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: invalid key", key); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PS_MSG_INVALID_ENTRY, "%s: invalid " ++ "key", key); + goto out; + } + } +@@ -148,9 +150,9 @@ getspec_build_volfile_path (xlator_t *this, const char *key, char *path, + ret = dict_get_str (this->options, + "volume-filename.default", &filename); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "no default volume filename given, " +- "defaulting to %s", DEFAULT_VOLUME_FILE_PATH); ++ gf_msg_debug (this->name, 0, "no default volume " ++ "filename given, defaulting to %s", ++ DEFAULT_VOLUME_FILE_PATH); + } + } + +@@ -203,7 +205,8 @@ _validate_volfile_checksum (xlator_t *this, char *key, + fd = open (filename, O_RDONLY); + if (-1 == fd) { + ret = 0; +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ PS_MSG_VOL_FILE_OPEN_FAILED, + "failed to open volume file (%s) : %s", + filename, strerror (errno)); + goto out; +@@ -271,8 +274,8 @@ server_getspec (rpcsvc_request_t *req) + /* to allocate the proper buffer to hold the file data */ + ret = stat (filename, &stbuf); + if (ret < 0){ +- gf_log (this->name, GF_LOG_ERROR, +- "Unable to stat %s (%s)", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ PS_MSG_STAT_ERROR, "Unable to stat %s (%s)", + filename, strerror (errno)); + op_errno = errno; + goto fail; +@@ -280,9 +283,9 @@ server_getspec (rpcsvc_request_t *req) + + spec_fd = open (filename, O_RDONLY); + if (spec_fd < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "Unable to open %s (%s)", +- filename, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ PS_MSG_FILE_OP_FAILED, "Unable to open %s " ++ "(%s)", filename, strerror (errno)); + op_errno = errno; + goto fail; + } +@@ -382,10 +385,9 @@ server_setvolume (rpcsvc_request_t *req) + "Internal error: failed to unserialize " + "request dictionary"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg \"%s\"", +- "Internal error: failed to unserialize " +- "request dictionary"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg \"%s\"", "Internal error: failed " ++ "to unserialize request dictionary"); + + op_ret = -1; + op_errno = EINVAL; +@@ -400,8 +402,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "ERROR", + "UUID not specified"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = EINVAL; +@@ -414,8 +416,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "ERROR", + "lock state version not supplied"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = EINVAL; +@@ -429,14 +431,16 @@ server_setvolume (rpcsvc_request_t *req) + goto fail; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", client->client_uid); ++ gf_msg_debug (this->name, 0, "Connected to %s", client->client_uid); + cancelled = server_cancel_grace_timer (this, client); + if (cancelled)//Do gf_client_put on behalf of grace-timer-handler. + gf_client_put (client, NULL); + + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto fail; + } + +@@ -452,8 +456,9 @@ server_setvolume (rpcsvc_request_t *req) + auth_set_username_passwd (params, config_params, client); + if (req->trans->ssl_name) { + if (dict_set_str(params,"ssl-name",req->trans->ssl_name) != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "failed to set ssl_name %s", req->trans->ssl_name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PS_MSG_SSL_NAME_SET_FAILED, "failed to set " ++ "ssl_name %s", req->trans->ssl_name); + /* Not fatal, auth will just fail. */ + } + } +@@ -463,8 +468,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "ERROR", + "No FOP version number specified"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + } + + ret = dict_get_int32 (params, "mgmt-version", &mgmt_version); +@@ -472,8 +477,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "ERROR", + "No MGMT version number specified"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + } + + ret = gf_compare_client_version (req, fop_version, mgmt_version); +@@ -483,14 +488,15 @@ server_setvolume (rpcsvc_request_t *req) + fop_version, mgmt_version); + /* get_supported_version (req)); */ + if (-1 == ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "asprintf failed while setting up error msg"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_ASPRINTF_FAILED, "asprintf failed while" ++ "setting up error msg"); + goto fail; + } + ret = dict_set_dynstr (reply, "ERROR", msg); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = EINVAL; +@@ -502,8 +508,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "ERROR", + "No remote-subvolume option specified"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = EINVAL; +@@ -515,14 +521,15 @@ server_setvolume (rpcsvc_request_t *req) + ret = gf_asprintf (&msg, "remote-subvolume \"%s\" is not found", + name); + if (-1 == ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_ASPRINTF_FAILED, + "asprintf failed while setting error msg"); + goto fail; + } + ret = dict_set_dynstr (reply, "ERROR", msg); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = ENOENT; +@@ -535,8 +542,8 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_get_str (params, "volfile-key", + &volfile_key); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set 'volfile-key'"); ++ gf_msg_debug (this->name, 0, "failed to set " ++ "'volfile-key'"); + + ret = _validate_volfile_checksum (this, volfile_key, + checksum); +@@ -546,8 +553,8 @@ server_setvolume (rpcsvc_request_t *req) + "varies from earlier " + "access"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed " ++ "to set error msg"); + + op_ret = -1; + op_errno = ESTALE; +@@ -561,25 +568,26 @@ server_setvolume (rpcsvc_request_t *req) + if (peerinfo) { + ret = dict_set_static_ptr (params, "peer-info", peerinfo); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set peer-info"); ++ gf_msg_debug (this->name, 0, "failed to set " ++ "peer-info"); + } + if (conf->auth_modules == NULL) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_AUTH_INIT_FAILED, + "Authentication module not initialized"); + } + + ret = dict_get_str (params, "client-version", &clnt_version); + if (ret) +- gf_log (this->name, GF_LOG_INFO, "client-version not set, " +- "may be of older version"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_CLIENT_VERSION_NOT_SET, ++ "client-version not set, may be of older version"); + + ret = gf_authenticate (params, config_params, + conf->auth_modules); + + if (ret == AUTH_ACCEPT) { + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_ACCEPTED, + "accepted client from %s (version: %s)", + client->client_uid, + (clnt_version) ? clnt_version : "old"); +@@ -587,20 +595,20 @@ server_setvolume (rpcsvc_request_t *req) + client->bound_xl = xl; + ret = dict_set_str (reply, "ERROR", "Success"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "Cannot authenticate client from %s %s", +- client->client_uid, ++ gf_msg (this->name, GF_LOG_ERROR, EACCES, ++ PS_MSG_AUTHENTICATE_ERROR, "Cannot authenticate client" ++ " from %s %s", client->client_uid, + (clnt_version) ? clnt_version : "old"); + + op_ret = -1; + op_errno = EACCES; + ret = dict_set_str (reply, "ERROR", "Authentication failed"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + goto fail; + } + +@@ -609,8 +617,8 @@ server_setvolume (rpcsvc_request_t *req) + "Check volfile and handshake " + "options in protocol/client"); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set error msg"); ++ gf_msg_debug (this->name, 0, "failed to set error " ++ "msg"); + + op_ret = -1; + op_errno = EACCES; +@@ -623,10 +631,9 @@ server_setvolume (rpcsvc_request_t *req) + /* create inode table for this bound_xl, if one doesn't + already exist */ + +- gf_log (this->name, GF_LOG_TRACE, +- "creating inode table with lru_limit=%"PRId32", " +- "xlator=%s", conf->inode_lru_limit, +- client->bound_xl->name); ++ gf_msg_trace (this->name, 0, "creating inode table with " ++ "lru_limit=%"PRId32", xlator=%s", ++ conf->inode_lru_limit, client->bound_xl->name); + + /* TODO: what is this ? */ + client->bound_xl->itable = +@@ -637,25 +644,24 @@ server_setvolume (rpcsvc_request_t *req) + ret = dict_set_str (reply, "process-uuid", + this->ctx->process_uuid); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set 'process-uuid'"); ++ gf_msg_debug (this->name, 0, "failed to set 'process-uuid'"); + + ret = dict_set_uint32 (reply, "clnt-lk-version", serv_ctx->lk_version); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "failed to set 'clnt-lk-version'"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PS_MSG_CLIENT_LK_VERSION_ERROR, "failed to set " ++ "'clnt-lk-version'"); + + ret = dict_set_uint64 (reply, "transport-ptr", + ((uint64_t) (long) req->trans)); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set 'transport-ptr'"); ++ gf_msg_debug (this->name, 0, "failed to set 'transport-ptr'"); + + fail: + rsp.dict.dict_len = dict_serialized_length (reply); + if (rsp.dict.dict_len > UINT_MAX) { +- gf_log ("server-handshake", GF_LOG_DEBUG, +- "failed to get serialized length of reply dict"); ++ gf_msg_debug ("server-handshake", 0, "failed to get serialized" ++ " length of reply dict"); + op_ret = -1; + op_errno = EINVAL; + rsp.dict.dict_len = 0; +@@ -667,8 +673,8 @@ fail: + if (rsp.dict.dict_val) { + ret = dict_serialize (reply, rsp.dict.dict_val); + if (ret < 0) { +- gf_log ("server-handshake", GF_LOG_DEBUG, +- "failed to serialize reply dict"); ++ gf_msg_debug ("server-handshake", 0, "failed " ++ "to serialize reply dict"); + op_ret = -1; + op_errno = -ret; + } +@@ -752,7 +758,9 @@ server_set_lk_version (rpcsvc_request_t *req) + client = gf_client_get (this, &req->cred, args.uid); + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto fail; + } + +diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c +index 545be6e..24d617f 100644 +--- a/xlators/protocol/server/src/server-helpers.c ++++ b/xlators/protocol/server/src/server-helpers.c +@@ -16,6 +16,7 @@ + #include "server.h" + #include "server-helpers.h" + #include "gidcache.h" ++#include "server-messages.h" + + #include + #include +@@ -42,25 +43,27 @@ gid_resolve (server_conf_t *conf, call_stack_t *root) + + ret = getpwuid_r (root->uid, &mypw, mystrs, sizeof(mystrs), &result); + if (ret != 0) { +- gf_log("gid-cache", GF_LOG_ERROR, "getpwuid_r(%u) failed", +- root->uid); ++ gf_msg ("gid-cache", GF_LOG_ERROR, errno, ++ PS_MSG_GET_UID_FAILED, "getpwuid_r(%u) failed", ++ root->uid); + return -1; + } + + if (!result) { +- gf_log ("gid-cache", GF_LOG_ERROR, "getpwuid_r(%u) found " +- "nothing", root->uid); ++ gf_msg ("gid-cache", GF_LOG_ERROR, 0, PS_MSG_UID_NOT_FOUND, ++ "getpwuid_r(%u) found nothing", root->uid); + return -1; + } + +- gf_log ("gid-cache", GF_LOG_TRACE, "mapped %u => %s", root->uid, +- result->pw_name); ++ gf_msg_trace ("gid-cache", 0, "mapped %u => %s", root->uid, ++ result->pw_name); + + ngroups = GF_MAX_AUX_GROUPS; + ret = getgrouplist (result->pw_name, root->gid, mygroups, &ngroups); + if (ret == -1) { +- gf_log ("gid-cache", GF_LOG_ERROR, "could not map %s to group " +- "list (%d gids)", result->pw_name, root->ngrps); ++ gf_msg ("gid-cache", GF_LOG_ERROR, 0, PS_MSG_MAPPING_ERROR, ++ "could not map %s to group list (%d gids)", ++ result->pw_name, root->ngrps); + return -1; + } + root->ngrps = (uint16_t) ngroups; +@@ -286,12 +289,14 @@ do_fd_cleanup (xlator_t *this, client_t* client, fdentry_t *fdentries, int fd_co + ret = inode_path (fd->inode, NULL, &path); + + if (ret > 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_FD_CLEANUP, + "fd cleanup on %s", path); + GF_FREE (path); + } else { + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_FD_CLEANUP, + "fd cleanup on inode with gfid %s", + uuid_utoa (fd->inode->gfid)); + } +@@ -334,7 +339,9 @@ server_connection_cleanup (xlator_t *this, client_t *client, + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto out; + } + +@@ -356,7 +363,8 @@ server_connection_cleanup (xlator_t *this, client_t *client, + if (fdentries != NULL) + ret = do_fd_cleanup (this, client, fdentries, fd_count); + else +- gf_log (this->name, GF_LOG_INFO, "no fdentries to clean"); ++ gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_FDENTRY_NULL, ++ "no fdentries to clean"); + + if (cd_ret || ret) + ret = -1; +@@ -521,9 +529,9 @@ server_build_config (xlator_t *this, server_conf_t *conf) + if (data) { + ret = gf_string2boolean(data->data, &conf->verify_volfile); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "wrong value for 'verify-volfile-checksum', " +- "Neglecting option"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PS_MSG_INVALID_ENTRY, "wrong value for '" ++ "verify-volfile-checksum', Neglecting option"); + } + } + +@@ -531,9 +539,9 @@ server_build_config (xlator_t *this, server_conf_t *conf) + if (data) { + ret = gf_string2boolean (data->data, &conf->trace); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "'trace' takes on only boolean values. " +- "Neglecting option"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PS_MSG_INVALID_ENTRY, "'trace' takes on only " ++ "boolean values. Neglecting option"); + } + } + +@@ -541,9 +549,8 @@ server_build_config (xlator_t *this, server_conf_t *conf) + ret = dict_get_int32 (this->options, "limits.transaction-size", + &conf->rpc_conf.max_block_size); + if (ret < 0) { +- gf_log (this->name, GF_LOG_TRACE, +- "defaulting limits.transaction-size to %d", +- DEFAULT_BLOCK_SIZE); ++ gf_msg_trace (this->name, 0, "defaulting limits.transaction-" ++ "size to %d", DEFAULT_BLOCK_SIZE); + conf->rpc_conf.max_block_size = DEFAULT_BLOCK_SIZE; + } + +@@ -553,16 +560,17 @@ server_build_config (xlator_t *this, server_conf_t *conf) + or directory specified is non standard */ + ret = stat (data->data, &buf); + if ((ret != 0) || !S_ISDIR (buf.st_mode)) { +- gf_log (this->name, GF_LOG_ERROR, +- "Directory '%s' doesn't exist, exiting.", +- data->data); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_DIR_NOT_FOUND, "Directory '%s' doesn't " ++ "exist, exiting.", data->data); + ret = -1; + goto out; + } + /* Make sure that conf-dir doesn't contain ".." in path */ + if ((gf_strstr (data->data, "/", "..")) == -1) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_CONF_DIR_INVALID, + "%s: invalid conf_dir", data->data); + goto out; + } +@@ -759,9 +767,8 @@ server_print_reply (call_frame_t *frame, int op_ret, int op_errno) + if (state->fd) + snprintf (fdstr, 32, " fd=%p", state->fd); + +- gf_log (this->name, GF_LOG_INFO, +- "%s%s => (%d, %d)%s", +- op, caller, op_ret, op_errno, fdstr); ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_SERVER_MSG, ++ "%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); + out: + return; + } +@@ -822,9 +829,8 @@ server_print_request (call_frame_t *frame) + break; + } + +- gf_log (this->name, GF_LOG_INFO, +- "%s%s%s%s%s%s%s", +- op, caller, ++ gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_MSG, ++ "%s%s%s%s%s%s%s", op, caller, + resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars); + out: + return; +@@ -859,9 +865,9 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) + if (entry->dict) { + trav->dict.dict_len = dict_serialized_length (entry->dict); + if (trav->dict.dict_len > UINT_MAX) { +- gf_log (THIS->name, GF_LOG_ERROR, +- "failed to get serialized length " +- "of reply dict"); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ PS_MSG_INVALID_ENTRY, "failed to get " ++ "serialized length of reply dict"); + errno = EINVAL; + trav->dict.dict_len = 0; + goto out; +@@ -877,7 +883,8 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) + + ret = dict_serialize (entry->dict, trav->dict.dict_val); + if (ret < 0) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ PS_MSG_DICT_SERIALIZE_FAIL, + "failed to serialize reply dict"); + errno = -ret; + trav->dict.dict_len = 0; +@@ -989,7 +996,8 @@ gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key) + pthread_mutex_lock (&conf->mutex); + { + list_for_each_entry (xprt, &conf->xprt_list, list) { +- gf_log ("mount-point-list", GF_LOG_INFO, ++ gf_msg ("mount-point-list", GF_LOG_INFO, 0, ++ PS_MSG_MOUNT_PT_FAIL, + "%s", xprt->peerinfo.identifier); + } + } +@@ -1021,7 +1029,7 @@ gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict) + total_read += xprt->total_bytes_read; + total_write += xprt->total_bytes_write; + } +- gf_log ("stats", GF_LOG_INFO, ++ gf_msg ("stats", GF_LOG_INFO, 0, PS_MSG_RW_STAT, + "total-read %"PRIu64", total-write %"PRIu64, + total_read, total_write); + } +@@ -1038,7 +1046,7 @@ server_cancel_grace_timer (xlator_t *this, client_t *client) + gf_boolean_t cancelled = _gf_false; + + if (!this || !client) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, PS_MSG_INVALID_ENTRY, + "Invalid arguments to cancel connection timer"); + return cancelled; + } +@@ -1046,7 +1054,9 @@ server_cancel_grace_timer (xlator_t *this, client_t *client) + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, ++ "server_ctx_get() failed"); + goto out; + } + +@@ -1124,8 +1134,8 @@ auth_set_username_passwd (dict_t *input_params, dict_t *config_params, + + ret = dict_get_str (input_params, "username", &username); + if (ret) { +- gf_log ("auth/login", GF_LOG_DEBUG, +- "username not found, returning DONT-CARE"); ++ gf_msg_debug ("auth/login", 0, "username not found, returning " ++ "DONT-CARE"); + /* For non trusted clients username and password + will not be there. So dont reject the client. + */ +@@ -1135,14 +1145,15 @@ auth_set_username_passwd (dict_t *input_params, dict_t *config_params, + + ret = dict_get_str (input_params, "password", &password); + if (ret) { +- gf_log ("auth/login", GF_LOG_WARNING, ++ gf_msg ("auth/login", GF_LOG_WARNING, 0, ++ PS_MSG_DICT_GET_FAILED, + "password not found, returning DONT-CARE"); + goto out; + } + + ret = dict_get_str (input_params, "remote-subvolume", &brick_name); + if (ret) { +- gf_log ("auth/login", GF_LOG_ERROR, ++ gf_msg ("auth/login", GF_LOG_ERROR, 0, PS_MSG_DICT_GET_FAILED, + "remote-subvolume not specified"); + ret = -1; + goto out; +@@ -1177,8 +1188,9 @@ auth_set_username_passwd (dict_t *input_params, dict_t *config_params, + GF_FREE (searchstr); + + if (!passwd_data) { +- gf_log ("auth/login", GF_LOG_ERROR, +- "wrong username/password " ++ gf_msg ("auth/login", GF_LOG_ERROR, 0, ++ PS_MSG_LOGIN_ERROR, "wrong " ++ "username/password " + "combination"); + ret = -1; + goto out; +@@ -1193,8 +1205,9 @@ auth_set_username_passwd (dict_t *input_params, dict_t *config_params, + gf_strdup (password); + } + if (ret == -1) +- gf_log ("auth/login", GF_LOG_ERROR, +- "wrong password for user %s", ++ gf_msg ("auth/login", GF_LOG_ERROR, 0, ++ PS_MSG_LOGIN_ERROR, "wrong " ++ "password for user %s", + username); + break; + } +diff --git a/xlators/protocol/server/src/server-messages.h b/xlators/protocol/server/src/server-messages.h +new file mode 100644 +index 0000000..f604086 +--- /dev/null ++++ b/xlators/protocol/server/src/server-messages.h +@@ -0,0 +1,796 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _PS_MESSAGES_H__ ++#define _PS_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/*! \file server-messages.h ++ * \brief server log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_PS_BASE GLFS_MSGID_COMP_PS ++#define GLFS_NUM_MESSAGES 82 ++#define GLFS_MSGID_END (GLFS_PS_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_PS_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++#define PS_MSG_AUTHENTICATE_ERROR (GLFS_PS_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_VOL_VALIDATE_FAILED (GLFS_PS_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_AUTH_INIT_FAILED (GLFS_PS_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_REMOTE_CLIENT_REFUSED (GLFS_PS_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GFID_RESOLVE_FAILED (GLFS_PS_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ANONYMOUS_FD_CREATE_FAILED (GLFS_PS_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_NO_MEMORY (GLFS_PS_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FD_NOT_FOUND (GLFS_PS_BASE + 8) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_INVALID_ENTRY (GLFS_PS_BASE + 9) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GET_UID_FAILED (GLFS_PS_BASE + 10) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_UID_NOT_FOUND (GLFS_PS_BASE + 11) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_MAPPING_ERROR (GLFS_PS_BASE + 12) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FD_CLEANUP (GLFS_PS_BASE + 13) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SERVER_CTX_GET_FAILED (GLFS_PS_BASE + 14) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FDENTRY_NULL (GLFS_PS_BASE + 15) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DIR_NOT_FOUND (GLFS_PS_BASE + 16) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SERVER_MSG (GLFS_PS_BASE + 17) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DICT_SERIALIZE_FAIL (GLFS_PS_BASE + 18) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RW_STAT (GLFS_PS_BASE + 19) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DICT_GET_FAILED (GLFS_PS_BASE + 20) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_LOGIN_ERROR (GLFS_PS_BASE + 21) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_REMOUNT_CLIENT_REQD (GLFS_PS_BASE + 22) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DEFAULTING_FILE (GLFS_PS_BASE + 23) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_VOL_FILE_OPEN_FAILED (GLFS_PS_BASE + 24) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_STAT_ERROR (GLFS_PS_BASE + 25) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SSL_NAME_SET_FAILED (GLFS_PS_BASE + 26) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ASPRINTF_FAILED (GLFS_PS_BASE + 27) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CLIENT_VERSION_NOT_SET (GLFS_PS_BASE + 28) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CLIENT_ACCEPTED (GLFS_PS_BASE + 29) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CLIENT_LK_VERSION_ERROR (GLFS_PS_BASE + 30) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GRACE_TIMER_EXPD (GLFS_PS_BASE + 31) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SERIALIZE_REPLY_FAILED (GLFS_PS_BASE + 32) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_AUTH_IP_ERROR (GLFS_PS_BASE + 33) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SKIP_FORMAT_CHK (GLFS_PS_BASE + 34) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_INTERNET_ADDR_ERROR (GLFS_PS_BASE + 35) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CLIENT_DISCONNECTING (GLFS_PS_BASE + 36) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GRACE_TIMER_START (GLFS_PS_BASE + 37) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_STATEDUMP_PATH_ERROR (GLFS_PS_BASE + 38) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GRP_CACHE_ERROR (GLFS_PS_BASE + 39) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RPC_CONF_ERROR (GLFS_PS_BASE + 40) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_TRANSPORT_ERROR (GLFS_PS_BASE + 41) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SUBVOL_NULL (GLFS_PS_BASE + 42) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_PARENT_VOL_ERROR (GLFS_PS_BASE + 43) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RPCSVC_CREATE_FAILED (GLFS_PS_BASE + 44) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RPCSVC_LISTENER_CREATE_FAILED (GLFS_PS_BASE + 45) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RPCSVC_NOTIFY (GLFS_PS_BASE + 46) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_PGM_REG_FAILED (GLFS_PS_BASE + 47) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ULIMIT_SET_FAILED (GLFS_PS_BASE + 48) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_STATFS (GLFS_PS_BASE + 49) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_LOOKUP_INFO (GLFS_PS_BASE + 50) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_LK_INFO (GLFS_PS_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_LOCK_ERROR (GLFS_PS_BASE + 52) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_INODELK_INFO (GLFS_PS_BASE + 53) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ENTRYLK_INFO (GLFS_PS_BASE + 54) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ACCESS_INFO (GLFS_PS_BASE + 55) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DIR_INFO (GLFS_PS_BASE + 56) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_MKNOD_INFO (GLFS_PS_BASE + 57) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_REMOVEXATTR_INFO (GLFS_PS_BASE + 58) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_GETXATTR_INFO (GLFS_PS_BASE + 59) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SETXATTR_INFO (GLFS_PS_BASE + 60) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_RENAME_INFO (GLFS_PS_BASE + 61) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_LINK_INFO (GLFS_PS_BASE + 62) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_TRUNCATE_INFO (GLFS_PS_BASE + 63) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FSTAT_INFO (GLFS_PS_BASE + 64) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FLUSH_INFO (GLFS_PS_BASE + 65) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SYNC_INFO (GLFS_PS_BASE + 66) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_WRITE_INFO (GLFS_PS_BASE + 67) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_READ_INFO (GLFS_PS_BASE + 68) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CHKSUM_INFO (GLFS_PS_BASE + 69) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_OPEN_INFO (GLFS_PS_BASE + 70) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CREATE_INFO (GLFS_PS_BASE + 71) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_SETATTR_INFO (GLFS_PS_BASE + 72) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_XATTROP_INFO (GLFS_PS_BASE + 73) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ALLOC_INFO (GLFS_PS_BASE + 74) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_DISCARD_INFO (GLFS_PS_BASE + 75) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_ZEROFILL_INFO (GLFS_PS_BASE + 76) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FD_CREATE_FAILED (GLFS_PS_BASE + 77) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_WRONG_STATE (GLFS_PS_BASE + 78) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_CONF_DIR_INVALID (GLFS_PS_BASE + 79) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_MOUNT_PT_FAIL (GLFS_PS_BASE + 80) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_STAT_INFO (GLFS_PS_BASE + 81) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define PS_MSG_FILE_OP_FAILED (GLFS_PS_BASE + 82) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_PS_MESSAGES_H_ */ ++ +diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c +index 461884d..a7da519 100644 +--- a/xlators/protocol/server/src/server-resolve.c ++++ b/xlators/protocol/server/src/server-resolve.c +@@ -15,6 +15,7 @@ + + #include "server.h" + #include "server-helpers.h" ++#include "server-messages.h" + + + int +@@ -63,11 +64,18 @@ resolve_gfid_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + resolve_loc = &resolve->resolve_loc; + + if (op_ret == -1) { +- gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG : +- GF_LOG_WARNING), +- "%s/%s: failed to resolve (%s)", +- uuid_utoa (resolve_loc->pargfid), resolve_loc->name, +- strerror (op_errno)); ++ if (op_errno == ENOENT) { ++ gf_msg_debug (this->name, 0, "%s/%s: failed to resolve" ++ " (%s)", ++ uuid_utoa (resolve_loc->pargfid), ++ resolve_loc->name, strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ PS_MSG_GFID_RESOLVE_FAILED, "%s/%s: failed to " ++ "resolve (%s)", ++ uuid_utoa (resolve_loc->pargfid), ++ resolve_loc->name, strerror (op_errno)); ++ } + goto out; + } + +@@ -104,10 +112,18 @@ resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + resolve_loc = &resolve->resolve_loc; + + if (op_ret == -1) { +- gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG : +- GF_LOG_WARNING), +- "%s: failed to resolve (%s)", +- uuid_utoa (resolve_loc->gfid), strerror (op_errno)); ++ if (op_errno == ENOENT) { ++ gf_msg_debug (this->name, GF_LOG_DEBUG, ++ "%s: failed to resolve (%s)", ++ uuid_utoa (resolve_loc->gfid), ++ strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ PS_MSG_GFID_RESOLVE_FAILED, ++ "%s: failed to resolve (%s)", ++ uuid_utoa (resolve_loc->gfid), ++ strerror (op_errno)); ++ } + loc_wipe (&resolve->resolve_loc); + goto out; + } +@@ -213,8 +229,8 @@ resolve_continue (call_frame_t *frame) + else if (!gf_uuid_is_null (resolve->gfid)) + ret = resolve_inode_simple (frame); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, +- "return value of resolve_*_simple %d", ret); ++ gf_msg_debug (this->name, 0, "return value of resolve_*_" ++ "simple %d", ret); + + resolve_loc_touchup (frame); + out: +@@ -281,9 +297,9 @@ resolve_entry_simple (call_frame_t *frame) + } + + if (resolve->type == RESOLVE_NOT) { +- gf_log (this->name, GF_LOG_DEBUG, "inode (pointer: %p gfid:%s" +- " found for path (%s) while type is RESOLVE_NOT", +- inode, uuid_utoa (inode->gfid), resolve->path); ++ gf_msg_debug (this->name, 0, "inode (pointer: %p gfid:%s found" ++ " for path (%s) while type is RESOLVE_NOT", ++ inode, uuid_utoa (inode->gfid), resolve->path); + resolve->op_ret = -1; + resolve->op_errno = EEXIST; + ret = -1; +@@ -420,9 +436,9 @@ out: + inode_unref (inode); + + if (ret != 0) +- gf_log ("server", GF_LOG_DEBUG, "inode for the gfid (%s) is " +- "not found. anonymous fd creation failed", +- uuid_utoa (resolve->gfid)); ++ gf_msg_debug ("server", 0, "inode for the gfid (%s) is " ++ "not found. anonymous fd creation failed", ++ uuid_utoa (resolve->gfid)); + return ret; + } + +@@ -476,7 +492,8 @@ server_resolve_fd (call_frame_t *frame) + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { +- gf_log ("", GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg ("", GF_LOG_INFO, ENOMEM, PS_MSG_NO_MEMORY, ++ "server_ctx_get() failed"); + resolve->op_ret = -1; + resolve->op_errno = ENOMEM; + return 0; +@@ -485,7 +502,8 @@ server_resolve_fd (call_frame_t *frame) + state->fd = gf_fd_fdptr_get (serv_ctx->fdtable, fd_no); + + if (!state->fd) { +- gf_log ("", GF_LOG_INFO, "fd not found in context"); ++ gf_msg ("", GF_LOG_INFO, EBADF, PS_MSG_FD_NOT_FOUND, "fd not " ++ "found in context"); + resolve->op_ret = -1; + resolve->op_errno = EBADF; + } +@@ -519,7 +537,8 @@ server_resolve (call_frame_t *frame) + + } else { + if (resolve == &state->resolve) +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ PS_MSG_INVALID_ENTRY, + "no resolution type for %s (%s)", + resolve->path, gf_fop_list[frame->root->op]); + +@@ -580,8 +599,9 @@ server_resolve_all (call_frame_t *frame) + server_resolve_done (frame); + + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "Invalid pointer for state->resolve_now"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ PS_MSG_INVALID_ENTRY, "Invalid pointer for " ++ "state->resolve_now"); + } + + return 0; +diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c +index df58116..99b8011 100644 +--- a/xlators/protocol/server/src/server-rpc-fops.c ++++ b/xlators/protocol/server/src/server-rpc-fops.c +@@ -22,6 +22,7 @@ + #include "glusterfs3-xdr.h" + #include "glusterfs3.h" + #include "compat-errno.h" ++#include "server-messages.h" + + #include "xdr-nfs3.h" + +@@ -44,7 +45,8 @@ server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + rsp.xdata.xdata_len, op_errno, out); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "%"PRId64": STATFS (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, errno, PS_MSG_STATFS, ++ "%"PRId64": STATFS (%s)", + frame->root->unique, strerror (op_errno)); + goto out; + } +@@ -138,8 +140,9 @@ out: + + if (op_ret) { + if (state->resolve.bname) { +- gf_log (this->name, ++ gf_msg (this->name, + fop_log_level (GF_FOP_LOOKUP, op_errno), ++ op_errno, PS_MSG_LOOKUP_INFO, + "%"PRId64": LOOKUP %s (%s/%s) ==> " + "(%s)", frame->root->unique, + state->loc.path, +@@ -147,8 +150,9 @@ out: + state->resolve.bname, + strerror (op_errno)); + } else { +- gf_log (this->name, ++ gf_msg (this->name, + fop_log_level (GF_FOP_LOOKUP, op_errno), ++ op_errno, PS_MSG_LOOKUP_INFO, + "%"PRId64": LOOKUP %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -180,7 +184,8 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_LK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_LK, op_errno), ++ op_errno, PS_MSG_LK_INFO, + "%"PRId64": LK %"PRId64" (%s) ==> " + "(%s)", frame->root->unique, + state->resolve.fd_no, +@@ -200,7 +205,7 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + lock->l_type = GF_LK_F_UNLCK; + break; + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_LOCK_ERROR, + "Unknown lock type: %"PRId32"!", lock->l_type); + break; + } +@@ -235,7 +240,8 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_INODELK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_INODELK, op_errno), ++ errno, PS_MSG_INODELK_INFO, + "%"PRId64": INODELK %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -271,7 +277,8 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_FINODELK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_FINODELK, op_errno), ++ op_errno, PS_MSG_INODELK_INFO, + "%"PRId64": FINODELK %"PRId64" (%s) " + "==> (%s)", frame->root->unique, + state->resolve.fd_no, +@@ -307,7 +314,8 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_ENTRYLK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_ENTRYLK, op_errno), ++ op_errno, PS_MSG_ENTRYLK_INFO, + "%"PRId64": ENTRYLK %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -343,7 +351,8 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_FENTRYLK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_FENTRYLK, op_errno), ++ op_errno, PS_MSG_ENTRYLK_INFO, + "%"PRId64": FENTRYLK %"PRId64" (%s) ==>(%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -378,7 +387,8 @@ server_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ op_errno, PS_MSG_ACCESS_INFO, + "%"PRId64": ACCESS %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -415,7 +425,8 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ op_errno, PS_MSG_DIR_INFO, + "%"PRId64": RMDIR %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -468,7 +479,8 @@ server_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_MKDIR, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_MKDIR, op_errno), ++ op_errno, PS_MSG_DIR_INFO, + "%"PRId64": MKDIR %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -515,7 +527,8 @@ server_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, fop_log_level (GF_FOP_MKNOD, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_MKNOD, op_errno), ++ op_errno, PS_MSG_MKNOD_INFO, + "%"PRId64": MKNOD %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -558,7 +571,8 @@ server_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ op_errno, PS_MSG_DIR_INFO, + "%"PRId64": FSYNCDIR %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -594,7 +608,8 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ op_errno, PS_MSG_DIR_INFO, + "%"PRId64": READDIR %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -642,7 +657,8 @@ server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_OPENDIR, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_OPENDIR, op_errno), ++ op_errno, PS_MSG_DIR_INFO, + "%"PRId64": OPENDIR %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -651,7 +667,9 @@ server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto out; + } + +@@ -692,7 +710,8 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + else + loglevel = GF_LOG_INFO; + +- gf_log (this->name, loglevel, ++ gf_msg (this->name, loglevel, op_errno, ++ PS_MSG_REMOVEXATTR_INFO, + "%"PRId64": REMOVEXATTR %s (%s) of key %s ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -726,7 +745,8 @@ server_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret == -1) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_REMOVEXATTR_INFO, + "%"PRId64": FREMOVEXATTR %"PRId64" (%s) (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), state->name, +@@ -761,7 +781,8 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret == -1) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_GETXATTR, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_GETXATTR, op_errno), ++ op_errno, PS_MSG_GETXATTR_INFO, + "%"PRId64": GETXATTR %s (%s) (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -802,7 +823,8 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret == -1) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_FGETXATTR, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_FGETXATTR, op_errno), ++ op_errno, PS_MSG_GETXATTR_INFO, + "%"PRId64": FGETXATTR %"PRId64" (%s) (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -840,7 +862,7 @@ _gf_server_log_setxattr_failure (dict_t *d, char *k, data_t *v, + frame = tmp; + state = CALL_STATE (frame); + +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, PS_MSG_SETXATTR_INFO, + "%"PRId64": SETXATTR %s (%s) ==> %s", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), k); +@@ -865,9 +887,14 @@ server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + _gf_server_log_setxattr_failure, + frame); + +- gf_log (THIS->name, ((op_errno == ENOTSUP) ? +- GF_LOG_DEBUG : GF_LOG_INFO), +- "%s", strerror (op_errno)); ++ if (op_errno == ENOTSUP) { ++ gf_msg_debug (THIS->name, 0, "%s", ++ strerror (op_errno)); ++ } else { ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ PS_MSG_SETXATTR_INFO, "%s", ++ strerror (op_errno)); ++ } + goto out; + } + +@@ -895,7 +922,7 @@ _gf_server_log_fsetxattr_failure (dict_t *d, char *k, data_t *v, + frame = tmp; + state = CALL_STATE (frame); + +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, PS_MSG_SETXATTR_INFO, + "%"PRId64": FSETXATTR %"PRId64" (%s) ==> %s", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), k); +@@ -921,9 +948,14 @@ server_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + _gf_server_log_fsetxattr_failure, + frame); + } +- gf_log (THIS->name, ((op_errno == ENOTSUP) ? +- GF_LOG_DEBUG : GF_LOG_INFO), +- "%s", strerror (op_errno)); ++ if (op_errno == ENOTSUP) { ++ gf_msg_debug (THIS->name, 0, "%s", ++ strerror (op_errno)); ++ } else { ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ PS_MSG_SETXATTR_INFO, "%s", ++ strerror (op_errno)); ++ } + goto out; + } + +@@ -963,7 +995,7 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (op_ret == -1) { + uuid_utoa_r (state->resolve.gfid, oldpar_str); + uuid_utoa_r (state->resolve2.gfid, newpar_str); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_RENAME_INFO, + "%"PRId64": RENAME %s (%s/%s) -> %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + oldpar_str, state->resolve.bname, state->loc2.path, +@@ -974,9 +1006,9 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + stbuf->ia_type = state->loc.inode->ia_type; + + /* TODO: log gfid of the inodes */ +- gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, +- "%"PRId64": RENAME_CBK %s ==> %s", +- frame->root->unique, state->loc.name, state->loc2.name); ++ gf_msg_trace (frame->root->client->bound_xl->name, 0, "%"PRId64": " ++ "RENAME_CBK %s ==> %s", frame->root->unique, ++ state->loc.name, state->loc2.name); + + /* Before renaming the inode, we have to get the inode for the + * destination entry (i.e. inode with state->loc2.parent as +@@ -1041,7 +1073,8 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret) { +- gf_log (this->name, fop_log_level (GF_FOP_UNLINK, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_UNLINK, op_errno), ++ op_errno, PS_MSG_LINK_INFO, + "%"PRId64": UNLINK %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -1050,9 +1083,8 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + /* TODO: log gfid of the inodes */ +- gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, +- "%"PRId64": UNLINK_CBK %s", +- frame->root->unique, state->loc.name); ++ gf_msg_trace (frame->root->client->bound_xl->name, 0, "%"PRId64": " ++ "UNLINK_CBK %s", frame->root->unique, state->loc.name); + + inode_unlink (state->loc.inode, state->loc.parent, + state->loc.name); +@@ -1096,7 +1128,7 @@ server_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "%"PRId64": SYMLINK %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -1149,7 +1181,7 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + uuid_utoa_r (state->resolve.gfid, gfid_str); + uuid_utoa_r (state->resolve2.pargfid, newpar_str); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "%"PRId64": LINK %s (%s) -> %s/%s ==> (%s)", + frame->root->unique, state->loc.path, + gfid_str, newpar_str, state->resolve2.bname, +@@ -1192,7 +1224,8 @@ server_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_TRUNCATE_INFO, + "%"PRId64": TRUNCATE %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1229,7 +1262,7 @@ server_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_STAT_INFO, + "%"PRId64": FSTAT %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1265,7 +1298,8 @@ server_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_TRUNCATE_INFO, + "%"PRId64": FTRUNCATE %"PRId64" (%s)==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1301,7 +1335,8 @@ server_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_FLUSH, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_FLUSH, op_errno), ++ op_errno, PS_MSG_FLUSH_INFO, + "%"PRId64": FLUSH %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1335,7 +1370,7 @@ server_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_SYNC_INFO, + "%"PRId64": FSYNC %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1372,7 +1407,7 @@ server_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_WRITE_INFO, + "%"PRId64": WRITEV %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1421,7 +1456,7 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_READ_INFO, + "%"PRId64": READV %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1459,7 +1494,7 @@ server_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_CHKSUM_INFO, + "%"PRId64": RCHECKSUM %"PRId64" (%s)==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), strerror (op_errno)); +@@ -1500,7 +1535,8 @@ server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_OPEN, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_OPEN, op_errno), ++ op_errno, PS_MSG_OPEN_INFO, + "%"PRId64": OPEN %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -1510,7 +1546,9 @@ server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto out; + } + +@@ -1551,7 +1589,7 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + state = CALL_STATE (frame); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_CREATE_INFO, + "%"PRId64": CREATE %s (%s/%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.pargfid), +@@ -1560,10 +1598,9 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + /* TODO: log gfid too */ +- gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, +- "%"PRId64": CREATE %s (%s)", +- frame->root->unique, state->loc.name, +- uuid_utoa (stbuf->ia_gfid)); ++ gf_msg_trace (frame->root->client->bound_xl->name, 0, "%"PRId64": " ++ "CREATE %s (%s)", frame->root->unique, state->loc.name, ++ uuid_utoa (stbuf->ia_gfid)); + + link_inode = inode_link (inode, state->loc.parent, + state->loc.name, stbuf); +@@ -1590,7 +1627,9 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto out; + } + +@@ -1635,7 +1674,7 @@ server_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "%"PRId64": READLINK %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -1676,7 +1715,8 @@ server_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, fop_log_level (GF_FOP_STAT, op_errno), ++ gf_msg (this->name, fop_log_level (GF_FOP_STAT, op_errno), ++ op_errno, PS_MSG_STAT_INFO, + "%"PRId64": STAT %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -1714,7 +1754,7 @@ server_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_SETATTR_INFO, + "%"PRId64": SETATTR %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -1752,7 +1792,7 @@ server_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_SETATTR_INFO, + "%"PRId64": FSETATTR %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -1791,7 +1831,8 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_XATTROP_INFO, + "%"PRId64": XATTROP %s (%s) ==> (%s)", + frame->root->unique, state->loc.path, + uuid_utoa (state->resolve.gfid), +@@ -1832,7 +1873,8 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_XATTROP_INFO, + "%"PRId64": FXATTROP %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -1876,7 +1918,7 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret < 0) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_DIR_INFO, + "%"PRId64": READDIRP %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -1925,7 +1967,7 @@ server_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_ALLOC_INFO, + "%"PRId64": FALLOCATE %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -1963,7 +2005,7 @@ server_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret) { + state = CALL_STATE (frame); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, PS_MSG_DISCARD_INFO, + "%"PRId64": DISCARD %"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -2003,7 +2045,8 @@ server_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + rsp.xdata.xdata_len, op_errno, out); + + if (op_ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, op_errno, ++ PS_MSG_ZEROFILL_INFO, + "%"PRId64": ZEROFILL%"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), +@@ -2290,8 +2333,8 @@ server_finodelk_resume (call_frame_t *frame, xlator_t *bound_xl) + GF_UNUSED int ret = -1; + server_state_t *state = NULL; + +- gf_log (bound_xl->name, GF_LOG_DEBUG, "frame %p, xlator %p", +- frame, bound_xl); ++ gf_msg_debug (bound_xl->name, 0, "frame %p, xlator %p", frame, ++ bound_xl); + + state = CALL_STATE (frame); + +@@ -2323,8 +2366,8 @@ server_inodelk_resume (call_frame_t *frame, xlator_t *bound_xl) + GF_UNUSED int ret = -1; + server_state_t *state = NULL; + +- gf_log (bound_xl->name, GF_LOG_DEBUG, "frame %p, xlator %p", +- frame, bound_xl); ++ gf_msg_debug (bound_xl->name, 0, "frame %p, xlator %p", frame, ++ bound_xl); + + state = CALL_STATE (frame); + +@@ -2499,7 +2542,8 @@ server_opendir_resume (call_frame_t *frame, xlator_t *bound_xl) + + state->fd = fd_create (state->loc.inode, frame->root->pid); + if (!state->fd) { +- gf_log ("server", GF_LOG_ERROR, "could not create the fd"); ++ gf_msg ("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, ++ "could not create the fd"); + goto err; + } + +@@ -2887,8 +2931,9 @@ server_create_resume (call_frame_t *frame, xlator_t *bound_xl) + + state->fd = fd_create (state->loc.inode, frame->root->pid); + if (!state->fd) { +- gf_log ("server", GF_LOG_ERROR, "fd creation for the inode %s " +- "failed", state->loc.inode? ++ gf_msg ("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, ++ "fd creation for the inode %s failed", ++ state->loc.inode ? + uuid_utoa (state->loc.inode->gfid):NULL); + state->resolve.op_ret = -1; + state->resolve.op_errno = ENOMEM; +@@ -3911,7 +3956,8 @@ server3_3_writev_vecsizer (int state, ssize_t *readsize, char *base_addr, + nextstate = SERVER3_3_VECWRITE_START; + break; + default: +- gf_log ("server", GF_LOG_ERROR, "wrong state: %d", state); ++ gf_msg ("server", GF_LOG_ERROR, 0, PS_MSG_WRONG_STATE, ++ "wrong state: %d", state); + } + + return nextstate; +@@ -3944,8 +3990,9 @@ server3_3_release (rpcsvc_request_t *req) + + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { +- gf_log (req->trans->name, GF_LOG_INFO, +- "server_ctx_get() failed"); ++ gf_msg (req->trans->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + req->rpc_err = SYSTEM_ERR; + goto out; + } +@@ -3985,8 +4032,9 @@ server3_3_releasedir (rpcsvc_request_t *req) + + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { +- gf_log (req->trans->name, GF_LOG_INFO, +- "server_ctx_get() failed"); ++ gf_msg (req->trans->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + req->rpc_err = SYSTEM_ERR; + goto out; + } +@@ -5987,9 +6035,9 @@ server3_3_lk (rpcsvc_request_t *req) + state->flock.l_type = F_UNLCK; + break; + default: +- gf_log (frame->root->client->bound_xl->name, GF_LOG_ERROR, +- "fd - %"PRId64" (%s): Unknown lock type: %"PRId32"!", +- state->resolve.fd_no, ++ gf_msg (frame->root->client->bound_xl->name, GF_LOG_ERROR, ++ 0, PS_MSG_LOCK_ERROR, "fd - %"PRId64" (%s): Unknown " ++ "lock type: %"PRId32"!", state->resolve.fd_no, + uuid_utoa (state->fd->inode->gfid), state->type); + break; + } +diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c +index f9d7d18..ca00dc0 100644 +--- a/xlators/protocol/server/src/server.c ++++ b/xlators/protocol/server/src/server.c +@@ -26,6 +26,7 @@ + #include "defaults.h" + #include "authenticate.h" + #include "event.h" ++#include "server-messages.h" + + rpcsvc_cbk_program_t server_cbk_prog = { + .progname = "Gluster Callback", +@@ -48,13 +49,15 @@ grace_time_handler (void *data) + + GF_VALIDATE_OR_GOTO (THIS->name, this, out); + +- gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s", +- client->client_uid); ++ gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_GRACE_TIMER_EXPD, "grace " ++ "timer expired for %s", client->client_uid); + + serv_ctx = server_ctx_get (client, this); + + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " ++ "failed"); + goto out; + } + +@@ -173,7 +176,8 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, + + iob = gfs_serialize_reply (req, arg, &rsp, xdrproc); + if (!iob) { +- gf_log ("", GF_LOG_ERROR, "Failed to serialize reply"); ++ gf_msg ("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, ++ "Failed to serialize reply"); + goto ret; + } + +@@ -355,13 +359,14 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data) + /* TODO: backward compatibility, remove when + newer versions are available */ + tmp = "addr"; +- gf_log ("server", GF_LOG_WARNING, ++ gf_msg ("server", GF_LOG_WARNING, 0, ++ PS_MSG_AUTH_IP_ERROR, + "assuming 'auth.ip' to be 'auth.addr'"); + } + ret = dict_set_dynptr (auth_dict, tmp, NULL, 0); + if (ret < 0) { +- gf_log ("server", GF_LOG_DEBUG, +- "failed to dict_set_dynptr"); ++ gf_msg_debug ("server", 0, "failed to " ++ "dict_set_dynptr"); + } + } + +@@ -388,7 +393,7 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v, + goto out; + + if (strncmp(tail, "addr.", 5) != 0) { +- gf_log (xl->name, GF_LOG_INFO, ++ gf_msg (xl->name, GF_LOG_INFO, 0, PS_MSG_SKIP_FORMAT_CHK, + "skip format check for non-addr auth option %s", k); + goto out; + } +@@ -423,7 +428,8 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v, + ret = 0; + } else { + ret = -1; +- gf_log (xl->name, GF_LOG_ERROR, ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ PS_MSG_INTERNET_ADDR_ERROR, + "internet address '%s'" + " does not conform to" + " standards.", addr); +@@ -456,10 +462,10 @@ validate_auth_options (xlator_t *this, dict_t *dict) + trav->xlator); + + if (-1 == error) { +- gf_log (this->name, GF_LOG_ERROR, +- "volume '%s' defined as subvolume, but no " +- "authentication defined for the same", +- trav->xlator->name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_AUTHENTICATE_ERROR, "volume '%s' " ++ "defined as subvolume, but no authentication " ++ "defined for the same", trav->xlator->name); + break; + } + trav = trav->next; +@@ -526,8 +532,9 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + if (!client) + break; + +- gf_log (this->name, GF_LOG_INFO, "disconnecting connection " +- "from %s", client->client_uid); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_CLIENT_DISCONNECTING, "disconnecting connection" ++ " from %s", client->client_uid); + + /* If lock self heal is off, then destroy the + conn object, else register a grace timer event */ +@@ -546,7 +553,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + serv_ctx = server_ctx_get (client, this); + + if (serv_ctx == NULL) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_SERVER_CTX_GET_FAILED, + "server_ctx_get() failed"); + goto out; + } +@@ -555,7 +563,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + { + if (!serv_ctx->grace_timer) { + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ PS_MSG_GRACE_TIMER_START, + "starting a grace timer for %s", + client->client_uid); + +@@ -593,8 +602,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_server_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + out: +@@ -659,8 +668,8 @@ server_init_grace_timer (xlator_t *this, dict_t *options, + if (!ret) + gf_string2boolean (lk_heal, &conf->lk_heal); + +- gf_log (this->name, GF_LOG_DEBUG, "lk-heal = %s", +- (conf->lk_heal) ? "on" : "off"); ++ gf_msg_debug (this->name, 0, "lk-heal = %s", ++ (conf->lk_heal) ? "on" : "off"); + + ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); + if (!ret) +@@ -670,8 +679,8 @@ server_init_grace_timer (xlator_t *this, dict_t *options, + + gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec, + gf_timefmt_s); +- gf_log (this->name, GF_LOG_DEBUG, "Server grace timeout value = %s", +- timestr); ++ gf_msg_debug (this->name, 0, "Server grace timeout value = %s", ++ timestr); + + conf->grace_ts.tv_nsec = 0; + +@@ -716,8 +725,8 @@ reconfigure (xlator_t *this, dict_t *options) + + if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ + conf->inode_lru_limit = inode_lru_limit; +- gf_log (this->name, GF_LOG_TRACE, "Reconfigured inode-lru-limit" +- " to %d", conf->inode_lru_limit); ++ gf_msg_trace (this->name, 0, "Reconfigured inode-lru-limit to " ++ "%d", conf->inode_lru_limit); + + /* traverse through the xlator graph. For each xlator in the + graph check whether it is a bound_xl or not (bound_xl means +@@ -732,22 +741,23 @@ reconfigure (xlator_t *this, dict_t *options) + if (data) { + ret = gf_string2boolean (data->data, &trace); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "'trace' takes on only boolean values. " +- "Neglecting option"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ PS_MSG_INVALID_ENTRY, "'trace' takes on only " ++ "boolean values. Neglecting option"); + ret = -1; + goto out; + } + conf->trace = trace; +- gf_log (this->name, GF_LOG_TRACE, "Reconfigured trace" +- " to %d", conf->trace); ++ gf_msg_trace (this->name, 0, "Reconfigured trace to %d", ++ conf->trace); + + } + + GF_OPTION_RECONF ("statedump-path", statedump_path, + options, path, out); + if (!statedump_path) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_STATEDUMP_PATH_ERROR, + "Error while reconfiguring statedump path"); + ret = -1; + goto out; +@@ -780,14 +790,15 @@ reconfigure (xlator_t *this, dict_t *options) + GF_OPTION_RECONF ("gid-timeout", conf->gid_cache_timeout, options, + int32, out); + if (gid_cache_reconf (&conf->gid_cache, conf->gid_cache_timeout) < 0) { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reconfigure group " +- "cache."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, ++ "Failed to reconfigure group cache."); + goto out; + } + + rpc_conf = conf->rpc; + if (!rpc_conf) { +- gf_log (this->name, GF_LOG_ERROR, "No rpc_conf !!!!"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, ++ "No rpc_conf !!!!"); + goto out; + } + +@@ -797,7 +808,7 @@ reconfigure (xlator_t *this, dict_t *options) + ret = rpcsvc_set_outstanding_rpc_limit (rpc_conf, options, + RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, + "Failed to reconfigure outstanding-rpc-limit"); + goto out; + } +@@ -807,8 +818,9 @@ reconfigure (xlator_t *this, dict_t *options) + if (listeners->trans->reconfigure ) + listeners->trans->reconfigure (listeners->trans, options); + else +- gf_log (this->name, GF_LOG_ERROR, +- "Reconfigure not found for transport" ); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_TRANSPORT_ERROR, "Reconfigure " ++ "not found for transport"); + } + } + +@@ -821,7 +833,7 @@ reconfigure (xlator_t *this, dict_t *options) + ret = server_init_grace_timer (this, options, conf); + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("", 0, "returning %d", ret); + return ret; + } + +@@ -858,13 +870,13 @@ init (xlator_t *this) + GF_VALIDATE_OR_GOTO ("init", this, out); + + if (this->children == NULL) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, + "protocol/server should have subvolume"); + goto out; + } + + if (this->parents != NULL) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, + "protocol/server should not have parent volumes"); + goto out; + } +@@ -906,7 +918,8 @@ init (xlator_t *this) + gf_path_strip_trailing_slashes (statedump_path); + this->ctx->statedump_path = gf_strdup (statedump_path); + } else { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_STATEDUMP_PATH_ERROR, + "Error setting statedump path"); + ret = -1; + goto out; +@@ -937,16 +950,17 @@ init (xlator_t *this) + + GF_OPTION_INIT("gid-timeout", conf->gid_cache_timeout, int32, out); + if (gid_cache_init (&conf->gid_cache, conf->gid_cache_timeout) < 0) { +- gf_log(this->name, GF_LOG_ERROR, "Failed to initialize " +- "group cache."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, ++ "Failed to initialize group cache."); + goto out; + } + + /* RPC related */ + conf->rpc = rpcsvc_init (this, this->ctx, this->options, 0); + if (conf->rpc == NULL) { +- gf_log (this->name, GF_LOG_ERROR, +- "creation of rpcsvc failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_RPCSVC_CREATE_FAILED, "creation of rpcsvc " ++ "failed"); + ret = -1; + goto out; + } +@@ -954,7 +968,7 @@ init (xlator_t *this) + ret = rpcsvc_set_outstanding_rpc_limit (conf->rpc, this->options, + RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, + "Failed to configure outstanding-rpc-limit"); + goto out; + } +@@ -967,14 +981,14 @@ init (xlator_t *this) + + ret = dict_get_str (this->options, "transport-type", &transport_type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, + "option transport-type not set"); + ret = -1; + goto out; + } + total_transport = rpc_transport_count (transport_type); + if (total_transport <= 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, + "failed to get total number of available tranpsorts"); + ret = -1; + goto out; +@@ -982,19 +996,21 @@ init (xlator_t *this) + ret = rpcsvc_create_listeners (conf->rpc, this->options, + this->name); + if (ret < 1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, + "creation of listener failed"); + ret = -1; + goto out; + } else if (ret < total_transport) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, + "creation of %d listeners failed, continuing with " + "succeeded transport", (total_transport - ret)); + } + + ret = rpcsvc_register_notify (conf->rpc, server_rpc_notify, this); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, + "registration of notify with rpcsvc failed"); + goto out; + } +@@ -1002,7 +1018,7 @@ init (xlator_t *this) + glusterfs3_3_fop_prog.options = this->options; + ret = rpcsvc_program_register (conf->rpc, &glusterfs3_3_fop_prog); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, + "registration of program (name:%s, prognum:%d, " + "progver:%d) failed", glusterfs3_3_fop_prog.progname, + glusterfs3_3_fop_prog.prognum, +@@ -1013,7 +1029,7 @@ init (xlator_t *this) + gluster_handshake_prog.options = this->options; + ret = rpcsvc_program_register (conf->rpc, &gluster_handshake_prog); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, + "registration of program (name:%s, prognum:%d, " + "progver:%d) failed", gluster_handshake_prog.progname, + gluster_handshake_prog.prognum, +@@ -1030,19 +1046,20 @@ init (xlator_t *this) + lim.rlim_max = 1048576; + + if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "WARNING: Failed to set 'ulimit -n 1M': %s", +- strerror(errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ PS_MSG_ULIMIT_SET_FAILED, "WARNING: Failed to " ++ "set 'ulimit -n 1M': %s", strerror(errno)); + lim.rlim_cur = 65536; + lim.rlim_max = 65536; + + if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "Failed to set max open fd to 64k: %s", ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ PS_MSG_FD_NOT_FOUND, "Failed to set " ++ "max open fd to 64k: %s", + strerror(errno)); + } else { +- gf_log (this->name, GF_LOG_TRACE, +- "max open fd set to 64k"); ++ gf_msg_trace (this->name, 0, "max open fd set " ++ "to 64k"); + } + } + } +-- +1.7.1 + diff --git a/SOURCES/0083-common-ha-cluster-HA-setup-sometimes-fails.patch b/SOURCES/0083-common-ha-cluster-HA-setup-sometimes-fails.patch new file mode 100644 index 0000000..0fa7171 --- /dev/null +++ b/SOURCES/0083-common-ha-cluster-HA-setup-sometimes-fails.patch @@ -0,0 +1,56 @@ +From c506658cf9ee9f00c1523190208e4fa77ea8b4b3 Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Mon, 15 Jun 2015 15:48:33 -0400 +Subject: [PATCH 083/101] common-ha: cluster HA setup sometimes fails + +the "s in the VIP_foo="x.x.x.x" lines are problematic now that the +config file isn't sourced. + +(A short term work-around is to simply eliminate them.) + +Change-Id: I3bd814abbf0e957af11bb4d9a3241445ab7b5ed6 +BUG: 1227311 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/50770 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + extras/ganesha/scripts/ganesha-ha.sh | 12 +++++++++--- + 1 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 9d73cf9..7c7e9c5 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -343,11 +343,14 @@ setup_create_resources() + + while [[ ${1} ]]; do + +- ipaddr=$(grep "^VIP_${1}=" ${HA_CONFDIR}/ganesha-ha.conf | cut -d = -f 2) ++ name="VIP_${1}" ++ nvs=$(grep "^${name}=" ${HA_CONFDIR}/ganesha-ha.conf) ++ eval ${nvs} ++ eval ipaddr=\$$name + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +- logger "warning pcs resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=10s failed" ++ logger "warning pcs resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s failed" + fi + + pcs -f ${cibfile} resource create ${1}-trigger_ip-1 ocf:heartbeat:Dummy +@@ -437,7 +440,10 @@ recreate_resources() + local cibfile=${1}; shift + + while [[ ${1} ]]; do +- ipaddr=$(grep "VIP_${1}=" ${HA_CONFDIR}/ganesha-ha.conf | cut -d = -f 2) ++ name="VIP_${1}" ++ nvs=$(grep "^${name}=" ${HA_CONFDIR}/ganesha-ha.conf) ++ eval ${nvs} ++ eval ipaddr=\$$name + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +-- +1.7.1 + diff --git a/SOURCES/0084-ec-Display-correct-message-after-successful-heal-sta.patch b/SOURCES/0084-ec-Display-correct-message-after-successful-heal-sta.patch new file mode 100644 index 0000000..5078dd1 --- /dev/null +++ b/SOURCES/0084-ec-Display-correct-message-after-successful-heal-sta.patch @@ -0,0 +1,43 @@ +From 4659ab64bf803f6dcef3fe93d2613d84ef62fa43 Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Wed, 17 Jun 2015 12:40:06 +0530 +Subject: [PATCH 084/101] ec: Display correct message after successful heal start + + Problem : While launching heal, it shows heal launch + was unsuccessful. However, internaly it was successfully + launched. + + Solution : Don't reset op_ret to -1 in for loop for + every brick. + Review link for master - + http://review.gluster.org/11267 + +Change-Id: Iff89fdaf6082767ed67523a56430a9e83e6984d3 +BUG: 1224137 +Signed-off-by: Ashish Pandey +Reviewed-on: https://code.engineering.redhat.com/gerrit/50892 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/ec/src/ec-heald.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c +index a7cf8f7..bfdf959 100644 +--- a/xlators/cluster/ec/src/ec-heald.c ++++ b/xlators/cluster/ec/src/ec-heald.c +@@ -541,10 +541,10 @@ ec_heal_op (xlator_t *this, dict_t *output, gf_xl_afr_op_t op, int xl_id) + + ec = this->private; + ++ op_ret = -1; + for (i = 0; i < ec->nodes; i++) { + snprintf (key, sizeof (key), "%d-%d-status", xl_id, i); + +- op_ret = -1; + if (((ec->xl_up >> i) & 1) == 0) { + ret = dict_set_str (output, key, "Brick is not connected"); + } else if (!ec->up) { +-- +1.7.1 + diff --git a/SOURCES/0085-cluster-ec-Prevent-races-in-ec_unlock-for-rename.patch b/SOURCES/0085-cluster-ec-Prevent-races-in-ec_unlock-for-rename.patch new file mode 100644 index 0000000..bef4f49 --- /dev/null +++ b/SOURCES/0085-cluster-ec-Prevent-races-in-ec_unlock-for-rename.patch @@ -0,0 +1,58 @@ +From dd36876008bd144a18fa43bde58ba09dd9c9506d Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 16 Jun 2015 22:59:17 +0530 +Subject: [PATCH 085/101] cluster/ec: Prevent races in ec_unlock for rename + + Backport of http://review.gluster.org/11261 + +If fop->lock_count > 1 then there is a chance that by the time +ec_unlock_timer_add() is called for the second lock epoll thread could +reply inodelk and jobs will be '0' leading to completion of state +machine and freeing of fop. So add sleep/resume. + +ec_lookup_rebuild already removes EC_XATTR_SIZE from xdata. So assign +link->size from buf->ia_size. + +BUG: 1231166 +Change-Id: Iea7ef6ad6fcd151deffaf2b7b1653eba35d777ab +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50992 +--- + xlators/cluster/ec/src/ec-common.c | 11 +++++++---- + 1 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index a158637..be69c57 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -1118,10 +1118,7 @@ int32_t ec_get_real_size_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + if (op_ret >= 0) { + link = fop->data; +- if (ec_dict_del_number(xdata, EC_XATTR_SIZE, &link->size) != 0) { +- gf_log(this->name, GF_LOG_WARNING, +- "Unable to determine real file size"); +- } ++ link->size = buf->ia_size; + } else { + /* Prevent failure of parent fop. */ + fop->error = 0; +@@ -1728,9 +1725,15 @@ void ec_unlock(ec_fop_data_t *fop) + { + int32_t i; + ++ /*If fop->lock_count > 1 then there is a chance that by the time ++ * ec_unlock_timer_add() is called for the second lock epoll thread could ++ * reply inodelk and jobs will be '0' leading to completion of state ++ * machine and freeing of fop. So add sleep/resume*/ ++ ec_sleep (fop); + for (i = 0; i < fop->lock_count; i++) { + ec_unlock_timer_add(&fop->locks[i]); + } ++ ec_resume (fop, 0); + } + + void +-- +1.7.1 + diff --git a/SOURCES/0086-glusterd-Porting-messages-to-new-logging-framework.patch b/SOURCES/0086-glusterd-Porting-messages-to-new-logging-framework.patch new file mode 100644 index 0000000..83b85c3 --- /dev/null +++ b/SOURCES/0086-glusterd-Porting-messages-to-new-logging-framework.patch @@ -0,0 +1,521 @@ +From 83c26b63c919d7adca81af98e31d343c0dae3c2c Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Mon, 9 Mar 2015 16:59:54 +0530 +Subject: [PATCH 086/101] glusterd: Porting messages to new logging framework + +cherry-picked from commit 2ae034374ce449c54b1b4ae8350401371db1d8d3 +>Change-Id: I56ced6fca0246c230cc389132c47a0f60472ed0c +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9836 +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: Atin Mukherjee + +Change-Id: I56ced6fca0246c230cc389132c47a0f60472ed0c +BUG: 1194640 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50893 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-hooks.h | 2 +- + xlators/mgmt/glusterd/src/glusterd-nfs-svc.c | 11 +++-- + xlators/mgmt/glusterd/src/glusterd-pmap.c | 7 ++- + xlators/mgmt/glusterd/src/glusterd-quotad-svc.c | 5 +- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 9 ++-- + xlators/mgmt/glusterd/src/glusterd-snapd-svc.c | 50 ++++++++++++++-------- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 1 + + xlators/mgmt/glusterd/src/glusterd-volgen.h | 8 +++- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 28 ++++++++----- + 9 files changed, 77 insertions(+), 44 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.h b/xlators/mgmt/glusterd/src/glusterd-hooks.h +index 1e99f34..85039ab 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-hooks.h ++++ b/xlators/mgmt/glusterd/src/glusterd-hooks.h +@@ -56,7 +56,7 @@ is_key_glusterd_hooks_friendly (char *key) + + /* This is very specific to hooks friendly behavior */ + if (fnmatch (GD_HOOKS_SPECIFIC_KEY, key, FNM_NOESCAPE) == 0) { +- gf_log (THIS->name, GF_LOG_DEBUG, "user namespace key %s", key); ++ gf_msg_debug (THIS->name, 0, "user namespace key %s", key); + is_friendly = _gf_true; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +index cb08a20..0c4d3c1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +@@ -14,6 +14,7 @@ + #include "glusterd-utils.h" + #include "glusterd-volgen.h" + #include "glusterd-nfs-svc.h" ++#include "glusterd-messages.h" + + char *nfs_svc_name = "nfs"; + +@@ -84,7 +85,8 @@ glusterd_nfssvc_check_volfile_identical (gf_boolean_t *identical) + + tmp_fd = mkstemp (tmpnfsvol); + if (tmp_fd < 0) { +- gf_log (this->name, GF_LOG_WARNING, "Unable to create temp file" ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to create temp file" + " %s:(%s)", tmpnfsvol, strerror (errno)); + goto out; + } +@@ -136,7 +138,8 @@ glusterd_nfssvc_check_topology_identical (gf_boolean_t *identical) + snprintf (tmpnfsvol, sizeof (tmpnfsvol), "/tmp/gnfs-XXXXXX"); + tmpfd = mkstemp (tmpnfsvol); + if (tmpfd < 0) { +- gf_log (this->name, GF_LOG_WARNING, "Unable to create temp file" ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to create temp file" + " %s: (%s)", tmpnfsvol, strerror (errno)); + goto out; + } +@@ -182,7 +185,7 @@ glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags) + goto out; + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -211,7 +214,7 @@ glusterd_nfssvc_stop (glusterd_svc_t *svc, int sig) + glusterd_nfs_pmap_deregister (); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c +index e4dacb8..fbdcfc8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c ++++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c +@@ -23,6 +23,7 @@ + #include "portmap-xdr.h" + #include "xdr-generic.h" + #include "protocol-common.h" ++#include "glusterd-messages.h" + #include "rpcsvc.h" + + #include +@@ -223,7 +224,8 @@ pmap_registry_bind (xlator_t *this, int port, const char *brickname, + pmap->ports[p].type = type; + pmap->ports[p].xprt = xprt; + +- gf_log ("pmap", GF_LOG_INFO, "adding brick %s on port %d", ++ gf_msg ("pmap", GF_LOG_INFO, 0, ++ GD_MSG_BRICK_ADD, "adding brick %s on port %d", + brickname, port); + + if (pmap->last_alloc < p) +@@ -267,7 +269,8 @@ pmap_registry_remove (xlator_t *this, int port, const char *brickname, + + goto out; + remove: +- gf_log ("pmap", GF_LOG_INFO, "removing brick %s on port %d", ++ gf_msg ("pmap", GF_LOG_INFO, 0, ++ GD_MSG_BRICK_REMOVE, "removing brick %s on port %d", + pmap->ports[p].brickname, p); + + free (pmap->ports[p].brickname); +diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +index bd77a72..37824f6 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +@@ -14,6 +14,7 @@ + #include "glusterd-utils.h" + #include "glusterd-volgen.h" + #include "glusterd-quotad-svc.h" ++#include "glusterd-messages.h" + + char *quotad_svc_name = "quotad"; + +@@ -94,7 +95,7 @@ glusterd_quotadsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -134,7 +135,7 @@ out: + if (cmdline) + dict_unref (cmdline); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index dd85d1e..49454cc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -61,14 +61,15 @@ glusterd_shdsvc_create_volfile () + ret = glusterd_create_global_volfile (build_shd_graph, filepath, + mod_dict); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create volfile"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volfile"); + goto out; + } + + out: + if (mod_dict) + dict_unref (mod_dict); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -116,7 +117,7 @@ glusterd_shdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -154,7 +155,7 @@ out: + if (cmdline) + dict_unref (cmdline); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +index 7e63929..757c7f6 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +@@ -92,7 +92,8 @@ glusterd_snapdsvc_init (void *data) + sizeof (logdir)); + ret = mkdir_p (logdir, 0755, _gf_true); + if ((ret == -1) && (EEXIST != errno)) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to create logdir %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Unable to create logdir %s", + logdir); + goto out; + } +@@ -109,7 +110,7 @@ glusterd_snapdsvc_init (void *data) + goto out; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -124,7 +125,8 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + + ret = glusterd_is_snapd_enabled (volinfo); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to read volume " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "Failed to read volume " + "options"); + goto out; + } +@@ -134,7 +136,8 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + if (glusterd_proc_is_running (&svc->proc)) { + ret = svc->stop (svc, SIGTERM); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_STOP_FAIL, + "Couldn't stop snapd for " + "volume: %s", + volinfo->volname); +@@ -147,7 +150,8 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + + ret = glusterd_snapdsvc_create_volfile (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Couldn't create " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_CREATE_FAIL, "Couldn't create " + "snapd volfile for volume: %s", + volinfo->volname); + goto out; +@@ -155,7 +159,8 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + + ret = svc->start (svc, flags); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Couldn't start " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_START_FAIL, "Couldn't start " + "snapd for volume: %s", volinfo->volname); + goto out; + } +@@ -170,7 +175,8 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } else if (glusterd_proc_is_running (&svc->proc)) { + ret = svc->stop (svc, SIGTERM); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_STOP_FAIL, + "Couldn't stop snapd for volume: %s", + volinfo->volname); + goto out; +@@ -179,7 +185,7 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -212,7 +218,8 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags) + /* Get volinfo->snapd from svc object */ + snapd = cds_list_entry (svc, glusterd_snapdsvc_t, svc); + if (!snapd) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get snapd object " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_OBJ_GET_FAIL, "Failed to get snapd object " + "from snapd service"); + goto out; + } +@@ -220,14 +227,16 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags) + /* Get volinfo from snapd */ + volinfo = cds_list_entry (snapd, glusterd_volinfo_t, snapd); + if (!volinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo from " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "Failed to get volinfo from " + "from snapd"); + goto out; + } + + ret = access (svc->proc.volfile, F_OK); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg (this->name, GF_LOG_DEBUG, 0, ++ GD_MSG_VOLINFO_GET_FAIL, + "snapd Volfile %s is not present", svc->proc.volfile); + /* If glusterd is down on one of the nodes and during + * that time "USS is enabled" for the first time. After some +@@ -239,7 +248,8 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags) + */ + ret = glusterd_snapdsvc_create_volfile (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Couldn't create " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Couldn't create " + "snapd volfile for volume: %s", + volinfo->volname); + goto out; +@@ -325,7 +335,8 @@ glusterd_snapdsvc_restart () + svc = &(volinfo->snapd.svc); + ret = svc->start (svc, PROC_START_NO_WAIT); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_START_FAIL, + "Couldn't start snapd for " + "vol: %s", volinfo->volname); + goto out; +@@ -350,13 +361,14 @@ glusterd_snapdsvc_rpc_notify (glusterd_conn_t *conn, rpc_clnt_event_t event) + + svc = cds_list_entry (conn, glusterd_svc_t, conn); + if (!svc) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get the service"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SVC_GET_FAIL, "Failed to get the service"); + return -1; + } + + switch (event) { + case RPC_CLNT_CONNECT: +- gf_log (this->name, GF_LOG_DEBUG, "%s has connected with " ++ gf_msg_debug (this->name, 0, "%s has connected with " + "glusterd.", svc->name); + svc->online = _gf_true; + break; +@@ -373,21 +385,23 @@ glusterd_snapdsvc_rpc_notify (glusterd_conn_t *conn, rpc_clnt_event_t event) + case RPC_CLNT_DESTROY: + snapd = cds_list_entry (svc, glusterd_snapdsvc_t, svc); + if (!snapd) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get the " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_OBJ_GET_FAIL, "Failed to get the " + "snapd object"); + return -1; + } + + volinfo = cds_list_entry (snapd, glusterd_volinfo_t, snapd); + if (!volinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get the " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "Failed to get the " + "volinfo object"); + return -1; + } + glusterd_volinfo_unref (volinfo); + + default: +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "got some other RPC event %d", event); + break; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index fc8b769..9c09c78 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -32,6 +32,7 @@ + #include "glusterd-volgen.h" + #include "glusterd-geo-rep.h" + #include "glusterd-utils.h" ++#include "glusterd-messages.h" + #include "run.h" + #include "options.h" + #include "glusterd-snapshot-utils.h" +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h +index 571a13c..cdeaea4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h +@@ -21,6 +21,7 @@ + #endif + + #include "glusterd.h" ++#include "glusterd-messages.h" + + /* volopt map key name definitions */ + +@@ -64,12 +65,15 @@ typedef struct volgen_graph volgen_graph_t; + if (!strchr (key, '.')) { \ + ret = option_complete (key, &completion); \ + if (ret) { \ +- gf_log ("", GF_LOG_ERROR, "Out of memory"); \ ++ gf_msg ("", GF_LOG_ERROR, ENOMEM, \ ++ GD_MSG_NO_MEMORY, "Out of memory"); \ + return _gf_false; \ + } \ + \ + if (!completion) { \ +- gf_log ("", GF_LOG_ERROR, "option %s does not" \ ++ gf_msg ("", GF_LOG_ERROR, 0, \ ++ GD_MSG_INVALID_ENTRY, \ ++ "option %s does not" \ + "exist", key); \ + return _gf_false; \ + } \ +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 39bf82f..624e577 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -61,14 +61,15 @@ validate_cache_max_min_size (glusterd_volinfo_t *volinfo, dict_t *dict, + "cache-min-file-size (%s) is greater than " + "cache-max-file-size (%s)", + current_min_value, current_max_value); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CACHE_MINMAX_SIZE_INVALID, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -118,7 +119,8 @@ validate_quota (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + + ret = glusterd_volinfo_get_boolean (volinfo, VKEY_FEATURES_QUOTA); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_GET_STAT_FAIL, + "failed to get the quota status"); + goto out; + } +@@ -126,7 +128,8 @@ validate_quota (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + if (ret == _gf_false) { + snprintf (errstr, sizeof (errstr), + "Cannot set %s. Enable quota first.", key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_DISABLED, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; +@@ -134,7 +137,7 @@ validate_quota (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + + ret = 0; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -156,12 +159,13 @@ validate_uss (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + snprintf (errstr, sizeof (errstr), "%s is not a valid boolean " + "value. %s expects a valid boolean value.", value, + key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "%s", errstr); + *op_errstr = gf_strdup (errstr); + goto out; + } + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -183,14 +187,15 @@ validate_stripe (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + if (volinfo->stripe_count == 1) { + snprintf (errstr, sizeof (errstr), + "Cannot set %s for a non-stripe volume.", key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NON_STRIPE_VOL, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -219,7 +224,8 @@ validate_subvols_per_directory (glusterd_volinfo_t *volinfo, dict_t *dict, + "subvols-per-directory(%d) is greater " + "than the number of subvolumes(%d).", + subvols, volinfo->subvol_count); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SUBVOLUMES_EXCEED, + "%s.", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; +@@ -227,7 +233,7 @@ validate_subvols_per_directory (glusterd_volinfo_t *volinfo, dict_t *dict, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +-- +1.7.1 + diff --git a/SOURCES/0087-sm-glusterd-Porting-messages-to-new-logging-framewor.patch b/SOURCES/0087-sm-glusterd-Porting-messages-to-new-logging-framewor.patch new file mode 100644 index 0000000..9aba9b3 --- /dev/null +++ b/SOURCES/0087-sm-glusterd-Porting-messages-to-new-logging-framewor.patch @@ -0,0 +1,2744 @@ +From 0cbf7b0fadc426fe877b4926cba851069cc48ead Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Wed, 18 Mar 2015 15:17:45 +0530 +Subject: [PATCH 087/101] sm/glusterd: Porting messages to new logging framework + +Backport of http://review.gluster.org/#/c/9927/ + +(cherry picked from commit 72a7a6ea78289b2897f9846dc4e111f442dd2788) +>Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950 +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9927 +>Reviewed-by: Atin Mukherjee +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: Krishnan Parthasarathi + +Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950 +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50890 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 711 ++++++++++++++++++---------- + xlators/mgmt/glusterd/src/glusterd-sm.c | 107 +++-- + 2 files changed, 524 insertions(+), 294 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 6cf200d..8fca680 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -205,12 +205,13 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id) + ret = dict_set_bin (dict, "transaction_id", + *txn_id, sizeof (**txn_id)); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set transaction id."); + goto out; + } + +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Transaction_id = %s", uuid_utoa (**txn_id)); + out: + if (ret && *txn_id) { +@@ -254,13 +255,13 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + + (*opinfo) = opinfo_obj->opinfo; + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Successfully got opinfo for transaction ID : %s", + uuid_utoa (*txn_id)); + + ret = 0; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -308,7 +309,7 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + + opinfo_obj->opinfo = (*opinfo); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Successfully set opinfo for transaction ID : %s", + uuid_utoa (*txn_id)); + ret = 0; +@@ -317,7 +318,7 @@ out: + if (opinfo_obj) + GF_FREE (opinfo_obj); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -335,14 +336,18 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id) + GF_ASSERT (priv); + + if (!txn_id) { +- gf_log ("", GF_LOG_ERROR, "Empty transaction id received."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, ++ "Empty transaction id received."); + ret = -1; + goto out; + } + + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Transaction opinfo not found"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Transaction opinfo not found"); + goto out; + } + +@@ -351,13 +356,13 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id) + + dict_del(priv->glusterd_txn_opinfo, uuid_utoa (*txn_id)); + +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Successfully cleared opinfo for transaction ID : %s", + uuid_utoa (*txn_id)); + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -438,7 +443,7 @@ glusterd_op_sm_inject_all_acc (uuid_t *txn_id) + { + int32_t ret = -1; + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, txn_id, NULL); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -627,7 +632,7 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin + out: + if (ret && brick_req) + GF_FREE (brick_req); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -681,7 +686,7 @@ glusterd_node_op_build_payload (glusterd_op_t op, gd1_mgmt_brick_op_req **req, + out: + if (ret && brick_req) + GF_FREE (brick_req); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -831,7 +836,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + ret = dict_get_uint32 (dict, "new-op-version", + &new_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get new_op_version"); + goto out; + } +@@ -842,7 +848,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + snprintf (errstr, sizeof (errstr), + "Required op_version (%d) is not " + "supported", new_op_version); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNSUPPORTED_VERSION, "%s", ++ errstr); + goto out; + } + } +@@ -850,7 +858,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "count", &dict_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Count(dict),not set in Volume-Set"); + goto out; + } +@@ -868,14 +877,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + goto out; + #else + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_INSTALLED, + "libxml not present in the system"); + *op_errstr = gf_strdup ("Error: xml libraries not " + "present to produce xml-output"); + goto out; + #endif + } +- gf_log (this->name, GF_LOG_ERROR, "No options received "); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_OPTIONS_GIVEN, "No options received "); + *op_errstr = gf_strdup ("Options not specified"); + ret = -1; + goto out; +@@ -883,7 +894,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get volume name"); + goto out; + } + +@@ -892,14 +905,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + if (!exists) { + snprintf (errstr, sizeof (errstr), + FMTSTR_CHECK_VOL_EXISTS, volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", errstr); + ret = -1; + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, + FMTSTR_CHECK_VOL_EXISTS, volname); + goto out; + } +@@ -923,21 +938,22 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + sprintf (str, "value%d", count); + ret = dict_get_str (dict, str, &value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "invalid key,value pair in 'volume set'"); + ret = -1; + goto out; + } + + if (strcmp (key, "config.memory-accounting") == 0) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "enabling memory accounting for volume %s", + volname); + ret = 0; + } + + if (strcmp (key, "config.transport") == 0) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "changing transport-type for volume %s", + volname); + ret = 0; +@@ -975,7 +991,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + } + + if (!exists) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, + "Option with name: %s does not exist", key); + ret = snprintf (errstr, sizeof (errstr), + "option : %s does not exist", +@@ -1019,7 +1036,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + snprintf (errstr, sizeof (errstr), "invalid " + "number format \"%s\" in option " + "\"%s\"", value, key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + +@@ -1029,7 +1047,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + snprintf (errstr, sizeof (errstr), + "Required op_version (%d) is not " + "supported", local_key_op_version); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERSION_UNSUPPORTED, ++ "%s", errstr); + goto out; + } + if (local_key_op_version > local_new_op_version) +@@ -1051,14 +1071,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + if (origin_glusterd) { + ret = dict_set_uint32 (dict, str, local_key_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set key-op-version in dict"); + goto out; + } + } else if (check_op_version) { + ret = dict_get_uint32 (dict, str, &key_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get key-op-version from" + " dict"); + goto out; +@@ -1068,7 +1090,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + snprintf (errstr, sizeof (errstr), + "option: %s op-version mismatch", + key); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERSION_MISMATCH, + "%s, required op-version = %"PRIu32", " + "available op-version = %"PRIu32, + errstr, key_op_version, +@@ -1103,7 +1126,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + if (strchr (value, '/')) { + snprintf (errstr, sizeof (errstr), + "Path is not allowed as option"); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_SET_FAIL, + "Unable to set the options in 'volume " + "set': %s", errstr); + ret = -1; +@@ -1126,17 +1150,24 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + /* Checks whether a directory with + given option exists or not */ + if (!stat(trash_path, &stbuf)) { +- snprintf (errstr, sizeof (errstr), +- "Path %s exists", value); +- gf_log (this->name, GF_LOG_ERROR, +- "Unable to set the options in " +- "'volume set': %s", errstr); ++ snprintf (errstr, ++ sizeof (errstr), ++ "Path %s exists", ++ value); ++ gf_msg (this->name, ++ GF_LOG_ERROR, ++ 0, GD_MSG_VOL_SET_FAIL, ++ "Unable to set the " ++ "options in " ++ "'volume set': %s", ++ errstr); + ret = -1; + goto out; + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "Directory with given name " +- "does not exists, continuing"); ++ gf_msg_debug (this->name, 0, ++ "Directory with given " ++ "name does not exists," ++ " continuing"); + } + + if (volinfo->status == GLUSTERD_STATUS_STARTED +@@ -1145,9 +1176,13 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + whether bricks are online */ + snprintf (errstr, sizeof (errstr), + "One or more bricks are down"); +- gf_log (this->name, GF_LOG_ERROR, +- "Unable to set the options in " +- "'volume set': %s", errstr); ++ gf_msg (this->name, ++ GF_LOG_ERROR, 0, ++ GD_MSG_VOL_SET_FAIL, ++ "Unable to set the " ++ "options in " ++ "'volume set': %s", ++ errstr); + ret = -1; + goto out; + } +@@ -1162,7 +1197,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + snprintf (errstr, sizeof (errstr), + "Trash translator is not enabled. Use " + "volume set %s trash on", volname); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_SET_FAIL, + "Unable to set the options in 'volume " + "set': %s", errstr); + ret = -1; +@@ -1171,7 +1207,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + ret = dict_set_str (val_dict, key, value); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to set the options in 'volume set'"); + ret = -1; + goto out; +@@ -1193,7 +1230,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + } + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Could not create " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, ++ "Could not create " + "temp volfile, some option failed: %s", + *op_errstr); + goto out; +@@ -1218,7 +1257,8 @@ cont: + ret = dict_set_uint32 (dict, "new-op-version", + local_new_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set new-op-version in dict"); + goto out; + } +@@ -1231,7 +1271,8 @@ cont: + ret = dict_set_uint32 (dict, "check-op-version", + _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set check-op-version in dict"); + goto out; + } +@@ -1253,11 +1294,11 @@ out: + if (ret) { + if (!(*op_errstr)) { + *op_errstr = gf_strdup ("Error, Validation Failed"); +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Error, Cannot Validate option :%s", + *op_errstr); + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Error, Cannot Validate option"); + } + } +@@ -1282,7 +1323,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1308,7 +1350,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "key", &key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get option key"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get option key"); + goto out; + } + if (strcmp(key, "all")) { +@@ -1342,7 +1385,7 @@ out: + *op_errstr = gf_strdup (msg); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1408,7 +1451,7 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr) + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -1464,7 +1507,8 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1574,7 +1618,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) + *op_errstr = gf_strdup ("Validation Failed for Status"); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning: %d", ret); ++ gf_msg_debug (this->name, 0, "Returning: %d", ret); + return ret; + } + +@@ -1659,7 +1703,8 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr) + if (_gf_false == glusterd_is_volume_started (volinfo)) { + snprintf (msg, sizeof (msg), "Volume %s is not started.", + volinfo->volname); +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", msg); + ret = -1; + goto out; + } +@@ -1670,7 +1715,7 @@ out: + gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + } +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1696,7 +1741,7 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data) + } + } + +- gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s", ++ gf_msg_debug ("glusterd", 0, "deleting dict with key=%s,value=%s", + key, value->data); + dict_del (this, key); + /**Delete scrubber (pause/resume) option from the dictionary if bitrot +@@ -1753,7 +1798,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + } else { + value = dict_get (volinfo->dict, key); + if (!value) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "no value set for option %s", key); + goto out; + } +@@ -1772,7 +1817,9 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to create volfile for" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, ++ "Unable to create volfile for" + " 'volume reset'"); + ret = -1; + goto out; +@@ -1792,7 +1839,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + + out: + GF_FREE (key_fixed); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1814,7 +1861,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) + conf = this->private; + ret = dict_get_str (dict, "key", &key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get key"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get key"); + goto out; + } + +@@ -1825,7 +1873,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) + if (strcmp (key, "all")) { + ret = glusterd_check_option_exists (key, &key_fixed); + if (ret <= 0) { +- gf_log (this->name, GF_LOG_ERROR, "Option %s does not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "Option %s does not " + "exist", key); + ret = -1; + goto out; +@@ -1891,7 +1940,7 @@ out: + if (dup_opt) + dict_unref (dup_opt); + +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + if (quorum_action) + glusterd_do_quorum_action (); + GF_FREE (next_version); +@@ -1913,7 +1962,8 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) + this = THIS; + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name" ); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1928,20 +1978,23 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) + + ret = dict_get_str (dict, "key", &key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get option key"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get option key"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } + + if (strcmp (key, "all") && + glusterd_check_option_exists (key, &key_fixed) != 1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, + "volinfo dict inconsistency: option %s not found", + key); + ret = -1; +@@ -1982,7 +2035,7 @@ out: + if (quorum_action) + glusterd_do_quorum_action (); + +- gf_log (this->name, GF_LOG_DEBUG, "'volume reset' returning %d", ret); ++ gf_msg_debug (this->name, 0, "'volume reset' returning %d", ret); + return ret; + } + +@@ -2012,7 +2065,8 @@ glusterd_start_bricks (glusterd_volinfo_t *volinfo) + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + ret = glusterd_brick_start (volinfo, brickinfo, _gf_false); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_DISCONNECTED, + "Failed to start %s:%s for %s", + brickinfo->hostname, brickinfo->path, + volinfo->volname); +@@ -2047,14 +2101,16 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, + + ret = dict_get_str (dict, "value1", &value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "invalid key,value pair in 'volume set'"); + goto out; + } + + ret = glusterd_check_option_exists (key, &key_fixed); + if (ret <= 0) { +- gf_log (this->name, GF_LOG_ERROR, "Invalid key %s", key); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNKNOWN_KEY, "Invalid key %s", key); + ret = -1; + goto out; + } +@@ -2083,7 +2139,8 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, + conf->op_version = op_version; + ret = glusterd_store_global_info (this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERS_STORE_FAIL, + "Failed to store op-version."); + } + } +@@ -2139,7 +2196,7 @@ out: + if (dup_opt) + dict_unref (dup_opt); + +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + if (quorum_action) + glusterd_do_quorum_action (); + GF_FREE (next_version); +@@ -2253,14 +2310,17 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + + ret = dict_get_int32 (dict, "count", &dict_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Count(dict),not set in Volume-Set"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Count(dict),not set in Volume-Set"); + goto out; + } + + if (dict_count == 0) { + ret = glusterd_volset_help (NULL, &op_errstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_SET_FAIL, "%s", + (op_errstr)? op_errstr: + "Volume set help internal error"); + } +@@ -2271,7 +2331,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -2283,7 +2344,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -2295,7 +2357,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + if (check_op_version) { + ret = dict_get_uint32 (dict, "new-op-version", &new_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get new op-version from dict"); + goto out; + } +@@ -2311,7 +2374,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + sprintf (str, "value%d", count); + ret = dict_get_str (dict, str, &value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "invalid key,value pair in 'volume set'"); + ret = -1; + goto out; +@@ -2363,7 +2427,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + value = gf_strdup (value); + + if (!value) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_SET_FAIL, + "Unable to set the options in 'volume set'"); + ret = -1; + goto out; +@@ -2397,7 +2462,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + } + + if (count == 1) { +- gf_log (this->name, GF_LOG_ERROR, "No options received "); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_OPTIONS_GIVEN, "No options received "); + ret = -1; + goto out; + } +@@ -2409,7 +2475,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + priv->op_version = new_op_version; + ret = glusterd_store_global_info (this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERS_STORE_FAIL, + "Failed to store op-version"); + goto out; + } +@@ -2425,7 +2492,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + } + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Unable to create volfile for" + " 'volume set'"); + ret = -1; +@@ -2439,7 +2507,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + if (GLUSTERD_STATUS_STARTED == volinfo->status) { + ret = glusterd_svcs_reconfigure (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SVC_RESTART_FAIL, + "Unable to restart services"); + goto out; + } +@@ -2460,7 +2529,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Unable to create volfile for" + " 'volume set'"); + ret = -1; +@@ -2475,7 +2545,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + if (GLUSTERD_STATUS_STARTED == volinfo->status) { + ret = glusterd_svcs_reconfigure (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_NFS_SERVER_START_FAIL, + "Unable to restart NFS-Server"); + goto out; + } +@@ -2485,7 +2556,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + + out: + GF_FREE (key_fixed); +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + if (quorum_action) + glusterd_do_quorum_action (); + return ret; +@@ -2529,7 +2600,8 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr, + if (!ret) { + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Volume with name: %s " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "Volume with name: %s " + "not exists", volname); + goto out; + } +@@ -2558,7 +2630,7 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr, + ret = dict_set_int32 (rsp_dict, "count", vol_count); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -2577,7 +2649,8 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo) + + ret = dict_set_str (volinfo->dict, latency_key, "on"); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "failed to set the volume %s " + "option %s value %s", + volinfo->volname, latency_key, "on"); + goto out; +@@ -2585,13 +2658,14 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo) + + ret = dict_set_str (volinfo->dict, fd_stats_key, "on"); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "failed to set the volume %s " + "option %s value %s", + volinfo->volname, fd_stats_key, "on"); + goto out; + } + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -2621,7 +2695,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume name get failed"); + goto out; + } + +@@ -2630,13 +2705,15 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + snprintf (msg, sizeof (msg), "Volume %s does not exists", + volname); + +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + goto out; + } + + ret = dict_get_int32 (dict, "op", &stats_op); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume profile op get failed"); + goto out; + } + +@@ -2658,7 +2735,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + break; + default: + GF_ASSERT (0); +- gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "Invalid profile op: %d", + stats_op); + ret = -1; + goto out; +@@ -2667,8 +2745,10 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + ret = glusterd_create_volfiles_and_notify_services (volinfo); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to create volfile for" +- " 'volume set'"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, ++ "Unable to create volfile for" ++ " 'volume set'"); + ret = -1; + goto out; + } +@@ -2684,7 +2764,7 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + ret = 0; + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -2710,7 +2790,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = dict_get_int32 (volinfo->rebal.dict, "count", &count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get brick count"); + goto out; + } +@@ -2718,7 +2799,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, + snprintf (dict_key, sizeof (dict_key), "%s.count", prefix); + ret = dict_set_int32 (dict, dict_key, count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set brick count in dict"); + goto out; + } +@@ -2729,7 +2811,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = dict_get_str (volinfo->rebal.dict, brick_key, &brick); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get %s", brick_key); + goto out; + } +@@ -2739,7 +2822,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, + brick_key); + ret = dict_set_str (dict, dict_key, brick); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to add brick to dict"); + goto out; + } +@@ -2774,7 +2858,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) + snprintf (key, sizeof (key), "task%d", index); + ret = _add_remove_bricks_to_dict (dict, volinfo, key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_ADD_REMOVE_BRICK_FAIL, + "Failed to add remove bricks to dict"); + goto out; + } +@@ -2785,7 +2870,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) + + default: + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "%s operation doesn't have a" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_TASK_ID, "%s operation doesn't have a" + " task_id", gd_op_list[op]); + goto out; + } +@@ -2793,7 +2879,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) + snprintf (key, sizeof (key), "task%d.type", index); + ret = dict_set_str (dict, key, (char *)gd_op_list[op]); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting task type in dict"); + goto out; + } +@@ -2805,7 +2892,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) + goto out; + ret = dict_set_dynstr (dict, key, uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting task id in dict"); + goto out; + } +@@ -2815,7 +2903,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) + snprintf (key, sizeof (key), "task%d.status", index); + ret = dict_set_int32 (dict, key, status); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting task status in dict"); + goto out; + } +@@ -2840,7 +2929,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo) + ret = _add_task_to_dict (rsp_dict, volinfo, volinfo->rebal.op, + tasks); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to add task details to dict"); + goto out; + } +@@ -2849,7 +2939,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo) + + ret = dict_set_int32 (rsp_dict, "tasks", tasks); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting tasks count in dict"); + goto out; + } +@@ -2901,7 +2992,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + if ((cmd & GF_CLI_STATUS_ALL)) { + ret = glusterd_get_all_volnames (rsp_dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAMES_GET_FAIL, + "failed to get all volume " + "names for status"); + } +@@ -2920,7 +3012,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Volume with name: %s " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "Volume with name: %s " + "does not exist", volname); + goto out; + } +@@ -3114,19 +3207,22 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + + ret = dict_set_int32 (rsp_dict, "brick-index-max", brick_index); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting brick-index-max to dict"); + goto out; + } + ret = dict_set_int32 (rsp_dict, "other-count", other_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting other-count to dict"); + goto out; + } + ret = dict_set_int32 (rsp_dict, "count", node_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting node count to dict"); + goto out; + } +@@ -3144,7 +3240,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, + ret = 0; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -3154,7 +3250,7 @@ glusterd_op_ac_none (glusterd_op_sm_event_t *event, void *ctx) + { + int ret = 0; + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -3210,7 +3306,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) + ret = proc->fn (NULL, this, peerinfo); + if (ret) { + rcu_read_unlock (); +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_LOCK_REQ_SEND_FAIL, + "Failed to send lock request " + "for operation 'Volume %s' to " + "peer %s", +@@ -3233,7 +3330,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) + peerinfo); + if (ret) { + rcu_read_unlock (); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set peerinfo"); + dict_unref (dict); + goto out; +@@ -3242,7 +3340,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) + ret = proc->fn (NULL, this, dict); + if (ret) { + rcu_read_unlock (); +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_MGMTV3_LOCK_REQ_SEND_FAIL, + "Failed to send mgmt_v3 lock " + "request for operation " + "'Volume %s' to peer %s", +@@ -3267,7 +3366,7 @@ out: + if (ret) + ret = glusterd_op_sm_locking_failed (&event->txn_id); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3370,7 +3469,7 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx) + if (!opinfo.pending_count) + ret = glusterd_op_sm_inject_all_acc (&event->txn_id); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3386,7 +3485,7 @@ glusterd_op_ac_ack_drain (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACK, + &event->txn_id, NULL); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -3426,13 +3525,15 @@ glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx) + } else { + ret = dict_get_str (lock_ctx->dict, "volname", &volname); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to acquire volname"); + else { + ret = glusterd_mgmt_v3_lock (volname, lock_ctx->uuid, + &op_errno, "vol"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Unable to acquire lock for %s", + volname); + goto out; +@@ -3454,7 +3555,7 @@ out: + dict_unref (lock_ctx->dict); + } + +- gf_log (THIS->name, GF_LOG_DEBUG, "Lock Returned %d", ret); ++ gf_msg_debug (THIS->name, 0, "Lock Returned %d", ret); + return ret; + } + +@@ -3486,13 +3587,15 @@ glusterd_op_ac_unlock (glusterd_op_sm_event_t *event, void *ctx) + } else { + ret = dict_get_str (lock_ctx->dict, "volname", &volname); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to acquire volname"); + else { + ret = glusterd_mgmt_v3_unlock (volname, lock_ctx->uuid, + "vol"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Unable to release lock for %s", + volname); + goto out; +@@ -3515,7 +3618,7 @@ out: + dict_unref (lock_ctx->dict); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Unlock Returned %d", ret); ++ gf_msg_debug (this->name, 0, "Unlock Returned %d", ret); + + if (priv->pending_quorum_action) + glusterd_do_quorum_action (); +@@ -3535,7 +3638,7 @@ glusterd_op_ac_local_unlock (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_unlock (*originator); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Unlock Returned %d", ret); ++ gf_msg_debug (THIS->name, 0, "Unlock Returned %d", ret); + + return ret; + } +@@ -3556,7 +3659,7 @@ glusterd_op_ac_rcvd_lock_acc (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, + &event->txn_id, NULL); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + out: + return ret; +@@ -3658,7 +3761,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + op = glusterd_op_get_op (); + ctx = (void*)glusterd_op_get_ctx (); + if (!ctx) { +- gf_log (this->name, GF_LOG_ERROR, "Null Context for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_OPTIONS_GIVEN, "Null Context for " + "op %d", op); + ret = -1; + goto out; +@@ -3668,7 +3772,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + #define GD_SYNC_OPCODE_KEY "sync-mgmt-operation" + ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY, (int32_t*)&op); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volume" + " operation"); + goto out; + } +@@ -3684,7 +3789,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + ret = dict_set_int32 (dict, "port", + glusterfs_port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set port in " + "dictionary"); + goto out; +@@ -3714,7 +3820,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + { + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_DICT_GET_FAILED, + "volname is not present in " + "operation ctx"); + goto out; +@@ -3737,7 +3844,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + dict_t *dict = ctx; + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_DICT_GET_FAILED, + "volname is not present in " + "operation ctx"); + goto out; +@@ -3762,7 +3870,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + ret = dict_get_uint32 (dict, "cmd", + &status_cmd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Status command not present " + "in op ctx"); + goto out; +@@ -3875,14 +3984,18 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + + rsp_dict = dict_new(); + if (!rsp_dict) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create rsp_dict"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_DICT_CREATE_FAIL, ++ "Failed to create rsp_dict"); + ret = -1; + goto out; + } + + ret = glusterd_op_build_payload (&dict, &op_errstr, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, ++ LOGSTR_BUILD_PAYLOAD, + gd_op_list[op]); + if (op_errstr == NULL) + gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); +@@ -3901,7 +4014,8 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_op_stage_validate (op, dict, &op_errstr, rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_STAGE_FAIL, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VALIDATE_FAILED, LOGSTR_STAGE_FAIL, + gd_op_list[op], "localhost", + (op_errstr) ? ":" : " ", (op_errstr) ? op_errstr : " "); + if (op_errstr == NULL) +@@ -3934,14 +4048,16 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + ret = dict_set_static_ptr (dict, "peerinfo", peerinfo); + if (ret) { + rcu_read_unlock (); +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "failed to " + "set peerinfo"); + goto out; + } + + ret = proc->fn (NULL, this, dict); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_STAGE_REQ_SEND_FAIL, "Failed to " + "send stage request for operation " + "'Volume %s' to peer %s", + gd_op_list[op], peerinfo->hostname); +@@ -3965,14 +4081,14 @@ out: + opinfo.op_ret = ret; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Sent stage op request for " ++ gf_msg_debug (this->name, 0, "Sent stage op request for " + "'Volume %s' to %d peers", gd_op_list[op], + opinfo.pending_count); + + if (!opinfo.pending_count) + ret = glusterd_op_sm_inject_all_acc (&event->txn_id); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + +@@ -4006,7 +4122,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, + if (ret) + continue; + +- gf_log (this->name, GF_LOG_DEBUG, "Got uuid %s", ++ gf_msg_debug (this->name, 0, "Got uuid %s", + uuid_str); + + ret = gf_uuid_parse (uuid_str, uuid); +@@ -4018,11 +4134,12 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, + + hostname = glusterd_uuid_to_hostname (uuid); + if (hostname) { +- gf_log (this->name, GF_LOG_DEBUG, "%s -> %s", ++ gf_msg_debug (this->name, 0, "%s -> %s", + uuid_str, hostname); + ret = dict_set_dynstr (dict, key, hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting hostname %s to dict", + hostname); + GF_FREE (hostname); +@@ -4032,7 +4149,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4066,7 +4183,8 @@ reassign_defrag_status (dict_t *dict, char *key, gf_defrag_status_t *status) + + ret = dict_set_int32(dict, key, *status); + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to reset defrag %s in dict", key); + + return ret; +@@ -4088,13 +4206,15 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, "Unable to get volume name"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -4111,7 +4231,8 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count) + snprintf (key, 256, "status-%d", i); + ret = dict_get_int32 (dict, key, (int32_t *)&status); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, + "failed to get defrag %s", key); + goto out; + } +@@ -4224,7 +4345,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + op_ctx = glusterd_op_get_ctx(); + + if (!op_ctx) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_OPCTX_NULL, + "Operation context is not present."); + goto out; + } +@@ -4233,13 +4355,13 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + case GD_OP_STATUS_VOLUME: + ret = dict_get_uint32 (op_ctx, "cmd", &cmd); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to get status cmd"); + goto out; + } + + if (!glusterd_is_volume_status_modify_op_ctx (cmd)) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "op_ctx modification not required for status " + "operation being performed"); + goto out; +@@ -4248,14 +4370,14 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + ret = dict_get_int32 (op_ctx, "brick-index-max", + &brick_index_max); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to get brick-index-max"); + goto out; + } + + ret = dict_get_int32 (op_ctx, "other-count", &other_count); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to get other-count"); + goto out; + } +@@ -4297,7 +4419,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + "brick%d.peerid", i); + uuid = gf_strdup (uuid_str); + if (!uuid) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "unable to create dup of" + " uuid_str"); + continue; +@@ -4315,7 +4437,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + "brick%d.path", + 0, count); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_CONVERSION_FAILED, + "Failed uuid to hostname conversion"); + + break; +@@ -4327,7 +4450,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + + ret = dict_get_int32 (op_ctx, "count", &count); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to get brick count"); + goto out; + } +@@ -4336,7 +4459,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + "%d-brick", + 1, (count + 1)); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_CONVERSION_FAILED, + "Failed uuid to hostname conversion"); + + break; +@@ -4347,7 +4471,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + case GD_OP_DEFRAG_BRICK_VOLUME: + ret = dict_get_int32 (op_ctx, "count", &count); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to get count"); + goto out; + } +@@ -4370,7 +4494,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + "node-name-%d", i); + uuid = gf_strdup (uuid_str); + if (!uuid) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "unable to create dup of" + " uuid_str"); + continue; +@@ -4388,18 +4512,20 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + "node-name-%d", + 1, (count + 1)); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_CONVERSION_FAILED, + "Failed uuid to hostname conversion"); + + ret = glusterd_op_check_peer_defrag_status (op_ctx, count); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DEFRAG_STATUS_UPDATE_FAIL, + "Failed to reset defrag status for fix-layout"); + break; + + default: + ret = 0; +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "op_ctx modification not required"); + break; + +@@ -4407,7 +4533,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) + + out: + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_OPCTX_UPDATE_FAIL, + "op_ctx modification failed"); + return; + } +@@ -4487,7 +4614,9 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_op_build_payload (&dict, &op_errstr, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, ++ LOGSTR_BUILD_PAYLOAD, + gd_op_list[op]); + if (op_errstr == NULL) + gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); +@@ -4497,7 +4626,8 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_op_commit_perform (op, dict, &op_errstr, NULL); //rsp_dict invalid for source + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_COMMIT_FAIL, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_OP_FAIL, LOGSTR_COMMIT_FAIL, + gd_op_list[op], "localhost", (op_errstr) ? ":" : " ", + (op_errstr) ? op_errstr : " "); + if (op_errstr == NULL) +@@ -4527,13 +4657,16 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) + ret = dict_set_static_ptr (dict, "peerinfo", peerinfo); + if (ret) { + rcu_read_unlock (); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set peerinfo"); + goto out; + } + ret = proc->fn (NULL, this, dict); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_COMMIT_REQ_SEND_FAIL, ++ "Failed to " + "send commit request for operation " + "'Volume %s' to peer %s", + gd_op_list[op], peerinfo->hostname); +@@ -4545,7 +4678,7 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) + rcu_read_unlock (); + + opinfo.pending_count = pending_count; +- gf_log (this->name, GF_LOG_DEBUG, "Sent commit op req for 'Volume %s' " ++ gf_msg_debug (this->name, 0, "Sent commit op req for 'Volume %s' " + "to %d peers", gd_op_list[op], opinfo.pending_count); + out: + if (dict) +@@ -4567,7 +4700,7 @@ out: + } + + err: +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + +@@ -4590,7 +4723,7 @@ glusterd_op_ac_rcvd_stage_op_acc (glusterd_op_sm_event_t *event, void *ctx) + &event->txn_id, NULL); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -4612,7 +4745,7 @@ glusterd_op_ac_stage_op_failed (glusterd_op_sm_event_t *event, void *ctx) + &event->txn_id, NULL); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -4634,7 +4767,7 @@ glusterd_op_ac_commit_op_failed (glusterd_op_sm_event_t *event, void *ctx) + &event->txn_id, NULL); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -4656,7 +4789,8 @@ glusterd_op_ac_brick_op_failed (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_remove_pending_entry (&opinfo.pending_bricks, ev_ctx->pending_node->node); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "unknown response received "); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNKNOWN_RESPONSE, "unknown response received "); + ret = -1; + free_errstr = _gf_true; + goto out; +@@ -4683,7 +4817,7 @@ out: + if (free_errstr && ev_ctx->op_errstr) + GF_FREE (ev_ctx->op_errstr); + GF_FREE (ctx); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -4710,7 +4844,8 @@ glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx) + if (op == GD_OP_REPLACE_BRICK) { + ret = glusterd_op_sm_inject_all_acc (&event->txn_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Couldn't start " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RBOP_START_FAIL, "Couldn't start " + "replace-brick operation."); + goto out; + } +@@ -4754,7 +4889,7 @@ glusterd_op_ac_rcvd_unlock_acc (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, + &event->txn_id, NULL); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + out: + return ret; +@@ -4824,14 +4959,16 @@ glusterd_op_txn_complete (uuid_t *txn_id) + ret = glusterd_unlock (MY_UUID); + /* unlock cant/shouldnt fail here!! */ + if (ret) +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_GLUSTERD_UNLOCK_FAIL, + "Unable to clear local lock, ret: %d", ret); + else +- gf_log (this->name, GF_LOG_DEBUG, "Cleared local lock"); ++ gf_msg_debug (this->name, 0, "Cleared local lock"); + } else { + ret = dict_get_str (ctx, "volname", &volname); + if (ret) +- gf_log ("", GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "No Volume name present. " + "Locks have not been held."); + +@@ -4839,7 +4976,8 @@ glusterd_op_txn_complete (uuid_t *txn_id) + ret = glusterd_mgmt_v3_unlock (volname, MY_UUID, + "vol"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Unable to release lock for %s", + volname); + } +@@ -4849,7 +4987,9 @@ glusterd_op_txn_complete (uuid_t *txn_id) + op_errno, req, ctx, op_errstr); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Responding to cli failed, " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_CLI_RESP, ++ "Responding to cli failed, " + "ret: %d", ret); + //Ignore this error, else state machine blocks + ret = 0; +@@ -4865,10 +5005,11 @@ glusterd_op_txn_complete (uuid_t *txn_id) + /* Clearing the transaction opinfo */ + ret = glusterd_clear_txn_opinfo (txn_id); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_CLEAR_FAIL, + "Unable to clear transaction's opinfo"); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4881,7 +5022,7 @@ glusterd_op_ac_unlocked_all (glusterd_op_sm_event_t *event, void *ctx) + + ret = glusterd_op_txn_complete (&event->txn_id); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -4908,7 +5049,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) + + rsp_dict = dict_new (); + if (!rsp_dict) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_DICT_CREATE_FAIL, + "Failed to get new dictionary"); + return -1; + } +@@ -4917,7 +5059,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) + rsp_dict); + + if (status) { +- gf_log (this->name, GF_LOG_ERROR, "Stage failed on operation" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VALIDATE_FAILED, "Stage failed on operation" + " 'Volume %s', Status : %d", gd_op_list[req_ctx->op], + status); + } +@@ -4934,7 +5077,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) + ret = dict_set_bin (rsp_dict, "transaction_id", + txn_id, sizeof(*txn_id)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set transaction id."); + goto out; + } +@@ -4946,7 +5090,7 @@ out: + if (op_errstr && (strcmp (op_errstr, ""))) + GF_FREE (op_errstr); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + if (rsp_dict) + dict_unref (rsp_dict); +@@ -5030,7 +5174,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx) + } + + if (status) +- gf_log (this->name, GF_LOG_ERROR, "Commit of operation " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_OP_FAIL, "Commit of operation " + "'Volume %s' failed: %d", gd_op_list[req_ctx->op], + status); + +@@ -5046,7 +5191,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx) + ret = dict_set_bin (rsp_dict, "transaction_id", + txn_id, sizeof(*txn_id)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set transaction id."); + goto out; + } +@@ -5061,7 +5207,7 @@ out: + if (rsp_dict) + dict_unref (rsp_dict); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -5088,7 +5234,7 @@ glusterd_op_ac_send_commit_failed (glusterd_op_sm_event_t *event, void *ctx) + opinfo.op_errstr = NULL; + } + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -5231,11 +5377,12 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr, + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "Unknown op %s", + gd_op_list[op]); + } + +- gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret); ++ gf_msg_debug (this->name, 0, "OP = %d. Returning %d", op, ret); + return ret; + } + +@@ -5353,7 +5500,8 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "Unknown op %s", + gd_op_list[op]); + break; + } +@@ -5361,7 +5509,7 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, + if (ret == 0) + glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_POST); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -5383,7 +5531,8 @@ glusterd_bricks_select_stop_volume (dict_t *dict, char **op_errstr, + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + gf_asprintf (op_errstr, FMTSTR_CHECK_VOL_EXISTS, volname); + goto out; +@@ -5430,26 +5579,29 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "Unable to allocate memory"); + goto out; + } + + ret = dict_get_int32 (dict, "count", &count); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get count"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get count"); + goto out; + } + + ret = dict_get_int32 (dict, "command", &command); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get command"); ++ gf_log ("glusterd", GF_LOG_ERROR, "Unable to get command"); + goto out; + } + +@@ -5458,7 +5610,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, + + ret = dict_get_int32 (dict, "force", &force); + if (ret) { +- gf_log (THIS->name, GF_LOG_INFO, "force flag is not set"); ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, "force flag is not set"); + ret = 0; + goto out; + } +@@ -5468,7 +5621,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, key, &brick); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get brick"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get brick"); + goto out; + } + +@@ -5524,7 +5678,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume name get failed"); + goto out; + } + +@@ -5534,13 +5689,15 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + volname); + + *op_errstr = gf_strdup (msg); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + goto out; + } + + ret = dict_get_int32 (dict, "op", &stats_op); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume profile op get failed"); + goto out; + } + +@@ -5554,7 +5711,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + if (ret) { + if (!priv->nfs_svc.online) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "NFS server" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_SERVER_NOT_RUNNING, ++ "NFS server" + " is not running"); + goto out; + } +@@ -5597,7 +5756,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + if (ret) { + if (!priv->nfs_svc.online) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "NFS server" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_SERVER_NOT_RUNNING, ++ "NFS server" + " is not running"); + goto out; + } +@@ -5662,7 +5823,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + + default: + GF_ASSERT (0); +- gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_ENTRY, "Invalid profile op: %d", + stats_op); + ret = -1; + goto out; +@@ -5671,7 +5833,7 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, + + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -5894,7 +6056,8 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get" + " volname"); + goto out; + } +@@ -5924,7 +6087,7 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr, + ret = 0; + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning ret %d", ret); + return ret; + } + +@@ -5948,7 +6111,9 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo, + cmd_replica_index = get_replica_index_for_per_replica_cmd + (volinfo, req_dict); + if (cmd_replica_index == -1) { +- gf_log (THIS->name, GF_LOG_ERROR, "Could not find the " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_REPLICA_INDEX_GET_FAIL, ++ "Could not find the " + "replica index for per replica type command"); + ret = -1; + goto out; +@@ -5976,14 +6141,16 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo, + uuid_utoa(MY_UUID)); + ret = dict_set_dynstr (dict, key, gf_strdup(value)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Unable to" + "set the dictionary for shd status msg"); + goto out; + } + snprintf (key, sizeof (key), "%d-shd-status",index); + ret = dict_set_str (dict, key, "off"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Unable to" + " set dictionary for shd status msg"); + goto out; + } +@@ -6018,7 +6185,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume name get failed"); + goto out; + } + +@@ -6028,13 +6196,15 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + volname); + + *op_errstr = gf_strdup (msg); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + goto out; + } + + ret = dict_get_int32 (dict, "heal-op", (int32_t*)&heal_op); + if (ret || (heal_op == GF_SHD_OP_INVALID)) { +- gf_log ("glusterd", GF_LOG_ERROR, "heal op invalid"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "heal op invalid"); + goto out; + } + +@@ -6043,7 +6213,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + case GF_SHD_OP_STATISTICS_HEAL_COUNT: + if (!priv->shd_svc.online) { + if (!rsp_dict) { +- gf_log (this->name, GF_LOG_ERROR, "Received " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_NULL, "Received " + "empty ctx."); + goto out; + } +@@ -6053,7 +6224,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + ALL_HEAL_XL, + dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Unable to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SHD_STATUS_SET_FAIL, "Unable to " + "fill the shd status for the local " + "bricks"); + goto out; +@@ -6063,7 +6235,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA: + if (!priv->shd_svc.online) { + if (!rsp_dict) { +- gf_log (this->name, GF_LOG_ERROR, "Received " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_NULL, "Received " + "empty ctx."); + goto out; + } +@@ -6072,7 +6245,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + PER_HEAL_XL, + dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Unable to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SHD_STATUS_SET_FAIL, "Unable to " + "fill the shd status for the local" + " bricks."); + goto out; +@@ -6106,7 +6280,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + if (!hxlator_count) + goto out; + if (hxlator_count == -1) { +- gf_log (this->name, GF_LOG_ERROR, "Could not determine the" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_XLATOR_COUNT_GET_FAIL, "Could not determine the" + "translator count"); + ret = -1; + goto out; +@@ -6129,7 +6304,7 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning ret %d", ret); + return ret; + + } +@@ -6150,7 +6325,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volume name get failed"); + goto out; + } + +@@ -6160,7 +6336,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr, + volname); + + *op_errstr = gf_strdup (msg); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + goto out; + } + pending_node = GF_CALLOC (1, sizeof (*pending_node), +@@ -6204,7 +6381,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_int32 (dict, "cmd", &cmd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get status type"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get status type"); + goto out; + } + +@@ -6229,7 +6407,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + } + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volname"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volname"); + goto out; + } + ret = glusterd_volinfo_find (volname, &volinfo); +@@ -6240,7 +6419,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + if ( (cmd & GF_CLI_STATUS_BRICK) != 0) { + ret = dict_get_str (dict, "brick", &brickname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get brick"); + goto out; + } +@@ -6269,7 +6449,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + } else if ((cmd & GF_CLI_STATUS_NFS) != 0) { + if (!priv->nfs_svc.online) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_SERVER_NOT_RUNNING, + "NFS server is not running"); + goto out; + } +@@ -6288,7 +6469,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { + if (!priv->shd_svc.online) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SELF_HEALD_DISABLED, + "Self-heal daemon is not running"); + goto out; + } +@@ -6306,7 +6488,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + ret = 0; + } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { + if (!priv->quotad_svc.online) { +- gf_log (this->name, GF_LOG_ERROR, "Quotad is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTAD_NOT_RUNNING, "Quotad is not " + "running"); + ret = -1; + goto out; +@@ -6363,7 +6546,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + ret = 0; + } else if ((cmd & GF_CLI_STATUS_SNAPD) != 0) { + if (!volinfo->snapd.svc.online) { +- gf_log (this->name, GF_LOG_ERROR, "snapd is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_NOT_RUNNING, "snapd is not " + "running"); + ret = -1; + goto out; +@@ -6371,7 +6555,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + pending_node = GF_CALLOC (1, sizeof (*pending_node), + gf_gld_mt_pending_node_t); + if (!pending_node) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "failed to allocate " + "memory for pending node"); + ret = -1; + goto out; +@@ -6395,7 +6580,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + gf_gld_mt_pending_node_t); + if (!pending_node) { + ret = -1; +- gf_log (THIS->name ,GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Unable to allocate memory"); + goto out; + } +@@ -6427,13 +6613,15 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get volname"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volname"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to find volume %s", ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "Failed to find volume %s", + volname); + goto out; + } +@@ -6456,7 +6644,7 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected) + } + + out: +- gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -6485,7 +6673,9 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_op_build_payload (&req_ctx->dict, &op_errstr, + NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, ++ LOGSTR_BUILD_PAYLOAD, + gd_op_list[op]); + if (op_errstr == NULL) + gf_asprintf (&op_errstr, +@@ -6509,7 +6699,7 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx) + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -6545,7 +6735,8 @@ glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_remove_pending_entry (&opinfo.pending_bricks, + pending_entry); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "unknown response received "); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNKNOWN_RESPONSE, "unknown response received "); + ret = -1; + goto out; + } +@@ -6566,7 +6757,7 @@ out: + if (ev_ctx->rsp_dict) + dict_unref (ev_ctx->rsp_dict); + GF_FREE (ev_ctx); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -6623,7 +6814,7 @@ glusterd_op_bricks_select (glusterd_op_t op, dict_t *dict, char **op_errstr, + break; + } + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -6958,7 +7149,7 @@ glusterd_op_sm_inject_event (glusterd_op_sm_event_type_t event_type, + if (txn_id) + gf_uuid_copy (event->txn_id, *txn_id); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Enqueue event: '%s'", ++ gf_msg_debug (THIS->name, 0, "Enqueue event: '%s'", + glusterd_op_sm_event_name_get (event->event)); + cds_list_add_tail (&event->list, &gd_op_sm_queue); + +@@ -7026,7 +7217,8 @@ glusterd_op_sm () + ret = synclock_trylock (&gd_op_sm_lock); + if (ret) { + lock_err = errno; +- gf_log (this->name, GF_LOG_ERROR, "lock failed due to %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_LOCK_FAIL, "lock failed due to %s", + strerror (lock_err)); + goto lock_failed; + } +@@ -7038,17 +7230,18 @@ glusterd_op_sm () + + cds_list_del_init (&event->list); + event_type = event->event; +- gf_log (this->name, GF_LOG_DEBUG, "Dequeued event of " ++ gf_msg_debug (this->name, 0, "Dequeued event of " + "type: '%s'", + glusterd_op_sm_event_name_get(event_type)); + +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (event->txn_id)); + + ret = glusterd_get_txn_opinfo (&event->txn_id, + &txn_op_info); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, + "Unable to get transaction's opinfo"); + glusterd_destroy_op_event_ctx (event); + GF_FREE (event); +@@ -7066,7 +7259,8 @@ glusterd_op_sm () + ret = handler (event, event->ctx); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDLER_RETURNED, + "handler returned: %d", ret); + glusterd_destroy_op_event_ctx (event); + GF_FREE (event); +@@ -7077,7 +7271,8 @@ glusterd_op_sm () + event_type); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_STATE_TRANSITION_FAIL, + "Unable to transition" + "state from '%s' to '%s'", + glusterd_op_sm_state_name_get(opinfo.state.state), +@@ -7092,14 +7287,16 @@ glusterd_op_sm () + /* Clearing the transaction opinfo */ + ret = glusterd_clear_txn_opinfo(&event->txn_id); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_CLEAR_FAIL, + "Unable to clear " + "transaction's opinfo"); + } else { + ret = glusterd_set_txn_opinfo (&event->txn_id, + &opinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_SET_FAIL, + "Unable to set " + "transaction's opinfo"); + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 6f41b7b..1a90aae 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -170,7 +170,9 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid) + */ + ret = dict_set_static_ptr (friends, "peerinfo", peerinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "failed to set peerinfo"); + goto unlock; + } + +@@ -182,7 +184,7 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid) + unlock: + rcu_read_unlock (); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + + out: + if (friends) +@@ -197,7 +199,7 @@ glusterd_ac_none (glusterd_friend_sm_event_t *event, void *ctx) + { + int ret = 0; + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + + return ret; + } +@@ -207,7 +209,8 @@ glusterd_ac_error (glusterd_friend_sm_event_t *event, void *ctx) + { + int ret = 0; + +- gf_log ("", GF_LOG_ERROR, "Received event %d ", event->event); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_AC_ERROR, "Received event %d ", event->event); + + return ret; + } +@@ -227,7 +230,8 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx) + + peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!peerinfo) { +- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + ret = -1; + goto out; +@@ -237,7 +241,9 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx) + (GD_FRIEND_EVENT_PROBE, &new_event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get new new_event"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, ++ "Unable to get new new_event"); + ret = -1; + goto out; + } +@@ -260,8 +266,10 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx) + ret = glusterd_friend_sm_inject_event (new_event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject new_event %d, " +- "ret = %d", new_event->event, ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, ++ "Unable to inject new_event %d, " ++ "ret = %d", new_event->event, ret); + } + + out: +@@ -275,7 +283,7 @@ out: + GF_FREE (new_ev_ctx->hostname); + GF_FREE (new_ev_ctx); + } +- gf_log ("", GF_LOG_DEBUG, "returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning with %d", ret); + return ret; + } + +@@ -300,7 +308,9 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx) + + peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, ++ "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + goto out; + } +@@ -320,7 +330,7 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx) + out: + rcu_read_unlock (); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -382,7 +392,9 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx) + */ + ret = dict_set_static_ptr (dict, "peerinfo", peerinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "failed to set peerinfo"); + goto out; + } + +@@ -397,7 +409,7 @@ out: + + if (dict) + dict_unref (dict); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + + return ret; + } +@@ -427,7 +439,8 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event, + + peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + goto out; + } +@@ -443,8 +456,9 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event, + gf_uuid_copy (new_event->peerid, peerinfo->uuid); + ret = glusterd_friend_sm_inject_event (new_event); + } else { +- gf_log ("glusterd", GF_LOG_ERROR, +- "Unable to get event"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, ++ "Unable to get event"); + } + + if (ctx) { +@@ -473,7 +487,7 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event, + out: + rcu_read_unlock (); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + + return ret; + } +@@ -516,7 +530,8 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx) + + cur_peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!cur_peerinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + ret = -1; + goto out; +@@ -559,7 +574,9 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx) + + ret = dict_set_static_ptr (friends, "peerinfo", peerinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "failed to set peerinfo"); + goto out; + } + +@@ -569,7 +586,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx) + } + } + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + + out: + rcu_read_unlock (); +@@ -606,7 +623,8 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + "Deleting stale volume %s", volinfo->volname); + ret = glusterd_delete_volume (volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_STALE_VOL_REMOVE_FAIL, + "Error deleting stale volume"); + goto out; + } +@@ -614,7 +632,7 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + } + ret = 0; + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -662,7 +680,8 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event, + + ret = glusterd_peer_detach_cleanup (priv); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_PEER_DETACH_CLEANUP_FAIL, + "Peer detach cleanup was not successful"); + ret = 0; + } +@@ -671,7 +690,7 @@ out: + GF_FREE (new_event->peername); + GF_FREE (new_event); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -687,7 +706,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx) + + peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!peerinfo) { +- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, ++ "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + rcu_read_unlock (); + goto out; +@@ -704,7 +725,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx) + + ret = glusterd_peerinfo_cleanup (peerinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Cleanup returned: %d", ret); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_DETACH_CLEANUP_FAIL, ++ "Cleanup returned: %d", ret); + } + out: + return 0; +@@ -747,7 +770,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (event->peerid, event->peername); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + ret = -1; + rcu_read_unlock (); +@@ -792,7 +816,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + (conf->op_version >= GD_OP_VERSION_RHS_3_0)) { + ret = glusterd_import_friend_missed_snap_list (ev_ctx->vols); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL, + "Failed to import peer's " + "missed_snaps_list."); + event_type = GD_FRIEND_EVENT_LOCAL_RJT; +@@ -810,7 +835,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + event->peername, + event->peerid); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_COMPARE_CONFLICT, + "Conflict in comparing peer's snapshots"); + event_type = GD_FRIEND_EVENT_LOCAL_RJT; + op_errno = GF_PROBE_SNAP_CONFLICT; +@@ -821,7 +847,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + ret = glusterd_friend_sm_new_event (event_type, &new_event); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Out of Memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of Memory"); + } + + new_event->peername = gf_strdup (event->peername); +@@ -861,7 +888,7 @@ out: + GF_FREE (new_event->peername); + GF_FREE (new_event); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -1112,7 +1139,7 @@ int + glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event) + { + GF_ASSERT (event); +- gf_log ("glusterd", GF_LOG_DEBUG, "Enqueue event: '%s'", ++ gf_msg_debug ("glusterd", 0, "Enqueue event: '%s'", + glusterd_friend_sm_event_name_get (event->event)); + cds_list_add_tail (&event->list, &gd_friend_sm_queue); + +@@ -1195,7 +1222,8 @@ glusterd_friend_sm () + peerinfo = glusterd_peerinfo_find (event->peerid, + event->peername); + if (!peerinfo) { +- gf_log ("glusterd", GF_LOG_CRITICAL, "Received" ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_PEER_NOT_FOUND, "Received" + " event %s with empty peer info", + glusterd_friend_sm_event_name_get (event_type)); + +@@ -1203,7 +1231,7 @@ glusterd_friend_sm () + rcu_read_unlock (); + continue; + } +- gf_log ("", GF_LOG_DEBUG, "Dequeued event of type: '%s'", ++ gf_msg_debug ("glusterd", 0, "Dequeued event of type: '%s'", + glusterd_friend_sm_event_name_get (event_type)); + + +@@ -1232,7 +1260,9 @@ glusterd_friend_sm () + } + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "handler returned: " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_HANDLER_RETURNED, ++ "handler returned: " + "%d", ret); + glusterd_destroy_friend_event_context (event); + GF_FREE (event); +@@ -1251,7 +1281,9 @@ glusterd_friend_sm () + event_type); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition" ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_STATE_TRANSITION_FAIL, ++ "Unable to transition" + " state from '%s' to '%s' for event '%s'", + glusterd_friend_sm_state_name_get(old_state), + glusterd_friend_sm_state_name_get(state[event_type].next_state), +@@ -1275,7 +1307,8 @@ glusterd_friend_sm () + * something has gone terribly wrong. + */ + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, + "Cannot find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + goto out; +-- +1.7.1 + diff --git a/SOURCES/0088-rebalance-store-glusterd-glusterd-porting-to-new-log.patch b/SOURCES/0088-rebalance-store-glusterd-glusterd-porting-to-new-log.patch new file mode 100644 index 0000000..78a3425 --- /dev/null +++ b/SOURCES/0088-rebalance-store-glusterd-glusterd-porting-to-new-log.patch @@ -0,0 +1,2769 @@ +From dab6b91c987cd2cfcd0c26114780cee5845190d4 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Fri, 13 Mar 2015 16:55:17 +0530 +Subject: [PATCH 088/101] rebalance,store,glusterd/glusterd: porting to new logging framework + +cherry-picked from commit 25f28a9c23b1adf665a982c2f5157bf13361521b +>Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9877 +>Tested-by: Gluster Build System +>Reviewed-by: Sachin Pandit +>Tested-by: NetBSD Build System +>Reviewed-by: Atin Mukherjee + +Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50895 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-rebalance.c | 102 +++-- + xlators/mgmt/glusterd/src/glusterd-store.c | 552 +++++++++++++++--------- + xlators/mgmt/glusterd/src/glusterd.c | 208 ++++++--- + 3 files changed, 538 insertions(+), 324 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +index 0367df3..4fd95c2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +@@ -55,7 +55,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, + /* Check only if operation is not remove-brick */ + if ((GD_OP_REMOVE_BRICK != op) && + !gd_is_remove_brick_committed (volinfo)) { +- gf_log (this->name, GF_LOG_DEBUG, "A remove-brick task on " ++ gf_msg_debug (this->name, 0, "A remove-brick task on " + "volume %s is not yet committed", volinfo->volname); + snprintf (op_errstr, len, "A remove-brick task on volume %s is" + " not yet committed. Either commit or stop the " +@@ -64,7 +64,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, + } + + if (glusterd_is_defrag_on (volinfo)) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "rebalance on volume %s already started", + volinfo->volname); + snprintf (op_errstr, len, "Rebalance on %s is already started", +@@ -74,7 +74,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, + + ret = 0; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -123,7 +123,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata, + } + UNLOCK (&defrag->lock); + +- gf_log ("", GF_LOG_DEBUG, "%s got RPC_CLNT_CONNECT", ++ gf_msg_debug (this->name, 0, "%s got RPC_CLNT_CONNECT", + rpc->conn.name); + break; + } +@@ -165,7 +165,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata, + glusterd_volinfo_unref (volinfo); + break; + default: +- gf_log ("", GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "got some other RPC event %d", event); + ret = 0; + break; +@@ -234,7 +234,8 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, + GLUSTERD_GET_DEFRAG_DIR (defrag_path, volinfo, priv); + ret = mkdir_p (defrag_path, 0777, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create " ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Failed to create " + "directory %s", defrag_path); + goto out; + } +@@ -296,7 +297,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, + + ret = runner_run_nowait (&runner); + if (ret) { +- gf_log ("glusterd", GF_LOG_DEBUG, "rebalance command failed"); ++ gf_msg_debug ("glusterd", 0, "rebalance command failed"); + goto out; + } + +@@ -310,7 +311,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, + defrag->cbk_fn = cbk; + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -352,7 +353,8 @@ glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo, + * with the older path + */ + if (ret && (errno == ENOENT)) { +- gf_log (this->name, GF_LOG_WARNING, "Rebalance sockfile " ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "Rebalance sockfile " + "%s does not exist. Trying old path.", + sockfile); + GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD (sockfile, volinfo, +@@ -400,14 +402,16 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, + int ret = -1; + + if (glusterd_volinfo_find(volname, volinfo)) { +- gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on invalid" ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, "Received rebalance on invalid" + " volname %s", volname); + snprintf (op_errstr, len, "Volume %s does not exist", + volname); + goto out; + } + if ((*volinfo)->brick_count <= (*volinfo)->dist_leaf_count) { +- gf_log ("glusterd", GF_LOG_ERROR, "Volume %s is not a " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_DISTRIBUTE, "Volume %s is not a " + "distribute type or contains only 1 brick", volname); + snprintf (op_errstr, len, "Volume %s is not a distribute " + "volume or contains only 1 brick.\n" +@@ -416,7 +420,8 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, + } + + if ((*volinfo)->status != GLUSTERD_STATUS_STARTED) { +- gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on stopped" ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_STOPPED, "Received rebalance on stopped" + " volname %s", volname); + snprintf (op_errstr, len, "Volume %s needs to " + "be started to perform rebalance", volname); +@@ -435,7 +440,7 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, + ret = 0; + + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -473,7 +478,8 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " + "command"); +@@ -484,14 +490,16 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + + ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd); + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get command"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + +@@ -581,20 +589,20 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "volname not found"); ++ gf_msg_debug (this->name, 0, "volname not found"); + goto out; + } + + ret = dict_get_int32 (dict, "rebalance-command", &cmd); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "cmd not found"); ++ gf_msg_debug (this->name, 0, "cmd not found"); + goto out; + } + + ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo, + msg, sizeof (msg)); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "failed to validate"); ++ gf_msg_debug (this->name, 0, "failed to validate"); + goto out; + } + switch (cmd) { +@@ -626,7 +634,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + op_ctx = glusterd_op_get_ctx (); + if (!op_ctx) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, + "Failed to get op_ctx"); + goto out; + } +@@ -634,7 +643,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + ret = glusterd_generate_and_set_task_id + (op_ctx, GF_REBALANCE_TID_KEY); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASKID_GEN_FAIL, + "Failed to generate task-id"); + goto out; + } +@@ -644,7 +654,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + if (ret) { + snprintf (msg, sizeof (msg), + "Missing rebalance-id"); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_REBALANCE_ID_MISSING, "%s", msg); + ret = 0; + } + } +@@ -652,7 +663,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + sizeof (msg), + GD_OP_REBALANCE); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "start validate failed"); + goto out; + } +@@ -662,10 +673,11 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + case GF_DEFRAG_CMD_STOP_DETACH_TIER: + ret = dict_get_str (dict, "cmd-str", &cmd_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " +- "command string"); +- ret = -1; +- goto out; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " ++ "command string"); ++ ret = -1; ++ goto out; + } + if ((strstr(cmd_str, "rebalance") != NULL) && + (volinfo->rebal.op != GD_OP_REBALANCE)) { +@@ -736,13 +748,13 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "volname not given"); ++ gf_msg_debug (this->name, 0, "volname not given"); + goto out; + } + + ret = dict_get_int32 (dict, "rebalance-command", &cmd); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "command not given"); ++ gf_msg_debug (this->name, 0, "command not given"); + goto out; + } + +@@ -750,7 +762,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo, + msg, sizeof (msg)); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "cmd validate failed"); ++ gf_msg_debug (this->name, 0, "cmd validate failed"); + goto out; + } + +@@ -763,7 +775,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) { + ctx = glusterd_op_get_ctx (); + if (!ctx) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, + "Failed to get op_ctx"); + ret = -1; + goto out; +@@ -778,7 +791,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + (volinfo->rebal.rebalance_id, ctx, + GF_REBALANCE_TID_KEY); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASKID_GEN_FAIL, + "Failed to set task-id"); + goto out; + } +@@ -798,7 +812,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, GF_REBALANCE_TID_KEY, &task_id_str); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Missing rebalance " ++ gf_msg_debug (this->name, 0, "Missing rebalance " + "id"); + ret = 0; + } else { +@@ -848,7 +862,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "failed to create volfiles"); + goto out; + } +@@ -856,7 +871,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLINFO_SET_FAIL, + "failed to store volinfo"); + goto out; + } +@@ -894,7 +910,8 @@ glusterd_defrag_event_notify_handle (dict_t *dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volname"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volname"); + return ret; + } + +@@ -907,8 +924,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) + } + volname = volname_ptr + 1; + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "volname received (%s) is not prefixed with rebalance.", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_REBALANCE_PFX_IN_VOLNAME, ++ "volname recieved (%s) is not prefixed with rebalance.", + volname); + ret = -1; + goto out; +@@ -916,7 +934,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo for %s" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, ++ "Failed to get volinfo for %s" + , volname); + return ret; + } +@@ -924,7 +944,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) + ret = glusterd_defrag_volume_status_update (volinfo, dict); + + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to update status"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DEFRAG_STATUS_UPDATE_FAIL, ++ "Failed to update status"); + + out: + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index ae87e9a..d790c6f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -38,6 +38,7 @@ + #include "store.h" + #include "glusterd-store.h" + #include "glusterd-snapshot-utils.h" ++#include "glusterd-messages.h" + + #include "rpc-clnt.h" + #include "common-utils.h" +@@ -170,19 +171,22 @@ glusterd_store_is_valid_brickpath (char *volname, char *brick) + + ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to create brick " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRICK_CREATION_FAIL, "Failed to create brick " + "info for brick %s", brick); + ret = 0; + goto out; + } + ret = glusterd_volinfo_new (&volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to create volinfo"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volinfo"); + ret = 0; + goto out; + } + if (volname_len >= sizeof (volinfo->volname)) { +- gf_log (this->name, GF_LOG_WARNING, "volume name too long"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_NAME_TOO_LONG, "volume name too long"); + ret = 0; + goto out; + } +@@ -332,7 +336,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_BRICK_FSTYPE, value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to save " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FS_LABEL_UPDATE_FAIL, "Failed to save " + "brick fs type of brick %s", brickinfo->path); + goto out; + } +@@ -343,7 +348,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_BRICK_MNTOPTS, value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to save " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to save " + "brick mnt opts of brick %s", brickinfo->path); + goto out; + } +@@ -405,7 +411,7 @@ glusterd_store_brickinfo_write (int fd, glusterd_brickinfo_t *brickinfo) + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_VGNAME, + brickinfo->vg); + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -425,11 +431,13 @@ glusterd_store_snapd_write (int fd, glusterd_volinfo_t *volinfo) + snprintf (value, sizeof(value), "%d", volinfo->snapd.port); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAPD_PORT, value); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "failed to store the snapd " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_PORT_STORE_FAIL, ++ "failed to store the snapd " + "port of volume %s", volinfo->volname); + + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -453,7 +461,7 @@ glusterd_store_perform_brick_store (glusterd_brickinfo_t *brickinfo) + out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (brickinfo->shandle); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -471,7 +479,8 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo) + + fd = gf_store_mkstemp (volinfo->snapd.handle); + if (fd <= 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create the " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "failed to create the " + "temporary file for the snapd store handle of volume " + "%s", volinfo->volname); + goto out; +@@ -479,7 +488,9 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo) + + ret = glusterd_store_snapd_write (fd, volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to write snapd port " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_PORT_STORE_FAIL, ++ "failed to write snapd port " + "info to store handle (volume: %s", volinfo->volname); + goto out; + } +@@ -489,7 +500,7 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo) + out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->snapd.handle); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -519,7 +530,7 @@ glusterd_store_brickinfo (glusterd_volinfo_t *volinfo, + + ret = glusterd_store_perform_brick_store (brickinfo); + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -536,21 +547,25 @@ glusterd_store_snapd_info (glusterd_volinfo_t *volinfo) + + ret = glusterd_store_create_snapd_shandle_on_absence (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_CREATE_FAIL, ++ "failed to create store " + "handle for snapd (volume: %s)", volinfo->volname); + goto out; + } + + ret = glusterd_store_perform_snapd_store (volinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "failed to store snapd info " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INFO_STORE_FAIL, ++ "failed to store snapd info " + "of the volume %s", volinfo->volname); + + out: + if (ret) + gf_store_unlink_tmppath (volinfo->snapd.handle); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -589,8 +604,8 @@ glusterd_store_delete_brick (glusterd_brickinfo_t *brickinfo, char *delete_path) + ret = unlink (brickpath); + + if ((ret < 0) && (errno != ENOENT)) { +- gf_log (this->name, GF_LOG_DEBUG, "Unlink failed on %s, " +- "reason: %s", brickpath, strerror(errno)); ++ gf_msg_debug (this->name, 0, "Unlink failed on %s", ++ brickpath); + ret = -1; + goto out; + } else { +@@ -602,7 +617,7 @@ out: + gf_store_handle_destroy (brickinfo->shandle); + brickinfo->shandle = NULL; + } +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -644,8 +659,8 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path) + brickdir, entry->d_name); + ret = unlink (path); + if (ret && errno != ENOENT) { +- gf_log (this->name, GF_LOG_DEBUG, "Unable to unlink %s, " +- "reason: %s", path, strerror(errno)); ++ gf_msg_debug (this->name, 0, "Unable to unlink %s", ++ path); + } + GF_FOR_EACH_ENTRY_IN_DIR (entry, dir); + } +@@ -655,7 +670,7 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path) + ret = rmdir (brickdir); + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -685,13 +700,15 @@ _storeslaves (dict_t *this, char *key, data_t *value, void *data) + if (!value || !value->data) + return -1; + +- gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s", ++ gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, val=%s", + key, value->data); + + ret = gf_store_save_value (shandle->fd, key, (char*)value->data); + if (ret) { +- gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store" +- " handle for path: %s", shandle->path); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_WRITE_FAIL, ++ "Unable to write into store" ++ " handle for path: %s", shandle->path); + return -1; + } + return 0; +@@ -732,18 +749,20 @@ int _storeopts (dict_t *this, char *key, data_t *value, void *data) + } + + if (1 == exists) { +- gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, " ++ gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, " + "val=%s", key, value->data); + + } else { +- gf_log (xl->name, GF_LOG_DEBUG, "Discarding:key= %s, val=%s", ++ gf_msg_debug (xl->name, 0, "Discarding:key= %s, val=%s", + key, value->data); + return 0; + } + + ret = gf_store_save_value (shandle->fd, key, (char*)value->data); + if (ret) { +- gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store" ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_WRITE_FAIL, ++ "Unable to write into store" + " handle for path: %s", shandle->path); + return -1; + } +@@ -779,7 +798,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo) + snprintf (buf, sizeof (buf), "%s", volinfo->parent_volname); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_PARENT_VOLNAME, buf); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_FAIL, "Failed to store " + GLUSTERD_STORE_KEY_PARENT_VOLNAME); + goto out; + } +@@ -787,7 +807,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo) + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP, + uuid_utoa (volinfo->restored_from_snap)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_WRITE_FAIL, + "Unable to write restored_from_snap"); + goto out; + } +@@ -797,19 +818,23 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo) + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, + buf); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HARD_LIMIT_SET_FAIL, + "Unable to write snap-max-hard-limit"); + goto out; + } + + ret = glusterd_store_snapd_info (volinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "snapd info store failed " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INFO_STORE_FAIL, "snapd info store failed " + "volume: %s", volinfo->volname); + + out: + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to write snap details" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPINFO_WRITE_FAIL, ++ "Failed to write snap details" + " for volume %s", volinfo->volname); + return ret; + } +@@ -988,7 +1013,8 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo) + + out: + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Unable to write volume " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_VALS_WRITE_FAIL, "Unable to write volume " + "values for %s", volinfo->volname); + return ret; + } +@@ -1018,7 +1044,7 @@ glusterd_store_create_volume_dir (glusterd_volinfo_t *volinfo) + sizeof (voldirpath)); + ret = gf_store_mkdir (voldirpath); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -1037,7 +1063,8 @@ glusterd_store_create_snap_dir (glusterd_snap_t *snap) + + ret = mkdir_p (snapdirpath, 0755, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snaps dir " ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Failed to create snaps dir " + "%s", snapdirpath); + } + return ret; +@@ -1063,7 +1090,7 @@ glusterd_store_volinfo_write (int fd, glusterd_volinfo_t *volinfo) + dict_foreach (volinfo->gsync_slaves, _storeslaves, shandle); + shandle->fd = 0; + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1106,7 +1133,7 @@ glusterd_store_snapinfo_write (glusterd_snap_t *snap) + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_TIMESTAMP, buf); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1284,7 +1311,7 @@ glusterd_store_brickinfos (glusterd_volinfo_t *volinfo, int vol_fd) + brick_count++; + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1342,7 +1369,7 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo) + &fd); + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1370,7 +1397,7 @@ glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo) + out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->node_state_shandle); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1398,7 +1425,7 @@ glusterd_store_perform_volume_store (glusterd_volinfo_t *volinfo) + out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->shandle); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1475,8 +1502,9 @@ glusterd_store_volinfo_atomic_update (glusterd_volinfo_t *volinfo) + + out: + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename " +- "temporary file(s): Reason %s", strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Couldn't rename " ++ "temporary file(s)"); + return ret; + } + +@@ -1504,8 +1532,9 @@ glusterd_store_snap_atomic_update (glusterd_snap_t *snap) + + ret = gf_store_rename_tmppath (snap->shandle); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename " +- "temporary file(s): Reason %s", strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Couldn't rename " ++ "temporary file(s)"); + + return ret; + } +@@ -1519,26 +1548,34 @@ glusterd_store_snap (glusterd_snap_t *snap) + + ret = glusterd_store_create_snap_dir (snap); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap dir"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPDIR_CREATE_FAIL, ++ "Failed to create snap dir"); + goto out; + } + + ret = glusterd_store_create_snap_shandle_on_absence (snap); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap info " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPINFO_CREATE_FAIL, ++ "Failed to create snap info " + "file"); + goto out; + } + + ret = glusterd_store_snapinfo_write (snap); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to write snap info"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPINFO_WRITE_FAIL, ++ "Failed to write snap info"); + goto out; + } + + ret = glusterd_store_snap_atomic_update (snap); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR,"Failed to do automic update"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_AUTOMIC_UPDATE_FAIL, ++ "Failed to do automic update"); + goto out; + } + +@@ -1546,7 +1583,7 @@ out: + if (ret && snap->shandle) + gf_store_unlink_tmppath (snap->shandle); + +- gf_log (THIS->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1594,7 +1631,7 @@ out: + if (ret) + glusterd_store_volume_cleanup_tmp (volinfo); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1629,15 +1666,17 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo) + + ret = mkdir (trashdir, 0777); + if (ret && errno != EEXIST) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create trash " +- "directory, reason : %s", strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Failed to create trash " ++ "directory"); + ret = -1; + goto out; + } + + ret = rename (pathname, delete_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to rename volume " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, "Failed to rename volume " + "directory for volume %s", volinfo->volname); + rename_fail = _gf_true; + goto out; +@@ -1645,8 +1684,8 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo) + + ret = recursive_rmdir (trashdir); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:" +- " %s", trashdir, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to rmdir: %s", ++ trashdir); + } + + out: +@@ -1656,7 +1695,7 @@ out: + } + ret = (rename_fail == _gf_true) ? -1: 0; + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1693,15 +1732,17 @@ glusterd_store_delete_snap (glusterd_snap_t *snap) + + ret = mkdir (trashdir, 0777); + if (ret && errno != EEXIST) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create trash " +- "directory, reason : %s", strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Failed to create trash " ++ "directory"); + ret = -1; + goto out; + } + + ret = rename (pathname, delete_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to rename snap " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, "Failed to rename snap " + "directory %s to %s", pathname, delete_path); + rename_fail = _gf_true; + goto out; +@@ -1709,8 +1750,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap) + + dir = opendir (delete_path); + if (!dir) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to open directory %s." +- " Reason : %s", delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to open directory %s.", ++ delete_path); + ret = 0; + goto out; + } +@@ -1720,8 +1761,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap) + snprintf (path, PATH_MAX, "%s/%s", delete_path, entry->d_name); + ret = stat (path, &st); + if (ret == -1) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to stat " +- "entry %s : %s", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to stat " ++ "entry %s", path); + goto stat_failed; + } + +@@ -1731,11 +1772,11 @@ glusterd_store_delete_snap (glusterd_snap_t *snap) + ret = unlink (path); + + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, " Failed to remove " +- "%s. Reason : %s", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, " Failed to remove " ++ "%s", path); + } + +- gf_log (this->name, GF_LOG_DEBUG, "%s %s", ++ gf_msg_debug (this->name, 0, "%s %s", + ret ? "Failed to remove":"Removed", + entry->d_name); + stat_failed: +@@ -1745,19 +1786,19 @@ stat_failed: + + ret = closedir (dir); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to close dir %s. " +- "Reason : %s",delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to close dir %s.", ++ delete_path); + } + + ret = rmdir (delete_path); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s", +- delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to rmdir: %s", ++ delete_path); + } + ret = rmdir (trashdir); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:" +- " %s", trashdir, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to rmdir: %s", ++ trashdir); + } + + out: +@@ -1767,7 +1808,7 @@ out: + } + ret = (rename_fail == _gf_true) ? -1: 0; + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1793,7 +1834,8 @@ glusterd_store_global_info (xlator_t *this) + GLUSTERD_INFO_FILE); + ret = gf_store_handle_new (path, &handle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_GET_FAIL, + "Unable to get store handle"); + goto out; + } +@@ -1805,8 +1847,9 @@ glusterd_store_global_info (xlator_t *this) + /* These options need to be available for all users */ + ret = chmod (handle->path, 0644); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "chmod error for %s: %s", +- GLUSTERD_INFO_FILE, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "chmod error for %s", ++ GLUSTERD_INFO_FILE); + goto out; + } + +@@ -1819,7 +1862,8 @@ glusterd_store_global_info (xlator_t *this) + ret = gf_store_save_value (handle->fd, GLUSTERD_STORE_UUID_KEY, + uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_UUID_SET_FAIL, + "Storing uuid failed ret = %d", ret); + goto out; + } +@@ -1828,7 +1872,8 @@ glusterd_store_global_info (xlator_t *this) + ret = gf_store_save_value (handle->fd, GD_OP_VERSION_KEY, + op_version_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERS_STORE_FAIL, + "Storing op-version failed ret = %d", ret); + goto out; + } +@@ -1848,7 +1893,8 @@ out: + GF_FREE (uuid_str); + + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_GLOBAL_INFO_STORE_FAIL, + "Failed to store glusterd global-info"); + + return ret; +@@ -1873,7 +1919,7 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version) + ret = gf_store_handle_retrieve (path, &handle); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Unable to get store " ++ gf_msg_debug (this->name, 0, "Unable to get store " + "handle!"); + goto out; + } +@@ -1884,14 +1930,15 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version) + ret = gf_store_retrieve_value (priv->handle, GD_OP_VERSION_KEY, + &op_version_str); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No previous op_version present"); + goto out; + } + + tmp_version = strtol (op_version_str, &tmp, 10); + if ((tmp_version <= 0) || (tmp && strlen (tmp) > 1)) { +- gf_log (this->name, GF_LOG_WARNING, "invalid version number"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_UNSUPPORTED_VERSION, "invalid version number"); + goto out; + } + +@@ -1930,7 +1977,7 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit, + ret = gf_store_handle_retrieve (path, &handle); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Unable to get store " ++ gf_msg_debug (this->name, 0, "Unable to get store " + "handle!"); + goto out; + } +@@ -1942,14 +1989,15 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit, + key, + &limit_str); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No previous %s present", key); + goto out; + } + + tmp_limit = strtoul (limit_str, &tmp, 10); + if ((tmp_limit <= 0) || (tmp && strlen (tmp) > 1)) { +- gf_log (this->name, GF_LOG_WARNING, "invalid version number"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_UNSUPPORTED_VERSION, "invalid version number"); + goto out; + } + +@@ -1976,7 +2024,8 @@ glusterd_restore_op_version (xlator_t *this) + if (!ret) { + if ((op_version < GD_OP_VERSION_MIN) || + (op_version > GD_OP_VERSION_MAX)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_UNSUPPORTED_VERSION, + "wrong op-version (%d) retrieved", op_version); + ret = -1; + goto out; +@@ -2022,9 +2071,11 @@ glusterd_retrieve_uuid () + int32_t ret = -1; + gf_store_handle_t *handle = NULL; + glusterd_conf_t *priv = NULL; ++ xlator_t *this = NULL; + char path[PATH_MAX] = {0,}; + +- priv = THIS->private; ++ this = THIS; ++ priv = this->private; + + if (!priv->handle) { + snprintf (path, PATH_MAX, "%s/%s", priv->workdir, +@@ -2032,7 +2083,7 @@ glusterd_retrieve_uuid () + ret = gf_store_handle_retrieve (path, &handle); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Unable to get store" ++ gf_msg_debug (this->name, 0, "Unable to get store" + "handle!"); + goto out; + } +@@ -2044,7 +2095,7 @@ glusterd_retrieve_uuid () + &uuid_str); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "No previous uuid is present"); ++ gf_msg_debug (this->name, 0, "No previous uuid is present"); + goto out; + } + +@@ -2052,7 +2103,7 @@ glusterd_retrieve_uuid () + + out: + GF_FREE (uuid_str); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2107,20 +2158,23 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo) + + ret = gf_store_handle_retrieve (path, &volinfo->snapd.handle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDLE_NULL, "volinfo handle is NULL"); + goto out; + } + + ret = gf_store_iter_new (volinfo->snapd.handle, &iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store " + "iter"); + goto out; + } + + ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store " + "iter"); + goto out; + } +@@ -2140,7 +2194,9 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo) + + ret = gf_store_iter_destroy (iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_DESTROY_FAIL, ++ "Failed to destroy store " + "iter"); + goto out; + } +@@ -2167,13 +2223,15 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + gf_store_iter_t *tmpiter = NULL; + char *tmpvalue = NULL; + struct pmap_registry *pmap = NULL; ++ xlator_t *this = NULL; + int brickid = 0; + gf_store_op_errno_t op_errno = GD_STORE_SUCCESS; + + GF_ASSERT (volinfo); + GF_ASSERT (volinfo->volname); + +- priv = THIS->private; ++ this = THIS; ++ priv = this->private; + + GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv); + +@@ -2208,9 +2266,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + + ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to iterate " +- "the store for brick: %s, reason: %s", path, +- gf_store_strerror (op_errno)); ++ gf_msg ("glusterd", GF_LOG_ERROR, op_errno, ++ GD_MSG_STORE_ITER_GET_FAIL, "Unable to iterate " ++ "the store for brick: %s", path); + goto out; + } + while (!ret) { +@@ -2286,7 +2344,8 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + strncpy (brickinfo->brick_id, value, + sizeof (brickinfo->brick_id)); + } else { +- gf_log ("", GF_LOG_ERROR, "Unknown key: %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNKNOWN_KEY, "Unknown key: %s", + key); + } + +@@ -2300,7 +2359,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + } + + if (op_errno != GD_STORE_EOF) { +- gf_log ("", GF_LOG_ERROR, "Error parsing brickinfo: " ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ GD_MSG_PARSE_BRICKINFO_FAIL, ++ "Error parsing brickinfo: " + "op_errno=%d", op_errno); + goto out; + } +@@ -2323,7 +2384,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + if (ret) + goto out; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -2390,15 +2451,17 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo) + dup_value = gf_strdup (value); + if (!dup_value) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Failed to strdup value string"); + goto out; + } + ret = dict_set_str (tmp_dict, key, dup_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Error setting data in rebal " +- "dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Error setting data in rebal " ++ "dict."); + goto out; + } + dup_value = NULL; +@@ -2432,7 +2495,7 @@ out: + if (tmp_dict) + dict_unref (tmp_dict); + +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -2464,26 +2527,29 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + + ret = gf_store_handle_retrieve (path, &volinfo->shandle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDLE_NULL, "volinfo handle is NULL"); + goto out; + } + + ret = gf_store_iter_new (volinfo->shandle, &iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store " + "iter"); + goto out; + } + + ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store " + "iter"); + goto out; + } + + while (!ret) { +- gf_log ("", GF_LOG_DEBUG, "key = %s value = %s", key, value); ++ gf_msg_debug (this->name, 0, "key = %s value = %s", key, value); + if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TYPE, + strlen (GLUSTERD_STORE_KEY_VOL_TYPE))) { + volinfo->type = atoi (value); +@@ -2521,7 +2587,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + strlen (GLUSTERD_STORE_KEY_VOL_ID))) { + ret = gf_uuid_parse (value, volinfo->volume_id); + if (ret) +- gf_log ("", GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UUID_PARSE_FAIL, + "failed to parse uuid"); + + } else if (!strncmp (key, GLUSTERD_STORE_KEY_USERNAME, +@@ -2538,11 +2605,12 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + ret = dict_set_dynstr (volinfo->gsync_slaves, key, + gf_strdup (value)); + if (ret) { +- gf_log ("",GF_LOG_ERROR, "Error in " +- "dict_set_str"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Error in " ++ "dict_set_str"); + goto out; + } +- gf_log ("", GF_LOG_DEBUG, "Parsed as "GEOREP" " ++ gf_msg_debug (this->name, 0, "Parsed as "GEOREP" " + " slave:key=%s,value:%s", key, value); + + } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_OP_VERSION, +@@ -2561,7 +2629,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + strlen (GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP))) { + ret = gf_uuid_parse (value, volinfo->restored_from_snap); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UUID_PARSE_FAIL, + "failed to parse restored snap's uuid"); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_PARENT_VOLNAME, + strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) { +@@ -2611,7 +2680,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + /*Ignore GLUSTERD_STORE_KEY_VOL_BRICK since + glusterd_store_retrieve_bricks gets it later*/ + if (!strstr (key, GLUSTERD_STORE_KEY_VOL_BRICK)) +- gf_log ("", GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UNKNOWN_KEY, + "Unknown key: %s", key); + break; + +@@ -2627,11 +2697,13 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + ret = dict_set_str(volinfo->dict, key, + gf_strdup (value)); + if (ret) { +- gf_log ("",GF_LOG_ERROR, "Error in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Error in " + "dict_set_str"); + goto out; + } +- gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-" ++ gf_msg_debug (this->name, 0, "Parsed as Volume-" + "set:key=%s,value:%s", key, value); + break; + } +@@ -2702,7 +2774,9 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) + + ret = gf_store_iter_destroy (iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_DESTROY_FAIL, ++ "Failed to destroy store " + "iter"); + goto out; + } +@@ -2747,7 +2821,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) + + ret = glusterd_store_update_volinfo (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to update volinfo " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_UPDATE_FAIL, "Failed to update volinfo " + "for %s volume", volname); + goto out; + } +@@ -2789,7 +2864,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) + ret = glusterd_volinfo_find (volinfo->parent_volname, + &origin_volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Parent volinfo " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "Parent volinfo " + "not found for %s volume", volname); + goto out; + } +@@ -2803,7 +2879,7 @@ out: + volinfo = NULL; + } + +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + + return volinfo; + } +@@ -2929,7 +3005,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) + dir = opendir (path); + + if (!dir) { +- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, "Unable to open dir %s", path); + goto out; + } + +@@ -2942,7 +3019,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) + + volinfo = glusterd_store_retrieve_volume (entry->d_name, snap); + if (!volinfo) { +- gf_log ("", GF_LOG_ERROR, "Unable to restore " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_RESTORE_FAIL, "Unable to restore " + "volume: %s", entry->d_name); + ret = -1; + goto out; +@@ -2951,7 +3029,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) + ret = glusterd_store_retrieve_node_state (volinfo); + if (ret) { + /* Backward compatibility */ +- gf_log ("", GF_LOG_INFO, "Creating a new node_state " ++ gf_log (this->name, GF_LOG_INFO, ++ "Creating a new node_state " + "for volume: %s.", entry->d_name); + glusterd_store_create_nodestate_sh_on_absence (volinfo); + ret = glusterd_store_perform_node_state_store (volinfo); +@@ -2966,7 +3045,7 @@ next: + out: + if (dir) + closedir (dir); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -2999,7 +3078,8 @@ glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path) + /* Snapshot bricks must have brick num as part + * of the brickpath + */ +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, + "Invalid brick path(%s)", brick_path); + ret = -1; + goto out; +@@ -3023,7 +3103,7 @@ out: + GF_FREE (*brick_mount_path); + *brick_mount_path = NULL; + } +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3071,24 +3151,26 @@ glusterd_mount_brick_paths (char *brick_mount_path, + NULL); + ret = runner_run (&runner); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to activate %s. Error: %s", +- brickinfo->device_path, strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_SNAP_ACTIVATE_FAIL, ++ "Failed to activate %s.", ++ brickinfo->device_path); + goto out; + } else +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Activating %s successful", brickinfo->device_path); + + /* Mount the snapshot */ + ret = glusterd_mount_lvm_snapshot (brickinfo, brick_mount_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_MOUNT_FAIL, + "Failed to mount lvm snapshot."); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3118,7 +3200,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, + ret = glusterd_find_brick_mount_path (brickinfo->path, + &brick_mount_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MNTPATH_GET_FAIL, + "Failed to find brick_mount_path for %s", + brickinfo->path); + goto out; +@@ -3132,17 +3215,17 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, + ret = mkdir_p (brick_mount_path, 0777, + _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to create %s. " +- "Error: %s", brick_mount_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, ++ "Failed to create %s. ", ++ brick_mount_path); + goto out; + } + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "Brick Path(%s) not valid. " +- "Error: %s", brickinfo->path, +- strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "Brick Path(%s) not valid. ", ++ brickinfo->path); + goto out; + } + } +@@ -3151,7 +3234,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, + * If not, mount the device_path at the brick_mount_path */ + ret = glusterd_mount_brick_paths (brick_mount_path, brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MNTPATH_MOUNT_FAIL, + "Failed to mount brick_mount_path"); + } + +@@ -3166,7 +3250,7 @@ out: + if (ret && brick_mount_path) + GF_FREE (brick_mount_path); + +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3185,7 +3269,8 @@ glusterd_resolve_snap_bricks (xlator_t *this, glusterd_snap_t *snap) + brick_list) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, + "resolve brick failed in restore"); + goto out; + } +@@ -3195,7 +3280,7 @@ glusterd_resolve_snap_bricks (xlator_t *this, glusterd_snap_t *snap) + ret = 0; + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -3224,33 +3309,37 @@ glusterd_store_update_snap (glusterd_snap_t *snap) + + ret = gf_store_handle_retrieve (path, &snap->shandle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "snap handle is NULL"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDLE_NULL, "snap handle is NULL"); + goto out; + } + + ret = gf_store_iter_new (snap->shandle, &iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store " + "iter"); + goto out; + } + + ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store " + "iter"); + goto out; + } + + while (!ret) { +- gf_log (this->name, GF_LOG_DEBUG, "key = %s value = %s", ++ gf_msg_debug (this->name, 0, "key = %s value = %s", + key, value); + + if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_ID, + strlen (GLUSTERD_STORE_KEY_SNAP_ID))) { + ret = gf_uuid_parse (value, snap->snap_id); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UUID_PARSE_FAIL, + "Failed to parse uuid"); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_RESTORED, + strlen (GLUSTERD_STORE_KEY_SNAP_RESTORED))) { +@@ -3279,7 +3368,9 @@ glusterd_store_update_snap (glusterd_snap_t *snap) + + ret = gf_store_iter_destroy (iter); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_ITER_DESTROY_FAIL, ++ "Failed to destroy store " + "iter"); + } + +@@ -3302,22 +3393,26 @@ glusterd_store_retrieve_snap (char *snapname) + + snap = glusterd_new_snap_object (); + if (!snap) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create " +- " snap object"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_OBJECT_STORE_FAIL, "Failed to create " ++ " snap object"); + goto out; + } + + strncpy (snap->snapname, snapname, strlen(snapname)); + ret = glusterd_store_update_snap (snap); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to update snapshot " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPSHOT_UPDATE_FAIL, ++ "Failed to update snapshot " + "for %s snap", snapname); + goto out; + } + + ret = glusterd_store_retrieve_volumes (this, snap); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to retrieve " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_VOL_RETRIEVE_FAIL, "Failed to retrieve " + "snap volumes for snap %s", snapname); + goto out; + } +@@ -3329,7 +3424,7 @@ glusterd_store_retrieve_snap (char *snapname) + glusterd_compare_snap_time); + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3363,11 +3458,13 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this) + if (!fp) { + /* If errno is ENOENT then there are no missed snaps yet */ + if (errno != ENOENT) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to open %s. " +- "Error: %s", path, strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "Failed to open %s. ", ++ path); + } else { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_MISSED_SNAP_LIST_EMPTY, + "No missed snaps list."); + ret = 0; + } +@@ -3380,16 +3477,16 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this) + &store_errno); + if (ret) { + if (store_errno == GD_STORE_EOF) { +- gf_log (this->name, +- GF_LOG_DEBUG, ++ gf_msg_debug (this->name, ++ 0, + "EOF for missed_snap_list"); + ret = 0; + break; + } +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, store_errno, ++ GD_MSG_MISSED_SNAP_GET_FAIL, + "Failed to fetch data from " +- "missed_snaps_list. Error: %s", +- gf_store_strerror (store_errno)); ++ "missed_snaps_list."); + goto out; + } + +@@ -3403,7 +3500,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this) + if (!missed_node_info || !brick_path || !snap_vol_id || + brick_num < 1 || snap_op < 1 || + snap_status < 1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_MISSED_SNAP_ENTRY, + "Invalid missed_snap_entry"); + ret = -1; + goto out; +@@ -3416,7 +3514,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this) + snap_op, + snap_status); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL, + "Failed to store missed snaps_list"); + goto out; + } +@@ -3425,7 +3524,7 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this) + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3452,7 +3551,9 @@ glusterd_store_retrieve_snaps (xlator_t *this) + backward compatibility */ + if (errno != ENOENT) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, "Unable to open dir %s", ++ path); + } + goto out; + } +@@ -3463,7 +3564,8 @@ glusterd_store_retrieve_snaps (xlator_t *this) + if (strcmp (entry->d_name, GLUSTERD_MISSED_SNAPS_LIST_FILE)) { + ret = glusterd_store_retrieve_snap (entry->d_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_RESTORE_FAIL, + "Unable to restore snapshot: %s", + entry->d_name); + goto out; +@@ -3475,7 +3577,7 @@ glusterd_store_retrieve_snaps (xlator_t *this) + /* Retrieve missed_snaps_list */ + ret = glusterd_store_retrieve_missed_snaps_list (this); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to retrieve missed_snaps_list"); + goto out; + } +@@ -3483,7 +3585,7 @@ glusterd_store_retrieve_snaps (xlator_t *this) + out: + if (dir) + closedir (dir); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -3522,7 +3624,8 @@ glusterd_store_write_missed_snapinfo (int32_t fd) + snap_opinfo->op, snap_opinfo->status); + ret = gf_store_save_value (fd, key, value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSEDSNAP_INFO_SET_FAIL, + "Failed to write missed snapinfo"); + goto out; + } +@@ -3531,7 +3634,7 @@ glusterd_store_write_missed_snapinfo (int32_t fd) + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3553,14 +3656,17 @@ glusterd_store_update_missed_snaps () + + ret = glusterd_store_create_missed_snaps_list_shandle_on_absence (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to obtain " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_LIST_STORE_HANDLE_GET_FAIL, ++ "Unable to obtain " + "missed_snaps_list store handle."); + goto out; + } + + fd = gf_store_mkstemp (priv->missed_snaps_list_shandle); + if (fd <= 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "Failed to create tmp file"); + ret = -1; + goto out; +@@ -3568,14 +3674,16 @@ glusterd_store_update_missed_snaps () + + ret = glusterd_store_write_missed_snapinfo (fd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_CREATE_FAIL, + "Failed to write missed snaps to disk"); + goto out; + } + + ret = gf_store_rename_tmppath (priv->missed_snaps_list_shandle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "Failed to rename the tmp file"); + goto out; + } +@@ -3583,13 +3691,14 @@ out: + if (ret && (fd > 0)) { + ret = gf_store_unlink_tmppath (priv->missed_snaps_list_shandle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TMP_FILE_UNLINK_FAIL, + "Failed to unlink the tmp file"); + } + ret = -1; + } + +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3598,6 +3707,7 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo) + { + int32_t ret = -1; + glusterd_conf_t *priv = NULL; ++ xlator_t *this = NULL; + char peerdir[PATH_MAX] = {0,}; + char filepath[PATH_MAX] = {0,}; + char hostname_path[PATH_MAX] = {0,}; +@@ -3608,7 +3718,8 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo) + goto out; + } + +- priv = THIS->private; ++ this = THIS; ++ priv = this->private; + + snprintf (peerdir, PATH_MAX, "%s/peers", priv->workdir); + +@@ -3644,7 +3755,7 @@ out: + gf_store_handle_destroy (peerinfo->shandle); + peerinfo->shandle = NULL; + } +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -3669,7 +3780,7 @@ glusterd_store_create_peer_dir () + glusterd_store_peerinfo_dirpath_set (path, sizeof (path)); + ret = gf_store_mkdir (path); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3798,7 +3909,7 @@ glusterd_store_peer_write (int fd, glusterd_peerinfo_t *peerinfo) + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3824,7 +3935,7 @@ glusterd_store_perform_peer_store (glusterd_peerinfo_t *peerinfo) + out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (peerinfo->shandle); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -3845,7 +3956,7 @@ glusterd_store_peerinfo (glusterd_peerinfo_t *peerinfo) + + ret = glusterd_store_perform_peer_store (peerinfo); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3879,7 +3990,9 @@ glusterd_store_retrieve_peers (xlator_t *this) + dir = opendir (path); + + if (!dir) { +- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, ++ "Unable to open dir %s", path); + ret = -1; + goto out; + } +@@ -3925,7 +4038,8 @@ glusterd_store_retrieve_peers (xlator_t *this) + strlen (GLUSTERD_STORE_KEY_PEER_HOSTNAME))) { + ret = gd_add_address_to_peer (peerinfo, value); + } else { +- gf_log ("", GF_LOG_ERROR, "Unknown key: %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNKNOWN_KEY, "Unknown key: %s", + key); + } + +@@ -3982,7 +4096,7 @@ out: + + if (dir) + closedir (dir); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -4012,7 +4126,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this) + + ret = glusterd_recreate_vol_brick_mounts (this, volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MNT_RECREATE_FAIL, + "Failed to recreate brick mounts " + "for %s", volinfo->volname); + goto out; +@@ -4025,7 +4140,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this) + ret = glusterd_recreate_vol_brick_mounts (this, + volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MNT_RECREATE_FAIL, + "Failed to recreate brick mounts " + "for %s", snap->snapname); + goto out; +@@ -4034,7 +4150,7 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this) + } + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -4066,7 +4182,8 @@ glusterd_snap_cleanup (xlator_t *this) + + dict = dict_new(); + if (!dict) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_CREATE_FAIL, + "Failed to create dict"); + ret = -1; + goto out; +@@ -4077,7 +4194,9 @@ glusterd_snap_cleanup (xlator_t *this) + if (snap->snap_status == GD_SNAP_STATUS_RESTORED) { + ret = glusterd_snapshot_revert_restore_from_snap (snap); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_SNAP_RESTORE_REVERT_FAIL, ++ "Failed to " + "revert partially restored snapshot " + "(%s)", snap->snapname); + goto out; +@@ -4086,7 +4205,8 @@ glusterd_snap_cleanup (xlator_t *this) + ret = glusterd_snap_remove (dict, snap, + _gf_true, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_REMOVE_FAIL, + "Failed to remove the snapshot %s", + snap->snapname); + goto out; +@@ -4097,7 +4217,7 @@ out: + if (dict) + dict_unref (dict); + +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -4121,7 +4241,8 @@ glusterd_resolve_all_bricks (xlator_t *this) + brick_list) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, + "resolve brick failed in restore"); + goto out; + } +@@ -4132,7 +4253,8 @@ glusterd_resolve_all_bricks (xlator_t *this) + cds_list_for_each_entry (snap, &priv->snapshots, snap_list) { + ret = glusterd_resolve_snap_bricks (this, snap); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_RESOLVE_BRICK_FAIL, + "resolving the snap bricks" + " failed for snap: %s", + snap->snapname); +@@ -4141,7 +4263,7 @@ glusterd_resolve_all_bricks (xlator_t *this) + } + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); ++ gf_msg_trace (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -4179,20 +4301,22 @@ glusterd_restore () + + ret = glusterd_snap_cleanup (this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to perform " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_CLEANUP_FAIL, "Failed to perform " + "a cleanup of the snapshots"); + goto out; + } + + ret = glusterd_recreate_all_snap_brick_mounts (this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to recreate " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_BRK_MNT_RECREATE_FAIL, "Failed to recreate " + "all snap brick mounts"); + goto out; + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4220,22 +4344,24 @@ glusterd_store_retrieve_quota_version (glusterd_volinfo_t *volinfo) + + ret = gf_store_handle_new (cksum_path, &handle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get store handle " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_HANDLE_GET_FAIL, ++ "Unable to get store handle " + "for %s", cksum_path); + goto out; + } + + ret = gf_store_retrieve_value (handle, "version", &version_str); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Version absent"); ++ gf_msg_debug (this->name, 0, "Version absent"); + ret = 0; + goto out; + } + + version = strtoul (version_str, &tmp, 10); + if ((errno == ERANGE) || (errno == EINVAL)) { +- gf_log (this->name, GF_LOG_DEBUG, "Invalid version number"); +- goto out; ++ gf_msg_debug (this->name, 0, "Invalid version number"); ++ goto out; + } + volinfo->quota_conf_version = version; + ret = 0; +@@ -4279,7 +4405,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo) + snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_cksum); + ret = gf_store_save_value (fd, "cksum", buf); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store cksum"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_STORE_FAIL, "Failed to store cksum"); + goto out; + } + +@@ -4287,7 +4414,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo) + snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_version); + ret = gf_store_save_value (fd, "version", buf); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store version"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERS_STORE_FAIL, "Failed to store version"); + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 39160c0..57592c8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -45,6 +45,7 @@ + #include "glusterd-scrub-svc.h" + #include "glusterd-quotad-svc.h" + #include "glusterd-snapd-svc.h" ++#include "glusterd-messages.h" + #include "common-utils.h" + #include "glusterd-geo-rep.h" + #include "run.h" +@@ -159,7 +160,8 @@ glusterd_uuid_init () + ret = glusterd_uuid_generate_save (); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_UUID_GEN_STORE_FAIL, + "Unable to generate and save new UUID"); + return ret; + } +@@ -187,7 +189,8 @@ glusterd_uuid_generate_save () + ret = glusterd_store_global_info (this); + + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_STORE_FAIL, + "Unable to store the generated uuid %s", + uuid_utoa (priv->uuid)); + +@@ -219,7 +222,8 @@ glusterd_options_init (xlator_t *this) + + ret = glusterd_store_options (this, priv->opts); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to store version"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERS_STORE_FAIL, "Unable to store version"); + return ret; + } + out: +@@ -298,7 +302,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_gld_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Memory accounting init" + " failed"); + return ret; + } +@@ -315,7 +320,8 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + glusterd_conf_t *priv = NULL; + + if (!xl || !data) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_NO_INIT, + "Calling rpc_notify without initializing"); + goto out; + } +@@ -360,7 +366,7 @@ glusterd_program_register (xlator_t *this, rpcsvc_t *svc, + + ret = rpcsvc_program_register (svc, prog); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "cannot register program (name: %s, prognum:%d, " + "progver:%d)", prog->progname, prog->prognum, + prog->progver); +@@ -389,7 +395,7 @@ glusterd_rpcsvc_options_build (dict_t *options) + goto out; + } + +- gf_log ("", GF_LOG_DEBUG, "listen-backlog value: %d", backlog); ++ gf_msg_debug ("", 0, "listen-backlog value: %d", backlog); + + out: + return ret; +@@ -410,12 +416,14 @@ glusterd_check_gsync_present (int *valid_state) + ret = runner_start (&runner); + if (ret == -1) { + if (errno == ENOENT) { +- gf_log ("glusterd", GF_LOG_INFO, GEOREP ++ gf_msg ("glusterd", GF_LOG_INFO, errno, ++ GD_MSG_MODULE_NOT_INSTALLED, GEOREP + " module not installed in the system"); + *valid_state = 0; + } + else { +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_MODULE_NOT_WORKING, GEOREP + " module not working as desired"); + *valid_state = -1; + } +@@ -426,14 +434,16 @@ glusterd_check_gsync_present (int *valid_state) + if (ptr) { + if (!strstr (buff, "gsyncd")) { + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_WORKING, GEOREP" module not " + "working as desired"); + *valid_state = -1; + goto out; + } + } else { + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_WORKING, GEOREP" module not " + "working as desired"); + *valid_state = -1; + goto out; +@@ -444,7 +454,7 @@ glusterd_check_gsync_present (int *valid_state) + + runner_end (&runner); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -468,7 +478,8 @@ group_write_allow (char *path, gid_t gid) + + out: + if (ret == -1) +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, errno, ++ GD_MSG_WRITE_ACCESS_GRANT_FAIL, + "failed to set up write access to %s for group %d (%s)", + path, gid, strerror (errno)); + return ret; +@@ -486,7 +497,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + + if (strlen (conf->workdir)+2 > PATH_MAX-strlen(GEOREP)) { + ret = -1; +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_DIRPATH_TOO_LONG, + "directory path %s/"GEOREP" is longer than PATH_MAX", + conf->workdir); + goto out; +@@ -495,7 +507,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + snprintf (georepdir, PATH_MAX, "%s/"GEOREP, conf->workdir); + ret = mkdir_p (georepdir, 0777, _gf_true); + if (-1 == ret) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create "GEOREP" directory %s", + georepdir); + goto out; +@@ -503,14 +516,16 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + + if (strlen (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP) >= PATH_MAX) { + ret = -1; +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_DIRPATH_TOO_LONG, + "directory path "DEFAULT_LOG_FILE_DIRECTORY"/" + GEOREP" is longer than PATH_MAX"); + goto out; + } + ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP, 0777, _gf_true); + if (-1 == ret) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create "GEOREP" log directory"); + goto out; + } +@@ -518,7 +533,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + /* Slave log file directory */ + if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves") >= PATH_MAX) { + ret = -1; +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_DIRPATH_TOO_LONG, + "directory path "DEFAULT_LOG_FILE_DIRECTORY"/" + GEOREP"-slaves"" is longer than PATH_MAX"); + goto out; +@@ -526,7 +542,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves", 0777, + _gf_true); + if (-1 == ret) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create "GEOREP" slave log directory"); + goto out; + } +@@ -534,7 +551,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + /* MountBroker log file directory */ + if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr") >= PATH_MAX) { + ret = -1; +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_DIRPATH_TOO_LONG, + "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP + "-slaves/mbr"" is longer than PATH_MAX"); + goto out; +@@ -542,7 +560,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr", 0777, + _gf_true); + if (-1 == ret) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create "GEOREP" mountbroker slave log directory"); + goto out; + } +@@ -553,7 +572,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + else { + gr = getgrnam (greplg_s); + if (!gr) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_LOGGROUP_INVALID, + "group "GEOREP"-log-group %s does not exist", greplg_s); + ret = -1; + goto out; +@@ -570,7 +590,7 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + } + + out: +- gf_log("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -822,7 +842,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) + ret = fstat (dfd, &st); + } + if (ret == -1 || !S_ISDIR (st.st_mode)) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, + "cannot access mountbroker-root directory %s", + mountbroker_root); + ret = -1; +@@ -830,14 +851,16 @@ check_prepare_mountbroker_root (char *mountbroker_root) + } + if (st.st_uid != 0 || + (st.st_mode & (S_IWGRP|S_IWOTH))) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, 0, ++ GD_MSG_DIR_PERM_LIBERAL, + "permissions on mountbroker-root directory %s are " + "too liberal", mountbroker_root); + ret = -1; + goto out; + } + if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { +- gf_log ("", GF_LOG_WARNING, ++ gf_msg ("", GF_LOG_WARNING, 0, ++ GD_MSG_DIR_PERM_STRICT, + "permissions on mountbroker-root directory %s are " + "probably too strict", mountbroker_root); + } +@@ -851,7 +874,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) + ret = fstat (dfd2, &st2); + } + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, + "error while checking mountbroker-root ancestors " + "%d (%s)", errno, strerror (errno)); + goto out; +@@ -863,14 +887,16 @@ check_prepare_mountbroker_root (char *mountbroker_root) + if (st2.st_uid != 0 || + ((st2.st_mode & (S_IWGRP|S_IWOTH)) && + !(st2.st_mode & S_ISVTX))) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, 0, ++ GD_MSG_DIR_PERM_LIBERAL, + "permissions on ancestors of mountbroker-root " + "directory are too liberal"); + ret = -1; + goto out; + } + if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { +- gf_log ("", GF_LOG_WARNING, ++ gf_msg ("", GF_LOG_WARNING, 0, ++ GD_MSG_DIR_PERM_STRICT, + "permissions on ancestors of mountbroker-root " + "directory are probably too strict"); + } +@@ -886,7 +912,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) + if (ret != -1) + ret = sys_fstatat (dfd0, MB_HIVE, &st, AT_SYMLINK_NOFOLLOW); + if (ret == -1 || st.st_mode != (S_IFDIR|0711)) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "failed to set up mountbroker-root directory %s", + mountbroker_root); + ret = -1; +@@ -977,7 +1004,8 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data) + return 0; + err: + +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("", GF_LOG_ERROR, 0, ++ GD_MSG_MOUNT_SPEC_INSTALL_FAIL, + "adding %smount spec failed: label: %s desc: %s", + georep ? GEOREP" " : "", label, pdesc); + +@@ -1042,14 +1070,14 @@ glusterd_init_uds_listener (xlator_t *this) + ret = rpcsvc_register_notify (rpc, glusterd_uds_rpcsvc_notify, + this); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Failed to register notify function"); + goto out; + } + + ret = rpcsvc_create_listeners (rpc, options, this->name); + if (ret != 1) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to create listener"); ++ gf_msg_debug (this->name, 0, "Failed to create listener"); + goto out; + } + ret = 0; +@@ -1071,7 +1099,9 @@ out: + dict_unref (options); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to start glusterd " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_SOCK_LISTENER_START_FAIL, ++ "Failed to start glusterd " + "unix domain socket listener."); + if (rpc) { + GF_FREE (rpc); +@@ -1165,7 +1195,8 @@ glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir) + */ + ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "stat fails on %s, exiting. (errno = %d)", + GLUSTERD_VAR_RUN_DIR, errno); + goto out; +@@ -1200,7 +1231,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, + + ret = stat (abs_path, &buf); + if ((ret != 0) && (ENOENT != errno)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "stat fails on %s, exiting. (errno = %d)", + abs_path, errno); + ret = -1; +@@ -1208,7 +1240,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, + } + + if ((!ret) && (!S_ISDIR(buf.st_mode))) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, ENOENT, ++ GD_MSG_DIR_NOT_FOUND, + "Provided snap path %s is not a directory," + "exiting", abs_path); + ret = -1; +@@ -1220,7 +1253,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, + ret = mkdir_p (abs_path, 0777, _gf_true); + + if (-1 == ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create directory %s" + " ,errno = %d", abs_path, errno); + goto out; +@@ -1247,27 +1281,32 @@ glusterd_svc_init_all () + /* Init SHD svc */ + ret = glusterd_shdsvc_init (&(priv->shd_svc)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to init shd service"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_SHDSVC, ++ "Failed to init shd service"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "shd service initialized"); ++ gf_msg_debug (THIS->name, 0, "shd service initialized"); + + /* Init NFS svc */ + ret = glusterd_nfssvc_init (&(priv->nfs_svc)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to init nfs service"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_NFSSVC, ++ "Failed to init nfs service"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "nfs service initialized"); ++ gf_msg_debug (THIS->name, 0, "nfs service initialized"); + + /* Init QuotaD svc */ + ret = glusterd_quotadsvc_init (&(priv->quotad_svc)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to init quotad " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init quotad " + "service"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "quotad service initialized"); ++ gf_msg_debug (THIS->name, 0, "quotad service initialized"); + + /* Init BitD svc */ + ret = glusterd_bitdsvc_init (&(priv->bitd_svc)); +@@ -1323,7 +1362,8 @@ init (xlator_t *this) + lim.rlim_max = 65536; + + if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_SETXATTR_FAIL, + "Failed to set 'ulimit -n " + " 65536': %s", strerror(errno)); + } else { +@@ -1345,14 +1385,16 @@ init (xlator_t *this) + + ret = stat (workdir, &buf); + if ((ret != 0) && (ENOENT != errno)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, + "stat fails on %s, exiting. (errno = %d)", + workdir, errno); + exit (1); + } + + if ((!ret) && (!S_ISDIR(buf.st_mode))) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, ENOENT, ++ GD_MSG_DIR_NOT_FOUND, + "Provided working area %s is not a directory," + "exiting", workdir); + exit (1); +@@ -1363,7 +1405,8 @@ init (xlator_t *this) + ret = mkdir_p (workdir, 0777, _gf_true); + + if (-1 == ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create directory %s" + " ,errno = %d", workdir, errno); + exit (1); +@@ -1386,8 +1429,9 @@ init (xlator_t *this) + ret = glusterd_init_var_run_dirs (this, var_run_dir, + GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to create " +- "snap backend dir"); ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_CREATE_DIR_FAILED, "Unable to create " ++ "snap backend folder"); + exit (1); + } + +@@ -1410,7 +1454,8 @@ init (xlator_t *this) + ret = gf_cmd_log_init (cmd_log_filename); + + if (ret == -1) { +- gf_log ("this->name", GF_LOG_CRITICAL, ++ gf_msg ("this->name", GF_LOG_CRITICAL, errno, ++ GD_MSG_FILE_OP_FAILED, + "Unable to create cmd log file %s", cmd_log_filename); + exit (1); + } +@@ -1420,7 +1465,8 @@ init (xlator_t *this) + ret = mkdir (storedir, 0777); + + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create volume directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1431,7 +1477,8 @@ init (xlator_t *this) + ret = mkdir (storedir, 0777); + + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create snaps directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1442,7 +1489,8 @@ init (xlator_t *this) + ret = mkdir (storedir, 0777); + + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create peers directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1451,7 +1499,8 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/bricks", DEFAULT_LOG_FILE_DIRECTORY); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create logs directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1460,7 +1509,8 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/nfs", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create nfs directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1487,7 +1537,8 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/glustershd", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create glustershd directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1496,7 +1547,8 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/quotad", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create quotad directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1505,7 +1557,8 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/groups", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, + "Unable to create glustershd directory %s" + " ,errno = %d", storedir, errno); + exit (1); +@@ -1516,14 +1569,16 @@ init (xlator_t *this) + goto out; + rpc = rpcsvc_init (this, this->ctx, this->options, 64); + if (rpc == NULL) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_INIT_FAIL, + "failed to init rpc"); + goto out; + } + + ret = rpcsvc_register_notify (rpc, glusterd_rpcsvc_notify, this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPCSVC_REG_NOTIFY_RETURNED, + "rpcsvc_register_notify returned %d", ret); + goto out; + } +@@ -1538,7 +1593,8 @@ init (xlator_t *this) + ret = dict_set_str (this->options, + "transport.socket.own-thread", "off"); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to clear own-thread"); + goto out; + } +@@ -1561,14 +1617,16 @@ init (xlator_t *this) + + ret = dict_get_str (this->options, "transport-type", &transport_type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get transport type"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get transport type"); + ret = -1; + goto out; + } + + total_transport = rpc_transport_count (transport_type); + if (total_transport <= 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_TRANSPORT_COUNT_GET_FAIL, + "failed to get total number of available tranpsorts"); + ret = -1; + goto out; +@@ -1576,12 +1634,14 @@ init (xlator_t *this) + + ret = rpcsvc_create_listeners (rpc, this->options, this->name); + if (ret < 1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_LISTENER_CREATE_FAIL, + "creation of listener failed"); + ret = -1; + goto out; + } else if (ret < total_transport) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_LISTENER_CREATE_FAIL, + "creation of %d listeners failed, continuing with " + "succeeded transport", (total_transport - ret)); + } +@@ -1641,20 +1701,22 @@ init (xlator_t *this) + + conf->base_port = GF_IANA_PRIV_PORTS_START; + if (dict_get_uint32(this->options, "base-port", &conf->base_port) == 0) { +- gf_log (this->name, GF_LOG_INFO, +- "base-port override: %d", conf->base_port); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "base-port override: %d", conf->base_port); + } + + /* Set option to run bricks on valgrind if enabled in glusterd.vol */ + conf->valgrind = _gf_false; + ret = dict_get_str (this->options, "run-with-valgrind", &valgrind_str); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "cannot get run-with-valgrind value"); + } + if (valgrind_str) { + if (gf_string2boolean (valgrind_str, &(conf->valgrind))) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_INVALID_ENTRY, + "run-with-valgrind value not a boolean string"); + } + } +@@ -1675,7 +1737,8 @@ init (xlator_t *this) + */ + ret = glusterd_hooks_create_hooks_directory (conf->workdir); + if (-1 == ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_DIR_OP_FAILED, + "Unable to create hooks directory "); + exit (1); + } +@@ -1709,7 +1772,8 @@ init (xlator_t *this) + * */ + ret = glusterd_restore_op_version (this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERS_RESTORE_FAIL, + "Failed to restore op_version"); + goto out; + } +-- +1.7.1 + diff --git a/SOURCES/0089-handler-messages-glusterd-Porting-to-new-logging-fra.patch b/SOURCES/0089-handler-messages-glusterd-Porting-to-new-logging-fra.patch new file mode 100644 index 0000000..e49ec06 --- /dev/null +++ b/SOURCES/0089-handler-messages-glusterd-Porting-to-new-logging-fra.patch @@ -0,0 +1,2145 @@ +From d7f00db9f94b1e68f0a7e0fbd4e30a69a1fd04d2 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Tue, 17 Mar 2015 18:03:36 +0530 +Subject: [PATCH 089/101] handler, messages/glusterd: Porting to new logging framework + +cherry-picked from commit cdda561c0a1f4c8050f664a444fe8b88d17e3b10 +>Change-Id: If67230445678dd895d69f18c9982c3f0fda62dbd +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9910 +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: Atin Mukherjee + +Change-Id: If67230445678dd895d69f18c9982c3f0fda62dbd +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50894 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 495 +++++++++++++------- + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 149 ++++--- + 2 files changed, 428 insertions(+), 216 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 9c922e3..683b402 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -123,7 +123,9 @@ glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t uuid, + (GD_FRIEND_EVENT_RCVD_FRIEND_REQ, &event); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "event generation failed: %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, ++ "event generation failed: %d", ret); + goto out; + } + +@@ -133,7 +135,8 @@ glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t uuid, + ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_friend_req_ctx_t); + + if (!ctx) { +- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Unable to allocate memory"); + ret = -1; + goto out; + } +@@ -163,7 +166,9 @@ glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t uuid, + + ret = glusterd_friend_sm_inject_event (event); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject event %d, " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, ++ "Unable to inject event %d, " + "ret = %d", event->event, ret); + goto out; + } +@@ -213,7 +218,8 @@ glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t uuid, + peerinfo = glusterd_peerinfo_find (uuid, hostname); + + if (peerinfo == NULL) { +- gf_log ("glusterd", GF_LOG_CRITICAL, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, 0, ++ GD_MSG_REQ_FROM_UNKNOWN_PEER, + "Received remove-friend from unknown peer %s", + hostname); + ret = glusterd_xfer_friend_remove_resp (req, hostname, +@@ -225,7 +231,9 @@ glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t uuid, + (GD_FRIEND_EVENT_RCVD_REMOVE_FRIEND, &event); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "event generation failed: %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, ++ "event generation failed: %d", ret); + goto out; + } + +@@ -235,7 +243,8 @@ glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t uuid, + ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_friend_req_ctx_t); + + if (!ctx) { +- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Unable to allocate memory"); + ret = -1; + goto out; + } +@@ -250,7 +259,8 @@ glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t uuid, + ret = glusterd_friend_sm_inject_event (event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject event %d, " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, "Unable to inject event %d, " + "ret = %d", event->event, ret); + goto out; + } +@@ -652,7 +662,8 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + * op state machine. */ + ret = glusterd_generate_txn_id (dict, &txn_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_IDGEN_FAIL, + "Failed to generate transaction id"); + goto out; + } +@@ -662,7 +673,8 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + * is the originator node for a command. */ + ret = glusterd_set_originator_uuid (dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_SET_FAIL, + "Failed to set originator_uuid."); + goto out; + } +@@ -671,7 +683,8 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + if (priv->op_version < GD_OP_VERSION_RHS_3_0) { + ret = glusterd_lock (MY_UUID); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_LOCK_FAIL, + "Unable to acquire lock on localhost, ret: %d", + ret); + snprintf (err_str, err_len, +@@ -684,7 +697,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + * not be held */ + ret = dict_get_str (dict, "volname", &tmp); + if (ret) { +- gf_log ("", GF_LOG_INFO, ++ gf_log (this->name, GF_LOG_INFO, + "No Volume name present. " + "Locks not being held."); + goto local_locking_done; +@@ -700,7 +713,8 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + ret = glusterd_mgmt_v3_lock (volname, MY_UUID, &op_errno, + "vol"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Unable to acquire lock for %s", volname); + snprintf (err_str, err_len, + "Another transaction is in progress for %s. " +@@ -710,7 +724,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + } + + locked = 1; +- gf_log (this->name, GF_LOG_DEBUG, "Acquired lock on localhost"); ++ gf_msg_debug (this->name, 0, "Acquired lock on localhost"); + + local_locking_done: + /* If no volname is given as a part of the command, locks will +@@ -727,7 +741,8 @@ local_locking_done: + + ret = glusterd_set_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_SET_FAIL, + "Unable to set transaction's opinfo"); + if (ctx) + dict_unref (ctx); +@@ -736,7 +751,8 @@ local_locking_done: + + ret = glusterd_op_sm_inject_event (event_type, txn_id, ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to acquire cluster" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, "Failed to acquire cluster" + " lock."); + goto out; + } +@@ -751,7 +767,8 @@ out: + ret = glusterd_mgmt_v3_unlock (volname, MY_UUID, + "vol"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Unable to release lock for %s", + volname); + ret = -1; +@@ -761,7 +778,7 @@ out: + if (volname) + GF_FREE (volname); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -789,20 +806,22 @@ __glusterd_handle_cluster_lock (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &lock_req, + (xdrproc_t)xdr_gd1_mgmt_cluster_lock_req); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode lock " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode lock " + "request received from peer"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Received LOCK from uuid: %s", ++ gf_msg_debug (this->name, 0, "Received LOCK from uuid: %s", + uuid_utoa (lock_req.uuid)); + + rcu_read_lock (); + ret = (glusterd_peerinfo_find_by_uuid (lock_req.uuid) == NULL); + rcu_read_unlock (); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "%s doesn't " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PEER_NOT_FOUND, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (lock_req.uuid)); + ret = -1; +@@ -822,7 +841,8 @@ __glusterd_handle_cluster_lock (rpcsvc_request_t *req) + + op_ctx = dict_new (); + if (!op_ctx) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_DICT_CREATE_FAIL, + "Unable to set new dict"); + goto out; + } +@@ -831,7 +851,8 @@ __glusterd_handle_cluster_lock (rpcsvc_request_t *req) + + ret = glusterd_set_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_SET_FAIL, + "Unable to set transaction's opinfo"); + dict_unref (txn_op_info.op_ctx); + goto out; +@@ -839,11 +860,12 @@ __glusterd_handle_cluster_lock (rpcsvc_request_t *req) + + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_LOCK, txn_id, ctx); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, + "Failed to inject event GD_OP_EVENT_LOCK"); + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + glusterd_friend_sm (); + glusterd_op_sm (); +@@ -875,7 +897,7 @@ glusterd_req_ctx_create (rpcsvc_request_t *rpc_req, + GF_ASSERT (this); + + gf_uuid_unparse (uuid, str); +- gf_log (this->name, GF_LOG_DEBUG, "Received op from uuid %s", str); ++ gf_msg_debug (this->name, 0, "Received op from uuid %s", str); + + dict = dict_new (); + if (!dict) +@@ -890,7 +912,8 @@ glusterd_req_ctx_create (rpcsvc_request_t *rpc_req, + req_ctx->op = op; + ret = dict_unserialize (buf_val, buf_len, &dict); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to unserialize the dictionary"); + goto out; + } +@@ -931,7 +954,8 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &op_req, + (xdrproc_t)xdr_gd1_mgmt_stage_op_req); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode stage " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode stage " + "request received from peer"); + req->rpc_err = GARBAGE_ARGS; + goto out; +@@ -941,19 +965,21 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req) + op_req.buf.buf_val, op_req.buf.buf_len, + gf_gld_mt_op_stage_ctx_t, &req_ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create req_ctx"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_CTX_CREATE_FAIL, "Failed to create req_ctx"); + goto out; + } + + ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + rcu_read_lock (); + ret = (glusterd_peerinfo_find_by_uuid (op_req.uuid) == NULL); + rcu_read_unlock (); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "%s doesn't " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PEER_NOT_FOUND, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (op_req.uuid)); + ret = -1; +@@ -965,7 +991,7 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req) + * phase where the transaction opinfos are created, won't be called. */ + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No transaction's opinfo set"); + + state.state = GD_OP_STATE_LOCKED; +@@ -974,7 +1000,8 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req) + + ret = glusterd_set_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_SET_FAIL, + "Unable to set transaction's opinfo"); + dict_unref (req_ctx->dict); + goto out; +@@ -984,7 +1011,8 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req) + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_STAGE_OP, + txn_id, req_ctx); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, + "Failed to inject event GD_OP_EVENT_STAGE_OP"); + + out: +@@ -1022,7 +1050,8 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &op_req, + (xdrproc_t)xdr_gd1_mgmt_commit_op_req); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode commit " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode commit " + "request received from peer"); + req->rpc_err = GARBAGE_ARGS; + goto out; +@@ -1032,7 +1061,8 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req) + ret = (glusterd_peerinfo_find_by_uuid (op_req.uuid) == NULL); + rcu_read_unlock (); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "%s doesn't " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PEER_NOT_FOUND, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (op_req.uuid)); + ret = -1; +@@ -1048,7 +1078,7 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req) + goto out; + + ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_OP, +@@ -1087,7 +1117,8 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; +- gf_log ("", GF_LOG_ERROR, "xdr decoding error"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "xdr decoding error"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1098,7 +1129,8 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + ret = dict_unserialize (cli_req.dict.dict_val, + cli_req.dict.dict_len, &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "Failed to " + "unserialize req-buffer to dictionary"); + goto out; + } +@@ -1106,13 +1138,16 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + + ret = dict_get_str (dict, "hostname", &hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get hostname"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_NOTFOUND_IN_DICT, ++ "Failed to get hostname"); + goto out; + } + + ret = dict_get_int32 (dict, "port", &port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get port"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PORT_NOTFOUND_IN_DICT, "Failed to get port"); + goto out; + } + +@@ -1132,7 +1167,7 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + + if (dict_get_str(this->options,"transport.socket.bind-address", + &bind_name) == 0) { +- gf_log ("glusterd", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "only checking probe address vs. bind address"); + ret = gf_is_same_address (bind_name, hostname); + } +@@ -1154,7 +1189,7 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + rcu_read_unlock (); + + if (ret) { +- gf_log ("glusterd", GF_LOG_DEBUG, "Probe host %s port %d " ++ gf_msg_debug ("glusterd", 0, "Probe host %s port %d " + "already a peer", hostname, port); + glusterd_xfer_cli_probe_resp (req, 0, GF_PROBE_FRIEND, NULL, + hostname, port, dict); +@@ -1218,6 +1253,9 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1228,7 +1266,8 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req) + ret = dict_unserialize (cli_req.dict.dict_val, + cli_req.dict.dict_len, &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "Failed to " + "unserialize req-buffer to dictionary"); + goto out; + } +@@ -1238,18 +1277,22 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req) + + ret = dict_get_str (dict, "hostname", &hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get hostname"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_NOTFOUND_IN_DICT, ++ "Failed to get hostname"); + goto out; + } + + ret = dict_get_int32 (dict, "port", &port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get port"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PORT_NOTFOUND_IN_DICT, "Failed to get port"); + goto out; + } + ret = dict_get_int32 (dict, "flags", &flags); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get flags"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FLAGS_NOTFOUND_IN_DICT, "Failed to get flags"); + goto out; + } + +@@ -1342,6 +1385,9 @@ __glusterd_handle_cli_list_friends (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf1_cli_peer_list_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1356,7 +1402,8 @@ __glusterd_handle_cli_list_friends (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + goto out; +@@ -1397,6 +1444,9 @@ __glusterd_handle_cli_get_volume (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1411,7 +1461,8 @@ __glusterd_handle_cli_get_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + goto out; +@@ -1422,7 +1473,8 @@ __glusterd_handle_cli_get_volume (rpcsvc_request_t *req) + + ret = dict_get_int32 (dict, "flags", &flags); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to get flags"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FLAGS_NOTFOUND_IN_DICT, "failed to get flags"); + goto out; + } + +@@ -1466,11 +1518,14 @@ __glusterd_handle_cli_uuid_reset (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } + +- gf_log ("glusterd", GF_LOG_DEBUG, "Received uuid reset req"); ++ gf_msg_debug ("glusterd", 0, "Received uuid reset req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -1480,7 +1535,8 @@ __glusterd_handle_cli_uuid_reset (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg_str, sizeof (msg_str), "Unable to decode " +@@ -1500,7 +1556,8 @@ __glusterd_handle_cli_uuid_reset (rpcsvc_request_t *req) + snprintf (msg_str, sizeof (msg_str), "volumes are already " + "present in the cluster. Resetting uuid is not " + "allowed"); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg_str); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLS_ALREADY_PRESENT, "%s", msg_str); + goto out; + } + +@@ -1509,7 +1566,8 @@ __glusterd_handle_cli_uuid_reset (rpcsvc_request_t *req) + snprintf (msg_str, sizeof (msg_str),"trusted storage pool " + "has been already formed. Please detach this peer " + "from the pool and reset its uuid."); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg_str); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_TSP_ALREADY_FORMED, "%s", msg_str); + goto out; + } + +@@ -1519,7 +1577,8 @@ __glusterd_handle_cli_uuid_reset (rpcsvc_request_t *req) + if (!gf_uuid_compare (uuid, MY_UUID)) { + snprintf (msg_str, sizeof (msg_str), "old uuid and the new uuid" + " are same. Try gluster peer reset again"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUIDS_SAME_RETRY, "%s", msg_str); + ret = -1; + goto out; + } +@@ -1570,11 +1629,14 @@ __glusterd_handle_cli_uuid_get (rpcsvc_request_t *req) + + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } + +- gf_log ("glusterd", GF_LOG_DEBUG, "Received uuid get req"); ++ gf_msg_debug ("glusterd", 0, "Received uuid get req"); + + if (cli_req.dict.dict_len) { + dict = dict_new (); +@@ -1587,7 +1649,8 @@ __glusterd_handle_cli_uuid_get (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg_str, sizeof (msg_str), "Unable to decode " +@@ -1609,7 +1672,8 @@ __glusterd_handle_cli_uuid_get (rpcsvc_request_t *req) + uuid_utoa_r (MY_UUID, uuid_str); + ret = dict_set_str (rsp_dict, "uuid", uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set uuid in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set uuid in " + "dictionary."); + goto out; + } +@@ -1617,7 +1681,9 @@ __glusterd_handle_cli_uuid_get (rpcsvc_request_t *req) + ret = dict_allocate_and_serialize (rsp_dict, &rsp.dict.dict_val, + &rsp.dict.dict_len); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize " + "dictionary."); + goto out; + } +@@ -1747,7 +1813,8 @@ __glusterd_handle_ganesha_cmd (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Failed to decode " + "request received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1764,7 +1831,8 @@ __glusterd_handle_ganesha_cmd (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -1820,7 +1888,8 @@ __glusterd_handle_reset_volume (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Failed to decode request " + "received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1833,8 +1902,9 @@ __glusterd_handle_reset_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " +- "unserialize req-buffer to dictionary"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " ++ "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " + "the command"); + goto out; +@@ -1847,10 +1917,11 @@ __glusterd_handle_reset_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAME_NOTFOUND_IN_DICT, "%s", err_str); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Received volume reset request for " ++ gf_msg_debug (this->name, 0, "Received volume reset request for " + "volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_RESET_VOLUME, dict); +@@ -1898,7 +1969,8 @@ __glusterd_handle_set_volume (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Failed to decode " + "request received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -1911,7 +1983,8 @@ __glusterd_handle_set_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -1926,7 +1999,8 @@ __glusterd_handle_set_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get volume " + "name while handling volume set command"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -1941,7 +2015,8 @@ __glusterd_handle_set_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get key while" + " handling volume set for %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -1949,10 +2024,11 @@ __glusterd_handle_set_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get value while" + " handling volume set for %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Received volume set request for " ++ gf_msg_debug (this->name, 0, "Received volume set request for " + "volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_SET_VOLUME, dict); +@@ -2000,6 +2076,9 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2012,7 +2091,8 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " +@@ -2026,7 +2106,8 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + ret = dict_get_str (dict, "hostname", &hostname); + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get hostname"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_NOTFOUND_IN_DICT, "%s", msg); + goto out; + } + +@@ -2036,7 +2117,8 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get volume name" + " or flags"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FLAGS_NOTFOUND_IN_DICT, "%s", msg); + goto out; + } + } +@@ -2048,7 +2130,8 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + ret = -1; + snprintf (msg, sizeof (msg), "sync from localhost" + " not allowed"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SYNC_FROM_LOCALHOST_UNALLOWED, "%s", msg); + goto out; + } + +@@ -2096,7 +2179,7 @@ glusterd_fsm_log_send_resp (rpcsvc_request_t *req, int op_ret, + (xdrproc_t)xdr_gf1_cli_fsm_log_rsp); + GF_FREE (rsp.fsm_log.fsm_log_val); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Responded, ret: %d", ret); ++ gf_msg_debug ("glusterd", 0, "Responded, ret: %d", ret); + + return 0; + } +@@ -2119,6 +2202,9 @@ __glusterd_handle_fsm_log (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf1_cli_fsm_log_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from client."); + req->rpc_err = GARBAGE_ARGS; + snprintf (msg, sizeof (msg), "Garbage request"); + goto out; +@@ -2182,7 +2268,7 @@ glusterd_op_lock_send_resp (rpcsvc_request_t *req, int32_t status) + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Responded to lock, ret: %d", ret); ++ gf_msg_debug (THIS->name, 0, "Responded to lock, ret: %d", ret); + + return 0; + } +@@ -2201,7 +2287,7 @@ glusterd_op_unlock_send_resp (rpcsvc_request_t *req, int32_t status) + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Responded to unlock, ret: %d", ret); ++ gf_msg_debug (THIS->name, 0, "Responded to unlock, ret: %d", ret); + + return ret; + } +@@ -2225,7 +2311,7 @@ glusterd_op_mgmt_v3_lock_send_resp (rpcsvc_request_t *req, uuid_t *txn_id, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_v3_lock_rsp); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Responded to mgmt_v3 lock, ret: %d", ++ gf_msg_debug (THIS->name, 0, "Responded to mgmt_v3 lock, ret: %d", + ret); + + return ret; +@@ -2250,7 +2336,7 @@ glusterd_op_mgmt_v3_unlock_send_resp (rpcsvc_request_t *req, uuid_t *txn_id, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_v3_unlock_rsp); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Responded to mgmt_v3 unlock, ret: %d", ++ gf_msg_debug (THIS->name, 0, "Responded to mgmt_v3 unlock, ret: %d", + ret); + + return ret; +@@ -2277,21 +2363,23 @@ __glusterd_handle_cluster_unlock (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &unlock_req, + (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode unlock " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode unlock " + "request received from peer"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Received UNLOCK from uuid: %s", uuid_utoa (unlock_req.uuid)); + + rcu_read_lock (); + ret = (glusterd_peerinfo_find_by_uuid (unlock_req.uuid) == NULL); + rcu_read_unlock (); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "%s doesn't " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PEER_NOT_FOUND, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (unlock_req.uuid)); + ret = -1; +@@ -2302,6 +2390,8 @@ __glusterd_handle_cluster_unlock (rpcsvc_request_t *req) + + if (!ctx) { + //respond here ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "No memory."); + return -1; + } + gf_uuid_copy (ctx->uuid, unlock_req.uuid); +@@ -2348,7 +2438,8 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req, + ret = dict_allocate_and_serialize (rsp_dict, &rsp.dict.dict_val, + &rsp.dict.dict_len); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, + "failed to get serialized length of dict"); + return ret; + } +@@ -2356,7 +2447,7 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); + +- gf_log (this->name, GF_LOG_DEBUG, "Responded to stage, ret: %d", ret); ++ gf_msg_debug (this->name, 0, "Responded to stage, ret: %d", ret); + GF_FREE (rsp.dict.dict_val); + + return ret; +@@ -2387,7 +2478,8 @@ glusterd_op_commit_send_resp (rpcsvc_request_t *req, + ret = dict_allocate_and_serialize (rsp_dict, &rsp.dict.dict_val, + &rsp.dict.dict_len); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, + "failed to get serialized length of dict"); + goto out; + } +@@ -2397,7 +2489,7 @@ glusterd_op_commit_send_resp (rpcsvc_request_t *req, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); + +- gf_log (this->name, GF_LOG_DEBUG, "Responded to commit, ret: %d", ret); ++ gf_msg_debug (this->name, 0, "Responded to commit, ret: %d", ret); + + out: + GF_FREE (rsp.dict.dict_val); +@@ -2416,6 +2508,9 @@ __glusterd_handle_incoming_friend_req (rpcsvc_request_t *req) + (xdrproc_t)xdr_gd1_mgmt_friend_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from friend"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2462,6 +2557,9 @@ __glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) + (xdrproc_t)xdr_gd1_mgmt_friend_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received."); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2472,7 +2570,9 @@ __glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) + ret = glusterd_remote_hostname_get (req, remote_hostname, + sizeof (remote_hostname)); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get the remote hostname"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_RESOLVE_FAIL, ++ "Unable to get the remote hostname"); + goto out; + } + ret = glusterd_handle_unfriend_req (req, friend_req.uuid, +@@ -2511,7 +2611,7 @@ glusterd_handle_friend_update_delete (dict_t *dict) + ret = glusterd_friend_remove (NULL, hostname); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -2526,7 +2626,8 @@ glusterd_peer_hostname_update (glusterd_peerinfo_t *peerinfo, + + ret = gd_add_address_to_peer (peerinfo, hostname); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_ADD_TO_PEERLIST_FAIL, + "Couldn't add address to the peer info"); + goto out; + } +@@ -2534,7 +2635,7 @@ glusterd_peer_hostname_update (glusterd_peerinfo_t *peerinfo, + if (store_update) + ret = glusterd_store_peerinfo (peerinfo); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2567,6 +2668,9 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + (xdrproc_t)xdr_gd1_mgmt_friend_update); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2578,7 +2682,9 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + } + rcu_read_unlock (); + if (ret) { +- gf_log ("", GF_LOG_CRITICAL, "Received friend update request " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_REQ_FROM_UNKNOWN_PEER, ++ "Received friend update request " + "from unknown peer %s", uuid_utoa (friend_req.uuid)); + goto out; + } +@@ -2594,7 +2700,8 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + friend_req.friends.friends_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + goto out; +@@ -2644,7 +2751,8 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + peerinfo = gd_peerinfo_from_dict (dict, key); + if (peerinfo == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEERINFO_CREATE_FAIL, + "Could not create peerinfo from dict " + "for prefix %s", key); + goto unlock; +@@ -2665,7 +2773,9 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + ret = gd_update_peerinfo_from_dict (peerinfo, dict, + key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_INFO_UPDATE_FAIL, ++ "Failed to " + "update peer %s", peerinfo->hostname); + } + } +@@ -2725,6 +2835,9 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + (xdrproc_t)xdr_gd1_mgmt_probe_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode probe " ++ "request"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2744,7 +2857,8 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + * sending the error. + */ + if (!gf_uuid_compare (probe_req.uuid, MY_UUID)) { +- gf_log (THIS->name, GF_LOG_ERROR, "Peer uuid %s is same as " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUIDS_SAME_RETRY, "Peer uuid %s is same as " + "local uuid. Please check the uuid of both the peers " + "from %s/%s", uuid_utoa (probe_req.uuid), + GLUSTERD_DEFAULT_WORKDIR, GLUSTERD_INFO_FILE); +@@ -2757,7 +2871,9 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + ret = glusterd_remote_hostname_get (req, remote_hostname, + sizeof (remote_hostname)); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get the remote hostname"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_RESOLVE_FAIL, ++ "Unable to get the remote hostname"); + goto out; + } + +@@ -2774,7 +2890,9 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + GD_FRIEND_STATE_PROBE_RCVD, + NULL, &peerinfo, 0, &args); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Failed to add peer %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PEER_ADD_FAIL, ++ "Failed to add peer %s", + remote_hostname); + rsp.op_errno = GF_PROBE_ADD_FAILED; + } +@@ -2828,6 +2946,9 @@ __glusterd_handle_cli_profile_volume (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -2844,7 +2965,8 @@ __glusterd_handle_cli_profile_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAME_NOTFOUND_IN_DICT, "%s", err_str); + goto out; + } + +@@ -2853,7 +2975,8 @@ __glusterd_handle_cli_profile_volume (rpcsvc_request_t *req) + ret = dict_get_int32 (dict, "op", &op); + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get operation"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -2873,7 +2996,7 @@ out: + dict, err_str); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2932,6 +3055,9 @@ __glusterd_handle_mount (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf1_cli_mount_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode mount " ++ "request received"); + req->rpc_err = GARBAGE_ARGS; + rsp.op_ret = -1; + rsp.op_errno = EINVAL; +@@ -2948,7 +3074,8 @@ __glusterd_handle_mount (rpcsvc_request_t *req) + mnt_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + rsp.op_ret = -1; +@@ -3013,6 +3140,9 @@ __glusterd_handle_umount (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf1_cli_umount_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode umount" ++ "request"); + req->rpc_err = GARBAGE_ARGS; + rsp.op_ret = -1; + goto out; +@@ -3106,15 +3236,15 @@ glusterd_friend_remove (uuid_t uuid, char *hostname) + + ret = glusterd_friend_remove_cleanup_vols (peerinfo->uuid); + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, "Volumes cleanup failed"); +- ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_CLEANUP_FAIL, "Volumes cleanup failed"); + rcu_read_unlock (); + /* Giving up the critical section here as glusterd_peerinfo_cleanup must + * be called from outside a critical section + */ + ret = glusterd_peerinfo_cleanup (peerinfo); + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "returning %d", ret); + return ret; + } + +@@ -3150,7 +3280,7 @@ out: + } + } + +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -3204,7 +3334,8 @@ glusterd_transport_inet_options_build (dict_t **options, const char *hostname, + */ + ret = dict_set_int32 (dict, "frame-timeout", 600); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set frame-timeout"); + goto out; + } +@@ -3217,7 +3348,7 @@ glusterd_transport_inet_options_build (dict_t **options, const char *hostname, + time, timeout); + *options = dict; + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -3271,7 +3402,9 @@ glusterd_friend_rpc_create (xlator_t *this, glusterd_peerinfo_t *peerinfo, + ret = glusterd_rpc_create (&peerinfo->rpc, options, + glusterd_peer_rpc_notify, peerctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create rpc for" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_CREATE_FAIL, ++ "failed to create rpc for" + " peer %s", peerinfo->hostname); + goto out; + } +@@ -3325,7 +3458,8 @@ glusterd_friend_add (const char *hoststr, int port, + ret = glusterd_friend_rpc_create (this, *friend, args); + } + else { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEERINFO_CREATE_FAIL, + "Failed to store peerinfo"); + } + } +@@ -3378,7 +3512,8 @@ glusterd_friend_add_from_peerinfo (glusterd_peerinfo_t *friend, + ret = glusterd_friend_rpc_create (this, friend, args); + } + else { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEERINFO_CREATE_FAIL, + "Failed to store peerinfo"); + } + } +@@ -3446,7 +3581,7 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port, + + out: + rcu_read_unlock (); +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -3488,8 +3623,9 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port, + (GD_FRIEND_EVENT_INIT_REMOVE_FRIEND, &event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, +- "Unable to get new event"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, ++ "Unable to get new event"); + goto out; + } + +@@ -3512,7 +3648,8 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port, + ret = glusterd_friend_sm_inject_event (event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject event %d, " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, "Unable to inject event %d, " + "ret = %d", event->event, ret); + goto out; + } +@@ -3695,7 +3832,8 @@ glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret, + if (dict) { + ret = dict_get_str (dict, "cmd-str", &cmd_str); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CMDSTR_NOTFOUND_IN_DICT, "Failed to get " + "command string"); + } + +@@ -3713,7 +3851,7 @@ glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret, + + if (dict) + dict_unref (dict); +- gf_log (this->name, GF_LOG_DEBUG, "Responded to CLI, ret: %d",ret); ++ gf_msg_debug (this->name, 0, "Responded to CLI, ret: %d", ret); + + return ret; + } +@@ -3790,7 +3928,8 @@ glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret, + if (dict) { + ret = dict_get_str (dict, "cmd-str", &cmd_str); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_CMDSTR_NOTFOUND_IN_DICT, "Failed to get " + "command string"); + } + +@@ -3806,7 +3945,7 @@ glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gf_cli_rsp); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Responded to CLI, ret: %d",ret); ++ gf_msg_debug (THIS->name, 0, "Responded to CLI, ret: %d", ret); + + return ret; + } +@@ -3828,7 +3967,8 @@ glusterd_list_friends (rpcsvc_request_t *req, dict_t *dict, int32_t flags) + + friends = dict_new (); + if (!friends) { +- gf_log ("", GF_LOG_WARNING, "Out of Memory"); ++ gf_msg (THIS->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of Memory"); + goto out; + } + +@@ -3910,7 +4050,8 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags) + + volumes = dict_new (); + if (!volumes) { +- gf_log ("", GF_LOG_WARNING, "Out of Memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of Memory"); + goto out; + } + +@@ -4023,6 +4164,9 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -4034,7 +4178,8 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) + ret = dict_unserialize (cli_req.dict.dict_val, + cli_req.dict.dict_len, &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize buffer"); + snprintf (err_str, sizeof (err_str), "Unable to decode " + "the command"); +@@ -4052,7 +4197,8 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get " + "volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", err_str); + goto out; + } + gf_log (this->name, GF_LOG_INFO, +@@ -4139,6 +4285,9 @@ __glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req) + ret = -1; + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -4150,7 +4299,8 @@ __glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to unserialize req-buffer to" + " dictionary"); + snprintf (err_str, sizeof (err_str), "unable to decode " +@@ -4160,7 +4310,8 @@ __glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req) + + } else { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Empty cli request."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CLI_REQ_EMPTY, "Empty cli request."); + goto out; + } + +@@ -4168,7 +4319,8 @@ __glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAME_NOTFOUND_IN_DICT, "%s", err_str); + goto out; + } + +@@ -4218,7 +4370,8 @@ get_volinfo_from_brickid (char *brickid, glusterd_volinfo_t **volinfo) + volid_str = brickid_dup; + brick = strchr (brickid_dup, ':'); + if (!brick) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_NOT_FOUND, + "Invalid brickid"); + goto out; + } +@@ -4231,7 +4384,8 @@ get_volinfo_from_brickid (char *brickid, glusterd_volinfo_t **volinfo) + /* Check if it is a snapshot volume */ + ret = glusterd_snap_volinfo_find_by_volume_id (volid, volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLINFO_GET_FAIL, + "Failed to find volinfo"); + goto out; + } +@@ -4258,6 +4412,9 @@ __glusterd_handle_barrier (rpcsvc_request_t *req) + + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -4275,14 +4432,17 @@ __glusterd_handle_barrier (rpcsvc_request_t *req) + ret = dict_unserialize (cli_req.dict.dict_val, cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to unserialize " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "Failed to unserialize " + "request dictionary."); + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Volname not present in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAME_NOTFOUND_IN_DICT, ++ "Volname not present in " + "dict"); + goto out; + } +@@ -4337,7 +4497,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get volume " + "name while handling get volume option command"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLNAME_NOTFOUND_IN_DICT, "%s", err_str); + goto out; + } + +@@ -4345,17 +4506,19 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get key " + "while handling get volume option for %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Received get volume opt request for " ++ gf_msg_debug (this->name, 0, "Received get volume opt request for " + "volume %s", volname); + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + snprintf (err_str, sizeof(err_str), + FMTSTR_CHECK_VOL_EXISTS, volname); +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -4364,7 +4527,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + if (!exists) { + snprintf (err_str, sizeof (err_str), "Option " + "with name: %s does not exist", key); +- gf_log (this->name, GF_LOG_ERROR, "%s", ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_UNKNOWN_KEY, "%s", + err_str); + if (key_fixed) + snprintf (err_str + ret, +@@ -4382,7 +4546,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + sprintf (dict_key, "key%d", count); + ret = dict_set_str(dict, dict_key, key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set %s in dictionary", key); + goto out; + } +@@ -4390,7 +4555,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + sprintf (op_version_buff, "%d", priv->op_version); + ret = dict_set_str (dict, dict_key, op_version_buff); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set value for key %s in dictionary", + key); + goto out; +@@ -4400,7 +4566,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + sprintf (dict_key, "key%d", count); + ret = dict_set_str(dict, dict_key, key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set %s in dictionary", key); + goto out; + } +@@ -4411,7 +4578,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + else + ret = dict_set_str(dict, dict_key,"Disabled"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set value for key %s in dictionary", + key); + goto out; +@@ -4421,7 +4589,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + sprintf (dict_key, "key%d", count); + ret = dict_set_str(dict, dict_key, key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set %s in dictionary", key); + goto out; + } +@@ -4438,7 +4607,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + ret = dict_set_str(dict, dict_key,"none"); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to " + "set value for key %s in dictionary", + key); + goto out; +@@ -4463,7 +4633,8 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict) + */ + ret = dict_set_int32 (dict, "count", 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set count " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set count " + "value in the dictionary"); + goto out; + } +@@ -4517,7 +4688,8 @@ __glusterd_handle_get_vol_opt (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Failed to decode " + "request received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -4530,7 +4702,8 @@ __glusterd_handle_get_vol_opt (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -4635,7 +4808,8 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, + brickinfo->path); + ret = get_volinfo_from_brickid (brickid, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, + "Failed to get volinfo from " + "brickid(%s)", brickid); + goto out; +@@ -4644,7 +4818,8 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, + ret = glusterd_brick_stop (volinfo, brickinfo, + _gf_false); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_STOP_FAIL, + "Unable to stop %s:%s", + brickinfo->hostname, brickinfo->path); + goto out; +@@ -4652,7 +4827,7 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, + + break; + } +- gf_log (this->name, GF_LOG_DEBUG, "Connected to %s:%s", ++ gf_msg_debug (this->name, 0, "Connected to %s:%s", + brickinfo->hostname, brickinfo->path); + glusterd_set_brick_status (brickinfo, GF_BRICK_STARTED); + ret = default_notify (this, GF_EVENT_CHILD_UP, NULL); +@@ -4674,7 +4849,7 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, + mydata = NULL; + break; + default: +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "got some other RPC event %d", event); + break; + } +@@ -4706,7 +4881,7 @@ glusterd_friend_remove_notify (glusterd_peerctx_t *peerctx) + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Could not find peer %s(%s). " ++ gf_msg_debug (THIS->name, 0, "Could not find peer %s(%s). " + "Peer could have been deleted.", peerctx->peername, + uuid_utoa (peerctx->peerid)); + ret = 0; +@@ -4721,7 +4896,8 @@ glusterd_friend_remove_notify (glusterd_peerctx_t *peerctx) + &new_event); + if (!ret) { + if (!req) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, + "Unable to find the request for responding " + "to User (%s)", peerinfo->hostname); + goto out; +@@ -4736,7 +4912,8 @@ glusterd_friend_remove_notify (glusterd_peerctx_t *peerctx) + ret = glusterd_friend_sm_inject_event (new_event); + + } else { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, + "Unable to create event for removing peer %s", + peerinfo->hostname); + } +@@ -4780,7 +4957,8 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + /* Peerinfo should be available at this point. Not finding it + * means that something terrible has happened + */ +- gf_log (THIS->name, GF_LOG_CRITICAL, "Could not find peer " ++ gf_msg (THIS->name, GF_LOG_CRITICAL, ENOENT, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer " + "%s(%s)", peerctx->peername, uuid_utoa (peerctx->peerid)); + ret = -1; + goto out; +@@ -4790,7 +4968,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + case RPC_CLNT_CONNECT: + { + rpc_clnt_set_connected (&rpc->conn); +- gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); ++ gf_msg_debug (this->name, 0, "got RPC_CLNT_CONNECT"); + peerinfo->connected = 1; + peerinfo->quorum_action = _gf_true; + peerinfo->generation = uatomic_add_return +@@ -4799,7 +4977,9 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + + ret = glusterd_peer_dump_version (this, rpc, peerctx); + if (ret) +- gf_log ("", GF_LOG_ERROR, "glusterd handshake failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDSHAKE_FAILED, ++ "glusterd handshake failed"); + break; + } + +@@ -4828,8 +5008,9 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + peerinfo->uuid, + "vol"); + if (ret) +- gf_log (this->name, +- GF_LOG_TRACE, ++ gf_msg (this->name, ++ GF_LOG_WARNING, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Lock not released " + "for %s", + volinfo->volname); +@@ -4859,7 +5040,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + } + + default: +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "got some other RPC event %d", event); + ret = 0; + break; +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index 9806556..db9b36c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -25,6 +25,7 @@ + #include "glusterd-svc-helper.h" + #include "glusterd-nfs-svc.h" + #include "glusterd-volgen.h" ++#include "glusterd-messages.h" + #include "run.h" + #include "syscall.h" + +@@ -58,6 +59,9 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "Failed to decode " ++ "request received from cli"); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -72,7 +76,8 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " +@@ -84,13 +89,14 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof (msg), "Could not get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + + ret = dict_get_int32 (dict, "operation", &op); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dict_get on operation failed"); + snprintf (msg, sizeof (msg), "Could not get operation"); + goto out; +@@ -100,21 +106,23 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get src brick"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "src brick=%s", src_brick); + + ret = dict_get_str (dict, "dst-brick", &dst_brick); + + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get dest brick"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "dst brick=%s", dst_brick); ++ gf_msg_debug (this->name, 0, "dst brick=%s", dst_brick); + gf_log (this->name, GF_LOG_INFO, "Received replace brick commit-force " + "request operation"); + +@@ -198,31 +206,34 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + ret = dict_get_str (dict, "src-brick", &src_brick); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get src brick"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get src brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "src brick=%s", src_brick); ++ gf_msg_debug (this->name, 0, "src brick=%s", src_brick); + + ret = dict_get_str (dict, "dst-brick", &dst_brick); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get dest brick"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get dest brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "dst brick=%s", dst_brick); ++ gf_msg_debug (this->name, 0, "dst brick=%s", dst_brick); + + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = dict_get_str (dict, "operation", &replace_op); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dict get on replace-brick operation failed"); + goto out; + } +@@ -255,7 +266,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + !glusterd_is_valid_volfpath (volname, dst_brick)) { + snprintf (msg, sizeof (msg), "brick path %s is too " + "long.", dst_brick); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRKPATH_TOO_LONG, "%s", msg); + *op_errstr = gf_strdup (msg); + + ret = -1; +@@ -273,7 +285,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + if (glusterd_is_defrag_on(volinfo)) { + snprintf (msg, sizeof(msg), "Volume name %s rebalance is in " + "progress. Please retry after completion", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OIP_RETRY_LATER, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; +@@ -299,7 +312,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + + if (ctx) { + if (!glusterd_is_fuse_available ()) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to open /dev/" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RB_CMD_FAIL, "Unable to open /dev/" + "fuse (%s), replace-brick command failed", + strerror (errno)); + snprintf (msg, sizeof(msg), "Fuse unavailable\n " +@@ -311,13 +325,13 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + } + + if (gf_is_local_addr (src_brickinfo->hostname)) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "I AM THE SOURCE HOST"); + if (src_brickinfo->port && rsp_dict) { + ret = dict_set_int32 (rsp_dict, "src-brick-port", + src_brickinfo->port); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "Could not set src-brick-port=%d", + src_brickinfo->port); + } +@@ -331,14 +345,16 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + dup_dstbrick = gf_strdup (dst_brick); + if (!dup_dstbrick) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Memory allocation failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Memory allocation failed"); + goto out; + } + host = strtok_r (dup_dstbrick, ":", &savetok); + path = strtok_r (NULL, ":", &savetok); + + if (!host || !path) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BAD_FORMAT, + "dst brick %s is not of form :", + dst_brick); + ret = -1; +@@ -370,7 +386,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + *op_errstr = gf_strdup ("Incorrect source or " + "destination brick"); + if (*op_errstr) +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_BRICK_NOT_FOUND, "%s", *op_errstr); + goto out; + } + +@@ -418,7 +435,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + dst_brickinfo->hostname, + dst_brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNTDIR_GET_FAIL, + "Failed to get brick mount_dir"); + goto out; + } +@@ -426,14 +444,16 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir", + dst_brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set brick1.mount_dir"); + goto out; + } + + ret = dict_set_int32 (rsp_dict, "brick_count", 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set local_brick_count"); + goto out; + } +@@ -443,7 +463,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + + out: + GF_FREE (dup_dstbrick); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -547,7 +567,6 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + if (!dict_ret) + dst_brickinfo->port = dst_port; + +- + if (gf_is_local_addr (dst_brickinfo->hostname)) { + gf_log ("", GF_LOG_INFO, + "adding dst-brick port no"); +@@ -621,7 +640,8 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo, + if (conf->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = dict_get_str (dict, "brick1.mount_dir", &brick_mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_BRICK_MOUNTDIR_GET_FAIL, + "brick1.mount_dir not present"); + goto out; + } +@@ -678,43 +698,47 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + + ret = dict_get_str (dict, "src-brick", &src_brick); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get src brick"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get src brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "src brick=%s", src_brick); ++ gf_msg_debug (this->name, 0, "src brick=%s", src_brick); + + ret = dict_get_str (dict, "dst-brick", &dst_brick); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get dst brick"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get dst brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "dst brick=%s", dst_brick); ++ gf_msg_debug (this->name, 0, "dst brick=%s", dst_brick); + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = dict_get_str (dict, "operation", &replace_op); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dict_get on operation failed"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Unable to allocate memory"); + goto out; + } + + ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo, + &src_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to get src-brickinfo"); + goto out; + } +@@ -722,14 +746,15 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + + ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RB_BRICKINFO_GET_FAIL, "Unable to get " + "replace brick destination brickinfo"); + goto out; + } + + ret = glusterd_resolve_brick (dst_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to resolve dst-brickinfo"); + goto out; + } +@@ -743,7 +768,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + if (is_origin_glusterd (dict)) { + ctx = glusterd_op_get_ctx(); + if (!ctx) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, "Failed to " + "get op_ctx"); + ret = -1; + goto out; +@@ -763,7 +789,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + gf_log (this->name, GF_LOG_DEBUG, "I AM THE DESTINATION HOST"); + ret = rb_kill_destination_brick (volinfo, dst_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_BRK_CLEANUP_FAIL, + "Unable to cleanup dst brick"); + goto out; + } +@@ -778,7 +805,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + ret = glusterd_op_perform_replace_brick (volinfo, src_brick, + dst_brick, dict); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to add dst-brick: " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_BRICK_ADD_FAIL, "Unable to add dst-brick: " + "%s to volume: %s", dst_brick, volinfo->volname); + (void) glusterd_svcs_manager (volinfo); + goto out; +@@ -788,7 +816,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + + ret = glusterd_svcs_manager (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_NFS_VOL_FILE_GEN_FAIL, + "Failed to generate nfs volume file"); + } + +@@ -802,7 +831,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Couldn't store" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RBOP_STATE_STORE_FAIL, "Couldn't store" + " replace brick operation's state"); + + out: +@@ -838,73 +868,74 @@ glusterd_do_replace_brick (void *data) + if (priv->timer) { + gf_timer_call_cancel (THIS->ctx, priv->timer); + priv->timer = NULL; +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "Cancelling timer thread"); + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Replace brick operation detected"); + + ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + ret = dict_get_str (dict, "src-brick", &src_brick); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get src brick"); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get src brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "src brick=%s", src_brick); + + ret = dict_get_str (dict, "dst-brick", &dst_brick); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get dst brick"); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get dst brick"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dst brick=%s", dst_brick); + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to find volinfo"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOLINFO_GET_FAIL, "Unable to find volinfo"); + goto out; + } + + ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo, + &src_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Unable to get " +- "src-brickinfo"); ++ gf_msg_debug (this->name, 0, "Unable to get src-brickinfo"); + goto out; + } + + ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); + if (!dst_brickinfo) { +- gf_log (this->name, GF_LOG_DEBUG, "Unable to get " +- "dst-brickinfo"); ++ gf_msg_debug (this->name, 0, "Unable to get dst-brickinfo"); + goto out; + } + + ret = glusterd_resolve_brick (dst_brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Unable to resolve " +- "dst-brickinfo"); ++ gf_msg_debug (this->name, 0, "Unable to resolve dst-brickinfo"); + goto out; + } + + ret = dict_get_int32 (dict, "src-brick-port", &src_port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get " +- "src-brick port"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get src-brick port"); + goto out; + } + + ret = dict_get_int32 (dict, "dst-brick-port", &dst_port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get dst-brick port"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get dst-brick port"); + } + + dst_brickinfo->port = dst_port; +-- +1.7.1 + diff --git a/SOURCES/0090-handshake-locks-mountbroker-syncop-glusterd-New-logg.patch b/SOURCES/0090-handshake-locks-mountbroker-syncop-glusterd-New-logg.patch new file mode 100644 index 0000000..fb83022 --- /dev/null +++ b/SOURCES/0090-handshake-locks-mountbroker-syncop-glusterd-New-logg.patch @@ -0,0 +1,1667 @@ +From 051717fb4e5c7678a0f04e492ebaf868ea73527f Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 12 Mar 2015 16:55:20 +0530 +Subject: [PATCH 090/101] handshake,locks,mountbroker,syncop/glusterd:New logging framework + +cherry-picked from commit 40795d95697068a0beb52364b97818dc80e49440 +>Change-Id: If491a6945b7a0afa10165ff9f9874a244aece36f +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9864 +>Tested-by: Gluster Build System +>Tested-by: NetBSD Build System +>Reviewed-by: Atin Mukherjee + +Change-Id: If491a6945b7a0afa10165ff9f9874a244aece36f +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50897 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-handshake.c | 265 ++++++++++++++-------- + xlators/mgmt/glusterd/src/glusterd-locks.c | 105 ++++++---- + xlators/mgmt/glusterd/src/glusterd-mountbroker.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 114 ++++++---- + 4 files changed, 318 insertions(+), 174 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c +index f171268..5267874 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c +@@ -26,6 +26,7 @@ + #include "glusterd-svc-mgmt.h" + #include "glusterd-snapd-svc-helper.h" + #include "glusterd-quotad-svc.h" ++#include "glusterd-messages.h" + + #include "glusterfs3.h" + #include "protocol-common.h" +@@ -75,20 +76,25 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname, + strtok_r (str_token, "/", &save_ptr); + snapname = strtok_r(NULL, "/", &save_ptr); + if (!snapname) { +- gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath); ++ gf_msg(this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, ++ "Invalid path: %s", volpath); + goto out; + } + + volname_token = strtok_r(NULL, "/", &save_ptr); + if (!volname_token) { +- gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath); ++ gf_msg (this->name, GF_LOG_ERROR, ++ EINVAL, GD_MSG_INVALID_ENTRY, ++ "Invalid path: %s", volpath); + goto out; + } + + snap = glusterd_find_snap_by_name (snapname); + if (!snap) { +- gf_log(this->name, GF_LOG_ERROR, "Failed to " +- "fetch snap %s", snapname); ++ gf_msg(this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_SNAP_NOT_FOUND, "Failed to " ++ "fetch snap %s", snapname); + goto out; + } + +@@ -110,14 +116,16 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname, + /* Split the volume name */ + vol = strtok_r (volname_token, ".", &save_ptr); + if (!vol) { +- gf_log(this->name, GF_LOG_ERROR, "Invalid " ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Invalid " + "volname (%s)", volname_token); + goto out; + } + + ret = glusterd_snap_volinfo_find (vol, snap, volinfo); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_INFO_FAIL, "Failed to " + "fetch snap volume from volname (%s)", + vol); + goto out; +@@ -128,9 +136,10 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname, + ret = glusterd_snap_volinfo_find_from_parent_volname ( + volname_token, snap, volinfo); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, "Failed to " +- "fetch snap volume from parent " +- "volname (%s)", volname_token); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_INFO_FAIL, "Failed to " ++ "fetch snap volume from parent " ++ "volname (%s)", volname_token); + goto out; + } + +@@ -187,7 +196,8 @@ build_volfile_path (char *volume_id, char *path, + + ret = glusterd_volinfo_find (volid_ptr, &volinfo); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, + "Couldn't find volinfo"); + goto out; + } +@@ -224,7 +234,8 @@ build_volfile_path (char *volume_id, char *path, + ret = get_snap_volname_and_volinfo (volid_ptr, &volname, + &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get snap" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_INFO_FAIL, "Failed to get snap" + " volinfo from path (%s)", volume_id); + ret = -1; + goto out; +@@ -252,7 +263,8 @@ build_volfile_path (char *volume_id, char *path, + + ret = glusterd_volinfo_find (volid_ptr, &volinfo); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, + "Couldn't find volinfo"); + goto out; + } +@@ -371,7 +383,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo, + ret = dict_unserialize (args->xdata.xdata_val, + args->xdata.xdata_len, &dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "Failed to unserialize request dictionary"); + goto out; + } +@@ -379,7 +392,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo, + ret = dict_get_int32 (dict, "min-op-version", + &client_min_op_version); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get client-min-op-version"); + goto out; + } +@@ -387,7 +401,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo, + ret = dict_get_int32 (dict, "max-op-version", + &client_max_op_version); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get client-max-op-version"); + goto out; + } +@@ -395,13 +410,13 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo, + ret = dict_get_str (dict, "brick_name", + brick_name); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No brick name present"); + ret = 0; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "brick_name = %s", *brick_name); ++ gf_msg_debug (this->name, 0, "brick_name = %s", *brick_name); + out: + peerinfo->max_op_version = client_max_op_version; + peerinfo->min_op_version = client_min_op_version; +@@ -439,7 +454,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + /* Find the snap-object */ + snap = glusterd_find_snap_by_id (snap_uuid); + if (!snap) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_NOT_FOUND, + "Unable to find the snap with snap_uuid %s", + missed_snapinfo->snap_uuid); + ret = -1; +@@ -456,7 +472,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + } + + if (!snap_vol) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, + "Unable to find the snap_vol(%s) " + "for snap(%s)", snap_opinfo->snap_vol_id, + snap->snapname); +@@ -472,7 +489,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + } + + if (brickinfo->snap_status != -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_STATUS_NOT_PENDING, + "The snap status of the missed " + "brick(%s) is not pending", brickinfo->path); + goto out; +@@ -481,7 +499,9 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + /* Fetch the device path */ + device = glusterd_get_brick_mount_device (snap_opinfo->brick_path); + if (!device) { +- gf_log (this->name, GF_LOG_ERROR, "Getting device name for the" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_GET_INFO_FAIL, ++ "Getting device name for the" + "brick %s:%s failed", brickinfo->hostname, + snap_opinfo->brick_path); + ret = -1; +@@ -491,7 +511,9 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + device = glusterd_build_snap_device_path (device, snap_vol->volname, + snap_opinfo->brick_num - 1); + if (!device) { +- gf_log (this->name, GF_LOG_ERROR, "cannot copy the snapshot " ++ gf_msg (this->name, GF_LOG_ERROR, ENXIO, ++ GD_MSG_SNAP_DEVICE_NAME_GET_FAIL, ++ "cannot copy the snapshot " + "device name (volname: %s, snapname: %s)", + snap_vol->volname, snap->snapname); + ret = -1; +@@ -504,7 +526,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + * snap volinfo. */ + ret = glusterd_update_mntopts (snap_opinfo->brick_path, brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to update " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to update " + "mount options for %s brick", brickinfo->path); + /* We should not fail snapshot operation if we fail to get + * the file-system type */ +@@ -512,7 +535,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + + ret = glusterd_take_lvm_snapshot (brickinfo, snap_opinfo->brick_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPSHOT_OP_FAILED, + "Failed to take snapshot of %s", + snap_opinfo->brick_path); + goto out; +@@ -525,7 +549,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + */ + ret = glusterd_update_fs_label (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to update " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_SET_INFO_FAIL, "Failed to update " + "file-system label for %s brick", brickinfo->path); + /* Failing to update label should not cause snapshot failure. + * Currently label is updated only for XFS and ext2/ext3/ext4 +@@ -537,7 +562,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + ret = glusterd_snap_brick_create (snap_vol, brickinfo, + snap_opinfo->brick_num - 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_CREATION_FAIL, "Failed to " + " create and mount the brick(%s) for the snap %s", + snap_opinfo->brick_path, + snap_vol->snapshot->snapname); +@@ -548,7 +574,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + ret = glusterd_store_volinfo (snap_vol, + GLUSTERD_VOLINFO_VER_AC_NONE); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store snapshot " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_STORE_FAIL, "Failed to store snapshot " + "volinfo (%s) for snap %s", snap_vol->volname, + snap->snapname); + goto out; +@@ -556,7 +583,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo, + + ret = glusterd_brick_start (snap_vol, brickinfo, _gf_false); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "starting the " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRICK_DISCONNECTED, "starting the " + "brick %s:%s for the snap %s failed", + brickinfo->hostname, brickinfo->path, + snap->snapname); +@@ -615,8 +643,9 @@ glusterd_take_missing_brick_snapshots (char *brick_name) + (missed_snapinfo, + snap_opinfo); + if (ret) { +- gf_log (this->name, +- GF_LOG_ERROR, ++ gf_msg (this->name, ++ GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_CREATE_FAIL, + "Failed to create " + "missed snap for %s", + brick_name); +@@ -647,7 +676,8 @@ glusterd_take_missing_brick_snapshots (char *brick_name) + if (update_list == _gf_true) { + ret = glusterd_store_update_missed_snaps (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL, + "Failed to update missed_snaps_list"); + goto out; + } +@@ -683,7 +713,8 @@ _client_supports_volume (peer_info_t *peerinfo, int32_t *op_errno) + (peerinfo->max_op_version < volinfo->client_op_version))) { + ret = _gf_false; + *op_errno = ENOTSUP; +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, ENOTSUP, ++ GD_MSG_UNSUPPORTED_VERSION, + "Client %s (%d -> %d) doesn't support required " + "op-version (%d). Rejecting volfile request.", + peerinfo->identifier, peerinfo->min_op_version, +@@ -738,7 +769,8 @@ __server_getspec (rpcsvc_request_t *req) + + ret = glusterd_get_args_from_dict (&args, peerinfo, &brick_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get args from dict"); + goto fail; + } +@@ -778,7 +810,8 @@ __server_getspec (rpcsvc_request_t *req) + /* to allocate the proper buffer to hold the file data */ + ret = stat (filename, &stbuf); + if (ret < 0){ +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "Unable to stat %s (%s)", + filename, strerror (errno)); + goto fail; +@@ -786,7 +819,8 @@ __server_getspec (rpcsvc_request_t *req) + + spec_fd = open (filename, O_RDONLY); + if (spec_fd < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, + "Unable to open %s (%s)", + filename, strerror (errno)); + goto fail; +@@ -808,11 +842,12 @@ __server_getspec (rpcsvc_request_t *req) + } + + if (brick_name) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Look for missing snap creates for %s", brick_name); + op_ret = glusterd_take_missing_brick_snapshots (brick_name); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_CREATE_FAIL, + "Failed to take missing brick snapshots"); + ret = -1; + goto fail; +@@ -872,14 +907,17 @@ __server_event_notify (rpcsvc_request_t *req) + ret = dict_unserialize (args.dict.dict_val, + args.dict.dict_len, &dict); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Failed to unserialize req"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, ++ "Failed to unserialize req"); + goto fail; + } + } + + switch (args.op) { + case GF_EN_DEFRAG_STATUS: +- gf_log ("", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEFRAG_STATUS_UPDATED, + "received defrag status updated"); + if (dict) { + glusterd_defrag_event_notify_handle (dict); +@@ -887,7 +925,8 @@ __server_event_notify (rpcsvc_request_t *req) + } + break; + default: +- gf_log ("", GF_LOG_ERROR, "Unknown op received in event " ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_OP_UNSUPPORTED, "Unknown op received in event " + "notify"); + ret = -1; + break; +@@ -925,7 +964,8 @@ gd_validate_cluster_op_version (xlator_t *this, int cluster_op_version, + conf = this->private; + + if (cluster_op_version > GD_OP_VERSION_MAX) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERSION_MISMATCH, + "operating version %d is more than the maximum " + "supported (%d) on the machine (as per peer request " + "from %s)", cluster_op_version, GD_OP_VERSION_MAX, +@@ -939,7 +979,8 @@ gd_validate_cluster_op_version (xlator_t *this, int cluster_op_version, + */ + if ((cluster_op_version < conf->op_version) && + !cds_list_empty (&conf->volumes)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERS_ADJUST_FAIL, + "cannot reduce operating version to %d from current " + "version %d as volumes exist (as per peer request from " + "%s)", cluster_op_version, conf->op_version, peerid); +@@ -1000,7 +1041,8 @@ gd_validate_mgmt_hndsk_req (rpcsvc_request_t *req, dict_t *dict) + rcu_read_unlock (); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Rejecting management " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HANDSHAKE_REQ_REJECTED, "Rejecting management " + "handshake request from unknown peer %s", + req->trans->peerinfo.identifier); + return _gf_false; +@@ -1048,7 +1090,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req) + + ret = dict_set_int32 (dict, GD_OP_VERSION_KEY, conf->op_version); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set operating version"); + rsp.op_ret = ret; + goto out; +@@ -1056,7 +1099,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req) + + ret = dict_set_int32 (dict, GD_MIN_OP_VERSION_KEY, GD_OP_VERSION_MIN); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set %s", GD_MIN_OP_VERSION_KEY); + rsp.op_ret = ret; + goto out; +@@ -1064,7 +1108,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req) + + ret = dict_set_int32 (dict, GD_MAX_OP_VERSION_KEY, GD_OP_VERSION_MAX); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set %s", GD_MAX_OP_VERSION_KEY); + rsp.op_ret = ret; + goto out; +@@ -1132,7 +1177,8 @@ __glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req) + + ret = dict_get_int32 (clnt_dict, GD_OP_VERSION_KEY, &peer_op_version); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, + "failed to get the op-version key peer=%s", + req->trans->peerinfo.identifier); + goto out; +@@ -1147,12 +1193,15 @@ __glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req) + /* As this is ACK from the Cluster for the versions supported, + can set the op-version of 'this' glusterd to the one + received. */ +- gf_log (this->name, GF_LOG_INFO, "using the op-version %d", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_VERS_INFO, "using the op-version %d", + peer_op_version); + conf->op_version = peer_op_version; + ret = glusterd_store_global_info (this); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to store op-version"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLOBAL_OP_VERSION_SET_FAIL, ++ "Failed to store op-version"); + + out: + rsp.op_ret = ret; +@@ -1200,13 +1249,15 @@ __server_get_volume_info (rpcsvc_request_t *req) + req->rpc_err = GARBAGE_ARGS; + goto out; + } +- gf_log ("glusterd", GF_LOG_INFO, "Received get volume info req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_VOL_INFO_REQ_RECVD, "Received get volume info req"); + + if (vol_info_req.dict.dict_len) { + /* Unserialize the dictionary */ + dict = dict_new (); + if (!dict) { +- gf_log ("", GF_LOG_WARNING, "Out of Memory"); ++ gf_msg ("glusterd", GF_LOG_WARNING, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of Memory"); + op_errno = ENOMEM; + ret = -1; + goto out; +@@ -1216,7 +1267,8 @@ __server_get_volume_info (rpcsvc_request_t *req) + vol_info_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + op_errno = -ret; +@@ -1229,7 +1281,8 @@ __server_get_volume_info (rpcsvc_request_t *req) + + ret = dict_get_int32 (dict, "flags", &flags); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to get flags"); ++ gf_msg (THIS->name, GF_LOG_ERROR, -ret, ++ GD_MSG_DICT_GET_FAILED, "failed to get flags"); + op_errno = -ret; + ret = -1; + goto out; +@@ -1237,7 +1290,8 @@ __server_get_volume_info (rpcsvc_request_t *req) + + if (!flags) { + /* Nothing to query about. Just return success */ +- gf_log (THIS->name, GF_LOG_ERROR, "No flags set"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_FLAG_SET, "No flags set"); + ret = 0; + goto out; + } +@@ -1266,7 +1320,8 @@ __server_get_volume_info (rpcsvc_request_t *req) + + dict_rsp = dict_new (); + if (!dict_rsp) { +- gf_log ("", GF_LOG_WARNING, "Out of Memory"); ++ gf_msg ("glusterd", GF_LOG_WARNING, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of Memory"); + op_errno = ENOMEM; + ret = -1; + goto out; +@@ -1337,7 +1392,8 @@ __server_get_snap_info (rpcsvc_request_t *req) + (xdrproc_t)xdr_gf_getsnap_name_uuid_req); + if (ret < 0) { + req->rpc_err = GARBAGE_ARGS; +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, + "Failed to decode management handshake response"); + goto out; + } +@@ -1354,7 +1410,8 @@ __server_get_snap_info (rpcsvc_request_t *req) + snap_info_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "Failed to unserialize dictionary"); + op_errno = EINVAL; + ret = -1; +@@ -1367,7 +1424,8 @@ __server_get_snap_info (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + op_errno = EINVAL; +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_DICT_GET_FAILED, + "Failed to retrieve volname"); + ret = -1; + goto out; +@@ -1384,7 +1442,8 @@ __server_get_snap_info (rpcsvc_request_t *req) + &snap_info_rsp); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, + "Error getting snapshot volume names and uuids : %s", + volname); + op_errno = EINVAL; +@@ -1513,7 +1572,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx) + (GD_FRIEND_EVENT_CONNECTED, &event); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get new event"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, "Unable to get new event"); + goto out; + } + +@@ -1521,7 +1581,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx) + + if (!ctx) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Memory not available"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Memory not available"); + goto out; + } + +@@ -1530,7 +1591,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx) + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { + ret = -1; +- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + goto unlock; + } +@@ -1546,13 +1608,14 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx) + ret = glusterd_friend_sm_inject_event (event); + + if (ret) +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_INJECT_FAIL, "Unable to inject " + "EVENT_CONNECTED ret = %d", ret); + unlock: + rcu_read_unlock (); + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -1598,7 +1661,7 @@ gd_validate_peer_op_version (xlator_t *this, glusterd_peerinfo_t *peerinfo, + + ret = 0; + out: +- gf_log (this->name , GF_LOG_DEBUG, "Peer %s %s", peerinfo->hostname, ++ gf_msg_debug (this->name , 0, "Peer %s %s", peerinfo->hostname, + ((ret < 0) ? "rejected" : "accepted")); + return ret; + } +@@ -1623,7 +1686,7 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov, + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)", ++ gf_msg_debug (this->name, 0, "Could not find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + ret = -1; + goto out; +@@ -1632,7 +1695,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov, + if (-1 == req->rpc_status) { + snprintf (msg, sizeof (msg), + "Error through RPC layer, retry again later"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_LAYER_ERROR, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -1640,7 +1704,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov, + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_mgmt_hndsk_rsp); + if (ret < 0) { + snprintf (msg, sizeof (msg), "Failed to decode XDR"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -1650,7 +1715,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov, + ret = -1; + snprintf (msg, sizeof (msg), + "Failed to get handshake ack from remote server"); +- gf_log (frame->this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (frame->this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_HANDSHAKE_ACK, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -1670,7 +1736,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov, + } else if (GD_MODE_SWITCH_ON == peerctx->args.mode) { + peerctx->args.mode = GD_MODE_ON; + } else { +- gf_log (this->name, GF_LOG_WARNING, "unknown mode %d", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UNKNOWN_MODE, "unknown mode %d", + peerctx->args.mode); + } + +@@ -1728,7 +1795,7 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { + ret = -1; +- gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)", ++ gf_msg_debug (this->name, 0, "Could not find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + goto out; + } +@@ -1737,7 +1804,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + ret = -1; + snprintf (msg, sizeof (msg), + "Error through RPC layer, retry again later"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_LAYER_ERROR, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -1746,7 +1814,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + if (ret < 0) { + snprintf (msg, sizeof (msg), "Failed to decode management " + "handshake response"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -1757,7 +1826,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + + op_errno = rsp.op_errno; + if (-1 == rsp.op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ GD_MSG_VERS_GET_FAIL, + "failed to get the 'versions' from peer (%s)", + req->conn->trans->peerinfo.identifier); + goto out; +@@ -1767,7 +1837,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + ret = gd_validate_peer_op_version (this, peerinfo, dict, + &peerctx->errstr); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERSION_MISMATCH, + "failed to validate the operating version of peer (%s)", + peerinfo->hostname); + goto out; +@@ -1779,7 +1850,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov, + + ret = dict_set_int32 (rsp_dict, GD_OP_VERSION_KEY, conf->op_version); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set operating version in dict"); + goto out; + } +@@ -1849,7 +1921,8 @@ glusterd_mgmt_handshake (xlator_t *this, glusterd_peerctx_t *peerctx) + ret = dict_set_dynstr (req_dict, GD_PEER_ID_KEY, + gf_strdup (uuid_utoa (MY_UUID))); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set peer ID in dict"); + goto out; + } +@@ -1861,7 +1934,7 @@ glusterd_mgmt_handshake (xlator_t *this, glusterd_peerctx_t *peerctx) + + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Could not find peer %s(%s)", ++ gf_msg_debug (THIS->name, 0, "Could not find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + goto unlock; + } +@@ -1908,7 +1981,7 @@ glusterd_set_clnt_mgmt_program (glusterd_peerinfo_t *peerinfo, + } + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "%s (%"PRId64":%"PRId64") not supported", + trav->progname, trav->prognum, + trav->progver); +@@ -1918,21 +1991,24 @@ glusterd_set_clnt_mgmt_program (glusterd_peerinfo_t *peerinfo, + } + + if (peerinfo->mgmt) { +- gf_log ("", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_VERS_INFO, + "Using Program %s, Num (%d), Version (%d)", + peerinfo->mgmt->progname, peerinfo->mgmt->prognum, + peerinfo->mgmt->progver); + } + + if (peerinfo->peer) { +- gf_log ("", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_VERS_INFO, + "Using Program %s, Num (%d), Version (%d)", + peerinfo->peer->progname, peerinfo->peer->prognum, + peerinfo->peer->progver); + } + + if (peerinfo->mgmt_v3) { +- gf_log ("", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_VERS_INFO, + "Using Program %s, Num (%d), Version (%d)", + peerinfo->mgmt_v3->progname, + peerinfo->mgmt_v3->prognum, +@@ -1990,7 +2066,7 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, + + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)", ++ gf_msg_debug (this->name, 0, "Couldn't find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + goto out; + } +@@ -1998,7 +2074,8 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, + if (-1 == req->rpc_status) { + snprintf (msg, sizeof (msg), + "Error through RPC layer, retry again later"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_LAYER_ERROR, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } +@@ -2006,20 +2083,22 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp); + if (ret < 0) { + snprintf (msg, sizeof (msg), "Failed to decode XDR"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } + if (-1 == rsp.op_ret) { + snprintf (msg, sizeof (msg), + "Failed to get the 'versions' from remote server"); +- gf_log (frame->this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (frame->this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERS_GET_FAIL, "%s", msg); + peerctx->errstr = gf_strdup (msg); + goto out; + } + + if (_mgmt_hndsk_prog_present (rsp.prog)) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Proceeding to op-version handshake with peer %s", + peerinfo->hostname); + ret = glusterd_mgmt_handshake (this, peerctx); +@@ -2030,14 +2109,17 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, + "Peer %s does not support required op-version", + peerinfo->hostname); + peerctx->errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERSION_UNSUPPORTED, "%s", msg); + goto out; + } + + /* Make sure we assign the proper program to peer */ + ret = glusterd_set_clnt_mgmt_program (peerinfo, rsp.prog); + if (ret) { +- gf_log ("", GF_LOG_WARNING, "failed to set the mgmt program"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_MGMT_PGM_SET_FAIL, ++ "failed to set the mgmt program"); + goto out; + } + +@@ -2049,7 +2131,8 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, + } else if (GD_MODE_SWITCH_ON == peerctx->args.mode) { + peerctx->args.mode = GD_MODE_ON; + } else { +- gf_log ("", GF_LOG_WARNING, "unknown mode %d", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_UNKNOWN_MODE, "unknown mode %d", + peerctx->args.mode); + } + +@@ -2111,7 +2194,7 @@ glusterd_peer_dump_version (xlator_t *this, struct rpc_clnt *rpc, + + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)", ++ gf_msg_debug (this->name, 0, "Couldn't find peer %s(%s)", + peerctx->peername, uuid_utoa (peerctx->peerid)); + goto unlock; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c +index bafdc53..a16e499 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-locks.c ++++ b/xlators/mgmt/glusterd/src/glusterd-locks.c +@@ -24,6 +24,7 @@ + #include "glusterd-errno.h" + #include "run.h" + #include "syscall.h" ++#include "glusterd-messages.h" + + #include + +@@ -113,7 +114,8 @@ glusterd_get_mgmt_v3_lock_owner (char *key, uuid_t *uuid) + GF_ASSERT (priv); + + if (!key || !uuid) { +- gf_log (this->name, GF_LOG_ERROR, "key or uuid is null."); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "key or uuid is null."); + ret = -1; + goto out; + } +@@ -126,7 +128,7 @@ glusterd_get_mgmt_v3_lock_owner (char *key, uuid_t *uuid) + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -150,7 +152,7 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + GF_ASSERT (type); + + if (locked_count == 0) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No %s locked as part of this transaction", + type); + goto out; +@@ -165,7 +167,8 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + * as key in the dict snapname2 */ + ret = dict_get_str (dict, name_buf, &name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get %s locked_count = %d", + name_buf, locked_count); + op_ret = ret; +@@ -174,7 +177,8 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + + ret = glusterd_mgmt_v3_unlock (name, uuid, type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Failed to release lock for %s.", + name); + op_ret = ret; +@@ -182,7 +186,7 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + } + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", op_ret); ++ gf_msg_trace (this->name, 0, "Returning %d", op_ret); + return op_ret; + } + +@@ -216,7 +220,8 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + * as key in the dict snapname2 */ + ret = dict_get_str (dict, name_buf, &name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get %s count = %d", + name_buf, count); + break; +@@ -224,7 +229,8 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + + ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Failed to acquire lock for %s %s " + "on behalf of %s. Reversing " + "this transaction", type, name, +@@ -245,13 +251,14 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + locked_count, + type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL, + "Failed to release multiple %s locks", + type); + } + ret = -1; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -295,14 +302,16 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type, + type); + ret = dict_get_str (dict, name_buf, &name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to fetch %sname", type); + goto out; + } + + ret = glusterd_mgmt_v3_unlock (name, uuid, type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Failed to release lock for %s %s " + "on behalf of %s.", type, name, + uuid_utoa(uuid)); +@@ -315,7 +324,8 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type, + count, + type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL, + "Failed to release all %s locks", type); + goto out; + } +@@ -323,7 +333,7 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type, + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -366,14 +376,16 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno, + type); + ret = dict_get_str (dict, name_buf, &name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to fetch %sname", type); + goto out; + } + + ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Failed to acquire lock for %s %s " + "on behalf of %s.", type, name, + uuid_utoa(uuid)); +@@ -387,7 +399,8 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno, + count, + type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_ACQUIRE_FAIL, + "Failed to acquire all %s locks", type); + goto out; + } +@@ -395,7 +408,7 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno, + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -413,7 +426,8 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid) + GF_ASSERT(this); + + if (!dict) { +- gf_log (this->name, GF_LOG_ERROR, "dict is null."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_EMPTY, "dict is null."); + ret = -1; + goto out; + } +@@ -424,7 +438,8 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid) + valid_types[i].type, + valid_types[i].default_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL, + "Unable to unlock all %s", + valid_types[i].type); + op_ret = ret; +@@ -433,7 +448,7 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid) + + ret = op_ret; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -451,7 +466,8 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno) + GF_ASSERT(this); + + if (!dict) { +- gf_log (this->name, GF_LOG_ERROR, "dict is null."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_EMPTY, "dict is null."); + ret = -1; + goto out; + } +@@ -463,7 +479,8 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno) + valid_types[i].type, + valid_types[i].default_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_ACQUIRE_FAIL, + "Unable to lock all %s", + valid_types[i].type); + break; +@@ -484,14 +501,15 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno) + valid_types[i].type, + valid_types[i].default_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL, + "Unable to unlock all %s", + valid_types[i].type); + } + } + ret = -1; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -515,7 +533,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + GF_ASSERT (priv); + + if (!name || !type) { +- gf_log (this->name, GF_LOG_ERROR, "name or type is null."); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "name or type is null."); + ret = -1; + goto out; + } +@@ -532,17 +551,18 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + ret = snprintf (key, sizeof(key), "%s_%s", name, type); + if (ret != strlen(name) + 1 + strlen(type)) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Unable to create key"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CREATE_KEY_FAIL, "Unable to create key"); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Trying to acquire lock of %s %s for %s as %s", + type, name, uuid_utoa (uuid), key); + + ret = glusterd_get_mgmt_v3_lock_owner (key, &owner); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to get mgmt_v3 lock owner"); + goto out; + } +@@ -570,7 +590,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + ret = dict_set_bin (priv->mgmt_v3_lock, key, lock_obj, + sizeof(glusterd_mgmt_v3_lock_obj)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to set lock owner in mgmt_v3 lock"); + if (lock_obj) + GF_FREE (lock_obj); +@@ -583,19 +604,20 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + name, type); + ret = dict_set_dynstr_with_alloc (priv->mgmt_v3_lock, key, bt); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "Failed to save " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to save " + "the back trace for lock %s-%s granted to %s", + name, type, uuid_utoa (uuid)); + ret = 0; + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Lock for %s %s successfully held by %s", + type, name, uuid_utoa (uuid)); + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -615,7 +637,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + GF_ASSERT (priv); + + if (!name || !type) { +- gf_log (this->name, GF_LOG_ERROR, "name is null."); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "name is null."); + ret = -1; + goto out; + } +@@ -632,18 +655,19 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + ret = snprintf (key, sizeof(key), "%s_%s", + name, type); + if (ret != strlen(name) + 1 + strlen(type)) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to create key"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CREATE_KEY_FAIL, "Unable to create key"); + ret = -1; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Trying to release lock of %s %s for %s as %s", + type, name, uuid_utoa (uuid), key); + + ret = glusterd_get_mgmt_v3_lock_owner (key, &owner); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to get mgmt_v3 lock owner"); + goto out; + } +@@ -672,19 +696,20 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + type); + if (ret != strlen ("debug.last-success-bt-") + strlen (name) + + strlen (type) + 1) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to create backtrace " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CREATE_KEY_FAIL, "Unable to create backtrace " + "key"); + ret = -1; + goto out; + } + dict_del (priv->mgmt_v3_lock, key); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Lock for %s %s successfully released", + type, name); + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c +index 0a68540..e837b2f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c +@@ -31,6 +31,7 @@ + #include "common-utils.h" + #include "glusterd-mountbroker.h" + #include "glusterd-op-sm.h" ++#include "glusterd-messages.h" + + static int + seq_dict_foreach (dict_t *dict, +@@ -217,7 +218,8 @@ parse_mount_pattern_desc (gf_mount_spec_t *mspec, char *pdesc) + + out: + if (ret == SYNTAX_ERR) { +- gf_log ("", GF_LOG_ERROR, "cannot parse mount patterns %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "cannot parse mount patterns %s", + pdesc); + } + +@@ -670,7 +672,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno) + + if (*op_errno) { + ret = -1; +- gf_log ("", GF_LOG_WARNING, "unsuccessful mount request (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, *op_errno, ++ GD_MSG_MOUNT_REQ_FAIL, ++ "unsuccessful mount request (%s)", + strerror (*op_errno)); + if (mtptemp) { + *cookieswitch = '/'; +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index a006afa..faf255a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -109,7 +109,8 @@ gd_collate_errors (struct syncargs *args, int op_ret, int op_errno, + "%s", op_err); + err_str[len] = '\0'; + +- gf_log ("", GF_LOG_ERROR, "%s", op_err); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MGMT_OP_FAIL, "%s", op_err); + args->errstr = gf_strdup (err_str); + } + +@@ -237,7 +238,8 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) + case GD_OP_START_VOLUME: + ret = glusterd_aggr_brick_mount_dirs (aggr, rsp); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNDIRS_AGGR_FAIL, "Failed to " + "aggregate brick mount dirs"); + goto out; + } +@@ -418,7 +420,7 @@ gd_syncop_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx, + (xdrproc_t) + xdr_gd1_mgmt_v3_lock_req); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -517,7 +519,7 @@ gd_syncop_mgmt_v3_unlock (dict_t *op_ctx, glusterd_peerinfo_t *peerinfo, + (xdrproc_t) + xdr_gd1_mgmt_v3_unlock_req); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -766,7 +768,8 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + rcu_read_unlock (); + if (ret) { + ret = -1; +- gf_log (this->name, GF_LOG_CRITICAL, "Staging response " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, "Staging response " + "for 'Volume %s' received from unknown " + "peer: %s", gd_op_list[rsp.op], + uuid_utoa (rsp.uuid)); +@@ -782,7 +785,8 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + ret = glusterd_syncop_aggr_rsp_dict (rsp.op, args->dict, + rsp_dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "%s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESP_AGGR_FAIL, "%s", + "Failed to aggregate response from " + " node/brick"); + } +@@ -963,7 +967,8 @@ gd_syncop_mgmt_brick_op (struct rpc_clnt *rpc, glusterd_pending_node_t *pnode, + if (GD_OP_STATUS_VOLUME == op) { + ret = dict_set_int32 (args.dict, "index", pnode->index); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting index on brick status" + " rsp dict"); + args.op_ret = -1; +@@ -1042,7 +1047,8 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + rcu_read_unlock (); + if (ret) { + ret = -1; +- gf_log (this->name, GF_LOG_CRITICAL, "Commit response " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, "Commit response " + "for 'Volume %s' received from unknown " + "peer: %s", gd_op_list[rsp.op], + uuid_utoa (rsp.uuid)); +@@ -1053,7 +1059,8 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + if (rsp.op == GD_OP_QUOTA) { + ret = dict_get_int32 (args->dict, "type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "opcode"); + goto out; + } +@@ -1065,7 +1072,8 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + ret = glusterd_syncop_aggr_rsp_dict (rsp.op, args->dict, + rsp_dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "%s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESP_AGGR_FAIL, "%s", + "Failed to aggregate response from " + " node/brick"); + } +@@ -1193,7 +1201,8 @@ gd_lock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx, + if (ret == -1) + *op_errstr = NULL; + +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_LOCK_FAIL, + "Failed to acquire lock"); + + } +@@ -1201,7 +1210,7 @@ gd_lock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx, + + ret = args.op_ret; + +- gf_log (this->name, GF_LOG_DEBUG, "Sent lock op req for 'Volume %s' " ++ gf_msg_debug (this->name, 0, "Sent lock op req for 'Volume %s' " + "to %d peers. Returning %d", gd_op_list[op], peer_cnt, ret); + out: + return ret; +@@ -1257,7 +1266,8 @@ gd_stage_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + op == GD_OP_START_VOLUME)) { + ret = glusterd_syncop_aggr_rsp_dict (op, aggr_dict, rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESP_AGGR_FAIL, "%s", + "Failed to aggregate response from node/brick"); + goto out; + } +@@ -1267,7 +1277,8 @@ gd_stage_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + + stage_done: + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_STAGE_FAIL, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VALIDATE_FAILED, LOGSTR_STAGE_FAIL, + gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", + (*op_errstr) ? *op_errstr : " "); + if (*op_errstr == NULL) +@@ -1306,7 +1317,7 @@ stage_done: + } + + +- gf_log (this->name, GF_LOG_DEBUG, "Sent stage op req for 'Volume %s' " ++ gf_msg_debug (this->name, 0, "Sent stage op req for 'Volume %s' " + "to %d peers", gd_op_list[op], peer_cnt); + + gd_synctask_barrier_wait((&args), peer_cnt); +@@ -1323,7 +1334,8 @@ out: + ret = glusterd_validate_and_set_gfid (op_ctx, req_dict, + op_errstr); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GFID_VALIDATE_SET_FAIL, + "Failed to validate and set gfid"); + } + +@@ -1368,7 +1380,8 @@ gd_commit_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + if (op == GD_OP_QUOTA) { + ret = dict_get_int32 (op_ctx, "type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "opcode"); + goto out; + } +@@ -1381,9 +1394,11 @@ gd_commit_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx, + rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", "Failed to aggregate " +- "response from node/brick"); +- goto out; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESP_AGGR_FAIL, "%s", ++ "Failed to aggregate " ++ "response from node/brick"); ++ goto out; + } + } + +@@ -1392,7 +1407,8 @@ gd_commit_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + + commit_done: + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_COMMIT_FAIL, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_OP_FAIL, LOGSTR_COMMIT_FAIL, + gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", + (*op_errstr) ? *op_errstr : " "); + if (*op_errstr == NULL) +@@ -1438,7 +1454,7 @@ commit_done: + else if (dict_get_str (op_ctx, "errstr", &errstr) == 0) + *op_errstr = gf_strdup (errstr); + +- gf_log (this->name, GF_LOG_DEBUG, "Sent commit op req for 'Volume %s' " ++ gf_msg_debug (this->name, 0, "Sent commit op req for 'Volume %s' " + "to %d peers", gd_op_list[op], peer_cnt); + out: + if (!ret) +@@ -1547,10 +1563,11 @@ gd_unlock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, int *op_ret, + + ret = args.op_ret; + +- gf_log (this->name, GF_LOG_DEBUG, "Sent unlock op req for 'Volume %s' " ++ gf_msg_debug (this->name, 0, "Sent unlock op req for 'Volume %s' " + "to %d peers. Returning %d", gd_op_list[op], peer_cnt, ret); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to unlock " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_UNLOCK_FAIL, "Failed to unlock " + "on some peer(s)"); + } + +@@ -1574,7 +1591,8 @@ out: + ret = glusterd_mgmt_v3_unlock (volname, MY_UUID, + type); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Unable to release lock for %s", + volname); + } +@@ -1631,8 +1649,9 @@ gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + ret = glusterd_op_bricks_select (op, req_dict, op_errstr, &selected, + rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", +- (*op_errstr)? *op_errstr: "Brick op failed. Check " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_FAIL, "%s", ++ (*op_errstr) ? *op_errstr : "Brick op failed. Check " + "glusterd log file for more details."); + goto out; + } +@@ -1657,7 +1676,8 @@ gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, + } + + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Brick Op failed " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_FAILURE, "Brick Op failed " + "due to rpc failure."); + goto out; + } +@@ -1694,7 +1714,7 @@ out: + + if (rsp_dict) + dict_unref (rsp_dict); +- gf_log (this->name, GF_LOG_DEBUG, "Sent op req to %d bricks", ++ gf_msg_debug (this->name, 0, "Sent op req to %d bricks", + brick_count); + return ret; + } +@@ -1726,7 +1746,8 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + + ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY, &tmp_op); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volume " + "operation"); + goto out; + } +@@ -1736,7 +1757,8 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + * save it in the dict */ + ret = glusterd_generate_txn_id (op_ctx, &txn_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_IDGEN_FAIL, + "Failed to generate transaction id"); + goto out; + } +@@ -1745,16 +1767,18 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + glusterd_txn_opinfo_init (&txn_opinfo, NULL, &op, NULL, NULL); + ret = glusterd_set_txn_opinfo (txn_id, &txn_opinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_SET_FAIL, + "Unable to set transaction's opinfo"); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Transaction ID : %s", uuid_utoa (*txn_id)); + + /* Save the MY_UUID as the originator_uuid */ + ret = glusterd_set_originator_uuid (op_ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_SET_FAIL, + "Failed to set originator_uuid."); + goto out; + } +@@ -1763,7 +1787,8 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + if (conf->op_version < GD_OP_VERSION_RHS_3_0) { + ret = glusterd_lock (MY_UUID); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_LOCK_FAIL, + "Unable to acquire lock"); + gf_asprintf (&op_errstr, + "Another transaction is in progress. " +@@ -1782,7 +1807,8 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + * not be held */ + ret = dict_get_str (op_ctx, "volname", &tmp); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Failed to get volume " ++ gf_msg_debug ("glusterd", 0, ++ "Failed to get volume " + "name"); + goto local_locking_done; + } else { +@@ -1797,7 +1823,8 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) + ret = glusterd_mgmt_v3_lock (volname, MY_UUID, + &op_errno, "vol"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Unable to acquire lock for %s", volname); + gf_asprintf (&op_errstr, + "Another transaction is in progress " +@@ -1834,7 +1861,8 @@ local_locking_done: + ret = gd_lock_op_phase (conf, op, op_ctx, &op_errstr, *txn_id, + &txn_opinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_LOCK_FAIL, + "Locking Peers Failed."); + goto out; + } +@@ -1842,7 +1870,9 @@ local_locking_done: + + ret = glusterd_op_build_payload (&req_dict, &op_errstr, op_ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, ++ LOGSTR_BUILD_PAYLOAD, + gd_op_list[op]); + if (op_errstr == NULL) + gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); +@@ -1879,7 +1909,8 @@ out: + /* Clearing the transaction opinfo */ + ret = glusterd_clear_txn_opinfo (txn_id); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_CLEAR_FAIL, + "Unable to clear transaction's " + "opinfo for transaction ID : %s", + uuid_utoa (*txn_id)); +@@ -1913,7 +1944,8 @@ glusterd_op_begin_synctask (rpcsvc_request_t *req, glusterd_op_t op, + + ret = dict_set_int32 (dict, GD_SYNC_OPCODE_KEY, op); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "dict set failed for setting operations"); + goto out; + } +-- +1.7.1 + diff --git a/SOURCES/0091-utils-glusterd-Porting-to-new-logging-framwork.patch b/SOURCES/0091-utils-glusterd-Porting-to-new-logging-framwork.patch new file mode 100644 index 0000000..4d46af8 --- /dev/null +++ b/SOURCES/0091-utils-glusterd-Porting-to-new-logging-framwork.patch @@ -0,0 +1,3142 @@ +From 5d89662a0e5d5d30498122ee70720928a812a5dd Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Mon, 23 Mar 2015 11:36:37 +0530 +Subject: [PATCH 091/101] utils/glusterd: Porting to new logging framwork + +cherry-pick of the commit 9863c8940936989d2ffb3c8ac28431d2b313384d +>Change-Id: Iacb30eb675693bcdb3ef9de8e7f43892c5d79f6d +>BUG: 1194640 +>Signed-off-by: Nandaja Varma +>Reviewed-on: http://review.gluster.org/9967 +>Tested-by: NetBSD Build System +>Reviewed-by: Poornima G +>Tested-by: Gluster Build System +>Reviewed-by: Krishnan Parthasarathi +>Reviewed-by: Kaushal M + +Change-Id: Iacb30eb675693bcdb3ef9de8e7f43892c5d79f6d +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50891 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-messages.h | 90 +++- + xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 76 ++- + xlators/mgmt/glusterd/src/glusterd-utils.c | 844 +++++++++++++++-------- + 3 files changed, 686 insertions(+), 324 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index f66b8db..16002bc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD +-#define GLFS_NUM_MESSAGES 447 ++#define GLFS_NUM_MESSAGES 458 + #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" +@@ -3626,6 +3626,94 @@ + */ + #define GD_MSG_VOL_TYPE_CHANGING_INFO (GLUSTERD_COMP_BASE + 447) + ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BRKPATH_MNTPNT_MISMATCH (GLUSTERD_COMP_BASE + 448) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_TASKS_COUNT_MISMATCH (GLUSTERD_COMP_BASE + 449) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_WRONG_OPTS_SETTING (GLUSTERD_COMP_BASE + 450) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_PATH_ALREADY_PART_OF_VOL (GLUSTERD_COMP_BASE + 451) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BRICK_VALIDATE_FAIL (GLUSTERD_COMP_BASE + 452) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_READIN_FILE_FAILED (GLUSTERD_COMP_BASE + 453) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_IMPORT_PRDICT_DICT (GLUSTERD_COMP_BASE + 454) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_OPTS_IMPORT_FAIL (GLUSTERD_COMP_BASE + 455) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BRICK_IMPORT_FAIL (GLUSTERD_COMP_BASE + 456) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOLINFO_IMPORT_FAIL (GLUSTERD_COMP_BASE + 457) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BRICK_ID_GEN_FAILED (GLUSTERD_COMP_BASE + 458) ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + +diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +index 6df1dae..5ece68c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +@@ -11,6 +11,7 @@ + #include "glusterd-peer-utils.h" + #include "glusterd-store.h" + #include "glusterd-server-quorum.h" ++#include "glusterd-messages.h" + #include "common-utils.h" + + void +@@ -32,7 +33,9 @@ glusterd_peerinfo_destroy (struct rcu_head *head) + + ret = glusterd_store_delete_peerinfo (peerinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Deleting peer info failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_PEERINFO_DELETE_FAIL, ++ "Deleting peer info failed"); + } + + GF_FREE (peerinfo->hostname); +@@ -111,7 +114,8 @@ glusterd_peerinfo_find_by_hostname (const char *hoststr) + + ret = getaddrinfo (hoststr, NULL, NULL, &addr); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ GD_MSG_GETADDRINFO_FAIL, + "error in getaddrinfo: %s\n", + gai_strerror(ret)); + goto out; +@@ -126,7 +130,7 @@ glusterd_peerinfo_find_by_hostname (const char *hoststr) + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Unable to find friend: %s", hoststr); ++ gf_msg_debug (this->name, 0, "Unable to find friend: %s", hoststr); + if (addr) + freeaddrinfo (addr); + return NULL; +@@ -161,7 +165,7 @@ glusterd_hostname_to_uuid (char *hostname, uuid_t uuid) + } + } + +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -191,7 +195,7 @@ glusterd_peerinfo_find_by_uuid (uuid_t uuid) + cds_list_for_each_entry_rcu (entry, &priv->peers, uuid_list) { + if (!gf_uuid_compare (entry->uuid, uuid)) { + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Friend found... state: %s", + glusterd_friend_sm_state_name_get (entry->state.state)); + found = entry; /* Probably should be rcu_dereferenced */ +@@ -201,7 +205,7 @@ glusterd_peerinfo_find_by_uuid (uuid_t uuid) + rcu_read_unlock (); + + if (!found) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Friend with uuid: %s, not found", uuid_utoa (uuid)); + return found; + } +@@ -226,7 +230,7 @@ glusterd_peerinfo_find (uuid_t uuid, const char *hostname) + if (peerinfo) { + return peerinfo; + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to find peer by uuid: %s", + uuid_utoa (uuid)); + } +@@ -239,7 +243,7 @@ glusterd_peerinfo_find (uuid_t uuid, const char *hostname) + if (peerinfo) { + return peerinfo; + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to find hostname: %s", hostname); + } + } +@@ -342,7 +346,7 @@ glusterd_chk_peers_connected_befriended (uuid_t skip_uuid) + } + rcu_read_unlock (); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %s", ++ gf_msg_debug (THIS->name, 0, "Returning %s", + (ret?"TRUE":"FALSE")); + return ret; + } +@@ -413,7 +417,7 @@ glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo, + (peerinfo->state.state != + GD_FRIEND_STATE_BEFRIENDED)) { + *down_peerstr = gf_strdup (peerinfo->hostname); +- gf_log ("", GF_LOG_DEBUG, "Peer %s is down. ", ++ gf_msg_debug (THIS->name, 0, "Peer %s is down. ", + peerinfo->hostname); + rcu_read_unlock (); + goto out; +@@ -424,7 +428,7 @@ glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo, + + ret = _gf_true; + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -451,7 +455,7 @@ glusterd_peer_hostname_new (const char *hostname, + ret = 0; + + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -548,7 +552,8 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, + snprintf (key, sizeof (key), "%s.uuid", prefix); + ret = dict_set_dynstr_with_alloc (dict, key, uuid_utoa (friend->uuid)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set key %s in dict", key); + goto out; + } +@@ -562,13 +567,16 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, + hostname_list); + if (!address) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not retrieve first " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_ADDRESS_GET_FAIL, ++ "Could not retrieve first " + "address for peer"); + goto out; + } + ret = dict_set_dynstr_with_alloc (dict, key, address->hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set key %s in dict", key); + goto out; + } +@@ -587,8 +595,9 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, + snprintf (key, sizeof (key), "%s.hostname%d", prefix, count); + ret = dict_set_dynstr_with_alloc (dict, key, address->hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to set key %s in dict", key); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set key %s in dict", key); + goto out; + } + count++; +@@ -597,11 +606,12 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, + snprintf (key, sizeof (key), "%s.address-count", prefix); + ret = dict_set_int32 (dict, key, count); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set key %s in dict", key); + + out: +- gf_log (this ? this->name : "glusterd", GF_LOG_DEBUG, "Returning %d", ++ gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", + ret); + return ret; + } +@@ -631,7 +641,7 @@ gd_peerinfo_find_from_hostname (const char *hoststr) + cds_list_for_each_entry_rcu (tmphost, &peer->hostnames, + hostname_list) { + if (!strncasecmp (tmphost->hostname, hoststr, 1024)) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Friend %s found.. state: %d", + tmphost->hostname, peer->state.state); + found = peer; /* Probably needs to be +@@ -688,7 +698,7 @@ gd_peerinfo_find_from_addrinfo (const struct addrinfo *addr) + /* Don't fail if getaddrinfo fails, continue + * onto the next address + */ +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "getaddrinfo for %s failed (%s)", + address->hostname, gai_strerror (ret)); + ret = 0; +@@ -744,13 +754,15 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + snprintf (key, sizeof (key), "%s.hostname", prefix); + ret = dict_get_str (dict, key, &hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Key %s not present in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Key %s not present in " + "dictionary", key); + goto out; + } + ret = gd_add_address_to_peer (peerinfo, hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_ADD_ADDRESS_TO_PEER_FAIL, + "Could not add address to peer"); + goto out; + } +@@ -768,7 +780,8 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + snprintf (key, sizeof (key), "%s.address-count", prefix); + ret = dict_get_int32 (dict, key, &count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Key %s not present in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Key %s not present in " + "dictionary", key); + goto out; + } +@@ -778,13 +791,15 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + snprintf (key, sizeof (key), "%s.hostname%d",prefix, i); + ret = dict_get_str (dict, key, &hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Key %s not present " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Key %s not present " + "in dictionary", key); + goto out; + } + ret = gd_add_address_to_peer (peerinfo, hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_ADD_ADDRESS_TO_PEER_FAIL, + "Could not add address to peer"); + goto out; + } +@@ -793,7 +808,7 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -825,7 +840,9 @@ gd_peerinfo_from_dict (dict_t *dict, const char *prefix) + 0); + if (new_peer == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not create peerinfo " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEERINFO_CREATE_FAIL, ++ "Could not create peerinfo " + "object"); + goto out; + } +@@ -833,7 +850,8 @@ gd_peerinfo_from_dict (dict_t *dict, const char *prefix) + snprintf (key, sizeof (key), "%s.uuid", prefix); + ret = dict_get_str (dict, key, &uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Key %s not present in " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Key %s not present in " + "dictionary", key); + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 82b2e57..23a60d2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -158,7 +158,8 @@ glusterd_lock (uuid_t uuid) + glusterd_get_lock_owner (&owner); + + if (!gf_uuid_is_null (owner)) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get lock" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_LOCK_FAIL, "Unable to get lock" + " for uuid: %s, lock held by: %s", + uuid_utoa_r (uuid, new_owner_str), + uuid_utoa_r (owner, owner_str)); +@@ -168,7 +169,7 @@ glusterd_lock (uuid_t uuid) + ret = glusterd_set_lock_owner (uuid); + + if (!ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Cluster lock held by" ++ gf_msg_debug (this->name, 0, "Cluster lock held by" + " %s", uuid_utoa (uuid)); + } + +@@ -194,23 +195,26 @@ glusterd_unlock (uuid_t uuid) + glusterd_get_lock_owner (&owner); + + if (gf_uuid_is_null (owner)) { +- gf_log (this->name, GF_LOG_ERROR, "Cluster lock not held!"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_LOCK_FAIL, "Cluster lock not held!"); + goto out; + } + + ret = gf_uuid_compare (uuid, owner); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Cluster lock held by %s ," +- "unlock req from %s!", uuid_utoa_r (owner ,owner_str) +- , uuid_utoa_r (uuid, new_owner_str)); +- goto out; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_LOCK_FAIL, "Cluster lock held by %s ," ++ "unlock req from %s!", uuid_utoa_r (owner, owner_str), ++ uuid_utoa_r (uuid, new_owner_str)); ++ goto out; + } + + ret = glusterd_unset_lock_owner (uuid); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to clear cluster " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_UNLOCK_FAIL, "Unable to clear cluster " + "lock"); + goto out; + } +@@ -340,7 +344,9 @@ glusterd_serialize_reply (rpcsvc_request_t *req, void *arg, + rsp_size = xdr_sizeof (xdrproc, arg); + iob = iobuf_get2 (req->svc->ctx->iobuf_pool, rsp_size); + if (!iob) { +- gf_log ("", GF_LOG_ERROR, "Failed to get iobuf"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, ++ "Failed to get iobuf"); + goto ret; + } + +@@ -353,7 +359,8 @@ glusterd_serialize_reply (rpcsvc_request_t *req, void *arg, + */ + retlen = xdr_serialize_generic (*outmsg, arg, xdrproc); + if (retlen == -1) { +- gf_log ("", GF_LOG_ERROR, "Failed to encode message"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_ENCODE_FAIL, "Failed to encode message"); + goto ret; + } + +@@ -385,7 +392,8 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg, + if (!iobref) { + iobref = iobref_new (); + if (!iobref) { +- gf_log ("", GF_LOG_ERROR, "out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "out of memory"); + goto out; + } + +@@ -394,7 +402,8 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg, + + iob = glusterd_serialize_reply (req, arg, &rsp, xdrproc); + if (!iob) { +- gf_log ("", GF_LOG_ERROR, "Failed to serialize reply"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_SERIALIZE_MSG_FAIL, "Failed to serialize reply"); + } else { + iobref_add (iobref, iob); + } +@@ -407,7 +416,8 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg, + * ref'ed the iob on receiving into the txlist. + */ + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, "Reply submission failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REPLY_SUBMIT_FAIL, "Reply submission failed"); + goto out; + } + +@@ -516,7 +526,7 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo) + ret = 0; + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -545,7 +555,8 @@ glusterd_volinfo_dup (glusterd_volinfo_t *volinfo, + + ret = glusterd_volinfo_new (&new_volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "not able to create the " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_SET_FAIL, "not able to create the " + "duplicate volinfo for the volume %s", + volinfo->volname); + goto out; +@@ -613,7 +624,8 @@ glusterd_brickinfo_dup (glusterd_brickinfo_t *brickinfo, + strcpy (dup_brickinfo->mnt_opts, brickinfo->mnt_opts); + ret = gf_canonicalize_path (dup_brickinfo->path); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to canonicalize " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_CANONICALIZE_FAIL, "Failed to canonicalize " + "brick path"); + goto out; + } +@@ -739,7 +751,7 @@ glusterd_volume_brickinfos_delete (glusterd_volinfo_t *volinfo) + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -783,7 +795,7 @@ glusterd_volinfo_delete (glusterd_volinfo_t *volinfo) + ret = 0; + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -808,7 +820,7 @@ glusterd_brickinfo_new (glusterd_brickinfo_t **brickinfo) + ret = 0; + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -825,7 +837,8 @@ glusterd_get_next_available_brickid (glusterd_volinfo_t *volinfo) + token = strrchr (brickinfo->brick_id, '-'); + ret = gf_string2int32 (++token, &brickid); + if (ret < 0) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_ID_GEN_FAILED, + "Unable to generate brick ID"); + return ret; + } +@@ -848,7 +861,7 @@ glusterd_resolve_brick (glusterd_brickinfo_t *brickinfo) + GF_ASSERT (brickinfo); + + ret = glusterd_hostname_to_uuid (brickinfo->hostname, brickinfo->uuid); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -869,7 +882,8 @@ glusterd_get_brick_mount_dir (char *brickpath, char *hostname, char *mount_dir) + + ret = glusterd_hostname_to_uuid (hostname, brick_uuid); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_TO_UUID_FAIL, + "Failed to convert hostname %s to uuid", + hostname); + goto out; +@@ -878,14 +892,16 @@ glusterd_get_brick_mount_dir (char *brickpath, char *hostname, char *mount_dir) + if (!gf_uuid_compare (brick_uuid, MY_UUID)) { + ret = glusterd_get_brick_root (brickpath, &mnt_pt); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRICKPATH_ROOT_GET_FAIL, + "Could not get the root of the brick path %s", + brickpath); + goto out; + } + + if (strncmp (brickpath, mnt_pt, strlen(mnt_pt))) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRKPATH_MNTPNT_MISMATCH, + "brick: %s brick mount: %s", + brickpath, mnt_pt); + ret = -1; +@@ -899,7 +915,7 @@ glusterd_get_brick_mount_dir (char *brickpath, char *hostname, char *mount_dir) + } + + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -961,7 +977,7 @@ out: + if (tmp_host) + GF_FREE (tmp_path); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1244,7 +1260,7 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path, + continue; + + if (strcmp (brickiter->path, path) == 0) { +- gf_log (this->name, GF_LOG_DEBUG, LOGSTR_FOUND_BRICK, ++ gf_msg_debug (this->name, 0, LOGSTR_FOUND_BRICK, + brickiter->hostname, brickiter->path, + volinfo->volname); + ret = 0; +@@ -1255,7 +1271,7 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1279,7 +1295,7 @@ glusterd_volume_brickinfo_get_by_brick (char *brick, + brickinfo); + (void) glusterd_brickinfo_delete (tmp_brickinfo); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -1319,7 +1335,7 @@ glusterd_volinfo_find_by_volume_id (uuid_t volume_id, glusterd_volinfo_t **volin + continue; + *volinfo = voliter; + ret = 0; +- gf_log (this->name, GF_LOG_DEBUG, "Volume %s found", ++ gf_msg_debug (this->name, 0, "Volume %s found", + voliter->volname); + break; + } +@@ -1343,7 +1359,7 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) + + cds_list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) { + if (!strcmp (tmp_volinfo->volname, volname)) { +- gf_log (this->name, GF_LOG_DEBUG, "Volume %s found", ++ gf_msg_debug (this->name, 0, "Volume %s found", + volname); + ret = 0; + *volinfo = tmp_volinfo; +@@ -1351,7 +1367,7 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) + } + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1370,14 +1386,14 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, + gf_log (this->name, GF_LOG_INFO, "%s already stopped", service); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Stopping gluster %s running in pid: " ++ gf_msg_debug (this->name, 0, "Stopping gluster %s running in pid: " + "%d", service, pid); + + ret = kill (pid, sig); + if (ret) { + switch (errno) { + case ESRCH: +- gf_log (this->name, GF_LOG_DEBUG, "%s is already stopped", ++ gf_msg_debug (this->name, 0, "%s is already stopped", + service); + ret = 0; + goto out; +@@ -1490,7 +1506,7 @@ glusterd_brick_connect (glusterd_volinfo_t *volinfo, + } + out: + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -1509,7 +1525,8 @@ _mk_rundir_p (glusterd_volinfo_t *volinfo) + snprintf (rundir, sizeof (rundir)-1, "%s/run", voldir); + ret = mkdir_p (rundir, 0777, _gf_true); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to create rundir"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Failed to create rundir"); + return ret; + } + +@@ -1676,7 +1693,8 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, + connect: + ret = glusterd_brick_connect (volinfo, brickinfo, socketpath); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_DISCONNECTED, + "Failed to connect to brick %s:%s on %s", + brickinfo->hostname, brickinfo->path, socketpath); + goto out; +@@ -1827,7 +1845,8 @@ glusterd_readin_file (const char *filepath, int *line_count) + + out: + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "%s", strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_READIN_FILE_FAILED, "%s", strerror (errno)); + if (fp) + fclose (fp); + +@@ -1899,7 +1918,8 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo, char *cksum_path, + fd = open (cksum_path, O_RDWR | O_APPEND | O_CREAT| O_TRUNC, 0600); + + if (-1 == fd) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to open %s," ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to open %s," + " errno: %d", cksum_path, errno); + ret = -1; + goto out; +@@ -1911,7 +1931,8 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo, char *cksum_path, + + sort_fd = mkstemp (sort_filepath); + if (sort_fd < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Could not generate " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Could not generate " + "temp file, reason: %s for volume: %s", + strerror (errno), volinfo->volname); + goto out; +@@ -1923,7 +1944,8 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo, char *cksum_path, + + ret = glusterd_sort_and_redirect (filepath, sort_fd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "sorting info file " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FILE_OP_FAILED, "sorting info file " + "failed"); + goto out; + } +@@ -1937,7 +1959,8 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo, char *cksum_path, + + ret = get_checksum_for_path (cksum_path_final, &cksum); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "unable to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_GET_FAIL, "unable to get " + "checksum for path: %s", cksum_path_final); + goto out; + } +@@ -1961,7 +1984,7 @@ out: + close (fd); + if (unlink_sortfile) + unlink (sort_filepath); +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + + return ret; + } +@@ -1999,7 +2022,8 @@ int glusterd_compute_cksum (glusterd_volinfo_t *volinfo, + ret = glusterd_volume_compute_cksum (volinfo, cksum_path, filepath, + is_quota_conf, &cs); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to compute checksum " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_COMPUTE_FAIL, "Failed to compute checksum " + "for volume %s", volinfo->volname); + goto out; + } +@@ -2026,13 +2050,16 @@ _add_dict_to_prdict (dict_t *this, char *key, data_t *value, void *data) + ctx->key_name, ctx->opt_count); + ret = dict_set_str (ctx->dict, optkey, key); + if (ret) +- gf_log ("", GF_LOG_ERROR, "option add for %s%d %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "option add for %s%d %s", + ctx->key_name, ctx->opt_count, key); + snprintf (optkey, sizeof (optkey), "%s.%s%d", ctx->prefix, + ctx->val_name, ctx->opt_count); + ret = dict_set_str (ctx->dict, optkey, value->data); + if (ret) +- gf_log ("", GF_LOG_ERROR, "option add for %s%d %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "option add for %s%d %s", + ctx->val_name, ctx->opt_count, value->data); + ctx->opt_count++; + +@@ -2406,7 +2433,7 @@ out: + GF_FREE (rebalance_id_str); + GF_FREE (rb_id_str); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -2450,7 +2477,8 @@ glusterd_vol_add_quota_conf_to_dict (glusterd_volinfo_t *volinfo, dict_t* load, + if (ret == 0) { + break; + } else if (ret < 0) { +- gf_log (this->name, GF_LOG_CRITICAL, "Quota " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_QUOTA_CONF_CORRUPT, "Quota " + "configuration store may be corrupt."); + goto out; + } +@@ -2547,7 +2575,7 @@ out: + if (ret) + dict_unref (dict); + +- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2627,7 +2655,7 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, + snprintf (key, sizeof (key), "volume%d.quota-version", count); + ret = dict_get_uint32 (peer_data, key, "a_version); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "quota-version key absent for" ++ gf_msg_debug (this->name, 0, "quota-version key absent for" + " volume %s in peer %s's response", volinfo->volname, + hostname); + ret = 0; +@@ -2656,7 +2684,7 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, + snprintf (key, sizeof (key), "volume%d.quota-cksum", count); + ret = dict_get_uint32 (peer_data, key, "a_cksum); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "quota checksum absent for " ++ gf_msg_debug (this->name, 0, "quota checksum absent for " + "volume %s in peer %s's response", volinfo->volname, + hostname); + ret = 0; +@@ -2676,7 +2704,7 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, + *status = GLUSTERD_VOL_COMP_SCS; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning with ret: %d, status: %d", ++ gf_msg_debug (this->name, 0, "Returning with ret: %d, status: %d", + ret, *status); + return ret; + } +@@ -2729,8 +2757,9 @@ import_prdict_dict (dict_t *peer_data, dict_t *dst_dict, char *key_prefix, + + out: + if (msg[0]) +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_IMPORT_PRDICT_DICT, "%s", msg); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + + } +@@ -2807,8 +2836,9 @@ glusterd_import_friend_volume_opts (dict_t *peer_data, int count, + + out: + if (msg[0]) +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_OPTS_IMPORT_FAIL, "%s", msg); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -2894,8 +2924,9 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, + *brickinfo = new_brickinfo; + out: + if (msg[0]) +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_IMPORT_FAIL, "%s", msg); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -2935,7 +2966,7 @@ glusterd_import_bricks (dict_t *peer_data, int32_t vol_count, + } + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -2982,14 +3013,14 @@ glusterd_import_quota_conf (dict_t *peer_data, int vol_idx, + key[sizeof(key)-1] = '\0'; + ret = dict_get_uint32 (peer_data, key, &new_volinfo->quota_conf_cksum); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, "Failed to get quota cksum"); ++ gf_msg_debug (this->name, 0, "Failed to get quota cksum"); + + snprintf (key, sizeof (key)-1, "%s%d.quota-version", prefix, vol_idx); + key[sizeof(key)-1] = '\0'; + ret = dict_get_uint32 (peer_data, key, + &new_volinfo->quota_conf_version); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, "Failed to get quota " ++ gf_msg_debug (this->name, 0, "Failed to get quota " + "version"); + + snprintf (key, sizeof (key)-1, "%s%d.gfid-count", prefix, vol_idx); +@@ -3021,7 +3052,8 @@ glusterd_import_quota_conf (dict_t *peer_data, int vol_idx, + ret = glusterd_quota_conf_write_gfid (fd, gfid, + (char)gfid_type); + if (ret < 0) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to write " ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, "Unable to write " + "gfid %s into quota.conf for %s", gfid_str, + new_volinfo->volname); + ret = -1; +@@ -3037,14 +3069,16 @@ out: + if (!ret) { + ret = glusterd_compute_cksum (new_volinfo, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_COMPUTE_FAIL, + "Failed to compute checksum"); + goto clear_quota_conf; + } + + ret = glusterd_store_save_quota_version_and_cksum (new_volinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CKSUM_VER_STORE_FAIL, + "Failed to save quota version and checksum"); + } + +@@ -3092,7 +3126,7 @@ gd_import_friend_volume_rebal_dict (dict_t *dict, int count, + out: + if (ret && volinfo->rebal.dict) + dict_unref (volinfo->rebal.dict); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3195,7 +3229,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + snprintf (key, sizeof (key), "%s%d.stripe_count", prefix, count); + ret = dict_get_int32 (peer_data, key, &new_volinfo->stripe_count); + if (ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "peer is possibly old version"); + + /* not having a 'replica_count' key is not a error +@@ -3204,7 +3239,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + snprintf (key, sizeof (key), "%s%d.replica_count", prefix, count); + ret = dict_get_int32 (peer_data, key, &new_volinfo->replica_count); + if (ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "peer is possibly old version"); + + /* not having a 'disperse_count' key is not a error +@@ -3213,7 +3249,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + snprintf (key, sizeof (key), "%s%d.disperse_count", prefix, count); + ret = dict_get_int32 (peer_data, key, &new_volinfo->disperse_count); + if (ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "peer is possibly old version"); + + /* not having a 'redundancy_count' key is not a error +@@ -3222,7 +3259,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + snprintf (key, sizeof (key), "%s%d.redundancy_count", prefix, count); + ret = dict_get_int32 (peer_data, key, &new_volinfo->redundancy_count); + if (ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "peer is possibly old version"); + + /* not having a 'dist_count' key is not a error +@@ -3231,7 +3269,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + snprintf (key, sizeof (key), "%s%d.dist_count", prefix, count); + ret = dict_get_int32 (peer_data, key, &new_volinfo->dist_leaf_count); + if (ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, + "peer is possibly old version"); + + /* not having a 'hot_brick_count' key is not a error +@@ -3418,7 +3457,9 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = gd_import_volume_snap_details (peer_data, new_volinfo, key, + volname); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to import snapshot " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_DETAILS_IMPORT_FAIL, ++ "Failed to import snapshot " + "details for volume %s", volname); + goto out; + } +@@ -3453,7 +3494,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + } else if (((op_version == 0) && (client_op_version != 0)) || + ((op_version != 0) && (client_op_version == 0))) { + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Only one volume op-version found"); + goto out; + } else { +@@ -3473,8 +3515,9 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + *volinfo = new_volinfo; + out: + if (msg[0]) +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_IMPORT_FAIL, "%s", msg); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -3489,7 +3532,9 @@ glusterd_volume_disconnect_all_bricks (glusterd_volinfo_t *volinfo) + if (glusterd_is_brick_started (brickinfo)) { + ret = glusterd_brick_disconnect (brickinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSD_BRICK_DISCONNECT_FAIL, ++ "Failed to " + "disconnect %s:%s", brickinfo->hostname, + brickinfo->path); + break; +@@ -3579,7 +3624,7 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo, + } + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -3613,7 +3658,8 @@ glusterd_delete_stale_volume (glusterd_volinfo_t *stale_volinfo, + valid_volinfo->restored_from_snap))) { + ret = glusterd_lvm_snapshot_remove (NULL, stale_volinfo); + if (ret) { +- gf_log(this->name, GF_LOG_WARNING, ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ GD_MSG_SNAP_REMOVE_FAIL, + "Failed to remove lvm snapshot for " + "restored volume %s", stale_volinfo->volname); + } +@@ -3733,14 +3779,15 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + goto out; + + if (!new_volinfo) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Not importing snap volume"); + goto out; + } + + ret = glusterd_snapdsvc_init (new_volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " + "snapdsvc for volume %s", new_volinfo->volname); + goto out; + } +@@ -3752,7 +3799,8 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + */ + ret = glusterd_snapdsvc_init (old_volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize" + " snapdsvc for old volume %s", + old_volinfo->volname); + goto out; +@@ -3784,7 +3832,7 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + glusterd_compare_volume_name); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with ret: %d", ret); ++ gf_msg_debug ("", 0, "Returning with ret: %d", ret); + return ret; + } + +@@ -3809,7 +3857,7 @@ glusterd_import_friend_volumes (dict_t *peer_data) + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -3877,7 +3925,8 @@ glusterd_import_global_opts (dict_t *friend_data) + ret = import_prdict_dict (friend_data, import_options, "key", "val", + count, "global"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to import" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLOBAL_OPT_IMPORT_FAIL, "Failed to import" + " global options"); + goto out; + } +@@ -3923,7 +3972,8 @@ glusterd_compare_friend_data (dict_t *peer_data, int32_t *status, + + ret = glusterd_import_global_opts (peer_data); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Importing global " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLOBAL_OPT_IMPORT_FAIL, "Importing global " + "options failed"); + goto out; + } +@@ -3957,7 +4007,7 @@ glusterd_compare_friend_data (dict_t *peer_data, int32_t *status, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Returning with ret: %d, status: %d", ret, *status); + return ret; + } +@@ -4057,7 +4107,8 @@ glusterd_unlink_file (char *sockfpath) + if (ENOENT == errno) + ret = 0; + else +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to remove %s" ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Failed to remove %s" + " error: %s", sockfpath, strerror (errno)); + } + +@@ -4070,32 +4121,44 @@ glusterd_nfs_pmap_deregister () + if (pmap_unset (MOUNT_PROGRAM, MOUNTV3_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered MOUNTV3 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-register MOUNTV3 is unsuccessful"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-register MOUNTV3 is unsuccessful"); + + if (pmap_unset (MOUNT_PROGRAM, MOUNTV1_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered MOUNTV1 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-register MOUNTV1 is unsuccessful"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-register MOUNTV1 is unsuccessful"); + + if (pmap_unset (NFS_PROGRAM, NFSV3_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered NFSV3 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-register NFSV3 is unsuccessful"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-register NFSV3 is unsuccessful"); + + if (pmap_unset (NLM_PROGRAM, NLMV4_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered NLM v4 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-registration of NLM v4 failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-registration of NLM v4 failed"); + + if (pmap_unset (NLM_PROGRAM, NLMV1_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered NLM v1 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-registration of NLM v1 failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-registration of NLM v1 failed"); + + if (pmap_unset (ACL_PROGRAM, ACLV3_VERSION)) + gf_log ("", GF_LOG_INFO, "De-registered ACL v3 successfully"); + else +- gf_log ("", GF_LOG_ERROR, "De-registration of ACL v3 failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_PMAP_UNSET_FAIL, ++ "De-registration of ACL v3 failed"); + } + + int +@@ -4197,7 +4260,7 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count, + + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4316,7 +4379,7 @@ glusterd_volume_count_get (void) + } + + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + + } +@@ -4366,7 +4429,9 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo, + if (gf_uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, ++ FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -4378,13 +4443,15 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo, + } + ret = glusterd_volume_start_glusterfs (volinfo, brickinfo, wait); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to start brick %s:%s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_DISCONNECTED, ++ "Unable to start brick %s:%s", + brickinfo->hostname, brickinfo->path); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "returning %d ", ret); ++ gf_msg_debug (this->name, 0, "returning %d ", ret); + return ret; + } + +@@ -4408,7 +4475,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf) + start_svcs = _gf_true; + glusterd_svcs_manager (volinfo); + } +- gf_log (this->name, GF_LOG_DEBUG, "starting the volume %s", ++ gf_msg_debug (this->name, 0, "starting the volume %s", + volinfo->volname); + cds_list_for_each_entry (brickinfo, &volinfo->bricks, + brick_list) { +@@ -4425,7 +4492,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf) + glusterd_svcs_manager (volinfo); + } + start_svcs = _gf_true; +- gf_log (this->name, GF_LOG_DEBUG, "starting the snap " ++ gf_msg_debug (this->name, 0, "starting the snap " + "volume %s", volinfo->volname); + cds_list_for_each_entry (brickinfo, &volinfo->bricks, + brick_list) { +@@ -4485,7 +4552,8 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + ret = glusterd_get_slave_info (slave, &slave_url, &slave_host, + &slave_vol, &op_errstr); + if (ret) { +- gf_log (this1->name, GF_LOG_ERROR, ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave details."); + ret = -1; + goto out; +@@ -4503,10 +4571,13 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + &is_template_in_use); + if (ret) { + if (!strstr(slave, "::")) +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_SLAVE_URL_INVALID, + "%s is not a valid slave url.", slave); + else +- gf_log (this1->name, GF_LOG_INFO, "Unable to get" ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_GET_STATEFILE_NAME_FAILED, ++ "Unable to get" + " statefile's name"); + goto out; + } +@@ -4514,7 +4585,8 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + /* If state-file entry is missing from the config file, + * do not start gsyncd on restart */ + if (is_template_in_use) { +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_NO_STATEFILE_ENTRY, + "state-file entry is missing in config file." + "Not Restarting"); + goto out; +@@ -4525,14 +4597,16 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + ret = gsync_status (volinfo->volname, slave, confpath, + &ret_status, &is_template_in_use); + if (ret == -1) { +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_GSYNC_VALIDATION_FAIL, + GEOREP" start option validation failed "); + ret = 0; + goto out; + } + + if (is_template_in_use == _gf_true) { +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_PIDFILE_NOT_FOUND, + "pid-file entry is missing in config file." + "Not Restarting"); + ret = 0; +@@ -4541,7 +4615,9 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + + ret = glusterd_gsync_read_frm_status (statefile, buf, sizeof (buf)); + if (ret < 0) { +- gf_log (this1->name, GF_LOG_ERROR, "Unable to read the status"); ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_STAT_FILE_READ_FAILED, ++ "Unable to read the status"); + goto out; + } + +@@ -4580,7 +4656,9 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + ret = dict_set_dynstr_with_alloc (volinfo->gsync_active_slaves, + key1, "running"); + if (ret) { +- gf_log (this1->name, GF_LOG_ERROR, "Unable to set key:%s" ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Unable to set key:%s" + " value:running in the dict", key1); + goto out; + } +@@ -4599,7 +4677,8 @@ out: + slave_host, slave_vol, + "Config Corrupted"); + if (op_ret) { +- gf_log (this1->name, GF_LOG_ERROR, ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_STATUSFILE_CREATE_FAILED, + "Unable to create status file" + ". Error : %s", strerror (errno)); + ret = op_ret; +@@ -4699,10 +4778,10 @@ glusterd_set_brick_status (glusterd_brickinfo_t *brickinfo, + GF_ASSERT (brickinfo); + brickinfo->status = status; + if (GF_BRICK_STARTED == status) { +- gf_log ("glusterd", GF_LOG_DEBUG, "Setting brick %s:%s status " ++ gf_msg_debug ("glusterd", 0, "Setting brick %s:%s status " + "to started", brickinfo->hostname, brickinfo->path); + } else { +- gf_log ("glusterd", GF_LOG_DEBUG, "Setting brick %s:%s status " ++ gf_msg_debug ("glusterd", 0, "Setting brick %s:%s status " + "to stopped", brickinfo->hostname, brickinfo->path); + } + } +@@ -4758,7 +4837,8 @@ glusterd_get_brick_root (char *path, char **mount_point) + + *ptr = '\0'; + if (stat (mnt_pt, &buf)) { +- gf_log (THIS->name, GF_LOG_ERROR, "error in " ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "error in " + "stat: %s", strerror (errno)); + goto err; + } +@@ -4771,7 +4851,8 @@ glusterd_get_brick_root (char *path, char **mount_point) + + if (ptr == mnt_pt) { + if (stat ("/", &buf)) { +- gf_log (THIS->name, GF_LOG_ERROR, "error in " ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "error in " + "stat: %s", strerror (errno)); + goto err; + } +@@ -4883,7 +4964,9 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) + runner_add_arg (&runner, fs->fs_tool_arg); + runner_add_arg (&runner, device); + } else { +- gf_log (THIS->name, GF_LOG_ERROR, "could not find %s to get" ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_INODE_SIZE_GET_FAIL, ++ "could not find %s to get" + "inode size for %s (%s): %s package missing?", + fs->fs_tool_name, device, fs_name, fs->fs_tool_pkg); + goto out; +@@ -4891,8 +4974,9 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) + + ret = runner_start (&runner); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to execute " +- "\"%s\": %s", fs->fs_tool_name, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_CMD_EXEC_FAIL, "failed to execute " ++ "\"%s\"", fs->fs_tool_name); + /* + * Runner_start might return an error after the child has + * been forked, e.g. if the program isn't there. In that +@@ -4921,7 +5005,8 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) + + ret = runner_end (&runner); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_CMD_EXEC_FAIL, + "%s exited with non-zero exit status", + fs->fs_tool_name); + +@@ -4929,7 +5014,8 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) + } + if (!cur_word) { + ret = -1; +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_INODE_SIZE_GET_FAIL, + "Unable to retrieve inode size using %s", + fs->fs_tool_name); + goto out; +@@ -4937,7 +5023,7 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) + + if (dict_set_dynstr_with_alloc (cached_fs, device, cur_word)) { + /* not fatal if not entered into the cache */ +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to cache fs inode size for %s", device); + } + +@@ -4949,7 +5035,8 @@ cached: + + out: + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "failed to get inode size"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_INODE_SIZE_GET_FAIL, "failed to get inode size"); + return ret; + } + +@@ -5057,7 +5144,9 @@ glusterd_get_brick_mount_device (char *brick_path) + + ret = glusterd_get_brick_root (brick_path, &mnt_pt); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get mount point " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICKPATH_ROOT_GET_FAIL, ++ "Failed to get mount point " + "for %s brick", brick_path); + goto out; + } +@@ -5065,7 +5154,9 @@ glusterd_get_brick_mount_device (char *brick_path) + entry = glusterd_get_mnt_entry_info (mnt_pt, buff, sizeof (buff), + &save_entry); + if (NULL == entry) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get mnt entry " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MNTENTRY_GET_FAIL, ++ "Failed to get mnt entry " + "for %s mount path", mnt_pt); + goto out; + } +@@ -5102,7 +5193,8 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, + + ret = statvfs (brickinfo->path, &brickstat); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "statfs error: %s ", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "statfs error: %s ", + strerror (errno)); + goto out; + } +@@ -5157,7 +5249,7 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, + ret = glusterd_add_inode_size_to_dict (dict, count); + out: + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, "Error adding brick" ++ gf_msg_debug (this->name, 0, "Error adding brick" + " detail to dict: %s", strerror (errno)); + return ret; + } +@@ -5246,7 +5338,7 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, + + out: + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -5277,7 +5369,8 @@ glusterd_get_all_volnames (dict_t *dict) + + out: + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "failed to get all " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "failed to get all " + "volume names for status"); + return ret; + } +@@ -5307,7 +5400,7 @@ glusterd_all_volume_cond_check (glusterd_condition_func func, int status, + } + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("", 0, "returning %d", ret); + return ret; + } + +@@ -5332,7 +5425,8 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo, + if (gf_uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -5345,19 +5439,20 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo, + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "About to stop glusterfs" ++ gf_msg_debug (this->name, 0, "About to stop glusterfs" + " for brick %s:%s", brickinfo->hostname, + brickinfo->path); + ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo, del_brick); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to stop" ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_BRICK_STOP_FAIL, "Unable to stop" + " brick: %s:%s", brickinfo->hostname, + brickinfo->path); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "returning %d ", ret); ++ gf_msg_debug (this->name, 0, "returning %d ", ret); + return ret; + } + +@@ -5448,8 +5543,9 @@ out: + if (is_allocated) + glusterd_brickinfo_delete (newbrickinfo); + if (op_errstr[0] != '\0') +- gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); +- gf_log (this->name, GF_LOG_DEBUG, "returning %d ", ret); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_VALIDATE_FAIL, "%s", op_errstr); ++ gf_msg_debug (this->name, 0, "returning %d ", ret); + return ret; + } + +@@ -5468,13 +5564,17 @@ glusterd_rb_check_bricks (glusterd_volinfo_t *volinfo, + + if (strcmp (rb->src_brick->hostname, src->hostname) || + strcmp (rb->src_brick->path, src->path)) { +- gf_log("", GF_LOG_ERROR, "Replace brick src bricks differ"); ++ gf_msg("", GF_LOG_ERROR, 0, ++ GD_MSG_RB_SRC_BRICKS_MISMATCH, ++ "Replace brick src bricks differ"); + return -1; + } + + if (strcmp (rb->dst_brick->hostname, dst->hostname) || + strcmp (rb->dst_brick->path, dst->path)) { +- gf_log ("", GF_LOG_ERROR, "Replace brick dst bricks differ"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_RB_DST_BRICKS_MISMATCH, ++ "Replace brick dst bricks differ"); + return -1; + } + +@@ -5586,7 +5686,8 @@ out: + } + + if (strlen (msg)) { +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_PATH_ALREADY_PART_OF_VOL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + +@@ -5690,7 +5791,7 @@ glusterd_sm_tr_log_transition_add_to_dict (dict_t *dict, + goto out; + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("", 0, "returning %d", ret); + return ret; + } + +@@ -5731,7 +5832,7 @@ glusterd_sm_tr_log_add_to_dict (dict_t *dict, + ret = dict_set_int32 (dict, key, log->count); + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("", 0, "returning %d", ret); + return ret; + } + +@@ -5762,7 +5863,7 @@ glusterd_sm_tr_log_init (glusterd_sm_tr_log_t *log, + ret = 0; + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug ("", 0, "returning %d", ret); + return ret; + } + +@@ -5809,11 +5910,11 @@ glusterd_sm_tr_log_transition_add (glusterd_sm_tr_log_t *log, + if (log->count < log->size) + log->count++; + ret = 0; +- gf_log (this->name, GF_LOG_DEBUG, "Transitioning from '%s' to '%s' " ++ gf_msg_debug (this->name, 0, "Transitioning from '%s' to '%s' " + "due to event '%s'", log->state_name_get (old_state), + log->state_name_get (new_state), log->event_name_get (event)); + out: +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -5833,7 +5934,7 @@ glusterd_remove_pending_entry (struct cds_list_head *list, void *elem) + } + } + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "returning %d", ret); + return ret; + + } +@@ -5865,7 +5966,7 @@ glusterd_delete_volume (glusterd_volinfo_t *volinfo) + + glusterd_volinfo_remove (volinfo); + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "returning %d", ret); + return ret; + } + +@@ -5923,7 +6024,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + path_tokens = GF_CALLOC (sizeof(char*), volinfo->brick_count, + gf_gld_mt_charptr); + if (!path_tokens) { +- gf_log ("", GF_LOG_DEBUG, "Could not allocate memory."); ++ gf_msg_debug ("", 0, "Could not allocate memory."); + ret = -1; + goto out; + } +@@ -5940,7 +6041,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + path[sizeof(path)-1] = '\0'; + path_tokens[count] = gf_strdup (path); + if (!path_tokens[count]) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "Could not allocate memory."); + ret = -1; + goto out; +@@ -5952,7 +6053,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + tmp_path_list = GF_CALLOC (sizeof(char), total_len + 1, + gf_gld_mt_char); + if (!tmp_path_list) { +- gf_log ("", GF_LOG_DEBUG, "Could not allocate memory."); ++ gf_msg_debug ("", 0, "Could not allocate memory."); + ret = -1; + goto out; + } +@@ -5975,12 +6076,12 @@ out: + path_tokens = NULL; + + if (ret == 0) { +- gf_log ("", GF_LOG_DEBUG, "No Local Bricks Present."); ++ gf_msg_debug ("", 0, "No Local Bricks Present."); + GF_FREE (tmp_path_list); + tmp_path_list = NULL; + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -6008,7 +6109,7 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave, + + if (!path_list) { + ret = 0; +- gf_log ("", GF_LOG_DEBUG, "No Bricks in this node." ++ gf_msg_debug ("", 0, "No Bricks in this node." + " Not starting gsyncd."); + goto out; + } +@@ -6071,7 +6172,7 @@ out: + "the " GEOREP " session"); + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -6088,21 +6189,24 @@ glusterd_recreate_volfiles (glusterd_conf_t *conf) + cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) { + ret = generate_brick_volfiles (volinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to " + "regenerate brick volfiles for %s", + volinfo->volname); + op_ret = ret; + } + ret = generate_client_volfiles (volinfo, GF_CLIENT_TRUSTED); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to " + "regenerate trusted client volfiles for %s", + volinfo->volname); + op_ret = ret; + } + ret = generate_client_volfiles (volinfo, GF_CLIENT_OTHER); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to " + "regenerate client volfiles for %s", + volinfo->volname); + op_ret = ret; +@@ -6125,7 +6229,8 @@ glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf) + if (!ret) { + ret = gf_string2boolean (type, &upgrade); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "upgrade option " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_STR_TO_BOOL_FAIL, "upgrade option " + "%s is not a valid boolean type", type); + ret = -1; + goto out; +@@ -6138,7 +6243,8 @@ glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf) + if (!ret) { + ret = gf_string2boolean (type, &downgrade); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "downgrade option " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_STR_TO_BOOL_FAIL, "downgrade option " + "%s is not a valid boolean type", type); + ret = -1; + goto out; +@@ -6146,7 +6252,8 @@ glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf) + } + + if (upgrade && downgrade) { +- gf_log ("glusterd", GF_LOG_ERROR, "Both upgrade and downgrade" ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_WRONG_OPTS_SETTING, "Both upgrade and downgrade" + " options are set. Only one should be on"); + ret = -1; + goto out; +@@ -6265,7 +6372,8 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, + if (gf_uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, + "Cannot resolve brick %s:%s", + brickinfo->hostname, brickinfo->path); + goto out; +@@ -6281,7 +6389,8 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, + + pidfile = fopen (pidfile_path, "r"); + if (!pidfile) { +- gf_log ("", GF_LOG_ERROR, "Unable to open pidfile: %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to open pidfile: %s", + pidfile_path); + ret = -1; + goto out; +@@ -6289,7 +6398,9 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, + + ret = fscanf (pidfile, "%d", &pid); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to get pid of brick process"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "Unable to get pid of brick process"); + ret = -1; + goto out; + } +@@ -6298,7 +6409,9 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, + DEFAULT_VAR_RUN_DIRECTORY"/glusterdump.%d.options", pid); + ret = glusterd_set_dump_options (dumpoptions_path, options, option_cnt); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "error while parsing the statedump " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BRK_STATEDUMP_FAIL, ++ "error while parsing the statedump " + "options"); + ret = -1; + goto out; +@@ -6354,7 +6467,8 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr) + + pidfile = fopen (pidfile_path, "r"); + if (!pidfile) { +- gf_log ("", GF_LOG_ERROR, "Unable to open pidfile: %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to open pidfile: %s", + pidfile_path); + ret = -1; + goto out; +@@ -6362,7 +6476,9 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr) + + ret = fscanf (pidfile, "%d", &pid); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to get pid of brick process"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "Unable to get pid of brick process"); + ret = -1; + goto out; + } +@@ -6371,7 +6487,9 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr) + DEFAULT_VAR_RUN_DIRECTORY"/glusterdump.%d.options", pid); + ret = glusterd_set_dump_options (dumpoptions_path, options, option_cnt); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "error while parsing the statedump " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BRK_STATEDUMP_FAIL, ++ "error while parsing the statedump " + "options"); + ret = -1; + goto out; +@@ -6429,7 +6547,8 @@ glusterd_quotad_statedump (char *options, int option_cnt, char **op_errstr) + + pidfile = fopen (pidfile_path, "r"); + if (!pidfile) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to open pidfile: %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to open pidfile: %s", + pidfile_path); + ret = -1; + goto out; +@@ -6437,7 +6556,8 @@ glusterd_quotad_statedump (char *options, int option_cnt, char **op_errstr) + + ret = fscanf (pidfile, "%d", &pid); + if (ret <= 0) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get pid of quotad " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to get pid of quotad " + "process"); + ret = -1; + goto out; +@@ -6447,7 +6567,8 @@ glusterd_quotad_statedump (char *options, int option_cnt, char **op_errstr) + DEFAULT_VAR_RUN_DIRECTORY"/glusterdump.%d.options", pid); + ret = glusterd_set_dump_options (dumpoptions_path, options, option_cnt); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "error while parsing " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_STATEDUMP_FAIL, "error while parsing " + "statedump options"); + ret = -1; + goto out; +@@ -6497,7 +6618,7 @@ glusterd_friend_contains_vol_bricks (glusterd_volinfo_t *volinfo, + else + ret = 1; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -6523,7 +6644,8 @@ glusterd_friend_remove_cleanup_vols (uuid_t uuid) + "Deleting stale volume %s", volinfo->volname); + ret = glusterd_delete_volume (volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_STALE_VOL_REMOVE_FAIL, + "Error deleting stale volume"); + goto out; + } +@@ -6531,7 +6653,7 @@ glusterd_friend_remove_cleanup_vols (uuid_t uuid) + } + ret = 0; + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -6651,7 +6773,9 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr, + cbk, volinfo->rebal.op); + break; + default: +- gf_log (this->name, GF_LOG_ERROR, "Unknown defrag status (%d)." ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REBALANCE_START_FAIL, ++ "Unknown defrag status (%d)." + "Not starting rebalance process for %s.", + volinfo->rebal.defrag_status, volinfo->volname); + break; +@@ -6725,19 +6849,24 @@ glusterd_validate_volume_id (dict_t *op_dict, glusterd_volinfo_t *volinfo) + + ret = dict_get_str (op_dict, "vol-id", &volid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume id for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get volume id for " + "volume %s", volinfo->volname); + goto out; + } + ret = gf_uuid_parse (volid_str, vol_uid); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to parse volume id " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_PARSE_FAIL, ++ "Failed to parse volume id " + "for volume %s", volinfo->volname); + goto out; + } + + if (gf_uuid_compare (vol_uid, volinfo->volume_id)) { +- gf_log (this->name, GF_LOG_ERROR, "Volume ids of volume %s - %s" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_ID_MISMATCH, "Volume ids of volume %s - %s" + " and %s - are different. Possibly a split brain among " + "peers.", volinfo->volname, volid_str, + uuid_utoa (volinfo->volume_id)); +@@ -6769,32 +6898,32 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, + + ret = dict_get_uint64 (rsp_dict, "files", &files); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get file count"); + + ret = dict_get_uint64 (rsp_dict, "size", &size); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get size of xfer"); + + ret = dict_get_uint64 (rsp_dict, "lookups", &lookup); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get lookedup file count"); + + ret = dict_get_int32 (rsp_dict, "status", (int32_t *)&status); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get status"); + + ret = dict_get_uint64 (rsp_dict, "failures", &failures); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get failure count"); + + ret = dict_get_uint64 (rsp_dict, "skipped", &skipped); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get skipped count"); + + ret = dict_get_uint64 (rsp_dict, "promoted", &promoted); +@@ -6809,7 +6938,7 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, + + ret = dict_get_double (rsp_dict, "run-time", &run_time); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get run-time"); + + if (files) +@@ -6858,7 +6987,9 @@ glusterd_check_topology_identical (const char *filename1, + /* fopen() the volfile1 to create the graph */ + fp1 = fopen (filename1, "r"); + if (fp1 == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "fopen() on file: %s failed " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "fopen() on file: %s failed " + "(%s)", filename1, strerror (errno)); + goto out; + } +@@ -6866,7 +6997,9 @@ glusterd_check_topology_identical (const char *filename1, + /* fopen() the volfile2 to create the graph */ + fp2 = fopen (filename2, "r"); + if (fp2 == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "fopen() on file: %s failed " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "fopen() on file: %s failed " + "(%s)", filename2, strerror (errno)); + goto out; + } +@@ -6894,7 +7027,7 @@ out: + if (grph2) + glusterfs_graph_destroy(grph2); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -6918,7 +7051,9 @@ glusterd_check_files_identical (char *filename1, char *filename2, + ret = stat (filename1, &buf1); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "stat on file: %s failed " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "stat on file: %s failed " + "(%s)", filename1, strerror (errno)); + goto out; + } +@@ -6926,7 +7061,9 @@ glusterd_check_files_identical (char *filename1, char *filename2, + ret = stat (filename2, &buf2); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "stat on file: %s failed " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "stat on file: %s failed " + "(%s)", filename2, strerror (errno)); + goto out; + } +@@ -6951,7 +7088,7 @@ glusterd_check_files_identical (char *filename1, char *filename2, + *identical = _gf_true; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -6979,7 +7116,8 @@ glusterd_volset_help (dict_t *dict, char **op_errstr) + #if (HAVE_LIB_XML) + ret = 0; + #else +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_INSTALLED, + "libxml not present in the system"); + if (op_errstr) + *op_errstr = gf_strdup ("Error: xml libraries not " +@@ -6997,7 +7135,7 @@ glusterd_volset_help (dict_t *dict, char **op_errstr) + *op_errstr = gf_strdup ("Failed to get volume options help"); + out: + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -7022,7 +7160,9 @@ glusterd_to_cli (rpcsvc_request_t *req, gf_cli_rsp *arg, struct iovec *payload, + + ret = dict_get_str (dict, "cmd-str", &cmd); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to get command " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get command " + "string"); + + if (cmd) { +@@ -7056,14 +7196,16 @@ glusterd_append_gsync_status (dict_t *dst, dict_t *src) + + ret = dict_set_dynstr_with_alloc (dst, "gsync-status", stop_msg); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, "Unable to set the stop" ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Unable to set the stop" + "message in the ctx dictionary"); + goto out; + } + + ret = 0; + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -7090,7 +7232,7 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (src, "gsync-count", &src_count); + if (ret || !src_count) { +- gf_log ("", GF_LOG_DEBUG, "Source brick empty"); ++ gf_msg_debug ("", 0, "Source brick empty"); + ret = 0; + goto out; + } +@@ -7106,7 +7248,8 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) + dst_sts_val = GF_CALLOC (1, sizeof(gf_gsync_status_t), + gf_common_mt_gsync_status_t); + if (!dst_sts_val) { +- gf_log ("", GF_LOG_ERROR, "Out Of Memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out Of Memory"); + goto out; + } + +@@ -7123,7 +7266,7 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) + ret = dict_set_int32 (dst, "gsync-count", dst_count+src_count); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + + } +@@ -7145,7 +7288,7 @@ glusterd_aggr_brick_mount_dirs (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_get_int32 (rsp_dict, "brick_count", &brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "No brick_count present"); ++ gf_msg_debug (this->name, 0, "No brick_count present"); + ret = 0; + goto out; + } +@@ -7156,7 +7299,7 @@ glusterd_aggr_brick_mount_dirs (dict_t *aggr, dict_t *rsp_dict) + ret = dict_get_str (rsp_dict, key, &brick_mount_dir); + if (ret) { + /* Coz the info will come from a different node */ +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "%s not present", key); + continue; + } +@@ -7164,7 +7307,8 @@ glusterd_aggr_brick_mount_dirs (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_dynstr_with_alloc (aggr, key, + brick_mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set %s", key); + goto out; + } +@@ -7172,7 +7316,7 @@ glusterd_aggr_brick_mount_dirs (dict_t *aggr, dict_t *rsp_dict) + + ret = 0; + out: +- gf_log (this->name, GF_LOG_TRACE, "Returning %d ", ret); ++ gf_msg_trace (this->name, 0, "Returning %d ", ret); + return ret; + } + +@@ -7189,7 +7333,8 @@ glusterd_gsync_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict, char *op_errstr) + } else { + ctx = glusterd_op_get_ctx (); + if (!ctx) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, + "Operation Context is not present"); + GF_ASSERT (0); + } +@@ -7209,7 +7354,8 @@ glusterd_gsync_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict, char *op_errstr) + ret = dict_set_dynstr_with_alloc (ctx, "conf_path", + conf_path); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to store conf path."); + goto out; + } +@@ -7224,7 +7370,7 @@ glusterd_gsync_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict, char *op_errstr) + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d ", ret); ++ gf_msg_debug ("", 0, "Returning %d ", ret); + return ret; + } + +@@ -7246,7 +7392,8 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + } else { + ctx = glusterd_op_get_ctx (); + if (!ctx) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, + "Operation Context is not present"); + GF_ASSERT (0); + } +@@ -7255,19 +7402,21 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + if (rsp_dict) { + ret = dict_get_int32 (rsp_dict, "src-brick-port", &src_port); + if (ret == 0) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "src-brick-port=%d found", src_port); + } + + ret = dict_get_int32 (rsp_dict, "dst-brick-port", &dst_port); + if (ret == 0) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "dst-brick-port=%d found", dst_port); + } + + ret = glusterd_aggr_brick_mount_dirs (ctx, rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNDIRS_AGGR_FAIL, ++ "Failed to " + "aggregate brick mount dirs"); + goto out; + } +@@ -7277,7 +7426,7 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_int32 (ctx, "src-brick-port", + src_port); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "Could not set src-brick"); + goto out; + } +@@ -7287,7 +7436,7 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_int32 (ctx, "dst-brick-port", + dst_port); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("", 0, + "Could not set dst-brick"); + goto out; + } +@@ -7411,7 +7560,9 @@ glusterd_volume_status_add_peer_rsp (dict_t *this, char *key, data_t *value, + + ret = dict_set (rsp_ctx->dict, new_key, new_value); + if (ret) +- gf_log ("", GF_LOG_ERROR, "Unable to set key: %s in dict", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Unable to set key: %s in dict", + key); + + return 0; +@@ -7464,7 +7615,8 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + + ret = dict_get_int32 (rsp_dict, "tasks", &remote_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get remote task count"); + goto out; + } +@@ -7477,13 +7629,16 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + glusterd_volume_status_copy_tasks_to_ctx_dict, + ctx_dict); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to copy tasks" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to copy tasks" + "to ctx_dict."); + goto out; + } + + if (local_count != remote_count) { +- gf_log (this->name, GF_LOG_ERROR, "Local tasks count (%d) and " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASKS_COUNT_MISMATCH, ++ "Local tasks count (%d) and " + "remote tasks count (%d) do not match. Not aggregating " + "tasks status.", local_count, remote_count); + ret = -1; +@@ -7500,7 +7655,8 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + snprintf (key, sizeof (key), "task%d.type", i); + ret = dict_get_str (rsp_dict, key, &task_type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get task typpe from rsp dict"); + goto out; + } +@@ -7518,14 +7674,16 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + snprintf (key, sizeof (key), "task%d.status", i); + ret = dict_get_int32 (rsp_dict, key, &remote_status); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get task status from rsp dict"); + goto out; + } + snprintf (key, sizeof (key), "task%d.id", i); + ret = dict_get_str (rsp_dict, key, &remote_task_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get task id from rsp dict"); + goto out; + } +@@ -7534,7 +7692,8 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + snprintf (key, sizeof (key), "task%d.id", j); + ret = dict_get_str (ctx_dict, key, &local_task_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get local task-id"); + goto out; + } +@@ -7543,7 +7702,8 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + strlen (remote_task_id))) { + /* Quit if a matching local task is not found */ + if (j == (local_count - 1)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASKS_COUNT_MISMATCH, + "Could not find matching local " + "task for task %s", + remote_task_id); +@@ -7556,7 +7716,8 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + snprintf (key, sizeof (key), "task%d.status", j); + ret = dict_get_int32 (ctx_dict, key, &local_status); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get local task status"); + goto out; + } +@@ -7585,7 +7746,9 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, + ret = dict_set_int32 (ctx_dict, key, + remote_status); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASK_STATUS_UPDATE_FAIL, ++ "Failed to " + "update task status"); + goto out; + } +@@ -7671,7 +7834,8 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_get_int32 (rsp_dict, "other-count", &rsp_other_count); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get other count from rsp_dict"); + goto out; + } +@@ -7699,7 +7863,8 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_set_int32 (ctx_dict, "count", node_count + rsp_node_count); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to update node count"); + goto out; + } +@@ -7707,7 +7872,8 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_int32 (ctx_dict, "other-count", + (other_count + rsp_other_count)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to update other-count"); + goto out; + } +@@ -7795,7 +7961,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_get_str (ctx_dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get volume name"); + goto out; + } + +@@ -7806,7 +7974,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_get_int32 (rsp_dict, "count", &index); + if (ret) +- gf_log ("", GF_LOG_ERROR, "failed to get index"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "failed to get index"); + + memset (key, 0, 256); + snprintf (key, 256, "node-uuid-%d", index); +@@ -7829,9 +7999,11 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + /* Setting the largest index value as the total count. */ + ret = dict_get_int32 (ctx_dict, "count", &count); + if (count < current_index) { +- ret = dict_set_int32 (ctx_dict, "count", current_index); +- if (ret) +- gf_log ("", GF_LOG_ERROR, "Failed to set count"); ++ ret = dict_set_int32 (ctx_dict, "count", current_index); ++ if (ret) ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set count"); + } + + /* Setting the same index for the node, as is in the peerlist.*/ +@@ -7839,7 +8011,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "node-uuid-%d", current_index); + ret = dict_set_dynstr (ctx_dict, key, node_uuid_str); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set node-uuid"); + } + } +@@ -7851,7 +8023,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "files-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set the file count"); + } + } +@@ -7864,7 +8036,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "size-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set the size of migration"); + } + } +@@ -7877,7 +8049,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "lookups-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set lookuped file count"); + } + } +@@ -7890,7 +8062,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "status-%d", current_index); + ret = dict_set_int32 (ctx_dict, key, value32); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set status"); + } + } +@@ -7903,7 +8075,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "failures-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set failure count"); + } + } +@@ -7916,7 +8088,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "skipped-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set skipped count"); + } + } +@@ -7928,7 +8100,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "run-time-%d", current_index); + ret = dict_set_double (ctx_dict, key, elapsed_time); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set run-time"); + } + } +@@ -7976,7 +8148,9 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + int dst_output_count = 0; + + if (!dst || !src) { +- gf_log ("", GF_LOG_ERROR, "Source or Destination " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_EMPTY, ++ "Source or Destination " + "dict is empty."); + goto out; + } +@@ -7985,7 +8159,7 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (src, "output_count", &src_output_count); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "No output from source"); ++ gf_msg_debug ("", 0, "No output from source"); + ret = 0; + goto out; + } +@@ -7996,7 +8170,9 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + output_name[len] = '\0'; + ret = dict_get_str (src, output_name, &output); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch %s", + output_name); + goto out; + } +@@ -8006,7 +8182,9 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + output_name[len] = '\0'; + ret = dict_set_dynstr (dst, output_name, gf_strdup (output)); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to set %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Unable to set %s", + output_name); + goto out; + } +@@ -8015,7 +8193,7 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + ret = dict_set_int32 (dst, "output_count", + dst_output_count+src_output_count); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -8050,12 +8228,14 @@ glusterd_volume_heal_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_get_bin (aggr, "transaction_id", (void **)&txn_id); + if (ret) + goto out; +- gf_log (THIS->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (THIS->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get txn_op_info " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Failed to get txn_op_info " + "for txn_id = %s", uuid_utoa (*txn_id)); + goto out; + } +@@ -8111,7 +8291,9 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + + ret = dict_get_int32 (dict, "type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get quota opcode"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get quota opcode"); + goto out; + } + +@@ -8126,7 +8308,9 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + + ret = dict_get_int32 (rsp_dict, "count", &rsp_dict_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get the count of " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get the count of " + "gfids from the rsp dict"); + goto out; + } +@@ -8137,7 +8321,7 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + * called after self-staging on the originator. This must not + * be treated as error. + */ +- gf_log (this->name, GF_LOG_DEBUG, "Failed to get count of gfids" ++ gf_msg_debug (this->name, 0, "Failed to get count of gfids" + " from req dict. This could be because count is not yet" + " copied from rsp_dict into op_ctx"); + +@@ -8146,7 +8330,9 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + + ret = dict_get_str (rsp_dict, key, &uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get gfid " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get gfid " + "from rsp dict"); + goto out; + } +@@ -8161,7 +8347,9 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + + ret = dict_set_dynstr (dict, key, uuid_str_dup); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set gfid " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set gfid " + "from rsp dict into req dict"); + GF_FREE (uuid_str_dup); + goto out; +@@ -8170,7 +8358,9 @@ glusterd_volume_quota_copy_to_op_ctx_dict (dict_t *dict, dict_t *rsp_dict) + + ret = dict_set_int32 (dict, "count", rsp_dict_count + count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set aggregated " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set aggregated " + "count in req dict"); + goto out; + } +@@ -8379,13 +8569,17 @@ glusterd_heal_volume_brick_rsp (dict_t *req_dict, dict_t *rsp_dict, + + ret = dict_get_str (req_dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get volume name"); + goto out; + } + + ret = dict_get_int32 (req_dict, "heal-op", &heal_op); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get heal_op"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get heal_op"); + goto out; + } + +@@ -8446,7 +8640,9 @@ glusterd_status_volume_brick_rsp (dict_t *rsp_dict, dict_t *op_ctx, + } + ret = dict_get_int32 (rsp_dict, "index", &index); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't get node index"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Couldn't get node index"); + goto out; + } + dict_del (rsp_dict, "index"); +@@ -8478,7 +8674,9 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, + + ret = dict_get_str (req_dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get volume name"); + goto out; + } + +@@ -8502,7 +8700,9 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, + + ret = dict_set_int32 (op_ctx, "count", i); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to set count"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set count"); + + snprintf (buf, 1024, "%s", uuid_utoa (MY_UUID)); + node_str = gf_strdup (buf); +@@ -8510,56 +8710,64 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, + snprintf (key, 256, "node-uuid-%d",i); + ret = dict_set_dynstr (op_ctx, key, node_str); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set node-uuid"); + + memset (key, 0 , 256); + snprintf (key, 256, "files-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.rebalance_files); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set file count"); + + memset (key, 0 , 256); + snprintf (key, 256, "size-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.rebalance_data); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set size of xfer"); + + memset (key, 0 , 256); + snprintf (key, 256, "lookups-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.lookedup_files); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set lookedup file count"); + + memset (key, 0 , 256); + snprintf (key, 256, "status-%d", i); + ret = dict_set_int32 (op_ctx, key, volinfo->rebal.defrag_status); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set status"); + + memset (key, 0 , 256); + snprintf (key, 256, "failures-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.rebalance_failures); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set failure count"); + + memset (key, 0 , 256); + snprintf (key, 256, "skipped-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.skipped_files); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set skipped count"); + + memset (key, 0, 256); + snprintf (key, 256, "run-time-%d", i); + ret = dict_set_double (op_ctx, key, volinfo->rebal.rebalance_time); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set run-time"); + + memset (key, 0 , 256); +@@ -8612,7 +8820,7 @@ glusterd_handle_node_rsp (dict_t *req_dict, void *pending_entry, + break; + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -8635,7 +8843,8 @@ glusterd_set_originator_uuid (dict_t *dict) + ret = dict_set_bin (dict, "originator_uuid", + originator_uuid, sizeof (uuid_t)); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set originator_uuid."); + goto out; + } +@@ -8700,7 +8909,8 @@ glusterd_generate_and_set_task_id (dict_t *dict, char *key) + + ret = dict_set_dynstr (dict, key, uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set %s in dict", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set %s in dict", + key); + goto out; + } +@@ -8731,7 +8941,8 @@ glusterd_copy_uuid_to_dict (uuid_t uuid, dict_t *dict, char *key) + ret = dict_set_dynstr (dict, key, task_id_str); + if (ret) { + GF_FREE (task_id_str); +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting uuid in dict with key %s", key); + } + +@@ -8832,7 +9043,8 @@ op_version_check (xlator_t *this, int min_op_version, char *msg, int msglen) + snprintf (msg, msglen, "One or more nodes do not support " + "the required op-version. Cluster op-version must " + "atleast be %d.", min_op_version); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNSUPPORTED_VERSION, "%s", msg); + ret = -1; + } + return ret; +@@ -8864,7 +9076,9 @@ glusterd_is_status_tasks_op (glusterd_op_t op, dict_t *dict) + + ret = dict_get_uint32 (dict, "cmd", &cmd); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get opcode"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get opcode"); + goto out; + } + +@@ -8979,7 +9193,9 @@ glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict, + + ret = dict_get_int32 (op_ctx, "type", &op_code); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get quota opcode"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get quota opcode"); + goto out; + } + +@@ -8993,13 +9209,17 @@ glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict, + + ret = dict_get_str (op_ctx, "path", &path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get path"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get path"); + goto out; + } + + ret = dict_get_int32 (op_ctx, "count", &count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get count"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get count"); + goto out; + } + +@@ -9026,7 +9246,9 @@ glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict, + + ret = dict_get_str (op_ctx, key, &uuid1_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get key '%s'", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get key '%s'", + key); + goto out; + } +@@ -9038,7 +9260,9 @@ glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict, + + ret = dict_get_str (op_ctx, key, &uuid2_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get key " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Failed to get key " + "'%s'", key); + goto out; + } +@@ -9063,12 +9287,16 @@ glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict, + + ret = dict_set_dynstr (req_dict, "gfid", uuid1_str_dup); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set gfid"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set gfid"); + GF_FREE (uuid1_str_dup); + goto out; + } + } else { +- gf_log (this->name, GF_LOG_ERROR, "Failed to iterate through %d" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_ITER_FAIL, ++ "Failed to iterate through %d" + " entries in the req dict", count); + ret = -1; + goto out; +@@ -9123,7 +9351,7 @@ glusterd_remove_auxiliary_mount (char *volname) + GLUSTERFS_GET_AUX_MOUNT_PIDFILE (pidfile, volname); + + if (!gf_is_service_running (pidfile, NULL)) { +- gf_log (this->name, GF_LOG_DEBUG, "Aux mount of volume %s " ++ gf_msg_debug (this->name, 0, "Aux mount of volume %s " + "absent, hence returning", volname); + return 0; + } +@@ -9131,7 +9359,8 @@ glusterd_remove_auxiliary_mount (char *volname) + GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volname, "/"); + ret = gf_umount_lazy (this->name, mountdir, 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "umount on %s failed, " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_LAZY_UMOUNT_FAIL, "umount on %s failed, " + "reason : %s", mountdir, strerror (errno)); + + /* Hide EBADF as it means the mount is already gone */ +@@ -9215,7 +9444,8 @@ glusterd_launch_synctask (synctask_fn_t fn, void *opaque) + ret = synctask_new (this->ctx->env, fn, gd_default_synctask_cbk, NULL, + opaque); + if (ret) +- gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn bricks" ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_SPAWN_SVCS_FAIL, "Failed to spawn bricks" + " and other volume related services"); + } + +@@ -9326,7 +9556,9 @@ glusterd_update_mntopts (char *brick_path, glusterd_brickinfo_t *brickinfo) + + ret = glusterd_get_brick_root (brick_path, &mnt_pt); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "getting the root " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICKPATH_ROOT_GET_FAIL, ++ "getting the root " + "of the brick (%s) failed ", brick_path); + goto out; + } +@@ -9334,7 +9566,9 @@ glusterd_update_mntopts (char *brick_path, glusterd_brickinfo_t *brickinfo) + entry = glusterd_get_mnt_entry_info (mnt_pt, buff, sizeof (buff), + &save_entry); + if (!entry) { +- gf_log (this->name, GF_LOG_ERROR, "getting the mount entry for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MNTENTRY_GET_FAIL, ++ "getting the mount entry for " + "the brick (%s) failed", brick_path); + ret = -1; + goto out; +@@ -9366,14 +9600,18 @@ glusterd_get_value_for_vme_entry (struct volopt_map_entry *vme, char **def_val) + CDS_INIT_LIST_HEAD (&vol_opt_handle.list); + + if (_get_xlator_opt_key_from_vme (vme, &key)) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get %s key from " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_KEY_FAILED, ++ "Failed to get %s key from " + "volume option entry", vme->key); + goto out; + } + + ret = xlator_volopt_dynload (vme->voltype, &dl_handle, &vol_opt_handle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "xlator_volopt_dynload error " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_XLATOR_VOLOPT_DYNLOAD_ERROR, ++ "xlator_volopt_dynload error " + "(%d)", ret); + ret = -2; + goto cont; +@@ -9383,7 +9621,9 @@ glusterd_get_value_for_vme_entry (struct volopt_map_entry *vme, char **def_val) + &local_def_val, &descr); + if (ret) { + /*Swallow Error if option not found*/ +- gf_log (this->name, GF_LOG_ERROR, "Failed to get option for %s " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_KEY_FAILED, ++ "Failed to get option for %s " + "key", key); + ret = -2; + goto cont; +@@ -9408,7 +9648,7 @@ cont: + goto out; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -9433,7 +9673,9 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts, + + /* Check whether key is passed for a single option */ + if (!all_opts && !input_key) { +- gf_log (this->name, GF_LOG_ERROR, "Key is NULL"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_KEY_NULL, ++ "Key is NULL"); + goto out; + } + +@@ -9460,14 +9702,18 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts, + sprintf (dict_key, "key%d", count); + ret = dict_set_str(ctx, dict_key, vme->key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to " + "set %s in dictionary", vme->key); + goto out; + } + sprintf (dict_key, "value%d", count); + ret = dict_set_dynstr_with_alloc (ctx, dict_key, def_val); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to " + "set %s for key %s in dictionary", def_val, + vme->key); + goto out; +@@ -9482,7 +9728,9 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts, + + ret = dict_set_int32 (ctx, "count", count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set count " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set count " + "in dictionary"); + } + +@@ -9492,7 +9740,7 @@ out: + "option %s does not exist", orig_key); + *op_errstr = gf_strdup (err_str); + } +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -9532,7 +9780,7 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out) + def_val = vme->value; + } else { + if (_get_xlator_opt_key_from_vme (vme, &key)) { +- gf_log ("glusterd", GF_LOG_DEBUG, "Failed to " ++ gf_msg_debug ("glusterd", 0, "Failed to " + "get %s key from volume option entry", + vme->key); + goto out; /*Some error while geting key*/ +@@ -9543,7 +9791,7 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out) + &vol_opt_handle); + + if (ret) { +- gf_log ("glusterd", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "xlator_volopt_dynload error(%d)", ret); + ret = 0; + goto cont; +@@ -9552,7 +9800,7 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out) + ret = xlator_option_info_list (&vol_opt_handle, key, + &def_val, &descr); + if (ret) { /*Swallow Error i.e if option not found*/ +- gf_log ("glusterd", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Failed to get option for %s key", key); + ret = 0; + goto cont; +@@ -9567,7 +9815,9 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out) + goto cont; + } + #else +- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_INSTALLED, ++ "Libxml not present"); + #endif + } else { + snprintf (tmp_str, sizeof (tmp_str), "Option: %s\nDefault " +@@ -9595,7 +9845,9 @@ cont: + goto out; + #else + if (xml_out) +- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_INSTALLED, ++ "Libxml not present"); + #endif + + if (!xml_out) +@@ -9604,7 +9856,9 @@ cont: + #if (HAVE_LIB_XML) + output = gf_strdup ((char *)buf->content); + #else +- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_NOT_INSTALLED, ++ "Libxml not present"); + #endif + + if (NULL == output) { +@@ -9614,7 +9868,7 @@ cont: + + ret = dict_set_dynstr (ctx, "help-str", output); + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -9644,7 +9898,9 @@ glusterd_check_client_op_version_support (char *volname, uint32_t op_version, + pthread_mutex_unlock (&priv->xprt_lock); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "One or more clients " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNSUPPORTED_VERSION, ++ "One or more clients " + "don't support the required op-version"); + if (op_errstr) + ret = gf_asprintf (op_errstr, "One or more connected " +-- +1.7.1 + diff --git a/SOURCES/0092-quota-glusterd-porting-to-new-logging-framework.patch b/SOURCES/0092-quota-glusterd-porting-to-new-logging-framework.patch new file mode 100644 index 0000000..a3e3a21 --- /dev/null +++ b/SOURCES/0092-quota-glusterd-porting-to-new-logging-framework.patch @@ -0,0 +1,478 @@ +From 28802dc69d4b2110ae6a74d67356669d4e104157 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 30 Apr 2015 16:57:00 +0530 +Subject: [PATCH 092/101] quota/glusterd: porting to new logging framework + +Change-Id: I879a181b6d6b97119a6b4fab90a12b8386635383 +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50910 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-quota.c | 159 +++++++++++++++++----------- + 1 files changed, 97 insertions(+), 62 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c +index 7238032..f4fc831 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quota.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quota.c +@@ -22,6 +22,7 @@ + #include "glusterd-nfs-svc.h" + #include "glusterd-quotad-svc.h" + #include "glusterd-volgen.h" ++#include "glusterd-messages.h" + #include "run.h" + #include "syscall.h" + #include "byte-order.h" +@@ -142,7 +143,8 @@ __glusterd_handle_quota (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " + "command"); +@@ -155,7 +157,8 @@ __glusterd_handle_quota (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof (msg), "Unable to get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name, " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name, " + "while handling quota command"); + goto out; + } +@@ -163,7 +166,8 @@ __glusterd_handle_quota (rpcsvc_request_t *req) + ret = dict_get_int32 (dict, "type", &type); + if (ret) { + snprintf (msg, sizeof (msg), "Unable to get type of command"); +- gf_log (this->name, GF_LOG_ERROR, "Unable to get type of cmd, " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get type of cmd, " + "while handling quota command"); + goto out; + } +@@ -204,7 +208,9 @@ glusterd_check_if_quota_trans_enabled (glusterd_volinfo_t *volinfo) + + flag = glusterd_volinfo_get_boolean (volinfo, VKEY_FEATURES_QUOTA); + if (flag == -1) { +- gf_log ("", GF_LOG_ERROR, "failed to get the quota status"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_GET_STAT_FAIL, ++ "failed to get the quota status"); + ret = -1; + goto out; + } +@@ -230,7 +236,7 @@ glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, char *volname, + runner_t runner = {0}; + + if (mkdtemp (mountdir) == NULL) { +- gf_log ("glusterd", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "failed to create a temporary mount directory"); + ret = -1; + goto out; +@@ -257,7 +263,8 @@ glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, char *volname, + runner_end (&runner); + + if ((pid = fork ()) < 0) { +- gf_log ("glusterd", GF_LOG_WARNING, "fork from parent failed"); ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_FORK_FAIL, "fork from parent failed"); + ret = -1; + goto out; + } else if (pid == 0) {//first child +@@ -270,8 +277,9 @@ glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, char *volname, + + ret = chdir (mountdir); + if (ret == -1) { +- gf_log ("glusterd", GF_LOG_WARNING, "chdir %s failed, " +- "reason: %s", mountdir, strerror (errno)); ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_DIR_OP_FAILED, "chdir %s failed", ++ mountdir); + exit (EXIT_FAILURE); + } + runinit (&runner); +@@ -348,7 +356,8 @@ glusterd_quota_get_default_soft_limit (glusterd_volinfo_t *volinfo, + + ret = dict_set_dynstr (rsp_dict, "default-soft-limit", val); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set default " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set default " + "soft-limit into dict"); + goto out; + } +@@ -445,14 +454,16 @@ glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr, + ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_QUOTA, + "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + + ret = dict_set_dynstr_with_alloc (volinfo->dict, + VKEY_FEATURES_INODE_QUOTA, "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + +@@ -512,23 +523,25 @@ glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr, + ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_QUOTA, + "off"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + + ret = dict_set_dynstr_with_alloc (volinfo->dict, + VKEY_FEATURES_INODE_QUOTA, "off"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + + for (i = 0; quota_options [i]; i++) { + ret = glusterd_volinfo_get (volinfo, quota_options[i], &value); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, "failed to get option" +- " %s", +- quota_options[i]); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "failed to get option" ++ " %s", quota_options[i]); + } else { + dict_del (volinfo->dict, quota_options[i]); + } +@@ -755,16 +768,17 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd) + + while ((bytes_read = read (src_fd, (void *)&buf, entry_sz)) > 0) { + if (bytes_read % 16 != 0) { +- gf_log (this->name, GF_LOG_ERROR, "quota.conf " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CONF_CORRUPT, "quota.conf " + "corrupted"); + ret = -1; + goto out; + } + ret = write (dst_fd, (void *) buf, bytes_read); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "write into quota.conf failed. Reason : %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "write into quota.conf failed."); + goto out; + } + } +@@ -958,7 +972,8 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path, + break; + } + if ((bytes_read % quota_conf_line_sz) != 0) { +- gf_log (this->name, GF_LOG_ERROR, "quota.conf " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CONF_CORRUPT, "quota.conf " + "corrupted"); + ret = -1; + goto out; +@@ -968,9 +983,9 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path, + + ret = write (fd, (void *) buf, bytes_to_write); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "write into quota.conf failed. Reason : %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "write into quota.conf failed."); + goto out; + } + +@@ -993,10 +1008,9 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path, + ret = glusterd_quota_conf_write_gfid (fd, gfid, + GF_QUOTA_CONF_TYPE_USAGE); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "write into quota.conf failed. " +- "Reason : %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "write into quota.conf failed. "); + goto out; + } + modified = _gf_true; +@@ -1007,10 +1021,9 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path, + ret = glusterd_quota_conf_write_gfid (fd, gfid, + GF_QUOTA_CONF_TYPE_OBJECTS); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "write into quota.conf failed. " +- "Reason : %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "write into quota.conf failed. "); + goto out; + } + modified = _gf_true; +@@ -1060,7 +1073,8 @@ out: + if (modified) { + ret = glusterd_compute_cksum (volinfo, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_COMPUTE_FAIL, "Failed to " + "compute cksum for quota conf file"); + return ret; + } +@@ -1068,7 +1082,9 @@ out: + ret = glusterd_store_save_quota_version_and_cksum + (volinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERS_CKSUM_STORE_FAIL, ++ "Failed to " + "store quota version and cksum"); + } + } +@@ -1103,7 +1119,8 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "path", &path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch path"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch path"); + goto out; + } + ret = gf_canonicalize_path (path); +@@ -1112,14 +1129,16 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "hard-limit", &hard_limit); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch hard limit"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch hard limit"); + goto out; + } + + if (dict_get (dict, "soft-limit")) { + ret = dict_get_str (dict, "soft-limit", &soft_limit); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch " + "soft limit"); + goto out; + } +@@ -1143,7 +1162,8 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "gfid", &gfid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get gfid of path " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get gfid of path " + "%s", path); + goto out; + } +@@ -1234,7 +1254,8 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "path", &path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch path"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch path"); + goto out; + } + +@@ -1251,7 +1272,8 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "gfid", &gfid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get gfid of path " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get gfid of path " + "%s", path); + goto out; + } +@@ -1289,14 +1311,16 @@ glusterd_set_quota_option (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "value", &value); + if(ret) { +- gf_log (this->name, GF_LOG_ERROR, "Option value absent."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Option value absent."); + return -1; + } + + option = gf_strdup (value); + ret = dict_set_dynstr (volinfo->dict, key, option); + if(ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to set option %s", + key); + return -1; + } +@@ -1358,7 +1382,8 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1469,7 +1494,8 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to re-create " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Unable to re-create " + "volfiles"); + ret = -1; + goto out; +@@ -1520,14 +1546,16 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = dict_get_str (dict, "path", &path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get path"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get path"); + goto out; + } + + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -1543,18 +1571,18 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = gf_lstat_dir (backend_path, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, "Failed to find " +- "directory %s. Reason : %s", backend_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DIR_OP_FAILED, "Failed to find " ++ "directory %s.", backend_path); + ret = 0; + continue; + } + ret = sys_lgetxattr (backend_path, GFID_XATTR_KEY, gfid, 16); + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, "Failed to get " +- "extended attribute %s for directory %s. " +- "Reason : %s", GFID_XATTR_KEY, backend_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_SETXATTR_FAIL, "Failed to get " ++ "extended attribute %s for directory %s. ", ++ GFID_XATTR_KEY, backend_path); + ret = 0; + continue; + } +@@ -1568,7 +1596,8 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = dict_set_dynstr (rsp_dict, key, gfid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to place " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to place " + "gfid of %s in dict", backend_path); + GF_FREE (gfid_str); + goto out; +@@ -1578,7 +1607,8 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo, + + ret = dict_set_int32 (rsp_dict, "count", count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set count"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set count"); + goto out; + } + +@@ -1620,12 +1650,14 @@ _glusterd_validate_quota_opts (dict_t *dict, int type, char **errstr) + opt = xlator_volume_option_get_list (&opt_list, key); + if (!opt) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Unknown option: %s", key); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_UNKNOWN_KEY, "Unknown option: %s", key); + goto out; + } + ret = dict_get_str (dict, "value", &value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Value not found for key %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Value not found for key %s", + key); + goto out; + } +@@ -1664,7 +1696,8 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1742,7 +1775,8 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE: + ret = dict_get_str (dict, "hard-limit", &hard_limit_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Faild to get hard-limit from dict"); + goto out; + } +@@ -1753,9 +1787,10 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + "value out of range (0 - %"PRId64 + "): %s", hard_limit_str); + else +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CONVERSION_FAILED, + "Failed to convert hard-limit " +- "from string to bytes"); ++ "string to value"); + goto out; + } + get_gfid = _gf_true; +@@ -1794,7 +1829,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + out: + if (ret && op_errstr && *op_errstr) + gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +-- +1.7.1 + diff --git a/SOURCES/0093-snapshot-Fix-terminating-slash-in-brick-mount-path.patch b/SOURCES/0093-snapshot-Fix-terminating-slash-in-brick-mount-path.patch new file mode 100644 index 0000000..ac88751 --- /dev/null +++ b/SOURCES/0093-snapshot-Fix-terminating-slash-in-brick-mount-path.patch @@ -0,0 +1,67 @@ +From e0accb86fde62ecc411a497bbdf2cfdf34d4ad65 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Tue, 16 Jun 2015 23:53:32 +0530 +Subject: [PATCH 093/101] snapshot: Fix terminating slash in brick mount path + +glusterd_find_brick_mount_path(), returns mount path, +with a terminating '/' at the ned of the string in +cases where the brick dir is a dir in the lvm root dir. + +Ignoring the terminating '/' fixes the issue. + +>Reviewed-on: http://review.gluster.org/11262/ +Change-Id: Ie7e63d37d48e2e03d541ae0076b8f143b8c9112f +BUG: 1232428 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51013 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + tests/bugs/snapshot/bug-1232430.t | 22 ++++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-store.c | 1 - + 2 files changed, 22 insertions(+), 1 deletions(-) + create mode 100755 tests/bugs/snapshot/bug-1232430.t + +diff --git a/tests/bugs/snapshot/bug-1232430.t b/tests/bugs/snapshot/bug-1232430.t +new file mode 100755 +index 0000000..50411b1 +--- /dev/null ++++ b/tests/bugs/snapshot/bug-1232430.t +@@ -0,0 +1,22 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../snapshot.rc ++ ++cleanup; ++TEST verify_lvm_version; ++TEST glusterd -LDEBUG; ++TEST pidof glusterd; ++ ++TEST setup_lvm 1 ++ ++TEST $CLI volume create $V0 $H0:$L1/brick_dir ++TEST $CLI volume start $V0 ++ ++TEST $CLI snapshot create snap1 $V0 no-timestamp ++ ++TEST $CLI snapshot delete snap1 ++ ++TEST $CLI volume stop $V0 force ++TEST $CLI volume delete $V0 ++cleanup +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index d790c6f..9e110e5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -3093,7 +3093,6 @@ glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path) + ptr++; + + if (*ptr == '/') { +- ptr++; + *ptr = '\0'; + } + +-- +1.7.1 + diff --git a/SOURCES/0094-rpm-glusterfs-devel-for-client-builds-should-not-dep.patch b/SOURCES/0094-rpm-glusterfs-devel-for-client-builds-should-not-dep.patch new file mode 100644 index 0000000..55c7b46 --- /dev/null +++ b/SOURCES/0094-rpm-glusterfs-devel-for-client-builds-should-not-dep.patch @@ -0,0 +1,66 @@ +From 8e5a99addc206ebf6e328e0c1089ddafe4e18dff Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Thu, 18 Jun 2015 12:16:16 +0200 +Subject: [PATCH 094/101] rpm: glusterfs-devel for client-builds should not depend on -server + +glusterfs-devel for client-side packages should *not* include the +libgfdb.so symlink and libgfdb.pc file or any of the libchangelog +ones. + +Label: DOWNSTREAM ONLY + +Change-Id: Ifb4a9cf48841e5af5dd0a98b6de51e2ee469fc56 +BUG: 1227029 +Signed-off-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/51019 +Reviewed-by: Balamurugan Arumugam +Tested-by: Balamurugan Arumugam +--- + glusterfs.spec.in | 17 ++++++++++++++++- + 1 files changed, 16 insertions(+), 1 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 29a1ac4..388c28c 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1113,14 +1113,26 @@ fi + %exclude %{_includedir}/glusterfs/y.tab.h + %exclude %{_includedir}/glusterfs/api + %exclude %{_libdir}/libgfapi.so ++%if ( ! 0%{?_build_server} ) ++%exclude %{_libdir}/libgfchangelog.so ++%endif ++%if ( 0%{!?_without_tiering:1} && ! 0%{?_build_server}) ++%exclude %{_libdir}/libgfdb.so ++%endif + %{_libdir}/*.so + # Glupy Translator examples + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/debug-trace.* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/helloworld.* + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/negative.* ++%if ( 0%{?_build_server} ) + %{_libdir}/pkgconfig/libgfchangelog.pc +-%if ( 0%{!?_without_tiering:1} ) ++%else ++%exclude %{_libdir}/pkgconfig/libgfchangelog.pc ++%endif ++%if ( 0%{!?_without_tiering:1} && 0%{?_build_server}) + %{_libdir}/pkgconfig/libgfdb.pc ++%else ++%exclude %{_libdir}/pkgconfig/libgfdb.pc + %endif + + %files client-xlators +@@ -1793,6 +1805,9 @@ end + %endif + + %changelog ++* Thu Jun 18 2015 Niels de Vos ++- glusterfs-devel for client-builds should not depend on -server (#1227029) ++ + * Fri Jun 12 2015 Aravinda VK + - Added rsync as dependency to georeplication rpm (#1231213) + +-- +1.7.1 + diff --git a/SOURCES/0095-snapshot-man-page-modifications.patch b/SOURCES/0095-snapshot-man-page-modifications.patch new file mode 100644 index 0000000..8510763 --- /dev/null +++ b/SOURCES/0095-snapshot-man-page-modifications.patch @@ -0,0 +1,59 @@ +From 0833dfe3ff2da4fd78194d1442d34f88513875b4 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Mon, 15 Jun 2015 15:59:21 +0530 +Subject: [PATCH 095/101] snapshot: man page modifications + +Modified man page to correct snap-max-hard-limit and +snap-max-soft-limit entries. + +>Reviewed-on: http://review.gluster.org/11229/ +Change-Id: Ide3405fc94ea5cf6e19504e6dc158938c1bf135b +BUG: 1130998 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51016 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + doc/gluster.8 | 15 +++++++++------ + 1 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/doc/gluster.8 b/doc/gluster.8 +index 6402cdd..715c52b 100644 +--- a/doc/gluster.8 ++++ b/doc/gluster.8 +@@ -137,7 +137,7 @@ If snapname is specified then mentioned snapshot is deleted. If volname is speci + Lists all snapshots taken. If volname is provided, then only the snapshots belonging to that particular volume is listed. + .TP + \fB\ snapshot info [snapname | (volume )] \fR +-This command gives information such as snapshot name, snapshot UUID, time at which snapshot was created, and it lists down the snap-volume-name, number of snapshots already taken and number of snapshots still available for that particular volume, and the state of the snapshot. If snapname is specified then info of the mentioned snapshot is displayed. If volname is specified then info of all snap-shots belonging to that volume is displayed. If both snapname and volname is not specified then info of all the snapshots present in the system are displayed. ++This command gives information such as snapshot name, snapshot UUID, time at which snapshot was created, and it lists down the snap-volume-name, number of snapshots already taken and number of snapshots still available for that particular volume, and the state of the snapshot. If snapname is specified then info of the mentioned snapshot is displayed. If volname is specified then info of all snapshots belonging to that volume is displayed. If both snapname and volname is not specified then info of all the snapshots present in the system are displayed. + .TP + \fB\ snapshot status [snapname | (volume )] \fR + This command gives status of the snapshot. The details included are snapshot brick path, volume group(LVM details), status of the snapshot bricks, PID of the bricks, data percentage filled for that particular volume group to which the snapshots belong to, and total size of the logical volume. +@@ -151,15 +151,18 @@ snapshot config without any keywords displays the snapshot config values of all + + Snapshot config command along with keywords can be used to change the existing config values. If volname is provided then config value of that volume is changed, else it will set/change the system limit. + +-snap-max-hard-limit, snap-max-soft-limit and auto-delete are global options, that will be inherited by all volumes in the system and cannot be set to individual volumes. ++snap-max-soft-limit and auto-delete are global options, that will be inherited by all volumes in the system and cannot be set to individual volumes. + +-The system limit takes precedence over the volume specific limit. ++snap-max-hard-limit can be set globally, as well as per volume. The lowest limit between the global system limit and the volume specific limit, becomes the ++"Effective snap-max-hard-limit" for a volume. + +-When auto-delete feature is enabled, then upon reaching the soft-limit, with every successful snapshot creation, the oldest snapshot will be deleted. ++snap-max-soft-limit is a percentage value, which is applied on the "Effective snap-max-hard-limit" to get the "Effective snap-max-soft-limit". + +-When auto-delete feature is disabled, then upon reaching the soft-limit, the user gets a warning with every successful snapshot creation. ++When auto-delete feature is enabled, then upon reaching the "Effective snap-max-soft-limit", with every successful snapshot creation, the oldest snapshot will be deleted. + +-When auto-delete feature is disabled, then upon reaching the hard-limit, further snapshot creations will not be allowed. ++When auto-delete feature is disabled, then upon reaching the "Effective snap-max-soft-limit", the user gets a warning with every successful snapshot creation. ++ ++When auto-delete feature is disabled, then upon reaching the "Effective snap-max-hard-limit", further snapshot creations will not be allowed. + + activate-on-create is disabled by default. If you enable activate-on-create, then further snapshot will be activated during the time of snapshot creation. + .TP +-- +1.7.1 + diff --git a/SOURCES/0096-ops-glusterd-Porting-messages-to-new-logging-framewo.patch b/SOURCES/0096-ops-glusterd-Porting-messages-to-new-logging-framewo.patch new file mode 100644 index 0000000..839ffbc --- /dev/null +++ b/SOURCES/0096-ops-glusterd-Porting-messages-to-new-logging-framewo.patch @@ -0,0 +1,3380 @@ +From a4cb69da281510a940cc1caa29fb66fba4011ec4 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Tue, 17 Mar 2015 13:16:06 +0530 +Subject: [PATCH 096/101] ops/glusterd: Porting messages to new logging framework + +>Change-Id: Iafeb07aabc1781d98f51c6c2627bf3bbdf493153 +>BUG: 1194640 +>Reviewed-on: http://review.gluster.org/9905 +>Tested-by: Gluster Build System +>Tested-by: NetBSD Build System +>Reviewed-by: Atin Mukherjee + +Change-Id: Iafeb07aabc1781d98f51c6c2627bf3bbdf493153 +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/50888 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 349 ++++++++++++------- + xlators/mgmt/glusterd/src/glusterd-log-ops.c | 42 ++- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 256 +++++++++----- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 423 +++++++++++++++-------- + 4 files changed, 704 insertions(+), 366 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index b4bef6e..a3fda98 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -22,6 +22,7 @@ + #include "glusterd-utils.h" + #include "glusterd-volgen.h" + #include "glusterd-svc-helper.h" ++#include "glusterd-messages.h" + #include "run.h" + #include + +@@ -106,7 +107,7 @@ insert_brick: + i++; + if (i < idx) + continue; +- gf_log (THIS->name, GF_LOG_DEBUG, "brick:%s index=%d, count=%d", ++ gf_msg_debug (THIS->name, 0, "brick:%s index=%d, count=%d", + brick->path, idx, count); + + cds_list_add (&brickinfo->brick_list, &brick->brick_list); +@@ -139,7 +140,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + "bricks (%d) supplied for stripe count (%d).", + (total_bricks - volinfo->brick_count), + stripe_count); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + break; +@@ -160,7 +162,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + (total_bricks - volinfo->brick_count), + stripe_count, + (volinfo->replica_count * stripe_count)); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + break; +@@ -171,7 +174,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + "Incorrect stripe count (%d) supplied. " + "Volume already has stripe count (%d)", + stripe_count, volinfo->stripe_count); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + if (stripe_count == volinfo->stripe_count) { +@@ -203,7 +207,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + snprintf (err_str, err_len, "Volume %s cannot be converted " + "from dispersed to striped-" + "dispersed", volinfo->volname); +- gf_log(THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg(THIS->name, GF_LOG_ERROR, EPERM, ++ GD_MSG_OP_NOT_PERMITTED, "%s", err_str); + goto out; + } + +@@ -235,7 +240,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + "bricks (%d) supplied for replica count (%d).", + (total_bricks - volinfo->brick_count), + replica_count); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + break; +@@ -243,7 +249,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + if (!(total_bricks % (volinfo->dist_leaf_count * replica_count))) { + /* Change the volume type */ + *type = GF_CLUSTER_TYPE_STRIPE_REPLICATE; +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_TYPE_CHANGING_INFO, + "Changing the type of volume %s from " + "'stripe' to 'replicate-stripe'", + volinfo->volname); +@@ -257,7 +264,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + (total_bricks - volinfo->brick_count), + replica_count, (volinfo->dist_leaf_count * + replica_count)); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + break; +@@ -268,7 +276,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + "Incorrect replica count (%d) supplied. " + "Volume already has (%d)", + replica_count, volinfo->replica_count); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + if (replica_count == volinfo->replica_count) { +@@ -299,7 +308,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + snprintf (err_str, err_len, "Volume %s cannot be converted " + "from dispersed to replicated-" + "dispersed", volinfo->volname); +- gf_log(THIS->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg(THIS->name, GF_LOG_ERROR, EPERM, ++ GD_MSG_OP_NOT_PERMITTED, "%s", err_str); + goto out; + } + out: +@@ -326,7 +336,8 @@ gd_rmbr_validate_replica_count (glusterd_volinfo_t *volinfo, + snprintf (err_str, err_len, + "replica count (%d) option given for non replicate " + "volume %s", replica_count, volinfo->volname); +- gf_log (THIS->name, GF_LOG_WARNING, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_NOT_REPLICA, "%s", err_str); + goto out; + + case GF_CLUSTER_TYPE_REPLICATE: +@@ -338,7 +349,8 @@ gd_rmbr_validate_replica_count (glusterd_volinfo_t *volinfo, + "than volume %s's replica count (%d)", + replica_count, volinfo->volname, + volinfo->replica_count); +- gf_log (THIS->name, GF_LOG_WARNING, "%s", err_str); ++ gf_msg (THIS->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + goto out; + } + if (replica_count == volinfo->replica_count) { +@@ -352,7 +364,8 @@ gd_rmbr_validate_replica_count (glusterd_volinfo_t *volinfo, + "(or %dxN)", brick_count, + volinfo->dist_leaf_count, + volinfo->dist_leaf_count); +- gf_log (THIS->name, GF_LOG_WARNING, "%s", ++ gf_msg (THIS->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", + err_str); + goto out; + } +@@ -423,7 +436,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -437,7 +451,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -445,7 +460,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + ret = -1; + snprintf (err_str, sizeof (err_str), "Volume %s does not exist", + volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, "%s", err_str); + goto out; + } + +@@ -453,24 +469,28 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "brick count"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (!ret) { +- gf_log (this->name, GF_LOG_INFO, "replica-count is %d", ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, "replica-count is %d", + replica_count); + } + + ret = dict_get_int32 (dict, "stripe-count", &stripe_count); + if (!ret) { +- gf_log (this->name, GF_LOG_INFO, "stripe-count is %d", ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, "stripe-count is %d", + stripe_count); + } + + if (!dict_get (dict, "force")) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get flag"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Failed to get flag"); + goto out; + } + +@@ -478,7 +498,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volinfo " + "for volume name %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "%s", err_str); + goto out; + + } +@@ -531,7 +552,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + snprintf (err_str, sizeof (err_str), "Incorrect number " + "of bricks supplied %d with count %d", + brick_count, volinfo->dist_leaf_count); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_REPLICA, "%s", err_str); + ret = -1; + goto out; + } +@@ -547,7 +569,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + err_str, + sizeof (err_str)); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COUNT_VALIDATE_FAILED, "%s", err_str); + goto out; + } + +@@ -557,7 +580,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + + ret = dict_set_int32 (dict, "stripe-count", stripe_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to set the stripe-count in dict"); + goto out; + } +@@ -569,7 +593,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + &type, err_str, + sizeof (err_str)); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COUNT_VALIDATE_FAILED, "%s", err_str); + goto out; + } + +@@ -579,7 +604,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + + ret = dict_set_int32 (dict, "replica-count", replica_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set the replica-count in dict"); + goto out; + } +@@ -589,14 +615,16 @@ brick_val: + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "bricks"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + + if (type != volinfo->type) { + ret = dict_set_int32 (dict, "type", type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set the new type in dict"); + goto out; + } +@@ -655,7 +683,7 @@ subvol_matcher_update (int *subvols, glusterd_volinfo_t *volinfo, + pos++; + continue; + } +- gf_log (THIS->name, GF_LOG_DEBUG, LOGSTR_FOUND_BRICK, ++ gf_msg_debug (THIS->name, 0, LOGSTR_FOUND_BRICK, + brickinfo->hostname, brickinfo->path, + volinfo->volname); + sub_volume = (pos / volinfo->dist_leaf_count); +@@ -786,7 +814,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -799,7 +828,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -807,7 +837,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get brick " + "count"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -815,7 +846,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str),"Volume %s does not exist", + volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, "%s", err_str); + goto out; + } + +@@ -845,7 +877,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (!ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "request to change replica-count to %d", replica_count); + ret = gd_rmbr_validate_replica_count (volinfo, replica_count, + count, err_str, +@@ -862,7 +895,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + ret = dict_set_int32 (dict, "replica-count", + replica_count); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set the replica_count " + "in dict"); + goto out; +@@ -888,7 +922,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + (volinfo->brick_count == volinfo->stripe_count)) { + snprintf (err_str, sizeof (err_str), + "Removing brick from a stripe volume is not allowed"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EPERM, ++ GD_MSG_OP_NOT_PERMITTED, "%s", err_str); + ret = -1; + goto out; + } +@@ -900,7 +935,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + "Removing bricks from stripe-replicate" + " configuration is not allowed without reducing " + "replica or stripe count explicitly."); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EPERM, ++ GD_MSG_OP_NOT_PERMITTED_AC_REQD, "%s", err_str); + ret = -1; + goto out; + } +@@ -912,7 +948,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + "Removing bricks from replicate configuration " + "is not allowed without reducing replica count " + "explicitly."); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EPERM, ++ GD_MSG_OP_NOT_PERMITTED_AC_REQD, "%s", err_str); + ret = -1; + goto out; + } +@@ -926,7 +963,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + snprintf (err_str, sizeof (err_str), "Remove brick " + "incorrect brick count of %d for %s %d", + count, vol_type, volinfo->dist_leaf_count); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", err_str); + ret = -1; + goto out; + } +@@ -958,10 +996,11 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get %s", + key); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Remove brick count %d brick:" ++ gf_msg_debug (this->name, 0, "Remove brick count %d brick:" + " %s", i, brick); + + ret = glusterd_volume_brickinfo_get_by_brick(brick, volinfo, +@@ -970,7 +1009,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Incorrect brick " + "%s for volume %s", brick, volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_BRICK_NOT_FOUND, "%s", err_str); + goto out; + } + strcat(brick_list, brick); +@@ -1004,7 +1044,8 @@ out: + if (err_str[0] == '\0') + snprintf (err_str, sizeof (err_str), + "Operation failed"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_OP_FAILED, "%s", err_str); + rsp.op_errstr = err_str; + cli_rsp = &rsp; + glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, +@@ -1055,7 +1096,8 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + slave++; + slave_buf = gf_strdup (slave); + if (!slave_buf) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Failed to gf_strdup"); + ret = -1; + goto out; +@@ -1066,7 +1108,8 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + + ret = dict_set_dynstr (param->rsp_dict, "slave", slave_buf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Unable to store slave"); + if (slave_buf) + GF_FREE(slave_buf); +@@ -1079,9 +1122,12 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + &conf_path, errmsg); + if (ret) { + if (*errmsg) +- gf_log ("", GF_LOG_ERROR, "%s", *errmsg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_SLAVE_CONFPATH_DETAILS_FETCH_FAIL, ++ "%s", *errmsg); + else +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_SLAVE_CONFPATH_DETAILS_FETCH_FAIL, + "Unable to fetch slave or confpath details."); + goto out; + } +@@ -1092,11 +1138,12 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + slave, conf_path, + &is_running); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "gsync running validation failed."); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_GSYNC_VALIDATION_FAIL, "gsync running validation failed."); + goto out; + } + if (_gf_false == is_running) { +- gf_log ("", GF_LOG_DEBUG, "gsync session for %s and %s is" ++ gf_msg_debug ("glusterd", 0, "gsync session for %s and %s is" + " not running on this node. Hence not restarting.", + param->volinfo->volname, slave); + ret = 0; +@@ -1105,7 +1152,7 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + + ret = glusterd_get_local_brickpaths (param->volinfo, &path_list); + if (!path_list) { +- gf_log ("", GF_LOG_DEBUG, "This node not being part of" ++ gf_msg_debug ("glusterd", 0, "This node not being part of" + " volume should not be running gsyncd. Hence" + " no gsyncd process to restart."); + ret = 0; +@@ -1116,11 +1163,12 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, + param->rsp_dict, path_list, + conf_path, 0); + if (ret) +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_GSYNC_RESTART_FAIL, + "Unable to restart gsync session."); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d.", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d.", ret); + return ret; + } + +@@ -1169,16 +1217,19 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + if (dict) { + ret = dict_get_int32 (dict, "stripe-count", &stripe_count); + if (!ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "stripe-count is set %d", stripe_count); + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (!ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "replica-count is set %d", replica_count); + ret = dict_get_int32 (dict, "type", &type); + if (!ret) +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "type is set %d, need to change it", type); + } + +@@ -1202,8 +1253,9 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + snprintf (key, sizeof(key), "brick%d.mount_dir", i); + ret = dict_get_str (dict, key, &brick_mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s not present", key); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, ++ "%s not present", key); + goto out; + } + strncpy (brickinfo->mount_dir, brick_mount_dir, +@@ -1278,7 +1330,8 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + if (brickinfo->vg[0]) { + ret = glusterd_is_valid_vg (brickinfo, 0, msg); + if (ret) { +- gf_log (THIS->name, GF_LOG_CRITICAL, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_INVALID_VG, "%s", msg); + goto out; + } + /* if anyone of the brick does not have thin support, +@@ -1291,7 +1344,8 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + if (gf_uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -1309,7 +1363,7 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count, + if ((!gf_uuid_compare (brickinfo->uuid, MY_UUID)) && + !restart_needed) { + restart_needed = 1; +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Restart gsyncd session, if it's already " + "running."); + } +@@ -1328,7 +1382,7 @@ out: + GF_FREE (free_ptr1); + GF_FREE (free_ptr2); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1368,7 +1422,8 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick, + ret = glusterd_brick_stop (volinfo, brickinfo, + _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Unable to stop " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_STOP_FAIL, "Unable to stop " + "glusterfs, ret: %d", ret); + } + goto out; +@@ -1377,7 +1432,7 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick, + brickinfo->decommissioned = 1; + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1413,7 +1468,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "Unable to get replica count"); + } + +@@ -1421,21 +1476,24 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = op_version_check (this, GD_OP_VER_PERSISTENT_AFR_XATTRS, + msg, sizeof(msg)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERSION_MISMATCH, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + } + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, + "Unable to find volume: %s", volname); + goto out; + } +@@ -1447,20 +1505,23 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (glusterd_is_defrag_on(volinfo)) { + snprintf (msg, sizeof(msg), "Volume name %s rebalance is in " + "progress. Please retry after completion", volname); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_OIP_RETRY_LATER, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } + ret = dict_get_int32 (dict, "count", &count); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get count"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get count"); + goto out; + } + + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Unable to get bricks"); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get bricks"); + goto out; + } + +@@ -1481,7 +1542,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + !glusterd_is_valid_volfpath (volname, brick)) { + snprintf (msg, sizeof (msg), "brick path %s is " + "too long", brick); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRKPATH_TOO_LONG, "%s", msg); + *op_errstr = gf_strdup (msg); + + ret = -1; +@@ -1491,7 +1553,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_NOT_FOUND, + "Add-brick: Unable" + " to get brickinfo"); + goto out; +@@ -1511,7 +1574,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (brickinfo->vg[0]) { + ret = glusterd_is_valid_vg (brickinfo, 1, msg); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "%s", ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_VG, "%s", + msg); + *op_errstr = gf_strdup (msg); + goto out; +@@ -1533,7 +1597,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + (brickinfo->path, brickinfo->hostname, + brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNTDIR_GET_FAIL, + "Failed to get brick mount_dir"); + goto out; + } +@@ -1543,7 +1608,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = dict_set_dynstr_with_alloc + (rsp_dict, key, brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set %s", key); + goto out; + } +@@ -1562,7 +1628,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = dict_set_int32 (rsp_dict, "brick_count", + local_brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set local_brick_count"); + goto out; + } +@@ -1574,7 +1641,7 @@ out: + GF_FREE (str_ret); + GF_FREE (all_bricks); + +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1604,21 +1671,24 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + ret = op_version_check (this, GD_OP_VER_PERSISTENT_AFR_XATTRS, + msg, sizeof(msg)); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_VERSION_MISMATCH, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Volume %s does not exist", volname); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "Volume %s does not exist", volname); + goto out; + } + +@@ -1628,7 +1698,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "command", &flag); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get brick command"); + goto out; + } +@@ -1636,7 +1707,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "count", &brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get brick count"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get brick count"); + goto out; + } + +@@ -1675,7 +1747,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + "needed when reducing replica count. Use the" + " 'force' option"); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_USE_THE_FORCE, "%s", errstr); + goto out; + } + +@@ -1685,7 +1758,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + "'force' or 'commit' to override this " + "behavior)", volinfo->volname); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", errstr); + goto out; + } + if (!gd_is_remove_brick_committed (volinfo)) { +@@ -1694,7 +1768,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + " or stop it before starting a new task.", + volinfo->volname); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "Earlier remove-brick" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OLD_REMOVE_BRICK_EXISTS, "Earlier remove-brick" + " task exists for volume %s.", + volinfo->volname); + goto out; +@@ -1702,7 +1777,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + if (glusterd_is_defrag_on(volinfo)) { + errstr = gf_strdup("Rebalance is in progress. Please " + "retry after completion"); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OIP_RETRY_LATER, "%s", errstr); + goto out; + } + +@@ -1729,7 +1805,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + ret = glusterd_generate_and_set_task_id + (dict, GF_REMOVE_BRICK_TID_KEY); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TASKID_GEN_FAIL, + "Failed to generate task-id"); + goto out; + } +@@ -1737,7 +1814,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY, + &task_id_str); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "Missing remove-brick-id"); + ret = 0; + } +@@ -1816,7 +1894,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + ret = 0; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + if (ret && errstr) { + if (op_errstr) + *op_errstr = errstr; +@@ -1959,27 +2037,31 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, "Unable to allocate memory"); + goto out; + } + + ret = dict_get_int32 (dict, "count", &count); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get count"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get count"); + goto out; + } + + + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get bricks"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get bricks"); + goto out; + } + +@@ -1990,7 +2072,8 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr) + + ret = glusterd_op_perform_add_bricks (volinfo, count, bricks, dict); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to add bricks"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_ADD_FAIL, "Unable to add bricks"); + goto out; + } + +@@ -2047,19 +2130,22 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_ADD_FAIL, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, "Unable to allocate memory"); + goto out; + } + + ret = dict_get_int32 (dict, "command", &flag); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get command"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get command"); + goto out; + } + cmd = flag; +@@ -2078,7 +2164,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + (volinfo->rebal.rebalance_id, dict, + GF_REMOVE_BRICK_TID_KEY); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REMOVE_BRICK_ID_SET_FAIL, + "Failed to set remove-brick-id"); + goto out; + } +@@ -2115,7 +2202,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + } + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "failed to create volfiles"); + goto out; + } +@@ -2123,7 +2211,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLINFO_SET_FAIL, + "failed to store volinfo"); + goto out; + } +@@ -2141,7 +2230,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_NOT_STARTED; + ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY, &task_id_str); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, errno, + "Missing remove-brick-id"); + ret = 0; + } else { +@@ -2184,7 +2273,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "count", &count); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get count"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get count"); + goto out; + } + +@@ -2200,7 +2290,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + } + ret = dict_set_int32 (bricks_dict, "count", count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to save remove-brick count"); + goto out; + } +@@ -2213,7 +2304,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + snprintf (key, 256, "brick%d", i); + ret = dict_get_str (dict, key, &brick); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get %s", + key); + goto out; + } +@@ -2222,13 +2314,15 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + brick_tmpstr = gf_strdup (brick); + if (!brick_tmpstr) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Failed to duplicate brick name"); + goto out; + } + ret = dict_set_dynstr (bricks_dict, key, brick_tmpstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to add brick to dict"); + goto out; + } +@@ -2246,7 +2340,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (!ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "changing replica count %d to %d on volume %s", + volinfo->replica_count, replica_count, + volinfo->volname); +@@ -2277,13 +2372,15 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to create volfiles"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "failed to create volfiles"); + goto out; + } + + ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to store volinfo"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLINFO_STORE_FAIL, "failed to store volinfo"); + goto out; + } + +@@ -2291,7 +2388,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + volinfo->status == GLUSTERD_STATUS_STARTED) { + ret = glusterd_svcs_reconfigure (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_NFS_RECONF_FAIL, + "Unable to reconfigure NFS-Server"); + goto out; + } +@@ -2322,7 +2420,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + volinfo->decommission_in_progress = 1; + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REBALANCE_START_FAIL, + "failed to start the rebalance"); + } + } else { +@@ -2355,7 +2454,8 @@ glusterd_op_stage_barrier (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Volname not present in " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Volname not present in " + "dict"); + goto out; + } +@@ -2363,7 +2463,8 @@ glusterd_op_stage_barrier (dict_t *dict, char **op_errstr) + ret = glusterd_volinfo_find (volname, &vol); + if (ret) { + gf_asprintf (op_errstr, "Volume %s does not exist", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", *op_errstr); + goto out; + } + +@@ -2377,12 +2478,13 @@ glusterd_op_stage_barrier (dict_t *dict, char **op_errstr) + if (ret == -1) { + gf_asprintf (op_errstr, "Barrier op for volume %s not present " + "in dict", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", *op_errstr); + goto out; + } + ret = 0; + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2401,7 +2503,8 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Volname not present in " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Volname not present in " + "dict"); + goto out; + } +@@ -2409,7 +2512,8 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr) + ret = glusterd_volinfo_find (volname, &vol); + if (ret) { + gf_asprintf (op_errstr, "Volume %s does not exist", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", *op_errstr); + goto out; + } + +@@ -2417,14 +2521,16 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr) + if (ret) { + gf_asprintf (op_errstr, "Barrier op for volume %s not present " + "in dict", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", *op_errstr); + goto out; + } + + ret = dict_set_dynstr_with_alloc (vol->dict, "features.barrier", + barrier_op); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set barrier op in" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set barrier op in" + " volume option dict"); + goto out; + } +@@ -2432,13 +2538,14 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr) + gd_update_volume_op_versions (vol); + ret = glusterd_create_volfiles (vol); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create volfiles"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volfiles"); + goto out; + } + ret = glusterd_store_volinfo (vol, GLUSTERD_VOLINFO_VER_AC_INCREMENT); + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c +index 449b28c..7611637 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c +@@ -20,6 +20,7 @@ + #include "glusterd-store.h" + #include "glusterd-utils.h" + #include "glusterd-volgen.h" ++#include "glusterd-messages.h" + + #include + +@@ -53,7 +54,8 @@ __glusterd_handle_log_rotate (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " +@@ -65,7 +67,8 @@ __glusterd_handle_log_rotate (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + +@@ -110,7 +113,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -119,7 +123,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr) + if (!exists) { + snprintf (msg, sizeof (msg), "Volume %s does not exist", + volname); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; +@@ -128,7 +133,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr) + if (_gf_false == glusterd_is_volume_started (volinfo)) { + snprintf (msg, sizeof (msg), "Volume %s needs to be started before" + " log rotate.", volname); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; +@@ -146,12 +152,13 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr) + if (ret) { + snprintf (msg, sizeof (msg), "Incorrect brick %s " + "for volume %s", brick, volname); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -182,13 +189,15 @@ glusterd_op_log_rotate (dict_t *dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "volname not found"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "volname not found"); + goto out; + } + + ret = dict_get_uint64 (dict, "rotate-key", &key); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "rotate key not found"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "rotate key not found"); + goto out; + } + +@@ -200,7 +209,8 @@ glusterd_op_log_rotate (dict_t *dict) + + ret = glusterd_brickinfo_new_from_brick (brick, &tmpbrkinfo); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_NOT_FOUND, + "cannot get brickinfo from brick"); + goto out; + } +@@ -225,7 +235,8 @@ cont: + GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); + file = fopen (pidfile, "r+"); + if (!file) { +- gf_log ("", GF_LOG_ERROR, "Unable to open pidfile: %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to open pidfile: %s", + pidfile); + ret = -1; + goto out; +@@ -233,7 +244,8 @@ cont: + + ret = fscanf (file, "%d", &pid); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to read pidfile: %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to read pidfile: %s", + pidfile); + ret = -1; + goto out; +@@ -246,11 +258,13 @@ cont: + + ret = rename (brickinfo->logfile, logfile); + if (ret) +- gf_log ("", GF_LOG_WARNING, "rename failed"); ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "rename failed"); + + ret = kill (pid, SIGHUP); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to SIGHUP to %d", pid); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_PID_KILL_FAIL, "Unable to SIGHUP to %d", pid); + goto out; + } + ret = 0; +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 2f9bac8..2ce65dc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -81,7 +81,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, + if (ctx) { + ret = dict_get_int32 (ctx, "status", &status); + if (ret) { +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get status"); + } + } +@@ -104,7 +104,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, + if (ctx && dict_get_int32 (ctx, "count", &count)) { + ret = dict_set_int32 (ctx, "count", 0); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "failed to set count in dictionary"); + } + } +@@ -113,14 +114,15 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, + case GD_OP_START_BRICK: + case GD_OP_STOP_BRICK: + { +- gf_log (this->name, GF_LOG_DEBUG, "op '%s' not supported", ++ gf_msg_debug (this->name, 0, "op '%s' not supported", + gd_op_list[op]); + break; + } + case GD_OP_NONE: + case GD_OP_MAX: + { +- gf_log (this->name, GF_LOG_ERROR, "invalid operation"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_OP_UNSUPPORTED, "invalid operation"); + break; + } + case GD_OP_CREATE_VOLUME: +@@ -179,7 +181,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, + ret = dict_allocate_and_serialize (ctx, &rsp.dict.dict_val, + &rsp.dict.dict_len); + if (ret < 0 ) +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, "failed to " + "serialize buffer"); + else + free_ptr = rsp.dict.dict_val; +@@ -197,7 +200,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, + ret = 0; + + GF_FREE (free_ptr); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -238,7 +241,8 @@ __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_probe_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "error"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "error"); + //rsp.op_ret = -1; + //rsp.op_errno = EINVAL; + goto out; +@@ -301,19 +305,22 @@ __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, + if (ctx->req == NULL) + goto cont; + +- gf_log (this->name, GF_LOG_DEBUG, "Adding address '%s' to " ++ gf_msg_debug (this->name, 0, "Adding address '%s' to " + "existing peer %s", rsp.hostname, uuid_utoa (rsp.uuid)); + + ret = glusterd_friend_remove (NULL, rsp.hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Could not remove " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STALE_PEERINFO_REMOVE_FAIL, ++ "Could not remove " + "stale peerinfo with name %s", rsp.hostname); + goto reply; + } + + ret = gd_add_address_to_peer (peerinfo, rsp.hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_ADD_TO_PEERLIST_FAIL, + "Couldn't add hostname to peer list"); + goto reply; + } +@@ -386,7 +393,8 @@ cont: + (GD_FRIEND_EVENT_INIT_FRIEND_REQ, &event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_NEW_FRIEND_SM_EVENT_GET_FAIL, + "Unable to get event"); + goto unlock; + } +@@ -450,7 +458,8 @@ __glusterd_friend_add_cbk (struct rpc_req * req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "error"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_RES_DECODE_FAIL, "error"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; +@@ -468,7 +477,9 @@ __glusterd_friend_add_cbk (struct rpc_req * req, struct iovec *iov, + peerinfo = glusterd_peerinfo_find (rsp.uuid, rsp.hostname); + if (peerinfo == NULL) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "received friend add response from" ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, ++ "received friend add response from" + " unknown peer uuid: %s", uuid_utoa (rsp.uuid)); + goto unlock; + } +@@ -481,7 +492,8 @@ __glusterd_friend_add_cbk (struct rpc_req * req, struct iovec *iov, + ret = glusterd_friend_sm_new_event (event_type, &event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, + "Unable to get event"); + goto unlock; + } +@@ -563,7 +575,8 @@ __glusterd_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "error"); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_RES_DECODE_FAIL, "error"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto respond; +@@ -592,7 +605,8 @@ inject: + ret = glusterd_friend_sm_new_event (event_type, &event); + + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_EVENT_NEW_GET_FAIL, + "Unable to get event"); + goto unlock; + } +@@ -651,14 +665,16 @@ __glusterd_friend_update_cbk (struct rpc_req *req, struct iovec *iov, + this = THIS; + + if (-1 == req->rpc_status) { +- gf_log (this->name, GF_LOG_ERROR, "RPC Error"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_FAILURE, "RPC Error"); + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, + (xdrproc_t)xdr_gd1_mgmt_friend_update_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize friend" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "Failed to serialize friend" + " update repsonse"); + goto out; + } +@@ -703,7 +719,8 @@ __glusterd_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, + txn_id = &priv->global_txn_id; + + if (-1 == req->rpc_status) { +- gf_log (this->name, GF_LOG_ERROR, "Lock response is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_LOCK_RESP_FROM_PEER, "Lock response is not " + "received from one of the peer"); + err_str = "Lock response is not received from one of the peer"; + glusterd_set_opinfo (err_str, ENETRESET, -1); +@@ -714,7 +731,8 @@ __glusterd_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, + ret = xdr_to_generic (*iov, &rsp, + (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "Failed to decode " + "cluster lock response received from peer"); + err_str = "Failed to decode cluster lock response received from" + " peer"; +@@ -725,16 +743,24 @@ __glusterd_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, + + op_ret = rsp.op_ret; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received lock %s from uuid: %s", (op_ret) ? "RJT" : "ACC", +- uuid_utoa (rsp.uuid)); ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_LOCK_FROM_UUID_REJCT, ++ "Received lock RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received lock ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + + rcu_read_lock (); + ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == NULL); + rcu_read_unlock (); + + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, + "cluster lock response received from unknown peer: %s." + "Ignoring response", uuid_utoa (rsp.uuid)); + err_str = "cluster lock response received from unknown peer"; +@@ -802,7 +828,8 @@ glusterd_mgmt_v3_lock_peers_cbk_fn (struct rpc_req *req, struct iovec *iov, + frame->cookie = NULL; + + if (-1 == req->rpc_status) { +- gf_log (this->name, GF_LOG_ERROR, "Lock response is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NO_LOCK_RESP_FROM_PEER, "Lock response is not " + "received from one of the peer"); + err_str = "Lock response is not received from one of the peer"; + glusterd_set_opinfo (err_str, ENETRESET, -1); +@@ -813,7 +840,8 @@ glusterd_mgmt_v3_lock_peers_cbk_fn (struct rpc_req *req, struct iovec *iov, + ret = xdr_to_generic (*iov, &rsp, + (xdrproc_t)xdr_gd1_mgmt_v3_lock_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "Failed to decode " + "mgmt_v3 lock response received from peer"); + err_str = "Failed to decode mgmt_v3 lock response received from" + " peer"; +@@ -826,16 +854,24 @@ glusterd_mgmt_v3_lock_peers_cbk_fn (struct rpc_req *req, struct iovec *iov, + + txn_id = &rsp.txn_id; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received mgmt_v3 lock %s from uuid: %s", +- (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_FROM_UUID_REJCT, ++ "Received mgmt_v3 lock RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received mgmt_v3 lock ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + + rcu_read_lock (); + ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == NULL); + rcu_read_unlock (); + + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, + "mgmt_v3 lock response received " + "from unknown peer: %s. Ignoring response", + uuid_utoa (rsp.uuid)); +@@ -921,10 +957,16 @@ glusterd_mgmt_v3_unlock_peers_cbk_fn (struct rpc_req *req, struct iovec *iov, + + txn_id = &rsp.txn_id; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received mgmt_v3 unlock %s from uuid: %s", +- (op_ret) ? "RJT" : "ACC", +- uuid_utoa (rsp.uuid)); ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FROM_UUID_REJCT, ++ "Received mgmt_v3 unlock RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received mgmt_v3 unlock ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + + rcu_read_lock (); + ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == NULL); +@@ -1017,9 +1059,16 @@ __glusterd_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, + + op_ret = rsp.op_ret; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received unlock %s from uuid: %s", +- (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNLOCK_FROM_UUID_REJCT, ++ "Received unlock RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received unlock ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + + rcu_read_lock (); + ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == NULL); +@@ -1095,7 +1144,8 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode stage " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "Failed to decode stage " + "response received from peer"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; +@@ -1114,7 +1164,8 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + rsp.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize rsp-buffer to dictionary"); + event_type = GD_OP_EVENT_RCVD_RJT; +@@ -1127,18 +1178,26 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + out: + op_ret = rsp.op_ret; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received stage %s from uuid: %s", +- (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STAGE_FROM_UUID_REJCT, ++ "Received stage RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received stage ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + + ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +- gf_log (this->name, GF_LOG_CRITICAL, "Stage response received " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, "Stage response received " + "from unknown peer: %s. Ignoring response.", + uuid_utoa (rsp.uuid)); + } +@@ -1234,7 +1293,8 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode commit " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, "Failed to decode commit " + "response received from peer"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; +@@ -1254,7 +1314,8 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + rsp.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize rsp-buffer to dictionary"); + event_type = GD_OP_EVENT_RCVD_RJT; +@@ -1266,18 +1327,25 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + + op_ret = rsp.op_ret; + +- gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG, +- "Received commit %s from uuid: %s", +- (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); +- ++ if (op_ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_FROM_UUID_REJCT, ++ "Received commit RJT from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Received commit ACC from uuid: %s", ++ uuid_utoa (rsp.uuid)); ++ } + ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +- gf_log (this->name, GF_LOG_CRITICAL, "Commit response for " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_RESP_FROM_UNKNOWN_PEER, "Commit response for " + "'Volume %s' received from unknown peer: %s", + gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); + } +@@ -1420,7 +1488,7 @@ glusterd_rpc_probe (call_frame_t *frame, xlator_t *this, + + out: + GF_FREE (req.hostname); +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1466,7 +1534,8 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + + ret = glusterd_add_volumes_to_export_dict (&peer_data); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to add list of volumes " + "in the peer_data dict for handshake"); + goto out; +@@ -1484,7 +1553,8 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + if (priv->op_version >= GD_OP_VERSION_RHS_3_0) { + ret = glusterd_add_missed_snaps_to_export_dict (peer_data); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL, + "Unable to add list of missed snapshots " + "in the peer_data dict for handshake"); + goto out; +@@ -1492,7 +1562,8 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + + ret = glusterd_add_snapshots_to_export_dict (peer_data); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAP_LIST_SET_FAIL, + "Unable to add list of snapshots " + "in the peer_data dict for handshake"); + goto out; +@@ -1517,7 +1588,7 @@ out: + if (peer_data) + dict_unref (peer_data); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1566,7 +1637,7 @@ glusterd_rpc_friend_remove (call_frame_t *frame, xlator_t *this, + out: + GF_FREE (req.hostname); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1612,7 +1683,7 @@ glusterd_rpc_friend_update (call_frame_t *frame, xlator_t *this, + out: + GF_FREE (req.friends.friends_val); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1646,7 +1717,7 @@ glusterd_cluster_lock (call_frame_t *frame, xlator_t *this, + this, glusterd_cluster_lock_cbk, + (xdrproc_t)xdr_gd1_mgmt_cluster_lock_req); + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1681,7 +1752,8 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this, + ret = dict_allocate_and_serialize (dict, &req.dict.dict_val, + &req.dict.dict_len); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, "Failed to serialize dict " + "to request buffer"); + goto out; + } +@@ -1690,11 +1762,12 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this, + ret = dict_get_bin (dict, "transaction_id", + (void **)&txn_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, + "Failed to get transaction id."); + goto out; + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Transaction_id = %s", uuid_utoa (*txn_id)); + gf_uuid_copy (req.txn_id, *txn_id); + } +@@ -1719,7 +1792,7 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this, + this, glusterd_mgmt_v3_lock_peers_cbk, + (xdrproc_t)xdr_gd1_mgmt_v3_lock_req); + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1754,7 +1827,9 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this, + ret = dict_allocate_and_serialize (dict, &req.dict.dict_val, + &req.dict.dict_len); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize dict " + "to request buffer"); + goto out; + } +@@ -1763,11 +1838,12 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this, + ret = dict_get_bin (dict, "transaction_id", + (void **)&txn_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, + "Failed to get transaction id."); + goto out; + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Transaction_id = %s", uuid_utoa (*txn_id)); + gf_uuid_copy (req.txn_id, *txn_id); + } +@@ -1793,7 +1869,7 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this, + (xdrproc_t) + xdr_gd1_mgmt_v3_unlock_req); + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1827,7 +1903,7 @@ glusterd_cluster_unlock (call_frame_t *frame, xlator_t *this, + this, glusterd_cluster_unlock_cbk, + (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req); + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1865,7 +1941,9 @@ glusterd_stage_op (call_frame_t *frame, xlator_t *this, + ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, + &req.buf.buf_len); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize dict " + "to request buffer"); + goto out; + } +@@ -1885,7 +1963,7 @@ out: + if ((_gf_true == is_alloc) && req.buf.buf_val) + GF_FREE (req.buf.buf_val); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1922,7 +2000,9 @@ glusterd_commit_op (call_frame_t *frame, xlator_t *this, + ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, + &req.buf.buf_len); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize dict to " + "request buffer"); + goto out; + } +@@ -1941,7 +2021,7 @@ out: + if ((_gf_true == is_alloc) && req.buf.buf_val) + GF_FREE (req.buf.buf_val); + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1985,7 +2065,9 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to decode brick op " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RES_DECODE_FAIL, ++ "Failed to decode brick op " + "response received"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; +@@ -2002,7 +2084,9 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, + rsp.output.output_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, ++ "Failed to " + "unserialize rsp-buffer to dictionary"); + event_type = GD_OP_EVENT_RCVD_RJT; + goto out; +@@ -2019,7 +2103,8 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, + index = node->index; + ret = dict_set_int32 (dict, "index", index); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Error setting index on brick status rsp dict"); + rsp.op_ret = -1; + event_type = GD_OP_EVENT_RCVD_RJT; +@@ -2031,7 +2116,7 @@ out: + if (req_ctx && req_ctx->dict) { + ret = dict_get_bin (req_ctx->dict, "transaction_id", + (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "transaction ID = %s", uuid_utoa (*txn_id)); + } + +@@ -2099,14 +2184,15 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this, + CDS_INIT_LIST_HEAD (&opinfo.pending_bricks); + + ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id); +- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", ++ gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + + ret = glusterd_op_bricks_select (req_ctx->op, req_ctx->dict, &op_errstr, + &opinfo.pending_bricks, NULL); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to select bricks " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_SELECT_FAIL, "Failed to select bricks " + "while performing brick op during 'Volume %s'", + gd_op_list[opinfo.op]); + opinfo.op_errstr = op_errstr; +@@ -2134,7 +2220,9 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this, + req_ctx->dict); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, ++ "Failed to " + "build brick op payload during " + "'Volume %s'", gd_op_list[req_ctx->op]); + goto out; +@@ -2166,7 +2254,8 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this, + } + + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Brick Op failed " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RPC_FAILURE, "Brick Op failed " + "due to rpc failure."); + goto out; + } +@@ -2187,7 +2276,7 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this, + glusterd_pending_node_put_rpc (pending_node); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Sent brick op req for operation " ++ gf_msg_trace (this->name, 0, "Sent brick op req for operation " + "'Volume %s' to %d bricks", gd_op_list[req_ctx->op], + pending_bricks); + opinfo.brick_pending_count = pending_bricks; +@@ -2198,7 +2287,8 @@ out: + txn_id, data); + opinfo.op_ret = ret; + } +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ ++ gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", ret); + return ret; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index ea8bf13..ac66efe 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -117,7 +117,9 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get volume name"); + goto out; + } + +@@ -125,20 +127,24 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + if (ret) { + snprintf (err_str, 512, "Unable to get type of volume %s", + volname); +- gf_log (this->name, GF_LOG_WARNING, "%s", err_str); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "%s", err_str); + goto out; + } + + ret = dict_get_str (dict, "bricks", &brick_list); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Bricks check : Could not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Bricks check : Could not " + "retrieve bricks list"); + goto out; + } + + ret = dict_get_int32 (dict, "count", &brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Bricks check : Could not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Bricks check : Could not " + "retrieve brick count"); + goto out; + } +@@ -146,16 +152,18 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + if (type != GF_CLUSTER_TYPE_DISPERSE) { + ret = dict_get_int32 (dict, "replica-count", &sub_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Bricks check : Could" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Bricks check : Could" + " not retrieve replica count"); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Replicate cluster type " ++ gf_msg_debug (this->name, 0, "Replicate cluster type " + "found. Checking brick order."); + } else { + ret = dict_get_int32 (dict, "disperse-count", &sub_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Bricks check : Could" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Bricks check : Could" + " not retrieve disperse count"); + goto out; + } +@@ -177,14 +185,17 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + ret = getaddrinfo (brick, NULL, NULL, &ai_info); + if (ret != 0) { + ret = 0; +- gf_log (this->name, GF_LOG_ERROR, "unable to resolve " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_HOSTNAME_RESOLVE_FAIL, ++ "unable to resolve " + "host name"); + goto out; + } + ai_list_tmp1 = malloc (sizeof (addrinfo_list_t)); + if (ai_list_tmp1 == NULL) { + ret = 0; +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "failed to allocate " + "memory"); + goto out; + } +@@ -222,18 +233,20 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + } + ++j; + } +- gf_log (this->name, GF_LOG_DEBUG, "Brick order okay"); ++ gf_msg_debug (this->name, 0, "Brick order okay"); + ret = 0; + goto out; + + check_failed: +- gf_log (this->name, GF_LOG_ERROR, "Failed bad brick order check"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BAD_BRKORDER_CHECK_FAIL, "Failed bad brick order check"); + snprintf (err_str, sizeof (failed_string), failed_string); + ret = -1; + goto out; + + found_bad_brick_order: +- gf_log (this->name, GF_LOG_INFO, "Bad brick order found"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_BAD_BRKORDER, "Bad brick order found"); + snprintf (err_str, sizeof (found_string), found_string); + ret = -1; + out: +@@ -281,11 +294,12 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + req->rpc_err = GARBAGE_ARGS; + snprintf (err_str, sizeof (err_str), "Failed to decode request " + "received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Received create volume req"); ++ gf_msg_debug (this->name, 0, "Received create volume req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -295,7 +309,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -311,14 +326,16 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + + if ((ret = glusterd_check_volume_exists (volname))) { + snprintf (err_str, sizeof (err_str), "Volume %s already exists", + volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, EEXIST, ++ GD_MSG_VOL_ALREADY_EXIST, "%s", err_str); + goto out; + } + +@@ -326,7 +343,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get brick count" + " for volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -334,7 +352,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get type of " + "volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -342,19 +361,22 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get " + "transport-type of volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get bricks for " + "volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + + if (!dict_get (dict, "force")) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get 'force' flag"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get 'force' flag"); + goto out; + } + +@@ -364,7 +386,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to set volume " + "id of volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "%s", err_str); + goto out; + } + free_ptr = NULL; +@@ -375,7 +398,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + username = gf_strdup (uuid_utoa (tmp_uuid)); + ret = dict_set_dynstr (dict, "internal-username", username); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set username for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set username for " + "volume %s", volname); + goto out; + } +@@ -384,7 +408,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req) + password = gf_strdup (uuid_utoa (tmp_uuid)); + ret = dict_set_dynstr (dict, "internal-password", password); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set password for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set password for " + "volume %s", volname); + goto out; + } +@@ -437,7 +462,8 @@ __glusterd_handle_cli_start_volume (rpcsvc_request_t *req) + snprintf (errstr, sizeof (errstr), "Failed to decode message " + "received from cli"); + req->rpc_err = GARBAGE_ARGS; +- gf_log (this->name, sizeof (errstr), "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", errstr); + goto out; + } + +@@ -449,7 +475,8 @@ __glusterd_handle_cli_start_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (errstr, sizeof (errstr), "Unable to decode " +@@ -461,12 +488,13 @@ __glusterd_handle_cli_start_volume (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (errstr, sizeof (errstr), "Unable to get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", errstr); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Received start vol req" +- " for volume %s", volname); ++ gf_msg_debug (this->name, 0, "Received start vol req" ++ " for volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_START_VOLUME, dict); + +@@ -510,7 +538,8 @@ __glusterd_handle_cli_stop_volume (rpcsvc_request_t *req) + snprintf (err_str, sizeof (err_str), "Failed to decode message " + "received from cli"); + req->rpc_err = GARBAGE_ARGS; +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + goto out; + } + if (cli_req.dict.dict_len) { +@@ -521,7 +550,8 @@ __glusterd_handle_cli_stop_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -535,11 +565,12 @@ __glusterd_handle_cli_stop_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Received stop vol req " ++ gf_msg_debug (this->name, 0, "Received stop vol req " + "for volume %s", dup_volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_STOP_VOLUME, dict); +@@ -585,7 +616,8 @@ __glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Failed to decode request " + "received from cli"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REQ_DECODE_FAIL, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } +@@ -598,7 +630,8 @@ __glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " +@@ -611,12 +644,13 @@ __glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Failed to get volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + req->rpc_err = GARBAGE_ARGS; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Received delete vol req" ++ gf_msg_debug (this->name, 0, "Received delete vol req" + "for volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_DELETE_VOLUME, dict); +@@ -727,7 +761,8 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (op_errstr, sizeof (op_errstr), +@@ -742,7 +777,8 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (op_errstr, sizeof (op_errstr), "Unable to find " + "volume name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", op_errstr); + goto out; + } + +@@ -786,7 +822,8 @@ out: + if (op_errstr[0] == '\0') + snprintf (op_errstr, sizeof (op_errstr), + "operation failed"); +- gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_OP_FAILED, "%s", op_errstr); + ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, + dict, op_errstr); + } +@@ -836,7 +873,8 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, + "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to " +@@ -848,14 +886,16 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get the volume " + "name"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + + ret = dict_get_str (dict, "options", &options); + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get options"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -863,7 +903,8 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str , sizeof (err_str), "Unable to get option " + "count"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -1030,7 +1071,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1046,28 +1088,34 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + + ret = dict_get_int32 (dict, "count", &brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get brick count " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get brick count " + "for volume %s", volname); + goto out; + } + + ret = dict_get_str (dict, "volume-id", &volume_uuid_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume id of " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume id of " + "volume %s", volname); + goto out; + } + + ret = gf_uuid_parse (volume_uuid_str, volume_uuid); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to parse volume id of" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_PARSE_FAIL, ++ "Unable to parse volume id of" + " volume %s", volname); + goto out; + } + + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get bricks for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to get bricks for " + "volume %s", volname); + goto out; + } +@@ -1115,7 +1163,9 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + + ret = glusterd_resolve_brick (brick_info); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, ++ FMTSTR_RESOLVE_BRICK, + brick_info->hostname, brick_info->path); + goto out; + } +@@ -1142,7 +1192,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + (brick_info->path, brick_info->hostname, + brick_info->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNTDIR_GET_FAIL, + "Failed to get brick mount_dir"); + goto out; + } +@@ -1152,7 +1203,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + ret = dict_set_dynstr_with_alloc + (rsp_dict, key, brick_info->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set %s", key); + goto out; + } +@@ -1173,7 +1225,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + if (ret) { + snprintf (msg, sizeof (msg), "Unable to get type of " + "volume %s", volname); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + goto out; + } + +@@ -1183,7 +1236,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + (type == GF_CLUSTER_TYPE_DISPERSE)) { + ret = glusterd_check_brick_order(dict, msg); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, "Not " ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BAD_BRKORDER, "Not " + "creating volume because of bad " + "brick order"); + goto out; +@@ -1194,7 +1248,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr, + + ret = dict_set_int32 (rsp_dict, "brick_count", local_brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set local_brick_count"); + goto out; + } +@@ -1207,7 +1262,7 @@ out: + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + } +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1226,13 +1281,15 @@ glusterd_op_stop_volume_args_get (dict_t *dict, char** volname, int *flags) + + ret = dict_get_str (dict, "volname", volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = dict_get_int32 (dict, "flags", flags); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get flags"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get flags"); + goto out; + } + out: +@@ -1250,19 +1307,22 @@ glusterd_op_statedump_volume_args_get (dict_t *dict, char **volname, + + ret = dict_get_str (dict, "volname", volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volname"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volname"); + goto out; + } + + ret = dict_get_str (dict, "options", options); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get options"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get options"); + goto out; + } + + ret = dict_get_int32 (dict, "option_cnt", option_cnt); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get option count"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get option count"); + goto out; + } + +@@ -1311,7 +1371,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -1333,7 +1394,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + brick_count++; + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -1396,7 +1458,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + (brickinfo->path, brickinfo->hostname, + brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_MOUNTDIR_GET_FAIL, + "Failed to get brick mount_dir"); + goto out; + } +@@ -1406,7 +1469,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + ret = dict_set_dynstr_with_alloc + (rsp_dict, key, brickinfo->mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set %s", key); + goto out; + } +@@ -1433,7 +1497,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + + ret = dict_set_int32 (rsp_dict, "brick_count", local_brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set local_brick_count"); + goto out; + } +@@ -1471,7 +1536,8 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + + if (!exists) { + snprintf (msg, sizeof (msg), FMTSTR_CHECK_VOL_EXISTS, volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + ret = -1; + goto out; + } +@@ -1479,7 +1545,8 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + snprintf (msg, sizeof (msg), FMTSTR_CHECK_VOL_EXISTS, volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_GET_FAIL, "%s", msg); + goto out; + } + +@@ -1494,7 +1561,8 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + if (_gf_false == glusterd_is_volume_started (volinfo)) { + snprintf (msg, sizeof(msg), "Volume %s " + "is not in the started state", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", msg); + ret = -1; + goto out; + } +@@ -1519,14 +1587,16 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + if (glusterd_is_defrag_on (volinfo)) { + snprintf (msg, sizeof(msg), "rebalance session is " + "in progress for the volume '%s'", volname); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_OIP, "%s", msg); + ret = -1; + goto out; + } ++ + out: + if (msg[0] != 0) + *op_errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1546,7 +1616,8 @@ glusterd_op_stage_delete_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1595,7 +1666,7 @@ out: + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + } +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -1699,14 +1770,16 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr) + priv = this->private; + if (!priv) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PRIV_NULL, + "priv is NULL"); + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1714,7 +1787,8 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr) + if (ret) { + ret = -1; + snprintf (msg, sizeof (msg), "Volume %s does not exist", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1727,7 +1801,8 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr) + ret = -1; + snprintf (msg, sizeof (msg), "Volume %s is not started.", + volname); +- gf_log (THIS->name, GF_LOG_WARNING, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1745,7 +1820,8 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr) + snprintf (msg, sizeof (msg), "Self-heal-daemon is " + "disabled. Heal will not be triggered on volume %s", + volname); +- gf_log (this->name, GF_LOG_WARNING, "%s", msg); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_SELF_HEALD_DISABLED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1756,7 +1832,7 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr) + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -1820,7 +1896,7 @@ glusterd_op_stage_statedump_volume (dict_t *dict, char **op_errstr) + out: + if (ret && msg[0] != '\0') + *op_errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1838,7 +1914,8 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof(msg), "Failed to get volume name"); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1846,7 +1923,8 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "path", &path); + if (ret) { + snprintf (msg, sizeof(msg), "Failed to get path"); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1854,7 +1932,8 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "kind", &kind); + if (ret) { + snprintf (msg, sizeof(msg), "Failed to get kind"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1862,7 +1941,8 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "type", &type); + if (ret) { + snprintf (msg, sizeof(msg), "Failed to get type"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1871,7 +1951,8 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + if (ret) { + snprintf (msg, sizeof(msg), "Volume %s does not exist", + volname); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1883,14 +1964,15 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr) + if (!glusterd_is_volume_started (volinfo)) { + snprintf (msg, sizeof(msg), "Volume %s is not started", + volname); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_STARTED, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1930,7 +2012,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = glusterd_volinfo_new (&volinfo); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Unable to allocate memory for volinfo"); + goto out; + } +@@ -1938,7 +2021,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "volname", &volname); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -1947,21 +2031,24 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "type", &volinfo->type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get type of volume" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get type of volume" + " %s", volname); + goto out; + } + + ret = dict_get_int32 (dict, "count", &volinfo->brick_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get brick count of" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get brick count of" + " volume %s", volname); + goto out; + } + + ret = dict_get_int32 (dict, "port", &volinfo->port); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get port"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get port"); + goto out; + } + +@@ -1969,7 +2056,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get bricks for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get bricks for " + "volume %s", volname); + goto out; + } +@@ -1983,7 +2071,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = dict_get_int32 (dict, "replica-count", + &volinfo->replica_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "replica count for volume %s", volname); + goto out; + } +@@ -1993,7 +2082,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = dict_get_int32 (dict, "stripe-count", + &volinfo->stripe_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get stripe" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get stripe" + " count for volume %s", volname); + goto out; + } +@@ -2001,14 +2091,16 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = dict_get_int32 (dict, "stripe-count", + &volinfo->stripe_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get stripe" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get stripe" + " count for volume %s", volname); + goto out; + } + ret = dict_get_int32 (dict, "replica-count", + &volinfo->replica_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "replica count for volume %s", volname); + goto out; + } +@@ -2018,19 +2110,23 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + ret = dict_get_int32 (dict, "disperse-count", + &volinfo->disperse_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "disperse count for volume %s", volname); + goto out; + } + ret = dict_get_int32 (dict, "redundancy-count", + &volinfo->redundancy_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get " + "redundancy count for volume %s", volname); + goto out; + } + if (priv->op_version < GD_OP_VERSION_3_7_0) { +- gf_log (this->name, GF_LOG_ERROR, "Disperse volume " ++ if (priv->op_version < GD_OP_VERSION_3_6_0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNSUPPORTED_VERSION, "Disperse volume " + "needs op-version 30700 or higher"); + ret = -1; + goto out; +@@ -2053,27 +2149,31 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "transport", &trans_type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get transport type of volume %s", volname); + goto out; + } + + ret = dict_get_str (dict, "volume-id", &str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get volume-id of volume %s", volname); + goto out; + } + ret = gf_uuid_parse (str, volinfo->volume_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UUID_PARSE_FAIL, + "unable to parse uuid %s of volume %s", str, volname); + goto out; + } + + ret = dict_get_str (dict, "internal-username", &username); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "unable to get internal username of volume %s", + volname); + goto out; +@@ -2082,7 +2182,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "internal-password", &password); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "unable to get internal password of volume %s", + volname); + goto out; +@@ -2119,7 +2220,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + ret = glusterd_resolve_brick (brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESOLVE_BRICK_FAIL, FMTSTR_RESOLVE_BRICK, + brickinfo->hostname, brickinfo->path); + goto out; + } +@@ -2132,7 +2234,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + snprintf (key, sizeof(key), "brick%d.mount_dir", i); + ret = dict_get_str (dict, key, &brick_mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "%s not present", key); + goto out; + } +@@ -2145,7 +2248,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + && brickinfo->vg[0]) { + ret = glusterd_is_valid_vg (brickinfo, 0, msg); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_VG, "%s", msg); + goto out; + } + +@@ -2244,12 +2348,14 @@ glusterd_start_volume (glusterd_volinfo_t *volinfo, int flags, + + ret = glusterd_store_volinfo (volinfo, verincrement); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store volinfo of " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_SET_FAIL, ++ "Failed to store volinfo of " + "%s volume", volinfo->volname); + goto out; + } + out: +- gf_log (this->name, GF_LOG_TRACE, "returning %d ", ret); ++ gf_msg_trace (this->name, 0, "returning %d ", ret); + return ret; + } + +@@ -2279,7 +2385,8 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -2302,7 +2409,8 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, key, + &brick_mount_dir); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "%s not present", key); + goto out; + } +@@ -2328,7 +2436,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + if (ret) { + ret = ganesha_manage_export (dict, "on", op_errstr); + if (ret) { +- gf_log ("", GF_LOG_WARNING, "NFS-Ganesha couldn't" ++ gf_log ("glusterd", GF_LOG_WARNING, "NFS-Ganesha couldn't" + "export the volume. %s", *op_errstr); + ret = 0; + } +@@ -2336,7 +2444,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + ret = glusterd_svcs_manager (volinfo); + + out: +- gf_log (this->name, GF_LOG_TRACE, "returning %d ", ret); ++ gf_msg_trace (this->name, 0, "returning %d ", ret); + return ret; + } + +@@ -2358,7 +2466,8 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo) + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + ret = glusterd_brick_stop (volinfo, brickinfo, _gf_false); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to stop " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_STOP_FAIL, "Failed to stop " + "brick (%s)", brickinfo->path); + goto out; + } +@@ -2368,7 +2477,8 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo) + + ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store volinfo of " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_SET_FAIL, "Failed to store volinfo of " + "%s volume", volinfo->volname); + goto out; + } +@@ -2377,7 +2487,7 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo) + GLUSTERFS_GET_AUX_MOUNT_PIDFILE (pidfile, volinfo->volname); + + if (!gf_is_service_running (pidfile, NULL)) { +- gf_log (this->name, GF_LOG_DEBUG, "Aux mount of volume %s " ++ gf_msg_debug (this->name, 0, "Aux mount of volume %s " + "absent", volinfo->volname); + } else { + GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volinfo->volname, +@@ -2385,9 +2495,10 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo) + + ret = gf_umount_lazy (this->name, mountdir, 0); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, +- "umount on %s failed, reason : %s", +- mountdir, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_UNOUNT_FAILED, ++ "umount on %s failed", ++ mountdir); + } + + if (!volinfo->is_snap_volume) { +@@ -2399,7 +2510,8 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo) + + ret = glusterd_svcs_manager (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to notify graph " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_GRAPH_CHANGE_NOTIFY_FAIL, "Failed to notify graph " + "change for %s volume", volinfo->volname); + + goto out; +@@ -2427,14 +2539,16 @@ glusterd_op_stop_volume (dict_t *dict) + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } + + ret = glusterd_stop_volume (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to stop %s volume", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_STOP_FAILED, "Failed to stop %s volume", + volname); + goto out; + } +@@ -2458,13 +2572,15 @@ glusterd_op_delete_volume (dict_t *dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, + volname); + goto out; + } +@@ -2475,7 +2591,7 @@ glusterd_op_delete_volume (dict_t *dict) + + ret = glusterd_delete_volume (volinfo); + out: +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -2506,7 +2622,7 @@ glusterd_op_statedump_volume (dict_t *dict, char **op_errstr) + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) + goto out; +- gf_log ("", GF_LOG_DEBUG, "Performing statedump on volume %s", volname); ++ gf_msg_debug ("glusterd", 0, "Performing statedump on volume %s", volname); + if (strstr (options, "nfs") != NULL) { + ret = glusterd_nfs_statedump (options, option_cnt, op_errstr); + if (ret) +@@ -2527,7 +2643,8 @@ glusterd_op_statedump_volume (dict_t *dict, char **op_errstr) + * exiting, if statedump of this brick fails. + */ + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, "could not " ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRK_STATEDUMP_FAIL, "could not " + "take the statedump of the brick %s:%s." + " Proceeding to other bricks", + brickinfo->hostname, brickinfo->path); +@@ -2554,7 +2671,7 @@ glusterd_clearlocks_send_cmd (glusterd_volinfo_t *volinfo, char *cmd, + if (ret < 0) { + snprintf (errstr, err_len, "clear-locks getxattr command " + "failed. Reason: %s", strerror (errno)); +- gf_log (THIS->name, GF_LOG_DEBUG, "%s", errstr); ++ gf_msg_debug (THIS->name, 0, "%s", errstr); + goto out; + } + +@@ -2573,7 +2690,7 @@ glusterd_clearlocks_rmdir_mount (glusterd_volinfo_t *volinfo, char *mntpt) + + ret = rmdir (mntpt); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, "rmdir failed"); ++ gf_msg_debug (THIS->name, 0, "rmdir failed"); + goto out; + } + +@@ -2604,7 +2721,7 @@ glusterd_clearlocks_unmount (glusterd_volinfo_t *volinfo, char *mntpt) + synclock_lock (&priv->big_lock); + if (ret) { + ret = 0; +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "umount failed on maintenance client"); + } + +@@ -2625,7 +2742,7 @@ glusterd_clearlocks_create_mount (glusterd_volinfo_t *volinfo, char **mntpt) + volinfo->volname); + tmpl = mkdtemp (template); + if (!tmpl) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Couldn't create temporary " ++ gf_msg_debug (THIS->name, 0, "Couldn't create temporary " + "mount directory. Reason %s", strerror (errno)); + goto out; + } +@@ -2677,11 +2794,11 @@ glusterd_clearlocks_mount (glusterd_volinfo_t *volinfo, char **xl_opts, + ret = runner_run (&runner); + synclock_lock (&priv->big_lock); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "Could not start glusterfs"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "Started glusterfs successfully"); + + out: +@@ -2702,7 +2819,7 @@ glusterd_clearlocks_get_local_client_ports (glusterd_volinfo_t *volinfo, + + GF_ASSERT (xl_opts); + if (!xl_opts) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Should pass non-NULL " ++ gf_msg_debug (THIS->name, 0, "Should pass non-NULL " + "xl_opts"); + goto out; + } +@@ -2726,7 +2843,7 @@ glusterd_clearlocks_get_local_client_ports (glusterd_volinfo_t *volinfo, + GF_PMAP_PORT_BRICKSERVER); + if (!port) { + ret = -1; +- gf_log (THIS->name, GF_LOG_DEBUG, "Couldn't get port " ++ gf_msg_debug (THIS->name, 0, "Couldn't get port " + " for brick %s:%s", brickinfo->hostname, + brickinfo->path); + goto out; +@@ -2766,26 +2883,30 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get volume name"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volume name"); + goto out; + } +- gf_log ("", GF_LOG_DEBUG, "Performing clearlocks on volume %s", volname); ++ gf_msg_debug ("glusterd", 0, "Performing clearlocks on volume %s", volname); + + ret = dict_get_str (dict, "path", &path); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get path"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get path"); + goto out; + } + + ret = dict_get_str (dict, "kind", &kind); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get kind"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get kind"); + goto out; + } + + ret = dict_get_str (dict, "type", &type); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get type"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Failed to get type"); + goto out; + } + +@@ -2810,7 +2931,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (msg, sizeof (msg), "Volume %s doesn't exist.", + volname); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_FOUND, "%s", msg); + goto out; + } + +@@ -2823,7 +2945,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (msg, sizeof (msg), "Couldn't get port numbers of " + "local bricks"); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRK_PORT_NUM_GET_FAIL, "%s", msg); + goto out; + } + +@@ -2831,7 +2954,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (msg, sizeof (msg), "Creating mount directory " + "for clear-locks failed."); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_CLRLOCKS_MOUNTDIR_CREATE_FAIL, "%s", msg); + goto out; + } + +@@ -2839,7 +2963,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (msg, sizeof (msg), "Failed to mount clear-locks " + "maintenance client."); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_CLRLOCKS_CLNT_MOUNT_FAIL, "%s", msg); + goto out; + } + +@@ -2855,14 +2980,16 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + GF_FREE (free_ptr); + snprintf (msg, sizeof (msg), "Failed to set clear-locks " + "result"); +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "%s", msg); + } + + umount: + glusterd_clearlocks_unmount (volinfo, mntpt); + + if (glusterd_clearlocks_rmdir_mount (volinfo, mntpt)) +- gf_log (THIS->name, GF_LOG_WARNING, "Couldn't unmount " ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_CLRLOCKS_CLNT_UMOUNT_FAIL, "Couldn't unmount " + "clear-locks mount point"); + + out: +-- +1.7.1 + diff --git a/SOURCES/0097-glusterd-uss-snapshot-Intialise-snapdsvc-after-volfi.patch b/SOURCES/0097-glusterd-uss-snapshot-Intialise-snapdsvc-after-volfi.patch new file mode 100644 index 0000000..2b6cb38 --- /dev/null +++ b/SOURCES/0097-glusterd-uss-snapshot-Intialise-snapdsvc-after-volfi.patch @@ -0,0 +1,127 @@ +From fc7a70ad87dbb456685a86b2dcca75b06d02930e Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Fri, 12 Jun 2015 17:13:05 +0530 +Subject: [PATCH 097/101] glusterd/uss/snapshot: Intialise snapdsvc after volfiles are created + +snapd svc should be initialised only after all +relevant volfiles and directories are created. + +>Reviewed-on: http://review.gluster.org/11227/ +Change-Id: I96770cfc0b350599cd60ff74f5ecec08145c3105 +BUG: 1230635 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51027 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 18 +++++++++--------- + xlators/mgmt/glusterd/src/glusterd-utils.c | 21 +++++++++++++-------- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 12 +++++++----- + 3 files changed, 29 insertions(+), 22 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index f779bff..654310c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -9454,15 +9454,6 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict, + /* Use the same version as the original version */ + new_volinfo->version = orig_vol->version; + +- /* Initialize the snapd service */ +- ret = glusterd_snapdsvc_init (new_volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd " +- "service for volume %s", orig_vol->volname); +- goto out; +- } +- + /* Copy the snap vol info to the new_volinfo.*/ + ret = glusterd_snap_volinfo_restore (dict, rsp_dict, new_volinfo, + snap_vol, volcount); +@@ -9533,6 +9524,15 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict, + goto out; + } + ++ /* Initialize the snapd service */ ++ ret = glusterd_snapdsvc_init (new_volinfo); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd " ++ "service for volume %s", orig_vol->volname); ++ goto out; ++ } ++ + ret = 0; + out: + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 23a60d2..f374f94 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -3784,14 +3784,6 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + goto out; + } + +- ret = glusterd_snapdsvc_init (new_volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " +- "snapdsvc for volume %s", new_volinfo->volname); +- goto out; +- } +- + ret = glusterd_volinfo_find (new_volinfo->volname, &old_volinfo); + if (0 == ret) { + /* snapdsvc initialization of old_volinfo is also required here +@@ -3819,6 +3811,19 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + } + + ret = glusterd_store_volinfo (new_volinfo, GLUSTERD_VOLINFO_VER_AC_NONE); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to store " ++ "volinfo for volume %s", new_volinfo->volname); ++ goto out; ++ } ++ ++ ret = glusterd_snapdsvc_init (new_volinfo); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to initialize " ++ "snapdsvc for volume %s", new_volinfo->volname); ++ goto out; ++ } ++ + ret = glusterd_create_volfiles_and_notify_services (new_volinfo); + if (ret) + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index ac66efe..7872314 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -2279,16 +2279,18 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + + volinfo->caps = caps; + +- ret = glusterd_snapdsvc_init (volinfo); ++ ret = glusterd_store_volinfo (volinfo, ++ GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- *op_errstr = gf_strdup ("Failed to initialize snapd service"); ++ glusterd_store_delete_volume (volinfo); ++ *op_errstr = gf_strdup ("Failed to store the " ++ "Volume information"); + goto out; + } + +- ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); ++ ret = glusterd_snapdsvc_init (volinfo); + if (ret) { +- glusterd_store_delete_volume (volinfo); +- *op_errstr = gf_strdup ("Failed to store the Volume information"); ++ *op_errstr = gf_strdup ("Failed to initialize snapd service"); + goto out; + } + +-- +1.7.1 + diff --git a/SOURCES/0098-build-add-pretrans-check.patch b/SOURCES/0098-build-add-pretrans-check.patch new file mode 100644 index 0000000..0717657 --- /dev/null +++ b/SOURCES/0098-build-add-pretrans-check.patch @@ -0,0 +1,180 @@ +From a701c96f94fb1c868566f7b3ad54b9e67b9ed211 Mon Sep 17 00:00:00 2001 +From: Bala.FA +Date: Wed, 17 Jun 2015 21:34:52 +0530 +Subject: [PATCH 098/101] build: add pretrans check + +This patch adds pretrans check for client-xlators, ganesha and +python-gluster sub-packages. + +Label: DOWNSTREAM ONLY + +Bug: 1232641 +Change-Id: I454016319832c11902c0ca79a79fbbcf8ac0a121 +Signed-off-by: Bala.FA +Reviewed-on: https://code.engineering.redhat.com/gerrit/50967 +--- + glusterfs.spec.in | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 127 insertions(+), 0 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 388c28c..e4d9d5f 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1512,6 +1512,47 @@ end + + + ++%pretrans client-xlators -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ + %pretrans devel -p + if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd +@@ -1594,6 +1635,47 @@ end + + + ++%pretrans ganesha -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/glusterfs-ganesha_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ + %if ( 0%{!?_without_georeplication:1} ) + %pretrans geo-replication -p + if not posix.access("/bin/bash", "x") then +@@ -1678,6 +1760,47 @@ end + + + ++%pretrans -n python-gluster -p ++if not posix.access("/bin/bash", "x") then ++ -- initial installation, no shell, no running glusterfsd ++ return 0 ++end ++ ++-- TODO: move this completely to a lua script ++-- For now, we write a temporary bash script and execute that. ++ ++script = [[#!/bin/sh ++pidof -c -o %PPID -x glusterfsd &>/dev/null ++ ++if [ $? -eq 0 ]; then ++ pushd . > /dev/null 2>&1 ++ for volume in /var/lib/glusterd/vols/*; do cd $volume; ++ vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` ++ volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` ++ if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then ++ exit 1; ++ fi ++ done ++ ++ popd > /dev/null 2>&1 ++ exit 1; ++fi ++]] ++ ++-- rpm in RHEL5 does not have os.tmpname() ++-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ ++tmpname = "/tmp/python-gluster_pretrans_" .. os.date("%s") ++tmpfile = io.open(tmpname, "w") ++tmpfile:write(script) ++tmpfile:close() ++ok, how, val = os.execute("/bin/bash " .. tmpname) ++os.remove(tmpname) ++if not (ok == 0) then ++ error("Detected running glusterfs processes", ok) ++end ++ ++ ++ + %if ( 0%{!?_without_rdma:1} ) + %pretrans rdma -p + if not posix.access("/bin/bash", "x") then +@@ -1805,6 +1928,10 @@ end + %endif + + %changelog ++* Thu Jun 18 2015 Bala.FA ++- add pretrans check for client-xlators, ganesha and python-gluster ++ sub-packages (#1232641) ++ + * Thu Jun 18 2015 Niels de Vos + - glusterfs-devel for client-builds should not depend on -server (#1227029) + +-- +1.7.1 + diff --git a/SOURCES/0099-glusterd-geo-rep-porting-log-messages-to-a-new-frame.patch b/SOURCES/0099-glusterd-geo-rep-porting-log-messages-to-a-new-frame.patch new file mode 100644 index 0000000..e94b1fe --- /dev/null +++ b/SOURCES/0099-glusterd-geo-rep-porting-log-messages-to-a-new-frame.patch @@ -0,0 +1,3080 @@ +From 6172b2d7b0e659d81921b3d1b47fd4881eaf1937 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Fri, 20 Mar 2015 12:04:32 +0530 +Subject: [PATCH 099/101] glusterd/geo-rep : porting log messages to a new framework + +Change-Id: I1f1b99822c2b301d68eaf392af4bbb475151e2c5 +BUG: 1231771 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: http://review.gluster.org/9952 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Kotresh HR +Reviewed-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/50896 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 1128 ++++++++++++++++--------- + xlators/mgmt/glusterd/src/glusterd-messages.h | 16 +- + 2 files changed, 763 insertions(+), 381 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +index de14664..f7f0086 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c ++++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +@@ -24,6 +24,7 @@ + #include "glusterd-svc-helper.h" + #include "run.h" + #include "syscall.h" ++#include "glusterd-messages.h" + + #include + +@@ -125,7 +126,8 @@ __glusterd_handle_sys_exec (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " + "the command"); +@@ -196,7 +198,8 @@ __glusterd_handle_copy_file (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to" + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " + "the command"); +@@ -270,7 +273,8 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize req-buffer to dictionary"); + snprintf (err_str, sizeof (err_str), "Unable to decode " + "the command"); +@@ -294,15 +298,15 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req) + + ret = dict_get_str (dict, "master", &master); + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, "master not found, while " +- "handling "GEOREP" options"); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED, ++ "master not found, while handling "GEOREP" options"); + master = "(No Master)"; + } + + ret = dict_get_str (dict, "slave", &slave); + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, "slave not found, while " +- "handling "GEOREP" options"); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED, ++ "slave not found, while handling "GEOREP" options"); + slave = "(No Slave)"; + } + +@@ -310,7 +314,8 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req) + if (ret < 0) { + snprintf (err_str, sizeof (err_str), "Command type not found " + "while handling "GEOREP" options"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", err_str); + goto out; + } + +@@ -429,6 +434,10 @@ glusterd_urltransform (runner_t *runner, char ***linearrp) + unsigned arr_len = 32; + unsigned arr_idx = 0; + gf_boolean_t error = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + linearr = GF_CALLOC (arr_len, sizeof (char *), gf_gld_mt_linearr); + if (!linearr) { +@@ -438,7 +447,9 @@ glusterd_urltransform (runner_t *runner, char ***linearrp) + + runner_redir (runner, STDOUT_FILENO, RUN_PIPE); + if (runner_start (runner) != 0) { +- gf_log ("", GF_LOG_ERROR, "spawning child failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SPAWNING_CHILD_FAILED, ++ "spawning child failed"); + + error = _gf_true; + goto out; +@@ -495,7 +506,9 @@ glusterd_urltransform (runner_t *runner, char ***linearrp) + error = _gf_true; + + if (error) { +- gf_log ("", GF_LOG_ERROR, "reading data from child failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_READ_CHILD_DATA_FAILED, ++ "reading data from child failed"); + glusterd_urltransform_free (linearr, arr_idx); + return -1; + } +@@ -581,10 +594,16 @@ glusterd_query_extutil_generic (char *resbuf, size_t blen, runner_t *runner, voi + int (*fcbk)(char *resbuf, size_t blen, FILE *fp, void *data)) + { + int ret = 0; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + runner_redir (runner, STDOUT_FILENO, RUN_PIPE); + if (runner_start (runner) != 0) { +- gf_log ("", GF_LOG_ERROR, "spawning child failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SPAWNING_CHILD_FAILED, ++ "spawning child failed"); + + return -1; + } +@@ -593,7 +612,9 @@ glusterd_query_extutil_generic (char *resbuf, size_t blen, runner_t *runner, voi + + ret |= runner_end (runner); + if (ret) +- gf_log ("", GF_LOG_ERROR, "reading data from child failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_READ_CHILD_DATA_FAILED, ++ "reading data from child failed"); + + return ret ? -1 : 0; + } +@@ -824,12 +845,15 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile, + glusterd_conf_t *priv = NULL; + int ret = -1; + struct stat stbuf = {0,}; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ GF_ASSERT (this->private); + GF_ASSERT (conf_path); + +- priv = THIS->private; ++ priv = this->private; + + GF_VALIDATE_OR_GOTO ("gsync", master, out); + GF_VALIDATE_OR_GOTO ("gsync", slave, out); +@@ -839,21 +863,24 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile, + + ret = lstat (conf_path, &stbuf); + if (!ret) { +- gf_log ("", GF_LOG_DEBUG, "Using passed config template(%s).", ++ gf_msg_debug (this->name, 0, "Using passed config template(%s).", + conf_path); + working_conf_path = conf_path; + } else { +- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. " +- "Looking for template config file (%s)", +- conf_path, temp_conf_path); ++ gf_msg (this->name, GF_LOG_WARNING, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "Config file (%s) missing. Looking for template " ++ "config file (%s)", conf_path, temp_conf_path); + ret = lstat (temp_conf_path, &stbuf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, + "Template config file (%s) missing.", + temp_conf_path); + goto out; + } +- gf_log ("", GF_LOG_INFO, "Using default config template(%s).", ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG, ++ "Using default config template(%s).", + temp_conf_path); + working_conf_path = temp_conf_path; + *is_template_in_use = _gf_true; +@@ -865,7 +892,8 @@ fetch_data: + slave, working_conf_path); + if ((ret == -1) || strlen(pidfile) == 0) { + if (*is_template_in_use == _gf_false) { +- gf_log ("", GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PIDFILE_CREATE_FAILED, + "failed to create the pidfile string. " + "Trying default config template"); + working_conf_path = temp_conf_path; +@@ -873,13 +901,15 @@ fetch_data: + goto fetch_data; + } else { + ret = -2; +- gf_log ("", GF_LOG_WARNING, +- "failed to create the pidfile string from template config"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PIDFILE_CREATE_FAILED, "failed to " ++ "create the pidfile string from template " ++ "config"); + goto out; + } + } + +- gf_log ("", GF_LOG_DEBUG, "pidfile = %s", pidfile); ++ gf_msg_debug (this->name, 0, "pidfile = %s", pidfile); + + ret = open (pidfile, O_RDWR); + out: +@@ -928,16 +958,22 @@ glusterd_gsync_volinfo_dict_set (glusterd_volinfo_t *volinfo, + { + int32_t ret = -1; + char *gsync_status = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + gsync_status = gf_strdup (value); + if (!gsync_status) { +- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY, ++ "Unable to allocate memory"); + goto out; + } + + ret = dict_set_dynstr (volinfo->dict, key, gsync_status); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to set dict"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, ++ "Unable to set dict"); + goto out; + } + +@@ -951,6 +987,10 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave) + { + int ret = 0; + runner_t runner = {0,}; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + runinit (&runner); + runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", +@@ -960,7 +1000,9 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave) + runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); + ret = runner_start (&runner); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "spawning child failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SPAWNING_CHILD_FAILED, ++ "spawning child failed"); + ret = -1; + goto out; + } +@@ -969,7 +1011,7 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave) + ret = -1; + + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -989,15 +1031,21 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + gf_boolean_t op_match = _gf_true; + gf_boolean_t val_match = _gf_true; + struct gsync_config_opt_vals_ *conf_vals = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + if (dict_get_str (dict, "subop", &subop) != 0) { +- gf_log ("", GF_LOG_WARNING, "missing subop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, ++ "missing subop"); + *op_errstr = gf_strdup ("Invalid config request"); + return -1; + } + + if (dict_get_str (dict, "slave", &slave) != 0) { +- gf_log ("", GF_LOG_WARNING, GEOREP" CONFIG: no slave given"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, ++ GEOREP" CONFIG: no slave given"); + *op_errstr = gf_strdup ("Slave required"); + return -1; + } +@@ -1006,7 +1054,8 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + return 0; + + if (dict_get_str (dict, "op_name", &op_name) != 0) { +- gf_log ("", GF_LOG_WARNING, "option name missing"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, ++ "option name missing"); + *op_errstr = gf_strdup ("Option name missing"); + return -1; + } +@@ -1014,11 +1063,15 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + if (runcmd (GSYNCD_PREFIX"/gsyncd", "--config-check", op_name, NULL)) { + ret = glusterd_verify_gsyncd_spawn (volname, slave); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to spawn gsyncd"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GSYNCD_SPAWN_FAILED, "Unable to spawn " ++ "gsyncd"); + return 0; + } + +- gf_log ("", GF_LOG_WARNING, "Invalid option %s", op_name); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_INVALID_ENTRY, ++ "Invalid option %s", op_name); + *op_errstr = gf_strdup ("Invalid option"); + + return -1; +@@ -1031,14 +1084,16 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + if (!t) + t = strtail (subop, "del"); + if (!t || (t[0] && strcmp (t, "-glob") != 0)) { +- gf_log ("", GF_LOG_WARNING, "unknown subop %s", subop); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_SUBOP_NOT_FOUND, ++ "unknown subop %s", subop); + *op_errstr = gf_strdup ("Invalid config request"); + return -1; + } + + if (strtail (subop, "set") && + dict_get_str (dict, "op_value", &op_value) != 0) { +- gf_log ("", GF_LOG_WARNING, "missing value for set"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, ++ "missing value for set"); + *op_errstr = gf_strdup ("missing value"); + } + +@@ -1054,7 +1109,9 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + banned = _gf_false; + } + if (banned) { +- gf_log ("", GF_LOG_WARNING, "Reserved option %s", op_name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_RESERVED_OPTION, ++ "Reserved option %s", op_name); + *op_errstr = gf_strdup ("Reserved option"); + + return -1; +@@ -1093,7 +1150,8 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname) + op_name); + errmsg[ret] = '\0'; + +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + return -1; + } +@@ -1121,16 +1179,22 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) + char conf_path[PATH_MAX] = ""; + int ret = -1; + glusterd_conf_t *priv = NULL; ++ xlator_t *this1 = NULL; ++ ++ this1 = THIS; ++ GF_ASSERT (this1); + + param = (glusterd_gsync_status_temp_t *)data; + + GF_ASSERT (param); + GF_ASSERT (param->volinfo); + +- if (THIS) +- priv = THIS->private; ++ if (this1) ++ priv = this1->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + goto out; + } + +@@ -1143,10 +1207,13 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) + &slave_host, &slave_vol, &errmsg); + if (ret) { + if (errmsg) +- gf_log ("", GF_LOG_ERROR, "Unable to fetch " +- "slave details. Error: %s", errmsg); ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, ++ "Unable to fetch slave details. Error: %s", ++ errmsg); + else +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this1->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave details."); + ret = -1; + goto out; +@@ -1169,7 +1236,7 @@ out: + if (slave_buf) + GF_FREE(slave_buf); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d.", ret); ++ gf_msg_debug (this1->name, 0, "Returning %d.", ret); + return ret; + } + +@@ -1194,6 +1261,10 @@ glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave, + int zero_slave_entries = _gf_true; + int ret = 0; + char *slavekey = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (volinfo); + GF_ASSERT (slave); +@@ -1216,7 +1287,7 @@ glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave, + goto out; + } + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + + } +@@ -1229,6 +1300,10 @@ glusterd_gsync_get_uuid (char *slave, glusterd_volinfo_t *vol, + char *slavekey = NULL; + char *slaveentry = NULL; + char *t = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (vol); + GF_ASSERT (slave); +@@ -1255,7 +1330,7 @@ glusterd_gsync_get_uuid (char *slave, glusterd_volinfo_t *vol, + *t = ':'; + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1267,6 +1342,10 @@ glusterd_check_gsync_running_local (char *master, char *slave, + int ret = -1; + int ret_status = 0; + gf_boolean_t is_template_in_use = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (master); + GF_ASSERT (slave); +@@ -1278,13 +1357,13 @@ glusterd_check_gsync_running_local (char *master, char *slave, + if (ret == 0 && ret_status == 0) + *is_run = _gf_true; + else if (ret == -1) { +- gf_log ("", GF_LOG_WARNING, GEOREP" validation " +- " failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VALIDATE_FAILED, ++ GEOREP" validation failed"); + goto out; + } + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + + } +@@ -1302,6 +1381,10 @@ glusterd_store_slave_in_info (glusterd_volinfo_t *volinfo, char *slave, + char *slaveentry = NULL; + char key[512] = {0, }; + char *t = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (volinfo); + GF_ASSERT (slave); +@@ -1329,18 +1412,19 @@ glusterd_store_slave_in_info (glusterd_volinfo_t *volinfo, char *slave, + GF_ASSERT (!t || *t != ':'); + + if (is_force) { +- gf_log ("", GF_LOG_DEBUG, GEOREP" has already been " +- "invoked for the %s (master) and %s (slave)." +- " Allowing without saving info again due to" +- " force command.", volinfo->volname, slave); ++ gf_msg_debug (this->name, 0, GEOREP" has already " ++ "been invoked for the %s (master) and " ++ "%s (slave). Allowing without saving " ++ "info again due to force command.", ++ volinfo->volname, slave); + ret = 0; + goto out; + } + +- gf_log ("", GF_LOG_ERROR, GEOREP" has already been invoked for " +- "the %s (master) and %s (slave) " +- "from a different machine", +- volinfo->volname, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVOKE_ERROR, ++ GEOREP" has already been invoked for " ++ "the %s (master) and %s (slave) from a different " ++ "machine", volinfo->volname, slave); + *op_errstr = gf_strdup (GEOREP" already running in " + "another machine"); + ret = -1; +@@ -1390,6 +1474,7 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo, + struct stat stbuf = {0,}; + + this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (volinfo); + GF_ASSERT (slave); +@@ -1410,7 +1495,8 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo, + snprintf (msg, sizeof (msg), "Session between %s and %s has" + " not been created. Please create session and retry.", + volinfo->volname, slave); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED, ++ "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } +@@ -1422,7 +1508,9 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo, + snprintf (msg, sizeof (msg), "Session between %s and %s has" + " not been created. Please create session and retry.", + volinfo->volname, slave); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SESSION_CREATE_ERROR, ++ "%s", msg); + goto out; + } + +@@ -1455,13 +1543,14 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo, + ret = glusterd_verify_gsyncd_spawn (volinfo->volname, slave); + if (ret && !is_force) { + snprintf (msg, sizeof (msg), "Unable to spawn gsyncd"); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_SPAWN_FAILED, ++ "%s", msg); + } + out: + if (ret && (msg[0] != '\0')) { + *op_errstr = gf_strdup (msg); + } +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1509,14 +1598,17 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave, + + confd = dict_new (); + if (!confd) { +- gf_log ("", GF_LOG_ERROR, "Not able to create dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, ++ "Not able to create dict."); + goto out; + } + + ret = glusterd_gsync_get_config (master, slave, conf_path, + confd); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_CONFIG_INFO_FAILED, ++ "Unable to get configuration data " + "for %s(master), %s(slave)", master, slave); + ret = -1; + goto out; +@@ -1524,7 +1616,8 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave, + + ret = dict_get_param (confd, "state_file", &statefile); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get state_file's name " ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to get state_file's name " + "for %s(master), %s(slave). Please check gsync " + "config file.", master, slave); + ret = -1; +@@ -1534,8 +1627,10 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave, + ret = glusterd_gsync_read_frm_status (statefile, monitor_status, + sizeof (monitor_status)); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to read the status " +- "file for %s(master), %s(slave)", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STAT_FILE_READ_FAILED, ++ "Unable to read the status file for %s(master), " ++ "%s(slave)", master, slave); + strncpy (monitor_status, "defunct", sizeof (monitor_status)); + } + +@@ -1594,7 +1689,9 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) + if (this) + priv = this->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + goto out; + } + +@@ -1609,10 +1706,12 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) + &slave_host, &slave_vol, &errmsg); + if (ret) { + if (errmsg) +- gf_log ("", GF_LOG_ERROR, "Unable to fetch " +- "slave details. Error: %s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, "Unable to fetch" ++ " slave details. Error: %s", errmsg); + else +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave details."); + ret = -1; + goto out; +@@ -1623,7 +1722,9 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) + priv->workdir, param->volinfo->volname, + slave_host, slave_vol); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to assign conf_path."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CONF_PATH_ASSIGN_FAILED, ++ "Unable to assign conf_path."); + ret = -1; + goto out; + } +@@ -1666,7 +1767,8 @@ glusterd_check_geo_rep_running (gsync_status_param_t *param, char **op_errstr) + ret = dict_foreach (param->volinfo->gsync_slaves, + _get_slave_status, param); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "_get_slave_satus failed"); + snprintf (msg, sizeof(msg), GEOREP" Unable to" + " get the status of active "GEOREP"" +@@ -1703,6 +1805,10 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo, + char msg[2048] = {0}; + char pidfile[PATH_MAX] = {0,}; + gf_boolean_t is_template_in_use = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (THIS && THIS->private); + GF_ASSERT (volinfo); +@@ -1720,15 +1826,18 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo, + pfd = gsyncd_getpidfile (volinfo->volname, slave, pidfile, + conf_path, &is_template_in_use); + if (pfd == -2) { +- gf_log ("", GF_LOG_ERROR, GEOREP" stop validation " +- "failed for %s & %s", volinfo->volname, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VALIDATE_FAILED, ++ GEOREP" stop validation failed for %s & %s", ++ volinfo->volname, slave); + ret = -1; + goto out; + } + if (gsync_status_byfd (pfd) == -1) { +- snprintf (msg, sizeof (msg), GEOREP" session b/w %s & %s is not" +- " running on this node.", volinfo->volname, slave); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ snprintf (msg, sizeof (msg), GEOREP" session b/w %s & %s is " ++ "not running on this node.", volinfo->volname, ++ slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SESSION_INACTIVE, ++ "%s", msg); + ret = -1; + /* monitor gsyncd already dead */ + goto out; +@@ -1737,7 +1846,8 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo, + if (is_template_in_use) { + snprintf (msg, sizeof (msg), "pid-file entry missing in " + "the config file(%s).", conf_path); +- gf_log ("", GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND, ++ "%s", msg); + ret = -1; + goto out; + } +@@ -1750,7 +1860,7 @@ out: + if (ret && (msg[0] != '\0')) { + *op_errstr = gf_strdup (msg); + } +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1768,11 +1878,17 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr) + char *slave_host = NULL; + char *slave_vol = NULL; + glusterd_conf_t *priv = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } +@@ -1786,7 +1902,8 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr) + exists = glusterd_check_volume_exists (volname); + ret = glusterd_volinfo_find (volname, &volinfo); + if ((ret) || (!exists)) { +- gf_log ("", GF_LOG_WARNING, "volume name does not exist"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND, ++ "volume name does not exist"); + snprintf (errmsg, sizeof(errmsg), "Volume name %s does not" + " exist", volname); + *op_errstr = gf_strdup (errmsg); +@@ -1804,14 +1921,15 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr) + &slave_host, &slave_vol, + &conf_path, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave or confpath details."); + ret = -1; + goto out; + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1822,13 +1940,18 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr, + { + + int ret = -1; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (op_errstr); + + if (master) { + ret = dict_get_str (dict, "master", master); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "master not found"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "master not found"); + *op_errstr = gf_strdup ("master not found"); + goto out; + } +@@ -1837,7 +1960,8 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr, + if (slave) { + ret = dict_get_str (dict, "slave", slave); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "slave not found"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "slave not found"); + *op_errstr = gf_strdup ("slave not found"); + goto out; + } +@@ -1846,7 +1970,8 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr, + if (host_uuid) { + ret = dict_get_str (dict, "host-uuid", host_uuid); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "host_uuid not found"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "host_uuid not found"); + *op_errstr = gf_strdup ("host_uuid not found"); + goto out; + } +@@ -1854,7 +1979,7 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr, + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1875,7 +2000,8 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr) + GF_ASSERT (conf); + + if (conf->op_version < 2) { +- gf_log ("", GF_LOG_ERROR, "Op Version not supported."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION, ++ "Op Version not supported."); + snprintf (errmsg, sizeof(errmsg), "One or more nodes do not" + " support the required op version."); + *op_errstr = gf_strdup (errmsg); +@@ -1886,7 +2012,7 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr) + ret = dict_get_str (dict, "command", &command); + if (ret) { + strcpy (errmsg, "internal error"); +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to get command from dict"); + goto out; + } +@@ -1916,13 +2042,15 @@ out: + command); + else + snprintf (errmsg, sizeof (errmsg), "%s", +- "gsync peer command was not specified"); ++ "gsync peer command was not " ++ "specified"); + } + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_CMD_ERROR, ++ "%s", errmsg); + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1937,17 +2065,24 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr) + int ret = -1; + glusterd_conf_t *priv = NULL; + struct stat stbuf = {0,}; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } + + if (priv->op_version < 2) { +- gf_log ("", GF_LOG_ERROR, "Op Version not supported."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION, ++ "Op Version not supported."); + snprintf (errmsg, sizeof(errmsg), "One or more nodes do not" + " support the required op version."); + *op_errstr = gf_strdup (errmsg); +@@ -1957,8 +2092,8 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "host-uuid", &host_uuid); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch" +- " host-uuid from dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch host-uuid from dict."); + goto out; + } + +@@ -1966,8 +2101,9 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr) + if (!strcmp (uuid_str, host_uuid)) { + ret = dict_get_str (dict, "source", &filename); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch" +- " filename from dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch filename from dict."); + *op_errstr = gf_strdup ("command unsuccessful"); + goto out; + } +@@ -1986,7 +2122,9 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Source file" + " is not a regular file."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SRC_FILE_ERROR, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -1994,7 +2132,7 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr) + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2011,9 +2149,12 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave, + glusterd_conf_t *priv = NULL; + int ret = -1; + struct stat stbuf = {0,}; ++ xlator_t *this = NULL; + +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ this = THIS; ++ GF_ASSERT (this); ++ ++ GF_ASSERT (this->private); + GF_ASSERT (volinfo); + GF_ASSERT (conf_path); + GF_ASSERT (is_template_in_use); +@@ -2022,7 +2163,8 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave, + + confd = dict_new (); + if (!confd) { +- gf_log ("", GF_LOG_ERROR, "Unable to create new dict"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, ++ "Unable to create new dict"); + goto out; + } + +@@ -2033,22 +2175,24 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave, + + ret = lstat (conf_path, &stbuf); + if (!ret) { +- gf_log ("", GF_LOG_INFO, "Using passed config template(%s).", ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO, ++ "Using passed config template(%s).", + conf_path); + working_conf_path = conf_path; + } else { +- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. " +- "Looking for template config file (%s)", +- conf_path, temp_conf_path); ++ gf_msg (this->name, GF_LOG_WARNING, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "Config file (%s) missing. Looking for template config" ++ " file (%s)", conf_path, temp_conf_path); + ret = lstat (temp_conf_path, &stbuf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, +- "Template config file (%s) missing.", +- temp_conf_path); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, "Template " ++ "config file (%s) missing.", temp_conf_path); + goto out; + } +- gf_log ("", GF_LOG_INFO, "Using default config template(%s).", +- temp_conf_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG, ++ "Using default config template(%s).", temp_conf_path); + working_conf_path = temp_conf_path; + *is_template_in_use = _gf_true; + } +@@ -2058,7 +2202,8 @@ fetch_data: + confd); + if (ret) { + if (*is_template_in_use == _gf_false) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_CONFIG_INFO_FAILED, + "Unable to get configuration data " + "for %s(master), %s(slave). " + "Trying template config.", +@@ -2067,7 +2212,8 @@ fetch_data: + *is_template_in_use = _gf_true; + goto fetch_data; + } else { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_CONFIG_INFO_FAILED, + "Unable to get configuration data " + "for %s(master), %s(slave) from " + "template config", +@@ -2079,14 +2225,16 @@ fetch_data: + ret = dict_get_param (confd, "state_file", &buf); + if (ret) { + if (*is_template_in_use == _gf_false) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get state_file's name. " + "Trying template config."); + working_conf_path = temp_conf_path; + *is_template_in_use = _gf_true; + goto fetch_data; + } else { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_STATEFILE_NAME_FAILED, + "Unable to get state_file's " + "name from template."); + goto out; +@@ -2104,7 +2252,7 @@ fetch_data: + if (confd) + dict_destroy (confd); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d ", ret); ++ gf_msg_debug (this->name, 0, "Returning %d ", ret); + return ret; + } + +@@ -2115,19 +2263,26 @@ glusterd_create_status_file (char *master, char *slave, char *slave_host, + int ret = -1; + runner_t runner = {0,}; + glusterd_conf_t *priv = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + goto out; + } + + if (!status) { +- gf_log ("", GF_LOG_ERROR, "Status Empty"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_STATUS_NULL, ++ "Status Empty"); + goto out; + } +- gf_log ("", GF_LOG_DEBUG, "slave = %s", slave); ++ gf_msg_debug (this->name, 0, "slave = %s", slave); + + runinit (&runner); + runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--create", +@@ -2141,14 +2296,16 @@ glusterd_create_status_file (char *master, char *slave, char *slave_host, + ret = runner_run (&runner); + synclock_lock (&priv->big_lock); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Creating status file failed."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STATUSFILE_CREATE_FAILED, ++ "Creating status file failed."); + ret = -1; + goto out; + } + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -2192,7 +2349,8 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol, + } + + if (!slave_user || !slave_ip) { +- gf_log (this->name, GF_LOG_ERROR, "Invalid slave url."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SLAVE_URL_INVALID, ++ "Invalid slave url."); + goto out; + } + +@@ -2211,12 +2369,13 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol, + ret = runner_run (&runner); + synclock_lock (&priv->big_lock); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Not a valid slave"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_SLAVE, ++ "Not a valid slave"); + ret = glusterd_gsync_read_frm_status (log_file_path, + buf, sizeof(buf)); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to read from %s", +- log_file_path); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_READ_ERROR, ++ "Unable to read from %s", log_file_path); + goto out; + } + +@@ -2246,7 +2405,7 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol, + out: + GF_FREE (slave_url_buf); + unlink (log_file_path); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2261,6 +2420,10 @@ glusterd_geo_rep_parse_slave (char *slave_url, + char *host = NULL; + char errmsg[PATH_MAX] = ""; + char *saved_url = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (slave_url); + GF_ASSERT (*slave_url); +@@ -2285,11 +2448,12 @@ glusterd_geo_rep_parse_slave (char *slave_url, + * actual hostname also has '@' */ + host++; + if (strstr (host, "@")) { +- gf_log ("", GF_LOG_DEBUG, "host = %s", host); ++ gf_msg_debug (this->name, 0, "host = %s", host); + ret = snprintf (errmsg, sizeof(errmsg) - 1, + "Invalid Hostname (%s).", host); + errmsg[ret] = '\0'; +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", errmsg); + ret = -1; + if (op_errstr) + *op_errstr = gf_strdup (errmsg); +@@ -2318,7 +2482,7 @@ out: + if (ret) + if (hostname) + GF_FREE (*hostname); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2358,13 +2522,15 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + ret = glusterd_op_gsync_args_get (dict, op_errstr, &volname, + &slave, &host_uuid); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch arguments"); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_ARG_FETCH_ERROR, ++ "Unable to fetch arguments"); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return -1; + } + + if (conf->op_version < 2) { +- gf_log ("", GF_LOG_ERROR, "Op Version not supported."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION, ++ "Op Version not supported."); + snprintf (errmsg, sizeof(errmsg), "One or more nodes do not" + " support the required op version."); + *op_errstr = gf_strdup (errmsg); +@@ -2375,11 +2541,12 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + exists = glusterd_check_volume_exists (volname); + ret = glusterd_volinfo_find (volname, &volinfo); + if ((ret) || (!exists)) { +- gf_log ("", GF_LOG_WARNING, "volume name does not exist"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND, ++ "volume name does not exist"); + snprintf (errmsg, sizeof(errmsg), "Volume name %s does not" + " exist", volname); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return -1; + } + +@@ -2387,7 +2554,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + &slave_host, &slave_vol, + &conf_path, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave or confpath details."); + ret = -1; + goto out; +@@ -2406,15 +2574,18 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + " down. Please bring up the peer and" + " retry.", down_peerstr, + volinfo->volname); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_DISCONNECTED, ++ "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + GF_FREE (down_peerstr); + down_peerstr = NULL; +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return -1; + } else if (ret == _gf_false) { +- gf_log ("", GF_LOG_INFO, "Peer %s," +- " which is a part of %s volume, is" ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_PEER_DISCONNECTED, ++ "Peer %s, which is a part of %s volume, is" + " down. Force creating geo-rep session." + " On bringing up the peer, re-run" + " \"gluster system:: execute" +@@ -2437,12 +2608,18 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + op_errstr, &is_force_blocker); + if (ret) { + if (is_force && !is_force_blocker) { +- gf_log ("", GF_LOG_INFO, "%s is not a valid slave" +- " volume. Error: %s. Force creating geo-rep" +- " session.", slave, *op_errstr); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_INVALID_SLAVE, ++ "%s is not a valid slave " ++ "volume. Error: %s. Force " ++ "creating geo-rep" ++ " session.", slave, ++ *op_errstr); + } else { +- gf_log ("", GF_LOG_ERROR, +- "%s is not a valid slave volume. Error: %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INVALID_SLAVE, ++ "%s is not a valid slave " ++ "volume. Error: %s", + slave, *op_errstr); + ret = -1; + +@@ -2471,7 +2648,9 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + " not present. Please run" + " \"gluster system:: execute" + " gsec_create\"", common_pem_file); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + ret = -1; + goto out; +@@ -2484,7 +2663,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + "for push-pem is not present. " + "Please install the hook-script " + "and retry", hook_script); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + ret = -1; + goto out; +@@ -2496,7 +2676,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + " not a regular file. Please run" + " \"gluster system:: execute" + " gsec_create\"", common_pem_file); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_REG_FILE_MISSING, "%s", errmsg); + ret = -1; + goto out; + } +@@ -2513,14 +2694,16 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + else + snprintf (errmsg, sizeof (errmsg), "Please check gsync " + "config file. Unable to get statefile's name"); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STATEFILE_NAME_NOT_FOUND, ++ "%s", errmsg); + ret = -1; + goto out; + } + + ret = dict_set_str (dict, "statefile", statefile); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, + "Unable to store statefile path"); + goto out; + } +@@ -2530,18 +2713,21 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Session between %s" + " and %s is already created.", + volinfo->volname, slave); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SESSION_ALREADY_EXIST, ++ "%s", errmsg); + ret = -1; + goto out; + } else if (!ret) +- gf_log ("", GF_LOG_INFO, "Session between %s" +- " and %s is already created. Force" ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_FORCE_CREATE_SESSION, ++ "Session between %s and %s is already created. Force" + " creating again.", volinfo->volname, slave); + + ret = glusterd_verify_gsyncd_spawn (volinfo->volname, slave); + if (ret) { + snprintf (errmsg, sizeof (errmsg), "Unable to spawn gsyncd."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_SPAWN_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -2551,7 +2737,7 @@ out: + if (ret && errmsg[0] != '\0') + *op_errstr = gf_strdup (errmsg); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2642,7 +2828,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + + ret = dict_get_int32 (dict, "type", &type); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "command type not found"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, ++ "command type not found"); + *op_errstr = gf_strdup ("command unsuccessful"); + goto out; + } +@@ -2679,7 +2866,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + &slave_host, &slave_vol, + &conf_path, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave or confpath details."); + ret = -1; + goto out; +@@ -2697,12 +2885,14 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + ret = -1; + goto out; + } else { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVE_URL_INVALID, + "state_file entry missing in config file (%s)", + conf_path); + + if ((type == GF_GSYNC_OPTION_TYPE_STOP) && is_force) { +- gf_log ("", GF_LOG_WARNING, "Allowing stop " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_STOP_FORCE, "Allowing stop " + "force to bypass missing statefile " + "entry in config file (%s), and " + "template file", conf_path); +@@ -2713,7 +2903,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + } else { + ret = dict_set_str (dict, "statefile", statefile); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to store statefile path"); + goto out; + } +@@ -2728,8 +2919,9 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof(errmsg), "Geo-replication" + " session between %s and %s does not exist.", + volinfo->volname, slave); +- gf_log ("", GF_LOG_ERROR, "%s. statefile = %s", +- errmsg, statefile); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "%s. statefile = %s", errmsg, statefile); + ret = -1; + goto out; + } +@@ -2779,9 +2971,11 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + /* gsyncd does a fuse mount to start + * the geo-rep session */ + if (!glusterd_is_fuse_available ()) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to " +- "open /dev/fuse (%s), geo-replication " +- "start failed", strerror (errno)); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_GEO_REP_START_FAILED, "Unable " ++ "to open /dev/fuse (%s), " ++ "geo-replication start failed", ++ strerror (errno)); + snprintf (errmsg, sizeof(errmsg), + "fuse unvailable"); + ret = -1; +@@ -2904,11 +3098,12 @@ out: + GF_FREE (path_list); + + if (ret && errmsg[0] != '\0') { +- gf_log (this->name, GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR, ++ "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -2944,15 +3139,16 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + snprintf (errmsg, sizeof(errmsg), + "pid-file entry mising in config file and " + "template config file."); +- gf_log (this->name, GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND, ++ "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + ret = -1; + goto out; + } + + if (gsync_status_byfd (pfd) == -1) { +- gf_log (this->name, GF_LOG_ERROR, "gsyncd b/w %s & %s is not" +- " running", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR, ++ "gsyncd b/w %s & %s is not running", master, slave); + /* monitor gsyncd already dead */ + goto out; + } +@@ -2963,14 +3159,15 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + /* Prepare to update status file*/ + ret = dict_get_str (dict, "statefile", &statefile); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Pause/Resume Failed:" +- " Unable to fetch statefile path"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Pause/Resume Failed: Unable to fetch statefile path"); + goto out; + } + ret = glusterd_gsync_read_frm_status (statefile, monitor_status, + sizeof (monitor_status)); + if (ret <= 0) { +- gf_log (this->name, GF_LOG_ERROR, "Pause/Resume Failed: " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STAT_FILE_READ_FAILED, "Pause/Resume Failed: " + "Unable to read status file for %s(master)" + " %s(slave)", master, slave); + goto out; +@@ -2982,7 +3179,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + if (is_pause) { + ret = kill (-pid, SIGSTOP); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_PID_KILL_FAIL, "Failed" + " to pause gsyncd. Error: %s", + strerror (errno)); + goto out; +@@ -2996,7 +3194,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + slave_host, slave_vol, + "Paused"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UPDATE_STATEFILE_FAILED, + "Unable to update state_file." + " Error : %s", strerror (errno)); + /* If status cannot be updated resume back */ +@@ -3007,9 +3206,11 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + "Please use 'resume force' to" + " resume back and retry pause" + " to reflect in status"); +- gf_log (this->name, GF_LOG_ERROR, +- "Resume back Failed. Error: %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, ++ errno, ++ GD_MSG_PID_KILL_FAIL, ++ "Resume back Failed. Error:" ++ "%s", strerror (errno)); + *op_errstr = gf_strdup (errmsg); + } + goto out; +@@ -3020,7 +3221,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + slave_vol, + "Started"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UPDATE_STATEFILE_FAILED, + "Resume Failed: Unable to update " + "state_file. Error : %s", + strerror (errno)); +@@ -3028,7 +3230,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + } + ret = kill (-pid, SIGCONT); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_PID_KILL_FAIL, + "Resumed Failed: Unable to send" + " SIGCONT. Error: %s", + strerror (errno)); +@@ -3045,7 +3248,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, + "inconsistent. Please use " + "'resume force' to resume and" + " reach consistent state"); +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STATUS_UPDATE_FAILED, + "Updating status back to paused" + " Failed. Error: %s", + strerror (errno)); +@@ -3075,9 +3279,12 @@ stop_gsync (char *master, char *slave, char **msg, + char buf [1024] = {0,}; + int i = 0; + gf_boolean_t is_template_in_use = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ GF_ASSERT (this->private); + + pfd = gsyncd_getpidfile (master, slave, pidfile, + conf_path, &is_template_in_use); +@@ -3085,14 +3292,16 @@ stop_gsync (char *master, char *slave, char **msg, + snprintf (errmsg, sizeof(errmsg) - 1, + "pid-file entry mising in config file and " + "template config file."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND, ++ "%s", errmsg); + *op_errstr = gf_strdup (errmsg); + ret = -1; + goto out; + } + if (gsync_status_byfd (pfd) == -1 && !is_force) { +- gf_log ("", GF_LOG_ERROR, "gsyncd b/w %s & %s is not" +- " running", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR, ++ "gsyncd b/w %s & %s is not running", master, ++ slave); + /* monitor gsyncd already dead */ + goto out; + } +@@ -3105,7 +3314,8 @@ stop_gsync (char *master, char *slave, char **msg, + pid = strtol (buf, NULL, 10); + ret = kill (-pid, SIGTERM); + if (ret && !is_force) { +- gf_log ("", GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_PID_KILL_FAIL, + "failed to kill gsyncd"); + goto out; + } +@@ -3153,31 +3363,39 @@ glusterd_gsync_op_already_set (char* master, char* slave, char* conf_path, + int32_t op_val_cli = 0; + int32_t ret = -1; + gf_boolean_t is_bool = _gf_true; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + confd = dict_new (); + if (!confd) { +- gf_log ("", GF_LOG_ERROR, "Not able to create dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, ++ "Not able to create dict."); + return -1; + } + + ret = glusterd_gsync_get_config (master, slave, conf_path, + confd); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data" +- "for %s(master), %s(slave)", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_CONFIG_INFO_FAILED, ++ "Unable to get configuration data for %s(master), " ++ "%s(slave)", master, slave); + goto out; + } + + ret = dict_get_param (confd, op_name, &op_val_buf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get op_value " +- "for %s(master), %s(slave). Please check gsync " +- "config file.", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to get op_value for %s(master), %s(slave). " ++ "Please check gsync config file.", master, slave); + ret = 1; + goto out; + } + +- gf_log("",GF_LOG_DEBUG, "val_cli:%s val_conf:%s",op_value,op_val_buf); ++ gf_msg_debug (this->name, 0, "val_cli:%s val_conf:%s", op_value, ++ op_val_buf); + + if (!strcmp(op_val_buf,"true") || !strcmp(op_val_buf,"1") + || !strcmp(op_val_buf,"yes")) { +@@ -3234,6 +3452,10 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + gf_boolean_t restart_required = _gf_true; + char **resopt = NULL; + gf_boolean_t op_already_set = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (slave); + GF_ASSERT (op_errstr); +@@ -3246,7 +3468,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + + if (strcmp (subop, "get") == 0 || strcmp (subop, "get-all") == 0) { + /* deferred to cli */ +- gf_log ("", GF_LOG_DEBUG, "Returning 0"); ++ gf_msg_debug (this->name, 0, "Returning 0"); + return 0; + } + +@@ -3263,14 +3485,16 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } + + ret = dict_get_str (dict, "conf_path", &conf_path); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch conf file path."); + goto out; + } +@@ -3294,14 +3518,15 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + ret = glusterd_gsync_op_already_set(master,slave,conf_path, + op_name,op_value); + if (ret == -1) { +- gf_log ("", GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GSYNCD_OP_SET_FAILED, + "glusterd_gsync_op_already_set failed."); + gf_asprintf (op_errstr, GEOREP" config-%s failed for " + "%s %s", subop, master, slave); + goto out; + } + if (ret == 0) { +- gf_log("", GF_LOG_DEBUG, "op_value is already set"); ++ gf_msg_debug (this->name, 0, "op_value is already set"); + op_already_set = _gf_true; + goto out; + } +@@ -3311,9 +3536,10 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + ret = runner_run (&runner); + synclock_lock (&priv->big_lock); + if (ret) { +- gf_log ("", GF_LOG_WARNING, "gsyncd failed to " +- "%s %s option for %s %s peers", +- subop, op_name, master, slave); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_GSYNCD_ERROR, ++ "gsyncd failed to %s %s option for " ++ "%s %s peers", subop, op_name, master, ++ slave); + + gf_asprintf (op_errstr, GEOREP" config-%s failed for %s %s", + subop, master, slave); +@@ -3327,14 +3553,16 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + if (ret) { + ret = dict_get_str (dict, "slave_host", &slave_host); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to fetch slave host."); + goto out; + } + + ret = dict_get_str (dict, "slave_vol", &slave_vol); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to fetch slave volume name."); + goto out; + } +@@ -3345,8 +3573,9 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, + "Switching Status " + "File"); + if (ret || lstat (op_value, &stbuf)) { +- gf_log ("", GF_LOG_ERROR, "Unable to create %s" +- ". Error : %s", op_value, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to " ++ "create %s. Error : %s", op_value, + strerror (errno)); + ret = -1; + goto out; +@@ -3376,7 +3605,7 @@ out: + } + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3385,13 +3614,17 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen) + { + int ret = 0; + int status_fd = -1; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (path); + GF_ASSERT (buf); + status_fd = open (path, O_RDONLY); + if (status_fd == -1) { +- gf_log ("", GF_LOG_ERROR, "Unable to read gsyncd status" +- " file"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_FILE_OP_FAILED, ++ "Unable to read gsyncd status file"); + return -1; + } + ret = read (status_fd, buf, blen - 1); +@@ -3406,7 +3639,8 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen) + *p-- = '\0'; + } + } else if (ret < 0) +- gf_log ("", GF_LOG_ERROR, "Status file of gsyncd is corrupt"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR, ++ "Status file of gsyncd is corrupt"); + + close (status_fd); + return ret; +@@ -3451,19 +3685,26 @@ glusterd_fetch_values_from_config (char *master, char *slave, + char **socketfile) + { + int ret = 0; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + ret = glusterd_gsync_get_config (master, slave, confpath, + confd); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data" +- "for %s(master), %s(slave)", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_CONFIG_INFO_FAILED, ++ "Unable to get configuration data for %s(master), " ++ "%s(slave)", master, slave); + goto out; + } + + if (statefile) { + ret = dict_get_param (confd, "state_file", statefile); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get state_file's name " + "for %s(master), %s(slave). " + "Please check gsync config file.", +@@ -3476,7 +3717,8 @@ glusterd_fetch_values_from_config (char *master, char *slave, + ret = dict_get_param (confd, "georep_session_working_dir", + georep_session_wrkng_dir); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get geo-rep session's " + "working directory name for %s(master), " + "%s(slave). Please check gsync config file.", +@@ -3489,7 +3731,8 @@ glusterd_fetch_values_from_config (char *master, char *slave, + ret = dict_get_param (confd, "state_socket_unencoded", + socketfile); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get socket file's name " + "for %s(master), %s(slave). " + "Please check gsync config file.", +@@ -3500,7 +3743,7 @@ glusterd_fetch_values_from_config (char *master, char *slave, + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3537,9 +3780,12 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave, + glusterd_conf_t *priv = NULL; + struct stat stbuf = {0,}; + dict_t *statusd = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ GF_ASSERT (this->private); + GF_ASSERT (volinfo); + GF_ASSERT (conf_path); + +@@ -3547,7 +3793,8 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave, + + confd = dict_new (); + if (!confd) { +- gf_log ("", GF_LOG_ERROR, "Not able to create dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, ++ "Not able to create dict."); + return -1; + } + +@@ -3558,22 +3805,24 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave, + + ret = lstat (conf_path, &stbuf); + if (!ret) { +- gf_log ("", GF_LOG_INFO, "Using passed config template(%s).", ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO, ++ "Using passed config template(%s).", + conf_path); + working_conf_path = conf_path; + } else { +- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. " +- "Looking for template config file (%s)", +- conf_path, temp_conf_path); ++ gf_msg (this->name, GF_LOG_WARNING, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "Config file (%s) missing. Looking for template " ++ "config file (%s)", conf_path, temp_conf_path); + ret = lstat (temp_conf_path, &stbuf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, +- "Template config file (%s) missing.", +- temp_conf_path); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, "Template " ++ "config file (%s) missing.", temp_conf_path); + goto out; + } +- gf_log ("", GF_LOG_INFO, "Using default config template(%s).", +- temp_conf_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG, ++ "Using default config template(%s).", temp_conf_path); + working_conf_path = temp_conf_path; + is_template_in_use = _gf_true; + } +@@ -3587,7 +3836,8 @@ fetch_data: + &socketfile); + if (ret) { + if (is_template_in_use == _gf_false) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FETCH_CONFIG_VAL_FAILED, + "Unable to fetch config values " + "for %s(master), %s(slave). " + "Trying default config template", +@@ -3596,10 +3846,10 @@ fetch_data: + is_template_in_use = _gf_true; + goto fetch_data; + } else { +- gf_log ("", GF_LOG_ERROR, +- "Unable to fetch config values " +- "for %s(master), %s(slave)", +- master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FETCH_CONFIG_VAL_FAILED, "Unable to " ++ "fetch config values for %s(master), " ++ "%s(slave)", master, slave); + goto out; + } + } +@@ -3607,8 +3857,10 @@ fetch_data: + ret = glusterd_gsync_read_frm_status (statefile, monitor_status, + sizeof (monitor_status)); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to read the status" +- "file for %s(master), %s(slave)", master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STAT_FILE_READ_FAILED, ++ "Unable to read the status file for %s(master), " ++ "%s(slave)", master, slave); + strncpy (monitor_status, "defunct", sizeof (monitor_status)); + } + +@@ -3623,7 +3875,9 @@ fetch_data: + sts_val = GF_CALLOC (1, sizeof(gf_gsync_status_t), + gf_common_mt_gsync_status_t); + if (!sts_val) { +- gf_log ("", GF_LOG_ERROR, "Out Of Memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, ++ "Out Of Memory"); + goto out; + } + +@@ -3705,7 +3959,9 @@ fetch_data: + brickinfo->path, sts_val); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to get status data " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GET_STATUS_DATA_FAIL, ++ "Unable to get status data " + "for %s(master), %s(slave), %s(brick)", + master, slave, brickinfo->path); + ret = -1; +@@ -3817,16 +4073,17 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave, + volinfo->gsync_active_slaves, + key, "running"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to set " +- "key:%s value:running in dict. But the " +- "config succeeded.", key); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Unable to set" ++ " key:%s value:running in dict. But " ++ "the config succeeded.", key); + goto out; + } + } + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3834,11 +4091,16 @@ static int32_t + glusterd_marker_changelog_create_volfile (glusterd_volinfo_t *volinfo) + { + int32_t ret = 0; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to create volfile" +- " for setting of marker while '"GEOREP" start'"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, ++ "Unable to create volfile for setting of marker " ++ "while '"GEOREP" start'"); + ret = -1; + goto out; + } +@@ -3859,13 +4121,16 @@ glusterd_set_gsync_knob (glusterd_volinfo_t *volinfo, char *key, int *vc) + { + int ret = -1; + int conf_enabled = _gf_false; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ GF_ASSERT (this->private); + + conf_enabled = glusterd_volinfo_get_boolean (volinfo, key); + if (conf_enabled == -1) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GET_KEY_FAILED, + "failed to get key %s from volinfo", key); + goto out; + } +@@ -3878,7 +4143,7 @@ glusterd_set_gsync_knob (glusterd_volinfo_t *volinfo, char *key, int *vc) + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -3925,37 +4190,44 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo, + int ret = 0; + gf_boolean_t is_template_in_use = _gf_false; + struct stat stbuf = {0, }; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (volinfo); + GF_ASSERT (slave); +- GF_ASSERT (THIS); +- GF_ASSERT (THIS->private); ++ GF_ASSERT (this->private); + +- priv = THIS->private; ++ priv = this->private; + + ret = glusterd_gsync_get_uuid (slave, volinfo, uuid); + if (ret) { +- gf_log ("", GF_LOG_INFO, "geo-replication status %s %s :" +- "session is not active", volinfo->volname, slave); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_SESSION_INACTIVE, ++ "geo-replication status %s %s : session is not " ++ "active", volinfo->volname, slave); + + ret = glusterd_get_statefile_name (volinfo, slave, + conf_path, &statefile, + &is_template_in_use); + if (ret) { + if (!strstr(slave, "::")) +- gf_log ("", GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_SLAVE_URL_INVALID, + "%s is not a valid slave url.", slave); + else +- gf_log ("", GF_LOG_INFO, "Unable to get" +- " statefile's name"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_GET_STATEFILE_NAME_FAILED, ++ "Unable to get statefile's name"); + ret = 0; + goto out; + } + + ret = lstat (statefile, &stbuf); + if (ret) { +- gf_log ("", GF_LOG_INFO, "%s statefile not present.", +- statefile); ++ gf_msg (this->name, GF_LOG_INFO, ENOENT, ++ GD_MSG_FILE_OP_FAILED, ++ "%s statefile not present.", statefile); + ret = 0; + goto out; + } +@@ -3967,7 +4239,7 @@ out: + if (statefile) + GF_FREE (statefile); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + } + +@@ -3994,9 +4266,12 @@ glusterd_get_gsync_status_all (dict_t *rsp_dict, char *node) + int32_t ret = 0; + glusterd_conf_t *priv = NULL; + glusterd_volinfo_t *volinfo = NULL; ++ xlator_t *this = NULL; + +- GF_ASSERT (THIS); +- priv = THIS->private; ++ this = THIS; ++ GF_ASSERT (this); ++ ++ priv = this->private; + + GF_ASSERT (priv); + +@@ -4007,7 +4282,7 @@ glusterd_get_gsync_status_all (dict_t *rsp_dict, char *node) + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug (this->name, 0, "Returning with %d", ret); + return ret; + + } +@@ -4023,6 +4298,10 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + glusterd_volinfo_t *volinfo = NULL; + int ret = 0; + char my_hostname[256] = {0,}; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + ret = gethostname(my_hostname, 256); + if (ret) { +@@ -4039,7 +4318,8 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + exists = glusterd_check_volume_exists (volname); + ret = glusterd_volinfo_find (volname, &volinfo); + if ((ret) || (!exists)) { +- gf_log ("", GF_LOG_WARNING, "volume name does not exist"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND, ++ "volume name does not exist"); + snprintf (errmsg, sizeof(errmsg), "Volume name %s does not" + " exist", volname); + *op_errstr = gf_strdup (errmsg); +@@ -4057,7 +4337,7 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "conf_path", &conf_path); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch conf file path."); + goto out; + } +@@ -4066,7 +4346,7 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + rsp_dict, my_hostname); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4082,6 +4362,10 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + char *gl_workdir = NULL; + char geo_rep_dir[PATH_MAX] = ""; + char *conf_path = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (slave); + GF_ASSERT (slave_host); +@@ -4093,14 +4377,16 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } + + ret = dict_get_str (dict, "conf_path", &conf_path); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch conf file path."); + goto out; + } +@@ -4123,9 +4409,9 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + ret = runner_run (&runner); + synclock_lock (&priv->big_lock); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "gsyncd failed to " +- "delete session info for %s and %s peers", +- master, slave); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SESSION_DEL_FAILED, ++ "gsyncd failed to delete session info for %s and " ++ "%s peers", master, slave); + + gf_asprintf (op_errstr, "gsyncd failed to " + "delete session info for %s and %s peers", +@@ -4142,12 +4428,13 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + ret = rmdir (geo_rep_dir); + if (ret) { + if (errno == ENOENT) +- gf_log ("", GF_LOG_DEBUG, "Geo Rep Dir(%s) Not Present.", +- geo_rep_dir); ++ gf_msg_debug (this->name, 0, "Geo Rep Dir(%s) Not Present.", ++ geo_rep_dir); + else { +- gf_log ("", GF_LOG_ERROR, "Unable to delete " +- "Geo Rep Dir(%s). Error: %s", geo_rep_dir, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, ++ "Unable to delete Geo Rep Dir(%s). Error: %s", ++ geo_rep_dir, strerror (errno)); + goto out; + } + } +@@ -4157,7 +4444,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + gf_asprintf (op_errstr, "delete successful"); + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4178,6 +4465,10 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + int output_count = 0; + glusterd_conf_t *priv = NULL; + runner_t runner = {0,}; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + GF_ASSERT (dict); + GF_ASSERT (op_errstr); +@@ -4186,28 +4477,33 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } + + ret = dict_get_str (dict, "command", &command); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to get command from dict"); + goto out; + } + + ret = dict_get_int32 (dict, "cmd_args_count", &cmd_args_count); + if (ret) +- gf_log ("", GF_LOG_INFO, "No cmd_args_count"); ++ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED, ++ "No cmd_args_count"); + + if (cmd_args_count) { + cmd_args = GF_CALLOC (cmd_args_count, sizeof (char*), + gf_common_mt_char); + if (!cmd_args) { +- gf_log ("", GF_LOG_ERROR, "Unable to calloc. " +- "Errno = %s", strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, ++ "Unable to calloc. Errno = %s", ++ strerror(errno)); + goto out; + } + +@@ -4217,9 +4513,9 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + "cmd_arg_%d", i); + ret = dict_get_str (dict, cmd_arg_name, &cmd_args[i-1]); + if (ret) { +- gf_log ("", GF_LOG_ERROR, +- "Unable to get %s in dict", +- cmd_arg_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to get" ++ " %s in dict", cmd_arg_name); + goto out; + } + } +@@ -4237,7 +4533,8 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + "execute command. Error : %s", + strerror (errno)); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_CMD_EXEC_FAIL, "%s", ++ errmsg); + ret = -1; + synclock_lock (&priv->big_lock); + goto out; +@@ -4258,15 +4555,21 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + buf[strlen(buf) - 1] = '\0'; + bufp = gf_strdup (buf); + if (!bufp) +- gf_log ("", GF_LOG_ERROR, "gf_strdup failed."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STRDUP_FAILED, ++ "gf_strdup failed."); + ret = dict_set_dynstr (rsp_dict, output_name, bufp); + if (ret) { + GF_FREE (bufp); +- gf_log ("", GF_LOG_ERROR, "output set failed."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "output set " ++ "failed."); + } + ret = dict_set_int32 (rsp_dict, "output_count", output_count); + if (ret) +- gf_log ("", GF_LOG_ERROR, "output_count set failed."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "output_count " ++ "set failed."); + } + } while (ptr); + +@@ -4276,7 +4579,8 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + "end. Error : %s", + strerror (errno)); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNABLE_TO_END, "%s", ++ errmsg); + ret = -1; + synclock_lock (&priv->big_lock); + goto out; +@@ -4290,7 +4594,7 @@ out: + cmd_args = NULL; + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4313,11 +4617,17 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + glusterd_conf_t *priv = NULL; + struct stat stbuf = {0,}; + gf_boolean_t free_contents = _gf_true; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + if (THIS) + priv = THIS->private; + if (priv == NULL) { +- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GLUSTERD_PRIV_NOT_FOUND, ++ "priv of glusterd not present"); + *op_errstr = gf_strdup ("glusterd defunct"); + goto out; + } +@@ -4328,8 +4638,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + + ret = dict_get_str (dict, "source", &filename); + if (ret < 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch" +- " filename from dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch filename from dict."); + *op_errstr = gf_strdup ("command unsuccessful"); + goto out; + } +@@ -4343,7 +4653,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Source file" + " does not exist in %s", priv->workdir); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, ENOENT, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + goto out; + } + +@@ -4352,7 +4663,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), + "Unable to allocate memory"); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -4362,7 +4675,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to open %s", + abs_filename); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FILE_OP_FAILED, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -4380,7 +4695,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to read all " + "the data from %s", abs_filename); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_READ_ERROR, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -4390,7 +4706,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to set" + " contents size in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "%s", errmsg); + goto out; + } + +@@ -4400,7 +4717,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to set" + " file mode in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -4410,7 +4729,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to set" + " pem contents in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "%s", errmsg); + goto out; + } + free_contents = _gf_false; +@@ -4422,7 +4742,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to get" + " pem contents in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", errmsg); + goto out; + } + ret = dict_get_int32 (dict, "contents_size", &contents_size); +@@ -4430,7 +4751,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to set" + " contents size in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", errmsg); + goto out; + } + +@@ -4439,7 +4761,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to get" + " file mode in dict."); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "%s", errmsg); + goto out; + } + +@@ -4448,7 +4771,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Unable to open %s", + abs_filename); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + ret = -1; + goto out; + } +@@ -4459,7 +4783,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr) + snprintf (errmsg, sizeof (errmsg), "Failed to write" + " to %s", abs_filename); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + ret = -1; + goto out; + } +@@ -4475,7 +4800,7 @@ out: + if (free_contents) + GF_FREE(contents); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4530,27 +4855,28 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "slave_url", &slave_url); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch slave url."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch slave url."); + goto out; + } + + ret = dict_get_str (dict, "slave_host", &slave_host); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch slave hostname."); + goto out; + } + + ret = dict_get_str (dict, "slave_vol", &slave_vol); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch slave volume name."); + goto out; + } + + ret = dict_get_str (dict, "conf_path", &conf_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, + "Unable to fetch conf file path."); + goto out; + } +@@ -4558,7 +4884,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (dict_get_str (dict, "master", &volname) == 0) { + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Volinfo for" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_DICT_GET_FAILED, "Volinfo for" + " %s (master) not found", volname); + goto out; + } +@@ -4572,7 +4899,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (!ret) { + ret = dict_set_str (rsp_dict, "conf_path", conf_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, + "Unable to store conf_file_path."); + goto out; + } +@@ -4603,7 +4931,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = dict_set_dynstr_with_alloc (volinfo->gsync_active_slaves, + key, "running"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to set key:%s" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Unable to set key:%s" + " value:running in the dict", key); + goto out; + } +@@ -4625,8 +4954,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + &is_running); + if (!ret && !is_force && path_list && + (_gf_true != is_running)) { +- gf_log (this->name, GF_LOG_WARNING, GEOREP" is not set " +- "up for %s(master) and %s(slave)", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GSYNCD_OP_SET_FAILED, GEOREP" is not " ++ "set up for %s(master) and %s(slave)", + volname, slave); + *op_errstr = strdup (GEOREP" is not set up"); + goto out; +@@ -4638,8 +4968,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + conf_path, op_errstr, + _gf_true); + if (ret) +- gf_log(this->name, GF_LOG_ERROR, GEOREP +- " Pause Failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PAUSE_FAILED, ++ GEOREP" Pause Failed"); + else + dict_del (volinfo->gsync_active_slaves, key); + +@@ -4651,8 +4982,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + volinfo->gsync_active_slaves, + key, "running"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to set " +- "key:%s value:running in dict", key); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Unable to set " ++ "key:%s value:running in dict", key); + goto out; + } + +@@ -4661,8 +4993,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + conf_path, op_errstr, + _gf_false); + if (ret) { +- gf_log(this->name, GF_LOG_ERROR, GEOREP +- " Resume Failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_RESUME_FAILED, ++ GEOREP" Resume Failed"); + dict_del (volinfo->gsync_active_slaves, key); + } + } else { +@@ -4679,7 +5012,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + slave, slave_host, + slave_vol,"Stopped"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_UPDATE_STATEFILE_FAILED, + "Unable to update state_file. " + "Error : %s", strerror (errno)); + } +@@ -4694,7 +5028,7 @@ out: + path_list = NULL; + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4708,14 +5042,18 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, + char confpath[PATH_MAX] = ""; + glusterd_conf_t *priv = NULL; + char *slave = NULL; ++ xlator_t *this = NULL; + +- GF_ASSERT (THIS); +- priv = THIS->private; ++ this = THIS; ++ GF_ASSERT (this); ++ ++ priv = this->private; + GF_ASSERT (priv); + + ret = dict_get_str (dict, "slave", &slave); + if (ret || !slave) { +- gf_log ("", GF_LOG_ERROR, "Unable to fetch slave from dict"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "Unable to fetch slave from dict"); + ret = -1; + goto out; + } +@@ -4723,7 +5061,8 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, + ret = glusterd_get_slave_info (slave, slave_url, + slave_host, slave_vol, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_FETCH_ERROR, + "Unable to fetch slave details."); + ret = -1; + goto out; +@@ -4731,21 +5070,21 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, + + ret = dict_set_str (dict, "slave_url", *slave_url); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, + "Unable to store slave IP."); + goto out; + } + + ret = dict_set_str (dict, "slave_host", *slave_host); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, + "Unable to store slave hostname"); + goto out; + } + + ret = dict_set_str (dict, "slave_vol", *slave_vol); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, + "Unable to store slave volume name."); + goto out; + } +@@ -4757,7 +5096,7 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, + confpath[ret] = '\0'; + *conf_path = gf_strdup (confpath); + if (!(*conf_path)) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_STRDUP_FAILED, + "Unable to gf_strdup. Error: %s", strerror (errno)); + ret = -1; + goto out; +@@ -4765,13 +5104,13 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, + + ret = dict_set_str (dict, "conf_path", *conf_path); + if (ret) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, + "Unable to store conf_path"); + goto out; + } + + out: +- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + + } +@@ -4798,7 +5137,8 @@ glusterd_get_slave_info (char *slave, + "Invalid Url: %s", slave); + errmsg[ret] = '\0'; + *op_errstr = gf_strdup (errmsg); +- gf_log (this->name, GF_LOG_ERROR, "Failed to normalize url"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_NORMALIZE_URL_FAIL, ++ "Failed to normalize url"); + goto out; + } + +@@ -4808,23 +5148,26 @@ glusterd_get_slave_info (char *slave, + if (slave) { + ret = glusterd_geo_rep_parse_slave (slave, hostname, op_errstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVE_URL_INVALID, + "Invalid slave url: %s", *op_errstr); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Hostname : %s", *hostname); ++ gf_msg_debug (this->name, 0, "Hostname : %s", *hostname); + + *slave_url = gf_strdup (slave); + if (!*slave_url) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STRDUP_FAILED, + "Failed to gf_strdup"); + ret = -1; + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Slave URL : %s", *slave_url); ++ gf_msg_debug (this->name, 0, "Slave URL : %s", *slave_url); + ret = 0; + } else { +- gf_log (this->name, GF_LOG_ERROR, "Invalid slave name"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Invalid slave name"); + goto out; + } + +@@ -4832,21 +5175,23 @@ glusterd_get_slave_info (char *slave, + if (slave) { + *slave_vol = gf_strdup (slave); + if (!*slave_vol) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STRDUP_FAILED, + "Failed to gf_strdup"); + ret = -1; + GF_FREE (*slave_url); + goto out; + } +- gf_log (this->name, GF_LOG_DEBUG, "Slave Vol : %s", *slave_vol); ++ gf_msg_debug (this->name, 0, "Slave Vol : %s", *slave_vol); + ret = 0; + } else { +- gf_log (this->name, GF_LOG_ERROR, "Invalid slave name"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Invalid slave name"); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4866,6 +5211,10 @@ glusterd_check_gsync_present (int *valid_state) + runner_t runner = {0,}; + char *ptr = NULL; + int ret = 0; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); + + runinit (&runner); + runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--version", NULL); +@@ -4873,13 +5222,15 @@ glusterd_check_gsync_present (int *valid_state) + ret = runner_start (&runner); + if (ret == -1) { + if (errno == ENOENT) { +- gf_log ("glusterd", GF_LOG_INFO, GEOREP +- " module not installed in the system"); ++ gf_msg ("glusterd", GF_LOG_INFO, ENOENT, ++ GD_MSG_MODULE_NOT_INSTALLED, GEOREP" module " ++ "not installed in the system"); + *valid_state = 0; + } + else { +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP +- " module not working as desired"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_ERROR, ++ GEOREP" module not working as desired"); + *valid_state = -1; + } + goto out; +@@ -4889,15 +5240,16 @@ glusterd_check_gsync_present (int *valid_state) + if (ptr) { + if (!strstr (buff, "gsyncd")) { + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " +- "working as desired"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_MODULE_ERROR, ++ GEOREP" module not working as desired"); + *valid_state = -1; + goto out; + } + } else { + ret = -1; +- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " +- "working as desired"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, GD_MSG_MODULE_ERROR, ++ GEOREP" module not working as desired"); + *valid_state = -1; + goto out; + } +@@ -4907,7 +5259,7 @@ glusterd_check_gsync_present (int *valid_state) + + runner_end (&runner); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -5130,15 +5482,19 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, + char errmsg[PATH_MAX] = ""; + glusterd_conf_t *conf = NULL; + struct stat stbuf = {0,}; ++ xlator_t *this = NULL; + +- GF_ASSERT (THIS); +- conf = THIS->private; ++ this = THIS; ++ GF_ASSERT (this); ++ ++ conf = this->private; + + ret = dict_get_str (dict, "conf_path", &conf_path); + if (ret) { + snprintf (errmsg, sizeof (errmsg), + "Unable to fetch conf file path."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -5146,7 +5502,8 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, + if (ret) { + snprintf (errmsg, sizeof (errmsg), + "Unable to fetch statefile path."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -5158,7 +5515,8 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, + snprintf (errmsg, sizeof (errmsg), "Unable to create %s" + ". Error : %s", buf, strerror (errno)); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_DIR_OP_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -5170,28 +5528,30 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, + snprintf (errmsg, sizeof (errmsg), "Unable to create %s" + ". Error : %s", buf, strerror (errno)); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_DIR_OP_FAILED, ++ "%s", errmsg); + goto out; + } + + ret = lstat (conf_path, &stbuf); + if (!ret) { +- gf_log ("", GF_LOG_DEBUG, "Session already running." +- " Not creating config file again."); ++ gf_msg_debug (this->name, 0, "Session already running." ++ " Not creating config file again."); + } else { + ret = create_conf_file (conf, conf_path); + if (ret || lstat (conf_path, &stbuf)) { + snprintf (errmsg, sizeof (errmsg), "Failed to create" + " config file(%s).", conf_path); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + goto out; + } + } + + ret = lstat (statefile, &stbuf); + if (!ret) { +- gf_log ("", GF_LOG_DEBUG, "Session already running." +- " Not creating status file again."); ++ gf_msg_debug (this->name, 0, "Session already running." ++ " Not creating status file again."); + goto out; + } else { + ret = glusterd_create_status_file (volinfo->volname, slave, +@@ -5201,14 +5561,15 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, + snprintf (errmsg, sizeof (errmsg), "Unable to create %s" + ". Error : %s", statefile, strerror (errno)); + *op_errstr = gf_strdup (errmsg); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "%s", errmsg); + ret = -1; + goto out; + } + } + + out: +- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -5254,8 +5615,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Volinfo for %s" +- " (master) not found", volname); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VOL_NOT_FOUND, ++ "Volinfo for %s (master) not found", volname); + goto out; + } + +@@ -5263,7 +5624,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (errmsg, sizeof (errmsg), + "Unable to fetch slave volume name."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", errmsg); + goto out; + } + +@@ -5271,7 +5633,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (errmsg, sizeof (errmsg), + "Unable to fetch slave IP."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -5293,7 +5656,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + } + + if (!slave_user || !slave_ip) { +- gf_log (this->name, GF_LOG_ERROR, "Invalid slave url."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SLAVE_URL_INVALID, ++ "Invalid slave url."); + ret = -1; + goto out; + } +@@ -5302,7 +5666,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) { + snprintf (errmsg, sizeof (errmsg), + "Unable to fetch slave host"); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, ++ "%s", errmsg); + ret = -1; + goto out; + } +@@ -5313,8 +5678,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (!strcmp (uuid_str, host_uuid)) { + ret = dict_get_int32 (dict, "push_pem", &is_pem_push); + if (!ret && is_pem_push) { +- gf_log ("", GF_LOG_DEBUG, "Trying to setup" +- " pem files in slave"); ++ gf_msg_debug (this->name, 0, "Trying to setup" ++ " pem files in slave"); + is_pem_push = 1; + } else + is_pem_push = 0; +@@ -5329,8 +5694,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + arg_buf = gf_strdup (hooks_args); + if (!arg_buf) { +- gf_log ("", GF_LOG_ERROR, "Failed to" +- " gf_strdup"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_STRDUP_FAILED, ++ "Failed to gf_strdup"); + if (is_force) { + ret = 0; + goto create_essentials; +@@ -5341,8 +5706,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_set_str (dict, "hooks_args", arg_buf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Failed to set" +- " hooks_args in dict."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, ++ "Failed to set hooks_args in dict."); + if (is_force) { + ret = 0; + goto create_essentials; +@@ -5364,14 +5729,17 @@ create_essentials: + if (ret) { + snprintf (errmsg, sizeof (errmsg), "Unable to store" + " slave info."); +- gf_log ("", GF_LOG_ERROR, "%s", errmsg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SLAVEINFO_STORE_ERROR, ++ "%s", errmsg); + goto out; + } + + /* Enable marker and changelog */ + ret = glusterd_set_gsync_confs (volinfo); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, "marker/changelog" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_MARKER_START_FAIL, "marker/changelog" + " start failed"); + *op_errstr = gf_strdup ("Index initialization failed"); + ret = -1; +@@ -5380,6 +5748,6 @@ create_essentials: + + out: + GF_FREE (slave_url_buf); +- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index 16002bc..b7729fb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD +-#define GLFS_NUM_MESSAGES 458 ++#define GLFS_NUM_MESSAGES 459 + #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" +@@ -3714,6 +3714,20 @@ + */ + #define GD_MSG_BRICK_ID_GEN_FAILED (GLUSTERD_COMP_BASE + 458) + ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GET_STATUS_DATA_FAIL (GLUSTERD_COMP_BASE + 459) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + +-- +1.7.1 + diff --git a/SOURCES/0100-glusterd-Fixing-the-compilation-failures.patch b/SOURCES/0100-glusterd-Fixing-the-compilation-failures.patch new file mode 100644 index 0000000..ddbad10 --- /dev/null +++ b/SOURCES/0100-glusterd-Fixing-the-compilation-failures.patch @@ -0,0 +1,30 @@ +From 655d584243f9f4d2c0eafed03953e299f677ebbb Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 18 Jun 2015 18:05:11 +0530 +Subject: [PATCH 100/101] glusterd: Fixing the compilation failures + +BUG: 1231771 +Change-Id: I800d1655a317aba807b08c41754fe2cad20fed3a +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/51034 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 1 - + 1 files changed, 0 insertions(+), 1 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 7872314..04b539b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -2124,7 +2124,6 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + goto out; + } + if (priv->op_version < GD_OP_VERSION_3_7_0) { +- if (priv->op_version < GD_OP_VERSION_3_6_0) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNSUPPORTED_VERSION, "Disperse volume " + "needs op-version 30700 or higher"); +-- +1.7.1 + diff --git a/SOURCES/0101-cluster-afr-Do-not-attempt-entry-self-heal-if-the-la.patch b/SOURCES/0101-cluster-afr-Do-not-attempt-entry-self-heal-if-the-la.patch new file mode 100644 index 0000000..6006c55 --- /dev/null +++ b/SOURCES/0101-cluster-afr-Do-not-attempt-entry-self-heal-if-the-la.patch @@ -0,0 +1,63 @@ +From 60fd3fba546d29a038857cf23f6e6feb98593ccc Mon Sep 17 00:00:00 2001 +From: Krutika Dhananjay +Date: Mon, 8 Jun 2015 11:36:12 +0530 +Subject: [PATCH 101/101] cluster/afr: Do not attempt entry self-heal if the last lookup on entry failed on src + + Backport of: http://review.gluster.org/11119 + +Test bug-948686.t was causing shd to dump core due to gfid being NULL. +This was due to the volume being stopped while index heal's in progress, +causing afr_selfheal_unlocked_lookup_on() to fail sometimes on the src brick +with ENOTCONN. And when afr_selfheal_newentry_mark() copies the gfid off the +src iatt, it essentially copies null gfid. This was causing the assertion +as part of xattrop in protocol/client to fail. + +Change-Id: I4f7117c7a392fab6c8ac819bcf87f58ed2f28144 +BUG: 1233144 +Signed-off-by: Krutika Dhananjay +Reviewed-on: https://code.engineering.redhat.com/gerrit/51033 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/afr/src/afr-self-heal-entry.c | 11 +++++++++-- + 1 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index cb3648c..ab210b3 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -181,6 +181,13 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (!replies[source].valid) + return -EIO; + ++ /* Skip healing this entry if the last lookup on it failed for reasons ++ * other than ENOENT. ++ */ ++ if ((replies[source].op_ret < 0) && ++ (replies[source].op_errno != ENOENT)) ++ return -replies[source].op_errno; ++ + for (i = 0; i < priv->child_count; i++) { + if (!healed_sinks[i]) + continue; +@@ -188,7 +195,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, + replies[source].op_errno == ENOENT) { + ret = afr_selfheal_entry_delete (this, fd->inode, name, + inode, i, replies); +- } else { ++ } else { + if (!gf_uuid_compare (replies[i].poststat.ia_gfid, + replies[source].poststat.ia_gfid)) + continue; +@@ -196,7 +203,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, + ret = afr_selfheal_recreate_entry (this, i, source, + fd->inode, name, inode, + replies, newentry); +- } ++ } + if (ret < 0) + break; + } +-- +1.7.1 + diff --git a/SOURCES/0102-common-ha-cluster-HA-setup-sometimes-fails.patch b/SOURCES/0102-common-ha-cluster-HA-setup-sometimes-fails.patch new file mode 100644 index 0000000..47c1844 --- /dev/null +++ b/SOURCES/0102-common-ha-cluster-HA-setup-sometimes-fails.patch @@ -0,0 +1,90 @@ +From c21040a0d9a81b6337ec7849bcee6bec525fdd4c Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Wed, 17 Jun 2015 11:03:12 -0400 +Subject: [PATCH 102/129] common-ha: cluster HA setup sometimes fails + +the "s in the VIP_foo="x.x.x.x" lines are problematic now that the +config file isn't sourced. + +Revised to also handle names containing '-', e.g. host-11, and FQNs, +e.g. host-11.lab.gluster.org + +backport of +>> Change-Id: I1a52afbf398a024cdff851d0c415d8363f699c90 +>> BUG: 1232001 +>> Signed-off-by: Kaleb S. KEITHLEY +>> http://review.gluster.org/#/c/11281/ +> +> Change-Id: I108eb5f1922a0b6ee41817d901a2ae0e027e5370 +> BUG: 1232002 +> Signed-off-by: Kaleb S. KEITHLEY +> http://review.gluster.org/#/c/11282/ + +Change-Id: I40b45d79d25f8b047081c86bf6b75c07216d5165 +BUG: 1227311 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/50952 +Reviewed-by: Soumya Koduri +--- + extras/ganesha/scripts/ganesha-ha.sh | 27 ++++++++++++++++++++++----- + 1 files changed, 22 insertions(+), 5 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 7c7e9c5..fc2a009 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -343,10 +343,23 @@ setup_create_resources() + + while [[ ${1} ]]; do + ++ # this is variable indirection ++ # from a nvs like 'VIP_host1=10.7.6.5' or 'VIP_host1="10.7.6.5"' ++ # (or VIP_host-1=..., or VIP_host-1.my.domain.name=...) ++ # a variable 'clean_name' is created (e.g. w/ value 'VIP_host_1') ++ # and a clean nvs (e.g. w/ value 'VIP_host_1="10_7_6_5"') ++ # after the `eval ${clean_nvs}` there is a variable VIP_host_1 ++ # with the value '10_7_6_5', and the following \$$ magic to ++ # reference it, i.e. `eval tmp_ipaddr=\$${clean_name}` gives us ++ # ${tmp_ipaddr} with 10_7_6_5 and then convert the _s back to .s ++ # to give us ipaddr="10.7.6.5". whew! + name="VIP_${1}" ++ clean_name=${name//[-.]/_} + nvs=$(grep "^${name}=" ${HA_CONFDIR}/ganesha-ha.conf) +- eval ${nvs} +- eval ipaddr=\$$name ++ clean_nvs=${nvs//[-.]/_} ++ eval ${clean_nvs} ++ eval tmp_ipaddr=\$${clean_name} ++ ipaddr=${tmp_ipaddr//_/.} + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +@@ -440,10 +453,15 @@ recreate_resources() + local cibfile=${1}; shift + + while [[ ${1} ]]; do ++ # this is variable indirection ++ # see the comment on the same a few lines up + name="VIP_${1}" ++ clean_name=${name//[-.]/_} + nvs=$(grep "^${name}=" ${HA_CONFDIR}/ganesha-ha.conf) +- eval ${nvs} +- eval ipaddr=\$$name ++ clean_nvs=${nvs//[-.]/_} ++ eval ${clean_nvs} ++ eval tmp_ipaddr=\$${clean_name} ++ ipaddr=${tmp_ipaddr//_/.} + + pcs -f ${cibfile} resource create ${1}-cluster_ip-1 ocf:heartbeat:IPaddr ip=${ipaddr} cidr_netmask=32 op monitor interval=15s + if [ $? -ne 0 ]; then +@@ -767,7 +785,6 @@ main() + teardown_resources ${HA_SERVERS} + + teardown_cluster ${HA_NAME} +- + ;; + + cleanup | --cleanup) +-- +1.7.1 + diff --git a/SOURCES/0103-glusterd-Fix-snapshot-of-a-volume-with-geo-rep.patch b/SOURCES/0103-glusterd-Fix-snapshot-of-a-volume-with-geo-rep.patch new file mode 100644 index 0000000..88e9767 --- /dev/null +++ b/SOURCES/0103-glusterd-Fix-snapshot-of-a-volume-with-geo-rep.patch @@ -0,0 +1,143 @@ +From 66aeea6bcf367f936ca0c8ad7f1b56d239fe68f7 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Mon, 15 Jun 2015 17:20:46 +0530 +Subject: [PATCH 103/129] glusterd: Fix snapshot of a volume with geo-rep + +Problem: + Snapshot fails for a volume configured with geo-rep + if geo-rep is created with root user with the following + syntax. + gluster vol geo-rep root@:: + + It works fine if created with following syntax. + gluster vol geo-rep :: + +Cause: + Geo-rep maintains persistent dictionary of slave associated + with master volume. The dictionary saves the slave info + along with 'root@' as sent from cli. + Snapshot while constructing the working dir path to copy + configuration files, constructs using this dictionary. + But the actual working dir is created with out considering + 'root@'. Hence the issue. + +Fix: + Fix is done at two layers. + 1. Parse and negelect 'root@' in cli itself. + 2. For existing geo-rep sessions and upgrade scenarios, + parse and neglect 'root@' in snapshot code as well. + +BUG: 1230646 +Change-Id: Ibd83816a9b48de8c25a07cdd9a813d930fd01950 +Signed-off-by: Kotresh HR +Reviewed-on: http://review.gluster.org/11233 +Reviewed-on: http://review.gluster.org/11310 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51070 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + cli/src/cli-cmd-parser.c | 22 ++++++++++++++++++- + .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 17 ++++++++++++++- + 2 files changed, 36 insertions(+), 3 deletions(-) + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 917be53..a506c9b 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -2426,6 +2426,9 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) + "push-pem", "detail", "pause", + "resume", NULL }; + char *w = NULL; ++ char *save_ptr = NULL; ++ char *slave_temp = NULL; ++ char *token = NULL; + + GF_ASSERT (words); + GF_ASSERT (options); +@@ -2582,14 +2585,29 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) + ret = dict_set_str (dict, "volname", + (char *)words[masteri]); + } +- if (!ret && slavei) +- ret = dict_set_str (dict, "slave", (char *)words[slavei]); ++ if (!ret && slavei) { ++ /* If geo-rep is created with root user using the syntax ++ * gluster vol geo-rep root@ ... ++ * pass down only else pass as it is. ++ */ ++ slave_temp = gf_strdup (words[slavei]); ++ token = strtok_r (slave_temp, "@", &save_ptr); ++ if (token && !strcmp (token, "root")) { ++ ret = dict_set_str (dict, "slave", ++ (char *)words[slavei]+5); ++ } else { ++ ret = dict_set_str (dict, "slave", ++ (char *)words[slavei]); ++ } ++ } + if (!ret) + ret = dict_set_int32 (dict, "type", type); + if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG) + ret = config_parse (words, wordcount, dict, cmdi, glob); + + out: ++ if (slave_temp) ++ GF_FREE (slave_temp); + if (ret) { + if (dict) + dict_destroy (dict); +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +index 6e4b363..8e17e44 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +@@ -3245,8 +3245,11 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname, + { + int32_t ret = -1; + char *token = NULL; ++ char *tok = NULL; + char *temp = NULL; + char *ip = NULL; ++ char *ip_i = NULL; ++ char *ip_temp = NULL; + char *buffer = NULL; + xlator_t *this = NULL; + char *slave_temp = NULL; +@@ -3287,6 +3290,7 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname, + ret = -1; + goto out; + } ++ ip_i = ip; + + token = strtok_r (NULL, "\0", &save_ptr); + if (!token) { +@@ -3301,8 +3305,16 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname, + goto out; + } + ++ /* If 'ip' has 'root@slavehost', point to 'slavehost' as ++ * working directory for root users are created without ++ * 'root@' */ ++ ip_temp = gf_strdup (ip); ++ tok = strtok_r (ip_temp, "@", &save_ptr); ++ if (tok && !strcmp (tok, "root")) ++ ip_i = ip + 5; ++ + ret = snprintf (session, PATH_MAX, "%s_%s_%s", +- origin_volname, ip, slave_temp); ++ origin_volname, ip_i, slave_temp); + if (ret < 0) /* Negative value is an error */ + goto out; + +@@ -3320,6 +3332,9 @@ out: + if (ip) + GF_FREE (ip); + ++ if (ip_temp) ++ GF_FREE (ip_temp); ++ + if (slave_temp) + GF_FREE (slave_temp); + +-- +1.7.1 + diff --git a/SOURCES/0104-quota-fix-double-accounting-with-rename-operation.patch b/SOURCES/0104-quota-fix-double-accounting-with-rename-operation.patch new file mode 100644 index 0000000..71c2848 --- /dev/null +++ b/SOURCES/0104-quota-fix-double-accounting-with-rename-operation.patch @@ -0,0 +1,119 @@ +From d4565510f62bb3c5f347e1083f18b1398f6bd803 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Wed, 17 Jun 2015 10:33:13 +0530 +Subject: [PATCH 104/129] quota: fix double accounting with rename operation + +This is a backport of http://review.gluster.org/#/c/11264/ + +> When a rename operation is performed, we are renaming +> the file first and performing remove-xattr when reducing +> the contri size from parents. +> This remove-xattr fails as the file is alreday renamed, +> this failure causes reduce-parent-size to abort resulting +> in double quota accounting +> +> This patch fixes the problem. We don't need to perform remove-xattr +> operation on a file when performing reduce-parent-size txn as this +> will be alreday done before starting reduce-parent-size txn +> +> Change-Id: If86e3dbb0233f6deaaa90bee72cb0ec1689c7325 +> BUG: 1232572 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11264 +> Reviewed-by: Raghavendra G +> Tested-by: NetBSD Build System + +Change-Id: I98ce323495daa57f2911daf0bd6554e51f78217b +BUG: 1178130 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51097 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + tests/bugs/quota/bug-1178130.t | 56 ++++++++++++++++++++++++++++ + xlators/features/marker/src/marker-quota.c | 4 +- + 2 files changed, 59 insertions(+), 1 deletions(-) + create mode 100644 tests/bugs/quota/bug-1178130.t + +diff --git a/tests/bugs/quota/bug-1178130.t b/tests/bugs/quota/bug-1178130.t +new file mode 100644 +index 0000000..a1ed110 +--- /dev/null ++++ b/tests/bugs/quota/bug-1178130.t +@@ -0,0 +1,56 @@ ++#!/bin/bash ++ ++# This regression test tries to ensure renaming a directory with content, and ++# no limit set, is accounted properly, when moved into a directory with quota ++# limit set. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++function usage() ++{ ++ local QUOTA_PATH=$1; ++ $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}' ++} ++ ++QDD=$(dirname $0)/quota ++# compile the test write program and run it ++build_tester $(dirname $0)/../../basic/quota.c -o $QDD ++ ++TEST glusterd ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2}; ++TEST $CLI volume start $V0; ++ ++TEST $CLI volume quota $V0 enable; ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST $CLI volume quota $V0 limit-usage / 500MB ++TEST $CLI volume quota $V0 hard-timeout 0 ++TEST $CLI volume quota $V0 soft-timeout 0 ++ ++TEST $QDD $M0/file 256 40 ++EXPECT "10.0MB" usage "/" ++ ++TEST kill_brick $V0 $H0 $B0/${V0}2 ++TEST mv $M0/file $M0/file2 ++TEST $CLI volume start $V0 force; ++ ++#wait for self heal to complete ++EXPECT_WITHIN $HEAL_TIMEOUT "0" STAT "$B0/${V0}2/file2" ++ ++#usage should remain same after rename and self-heal operation ++EXPECT "10.0MB" usage "/" ++ ++TEST $CLI volume stop $V0 ++TEST $CLI volume delete $V0 ++EXPECT "1" get_aux ++ ++rm -f $QDD ++ ++cleanup; +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index ef70236..e183829 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2588,9 +2588,11 @@ mq_remove_contri (xlator_t *this, loc_t *loc, inode_contribution_t *contri) + + ret = syncop_removexattr (FIRST_CHILD(this), loc, contri_key, 0, NULL); + if (ret < 0) { +- if (-ret == ENOENT || -ret == ESTALE) { ++ if (-ret == ENOENT || -ret == ESTALE || -ret == ENODATA) { + /* Remove contri in done when unlink operation is + * performed, so return success on ENOENT/ESTSLE ++ * rename operation removes xattr earlier, ++ * so return success on ENODATA + */ + ret = 0; + } else { +-- +1.7.1 + diff --git a/SOURCES/0105-gluster-shared_storage-Add-Remove-shared-storage-fro.patch b/SOURCES/0105-gluster-shared_storage-Add-Remove-shared-storage-fro.patch new file mode 100644 index 0000000..1bbdda3 --- /dev/null +++ b/SOURCES/0105-gluster-shared_storage-Add-Remove-shared-storage-fro.patch @@ -0,0 +1,44 @@ +From d80f5af26ee4bcc244d40a3587904a89cf1c5bd1 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 17 Jun 2015 15:00:23 +0530 +Subject: [PATCH 105/129] gluster/shared_storage: Add/Remove shared storage from /etc/fstab during enable/disable + +While creating/deleting shared storage volume, add/remove the shared storage +entry from /etc/fstab, so as to ensure availability of the shared storage, +even after a node reboot + +>Reviewed-on: http://review.gluster.org/11272/ +Change-Id: Ib9edc8fd02c74a677062ca53ffd10be997b056c6 +BUG: 1231223 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51101 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + .../set/post/S32gluster_enable_shared_storage.sh | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +index 28fa0e5..68bc44d 100755 +--- a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh ++++ b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +@@ -80,6 +80,8 @@ done + if [ "$option" == "disable" ]; then + # Unmount the volume on all the nodes + umount /var/run/gluster/shared_storage ++ cat /etc/fstab | grep -v "gluster_shared_storage /var/run/gluster/shared_storage/" > /var/run/gluster/fstab.tmp ++ mv /var/run/gluster/fstab.tmp /etc/fstab + fi + + if [ "$is_originator" == 1 ]; then +@@ -121,4 +123,7 @@ if [ "$option" == "enable" ]; then + umount /var/run/gluster/shared_storage + mkdir -p /var/run/gluster/shared_storage + $mount_cmd ++ cp /etc/fstab /var/run/gluster/fstab.tmp ++ echo "$local_node_hostname:/gluster_shared_storage /var/run/gluster/shared_storage/ glusterfs defaults 0 0" >> /var/run/gluster/fstab.tmp ++ mv /var/run/gluster/fstab.tmp /etc/fstab + fi +-- +1.7.1 + diff --git a/SOURCES/0106-glusterd-mgmt_v3-Print-the-node-info-with-failure-me.patch b/SOURCES/0106-glusterd-mgmt_v3-Print-the-node-info-with-failure-me.patch new file mode 100644 index 0000000..5751a5f --- /dev/null +++ b/SOURCES/0106-glusterd-mgmt_v3-Print-the-node-info-with-failure-me.patch @@ -0,0 +1,46 @@ +From 61ad9dea00273f7d3c7ba893e17be04a5a29d48a Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 17 Jun 2015 14:18:32 +0530 +Subject: [PATCH 106/129] glusterd/mgmt_v3: Print the node info, with failure messages + +While reporting multiple failure messages from different +nodes, print the node ip and the failure stage. + +>Reviewed-on: http://review.gluster.org/11234/ +Change-Id: I657d3debf1b509e4a27baf9e4b580f1ee32e3c5f +BUG: 1121560 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51039 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-mgmt.c | 6 ++---- + 1 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +index f8e65ac..41e6391 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +@@ -120,17 +120,15 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, + err_string); + } + +- cli_err_str = ((is_operrstr_blk) ? op_errstr : op_err); +- + if (args->errstr) { + len = snprintf (err_str, sizeof(err_str), + "%s\n%s", args->errstr, +- cli_err_str); ++ op_err); + GF_FREE (args->errstr); + args->errstr = NULL; + } else + len = snprintf (err_str, sizeof(err_str), +- "%s", cli_err_str); ++ "%s", op_err); + + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_OP_FAIL, "%s", op_err); +-- +1.7.1 + diff --git a/SOURCES/0107-build-exclude-libgfdb.pc-conditionally.patch b/SOURCES/0107-build-exclude-libgfdb.pc-conditionally.patch new file mode 100644 index 0000000..ad167b3 --- /dev/null +++ b/SOURCES/0107-build-exclude-libgfdb.pc-conditionally.patch @@ -0,0 +1,46 @@ +From d9c849a0483f6a6aeaff848101edee2b91878f44 Mon Sep 17 00:00:00 2001 +From: Bala.FA +Date: Fri, 19 Jun 2015 11:09:53 +0530 +Subject: [PATCH 107/129] build: exclude libgfdb.pc conditionally + +This patch fixes rhel-5 build failure where libgfdb.pc is not +applicable. + +Label: DOWNSTREAM ONLY + +BUG: 1233486 +Change-Id: Ied3978aa14ff6bd72f25eff9759e501100cb6343 +Signed-off-by: Bala.FA +Reviewed-on: https://code.engineering.redhat.com/gerrit/51099 +--- + glusterfs.spec.in | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index e4d9d5f..7ee37fa 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1132,8 +1132,10 @@ fi + %if ( 0%{!?_without_tiering:1} && 0%{?_build_server}) + %{_libdir}/pkgconfig/libgfdb.pc + %else ++%if ( 0%{?rhel} && 0%{?rhel} >= 6 ) + %exclude %{_libdir}/pkgconfig/libgfdb.pc + %endif ++%endif + + %files client-xlators + %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/*.so +@@ -1928,6 +1930,9 @@ end + %endif + + %changelog ++* Fri Jun 19 2015 Bala.FA ++- exclude libgfdb.pc conditionally for rhel-5 (#1233486) ++ + * Thu Jun 18 2015 Bala.FA + - add pretrans check for client-xlators, ganesha and python-gluster + sub-packages (#1232641) +-- +1.7.1 + diff --git a/SOURCES/0108-libgfchangelog-Fix-crash-in-gf_changelog_process.patch b/SOURCES/0108-libgfchangelog-Fix-crash-in-gf_changelog_process.patch new file mode 100644 index 0000000..2c30381 --- /dev/null +++ b/SOURCES/0108-libgfchangelog-Fix-crash-in-gf_changelog_process.patch @@ -0,0 +1,90 @@ +From 9324d717d9785bc5b811beebabeb02401ed35f3e Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Wed, 17 Jun 2015 14:39:26 +0530 +Subject: [PATCH 108/129] libgfchangelog: Fix crash in gf_changelog_process + +Problem: + Crash observed in gf_changelog_process and + gf_changelog_callback_invoker. + +Cause: + Assignments to arguments passed to thread is done + post thread creation. If the thread created gets + scheduled before the assignment and access these + variables, it would crash with segmentation fault. + +Solution: + Assignments to arguments are done prior to the thread + creation. + +BUG: 1232609 +Change-Id: Ie90325f46713dcdd94c4ac715815c814ca804489 +Signed-off-by: Kotresh HR +Reviewed-on: http://review.gluster.org/11273 +Reviewed-on: http://review.gluster.org/11308 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51069 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + .../lib/src/gf-changelog-journal-handler.c | 9 ++++++--- + xlators/features/changelog/lib/src/gf-changelog.c | 13 ++++++++----- + 2 files changed, 14 insertions(+), 8 deletions(-) + +diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c +index 2975b06..f07d341 100644 +--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c ++++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c +@@ -790,13 +790,16 @@ gf_changelog_init_processor (gf_changelog_journal_t *jnl) + goto cleanup_mutex; + + INIT_LIST_HEAD (&jnl_proc->entries); ++ jnl_proc->waiting = _gf_false; ++ jnl->jnl_proc = jnl_proc; ++ + ret = pthread_create (&jnl_proc->processor, + NULL, gf_changelog_process, jnl); +- if (ret != 0) ++ if (ret != 0) { ++ jnl->jnl_proc = NULL; + goto cleanup_cond; +- jnl_proc->waiting = _gf_false; ++ } + +- jnl->jnl_proc = jnl_proc; + return 0; + + cleanup_cond: +diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c +index 82abc66..874ffd0 100644 +--- a/xlators/features/changelog/lib/src/gf-changelog.c ++++ b/xlators/features/changelog/lib/src/gf-changelog.c +@@ -292,11 +292,6 @@ gf_init_event (gf_changelog_t *entry) + + ev->next_seq = 0; /* bootstrap sequencing */ + +- ret = gf_thread_create (&ev->invoker, NULL, +- gf_changelog_callback_invoker, ev); +- if (ret != 0) +- goto cleanup_cond; +- + if (GF_NEED_ORDERED_EVENTS (entry)) { + entry->pickevent = pick_event_ordered; + entry->queueevent = queue_ordered_event; +@@ -305,6 +300,14 @@ gf_init_event (gf_changelog_t *entry) + entry->queueevent = queue_unordered_event; + } + ++ ret = gf_thread_create (&ev->invoker, NULL, ++ gf_changelog_callback_invoker, ev); ++ if (ret != 0) { ++ entry->pickevent = NULL; ++ entry->queueevent = NULL; ++ goto cleanup_cond; ++ } ++ + return 0; + + cleanup_cond: +-- +1.7.1 + diff --git a/SOURCES/0109-Porting-new-log-messages-for-posix.patch b/SOURCES/0109-Porting-new-log-messages-for-posix.patch new file mode 100644 index 0000000..995557b --- /dev/null +++ b/SOURCES/0109-Porting-new-log-messages-for-posix.patch @@ -0,0 +1,5354 @@ +From 4f5ae8f4d37677c2ee104a57c709501de467fd76 Mon Sep 17 00:00:00 2001 +From: Hari Gowtham +Date: Wed, 27 May 2015 13:17:30 +0530 +Subject: [PATCH 109/129] Porting new log messages for posix + +Change-Id: I29bdeefb755805858e3cb1817b679cb6f9a476a9 +BUG: 1231780 +Signed-off-by: Hari Gowtham +Reviewed-on: http://review.gluster.org/9893 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/50991 +Tested-by: Pranith Kumar Karampuri +--- + glusterfsd/src/glusterfsd-messages.h | 2 +- + libglusterfs/src/glfs-message-id.h | 1 + + xlators/storage/posix/src/Makefile.am | 3 +- + xlators/storage/posix/src/posix-aio.c | 76 +- + xlators/storage/posix/src/posix-handle.c | 178 +++-- + xlators/storage/posix/src/posix-handle.h | 53 +- + xlators/storage/posix/src/posix-helpers.c | 323 +++++---- + xlators/storage/posix/src/posix-messages.h | 899 ++++++++++++++++++++ + xlators/storage/posix/src/posix.c | 1228 ++++++++++++++-------------- + 9 files changed, 1872 insertions(+), 891 deletions(-) + create mode 100644 xlators/storage/posix/src/posix-messages.h + +diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h +index ba3b7a5..1e1d170 100644 +--- a/glusterfsd/src/glusterfsd-messages.h ++++ b/glusterfsd/src/glusterfsd-messages.h +@@ -41,7 +41,7 @@ + */ + + #define GLFS_COMP_BASE GLFS_MSGID_COMP_GLUSTERFSD +-#define GLFS_NUM_MESSAGES 33 ++#define GLFS_NUM_MESSAGES 34 + #define GLFS_MSGID_END (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index e28327d..df7caa2 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -65,6 +65,7 @@ + #define GLFS_MSGID_COMP_DHT_END GLFS_MSGID_COMP_DHT +\ + GLFS_MSGID_SEGMENT + ++ + /* there is no component called 'common', however reserving this segment + * for common actions/errors like dict_{get/set}, memory accounting*/ + +diff --git a/xlators/storage/posix/src/Makefile.am b/xlators/storage/posix/src/Makefile.am +index 509b052..9dd89e7 100644 +--- a/xlators/storage/posix/src/Makefile.am ++++ b/xlators/storage/posix/src/Makefile.am +@@ -8,7 +8,8 @@ posix_la_SOURCES = posix.c posix-helpers.c posix-handle.c posix-aio.c + posix_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(LIBAIO) \ + $(ACL_LIBS) + +-noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h posix-aio.h ++noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h posix-aio.h \ ++ posix-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(top_srcdir)/rpc/xdr/src \ +diff --git a/xlators/storage/posix/src/posix-aio.c b/xlators/storage/posix/src/posix-aio.c +index c3bbddd..3d4d2f6 100644 +--- a/xlators/storage/posix/src/posix-aio.c ++++ b/xlators/storage/posix/src/posix-aio.c +@@ -16,6 +16,7 @@ + #include "glusterfs.h" + #include "posix.h" + #include ++#include "posix-messages.h" + + #ifdef HAVE_LIBAIO + #include +@@ -55,9 +56,9 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags, + } + + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, +- "fcntl() failed (%s). fd=%d flags=%d pfd->odirect=%d", +- strerror (errno), pfd->fd, flags, pfd->odirect); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, P_MSG_FCNTL_FAILED, ++ "fcntl() failed. fd=%d flags=%d pfd->odirect=%d", ++ pfd->fd, flags, pfd->odirect); + } + } + +@@ -101,11 +102,11 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2) + if (res < 0) { + op_ret = -1; + op_errno = -res; +- gf_log (this->name, GF_LOG_ERROR, +- "readv(async) failed fd=%d,size=%lu,offset=%llu (%d/%s)", ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_READV_FAILED, ++ "readv(async) failed fd=%d,size=%lu,offset=%llu (%d)", + _fd, paiocb->iocb.u.c.nbytes, + (unsigned long long) paiocb->offset, +- res, strerror (op_errno)); ++ res); + goto out; + } + +@@ -113,9 +114,8 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2) + if (ret != 0) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fstat failed on fd=%d: %s", _fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED, ++ "fstat failed on fd=%d", _fd); + goto out; + } + +@@ -182,7 +182,7 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto err; + } +@@ -190,7 +190,8 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + + if (!size) { + op_errno = EINVAL; +- gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size); ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ P_MSG_INVALID_ARGUMENT, "size=%"GF_PRI_SIZET, size); + goto err; + } + +@@ -232,9 +233,10 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + UNLOCK (&fd->lock); + + if (ret != 1) { +- gf_log (this->name, GF_LOG_ERROR, +- "io_submit() returned %d", ret); + op_errno = -ret; ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_IO_SUBMIT_FAILED, ++ "io_submit() returned %d", ret); + goto err; + } + +@@ -274,10 +276,10 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2) + if (res < 0) { + op_ret = -1; + op_errno = -res; +- gf_log (this->name, GF_LOG_ERROR, +- "writev(async) failed fd=%d,offset=%llu (%d/%s)", +- _fd, (unsigned long long) paiocb->offset, res, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_WRITEV_FAILED, ++ "writev(async) failed fd=%d,offset=%llu (%d)", ++ _fd, (unsigned long long) paiocb->offset, res); + + goto out; + } +@@ -286,9 +288,8 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2) + if (ret != 0) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fstat failed on fd=%d: %s", _fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED, ++ "fstat failed on fd=%d", _fd); + goto out; + } + +@@ -339,7 +340,7 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto err; + } +@@ -371,9 +372,8 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + ret = posix_fdstat (this, _fd, &paiocb->prebuf); + if (ret != 0) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED, ++ "fstat failed on fd=%p", fd); + goto err; + } + +@@ -388,9 +388,11 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + UNLOCK (&fd->lock); + + if (ret != 1) { +- gf_log (this->name, GF_LOG_ERROR, +- "io_submit() returned %d", ret); + op_errno = -ret; ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_IO_SUBMIT_FAILED, ++ "io_submit() returned %d,gfid=%s", ret, ++ uuid_utoa(fd->inode->gfid)); + goto err; + } + +@@ -428,7 +430,8 @@ posix_aio_thread (void *data) + ret = io_getevents (priv->ctxp, 1, POSIX_AIO_MAX_NR_GETEVENTS, + &events[0], NULL); + if (ret <= 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ P_MSG_IO_GETEVENTS_FAILED, + "io_getevents() returned %d", ret); + if (ret == -EINTR) + continue; +@@ -450,7 +453,8 @@ posix_aio_thread (void *data) + event->res2); + break; + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_UNKNOWN_OP, + "unknown op %d found in piocb", + paiocb->op); + break; +@@ -472,7 +476,7 @@ posix_aio_init (xlator_t *this) + + ret = io_setup (POSIX_AIO_MAX_NR_EVENTS, &priv->ctxp); + if ((ret == -1 && errno == ENOSYS) || ret == -ENOSYS) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_AIO_UNAVAILABLE, + "Linux AIO not available at run-time." + " Continuing with synchronous IO"); + ret = 0; +@@ -480,9 +484,10 @@ posix_aio_init (xlator_t *this) + } + + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "io_setup() failed. ret=%d, errno=%d", +- ret, errno); ++ gf_msg (this->name, GF_LOG_WARNING, -ret, ++ P_MSG_IO_SETUP_FAILED, ++ "io_setup() failed. ret=%d", ++ ret); + goto out; + } + +@@ -541,7 +546,7 @@ posix_aio_off (xlator_t *this) + int + posix_aio_on (xlator_t *this) + { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE, + "Linux AIO not available at build-time." + " Continuing with synchronous IO"); + return 0; +@@ -550,7 +555,7 @@ posix_aio_on (xlator_t *this) + int + posix_aio_off (xlator_t *this) + { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE, + "Linux AIO not available at build-time." + " Continuing with synchronous IO"); + return 0; +@@ -561,9 +566,10 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags, + off_t offset, size_t size) + { + xlator_t *this = THIS; +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE, + "Linux AIO not available at build-time." + " Continuing with synchronous IO"); + return; + } ++ + #endif +diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c +index 6182fd8..281d52f 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; + } +diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h +index e0b5b67..356b7b9 100644 +--- a/xlators/storage/posix/src/posix-handle.h ++++ b/xlators/storage/posix/src/posix-handle.h +@@ -19,6 +19,7 @@ + #include + #include "xlator.h" + #include "gf-dirent.h" ++#include "posix-messages.h" + + /* From Open Group Base Specifications Issue 6 */ + #ifndef _XOPEN_PATH_MAX +@@ -50,9 +51,9 @@ + flags); \ + if (op_ret == -1) { \ + op_errno = errno; \ +- gf_log (this->name, GF_LOG_WARNING, \ +- "setting xattr failed on %s: key = %s (%s)", \ +- path, key, strerror (op_errno)); \ ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_PGFID_OP, \ ++ "setting xattr failed on %s: key = %s ", \ ++ path, key); \ + goto label; \ + } \ + } while (0) +@@ -67,9 +68,10 @@ + SET_PGFID_XATTR (path, key, value, flags, \ + op_ret, this, label); \ + } else { \ +- gf_log(this->name, GF_LOG_WARNING, "getting " \ +- "xattr failed on %s: key = %s (%s)", \ +- path, key, strerror (op_errno)); \ ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, \ ++ P_MSG_PGFID_OP, "getting xattr " \ ++ "failed on %s: key = %s ", \ ++ path, key); \ + } \ + } \ + } while (0) +@@ -78,9 +80,10 @@ + op_ret = sys_lremovexattr (path, key); \ + if (op_ret == -1) { \ + op_errno = errno; \ +- gf_log (this->name, GF_LOG_WARNING, "removing xattr " \ +- "failed on %s: key = %s (%s)", path, key, \ +- strerror (op_errno)); \ ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, \ ++ P_MSG_PGFID_OP, \ ++ "removing xattr failed" \ ++ "on %s: key = %s", path, key); \ + goto label; \ + } \ + } while (0) +@@ -93,9 +96,9 @@ + if (op_errno == ENOATTR || op_errno == ENODATA) { \ + value = 1; \ + } else { \ +- gf_log (this->name, GF_LOG_WARNING,"getting xattr " \ +- "failed on %s: key = %s (%s)", path, key, \ +- strerror (op_errno)); \ ++ gf_msg (this->name, GF_LOG_WARNING, errno, \ ++ P_MSG_PGFID_OP, "getting xattr " \ ++ "failed on %s: key = %s ", path, key); \ + goto label; \ + } \ + } else { \ +@@ -110,8 +113,9 @@ + op_ret = sys_lgetxattr (path, key, &value, sizeof (value)); \ + if (op_ret == -1) { \ + op_errno = errno; \ +- gf_log (this->name, GF_LOG_WARNING, "getting xattr failed on " \ +- "%s: key = %s (%s)", path, key, strerror (op_errno)); \ ++ gf_msg (this->name, GF_LOG_WARNING, errno, \ ++ P_MSG_PGFID_OP, "getting xattr failed on " \ ++ "%s: key = %s ", path, key); \ + goto label; \ + } else { \ + value = ntoh32 (value); \ +@@ -182,7 +186,8 @@ + + #define MAKE_INODE_HANDLE(rpath, this, loc, iatt_p) do { \ + if (gf_uuid_is_null (loc->gfid)) { \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ P_MSG_INODE_HANDLE_CREATE, \ + "null gfid for path %s", (loc)->path); \ + break; \ + } \ +@@ -194,12 +199,13 @@ + errno = 0; \ + op_ret = posix_istat (this, loc->gfid, NULL, iatt_p); \ + if (errno != ELOOP) { \ +- MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL); \ ++ MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL); \ + if (!rpath) { \ + op_ret = -1; \ +- gf_log (this->name, GF_LOG_ERROR, \ +- "Failed to create inode handle " \ +- "for path %s", (loc)->path); \ ++ gf_msg (this->name, GF_LOG_ERROR, errno, \ ++ P_MSG_INODE_HANDLE_CREATE, \ ++ "Failed to create inode handle " \ ++ "for path %s", (loc)->path); \ + } \ + break; \ + } \ +@@ -211,7 +217,7 @@ + char *__parp; \ + \ + if (gf_uuid_is_null (loc->pargfid) || !loc->name) { \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ENTRY_HANDLE_CREATE,\ + "null pargfid/name for path %s", loc->path); \ + break; \ + } \ +@@ -229,9 +235,10 @@ + MAKE_HANDLE_PATH (parp, this, loc->pargfid, NULL); \ + MAKE_HANDLE_PATH (entp, this, loc->pargfid, loc->name); \ + if (!parp || !entp) { \ +- gf_log (this->name, GF_LOG_ERROR, \ +- "Failed to create entry handle " \ +- "for path %s", loc->path); \ ++ gf_msg (this->name, GF_LOG_ERROR, errno, \ ++ P_MSG_ENTRY_HANDLE_CREATE, \ ++ "Failed to create entry handle " \ ++ "for path %s", loc->path); \ + } \ + break; \ + } \ +diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c +index 9018a73..e2c5eb2 100644 +--- a/xlators/storage/posix/src/posix-helpers.c ++++ b/xlators/storage/posix/src/posix-helpers.c +@@ -143,11 +143,13 @@ _posix_xattr_get_set_from_backend (posix_xattr_filler_t *filler, char *key) + xattr_size); + if (xattr_size == -1) { + if (filler->real_path) +- gf_log (filler->this->name, GF_LOG_WARNING, ++ gf_msg (filler->this->name, GF_LOG_WARNING, 0, ++ P_MSG_XATTR_FAILED, + "getxattr failed. path: %s, key: %s", + filler->real_path, key); + else +- gf_log (filler->this->name, GF_LOG_WARNING, ++ gf_msg (filler->this->name, GF_LOG_WARNING, 0, ++ P_MSG_XATTR_FAILED, + "getxattr failed. gfid: %s, key: %s", + uuid_utoa (filler->fd->inode->gfid), + key); +@@ -159,11 +161,11 @@ _posix_xattr_get_set_from_backend (posix_xattr_filler_t *filler, char *key) + ret = dict_set_bin (filler->xattr, key, value, xattr_size); + if (ret < 0) { + if (filler->real_path) +- gf_log (filler->this->name, GF_LOG_DEBUG, ++ gf_msg_debug (filler->this->name, 0, + "dict set failed. path: %s, key: %s", + filler->real_path, key); + else +- gf_log (filler->this->name, GF_LOG_DEBUG, ++ gf_msg_debug (filler->this->name, 0, + "dict set failed. gfid: %s, key: %s", + uuid_utoa (filler->fd->inode->gfid), + key); +@@ -198,14 +200,15 @@ _posix_get_marker_all_contributions (posix_xattr_filler_t *filler) + " with 'user_xattr' flag)"); + } else { + if (filler->real_path) +- gf_log (THIS->name, GF_LOG_WARNING, +- "listxattr failed on %s: %s", +- filler->real_path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ P_MSG_XATTR_FAILED, ++ "listxattr failed on %s", ++ filler->real_path); + else +- gf_log (THIS->name, GF_LOG_WARNING, +- "listxattr failed on %s: %s", +- uuid_utoa (filler->fd->inode->gfid), +- strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ P_MSG_XATTR_FAILED, ++ "listxattr failed on %s", ++ uuid_utoa (filler->fd->inode->gfid)); + } + goto out; + } +@@ -295,7 +298,8 @@ _posix_filler_get_openfd_count (posix_xattr_filler_t *filler, char *key) + + ret = dict_set_uint32 (filler->xattr, key, inode->fd_count); + if (ret < 0) { +- gf_log (filler->this->name, GF_LOG_WARNING, ++ gf_msg (filler->this->name, GF_LOG_WARNING, 0, ++ P_MSG_DICT_SET_FAILED, + "Failed to set dictionary value for %s", key); + goto out; + } +@@ -328,9 +332,10 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, + if (req_size >= filler->stbuf->ia_size) { + _fd = open (filler->real_path, O_RDONLY); + if (_fd == -1) { +- gf_log (filler->this->name, GF_LOG_ERROR, +- "Opening file %s failed: %s", +- filler->real_path, strerror (errno)); ++ gf_msg (filler->this->name, GF_LOG_ERROR, errno, ++ P_MSG_XDATA_GETXATTR, ++ "Opening file %s failed", ++ filler->real_path); + goto err; + } + +@@ -352,26 +357,30 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, + + ret = read (_fd, databuf, filler->stbuf->ia_size); + if (ret == -1) { +- gf_log (filler->this->name, GF_LOG_ERROR, +- "Read on file %s failed: %s", +- filler->real_path, strerror (errno)); ++ gf_msg (filler->this->name, GF_LOG_ERROR, errno, ++ P_MSG_XDATA_GETXATTR, ++ "Read on file %s failed", ++ filler->real_path); + goto err; + } + + ret = close (_fd); + _fd = -1; + if (ret == -1) { +- gf_log (filler->this->name, GF_LOG_ERROR, +- "Close on file %s failed: %s", +- filler->real_path, strerror (errno)); ++ gf_msg (filler->this->name, GF_LOG_ERROR, errno, ++ P_MSG_XDATA_GETXATTR, ++ "Close on file %s failed", ++ filler->real_path); + goto err; + } + + ret = dict_set_bin (filler->xattr, key, + databuf, filler->stbuf->ia_size); + if (ret < 0) { +- gf_log (filler->this->name, GF_LOG_ERROR, +- "failed to set dict value. key: %s, path: %s", ++ gf_msg (filler->this->name, GF_LOG_ERROR, 0, ++ P_MSG_XDATA_GETXATTR, ++ "failed to set dict value. key: %s," ++ "path: %s", + key, filler->real_path); + goto err; + } +@@ -385,6 +394,16 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, + } + } else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) { + ret = _posix_filler_get_openfd_count (filler, key); ++ loc = filler->loc; ++ if (loc) { ++ ret = dict_set_uint32 (filler->xattr, key, ++ loc->inode->fd_count); ++ if (ret < 0) ++ gf_msg (filler->this->name, GF_LOG_WARNING, 0, ++ P_MSG_XDATA_GETXATTR, ++ "Failed to set dictionary value for %s", ++ key); ++ } + } else if (!strcmp (key, GET_ANCESTRY_PATH_KEY)) { + /* As of now, the only consumers of POSIX_ANCESTRY_PATH attempt + * fetching it via path-based fops. Hence, leaving it as it is +@@ -524,7 +543,8 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename, + + MAKE_HANDLE_PATH (real_path, this, gfid, basename); + if (!real_path) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ESTALE, ++ P_MSG_HANDLE_PATH_CREATE, + "Failed to create handle path for %s/%s", + uuid_utoa (gfid), basename ? basename : ""); + errno = ESTALE; +@@ -537,16 +557,17 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename, + if (ret != 0) { + if (ret == -1) { + if (errno != ENOENT && errno != ELOOP) +- gf_log (this->name, GF_LOG_WARNING, +- "lstat failed on %s (%s)", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_LSTAT_FAILED, ++ "lstat failed on %s", ++ real_path); + } else { + // may be some backend filesystem issue +- gf_log (this->name, GF_LOG_ERROR, "lstat failed on " +- "%s and return value is %d instead of -1. " +- "Please see dmesg output to check whether the " +- "failure is due to backend filesystem issue", +- real_path, ret); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LSTAT_FAILED, ++ "lstat failed on %s and return value is %d " ++ "instead of -1. Please see dmesg output to " ++ "check whether the failure is due to backend " ++ "filesystem issue", real_path, ret); + ret = -1; + } + goto out; +@@ -595,16 +616,17 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path, + if (ret != 0) { + if (ret == -1) { + if (errno != ENOENT) +- gf_log (this->name, GF_LOG_WARNING, +- "lstat failed on %s (%s)", +- path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_LSTAT_FAILED, ++ "lstat failed on %s", ++ path); + } else { + // may be some backend filesytem issue +- gf_log (this->name, GF_LOG_ERROR, "lstat failed on " +- "%s and return value is %d instead of -1. " +- "Please see dmesg output to check whether the " +- "failure is due to backend filesystem issue", +- path, ret); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LSTAT_FAILED, ++ "lstat failed on %s and return value is %d " ++ "instead of -1. Please see dmesg output to " ++ "check whether the failure is due to backend " ++ "filesystem issue", path, ret); + ret = -1; + } + goto out; +@@ -768,7 +790,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) + + ret = dict_get_ptr (xattr_req, "gfid-req", &uuid_req); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "failed to get the gfid from dict for %s", + loc->path); + goto out; +@@ -776,9 +798,8 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) + + ret = sys_lsetxattr (path, GFID_XATTR_KEY, uuid_req, 16, XATTR_CREATE); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "setting GFID on %s failed (%s)", path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_GFID_FAILED, ++ "setting GFID on %s failed ", path); + goto out; + } + gf_uuid_copy (uuid_curr, uuid_req); +@@ -824,19 +845,20 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp, + ret = write (file_fd, value->data, value->len); + if (ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "write failed while doing setxattr " +- "for key %s on path %s: %s", +- key, real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_SET_FILE_CONTENTS, "write failed" ++ "while doing setxattr for key %s on" ++ "path%s", key, real_path); + goto out; + } + + ret = close (file_fd); + if (ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "close failed on %s: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_SET_FILE_CONTENTS, ++ "close failed on %s", ++ real_path); + goto out; + } + } +@@ -847,29 +869,28 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp, + + if (file_fd == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "failed to open file %s with O_CREAT: %s", +- key, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_SET_FILE_CONTENTS, "failed to open file" ++ "%s with O_CREAT", key); + goto out; + } + + ret = write (file_fd, value->data, value->len); + if (ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "write failed on %s while setxattr with " +- "key %s: %s", +- real_path, key, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_SET_FILE_CONTENTS, "write failed on %s" ++ "while setxattr with key %s", real_path, key); + goto out; + } + + ret = close (file_fd); + if (ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "close failed on %s while setxattr with " +- "key %s: %s", +- real_path, key, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_SET_FILE_CONTENTS, "close failed on" ++ " %s while setxattr with key %s", ++ real_path, key); + goto out; + } + } +@@ -893,7 +914,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid, + MAKE_HANDLE_PATH (real_path, this, pargfid, name); + if (!real_path) { + op_ret = -ESTALE; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ESTALE, ++ P_MSG_XDATA_GETXATTR, + "Failed to create handle path for %s/%s", + uuid_utoa (pargfid), name); + goto out; +@@ -902,8 +924,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid, + op_ret = posix_istat (this, pargfid, name, &stbuf); + if (op_ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, "lstat failed on %s: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, ++ "lstat failed on %s", real_path); + goto out; + } + +@@ -911,8 +933,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid, + + if (file_fd == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, "open failed on %s: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, ++ "open failed on %s", real_path); + goto out; + } + +@@ -926,8 +948,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid, + ret = read (file_fd, *contents, stbuf.ia_size); + if (ret <= 0) { + op_ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "read on %s failed: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, ++ "read on %s failed", real_path); + goto out; + } + +@@ -937,8 +959,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid, + file_fd = -1; + if (op_ret == -1) { + op_ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, "close on %s failed: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, ++ "close on %s failed", real_path); + goto out; + } + +@@ -1039,7 +1061,7 @@ void posix_dump_buffer (xlator_t *this, const char *real_path, const char *key, + for (index = 0; index < value->len; index++) + sprintf(buffer+3*index, " %02x", data[index]); + } +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Dump %s: key:%s flags: %u length:%u data:%s ", + real_path, key, flags, value->len, + (log_level == GF_LOG_TRACE ? buffer : "")); +@@ -1072,24 +1094,33 @@ posix_handle_pair (xlator_t *this, const char *real_path, + if (errno == ENOENT) { + if (!posix_special_xattr (marker_xattrs, + key)) { +- gf_log (this->name, GF_LOG_ERROR, +- "setxattr on %s failed: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, ++ "setxattr on %s failed", ++ real_path); + } + } else { + + #ifdef GF_DARWIN_HOST_OS +- gf_log (this->name, +- ((errno == EINVAL) ? +- GF_LOG_DEBUG : GF_LOG_ERROR), +- "%s: key:%s flags: %u length:%d error:%s", +- real_path, key, flags, value->len, +- strerror (errno)); ++ if (errno == EINVAL) { ++ gf_msg_debug (this->name, 0, "%s: key:" ++ "%s flags: %u length:%d " ++ "error:%s", real_path, ++ key, flags, value->len, ++ strerror (errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, ++ errno, P_MSG_XATTR_FAILED, ++ "%s: key:%s flags: " ++ "%u length:%d", ++ real_path, key, flags, ++ value->len); ++ + #else /* ! DARWIN */ +- gf_log (this->name, GF_LOG_ERROR, +- "%s: key:%s flags: %u length:%d error:%s", +- real_path, key, flags, value->len, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "%s: key:%s" ++ "flags: %u length:%d", real_path, ++ key, flags, value->len); + #endif /* DARWIN */ + } + +@@ -1118,21 +1149,26 @@ posix_fhandle_pair (xlator_t *this, int fd, + if (sys_ret < 0) { + ret = -errno; + if (errno == ENOENT) { +- gf_log (this->name, GF_LOG_ERROR, +- "fsetxattr on fd=%d failed: %s", fd, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fsetxattr on fd=%d" ++ " failed", fd); + } else { + + #ifdef GF_DARWIN_HOST_OS +- gf_log (this->name, +- ((errno == EINVAL) ? +- GF_LOG_DEBUG : GF_LOG_ERROR), +- "fd=%d: key:%s error:%s", +- fd, key, strerror (errno)); ++ if (errno == EINVAL) { ++ gf_msg_debug (this->name, 0, "fd=%d: key:%s " ++ "error:%s", fd, key, ++ strerror (errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fd=%d: key:%s", ++ fd, key); ++ } ++ + #else /* ! DARWIN */ +- gf_log (this->name, GF_LOG_ERROR, +- "fd=%d: key:%s error:%s", +- fd, key, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fd=%d: key:%s", ++ fd, key); + #endif /* DARWIN */ + } + +@@ -1159,14 +1195,14 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid) + /* check that it is valid directory handle */ + size = sys_lstat (hpath, &stbuf); + if (size < 0) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Handle stat failed: " ++ gf_msg_debug (this->name, 0, "%s: Handle stat failed: " + "%s", hpath, strerror (errno)); + goto out; + } + + iatt_from_stat (&iabuf, &stbuf); + if (iabuf.ia_nlink != 1 || !IA_ISLNK (iabuf.ia_type)) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Handle nlink %d %d", ++ gf_msg_debug (this->name, 0, "%s: Handle nlink %d %d", + hpath, iabuf.ia_nlink, IA_ISLNK (iabuf.ia_type)); + goto out; + } +@@ -1174,7 +1210,7 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid) + size = posix_handle_path (this, gfid, NULL, newpath, sizeof (newpath)); + if (size <= 0) { + if (errno == ENOENT) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: %s", newpath, ++ gf_msg_debug (this->name, 0, "%s: %s", newpath, + strerror (ENOENT)); + stale = _gf_true; + } +@@ -1183,12 +1219,12 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid) + + size = sys_lgetxattr (newpath, GFID_XATTR_KEY, gfid_curr, 16); + if (size < 0 && errno == ENOENT) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: %s", newpath, ++ gf_msg_debug (this->name, 0, "%s: %s", newpath, + strerror (ENOENT)); + stale = _gf_true; + } else if (size == 16 && gf_uuid_compare (gfid, gfid_curr)) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: mismatching gfid: %s, " +- "at %s", hpath, uuid_utoa (gfid_curr), newpath); ++ gf_msg_debug (this->name, 0, "%s: mismatching gfid: %s, " ++ "at %s", hpath, uuid_utoa (gfid_curr), newpath); + stale = _gf_true; + } + +@@ -1196,11 +1232,11 @@ out: + if (stale) { + size = sys_unlink (hpath); + if (size < 0 && errno != ENOENT) +- gf_log (this->name, GF_LOG_ERROR, "%s: Failed to " +- "remove handle to %s (%s)", hpath, newpath, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_STALE_HANDLE_REMOVE_FAILED, "%s: Failed" ++ "to remove handle to %s", hpath, newpath); + } else if (size == 16) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Fresh handle for " ++ gf_msg_debug (this->name, 0, "%s: Fresh handle for " + "%s with gfid %s", hpath, newpath, + uuid_utoa (gfid_curr)); + } +@@ -1223,7 +1259,7 @@ janitor_walker (const char *fpath, const struct stat *sb, + case S_IFCHR: + case S_IFIFO: + case S_IFSOCK: +- gf_log (THIS->name, GF_LOG_TRACE, ++ gf_msg_trace (THIS->name, 0, + "unlinking %s", fpath); + unlink (fpath); + if (stbuf.ia_nlink == 1) +@@ -1232,7 +1268,7 @@ janitor_walker (const char *fpath, const struct stat *sb, + + case S_IFDIR: + if (ftwbuf->level) { /* don't remove top level dir */ +- gf_log (THIS->name, GF_LOG_TRACE, ++ gf_msg_debug (THIS->name, 0, + "removing directory %s", fpath); + + rmdir (fpath); +@@ -1297,8 +1333,9 @@ posix_janitor_thread_proc (void *data) + while (1) { + time (&now); + if ((now - priv->last_landfill_check) > priv->janitor_sleep_duration) { +- gf_log (this->name, GF_LOG_TRACE, +- "janitor cleaning out %s", priv->trash_path); ++ gf_msg_trace (this->name, 0, ++ "janitor cleaning out %s", ++ priv->trash_path); + + nftw (priv->trash_path, + janitor_walker, +@@ -1311,12 +1348,12 @@ posix_janitor_thread_proc (void *data) + pfd = janitor_get_next_fd (this); + if (pfd) { + if (pfd->dir == NULL) { +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "janitor: closing file fd=%d", pfd->fd); + close (pfd->fd); + } else { +- gf_log (this->name, GF_LOG_TRACE, +- "janitor: closing dir fd=%p", pfd->dir); ++ gf_msg_debug (this->name, 0, "janitor: closing" ++ " dir fd=%p", pfd->dir); + closedir (pfd->dir); + } + +@@ -1343,9 +1380,9 @@ posix_spawn_janitor_thread (xlator_t *this) + posix_janitor_thread_proc, this); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "spawning janitor thread failed: %s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_THREAD_FAILED, "spawning janitor " ++ "thread failed"); + goto unlock; + } + +@@ -1537,7 +1574,8 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p) + + MAKE_HANDLE_PATH (real_path, this, fd->inode->gfid, NULL); + if (!real_path) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_HANDLE_PATH_CREATE_FAILED, + "Failed to create handle path (%s)", + uuid_utoa (fd->inode->gfid)); + ret = -1; +@@ -1633,16 +1671,16 @@ posix_fs_health_check (xlator_t *this) + + fd = open (file_path, O_CREAT|O_RDWR, 0644); + if (fd == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "open() on %s returned: %s", file_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_HEALTHCHECK_FAILED, ++ "open() on %s returned", file_path); + goto out; + } + nofbytes = write (fd, timestamp, timelen); + if (nofbytes != timelen) { +- gf_log (this->name, GF_LOG_WARNING, +- "write() on %s returned: %s", file_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_HEALTHCHECK_FAILED, ++ "write() on %s returned", file_path); + goto out; + } + /* Seek the offset to the beginning of the file, so that the offset for +@@ -1650,9 +1688,9 @@ posix_fs_health_check (xlator_t *this) + lseek(fd, 0, SEEK_SET); + nofbytes = read (fd, buff, timelen); + if (nofbytes == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "read() on %s returned: %s", file_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_HEALTHCHECK_FAILED, ++ "read() on %s returned", file_path); + goto out; + } + ret = 0; +@@ -1680,7 +1718,7 @@ posix_health_check_thread_proc (void *data) + if (interval == 0) + goto out; + +- gf_log (this->name, GF_LOG_DEBUG, "health-check thread started, " ++ gf_msg_debug (this->name, 0, "health-check thread started, " + "interval = %d seconds", interval); + + while (1) { +@@ -1697,9 +1735,10 @@ posix_health_check_thread_proc (void *data) + ret = posix_fs_health_check (this); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "health_check on %s returned: %s", +- priv->base_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_HEALTHCHECK_FAILED, ++ "health_check on %s returned", ++ priv->base_path); + goto abort; + } + +@@ -1707,7 +1746,7 @@ posix_health_check_thread_proc (void *data) + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "health-check thread exiting"); ++ gf_msg_debug (this->name, 0, "health-check thread exiting"); + + LOCK (&priv->lock); + { +@@ -1719,18 +1758,21 @@ out: + + abort: + /* health-check failed */ +- gf_log (this->name, GF_LOG_EMERG, "health-check failed, going down"); ++ 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); + if (ret == 0) { +- gf_log (this->name, GF_LOG_EMERG, "still alive! -> SIGTERM"); ++ gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED, ++ "still alive! -> SIGTERM"); + kill (getpid(), SIGTERM); + } + + ret = sleep (30); + if (ret == 0) { +- gf_log (this->name, GF_LOG_EMERG, "still alive! -> SIGKILL"); ++ gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED, ++ "still alive! -> SIGKILL"); + kill (getpid(), SIGKILL); + } + +@@ -1762,9 +1804,9 @@ posix_spawn_health_check_thread (xlator_t *xl) + if (ret < 0) { + priv->health_check_interval = 0; + priv->health_check_active = _gf_false; +- gf_log (xl->name, GF_LOG_ERROR, +- "unable to setup health-check thread: %s", +- strerror (errno)); ++ gf_msg (xl->name, GF_LOG_ERROR, errno, ++ P_MSG_HEALTHCHECK_FAILED, ++ "unable to setup health-check thread"); + goto unlock; + } + +@@ -1810,7 +1852,8 @@ posix_fsyncer_process (xlator_t *this, call_stub_t *stub, gf_boolean_t do_fsync) + + ret = posix_fd_ctx_get (stub->args.fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_GET_FDCTX_FAILED, + "could not get fdctx for fd(%s)", + uuid_utoa (stub->args.fd->inode->gfid)); + call_unwind_error (stub, -1, EINVAL); +@@ -1827,7 +1870,7 @@ posix_fsyncer_process (xlator_t *this, call_stub_t *stub, gf_boolean_t do_fsync) + } + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "could not fstat fd(%s)", + uuid_utoa (stub->args.fd->inode->gfid)); + call_unwind_error (stub, -1, errno); +@@ -1887,7 +1930,7 @@ posix_fsyncer (void *d) + + usleep (priv->batch_fsync_delay_usec); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "picked %d fsyncs", count); + + switch (priv->batch_fsync_mode) { +diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h +new file mode 100644 +index 0000000..9916aed +--- /dev/null ++++ b/xlators/storage/posix/src/posix-messages.h +@@ -0,0 +1,899 @@ ++/* ++ Copyright (c) 2014 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _POSIX_MESSAGES_H_ ++#define _POSIX_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/*! \file posix-messages.h ++ * \brief Psix log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define POSIX_COMP_BASE GLFS_MSGID_COMP_POSIX ++#define GLFS_NUM_MESSAGES 104 ++#define GLFS_MSGID_END (POSIX_COMP_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x POSIX_COMP_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++/*! ++ * @messageid 106001 ++ * @diagnosis Operation could not be performed because the server quorum was not ++ * met ++ * @recommendedaction Ensure that other peer nodes are online and reachable from ++ * the local peer node ++ */ ++ ++#define P_MSG_XATTR_FAILED (POSIX_COMP_BASE + 1) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_NULL_GFID (POSIX_COMP_BASE + 2) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ ++#define P_MSG_FCNTL_FAILED (POSIX_COMP_BASE + 3) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_READV_FAILED (POSIX_COMP_BASE + 4) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FSTAT_FAILED (POSIX_COMP_BASE + 5) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_PFD_NULL (POSIX_COMP_BASE + 6) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INVALID_ARGUMENT (POSIX_COMP_BASE + 7) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_IO_SUBMIT_FAILED (POSIX_COMP_BASE + 8) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_WRITEV_FAILED (POSIX_COMP_BASE + 9) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_IO_GETEVENTS_FAILED (POSIX_COMP_BASE + 10) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_UNKNOWN_OP (POSIX_COMP_BASE + 11) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_AIO_UNAVAILABLE (POSIX_COMP_BASE + 12) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_IO_SETUP_FAILED (POSIX_COMP_BASE + 13) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_ZEROFILL_FAILED (POSIX_COMP_BASE + 14) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_OPENDIR_FAILED (POSIX_COMP_BASE + 15) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DIRFD_FAILED (POSIX_COMP_BASE + 16) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FD_PATH_SETTING_FAILED (POSIX_COMP_BASE + 17) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_LSTAT_FAILED (POSIX_COMP_BASE + 18) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_READYLINK_FAILED (POSIX_COMP_BASE + 19) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GFID_FAILED (POSIX_COMP_BASE + 20) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_CREATE_FAILED (POSIX_COMP_BASE + 21) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_MKNOD_FAILED (POSIX_COMP_BASE + 22) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_LCHOWN_FAILED (POSIX_COMP_BASE + 23) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_ACL_FAILED (POSIX_COMP_BASE + 24) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_MKDIR_NOT_PERMITTED (POSIX_COMP_BASE + 25) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DIR_OF_SAME_ID (POSIX_COMP_BASE + 26) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_MKDIR_FAILED (POSIX_COMP_BASE + 27) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_CHOWN_FAILED (POSIX_COMP_BASE + 28) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_UNLINK_FAILED (POSIX_COMP_BASE + 29) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_KEY_STATUS_INFO (POSIX_COMP_BASE + 30) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_XATTR_STATUS (POSIX_COMP_BASE + 31) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_RMDIR_NOT_PERMITTED (POSIX_COMP_BASE + 32) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_RMDIR_FAILED (POSIX_COMP_BASE + 33) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DIR_OPERATION_FAILED (POSIX_COMP_BASE + 34) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SYMLINK_FAILED (POSIX_COMP_BASE + 35) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DIR_FOUND (POSIX_COMP_BASE + 36) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_LINK_FAILED (POSIX_COMP_BASE + 37) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_TRUNCATE_FAILED (POSIX_COMP_BASE + 38) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FILE_OP_FAILED (POSIX_COMP_BASE + 39) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_READ_FAILED (POSIX_COMP_BASE + 40) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DICT_SET_FAILED (POSIX_COMP_BASE + 41) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_STATVFS_FAILED (POSIX_COMP_BASE + 42) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DIR_NOT_NULL (POSIX_COMP_BASE + 43) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FSYNC_FAILED (POSIX_COMP_BASE + 44) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_CLOSE_FAILED (POSIX_COMP_BASE + 45) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GETTING_FILENAME_FAILED (POSIX_COMP_BASE + 46) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INODE_PATH_GET_FAILED (POSIX_COMP_BASE + 47) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GET_KEY_VALUE_FAILED (POSIX_COMP_BASE + 48) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_CHMOD_FAILED (POSIX_COMP_BASE + 49) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FCHMOD_FAILED (POSIX_COMP_BASE + 50) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FCHOWN_FAILED (POSIX_COMP_BASE + 51) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_UTIMES_FAILED (POSIX_COMP_BASE + 52) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FUTIMES_FAILED (POSIX_COMP_BASE + 53) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_XATTR_NOT_REMOVED (POSIX_COMP_BASE + 54) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_PFD_GET_FAILED (POSIX_COMP_BASE + 55) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_ACCESS_FAILED (POSIX_COMP_BASE + 56) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_PREAD_FAILED (POSIX_COMP_BASE + 57) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_UUID_NULL (POSIX_COMP_BASE + 58) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_EXPORT_DIR_MISSING (POSIX_COMP_BASE + 59) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SUBVOLUME_ERROR (POSIX_COMP_BASE + 60) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_VOLUME_DANGLING (POSIX_COMP_BASE + 61) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INVALID_OPTION (POSIX_COMP_BASE + 62) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INVALID_VOLUME_ID (POSIX_COMP_BASE + 63) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_VOLUME_ID_ABSENT (POSIX_COMP_BASE + 64) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HOSTNAME_MISSING (POSIX_COMP_BASE + 65) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SET_ULIMIT_FAILED (POSIX_COMP_BASE + 66) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SET_FILE_MAX_FAILED (POSIX_COMP_BASE + 67) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_MAX_FILE_OPEN (POSIX_COMP_BASE + 68) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ ++#define P_MSG_OPEN_FAILED (POSIX_COMP_BASE + 69) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_LOOKUP_NOT_PERMITTED (POSIX_COMP_BASE + 70) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_RENAME_FAILED (POSIX_COMP_BASE + 71) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_WRITE_FAILED (POSIX_COMP_BASE + 72) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FILE_FAILED (POSIX_COMP_BASE + 73) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_THREAD_FAILED (POSIX_COMP_BASE + 74) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HEALTHCHECK_FAILED (POSIX_COMP_BASE + 75) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GET_FDCTX_FAILED (POSIX_COMP_BASE + 76) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLEPATH_FAILED (POSIX_COMP_BASE + 77) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_IPC_NOT_HANDLE (POSIX_COMP_BASE + 78) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SET_XDATA_FAIL (POSIX_COMP_BASE + 79) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_DURABILITY_REQ_NOT_SATISFIED (POSIX_COMP_BASE + 80) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_XATTR_NOTSUP (POSIX_COMP_BASE + 81) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GFID_SET_FAILED (POSIX_COMP_BASE + 82) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_ACL_NOTSUP (POSIX_COMP_BASE + 83) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_BASEPATH_CHDIR_FAILED (POSIX_COMP_BASE + 84) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INVALID_OPTION_VAL (POSIX_COMP_BASE + 85) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INVALID_NODE_UUID (POSIX_COMP_BASE + 86) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_FSYNCER_THREAD_CREATE_FAILED (POSIX_COMP_BASE + 87) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_GF_DIRENT_CREATE_FAILED (POSIX_COMP_BASE + 88) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_VOLUME_ID_FETCH_FAILED (POSIX_COMP_BASE + 89) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_UNKNOWN_ARGUMENT (POSIX_COMP_BASE + 90) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_INODE_HANDLE_CREATE (POSIX_COMP_BASE + 91) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_ENTRY_HANDLE_CREATE (POSIX_COMP_BASE + 92) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_PGFID_OP (POSIX_COMP_BASE + 93) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_POSIX_AIO (POSIX_COMP_BASE + 94) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_CREATE_TRASH (POSIX_COMP_BASE + 95) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_CREATE (POSIX_COMP_BASE + 96) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_PATH_CREATE (POSIX_COMP_BASE + 97) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_SET_FILE_CONTENTS (POSIX_COMP_BASE + 98) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_XDATA_GETXATTR (POSIX_COMP_BASE + 99) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_STALE_HANDLE_REMOVE_FAILED (POSIX_COMP_BASE + 100) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_PATH_CREATE_FAILED (POSIX_COMP_BASE + 101) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_TRASH_CREATE (POSIX_COMP_BASE + 102) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_HANDLE_DELETE (POSIX_COMP_BASE + 103) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define P_MSG_READLINK_FAILED (POSIX_COMP_BASE + 104) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_GLUSTERD_MESSAGES_H_ */ +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 2a1df28..a2e484e 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -53,6 +53,7 @@ + #include "hashfn.h" + #include "posix-aio.h" + #include "glusterfs-acl.h" ++#include "posix-messages.h" + + extern char *marker_xattrs[]; + #define ALIGN_SIZE 4096 +@@ -118,9 +119,9 @@ posix_lookup (call_frame_t *frame, xlator_t *this, + should not get any gfid on it */ + if (__is_root_gfid (loc->pargfid) && loc->name + && (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { +- gf_log (this->name, GF_LOG_WARNING, +- "Lookup issued on %s, which is not permitted", +- GF_HIDDEN_PATH); ++ gf_msg (this->name, GF_LOG_WARNING, EPERM, ++ P_MSG_LOOKUP_NOT_PERMITTED, "Lookup issued on %s," ++ " which is not permitted", GF_HIDDEN_PATH); + op_errno = EPERM; + op_ret = -1; + goto out; +@@ -145,10 +146,10 @@ posix_lookup (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + if (op_errno != ENOENT) { +- gf_log (this->name, GF_LOG_ERROR, +- "lstat on %s failed: %s", +- real_path ? real_path : "null", +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", ++ real_path ? real_path : "null"); + } + + entry_ret = -1; +@@ -184,9 +185,9 @@ parent: + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_LSTAT_FAILED, "post-operation lstat on" ++ " parent %s failed", par_path); + if (op_errno == ENOENT) + /* If parent directory is missing in a lookup, + errno should be ESTALE (bad handle) and not +@@ -200,7 +201,8 @@ parent: + op_ret = entry_ret; + out: + if (!op_ret && !gfidless && gf_uuid_is_null (buf.ia_gfid)) { +- gf_log (this->name, GF_LOG_ERROR, "buf->ia_gfid is null for " ++ gf_msg (this->name, GF_LOG_ERROR, ENODATA, P_MSG_NULL_GFID, ++ "buf->ia_gfid is null for " + "%s", (real_path) ? real_path: ""); + op_ret = -1; + op_errno = ENODATA; +@@ -240,11 +242,15 @@ posix_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, (op_errno == ENOENT)? +- GF_LOG_DEBUG:GF_LOG_ERROR, +- "lstat on %s failed: %s", +- real_path ? real_path : "", +- strerror (op_errno)); ++ if (op_errno == ENOENT) { ++ gf_msg_debug(this->name, 0, "lstat on %s failed: %s", ++ real_path ? real_path : "", ++ strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_LSTAT_FAILED, "lstat on %s failed", ++ real_path ? real_path : ""); ++ } + goto out; + } + if (xdata) +@@ -272,8 +278,8 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf) + + ret = sys_lstat (path, &stat); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "lstat failed: %s (%s)", path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_LSTAT_FAILED, ++ "lstat failed: %s", path); + goto out; + } + +@@ -286,8 +292,7 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf) + /* in Linux symlinks are always in mode 0777 and no + such call as lchmod exists. + */ +- gf_log (this->name, GF_LOG_DEBUG, +- "%s (%s)", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "%s (%s)", path, strerror (errno)); + if (is_symlink) { + ret = 0; + goto out; +@@ -332,8 +337,8 @@ posix_do_utimes (xlator_t *this, + + ret = sys_lstat (path, &stat); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "%s (%s)", path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_FILE_OP_FAILED, "%s", path); + goto out; + } + +@@ -347,8 +352,8 @@ posix_do_utimes (xlator_t *this, + + ret = lutimes (path, tv); + if ((ret == -1) && (errno == ENOSYS)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "%s (%s)", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "%s (%s)", ++ path, strerror (errno)); + if (is_symlink) { + ret = 0; + goto out; +@@ -382,9 +387,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "setattr (lstat) on %s failed: %s", +- real_path ? real_path : "", strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "setattr (lstat) on %s failed", ++ real_path ? real_path : ""); + goto out; + } + +@@ -392,9 +397,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_chown (this, real_path, stbuf, valid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "setattr (chown) on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_CHOWN_FAILED, "setattr (chown) on %s " ++ "failed", real_path); + goto out; + } + } +@@ -403,9 +408,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_chmod (this, real_path, stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "setattr (chmod) on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_CHMOD_FAILED, "setattr (chmod) on %s " ++ "failed", real_path); + goto out; + } + } +@@ -414,9 +419,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_utimes (this, real_path, stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "setattr (utimes) on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_UTIMES_FAILED, "setattr (utimes) on %s " ++ "failed", real_path); + goto out; + } + } +@@ -425,9 +430,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + op_ret = lchown (real_path, -1, -1); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lchown (%s, -1, -1) failed => (%s)", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_LCHOWN_FAILED, "lchown (%s, -1, -1) " ++ "failed", real_path); + + goto out; + } +@@ -436,9 +441,8 @@ posix_setattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->gfid, real_path, &statpost); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "setattr (lstat) on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "setattr (lstat) on %s failed", real_path); + goto out; + } + +@@ -490,7 +494,8 @@ posix_do_futimes (xlator_t *this, + int fd, + struct iatt *stbuf) + { +- gf_log (this->name, GF_LOG_WARNING, "function not implemented fd(%d)", fd); ++ gf_msg (this->name, GF_LOG_WARNING, ENOSYS, P_MSG_UNKNOWN_OP, ++ "function not implemented fd(%d)", fd); + + errno = ENOSYS; + return -1; +@@ -518,17 +523,15 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_DEBUG, +- "pfd is NULL from fd=%p", fd); ++ gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); + goto out; + } + + op_ret = posix_fdstat (this, pfd->fd, &statpre); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsetattr (fstat) failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fsetattr (fstat) failed on fd=%p", fd); + goto out; + } + +@@ -536,9 +539,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_fchown (this, pfd->fd, stbuf, valid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsetattr (fchown) failed on fd=%p: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FCHOWN_FAILED, "fsetattr (fchown) failed" ++ " on fd=%p", fd); + goto out; + } + +@@ -548,9 +551,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_fchmod (this, pfd->fd, stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsetattr (fchmod) failed on fd=%p: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FCHMOD_FAILED, "fsetattr (fchmod) failed" ++ " on fd=%p", fd); + goto out; + } + } +@@ -559,9 +562,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_do_futimes (this, pfd->fd, stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsetattr (futimes) on failed fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FUTIMES_FAILED, "fsetattr (futimes) on " ++ "failed fd=%p", fd); + goto out; + } + } +@@ -570,9 +573,10 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + op_ret = fchown (pfd->fd, -1, -1); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fchown (%d, -1, -1) failed => (%s)", +- pfd->fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FCHOWN_FAILED, ++ "fchown (%d, -1, -1) failed", ++ pfd->fd); + + goto out; + } +@@ -581,9 +585,8 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, pfd->fd, &statpost); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsetattr (fstat) failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fsetattr (fstat) failed on fd=%p", fd); + goto out; + } + +@@ -616,17 +619,15 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "pfd is NULL from fd=%p", fd); ++ gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); + goto out; + } + + ret = posix_fdstat (this, pfd->fd, statpre); + if (ret == -1) { + ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fallocate (fstat) failed on fd=%p: %s", fd, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fallocate (fstat) failed on fd=%p", fd); + goto out; + } + +@@ -639,9 +640,8 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, + ret = posix_fdstat (this, pfd->fd, statpost); + if (ret == -1) { + ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fallocate (fstat) failed on fd=%p: %s", fd, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fallocate (fstat) failed on fd=%p", fd); + goto out; + } + +@@ -701,9 +701,6 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct) + if (o_direct) { + alloc_buf = _page_aligned_alloc(vect_size, &iov_base); + if (!alloc_buf) { +- gf_log ("_posix_do_zerofill", GF_LOG_DEBUG, +- "memory alloc failed, vect_size %d: %s", +- vect_size, strerror(errno)); + GF_FREE(vector); + return -1; + } +@@ -768,33 +765,31 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "pfd is NULL from fd=%p", fd); ++ gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); + goto out; + } + + ret = posix_fdstat (this, pfd->fd, statpre); + if (ret == -1) { + ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation fstat failed on fd = %p: %s", fd, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "pre-operation fstat failed on fd = %p", fd); + goto out; + } + ret = _posix_do_zerofill(pfd->fd, offset, len, pfd->flags & O_DIRECT); + if (ret < 0) { + ret = -errno; +- gf_log(this->name, GF_LOG_ERROR, +- "zerofill failed on fd %d length %" PRId64 " %s", +- pfd->fd, len, strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ZEROFILL_FAILED, ++ "zerofill failed on fd %d length %" PRId64 , ++ pfd->fd, len); + goto out; + } + if (pfd->flags & (O_SYNC|O_DSYNC)) { + ret = fsync (pfd->fd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "fsync() in writev on fd %d failed: %s", +- pfd->fd, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_WRITEV_FAILED, "fsync() in writev on fd" ++ "%d failed", pfd->fd); + ret = -errno; + goto out; + } +@@ -803,9 +798,8 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, + ret = posix_fdstat (this, pfd->fd, statpost); + if (ret == -1) { + ret = -errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post operation fstat failed on fd=%p: %s", fd, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "post operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -899,7 +893,8 @@ posix_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) + * means somebody sent one that nobody else recognized, which is an + * error much like an uncaught exception. + */ +- gf_log (this->name, GF_LOG_ERROR, "GF_LOG_IPC(%d) not handled", op); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_IPC_NOT_HANDLE, ++ "GF_LOG_IPC(%d) not handled", op); + STACK_UNWIND_STRICT (ipc, frame, -1, -EOPNOTSUPP, NULL); + return 0; + +@@ -934,18 +929,16 @@ posix_opendir (call_frame_t *frame, xlator_t *this, + + if (dir == NULL) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "opendir failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPENDIR_FAILED, ++ "opendir failed on %s", real_path); + goto out; + } + + op_ret = dirfd (dir); + if (op_ret < 0) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "dirfd() failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_DIRFD_FAILED, ++ "dirfd() failed on %s", real_path); + goto out; + } + +@@ -961,9 +954,9 @@ posix_opendir (call_frame_t *frame, xlator_t *this, + + op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); + if (op_ret) +- gf_log (this->name, GF_LOG_WARNING, +- "failed to set the fd context path=%s fd=%p", +- real_path, fd); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_FD_PATH_SETTING_FAILED, "failed to set the fd" ++ "context path=%s fd=%p", real_path, fd); + + op_ret = 0; + +@@ -999,14 +992,13 @@ posix_releasedir (xlator_t *this, + + ret = fd_ctx_del (fd, this, &tmp_pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "pfd from fd=%p is NULL", fd); ++ gf_msg_debug (this->name, 0, "pfd from fd=%p is NULL", fd); + goto out; + } + + pfd = (struct posix_fd *)(long)tmp_pfd; + if (!pfd->dir) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL, + "pfd->dir is NULL for fd=%p", fd); + goto out; + } +@@ -1047,19 +1039,17 @@ posix_readlink (call_frame_t *frame, xlator_t *this, + MAKE_INODE_HANDLE (real_path, this, loc, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lstat on %s failed: %s", +- loc->path ? loc->path : "", +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", ++ loc->path ? loc->path : ""); + goto out; + } + + op_ret = sys_readlink (real_path, dest, size); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "readlink on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READYLINK_FAILED, ++ "readlink on %s failed", real_path); + goto out; + } + +@@ -1118,9 +1108,9 @@ posix_mknod (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent of %s failed: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent of %s failed", ++ real_path); + goto out; + } + +@@ -1135,9 +1125,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this, + dict_del (xdata, GLUSTERFS_INTERNAL_FOP_KEY); + op_ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); + if (op_ret) { +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to get the gfid from dict for %s", +- loc->path); ++ gf_msg_debug (this->name, 0, "failed to get the gfid from " ++ "dict for %s", loc->path); + goto real_op; + } + op_ret = posix_create_link_if_gfid_exists (this, uuid_req, +@@ -1163,17 +1152,17 @@ real_op: + doesn't work */ + tmp_fd = creat (real_path, mode); + if (tmp_fd == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "create failed on %s: %s", +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_CREATE_FAILED, "create failed on" ++ "%s", real_path); + goto out; + } + close (tmp_fd); + } else { + +- gf_log (this->name, GF_LOG_ERROR, +- "mknod on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_MKNOD_FAILED, ++ "mknod on %s failed", real_path); + goto out; + } + } +@@ -1184,9 +1173,8 @@ real_op: + op_ret = lchown (real_path, frame->root->uid, gid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lchown on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, ++ "lchown on %s failed", real_path); + goto out; + } + #endif +@@ -1194,9 +1182,8 @@ real_op: + post_op: + op_ret = posix_acl_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting ACLs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ACL_FAILED, ++ "setting ACLs on %s failed", real_path); + } + + if (priv->update_pgfid_nlinks) { +@@ -1211,15 +1198,14 @@ post_op: + ignore: + op_ret = posix_entry_create_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting xattrs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_XATTR_FAILED, ++ "setting xattrs on %s failed", real_path); + } + + if (!linked) { + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; +@@ -1229,18 +1215,17 @@ ignore: + op_ret = posix_pstat (this, NULL, real_path, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "mknod on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKNOD_FAILED, ++ "mknod on %s failed", real_path); + goto out; + } + + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1295,9 +1280,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + should not get created from a user request */ + if (__is_root_gfid (loc->pargfid) && + (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { +- gf_log (this->name, GF_LOG_WARNING, +- "mkdir issued on %s, which is not permitted", +- GF_HIDDEN_PATH); ++ gf_msg (this->name, GF_LOG_WARNING, EPERM, ++ P_MSG_MKDIR_NOT_PERMITTED, "mkdir issued on %s, which" ++ "is not permitted", GF_HIDDEN_PATH); + op_errno = EPERM; + op_ret = -1; + goto out; +@@ -1332,11 +1317,11 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + posix_handle_path (this, uuid_req, NULL, + gfid_path, size); + +- gf_log (this->name, GF_LOG_WARNING, +- "mkdir (%s): gfid (%s) is already associated " +- "with directory (%s). Hence, both directories " +- "will share same gfid and this can lead to " +- "inconsistencies.", loc->path, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_DIR_OF_SAME_ID, "mkdir (%s): gfid (%s) is" ++ "already associated with directory (%s). Hence," ++ "both directories will share same gfid and this" ++ "can lead to inconsistencies.", loc->path, + uuid_utoa (uuid_req), gfid_path ? gfid_path + : ""); + } +@@ -1345,9 +1330,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1359,9 +1344,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + op_ret = mkdir (real_path, mode); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "mkdir of %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKDIR_FAILED, ++ "mkdir of %s failed", real_path); + goto out; + } + +@@ -1371,29 +1355,26 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + op_ret = chown (real_path, frame->root->uid, gid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "chown on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, ++ "chown on %s failed", real_path); + goto out; + } + #endif + op_ret = posix_acl_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting ACLs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, ++ "setting ACLs on %s failed ", real_path); + } + + op_ret = posix_entry_create_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting xattrs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, ++ "setting xattrs on %s failed", real_path); + } + + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; +@@ -1402,18 +1383,17 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, NULL, real_path, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lstat on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", real_path); + goto out; + } + + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent of %s failed: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent of %s failed", ++ real_path); + goto out; + } + +@@ -1448,10 +1428,10 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path, + if (stbuf && stbuf->ia_nlink == 1) { + ret = posix_handle_unset (this, stbuf->ia_gfid, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "unlink of gfid handle failed for path:%s with" +- " gfid %s with errno:%s", real_path, +- uuid_utoa (stbuf->ia_gfid), strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_UNLINK_FAILED, "unlink of gfid handle " ++ "failed for path:%s with gfid %s", ++ real_path, uuid_utoa (stbuf->ia_gfid)); + } + } + +@@ -1461,9 +1441,8 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path, + if (op_errno) + *op_errno = errno; + +- gf_log (this->name, GF_LOG_ERROR, +- "unlink of %s failed: %s", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_UNLINK_FAILED, ++ "unlink of %s failed", real_path); + goto err; + } + +@@ -1513,9 +1492,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1534,8 +1513,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + + UNLOCK (&loc->inode->lock); + +- gf_log (this->name, GF_LOG_INFO, "open-fd-key-status: " +- "%"PRIu32" for %s", skip_unlink, real_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_KEY_STATUS_INFO, ++ "open-fd-key-status: %"PRIu32" for %s", skip_unlink, ++ real_path); + + if (skip_unlink) { + op_ret = -1; +@@ -1564,8 +1544,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + + UNLOCK (&loc->inode->lock); + +- gf_log (this->name, GF_LOG_INFO, "linkto_xattr status: " +- "%"PRIu32" for %s", skip_unlink, real_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_XATTR_STATUS, ++ "linkto_xattr status: %"PRIu32" for %s", skip_unlink, ++ real_path); + + if (skip_unlink) { + op_ret = -1; +@@ -1581,9 +1562,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + if (fd == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "open of %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_OPEN_FAILED, ++ "open of %s failed", real_path); + goto out; + } + } +@@ -1602,7 +1583,8 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + UNLOCK (&loc->inode->lock); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "modification of " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_XATTR_FAILED, "modification of " + "parent gfid xattr failed (path:%s gfid:%s)", + real_path, uuid_utoa (loc->inode->gfid)); + if (op_errno != ENOATTR) +@@ -1620,9 +1602,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1651,9 +1633,6 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + * all records if link count == 0*/ + if (!unwind_dict) { + op_ret = 0; +- gf_log (this->name, GF_LOG_WARNING, +- "Memory allocation failure while " +- "creating unwind_dict"); + goto out; + } + /* Even if unwind_dict fails to set CTR_RESPONSE_LINK_COUNT_XDATA we +@@ -1663,7 +1642,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this, + op_ret = dict_set_uint32 (unwind_dict, CTR_RESPONSE_LINK_COUNT_XDATA, + stbuf.ia_nlink); + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_SET_XDATA_FAIL, + "Failed to set CTR_RESPONSE_LINK_COUNT_XDATA"); + } + +@@ -1714,9 +1693,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, + should not get deleted from inside process */ + if (__is_root_gfid (loc->pargfid) && + (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { +- gf_log (this->name, GF_LOG_WARNING, +- "rmdir issued on %s, which is not permitted", +- GF_HIDDEN_PATH); ++ gf_msg (this->name, GF_LOG_WARNING, EPERM, ++ P_MSG_RMDIR_NOT_PERMITTED, "rmdir issued on %s, which" ++ "is not permitted", GF_HIDDEN_PATH); + op_errno = EPERM; + op_ret = -1; + goto out; +@@ -1734,9 +1713,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1748,9 +1727,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, + + op_ret = mkdir (priv->trash_path, 0755); + if (errno != EEXIST && op_ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "mkdir of %s failed: %s", priv->trash_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_MKDIR_FAILED, ++ "mkdir of %s failed", priv->trash_path); + } else { + sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str); + op_ret = rename (real_path, tmp_path); +@@ -1770,25 +1749,28 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, + + /* No need to log a common error as ENOTEMPTY */ + if (op_ret == -1 && op_errno != ENOTEMPTY) { +- gf_log (this->name, GF_LOG_ERROR, +- "rmdir of %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_RMDIR_FAILED, ++ "rmdir of %s failed", real_path); + } + + if (op_ret == -1) { +- gf_log (this->name, +- (op_errno == ENOTEMPTY) ? GF_LOG_DEBUG : GF_LOG_ERROR, +- "%s on %s failed", (flags) ? "rename" : "rmdir", +- real_path); ++ if (op_errno == ENOTEMPTY) { ++ gf_msg_debug (this->name, 0, "%s on %s failed", (flags) ++ ? "rename" : "rmdir", real_path); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_DIR_OPERATION_FAILED, "%s on %s failed", ++ (flags) ? "rename" : "rmdir", real_path); ++ } + goto out; + } + + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent of %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent of %s failed", ++ par_path); + goto out; + } + +@@ -1843,9 +1825,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1857,9 +1839,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "symlink of %s --> %s failed: %s", +- real_path, linkname, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_SYMLINK_FAILED, ++ "symlink of %s --> %s failed", ++ real_path, linkname); + goto out; + } + +@@ -1869,17 +1851,15 @@ posix_symlink (call_frame_t *frame, xlator_t *this, + op_ret = lchown (real_path, frame->root->uid, gid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lchown failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, ++ "lchown failed on %s", real_path); + goto out; + } + #endif + op_ret = posix_acl_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting ACLs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, ++ "setting ACLs on %s failed", real_path); + } + + if (priv->update_pgfid_nlinks) { +@@ -1892,14 +1872,13 @@ posix_symlink (call_frame_t *frame, xlator_t *this, + ignore: + op_ret = posix_entry_create_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting xattrs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, ++ "setting xattrs on %s failed ", real_path); + } + + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; +@@ -1908,18 +1887,17 @@ ignore: + op_ret = posix_pstat (this, NULL, real_path, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lstat failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat failed on %s", real_path); + goto out; + } + + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -1997,18 +1975,18 @@ posix_rename (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &preoldparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_oldpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_oldpath); + goto out; + } + + op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &prenewparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent of %s failed: %s", +- par_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent of %s failed", ++ par_newpath); + goto out; + } + +@@ -2023,7 +2001,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, + } + + if (was_present && IA_ISDIR(stbuf.ia_type) && !newloc->inode) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND, + "found directory at %s while expecting ENOENT", + real_newpath); + op_ret = -1; +@@ -2033,7 +2011,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, + + if (was_present && IA_ISDIR(stbuf.ia_type) && + gf_uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND, + "found directory %s at %s while renaming %s", + uuid_utoa_r (newloc->inode->gfid, olddirid), + real_newpath, +@@ -2063,12 +2041,17 @@ posix_rename (call_frame_t *frame, xlator_t *this, + op_ret = sys_rename (real_oldpath, real_newpath); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, +- (op_errno == ENOTEMPTY ? GF_LOG_DEBUG +- : GF_LOG_ERROR), +- "rename of %s to %s failed: %s", +- real_oldpath, real_newpath, +- strerror (op_errno)); ++ if (op_errno == ENOTEMPTY) { ++ gf_msg_debug (this->name, 0, "rename of %s to" ++ " %s failed: %s", real_oldpath, ++ real_newpath, ++ strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_RENAME_FAILED, ++ "rename of %s to %s failed", ++ real_oldpath, real_newpath); ++ } + + if (priv->update_pgfid_nlinks + && !IA_ISDIR (oldloc->inode->ia_type)) { +@@ -2098,7 +2081,8 @@ unlock: + UNLOCK (&oldloc->inode->lock); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "modification of " ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_FAILED, ++ "modification of " + "parent gfid xattr failed (gfid:%s)", + uuid_utoa (oldloc->inode->gfid)); + goto out; +@@ -2118,27 +2102,26 @@ unlock: + op_ret = posix_pstat (this, NULL, real_newpath, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lstat on %s failed: %s", +- real_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", real_newpath); + goto out; + } + + op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &postoldparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_oldpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_oldpath); + goto out; + } + + op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postnewparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_newpath); + goto out; + } + +@@ -2200,8 +2183,8 @@ posix_link (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s", +- par_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat failed: %s", par_newpath); + goto out; + } + +@@ -2210,9 +2193,9 @@ posix_link (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "link %s to %s failed: %s", +- real_oldpath, real_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LINK_FAILED, ++ "link %s to %s failed", ++ real_oldpath, real_newpath); + goto out; + } + +@@ -2221,17 +2204,16 @@ posix_link (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, NULL, real_newpath, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "lstat on %s failed: %s", +- real_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", real_newpath); + goto out; + } + + op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s", +- par_newpath, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat failed: %s", par_newpath); + goto out; + } + +@@ -2249,7 +2231,8 @@ posix_link (call_frame_t *frame, xlator_t *this, + UNLOCK (&newloc->inode->lock); + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "modification of " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_XATTR_FAILED, "modification of " + "parent gfid xattr failed (path:%s gfid:%s)", + real_newpath, uuid_utoa (newloc->inode->gfid)); + goto out; +@@ -2299,26 +2282,25 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + MAKE_INODE_HANDLE (real_path, this, loc, &prebuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on %s failed: %s", +- real_path ? real_path : "", strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on %s failed", ++ real_path ? real_path : ""); + goto out; + } + + op_ret = truncate (real_path, offset); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "truncate on %s failed: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED, ++ "truncate on %s failed", real_path); + goto out; + } + + op_ret = posix_pstat (this, loc->gfid, real_path, &postbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "lstat on %s failed: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "lstat on %s failed", real_path); + goto out; + } + +@@ -2382,9 +2364,9 @@ posix_create (call_frame_t *frame, xlator_t *this, + op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "pre-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -2412,9 +2394,8 @@ posix_create (call_frame_t *frame, xlator_t *this, + if (_fd == -1) { + op_errno = errno; + op_ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "open on %s failed: %s", real_path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPEN_FAILED, ++ "open on %s failed", real_path); + goto out; + } + +@@ -2430,16 +2411,14 @@ posix_create (call_frame_t *frame, xlator_t *this, + op_ret = chown (real_path, frame->root->uid, gid); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "chown on %s failed: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, ++ "chown on %s failed", real_path); + } + #endif + op_ret = posix_acl_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting ACLs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, ++ "setting ACLs on %s failed", real_path); + } + + if (priv->update_pgfid_nlinks) { +@@ -2452,15 +2431,14 @@ posix_create (call_frame_t *frame, xlator_t *this, + ignore: + op_ret = posix_entry_create_xattr_set (this, real_path, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "setting xattrs on %s failed (%s)", real_path, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, ++ "setting xattrs on %s failed ", real_path); + } + + fill_stat: + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; +@@ -2469,17 +2447,17 @@ fill_stat: + op_ret = posix_fdstat (this, _fd, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fstat on %d failed: %s", _fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fstat on %d failed", _fd); + goto out; + } + + op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation lstat on parent %s failed: %s", +- par_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, ++ "post-operation lstat on parent %s failed", ++ par_path); + goto out; + } + +@@ -2495,7 +2473,8 @@ fill_stat: + + op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); + if (op_ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_FD_PATH_SETTING_FAILED, + "failed to set the fd context path=%s fd=%p", + real_path, fd); + +@@ -2575,8 +2554,8 @@ posix_open (call_frame_t *frame, xlator_t *this, + if (_fd == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "open on %s, flags: %d: %s", +- real_path, flags, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FILE_OP_FAILED, ++ "open on %s, flags: %d", real_path, flags); + goto out; + } + +@@ -2591,7 +2570,8 @@ posix_open (call_frame_t *frame, xlator_t *this, + + op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); + if (op_ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_FD_PATH_SETTING_FAILED, + "failed to set the fd context path=%s fd=%p", + real_path, fd); + +@@ -2643,14 +2623,15 @@ posix_readv (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto out; + } + + if (!size) { + op_errno = EINVAL; +- gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ P_MSG_INVALID_ARGUMENT, "size=%"GF_PRI_SIZET, size); + goto out; + } + +@@ -2664,9 +2645,8 @@ posix_readv (call_frame_t *frame, xlator_t *this, + op_ret = pread (_fd, iobuf->ptr, size, offset); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "read failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READ_FAILED, ++ "read failed on fd=%p", fd); + goto out; + } + +@@ -2691,9 +2671,8 @@ posix_readv (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, _fd, &stbuf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fstat failed on fd=%p", fd); + goto out; + } + +@@ -2818,16 +2797,17 @@ _fill_writev_xdata (fd_t *fd, dict_t *xdata, xlator_t *this, int is_append) + ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_OPEN_FD_COUNT, + fd->inode->fd_count); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set " +- "dictionary value for %s", uuid_utoa (fd->inode->gfid), +- GLUSTERFS_OPEN_FD_COUNT); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED, ++ "%s: Failed to set dictionary value for %s", ++ uuid_utoa (fd->inode->gfid), GLUSTERFS_OPEN_FD_COUNT); + } + + ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_WRITE_IS_APPEND, + is_append); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set " +- "dictionary value for %s", uuid_utoa (fd->inode->gfid), ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED, ++ "%s: Failed to set dictionary value for %s", ++ uuid_utoa (fd->inode->gfid), + GLUSTERFS_WRITE_IS_APPEND); + } + out: +@@ -2863,7 +2843,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ret, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + op_errno = -ret; + goto out; +@@ -2885,9 +2865,8 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + op_ret = posix_fdstat (this, _fd, &preop); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "pre-operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -2907,8 +2886,9 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (op_ret < 0) { + op_errno = -op_ret; + op_ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "write failed: offset %"PRIu64 +- ", %s", offset, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_WRITE_FAILED, ++ "write failed: offset %"PRIu64 ++ ",", offset); + goto out; + } + +@@ -2927,9 +2907,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (flags & (O_SYNC|O_DSYNC)) { + ret = fsync (_fd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "fsync() in writev on fd %d failed: %s", +- _fd, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_WRITEV_FAILED, ++ "fsync() in writev on fd %d failed", ++ _fd); + op_ret = -1; + op_errno = errno; + goto out; +@@ -2940,9 +2921,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (ret == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation fstat failed on fd=%p: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FSTAT_FAILED, ++ "post-operation fstat failed on fd=%p", ++ fd); + goto out; + } + } +@@ -2991,9 +2973,8 @@ posix_statfs (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "statvfs failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_STATVFS_FAILED, ++ "statvfs failed on %s", real_path); + goto out; + } + +@@ -3030,7 +3011,7 @@ posix_flush (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL on fd=%p", fd); + goto out; + } +@@ -3059,14 +3040,14 @@ posix_release (xlator_t *this, fd_t *fd) + + ret = fd_ctx_del (fd, this, &tmp_pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto out; + } + pfd = (struct posix_fd *)(long)tmp_pfd; + + if (pfd->dir) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DIR_NOT_NULL, + "pfd->dir is %p (not NULL) for file fd=%p", + pfd->dir, fd); + } +@@ -3153,7 +3134,7 @@ posix_fsync (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd not found in fd's ctx"); + goto out; + } +@@ -3163,9 +3144,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, _fd, &preop); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, +- "pre-operation fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED, ++ "pre-operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -3173,18 +3153,18 @@ posix_fsync (call_frame_t *frame, xlator_t *this, + op_ret = sys_fdatasync (_fd); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fdatasync on fd=%p failed: %s", +- fd, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FSYNC_FAILED, "fdatasync on fd=%p" ++ "failed:", fd); + goto out; + } + } else { + op_ret = sys_fsync (_fd); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "fsync on fd=%p failed: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FSYNC_FAILED, "fsync on fd=%p " ++ "failed", fd); + goto out; + } + } +@@ -3192,9 +3172,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, _fd, &postop); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, +- "post-operation fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED, ++ "post-operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -3449,9 +3428,8 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + dirp = opendir (dirpath); + if (!dirp) { + *op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, +- "could not opendir %s: %s", dirpath, +- strerror (*op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_OPEN_FAILED, ++ "could not opendir %s", dirpath); + goto out; + } + +@@ -3506,8 +3484,6 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + + 1 // ':' + + strlen (temppath) + 1 ); + if (!tempv) { +- gf_log (this->name, GF_LOG_WARNING, +- "realloc failed on path"); + GF_FREE (*path); + op_ret = -1; + *op_errno = ENOMEM; +@@ -3528,9 +3504,8 @@ out: + op_ret = closedir (dirp); + if (op_ret == -1) { + *op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, +- "closedir failed: %s", +- strerror (*op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_CLOSE_FAILED, "closedir failed"); + } + } + +@@ -3588,9 +3563,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, + " with 'user_xattr' flag)"); + + } else { +- gf_log (this->name, GF_LOG_WARNING, +- "listxattr failed on %s: %s", +- leaf_path, strerror (*op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_XATTR_FAILED, "listxattr failed on" ++ "%s", leaf_path); + + } + +@@ -3620,9 +3595,8 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, + op_ret = sys_lstat (leaf_path, &stbuf); + if (op_ret == -1) { + *op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, "lstat failed" +- " on %s: %s", leaf_path, +- strerror (*op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_LSTAT_FAILED, ++ "lstat failed on %s", leaf_path); + goto out; + } + +@@ -3637,12 +3611,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, + sizeof(nlink_samepgfid)); + if (op_ret == -1) { + *op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "getxattr failed on " +- "%s: key = %s (%s)", +- leaf_path, +- key, +- strerror (*op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "getxattr failed on " ++ "%s: key = %s ", leaf_path, key); + goto out; + } + +@@ -3766,9 +3737,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + &file_contents); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_ERROR, +- "getting file contents failed: %s", +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_FILE_FAILED, "getting file contents" ++ "failed"); + goto out; + } + } +@@ -3782,9 +3753,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (loc->inode && name && GF_POSIX_ACL_REQUEST (name)) { + ret = posix_pacl_get (real_path, name, &value); + if (ret || !value) { +- gf_log (this->name, GF_LOG_WARNING, +- "could not get acl (%s) for %s: %s", name, +- real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_ACL_FAILED, "could not get acl (%s) for" ++ "%s", name, real_path); + op_ret = -1; + op_errno = errno; + goto out; +@@ -3793,9 +3764,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + ret = dict_set_dynstr (dict, (char *)name, value); + if (ret < 0) { + GF_FREE (value); +- gf_log (this->name, GF_LOG_WARNING, +- "could not set acl (%s) for %s in dictionary: " +- "(%s)", name, real_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_ACL_FAILED, "could not set acl (%s) for" ++ "%s in dictionary", name, real_path); + op_ret = -1; + op_errno = errno; + goto out; +@@ -3813,10 +3784,16 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (ret < 0) { + op_ret = -1; + op_errno = -ret; +- gf_log (this->name, (op_errno == ENOENT) ? +- GF_LOG_DEBUG : GF_LOG_WARNING, +- "Failed to get real filename (%s, %s): %s", +- loc->path, name, strerror (op_errno)); ++ if (op_errno == ENOENT) { ++ gf_msg_debug (this->name, 0, "Failed to get " ++ "real filename (%s, %s)", ++ loc->path, name); ++ } else { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ P_MSG_GETTING_FILENAME_FAILED, ++ "Failed to get real filename (%s, %s):" ++ , loc->path, name); ++ } + goto out; + } + +@@ -3828,15 +3805,15 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (!list_empty (&loc->inode->fd_list)) { + ret = dict_set_uint32 (dict, (char *)name, 1); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, +- "Failed to set dictionary value for %s", +- name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_DICT_SET_FAILED, "Failed to set " ++ "dictionary value for %s", name); + } else { + ret = dict_set_uint32 (dict, (char *)name, 0); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, +- "Failed to set dictionary value for %s", +- name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_DICT_SET_FAILED, "Failed to set " ++ "dictionary value for %s", name); + } + goto done; + } +@@ -3862,9 +3839,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + size = strlen (dyn_rpath) + 1; + ret = dict_set_dynstr (dict, (char *)name, dyn_rpath); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "could not set value (%s) in dictionary", +- dyn_rpath); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_DICT_SET_FAILED, "could not set value" ++ " (%s) in dictionary", dyn_rpath); + GF_FREE (dyn_rpath); + } + +@@ -3887,9 +3864,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + ret = dict_set_dynstr (dict, GF_XATTR_NODE_UUID_KEY, + dyn_rpath); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "could not set value (%s) in dictionary", +- dyn_rpath); ++ gf_msg (this->name, GF_LOG_WARNING, -ret, ++ P_MSG_DICT_SET_FAILED, "could not set value" ++ "(%s) in dictionary", dyn_rpath); + GF_FREE (dyn_rpath); + op_errno = -ret; + goto out; +@@ -3902,7 +3879,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + ret = inode_path (loc->inode, NULL, &path); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, "%s: could not get " ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ P_MSG_INODE_PATH_GET_FAILED, ++ "%s: could not get " + "inode path", uuid_utoa (loc->inode->gfid)); + goto out; + } +@@ -3911,9 +3890,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY, path); + if (ret < 0) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_WARNING, +- "could not set value (%s) in dictionary", +- host_buf); + GF_FREE (path); + goto out; + } +@@ -3935,7 +3911,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + + op_ret = dict_set_dynstr (dict, GET_ANCESTRY_PATH_KEY, path); + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "could not get " ++ gf_msg (this->name, GF_LOG_WARNING, -op_ret, ++ P_MSG_GET_KEY_VALUE_FAILED, "could not get " + "value for key (%s)", GET_ANCESTRY_PATH_KEY); + GF_FREE (path); + op_errno = -op_ret; +@@ -3964,9 +3941,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (priv->xattr_user_namespace == XATTR_STRIP) { + if (strncmp(key, "user.",5) == 0) { + key += 5; +- gf_log (this->name, +- GF_LOG_DEBUG, +- "getxattr for file %s" ++ gf_msg_debug (this->name, 0, "getxattr for file %s" + " stripping user key: %s -> %s", + real_path, keybuffer, key); + } +@@ -3984,13 +3959,13 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + "flag)"); + } else if (op_errno == ENOATTR || + op_errno == ENODATA) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No such attribute:%s for file %s", + key, real_path); + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "getxattr failed on %s: %s (%s)", +- real_path, key, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_XATTR_FAILED, "getxattr failed" ++ " on %s: %s ", real_path, key); + } + + goto done; +@@ -4005,9 +3980,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " +- "%s: key = %s (%s)", real_path, key, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "getxattr failed on " ++ "%s: key = %s", real_path, key); + GF_FREE (value); + goto out; + } +@@ -4015,7 +3990,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + op_ret = dict_set_dynptr (dict, key, value, size); + if (op_ret < 0) { + op_errno = -op_ret; +- gf_log (this->name, GF_LOG_ERROR, "dict set operation " ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_DICT_SET_FAILED, "dict set operation " + "on %s for the key %s failed.", real_path, key); + GF_FREE (value); + goto out; +@@ -4036,9 +4012,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + "flag)"); + } + else { +- gf_log (this->name, GF_LOG_ERROR, +- "listxattr failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, ++ "listxattr failed on %s", ++ real_path); + } + goto out; + } +@@ -4067,9 +4044,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " +- "%s: key = %s (%s)", real_path, keybuffer, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "getxattr failed on " ++ "%s: key = %s ", real_path, keybuffer); + break; + } + +@@ -4084,9 +4061,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " +- "%s: key = %s (%s)", real_path, keybuffer, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "getxattr failed on " ++ "%s: key = %s ", real_path, keybuffer); + GF_FREE (value); + break; + } +@@ -4102,7 +4079,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + op_ret = dict_set_dynptr (dict, keybuffer, value, size); + if (op_ret < 0) { + op_errno = -op_ret; +- gf_log (this->name, GF_LOG_ERROR, "dict set operation " ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_DICT_SET_FAILED, "dict set operation " + "on %s for the key %s failed.", real_path, + keybuffer); + GF_FREE (value); +@@ -4163,7 +4141,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto out; + } +@@ -4179,9 +4157,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + if (name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) { + ret = dict_set_uint32 (dict, (char *)name, 1); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, +- "Failed to set dictionary value for %s", +- name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_DICT_SET_FAILED, "Failed to set " ++ "dictionary value for %s", name); + goto done; + } + +@@ -4211,11 +4189,15 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + size = sys_fgetxattr (_fd, key, NULL, 0); + if (size == -1) { + op_errno = errno; +- gf_log (this->name, +- ((errno == ENODATA || errno == ENOATTR) ? +- GF_LOG_DEBUG : GF_LOG_ERROR), +- "fgetxattr failed on key %s (%s)", key, +- strerror (op_errno)); ++ if (errno == ENODATA || errno == ENOATTR) { ++ gf_msg_debug (this->name, 0, "fgetxattr failed" ++ " on key %s (%s)", key, ++ strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fgetxattr failed " ++ "on key %s", key); ++ } + goto done; + } + +@@ -4228,16 +4210,17 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " +- "fd %p for the key %s (%s)", fd, key, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fgetxattr failed on " ++ "fd %p for the key %s ", fd, key); + GF_FREE (value); + goto out; + } + value [size] = '\0'; + op_ret = dict_set_dynptr (dict, key, value, size); + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "dict set operation " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_DICT_SET_FAILED, "dict set operation " + "on key %s failed", key); + GF_FREE (value); + goto out; +@@ -4256,9 +4239,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + "brick with 'user_xattr' flag)"); + } + else { +- gf_log (this->name, GF_LOG_ERROR, +- "listxattr failed on %p: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "listxattr failed on %p:", ++ fd); + } + goto out; + } +@@ -4285,9 +4268,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " +- "fd %p for the key %s (%s)", fd, key, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fgetxattr failed on " ++ "fd %p for the key %s ", fd, key); + break; + } + +@@ -4303,9 +4286,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + if (size == -1) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " +- "the fd %p for the key %s (%s)", fd, key, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fgetxattr failed on " ++ "the fd %p for the key %s ", fd, key); + GF_FREE (value); + break; + } +@@ -4314,7 +4297,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, + + op_ret = dict_set_dynptr (dict, key, value, size); + if (op_ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set operation " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_DICT_SET_FAILED, "dict set operation " + "failed on key %s", key); + GF_FREE (value); + goto out; +@@ -4380,7 +4364,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto out; + } +@@ -4408,9 +4392,10 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, + if (op_ret < 0) { + op_ret = -1; + op_errno = errno; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_DURABILITY_REQ_NOT_SATISFIED, + "could not satisfy durability request: " +- "reason (%s)", strerror (errno)); ++ "reason "); + } + } + +@@ -4455,7 +4440,7 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data) + char *newkey = NULL; + if (priv->xattr_user_namespace == XATTR_STRIP) { + gf_remove_prefix (XATTR_USER_PREFIX, key, &newkey); +- gf_log("remove_xattr", GF_LOG_DEBUG, "key %s => %s" , key, ++ gf_msg_debug ("remove_xattr", 0, "key %s => %s" , key, + newkey); + key = newkey; + } +@@ -4478,9 +4463,9 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data) + if (op_ret == -1) { + filler->op_errno = errno; + if (errno != ENOATTR && errno != ENODATA && errno != EPERM) +- gf_log (this->name, GF_LOG_ERROR, +- "removexattr failed on %s (for %s): %s", +- filler->real_path, key, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "removexattr failed on %s" ++ " (for %s)", filler->real_path, key); + } + #ifdef GF_DARWIN_HOST_OS + GF_FREE(newkey); +@@ -4512,14 +4497,15 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, + + + if (!strcmp (GFID_XATTR_KEY, name)) { +- gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" +- " on gfid for file %s", real_path); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, ++ "Remove xattr called on gfid for file %s", real_path); + op_ret = -1; + goto out; + } + if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) { +- gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" +- " on volume-id for file %s", real_path); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, ++ "Remove xattr called on volume-id for file %s", ++ real_path); + op_ret = -1; + goto out; + } +@@ -4548,9 +4534,9 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, + op_errno = errno; + if (op_errno != ENOATTR && op_errno != ENODATA && + op_errno != EPERM) +- gf_log (this->name, GF_LOG_ERROR, +- "removexattr on %s (for %s): %s", real_path, +- name, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "removexattr on %s " ++ "(for %s)", real_path, name); + goto out; + } + +@@ -4592,20 +4578,20 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, + DECLARE_OLD_FS_ID_VAR; + + if (!strcmp (GFID_XATTR_KEY, name)) { +- gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" +- " on gfid for file"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, ++ "Remove xattr called on gfid for file"); + goto out; + } + if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) { +- gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" +- " on volume-id for file"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, ++ "Remove xattr called on volume-id for file"); + goto out; + } + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL from fd=%p", fd); + goto out; + } +@@ -4620,9 +4606,9 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, + op_errno = errno; + if (op_errno != ENOATTR && op_errno != ENODATA && + op_errno != EPERM) +- gf_log (this->name, GF_LOG_ERROR, +- "fremovexattr (for %s): %s", +- name, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_XATTR_FAILED, "fremovexattr (for %s)", ++ name); + goto out; + } + +@@ -4666,7 +4652,7 @@ posix_fsyncdir (call_frame_t *frame, xlator_t *this, + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { + op_errno = -ret; +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + goto out; + } +@@ -4686,7 +4672,7 @@ posix_print_xattr (dict_t *this, + data_t *value, + void *data) + { +- gf_log ("posix", GF_LOG_DEBUG, ++ gf_msg_debug ("posix", 0, + "(key/val) = (%s/%d)", key, data_to_int32 (value)); + } + +@@ -4772,13 +4758,14 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + !posix_special_xattr (marker_xattrs, + k)) { + if (filler->real_path) +- gf_log (this->name, GF_LOG_ERROR, +- "getxattr failed on %s while doing " +- "xattrop: Key:%s (%s)", +- filler->real_path, +- k, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, ++ op_errno, P_MSG_XATTR_FAILED, ++ "getxattr failed on %s while " ++ "doing xattrop: Key:%s ", ++ filler->real_path, k); + else +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ op_errno, P_MSG_XATTR_FAILED, + "fgetxattr failed on gfid=%s " + "while doing xattrop: " + "Key:%s (%s)", +@@ -4814,11 +4801,11 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, +- "Unknown xattrop type (%d) on %s. " +- "Please send a bug report to " +- "gluster-devel@gluster.org", +- optype, filler->real_path); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_UNKNOWN_OP, "Unknown xattrop type (%d)" ++ " on %s. Please send a bug report to " ++ "gluster-devel@gluster.org", optype, ++ filler->real_path); + op_ret = -1; + op_errno = EINVAL; + goto unlock; +@@ -4842,17 +4829,17 @@ unlock: + + if (size == -1) { + if (filler->real_path) +- gf_log (this->name, GF_LOG_ERROR, +- "setxattr failed on %s while doing xattrop: " +- "key=%s (%s)", filler->real_path, +- k, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_XATTR_FAILED, "setxattr failed on %s " ++ "while doing xattrop: key=%s", ++ filler->real_path, k); + else +- gf_log (this->name, GF_LOG_ERROR, +- "fsetxattr failed on gfid=%s while doing xattrop: " +- "key=%s (%s)", ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ P_MSG_XATTR_FAILED, ++ "fsetxattr failed on gfid=%s while doing " ++ "xattrop: key=%s (%s)", + uuid_utoa (filler->inode->gfid), + k, strerror (op_errno)); +- + op_ret = -1; + goto out; + } else { +@@ -4860,12 +4847,12 @@ unlock: + + if (size != 0) { + if (filler->real_path) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dict_set_bin failed (path=%s): " + "key=%s (%s)", filler->real_path, + k, strerror (-size)); + else +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "dict_set_bin failed (gfid=%s): " + "key=%s (%s)", + uuid_utoa (filler->inode->gfid), +@@ -4912,9 +4899,9 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + if (fd) { + op_ret = posix_fd_ctx_get (fd, this, &pfd); + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "failed to get pfd from fd=%p", +- fd); ++ gf_msg (this->name, GF_LOG_WARNING, EBADFD, ++ P_MSG_PFD_GET_FAILED, "failed to get pfd from" ++ " fd=%p", fd); + op_errno = EBADFD; + goto out; + } +@@ -4996,8 +4983,8 @@ posix_access (call_frame_t *frame, xlator_t *this, + op_ret = access (real_path, mask & 07); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "access failed on %s: %s", +- real_path, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACCESS_FAILED, ++ "access failed on %s", real_path); + goto out; + } + op_ret = 0; +@@ -5035,7 +5022,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + op_errno = -ret; + goto out; +@@ -5046,9 +5033,8 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, _fd, &preop); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "pre-operation fstat failed on fd=%p: %s", fd, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "pre-operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -5056,18 +5042,16 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, + + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "ftruncate failed on fd=%p (%"PRId64": %s", +- fd, offset, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED, ++ "ftruncate failed on fd=%p (%"PRId64"", fd, offset); + goto out; + } + + op_ret = posix_fdstat (this, _fd, &postop); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, +- "post-operation fstat failed on fd=%p: %s", +- fd, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "post-operation fstat failed on fd=%p", fd); + goto out; + } + +@@ -5108,7 +5092,7 @@ posix_fstat (call_frame_t *frame, xlator_t *this, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + op_errno = -ret; + goto out; +@@ -5119,8 +5103,8 @@ posix_fstat (call_frame_t *frame, xlator_t *this, + op_ret = posix_fdstat (this, _fd, &buf); + if (op_ret == -1) { + op_errno = errno; +- gf_log (this->name, GF_LOG_ERROR, "fstat failed on fd=%p: %s", +- fd, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, ++ "fstat failed on fd=%p", fd); + goto out; + } + +@@ -5235,7 +5219,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + count = -1; + errno = -ret; +@@ -5268,7 +5252,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + seekdir (dir, off); + #ifndef GF_LINUX_HOST_OS + if ((u_long)telldir(dir) != off && off != pfd->dir_eof) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_DIR_OPERATION_FAILED, + "seekdir(0x%llx) failed on dir=%p: " + "Invalid argument (offset reused from " + "another DIR * structure?)", off, dir); +@@ -5283,9 +5268,9 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + in_case = (u_long)telldir (dir); + + if (in_case == -1) { +- gf_log (THIS->name, GF_LOG_ERROR, +- "telldir failed on dir=%p: %s", +- dir, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ P_MSG_DIR_OPERATION_FAILED, ++ "telldir failed on dir=%p", dir); + goto out; + } + +@@ -5295,9 +5280,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + + if (!entry) { + if (errno == EBADF) { +- gf_log (THIS->name, GF_LOG_WARNING, +- "readdir failed on dir=%p: %s", +- dir, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ P_MSG_DIR_OPERATION_FAILED, ++ "readdir failed on dir=%p", ++ dir); + goto out; + } + break; +@@ -5342,7 +5328,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + #ifndef GF_LINUX_HOST_OS + if ((u_long)telldir(dir) != in_case && + in_case != pfd->dir_eof) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_DIR_OPERATION_FAILED, + "seekdir(0x%llx) failed on dir=%p: " + "Invalid argument (offset reused from " + "another DIR * structure?)", +@@ -5358,9 +5345,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, + this_entry = gf_dirent_for_name (entry->d_name); + + if (!this_entry) { +- gf_log (THIS->name, GF_LOG_ERROR, +- "could not create gf_dirent for entry %s: (%s)", +- entry->d_name, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ P_MSG_GF_DIRENT_CREATE_FAILED, ++ "could not create " ++ "gf_dirent for entry %s", entry->d_name); + goto out; + } + /* +@@ -5403,7 +5391,8 @@ posix_entry_xattr_fill (xlator_t *this, inode_t *inode, + + MAKE_HANDLE_PATH (entry_path, this, fd->inode->gfid, name); + if (!entry_path) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_HANDLE_CREATE, + "Failed to create handle path for %s/%s", + uuid_utoa (fd->inode->gfid), name); + +@@ -5500,7 +5489,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + op_errno = -ret; + goto out; +@@ -5509,7 +5498,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, + dir = pfd->dir; + + if (!dir) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, P_MSG_PFD_NULL, + "dir is NULL for fd=%p", fd); + op_errno = EINVAL; + goto out; +@@ -5663,7 +5652,7 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this, + + ret = posix_fd_ctx_get (fd, this, &pfd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, + "pfd is NULL, fd=%p", fd); + op_errno = -ret; + goto out; +@@ -5678,9 +5667,10 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this, + + ret = pread (_fd, buf, len, offset); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "pread of %d bytes returned %d (%s)", +- len, ret, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_PREAD_FAILED, ++ "pread of %d bytes returned %d ", ++ len, ret); + + op_errno = errno; + } +@@ -5740,8 +5730,6 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_posix_mt_end + 1); + + if (ret != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); + return ret; + } + +@@ -5759,9 +5747,10 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid) + + ret = sys_lstat (priv->base_path, &st); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to stat " +- "brick path %s (%s)", +- priv->base_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_DIR_OPERATION_FAILED, "Failed to stat " ++ "brick path %s", ++ priv->base_path); + return ret; + } + +@@ -5771,9 +5760,9 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid) + + ret = sys_chown (priv->base_path, uid, gid); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to set " +- "uid/gid for brick path %s, %s", +- priv->base_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_DIR_OPERATION_FAILED, "Failed to set uid/gid for" ++ " brick path %s", priv->base_path); + + return ret; + } +@@ -5820,7 +5809,7 @@ int + reconfigure (xlator_t *this, dict_t *options) + { + int ret = -1; +- struct posix_private *priv = NULL; ++struct posix_private *priv = NULL; + int32_t uid = -1; + int32_t gid = -1; + char *batch_fsync_mode_str = NULL; +@@ -5839,8 +5828,8 @@ reconfigure (xlator_t *this, dict_t *options) + options, str, out); + + if (set_batch_fsync_mode (priv, batch_fsync_mode_str) != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s", +- batch_fsync_mode_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, ++ "Unknown mode string: %s", batch_fsync_mode_str); + goto out; + } + +@@ -5852,7 +5841,8 @@ reconfigure (xlator_t *this, dict_t *options) + options, str, out); + + if (set_xattr_user_namespace_mode (priv, xattr_user_namespace_mode_str) != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Unknown xattr user namespace mode string: %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_UNKNOWN_ARGUMENT, ++ "Unknown xattr user namespace mode string: %s", + xattr_user_namespace_mode_str); + goto out; + } +@@ -5874,10 +5864,10 @@ reconfigure (xlator_t *this, dict_t *options) + options, bool, out); + + if (priv->node_uuid_pathinfo && +- (gf_uuid_is_null (priv->glusterd_uuid))) { +- gf_log (this->name, GF_LOG_INFO, +- "glusterd uuid is NULL, pathinfo xattr would" +- " fallback to :"); ++ (gf_uuid_is_null (priv->glusterd_uuid))) { ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, ++ "glusterd uuid is NULL, pathinfo xattr would" ++ " fallback to :"); + } + + GF_OPTION_RECONF ("health-check-interval", priv->health_check_interval, +@@ -5918,19 +5908,20 @@ init (xlator_t *this) + dir_data = dict_get (this->options, "directory"); + + if (this->children) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, P_MSG_SUBVOLUME_ERROR, + "FATAL: storage/posix cannot have subvolumes"); + ret = -1; + goto out; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_VOLUME_DANGLING, + "Volume is dangling. Please check the volume file."); + } + + if (!dir_data) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ P_MSG_EXPORT_DIR_MISSING, + "Export directory not specified in volume file."); + ret = -1; + goto out; +@@ -5941,7 +5932,7 @@ init (xlator_t *this) + /* Check whether the specified directory exists, if not log it. */ + op_ret = stat (dir_data->data, &buf); + if ((op_ret != 0) || !S_ISDIR (buf.st_mode)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, + "Directory '%s' doesn't exist, exiting.", + dir_data->data); + ret = -1; +@@ -5959,25 +5950,29 @@ init (xlator_t *this) + if (tmp_data) { + if (gf_string2boolean (tmp_data->data, + &tmp_bool) == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_OPTION, + "wrong option provided for key " + "\"mandate-attribute\""); + ret = -1; + goto out; + } + if (!tmp_bool) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_XATTR_NOTSUP, + "Extended attribute not supported, " + "starting as per option"); + } else { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ P_MSG_XATTR_NOTSUP, + "Extended attribute not supported, " + "exiting."); + ret = -1; + goto out; + } + } else { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ P_MSG_XATTR_NOTSUP, + "Extended attribute not supported, exiting."); + ret = -1; + goto out; +@@ -5988,9 +5983,10 @@ init (xlator_t *this) + if (tmp_data) { + op_ret = gf_uuid_parse (tmp_data->data, dict_uuid); + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "wrong volume-id (%s) set in volume file", +- tmp_data->data); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_VOLUME_ID, ++ "wrong volume-id (%s) set" ++ " in volume file", tmp_data->data); + ret = -1; + goto out; + } +@@ -5998,7 +5994,8 @@ init (xlator_t *this) + "trusted.glusterfs.volume-id", old_uuid, 16); + if (size == 16) { + if (gf_uuid_compare (old_uuid, dict_uuid)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_VOLUME_ID, + "mismatching volume-id (%s) received. " + "already is a part of volume %s ", + tmp_data->data, uuid_utoa (old_uuid)); +@@ -6007,7 +6004,8 @@ init (xlator_t *this) + } + } else if ((size == -1) && + (errno == ENODATA || errno == ENOATTR)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_VOLUME_ID_ABSENT, + "Extended attribute trusted.glusterfs." + "volume-id is absent"); + ret = -1; +@@ -6016,14 +6014,16 @@ init (xlator_t *this) + } else if ((size == -1) && (errno != ENODATA) && + (errno != ENOATTR)) { + /* Wrong 'volume-id' is set, it should be error */ +- gf_log (this->name, GF_LOG_WARNING, +- "%s: failed to fetch volume-id (%s)", +- dir_data->data, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_VOLUME_ID_FETCH_FAILED, ++ "%s: failed to fetch volume-id", ++ dir_data->data); + ret = -1; + goto out; + } else { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_VOLUME_ID_FETCH_FAILED, + "failed to fetch proper volume id from export"); + goto out; + } +@@ -6034,7 +6034,8 @@ init (xlator_t *this) + size = sys_lgetxattr (dir_data->data, "trusted.gfid", gfid, 16); + if (size == 16) { + if (!__is_root_gfid (gfid)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_GFID_SET_FAILED, + "%s: gfid (%s) is not that of glusterfs '/' ", + dir_data->data, uuid_utoa (gfid)); + ret = -1; +@@ -6042,7 +6043,8 @@ init (xlator_t *this) + } + } else if (size != -1) { + /* Wrong 'gfid' is set, it should be error */ +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_GFID_SET_FAILED, + "%s: wrong value set as gfid", + dir_data->data); + ret = -1; +@@ -6050,9 +6052,10 @@ init (xlator_t *this) + } else if ((size == -1) && (errno != ENODATA) && + (errno != ENOATTR)) { + /* Wrong 'gfid' is set, it should be error */ +- gf_log (this->name, GF_LOG_WARNING, +- "%s: failed to fetch gfid (%s)", +- dir_data->data, strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_GFID_SET_FAILED, ++ "%s: failed to fetch gfid", ++ dir_data->data); + ret = -1; + goto out; + } else { +@@ -6060,9 +6063,10 @@ init (xlator_t *this) + size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid, + 16, XATTR_CREATE); + if (size == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to set gfid (%s)", +- dir_data->data, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_GFID_SET_FAILED, ++ "%s: failed to set gfid", ++ dir_data->data); + ret = -1; + goto out; + } +@@ -6071,7 +6075,8 @@ init (xlator_t *this) + size = sys_lgetxattr (dir_data->data, POSIX_ACL_ACCESS_XATTR, + NULL, 0); + if ((size < 0) && (errno == ENOTSUP)) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_ACL_NOTSUP, + "Posix access control list is not supported."); + + ret = 0; +@@ -6099,7 +6104,8 @@ init (xlator_t *this) + _XOPEN_PATH_MAX + _private->base_path_length > _private->path_max) { + ret = chdir(_private->base_path); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_BASEPATH_CHDIR_FAILED, + "chdir() to \"%s\" failed", + _private->base_path); + goto out; +@@ -6130,8 +6136,9 @@ init (xlator_t *this) + } + ret = gethostname (_private->hostname, 256); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "could not find hostname (%s)", strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_HOSTNAME_MISSING, ++ "could not find hostname "); + } + } + +@@ -6141,13 +6148,14 @@ init (xlator_t *this) + if (gf_string2boolean (tmp_data->data, + &_private->export_statfs) == -1) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_OPTION_VAL, + "'export-statfs-size' takes only boolean " + "options"); + goto out; + } + if (!_private->export_statfs) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "'statfs()' returns dummy size"); + } + +@@ -6157,14 +6165,14 @@ init (xlator_t *this) + if (gf_string2boolean (tmp_data->data, + &_private->background_unlink) == -1) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "'background-unlink' takes only boolean " +- "options"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_OPTION_VAL, "'background-unlink'" ++ " takes only boolean options"); + goto out; + } + + if (_private->background_unlink) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "unlinks will be performed in background"); + } + +@@ -6173,14 +6181,14 @@ init (xlator_t *this) + if (gf_string2boolean (tmp_data->data, + &_private->o_direct) == -1) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_OPTION_VAL, + "wrong option provided for 'o-direct'"); + goto out; + } + if (_private->o_direct) +- gf_log (this->name, GF_LOG_DEBUG, +- "o-direct mode is enabled (O_DIRECT " +- "for every open)"); ++ gf_msg_debug (this->name, 0, "o-direct mode is enabled" ++ " (O_DIRECT for every open)"); + } + + tmp_data = dict_get (this->options, "update-link-count-parent"); +@@ -6188,29 +6196,31 @@ init (xlator_t *this) + if (gf_string2boolean (tmp_data->data, + &_private->update_pgfid_nlinks) == -1) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "wrong value provided for " +- "'update-link-count-parent'"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ P_MSG_INVALID_OPTION, "wrong value provided " ++ "for 'update-link-count-parent'"); + goto out; + } + if (_private->update_pgfid_nlinks) +- gf_log (this->name, GF_LOG_DEBUG, +- "update-link-count-parent is enabled. Thus for each " +- "file an extended attribute representing the " +- "number of hardlinks for that file within the " +- "same parent directory is set."); ++ gf_msg_debug (this->name, 0, "update-link-count-parent" ++ " is enabled. Thus for each file an " ++ "extended attribute representing the " ++ "number of hardlinks for that file " ++ "within the same parent directory is" ++ " set."); + } + + ret = dict_get_str (this->options, "glusterd-uuid", &guuid); + if (!ret) { + if (gf_uuid_parse (guuid, _private->glusterd_uuid)) +- gf_log (this->name, GF_LOG_WARNING, "Cannot parse " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_INVALID_NODE_UUID, "Cannot parse " + "glusterd (node) UUID, node-uuid xattr " + "request would return - \"No such attribute\""); + } else { +- gf_log (this->name, GF_LOG_DEBUG, "No glusterd (node) UUID " +- "passed - node-uuid xattr request will return " +- "\"No such attribute\""); ++ gf_msg_debug (this->name, 0, "No glusterd (node) UUID passed -" ++ " node-uuid xattr request will return \"No such" ++ " attribute\""); + } + ret = 0; + +@@ -6219,9 +6229,8 @@ init (xlator_t *this) + dict_ret = dict_get_int32 (this->options, "janitor-sleep-duration", + &janitor_sleep); + if (dict_ret == 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Setting janitor sleep duration to %d.", +- janitor_sleep); ++ gf_msg_debug (this->name, 0, "Setting janitor sleep duration " ++ "to %d.", janitor_sleep); + + _private->janitor_sleep_duration = janitor_sleep; + } +@@ -6231,7 +6240,7 @@ init (xlator_t *this) + _private->mount_lock = opendir (dir_data->data); + if (!_private->mount_lock) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, + "Could not lock brick directory"); + goto out; + } +@@ -6242,22 +6251,23 @@ init (xlator_t *this) + lim.rlim_max = 1048576; + + if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_SET_ULIMIT_FAILED, + "Failed to set 'ulimit -n " +- " 1048576': %s", strerror(errno)); ++ " 1048576'"); + lim.rlim_cur = 65536; + lim.rlim_max = 65536; + + if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_SET_FILE_MAX_FAILED, + "Failed to set maximum allowed open " +- "file descriptors to 64k: %s", +- strerror(errno)); ++ "file descriptors to 64k"); + } + else { +- gf_log (this->name, GF_LOG_INFO, +- "Maximum allowed open file descriptors " +- "set to 65536"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ P_MSG_MAX_FILE_OPEN, "Maximum allowed " ++ "open file descriptors set to 65536"); + } + } + } +@@ -6266,7 +6276,7 @@ init (xlator_t *this) + + op_ret = posix_handle_init (this); + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, + "Posix handle setup failed"); + ret = -1; + goto out; +@@ -6274,7 +6284,7 @@ init (xlator_t *this) + + op_ret = posix_handle_trash_init (this); + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE_TRASH, + "Posix landfill setup failed"); + ret = -1; + goto out; +@@ -6294,7 +6304,7 @@ init (xlator_t *this) + op_ret = posix_aio_on (this); + + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_POSIX_AIO, + "Posix AIO init failed"); + ret = -1; + goto out; +@@ -6305,7 +6315,7 @@ init (xlator_t *this) + _private->node_uuid_pathinfo, bool, out); + if (_private->node_uuid_pathinfo && + (gf_uuid_is_null (_private->glusterd_uuid))) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, + "glusterd uuid is NULL, pathinfo xattr would" + " fallback to :"); + } +@@ -6328,16 +6338,17 @@ init (xlator_t *this) + + ret = gf_thread_create (&_private->fsyncer, NULL, posix_fsyncer, this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "fsyncer thread" +- " creation failed (%s)", strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ P_MSG_FSYNCER_THREAD_CREATE_FAILED, ++ "fsyncer thread creation failed"); + goto out; + } + + GF_OPTION_INIT ("batch-fsync-mode", batch_fsync_mode_str, str, out); + + if (set_batch_fsync_mode (_private, batch_fsync_mode_str) != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s", +- batch_fsync_mode_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, ++ "Unknown mode string: %s", batch_fsync_mode_str); + goto out; + } + +@@ -6350,7 +6361,7 @@ init (xlator_t *this) + + if (set_xattr_user_namespace_mode (_private, + xattr_user_namespace_mode_str) != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, + "Unknown xattr user namespace mode string: %s", + xattr_user_namespace_mode_str); + goto out; +@@ -6376,7 +6387,6 @@ fini (xlator_t *this) + GF_FREE (priv); + return; + } +- + struct xlator_dumpops dumpops = { + .priv = posix_priv, + .inode = posix_inode, +-- +1.7.1 + diff --git a/SOURCES/0110-rdma-porting-rdma-to-a-new-message-id-logging-format.patch b/SOURCES/0110-rdma-porting-rdma-to-a-new-message-id-logging-format.patch new file mode 100644 index 0000000..f72edbf --- /dev/null +++ b/SOURCES/0110-rdma-porting-rdma-to-a-new-message-id-logging-format.patch @@ -0,0 +1,2485 @@ +From bcba9c27187a1284e9f0834f7e056324a162d80a Mon Sep 17 00:00:00 2001 +From: Humble Devassy Chirammal +Date: Wed, 29 Apr 2015 11:38:11 +0530 +Subject: [PATCH 110/129] rdma: porting rdma to a new message id logging format + +Change-Id: I71e940817ae0a9378e82332d5a8569114fc13482 +BUG: 1231782 +Signed-off-by: Humble Devassy Chirammal +Reviewed-on: http://review.gluster.org/9868 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/51003 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glfs-message-id.h | 2 +- + rpc/rpc-lib/src/Makefile.am | 3 +- + rpc/rpc-lib/src/rpc-lib-messages.h | 83 +++ + rpc/rpc-transport/rdma/src/Makefile.am | 2 +- + rpc/rpc-transport/rdma/src/name.c | 149 ++--- + rpc/rpc-transport/rdma/src/rdma.c | 698 +++++++++++-------- + .../rdma/src/rpc-trans-rdma-messages.h | 217 ++++++ + 7 files changed, 781 insertions(+), 373 deletions(-) + create mode 100644 rpc/rpc-lib/src/rpc-lib-messages.h + create mode 100644 rpc/rpc-transport/rdma/src/rpc-trans-rdma-messages.h + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index df7caa2..d67115c 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -1,5 +1,5 @@ + /* +- Copyright (c) 2013 Red Hat, Inc. ++ Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser +diff --git a/rpc/rpc-lib/src/Makefile.am b/rpc/rpc-lib/src/Makefile.am +index 6a098c9..36eb245 100644 +--- a/rpc/rpc-lib/src/Makefile.am ++++ b/rpc/rpc-lib/src/Makefile.am +@@ -8,7 +8,8 @@ libgfrpc_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + libgfrpc_la_LDFLAGS = -version-info $(LIBGFRPC_LT_VERSION) $(GF_LDFLAGS) + + noinst_HEADERS = rpcsvc.h rpc-transport.h xdr-common.h xdr-rpc.h xdr-rpcclnt.h \ +- rpc-clnt.h rpcsvc-common.h protocol-common.h rpc-drc.h rpc-clnt-ping.h ++ rpc-clnt.h rpcsvc-common.h protocol-common.h rpc-drc.h rpc-clnt-ping.h \ ++ rpc-lib-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(top_srcdir)/rpc/xdr/src \ +diff --git a/rpc/rpc-lib/src/rpc-lib-messages.h b/rpc/rpc-lib/src/rpc-lib-messages.h +new file mode 100644 +index 0000000..51351e8 +--- /dev/null ++++ b/rpc/rpc-lib/src/rpc-lib-messages.h +@@ -0,0 +1,83 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _RPC_LIB_MESSAGES_H_ ++#define _RPC_LIB_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_RPC_LIB_BASE GLFS_MSGID_COMP_RPC_LIB ++#define GLFS_NUM_MESSAGES 12 ++#define GLFS_RPC_LIB_MSGID_END (GLFS_RPC_LIB_BASE + GLFS_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++ ++#define glfs_msg_start_x GLFS_RPC_LIB_BASE, "Invalid: Start of messages" ++ ++/*------------*/ ++/* First slot is allocated for common transport msg ids */ ++ ++#define TRANS_MSG_ADDR_FAMILY_NOT_SPECIFIED (GLFS_RPC_LIB_BASE + 1) ++ ++#define TRANS_MSG_UNKNOWN_ADDR_FAMILY (GLFS_RPC_LIB_BASE + 2) ++ ++#define TRANS_MSG_REMOTE_HOST_ERROR (GLFS_RPC_LIB_BASE + 3) ++ ++#define TRANS_MSG_DNS_RESOL_FAILED (GLFS_RPC_LIB_BASE + 4) ++ ++#define TRANS_MSG_LISTEN_PATH_ERROR (GLFS_RPC_LIB_BASE + 5) ++ ++#define TRANS_MSG_CONNECT_PATH_ERROR (GLFS_RPC_LIB_BASE + 6) ++ ++#define TRANS_MSG_GET_ADDR_INFO_FAILED (GLFS_RPC_LIB_BASE + 7) ++ ++#define TRANS_MSG_PORT_BIND_FAILED (GLFS_RPC_LIB_BASE + 8) ++ ++#define TRANS_MSG_INET_ERROR (GLFS_RPC_LIB_BASE + 9) ++ ++#define TRANS_MSG_GET_NAME_INFO_FAILED (GLFS_RPC_LIB_BASE + 10) ++ ++#define TRANS_MSG_TRANSPORT_ERROR (GLFS_RPC_LIB_BASE + 11) ++ ++#define TRANS_MSG_TIMEOUT_EXCEEDED (GLFS_RPC_LIB_BASE + 12) ++ ++/*------------*/ ++ ++#define glfs_msg_end_x GLFS_RPC_LIB_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_RPC_LIB_MESSAGES_H_ */ ++ +diff --git a/rpc/rpc-transport/rdma/src/Makefile.am b/rpc/rpc-transport/rdma/src/Makefile.am +index fed139e..6526b6c 100644 +--- a/rpc/rpc-transport/rdma/src/Makefile.am ++++ b/rpc/rpc-transport/rdma/src/Makefile.am +@@ -9,7 +9,7 @@ rdma_la_SOURCES = rdma.c name.c + rdma_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + -libverbs -lrdmacm + +-noinst_HEADERS = rdma.h name.h ++noinst_HEADERS = rdma.h name.h rpc-trans-rdma-messages.h + -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src/ \ + -I$(top_srcdir)/xlators/protocol/lib/src/ $(GF_CFLAGS) + +diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c +index 52ce5bb..97b2e37 100644 +--- a/rpc/rpc-transport/rdma/src/name.c ++++ b/rpc/rpc-transport/rdma/src/name.c +@@ -22,6 +22,8 @@ + #include "rpc-transport.h" + #include "rdma.h" + #include "common-utils.h" ++#include "rpc-lib-messages.h" ++#include "rpc-trans-rdma-messages.h" + + + int32_t +@@ -38,7 +40,7 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, + { + int32_t ret = -1; + uint16_t port = ceiling - 1; +- // by default assume none of the ports are blocked and all are available ++ /* by default assume none of the ports are blocked and all are available */ + gf_boolean_t ports[1024] = {_gf_false,}; + int i = 0; + +@@ -48,10 +50,8 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, + ports[i] = _gf_false; + } + +- while (port) +- { +- switch (sockaddr->sa_family) +- { ++ while (port) { ++ switch (sockaddr->sa_family) { + case AF_INET6: + ((struct sockaddr_in6 *)sockaddr)->sin6_port + = htons (port); +@@ -63,7 +63,7 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, + = htons (port); + break; + } +- // ignore the reserved ports ++ /* ignore the reserved ports */ + if (ports[port] == _gf_true) { + port--; + continue; +@@ -134,7 +134,8 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) + + if (!(remote_host_data || connect_path_data) || + (remote_host_data && connect_path_data)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_ADDR_FAMILY_NOT_SPECIFIED, + "address-family not specified and not able to " + "determine the same from other options " + "(remote-host:%s and connect-path:%s)", +@@ -144,14 +145,13 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) + } + + if (remote_host_data) { +- gf_log (this->name, GF_LOG_DEBUG, +- "address-family not specified, guessing it " +- "to be inet/inet6"); ++ gf_msg_debug (this->name, 0, "address-family not " ++ "specified, guessing it to be " ++ "inet/inet6"); + sockaddr->sa_family = AF_UNSPEC; + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "address-family not specified, guessing it " +- "to be unix"); ++ gf_msg_debug (this->name, 0, "address-family not " ++ "specified, guessing it to be unix"); + sockaddr->sa_family = AF_UNIX; + } + +@@ -166,7 +166,8 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) + } else if (!strcasecmp (address_family, "inet-sdp")) { + sockaddr->sa_family = AF_INET_SDP; + } else { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_UNKNOWN_ADDR_FAMILY, + "unknown address-family (%s) specified", + address_family); + sockaddr->sa_family = AF_UNSPEC; +@@ -191,47 +192,40 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, + int32_t ret = 0; + + remote_host_data = dict_get (options, "remote-host"); +- if (remote_host_data == NULL) +- { +- gf_log (this->name, GF_LOG_ERROR, +- "option remote-host missing in volume %s", +- this->name); ++ if (remote_host_data == NULL) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_REMOTE_HOST_ERROR, "option remote-host " ++ "missing in volume %s", this->name); + ret = -1; + goto err; + } + + remote_host = data_to_str (remote_host_data); +- if (remote_host == NULL) +- { +- gf_log (this->name, GF_LOG_ERROR, +- "option remote-host has data NULL in volume %s", +- this->name); ++ if (remote_host == NULL) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_REMOTE_HOST_ERROR, "option remote-host " ++ "has data NULL in volume %s", this->name); + ret = -1; + goto err; + } + + if (remote_port == 0) { + remote_port_data = dict_get (options, "remote-port"); +- if (remote_port_data == NULL) +- { +- gf_log (this->name, GF_LOG_DEBUG, +- "option remote-port missing in volume %s. " +- "Defaulting to %d", +- this->name, GF_DEFAULT_RDMA_LISTEN_PORT); ++ if (remote_port_data == NULL) { ++ gf_msg_debug (this->name, 0, "option remote-port " ++ "missing in volume %s. Defaulting to %d", ++ this->name, GF_DEFAULT_RDMA_LISTEN_PORT); + + remote_port = GF_DEFAULT_RDMA_LISTEN_PORT; +- } +- else +- { ++ } else { + remote_port = data_to_uint16 (remote_port_data); + } + } + +- if (remote_port == -1) +- { +- gf_log (this->name, GF_LOG_ERROR, +- "option remote-port has invalid port in volume %s", +- this->name); ++ if (remote_port == -1) { ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ RDMA_MSG_INVALID_ENTRY, "option remote-port has " ++ "invalid port in volume %s", this->name); + ret = -1; + goto err; + } +@@ -242,7 +236,7 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, + sockaddr->sa_family, + &this->dnscache, &addr_info); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, TRANS_MSG_DNS_RESOL_FAILED, + "DNS resolution failed on host %s", remote_host); + goto err; + } +@@ -267,32 +261,32 @@ af_unix_client_get_remote_sockaddr (rpc_transport_t *this, + connect_path_data = dict_get (this->options, + "transport.rdma.connect-path"); + if (!connect_path_data) { +- gf_log (this->name, GF_LOG_ERROR, +- "option transport.rdma.connect-path not " +- "specified for address-family unix"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_CONNECT_PATH_ERROR, "option " ++ "transport.rdma.connect-path not specified for " ++ "address-family unix"); + ret = -1; + goto err; + } + + connect_path = data_to_str (connect_path_data); + if (!connect_path) { +- gf_log (this->name, GF_LOG_ERROR, +- "connect-path is null-string"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ RDMA_MSG_INVALID_ENTRY, "connect-path is null-string"); + ret = -1; + goto err; + } + + if (strlen (connect_path) > UNIX_PATH_MAX) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_CONNECT_PATH_ERROR, + "connect-path value length %"GF_PRI_SIZET" > " + "%d octets", strlen (connect_path), UNIX_PATH_MAX); + ret = -1; + goto err; + } + +- gf_log (this->name, +- GF_LOG_DEBUG, +- "using connect-path %s", connect_path); ++ gf_msg_debug (this->name, 0, "using connect-path %s", connect_path); + sockaddr_un = (struct sockaddr_un *)sockaddr; + strcpy (sockaddr_un->sun_path, connect_path); + *sockaddr_len = sizeof (struct sockaddr_un); +@@ -315,7 +309,8 @@ af_unix_server_get_local_sockaddr (rpc_transport_t *this, + listen_path_data = dict_get (this->options, + "transport.rdma.listen-path"); + if (!listen_path_data) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_LISTEN_PATH_ERROR, + "missing option listen-path"); + ret = -1; + goto err; +@@ -328,8 +323,9 @@ af_unix_server_get_local_sockaddr (rpc_transport_t *this, + #endif + + if (strlen (listen_path) > UNIX_PATH_MAX) { +- gf_log (this->name, GF_LOG_ERROR, +- "option listen-path has value length %"GF_PRI_SIZET" > %d", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_LISTEN_PATH_ERROR, "option listen-path has " ++ "value length %"GF_PRI_SIZET" > %d", + strlen (listen_path), UNIX_PATH_MAX); + ret = -1; + goto err; +@@ -399,7 +395,8 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, + + ret = getaddrinfo(listen_host, service, &hints, &res); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ TRANS_MSG_GET_ADDR_INFO_FAILED, + "getaddrinfo failed for host %s, service %s (%s)", + listen_host, service, gai_strerror (ret)); + ret = -1; +@@ -422,8 +419,7 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, + int ret = 0; + + *sockaddr_len = sizeof (struct sockaddr_in6); +- switch (sockaddr->sa_family) +- { ++ switch (sockaddr->sa_family) { + case AF_INET_SDP: + case AF_INET: + *sockaddr_len = sizeof (struct sockaddr_in); +@@ -433,7 +429,8 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, + *sockaddr_len, + GF_CLIENT_PORT_CEILING); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_PORT_BIND_FAILED, + "cannot bind rdma_cm_id to port " + "less than %d (%s)", GF_CLIENT_PORT_CEILING, + strerror (errno)); +@@ -457,7 +454,8 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_UNKNOWN_ADDR_FAMILY, + "unknown address family %d", sockaddr->sa_family); + ret = -1; + break; +@@ -481,8 +479,7 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, + goto err; + } + +- switch (sockaddr->sa_family) +- { ++ switch (sockaddr->sa_family) { + case AF_INET_SDP: + sockaddr->sa_family = AF_INET; + is_inet_sdp = 1; +@@ -508,7 +505,8 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_UNKNOWN_ADDR_FAMILY, + "unknown address-family %d", sockaddr->sa_family); + ret = -1; + } +@@ -541,22 +539,20 @@ gf_rdma_server_get_local_sockaddr (rpc_transport_t *this, + } else if (!strcasecmp (address_family, "unix")) { + addr->sa_family = AF_UNIX; + } else { +- gf_log (this->name, GF_LOG_ERROR, +- "unknown address family (%s) specified", +- address_family); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address" ++ " family (%s) specified", address_family); + addr->sa_family = AF_UNSPEC; + ret = -1; + goto err; + } + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "option address-family not specified, defaulting " +- "to inet"); ++ gf_msg_debug (this->name, 0, "option address-family not " ++ "specified, defaulting to inet"); + addr->sa_family = AF_INET; + } + +- switch (addr->sa_family) +- { ++ switch (addr->sa_family) { + case AF_INET_SDP: + is_inet_sdp = 1; + addr->sa_family = AF_INET; +@@ -639,8 +635,8 @@ fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *add + service, sizeof (service), + NI_NUMERICHOST | NI_NUMERICSERV); + if (ret != 0) { +- gf_log (this->name, +- GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ TRANS_MSG_GET_NAME_INFO_FAILED, + "getnameinfo failed (%s)", gai_strerror (ret)); + } + +@@ -655,21 +651,20 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) + int32_t ret = 0; + char is_inet_sdp = 0; + +- switch (((struct sockaddr *) &this->myinfo.sockaddr)->sa_family) +- { ++ switch (((struct sockaddr *) &this->myinfo.sockaddr)->sa_family) { + case AF_INET_SDP: + is_inet_sdp = 1; + ((struct sockaddr *) &this->peerinfo.sockaddr)->sa_family = ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family = AF_INET; + + case AF_INET: +- case AF_INET6: +- { ++ case AF_INET6: { + ret = fill_inet6_inet_identifiers (this, + &this->myinfo.sockaddr, + this->myinfo.sockaddr_len, + this->myinfo.identifier); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_INET_ERROR, + "can't fill inet/inet6 identifier for server"); + goto err; + } +@@ -679,7 +674,8 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) + this->peerinfo.sockaddr_len, + this->peerinfo.identifier); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_INET_ERROR, + "can't fill inet/inet6 identifier for client"); + goto err; + } +@@ -703,7 +699,8 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ TRANS_MSG_UNKNOWN_ADDR_FAMILY, + "unknown address family (%d)", + ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family); + ret = -1; +diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c +index f62f401..89fb6cb 100644 +--- a/rpc/rpc-transport/rdma/src/rdma.c ++++ b/rpc/rpc-transport/rdma/src/rdma.c +@@ -22,6 +22,8 @@ + #include "byte-order.h" + #include "xlator.h" + #include "xdr-rpc.h" ++#include "rpc-lib-messages.h" ++#include "rpc-trans-rdma-messages.h" + #include + + #define GF_RDMA_LOG_NAME "rpc-transport/rdma" +@@ -116,7 +118,8 @@ gf_rdma_new_post (rpc_transport_t *this, gf_rdma_device_t *device, int32_t len, + post->buf_size, + IBV_ACCESS_LOCAL_WRITE); + if (!post->mr) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_MR_ALOC_FAILED, + "memory registration failed (%s)", + strerror (errno)); + goto out; +@@ -324,12 +327,13 @@ __gf_rdma_create_posts (rpc_transport_t *this, int32_t count, int32_t size, + priv = this->private; + device = priv->device; + +- for (i=0 ; iname, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_POST_CREATION_FAILED, + "post creation failed"); + ret = -1; + break; +@@ -399,9 +403,10 @@ gf_rdma_deregister_arena (struct list_head **mr_list, + list_for_each_entry_safe (tmp, dummy, mr_list[i], list) { + if (tmp->iobuf_arena == iobuf_arena) { + if (ibv_dereg_mr(tmp->mr)) { +- gf_log("rdma", GF_LOG_WARNING, +- "deallocation of memory region " +- "failed"); ++ gf_msg ("rdma", GF_LOG_WARNING, 0, ++ RDMA_MSG_DEREGISTER_ARENA_FAILED, ++ "deallocation of memory region " ++ "failed"); + return -1; + } + list_del(&tmp->list); +@@ -431,8 +436,10 @@ gf_rdma_register_arena (void **arg1, void *arg2) + new = GF_CALLOC(1, sizeof(gf_rdma_arena_mr), + gf_common_mt_rdma_arena_mr); + if (new == NULL) { +- gf_log ("rdma", GF_LOG_INFO, "Out of memory:" +- " registering pre allocated buffer wth rdma device failed."); ++ gf_msg ("rdma", GF_LOG_INFO, ENOMEM, ++ RDMA_MSG_MR_ALOC_FAILED, "Out of " ++ "memory: registering pre allocated buffer " ++ "with rdma device failed."); + return -1; + } + INIT_LIST_HEAD (&new->list); +@@ -445,8 +452,9 @@ gf_rdma_register_arena (void **arg1, void *arg2) + IBV_ACCESS_REMOTE_WRITE + ); + if (!mr) +- gf_log("rdma", GF_LOG_WARNING, +- "allocation of mr failed"); ++ gf_msg ("rdma", GF_LOG_WARNING, 0, ++ RDMA_MSG_MR_ALOC_FAILED, "allocation of mr " ++ "failed"); + + new->mr = mr; + list_add (&new->list, &device[i]->all_mr); +@@ -473,8 +481,10 @@ gf_rdma_register_iobuf_pool (gf_rdma_device_t *device, + new = GF_CALLOC(1, sizeof(gf_rdma_arena_mr), + gf_common_mt_rdma_arena_mr); + if (new == NULL) { +- gf_log ("rdma", GF_LOG_INFO, "Out of memory:" +- " registering pre allocated buffer with rdma device failed."); ++ gf_msg ("rdma", GF_LOG_INFO, ENOMEM, ++ RDMA_MSG_MR_ALOC_FAILED, "Out of " ++ "memory: registering pre allocated " ++ "buffer with rdma device failed."); + return; + } + INIT_LIST_HEAD (&new->list); +@@ -486,8 +496,9 @@ gf_rdma_register_iobuf_pool (gf_rdma_device_t *device, + IBV_ACCESS_LOCAL_WRITE | + IBV_ACCESS_REMOTE_WRITE); + if (!mr) { +- gf_log ("rdma", GF_LOG_WARNING, "failed to pre" +- " register buffers with rdma " ++ gf_msg ("rdma", GF_LOG_WARNING, 0, ++ RDMA_MSG_MR_ALOC_FAILED, "failed" ++ " to pre register buffers with rdma " + "devices."); + + } +@@ -557,7 +568,7 @@ gf_rdma_create_posts (rpc_transport_t *this) + GF_RDMA_RECV_POST); + + if (!ret) { +- for (i=0 ; irecv_count ; i++) { ++ for (i = 0 ; i < options->recv_count ; i++) { + post = gf_rdma_get_post (&device->recvq); + if (gf_rdma_post_recv (device->srq, post) != 0) { + ret = -1; +@@ -614,14 +625,15 @@ gf_rdma_create_cq (rpc_transport_t *this) + device->recv_chan, + 0); + if (!device->recv_cq) { +- gf_log (this->name, GF_LOG_ERROR, +- "creation of CQ for device %s failed", +- device->device_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_CQ_CREATION_FAILED, "creation of CQ for " ++ "device %s failed", device->device_name); + ret = -1; + goto out; + } else if (ibv_req_notify_cq (device->recv_cq, 0)) { +- gf_log (this->name, GF_LOG_ERROR, +- "ibv_req_notify_cq on recv CQ of device %s failed", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_REQ_NOTIFY_CQ_REVQ_FAILED, "ibv_req_notify_" ++ "cq on recv CQ of device %s failed", + device->device_name); + ret = -1; + goto out; +@@ -630,8 +642,9 @@ gf_rdma_create_cq (rpc_transport_t *this) + do { + ret = ibv_query_device (priv->device->context, &device_attr); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "ibv_query_device on %s returned %d (%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_QUERY_DEVICE_FAILED, "ibv_query_" ++ "device on %s returned %d (%s)", + priv->device->device_name, ret, + (ret > 0) ? strerror (ret) : ""); + ret = -1; +@@ -647,15 +660,17 @@ gf_rdma_create_cq (rpc_transport_t *this) + send_cqe, device, + device->send_chan, 0); + if (!device->send_cq) { +- gf_log (this->name, GF_LOG_ERROR, +- "creation of send_cq for device %s failed", +- device->device_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_CQ_CREATION_FAILED, ++ "creation of send_cq " ++ "for device %s failed", device->device_name); + ret = -1; + goto out; + } + + if (ibv_req_notify_cq (device->send_cq, 0)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_REQ_NOTIFY_CQ_SENDQ_FAILED, + "ibv_req_notify_cq on send_cq for device %s" + " failed", device->device_name); + ret = -1; +@@ -734,16 +749,18 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + + trav->send_chan = ibv_create_comp_channel (trav->context); + if (!trav->send_chan) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not create send completion channel for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_SEND_COMP_CHAN_FAILED, "could not " ++ "create send completion channel for " + "device (%s)", device_name); + goto out; + } + + trav->recv_chan = ibv_create_comp_channel (trav->context); + if (!trav->recv_chan) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not create recv completion channel for " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_RECV_COMP_CHAN_FAILED, "could not " ++ "create recv completion channel for " + "device (%s)", device_name); + + /* TODO: cleanup current mess */ +@@ -751,7 +768,8 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + } + + if (gf_rdma_create_cq (this) < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_CQ_CREATION_FAILED, + "could not create CQ for device (%s)", + device_name); + goto out; +@@ -761,9 +779,10 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + trav->pd = ibv_alloc_pd (trav->context); + + if (!trav->pd) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not allocate protection domain for " +- "device (%s)", device_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_ALOC_PROT_DOM_FAILED, "could not " ++ "allocate protection domain for device (%s)", ++ device_name); + goto out; + } + +@@ -777,8 +796,9 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + trav->srq = ibv_create_srq (trav->pd, &attr); + + if (!trav->srq) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not create SRQ for device (%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_CRE_SRQ_FAILED, "could not create SRQ" ++ " for device (%s)", + device_name); + goto out; + } +@@ -791,9 +811,9 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + gf_rdma_register_iobuf_pool(trav, iobuf_pool); + + if (gf_rdma_create_posts (this) < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not allocate posts for device (%s)", +- device_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_ALOC_POST_FAILED, "could not allocate" ++ "posts for device (%s)", device_name); + goto out; + } + +@@ -802,7 +822,8 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + gf_rdma_send_completion_proc, + trav->send_chan); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_SEND_COMP_THREAD_FAILED, + "could not create send completion thread for " + "device (%s)", device_name); + goto out; +@@ -812,7 +833,8 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + gf_rdma_recv_completion_proc, + trav->recv_chan); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_RECV_COMP_THREAD_FAILED, + "could not create recv completion thread " + "for device (%s)", device_name); + return NULL; +@@ -822,14 +844,15 @@ gf_rdma_get_device (rpc_transport_t *this, struct ibv_context *ibctx, + gf_rdma_async_event_thread, + ibctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ RDMA_MSG_ASYNC_EVENT_THEAD_FAILED, + "could not create async_event_thread"); + return NULL; + } + + /* qpreg */ + pthread_mutex_init (&trav->qpreg.lock, NULL); +- for (i=0; i<42; i++) { ++ for (i = 0; i < 42; i++) { + trav->qpreg.ents[i].next = &trav->qpreg.ents[i]; + trav->qpreg.ents[i].prev = &trav->qpreg.ents[i]; + } +@@ -912,19 +935,20 @@ gf_rdma_transport_new (rpc_transport_t *listener, struct rdma_cm_id *cm_id) + + device_name = (char *)ibv_get_device_name (cm_id->verbs->device); + if (device_name == NULL) { +- gf_log (listener->name, GF_LOG_WARNING, +- "cannot get device name (peer:%s me:%s)", +- this->peerinfo.identifier, this->myinfo.identifier); ++ gf_msg (listener->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_DEVICE_NAME_FAILED, "cannot get device " ++ "name (peer:%s me:%s)", this->peerinfo.identifier, ++ this->myinfo.identifier); + goto out; + } + + priv->device = gf_rdma_get_device (this, cm_id->verbs, + device_name); + if (priv->device == NULL) { +- gf_log (listener->name, GF_LOG_WARNING, +- "cannot get infiniband device %s (peer:%s me:%s)", +- device_name, this->peerinfo.identifier, +- this->myinfo.identifier); ++ gf_msg (listener->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_IB_DEVICE_FAILED, "cannot get infiniband" ++ " device %s (peer:%s me:%s)", device_name, ++ this->peerinfo.identifier, this->myinfo.identifier); + goto out; + } + +@@ -978,23 +1002,25 @@ gf_rdma_cm_handle_connect_request (struct rdma_cm_event *event) + + this = gf_rdma_transport_new (listener, child_cm_id); + if (this == NULL) { +- gf_log (listener->name, GF_LOG_WARNING, +- "could not create a transport for incoming connection" ++ gf_msg (listener->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_CREAT_INC_TRANS_FAILED, "could not create " ++ "a transport for incoming connection" + " (me.name:%s me.identifier:%s)", listener->name, + listener->myinfo.identifier); + rdma_destroy_id (child_cm_id); + goto out; + } + +- gf_log (listener->name, GF_LOG_TRACE, +- "got a connect request (me:%s peer:%s)", +- listener->myinfo.identifier, this->peerinfo.identifier); ++ gf_msg_trace (listener->name, 0, "got a connect request (me:%s peer:" ++ "%s)", listener->myinfo.identifier, ++ this->peerinfo.identifier); + + ret = gf_rdma_create_qp (this); + if (ret < 0) { +- gf_log (listener->name, GF_LOG_WARNING, +- "could not create QP (peer:%s me:%s)", +- this->peerinfo.identifier, this->myinfo.identifier); ++ gf_msg (listener->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_CREAT_QP_FAILED, "could not create QP " ++ "(peer:%s me:%s)", this->peerinfo.identifier, ++ this->myinfo.identifier); + gf_rdma_cm_handle_disconnect (this); + goto out; + } +@@ -1006,8 +1032,9 @@ gf_rdma_cm_handle_connect_request (struct rdma_cm_event *event) + + ret = rdma_accept(child_cm_id, &conn_param); + if (ret < 0) { +- gf_log (listener->name, GF_LOG_WARNING, "rdma_accept failed " +- "peer:%s me:%s (%s)", this->peerinfo.identifier, ++ gf_msg (listener->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_ACCEPT_FAILED, "rdma_accept failed peer:%s " ++ "me:%s (%s)", this->peerinfo.identifier, + this->myinfo.identifier, strerror (errno)); + gf_rdma_cm_handle_disconnect (this); + goto out; +@@ -1042,9 +1069,10 @@ gf_rdma_cm_handle_route_resolved (struct rdma_cm_event *event) + + ret = gf_rdma_create_qp (this); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "could not create QP (peer:%s me:%s)", +- this->peerinfo.identifier, this->myinfo.identifier); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_CREAT_QP_FAILED, "could not create QP " ++ "(peer:%s me:%s)", this->peerinfo.identifier, ++ this->myinfo.identifier); + gf_rdma_cm_handle_disconnect (this); + goto out; + } +@@ -1057,14 +1085,15 @@ gf_rdma_cm_handle_route_resolved (struct rdma_cm_event *event) + + ret = rdma_connect(peer->cm_id, &conn_param); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_CONNECT_FAILED, + "rdma_connect failed (%s)", strerror (errno)); + gf_rdma_cm_handle_disconnect (this); + goto out; + } + +- gf_log (this->name, GF_LOG_TRACE, "route resolved (me:%s peer:%s)", +- this->myinfo.identifier, this->peerinfo.identifier); ++ gf_msg_trace (this->name, 0, "route resolved (me:%s peer:%s)", ++ this->myinfo.identifier, this->peerinfo.identifier); + + ret = 0; + out: +@@ -1099,15 +1128,16 @@ gf_rdma_cm_handle_addr_resolved (struct rdma_cm_event *event) + + ret = rdma_resolve_route(peer->cm_id, 2000); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "rdma_resolve_route failed (me:%s peer:%s) (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_ROUTE_RESOLVE_FAILED, "rdma_resolve_route " ++ "failed (me:%s peer:%s) (%s)", + this->myinfo.identifier, this->peerinfo.identifier, + strerror (errno)); + gf_rdma_cm_handle_disconnect (this); + } + +- gf_log (this->name, GF_LOG_TRACE, "Address resolved (me:%s peer:%s)", +- this->myinfo.identifier, this->peerinfo.identifier); ++ gf_msg_trace (this->name, 0, "Address resolved (me:%s peer:%s)", ++ this->myinfo.identifier, this->peerinfo.identifier); + + return ret; + } +@@ -1120,8 +1150,7 @@ gf_rdma_cm_handle_disconnect (rpc_transport_t *this) + char need_unref = 0; + + priv = this->private; +- gf_log (this->name, GF_LOG_DEBUG, +- "peer disconnected, cleaning up"); ++ gf_msg_debug (this->name, 0, "peer disconnected, cleaning up"); + + pthread_mutex_lock (&priv->write_mutex); + { +@@ -1155,9 +1184,10 @@ gf_rdma_cm_handle_connect_init (struct rdma_cm_event *event) + priv = this->private; + + if (priv->connected == 1) { +- gf_log (this->name, GF_LOG_TRACE, +- "received event RDMA_CM_EVENT_ESTABLISHED (me:%s peer:%s)", +- this->myinfo.identifier, this->peerinfo.identifier); ++ gf_msg_trace (this->name, 0, "received event " ++ "RDMA_CM_EVENT_ESTABLISHED (me:%s peer:%s)", ++ this->myinfo.identifier, ++ this->peerinfo.identifier); + return ret; + } + +@@ -1171,9 +1201,10 @@ gf_rdma_cm_handle_connect_init (struct rdma_cm_event *event) + pthread_mutex_unlock (&priv->write_mutex); + + if (priv->entity == GF_RDMA_CLIENT) { +- gf_log (this->name, GF_LOG_TRACE, +- "received event RDMA_CM_EVENT_ESTABLISHED (me:%s peer:%s)", +- this->myinfo.identifier, this->peerinfo.identifier); ++ gf_msg_trace (this->name, 0, "received event " ++ "RDMA_CM_EVENT_ESTABLISHED (me:%s peer:%s)", ++ this->myinfo.identifier, ++ this->peerinfo.identifier); + ret = rpc_transport_notify (this, RPC_TRANSPORT_CONNECT, this); + + } else if (priv->entity == GF_RDMA_SERVER) { +@@ -1224,7 +1255,8 @@ gf_rdma_cm_event_handler (void *data) + while (1) { + ret = rdma_get_cm_event (event_channel, &event); + if (ret != 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_CM_EVENT_FAILED, + "rdma_cm_get_event failed (%s)", + strerror (errno)); + break; +@@ -1254,10 +1286,9 @@ gf_rdma_cm_event_handler (void *data) + case RDMA_CM_EVENT_REJECTED: + this = event->id->context; + +- gf_log (this->name, GF_LOG_WARNING, +- "cma event %s, error %d (me:%s peer:%s)\n " +- "Host Unreachable, Check your connection " +- "with IPoIB", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_CM_EVENT_FAILED, "cma event %s, " ++ "error %d (me:%s peer:%s)\n", + rdma_event_str(event->event), event->status, + this->myinfo.identifier, + this->peerinfo.identifier); +@@ -1271,10 +1302,10 @@ gf_rdma_cm_event_handler (void *data) + case RDMA_CM_EVENT_DISCONNECTED: + this = event->id->context; + +- gf_log (this->name, GF_LOG_DEBUG, +- "received disconnect (me:%s peer:%s)\n", +- this->myinfo.identifier, +- this->peerinfo.identifier); ++ gf_msg_debug (this->name, 0, "received disconnect " ++ "(me:%s peer:%s)\n", ++ this->myinfo.identifier, ++ this->peerinfo.identifier); + + rdma_ack_cm_event (event); + event = NULL; +@@ -1283,13 +1314,15 @@ gf_rdma_cm_event_handler (void *data) + continue; + + case RDMA_CM_EVENT_DEVICE_REMOVAL: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "device removed"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CM_EVENT_FAILED, "device " ++ "removed"); + gf_rdma_cm_handle_device_removal (event); + break; + + default: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CM_EVENT_FAILED, + "unhandled event: %s, ignoring", + rdma_event_str(event->event)); + break; +@@ -1367,8 +1400,8 @@ __gf_rdma_send_error (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + len = __gf_rdma_encode_error (peer, reply_info, entry->rpchdr, + (gf_rdma_header_t *)post->buf, err); + if (len == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, +- "encode error returned -1"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, 0, ++ RDMA_MSG_ENCODE_ERROR, "encode error returned -1"); + goto out; + } + +@@ -1378,7 +1411,8 @@ __gf_rdma_send_error (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if (!ret) { + ret = len; + } else { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POST_SEND_FAILED, + "gf_rdma_post_send (to %s) failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); +@@ -1428,7 +1462,8 @@ __gf_rdma_create_read_chunks_from_vector (gf_rdma_peer_t *peer, + IBV_ACCESS_REMOTE_READ); + } + if (!mr) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_MR_ALOC_FAILED, + "memory registration failed (%s) (peer:%s)", + strerror (errno), + peer->trans->peerinfo.identifier); +@@ -1480,7 +1515,8 @@ __gf_rdma_create_read_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->rpchdr_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_READ_CHUNK_VECTOR_FAILED, + "cannot create read chunks from vector " + "entry->rpchdr"); + goto out; +@@ -1493,7 +1529,8 @@ __gf_rdma_create_read_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->proghdr_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_READ_CHUNK_VECTOR_FAILED, + "cannot create read chunks from vector " + "entry->proghdr"); + } +@@ -1506,7 +1543,8 @@ __gf_rdma_create_read_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->prog_payload_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_READ_CHUNK_VECTOR_FAILED, + "cannot create read chunks from vector" + " entry->prog_payload"); + } +@@ -1520,7 +1558,8 @@ __gf_rdma_create_read_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->prog_payload_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_READ_CHUNK_VECTOR_FAILED, + "cannot create read chunks from vector " + "entry->prog_payload"); + } +@@ -1570,8 +1609,9 @@ __gf_rdma_create_write_chunks_from_vector (gf_rdma_peer_t *peer, + } + + if (!mr) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "memory registration failed (%s) (peer:%s)", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_MR_ALOC_FAILED, "memory " ++ "registration failed (%s) (peer:%s)", + strerror (errno), + peer->trans->peerinfo.identifier); + goto out; +@@ -1612,7 +1652,8 @@ __gf_rdma_create_write_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if ((chunk_type == gf_rdma_replych) + && ((entry->msg.request.rsphdr_count != 1) || + (entry->msg.request.rsphdr_vec[0].iov_base == NULL))) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_BUFFER_ERROR, + (entry->msg.request.rsphdr_count == 1) + ? "chunktype specified as reply chunk but the vector " + "specifying the buffer to be used for holding reply" +@@ -1648,7 +1689,8 @@ __gf_rdma_create_write_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->msg.request.rsp_payload_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_CHUNK_VECTOR_FAILED, + "cannot create write chunks from vector " + "entry->rpc_payload"); + goto out; +@@ -1678,7 +1720,8 @@ __gf_rdma_create_write_chunks (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->msg.request.rsphdr_count, + request_ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_CHUNK_VECTOR_FAILED, + "cannot create write chunks from vector " + "entry->rpchdr"); + goto out; +@@ -1783,9 +1826,7 @@ __gf_rdma_request_context_destroy (gf_rdma_request_context_t *context) + if (priv->connected) { + ret = __gf_rdma_quota_put (peer); + if (ret < 0) { +- gf_log ("rdma", GF_LOG_DEBUG, +- "failed to send " +- "message"); ++ gf_msg_debug ("rdma", 0, "failed to send message"); + mem_put (context); + __gf_rdma_disconnect (peer->trans); + goto out; +@@ -1924,7 +1965,8 @@ __gf_rdma_ioq_churn_request (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if ((entry->msg.request.rsphdr_count != 0) + && (entry->msg.request.rsp_payload_count != 0)) { + ret = -1; +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_REPLY_CHUNCK_CONFLICT, + "both write-chunklist and reply-chunk cannot be " + "present"); + goto out; +@@ -1976,7 +2018,8 @@ __gf_rdma_ioq_churn_request (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + + if (chunk_count > GF_RDMA_MAX_SEGMENTS) { + ret = -1; +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CHUNK_COUNT_GREAT_MAX_SEGMENTS, + "chunk count(%d) exceeding maximum allowed RDMA " + "segment count(%d)", chunk_count, GF_RDMA_MAX_SEGMENTS); + goto out; +@@ -2022,7 +2065,8 @@ __gf_rdma_ioq_churn_request (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + &chunkptr, + request_ctx); + if (ret != 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CREATE_READ_CHUNK_FAILED, + "creation of read chunks failed"); + goto out; + } +@@ -2035,7 +2079,8 @@ __gf_rdma_ioq_churn_request (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + &chunkptr, + request_ctx); + if (ret != 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CREATE_WRITE_REPLAY_FAILED, + "creation of write/reply chunk failed"); + goto out; + } +@@ -2069,7 +2114,8 @@ __gf_rdma_ioq_churn_request (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if (!ret) { + ret = len; + } else { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POST_SEND_FAILED, + "gf_rdma_post_send (to %s) failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); +@@ -2141,7 +2187,8 @@ __gf_rdma_send_reply_inline (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if (send_size > GLUSTERFS_RDMA_INLINE_THRESHOLD) { + ret = __gf_rdma_send_error (peer, entry, post, reply_info, + ERR_CHUNK); +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_SIZE_GREAT_INLINE_THRESHOLD, + "msg size (%d) is greater than maximum size " + "of msg that can be sent inlined (%d)", + send_size, GLUSTERFS_RDMA_INLINE_THRESHOLD); +@@ -2178,8 +2225,9 @@ __gf_rdma_send_reply_inline (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + if (!ret) { + ret = send_size; + } else { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "posting send (to %s) failed with ret = %d (%s)", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POST_SEND_FAILED, "posting send (to %s) " ++ "failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); + gf_rdma_post_unref (post); +@@ -2212,9 +2260,9 @@ __gf_rdma_reply_encode_write_chunks (gf_rdma_peer_t *peer, + } + + if (chunk_size < payload_size) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, +- "length of payload (%d) is exceeding the total " +- "write chunk length (%d)", payload_size, chunk_size); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, "length of payload (%d) is " ++ "exceeding the total write chunk length (%d)", ++ payload_size, chunk_size); + goto out; + } + +@@ -2280,9 +2328,10 @@ __gf_rdma_register_local_mr_for_rdma (gf_rdma_peer_t *peer, + IBV_ACCESS_LOCAL_WRITE); + } + if (ctx->mr[ctx->mr_count] == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "registering memory for IBV_ACCESS_LOCAL_WRITE " +- "failed (%s)", strerror (errno)); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_MR_ALOC_FAILED, ++ "registering memory for IBV_ACCESS_LOCAL_WRITE" ++ " failed (%s)", strerror (errno)); + goto out; + } + +@@ -2330,9 +2379,9 @@ __gf_rdma_write (gf_rdma_peer_t *peer, gf_rdma_post_t *post, struct iovec *vec, + for ((i = *idx), (num_sge = 0); (xfer_len != 0); i++, num_sge++) { + size = min (xfer_len, vec[i].iov_len); + +- sg_list [num_sge].addr = (unsigned long)vec[i].iov_base; +- sg_list [num_sge].length = size; +- sg_list [num_sge].lkey = post->ctx.mr[i]->lkey; ++ sg_list[num_sge].addr = (unsigned long)vec[i].iov_base; ++ sg_list[num_sge].length = size; ++ sg_list[num_sge].lkey = post->ctx.mr[i]->lkey; + + xfer_len -= size; + } +@@ -2353,8 +2402,8 @@ __gf_rdma_write (gf_rdma_peer_t *peer, gf_rdma_post_t *post, struct iovec *vec, + + ret = ibv_post_send(peer->qp, &wr, &bad_wr); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma write to " ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_CLIENT_ERROR, "rdma write to " + "client (%s) failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); +@@ -2389,7 +2438,8 @@ __gf_rdma_do_gf_rdma_write (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + ret = __gf_rdma_register_local_mr_for_rdma (peer, vector, count, + &post->ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_MR_ALOC_FAILED, + "registering memory region for rdma failed"); + goto out; + } +@@ -2406,8 +2456,9 @@ __gf_rdma_do_gf_rdma_write (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + &payload_idx, + &reply_info->wc_array->wc_array[i]); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma write to client (%s) failed", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_CLIENT_ERROR, "rdma write to " ++ "client (%s) failed", + peer->trans->peerinfo.identifier); + goto out; + } +@@ -2450,8 +2501,8 @@ __gf_rdma_send_reply_type_nomsg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + reply_info, + (uint32_t **)&buf); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "encoding write chunks failed"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_ENCODE_ERROR, "encoding write chunks failed"); + ret = __gf_rdma_send_error (peer, entry, post, reply_info, + ERR_CHUNK); + goto out; +@@ -2470,18 +2521,19 @@ __gf_rdma_send_reply_type_nomsg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + ret = __gf_rdma_do_gf_rdma_write (peer, post, vector, count, + entry->iobref, reply_info); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma write to peer (%s) failed", +- peer->trans->peerinfo.identifier); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_PEER_FAILED, "rdma write to peer " ++ "(%s) failed", peer->trans->peerinfo.identifier); + gf_rdma_post_unref (post); + goto out; + } + + ret = gf_rdma_post_send (peer->qp, post, (buf - post->buf)); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "posting a send request to client (%s) failed with " +- "ret = %d (%s)", peer->trans->peerinfo.identifier, ret, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POST_SEND_FAILED, "posting a send request " ++ "to client (%s) failed with ret = %d (%s)", ++ peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); + ret = -1; + gf_rdma_post_unref (post); +@@ -2509,7 +2561,8 @@ __gf_rdma_send_reply_type_msg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + + GLUSTERFS_RDMA_MAX_HEADER_SIZE; + + if (send_size > GLUSTERFS_RDMA_INLINE_THRESHOLD) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_SIZE_GREAT_INLINE_THRESHOLD, + "client has provided only write chunks, but the " + "combined size of rpc and program header (%d) is " + "exceeding the size of msg that can be sent using " +@@ -2534,8 +2587,8 @@ __gf_rdma_send_reply_type_msg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + reply_info, + (uint32_t **)&ptr); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "encoding write chunks failed"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_ENCODE_ERROR, "encoding write chunks failed"); + ret = __gf_rdma_send_error (peer, entry, post, reply_info, + ERR_CHUNK); + goto out; +@@ -2550,7 +2603,8 @@ __gf_rdma_send_reply_type_msg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + entry->prog_payload_count, + entry->iobref, reply_info); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, "rdma write to peer " ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_PEER_FAILED, "rdma write to peer " + "(%s) failed", peer->trans->peerinfo.identifier); + gf_rdma_post_unref (post); + goto out; +@@ -2564,7 +2618,8 @@ __gf_rdma_send_reply_type_msg (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + + ret = gf_rdma_post_send (peer->qp, post, (ptr - post->buf)); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_CLIENT_ERROR, + "rdma send to client (%s) failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, ret, + (ret > 0) ? strerror (ret) : ""); +@@ -2640,7 +2695,8 @@ __gf_rdma_ioq_churn_reply (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + ret = __gf_rdma_send_reply_inline (peer, entry, post, + reply_info); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_REPLY_FAILED, + "failed to send reply to peer (%s) as an " + "inlined rdma msg", + peer->trans->peerinfo.identifier); +@@ -2651,7 +2707,8 @@ __gf_rdma_ioq_churn_reply (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + ret = __gf_rdma_send_reply_type_nomsg (peer, entry, post, + reply_info); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_REPLY_FAILED, + "failed to send reply to peer (%s) as " + "RDMA_NOMSG", peer->trans->peerinfo.identifier); + } +@@ -2661,7 +2718,8 @@ __gf_rdma_ioq_churn_reply (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + ret = __gf_rdma_send_reply_type_msg (peer, entry, post, + reply_info); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_SEND_REPLY_FAILED, + "failed to send reply with write chunks " + "to peer (%s)", + peer->trans->peerinfo.identifier); +@@ -2669,7 +2727,8 @@ __gf_rdma_ioq_churn_reply (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry, + break; + + default: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_CHUNK_TYPE, + "invalid chunktype (%d) specified for sending reply " + " (peer:%s)", type, peer->trans->peerinfo.identifier); + break; +@@ -2715,7 +2774,8 @@ __gf_rdma_ioq_churn_entry (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry) + if (entry->is_request) { + ret = __gf_rdma_ioq_churn_request (peer, entry, post); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PROC_IOQ_ENTRY_FAILED, + "failed to process request ioq entry " + "to peer(%s)", + peer->trans->peerinfo.identifier); +@@ -2723,7 +2783,8 @@ __gf_rdma_ioq_churn_entry (gf_rdma_peer_t *peer, gf_rdma_ioq_t *entry) + } else { + ret = __gf_rdma_ioq_churn_reply (peer, entry, post); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PROC_IOQ_ENTRY_FAILED, + "failed to process reply ioq entry " + "to peer (%s)", + peer->trans->peerinfo.identifier); +@@ -2748,8 +2809,7 @@ __gf_rdma_ioq_churn (gf_rdma_peer_t *peer) + gf_rdma_ioq_t *entry = NULL; + int32_t ret = 0; + +- while (!list_empty (&peer->ioq)) +- { ++ while (!list_empty (&peer->ioq)) { + /* pick next entry */ + entry = peer->ioq_next; + +@@ -2783,7 +2843,8 @@ gf_rdma_writev (rpc_transport_t *this, gf_rdma_ioq_t *entry) + pthread_mutex_lock (&priv->write_mutex); + { + if (!priv->connected) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_PEER_DISCONNECTED, + "rdma is not connected to peer (%s)", + this->peerinfo.identifier); + ret = -1; +@@ -2797,9 +2858,10 @@ gf_rdma_writev (rpc_transport_t *this, gf_rdma_ioq_t *entry) + need_append = 0; + + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "processing ioq entry destined " +- "to (%s) failed", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_PROC_IOQ_ENTRY_FAILED, ++ "processing ioq entry destined" ++ " to (%s) failed", + this->peerinfo.identifier); + } + } +@@ -2942,7 +3004,8 @@ gf_rdma_submit_request (rpc_transport_t *this, rpc_transport_req_t *req) + + entry = gf_rdma_ioq_new (this, &data); + if (entry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_NEW_IOQ_ENTRY_FAILED, + "getting a new ioq entry failed (peer:%s)", + this->peerinfo.identifier); + goto out; +@@ -2953,7 +3016,8 @@ gf_rdma_submit_request (rpc_transport_t *this, rpc_transport_req_t *req) + if (ret > 0) { + ret = 0; + } else if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_PEER_FAILED, + "sending request to peer (%s) failed", + this->peerinfo.identifier); + rpc_transport_disconnect (this); +@@ -2978,7 +3042,8 @@ gf_rdma_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply) + + entry = gf_rdma_ioq_new (this, &data); + if (entry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_NEW_IOQ_ENTRY_FAILED, + "getting a new ioq entry failed (peer:%s)", + this->peerinfo.identifier); + goto out; +@@ -2988,7 +3053,8 @@ gf_rdma_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply) + if (ret > 0) { + ret = 0; + } else if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_WRITE_PEER_FAILED, + "sending request to peer (%s) failed", + this->peerinfo.identifier); + rpc_transport_disconnect (this); +@@ -3129,7 +3195,9 @@ gf_rdma_create_qp (rpc_transport_t *this) + device_name = (char *)ibv_get_device_name (peer->cm_id->verbs->device); + if (device_name == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_WARNING, "cannot get device_name"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_DEVICE_NAME_FAILED, "cannot get " ++ "device_name"); + goto out; + } + +@@ -3137,7 +3205,8 @@ gf_rdma_create_qp (rpc_transport_t *this) + device_name); + if (device == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_WARNING, "cannot get device for " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_DEVICE_FAILED, "cannot get device for " + "device %s", device_name); + goto out; + } +@@ -3161,9 +3230,9 @@ gf_rdma_create_qp (rpc_transport_t *this) + + ret = rdma_create_qp(peer->cm_id, device->pd, &init_attr); + if (ret != 0) { +- gf_log (peer->trans->name, GF_LOG_CRITICAL, +- "%s: could not create QP (%s)", this->name, +- strerror (errno)); ++ gf_msg (peer->trans->name, GF_LOG_CRITICAL, errno, ++ RDMA_MSG_CREAT_QP_FAILED, "%s: could not create QP " ++ "(%s)", this->name, strerror (errno)); + ret = -1; + goto out; + } +@@ -3358,8 +3427,9 @@ gf_rdma_decode_error_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + ret = rpc_reply_to_xdr (&rpc_msg, iobuf_ptr (iobuf), + iobuf_pagesize (iobuf), &post->ctx.vector[0]); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "Failed to create RPC reply"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_RPC_REPLY_CREATE_FAILED, "Failed to create " ++ "RPC reply"); + goto out; + } + +@@ -3400,8 +3470,9 @@ gf_rdma_decode_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + + ret = gf_rdma_get_read_chunklist (&ptr, readch); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "cannot get read chunklist from msg"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_READ_CHUNK_FAILED, "cannot get read " ++ "chunklist from msg"); + goto out; + } + +@@ -3410,8 +3481,9 @@ gf_rdma_decode_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + + ret = gf_rdma_get_write_chunklist (&ptr, &write_ary); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "cannot get write chunklist from msg"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_GET_WRITE_CHUNK_FAILED, "cannot get write " ++ "chunklist from msg"); + goto out; + } + +@@ -3421,7 +3493,8 @@ gf_rdma_decode_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + if (write_ary != NULL) { + reply_info = gf_rdma_reply_info_alloc (peer); + if (reply_info == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_REPLY_INFO_ALLOC_FAILED, + "reply_info_alloc failed"); + ret = -1; + goto out; +@@ -3433,15 +3506,17 @@ gf_rdma_decode_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + } else { + ret = gf_rdma_get_write_chunklist (&ptr, &write_ary); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "cannot get reply chunklist from msg"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_CHUNKLIST_ERROR, "cannot get reply " ++ "chunklist from msg"); + goto out; + } + + if (write_ary != NULL) { + reply_info = gf_rdma_reply_info_alloc (peer); + if (reply_info == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_REPLY_INFO_ALLOC_FAILED, + "reply_info_alloc_failed"); + ret = -1; + goto out; +@@ -3507,36 +3582,38 @@ gf_rdma_decode_header (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + case GF_RDMA_NOMSG: + ret = gf_rdma_decode_msg (peer, post, readch, bytes_in_post); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "cannot decode msg of type (%d)", +- header->rm_type); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_ENCODE_ERROR, "cannot decode msg of " ++ "type (%d)", header->rm_type); + } + + break; + + case GF_RDMA_MSGP: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma msg of msg-type GF_RDMA_MSGP should not have " +- "been received"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_ENTRY, "rdma msg of msg-type " ++ "GF_RDMA_MSGP should not have been received"); + ret = -1; + break; + + case GF_RDMA_DONE: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma msg of msg-type GF_RDMA_DONE should not have " +- "been received"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_ENTRY, "rdma msg of msg-type " ++ "GF_RDMA_DONE should not have been received"); + ret = -1; + break; + + case GF_RDMA_ERROR: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "received a msg of type RDMA_ERROR"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_RDMA_ERROR_RECEIVED, "received a msg of type" ++ " RDMA_ERROR"); + ret = gf_rdma_decode_error_msg (peer, post, bytes_in_post); + break; + + default: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "unknown rdma msg-type (%d)", header->rm_type); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_ENTRY, "unknown rdma msg-type (%d)", ++ header->rm_type); + } + + return ret; +@@ -3562,9 +3639,10 @@ gf_rdma_do_reads (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + } + + if (i == 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "message type specified as rdma-read but there are no " +- "rdma read-chunks present"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_CHUNK_TYPE, "message type specified " ++ "as rdma-read but there are no rdma read-chunks " ++ "present"); + goto out; + } + +@@ -3592,9 +3670,9 @@ gf_rdma_do_reads (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + pthread_mutex_lock (&priv->write_mutex); + { + if (!priv->connected) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "transport not connected to peer (%s), " +- "not doing rdma reads", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PEER_DISCONNECTED, "transport not " ++ "connected to peer (%s), not doing rdma reads", + peer->trans->peerinfo.identifier); + goto unlock; + } +@@ -3623,7 +3701,8 @@ gf_rdma_do_reads (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + ret = __gf_rdma_register_local_mr_for_rdma (peer, + &post->ctx.vector[count], 1, &post->ctx); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_MR_ALOC_FAILED, + "registering local memory" + " for rdma read failed"); + goto unlock; +@@ -3652,9 +3731,9 @@ gf_rdma_do_reads (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + wr[i-1].next = NULL; + ret = ibv_post_send (peer->qp, wr, &bad_wr); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma read from client " +- "(%s) failed with ret = %d (%s)", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_READ_CLIENT_ERROR, "rdma read from " ++ "client (%s) failed with ret = %d (%s)", + peer->trans->peerinfo.identifier, + ret, (ret > 0) ? strerror (ret) : ""); + +@@ -3746,16 +3825,15 @@ gf_rdma_pollin_notify (gf_rdma_peer_t *peer, gf_rdma_post_t *post) + RPC_TRANSPORT_MAP_XID_REQUEST, + &request_info); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, +- "cannot get request information from rpc " +- "layer"); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, "cannot get request" ++ "information from rpc layer"); + goto out; + } + + rpc_req = request_info.rpc_req; + if (rpc_req == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, +- "rpc request structure not found"); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, "rpc request " ++ "structure not found"); + ret = -1; + goto out; + } +@@ -3780,8 +3858,8 @@ gf_rdma_pollin_notify (gf_rdma_peer_t *peer, gf_rdma_post_t *post) + ret = rpc_transport_notify (peer->trans, RPC_TRANSPORT_MSG_RECEIVED, + pollin); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "transport_notify failed"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ TRANS_MSG_TRANSPORT_ERROR, "transport_notify failed"); + } + + out: +@@ -3843,16 +3921,18 @@ gf_rdma_recv_reply (gf_rdma_peer_t *peer, gf_rdma_post_t *post) + RPC_TRANSPORT_MAP_XID_REQUEST, + &request_info); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "cannot get request information (peer:%s) from rpc " +- "layer", peer->trans->peerinfo.identifier); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ TRANS_MSG_TRANSPORT_ERROR, "cannot get request " ++ "information (peer:%s) from rpc layer", ++ peer->trans->peerinfo.identifier); + goto out; + } + + rpc_req = request_info.rpc_req; + if (rpc_req == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rpc request structure not found"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_RPC_ST_ERROR, "rpc request structure not " ++ "found"); + ret = -1; + goto out; + } +@@ -3870,7 +3950,8 @@ out: + if (ret == 0) { + ret = gf_rdma_pollin_notify (peer, post); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POLL_IN_NOTIFY_FAILED, + "pollin notify failed"); + } + } +@@ -3888,14 +3969,16 @@ gf_rdma_recv_request (gf_rdma_peer_t *peer, gf_rdma_post_t *post, + if (readch != NULL) { + ret = gf_rdma_do_reads (peer, post, readch); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PEER_READ_FAILED, + "rdma read from peer (%s) failed", + peer->trans->peerinfo.identifier); + } + } else { + ret = gf_rdma_pollin_notify (peer, post); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POLL_IN_NOTIFY_FAILED, + "pollin notification failed"); + } + } +@@ -3916,15 +3999,17 @@ gf_rdma_process_recv (gf_rdma_peer_t *peer, struct ibv_wc *wc) + + post = (gf_rdma_post_t *) (long) wc->wr_id; + if (post == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "no post found in successful work completion element"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_POST_MISSING, "no post found in successful " ++ "work completion element"); + goto out; + } + + ret = gf_rdma_decode_header (peer, post, &readch, wc->byte_len); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "decoding of header failed"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_HEADER_DECODE_FAILED, "decoding of header " ++ "failed"); + goto out; + } + +@@ -3945,7 +4030,7 @@ gf_rdma_process_recv (gf_rdma_peer_t *peer, struct ibv_wc *wc) + * instead of directly setting it to header->rm_credit. + */ + priv->peer.quota = header->rm_credit +- - ( 1 - priv->peer.quota); ++ - (1 - priv->peer.quota); + } + } + pthread_mutex_unlock (&priv->write_mutex); +@@ -3966,7 +4051,8 @@ gf_rdma_process_recv (gf_rdma_peer_t *peer, struct ibv_wc *wc) + + case GF_RDMA_ERROR: + if (header->rm_body.rm_error.rm_type == ERR_CHUNK) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_RDMA_ERROR_RECEIVED, + "peer (%s), couldn't encode or decode the msg " + "properly or write chunks were not provided " + "for replies that were bigger than " +@@ -3975,36 +4061,40 @@ gf_rdma_process_recv (gf_rdma_peer_t *peer, struct ibv_wc *wc) + GLUSTERFS_RDMA_INLINE_THRESHOLD); + ret = gf_rdma_pollin_notify (peer, post); + if (ret == -1) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, +- "pollin notification failed"); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, "pollin " ++ "notification failed"); + } + goto out; + } else { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, +- "an error has happened while transmission of " +- "msg, disconnecting the transport"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, 0, ++ TRANS_MSG_TRANSPORT_ERROR, "an error has " ++ "happened while transmission of msg, " ++ "disconnecting the transport"); + ret = -1; + goto out; + } + + default: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "invalid rdma msg-type (%d)", header->rm_type); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_INVALID_ENTRY, "invalid rdma msg-type (%d)", ++ header->rm_type); + goto out; + } + + if (msg_type == CALL) { + ret = gf_rdma_recv_request (peer, post, readch); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "receiving a request from peer (%s) failed", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PEER_REQ_FAILED, "receiving a request" ++ " from peer (%s) failed", + peer->trans->peerinfo.identifier); + } + } else { + ret = gf_rdma_recv_reply (peer, post); + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "receiving a reply from peer (%s) failed", ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_PEER_REP_FAILED, "receiving a reply " ++ "from peer (%s) failed", + peer->trans->peerinfo.identifier); + } + } +@@ -4029,21 +4119,22 @@ gf_rdma_async_event_thread (void *context) + &event); + + if (ret && errno != EINTR) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "Error getting event (%s)", +- strerror (errno)); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_EVENT_ERROR, "Error getting " ++ "event (%s)", strerror (errno)); + } +- } while(ret && errno == EINTR); ++ } while (ret && errno == EINTR); + + switch (event.event_type) { + case IBV_EVENT_SRQ_LIMIT_REACHED: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "received srq_limit reached"); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_EVENT_SRQ_LIMIT_REACHED, "received " ++ "srq_limit reached"); + break; + + default: +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, +- "event (%d) received", event.event_type); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, "event (%d) " ++ "received", event.event_type); + break; + } + +@@ -4074,7 +4165,8 @@ gf_rdma_recv_completion_proc (void *data) + failed = 0; + ret = ibv_get_cq_event (chan, &event_cq, &event_ctx); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_GET_CQ_FAILED, + "ibv_get_cq_event failed, terminating recv " + "thread %d (%d)", ret, errno); + continue; +@@ -4084,7 +4176,8 @@ gf_rdma_recv_completion_proc (void *data) + + ret = ibv_req_notify_cq (event_cq, 0); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_REQ_NOTIFY_CQ_FAILED, + "ibv_req_notify_cq on %s failed, terminating " + "recv thread: %d (%d)", + device->device_name, ret, errno); +@@ -4119,9 +4212,10 @@ gf_rdma_recv_completion_proc (void *data) + pthread_mutex_unlock (&device->qpreg.lock); + + if (wc[index].status != IBV_WC_SUCCESS) { +- gf_log (GF_RDMA_LOG_NAME, +- GF_LOG_ERROR, "recv work request " +- "on `%s' returned error (%d)", ++ gf_msg (GF_RDMA_LOG_NAME, ++ GF_LOG_ERROR, 0, ++ RDMA_MSG_RECV_ERROR, "recv work " ++ "request on `%s' returned error (%d)", + device->device_name, + wc[index].status); + failed = 1; +@@ -4142,10 +4236,10 @@ gf_rdma_recv_completion_proc (void *data) + &wc[index]); + rpc_transport_unref (peer->trans); + } else { +- gf_log (GF_RDMA_LOG_NAME, +- GF_LOG_DEBUG, +- "could not lookup peer for qp_num: %d", +- wc[index].qp_num); ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, ++ "could not lookup peer " ++ "for qp_num: %d", ++ wc[index].qp_num); + } + + gf_rdma_post_unref (post); +@@ -4153,8 +4247,8 @@ gf_rdma_recv_completion_proc (void *data) + } + + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, +- GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_POLL_CQ_ERROR, + "ibv_poll_cq on `%s' returned error " + "(ret = %d, errno = %d)", + device->device_name, ret, errno); +@@ -4185,7 +4279,8 @@ gf_rdma_handle_failed_send_completion (gf_rdma_peer_t *peer, struct ibv_wc *wc) + + post = (gf_rdma_post_t *) (long) wc->wr_id; + +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_RDMA_HANDLE_FAILED, + "send work request on `%s' returned error " + "wc.status = %d, wc.vendor_err = %d, post->buf = %p, " + "wc.byte_len = %d, post->reused = %d", +@@ -4193,12 +4288,13 @@ gf_rdma_handle_failed_send_completion (gf_rdma_peer_t *peer, struct ibv_wc *wc) + wc->vendor_err, post->buf, wc->byte_len, post->reused); + + if (wc->status == IBV_WC_RETRY_EXC_ERR) { +- gf_log ("rdma", GF_LOG_ERROR, "connection between client and" +- " server not working. check by running " +- "'ibv_srq_pingpong'. also make sure subnet manager" +- " is running (eg: 'opensm'), or check if rdma port is " +- "valid (or active) by running 'ibv_devinfo'. contact " +- "Gluster Support Team if the problem persists."); ++ gf_msg ("rdma", GF_LOG_ERROR, 0, TRANS_MSG_TIMEOUT_EXCEEDED, ++ "connection between client and server not working. " ++ "check by running 'ibv_srq_pingpong'. also make sure " ++ "subnet manager is running (eg: 'opensm'), or check " ++ "if rdma port is valid (or active) by running " ++ "'ibv_devinfo'. contact Gluster Support Team if the " ++ "problem persists."); + } + + if (peer) { +@@ -4279,7 +4375,8 @@ gf_rdma_send_completion_proc (void *data) + failed = 0; + ret = ibv_get_cq_event (chan, &event_cq, &event_ctx); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_GET_CQ_FAILED, + "ibv_get_cq_event on failed, terminating " + "send thread: %d (%d)", ret, errno); + continue; +@@ -4289,7 +4386,8 @@ gf_rdma_send_completion_proc (void *data) + + ret = ibv_req_notify_cq (event_cq, 0); + if (ret) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_REQ_NOTIFY_CQ_FAILED, + "ibv_req_notify_cq on %s failed, terminating " + "send thread: %d (%d)", + device->device_name, ret, errno); +@@ -4351,10 +4449,9 @@ gf_rdma_send_completion_proc (void *data) + quota_ret = gf_rdma_quota_put + (peer); + if (quota_ret < 0) { +- gf_log ("rdma", +- GF_LOG_DEBUG, +- "failed to send " +- "message"); ++ gf_msg_debug ("rdma", ++ 0, "failed to send " ++ "message"); + } + } + } +@@ -4362,7 +4459,7 @@ gf_rdma_send_completion_proc (void *data) + if (peer) { + rpc_transport_unref (peer->trans); + } else { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_DEBUG, ++ gf_msg_debug (GF_RDMA_LOG_NAME, 0, + "could not lookup peer for qp_num: %d", + wc[index].qp_num); + +@@ -4371,7 +4468,8 @@ gf_rdma_send_completion_proc (void *data) + } + + if (ret < 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_ERROR, errno, ++ RDMA_MSG_IBV_POLL_CQ_ERROR, + "ibv_poll_cq on `%s' returned error (ret = %d," + " errno = %d)", + device->device_name, ret, errno); +@@ -4442,26 +4540,30 @@ gf_rdma_options_init (rpc_transport_t *this) + if (temp) + mtu = data_to_int32 (temp); + switch (mtu) { ++ + case 256: options->mtu = IBV_MTU_256; + break; ++ + case 512: options->mtu = IBV_MTU_512; + break; ++ + case 1024: options->mtu = IBV_MTU_1024; + break; ++ + case 2048: options->mtu = IBV_MTU_2048; + break; ++ + case 4096: options->mtu = IBV_MTU_4096; + break; + default: + if (temp) +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "%s: unrecognized MTU value '%s', defaulting " +- "to '2048'", this->name, +- data_to_str (temp)); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, 0, ++ RDMA_MSG_UNRECG_MTU_VALUE, "%s: unrecognized " ++ "MTU value '%s', defaulting to '2048'", ++ this->name, data_to_str (temp)); + else +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_TRACE, +- "%s: defaulting MTU to '2048'", +- this->name); ++ gf_msg_trace (GF_RDMA_LOG_NAME, 0, "%s: defaulting " ++ "MTU to '2048'", this->name); + options->mtu = IBV_MTU_2048; + break; + } +@@ -4488,9 +4590,9 @@ __gf_rdma_ctx_create (void) + pthread_mutex_init (&rdma_ctx->lock, NULL); + rdma_ctx->rdma_cm_event_channel = rdma_create_event_channel (); + if (rdma_ctx->rdma_cm_event_channel == NULL) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "rdma_cm event channel creation failed (%s)", +- strerror (errno)); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, ++ RDMA_MSG_CM_EVENT_FAILED, "rdma_cm event channel " ++ "creation failed (%s)", strerror (errno)); + goto out; + } + +@@ -4498,9 +4600,9 @@ __gf_rdma_ctx_create (void) + gf_rdma_cm_event_handler, + rdma_ctx->rdma_cm_event_channel); + if (ret != 0) { +- gf_log (GF_RDMA_LOG_NAME, GF_LOG_WARNING, +- "creation of thread to handle rdma-cm events " +- "failed (%s)", strerror (ret)); ++ gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ret, ++ RDMA_MSG_CM_EVENT_FAILED, "creation of thread to " ++ "handle rdma-cm events failed (%s)", strerror (ret)); + goto out; + } + +@@ -4525,7 +4627,7 @@ gf_rdma_init (rpc_transport_t *this) + glusterfs_ctx_t *ctx = NULL; + gf_rdma_options_t *options = NULL; + +- ctx= this->ctx; ++ ctx = this->ctx; + + priv = this->private; + +@@ -4602,8 +4704,8 @@ gf_rdma_connect (struct rpc_transport *this, int port) + &sock_union.sa, + &sockaddr_len, port); + if (ret != 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "cannot get remote address to connect"); ++ gf_msg_debug (this->name, 0, "cannot get remote address to " ++ "connect"); + goto out; + } + +@@ -4623,9 +4725,9 @@ gf_rdma_connect (struct rpc_transport *this, int port) + ret = rdma_create_id (rdma_ctx->rdma_cm_event_channel, + &peer->cm_id, this, RDMA_PS_TCP); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "creation of rdma_cm_id failed (%s)", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ RDMA_MSG_CM_EVENT_FAILED, "creation of " ++ "rdma_cm_id failed (%s)", strerror (errno)); + ret = -errno; + goto unlock; + } +@@ -4645,7 +4747,8 @@ gf_rdma_connect (struct rpc_transport *this, int port) + &this->myinfo.sockaddr_len, + peer->cm_id); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_CLIENT_BIND_FAILED, + "client bind failed: %s", strerror (errno)); + goto unlock; + } +@@ -4653,7 +4756,8 @@ gf_rdma_connect (struct rpc_transport *this, int port) + ret = rdma_resolve_addr (peer->cm_id, NULL, &sock_union.sa, + 2000); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_RDMA_RESOLVE_ADDR_FAILED, + "rdma_resolve_addr failed (%s)", + strerror (errno)); + goto unlock; +@@ -4699,7 +4803,8 @@ gf_rdma_listen (rpc_transport_t *this) + ret = gf_rdma_server_get_local_sockaddr (this, &sock_union.sa, + &sockaddr_len); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_NW_ADDR_UNKNOWN, + "cannot find network address of server to bind to"); + goto err; + } +@@ -4707,9 +4812,9 @@ gf_rdma_listen (rpc_transport_t *this) + ret = rdma_create_id (rdma_ctx->rdma_cm_event_channel, + &peer->cm_id, this, RDMA_PS_TCP); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "creation of rdma_cm_id failed (%s)", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_CM_EVENT_FAILED, "creation of rdma_cm_id " ++ "failed (%s)", strerror (errno)); + goto err; + } + +@@ -4722,7 +4827,8 @@ gf_rdma_listen (rpc_transport_t *this) + service, sizeof (service), + NI_NUMERICHOST); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ TRANS_MSG_GET_NAME_INFO_FAILED, + "getnameinfo failed (%s)", gai_strerror (ret)); + goto err; + } +@@ -4733,21 +4839,24 @@ gf_rdma_listen (rpc_transport_t *this) + RDMA_OPTION_ID_REUSEADDR, + (void *)&optval, sizeof(optval)); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "rdma option set failed (%s)", strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_OPTION_SET_FAILED, "rdma option set failed " ++ "(%s)", strerror (errno)); + goto err; + } + + ret = rdma_bind_addr (peer->cm_id, &sock_union.sa); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_RDMA_BIND_ADDR_FAILED, + "rdma_bind_addr failed (%s)", strerror (errno)); + goto err; + } + + ret = rdma_listen (peer->cm_id, 10); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ RDMA_MSG_LISTEN_FAILED, + "rdma_listen failed (%s)", strerror (errno)); + goto err; + } +@@ -4789,7 +4898,8 @@ init (rpc_transport_t *this) + this->private = priv; + + if (gf_rdma_init (this)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ RDMA_MSG_INIT_IB_DEVICE_FAILED, + "Failed to initialize IB Device"); + this->private = NULL; + GF_FREE (priv); +@@ -4830,8 +4940,8 @@ fini (struct rpc_transport *this) + pthread_mutex_destroy (&priv->recv_mutex); + pthread_mutex_destroy (&priv->write_mutex); + +- gf_log (this->name, GF_LOG_TRACE, +- "called fini on transport: %p", this); ++ gf_msg_trace (this->name, 0, ++ "called fini on transport: %p", this); + GF_FREE (priv); + } + +diff --git a/rpc/rpc-transport/rdma/src/rpc-trans-rdma-messages.h b/rpc/rpc-transport/rdma/src/rpc-trans-rdma-messages.h +new file mode 100644 +index 0000000..0957de2 +--- /dev/null ++++ b/rpc/rpc-transport/rdma/src/rpc-trans-rdma-messages.h +@@ -0,0 +1,217 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _RPC_TRANS_RDMA_MESSAGES_H_ ++#define _RPC_TRANS_RDMA_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES_RDMA ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_RPC_TRANS_RDMA_BASE GLFS_MSGID_COMP_RPC_TRANS_RDMA ++#define GLFS_NUM_MESSAGES_RDMA 77 ++#define GLFS_RPC_TRANS_RDMA_MSGID_END (GLFS_RPC_TRANS_RDMA_BASE + GLFS_NUM_MESSAGES_RDMA + 1) ++ ++/* Messages with message IDs */ ++ ++#define glfs_msg_start_rdma GLFS_RPC_TRANS_RDMA_BASE, "Invalid: Start of messages" ++ ++/* This slot/segment is allocated for RDMA message IDs ++ * The allocation starts from BASE. ++ ++*/ ++ ++#define RDMA_MSG_PORT_BIND_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 1) ++ ++#define RDMA_MSG_POST_CREATION_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 2) ++ ++#define RDMA_MSG_DEREGISTER_ARENA_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 3) ++ ++#define RDMA_MSG_MR_ALOC_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 4) ++ ++#define RDMA_MSG_PREREG_BUFFER_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 5) ++ ++#define RDMA_MSG_CQ_CREATION_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 6) ++ ++#define RDMA_MSG_REQ_NOTIFY_CQ_REVQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 7) ++ ++#define RDMA_MSG_QUERY_DEVICE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 8) ++ ++#define RDMA_MSG_REQ_NOTIFY_CQ_SENDQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 9) ++ ++#define RDMA_MSG_SEND_COMP_CHAN_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 10) ++ ++#define RDMA_MSG_RECV_COMP_CHAN_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 11) ++ ++#define RDMA_MSG_ALOC_PROT_DOM_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 12) ++ ++#define RDMA_MSG_CRE_SRQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 13) ++ ++#define RDMA_MSG_ALOC_POST_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 14) ++ ++#define RDMA_MSG_SEND_COMP_THREAD_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 15) ++ ++#define RDMA_MSG_RECV_COMP_THREAD_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 16) ++ ++#define RDMA_MSG_ASYNC_EVENT_THEAD_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 17) ++ ++#define RDMA_MSG_GET_DEVICE_NAME_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 18) ++ ++#define RDMA_MSG_GET_IB_DEVICE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 19) ++ ++#define RDMA_MSG_CREAT_INC_TRANS_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 20) ++ ++#define RDMA_MSG_CREAT_QP_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 21) ++ ++#define RDMA_MSG_ACCEPT_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 22) ++ ++#define RDMA_MSG_CONNECT_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 23) ++ ++#define RDMA_MSG_ROUTE_RESOLVE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 24) ++ ++#define RDMA_MSG_GET_DEVICE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 25) ++ ++#define RDMA_MSG_PEER_DISCONNECTED (GLFS_RPC_TRANS_RDMA_BASE + 26) ++ ++#define RDMA_MSG_ENCODE_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 27) ++ ++#define RDMA_MSG_POST_SEND_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 28) ++ ++#define RDMA_MSG_READ_CHUNK_VECTOR_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 29) ++ ++#define RDMA_MSG_WRITE_CHUNK_VECTOR_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 30) ++ ++#define RDMA_MSG_WRITE_REPLY_CHUNCK_CONFLICT (GLFS_RPC_TRANS_RDMA_BASE + 31) ++ ++#define RDMA_MSG_CHUNK_COUNT_GREAT_MAX_SEGMENTS (GLFS_RPC_TRANS_RDMA_BASE + 32) ++ ++#define RDMA_MSG_CREATE_READ_CHUNK_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 33) ++ ++#define RDMA_MSG_CREATE_WRITE_REPLAY_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 34) ++ ++#define RDMA_MSG_SEND_SIZE_GREAT_INLINE_THRESHOLD (GLFS_RPC_TRANS_RDMA_BASE + 35) ++ ++#define RDMA_MSG_REG_ACCESS_LOCAL_WRITE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 36) ++ ++#define RDMA_MSG_WRITE_PEER_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 37) ++ ++#define RDMA_MSG_SEND_REPLY_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 38) ++ ++#define RDMA_MSG_INVALID_CHUNK_TYPE (GLFS_RPC_TRANS_RDMA_BASE + 39) ++ ++#define RDMA_MSG_PROC_IOQ_ENTRY_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 40) ++ ++#define RDMA_MSG_NEW_IOQ_ENTRY_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 41) ++ ++#define RDMA_MSG_RPC_REPLY_CREATE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 42) ++ ++#define RDMA_MSG_GET_READ_CHUNK_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 43) ++ ++#define RDMA_MSG_GET_WRITE_CHUNK_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 44) ++ ++#define RDMA_MSG_REPLY_INFO_ALLOC_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 45) ++ ++#define RDMA_MSG_RDMA_ERROR_RECEIVED (GLFS_RPC_TRANS_RDMA_BASE + 46) ++ ++#define RDMA_MSG_GET_REQ_INFO_RPC_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 47) ++ ++#define RDMA_MSG_POLL_IN_NOTIFY_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 48) ++ ++#define RDMA_MSG_HEADER_DECODE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 49) ++ ++#define RDMA_MSG_EVENT_SRQ_LIMIT_REACHED (GLFS_RPC_TRANS_RDMA_BASE + 50) ++ ++#define RDMA_MSG_UNRECG_MQ_VALUE (GLFS_RPC_TRANS_RDMA_BASE + 51) ++ ++#define RDMA_MSG_BUFFER_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 52) ++ ++#define RDMA_MSG_OPTION_SET_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 53) ++ ++#define RDMA_MSG_LISTEN_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 54) ++ ++#define RDMA_MSG_INIT_IB_DEVICE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 55) ++ ++#define RDMA_MSG_WRITE_CLIENT_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 56) ++ ++#define RDMA_MSG_CHUNKLIST_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 57) ++ ++#define RDMA_MSG_INVALID_ENTRY (GLFS_RPC_TRANS_RDMA_BASE + 58) ++ ++#define RDMA_MSG_READ_CLIENT_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 59) ++ ++#define RDMA_MSG_RPC_ST_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 60) ++ ++#define RDMA_MSG_PEER_READ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 61) ++ ++#define RDMA_MSG_POST_MISSING (GLFS_RPC_TRANS_RDMA_BASE + 62) ++ ++#define RDMA_MSG_PEER_REQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 63) ++ ++#define RDMA_MSG_PEER_REP_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 64) ++ ++#define RDMA_MSG_EVENT_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 65) ++ ++#define RDMA_MSG_IBV_GET_CQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 66) ++ ++#define RDMA_MSG_IBV_REQ_NOTIFY_CQ_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 67) ++ ++#define RDMA_MSG_RECV_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 68) ++ ++#define RDMA_MSG_IBV_POLL_CQ_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 69) ++ ++#define RDMA_MSG_RDMA_HANDLE_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 70) ++ ++#define RDMA_MSG_CM_EVENT_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 71) ++ ++#define RDMA_MSG_CLIENT_BIND_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 72) ++ ++#define RDMA_MSG_RDMA_RESOLVE_ADDR_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 73) ++ ++#define RDMA_MSG_NW_ADDR_UNKNOWN (GLFS_RPC_TRANS_RDMA_BASE + 74) ++ ++#define RDMA_MSG_RDMA_BIND_ADDR_FAILED (GLFS_RPC_TRANS_RDMA_BASE + 75) ++ ++#define RDMA_MSG_SEND_CLIENT_ERROR (GLFS_RPC_TRANS_RDMA_BASE + 76) ++ ++#define RDMA_MSG_UNRECG_MTU_VALUE (GLFS_RPC_TRANS_RDMA_BASE + 77) ++ ++ ++ ++/*------------*/ ++ ++#define glfs_msg_end_rdma GLFS_RPC_TRANS_RDMA_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_RPC_TRANS_RDMA_MESSAGES_H_ */ ++ +-- +1.7.1 + diff --git a/SOURCES/0111-glusterd-afr-set-afr-pending-xattrs-on-replace-brick.patch b/SOURCES/0111-glusterd-afr-set-afr-pending-xattrs-on-replace-brick.patch new file mode 100644 index 0000000..fbb76c3 --- /dev/null +++ b/SOURCES/0111-glusterd-afr-set-afr-pending-xattrs-on-replace-brick.patch @@ -0,0 +1,667 @@ +From 9bcb02bdc78fdc960004cfef77062bd74b891acf Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Fri, 5 Jun 2015 16:46:39 +0530 +Subject: [PATCH 111/129] glusterd/ afr : set afr pending xattrs on replace brick + +This patch is part one change to prevent data loss +in a replicate volume on doing a replace-brick commit +force operation. + +Problem: After doing replace-brick commit force, there is a +chance that self heal happens from the replaced (sink) brick +rather than the source brick leading to data loss. + +Solution: During the commit phase of replace brick, after old +brick is brought down, create a temporary mount and perform +setfattr operation (on virtual xattr) indicating AFR to mark +the replaced brick as sink. + +As a part of this change replace-brick command is being changed +to use mgmt_v3 framework rather than op-state-machine framework. + +Many thanks to Krishnan Parthasarathi for helping me out on this. + +Upstream links: +master : http://review.gluster.org/10076/ +3.7 : http://review.gluster.org/11253/ + +Change-Id: If0d51b5b3cef5b34d5672d46ea12eaa9d35fd894 +BUG: 1140649 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51017 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + libglusterfs/src/glusterfs.h | 2 + + xlators/mgmt/glusterd/src/glusterd-mgmt.c | 52 ++++ + xlators/mgmt/glusterd/src/glusterd-mgmt.h | 29 ++ + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-op-sm.h | 6 +- + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 298 ++++++++++++-------- + xlators/mgmt/glusterd/src/glusterd.h | 1 - + 7 files changed, 272 insertions(+), 118 deletions(-) + +diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h +index 6f20185..c00bf55 100644 +--- a/libglusterfs/src/glusterfs.h ++++ b/libglusterfs/src/glusterfs.h +@@ -169,6 +169,8 @@ + #define GF_AFR_SBRAIN_CHOICE "replica.split-brain-choice" + #define GF_AFR_SPB_CHOICE_TIMEOUT "replica.split-brain-choice-timeout" + #define GF_AFR_SBRAIN_RESOLVE "replica.split-brain-heal-finalize" ++#define GF_AFR_REPLACE_BRICK "trusted.replace-brick" ++#define GF_AFR_DIRTY "trusted.afr.dirty" + + #define GF_GFIDLESS_LOOKUP "gfidless-lookup" + /* replace-brick and pump related internal xattrs */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +index 41e6391..607d2c5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +@@ -169,6 +169,16 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, + + break; + ++ case GD_OP_REPLACE_BRICK: ++ ret = glusterd_op_stage_replace_brick (dict, op_errstr, ++ rsp_dict); ++ if (ret) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "Replace-brick prevalidation failed."); ++ goto out; ++ } ++ break; ++ + default: + break; + } +@@ -242,6 +252,17 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, + } + break; + } ++ case GD_OP_REPLACE_BRICK: ++ { ++ ret = glusterd_op_replace_brick (dict, rsp_dict); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_OP_FAIL, ++ "Replace-brick commit failed."); ++ goto out; ++ } ++ break; ++ } + default: + break; + } +@@ -527,6 +548,16 @@ glusterd_pre_validate_aggr_rsp_dict (glusterd_op_t op, + goto out; + } + break; ++ case GD_OP_REPLACE_BRICK: ++ ret = glusterd_rb_use_rsp_dict (aggr, rsp); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PRE_VALIDATION_FAIL, ++ "Failed to aggregate prevalidate " ++ "response dictionaries."); ++ goto out; ++ } ++ break; + default: + ret = -1; + gf_msg (this->name, GF_LOG_ERROR, EINVAL, +@@ -809,6 +840,7 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, + int32_t ret = -1; + dict_t *req_dict = NULL; + xlator_t *this = NULL; ++ char *volname = NULL; + + this = THIS; + GF_ASSERT (this); +@@ -824,6 +856,26 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, + case GD_OP_SNAP: + dict_copy (dict, req_dict); + break; ++ case GD_OP_REPLACE_BRICK: ++ { ++ ret = dict_get_str (dict, "volname", &volname); ++ if (ret) { ++ gf_log (this->name, GF_LOG_CRITICAL, ++ "volname is not present in " ++ "operation ctx"); ++ goto out; ++ } ++ ++ if (strcasecmp (volname, "all")) { ++ ret = glusterd_dict_set_volid (dict, ++ volname, ++ op_errstr); ++ if (ret) ++ goto out; ++ } ++ dict_copy (dict, req_dict); ++ } ++ break; + default: + break; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-mgmt.h +index a9812a4..b49137f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.h +@@ -50,4 +50,33 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src); + + int32_t + glusterd_set_barrier_value (dict_t *dict, char *option); ++int ++ ++glusterd_mgmt_v3_initiate_lockdown (glusterd_op_t op, dict_t *dict, ++ char **op_errstr, uint32_t *op_errno, ++ gf_boolean_t *is_acquired, ++ uint32_t txn_generation); ++ ++int ++glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, ++ glusterd_op_t op); ++ ++int ++glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, ++ char **op_errstr, uint32_t *op_errno, ++ uint32_t txn_generation); ++ ++int ++glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, ++ char **op_errstr, uint32_t *op_errno, ++ uint32_t txn_generation); ++ ++int ++glusterd_mgmt_v3_release_peer_locks (glusterd_op_t op, dict_t *dict, ++ int32_t op_ret, char **op_errstr, ++ gf_boolean_t is_acquired, ++ uint32_t txn_generation); ++ ++int32_t ++glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid); + #endif /* _GLUSTERD_MGMT_H_ */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 8fca680..8e5c4bb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -3665,7 +3665,7 @@ out: + return ret; + } + +-static int ++int + glusterd_dict_set_volid (dict_t *dict, char *volname, char **op_errstr) + { + int ret = -1; +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h +index 368bb04..1b64419 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h +@@ -234,9 +234,6 @@ glusterd_check_option_exists(char *optstring, char **completion); + int + set_xlator_option (dict_t *dict, char *key, char *value); + +-void +-glusterd_do_replace_brick (void *data); +- + char* + glusterd_op_sm_state_name_get (int state); + +@@ -298,4 +295,7 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id); + + void + glusterd_set_opinfo (char *errstr, int32_t op_errno, int32_t op_ret); ++ ++int ++glusterd_dict_set_volid (dict_t *dict, char *volname, char **op_errstr); + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index db9b36c..b063284 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -26,6 +26,7 @@ + #include "glusterd-nfs-svc.h" + #include "glusterd-volgen.h" + #include "glusterd-messages.h" ++#include "glusterd-mgmt.h" + #include "run.h" + #include "syscall.h" + +@@ -39,6 +40,79 @@ + extern uuid_t global_txn_id; + + int ++glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (rpcsvc_request_t *req, ++ glusterd_op_t op, ++ dict_t *dict); ++int ++glusterd_handle_replicate_replace_brick (glusterd_volinfo_t *volinfo, ++ glusterd_brickinfo_t *brickinfo) ++{ ++ int32_t ret = -1; ++ char tmpmount[] = "/tmp/mntXXXXXX"; ++ char logfile[PATH_MAX] = {0,}; ++ int dirty[3] = {0,}; ++ runner_t runner = {0}; ++ glusterd_conf_t *priv = NULL; ++ char *pid = NULL; ++ ++ priv = THIS->private; ++ ++ dirty[2] = hton32(1); ++ ++ ret = sys_lsetxattr (brickinfo->path, GF_AFR_DIRTY, dirty, ++ sizeof (dirty), 0); ++ if (ret == -1) { ++ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" ++ " attribute %s : %s.", GF_AFR_DIRTY, strerror (errno)); ++ goto out; ++ } ++ ++ if (mkdtemp (tmpmount) == NULL) { ++ gf_log (THIS->name, GF_LOG_ERROR, ++ "failed to create a temporary mount directory."); ++ ret = -1; ++ goto out; ++ } ++ snprintf (logfile, sizeof (logfile), ++ DEFAULT_LOG_FILE_DIRECTORY"/%s-replace-brick-mount.log", ++ volinfo->volname); ++ ++ ret = gf_asprintf (&pid, "%d", GF_CLIENT_PID_AFR_SELF_HEALD); ++ if (ret < 0) ++ goto out; ++ ++ runinit (&runner); ++ runner_add_args (&runner, SBIN_DIR"/glusterfs", ++ "-s", "localhost", ++ "--volfile-id", volinfo->volname, ++ "--client-pid", pid, ++ "-l", logfile, tmpmount, NULL); ++ synclock_unlock (&priv->big_lock); ++ ret = runner_run (&runner); ++ ++ if (ret) { ++ runner_log (&runner, THIS->name, GF_LOG_ERROR, "mount command" ++ "failed."); ++ goto lock; ++ } ++ ret = sys_lsetxattr (tmpmount, GF_AFR_REPLACE_BRICK, ++ brickinfo->brick_id, sizeof (brickinfo->brick_id), ++ 0); ++ if (ret == -1) ++ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" ++ " attribute %s : %s", GF_AFR_REPLACE_BRICK, ++ strerror (errno)); ++ gf_umount_lazy (THIS->name, tmpmount, 1); ++lock: ++ synclock_lock (&priv->big_lock); ++out: ++ if (pid) ++ GF_FREE (pid); ++ gf_log ("", GF_LOG_DEBUG, "Returning with ret"); ++ return ret; ++} ++ ++int + __glusterd_handle_replace_brick (rpcsvc_request_t *req) + { + int32_t ret = -1; +@@ -126,22 +200,12 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + gf_log (this->name, GF_LOG_INFO, "Received replace brick commit-force " + "request operation"); + +- ret = glusterd_op_begin (req, GD_OP_REPLACE_BRICK, dict, +- msg, sizeof (msg)); ++ ret = glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (req, ++ GD_OP_REPLACE_BRICK, dict); + + out: + free (cli_req.dict.dict_val);//malloced by xdr + +- glusterd_friend_sm (); +- glusterd_op_sm (); +- +- if (ret) { +- if (msg[0] == '\0') +- snprintf (msg, sizeof (msg), "Operation failed"); +- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, +- dict, msg); +- } +- + return ret; + } + +@@ -188,7 +252,6 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + glusterd_peerinfo_t *peerinfo = NULL; + glusterd_brickinfo_t *dst_brickinfo = NULL; + gf_boolean_t enabled = _gf_false; +- dict_t *ctx = NULL; + glusterd_conf_t *priv = NULL; + char *savetok = NULL; + char pidfile[PATH_MAX] = {0}; +@@ -292,8 +355,6 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + goto out; + } + +- ctx = glusterd_op_get_ctx(); +- + if (!strcmp(replace_op, "GF_REPLACE_OP_COMMIT_FORCE")) { + is_force = _gf_true; + } else { +@@ -310,7 +371,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + goto out; + } + +- if (ctx) { ++ if (dict) { + if (!glusterd_is_fuse_available ()) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RB_CMD_FAIL, "Unable to open /dev/" +@@ -493,7 +554,6 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + dict_t *rsp_dict, dict_t *req_dict, char *replace_op) + { + xlator_t *this = NULL; +- dict_t *ctx = NULL; + int ret = 0; + int dict_ret = 0; + int src_port = 0; +@@ -536,9 +596,8 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + } + } + +- ctx = glusterd_op_get_ctx (); +- if (ctx) { +- ret = dict_set_int32 (ctx, "src-brick-port", ++ if (req_dict) { ++ ret = dict_set_int32 (req_dict, "src-brick-port", + src_brickinfo->port); + if (ret) { + gf_log (this->name, GF_LOG_DEBUG, +@@ -558,7 +617,6 @@ static int + rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + dict_t *req_dict, char *replace_op) + { +- dict_t *ctx = NULL; + int ret = 0; + int dict_ret = 0; + int dst_port = 0; +@@ -581,9 +639,8 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + } + } + +- ctx = glusterd_op_get_ctx (); +- if (ctx) { +- ret = dict_set_int32 (ctx, "dst-brick-port", ++ if (req_dict) { ++ ret = dict_set_int32 (req_dict, "dst-brick-port", + dst_brickinfo->port); + if (ret) { + gf_log ("", GF_LOG_DEBUG, +@@ -658,6 +715,16 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo, + if (ret) + goto out; + ++ /* if the volume is a replicate volume, do: */ ++ if (glusterd_is_volume_replicate (volinfo)) { ++ if (!gf_uuid_compare (new_brickinfo->uuid, MY_UUID)) { ++ ret = glusterd_handle_replicate_replace_brick ++ (volinfo, new_brickinfo); ++ if (ret < 0) ++ goto out; ++ } ++ } ++ + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) + goto out; +@@ -764,17 +831,6 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + if (ret) + goto out; + +- /* Set task-id, if available, in op_ctx dict for*/ +- if (is_origin_glusterd (dict)) { +- ctx = glusterd_op_get_ctx(); +- if (!ctx) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_OPCTX_GET_FAIL, "Failed to " +- "get op_ctx"); +- ret = -1; +- goto out; +- } +- } + ret = rb_update_dstbrick_port (dst_brickinfo, rsp_dict, + dict, replace_op); + if (ret) +@@ -839,119 +895,135 @@ out: + return ret; + } + +-void +-glusterd_do_replace_brick (void *data) ++int ++glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (rpcsvc_request_t *req, ++ glusterd_op_t op, ++ dict_t *dict) + { +- glusterd_volinfo_t *volinfo = NULL; +- int32_t src_port = 0; +- int32_t dst_port = 0; +- int32_t ret = 0; +- dict_t *dict = NULL; +- char *src_brick = NULL; +- char *dst_brick = NULL; +- char *volname = NULL; +- glusterd_brickinfo_t *src_brickinfo = NULL; +- glusterd_brickinfo_t *dst_brickinfo = NULL; +- glusterd_conf_t *priv = NULL; +- uuid_t *txn_id = NULL; +- xlator_t *this = NULL; ++ int32_t ret = -1; ++ int32_t op_ret = -1; ++ uint32_t txn_generation = 0; ++ uint32_t op_errno = 0; ++ char *cli_errstr = NULL; ++ char *op_errstr = NULL; ++ dict_t *req_dict = NULL; ++ dict_t *tmp_dict = NULL; ++ uuid_t *originator_uuid = NULL; ++ xlator_t *this = NULL; ++ glusterd_conf_t *conf = NULL; ++ gf_boolean_t success = _gf_false; ++ gf_boolean_t is_acquired = _gf_false; + + this = THIS; +- GF_ASSERT (this); +- priv = this->private; +- GF_ASSERT (priv); +- GF_ASSERT (data); +- +- txn_id = &priv->global_txn_id; +- dict = data; +- +- if (priv->timer) { +- gf_timer_call_cancel (THIS->ctx, priv->timer); +- priv->timer = NULL; +- gf_msg_debug ("", 0, +- "Cancelling timer thread"); +- } +- +- gf_msg_debug (this->name, 0, +- "Replace brick operation detected"); +- +- ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_msg_debug (this->name, 0, "transaction ID = %s", +- uuid_utoa (*txn_id)); ++ GF_ASSERT (this); ++ GF_ASSERT (req); ++ GF_ASSERT (dict); ++ conf = this->private; ++ GF_ASSERT (conf); + +- ret = dict_get_str (dict, "src-brick", &src_brick); +- if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, +- GD_MSG_DICT_GET_FAILED, "Unable to get src brick"); ++ txn_generation = conf->generation; ++ originator_uuid = GF_CALLOC (1, sizeof(uuid_t), ++ gf_common_mt_uuid_t); ++ if (!originator_uuid) { ++ ret = -1; + goto out; + } + +- gf_msg_debug (this->name, 0, +- "src brick=%s", src_brick); +- +- ret = dict_get_str (dict, "dst-brick", &dst_brick); ++ gf_uuid_copy (*originator_uuid, MY_UUID); ++ ret = dict_set_bin (dict, "originator_uuid", ++ originator_uuid, sizeof (uuid_t)); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, +- GD_MSG_DICT_GET_FAILED, "Unable to get dst brick"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set originator_uuid."); + goto out; + } + +- gf_msg_debug (this->name, 0, +- "dst brick=%s", dst_brick); +- +- ret = glusterd_volinfo_find (volname, &volinfo); ++ ret = dict_set_int32 (dict, "is_synctasked", _gf_true); + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, EINVAL, +- GD_MSG_VOLINFO_GET_FAIL, "Unable to find volinfo"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set synctasked flag to true."); + goto out; + } + +- ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo, +- &src_brickinfo); +- if (ret) { +- gf_msg_debug (this->name, 0, "Unable to get src-brickinfo"); ++ tmp_dict = dict_new(); ++ if (!tmp_dict) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_CREATE_FAIL, "Unable to create dict"); + goto out; + } ++ dict_copy (dict, tmp_dict); + +- ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); +- if (!dst_brickinfo) { +- gf_msg_debug (this->name, 0, "Unable to get dst-brickinfo"); ++ ret = glusterd_mgmt_v3_initiate_lockdown (op, dict, &op_errstr, ++ &op_errno, &is_acquired, ++ txn_generation); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCKDOWN_FAIL, ++ "mgmt_v3 lockdown failed."); + goto out; + } + +- ret = glusterd_resolve_brick (dst_brickinfo); ++ ret = glusterd_mgmt_v3_build_payload (&req_dict, &op_errstr, dict, op); + if (ret) { +- gf_msg_debug (this->name, 0, "Unable to resolve dst-brickinfo"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_PAYLOAD_BUILD_FAIL, LOGSTR_BUILD_PAYLOAD, ++ gd_op_list[op]); ++ if (op_errstr == NULL) ++ gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); + goto out; + } + +- ret = dict_get_int32 (dict, "src-brick-port", &src_port); ++ ret = glusterd_mgmt_v3_pre_validate (op, req_dict, &op_errstr, ++ &op_errno, txn_generation); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_DICT_GET_FAILED, "Unable to get src-brick port"); ++ GD_MSG_PRE_VALIDATION_FAIL, "Pre Validation Failed"); + goto out; + } + +- ret = dict_get_int32 (dict, "dst-brick-port", &dst_port); ++ ret = glusterd_mgmt_v3_commit (op, dict, req_dict, &op_errstr, ++ &op_errno, txn_generation); + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, errno, +- GD_MSG_DICT_GET_FAILED, "Unable to get dst-brick port"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_COMMIT_OP_FAIL, "Commit Op Failed"); ++ goto out; + } + +- dst_brickinfo->port = dst_port; +- src_brickinfo->port = src_port; ++ ret = 0; + + out: +- if (ret) +- ret = glusterd_op_sm_inject_event (GD_OP_EVENT_RCVD_RJT, +- txn_id, NULL); +- else +- ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, +- txn_id, NULL); ++ op_ret = ret; + +- synclock_lock (&priv->big_lock); +- { +- glusterd_op_sm (); ++ (void) glusterd_mgmt_v3_release_peer_locks (op, dict, op_ret, ++ &op_errstr, is_acquired, ++ txn_generation); ++ ++ if (is_acquired) { ++ ret = glusterd_multiple_mgmt_v3_unlock (tmp_dict, MY_UUID); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, ++ "Failed to release mgmt_v3 locks on " ++ "localhost."); ++ op_ret = ret; ++ } + } +- synclock_unlock (&priv->big_lock); ++ /* SEND CLI RESPONSE */ ++ glusterd_op_send_cli_response (op, op_ret, op_errno, req, ++ dict, op_errstr); ++ ++ if (req_dict) ++ dict_unref (req_dict); ++ ++ if (tmp_dict) ++ dict_unref (tmp_dict); ++ ++ if (op_errstr) { ++ GF_FREE (op_errstr); ++ op_errstr = NULL; ++ } ++ ++ return 0; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index 59234bc..cfe7a7b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -1044,7 +1044,6 @@ int glusterd_op_stage_barrier (dict_t *dict, char **op_errstr); + int glusterd_op_barrier (dict_t *dict, char **op_errstr); + + /* misc */ +-void glusterd_do_replace_brick (void *data); + int glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick, + int force, int *need_migrate); + int glusterd_op_stop_volume_args_get (dict_t *dict, char** volname, int *flags); +-- +1.7.1 + diff --git a/SOURCES/0112-libglusterfs-allocate-a-segment-for-quota-logging.patch b/SOURCES/0112-libglusterfs-allocate-a-segment-for-quota-logging.patch new file mode 100644 index 0000000..ccff8c9 --- /dev/null +++ b/SOURCES/0112-libglusterfs-allocate-a-segment-for-quota-logging.patch @@ -0,0 +1,37 @@ +From d4eb5efb838b65d6da3bde1299d27c5bd75cf6d2 Mon Sep 17 00:00:00 2001 +From: Humble Devassy Chirammal +Date: Tue, 28 Apr 2015 17:08:32 +0530 +Subject: [PATCH 112/129] libglusterfs: allocate a segment for quota logging + +Change-Id: Ia71488a20147ec3e99548aea15b4a57bb325fd06 +BUG: 1231792 +Signed-off-by: Humble Devassy Chirammal +Reviewed-on: http://review.gluster.org/10420 +Tested-by: Gluster Build System +Reviewed-by: Vijay Bellur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51006 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glfs-message-id.h | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index d67115c..69ed188 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -109,6 +109,11 @@ + #define GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END (GLFS_MSGID_COMP_RPC_TRANS_SOCKET + \ + GLFS_MSGID_SEGMENT) + ++#define GLFS_MSGID_COMP_QUOTA GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END ++#define GLFS_MSGID_COMP_QUOTA_END (GLFS_MSGID_COMP_QUOTA +\ ++ GLFS_MSGID_SEGMENT) ++ ++ + /* --- new segments for messages goes above this line --- */ + + #endif /* !_GLFS_MESSAGE_ID_H_ */ +-- +1.7.1 + diff --git a/SOURCES/0113-libgfapi-port-gfapi-to-new-logging-framework.patch b/SOURCES/0113-libgfapi-port-gfapi-to-new-logging-framework.patch new file mode 100644 index 0000000..1680b5e --- /dev/null +++ b/SOURCES/0113-libgfapi-port-gfapi-to-new-logging-framework.patch @@ -0,0 +1,37 @@ +From 7005ca84449a4f7d7dd47f9618e1846d46dd6a48 Mon Sep 17 00:00:00 2001 +From: Humble Devassy Chirammal +Date: Sat, 25 Apr 2015 12:44:15 +0530 +Subject: [PATCH 113/129] libgfapi : port gfapi to new logging framework + +Change-Id: Iaa0a92f82b9a0a26eda1a8d72b3b66ce66fab443 +BUG: 1231788 +Signed-off-by: Humble Devassy Chirammal +Reviewed-on: http://review.gluster.org/9918 +Tested-by: Gluster Build System +Reviewed-by: jiffin tony Thottan +Reviewed-by: Raghavendra Talur +Reviewed-by: soumya k +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/51004 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + api/src/gfapi-messages.h | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/api/src/gfapi-messages.h b/api/src/gfapi-messages.h +index 2c59af2..c303aa0 100644 +--- a/api/src/gfapi-messages.h ++++ b/api/src/gfapi-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLFS_GFAPI_BASE GLFS_MSGID_COMP_API +-#define GLFS_NUM_MESSAGES 45 ++#define GLFS_NUM_MESSAGES 46 + #define GLFS_MSGID_END (GLFS_GFAPI_BASE + GLFS_NUM_MESSAGESi + 1) + /* Messages with message IDs */ + #define glfs_msg_start_x GLFS_GFAPI_BASE, "Invalid: Start of messages" +-- +1.7.1 + diff --git a/SOURCES/0114-cluster-afr-set-pending-xattrs-for-replaced-brick.patch b/SOURCES/0114-cluster-afr-set-pending-xattrs-for-replaced-brick.patch new file mode 100644 index 0000000..02b78cb --- /dev/null +++ b/SOURCES/0114-cluster-afr-set-pending-xattrs-for-replaced-brick.patch @@ -0,0 +1,476 @@ +From a4f226f50a2ef943b5db095877bab5a3eebf7283 Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Thu, 11 Jun 2015 14:58:05 +0530 +Subject: [PATCH 114/129] cluster/afr : set pending xattrs for replaced brick + +This patch is part two change to prevent data loss +in a replicate volume on doing a replace-brick commit +force operation. + +Problem: After doing replace-brick commit force, there is a +chance that self heal might happen from the replaced (sink) brick +rather than the source brick leading to data loss. + +Solution: Mark pending changelogs on afr children for +the replaced afr-child so that heal is performed in the +correct direction. + +Upstream patch links: +master : http://review.gluster.org/10448/ +3.7 : http://review.gluster.org/11254/ +Change-Id: Icb9807e49b4c1c4f1dcab115318d9a58ccf95675 +BUG: 1140649 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51021 +Reviewed-by: Krutika Dhananjay +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + tests/basic/afr/replace-brick-self-heal.t | 59 ++++++ + xlators/cluster/afr/src/afr-inode-write.c | 255 +++++++++++++++++++++++- + xlators/cluster/afr/src/afr-self-heal-common.c | 16 +- + xlators/cluster/afr/src/afr-self-heal.h | 8 + + 4 files changed, 329 insertions(+), 9 deletions(-) + create mode 100644 tests/basic/afr/replace-brick-self-heal.t + +diff --git a/tests/basic/afr/replace-brick-self-heal.t b/tests/basic/afr/replace-brick-self-heal.t +new file mode 100644 +index 0000000..1901466 +--- /dev/null ++++ b/tests/basic/afr/replace-brick-self-heal.t +@@ -0,0 +1,59 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++cleanup; ++ ++function match_dirs { ++ diff <(ls $1 | sort) <(ls $2 | sort) ++ if [ $? -eq 0 ]; ++ then ++ echo "Y" ++ else ++ echo "N" ++ fi ++} ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume start $V0 ++TEST $CLI volume set $V0 cluster.data-self-heal off ++TEST $CLI volume set $V0 cluster.metadata-self-heal off ++TEST $CLI volume set $V0 cluster.entry-self-heal off ++ ++TEST $CLI volume set $V0 self-heal-daemon off ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++#Create files ++for i in {1..5} ++do ++ echo $i > $M0/file$i.txt ++done ++ ++# Replace brick1 ++TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force ++ ++# Replaced-brick should accuse the non-replaced-brick (Simulating case for data-loss) ++TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}1_new/ ++ ++# Check if pending xattr and dirty-xattr are set for replaced-brick ++EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0 ++EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}1_new ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++TEST $CLI volume set $V0 self-heal-daemon on ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status ++TEST $CLI volume heal $V0 ++ ++# Check if heal has happened ++EXPECT_WITHIN $HEAL_TIMEOUT "Y" match_dirs $B0/${V0}0 $B0/${V0}1_new ++ ++# To make sure that data was not lost from brick0 ++TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1 | sort) ++EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0 ++ ++# Test if data was healed ++TEST diff $B0/${V0}0/file1.txt $B0/${V0}1/file1.txt ++cleanup; +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index 3db4010..ecd2b9d 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -35,7 +35,7 @@ + #include "compat-errno.h" + #include "compat.h" + #include "protocol-common.h" +- ++#include "byte-order.h" + #include "afr-transaction.h" + #include "afr-self-heal.h" + +@@ -972,6 +972,211 @@ afr_setxattr_wind (call_frame_t *frame, xlator_t *this, int subvol) + } + + int ++afr_rb_set_pending_changelog_cbk (call_frame_t *frame, void *cookie, ++ xlator_t *this, int op_ret, int op_errno, ++ dict_t *xattr, dict_t *xdata) ++ ++{ ++ afr_local_t *local = NULL; ++ int i = 0; ++ ++ local = frame->local; ++ i = (long) cookie; ++ ++ local->replies[i].valid = 1; ++ local->replies[i].op_ret = op_ret; ++ local->replies[i].op_errno = op_errno; ++ ++ syncbarrier_wake (&local->barrier); ++ return 0; ++} ++ ++char * ++afr_opret_matrix_generate (afr_private_t *priv, afr_local_t *local) ++{ ++ char *matrix = NULL; ++ char *ptr = NULL; ++ int i = 0; ++ ++ /* Allocate max amount of chars required, including -ve values ++ * and spaces */ ++ matrix = GF_CALLOC (priv->child_count, 3 * sizeof (char), ++ gf_afr_mt_char); ++ if (!matrix) ++ return NULL; ++ ptr = matrix; ++ for (i = 0; i < priv->child_count; i++) { ++ if (local->replies[i].valid) ++ ptr += sprintf (ptr, "%d ", local->replies[i].op_ret); ++ else ++ ptr += sprintf (ptr, "-1 "); ++ } ++ return matrix; ++} ++ ++int ++afr_rb_set_pending_changelog (call_frame_t *frame, xlator_t *this, ++ unsigned char *locked_nodes) ++{ ++ afr_local_t *local = NULL; ++ afr_private_t *priv = NULL; ++ int ret = 0, i = 0; ++ char *matrix = NULL; ++ ++ local = frame->local; ++ priv = this->private; ++ ++ AFR_ONLIST (locked_nodes, frame, afr_rb_set_pending_changelog_cbk, ++ xattrop, &local->loc, GF_XATTROP_ADD_ARRAY, ++ local->xdata_req, NULL); ++ ++ /* It is sufficient if xattrop was successful on one child */ ++ for (i = 0; i < priv->child_count; i++) { ++ if (local->replies[i].valid && ++ local->replies[i].op_ret == 0) { ++ matrix = afr_opret_matrix_generate (priv, local); ++ gf_log (this->name, GF_LOG_DEBUG, "Successfully set " ++ "pending changelog. op_ret matrix : [ %s].", ++ matrix); ++ ret = 0; ++ goto out; ++ } ++ ret = afr_higher_errno (ret, local->replies[i].op_errno); ++ } ++ gf_log (this->name, GF_LOG_ERROR, "Couldn't set pending xattr " ++ "on any child. (%s)", strerror (ret)); ++out: ++ if (matrix) ++ GF_FREE (matrix); ++ return -ret; ++} ++ ++int ++_afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame, ++ loc_t *loc, int rb_index, ++ afr_transaction_type type) ++{ ++ afr_local_t *local = NULL; ++ afr_private_t *priv = NULL; ++ unsigned char *locked_nodes = NULL; ++ struct gf_flock flock = {0, }; ++ struct gf_flock unflock = {0, }; ++ int i = 0; ++ int count = 0; ++ int ret = -ENOMEM; ++ int idx = -1; ++ ++ priv = this->private; ++ local = frame->local; ++ ++ locked_nodes = alloca0 (priv->child_count); ++ ++ idx = afr_index_for_transaction_type (type); ++ ++ local->pending = afr_matrix_create (priv->child_count, ++ AFR_NUM_CHANGE_LOGS); ++ if (!local->pending) ++ goto out; ++ ++ for (i = 0; i < priv->child_count; i++) { ++ if (i == rb_index) ++ local->pending[i][idx] = hton32 (1); ++ } ++ ++ local->xdata_req = dict_new (); ++ if (!local->xdata_req) ++ goto out; ++ ++ ret = afr_set_pending_dict (priv, local->xdata_req, local->pending); ++ if (ret < 0) ++ goto out; ++ ++ if (AFR_ENTRY_TRANSACTION == type) { ++ AFR_SEQ (frame, afr_selfheal_lock_cbk, entrylk, this->name, ++ loc, NULL, ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL); ++ } else { ++ flock.l_type = F_WRLCK; ++ flock.l_start = LLONG_MAX - 1; ++ flock.l_len = 0; ++ AFR_SEQ (frame, afr_selfheal_lock_cbk, inodelk, this->name, ++ loc, F_SETLKW, &flock, NULL); ++ } ++ count = afr_locked_fill (frame, this, locked_nodes); ++ ++ if (!count) { ++ gf_log (this->name, GF_LOG_ERROR, "Couldn't acquire lock on" ++ " any child."); ++ ret = -EAGAIN; ++ goto unlock; ++ } ++ ++ ret = afr_rb_set_pending_changelog (frame, this, locked_nodes); ++ if (ret) ++ goto unlock; ++ ret = 0; ++unlock: ++ if (AFR_ENTRY_TRANSACTION == type) { ++ AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk, ++ entrylk, this->name, loc, NULL, ENTRYLK_UNLOCK, ++ ENTRYLK_WRLCK, NULL); ++ } else { ++ unflock.l_type = F_UNLCK; ++ unflock.l_start = LLONG_MAX - 1; ++ unflock.l_len = 0; ++ AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk, ++ inodelk, this->name, loc, F_SETLK, &unflock, NULL); ++ } ++out: ++ return ret; ++} ++ ++int ++_afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, ++ int rb_index) ++{ ++ ++ afr_local_t *local = NULL; ++ afr_private_t *priv = NULL; ++ int ret = -1; ++ int op_errno = ENOMEM; ++ ++ priv = this->private; ++ ++ local = AFR_FRAME_INIT (frame, op_errno); ++ if (!local) ++ goto out; ++ ++ loc_copy (&local->loc, loc); ++ ++ gf_log (this->name, GF_LOG_DEBUG, "Child being replaced is : %s", ++ priv->children[rb_index]->name); ++ ++ ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index, ++ AFR_METADATA_TRANSACTION); ++ if (ret) { ++ op_errno = -ret; ++ ret = -1; ++ goto out; ++ } ++ ++ dict_unref (local->xdata_req); ++ afr_matrix_cleanup (local->pending, priv->child_count); ++ ++ ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index, ++ AFR_ENTRY_TRANSACTION); ++ if (ret) { ++ op_errno = -ret; ++ ret = -1; ++ goto out; ++ } ++ ret = 0; ++out: ++ AFR_STACK_UNWIND (setxattr, frame, ret, op_errno, NULL); ++ return 0; ++} ++ ++ ++int + afr_split_brain_resolve_do (call_frame_t *frame, xlator_t *this, loc_t *loc, + char *data) + { +@@ -1169,6 +1374,50 @@ afr_handle_spb_choice_timeout (xlator_t *this, call_frame_t *frame, + return ret; + } + ++int ++afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, ++ dict_t *dict) ++{ ++ int len = 0; ++ int ret = -1; ++ int rb_index = -1; ++ int op_errno = EPERM; ++ void *value = NULL; ++ char *replace_brick = NULL; ++ ++ ret = dict_get_ptr_and_len (dict, GF_AFR_REPLACE_BRICK, &value, ++ &len); ++ ++ if (value) { ++ replace_brick = alloca0 (len + 1); ++ memcpy (replace_brick, value, len); ++ ++ if (!(frame->root->pid == GF_CLIENT_PID_AFR_SELF_HEALD)) { ++ ret = 1; ++ goto out; ++ } ++ rb_index = afr_get_child_index_from_name (this, replace_brick); ++ ++ if (rb_index < 0) ++ /* Didn't belong to this replica pair ++ * Just do a no-op ++ */ ++ AFR_STACK_UNWIND (setxattr, frame, 0, 0, NULL); ++ else ++ _afr_handle_replace_brick (this, frame, loc, rb_index); ++ ret = 0; ++ } ++out: ++ if (ret == 1) { ++ gf_log (this->name, GF_LOG_ERROR, "'%s' is an internal" ++ " extended attribute : %s.", ++ GF_AFR_REPLACE_BRICK, strerror (op_errno)); ++ AFR_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); ++ ret = 0; ++ } ++ return ret; ++} ++ + static int + afr_handle_special_xattr (xlator_t *this, call_frame_t *frame, loc_t *loc, + dict_t *dict) +@@ -1180,6 +1429,10 @@ afr_handle_special_xattr (xlator_t *this, call_frame_t *frame, loc_t *loc, + goto out; + + ret = afr_handle_spb_choice_timeout (this, frame, dict); ++ if (ret == 0) ++ goto out; ++ ++ ret = afr_handle_replace_brick (this, frame, loc, dict); + out: + return ret; + } +diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c +index 207e9b9..1e46226 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-common.c ++++ b/xlators/cluster/afr/src/afr-self-heal-common.c +@@ -807,8 +807,8 @@ afr_selfheal_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + + int +-afr_selfheal_locked_fill (call_frame_t *frame, xlator_t *this, +- unsigned char *locked_on) ++afr_locked_fill (call_frame_t *frame, xlator_t *this, ++ unsigned char *locked_on) + { + int i = 0; + afr_private_t *priv = NULL; +@@ -851,7 +851,7 @@ afr_selfheal_tryinodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, + + loc_wipe (&loc); + +- return afr_selfheal_locked_fill (frame, this, locked_on); ++ return afr_locked_fill (frame, this, locked_on); + } + + +@@ -882,7 +882,7 @@ afr_selfheal_inodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, + for (i = 0; i < priv->child_count; i++) { + if (local->replies[i].op_ret == -1 && + local->replies[i].op_errno == EAGAIN) { +- afr_selfheal_locked_fill (frame, this, locked_on); ++ afr_locked_fill (frame, this, locked_on); + afr_selfheal_uninodelk (frame, this, inode, dom, off, + size, locked_on); + +@@ -894,7 +894,7 @@ afr_selfheal_inodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, + + loc_wipe (&loc); + +- return afr_selfheal_locked_fill (frame, this, locked_on); ++ return afr_locked_fill (frame, this, locked_on); + } + + +@@ -937,7 +937,7 @@ afr_selfheal_tryentrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, + + loc_wipe (&loc); + +- return afr_selfheal_locked_fill (frame, this, locked_on); ++ return afr_locked_fill (frame, this, locked_on); + } + + +@@ -962,7 +962,7 @@ afr_selfheal_entrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, + for (i = 0; i < priv->child_count; i++) { + if (local->replies[i].op_ret == -1 && + local->replies[i].op_errno == EAGAIN) { +- afr_selfheal_locked_fill (frame, this, locked_on); ++ afr_locked_fill (frame, this, locked_on); + afr_selfheal_unentrylk (frame, this, inode, dom, name, + locked_on); + +@@ -974,7 +974,7 @@ afr_selfheal_entrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, + + loc_wipe (&loc); + +- return afr_selfheal_locked_fill (frame, this, locked_on); ++ return afr_locked_fill (frame, this, locked_on); + } + + +diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h +index 956f075..a707e20 100644 +--- a/xlators/cluster/afr/src/afr-self-heal.h ++++ b/xlators/cluster/afr/src/afr-self-heal.h +@@ -251,4 +251,12 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, + + int + afr_selfheal_do (call_frame_t *frame, xlator_t *this, uuid_t gfid); ++ ++int ++afr_selfheal_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int op_ret, int op_errno, dict_t *xdata); ++ ++int ++afr_locked_fill (call_frame_t *frame, xlator_t *this, ++ unsigned char *locked_on); + #endif /* !_AFR_SELFHEAL_H */ +-- +1.7.1 + diff --git a/SOURCES/0115-common-ha-cluster-setup-issues-on-RHEL7.patch b/SOURCES/0115-common-ha-cluster-setup-issues-on-RHEL7.patch new file mode 100644 index 0000000..1a71161 --- /dev/null +++ b/SOURCES/0115-common-ha-cluster-setup-issues-on-RHEL7.patch @@ -0,0 +1,141 @@ +From bf7d9cb56b80314a8c936ae01d2d755aefa93e16 Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Tue, 16 Jun 2015 10:07:48 -0400 +Subject: [PATCH 115/129] common-ha: cluster setup issues on RHEL7 + + * use --name on RHEL7 (later versions of pcs drop --name) we guessed + wrong and did not get the version that dropped use of --name option + * more robust config file param parsing for n/v with ""s in the value + after not sourcing the config file + * pid file fix. RHEL6 init.d adds -p /var/run/ganesha.nfsd.pid to + cmdline options. RHEL7 systemd does not, so defaults to + /var/run/ganesha.pid. + +> backport of +>> Change-Id: I575aa13c98f05523cca10c55f2c387200bad3f93 +>> BUG: 1229948 +>> Signed-off-by: Kaleb S. KEITHLEY +>> http://review.gluster.org/#/c/11257/ +> +> Change-Id: I2236d41c8a87e4ead082274dddec19307d1f4db9 +> BUG: 1232333 +> Signed-off-by: Kaleb S. KEITHLEY +> http://review.gluster.org/#/c/11258/ + +Change-Id: Ib0245c6e1242524af2a8d8bc3b204fe892304fcc +BUG: 1229601 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/50841 +Reviewed-by: Soumya Koduri +--- + extras/ganesha/ocf/ganesha_grace | 12 ++++++++++-- + extras/ganesha/ocf/ganesha_mon | 12 ++++++++++-- + extras/ganesha/scripts/ganesha-ha.sh | 23 ++++++++++++++--------- + 3 files changed, 34 insertions(+), 13 deletions(-) + +diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace +index dceaccf..75ec16c 100644 +--- a/extras/ganesha/ocf/ganesha_grace ++++ b/extras/ganesha/ocf/ganesha_grace +@@ -88,14 +88,22 @@ ganesha_grace_start() + local resourcename="" + local deadserver="" + local tmpIFS=${IFS} ++ local pid_file="/var/run/ganesha.nfsd.pid" ++ ++ # RHEL6 /etc/init.d/nfs-ganesha adds "-p /var/run/ganesha.nfsd.pid" ++ # RHEL7 systemd does not. Would be nicer if all distros used the ++ # same pid file. ++ if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then ++ pid_file="/var/run/ganesha.pid" ++ fi + + # logger "ganesha_grace_start()" + # we're here because somewhere in the cluster one or more + # of the ganesha.nfsds have died, triggering a floating IP + # address to move. Resource constraint location rules ensure + # that this is invoked before the floating IP is moved. +- if [ -e /var/run/ganesha.nfsd.pid -a \ +- -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then ++ if [ -e ${pid_file} -a \ ++ -d /proc/$(cat ${pid_file} ) ]; then + # my ganesha.nfsd is still running + # find out which one died? + +diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon +index 47943f8..c8e7de9 100644 +--- a/extras/ganesha/ocf/ganesha_mon ++++ b/extras/ganesha/ocf/ganesha_mon +@@ -97,9 +97,17 @@ ganesha_mon_stop() + ganesha_mon_monitor() + { + local short_host=$(hostname -s) ++ local pid_file="/var/run/ganesha.nfsd.pid" + +- if [ -e /var/run/ganesha.nfsd.pid -a \ +- -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then ++ # RHEL6 /etc/init.d/nfs-ganesha adds -p /var/run/ganesha.nfsd.pid ++ # RHEL7 systemd does not. Would be nice if all distros used the ++ # same pid file. ++ if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then ++ pid_file="/var/run/ganesha.pid" ++ fi ++ ++ if [ -e ${pid_file} -a \ ++ -d /proc/$(cat ${pid_file} ) ]; then + ( pcs resource delete ${short_host}-dead_ip-1 > /dev/null 2>&1 ) + + attrd_updater -n ganesha-active -v 1 +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index fc2a009..725b6b4 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -26,7 +26,9 @@ HA_CONFDIR="" + HA_VOL_NAME="gluster_shared_storage" + HA_VOL_MNT="/var/run/gluster/shared_storage" + SERVICE_MAN="DISTRO_NOT_FOUND" +-CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=") ++cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) ++eval $(echo ${cfgline} | grep -F CONFFILE=) ++GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + RHEL6_PCS_CNAME_OPTION="--name" + +@@ -236,7 +238,7 @@ cleanup_ganesha_config () + rm -rf ${HA_CONFDIR}/.export_added + rm -rf /etc/cluster/cluster.conf* + rm -rf /var/lib/pacemaker/cib/* +- sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' $CONF ++ sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' ${GANESHA_CONF} + } + + do_create_virt_ip_constraints() +@@ -740,15 +742,18 @@ main() + local node="" + local vip="" + +- ha_name=$(grep ^HA_NAME= ${ha_conf} | cut -d = -f 2) +- HA_NAME=${ha_name//\"/} +- ha_vol_server=$(grep ^HA_VOL_SERVER= ${ha_conf} | cut -d = -f 2) +- HA_VOL_SERVER=${ha_vol_server//\"/} +- ha_cluster_nodes=$(grep ^HA_CLUSTER_NODES= ${ha_conf} | cut -d = -f 2) +- HA_CLUSTER_NODES=${ha_cluster_nodes//\"/} ++ # ignore any comment lines ++ cfgline=$(grep ^HA_NAME= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_NAME=) ++ cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=) ++ cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=) + ++ # we'll pretend that nobody ever edits /etc/os-release + if [ -e /etc/os-release ]; then +- RHEL6_PCS_CNAME_OPTION="" ++ eval $(grep -F "REDHAT_SUPPORT_PRODUCT=" /etc/os-release) ++ [ "$REDHAT_SUPPORT_PRODUCT" == "Fedora" ] && RHEL6_PCS_CNAME_OPTION="" + fi + + case "${cmd}" in +-- +1.7.1 + diff --git a/SOURCES/0116-NFS-Ganesha-Automatically-export-vol-that-was-export.patch b/SOURCES/0116-NFS-Ganesha-Automatically-export-vol-that-was-export.patch new file mode 100644 index 0000000..11bd2ae --- /dev/null +++ b/SOURCES/0116-NFS-Ganesha-Automatically-export-vol-that-was-export.patch @@ -0,0 +1,572 @@ +From 50bdfe8131b6cfa8a449b374b9af122fe842cdd0 Mon Sep 17 00:00:00 2001 +From: Meghana Madhusudhan +Date: Fri, 19 Jun 2015 14:29:59 +0530 +Subject: [PATCH 116/129] NFS-Ganesha: Automatically export vol that was exported before vol restart + +Consider a volume that is exported via NFS-Ganesha. Stopping this +volume will automatically unexport the volume. Starting this volume +should automatically export it. Although the logic was already there, +there was a bug in it. Fixing the same by introducing a hook script. + +Also with the new CLI options, the hook script S31ganesha-set.sh +is no longer required. Hence, removing the same. +Adding a comment to tell the user that one of the CLI +commands will take a few minutes to complete. + +Change-Id: I4b24dc2b986a6ccc86e4eb890435ef0175ffd547 +BUG: 1226863 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/50876 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + cli/src/cli-cmd-parser.c | 3 +- + extras/hook-scripts/set/post/Makefile.am | 2 +- + extras/hook-scripts/set/post/S31ganesha-set.sh | 290 -------------------- + extras/hook-scripts/start/post/Makefile.am | 2 +- + extras/hook-scripts/start/post/S31ganesha-start.sh | 114 ++++++++ + glusterfs.spec.in | 6 +- + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 14 +- + 8 files changed, 127 insertions(+), 307 deletions(-) + delete mode 100755 extras/hook-scripts/set/post/S31ganesha-set.sh + create mode 100755 extras/hook-scripts/start/post/S31ganesha-start.sh + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index a506c9b..2ddbe88 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -879,7 +879,7 @@ cli_cmd_ganesha_parse (struct cli_state *state, + + question = "Enabling NFS-Ganesha requires Gluster-NFS to be" + " disabled across the trusted pool. Do you " +- "still want to continue?"; ++ "still want to continue?\n"; + + if (strcmp (value, "enable") == 0) { + answer = cli_cmd_get_confirmation (state, question); +@@ -890,6 +890,7 @@ cli_cmd_ganesha_parse (struct cli_state *state, + goto out; + } + } ++ cli_out ("This will take a few minutes to complete. Please wait .."); + + ret = dict_set_str (dict, "key", key); + if (ret) { +diff --git a/extras/hook-scripts/set/post/Makefile.am b/extras/hook-scripts/set/post/Makefile.am +index 99dfaa3..db86bc2 100644 +--- a/extras/hook-scripts/set/post/Makefile.am ++++ b/extras/hook-scripts/set/post/Makefile.am +@@ -1 +1 @@ +-EXTRA_DIST = S30samba-set.sh S31ganesha-set.sh S32gluster_enable_shared_storage.sh ++EXTRA_DIST = S30samba-set.sh S32gluster_enable_shared_storage.sh +diff --git a/extras/hook-scripts/set/post/S31ganesha-set.sh b/extras/hook-scripts/set/post/S31ganesha-set.sh +deleted file mode 100755 +index f839aa3..0000000 +--- a/extras/hook-scripts/set/post/S31ganesha-set.sh ++++ /dev/null +@@ -1,290 +0,0 @@ +-#!/bin/bash +-PROGNAME="Sganesha-set" +-OPTSPEC="volname:,gd-workdir:" +-VOL= +-declare -i EXPORT_ID +-ganesha_key="FALSE" +-GANESHA_DIR="/var/lib/glusterfs-ganesha" +-CONF1="$GANESHA_DIR/nfs-ganesha.conf" +-GANESHA_LOG_DIR="/var/log/nfs-ganesha/" +-LOG="$GANESHA_LOG_DIR/ganesha.nfsd.log" +-gnfs="enabled" +-enable_ganesha="" +-host_name="none" +-LOC="" +-GLUSTERD_WORKDIR= +- +-function parse_args () +-{ +- ARGS=$(getopt -l $OPTSPEC -o "o" -name $PROGNAME $@) +- eval set -- "$ARGS" +- +- while true; do +- case $1 in +- --volname) +- shift +- VOL=$1 +- ;; +- --gd-workdir) +- shift +- GLUSTERD_WORKDIR=$1 +- ;; +- *) +- shift +- for pair in $@; do +- read key value < <(echo "$pair" | tr "=" " ") +- case "$key" in +- "nfs-ganesha.enable") +- enable_ganesha=$value +- ganesha_key="TRUE" +- ;; +- "nfs-ganesha.host") +- host_name=$value +- ganesha_key="TRUE" +- ;; +- *) +- ;; +- esac +- done +- shift +- break +- ;; +- esac +- shift +- done +-} +- +- +-function check_if_host_set() +-{ +- if ! cat $GLUSTERD_WORKDIR/vols/$VOL/info | grep -q "nfs-ganesha.host" +- then +- exit 1 +- fi +-} +- +-function check_nfsd_loc() +-{ +- if ls /usr/bin | grep "[g]anesha.nfsd" +- then +- LOC="/usr" +- else +- LOC="/usr/local" +- fi +-} +- +- +-function check_gluster_nfs() +-{ +- if cat $GLUSTERD_WORKDIR/vols/$VOL/info | grep -q "nfs.disable=ON" +- then +- gnfs="disabled" +- fi +-} +- +-function check_cmd_status() +-{ +- if [ "$1" != "0" ] +- then +- rm -rf $GANESHA_DIR/exports/export.$VOL.conf +- exit 1 +- fi +-} +- +- +- +-#This function generates a new export entry as export.volume_name.conf +-function write_conf() +-{ +- echo "EXPORT{ +- " +- echo "Export_Id = ;" +- echo "Path=\"/$1\";" +- echo "FSAL { +- " +- echo "name = "GLUSTER";" +- echo "hostname=\"$2\";" +- echo "volume=\"$1\";" +- echo "}" +- echo "Access_type = RW;" +- echo "Squash = No_root_squash;" +- echo "Disable_ACL = TRUE;" +- echo "Pseudo=\"/$1\";" +- echo "Protocols = \"3,4\" ;" +- echo "Transports = \"UDP,TCP\" ;" +- echo "SecType = \"sys\";" +- echo "Tag = \"$1\";" +- echo "}" +-} +- +-#This function keeps track of export IDs and increments it with every new entry +-function export_add() +-{ +- count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l` +- if [ "$count" = "1" ] ; +- then +- EXPORT_ID=1 +- else +- #if [ -s /var/lib/ganesha/export_removed ]; +- # then +- # EXPORT_ID=`head -1 /var/lib/ganesha/export_removed` +- # sed -i -e "1d" /var/lib/ganesha/export_removed +- # else +- +- EXPORT_ID=`cat $GANESHA_DIR/.export_added` +- check_cmd_status `echo $?` +- EXPORT_ID=EXPORT_ID+1 +- #fi +- fi +- echo $EXPORT_ID > $GANESHA_DIR/.export_added +- check_cmd_status `echo $?` +- sed -i s/Export_Id.*/"Export_Id = $EXPORT_ID ;"/ \ +-$GANESHA_DIR/exports/export.$VOL.conf +- echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF1 +- check_cmd_status `echo $?` +-} +- +-#This function removes an export dynamically(uses the export_id of the export) +-function dynamic_export_remove() +-{ +- removed_id=`cat $GANESHA_DIR/exports/export.$VOL.conf |\ +-grep Export_Id | cut -d " " -f3` +- check_cmd_status `echo $?` +- dbus-send --print-reply --system \ +---dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ +-org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id +- check_cmd_status `echo $?` +- +-} +- +-#This function adds a new export dynamically by sending dbus signals +-function dynamic_export_add() +-{ +- dbus-send --print-reply --system --dest=org.ganesha.nfsd \ +-/org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.AddExport \ +-string:$GANESHA_DIR/exports/export.$VOL.conf string:"EXPORT(Tag=$VOL)" +- check_cmd_status `echo $?` +- +-} +- +-function start_ganesha() +-{ +- check_gluster_nfs +- #Remove export entry from nfs-ganesha.conf +- sed -i /$VOL.conf/d $CONF1 +- #Create a new export entry +- export_add +- if ! ps aux | grep -q "[g]anesha.nfsd" +- then +- if ls /usr/bin/ganesha.nfsd +- then +- /usr/bin/ganesha.nfsd -f $CONF1 -L $LOG -N NIV_EVENT -d +- sleep 2 +- else +- /usr/local/bin/ganesha.nfsd -f $CONF1 -L $LOG -N NIV_EVENT -d +- sleep 2 +- fi +- else +- dynamic_export_add $VOL +- fi +- +- +- if !( ps aux | grep -q "[g]anesha.nfsd") +- then +- rm -rf $GANESHA_DIR/exports/* +- rm -rf $GANESHA_DIR/.export_added +- exit 1 +- fi +- +-} +- +-#This function generates a new config file when ganesha.host is set +-#If the volume is already exported, only hostname is changed +-function set_hostname() +-{ +- if ! ls $GANESHA_DIR/exports/ | grep -q $VOL.conf +- then +- write_conf $VOL $host_name >\ +-$GANESHA_DIR/exports/export.$VOL.conf +- else +- sed -i s/hostname.*/"hostname=\ +-\"$host_name\";"/ $GANESHA_DIR/exports/export.$VOL.conf +- fi +-} +- +- +-function check_ganesha_dir() +-{ +- #Check if the configuration file is placed in /etc/glusterfs-ganesha +- if ! ls /etc/glusterfs-ganesha | grep "nfs-ganesha.conf" +- then +- exit 1 +- else +- if [ ! -d "$GANESHA_DIR" ]; +- then +- mkdir $GANESHA_DIR +- check_cmd_status `echo $?` +- fi +- cp /etc/glusterfs-ganesha/nfs-ganesha.conf $GANESHA_DIR/ +- check_cmd_status `echo $?` +- fi +- if [ ! -d "$GANESHA_DIR/exports" ]; +- then +- mkdir $GANESHA_DIR/exports +- check_cmd_status `echo $?` +- fi +- if [ ! -d "$GANESHA_LOG_DIR" ] ; +- then +- mkdir $GANESHA_LOG_DIR +- check_cmd_status `echo $?` +- fi +- +- +- +-} +- +-function stop_ganesha() +-{ +- dynamic_export_remove $VOL +- #Remove the specfic export configuration file +- rm -rf $GANESHA_DIR/exports/export.$VOL.conf +- #Remove that entry from nfs-ganesha.conf +- sed -i /$VOL.conf/d $CONF1 +- #If there are no other volumes exported, stop nfs-ganesha +- if [ ! "$(ls -A $GANESHA_DIR/exports)" ]; +- then +- pkill ganesha.nfsd +- rm -rf $GANESHA_DIR/.export_added +- fi +-} +- +- parse_args $@ +- if [ "$ganesha_key" == "FALSE" ] +- then +- exit 0 +- fi +- check_ganesha_dir $VOL +- if echo $enable_ganesha | grep -q -i "ON" +- then +- check_if_host_set $VOL +- if ! showmount -e localhost | cut -d "" -f1 | grep -q "$VOL[[:space:]]" +- then +- start_ganesha +- fi +- elif echo $enable_ganesha | grep -q -i "OFF" +- then +- check_if_host_set $VOL +- stop_ganesha +- fi +- if [ "$host_name" != "none" ]; +- then +- if showmount -e localhost | cut -d "" -f1 | grep -q "$VOL[[:space:]]" +- then +- dynamic_export_remove $VOL +- set_hostname +- start_ganesha +- else +- set_hostname +- fi +- +- fi +diff --git a/extras/hook-scripts/start/post/Makefile.am b/extras/hook-scripts/start/post/Makefile.am +index d9cba93..ad53233 100644 +--- a/extras/hook-scripts/start/post/Makefile.am ++++ b/extras/hook-scripts/start/post/Makefile.am +@@ -1 +1 @@ +-EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh ++EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S31ganesha-start.sh +diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh +new file mode 100755 +index 0000000..7ba8af1 +--- /dev/null ++++ b/extras/hook-scripts/start/post/S31ganesha-start.sh +@@ -0,0 +1,114 @@ ++#!/bin/bash ++PROGNAME="Sganesha-start" ++OPTSPEC="volname:,gd-workdir:" ++VOL= ++declare -i EXPORT_ID ++ganesha_key="ganesha.enable" ++GANESHA_DIR="/etc/ganesha" ++CONF1="$GANESHA_DIR/ganesha.conf" ++GLUSTERD_WORKDIR= ++ ++function parse_args () ++{ ++ ARGS=$(getopt -l $OPTSPEC -o "o" -name $PROGNAME $@) ++ eval set -- "$ARGS" ++ ++ while true; do ++ case $1 in ++ --volname) ++ shift ++ VOL=$1 ++ ;; ++ --gd-workdir) ++ shift ++ GLUSTERD_WORKDIR=$1 ++ ;; ++ *) ++ shift ++ break ++ ;; ++ esac ++ shift ++ done ++} ++ ++ ++ ++#This function generates a new export entry as export.volume_name.conf ++function write_conf() ++{ ++ echo "EXPORT{ ++ " ++ echo "Export_Id = ;" ++ echo "Path=\"/$1\";" ++ echo "FSAL { ++ " ++ echo "name = "GLUSTER";" ++ echo "hostname="localhost";" ++ echo "volume=\"$1\";" ++ echo "}" ++ echo "Access_type = RW;" ++ echo "Squash = No_root_squash;" ++ echo "Disable_ACL = TRUE;" ++ echo "Pseudo=\"/$1\";" ++ echo "Protocols = \"3\",\"4\" ;" ++ echo "Transports = \"UDP\",\"TCP\" ;" ++ echo "SecType = \"sys\";" ++ echo "}" ++} ++ ++#This function keeps track of export IDs and increments it with every new entry ++function export_add() ++{ ++ count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l` ++ if [ "$count" = "0" ] ; ++ then ++ EXPORT_ID=2 ++ else ++ #if [ -s /var/lib/ganesha/export_removed ]; ++ # then ++ # EXPORT_ID=`head -1 /var/lib/ganesha/export_removed` ++ # sed -i -e "1d" /var/lib/ganesha/export_removed ++ # else ++ ++ EXPORT_ID=`cat $GANESHA_DIR/.export_added` ++ EXPORT_ID=EXPORT_ID+1 ++ #fi ++ fi ++ echo $EXPORT_ID > $GANESHA_DIR/.export_added ++ sed -i s/Export_Id.*/"Export_Id= $EXPORT_ID ;"/ \ ++$GANESHA_DIR/exports/export.$VOL.conf ++ echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF1 ++} ++ ++#This function adds a new export dynamically by sending dbus signals ++function dynamic_export_add() ++{ ++ dbus-send --print-reply --system --dest=org.ganesha.nfsd \ ++/org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.AddExport \ ++string:$GANESHA_DIR/exports/export.$VOL.conf string:"EXPORT(Path=/$VOL)" ++ ++} ++ ++function start_ganesha() ++{ ++ #Remove export entry from nfs-ganesha.conf ++ sed -i /$VOL.conf/d $CONF1 ++ #Create a new export entry ++ export_add $VOL ++ dynamic_export_add $VOL ++ ++} ++ ++ parse_args $@ ++ ganesha_value=$(grep $ganesha_key $GLUSTERD_WORKDIR/vols/$VOL/info |\ ++ cut -d"=" -f2) ++ if [ "$ganesha_value" = "on" ] ++ then ++ write_conf $VOL ++ start_ganesha $VOL ++ else ++ exit 0 ++ fi ++ ++ +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 7ee37fa..78bd311 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -1267,10 +1267,10 @@ fi + %config %{_sharedstatedir}/glusterd/hooks/1/add-brick/post/disabled-quota-root-xattr-heal.sh + %config %{_sharedstatedir}/glusterd/hooks/1/add-brick/pre/S28Quota-enable-root-xattr-heal.sh + %config %{_sharedstatedir}/glusterd/hooks/1/set/post/S30samba-set.sh +-%config %{_sharedstatedir}/glusterd/hooks/1/set/post/S31ganesha-set.sh + %config %{_sharedstatedir}/glusterd/hooks/1/set/post/S32gluster_enable_shared_storage.sh + %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S29CTDBsetup.sh + %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S30samba-start.sh ++%config %{_sharedstatedir}/glusterd/hooks/1/start/post/S31ganesha-start.sh + %config %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S30samba-stop.sh + %config %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh + %config %{_sharedstatedir}/glusterd/hooks/1/reset/post/S31ganesha-reset.sh +@@ -1930,6 +1930,7 @@ end + %endif + + %changelog ++ + * Fri Jun 19 2015 Bala.FA + - exclude libgfdb.pc conditionally for rhel-5 (#1233486) + +@@ -1940,6 +1941,9 @@ end + * Thu Jun 18 2015 Niels de Vos + - glusterfs-devel for client-builds should not depend on -server (#1227029) + ++* Mon Jun 15 2015 Niels de Vos ++- Replace hook script S31ganesha-set.sh by S31ganesha-start.sh (#1231738) ++ + * Fri Jun 12 2015 Aravinda VK + - Added rsync as dependency to georeplication rpm (#1231213) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +index 40a74cd..df2dd6d 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c ++++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +@@ -511,9 +511,10 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr) + goto out; + } + } ++ ++ vol_opts = volinfo->dict; + /* cache-invalidation should be on when a volume is exported + * and off when a volume is unexported. */ +- vol_opts = volinfo->dict; + ret = dict_set_dynstr_with_alloc (vol_opts, + "features.cache-invalidation", value); + if (ret) +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 04b539b..4f6a8dc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -1578,7 +1578,7 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + if (ret) { + ret = ganesha_manage_export(dict, "off", op_errstr); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, "Could not" ++ gf_log (THIS->name, GF_LOG_WARNING, "Could not " + "unexport volume via NFS-Ganesha"); + ret = 0; + } +@@ -2431,17 +2431,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + if (ret) + goto out; + } +- /* Check if the volume is exported via NFS-Ganesha, if yes +- * export it as part of starting the volume */ +- ret = glusterd_check_ganesha_export (volinfo); +- if (ret) { +- ret = ganesha_manage_export (dict, "on", op_errstr); +- if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, "NFS-Ganesha couldn't" +- "export the volume. %s", *op_errstr); +- ret = 0; +- } +- } ++ + ret = glusterd_svcs_manager (volinfo); + + out: +-- +1.7.1 + diff --git a/SOURCES/0117-features-bitrot-tuanble-object-signing-waiting-time-.patch b/SOURCES/0117-features-bitrot-tuanble-object-signing-waiting-time-.patch new file mode 100644 index 0000000..98c1c38 --- /dev/null +++ b/SOURCES/0117-features-bitrot-tuanble-object-signing-waiting-time-.patch @@ -0,0 +1,386 @@ +From 7c8df30e18538917e361faff2ed032024d5ba16f Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Fri, 5 Jun 2015 13:58:28 +0530 +Subject: [PATCH 117/129] features/bitrot: tuanble object signing waiting time value for bitrot + + Currently bitrot using 120 second waiting time for object to be signed + after all fop's released. This signing waiting time value should be tunable. + + Command for changing the signing waiting time will be + #gluster volume bitrot signing-time + +BUG: 1227900 +Change-Id: I6f63cc77c996bfc576a05801be39a2028e5db866 +Signed-off-by: Gaurav Kumar Garg +upstream patch url: http://review.gluster.org/#/c/11105/ +Reviewed-on: https://code.engineering.redhat.com/gerrit/50741 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + cli/src/cli-cmd-parser.c | 33 ++++++++++++++- + rpc/xdr/src/cli1-xdr.x | 1 + + tests/bugs/bitrot/bug-1228680.t | 31 ++++++++++++++ + xlators/features/bit-rot/src/bitd/bit-rot.c | 37 ++++++++++++++--- + xlators/features/bit-rot/src/bitd/bit-rot.h | 2 +- + xlators/mgmt/glusterd/src/glusterd-bitrot.c | 49 +++++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-volgen.c | 33 +++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 7 +++ + 8 files changed, 182 insertions(+), 11 deletions(-) + create mode 100644 tests/bugs/bitrot/bug-1228680.t + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 2ddbe88..51da792 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -5018,8 +5018,8 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options) + char *volname = NULL; + char *opwords[] = {"enable", "disable", + "scrub-throttle", +- "scrub-frequency", +- "scrub", NULL}; ++ "scrub-frequency", "scrub", ++ "signing-time", NULL}; + char *scrub_throt_values[] = {"lazy", "normal", + "aggressive", NULL}; + char *scrub_freq_values[] = {"hourly", +@@ -5030,6 +5030,7 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options) + NULL}; + dict_t *dict = NULL; + gf_bitrot_type type = GF_BITROT_OPTION_TYPE_NONE; ++ uint32_t expiry_time = 0; + + GF_ASSERT (words); + GF_ASSERT (options); +@@ -5039,7 +5040,7 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options) + goto out; + + if (wordcount < 4 || wordcount > 5) { +- gf_log ("", GF_LOG_ERROR, "Invalid syntax"); ++ gf_log ("cli", GF_LOG_ERROR, "Invalid syntax"); + goto out; + } + +@@ -5167,6 +5168,32 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options) + goto set_type; + } + } ++ } ++ ++ if (!strcmp (words[3], "signing-time")) { ++ if (!words[4]) { ++ cli_err ("Missing signing-time value for bitrot " ++ "option"); ++ ret = -1; ++ goto out; ++ } else { ++ type = GF_BITROT_OPTION_TYPE_EXPIRY_TIME; ++ ++ expiry_time = strtol (words[4], NULL, 0); ++ if (expiry_time < 1) { ++ cli_err ("Expiry time value should not be less" ++ " than 1"); ++ ret = -1; ++ goto out; ++ } ++ ++ ret = dict_set_int32 (dict, "expiry-time", expiry_time); ++ if (ret) { ++ cli_out ("Failed to set dict for bitrot"); ++ goto out; ++ } ++ goto set_type; ++ } + } else { + cli_err ("Invalid option %s for bitrot. Please enter valid " + "bitrot option", words[3]); +diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x +index 0d5d3cc..34f324f 100644 +--- a/rpc/xdr/src/cli1-xdr.x ++++ b/rpc/xdr/src/cli1-xdr.x +@@ -40,6 +40,7 @@ enum gf_bitrot_type { + GF_BITROT_OPTION_TYPE_SCRUB_THROTTLE, + GF_BITROT_OPTION_TYPE_SCRUB_FREQ, + GF_BITROT_OPTION_TYPE_SCRUB, ++ GF_BITROT_OPTION_TYPE_EXPIRY_TIME, + GF_BITROT_OPTION_TYPE_MAX + }; + +diff --git a/tests/bugs/bitrot/bug-1228680.t b/tests/bugs/bitrot/bug-1228680.t +new file mode 100644 +index 0000000..c77beed +--- /dev/null ++++ b/tests/bugs/bitrot/bug-1228680.t +@@ -0,0 +1,31 @@ ++#!/bin/bash ++ ++## Test case for bitrot ++## Tunable object signing waiting time value for bitrot. ++ ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup; ++ ++ ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create and start the volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 ++TEST $CLI volume start $V0 ++ ++## Enable bitrot on volume $V0 ++TEST $CLI volume bitrot $V0 enable ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++ ++## Set object expiry time value 20 second. ++TEST $CLI volume bitrot $V0 signing-time 20 ++ ++ ++cleanup; +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index 8149083..a4821ba 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -753,8 +753,11 @@ br_initialize_timer (xlator_t *this, br_object_t *object, br_child_t *child, + goto out; + INIT_LIST_HEAD (&timer->entry); + ++ timer->expires = (priv->expiry_time >> 1); ++ if (!timer->expires) ++ timer->expires = 1; ++ + timer->data = object; +- timer->expires = priv->expiry_time; + timer->function = br_add_object_to_queue; + gf_tw_add_timer (priv->timer_wheel, timer); + +@@ -1491,12 +1494,28 @@ br_rate_limit_signer (xlator_t *this, int child_count, int numbricks) + } + + static int32_t ++br_signer_handle_options (xlator_t *this, br_private_t *priv, dict_t *options) ++{ ++ if (options) ++ GF_OPTION_RECONF ("expiry-time", priv->expiry_time, ++ options, uint32, error_return); ++ else ++ GF_OPTION_INIT ("expiry-time", priv->expiry_time, ++ uint32, error_return); ++ ++ return 0; ++ ++error_return: ++ return -1; ++} ++ ++static int32_t + br_signer_init (xlator_t *this, br_private_t *priv) + { + int32_t ret = 0; + int numbricks = 0; + +- GF_OPTION_INIT ("expiry-time", priv->expiry_time, int32, error_return); ++ GF_OPTION_INIT ("expiry-time", priv->expiry_time, uint32, error_return); + GF_OPTION_INIT ("brick-count", numbricks, int32, error_return); + + ret = br_rate_limit_signer (this, priv->child_count, numbricks); +@@ -1581,6 +1600,8 @@ init (xlator_t *this) + + if (!priv->iamscrubber) { + ret = br_signer_init (this, priv); ++ if (!ret) ++ ret = br_signer_handle_options (this, priv, NULL); + } else { + ret = br_scrubber_init (this, priv); + if (!ret) +@@ -1651,8 +1672,12 @@ reconfigure (xlator_t *this, dict_t *options) + + priv = this->private; + +- if (!priv->iamscrubber) ++ if (!priv->iamscrubber) { ++ ret = br_signer_handle_options (this, priv, options); ++ if (ret) ++ goto err; + return 0; ++ } + + ret = br_scrubber_handle_options (this, priv, options); + if (ret) +@@ -1700,10 +1725,8 @@ struct xlator_cbks cbks; + struct volume_options options[] = { + { .key = {"expiry-time"}, + .type = GF_OPTION_TYPE_INT, +- /* Let the default timer be half the value of the wait time for +- * sining (which is 120 as of now) */ +- .default_value = "60", +- .description = "default time duration for which an object waits " ++ .default_value = "120", ++ .description = "Waiting time for an object on which it waits " + "before it is signed", + }, + { .key = {"brick-count"}, +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h +index 40e02eb..562f17e 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.h +@@ -162,7 +162,7 @@ struct br_private { + and ready to be picked up for + signing and the workers which sign + the objects */ +- int32_t expiry_time; /* objects "wait" time */ ++ uint32_t expiry_time; /* objects "wait" time */ + + br_tbf_t *tbf; /* token bucket filter */ + +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitrot.c b/xlators/mgmt/glusterd/src/glusterd-bitrot.c +index 08976cf..1563102 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitrot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-bitrot.c +@@ -37,6 +37,7 @@ const char *gd_bitrot_op_list[GF_BITROT_OPTION_TYPE_MAX] = { + [GF_BITROT_OPTION_TYPE_SCRUB_THROTTLE] = "scrub-throttle", + [GF_BITROT_OPTION_TYPE_SCRUB_FREQ] = "scrub-frequency", + [GF_BITROT_OPTION_TYPE_SCRUB] = "scrub", ++ [GF_BITROT_OPTION_TYPE_EXPIRY_TIME] = "expiry-time", + }; + + int +@@ -248,6 +249,46 @@ out: + } + + static int ++glusterd_bitrot_expiry_time (glusterd_volinfo_t *volinfo, dict_t *dict, ++ char *key, char **op_errstr) ++{ ++ int32_t ret = -1; ++ uint32_t expiry_time = 0; ++ xlator_t *this = NULL; ++ char dkey[1024] = {0,}; ++ char *key_value = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); ++ ++ ret = dict_get_uint32 (dict, "expiry-time", &expiry_time); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Unable to get bitrot expiry" ++ " timer value."); ++ goto out; ++ } ++ ++ snprintf (dkey, sizeof (dkey), "%d", expiry_time); ++ key_value = gf_strdup (dkey); ++ ++ ret = dict_set_dynstr (volinfo->dict, key, key_value); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ key); ++ goto out; ++ } ++ ++ ret = glusterd_bitdsvc_reconfigure (); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to reconfigure bitrot" ++ "services"); ++ goto out; ++ } ++out: ++ return ret; ++} ++ ++static int + glusterd_bitrot_enable (glusterd_volinfo_t *volinfo, char **op_errstr) + { + int32_t ret = -1; +@@ -476,6 +517,14 @@ glusterd_op_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + goto out; + break; + ++ case GF_BITROT_OPTION_TYPE_EXPIRY_TIME: ++ ret = glusterd_bitrot_expiry_time (volinfo, dict, ++ "features.expiry-time", ++ op_errstr); ++ if (ret) ++ goto out; ++ break; ++ + default: + gf_asprintf (op_errstr, "Bitrot command failed. Invalid " + "opcode"); +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index 9c09c78..a79e129 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -3743,6 +3743,33 @@ gd_get_matching_option (char **options, char *option) + } + + static int ++bitrot_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme, ++ void *param) ++{ ++ xlator_t *xl = NULL; ++ char *bitrot_option = NULL; ++ int ret = 0; ++ glusterd_volinfo_t *volinfo = NULL; ++ ++ volinfo = param; ++ ++ xl = first_of (graph); ++ ++ if (!strcmp (vme->option, "expiry-time")) { ++ ret = gf_asprintf (&bitrot_option, "expiry-time"); ++ if (ret != -1) { ++ ret = xlator_set_option (xl, bitrot_option, vme->value); ++ GF_FREE (bitrot_option); ++ } ++ ++ if (ret) ++ return -1; ++ } ++ ++ return ret; ++} ++ ++static int + scrubber_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme, + void *param) + { +@@ -4981,6 +5008,12 @@ build_bitd_volume_graph (volgen_graph_t *graph, + goto out; + } + ++ ret = volgen_graph_set_options_generic (&cgraph, set_dict, ++ volinfo, ++ bitrot_option_handler); ++ if (ret) ++ goto out; ++ + ret = volgen_graph_merge_sub (graph, &cgraph, clusters); + if (ret) + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 624e577..415bc01 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1866,6 +1866,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .flags = OPT_FLAG_FORCE, + .type = NO_DOC, + }, ++ { .key = "features.expiry-time", ++ .voltype = "features/bitrot", ++ .value = "120", ++ .option = "expiry-time", ++ .op_version = GD_OP_VERSION_3_7_0, ++ .type = NO_DOC, ++ }, + /* Upcall translator options */ + { .key = "features.cache-invalidation", + .voltype = "features/upcall", +-- +1.7.1 + diff --git a/SOURCES/0118-features-bitrot-fix-fd-leak-in-truncate-stub.patch b/SOURCES/0118-features-bitrot-fix-fd-leak-in-truncate-stub.patch new file mode 100644 index 0000000..01ba9c0 --- /dev/null +++ b/SOURCES/0118-features-bitrot-fix-fd-leak-in-truncate-stub.patch @@ -0,0 +1,143 @@ +From 473a0cb2ac1696c13b1a576b71b26eba941dba77 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Thu, 4 Jun 2015 10:07:38 +0530 +Subject: [PATCH 118/129] features/bitrot: fix fd leak in truncate (stub) + +The need to perform object versioning in the truncate() code path +required an fd to reuse existing versioning infrastructure that's +used by fd based operations (such as writev(), ftruncate(), etc..). + +This tempted the use of anonymous fd which was never ever unref()'d +after use resulting in fd and/or memory leak depending on the code +path taken. Versioning resulted in a dangling file descriptor left +open in the filesystem effecting the signing process of a given +object (no release() would be trigerred, hence no signing would be +performed). On the other hand, cases where the object need not be +versioned, the anonymous fd in still ref()'d resulting in memory +leak (NOTE: there's no "dangling" file descriptor in this case). + +BUG: 1227900 +Change-Id: Ia62d4eef86d7af3dda19817adb1e461eb6a8886d +Signed-off-by: Venky Shankar +Reviewed-on: http://review.gluster.org/11077 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51130 +--- + tests/bugs/bitrot/bug-1227996.t | 58 ++++++++++++++++++++++ + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 11 +++- + 2 files changed, 66 insertions(+), 3 deletions(-) + create mode 100644 tests/bugs/bitrot/bug-1227996.t + +diff --git a/tests/bugs/bitrot/bug-1227996.t b/tests/bugs/bitrot/bug-1227996.t +new file mode 100644 +index 0000000..47ebc42 +--- /dev/null ++++ b/tests/bugs/bitrot/bug-1227996.t +@@ -0,0 +1,58 @@ ++#!/bin/bash ++ ++## Test case for bitrot ++## Tunable object signing waiting time value for bitrot. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++SLEEP_TIME=3 ++ ++cleanup; ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create and start the volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 ++TEST $CLI volume start $V0 ++ ++## Enable bitrot on volume $V0 ++TEST $CLI volume bitrot $V0 enable ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++ ++# wait a bit for oneshot crawler to finish ++sleep $SLEEP_TIME ++ ++## Set object expiry time value ++TEST $CLI volume bitrot $V0 signing-time $SLEEP_TIME ++ ++## Mount the volume ++TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; ++ ++# create and check object signature ++fname="$M0/filezero" ++echo "ZZZ" > $fname ++ ++# wait till the object is signed ++sleep `expr $SLEEP_TIME \* 2` ++ ++backpath=$(get_backend_paths $fname) ++TEST getfattr -m . -n trusted.bit-rot.signature $backpath ++ ++## for now just remove the signature xattr to test for signing ++## upon truncate() ++TEST setfattr -x trusted.bit-rot.signature $backpath ++ ++## overwrite the file (truncate(), write()) ++echo "XYX" > $fname ++ ++# wait till the object is signed ++sleep `expr $SLEEP_TIME \* 2` ++ ++# test for new signature ++TEST getfattr -m . -n trusted.bit-rot.signature $backpath ++ ++cleanup; +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 69e326b..4f0605d 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -1434,6 +1434,9 @@ int32_t + br_stub_truncate_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, + off_t offset, dict_t *xdata) + { ++ br_stub_local_t *local = frame->local; ++ ++ fd_unref (local->u.context.fd); + STACK_WIND (frame, br_stub_ftruncate_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->truncate, loc, offset, xdata); + return 0; +@@ -1482,14 +1485,14 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + + ret = br_stub_need_versioning (this, fd, &inc_version, &modified, &ctx); + if (ret) +- goto unwind; ++ goto cleanup_fd; + + if (!inc_version && modified) + goto wind; + + ret = br_stub_versioning_prep (frame, this, fd, ctx); + if (ret) +- goto unwind; ++ goto cleanup_fd; + + local = frame->local; + if (!inc_version) { +@@ -1513,12 +1516,14 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + wind: + STACK_WIND (frame, cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->truncate, loc, offset, xdata); ++ fd_unref (fd); + return 0; + + cleanup_local: + br_stub_cleanup_local (local); + br_stub_dealloc_local (local); +- ++ cleanup_fd: ++ fd_unref (fd); + unwind: + frame->local = NULL; + STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, NULL, NULL, +-- +1.7.1 + diff --git a/SOURCES/0119-tier-volume-set-Validate-volume-set-option-for-tier.patch b/SOURCES/0119-tier-volume-set-Validate-volume-set-option-for-tier.patch new file mode 100644 index 0000000..a2f39ff --- /dev/null +++ b/SOURCES/0119-tier-volume-set-Validate-volume-set-option-for-tier.patch @@ -0,0 +1,186 @@ +From 27a3fd3e46dcfd46f81a5989789313e1bc78da19 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Mon, 11 May 2015 14:43:23 +0530 +Subject: [PATCH 119/129] tier/volume set: Validate volume set option for tier + +Backport of http://review.gluster.org/#/c/10751/ + +Volume set option related to tier volume can only be set +for tier volume, also currently all volume set i for tier +option accepts a non-negative integer. This patch validate +both condition. + +Change-Id: I3611af048ff4ab193544058cace8db205ea92336 +BUG: 1216960 +Signed-off-by: Joseph Fernandes +Reviewed-on: https://code.engineering.redhat.com/gerrit/50617 +Reviewed-by: Dan Lambright +Tested-by: Dan Lambright +--- + tests/basic/tier/tier.t | 21 ++++-- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 82 +++++++++++++++++++++- + 2 files changed, 93 insertions(+), 10 deletions(-) + +diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t +index 2a5f748..bec34ef 100755 +--- a/tests/basic/tier/tier.t ++++ b/tests/basic/tier/tier.t +@@ -52,8 +52,6 @@ function confirm_vol_stopped { + fi + } + +-LAST_BRICK=1 +-CACHE_BRICK=2 + DEMOTE_TIMEOUT=12 + PROMOTE_TIMEOUT=5 + MIGRATION_TIMEOUT=10 +@@ -67,16 +65,27 @@ TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK} + TEST ! $CLI volume attach-tier $V0 replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST + + TEST $CLI volume start $V0 +-TEST $CLI volume set $V0 cluster.tier-demote-frequency 4 +-TEST $CLI volume set $V0 cluster.tier-promote-frequency 4 +-TEST $CLI volume set $V0 cluster.read-freq-threshold 0 +-TEST $CLI volume set $V0 cluster.write-freq-threshold 0 ++ + TEST $CLI volume set $V0 performance.quick-read off + TEST $CLI volume set $V0 performance.io-cache off + TEST $CLI volume set $V0 features.ctr-enabled on + ++#Not a tier volume ++TEST ! $CLI volume set $V0 cluster.tier-demote-frequency 4 ++ + TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST + ++#Tier options expect non-negative value ++TEST ! $CLI volume set $V0 cluster.tier-promote-frequency -1 ++ ++#Tier options expect non-negative value ++TEST ! $CLI volume set $V0 cluster.read-freq-threshold qwerty ++ ++TEST $CLI volume set $V0 cluster.tier-demote-frequency 4 ++TEST $CLI volume set $V0 cluster.tier-promote-frequency 4 ++TEST $CLI volume set $V0 cluster.read-freq-threshold 0 ++TEST $CLI volume set $V0 cluster.write-freq-threshold 0 ++ + TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; + + # Basic operations. +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 415bc01..34c9fc5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -17,6 +17,76 @@ + #include "glusterd-utils.h" + + static int ++validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, ++ char *value, char **op_errstr) ++{ ++ char errstr[2048] = ""; ++ int ret = 0; ++ xlator_t *this = NULL; ++ int origin_val = -1; ++ ++ this = THIS; ++ GF_ASSERT (this); ++ ++ if (volinfo->type != GF_CLUSTER_TYPE_TIER) { ++ snprintf (errstr, sizeof (errstr), "Volume %s is not a tier " ++ "volume. Option %s is only valid for tier volume.", ++ volinfo->volname, key); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ *op_errstr = gf_strdup (errstr); ++ ret = -1; ++ goto out; ++ } ++ ++ /* ++ * All the volume set options for tier are expecting a positive ++ * Integer. Change the function accordingly if this constraint is ++ * changed. ++ */ ++ ++ ret = gf_string2int (value, &origin_val); ++ if (ret) { ++ snprintf (errstr, sizeof (errstr), "%s is not a compatible " ++ "value. %s expects an integer value.", ++ value, key); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ *op_errstr = gf_strdup (errstr); ++ ret = -1; ++ goto out; ++ } ++ ++ if (strstr ("cluster.tier-promote-frequency", key) || ++ strstr ("cluster.tier-demote-frequency", key)) { ++ if (origin_val < 1) { ++ snprintf (errstr, sizeof (errstr), "%s is not a " ++ "compatible value. %s expects a positive " ++ "integer value.", ++ value, key); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ *op_errstr = gf_strdup (errstr); ++ ret = -1; ++ goto out; ++ } ++ } else { ++ if (origin_val < 0) { ++ snprintf (errstr, sizeof (errstr), "%s is not a " ++ "compatible value. %s expects a non-negative" ++ " integer value.", ++ value, key); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ *op_errstr = gf_strdup (errstr); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++out: ++ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ ++ return ret; ++} ++ ++static int + validate_cache_max_min_size (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) + { +@@ -1764,25 +1834,29 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "cluster/tier", + .option = "write-freq-threshold", + .op_version = GD_OP_VERSION_3_7_0, +- .flags = OPT_FLAG_CLIENT_OPT ++ .flags = OPT_FLAG_CLIENT_OPT, ++ .validate_fn = validate_tier + }, + { .key = "cluster.read-freq-threshold", + .voltype = "cluster/tier", + .option = "read-freq-threshold", + .op_version = GD_OP_VERSION_3_7_0, +- .flags = OPT_FLAG_CLIENT_OPT ++ .flags = OPT_FLAG_CLIENT_OPT, ++ .validate_fn = validate_tier + }, + { .key = "cluster.tier-promote-frequency", + .voltype = "cluster/tier", + .option = "tier-promote-frequency", + .op_version = GD_OP_VERSION_3_7_0, +- .flags = OPT_FLAG_CLIENT_OPT ++ .flags = OPT_FLAG_CLIENT_OPT, ++ .validate_fn = validate_tier + }, + { .key = "cluster.tier-demote-frequency", + .voltype = "cluster/tier", + .option = "tier-demote-frequency", + .op_version = GD_OP_VERSION_3_7_0, +- .flags = OPT_FLAG_CLIENT_OPT ++ .flags = OPT_FLAG_CLIENT_OPT, ++ .validate_fn = validate_tier + }, + { .key = "features.ctr-enabled", + .voltype = "features/changetimerecorder", +-- +1.7.1 + diff --git a/SOURCES/0120-glusterd-tier-glusterd-crashed-with-detach-tier-comm.patch b/SOURCES/0120-glusterd-tier-glusterd-crashed-with-detach-tier-comm.patch new file mode 100644 index 0000000..ef37b77 --- /dev/null +++ b/SOURCES/0120-glusterd-tier-glusterd-crashed-with-detach-tier-comm.patch @@ -0,0 +1,93 @@ +From b9464c0b0efc95956b914a0ef25200a471b840c3 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 4 Jun 2015 14:14:14 +0530 +Subject: [PATCH 120/129] glusterd/tier: glusterd crashed with detach-tier commit force + +this patch has is a back port of fix 11081 + +glusterd crashed when doing "detach-tier commit force" on a +non-tiered volume. + +> Change-Id: I884771893bb80bec46ae8642c2cfd7e54ab116a6 +> BUG: 1229274 +> Signed-off-by: Mohammed Rafi KC +> Reviewed-on: http://review.gluster.org/11081 +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System +> Reviewed-by: Dan Lambright +> Reviewed-by: Krishnan Parthasarathi +> Signed-off-by: Joseph Fernandes + +Change-Id: I884771893bb80bec46ae8642c2cfd7e54ab116a6 +Reviewed-on: https://code.engineering.redhat.com/gerrit/50622 +Reviewed-by: Dan Lambright +Tested-by: Dan Lambright +--- + cli/src/cli-rpc-ops.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 7 +++++++ + xlators/mgmt/glusterd/src/glusterd-rebalance.c | 9 ++++++++- + 3 files changed, 16 insertions(+), 2 deletions(-) + +diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c +index 290028f..a834147 100644 +--- a/cli/src/cli-rpc-ops.c ++++ b/cli/src/cli-rpc-ops.c +@@ -1784,7 +1784,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, + rsp.op_errstr); + } + } +- if (cmd == GF_DEFRAG_CMD_STATUS) { ++ if (cmd == GF_DEFRAG_CMD_STATUS || cmd == GF_DEFRAG_CMD_STATUS_TIER) { + if (rsp.op_ret == -1) { + if (strcmp (rsp.op_errstr, "")) + snprintf (msg, sizeof (msg), +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index a3fda98..7dc34c2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -1888,6 +1888,13 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + break; + + case GF_OP_CMD_DETACH_COMMIT_FORCE: ++ if (volinfo->type != GF_CLUSTER_TYPE_TIER) { ++ snprintf (msg, sizeof(msg), "volume %s is not a tier " ++ "volume", volinfo->volname); ++ errstr = gf_strdup (msg); ++ gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ goto out; ++ } + case GF_OP_CMD_COMMIT_FORCE: + break; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +index 4fd95c2..8449bb2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +@@ -606,9 +606,15 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + goto out; + } + switch (cmd) { ++ case GF_DEFRAG_CMD_START_TIER: ++ if (volinfo->type != GF_CLUSTER_TYPE_TIER) { ++ gf_asprintf (op_errstr, "volume %s is not a tier " ++ "volume.", volinfo->volname); ++ ret = -1; ++ goto out; ++ } + case GF_DEFRAG_CMD_START: + case GF_DEFRAG_CMD_START_LAYOUT_FIX: +- case GF_DEFRAG_CMD_START_TIER: + /* Check if the connected clients are all of version + * RHS-2.1u5 and higher. This is needed to prevent some data + * loss issues that could occur when older clients are connected +@@ -668,6 +674,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) + goto out; + } + break; ++ case GF_DEFRAG_CMD_STATUS_TIER: + case GF_DEFRAG_CMD_STATUS: + case GF_DEFRAG_CMD_STOP: + case GF_DEFRAG_CMD_STOP_DETACH_TIER: +-- +1.7.1 + diff --git a/SOURCES/0121-glusterd-shared_storage-Added-help-description-for-e.patch b/SOURCES/0121-glusterd-shared_storage-Added-help-description-for-e.patch new file mode 100644 index 0000000..51af9ee --- /dev/null +++ b/SOURCES/0121-glusterd-shared_storage-Added-help-description-for-e.patch @@ -0,0 +1,38 @@ +From fca2ff085f4942bceae164badeec9626c7476842 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Fri, 19 Jun 2015 12:32:51 +0530 +Subject: [PATCH 121/129] glusterd/shared_storage: Added help description for enable-shared-storage option + +Added help description in gluster volume set help for +cluster.enable-shared-storage option. + +>Reviewed-on: http://review.gluster.org/11324/ +Change-Id: I36481d1ca856739e83f0c9c7432ac0cb4131d665 +BUG: 1232624 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/51128 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 34c9fc5..83256c4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1826,6 +1826,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .value = "disable", + .type = GLOBAL_DOC, + .op_version = GD_OP_VERSION_3_7_1, ++ .description = "Create and mount the shared storage volume" ++ "(gluster_shared_storage) at " ++ "/var/run/gluster/shared_storage on enabling this " ++ "option. Unmount and delete the shared storage volume " ++ " on disabling this option." + }, + + #if USE_GFDB /* no GFDB means tiering is disabled */ +-- +1.7.1 + diff --git a/SOURCES/0122-cluster-dht-Prevent-use-after-free-bug.patch b/SOURCES/0122-cluster-dht-Prevent-use-after-free-bug.patch new file mode 100644 index 0000000..c0e388e --- /dev/null +++ b/SOURCES/0122-cluster-dht-Prevent-use-after-free-bug.patch @@ -0,0 +1,42 @@ +From 99c25e8b07f36adf7786164ff9ca4225b1835ca0 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Sat, 13 Jun 2015 17:33:14 +0530 +Subject: [PATCH 122/129] cluster/dht: Prevent use after free bug + + Backport of http://review.gluster.org/11209 + +BUG: 1233046 +Change-Id: If3685c9ed84a6720d8696d11773005e9786b503f +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/50997 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-helper.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index ac2f794..f24c62c 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -1577,6 +1577,8 @@ dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + local->lock.locks[i]->domain, + &local->lock.locks[i]->loc, F_SETLK, + &flock, NULL); ++ if (!--call_cnt) ++ break; + } + + return 0; +@@ -1666,7 +1668,7 @@ dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + + local->call_cnt = lk_count; + +- for (i = 0; i < local->lock.lk_count; i++) { ++ for (i = 0; i < lk_count; i++) { + flock.l_type = local->lock.locks[i]->type; + + STACK_WIND_COOKIE (lock_frame, dht_nonblocking_inodelk_cbk, +-- +1.7.1 + diff --git a/SOURCES/0123-afr-complete-conservative-merge-even-in-case-of-gfid.patch b/SOURCES/0123-afr-complete-conservative-merge-even-in-case-of-gfid.patch new file mode 100644 index 0000000..5c123bd --- /dev/null +++ b/SOURCES/0123-afr-complete-conservative-merge-even-in-case-of-gfid.patch @@ -0,0 +1,150 @@ +From afc090ba37104c6a478cdb41661b96d94ff2d089 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Fri, 19 Jun 2015 15:29:06 +0530 +Subject: [PATCH 123/129] afr: complete conservative merge even in case of gfid split-brain. + +Patch URL in master: http://review.gluster.org/#/c/9429/ +Patch ULR in release 3.7: http://review.gluster.org/#/c/11327/ + +Problem: +While performing conservative merge, we bail out of the merge if we encounter a +file with mismatching gfid or type. What this means is all entries that come +after the mismatching file (during the merge) never get healed, no matter how +many index heals are done. + +Fix: +Continue with the merging of rest of the entries even if a gfid/type mismatch is +found, but ensure that post-op does not happen on the parent dir in such a case. + +Change-Id: I620911e14cf1a9c4482e44469fb00386dd4fe7ee +BUG: 1230517 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/51116 +--- + tests/bugs/replicate/bug-1180545.t | 48 +++++++++++++++++++++++++ + xlators/cluster/afr/src/afr-self-heal-entry.c | 20 +++++++++- + 2 files changed, 66 insertions(+), 2 deletions(-) + create mode 100644 tests/bugs/replicate/bug-1180545.t + +diff --git a/tests/bugs/replicate/bug-1180545.t b/tests/bugs/replicate/bug-1180545.t +new file mode 100644 +index 0000000..748d5de +--- /dev/null ++++ b/tests/bugs/replicate/bug-1180545.t +@@ -0,0 +1,48 @@ ++#!/bin/bash ++ ++#Create gfid split-brain of directory and check if conservative merge ++#completes successfully. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../afr.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/brick{0,1} ++TEST $CLI volume set $V0 cluster.heal-timeout 60 ++TEST $CLI volume set $V0 cluster.self-heal-daemon off ++TEST $CLI volume start $V0 ++TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++#Create files with alternate brick down. One file has gfid mismatch. ++TEST mkdir $M0/DIR ++ ++TEST kill_brick $V0 $H0 $B0/brick1 ++TEST touch $M0/DIR/FILE ++TEST touch $M0/DIR/file{1..5} ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++TEST kill_brick $V0 $H0 $B0/brick0 ++TEST touch $M0/DIR/FILE ++TEST touch $M0/DIR/file{6..10} ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++ ++#Trigger heal and verify number of entries in backend ++TEST $CLI volume set $V0 cluster.self-heal-daemon on ++EXPECT_WITHIN PROCESS_UP_TIMEOUT "Y" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 ++TEST $CLI volume heal $V0 ++ ++EXPECT_WITHIN $HEAL_TIMEOUT '2' count_sh_entries $B0/brick0 ++EXPECT_WITHIN $HEAL_TIMEOUT '2' count_sh_entries $B0/brick1 ++#Two entries for DIR and two for FILE ++EXPECT_WITHIN $HEAL_TIMEOUT "4" afr_get_pending_heal_count $V0 ++TEST diff <(ls $B0/brick0/DIR) <(ls $B0/brick1/DIR) ++cleanup +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index ab210b3..e64b6e4 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -508,6 +508,7 @@ afr_selfheal_entry_do_subvol (call_frame_t *frame, xlator_t *this, + call_frame_t *iter_frame = NULL; + xlator_t *subvol = NULL; + afr_private_t *priv = NULL; ++ gf_boolean_t mismatch = _gf_false; + + priv = this->private; + subvol = priv->children[child]; +@@ -537,6 +538,11 @@ afr_selfheal_entry_do_subvol (call_frame_t *frame, xlator_t *this, + entry->d_name); + AFR_STACK_RESET (iter_frame); + ++ if (ret == -1) { ++ /* gfid or type mismatch. */ ++ mismatch = _gf_true; ++ ret = 0; ++ } + if (ret) + break; + } +@@ -547,6 +553,9 @@ afr_selfheal_entry_do_subvol (call_frame_t *frame, xlator_t *this, + } + + AFR_STACK_DESTROY (iter_frame); ++ if (mismatch == _gf_true) ++ /* undo pending will be skipped */ ++ ret = -1; + return ret; + } + +@@ -557,6 +566,7 @@ afr_selfheal_entry_do (call_frame_t *frame, xlator_t *this, fd_t *fd, + { + int i = 0; + afr_private_t *priv = NULL; ++ gf_boolean_t mismatch = _gf_false; + int ret = 0; + + priv = this->private; +@@ -568,14 +578,20 @@ afr_selfheal_entry_do (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (i != source && !healed_sinks[i]) + continue; + ret = afr_selfheal_entry_do_subvol (frame, this, fd, i); ++ if (ret == -1) { ++ /* gfid or type mismatch. */ ++ mismatch = _gf_true; ++ continue; ++ } + if (ret) + break; + } ++ if (mismatch == _gf_true) ++ /* undo pending will be skipped */ ++ ret = -1; + return ret; + } + +- +- + static int + __afr_selfheal_entry (call_frame_t *frame, xlator_t *this, fd_t *fd, + unsigned char *locked_on) +-- +1.7.1 + diff --git a/SOURCES/0124-dht-Error-value-check-before-performing-rebalance-co.patch b/SOURCES/0124-dht-Error-value-check-before-performing-rebalance-co.patch new file mode 100644 index 0000000..5beb9e2 --- /dev/null +++ b/SOURCES/0124-dht-Error-value-check-before-performing-rebalance-co.patch @@ -0,0 +1,65 @@ +From 59fe175bc473db2a87ee8f40f220275da9e7b0ff Mon Sep 17 00:00:00 2001 +From: Sakshi +Date: Fri, 5 Jun 2015 13:48:09 +0530 +Subject: [PATCH 124/129] dht : Error value check before performing rebalance complete + +Change-Id: I7a0cd288d16f27b887c7820162efdbe99a039d95 +BUG: 1224115 +Signed-off-by: Sakshi +Reviewed-on: https://code.engineering.redhat.com/gerrit/51121 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-inode-write.c | 18 +++++++++++++----- + 1 files changed, 13 insertions(+), 5 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c +index 85102a3..1846ece 100644 +--- a/xlators/cluster/dht/src/dht-inode-write.c ++++ b/xlators/cluster/dht/src/dht-inode-write.c +@@ -29,21 +29,29 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + struct iatt *postbuf, dict_t *xdata) + { + dht_local_t *local = NULL; ++ call_frame_t *prev = NULL; + int ret = -1; + xlator_t *subvol1 = NULL; + xlator_t *subvol2 = NULL; + +- if (op_ret == -1 && !dht_inode_missing(op_errno)) { +- goto out; +- } +- + local = frame->local; ++ prev = cookie; ++ + if (!local) { + op_ret = -1; + op_errno = EINVAL; + goto out; + } + ++ if (op_ret == -1 && !dht_inode_missing(op_errno)) { ++ local->op_errno = op_errno; ++ local->op_ret = -1; ++ gf_msg_debug (this->name, 0, ++ "subvolume %s returned -1 (%s)", ++ prev->this->name, strerror (op_errno)); ++ goto out; ++ } ++ + if (local->call_cnt != 1) { + /* preserve the modes of source */ + if (local->stbuf.ia_blocks) { +@@ -57,7 +65,7 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + local->op_errno = op_errno; + /* Phase 2 of migration */ +- if (IS_DHT_MIGRATION_PHASE2 (postbuf)) { ++ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { + ret = dht_rebalance_complete_check (this, frame); + if (!ret) + return 0; +-- +1.7.1 + diff --git a/SOURCES/0125-common-ha-Fixing-add-node-operation.patch b/SOURCES/0125-common-ha-Fixing-add-node-operation.patch new file mode 100644 index 0000000..c96a492 --- /dev/null +++ b/SOURCES/0125-common-ha-Fixing-add-node-operation.patch @@ -0,0 +1,185 @@ +From 8ac406785cfa18813d1f04bd7587a05e750735d5 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Thu, 18 Jun 2015 06:39:41 +0530 +Subject: [PATCH 125/129] common-ha : Fixing add node operation + +Resource create for the added node referenced a variable +new_node that was never passed. This led to a wrong schema +type in the cib file and hence the added node always ended +up in failed state. And also, resources were wrongly +created twice and led to more errors. I have fixed the variable +name and deleted the repetitive invocation of the recreate-resource +function. + +The new node has to be added to the existing ganesha-ha config +file for correct behaviour during subsequent add-node operations. +This edited file has to be copied to all the other cluster nodes. +I have added a fix for this as well. + +This is the backport of the fix merged on master, +http://review.gluster.org/#/c/11316/ + +Change-Id: I28b585a252f25a85e481c9c420d10e1e30c5dd9a +BUG: 1228626 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/51195 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + cli/src/cli-rpc-ops.c | 2 +- + extras/ganesha/scripts/ganesha-ha.sh | 64 ++++++++++++++++++++-------------- + 2 files changed, 39 insertions(+), 27 deletions(-) + +diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c +index a834147..57e11fa 100644 +--- a/cli/src/cli-rpc-ops.c ++++ b/cli/src/cli-rpc-ops.c +@@ -1976,7 +1976,7 @@ gf_cli_ganesha_cbk (struct rpc_req *req, struct iovec *iov, + } + + else { +- cli_out("ganesha enable : success "); ++ cli_out("nfs-ganesha : success "); + } + + ret = rsp.op_ret; +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 725b6b4..74c1194 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -53,11 +53,15 @@ determine_service_manager () { + + manage_service () + { ++ local action=${1} ++ local new_node=${2} + if [ "$SERVICE_MAN" == "/usr/sbin/systemctl" ] + then +- $SERVICE_MAN $1 nfs-ganesha ++ ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha" + else +- $SERVICE_MAN nfs-ganesha $1 ++ ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}" + fi + } + +@@ -171,7 +175,8 @@ setup_copy_config() + if [ -e /var/lib/glusterd/nfs/secret.pem ]; then + while [[ ${1} ]]; do + if [ ${short_host} != ${1} ]; then +- scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/nfs/secret.pem /etc/ganesha/ganesha-ha.conf ${1}:/etc/ganesha/ ++ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem ${1}:${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/ + if [ $? -ne 0 ]; then + logger "warning: scp ganesha-ha.conf to ${1} failed" + fi +@@ -185,9 +190,11 @@ setup_copy_config() + + copy_export_config () + { +- . /etc/ganesha/ganesha.conf +- scp $HA_VOL_SERVER:/etc/ganesha.conf ${1}:/etc/ganesha/ +- scp -r $HA_VOL_SERVER:$2/exports/ ${1}:${2}/ ++ local new_node=${1} ++ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${GANESHA_CONF} ${new_node}:/etc/ganesha/ ++ scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${new_node}:${HA_CONFDIR}/ + } + + +@@ -547,9 +554,6 @@ clear_resources() + + shift + done +- +- recreate_resources ${cibfile} ${add_node} ${add_vip} ${HA_SERVERS} +- + } + + +@@ -570,9 +574,9 @@ addnode_create_resources() + logger "warning: pcs -f ${cibfile} resource create nfs_start-${add_node} ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} failed" + fi + +- pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${newnode}=INFINITY ++ pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${add_node}=INFINITY + if [ $? -ne 0 ]; then +- logger "warning: pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${newnode}=INFINITY failed" ++ logger "warning: pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${add_node}=INFINITY failed" + fi + + pcs -f ${cibfile} constraint order nfs_start-${add_node} then nfs-mon-clone +@@ -802,24 +806,34 @@ main() + + logger "adding ${node} with ${vip} to ${HA_NAME}" + +- determine_servers "add" ++ copy_export_config ${node} ${HA_CONFDIR} + +- pcs cluster node add ${node} +- if [ $? -ne 0 ]; then +- logger "warning: pcs cluster node add ${node} failed" +- fi ++ determine_service_manager + +- addnode_create_resources ${node} ${vip} ++ manage_service "start" ${node} + +- setup_state_volume ${node} ++ determine_servers "add" + +- setup_copy_config ${node} ++ pcs cluster node add ${node} ++ if [ $? -ne 0 ]; then ++ logger "warning: pcs cluster node add ${node} failed" ++ fi + +- copy_export_config ${node} ${HA_CONFDIR} ++ addnode_create_resources ${node} ${vip} ++ #Subsequent add-node recreates resources for all the nodes ++ #that already exist in the cluster. The nodes are picked up ++ #from the entries in the ganesha-ha.conf file. Adding the ++ #newly added node to the file so that the resources specfic ++ #to this node is correctly recreated in the future. ++ echo "VIP_$node=\"$vip\"" >> ${HA_CONFDIR}/ganesha-ha.conf + +- determine_service_manager ++ NEW_NODES="$HA_CLUSTER_NODES,$node" + +- manage_service "start" ++ sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \ ++$HA_CONFDIR/ganesha-ha.conf ++ HA_SERVERS="${HA_SERVERS} ${node}" ++ ++ setup_copy_config ${HA_SERVERS} + ;; + + delete | --delete) +@@ -838,8 +852,6 @@ main() + + # TODO: delete node's directory in shared state + +- teardown_clean_etccluster ${node} +- + determine_service_manager + + manage-service "stop" +@@ -856,9 +868,9 @@ main() + + help | --help) + echo "Usage : add|delete|status" +- echo "Add-node : ganesha-ha.sh --add \ ++ echo "Add-node : ganesha-ha.sh --add \ + " +- echo "Delete-node: ganesha-ha.sh --delete \ ++ echo "Delete-node: ganesha-ha.sh --delete \ + " + ;; + *) +-- +1.7.1 + diff --git a/SOURCES/0126-quota-allow-writes-when-with-ENOENT-ESTALE-on-active.patch b/SOURCES/0126-quota-allow-writes-when-with-ENOENT-ESTALE-on-active.patch new file mode 100644 index 0000000..1f44416 --- /dev/null +++ b/SOURCES/0126-quota-allow-writes-when-with-ENOENT-ESTALE-on-active.patch @@ -0,0 +1,87 @@ +From 3a1bcd22e39c26b247ef01da374cceb3d07255d1 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 18 Jun 2015 12:02:50 +0530 +Subject: [PATCH 126/129] quota: allow writes when with ENOENT/ESTALE on active fd + +This is a backport of http://review.gluster.org/#/c/11307/ + +> We may get ENOENT/ESTALE in case of below scenario +> fd = open file.txt +> unlink file.txt +> write on fd +> Here build_ancestry can fail as the file is removed. +> For now ignore ENOENT/ESTALE on active fd with +> writev and fallocate. +> We need to re-visit this code once we understand +> how other file-system behave in this scenario +> +> Below patch fixes the issue in DHT: +> http://review.gluster.org/#/c/11097 +> +> Change-Id: I7be683583b808c280e3ea2ddd036c1558a6d53e5 +> BUG: 1188242 +> Signed-off-by: vmallika + +Change-Id: Idf4696ef7c02e426b076f18a4e65d7ef6b9560ea +BUG: 1224115 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51224 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 32 +++++++++++++++++++++++++++++++- + 1 files changed, 31 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index 569b3c0..ef094f8 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -1578,6 +1578,20 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, + + vector = new_vector; + count = new_count; ++ } else if (op_errno == ENOENT || op_errno == ESTALE) { ++ /* We may get ENOENT/ESTALE in case of below scenario ++ * fd = open file.txt ++ * unlink file.txt ++ * write on fd ++ * Here build_ancestry can fail as the file is removed. ++ * For now ignore ENOENT/ESTALE with writes on active fd ++ * We need to re-visit this code once we understand ++ * how other file-system behave in this scenario ++ */ ++ gf_msg_debug (this->name, 0, "quota enforcer failed " ++ "with ENOENT/ESTALE on %s, cannot check " ++ "quota limits and allowing writes", ++ uuid_utoa (fd->inode->gfid)); + } else { + goto unwind; + } +@@ -4600,7 +4614,23 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, + + if (local->op_ret == -1) { + op_errno = local->op_errno; +- goto unwind; ++ if (op_errno == ENOENT || op_errno == ESTALE) { ++ /* We may get ENOENT/ESTALE in case of below scenario ++ * fd = open file.txt ++ * unlink file.txt ++ * fallocate on fd ++ * Here build_ancestry can fail as the file is removed. ++ * For now ignore ENOENT/ESTALE on active fd ++ * We need to re-visit this code once we understand ++ * how other file-system behave in this scenario ++ */ ++ gf_msg_debug (this->name, 0, "quota enforcer failed " ++ "with ENOENT/ESTALE on %s, cannot check " ++ "quota limits and allowing fallocate", ++ uuid_utoa (fd->inode->gfid)); ++ } else { ++ goto unwind; ++ } + } + + STACK_WIND (frame, quota_fallocate_cbk, +-- +1.7.1 + diff --git a/SOURCES/0127-tier-glusterd-Add-description-for-volume-set-options.patch b/SOURCES/0127-tier-glusterd-Add-description-for-volume-set-options.patch new file mode 100644 index 0000000..638d0a9 --- /dev/null +++ b/SOURCES/0127-tier-glusterd-Add-description-for-volume-set-options.patch @@ -0,0 +1,110 @@ +From 6f86287aac50f0bddb1bd64ee12031289ab08ca6 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Tue, 12 May 2015 14:50:33 +0530 +Subject: [PATCH 127/129] tier/glusterd: Add description for volume set options + +Backport of http://review.gluster.org/#/c/10757/ + +>>Change-Id: Idc2eed77f8d841b6628183867e84601ce605d610 +>>BUG: 1215571 +>>Signed-off-by: Mohammed Rafi KC +>>Signed-off-by: Joseph Fernandes +>>Reviewed-on: http://review.gluster.org/10757 +>>Tested-by: NetBSD Build System +>>Reviewed-by: Dan Lambright +Signed-off-by: Joseph Fernandes + +Change-Id: Id25ff82bc84c4c8c60f568ecf5846930fe86bd21 +BUG: 1229260 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51204 +Reviewed-by: Dan Lambright +Tested-by: Dan Lambright +--- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 38 ++++++++++++++++++---- + 1 files changed, 31 insertions(+), 7 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 83256c4..af26584 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1840,46 +1840,70 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .option = "write-freq-threshold", + .op_version = GD_OP_VERSION_3_7_0, + .flags = OPT_FLAG_CLIENT_OPT, +- .validate_fn = validate_tier ++ .validate_fn = validate_tier, ++ .description = "Defines the number of writes, in a promotion/demotion" ++ " cycle, that would mark a file HOT for promotion. Any" ++ " file that has write hits less than this value will " ++ "be considered as COLD and will be demoted." + }, + { .key = "cluster.read-freq-threshold", + .voltype = "cluster/tier", + .option = "read-freq-threshold", + .op_version = GD_OP_VERSION_3_7_0, + .flags = OPT_FLAG_CLIENT_OPT, +- .validate_fn = validate_tier ++ .validate_fn = validate_tier, ++ .description = "Defines the number of reads, in a promotion/demotion " ++ "cycle, that would mark a file HOT for promotion. Any " ++ "file that has read hits less than this value will be " ++ "considered as COLD and will be demoted." + }, + { .key = "cluster.tier-promote-frequency", + .voltype = "cluster/tier", + .option = "tier-promote-frequency", + .op_version = GD_OP_VERSION_3_7_0, + .flags = OPT_FLAG_CLIENT_OPT, +- .validate_fn = validate_tier ++ .validate_fn = validate_tier, ++ .description = "Defines how often the promotion should be triggered " ++ "i.e. periodicity of promotion cycles. The value is in " ++ "secs." + }, + { .key = "cluster.tier-demote-frequency", + .voltype = "cluster/tier", + .option = "tier-demote-frequency", + .op_version = GD_OP_VERSION_3_7_0, + .flags = OPT_FLAG_CLIENT_OPT, +- .validate_fn = validate_tier ++ .validate_fn = validate_tier, ++ .description = "Defines how often the demotion should be triggered " ++ "i.e. periodicity of demotion cycles. The value is in " ++ "secs." + }, + { .key = "features.ctr-enabled", + .voltype = "features/changetimerecorder", + .value = "off", + .option = "ctr-enabled", +- .op_version = GD_OP_VERSION_3_7_0 ++ .op_version = GD_OP_VERSION_3_7_0, ++ .description = "Enable CTR xlator" + }, + { .key = "features.record-counters", + .voltype = "features/changetimerecorder", + .value = "off", + .option = "record-counters", +- .op_version = GD_OP_VERSION_3_7_0 ++ .op_version = GD_OP_VERSION_3_7_0, ++ .description = "Its a Change Time Recorder Xlator option to enable recording write " ++ "and read heat counters. The default is disabled. " ++ "If enabled, \"cluster.write-freq-threshold\" and " ++ "\"cluster.read-freq-threshold\" defined the number " ++ "of writes (or reads) to a given file are needed " ++ "before triggering migration." + }, + { .key = "features.ctr_link_consistency", + .voltype = "features/changetimerecorder", + .value = "off", + .option = "ctr_link_consistency", +- .op_version = GD_OP_VERSION_3_7_0 ++ .op_version = GD_OP_VERSION_3_7_0, ++ .description = "Enable a crash consistent way of recording hardlink " ++ "updates by Change Time Recorder Xlator. When recording in a crash " ++ "consistent way the data operations will experience more latency." + }, + #endif /* USE_GFDB */ + { .key = "locks.trace", +-- +1.7.1 + diff --git a/SOURCES/0128-cluster-ec-Avoid-parallel-executions-of-the-same-sta.patch b/SOURCES/0128-cluster-ec-Avoid-parallel-executions-of-the-same-sta.patch new file mode 100644 index 0000000..3904938 --- /dev/null +++ b/SOURCES/0128-cluster-ec-Avoid-parallel-executions-of-the-same-sta.patch @@ -0,0 +1,91 @@ +From f83c5ad964c09857faa22dd99fb2537f290a979f Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 23 Jun 2015 06:39:49 +0530 +Subject: [PATCH 128/129] cluster/ec: Avoid parallel executions of the same state machine + + Backport of http://review.gluster.org/11317 + +In very rare circumstances it was possible that a subfop started +by another fop could finish fast enough to cause that two or more +instances of the same state machine be executing at the same time. + +Change-Id: I319924a18bd3f88115e751a66f8f4560435e0e0e +BUG: 1230513 +Signed-off-by: Xavier Hernandez +Reviewed-on: https://code.engineering.redhat.com/gerrit/51301 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/ec/src/ec-common.c | 25 ++++++++++++------------- + 1 files changed, 12 insertions(+), 13 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index be69c57..f69234e 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -250,7 +250,7 @@ int32_t ec_check_complete(ec_fop_data_t * fop, ec_resume_f resume) + + GF_ASSERT(fop->resume == NULL); + +- if (fop->jobs != 0) ++ if (--fop->jobs != 0) + { + ec_trace("WAIT", fop, "resume=%p", resume); + +@@ -1259,11 +1259,6 @@ void ec_lock(ec_fop_data_t *fop) + ec_lock_link_t *timer_link = NULL; + ec_lock_t *lock; + +- /* There is a chance that ec_resume is called on fop even before ec_sleep. +- * Which can result in refs == 0 for fop leading to use after free in this +- * function when it calls ec_sleep so do ec_sleep at start and end of this +- * function.*/ +- ec_sleep (fop); + while (fop->locked < fop->lock_count) { + /* Since there are only up to 2 locks per fop, this xor will change + * the order of the locks if fop->first_lock is 1. */ +@@ -1328,7 +1323,6 @@ void ec_lock(ec_fop_data_t *fop) + timer_link = NULL; + } + } +- ec_resume (fop, 0); + + if (timer_link != NULL) { + ec_resume(timer_link->fop, 0); +@@ -1725,15 +1719,9 @@ void ec_unlock(ec_fop_data_t *fop) + { + int32_t i; + +- /*If fop->lock_count > 1 then there is a chance that by the time +- * ec_unlock_timer_add() is called for the second lock epoll thread could +- * reply inodelk and jobs will be '0' leading to completion of state +- * machine and freeing of fop. So add sleep/resume*/ +- ec_sleep (fop); + for (i = 0; i < fop->lock_count; i++) { + ec_unlock_timer_add(&fop->locks[i]); + } +- ec_resume (fop, 0); + } + + void +@@ -1879,6 +1867,17 @@ void __ec_manager(ec_fop_data_t * fop, int32_t error) + break; + } + ++ /* At each state, fop must not be used anywhere else and there ++ * shouldn't be any pending subfop going on. */ ++ GF_ASSERT(fop->jobs == 0); ++ ++ /* While the manager is running we need to avoid that subfops launched ++ * from it could finish and call ec_resume() before the fop->handler ++ * has completed. This could lead to the same manager being executed ++ * by two threads concurrently. ec_check_complete() will take care of ++ * this reference. */ ++ fop->jobs = 1; ++ + fop->state = fop->handler(fop, fop->state); + + error = ec_check_complete(fop, __ec_manager); +-- +1.7.1 + diff --git a/SOURCES/0129-nfs.c-nfs3.c-port-log-messages-to-a-new-framework.patch b/SOURCES/0129-nfs.c-nfs3.c-port-log-messages-to-a-new-framework.patch new file mode 100644 index 0000000..4074859 --- /dev/null +++ b/SOURCES/0129-nfs.c-nfs3.c-port-log-messages-to-a-new-framework.patch @@ -0,0 +1,2827 @@ +From c4d312023ff5bc927327fc10d826c12bdbf2afeb Mon Sep 17 00:00:00 2001 +From: Hari Gowtham +Date: Wed, 17 Jun 2015 13:28:51 +0530 +Subject: [PATCH 129/129] nfs.c nfs3.c: port log messages to a new framework + +Change-Id: I9ddb90d66d3ad3adb2916c0c949834794ee7bdf3 +BUG: 1231778 +Signed-off-by: Hari Gowtham +Reviewed-on: http://review.gluster.org/11146 +Tested-by: Gluster Build System +Reviewed-by: jiffin tony Thottan +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/50899 +Reviewed-by: Jiffin Thottan +Tested-by: Niels de Vos +--- + xlators/nfs/server/src/nfs-messages.h | 11 +- + xlators/nfs/server/src/nfs.c | 356 ++++++++++++-------- + xlators/nfs/server/src/nfs3.c | 593 ++++++++++++++++++++------------- + 3 files changed, 585 insertions(+), 375 deletions(-) + +diff --git a/xlators/nfs/server/src/nfs-messages.h b/xlators/nfs/server/src/nfs-messages.h +index 9c634b2..77b8564 100644 +--- a/xlators/nfs/server/src/nfs-messages.h ++++ b/xlators/nfs/server/src/nfs-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLFS_NFS_BASE GLFS_MSGID_COMP_NFS +-#define GLFS_NFS_NUM_MESSAGES 201 ++#define GLFS_NFS_NUM_MESSAGES 202 + #define GLFS_MSGID_END (GLFS_NFS_BASE + GLFS_NFS_NUM_MESSAGES + 1) + + /* Messages with message IDs */ +@@ -1654,6 +1654,15 @@ + * + */ + ++#define NFS_MSG_ENABLE_THROTTLE_FAIL (GLFS_NFS_BASE + 202) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + +diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c +index 85af465..8b4bc75 100644 +--- a/xlators/nfs/server/src/nfs.c ++++ b/xlators/nfs/server/src/nfs.c +@@ -37,6 +37,7 @@ + #include "rpc-drc.h" + #include "syscall.h" + #include "rpcsvc.h" ++#include "nfs-messages.h" + + #define OPT_SERVER_AUX_GIDS "nfs.server-aux-gids" + #define OPT_SERVER_GID_CACHE_TIMEOUT "nfs.server.aux-gid-timeout" +@@ -69,8 +70,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, + + ret = nfs_add_initer (&nfs->versions, init, required); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, +- "Failed to add protocol initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add protocol initializer"); + goto err; + } + +@@ -91,8 +92,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, + + /* program not added */ + if (!found) { +- gf_log (GF_NFS, GF_LOG_ERROR, +- "Program: %s NOT found", prog->progname); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_NOT_FOUND, ++ "Program: %s NOT found", prog->progname); + goto err; + } + +@@ -100,12 +101,12 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, + if (nfs->override_portnum) + prog->progport = nfs->override_portnum; + +- gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s", prog->progname); ++ gf_msg_debug (GF_NFS, 0, "Starting program: %s", prog->progname); + + ret = rpcsvc_program_register (nfs->rpcsvc, prog); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Program: %s init failed", +- prog->progname); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_INIT_FAIL, ++ "Program: %s init failed", prog->progname); + goto err; + } + +@@ -115,9 +116,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, + + ret = rpcsvc_program_register_portmap (prog, prog->progport); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, +- "Program %s registration failed", +- prog->progname); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_REG_FAIL, ++ "Program %s registration failed", prog->progname); + goto err; + } + ret = 0; /* All well */ +@@ -249,7 +249,8 @@ nfs_add_initer (struct list_head *list, nfs_version_initer_t init, + + new = GF_CALLOC (1, sizeof (*new), gf_nfs_mt_nfs_initer_list); + if (!new) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Memory allocation failed"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Memory allocation failed"); + return -1; + } + +@@ -301,7 +302,7 @@ nfs_init_versions (struct nfs_state *nfs, xlator_t *this) + if ((!nfs) || (!this)) + return -1; + +- gf_log (GF_NFS, GF_LOG_DEBUG, "Initing protocol versions"); ++ gf_msg_debug (GF_NFS, 0, "Initing protocol versions"); + versions = &nfs->versions; + list_for_each_entry_safe (version, tmp, versions, list) { + if (!version->init) { +@@ -318,23 +319,25 @@ nfs_init_versions (struct nfs_state *nfs, xlator_t *this) + version->program = prog; + if (nfs->override_portnum) + prog->progport = nfs->override_portnum; +- gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s", ++ gf_msg_debug (GF_NFS, 0, "Starting program: %s", + prog->progname); + + ret = rpcsvc_program_register (nfs->rpcsvc, prog); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Program: %s init failed", +- prog->progname); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_PGM_INIT_FAIL, ++ "Program: %s init failed", prog->progname); + goto err; + } + if (nfs->register_portmap) { + ret = rpcsvc_program_register_portmap (prog, + prog->progport); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, +- "%s program %s registration failed", ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_PGM_REG_FAIL, ++ "%s program %s registration failed", + version->required ? +- "Required" : "Optional", ++ "Required" : "Optional", + prog->progname); + + /* fatal error if the program is required */ +@@ -359,30 +362,31 @@ nfs_add_all_initiators (struct nfs_state *nfs) + /* Add the initializers for all versions. */ + ret = nfs_add_initer (&nfs->versions, mnt3svc_init, _gf_true); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " +- "MOUNT3 protocol initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add MOUNT3 protocol initializer"); + goto ret; + } + + ret = nfs_add_initer (&nfs->versions, mnt1svc_init, _gf_true); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " +- "MOUNT1 protocol initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add MOUNT1 protocol initializer"); + goto ret; + } + + ret = nfs_add_initer (&nfs->versions, nfs3svc_init, _gf_true); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " +- "NFS3 protocol initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add NFS3 protocol initializer"); + goto ret; + } + + if (nfs->enable_nlm == _gf_true) { + ret = nfs_add_initer (&nfs->versions, nlm4svc_init, _gf_false); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add protocol" +- " initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add protocol initializer"); + goto ret; + } + } +@@ -390,8 +394,9 @@ nfs_add_all_initiators (struct nfs_state *nfs) + if (nfs->enable_acl == _gf_true) { + ret = nfs_add_initer (&nfs->versions, acl3svc_init, _gf_false); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " +- "ACL protocol initializer"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_PROT_INIT_ADD_FAIL, ++ "Failed to add ACL protocol initializer"); + goto ret; + } + } +@@ -439,7 +444,7 @@ nfs_subvolume_set_started (struct nfs_state *nfs, xlator_t *xl) + { + for (;x < nfs->allsubvols; ++x) { + if (nfs->initedxl[x] == xl) { +- gf_log (GF_NFS, GF_LOG_DEBUG, ++ gf_msg_debug (GF_NFS, 0, + "Volume already started %s", + xl->name); + break; +@@ -448,7 +453,7 @@ nfs_subvolume_set_started (struct nfs_state *nfs, xlator_t *xl) + if (nfs->initedxl[x] == NULL) { + nfs->initedxl[x] = xl; + ++nfs->upsubvols; +- gf_log (GF_NFS, GF_LOG_DEBUG, "Starting up: %s " ++ gf_msg_debug (GF_NFS, 0, "Starting up: %s " + ", vols started till now: %d", xl->name, + nfs->upsubvols); + goto unlock; +@@ -469,13 +474,15 @@ nfs_start_subvol_lookup_cbk (call_frame_t *frame, void *cookie, + struct iatt *postparent) + { + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to lookup root: %s", ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, op_errno, ++ NFS_MSG_LOOKUP_ROOT_FAIL, ++ "Failed to lookup root: %s", + strerror (op_errno)); + goto err; + } + + nfs_subvolume_set_started (this->private, ((xlator_t *)cookie)); +- gf_log (GF_NFS, GF_LOG_TRACE, "Started %s", ((xlator_t *)cookie)->name); ++ gf_msg_trace (GF_NFS, 0, "Started %s", ((xlator_t *)cookie)->name); + err: + return 0; + } +@@ -492,7 +499,7 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) + return -1; + + if (nfs_subvolume_started (nfsx->private, xl)) { +- gf_log (GF_NFS,GF_LOG_TRACE, "Subvolume already started: %s", ++ gf_msg_trace (GF_NFS, 0, "Subvolume already started: %s", + xl->name); + ret = 0; + goto err; +@@ -500,7 +507,9 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) + + ret = nfs_root_loc_fill (xl->itable, &rootloc); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init root loc"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, ++ NFS_MSG_ROOT_LOC_INIT_FAIL, ++ "Failed to init root loc"); + goto err; + } + +@@ -509,8 +518,9 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) + nfs_start_subvol_lookup_cbk, + (void *)nfsx->private); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to lookup root: %s", +- strerror (-ret)); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, -ret, ++ NFS_MSG_LOOKUP_ROOT_FAIL, ++ "Failed to lookup root: %s", strerror (-ret)); + goto err; + } + +@@ -533,12 +543,14 @@ nfs_startup_subvolumes (xlator_t *nfsx) + nfs = nfsx->private; + cl = nfs->subvols; + while (cl) { +- gf_log (GF_NFS, GF_LOG_DEBUG, "Starting subvolume: %s", ++ gf_msg_debug (GF_NFS, 0, "Starting subvolume: %s", + cl->xlator->name); + ret = nfs_startup_subvolume (nfsx, cl->xlator); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to start-up " +- "xlator: %s", cl->xlator->name); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, ++ NFS_MSG_STARTUP_FAIL, ++ "Failed to start-up xlator: %s", ++ cl->xlator->name); + goto err; + } + cl = cl->next; +@@ -562,8 +574,8 @@ nfs_init_subvolume (struct nfs_state *nfs, xlator_t *xl) + lrusize = nfs->memfactor * GF_NFS_INODE_LRU_MULT; + xl->itable = inode_table_new (lrusize, xl); + if (!xl->itable) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to allocate " +- "inode table"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to allocate inode table"); + goto err; + } + ret = 0; +@@ -583,14 +595,15 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl) + + lrusize = nfs->memfactor * GF_NFS_INODE_LRU_MULT; + nfs->subvols = cl; +- gf_log (GF_NFS, GF_LOG_TRACE, "inode table lru: %d", lrusize); ++ gf_msg_trace (GF_NFS, 0, "inode table lru: %d", lrusize); + + while (cl) { +- gf_log (GF_NFS, GF_LOG_DEBUG, "Initing subvolume: %s", ++ gf_msg_debug (GF_NFS, 0, "Initing subvolume: %s", + cl->xlator->name); + ret = nfs_init_subvolume (nfs, cl->xlator); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init " ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, ++ NFS_MSG_XLATOR_INIT_FAIL, "Failed to init " + "xlator: %s", cl->xlator->name); + goto err; + } +@@ -602,12 +615,13 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl) + nfs->initedxl = GF_CALLOC (svcount, sizeof (xlator_t *), + gf_nfs_mt_xlator_t ); + if (!nfs->initedxl) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to allocated inited xls"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to allocated inited xls"); + ret = -1; + goto err; + } + +- gf_log (GF_NFS, GF_LOG_TRACE, "Inited volumes: %d", svcount); ++ gf_msg_trace (GF_NFS, 0, "Inited volumes: %d", svcount); + nfs->allsubvols = svcount; + ret = 0; + err: +@@ -647,7 +661,7 @@ nfs_user_create (nfs_user_t *newnfu, uid_t uid, gid_t gid, gid_t *auxgids, + newnfu->gids[0] = gid; + newnfu->ngrps = 1; + +- gf_log (GF_NFS, GF_LOG_TRACE, "uid: %d, gid %d, gids: %d", uid, gid, ++ gf_msg_trace (GF_NFS, 0, "uid: %d, gid %d, gids: %d", uid, gid, + auxcount); + + if (!auxgids) +@@ -656,7 +670,7 @@ nfs_user_create (nfs_user_t *newnfu, uid_t uid, gid_t gid, gid_t *auxgids, + for (; y < auxcount; ++x,++y) { + newnfu->gids[x] = auxgids[y]; + ++newnfu->ngrps; +- gf_log (GF_NFS, GF_LOG_TRACE, "gid: %d", auxgids[y]); ++ gf_msg_trace (GF_NFS, 0, "gid: %d", auxgids[y]); + } + + return 0; +@@ -707,8 +721,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_nfs_mt_end + 1); + + if (ret != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + +@@ -730,7 +744,7 @@ nfs_init_state (xlator_t *this) + return NULL; + + if (!this->children) { +- gf_log (GF_NFS, GF_LOG_INFO, ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NFS_MAN_DISABLE, + "NFS is manually disabled: Exiting"); + /* Nothing for nfs process to do, exit cleanly */ + kill (getpid (), SIGTERM); +@@ -738,7 +752,8 @@ nfs_init_state (xlator_t *this) + + nfs = GF_CALLOC (1, sizeof (*nfs), gf_nfs_mt_nfs_state); + if (!nfs) { +- gf_log (GF_NFS, GF_LOG_ERROR, "memory allocation failed"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "memory allocation failed"); + return NULL; + } + +@@ -747,14 +762,16 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "nfs.mem-factor", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, ++ NFS_MSG_DICT_GET_FAILED, ++ "Failed to parse dict"); + goto free_rpcsvc; + } + + ret = gf_string2uint (optstr, &nfs->memfactor); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse uint string"); + goto free_rpcsvc; + } + } +@@ -763,8 +780,8 @@ nfs_init_state (xlator_t *this) + /* FIXME: Really saddens me to see this as xlator wide. */ + nfs->foppool = mem_pool_new (struct nfs_fop_local, fopspoolsize); + if (!nfs->foppool) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to allocate fops " +- "local pool"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to allocate fops local pool"); + goto free_rpcsvc; + } + +@@ -773,14 +790,16 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "nfs.dynamic-volumes", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, ++ NFS_MSG_DICT_GET_FAILED, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool string"); + goto free_foppool; + } + +@@ -791,14 +810,16 @@ nfs_init_state (xlator_t *this) + nfs->enable_nlm = _gf_true; + ret = dict_get_str_boolean (this->options, "nfs.nlm", _gf_true); + if (ret == _gf_false) { +- gf_log (GF_NFS, GF_LOG_INFO, "NLM is manually disabled"); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NLM_MAN_DISABLE, ++ "NLM is manually disabled"); + nfs->enable_nlm = _gf_false; + } + + nfs->enable_acl = _gf_true; + ret = dict_get_str_boolean (this->options, "nfs.acl", _gf_true); + if (ret == _gf_false) { +- gf_log (GF_NFS, GF_LOG_INFO, "ACL is manually disabled"); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_ACL_MAN_DISABLE, ++ "ACL is manually disabled"); + nfs->enable_acl = _gf_false; + } + +@@ -807,14 +828,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "nfs.enable-ino32", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool string"); + goto free_foppool; + } + +@@ -826,14 +848,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "nfs.port", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2uint (optstr, &nfs->override_portnum); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse uint string"); + goto free_foppool; + } + } +@@ -845,13 +868,16 @@ nfs_init_state (xlator_t *this) + else + ret = gf_asprintf (&optstr, "%d", GF_NFS3_PORT); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "failed mem-allocation"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "failed mem-allocation"); + goto free_foppool; + } + ret = dict_set_dynstr (this->options, + "transport.socket.listen-port", optstr); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_dynstr error"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_DICT_SET_FAILED, ++ "dict_set_dynstr error"); + goto free_foppool; + } + } +@@ -861,7 +887,8 @@ nfs_init_state (xlator_t *this) + */ + ret = dict_set_str (this->options, "transport-type", "socket"); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_DICT_SET_FAILED, ++ "dict_set_str error"); + goto free_foppool; + } + +@@ -869,13 +896,15 @@ nfs_init_state (xlator_t *this) + if (dict_get(this->options, "nfs.mount-udp")) { + ret = dict_get_str (this->options, "nfs.mount-udp", &optstr); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool " + "string"); + goto free_foppool; + } +@@ -889,14 +918,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "nfs.exports-auth-enable", + &optstr); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool string"); + goto free_foppool; + } + +@@ -909,14 +939,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, + "nfs.auth-refresh-interval-sec", &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2uint (optstr, &nfs->auth_refresh_time_secs); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse uint string"); + goto free_foppool; + } + } +@@ -926,14 +957,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, + "nfs.auth-cache-ttl-sec", &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2uint (optstr, &nfs->auth_cache_ttl_sec); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse uint string"); + goto free_foppool; + } + } +@@ -946,7 +978,8 @@ nfs_init_state (xlator_t *this) + if (dict_get(this->options, "nfs.mount-rmtab")) { + ret = dict_get_str (this->options, "nfs.mount-rmtab", &nfs->rmtab); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + +@@ -965,13 +998,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "rpc-auth.ports.insecure", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool " + "string"); + goto free_foppool; + } +@@ -984,14 +1019,15 @@ nfs_init_state (xlator_t *this) + ret = dict_get_str (this->options, "rpc-auth-allow-insecure", + &optstr); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, ++ "Failed to parse dict"); + goto free_foppool; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " +- "string"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, ++ "Failed to parse bool string"); + goto free_foppool; + } + +@@ -1005,14 +1041,16 @@ nfs_init_state (xlator_t *this) + ret = dict_set_str (this->options, + "rpc-auth-allow-insecure", "on"); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_DICT_SET_FAILED, "dict_set_str error"); + goto free_foppool; + } + dict_del (this->options, "rpc-auth.ports.insecure"); + ret = dict_set_str (this->options, + "rpc-auth.ports.insecure", "on"); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_DICT_SET_FAILED, "dict_set_str error"); + goto free_foppool; + } + } +@@ -1027,21 +1065,24 @@ nfs_init_state (xlator_t *this) + uint32, free_foppool); + + if (gid_cache_init(&nfs->gid_cache, nfs->server_aux_gids_max_age) < 0) { +- gf_log(GF_NFS, GF_LOG_ERROR, "Failed to initialize group cache."); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_INIT_GRP_CACHE_FAIL, ++ "Failed to initialize group cache."); + goto free_foppool; + } + + ret = sys_access (nfs->rpc_statd, X_OK); + if (ret) { +- gf_log (GF_NFS, GF_LOG_WARNING, "%s not enough permissions to" +- " access. Disabling NLM", nfs->rpc_statd); ++ gf_msg (GF_NFS, GF_LOG_WARNING, EPERM, NFS_MSG_NO_PERM, ++ "%s not enough permissions to access. Disabling NLM", ++ nfs->rpc_statd); + nfs->enable_nlm = _gf_false; + } + + ret = sys_stat (nfs->rpc_statd, &stbuf); + if (ret || !S_ISREG (stbuf.st_mode)) { +- gf_log (GF_NFS, GF_LOG_WARNING, "%s not a regular file." +- " Disabling NLM", nfs->rpc_statd); ++ gf_msg (GF_NFS, GF_LOG_WARNING, 0, NFS_MSG_REG_FILE_ERROR, ++ "%s not a regular file. Disabling NLM", nfs->rpc_statd); + nfs->enable_nlm = _gf_false; + } + +@@ -1049,13 +1090,15 @@ nfs_init_state (xlator_t *this) + this->options, fopspoolsize); + if (!nfs->rpcsvc) { + ret = -1; +- gf_log (GF_NFS, GF_LOG_ERROR, "RPC service init failed"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RPC_INIT_FAIL, ++ "RPC service init failed"); + goto free_foppool; + } + + ret = rpcsvc_set_throttle_on (nfs->rpcsvc); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Enabling throttle failed"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_ENABLE_THROTTLE_FAIL, ++ "Enabling throttle failed"); + goto free_foppool; + } + +@@ -1063,7 +1106,7 @@ nfs_init_state (xlator_t *this) + this->options, + RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RPC_CONFIG_FAIL, + "Failed to configure outstanding-rpc-limit"); + goto free_foppool; + } +@@ -1137,7 +1180,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + * 1. SET */ + while (blacklist_keys[keyindx]) { + if (dict_get (options, blacklist_keys[keyindx])) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, ++ NFS_MSG_RECONFIG_FAIL, + "Reconfiguring %s needs NFS restart", + blacklist_keys[keyindx]); + goto out; +@@ -1148,7 +1192,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + /* UNSET for nfs.mem-factor */ + if ((!dict_get (options, "nfs.mem-factor")) && + (nfs->memfactor != GF_NFS_DEFAULT_MEMFACTOR)) { +- gf_log (GF_NFS, GF_LOG_INFO, ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_FAIL, + "Reconfiguring nfs.mem-factor needs NFS restart"); + goto out; + } +@@ -1156,7 +1200,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + /* UNSET for nfs.port */ + if ((!dict_get (options, "nfs.port")) && + (nfs->override_portnum)) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "Reconfiguring nfs.port needs NFS restart"); + goto out; + } +@@ -1166,14 +1210,15 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + if (dict_get (options, OPT_SERVER_RPC_STATD_PIDFILE)) { + ret = dict_get_str (options, "nfs.rpc-statd", &rpc_statd); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read " +- "reconfigured option: nfs.rpc-statd"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read reconfigured option: " ++ "nfs.rpc-statd"); + goto out; + } + } + + if (strcmp(nfs->rpc_statd, rpc_statd) != 0) { +- gf_log (GF_NFS, GF_LOG_INFO, ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_FAIL, + "Reconfiguring nfs.rpc-statd needs NFS restart"); + goto out; + } +@@ -1183,8 +1228,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + if (dict_get (options, "nfs.mount-rmtab")) { + ret = dict_get_str (options, "nfs.mount-rmtab", &rmtab); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read " +- "reconfigured option: nfs.mount-rmtab"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read reconfigured option:" ++ " nfs.mount-rmtab"); + goto out; + } + gf_path_strip_trailing_slashes (rmtab); +@@ -1193,21 +1239,21 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + if (strcmp ("/-", rmtab) == 0) { + GF_FREE (nfs->rmtab); + nfs->rmtab = NULL; +- gf_log (GF_NFS, GF_LOG_INFO, +- "Disabled writing of nfs.mount-rmtab"); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_WRITE_FAIL, ++ "Disabled writing of nfs.mount-rmtab"); + } else if (!nfs->rmtab || strcmp (nfs->rmtab, rmtab) != 0) { + mount_rewrite_rmtab (nfs->mstate, rmtab); +- gf_log (GF_NFS, GF_LOG_INFO, +- "Reconfigured nfs.mount-rmtab path: %s", +- nfs->rmtab); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_PATH, ++ "Reconfigured nfs.mount-rmtab path: %s", nfs->rmtab); + } + + GF_OPTION_RECONF (OPT_SERVER_AUX_GIDS, optbool, + options, bool, out); + if (nfs->server_aux_gids != optbool) { + nfs->server_aux_gids = optbool; +- gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured %s with value %d", +- OPT_SERVER_AUX_GIDS, optbool); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VALUE, ++ "Reconfigured %s with value %d", OPT_SERVER_AUX_GIDS, ++ optbool); + } + + GF_OPTION_RECONF (OPT_SERVER_GID_CACHE_TIMEOUT, optuint32, +@@ -1215,8 +1261,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + if (nfs->server_aux_gids_max_age != optuint32) { + nfs->server_aux_gids_max_age = optuint32; + gid_cache_reconf (&nfs->gid_cache, optuint32); +- gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured %s with value %d", +- OPT_SERVER_GID_CACHE_TIMEOUT, optuint32); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VALUE, ++ "Reconfigured %s with value %d", ++ OPT_SERVER_GID_CACHE_TIMEOUT, optuint32); + } + + /* reconfig nfs.dynamic-volumes */ +@@ -1233,8 +1280,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + } + if (nfs->dynamicvolumes != optbool) { + nfs->dynamicvolumes = optbool; +- gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured nfs.dynamic-volumes" +- " with value %d", optbool); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VOL, ++ "Reconfigured nfs.dynamic-volumes with value %d", ++ optbool); + } + + optbool = _gf_false; +@@ -1242,7 +1290,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + ret = dict_get_str_boolean (options, "nfs.enable-ino32", + _gf_false); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read reconfigured option: " + "nfs.enable-ino32"); + goto out; +@@ -1251,8 +1299,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + } + if (nfs->enable_ino32 != optbool) { + nfs->enable_ino32 = optbool; +- gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured nfs.enable-ino32" +- " with value %d", optbool); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_ENABLE, ++ "Reconfigured nfs.enable-ino32 with value %d", optbool); + } + + /* nfs.nlm is enabled by default */ +@@ -1263,8 +1311,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + optbool = ret; + } + if (nfs->enable_nlm != optbool) { +- gf_log (GF_NFS, GF_LOG_INFO, "NLM is manually %s", +- (optbool ? "enabled":"disabled")); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NLM_INFO, "NLM is" ++ " manually %s", (optbool ? "enabled":"disabled")); + nfs->enable_nlm = optbool; + nfs_reconfigure_nlm4 (this); + } +@@ -1277,8 +1325,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) + optbool = ret; + } + if (nfs->enable_acl != optbool) { +- gf_log (GF_NFS, GF_LOG_INFO, "ACL is manually %s", +- (optbool ? "enabled":"disabled")); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_ACL_INFO, "ACL is " ++ "manually %s", (optbool ? "enabled":"disabled")); + nfs->enable_acl = optbool; + nfs_reconfigure_acl3 (this); + } +@@ -1307,7 +1355,7 @@ reconfigure (xlator_t *this, dict_t *options) + /* Reconfigure nfs options */ + ret = nfs_reconfigure_state(this, options); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "nfs reconfigure state failed"); + return (-1); + } +@@ -1315,7 +1363,7 @@ reconfigure (xlator_t *this, dict_t *options) + /* Reconfigure nfs3 options */ + ret = nfs3_reconfigure_state(this, options); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "nfs3 reconfigure state failed"); + return (-1); + } +@@ -1323,7 +1371,7 @@ reconfigure (xlator_t *this, dict_t *options) + /* Reconfigure mount options */ + ret = mount_reconfigure_state(this, options); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "mount reconfigure state failed"); + return (-1); + } +@@ -1331,7 +1379,7 @@ reconfigure (xlator_t *this, dict_t *options) + /* Reconfigure rpc layer */ + ret = rpcsvc_reconfigure_options (nfs->rpcsvc, options); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "rpcsvc reconfigure options failed"); + return (-1); + } +@@ -1341,7 +1389,7 @@ reconfigure (xlator_t *this, dict_t *options) + options, + RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT); + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "Failed to reconfigure outstanding-rpc-limit"); + return (-1); + } +@@ -1359,7 +1407,7 @@ reconfigure (xlator_t *this, dict_t *options) + /* Reconfigure drc */ + ret = rpcsvc_drc_reconfigure (nfs->rpcsvc, options); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, + "rpcsvc DRC reconfigure failed"); + return (-1); + } +@@ -1395,47 +1443,55 @@ init (xlator_t *this) { + + nfs = nfs_init_state (this); + if (!nfs) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to init nfs option"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_OPT_INIT_FAIL, ++ "Failed to init nfs option"); + return (-1); + } + + ret = nfs_add_all_initiators (nfs); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add initiators"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, ++ "Failed to add initiators"); + return (-1); + } + + ret = nfs_init_subvolumes (nfs, this->children); + if (ret) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init NFS exports"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, ++ "Failed to init NFS exports"); + return (-1); + } + + ret = mount_init_state (this); + if (ret) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init Mount state"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, ++ "Failed to init Mount state"); + return (-1); + } + + ret = nlm4_init_state (this); + if (ret) { +- gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init NLM state"); ++ gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, ++ "Failed to init NLM state"); + return (-1); + } + + ret = nfs_init_versions (nfs, this); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to initialize protocols"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, ++ "Failed to initialize protocols"); + return (-1); + } + + ret = nfs_drc_init (this); + if (ret) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to initialize DRC"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, ++ "Failed to initialize DRC"); + return (-1); + } + +- gf_log (GF_NFS, GF_LOG_INFO, "NFS service started"); ++ gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_STARTED, ++ "NFS service started"); + return (0); /* SUCCESS */ + } + +@@ -1448,7 +1504,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + + subvol = (xlator_t *)data; + +- gf_log (GF_NFS, GF_LOG_TRACE, "Notification received: %d", ++ gf_msg_trace (GF_NFS, 0, "Notification received: %d", + event); + + switch (event) { +@@ -1478,7 +1534,7 @@ fini (xlator_t *this) + + mnt3svc_deinit (this); + nfs = (struct nfs_state *)this->private; +- gf_log (GF_NFS, GF_LOG_DEBUG, "NFS service going down"); ++ gf_msg_debug (GF_NFS, 0, "NFS service going down"); + nfs_deinit_versions (&nfs->versions, this); + return 0; + } +@@ -1532,7 +1588,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Could not get volname"); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, NFS_MSG_VOL_NOT_FOUND, ++ "Could not get volname"); + goto out; + } + +@@ -1544,7 +1601,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) + snprintf (key, sizeof (key), "client%d.hostname", count); + ret = dict_set_str (dict, key, mentry->hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ NFS_MSG_WRITE_FAIL, + "Error writing hostname to dict"); + goto out; + } +@@ -1556,7 +1614,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) + snprintf (key, sizeof (key), "client%d.bytesread", count); + ret = dict_set_uint64 (dict, key, 0); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ NFS_MSG_WRITE_FAIL, + "Error writing bytes read to dict"); + goto out; + } +@@ -1565,7 +1624,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) + snprintf (key, sizeof (key), "client%d.byteswrite", count); + ret = dict_set_uint64 (dict, key, 0); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ NFS_MSG_WRITE_FAIL, + "Error writing bytes write to dict"); + goto out; + } +@@ -1575,11 +1635,11 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) + + ret = dict_set_int32 (dict, "clientcount", count); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, NFS_MSG_WRITE_FAIL, + "Error writing client count to dict"); + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -1594,13 +1654,13 @@ nfs_priv (xlator_t *this) + /* DRC needs the global drc structure, xl is of no use to it. */ + ret = rpcsvc_drc_priv (((struct nfs_state *)(this->private))->rpcsvc->drc); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Statedump of DRC failed"); ++ gf_msg_debug (this->name, 0, "Statedump of DRC failed"); + goto out; + } + + ret = nlm_priv (this); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Statedump of NLM failed"); ++ gf_msg_debug (this->name, 0, "Statedump of NLM failed"); + goto out; + } + out: +diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c +index 4e03277..d66ac5d 100644 +--- a/xlators/nfs/server/src/nfs3.c ++++ b/xlators/nfs/server/src/nfs3.c +@@ -32,6 +32,7 @@ + #include "nfs.h" + #include "xdr-rpc.h" + #include "xdr-generic.h" ++#include "nfs-messages.h" + + #include + #include +@@ -42,8 +43,10 @@ + do { \ + if ((str)) { \ + if (strlen ((str)) > (len)) { \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "strlen "\ +- "too long"); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, \ ++ ENAMETOOLONG, \ ++ NFS_MSG_STR_TOO_LONG, \ ++ "strlen too long"); \ + status = NFS3ERR_NAMETOOLONG; \ + retval = -ENAMETOOLONG; \ + goto label; \ +@@ -54,8 +57,9 @@ + #define nfs3_validate_nfs3_state(request, state, status, label, retval) \ + do { \ + state = rpcsvc_request_program_private (request); \ +- if (!state) { \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state " \ ++ if (!state) { \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EFAULT, \ ++ NFS_MSG_STATE_MISSING, "NFSv3 state " \ + "missing from RPC request"); \ + status = NFS3ERR_SERVERFAULT; \ + ret = -EFAULT; \ +@@ -80,7 +84,8 @@ __nfs3_get_export_by_index (struct nfs3_state *nfs3, uuid_t exportid) + } + + exp = NULL; +- gf_log (GF_NFS, GF_LOG_ERROR, "searchindex=%d not found", searchindex); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_INDEX_NOT_FOUND, ++ "searchindex=%d not found", searchindex); + found: + return exp; + } +@@ -130,7 +135,8 @@ nfs3_export_access (struct nfs3_state *nfs3, uuid_t exportid) + exp = __nfs3_get_export_by_exportid (nfs3, exportid); + + if (!exp) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to get export by ID"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_EXPORT_ID_FAIL, ++ "Failed to get export by ID"); + goto err; + } + +@@ -143,7 +149,9 @@ err: + #define nfs3_check_rw_volaccess(nfs3state, exid, status, label) \ + do { \ + if (nfs3_export_access (nfs3state,exid)!=GF_NFS3_VOLACCESS_RW){\ +- gf_log (GF_NFS3, GF_LOG_ERROR, "No read-write access");\ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EACCES, \ ++ NFS_MSG_NO_RW_ACCESS, \ ++ "No read-write access"); \ + status = NFS3ERR_ROFS; \ + goto label; \ + } \ +@@ -214,8 +222,8 @@ out: + rpc_transport_t *trans = NULL; \ + volume = nfs3_fh_to_xlator ((nfs3state), handle); \ + if (!volume) { \ +- gf_uuid_unparse (handle->exportid, exportid); \ +- gf_uuid_unparse (handle->gfid, gfid); \ ++ gf_uuid_unparse (handle->exportid, exportid); \ ++ gf_uuid_unparse (handle->gfid, gfid); \ + trans = rpcsvc_request_transport (req); \ + GF_LOG_OCCASIONALLY (nfs3state->occ_logger, \ + GF_NFS3, GF_LOG_ERROR, "Failed to map " \ +@@ -230,7 +238,7 @@ out: + status = NFS3ERR_STALE; \ + goto label; \ + } else { \ +- gf_log (GF_NFS3, GF_LOG_TRACE, "FH to Volume:" \ ++ gf_msg_trace (GF_NFS3, 0, "FH to Volume:" \ + "%s", volume->name); \ + rpcsvc_request_set_private (req, volume); \ + } \ +@@ -240,7 +248,9 @@ out: + #define nfs3_validate_gluster_fh(handle, status, errlabel) \ + do { \ + if (!nfs3_fh_validate (handle)) { \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad Handle"); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_BAD_HANDLE, \ ++ "Bad Handle"); \ + status = NFS3ERR_BADHANDLE; \ + goto errlabel; \ + } \ +@@ -261,13 +271,14 @@ out: + trans = rpcsvc_request_transport (cst->req); \ + xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ + &cst->resolvefh); \ +- gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ ++ gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ + sprintf (buf, "(%s) %s : %s", \ + trans->peerinfo.identifier, \ + xlatorp ? xlatorp->name : "ERR", gfid); \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "Unable to resolve FH"\ +- ": %s", buf); \ +- nfstat = nfs3_errno_to_nfsstat3 (-auth_errno);\ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_RESOLVE_FH_FAIL, "Unable to " \ ++ "resolve FH: %s", buf); \ ++ nfstat = nfs3_errno_to_nfsstat3 (-auth_errno); \ + goto erlabl; \ + } \ + } while (0) \ +@@ -281,13 +292,15 @@ out: + trans = rpcsvc_request_transport (cst->req); \ + xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ + &cst->resolvefh); \ +- gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ +- snprintf (buf, sizeof (buf), "(%s) %s : %s", \ ++ gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ ++ snprintf (buf, sizeof (buf), "(%s) %s : %s", \ + trans->peerinfo.identifier, \ + xlatorp ? xlatorp->name : "ERR", \ +- gfid ); \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "%s: %s", \ +- strerror(cst->resolve_errno), buf); \ ++ gfid); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_RESOLVE_STAT, \ ++ "%s: %s", strerror(cst->resolve_errno), \ ++ buf); \ + nfstat = nfs3_errno_to_nfsstat3 (cst->resolve_errno);\ + goto erlabl; \ + } \ +@@ -303,12 +316,13 @@ out: + trans = rpcsvc_request_transport (cst->req); \ + xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ + &cst->resolvefh); \ +- gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ +- snprintf (buf, sizeof (buf), "(%s) %s : %s", \ +- trans->peerinfo.identifier, \ ++ gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ ++ snprintf (buf, sizeof (buf), "(%s) %s : %s", \ ++ trans->peerinfo.identifier, \ + xlatorp ? xlatorp->name : "ERR", \ +- gfid); \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "%s: %s", \ ++ gfid); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_RESOLVE_STAT, "%s: %s", \ + strerror(cst->resolve_errno), buf); \ + nfstat = nfs3_errno_to_nfsstat3 (cs->resolve_errno);\ + goto erlabl; \ +@@ -349,7 +363,7 @@ out: + goto erl; \ + } \ + \ +- gf_uuid_copy ((fhd)->gfid, zero); \ ++ gf_uuid_copy ((fhd)->gfid, zero); \ + (fhd)->gfid[15] = 1; \ + (enam) = NULL; \ + if ((gf_nfs_dvm_off (nfs_state (nfs3st->nfsx)))) \ +@@ -366,8 +380,10 @@ out: + #define nfs3_volume_started_check(nf3stt, vlm, rtval, erlbl) \ + do { \ + if ((!nfs_subvolume_started (nfs_state (nf3stt->nfsx), vlm))){\ +- gf_log (GF_NFS3, GF_LOG_ERROR, "Volume is disabled: %s",\ +- vlm->name); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_VOL_DISABLE, \ ++ "Volume is disabled: %s", \ ++ vlm->name); \ + rtval = RPCSVC_ACTOR_IGNORE; \ + goto erlbl; \ + } \ +@@ -442,7 +458,8 @@ nfs3_call_state_init (struct nfs3_state *s, rpcsvc_request_t *req, xlator_t *v) + + cs = (nfs3_call_state_t *) mem_get (s->localpool); + if (!cs) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "out of memory"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "out of memory"); + return NULL; + } + +@@ -465,7 +482,7 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs) + return; + + if (cs->fd) { +- gf_log (GF_NFS3, GF_LOG_TRACE, "fd 0x%lx ref: %d", ++ gf_msg_trace (GF_NFS3, 0, "fd 0x%lx ref: %d", + (long)cs->fd, cs->fd->refcount); + fd_unref (cs->fd); + } +@@ -495,8 +512,9 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs) + do { \ + calls = nfs3_call_state_init ((nfs3state), (rq), (vl)); \ + if (!calls) { \ +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to " \ +- "init call state"); \ ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ ++ NFS_MSG_INIT_CALL_STAT_FAIL, "Failed to"\ ++ " init call state"); \ + opstat = NFS3ERR_SERVERFAULT; \ + goto errlabel; \ + } \ +@@ -514,8 +532,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, + + nfs3 = (struct nfs3_state *)rpcsvc_request_program_private (req); + if (!nfs3) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state not found in RPC" +- " request"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_STATE_MISSING, ++ "NFSv3 state not found in RPC request"); + goto ret; + } + +@@ -526,7 +544,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, + can have 'xdr_sizeof' */ + iob = iobuf_get (nfs3->iobpool); + if (!iob) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to get iobuf"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to get iobuf"); + goto ret; + } + +@@ -539,7 +558,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, + */ + retlen = sfunc (*outmsg, arg); + if (retlen == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to encode message"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ENCODE_FAIL, ++ "Failed to encode message"); + goto ret; + } + +@@ -569,26 +589,30 @@ nfs3svc_submit_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc) + + iob = nfs3_serialize_reply (req, arg, sfunc, &outmsg); + if (!iob) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to serialize reply"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SERIALIZE_REPLY_FAIL, ++ "Failed to serialize reply"); + goto ret; + } + + iobref = iobref_new (); + if (!iobref) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new()"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "failed on iobref_new()"); + goto ret; + } + + ret = iobref_add (iobref, iob); + if (ret) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to add iob to iobref"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to add iob to iobref"); + goto ret; + } + + /* Then, submit the message for transmission. */ + ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBMIT_REPLY_FAIL, ++ "Reply submission failed"); + goto ret; + } + +@@ -621,13 +645,15 @@ nfs3svc_submit_vector_reply (rpcsvc_request_t *req, void *arg, + + iob = nfs3_serialize_reply (req, arg, sfunc, &outmsg); + if (!iob) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to serialize reply"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SERIALIZE_REPLY_FAIL, ++ "Failed to serialize reply"); + goto ret; + } + if (iobref == NULL) { + iobref = iobref_new (); + if (!iobref) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, ++ NFS_MSG_NO_MEMORY, "failed on iobref_new"); + goto ret; + } + new_iobref = 1; +@@ -635,14 +661,16 @@ nfs3svc_submit_vector_reply (rpcsvc_request_t *req, void *arg, + + ret = iobref_add (iobref, iob); + if (ret) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to add iob to iobref"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Failed to add iob to iobref"); + goto ret; + } + + /* Then, submit the message for transmission. */ + ret = rpcsvc_submit_message (req, &outmsg, 1, payload, vcount, iobref); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBMIT_REPLY_FAIL, ++ "Reply submission failed"); + goto ret; + } + +@@ -727,9 +755,10 @@ nfs3svc_getattr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + */ + + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_GETATTR_LOOKUP_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + status = nfs3_cbk_errno_status (op_ret, op_errno); + } + else { +@@ -757,9 +786,10 @@ nfs3svc_getattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cs = frame->local; + + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_GETATTR_STAT_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + status = nfs3_cbk_errno_status (op_ret, op_errno); + } + +@@ -833,8 +863,9 @@ nfs3_getattr_resume (void *carg) + + check_err: + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Stat fop failed: %s: %s", +- cs->oploc.path, strerror (-ret)); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_STAT_FOP_FAIL, ++ "Stat fop failed: %s: %s", cs->oploc.path, ++ strerror (-ret)); + stat = nfs3_errno_to_nfsstat3 (-ret); + } + +@@ -899,14 +930,16 @@ nfs3svc_getattr (rpcsvc_request_t *req) + + nfs3_prep_getattr3args (&args, &fh); + if (xdr_to_getattr3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_getattr (req, &fh); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "GETATTR procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_GETATTR_FAIL, ++ "GETATTR procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -942,7 +975,7 @@ nfs3svc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_TRUNCATE_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -982,7 +1015,7 @@ nfs3svc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_SETATTR_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -1038,15 +1071,17 @@ nfs3svc_setattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_SETATTR_STAT_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); + goto nfs3err; + } + + if (buf->ia_ctime != cs->timestamp.seconds) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Timestamps not in sync"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_TIMESTAMP_NO_SYNC, ++ "Timestamps not in sync"); + stat = NFS3ERR_NOT_SYNC; + goto nfs3err; + } +@@ -1130,18 +1165,19 @@ nfs3_setattr (rpcsvc_request_t *req, struct nfs3_fh *fh, sattr3 *sattr, + cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf, + NULL); + if (guard->check) { +- gf_log (GF_NFS3, GF_LOG_TRACE, "Guard check required"); ++ gf_msg_trace (GF_NFS3, 0, "Guard check required"); + cs->timestamp = guard->sattrguard3_u.obj_ctime; + cs->sattrguardcheck = 1; + } else { +- gf_log (GF_NFS3, GF_LOG_TRACE, "Guard check not required"); ++ gf_msg_trace (GF_NFS3, 0, "Guard check not required"); + cs->sattrguardcheck = 0; + } + + if (!cs->setattr_valid) { + ret = -EINVAL; /* Force a reply */ + stat = NFS3_OK; +- gf_log (GF_NFS3, GF_LOG_ERROR, "cs->setattr_valid is invalid"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_SETATTR_INVALID, ++ "cs->setattr_valid is invalid"); + goto nfs3err; + } + +@@ -1177,14 +1213,17 @@ nfs3svc_setattr (rpcsvc_request_t *req) + + nfs3_prep_setattr3args (&args, &fh); + if (xdr_to_setattr3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, ++ NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_setattr (req, &fh, &args.new_attributes, &args.guard); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "SETATTR procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_SETATTR_FAIL, ++ "SETATTR procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -1219,7 +1258,7 @@ nfs3_fresh_lookup (nfs3_call_state_t *cs) + char *oldresolventry = NULL; + + GF_VALIDATE_OR_GOTO (GF_NFS3, cs, err); +- gf_log (GF_NFS3, GF_LOG_DEBUG, "inode needs fresh lookup"); ++ gf_msg_debug (GF_NFS3, 0, "inode needs fresh lookup"); + inode_unlink (cs->resolvedloc.inode, cs->resolvedloc.parent, + cs->resolventry); + nfs_loc_wipe (&cs->resolvedloc); +@@ -1251,10 +1290,16 @@ nfs3svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, +- (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_WARNING), +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ if (op_errno == ENOENT) { ++ gf_msg_trace (GF_NFS, 0, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), ++ cs->resolvedloc.path, strerror (op_errno)); ++ } else { ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_SVC_LOOKUP, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), ++ cs->resolvedloc.path, strerror (op_errno)); ++ } + status = nfs3_cbk_errno_status (op_ret, op_errno); + goto xmit_res; + } +@@ -1297,9 +1342,10 @@ nfs3svc_lookup_parentdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_SVC_PAR_LOOKUP, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + status = nfs3_cbk_errno_status (op_ret, op_errno); + goto xmit_res; + } +@@ -1343,8 +1389,8 @@ nfs3_lookup_parentdir_resume (void *carg) + inode_t *parent = NULL; + + if (!carg) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," +- " carg value NULL"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Invalid argument, carg value NULL"); + return EINVAL; + } + +@@ -1382,7 +1428,9 @@ nfs3_lookup_parentdir_resume (void *carg) + NFS_RESOLVE_CREATE); + + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "nfs_inode_loc_fill" ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_INODE_LOC_FILL_ERROR, ++ "nfs_inode_loc_fill" + " error"); + goto errtostat; + } +@@ -1419,8 +1467,8 @@ nfs3_lookup_resume (void *carg) + struct nfs3_fh newfh = {{0},}; + + if (!carg) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," +- " carg value NULL"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Invalid argument, carg value NULL"); + return EINVAL; + } + +@@ -1484,7 +1532,9 @@ nfs3_lookup (rpcsvc_request_t *req, struct nfs3_fh *fh, int fhlen, char *name) + nfs3_lookup_resume); + + if (ret < 0) { +- gf_log (GF_NFS, GF_LOG_ERROR, "failed to start hard reslove"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, ++ NFS_MSG_HARD_RESOLVE_FAIL, ++ "failed to start hard reslove"); + stat = nfs3_errno_to_nfsstat3 (-ret); + } + +@@ -1517,14 +1567,17 @@ nfs3svc_lookup (rpcsvc_request_t *req) + + nfs3_prep_lookup3args (&args, &fh, name); + if (xdr_to_lookup3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_lookup (req, &fh, args.what.dir.data.data_len, name); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "LOOKUP procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_LOOKUP_PROC_FAIL, ++ "LOOKUP procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -1557,7 +1610,7 @@ nfs3svc_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cs = frame->local; + + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_ACCESS_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + status = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -1580,8 +1633,8 @@ nfs3_access_resume (void *carg) + nfs3_call_state_t *cs = NULL; + + if (!carg) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," +- " carg value NULL"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Invalid argument, carg value NULL"); + return EINVAL; + } + +@@ -1667,14 +1720,17 @@ nfs3svc_access (rpcsvc_request_t *req) + + nfs3_prep_access3args (&args, &fh); + if (xdr_to_access3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_access (req, &fh, args.access); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "ACCESS procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_ACCESS_PROC_FAIL, ++ "ACCESS procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -1710,7 +1766,7 @@ nfs3svc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READLINK_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -1771,7 +1827,8 @@ nfs3_readlink (rpcsvc_request_t *req, struct nfs3_fh *fh) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -1814,14 +1871,17 @@ nfs3svc_readlink (rpcsvc_request_t *req) + + nfs3_prep_readlink3args (&args, &fh); + if (xdr_to_readlink3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_readlink (req, &fh); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "READLINK procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_READLINK_PROC_FAIL, ++ "READLINK procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -1878,7 +1938,7 @@ nfs3svc_read_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READ_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -1946,7 +2006,8 @@ nfs3_read_resume (void *carg) + nfs3_check_fh_resolve_status (cs, stat, nfs3err); + fd = fd_anonymous (cs->resolvedloc.inode); + if (!fd) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, ++ "Failed to create anonymous fd"); + goto nfs3err; + } + +@@ -1975,7 +2036,8 @@ nfs3_read (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -2018,14 +2080,17 @@ nfs3svc_read (rpcsvc_request_t *req) + + nfs3_prep_read3args (&args, &fh); + if (xdr_to_read3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_read (req, &fh, args.offset, args.count); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "READ procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_READ_FAIL, ++ "READ procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -2065,7 +2130,7 @@ nfs3svc_write_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + nfs3 = rpcsvc_request_program_private (cs->req); + + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_FSYNC_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -2125,7 +2190,7 @@ nfs3svc_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cs = frame->local; + nfs3 = rpcsvc_request_program_private (cs->req); + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_WRITE_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -2194,7 +2259,8 @@ nfs3_write_resume (void *carg) + nfs3_check_fh_resolve_status (cs, stat, nfs3err); + fd = fd_anonymous (cs->resolvedloc.inode); + if (!fd) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, ++ "Failed to create anonymous fd"); + goto nfs3err; + } + +@@ -2245,7 +2311,8 @@ nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh) || (!payload.iov_base)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -2309,7 +2376,8 @@ nfs3svc_write_vecsizer (int state, ssize_t *readsize, char *base_addr, + ret = 0; + *readsize = 0; + } else +- gf_log ("nfs", GF_LOG_ERROR, "state wrong"); ++ gf_msg ("nfs", GF_LOG_ERROR, 0, NFS_MSG_STATE_WRONG, ++ "state wrong"); + + return ret; + } +@@ -2326,7 +2394,8 @@ nfs3svc_write (rpcsvc_request_t *req) + return ret; + nfs3_prep_write3args (&args, &fh); + if (xdr_to_write3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } +@@ -2340,7 +2409,9 @@ nfs3svc_write (rpcsvc_request_t *req) + ret = nfs3_write (req, &fh, args.offset, args.count, args.stable, + req->msg[1], rpcsvc_request_iobref_ref (req)); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "WRITE procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_WRITE_FAIL, ++ "WRITE procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -2377,9 +2448,10 @@ nfs3svc_create_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_CREATE_SETATTR_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); + goto nfs3err; + } +@@ -2410,7 +2482,7 @@ nfs3svc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_CREATE_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -2514,9 +2586,10 @@ nfs3svc_create_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cs = frame->local; + nfs_request_user_init (&nfu, cs->req); + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_CREATE_STAT_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + ret = -op_errno; + stat = nfs3_cbk_errno_status (op_ret, op_errno); + goto nfs3err; +@@ -2524,13 +2597,13 @@ nfs3svc_create_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if ((cs->stbuf.ia_mtime == buf->ia_mtime) && + (cs->stbuf.ia_atime == buf->ia_atime)) { +- gf_log (GF_NFS3, GF_LOG_DEBUG, ++ gf_msg_debug (GF_NFS3, 0, + "Create req retransmitted verf %x %x", + cs->stbuf.ia_mtime, cs->stbuf.ia_atime); + stat = NFS3_OK; + nfs3_fh_build_child_fh (&cs->parent, buf, &cs->fh); + } else { +- gf_log (GF_NFS3, GF_LOG_DEBUG, ++ gf_msg_debug (GF_NFS3, 0, + "File already exist new_verf %x %x" + "old_verf %x %x", cs->stbuf.ia_mtime, + cs->stbuf.ia_atime, +@@ -2684,7 +2757,8 @@ nfs3svc_create (rpcsvc_request_t *req) + + nfs3_prep_create3args (&args, &dirfh, name); + if (xdr_to_create3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } +@@ -2695,7 +2769,8 @@ nfs3svc_create (rpcsvc_request_t *req) + ret = nfs3_create (req, &dirfh, name, args.how.mode, + &args.how.createhow3_u.obj_attributes, cverf); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "CREATE procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_CREATE_FAIL, ++ "CREATE procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -2731,9 +2806,10 @@ nfs3svc_mkdir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_MKDIR_SETATTR_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); + goto nfs3err; + } +@@ -2763,7 +2839,7 @@ nfs3svc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKDIR_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -2849,7 +2925,8 @@ nfs3_mkdir (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!dirfh) || (!name) || (!sattr)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -2895,14 +2972,16 @@ nfs3svc_mkdir (rpcsvc_request_t *req) + return ret; + nfs3_prep_mkdir3args (&args, &dirfh, name); + if (xdr_to_mkdir3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_mkdir (req, &dirfh, name, &args.attributes); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "MKDIR procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_DIR_OP_FAIL, ++ "MKDIR procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -2941,7 +3020,7 @@ nfs3svc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_SYMLINK_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -3003,7 +3082,8 @@ nfs3_symlink (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!dirfh) || (!name) || (!target) || (!sattr)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -3058,7 +3138,8 @@ nfs3svc_symlink (rpcsvc_request_t *req) + return ret; + nfs3_prep_symlink3args (&args, &dirfh, name, target); + if (xdr_to_symlink3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } +@@ -3066,7 +3147,8 @@ nfs3svc_symlink (rpcsvc_request_t *req) + ret = nfs3_symlink (req, &dirfh, name, target, + &args.symlink.symlink_attributes); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "SYMLINK procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EXDEV, NFS_MSG_SYMLINK_FAIL, ++ "SYMLINK procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -3103,7 +3185,7 @@ nfs3svc_mknod_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKNOD_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -3135,7 +3217,7 @@ nfs3svc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKNOD_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -3282,7 +3364,8 @@ nfs3_mknod (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name, + sattr3 *sattr = NULL; + + if ((!req) || (!fh) || (!name) || (!nodedata)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -3351,14 +3434,16 @@ nfs3svc_mknod (rpcsvc_request_t *req) + return ret; + nfs3_prep_mknod3args (&args, &fh, name); + if (xdr_to_mknod3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_mknod (req, &fh, name, &args.what); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "MKNOD procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_MKNOD_FAIL, ++ "MKNOD procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -3393,7 +3478,7 @@ nfs3svc_remove_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_REMOVE_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -3471,7 +3556,8 @@ nfs3_remove (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh) || (!name)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -3517,14 +3603,16 @@ nfs3svc_remove (rpcsvc_request_t *req) + return ret; + nfs3_prep_remove3args (&args, &fh, name); + if (xdr_to_remove3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_remove (req, &fh, name); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "REMOVE procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_REMOVE_FAIL, ++ "REMOVE procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -3559,7 +3647,7 @@ nfs3svc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_RMDIR_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -3617,7 +3705,8 @@ nfs3_rmdir (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh) || (!name)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -3663,14 +3752,16 @@ nfs3svc_rmdir (rpcsvc_request_t *req) + return ret; + nfs3_prep_rmdir3args (&args, &fh, name); + if (xdr_to_rmdir3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_rmdir (req, &fh, name); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "RMDIR procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_DIR_OP_FAIL, ++ "RMDIR procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -3713,7 +3804,7 @@ nfs3svc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_RENAME_CBK, + "%x: rename %s -> %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->oploc.path, + cs->resolvedloc.path, strerror (op_errno)); +@@ -3812,7 +3903,8 @@ nfs3_rename (rpcsvc_request_t *req, struct nfs3_fh *olddirfh, char *oldname, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!olddirfh) || (!oldname) || (!newdirfh) || (!newname)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -3874,14 +3966,16 @@ nfs3svc_rename (rpcsvc_request_t *req) + return ret; + nfs3_prep_rename3args (&args, &olddirfh, oldname, &newdirfh, newname); + if (xdr_to_rename3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_rename (req, &olddirfh, oldname, &newdirfh, newname); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "RENAME procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_RENAME_FAIL, ++ "RENAME procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -3918,7 +4012,7 @@ nfs3svc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_LINK_CBK, + "%x: link %s <- %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->oploc.path, + cs->resolvedloc.path, strerror (op_errno)); +@@ -4009,7 +4103,8 @@ nfs3_link (rpcsvc_request_t *req, struct nfs3_fh *targetfh, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!targetfh) || (!dirfh) || (!newname)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -4063,14 +4158,16 @@ nfs3svc_link (rpcsvc_request_t *req) + return ret; + nfs3_prep_link3args (&args, &targetfh, &dirfh, newpath); + if (xdr_to_link3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_link (req, &targetfh, &dirfh, newpath); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "LINK procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EXDEV, NFS_MSG_LINK_FAIL, ++ "LINK procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4129,7 +4226,8 @@ nfs3svc_readdir_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_READDIR_FSTAT_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -4140,7 +4238,7 @@ nfs3svc_readdir_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + * readdir'ing. + */ + if (cs->operrno == ENOENT) { +- gf_log (GF_NFS3, GF_LOG_TRACE, "Reached end-of-directory"); ++ gf_msg_trace (GF_NFS3, 0, "Reached end-of-directory"); + is_eof = 1; + } + +@@ -4188,7 +4286,7 @@ nfs3svc_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READDIR_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -4320,7 +4418,8 @@ nfs3_readdir_open_resume (void *carg) + nfs3_check_fh_resolve_status (cs, stat, nfs3err); + cs->fd = fd_anonymous (cs->resolvedloc.inode); + if (!cs->fd) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Faile to create anonymous fd"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, ++ "Fail to create anonymous fd"); + goto nfs3err; + } + +@@ -4336,7 +4435,9 @@ nfs3_readdir_open_resume (void *carg) + ret = nfs_opendir (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, + nfs3svc_readdir_opendir_cbk, cs); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "auto-opendir failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_DIR_OP_FAIL, ++ "auto-opendir failed"); + } + } + +@@ -4376,7 +4477,8 @@ nfs3_readdir (rpcsvc_request_t *req, struct nfs3_fh *fh, cookie3 cookie, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -4435,7 +4537,8 @@ nfs3svc_readdir (rpcsvc_request_t *req) + return ret; + nfs3_prep_readdir3args (&ra, &fh); + if (xdr_to_readdir3args (req->msg[0], &ra) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } +@@ -4444,7 +4547,9 @@ nfs3svc_readdir (rpcsvc_request_t *req) + + ret = nfs3_readdir (req, &fh, ra.cookie, verf, ra.count, 0); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "READDIR procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_READDIR_FAIL, ++ "READDIR procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4467,7 +4572,8 @@ nfs3svc_readdirp (rpcsvc_request_t *req) + return ret; + nfs3_prep_readdirp3args (&ra, &fh); + if (xdr_to_readdirp3args (req->msg[0], &ra) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } +@@ -4477,7 +4583,9 @@ nfs3svc_readdirp (rpcsvc_request_t *req) + ret = nfs3_readdir (req, &fh, ra.cookie, cverf, ra.dircount, + ra.maxcount); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "READDIRP procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_READDIRP_FAIL, ++ "READDIRP procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4512,9 +4620,10 @@ nfs3_fsstat_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_FSSTAT_STAT_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); + } else + stat = NFS3_OK; +@@ -4539,9 +4648,10 @@ nfs3_fsstat_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, +- "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), +- cs->resolvedloc.path, strerror (op_errno)); ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, ++ NFS_MSG_FSSTAT_STATFS_CBK, "%x: %s => -1 (%s)", ++ rpcsvc_request_xid (cs->req), cs->resolvedloc.path, ++ strerror (op_errno)); + ret = -op_errno; + stat = nfs3_cbk_errno_status (op_ret, op_errno); + goto err; +@@ -4612,7 +4722,8 @@ nfs3_fsstat (rpcsvc_request_t *req, struct nfs3_fh *fh) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -4654,14 +4765,16 @@ nfs3svc_fsstat (rpcsvc_request_t *req) + return ret; + nfs3_prep_fsstat3args (&args, &fh); + if (xdr_to_fsstat3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_fsstat (req, &fh); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "FSTAT procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FSTAT_FAIL, ++ "FSTAT procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4699,7 +4812,7 @@ nfs3svc_fsinfo_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cs = frame->local; + + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_FSINFO_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + status = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -4759,7 +4872,8 @@ nfs3_fsinfo (rpcsvc_request_t *req, struct nfs3_fh *fh) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -4799,14 +4913,16 @@ nfs3svc_fsinfo (rpcsvc_request_t *req) + + nfs3_prep_fsinfo3args (&args, &root); + if (xdr_to_fsinfo3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding arguments"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_fsinfo (req, &root); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "FSINFO procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FSINFO_FAIL, ++ "FSINFO procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4841,7 +4957,7 @@ nfs3svc_pathconf_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_PATHCONF_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -4901,7 +5017,8 @@ nfs3_pathconf (rpcsvc_request_t *req, struct nfs3_fh *fh) + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -4943,14 +5060,17 @@ nfs3svc_pathconf (rpcsvc_request_t *req) + return ret; + nfs3_prep_pathconf3args (&args, &fh); + if (xdr_to_pathconf3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_pathconf (req, &fh); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "PATHCONF procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, ++ NFS_MSG_PATHCONF_FAIL, ++ "PATHCONF procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -4985,7 +5105,7 @@ nfs3svc_commit_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + cs = frame->local; + if (op_ret == -1) { +- gf_log (GF_NFS, GF_LOG_WARNING, ++ gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_COMMIT_CBK, + "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + stat = nfs3_cbk_errno_status (op_ret, op_errno); +@@ -5055,7 +5175,8 @@ nfs3_commit_open_resume (void *carg) + nfs3_check_fh_resolve_status (cs, stat, nfs3err); + cs->fd = fd_anonymous (cs->resolvedloc.inode); + if (!cs->fd) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd."); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, ++ "Failed to create anonymous fd."); + goto nfs3err; + } + +@@ -5086,7 +5207,8 @@ nfs3_commit (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, + nfs3_call_state_t *cs = NULL; + + if ((!req) || (!fh)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, ++ "Bad arguments"); + return -1; + } + +@@ -5131,14 +5253,16 @@ nfs3svc_commit (rpcsvc_request_t *req) + return ret; + nfs3_prep_commit3args (&args, &fh); + if (xdr_to_commit3args (req->msg[0], &args) <= 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, ++ "Error decoding args"); + rpcsvc_request_seterr (req, GARBAGE_ARGS); + goto rpcerr; + } + + ret = nfs3_commit (req, &fh, args.offset, args.count); + if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "COMMIT procedure failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_COMMIT_FAIL, ++ "COMMIT procedure failed"); + rpcsvc_request_seterr (req, SYSTEM_ERR); + ret = RPCSVC_ACTOR_ERROR; + } +@@ -5230,16 +5354,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) + if (dict_get (options, "nfs3.read-size")) { + ret = dict_get_str (options, "nfs3.read-size", &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: nfs3.read-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: nfs3.read-size"); + ret = -1; + goto err; + } + + ret = gf_string2uint64 (optstr, &size64); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" +- " option: nfs3.read-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, ++ "Failed to format option: nfs3.read-size"); + ret = -1; + goto err; + } +@@ -5253,16 +5377,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) + if (dict_get (options, "nfs3.write-size")) { + ret = dict_get_str (options, "nfs3.write-size", &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: nfs3.write-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: nfs3.write-size"); + ret = -1; + goto err; + } + + ret = gf_string2uint64 (optstr, &size64); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" +- " option: nfs3.write-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, ++ "Failed to format option: nfs3.write-size"); + ret = -1; + goto err; + } +@@ -5276,16 +5400,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) + if (dict_get (options, "nfs3.readdir-size")) { + ret = dict_get_str (options,"nfs3.readdir-size", &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read" +- " option: nfs3.readdir-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: nfs3.readdir-size"); + ret = -1; + goto err; + } + + ret = gf_string2uint64 (optstr, &size64); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" +- " option: nfs3.readdir-size"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, ++ "Failed to format option: nfs3.readdir-size"); + ret = -1; + goto err; + } +@@ -5340,7 +5464,8 @@ nfs3_init_subvolume_options (xlator_t *nfsx, + + ret = snprintf (searchkey, 1024, "nfs3.%s.volume-id",exp->subvol->name); + if (ret < 0) { +- gf_log (GF_MNT, GF_LOG_ERROR, "snprintf failed"); ++ gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, ++ "snprintf failed"); + ret = -1; + goto err; + } +@@ -5348,14 +5473,15 @@ nfs3_init_subvolume_options (xlator_t *nfsx, + if (dict_get (options, searchkey)) { + ret = dict_get_str (options, searchkey, &optstr); + if (ret < 0) { +- gf_log (GF_MNT, GF_LOG_ERROR, "Failed to read option" +- ": %s", searchkey); ++ gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: %s", searchkey); + ret = -1; + goto err; + } + } else { +- gf_log (GF_MNT, GF_LOG_ERROR, "DVM is on but volume-id not " +- "given for volume: %s", exp->subvol->name); ++ gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_VOLID_MISSING, "DVM is" ++ " on but volume-id not given for volume: %s", ++ exp->subvol->name); + ret = -1; + goto err; + } +@@ -5363,8 +5489,9 @@ nfs3_init_subvolume_options (xlator_t *nfsx, + if (optstr) { + ret = gf_uuid_parse (optstr, volumeid); + if (ret < 0) { +- gf_log (GF_MNT, GF_LOG_ERROR, "Failed to parse volume " +- "UUID"); ++ gf_msg (GF_MNT, GF_LOG_ERROR, 0, ++ NFS_MSG_PARSE_VOL_UUID_FAIL, ++ "Failed to parse volume UUID"); + ret = -1; + goto err; + } +@@ -5376,7 +5503,8 @@ no_dvm: + name = exp->subvol->name; + ret = snprintf (searchkey, 1024, "nfs3.%s.volume-access", name); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, ++ "snprintf failed"); + ret = -1; + goto err; + } +@@ -5385,8 +5513,8 @@ no_dvm: + if (dict_get (options, searchkey)) { + ret = dict_get_str (options, searchkey, &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: %s", searchkey); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: %s", searchkey); + ret = -1; + goto err; + } +@@ -5397,7 +5525,8 @@ no_dvm: + + ret = snprintf (searchkey, 1024, "rpc-auth.%s.unix", name); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, ++ "snprintf failed"); + ret = -1; + goto err; + } +@@ -5405,8 +5534,8 @@ no_dvm: + if (dict_get (options, searchkey)) { + ret = dict_get_str (options, searchkey, &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: %s", searchkey); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: %s", searchkey); + ret = -1; + goto err; + } +@@ -5415,7 +5544,8 @@ no_dvm: + exp->trusted_sync = 0; + ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-sync", name); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, ++ "snprintf failed"); + ret = -1; + goto err; + } +@@ -5423,15 +5553,16 @@ no_dvm: + if (dict_get (options, searchkey)) { + ret = dict_get_str (options, searchkey, &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: %s", searchkey); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: %s", searchkey); + ret = -1; + goto err; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to convert str " ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, ++ NFS_MSG_STR2BOOL_FAIL, "Failed to convert str " + "to gf_boolean_t"); + ret = -1; + goto err; +@@ -5444,7 +5575,8 @@ no_dvm: + exp->trusted_write = 0; + ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-write", name); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, ++ "snprintf failed"); + ret = -1; + goto err; + } +@@ -5452,16 +5584,17 @@ no_dvm: + if (dict_get (options, searchkey)) { + ret = dict_get_str (options, searchkey, &optstr); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " +- " option: %s", searchkey); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, ++ "Failed to read option: %s", searchkey); + ret = -1; + goto err; + } + + ret = gf_string2boolean (optstr, &boolt); + if (ret < 0) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to convert str " +- "to gf_boolean_t"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, ++ NFS_MSG_STR2BOOL_FAIL, "Failed to convert str" ++ " to gf_boolean_t"); + ret = -1; + goto err; + } +@@ -5477,7 +5610,7 @@ no_dvm: + if (exp->trusted_sync) + exp->trusted_write = 1; + +- gf_log (GF_NFS3, GF_LOG_TRACE, "%s: %s, %s, %s", exp->subvol->name, ++ gf_msg_trace (GF_NFS3, 0, "%s: %s, %s, %s", exp->subvol->name, + (exp->access == GF_NFS3_VOLACCESS_RO)?"read-only":"read-write", + (exp->trusted_sync == 0)?"no trusted_sync":"trusted_sync", + (exp->trusted_write == 0)?"no trusted_write":"trusted_write"); +@@ -5499,11 +5632,12 @@ nfs3_init_subvolume (struct nfs3_state *nfs3, xlator_t *subvol) + exp = GF_CALLOC (1, sizeof (*exp), gf_nfs_mt_nfs3_export); + exp->subvol = subvol; + INIT_LIST_HEAD (&exp->explist); +- gf_log (GF_NFS3, GF_LOG_TRACE, "Initing state: %s", exp->subvol->name); ++ gf_msg_trace (GF_NFS3, 0, "Initing state: %s", exp->subvol->name); + + ret = nfs3_init_subvolume_options (nfs3->nfsx, exp, NULL); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init subvol"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBVOL_INIT_FAIL, ++ "Failed to init subvol"); + goto exp_free; + } + +@@ -5533,8 +5667,9 @@ nfs3_init_subvolumes (struct nfs3_state *nfs3) + while (xl_list) { + exp = nfs3_init_subvolume (nfs3, xl_list->xlator); + if (!exp) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init subvol: " +- "%s", xl_list->xlator->name); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, ++ NFS_MSG_SUBVOL_INIT_FAIL, "Failed to init " ++ "subvol: %s", xl_list->xlator->name); + goto err; + } + list_add_tail (&exp->explist, &nfs3->exports); +@@ -5561,24 +5696,27 @@ nfs3_init_state (xlator_t *nfsx) + nfs3 = (struct nfs3_state *)GF_CALLOC (1, sizeof (*nfs3), + gf_nfs_mt_nfs3_state); + if (!nfs3) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Memory allocation failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "Memory allocation failed"); + return NULL; + } + + nfs = nfsx->private; + ret = nfs3_init_options (nfs3, nfsx->options); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init options"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_OPT_INIT_FAIL, ++ "Failed to init options"); + goto ret; + } + + nfs3->iobpool = nfsx->ctx->iobuf_pool; + + localpool = nfs->memfactor * GF_NFS_CONCURRENT_OPS_MULT; +- gf_log (GF_NFS3, GF_LOG_TRACE, "local pool: %d", localpool); ++ gf_msg_trace (GF_NFS3, 0, "local pool: %d", localpool); + nfs3->localpool = mem_pool_new (nfs3_call_state_t, localpool); + if (!nfs3->localpool) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "local mempool creation failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, ++ "local mempool creation failed"); + ret = -1; + goto ret; + } +@@ -5588,8 +5726,8 @@ nfs3_init_state (xlator_t *nfsx) + INIT_LIST_HEAD (&nfs3->exports); + ret = nfs3_init_subvolumes (nfs3); + if (ret == -1) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init per-subvolume " +- "state"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBVOL_INIT_FAIL, ++ "Failed to init per-subvolume state"); + goto free_localpool; + } + +@@ -5600,7 +5738,8 @@ nfs3_init_state (xlator_t *nfsx) + + ret = rpcsvc_create_listeners (nfs->rpcsvc, nfsx->options, nfsx->name); + if (ret == -1) { +- gf_log (GF_NFS, GF_LOG_ERROR, "Unable to create listeners"); ++ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_LISTENERS_CREATE_FAIL, ++ "Unable to create listeners"); + goto free_localpool; + } + +@@ -5631,7 +5770,8 @@ nfs3svc_init (xlator_t *nfsx) + + nfs3 = nfs3_init_state (nfsx); + if (!nfs3) { +- gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state init failed"); ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_STATE_INIT_FAIL, ++ "NFSv3 state init failed"); + return NULL; + } + +@@ -5658,7 +5798,7 @@ nfs3_reconfigure_state (xlator_t *nfsx, dict_t *options) + + ret = nfs3_init_options (nfs3, options); + if (ret) { +- gf_log (GF_NFS3, GF_LOG_ERROR, ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_RECONF_FAIL, + "Failed to reconfigure options"); + goto out; + } +@@ -5666,7 +5806,8 @@ nfs3_reconfigure_state (xlator_t *nfsx, dict_t *options) + list_for_each_entry (exp, &nfs3->exports, explist) { + ret = nfs3_init_subvolume_options (nfsx, exp, options); + if (ret) { +- gf_log (GF_NFS3, GF_LOG_ERROR, ++ gf_msg (GF_NFS3, GF_LOG_ERROR, 0, ++ NFS_MSG_RECONF_SUBVOL_FAIL, + "Failed to reconfigure subvol options"); + goto out; + } +-- +1.7.1 + diff --git a/SOURCES/0130-features-quota-port-QUOTA-messages-to-new-logging-fr.patch b/SOURCES/0130-features-quota-port-QUOTA-messages-to-new-logging-fr.patch new file mode 100644 index 0000000..376422a --- /dev/null +++ b/SOURCES/0130-features-quota-port-QUOTA-messages-to-new-logging-fr.patch @@ -0,0 +1,1846 @@ +From 4e48c71a771fa3ea38312a81de82437c351d68b1 Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Mon, 25 May 2015 16:52:10 +0530 +Subject: [PATCH 130/190] features/quota: port QUOTA messages to new logging framework + +BUG: 1233694 +Change-Id: Iff6d79b5884073306941e6c814a8ab9b18e383eb +Signed-off-by: Susant Palai +Reviewed-on: http://review.gluster.org/7574 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/51134 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/Makefile.am | 3 +- + xlators/features/quota/src/quota-enforcer-client.c | 46 +- + xlators/features/quota/src/quota-messages.h | 247 +++++++++ + xlators/features/quota/src/quota.c | 585 ++++++++++---------- + xlators/features/quota/src/quota.h | 6 +- + xlators/features/quota/src/quotad-aggregator.c | 29 +- + 6 files changed, 594 insertions(+), 322 deletions(-) + create mode 100644 xlators/features/quota/src/quota-messages.h + +diff --git a/xlators/features/quota/src/Makefile.am b/xlators/features/quota/src/Makefile.am +index 7165adc..79bc929 100644 +--- a/xlators/features/quota/src/Makefile.am ++++ b/xlators/features/quota/src/Makefile.am +@@ -10,7 +10,8 @@ quota_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + quotad_la_SOURCES = quotad.c quotad-helpers.c quotad-aggregator.c + quotad_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h quotad-helpers.h ++noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h \ ++ quotad-helpers.h quota-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(top_srcdir)/xlators/cluster/dht/src -I$(top_srcdir)/rpc/xdr/src/ \ +diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c +index 55e700c..067db6d 100644 +--- a/xlators/features/quota/src/quota-enforcer-client.c ++++ b/xlators/features/quota/src/quota-enforcer-client.c +@@ -44,6 +44,7 @@ + #endif + + #include "quota.h" ++#include "quota-messages.h" + + extern struct rpc_clnt_program quota_enforcer_clnt; + +@@ -149,7 +150,9 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov, + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lookup_rsp); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_XDR_DECODING_FAILED, ++ "XDR decoding failed"); + rsp.op_ret = -1; + op_errno = EINVAL; + goto out; +@@ -170,8 +173,8 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov, + + if ((!gf_uuid_is_null (inode->gfid)) + && (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) { +- gf_log (frame->this->name, GF_LOG_DEBUG, +- "gfid changed for %s", local->validate_loc.path); ++ gf_msg_debug (frame->this->name, ESTALE, ++ "gfid changed for %s", local->validate_loc.path); + rsp.op_ret = -1; + op_errno = ESTALE; + goto out; +@@ -226,14 +229,14 @@ out: + if (rsp.op_ret == -1) { + /* any error other than ENOENT */ + if (rsp.op_errno != ENOENT) +- gf_log (this->name, GF_LOG_WARNING, +- "remote operation failed: %s. Path: %s (%s)", +- strerror (rsp.op_errno), +- local->validate_loc.path, ++ gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ Q_MSG_LOOKUP_FAILED, ++ "Getting cluster-wide size of directory failed " ++ "(path: %s gfid:%s)", local->validate_loc.path, + loc_gfid_utoa (&local->validate_loc)); + else +- gf_log (this->name, GF_LOG_TRACE, +- "not found on remote node"); ++ gf_msg_trace (this->name, ENOENT, ++ "not found on remote node"); + + } else if (local->quotad_conn_retry) { + gf_log (this->name, GF_LOG_DEBUG, "connected to quotad after " +@@ -263,6 +266,7 @@ _quota_enforcer_lookup (void *data) + call_frame_t *frame = NULL; + loc_t *loc = NULL; + xlator_t *this = NULL; ++ char *dir_path = NULL; + + frame = data; + local = frame->local; +@@ -291,6 +295,11 @@ _quota_enforcer_lookup (void *data) + else + req.bname = ""; + ++ if (loc->path) ++ dir_path = (char *)loc->path; ++ else ++ dir_path = ""; ++ + ret = quota_enforcer_submit_request (&req, frame, + priv->quota_enforcer, + GF_AGGREGATOR_LOOKUP, +@@ -299,7 +308,10 @@ _quota_enforcer_lookup (void *data) + (xdrproc_t)xdr_gfs3_lookup_req); + + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_RPC_SUBMIT_FAILED, "Couldn't send the request to " ++ "fetch cluster wide size of directory (path:%s gfid:%s)" ++ , dir_path, req.gfid); + } + + GF_FREE (req.xdata.xdata_val); +@@ -351,19 +363,19 @@ quota_enforcer_notify (struct rpc_clnt *rpc, void *mydata, + switch (event) { + case RPC_CLNT_CONNECT: + { +- gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); ++ gf_msg_trace (this->name, 0, "got RPC_CLNT_CONNECT"); + break; + } + + case RPC_CLNT_DISCONNECT: + { +- gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); ++ gf_msg_trace (this->name, 0, "got RPC_CLNT_DISCONNECT"); + break; + } + + default: +- gf_log (this->name, GF_LOG_TRACE, +- "got some other RPC event %d", event); ++ gf_msg_trace (this->name, 0, ++ "got some other RPC event %d", event); + ret = 0; + break; + } +@@ -449,7 +461,9 @@ quota_enforcer_init (xlator_t *this, dict_t *options) + + ret = rpc_clnt_register_notify (rpc, quota_enforcer_notify, this); + if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "failed to register notify"); ++ gf_msg ("quota", GF_LOG_ERROR, 0, ++ Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED, ++ "failed to register notify"); + goto out; + } + +@@ -466,7 +480,7 @@ out: + } + + return rpc; +-} ++ } + + struct rpc_clnt_procedure quota_enforcer_actors[GF_AGGREGATOR_MAXVALUE] = { + [GF_AGGREGATOR_NULL] = {"NULL", NULL}, +diff --git a/xlators/features/quota/src/quota-messages.h b/xlators/features/quota/src/quota-messages.h +new file mode 100644 +index 0000000..d39b8d0 +--- /dev/null ++++ b/xlators/features/quota/src/quota-messages.h +@@ -0,0 +1,247 @@ ++/* ++ Copyright (c) 2013 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _QUOTA_MESSAGES_H_ ++#define _QUOTA_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/*! \file quota-messages.h ++ * \brief Quota log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check across the code if the message ID macro in question is reused ++ * anywhere. If reused then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_QUOTA_BASE GLFS_MSGID_COMP_QUOTA ++#define GLFS_NUM_MESSAGES 23 ++#define GLFS_MSGID_END (GLFS_QUOTA_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x GLFS_QUOTA_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++/*! ++ * @messageid 110001 ++ * @diagnosis Quota enforcement has failed. ++ * @recommendedaction None ++ */ ++#define Q_MSG_ENFORCEMENT_FAILED (GLFS_QUOTA_BASE + 1) ++ ++ ++/*! ++* @messageid 110002 ++* @diagnosis system is out of memory ++* @recommendedaction None ++*/ ++#define Q_MSG_ENOMEM (GLFS_QUOTA_BASE + 2) ++ ++/*! ++ * @messageid 110003 ++ * @diagnosis Parent inode is not present in the inode table due to the ++ * inode table limits or the brick was restarted recently. ++ * @recommendedaction If it is a brick restart then perform a crawl on the ++ * file system or the specific directory in which the problem is observed. ++ * If inode table limit has been reached,please increase the limit of ++ * network.inode-lru-limit to a higher value(can be set through CLI). ++ */ ++#define Q_MSG_PARENT_NULL (GLFS_QUOTA_BASE + 3) ++ ++/*! ++ * @messageid 110005 ++ * @diagnosis This is to inform the admin that the user has crossed the soft limit ++ * of the quota configured on the directory and expected to cross the hard limit soon. ++ * @recommendedaction You may reconfigure your quota limits. ++ */ ++#define Q_MSG_CROSSED_SOFT_LIMIT (GLFS_QUOTA_BASE + 4) ++ ++/*! ++ * @messageid 110007 ++ * @diagnosis Quota translator failed to connect to quotad. This could be ++ * due to one or more of the following reasons, (1) Quotad is not running. ++ * (2) Brick process has run out of memory. ++ * @recommendedaction If quotad is not running, consider starting quotad. ++ * else check system memory consumption. ++ */ ++#define Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED (GLFS_QUOTA_BASE + 5) ++ ++/*! ++ * @messageid 110008 ++ * @diagnosis Getting cluster-wide size failed ++ * @recommendedaction Restart quotad. Kill quotad by searching ++ * "ps ax | grep quotad" and use volume start force to restart it. ++ */ ++ ++#define Q_MSG_REMOTE_OPERATION_FAILED (GLFS_QUOTA_BASE + 6) ++ ++/*! ++ * @messageid 110009 ++ * @diagnosis Updation of global quota size failed. This may be due to quotad ++ * is down or lost connection with quotad. ++ * @recommendedaction Please restart quotad. ++ */ ++ ++#define Q_MSG_FAILED_TO_SEND_FOP (GLFS_QUOTA_BASE + 7) ++ ++/*! ++ * @messageid 110010 ++ * @diagnosis ++ * @recommendedaction Check volfile for correctness ++ */ ++ ++#define Q_MSG_INVALID_VOLFILE (GLFS_QUOTA_BASE + 8) ++ ++/*! ++ * @messageid 110011 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_INODE_PARENT_NOT_FOUND (GLFS_QUOTA_BASE + 9) ++ ++/*! ++ * @messageid 110012 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_XDR_DECODE_ERROR (GLFS_QUOTA_BASE + 10) ++ ++/*! ++ * @messageid 110013 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_DICT_UNSERIALIZE_FAIL (GLFS_QUOTA_BASE + 11) ++ ++/*! ++ * @messageid 110014 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_DICT_SERIALIZE_FAIL (GLFS_QUOTA_BASE + 12) ++ ++/*! ++ * @messageid 110015 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_RPCSVC_INIT_FAILED (GLFS_QUOTA_BASE + 13) ++ ++/*! ++ * @messageid 110016 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_RPCSVC_LISTENER_CREATION_FAILED (GLFS_QUOTA_BASE + 14) ++ ++/*! ++ * @messageid 110017 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_RPCSVC_REGISTER_FAILED (GLFS_QUOTA_BASE + 15) ++ ++/*! ++ * @messageid 110018 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_XDR_DECODING_FAILED (GLFS_QUOTA_BASE + 16) ++/*! ++ * @messageid 110019 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED (GLFS_QUOTA_BASE + 17) ++/*! ++ * @messageid 110020 ++ * @diagnosis ++ * @recommendedaction Umount and mount the corresponing volume ++ */ ++ ++#define Q_MSG_ANCESTRY_BUILD_FAILED (GLFS_QUOTA_BASE + 18) ++ ++/*! ++ * @messageid 110021 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_SIZE_KEY_MISSING (GLFS_QUOTA_BASE + 19) ++ ++/*! ++ * @messageid 110022 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_INODE_CTX_GET_FAILED (GLFS_QUOTA_BASE + 20) ++ ++/*! ++ * @messageid 110023 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_INODE_CTX_SET_FAILED (GLFS_QUOTA_BASE + 21) ++ ++/*! ++ * @messageid 110024 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_LOOKUP_FAILED (GLFS_QUOTA_BASE + 22) ++ ++/*! ++ * @messageid 110025 ++ * @diagnosis ++ * @recommendedaction ++ */ ++ ++#define Q_MSG_RPC_SUBMIT_FAILED (GLFS_QUOTA_BASE + 23) ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_QUOTA_MESSAGES_H_ */ ++ +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index ef094f8..3212cb0 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -14,6 +14,7 @@ + #include "defaults.h" + #include "statedump.h" + #include "quota-common-utils.h" ++#include "quota-messages.h" + + struct volume_options options[]; + +@@ -40,9 +41,9 @@ __quota_init_inode_ctx (inode_t *inode, xlator_t *this, + + ret = __inode_ctx_put (inode, this, (uint64_t )(long)ctx); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot set quota context in inode (gfid:%s)", +- uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_SET_FAILED, "cannot set quota context " ++ "in inode (gfid:%s)", uuid_utoa (inode->gfid)); + } + out: + return ret; +@@ -124,22 +125,21 @@ quota_inode_loc_fill (inode_t *inode, loc_t *loc) + + parent = inode_parent (inode, 0, NULL); + if (!parent) { +- gf_log (this->name, GF_LOG_DEBUG, +- "cannot find parent for inode (gfid:%s)", +- uuid_utoa (inode->gfid)); ++ gf_msg_debug (this->name, 0, "cannot find parent for " ++ "inode (gfid:%s)", uuid_utoa (inode->gfid)); + } + + ignore_parent: + ret = inode_path (inode, NULL, &resolvedpath); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "cannot construct path for inode (gfid:%s)", +- uuid_utoa (inode->gfid)); ++ gf_msg_debug (this->name, 0, "cannot construct path for " ++ "inode (gfid:%s)", uuid_utoa (inode->gfid)); + } + + ret = quota_loc_fill (loc, inode, parent, resolvedpath); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "cannot fill loc"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "cannot fill loc"); + goto err; + } + +@@ -260,7 +260,9 @@ quota_inode_parent (inode_t *inode, uuid_t pargfid, const char *name) + + parent = __quota_inode_parent (inode, pargfid, name); + if (!parent) +- gf_log_callingfn (THIS->name, GF_LOG_ERROR, "Failed to find " ++ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0, ++ Q_MSG_PARENT_NULL, ++ "Failed to find " + "ancestor for inode (%s)", + uuid_utoa(inode->gfid)); + +@@ -349,7 +351,8 @@ check_ancestory_continue (struct list_head *parents, inode_t *inode, + local = frame->local; + + if (parents && list_empty (parents)) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, EIO, ++ Q_MSG_ANCESTRY_BUILD_FAILED, + "Couldn't build ancestry for inode (gfid:%s). " + "Without knowing ancestors till root, quota " + "cannot be enforced. " +@@ -413,7 +416,8 @@ check_ancestory_2_cbk (struct list_head *parents, inode_t *inode, + goto out; + + if (parents == NULL || list_empty (parents)) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ Q_MSG_ENFORCEMENT_FAILED, + "Couldn't build ancestry for inode (gfid:%s). " + "Without knowing ancestors till root, quota " + "cannot be enforced.", +@@ -558,8 +562,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ctx = (quota_inode_ctx_t *)(unsigned long)value; + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_WARNING, +- "quota context is not present in inode (gfid:%s)", ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_INODE_CTX_GET_FAILED, "quota context is" ++ " not present in inode (gfid:%s)", + uuid_utoa (local->validate_loc.inode->gfid)); + op_errno = EINVAL; + goto unwind; +@@ -567,8 +572,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "dict get failed " +- "on quota size"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_SIZE_KEY_MISSING, "quota size key not present " ++ "in dict"); + op_errno = EINVAL; + } + +@@ -662,7 +668,8 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + parent = inode_parent (local->loc.inode, 0, NULL); + if (parent == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "parent is NULL"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_PARENT_NULL, "parent is NULL"); + op_errno = EINVAL; + goto err; + } +@@ -855,8 +862,9 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this, + + ret = quota_inode_loc_fill (inode, &local->validate_loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot fill loc for inode (gfid:%s), hence " ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENFORCEMENT_FAILED, ++ "cannot fill loc for inode (gfid:%s), hence " + "aborting quota-checks and continuing with fop", + uuid_utoa (inode->gfid)); + } +@@ -876,14 +884,16 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this, + + ret = dict_set_int8 (xdata, QUOTA_SIZE_KEY, 1); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "dict set failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "dict set failed"); + ret = -ENOMEM; + goto err; + } + + ret = dict_set_str (xdata, "volume-uuid", priv->volume_uuid); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "dict set failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "dict set failed"); + ret = -ENOMEM; + goto err; + } +@@ -919,12 +929,13 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + + if ((op_ret < 0) || list_empty (parents)) { + if (op_ret >= 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EIO, ++ Q_MSG_ANCESTRY_BUILD_FAILED, + "Couldn't build ancestry for inode (gfid:%s). " +- "Without knowing ancestors till root, quota " ++ "Without knowing ancestors till root, quota" + "cannot be enforced. " + "Hence, failing fop with EIO", +- uuid_utoa (inode->gfid)); ++ uuid_utoa (inode->gfid)); + op_errno = EIO; + } + +@@ -1184,7 +1195,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + goto done; + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to check " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_ENFORCEMENT_FAILED, "Failed to check " + "quota object limit"); + goto err; + } +@@ -1196,7 +1208,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + goto done; + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to check " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_ENFORCEMENT_FAILED, "Failed to check " + "quota size limit"); + goto err; + } +@@ -1334,9 +1347,9 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict, + + ret = quota_inode_ctx_get (inode, this, &ctx, 1); + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_WARNING, "cannot create quota " +- "context in inode(gfid:%s)", +- uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota " ++ "context in inode(gfid:%s)", uuid_utoa (inode->gfid)); + ret = -1; + *op_errno = ENOMEM; + goto out; +@@ -1374,11 +1387,12 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict, + loc->parent->gfid); + if (dentry == NULL) { + /* +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (par:%" +- PRId64", name:%s) for inode(ino:%" +- PRId64", gfid:%s)", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, ++ "cannot create a new dentry (par:%" ++- PRId64", name:%s) for inode(ino:%" ++- PRId64", gfid:%s)", ++- uuid_utoa (local->loc.inode->gfid)); + */ + ret = -1; + *op_errno = ENOMEM; +@@ -1457,14 +1471,15 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + + ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_KEY, 1); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "dict set of key for hard-limit failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "dict set of key for " ++ "hard-limit failed"); + goto err; + } + + ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_OBJECTS_KEY, 1); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, + "dict set of key for quota object limit failed"); + goto err; + } +@@ -1509,15 +1524,17 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = inode_ctx_get (local->loc.inode, this, &ctx_int); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "%s: failed to get the context", local->loc.path); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, "%s: failed to get the " ++ "context", local->loc.path); + goto out; + } + + ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int; + + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, + "quota context not set in %s (gfid:%s)", + local->loc.path, uuid_utoa (local->loc.inode->gfid)); + goto out; +@@ -1551,10 +1568,8 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, + priv = this->private; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + if (local->op_ret == -1) { + op_errno = local->op_errno; +@@ -1647,11 +1662,10 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + + ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (fd->inode->gfid)); + } + + stub = fop_writev_stub (frame, quota_writev_helper, fd, vector, count, +@@ -1733,10 +1747,8 @@ quota_mkdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, + int32_t op_errno = EINVAL; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + op_errno = local->op_errno; + +@@ -1781,7 +1793,8 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + ret = loc_copy (&local->loc, loc); + if (ret) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + +@@ -1836,9 +1849,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_inode_ctx_get (inode, this, &ctx, 1); + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_WARNING, "cannot create quota " +- "context in inode(gfid:%s)", +- uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota " ++ "context in inode(gfid:%s)", uuid_utoa (inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; + goto unwind; +@@ -1851,9 +1864,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dentry = __quota_dentry_new (ctx, (char *)local->loc.name, + local->loc.parent->gfid); + if (dentry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (name:%s) for " +- "inode(gfid:%s)", local->loc.name, ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "cannot create a new dentry " ++ "(name:%s) for inode(gfid:%s)", local->loc.name, + uuid_utoa (local->loc.inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; +@@ -1881,12 +1894,10 @@ quota_create_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, + + local = frame->local; + ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); ++ + priv = this->private; + +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } + + if (local->op_ret == -1) { + op_errno = local->op_errno; +@@ -1931,7 +1942,8 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + + ret = loc_copy (&local->loc, loc); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + op_errno = ENOMEM; + goto err; + } +@@ -1987,8 +1999,9 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ctx = (quota_inode_ctx_t *)(unsigned long)value; + + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "quota context not set in inode (gfid:%s)", ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_INODE_CTX_GET_FAILED, ++ "quota context not set inode (gfid:%s)", + uuid_utoa (local->loc.inode->gfid)); + goto out; + } +@@ -2036,7 +2049,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + + ret = loc_copy (&local->loc, loc); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + +@@ -2079,11 +2093,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_inode_ctx_get (inode, this, &ctx, 0); + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (inode->gfid)); + goto out; + } + +@@ -2093,13 +2106,15 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if ((strcmp (dentry->name, local->loc.name) == 0) && + (gf_uuid_compare (local->loc.parent->gfid, + dentry->par) == 0)) { +- found = 1; +- gf_log (this->name, GF_LOG_WARNING, +- "new entry being linked (name:%s) for " +- "inode (gfid:%s) is already present " +- "in inode-dentry-list", dentry->name, +- uuid_utoa (local->loc.inode->gfid)); +- break; ++ found = 1; ++ ++ gf_msg_debug (this->name, 0, "new entry being" ++ " linked (name:%s) for inode " ++ "(gfid:%s) is already present " ++ "in inode-dentry-list", ++ dentry->name, ++ uuid_utoa (local->loc.inode->gfid)); ++ break; + } + } + +@@ -2108,9 +2123,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + (char *)local->loc.name, + local->loc.parent->gfid); + if (dentry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (name:%s) " +- "for inode(gfid:%s)", local->loc.name, ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, ++ "cannot create a new dentry (name:%s)" ++ "for inode(gfid:%s)", local->loc.name, + uuid_utoa (local->loc.inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; +@@ -2142,10 +2158,8 @@ quota_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + priv = this->private; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + op_errno = local->op_errno; + +@@ -2192,7 +2206,8 @@ quota_link_continue (call_frame_t *frame) + local->newloc.parent, + &common_ancestor); + if (ret < 0 || gf_uuid_is_null(common_ancestor)) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, ESTALE, ++ Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get " + "common_ancestor for %s and %s", + local->oldloc.path, local->newloc.path); + op_errno = ESTALE; +@@ -2223,11 +2238,10 @@ quota_link_continue (call_frame_t *frame) + + quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->oldloc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->oldloc.inode->gfid)); + } + + LOCK (&local->lock); +@@ -2274,9 +2288,9 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + /* No need to check quota limit if src and dst parents are same */ + if (oldloc->parent && newloc->parent && + !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { +- gf_log (this->name, GF_LOG_DEBUG, "link %s -> %s are " +- "in the same directory, so skip check limit", +- oldloc->path, newloc->path); ++ gf_msg_debug (this->name, GF_LOG_DEBUG, "link %s -> %s are " ++ "in the same directory, so skip check limit", ++ oldloc->path, newloc->path); + goto off; + } + +@@ -2292,19 +2306,22 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + + ret = loc_copy (&local->loc, newloc); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + + ret = loc_copy (&local->oldloc, oldloc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "loc_copy failed"); + goto err; + } + + ret = loc_copy (&local->newloc, newloc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "loc_copy failed"); + goto err; + } + +@@ -2359,12 +2376,8 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- op_ret = -1; +- op_errno = EINVAL; +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) { + size = buf->ia_blocks * 512; +@@ -2376,11 +2389,10 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0); + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->oldloc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->oldloc.inode->gfid)); + + goto out; + } +@@ -2397,10 +2409,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + (gf_uuid_compare (local->newloc.parent->gfid, + dentry->par) == 0)) { + new_dentry_found = 1; +- gf_log (this->name, GF_LOG_WARNING, +- "new entry being linked (name:%s) for " +- "inode (gfid:%s) is already present " +- "in inode-dentry-list", dentry->name, ++ gf_msg_debug (this->name, 0, "new entry being " ++ "linked (name:%s) for inode (gfid:%s) " ++ "is in inode-dentry-list", dentry->name, + uuid_utoa (local->oldloc.inode->gfid)); + } + +@@ -2411,9 +2422,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (old_dentry != NULL) { + __quota_dentry_free (old_dentry); + } else { +- gf_log (this->name, GF_LOG_WARNING, +- "dentry corresponding to the path just renamed " +- "(name:%s) is not present", local->oldloc.name); ++ gf_msg_debug (this->name, 0, "dentry corresponding" ++ "the path just renamed (name:%s) is not" ++ " present", local->oldloc.name); + } + + if (!new_dentry_found) { +@@ -2421,11 +2432,12 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + (char *)local->newloc.name, + local->newloc.parent->gfid); + if (dentry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (name:%s) " +- "for inode(gfid:%s)", +- local->newloc.name, +- uuid_utoa (local->oldloc.inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, ++ "cannot create a new dentry (name:%s) " ++ "for inode(gfid:%s)", ++ local->newloc.name, ++ uuid_utoa (local->newloc.inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; + goto unlock; +@@ -2456,10 +2468,8 @@ quota_rename_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + priv = this->private; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + op_errno = local->op_errno; + +@@ -2505,8 +2515,8 @@ quota_rename_get_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = dict_get_bin (xdata, QUOTA_SIZE_KEY, (void **) &size); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "size key not present in dict"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_SIZE_KEY_MISSING, "size key not present in dict"); + op_errno = EINVAL; + goto out; + } +@@ -2542,7 +2552,8 @@ quota_rename_continue (call_frame_t *frame) + local->newloc.parent, + &common_ancestor); + if (ret < 0 || gf_uuid_is_null(common_ancestor)) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, ESTALE, ++ Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get " + "common_ancestor for %s and %s", + local->oldloc.path, local->newloc.path); + op_errno = ESTALE; +@@ -2559,11 +2570,14 @@ quota_rename_continue (call_frame_t *frame) + if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) { + ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, + "quota context not set in inode (gfid:%s), " + "considering file size as zero while enforcing " + "quota on new ancestry", + uuid_utoa (local->oldloc.inode->gfid)); ++ ++ + local->delta = 0; + } else { + +@@ -2619,9 +2633,9 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + /* No need to check quota limit if src and dst parents are same */ + if (oldloc->parent && newloc->parent && + !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { +- gf_log (this->name, GF_LOG_DEBUG, "rename %s -> %s are " +- "in the same directory, so skip check limit", +- oldloc->path, newloc->path); ++ gf_msg_debug (this->name, 0, "rename %s -> %s are " ++ "in the same directory, so skip check limit", ++ oldloc->path, newloc->path); + goto off; + } + +@@ -2634,13 +2648,15 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + + ret = loc_copy (&local->oldloc, oldloc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "loc_copy failed"); + goto err; + } + + ret = loc_copy (&local->newloc, newloc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "loc_copy failed"); + goto err; + } + +@@ -2697,11 +2713,10 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 1); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + + goto out; + } +@@ -2713,10 +2728,11 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dentry = __quota_dentry_new (ctx, (char *)local->loc.name, + local->loc.parent->gfid); + if (dentry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (name:%s) for " +- "inode(gfid:%s)", local->loc.name, +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "cannot create " ++ "a new dentry (name:%s) for inode(gfid:%s)", ++ local->loc.name, ++ uuid_utoa (local->loc.inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; + } +@@ -2740,10 +2756,8 @@ quota_symlink_helper (call_frame_t *frame, xlator_t *this, const char *linkpath, + quota_priv_t *priv = NULL; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + priv = this->private; + +@@ -2787,7 +2801,8 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, + + ret = loc_copy (&local->loc, loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + +@@ -2835,18 +2850,15 @@ quota_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + goto out; + } + +@@ -2884,7 +2896,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + + ret = loc_copy (&local->loc, loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + +@@ -2917,18 +2930,15 @@ quota_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + goto out; + } + +@@ -3018,7 +3028,7 @@ dict_set: + if (ret < 0) + goto out; + +- gf_log (this->name, GF_LOG_DEBUG, "str = %s", dir_limit); ++ gf_msg_debug (this->name, 0, "str = %s", dir_limit); + + QUOTA_STACK_UNWIND (getxattr, frame, 0, 0, dict, NULL); + +@@ -3083,19 +3093,15 @@ quota_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { + if (!IA_ISDIR (buf->ia_type)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler " +- "has finished crawling, its an error", ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", + uuid_utoa (local->loc.inode->gfid)); + } + +@@ -3134,7 +3140,8 @@ quota_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + frame->local = local; + ret = loc_copy (&local->loc, loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto unwind; + } + +@@ -3168,19 +3175,15 @@ quota_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { + if (!IA_ISDIR (buf->ia_type)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler " +- "has finished crawling, its an error", ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", + uuid_utoa (local->loc.inode->gfid)); + } + +@@ -3249,18 +3252,15 @@ quota_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + goto out; + } + +@@ -3298,7 +3298,8 @@ quota_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + + ret = loc_copy (&local->loc, loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto unwind; + } + +@@ -3333,18 +3334,15 @@ quota_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + goto out; + } + +@@ -3412,18 +3410,15 @@ quota_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on " +- "inode (%s). " +- "If quota is not enabled recently and crawler has " +- "finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + goto out; + } + +@@ -3490,18 +3485,15 @@ quota_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { + if (!IA_ISDIR (statpost->ia_type)) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is " +- "NULL on inode (%s). " +- "If quota is not enabled recently and crawler " +- "has finished crawling, its an error", ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", + uuid_utoa (local->loc.inode->gfid)); + } + +@@ -3543,7 +3535,8 @@ quota_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + + ret = loc_copy (&local->loc, loc); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto unwind; + } + +@@ -3577,18 +3570,15 @@ quota_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto out; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, out); + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + if (ctx == NULL) { + if (!IA_ISDIR (statpost->ia_type)) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is " +- "NULL on inode (%s). " +- "If quota is not enabled recently and crawler " +- "has finished crawling, its an error", ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", + uuid_utoa (local->loc.inode->gfid)); + } + +@@ -3663,8 +3653,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_inode_ctx_get (inode, this, &ctx, 1); + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_WARNING, "cannot create quota " +- "context in inode (gfid:%s)", uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, ++ "cannot create quota context in " ++ "inode(gfid:%s)", uuid_utoa (inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; + goto unwind; +@@ -3677,10 +3669,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dentry = __quota_dentry_new (ctx, (char *)local->loc.name, + local->loc.parent->gfid); + if (dentry == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot create a new dentry (name:%s) for " +- "inode(gfid:%s)", local->loc.name, +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "cannot create a new dentry " ++ "(name:%s) for inode(gfid:%s)", local->loc.name, ++ uuid_utoa (local->loc.inode->gfid)); + op_ret = -1; + op_errno = ENOMEM; + goto unlock; +@@ -3705,10 +3697,8 @@ quota_mknod_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, + quota_priv_t *priv = NULL; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + priv = this->private; + +@@ -3753,7 +3743,8 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + + ret = loc_copy (&local->loc, loc); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "loc_copy failed"); + goto err; + } + +@@ -4111,11 +4102,8 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + * cookie, and it would only do so if the value was non-NULL. This + * check is therefore just routine defensive coding. + */ +- if (!inode) { +- gf_log(this->name,GF_LOG_WARNING, +- "null inode, cannot adjust for quota"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", inode, unwind); + + inode_ctx_get (inode, this, &value); + ctx = (quota_inode_ctx_t *)(unsigned long)value; +@@ -4149,8 +4137,9 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = dict_set_int8 (xdata, "quota-deem-statfs", 1); + if (-1 == ret) +- gf_log (this->name, GF_LOG_ERROR, "Dict set failed, " +- "deem-statfs option may have no effect"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ Q_MSG_ENOMEM, "Dict set failed, deem-statfs option may " ++ "have no effect"); + + unwind: + QUOTA_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata); +@@ -4215,8 +4204,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ctx = (quota_inode_ctx_t *)(unsigned long)value; + if ((ret == -1) || (ctx == NULL)) { +- gf_log (this->name, GF_LOG_WARNING, +- "quota context is not present in inode (gfid:%s)", ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_INODE_CTX_GET_FAILED, ++ "quota context is not present in inode (gfid:%s)", + uuid_utoa (local->validate_loc.inode->gfid)); + op_errno = EINVAL; + goto resume; +@@ -4224,8 +4214,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "dict get failed " +- "on quota size"); ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ Q_MSG_SIZE_KEY_MISSING, "size key not present in " ++ "dict"); + op_errno = EINVAL; + } + +@@ -4259,7 +4250,8 @@ quota_get_limit_dir_continuation (struct list_head *parents, inode_t *inode, + + if ((op_ret < 0) || list_empty (parents)) { + if (op_ret >= 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EIO, ++ Q_MSG_ANCESTRY_BUILD_FAILED, + "Couldn't build ancestry for inode (gfid:%s). " + "Without knowing ancestors till root, quota " + "cannot be enforced. " +@@ -4345,8 +4337,8 @@ quota_get_limit_dir (call_frame_t *frame, inode_t *cur_inode, xlator_t *this) + return; + + off: +- gf_log (this->name, GF_LOG_DEBUG, +- "No limit set on the inode or it's parents."); ++ gf_msg_debug (this->name, 0, ++ "No limit set on the inode or it's parents."); + + QUOTA_STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->statfs, +@@ -4429,7 +4421,6 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + gf_log (this->name, GF_LOG_ERROR, + "Missing inode, can't adjust for quota"); + +- + off: + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->statfs, loc, xdata); +@@ -4510,8 +4501,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + if (dict) { + ret = dict_set_int8 (dict, QUOTA_LIMIT_KEY, 1); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "dict set of key for hard-limit failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, ++ "dict set of key for hard-limit"); + goto err; + } + } +@@ -4519,8 +4511,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + if (dict) { + ret = dict_set_int8 (dict, QUOTA_LIMIT_OBJECTS_KEY, 1); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "dict set of key for hard-limit failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ Q_MSG_ENOMEM, "dict set of key for hard-limit " ++ "failed"); + goto err; + } + } +@@ -4568,16 +4561,18 @@ quota_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + ret = inode_ctx_get (local->loc.inode, this, &ctx_int); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "%s: failed to get the context", local->loc.path); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, ++ "%s: failed to get the context", local->loc.path); + goto out; + } + + ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int; + + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "quota context not set in %s (gfid:%s)", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INODE_CTX_GET_FAILED, ++ "quota context not set in %s (gfid:%s)", + local->loc.path, uuid_utoa (local->loc.inode->gfid)); + goto out; + } +@@ -4605,10 +4600,8 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, + quota_priv_t *priv = NULL; + + local = frame->local; +- if (local == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "local is NULL"); +- goto unwind; +- } ++ ++ GF_VALIDATE_OR_GOTO ("quota", local, unwind); + + priv = this->private; + +@@ -4676,11 +4669,10 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + + ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0); + if (ctx == NULL) { +- gf_log (this->name, GF_LOG_DEBUG, "quota context is " +- "NULL on inode (%s). " +- "If quota is not enabled recently and crawler " +- "has finished crawling, its an error", +- uuid_utoa (local->loc.inode->gfid)); ++ gf_msg_debug (this->name, 0, "quota context is NULL on inode" ++ " (%s). If quota is not enabled recently and " ++ "crawler has finished crawling, its an error", ++ uuid_utoa (local->loc.inode->gfid)); + } + + stub = fop_fallocate_stub(frame, quota_fallocate_helper, fd, mode, +@@ -4748,8 +4740,9 @@ quota_log_helper (char **usage_str, int64_t cur_size, inode_t *inode, + + *usage_str = gf_uint64_2human_readable (cur_size); + if (!(*usage_str)) +- gf_log (this->name, GF_LOG_ERROR, "integer to string " +- "conversion failed Reason:\"Cannot allocate memory\""); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM, ++ "integer to string conversion failed Reason" ++ ":\"Cannot allocate memory\""); + + inode_path (inode, NULL, path); + if (!(*path)) +@@ -4784,8 +4777,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, + quota_log_helper (&usage_str, cur_size, inode, + &path, &cur_time); + +- gf_log (this->name, GF_LOG_ALERT, "Usage crossed " +- "soft limit: %s used by %s", usage_str, path); ++ gf_msg (this->name, GF_LOG_ALERT, 0, ++ Q_MSG_CROSSED_SOFT_LIMIT, "Usage crossed soft limit: " ++ "%s used by %s", usage_str, path); + ctx->prev_log = cur_time; + } + /* Usage is above soft limit */ +@@ -4795,8 +4789,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, + quota_log_helper (&usage_str, cur_size, inode, + &path, &cur_time); + +- gf_log (this->name, GF_LOG_ALERT, "Usage is above " +- "soft limit: %s used by %s", usage_str, path); ++ gf_msg (this->name, GF_LOG_ALERT, 0, Q_MSG_CROSSED_SOFT_LIMIT, ++ "Usage is above soft limit: %s used by %s", ++ usage_str, path); + ctx->prev_log = cur_time; + } + +@@ -4815,8 +4810,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_quota_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, "Memory accounting" +- "init failed"); ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM, ++ "Memory accounting init failed"); + return ret; + } + +@@ -4864,14 +4859,16 @@ init (xlator_t *this) + + if ((this->children == NULL) + || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_INVALID_VOLFILE, + "FATAL: quota (%s) not configured with " + "exactly one child", this->name); + return -1; + } + + if (this->parents == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_INVALID_VOLFILE, + "dangling volume. check volfile"); + } + +@@ -4893,8 +4890,8 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (quota_local_t, 64); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "failed to create local_t's memory pool"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ Q_MSG_ENOMEM, "failed to create local_t's memory pool"); + goto err; + } + +@@ -4902,8 +4899,9 @@ init (xlator_t *this) + rpc = quota_enforcer_init (this, this->options); + if (rpc == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_WARNING, +- "quota enforcer rpc init failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED, ++ "quota enforcer rpc init failed"); + goto err; + } + +@@ -4947,8 +4945,9 @@ reconfigure (xlator_t *this, dict_t *options) + this->options); + if (priv->rpc_clnt == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_WARNING, +- "quota enforcer rpc init failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED, ++ "quota enforcer rpc init failed"); + goto out; + } + +diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h +index 566302c..56876f0 100644 +--- a/xlators/features/quota/src/quota.h ++++ b/xlators/features/quota/src/quota.h +@@ -36,6 +36,7 @@ + #include "compat-errno.h" + #include "protocol-common.h" + #include "quota-common-utils.h" ++#include "quota-messages.h" + + #define DIRTY "dirty" + #define SIZE "size" +@@ -79,8 +80,9 @@ + var = GF_CALLOC (sizeof (type), 1, \ + gf_quota_mt_##type); \ + if (!var) { \ +- gf_log ("", GF_LOG_ERROR, \ +- "out of memory"); \ ++ gf_msg ("", GF_LOG_ERROR, \ ++ ENOMEM, Q_MSG_ENOMEM, \ ++ "out of memory"); \ + ret = -1; \ + goto label; \ + } \ +diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c +index 6f2f6e8..6c9c40a 100644 +--- a/xlators/features/quota/src/quotad-aggregator.c ++++ b/xlators/features/quota/src/quotad-aggregator.c +@@ -90,7 +90,8 @@ quotad_aggregator_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, + + iob = quotad_serialize_reply (req, arg, &rsp, xdrproc); + if (!iob) { +- gf_log ("", GF_LOG_ERROR, "Failed to serialize reply"); ++ gf_msg ("", GF_LOG_ERROR, 0, Q_MSG_DICT_SERIALIZE_FAIL, ++ "Failed to serialize reply"); + goto ret; + } + +@@ -148,7 +149,9 @@ quotad_aggregator_getlimit_cbk (xlator_t *this, call_frame_t *frame, + out: + rsp->op_ret = ret; + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to unserialize " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_DICT_UNSERIALIZE_FAIL, ++ "failed to unserialize " + "nameless lookup rsp"); + goto reply; + } +@@ -193,7 +196,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req) + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + //failed to decode msg; +- gf_log ("", GF_LOG_ERROR, "xdr decoding error"); ++ gf_msg ("this->name", GF_LOG_ERROR, 0, Q_MSG_XDR_DECODE_ERROR, ++ "xdr decoding error"); + req->rpc_err = GARBAGE_ARGS; + goto err; + } +@@ -203,8 +207,10 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req) + ret = dict_unserialize (cli_req.dict.dict_val, + cli_req.dict.dict_len, &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " +- "unserialize req-buffer to dictionary"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_DICT_UNSERIALIZE_FAIL, ++ "Failed to unserialize req-buffer to " ++ "dictionary"); + goto err; + } + } +@@ -230,8 +236,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req) + + ret = dict_set_int32 (state->xdata, QUOTA_LIMIT_OBJECTS_KEY, 42); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set " +- "QUOTA_LIMIT_OBJECTS_KEY"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM, ++ "Failed to set QUOTA_LIMIT_OBJECTS_KEY"); + goto err; + } + +@@ -384,7 +390,8 @@ quotad_aggregator_init (xlator_t *this) + /* RPC related */ + priv->rpcsvc = rpcsvc_init (this, this->ctx, this->options, 0); + if (priv->rpcsvc == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_RPCSVC_INIT_FAILED, + "creation of rpcsvc failed"); + ret = -1; + goto out; +@@ -393,7 +400,8 @@ quotad_aggregator_init (xlator_t *this) + ret = rpcsvc_create_listeners (priv->rpcsvc, this->options, + this->name); + if (ret < 1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_RPCSVC_LISTENER_CREATION_FAILED, + "creation of listener failed"); + ret = -1; + goto out; +@@ -404,7 +412,8 @@ quotad_aggregator_init (xlator_t *this) + + ret = rpcsvc_program_register (priv->rpcsvc, "ad_aggregator_prog); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ Q_MSG_RPCSVC_REGISTER_FAILED, + "registration of program (name:%s, prognum:%d, " + "progver:%d) failed", quotad_aggregator_prog.progname, + quotad_aggregator_prog.prognum, +-- +1.7.1 + diff --git a/SOURCES/0131-NFS-Ganesha-Implement-refresh-config.patch b/SOURCES/0131-NFS-Ganesha-Implement-refresh-config.patch new file mode 100644 index 0000000..2188f86 --- /dev/null +++ b/SOURCES/0131-NFS-Ganesha-Implement-refresh-config.patch @@ -0,0 +1,216 @@ +From 5030beca77210c5bbaed14c7c704a50bfcc0be60 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Fri, 19 Jun 2015 05:48:05 +0530 +Subject: [PATCH 131/190] NFS-Ganesha : Implement refresh-config + +It is important that we give an automatic way of refreshing the config +when the user has changed the export file manually. +Without this, the user will be forced to restart the server. +Implementing refresh_config by using dbus signals to unexport +and export the same export dynamically. +Making a few changes to make sure that "--help" +doesn't throw unnecessary error messages. + +This is the backport of the patch merged on upstream master, +http://review.gluster.org/#/c/11331/ + +Change-Id: Ibea8f90641dc78a8570b501e92831ddb33b9552e +BUG: 1233033 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/51493 +Reviewed-by: Soumya Koduri +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + extras/ganesha/scripts/dbus-send.sh | 8 ++- + extras/ganesha/scripts/ganesha-ha.sh | 96 +++++++++++++++++++++++++++++---- + 2 files changed, 89 insertions(+), 15 deletions(-) + +diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh +index 170983a..b96bba9 100755 +--- a/extras/ganesha/scripts/dbus-send.sh ++++ b/extras/ganesha/scripts/dbus-send.sh +@@ -4,14 +4,16 @@ declare -i EXPORT_ID + GANESHA_DIR=${1%/} + OPTION=$2 + VOL=$3 +- +-CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=") ++cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) ++eval $(echo ${cfgline} | grep -F CONFFILE=) ++CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + function check_cmd_status() + { + if [ "$1" != "0" ] + then + rm -rf $GANESHA_DIR/exports/export.$VOL.conf ++ sed -i /$VOL.conf/d $CONF + exit 1 + fi + } +@@ -20,7 +22,7 @@ function check_cmd_status() + function dynamic_export_add() + { + count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l` +- if [ "$count" = "1" ] ; ++ if [ "$count" = "0" ] ; + then + EXPORT_ID=2 + else +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 74c1194..3fa09bd 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -32,6 +32,17 @@ GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + RHEL6_PCS_CNAME_OPTION="--name" + ++usage() { ++ ++ echo "Usage : add|delete|status" ++ echo "Add-node : ganesha-ha.sh --add \ ++ " ++ echo "Delete-node: ganesha-ha.sh --delete \ ++" ++ echo "Refresh-config : ganesha-ha.sh --refresh-config \ ++ " ++} ++ + determine_service_manager () { + + if [ -e "/usr/bin/systemctl" ]; +@@ -171,12 +182,17 @@ setup_finalize() + setup_copy_config() + { + local short_host=$(hostname -s) ++ local tganesha_conf=$(mktemp -u) + + if [ -e /var/lib/glusterd/nfs/secret.pem ]; then + while [[ ${1} ]]; do +- if [ ${short_host} != ${1} ]; then ++ current_host=`echo ${1} | cut -d "." -f 1` ++ if [ ${short_host} != ${current_host} ]; then ++ cp ${HA_CONFDIR}/ganesha-ha.conf ${tganesha_conf} + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem ${1}:${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/ ++/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_conf}\ ++ ${1}:${HA_CONFDIR}/ganesha-ha.conf ++ rm -rf ${tganesha_conf} + if [ $? -ne 0 ]; then + logger "warning: scp ganesha-ha.conf to ${1} failed" + fi +@@ -188,6 +204,56 @@ setup_copy_config() + fi + } + ++refresh_config () ++{ ++ local short_host=$(hostname -s) ++ local VOL=${1} ++ local HA_CONFDIR=${2} ++ local tganesha_export=$(mktemp -u) ++ ++ removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\ ++grep Export_Id | cut -d " " -f8` ++ ++ if [ -e /var/lib/glusterd/nfs/secret.pem ]; then ++ while [[ ${3} ]]; do ++ current_host=`echo ${3} | cut -d "." -f 1` ++ if [ ${short_host} != ${current_host} ]; then ++ cp ${HA_CONFDIR}/exports/export.$VOL.conf ${tganesha_export} ++ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_export} \ ++${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf ++ rm -rf ${tganesha_export} ++ ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --print-reply --system \ ++--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ ++org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id" ++ sleep 1 ++ ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --system \ ++--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ ++org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \ ++string:\"EXPORT(Path=/$VOL)\"" ++ if [ $? -ne 0 ]; then ++ echo "warning: refresh-config failed on ${current_host}" ++ fi ++ fi ++ shift ++ done ++ else ++ echo "warning: refresh-config failed on ${1}" ++ fi ++ ++#Run the same command on the localhost, ++ dbus-send --print-reply --system \ ++--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ ++org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id ++ sleep 1 ++ dbus-send --system \ ++--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ ++org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \ ++string:"EXPORT(Path=/$VOL)" ++} ++ + copy_export_config () + { + local new_node=${1} +@@ -740,18 +806,25 @@ setup_state_volume() + + main() + { ++ + local cmd=${1}; shift ++ if [[ ${cmd} == *help ]] ++ then ++ usage ++ exit 0 ++ fi ++ + HA_CONFDIR=${1}; shift + local ha_conf=${HA_CONFDIR}/ganesha-ha.conf + local node="" + local vip="" + + # ignore any comment lines +- cfgline=$(grep ^HA_NAME= ${ha_conf}) ++ cfgline=$(grep ^HA_NAME= ${ha_conf}) + eval $(echo ${cfgline} | grep -F HA_NAME=) +- cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf}) ++ cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf}) + eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=) +- cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf}) ++ cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf}) + eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=) + + # we'll pretend that nobody ever edits /etc/os-release +@@ -864,18 +937,17 @@ $HA_CONFDIR/ganesha-ha.conf + ;; + + refresh-config | --refresh-config) +- ;; ++ VOL=${1} + +- help | --help) +- echo "Usage : add|delete|status" +- echo "Add-node : ganesha-ha.sh --add \ +- " +- echo "Delete-node: ganesha-ha.sh --delete \ +-" ++ determine_servers "refresh-config" ++ ++ refresh_config ${VOL} ${HA_CONFDIR} ${HA_SERVERS} + ;; ++ + *) + # setup and teardown are not intended to be used by a + # casual user ++ usage + logger "Usage: ganesha-ha.sh add|delete|status" + ;; + +-- +1.7.1 + diff --git a/SOURCES/0132-glusterd-use-mkdir_p-for-creating-rundir.patch b/SOURCES/0132-glusterd-use-mkdir_p-for-creating-rundir.patch new file mode 100644 index 0000000..7759eaa --- /dev/null +++ b/SOURCES/0132-glusterd-use-mkdir_p-for-creating-rundir.patch @@ -0,0 +1,77 @@ +From ee77fa7ac83f1d5b3b77c032bf97374f34304a64 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Tue, 23 Jun 2015 15:40:32 +0530 +Subject: [PATCH 132/190] glusterd: use mkdir_p for creating rundir + +snapdsvc initialization is now dependent on all subsequent directories and +volfile creations. + +However this may not hold true correct for all the cases. While importing a +volume we would need to start the service before the store creation. + +To avoid this dependency, use mkdir_p instead of mkdir to create rundir + +Change-Id: Ib251043398c40f1b76378e3bc6d0c36c1fe4cca3 +BUG: 1234720 +Signed-off-by: Atin Mukherjee +Reviewed-on: http://review.gluster.org/11364 +Tested-by: NetBSD Build System +Reviewed-by: Rajesh Joseph +Reviewed-by: Kaushal M +Reviewed-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/51469 +Reviewed-by: Vijay Bellur +Tested-by: Vijay Bellur +--- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 14 +++++++------- + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +index 1a68afb..04096a4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +@@ -23,7 +23,7 @@ glusterd_svc_create_rundir (char *rundir) + { + int ret = -1; + +- ret = mkdir (rundir, 0777); ++ ret = mkdir_p (rundir, 0777, _gf_true); + if ((ret == -1) && (EEXIST != errno)) { + gf_msg (THIS->name, GF_LOG_ERROR, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create rundir %s", +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index f374f94..ab68f71 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -3802,6 +3802,13 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + (void) glusterd_delete_stale_volume (old_volinfo, new_volinfo); + } + ++ ret = glusterd_snapdsvc_init (new_volinfo); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to initialize " ++ "snapdsvc for volume %s", new_volinfo->volname); ++ goto out; ++ } ++ + if (glusterd_is_volume_started (new_volinfo)) { + (void) glusterd_start_bricks (new_volinfo); + if (glusterd_is_snapd_enabled (new_volinfo)) { +@@ -3817,13 +3824,6 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + goto out; + } + +- ret = glusterd_snapdsvc_init (new_volinfo); +- if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize " +- "snapdsvc for volume %s", new_volinfo->volname); +- goto out; +- } +- + ret = glusterd_create_volfiles_and_notify_services (new_volinfo); + if (ret) + goto out; +-- +1.7.1 + diff --git a/SOURCES/0133-glusterd-Store-peerinfo-after-updating-hostnames.patch b/SOURCES/0133-glusterd-Store-peerinfo-after-updating-hostnames.patch new file mode 100644 index 0000000..6659e11 --- /dev/null +++ b/SOURCES/0133-glusterd-Store-peerinfo-after-updating-hostnames.patch @@ -0,0 +1,37 @@ +From 2f74e466e5bffedb8e4485a82480d9e1f4a971f1 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Tue, 23 Jun 2015 15:40:59 +0530 +Subject: [PATCH 133/190] glusterd: Store peerinfo after updating hostnames + +BUG: 1234725 +Change-Id: I29c470d0bcb228763e9d08c737c82ab74b0f60ff +Signed-off-by: Kaushal M +Reviewed-upstream-on: http://review.gluster.org/11365 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51547 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 683b402..0923d4b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -2777,7 +2777,13 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + GD_MSG_PEER_INFO_UPDATE_FAIL, + "Failed to " + "update peer %s", peerinfo->hostname); ++ goto unlock; + } ++ ret = glusterd_store_peerinfo (peerinfo); ++ if (ret) ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEERINFO_CREATE_FAIL, ++ "Failed to store peerinfo"); + } + unlock: + rcu_read_unlock (); +-- +1.7.1 + diff --git a/SOURCES/0134-tools-glusterfind-Fail-glusterfind-creation-if-volum.patch b/SOURCES/0134-tools-glusterfind-Fail-glusterfind-creation-if-volum.patch new file mode 100644 index 0000000..bfb448f --- /dev/null +++ b/SOURCES/0134-tools-glusterfind-Fail-glusterfind-creation-if-volum.patch @@ -0,0 +1,89 @@ +From 8679f961d15865230b648f5a2bce832c994f8a29 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Wed, 17 Jun 2015 17:05:22 +0530 +Subject: [PATCH 134/190] tools/glusterfind: Fail glusterfind creation if volume is offline + +Following two fixes are done. + +1. Fail glusterfind session creation if volume is not online + even before session directories are created. This avoids + 'glusterfind list' to pick the session directories and show + status as 'Session Corrupted'. + +2. Check of '!Started' instead of wether the volume is 'Stopped'. + It covers all the cases. + +BUG: 1228598 +Change-Id: Ic4efcda6b620e7044d97a51c59d83103d88e55c8 +Reviewed-on: http://review.gluster.org/11278 +Reviewed-on: http://review.gluster.org/11322 +Reviewed-by: Aravinda VK +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51457 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + tools/glusterfind/src/main.py | 25 +++++++++++++++++-------- + 1 files changed, 17 insertions(+), 8 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 29fa28b..8d32295 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -31,7 +31,7 @@ ParseError = etree.ParseError if hasattr(etree, 'ParseError') else SyntaxError + + logger = logging.getLogger() + node_outfiles = [] +-vol_statusStr = "Stopped" ++vol_statusStr = "" + + + class StoreAbsPath(Action): +@@ -88,8 +88,8 @@ def run_cmd_nodes(task, args, **kwargs): + "tmp_output_%s" % num) + + if task == "pre": +- if vol_statusStr == "Stopped": +- fail("Volume %s is in stopped state" % args.volume, ++ if vol_statusStr != "Started": ++ fail("Volume %s is not online" % args.volume, + logger=logger) + + # If Full backup is requested or start time is zero, use brickfind +@@ -128,8 +128,8 @@ def run_cmd_nodes(task, args, **kwargs): + args.session, + args.volume] + (["--debug"] if args.debug else []) + elif task == "create": +- if vol_statusStr == "Stopped": +- fail("Volume %s is in stopped state" % args.volume, ++ if vol_statusStr != "Started": ++ fail("Volume %s is not online" % args.volume, + logger=logger) + + # When glusterfind create, create session directory in +@@ -324,9 +324,18 @@ def mode_create(session_dir, args): + logger.debug("Init is called - Session: %s, Volume: %s" + % (args.session, args.volume)) + +- execute(["gluster", "volume", "info", args.volume], +- exit_msg="Unable to get volume details", +- logger=logger) ++ cmd = ["gluster", 'volume', 'info', args.volume, "--xml"] ++ _, data, _ = execute(cmd, ++ exit_msg="Failed to Run Gluster Volume Info", ++ logger=logger) ++ try: ++ tree = etree.fromstring(data) ++ statusStr = tree.find('volInfo/volumes/volume/statusStr').text ++ except (ParseError, AttributeError) as e: ++ fail("Invalid Volume: %s" % e, logger=logger) ++ ++ if statusStr != "Started": ++ fail("Volume %s is not online" % args.volume, logger=logger) + + mkdirp(session_dir, exit_on_err=True, logger=logger) + mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True, +-- +1.7.1 + diff --git a/SOURCES/0135-geo-rep-Fix-geo-rep-fanout-setup-with-meta-volume.patch b/SOURCES/0135-geo-rep-Fix-geo-rep-fanout-setup-with-meta-volume.patch new file mode 100644 index 0000000..f154fd5 --- /dev/null +++ b/SOURCES/0135-geo-rep-Fix-geo-rep-fanout-setup-with-meta-volume.patch @@ -0,0 +1,43 @@ +From f37ec5bcb6391ed5b6e3113667d2c6f19eb12fdf Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Tue, 23 Jun 2015 18:28:56 +0530 +Subject: [PATCH 135/190] geo-rep: Fix geo-rep fanout setup with meta volume + +Lock filename was formed with 'master volume id' +and 'subvol number'. Hence multiple slaves try +acquiring lock on same file and become PASSIVE +ending up not syncing data. Using 'slave volume id' +in lock filename will fix the issue making lock +file unique across different slaves. + +BUG: 1234419 +Change-Id: I366fc746f0f745b9a4590bb41839900c0a7b7071 +Reviewed-on: http://review.gluster.org/11367 +Reviewed-on: http://review.gluster.org/11366 +Reviewed-by: Aravinda VK +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51566 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + geo-replication/syncdaemon/master.py | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py +index e05dc37..dc54de3 100644 +--- a/geo-replication/syncdaemon/master.py ++++ b/geo-replication/syncdaemon/master.py +@@ -442,8 +442,8 @@ class GMasterCommon(object): + + def mgmt_lock(self): + """Take management volume lock """ +- bname = str(self.uuid) + "_subvol_" + str(gconf.subvol_num) \ +- + ".lock" ++ bname = str(self.uuid) + "_" + str(gconf.slave_id) + "_subvol_" \ ++ + str(gconf.subvol_num) + ".lock" + mgmt_lock_dir = os.path.join(gconf.meta_volume_mnt, "geo-rep") + path = os.path.join(mgmt_lock_dir, bname) + logging.debug("lock_file_path: %s" % path) +-- +1.7.1 + diff --git a/SOURCES/0136-geo-rep-Fix-toggling-of-use_meta_volume-config.patch b/SOURCES/0136-geo-rep-Fix-toggling-of-use_meta_volume-config.patch new file mode 100644 index 0000000..a0dd70a --- /dev/null +++ b/SOURCES/0136-geo-rep-Fix-toggling-of-use_meta_volume-config.patch @@ -0,0 +1,39 @@ +From 8e0512a12b9eebdc486a2c284ba1374153995c8b Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Tue, 23 Jun 2015 10:38:27 +0530 +Subject: [PATCH 136/190] geo-rep: Fix toggling of use_meta_volume config + +If meta-volume is deleted and use_meta_volume +is set to false, geo-rep still fails complaining +meta volume is not mounted. The patch fixes that +issue. + +BUG: 1233575 +Change-Id: I6d9f0bea33a5b58e238bd8b9f510916ee2108b2e +Reviewed-on: http://review.gluster.org/11358 +Reviewed-on: http://review.gluster.org/11359 +Reviewed-by: Aravinda VK +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51580 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + geo-replication/syncdaemon/master.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py +index dc54de3..6c96a02 100644 +--- a/geo-replication/syncdaemon/master.py ++++ b/geo-replication/syncdaemon/master.py +@@ -476,7 +476,7 @@ class GMasterCommon(object): + return True + + def should_crawl(self): +- if not gconf.use_meta_volume: ++ if not boolify(gconf.use_meta_volume): + return gconf.glusterd_uuid in self.master.server.node_uuid() + + if not os.path.ismount(gconf.meta_volume_mnt): +-- +1.7.1 + diff --git a/SOURCES/0137-geo-rep-Fix-glusterd-working-directory.patch b/SOURCES/0137-geo-rep-Fix-glusterd-working-directory.patch new file mode 100644 index 0000000..e492060 --- /dev/null +++ b/SOURCES/0137-geo-rep-Fix-glusterd-working-directory.patch @@ -0,0 +1,40 @@ +From 596c0ab6b398a911f0093deb7f2cbf4287eb2c35 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Wed, 24 Jun 2015 18:30:18 +0530 +Subject: [PATCH 137/190] geo-rep: Fix glusterd working directory + +Mountbroker setup in geo-replication requires +the script 'set_geo_rep_pem_keys.sh to be +run manually out of gluster context. Hence +the ${GLUSTERD_WORKDIR} is never set. So +getting glusterd working dir using 'gluster +system:: getwd'. + +BUG: 1235225 +Change-Id: I14beb1810b110804714acf714567580d34783690 +Reviewed-on: http://review.gluster.org/11381 +Reviewed-on: http://review.gluster.org/11382 +Reviewed-by: Aravinda VK +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51602 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + geo-replication/src/set_geo_rep_pem_keys.sh | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/geo-replication/src/set_geo_rep_pem_keys.sh b/geo-replication/src/set_geo_rep_pem_keys.sh +index 4f613da..ae23f4f 100755 +--- a/geo-replication/src/set_geo_rep_pem_keys.sh ++++ b/geo-replication/src/set_geo_rep_pem_keys.sh +@@ -12,6 +12,7 @@ function main() + user=$1 + master_vol=$2 + slave_vol=$3 ++ GLUSTERD_WORKDIR=$(gluster system:: getwd) + + if [ "$user" == "" ]; then + echo "Please enter the user's name" +-- +1.7.1 + diff --git a/SOURCES/0138-geo-rep-Fix-ssh-issue-in-geo-rep.patch b/SOURCES/0138-geo-rep-Fix-ssh-issue-in-geo-rep.patch new file mode 100644 index 0000000..6b8d492 --- /dev/null +++ b/SOURCES/0138-geo-rep-Fix-ssh-issue-in-geo-rep.patch @@ -0,0 +1,48 @@ +From f8708968fa4d08f0aa7329d20e68407e7f41af97 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Wed, 24 Jun 2015 20:00:11 +0530 +Subject: [PATCH 138/190] geo-rep: Fix ssh issue in geo-rep + +In geo-rep mountbroker setup, workers fails with +'Permission Denied' even though the public keys +are shared to all the slave nodes. The issue +is with selinux context not being set for .ssh +and .ssh/authorizedkeys. Doing restorecon on +these entries to set default selinux security +context fixes the issue. + +BUG: 1224199 +Change-Id: I272172b78f0d28e7f14420918a2f1206e52a58a7 +Reviewed-on: http://review.gluster.org/11383 +Reviewed-on: http://review.gluster.org/11384 +Reviewed-by: Aravinda VK +Reviewed-by: darshan n +Reviewed-by: Venky Shankar +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51607 +Tested-by: Venky Shankar +--- + extras/peer_add_secret_pub.in | 7 +++++++ + 1 files changed, 7 insertions(+), 0 deletions(-) + +diff --git a/extras/peer_add_secret_pub.in b/extras/peer_add_secret_pub.in +index e3a9aa2..c9674af 100644 +--- a/extras/peer_add_secret_pub.in ++++ b/extras/peer_add_secret_pub.in +@@ -53,6 +53,13 @@ if [ ! -d $authorized_keys_file ]; then + chown $user: $authorized_keys_file; + fi + ++# Restore SELinux security contexts. This is required ++# for passwdless SSH to work. ++ ++if type restorecon >/dev/null 2>&1; then ++ restorecon -F $ssh_dir $authorized_keys_file; ++fi ++ + # Add to authorized_keys file only if not exists already + while read line + do +-- +1.7.1 + diff --git a/SOURCES/0139-cluster-ec-wind-fops-on-good-subvols-for-access-read.patch b/SOURCES/0139-cluster-ec-wind-fops-on-good-subvols-for-access-read.patch new file mode 100644 index 0000000..0f7eeb8 --- /dev/null +++ b/SOURCES/0139-cluster-ec-wind-fops-on-good-subvols-for-access-read.patch @@ -0,0 +1,645 @@ +From 1c94a3d3bd4ac1237d497f03a899ba29590fc37f Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Mon, 15 Jun 2015 16:32:06 +0530 +Subject: [PATCH 139/190] cluster/ec: wind fops on good subvols for access/readdir[p] + + Backport of http://review.gluster.org/11246 + +Change-Id: I1e629a6adc803c4b7164a5a7a81ee5cb1d0e139c +BUG: 1228525 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/51322 +--- + tests/basic/ec/ec-readdir.t | 30 +++++- + xlators/cluster/ec/src/ec-combine.c | 12 +-- + xlators/cluster/ec/src/ec-common.c | 28 ++++- + xlators/cluster/ec/src/ec-common.h | 3 +- + xlators/cluster/ec/src/ec-data.c | 2 + + xlators/cluster/ec/src/ec-data.h | 1 + + xlators/cluster/ec/src/ec-dir-read.c | 207 +++++++++++++++++--------------- + xlators/cluster/ec/src/ec-inode-read.c | 89 +++++++++++---- + 8 files changed, 232 insertions(+), 140 deletions(-) + +diff --git a/tests/basic/ec/ec-readdir.t b/tests/basic/ec/ec-readdir.t +index bbfa2dd..fad101b 100644 +--- a/tests/basic/ec/ec-readdir.t ++++ b/tests/basic/ec/ec-readdir.t +@@ -9,12 +9,38 @@ cleanup + TEST glusterd + TEST pidof glusterd + TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0..5} ++TEST $CLI volume heal $V0 disable + TEST $CLI volume start $V0 + + TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; + EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 1 + +-TEST touch $M0/{1..100} +-EXPECT "100" echo $(ls $M0/* | wc -l) ++TEST mkdir $M0/d ++TEST touch $M0/d/{1..100} ++EXPECT "100" echo $(ls $M0/d/* | wc -l) ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++TEST kill_brick $V0 $H0 $B0/${V0}3 ++TEST rm -rf $M0/d/{1..100} ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 1 ++#Do it 3 times so that even with all load balancing, readdir never falls ++#on stale bricks ++EXPECT "0" echo $(ls $M0/d/ | wc -l) ++EXPECT "0" echo $(ls $M0/d/ | wc -l) ++EXPECT "0" echo $(ls $M0/d/ | wc -l) ++#Do the same test above for creation of entries ++TEST mkdir $M0/d1 ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++TEST kill_brick $V0 $H0 $B0/${V0}3 ++TEST touch $M0/d1/{1..100} ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 1 ++#Do it 3 times so that even with all load balancing, readdir never falls ++#on stale bricks ++EXPECT "100" echo $(ls $M0/d1/ | wc -l) ++EXPECT "100" echo $(ls $M0/d1/ | wc -l) ++EXPECT "100" echo $(ls $M0/d1/ | wc -l) + cleanup +diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c +index a8cfabc..bf698d9 100644 +--- a/xlators/cluster/ec/src/ec-combine.c ++++ b/xlators/cluster/ec/src/ec-combine.c +@@ -875,7 +875,7 @@ void ec_combine (ec_cbk_data_t *newcbk, ec_combine_f combine) + ec_fop_data_t *fop = newcbk->fop; + ec_cbk_data_t *cbk = NULL, *tmp = NULL; + struct list_head *item = NULL; +- int32_t needed = 0, resume = 0; ++ int32_t needed = 0; + char str[32]; + + LOCK(&fop->lock); +@@ -912,12 +912,6 @@ void ec_combine (ec_cbk_data_t *newcbk, ec_combine_f combine) + ec_trace("ANSWER", fop, "combine=%s[%d]", + ec_bin(str, sizeof(str), newcbk->mask, 0), newcbk->count); + +- if ((newcbk->count == fop->expected) && (fop->answer == NULL)) { +- fop->answer = newcbk; +- +- resume = 1; +- } +- + cbk = list_entry(fop->cbk_list.next, ec_cbk_data_t, list); + if ((fop->mask ^ fop->remaining) == fop->received) { + needed = fop->minimum - cbk->count; +@@ -927,9 +921,5 @@ void ec_combine (ec_cbk_data_t *newcbk, ec_combine_f combine) + + if (needed > 0) { + ec_dispatch_next(fop, newcbk->idx); +- } else if (resume) { +- ec_update_bad(fop, newcbk->mask); +- +- ec_resume(fop, 0); + } + } +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index f69234e..4dbbe28 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -186,6 +186,10 @@ void ec_update_bad(ec_fop_data_t * fop, uintptr_t good) + ec_t *ec = fop->xl->private; + uintptr_t bad; + ++ /*Don't let fops that do dispatch_one() to update bad*/ ++ if (fop->expected == 1) ++ return; ++ + bad = ec->xl_up & ~(fop->remaining | good); + fop->bad |= bad; + fop->good |= good; +@@ -314,6 +318,20 @@ void ec_resume_parent(ec_fop_data_t * fop, int32_t error) + } + } + ++gf_boolean_t ++ec_is_recoverable_error (int32_t op_errno) ++{ ++ switch (op_errno) { ++ case ENOTCONN: ++ case ESTALE: ++ case ENOENT: ++ case EBADFD:/*Opened fd but brick is disconnected*/ ++ case EIO:/*Backend-fs crash like XFS/ext4 etc*/ ++ return _gf_true; ++ } ++ return _gf_false; ++} ++ + void ec_complete(ec_fop_data_t * fop) + { + ec_cbk_data_t * cbk = NULL; +@@ -329,14 +347,12 @@ void ec_complete(ec_fop_data_t * fop) + if (!list_empty(&fop->cbk_list)) { + cbk = list_entry(fop->cbk_list.next, ec_cbk_data_t, list); + healing_count = ec_bits_count (cbk->mask & fop->healing); ++ /* fop shouldn't be treated as success if it is not ++ * successful on at least fop->minimum good copies*/ + if ((cbk->count - healing_count) >= fop->minimum) { +- /* fop shouldn't be treated as success if it is not +- * successful on at least fop->minimum good copies*/ +- if ((cbk->op_ret >= 0) || (cbk->op_errno != ENOTCONN)) { +- fop->answer = cbk; ++ fop->answer = cbk; + +- update = 1; +- } ++ update = 1; + } + } + +diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h +index e3f01ca..3334a7b 100644 +--- a/xlators/cluster/ec/src/ec-common.h ++++ b/xlators/cluster/ec/src/ec-common.h +@@ -75,7 +75,7 @@ typedef enum { + #define EC_STATE_HEAL_POST_INODELK_UNLOCK 217 + #define EC_STATE_HEAL_DISPATCH 218 + +-int32_t ec_dispatch_one_retry(ec_fop_data_t *fop, int32_t idx, int32_t op_ret); ++int32_t ec_dispatch_one_retry (ec_fop_data_t *fop, int32_t idx, int32_t op_ret); + int32_t ec_dispatch_next(ec_fop_data_t * fop, int32_t idx); + + void ec_complete(ec_fop_data_t * fop); +@@ -111,5 +111,6 @@ void ec_resume(ec_fop_data_t * fop, int32_t error); + void ec_resume_parent(ec_fop_data_t * fop, int32_t error); + + void ec_manager(ec_fop_data_t * fop, int32_t error); ++gf_boolean_t ec_is_recoverable_error (int32_t op_errno); + + #endif /* __EC_COMMON_H__ */ +diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c +index 047ccd5..72f3b0b 100644 +--- a/xlators/cluster/ec/src/ec-data.c ++++ b/xlators/cluster/ec/src/ec-data.c +@@ -59,6 +59,7 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, + cbk->count = 1; + cbk->op_ret = op_ret; + cbk->op_errno = op_errno; ++ INIT_LIST_HEAD (&cbk->entries.list); + + LOCK(&fop->lock); + +@@ -92,6 +93,7 @@ void ec_cbk_data_destroy(ec_cbk_data_t * cbk) + iobref_unref(cbk->buffers); + } + GF_FREE(cbk->vector); ++ gf_dirent_free (&cbk->entries); + + mem_put(cbk); + } +diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h +index 8f6d5de..670b3b8 100644 +--- a/xlators/cluster/ec/src/ec-data.h ++++ b/xlators/cluster/ec/src/ec-data.h +@@ -266,6 +266,7 @@ struct _ec_cbk_data + struct iovec * vector; + struct iobref * buffers; + uint64_t dirty[2]; ++ gf_dirent_t entries; + }; + + struct _ec_heal +diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c +index 7821878..69df4d2 100644 +--- a/xlators/cluster/ec/src/ec-dir-read.c ++++ b/xlators/cluster/ec/src/ec-dir-read.c +@@ -316,34 +316,36 @@ out: + + /* FOP: readdir */ + +-void ec_adjust_readdir(ec_t * ec, int32_t idx, gf_dirent_t * entries) ++void ec_adjust_readdirp (ec_t *ec, int32_t idx, gf_dirent_t *entries) + { + gf_dirent_t * entry; + + list_for_each_entry(entry, &entries->list, list) + { ++ if (!entry->inode) ++ continue; ++ + if (entry->d_stat.ia_type == IA_IFREG) + { + if ((entry->dict == NULL) || + (ec_dict_del_number(entry->dict, EC_XATTR_SIZE, +- &entry->d_stat.ia_size) != 0)) +- { +- gf_log(ec->xl->name, GF_LOG_WARNING, "Unable to get exact " +- "file size."); +- +- entry->d_stat.ia_size *= ec->fragments; ++ &entry->d_stat.ia_size) != 0)) { ++ inode_unref (entry->inode); ++ entry->inode = NULL; ++ } else { ++ ec_iatt_rebuild(ec, &entry->d_stat, 1, 1); + } +- +- ec_iatt_rebuild(ec, &entry->d_stat, 1, 1); + } + } + } + +-int32_t ec_readdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, +- int32_t op_ret, int32_t op_errno, gf_dirent_t * entries, +- dict_t * xdata) ++int32_t ++ec_common_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, ++ gf_dirent_t *entries, dict_t *xdata) + { +- ec_fop_data_t * fop = NULL; ++ ec_fop_data_t *fop = NULL; ++ ec_cbk_data_t *cbk = NULL; + int32_t idx = (int32_t)(uintptr_t)cookie; + + VALIDATE_OR_GOTO(this, out); +@@ -356,18 +358,15 @@ int32_t ec_readdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_trace("CBK", fop, "idx=%d, frame=%p, op_ret=%d, op_errno=%d", idx, + frame, op_ret, op_errno); + +- if (op_ret > 0) +- { +- ec_adjust_readdir(fop->xl->private, idx, entries); +- } +- +- if (!ec_dispatch_one_retry(fop, idx, op_ret)) +- { +- if (fop->cbks.readdir != NULL) +- { +- fop->cbks.readdir(fop->req_frame, fop, this, op_ret, op_errno, +- entries, xdata); +- } ++ cbk = ec_cbk_data_allocate (frame, this, fop, fop->id, ++ idx, op_ret, op_errno); ++ if (cbk) { ++ if (xdata) ++ cbk->xdata = dict_ref (xdata); ++ if (cbk->op_ret >= 0) ++ list_splice_init (&entries->list, ++ &cbk->entries.list); ++ ec_combine (cbk, NULL); + } + + out: +@@ -383,14 +382,15 @@ void ec_wind_readdir(ec_t * ec, ec_fop_data_t * fop, int32_t idx) + { + ec_trace("WIND", fop, "idx=%d", idx); + +- STACK_WIND_COOKIE(fop->frame, ec_readdir_cbk, (void *)(uintptr_t)idx, ++ STACK_WIND_COOKIE(fop->frame, ec_common_readdir_cbk, (void *)(uintptr_t)idx, + ec->xl_list[idx], ec->xl_list[idx]->fops->readdir, + fop->fd, fop->size, fop->offset, fop->xdata); + } + + int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + { +- ec_fd_t *ctx; ++ ec_fd_t *ctx = NULL; ++ ec_cbk_data_t *cbk = NULL; + + switch (state) + { +@@ -404,27 +404,21 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_REPORT; + } + +- if (fop->xdata == NULL) +- { +- fop->xdata = dict_new(); +- if (fop->xdata == NULL) +- { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare " +- "readdirp request"); +- +- fop->error = EIO; ++ if (fop->id == GF_FOP_READDIRP) { ++ if (fop->xdata == NULL) { ++ fop->xdata = dict_new(); ++ if (fop->xdata == NULL) { ++ fop->error = EIO; + +- return EC_STATE_REPORT; +- } +- } +- if (dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0) != 0) +- { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare " +- "readdirp request"); ++ return EC_STATE_REPORT; ++ } ++ } + +- fop->error = EIO; ++ if (dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0)) { ++ fop->error = EIO; + +- return EC_STATE_REPORT; ++ return EC_STATE_REPORT; ++ } + } + + if (fop->offset != 0) +@@ -440,37 +434,92 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_REPORT; + } + fop->mask &= 1ULL << idx; ++ } else { ++ ec_lock_prepare_fd(fop, fop->fd, EC_QUERY_INFO); ++ ec_lock(fop); + } + +- /* Fall through */ ++ return EC_STATE_DISPATCH; + + case EC_STATE_DISPATCH: + ec_dispatch_one(fop); + ++ return EC_STATE_PREPARE_ANSWER; ++ ++ case EC_STATE_PREPARE_ANSWER: ++ cbk = fop->answer; ++ if (cbk) { ++ if ((cbk->op_ret < 0) && ++ ec_is_recoverable_error (cbk->op_errno)) { ++ GF_ASSERT (fop->mask & (1ULL<idx)); ++ fop->mask ^= (1ULL << cbk->idx); ++ if (fop->mask == 0) ++ return EC_STATE_REPORT; ++ return EC_STATE_DISPATCH; ++ } ++ if ((cbk->op_ret > 0) && (fop->id == GF_FOP_READDIRP)) { ++ ec_adjust_readdirp (fop->xl->private, cbk->idx, ++ &cbk->entries); ++ } ++ } else { ++ ec_fop_set_error(fop, EIO); ++ } + return EC_STATE_REPORT; + ++ case EC_STATE_REPORT: ++ cbk = fop->answer; ++ GF_ASSERT (cbk); ++ if (fop->id == GF_FOP_READDIR) { ++ if (fop->cbks.readdir != NULL) { ++ fop->cbks.readdir(fop->req_frame, fop, fop->xl, cbk->op_ret, ++ cbk->op_errno, &cbk->entries, cbk->xdata); ++ } ++ } else { ++ if (fop->cbks.readdirp != NULL) { ++ fop->cbks.readdirp(fop->req_frame, fop, fop->xl, ++ cbk->op_ret, cbk->op_errno, ++ &cbk->entries, cbk->xdata); ++ } ++ } ++ if (fop->offset == 0) ++ return EC_STATE_LOCK_REUSE; ++ else ++ return EC_STATE_END; ++ + case -EC_STATE_INIT: +- if (fop->id == GF_FOP_READDIR) +- { +- if (fop->cbks.readdir != NULL) +- { ++ case -EC_STATE_LOCK: ++ case -EC_STATE_DISPATCH: ++ case -EC_STATE_PREPARE_ANSWER: ++ case -EC_STATE_REPORT: ++ if (fop->id == GF_FOP_READDIR) { ++ if (fop->cbks.readdir != NULL) { + fop->cbks.readdir(fop->req_frame, fop, fop->xl, -1, + fop->error, NULL, NULL); + } +- } +- else +- { +- if (fop->cbks.readdirp != NULL) +- { ++ } else { ++ if (fop->cbks.readdirp != NULL) { + fop->cbks.readdirp(fop->req_frame, fop, fop->xl, -1, + fop->error, NULL, NULL); + } + } ++ if (fop->offset == 0) ++ return EC_STATE_LOCK_REUSE; ++ else ++ return EC_STATE_END; + +- case EC_STATE_REPORT: +- case -EC_STATE_REPORT: +- return EC_STATE_END; ++ case -EC_STATE_LOCK_REUSE: ++ case EC_STATE_LOCK_REUSE: ++ GF_ASSERT (fop->offset == 0); ++ ec_lock_reuse(fop); ++ ++ return EC_STATE_UNLOCK; + ++ case -EC_STATE_UNLOCK: ++ case EC_STATE_UNLOCK: ++ GF_ASSERT (fop->offset == 0); ++ ec_unlock(fop); ++ ++ return EC_STATE_END; + default: + gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); +@@ -544,51 +593,11 @@ out: + + /* FOP: readdirp */ + +-int32_t ec_readdirp_cbk(call_frame_t * frame, void * cookie, xlator_t * this, +- int32_t op_ret, int32_t op_errno, +- gf_dirent_t * entries, dict_t * xdata) +-{ +- ec_fop_data_t * fop = NULL; +- int32_t idx = (int32_t)(uintptr_t)cookie; +- +- VALIDATE_OR_GOTO(this, out); +- GF_VALIDATE_OR_GOTO(this->name, frame, out); +- GF_VALIDATE_OR_GOTO(this->name, frame->local, out); +- GF_VALIDATE_OR_GOTO(this->name, this->private, out); +- +- fop = frame->local; +- +- ec_trace("CBK", fop, "idx=%d, frame=%p, op_ret=%d, op_errno=%d", idx, +- frame, op_ret, op_errno); +- +- if (op_ret > 0) +- { +- ec_adjust_readdir(fop->xl->private, idx, entries); +- } +- +- if (!ec_dispatch_one_retry(fop, idx, op_ret)) +- { +- if (fop->cbks.readdirp != NULL) +- { +- fop->cbks.readdirp(fop->req_frame, fop, this, op_ret, op_errno, +- entries, xdata); +- } +- } +- +-out: +- if (fop != NULL) +- { +- ec_complete(fop); +- } +- +- return 0; +-} +- + void ec_wind_readdirp(ec_t * ec, ec_fop_data_t * fop, int32_t idx) + { + ec_trace("WIND", fop, "idx=%d", idx); + +- STACK_WIND_COOKIE(fop->frame, ec_readdirp_cbk, (void *)(uintptr_t)idx, ++ STACK_WIND_COOKIE(fop->frame, ec_common_readdir_cbk, (void *)(uintptr_t)idx, + ec->xl_list[idx], ec->xl_list[idx]->fops->readdirp, + fop->fd, fop->size, fop->offset, fop->xdata); + } +diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c +index ef2170f..1f91391 100644 +--- a/xlators/cluster/ec/src/ec-inode-read.c ++++ b/xlators/cluster/ec/src/ec-inode-read.c +@@ -22,7 +22,8 @@ + int32_t ec_access_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + int32_t op_ret, int32_t op_errno, dict_t * xdata) + { +- ec_fop_data_t * fop = NULL; ++ ec_fop_data_t *fop = NULL; ++ ec_cbk_data_t *cbk = NULL; + int32_t idx = (int32_t)(uintptr_t)cookie; + + VALIDATE_OR_GOTO(this, out); +@@ -35,19 +36,18 @@ int32_t ec_access_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + ec_trace("CBK", fop, "idx=%d, frame=%p, op_ret=%d, op_errno=%d", idx, + frame, op_ret, op_errno); + +- if (!ec_dispatch_one_retry(fop, idx, op_ret)) +- { +- if (fop->cbks.access != NULL) +- { +- fop->cbks.access(fop->req_frame, fop, this, op_ret, op_errno, +- xdata); +- } ++ cbk = ec_cbk_data_allocate (frame, this, fop, GF_FOP_ACCESS, ++ idx, op_ret, op_errno); ++ if (cbk) { ++ if (xdata) ++ cbk->xdata = dict_ref (xdata); ++ ec_combine (cbk, NULL); + } + + out: + if (fop != NULL) + { +- ec_complete(fop); ++ ec_complete (fop); + } + + return 0; +@@ -62,25 +62,72 @@ void ec_wind_access(ec_t * ec, ec_fop_data_t * fop, int32_t idx) + &fop->loc[0], fop->int32, fop->xdata); + } + +-int32_t ec_manager_access(ec_fop_data_t * fop, int32_t state) ++int32_t ++ec_manager_access(ec_fop_data_t *fop, int32_t state) + { +- switch (state) +- { ++ ec_cbk_data_t *cbk = NULL; ++ ++ switch (state) { + case EC_STATE_INIT: ++ case EC_STATE_LOCK: ++ ec_lock_prepare_inode (fop, &fop->loc[0], EC_QUERY_INFO); ++ ec_lock (fop); ++ ++ return EC_STATE_DISPATCH; ++ + case EC_STATE_DISPATCH: +- ec_dispatch_one(fop); ++ ec_dispatch_one (fop); + ++ return EC_STATE_PREPARE_ANSWER; ++ ++ case EC_STATE_PREPARE_ANSWER: ++ cbk = fop->answer; ++ if (cbk) { ++ if ((cbk->op_ret < 0) && ec_is_recoverable_error (cbk->op_errno)) { ++ GF_ASSERT (fop->mask & (1ULL<idx)); ++ fop->mask ^= (1ULL << cbk->idx); ++ if (fop->mask == 0) ++ return EC_STATE_REPORT; ++ return EC_STATE_DISPATCH; ++ } ++ } else { ++ ec_fop_set_error(fop, EIO); ++ } + return EC_STATE_REPORT; + +- case -EC_STATE_INIT: +- if (fop->cbks.access != NULL) +- { +- fop->cbks.access(fop->req_frame, fop, fop->xl, -1, fop->error, +- NULL); ++ case EC_STATE_REPORT: ++ cbk = fop->answer; ++ GF_ASSERT (cbk); ++ if (fop->cbks.access != NULL) { ++ if (cbk) { ++ fop->cbks.access(fop->req_frame, fop, fop->xl, ++ cbk->op_ret, cbk->op_errno, ++ cbk->xdata); ++ } + } ++ return EC_STATE_LOCK_REUSE; + ++ case -EC_STATE_INIT: ++ case -EC_STATE_LOCK: ++ case -EC_STATE_DISPATCH: ++ case -EC_STATE_PREPARE_ANSWER: + case -EC_STATE_REPORT: +- case EC_STATE_REPORT: ++ if (fop->cbks.access != NULL) { ++ fop->cbks.access(fop->req_frame, fop, fop->xl, -1, ++ fop->error, NULL); ++ } ++ return -EC_STATE_LOCK_REUSE; ++ ++ case -EC_STATE_LOCK_REUSE: ++ case EC_STATE_LOCK_REUSE: ++ ec_lock_reuse(fop); ++ ++ return EC_STATE_UNLOCK; ++ ++ case -EC_STATE_UNLOCK: ++ case EC_STATE_UNLOCK: ++ ec_unlock(fop); ++ + return EC_STATE_END; + + default: +@@ -88,7 +135,7 @@ int32_t ec_manager_access(ec_fop_data_t * fop, int32_t state) + state, ec_fop_name(fop->id)); + + return EC_STATE_END; +- } ++ } + } + + void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, +-- +1.7.1 + diff --git a/SOURCES/0140-cluster-afr-Pick-gfid-from-poststat-during-fresh-loo.patch b/SOURCES/0140-cluster-afr-Pick-gfid-from-poststat-during-fresh-loo.patch new file mode 100644 index 0000000..24d5a08 --- /dev/null +++ b/SOURCES/0140-cluster-afr-Pick-gfid-from-poststat-during-fresh-loo.patch @@ -0,0 +1,384 @@ +From 56092f9ab16a7606e549e0aba84a78ed6de0d397 Mon Sep 17 00:00:00 2001 +From: Krutika Dhananjay +Date: Wed, 24 Jun 2015 08:02:51 +0530 +Subject: [PATCH 140/190] cluster/afr: Pick gfid from poststat during fresh lookup for read child calculation + + Backport of: http://review.gluster.org/11373 + +Change-Id: I669f7c7d02e1dbd276f3d4c9c7bd8c575517e1b7 +BUG: 1223757 +Signed-off-by: Krutika Dhananjay +Reviewed-on: https://code.engineering.redhat.com/gerrit/51654 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/inode.c | 22 +++++++++ + libglusterfs/src/inode.h | 3 + + xlators/cluster/afr/src/afr-common.c | 68 +++++++++++++++++----------- + xlators/cluster/afr/src/afr-dir-read.c | 7 +++- + xlators/cluster/afr/src/afr-dir-write.c | 6 +- + xlators/cluster/afr/src/afr-inode-write.c | 5 +- + xlators/cluster/afr/src/afr-read-txn.c | 4 +- + xlators/cluster/afr/src/afr.h | 19 ++++++--- + 8 files changed, 93 insertions(+), 41 deletions(-) + +diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c +index 7c54865..7d3215e 100644 +--- a/libglusterfs/src/inode.c ++++ b/libglusterfs/src/inode.c +@@ -2126,6 +2126,28 @@ inode_ctx_reset0 (inode_t *inode, xlator_t *xlator, uint64_t *value1_p) + return ret; + } + ++int ++inode_is_linked (inode_t *inode) ++{ ++ int ret = 0; ++ inode_table_t *table = NULL; ++ ++ if (!inode) { ++ gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ "inode not found"); ++ return 0; ++ } ++ ++ table = inode->table; ++ ++ pthread_mutex_lock (&table->lock); ++ { ++ ret = __is_inode_hashed (inode); ++ } ++ pthread_mutex_unlock (&table->lock); ++ ++ return ret; ++} + + void + inode_dump (inode_t *inode, char *prefix) +diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h +index 5081559..474dc39 100644 +--- a/libglusterfs/src/inode.h ++++ b/libglusterfs/src/inode.h +@@ -269,4 +269,7 @@ inode_table_set_lru_limit (inode_table_t *table, uint32_t lru_limit); + void + inode_ctx_merge (fd_t *fd, inode_t *inode, inode_t *linked_inode); + ++int ++inode_is_linked (inode_t *inode); ++ + #endif /* _INODE_H */ +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 410d31d..7150f0f 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -987,7 +987,7 @@ out: + + + int +-afr_hash_child (inode_t *inode, int32_t child_count, int hashmode) ++afr_hash_child (afr_read_subvol_args_t *args, int32_t child_count, int hashmode) + { + uuid_t gfid_copy = {0,}; + pid_t pid; +@@ -996,11 +996,9 @@ afr_hash_child (inode_t *inode, int32_t child_count, int hashmode) + return -1; + } + +- if (inode) { +- gf_uuid_copy (gfid_copy, inode->gfid); +- } ++ gf_uuid_copy (gfid_copy, args->gfid); + +- if (hashmode > 1 && inode->ia_type != IA_IFDIR) { ++ if ((hashmode > 1) && (args->ia_type != IA_IFDIR)) { + /* + * Why getpid? Because it's one of the cheapest calls + * available - faster than gethostname etc. - and returns a +@@ -1021,32 +1019,41 @@ afr_hash_child (inode_t *inode, int32_t child_count, int hashmode) + + int + afr_read_subvol_select_by_policy (inode_t *inode, xlator_t *this, +- unsigned char *readable) ++ unsigned char *readable, ++ afr_read_subvol_args_t *args) + { +- afr_private_t *priv = NULL; +- int read_subvol = -1; +- int i = 0; ++ int i = 0; ++ int read_subvol = -1; ++ afr_private_t *priv = NULL; ++ afr_read_subvol_args_t local_args = {0,}; + + priv = this->private; + + /* first preference - explicitly specified or local subvolume */ + if (priv->read_child >= 0 && readable[priv->read_child]) +- return priv->read_child; ++ return priv->read_child; ++ ++ if (inode_is_linked (inode)) { ++ gf_uuid_copy (local_args.gfid, inode->gfid); ++ local_args.ia_type = inode->ia_type; ++ } else if (args) { ++ local_args = *args; ++ } + + /* second preference - use hashed mode */ +- read_subvol = afr_hash_child (inode, priv->child_count, +- priv->hash_mode); ++ read_subvol = afr_hash_child (&local_args, priv->child_count, ++ priv->hash_mode); + if (read_subvol >= 0 && readable[read_subvol]) +- return read_subvol; ++ return read_subvol; + + for (i = 0; i < priv->child_count; i++) { +- if (readable[i]) +- return i; ++ if (readable[i]) ++ return i; + } + +- /* no readable subvolumes, either split brain or all subvols down */ ++ /* no readable subvolumes, either split brain or all subvols down */ + +- return -1; ++ return -1; + } + + +@@ -1069,7 +1076,8 @@ afr_inode_read_subvol_type_get (inode_t *inode, xlator_t *this, + + int + afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, +- int *event_p, afr_transaction_type type) ++ int *event_p, afr_transaction_type type, ++ afr_read_subvol_args_t *args) + { + afr_private_t *priv = NULL; + unsigned char *data_readable = NULL; +@@ -1096,10 +1104,10 @@ afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, + + if (AFR_COUNT (intersection, priv->child_count) > 0) + subvol = afr_read_subvol_select_by_policy (inode, this, +- intersection); ++ intersection, args); + else + subvol = afr_read_subvol_select_by_policy (inode, this, +- readable); ++ readable, args); + if (subvol_p) + *subvol_p = subvol; + if (event_p) +@@ -1413,7 +1421,8 @@ afr_get_parent_read_subvol (xlator_t *this, inode_t *parent, + priv = this->private; + + if (parent) +- par_read_subvol = afr_data_subvol_get (parent, this, 0, 0); ++ par_read_subvol = afr_data_subvol_get (parent, this, 0, 0, ++ NULL); + + for (i = 0; i < priv->child_count; i++) { + if (!replies[i].valid) +@@ -1462,6 +1471,8 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) + gf_boolean_t can_interpret = _gf_true; + inode_t *parent = NULL; + int spb_choice = -1; ++ ia_type_t ia_type = IA_INVAL; ++ afr_read_subvol_args_t args = {0,}; + + priv = this->private; + local = frame->local; +@@ -1509,6 +1520,7 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) + if (read_subvol == -1 || !readable[read_subvol]) { + read_subvol = i; + gf_uuid_copy (read_gfid, replies[i].poststat.ia_gfid); ++ ia_type = replies[i].poststat.ia_type; + local->op_ret = 0; + } + } +@@ -1554,14 +1566,16 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) + a response from all the UP subvolumes and all of them resolved + to the same GFID + */ ++ gf_uuid_copy (args.gfid, read_gfid); ++ args.ia_type = ia_type; + if (afr_replies_interpret (frame, this, local->inode)) { + read_subvol = afr_data_subvol_get (local->inode, this, +- 0, 0); ++ 0, 0, &args); + afr_inode_read_subvol_reset (local->inode, this); + goto cant_interpret; + } else { + read_subvol = afr_data_subvol_get (local->inode, this, +- 0, 0); ++ 0, 0, &args); + } + } else { + cant_interpret: +@@ -1979,7 +1993,7 @@ afr_discover_done (call_frame_t *frame, xlator_t *this) + + afr_replies_interpret (frame, this, local->inode); + +- read_subvol = afr_data_subvol_get (local->inode, this, 0, 0); ++ read_subvol = afr_data_subvol_get (local->inode, this, 0, 0, NULL); + if (read_subvol == -1) { + gf_log (this->name, GF_LOG_WARNING, "no read subvols for %s", + local->loc.path); +@@ -2142,7 +2156,7 @@ afr_discover (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req + } + + afr_read_subvol_get (loc->inode, this, NULL, &event, +- AFR_DATA_TRANSACTION); ++ AFR_DATA_TRANSACTION, NULL); + + if (event != local->event_generation) + afr_inode_refresh (frame, this, loc->inode, afr_discover_do); +@@ -2288,7 +2302,7 @@ afr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) + } + + afr_read_subvol_get (loc->parent, this, NULL, &event, +- AFR_DATA_TRANSACTION); ++ AFR_DATA_TRANSACTION, NULL); + + if (event != local->event_generation) + afr_inode_refresh (frame, this, loc->parent, afr_lookup_do); +@@ -2608,7 +2622,7 @@ afr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + local = frame->local; + +- read_subvol = afr_data_subvol_get (local->inode, this, 0, 0); ++ read_subvol = afr_data_subvol_get (local->inode, this, 0, 0, NULL); + + LOCK (&frame->lock); + { +diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c +index 984ed9c..11f583e 100644 +--- a/xlators/cluster/afr/src/afr-dir-read.c ++++ b/xlators/cluster/afr/src/afr-dir-read.c +@@ -153,7 +153,12 @@ afr_validate_read_subvol (inode_t *inode, xlator_t *this, int par_read_subvol) + if (!priv->consistent_metadata) + return 0; + +- entry_read_subvol = afr_data_subvol_get (inode, this, 0, 0); ++ /* For an inode fetched through readdirp which is yet to be linked, ++ * inode ctx would not be initialised (yet). So this function returns ++ * -1 above due to gen being 0, which is why it is OK to pass NULL for ++ * read_subvol_args here. ++ */ ++ entry_read_subvol = afr_data_subvol_get (inode, this, 0, 0, NULL); + if (entry_read_subvol != par_read_subvol) + return -1; + +diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c +index 8a2c0e4..2891f36 100644 +--- a/xlators/cluster/afr/src/afr-dir-write.c ++++ b/xlators/cluster/afr/src/afr-dir-write.c +@@ -95,14 +95,14 @@ __afr_dir_write_finalize (call_frame_t *frame, xlator_t *this) + if (local->inode) { + afr_replies_interpret (frame, this, local->inode); + inode_read_subvol = afr_data_subvol_get (local->inode, this, +- NULL, NULL); ++ NULL, NULL, NULL); + } + if (local->parent) + parent_read_subvol = afr_data_subvol_get (local->parent, this, +- NULL, NULL); ++ NULL, NULL, NULL); + if (local->parent2) + parent2_read_subvol = afr_data_subvol_get (local->parent2, this, +- NULL, NULL); ++ NULL, NULL, NULL); + + local->op_ret = -1; + local->op_errno = afr_final_errno (local, priv); +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index ecd2b9d..5d32927 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -53,10 +53,11 @@ __afr_inode_write_finalize (call_frame_t *frame, xlator_t *this) + if (local->inode) { + if (local->transaction.type == AFR_METADATA_TRANSACTION) + read_subvol = afr_metadata_subvol_get (local->inode, this, +- NULL, NULL); ++ NULL, NULL, ++ NULL); + else + read_subvol = afr_data_subvol_get (local->inode, this, +- NULL, NULL); ++ NULL, NULL, NULL); + } + + local->op_ret = -1; +diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c +index 0ec1d91..6121108 100644 +--- a/xlators/cluster/afr/src/afr-read-txn.c ++++ b/xlators/cluster/afr/src/afr-read-txn.c +@@ -90,7 +90,7 @@ afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err) + memcpy (local->readable, local->child_up, priv->child_count); + + read_subvol = afr_read_subvol_select_by_policy (inode, this, +- local->readable); ++ local->readable, NULL); + if (read_subvol == -1) + AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, EIO, -1, readfn); + +@@ -232,7 +232,7 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + goto refresh; + + read_subvol = afr_read_subvol_select_by_policy (inode, this, +- local->readable); ++ local->readable, NULL); + + if (read_subvol < 0 || read_subvol > priv->child_count) { + gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_SPLIT_BRAIN, +diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h +index 855d3a3..e6e7f3e 100644 +--- a/xlators/cluster/afr/src/afr.h ++++ b/xlators/cluster/afr/src/afr.h +@@ -755,6 +755,11 @@ typedef struct afr_spbc_timeout { + int spb_child_index; + } afr_spbc_timeout_t; + ++typedef struct afr_read_subvol_args { ++ ia_type_t ia_type; ++ uuid_t gfid; ++} afr_read_subvol_args_t; ++ + /* did a call fail due to a child failing? */ + #define child_went_down(op_ret, op_errno) (((op_ret) < 0) && \ + ((op_errno == ENOTCONN) || \ +@@ -787,7 +792,8 @@ afr_inode_read_subvol_reset (inode_t *inode, xlator_t *this); + + int + afr_read_subvol_select_by_policy (inode_t *inode, xlator_t *this, +- unsigned char *readable); ++ unsigned char *readable, ++ afr_read_subvol_args_t *args); + + int + afr_inode_read_subvol_type_get (inode_t *inode, xlator_t *this, +@@ -795,13 +801,14 @@ afr_inode_read_subvol_type_get (inode_t *inode, xlator_t *this, + int type); + int + afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, +- int *event_p, afr_transaction_type type); ++ int *event_p, afr_transaction_type type, ++ afr_read_subvol_args_t *args); + +-#define afr_data_subvol_get(i, t, s, e) \ +- afr_read_subvol_get(i, t, s, e, AFR_DATA_TRANSACTION) ++#define afr_data_subvol_get(i, t, s, e, a) \ ++ afr_read_subvol_get(i, t, s, e, AFR_DATA_TRANSACTION, a) + +-#define afr_metadata_subvol_get(i, t, s, e) \ +- afr_read_subvol_get(i, t, s, e, AFR_METADATA_TRANSACTION) ++#define afr_metadata_subvol_get(i, t, s, e, a) \ ++ afr_read_subvol_get(i, t, s, e, AFR_METADATA_TRANSACTION, a) + + int + afr_inode_refresh (call_frame_t *frame, xlator_t *this, inode_t *inode, +-- +1.7.1 + diff --git a/SOURCES/0141-protocol-client-removing-duplicate-printing-in-gf_ms.patch b/SOURCES/0141-protocol-client-removing-duplicate-printing-in-gf_ms.patch new file mode 100644 index 0000000..cbacc4e --- /dev/null +++ b/SOURCES/0141-protocol-client-removing-duplicate-printing-in-gf_ms.patch @@ -0,0 +1,687 @@ +From d65ecec648d5681044c01279f62c11925e752c87 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Wed, 17 Jun 2015 18:42:06 +0530 +Subject: [PATCH 141/190] protocol/client : removing duplicate printing in gf_msg + +Since the 3rd and 5th argument of gf_msg framework +prints the error string in case of strerror(), +5th argument is removed. + +Change-Id: Ib1794ea2d4cb5c46a39311f0afcfd7e494540506 +BUG: 1231775 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: https://code.engineering.redhat.com/gerrit/51100 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/protocol/client/src/client-handshake.c | 23 +- + xlators/protocol/client/src/client-rpc-fops.c | 258 ++++++++++++------------ + 2 files changed, 139 insertions(+), 142 deletions(-) + +diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c +index 457fa25..d45bf95 100644 +--- a/xlators/protocol/client/src/client-handshake.c ++++ b/xlators/protocol/client/src/client-handshake.c +@@ -719,9 +719,9 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + + if (rsp.op_ret < 0) { +- gf_msg (frame->this->name, GF_LOG_WARNING, 0, +- PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed (%s)", +- local->loc.path, strerror (rsp.op_errno)); ++ gf_msg (frame->this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed.", ++ local->loc.path); + } else { + gf_msg_debug (frame->this->name, 0, + "reopen on %s succeeded (remote-fd = %"PRId64")", +@@ -811,9 +811,9 @@ client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + } + + if (rsp.op_ret < 0) { +- gf_msg (frame->this->name, GF_LOG_WARNING, 0, +- PC_MSG_DIR_OP_FAILED, "reopendir on %s failed (%s)", +- local->loc.path, strerror (rsp.op_errno)); ++ gf_msg (frame->this->name, GF_LOG_WARNING, rsp.op_errno, ++ PC_MSG_DIR_OP_FAILED, "reopendir on %s failed", ++ local->loc.path); + } else { + gf_msg (frame->this->name, GF_LOG_INFO, 0, + PC_MSG_DIR_OP_SUCCESS, "reopendir on %s succeeded " +@@ -1110,9 +1110,8 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + op_ret = rsp.op_ret; + op_errno = gf_error_to_errno (rsp.op_errno); + if (-1 == rsp.op_ret) { +- gf_msg (frame->this->name, GF_LOG_WARNING, 0, +- PC_MSG_VOL_SET_FAIL, "failed to set the volume (%s)", +- (op_errno)? strerror (op_errno) : "--"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, op_errno, ++ PC_MSG_VOL_SET_FAIL, "failed to set the volume"); + } + + reply = dict_new (); +@@ -1145,9 +1144,9 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m + } + + if (op_ret < 0) { +- gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_SETVOLUME_FAIL, +- "SETVOLUME on remote-host failed: %s", +- remote_error ? remote_error : strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ PC_MSG_SETVOLUME_FAIL, ++ "SETVOLUME on remote-host failed"); + errno = op_errno; + if (remote_error && + (strcmp ("Authentication failed", remote_error) == 0)) { +diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c +index 223a60d..9512087 100644 +--- a/xlators/protocol/client/src/client-rpc-fops.c ++++ b/xlators/protocol/client/src/client-rpc-fops.c +@@ -171,10 +171,10 @@ out: + /* no need to print the gfid, because it will be null, + * since symlink operation failed. + */ +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s. Path: (%s to %s)", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ "remote operation failed. Path: (%s to %s)", + local->loc.path, local->loc2.path); + } + } +@@ -245,9 +245,9 @@ out: + GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { + gf_msg (this->name, fop_log_level (GF_FOP_MKNOD, + gf_error_to_errno (rsp.op_errno)), +- rsp.op_errno, PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s. Path: %s", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed. Path: %s", + local->loc.path); + } + +@@ -314,10 +314,10 @@ out: + if (rsp.op_ret == -1 && + GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { + gf_msg (this->name, fop_log_level (GF_FOP_MKDIR, +- gf_error_to_errno (rsp.op_errno)), rsp.op_errno, ++ gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s. Path: %s", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ "remote operation failed. Path: %s", + local->loc.path); + } + +@@ -460,9 +460,9 @@ out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_OPEN, + gf_error_to_errno (rsp.op_errno)), +- rsp.op_errno, PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s. Path: %s (%s)", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, ++ "remote operation failed. Path: %s (%s)", + local->loc.path, loc_gfid_utoa (&local->loc)); + } + +@@ -525,10 +525,10 @@ out: + strerror (gf_error_to_errno + (rsp.op_errno))); + } else { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + } + +@@ -588,10 +588,10 @@ out: + " %s", strerror + (gf_error_to_errno (rsp.op_errno))); + } else { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s", strerror +- (gf_error_to_errno (rsp.op_errno))); ++ "failed"); + } + } + +@@ -659,10 +659,9 @@ out: + (gf_error_to_errno (rsp.op_errno))); + } else { + gf_msg (this->name, GF_LOG_WARNING, +- rsp.op_errno, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s", strerror +- (gf_error_to_errno (rsp.op_errno))); ++ "failed"); + } + } + +@@ -720,9 +719,9 @@ client3_3_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + } + CLIENT_STACK_UNWIND (rmdir, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &preparent, +@@ -779,10 +778,10 @@ client3_3_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (truncate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -837,10 +836,10 @@ client3_3_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (statfs, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &statfs, xdata); +@@ -899,10 +898,10 @@ client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); +@@ -965,10 +964,9 @@ out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_FLUSH, + gf_error_to_errno (rsp.op_errno)), +- rsp.op_errno, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (flush, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1024,10 +1022,10 @@ client3_3_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fsync, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -1084,7 +1082,7 @@ out: + } else { + gf_msg (this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s", strerror (op_errno)); ++ "failed"); + } + } + +@@ -1157,8 +1155,8 @@ out: + } else { + gf_msg (this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s. Path: %s (%s). Key: %s", +- strerror (op_errno), local->loc.path, ++ "failed. Path: %s (%s). Key: %s", ++ local->loc.path, + loc_gfid_utoa (&local->loc), + (local->name) ? local->name : "(null)"); + } +@@ -1234,7 +1232,7 @@ out: + } else { + gf_msg (this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s", strerror (op_errno)); ++ "failed"); + } + } + +@@ -1294,10 +1292,10 @@ out: + else + loglevel = GF_LOG_WARNING; + +- gf_msg (this->name, loglevel, rsp.op_errno, ++ gf_msg (this->name, loglevel, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + + CLIENT_STACK_UNWIND (removexattr, frame, rsp.op_ret, +@@ -1347,10 +1345,10 @@ client3_3_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fremovexattr, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1398,10 +1396,10 @@ client3_3_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fsyncdir, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1449,10 +1447,10 @@ client3_3_access_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (access, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1508,10 +1506,10 @@ client3_3_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (ftruncate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -1565,10 +1563,10 @@ client3_3_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fstat, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &stat, xdata); +@@ -1618,9 +1616,9 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_INODELK, +- gf_error_to_errno (rsp.op_errno)), rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " +- "%s", strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + } + CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), xdata); +@@ -1670,9 +1668,9 @@ client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_FINODELK, +- gf_error_to_errno (rsp.op_errno)), rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " +- "%s", strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); +@@ -1724,9 +1722,9 @@ client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_ENTRYLK, +- gf_error_to_errno (rsp.op_errno)), rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " +- "%s", strerror (gf_error_to_errno (rsp.op_errno))); ++ gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + } + + CLIENT_STACK_UNWIND (entrylk, frame, rsp.op_ret, +@@ -1776,10 +1774,10 @@ client3_3_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if ((rsp.op_ret == -1) && + (EAGAIN != gf_error_to_errno (rsp.op_errno))) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + + CLIENT_STACK_UNWIND (fentrylk, frame, rsp.op_ret, +@@ -1840,10 +1838,10 @@ client3_3_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " +- "%s. Path: %s (%s)", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed. " ++ "Path: %s (%s)", + local->loc.path, loc_gfid_utoa (&local->loc)); + } + +@@ -1910,10 +1908,10 @@ client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (op_errno))); ++ "remote operation failed"); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); +@@ -1976,7 +1974,7 @@ out: + } else { + gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s", strerror (op_errno)); ++ "failed"); + } + } + +@@ -2032,10 +2030,10 @@ client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fsetattr, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -2091,10 +2089,10 @@ client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -2149,10 +2147,10 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (discard, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -2207,10 +2205,10 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (zerofill, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -2258,10 +2256,10 @@ client3_3_ipc_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (ipc, frame, + rsp.op_ret, gf_error_to_errno (rsp.op_errno), +@@ -2318,10 +2316,10 @@ client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (setattr, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, +@@ -2394,10 +2392,10 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s. Path: %s", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ "remote operation failed. Path: %s", + local->loc.path); + } + +@@ -2450,10 +2448,10 @@ client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (rchecksum, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), +@@ -2532,10 +2530,10 @@ client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if ((rsp.op_ret == -1) && + (EAGAIN != gf_error_to_errno (rsp.op_errno))) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + + CLIENT_STACK_UNWIND (lk, frame, rsp.op_ret, +@@ -2595,11 +2593,11 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s remote_fd = %d", +- strerror (gf_error_to_errno (rsp.op_errno)), +- local->cmd); ++ "remote operation failed: remote_fd = %d", ++ local->cmd); + } + CLIENT_STACK_UNWIND (readdir, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &entries, xdata); +@@ -2662,10 +2660,10 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (readdirp, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &entries, xdata); +@@ -2734,10 +2732,10 @@ client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } + CLIENT_STACK_UNWIND (rename, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), +@@ -2804,10 +2802,10 @@ client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s (%s -> %s)", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ "remote operation failed: (%s -> %s)", + local->loc.path, local->loc2.path); + } + } +@@ -2878,10 +2876,10 @@ client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + out: + if (rsp.op_ret == -1) { + gf_msg (this->name, fop_log_level (GF_FOP_OPENDIR, +- gf_error_to_errno (rsp.op_errno)), rsp.op_errno, +- PC_MSG_REMOTE_OP_FAILED, "remote operation failed: " +- "%s. Path: %s (%s)", +- strerror (gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno)), ++ gf_error_to_errno (rsp.op_errno), ++ PC_MSG_REMOTE_OP_FAILED, "remote operation failed." ++ " Path: %s (%s)", + local->loc.path, loc_gfid_utoa (&local->loc)); + } + CLIENT_STACK_UNWIND (opendir, frame, rsp.op_ret, +@@ -2968,8 +2966,8 @@ out: + !(rsp.op_errno == ESTALE)) + gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, "remote operation " +- "failed: %s. Path: %s (%s)", +- strerror (rsp.op_errno), local->loc.path, ++ "failed. Path: %s (%s)", ++ local->loc.path, + loc_gfid_utoa (&local->loc)); + else + gf_msg_trace (this->name, 0, "not found on remote " +@@ -3043,10 +3041,10 @@ client3_3_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, + + out: + if (rsp.op_ret == -1) { +- gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno, ++ gf_msg (this->name, GF_LOG_WARNING, ++ gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, +- "remote operation failed: %s", +- strerror (gf_error_to_errno (rsp.op_errno))); ++ "remote operation failed"); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); +-- +1.7.1 + diff --git a/SOURCES/0142-EC-While-Healing-a-file-set-the-config-xattr.patch b/SOURCES/0142-EC-While-Healing-a-file-set-the-config-xattr.patch new file mode 100644 index 0000000..2a0c1a0 --- /dev/null +++ b/SOURCES/0142-EC-While-Healing-a-file-set-the-config-xattr.patch @@ -0,0 +1,58 @@ +From 0988aa934898e2d44e21eab6aadc86bd7f5d97b3 Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Thu, 25 Jun 2015 16:30:40 +0530 +Subject: [PATCH 142/190] EC : While Healing a file, set the config xattr + + Problem : trusted.ec.config attr was missing for the healed file + + Solution: Writing trusted.ec.config while healing a file. + + Review link for master branch - + http://review.gluster.org/11407/ + +Change-Id: I340dd45ff8ab5bc1cd6e9b0cd2b2ded236e5acf0 +BUG: 1235244 +Signed-off-by: Ashish Pandey +Reviewed-on: https://code.engineering.redhat.com/gerrit/51658 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/ec/src/ec-heal.c | 15 ++++++++++++++- + 1 files changed, 14 insertions(+), 1 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index af75c95..c2b8e11 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -2328,7 +2328,7 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, + unsigned char *create = NULL; + dict_t *xdata = NULL; + char *linkname = NULL; +- ++ ec_config_t config; + /* There should be just one gfid key */ + EC_REPLIES_ALLOC (replies, ec->nodes); + if (gfid_db->count != 1) { +@@ -2422,6 +2422,19 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, + if (output1[i]) + output[i] = 1; + break; ++ case IA_IFREG: ++ config.version = EC_CONFIG_VERSION; ++ config.algorithm = EC_CONFIG_ALGORITHM; ++ config.gf_word_size = EC_GF_BITS; ++ config.bricks = ec->nodes; ++ config.redundancy = ec->redundancy; ++ config.chunk_size = EC_METHOD_CHUNK_SIZE; ++ ++ if (ec_dict_set_config(xdata, EC_XATTR_CONFIG, ++ &config) < 0) { ++ ret = -EIO; ++ goto out; ++ } + default: + ret = dict_set_int32 (xdata, GLUSTERFS_INTERNAL_FOP_KEY, + 1); +-- +1.7.1 + diff --git a/SOURCES/0143-libglusterfs-Introducing-new-logging-message.patch b/SOURCES/0143-libglusterfs-Introducing-new-logging-message.patch new file mode 100644 index 0000000..4df7156 --- /dev/null +++ b/SOURCES/0143-libglusterfs-Introducing-new-logging-message.patch @@ -0,0 +1,1997 @@ +From bebed1c6df5d5ffe46d5ea427f8d3669f88172ff Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Mon, 18 May 2015 12:15:07 +0530 +Subject: [PATCH 143/190] libglusterfs: Introducing new logging message + +Change-Id: I137f1b7805895810b8e6f0a70a183782bf472bf5 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq +Reviewed-on: http://review.gluster.org/9898 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/51144 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/Makefile.am | 1 + + libglusterfs/src/libglusterfs-messages.h | 1956 ++++++++++++++++++++++++++++++ + 2 files changed, 1957 insertions(+), 0 deletions(-) + create mode 100644 libglusterfs/src/libglusterfs-messages.h + +diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am +index a9830b4..80ce672 100644 +--- a/libglusterfs/src/Makefile.am ++++ b/libglusterfs/src/Makefile.am +@@ -44,6 +44,7 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec. + run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \ + gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \ + template-component-messages.h strfd.h syncop-utils.h parse-utils.h \ ++ libglusterfs-messages.h \ + $(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h \ + $(CONTRIBDIR)/libexecinfo/execinfo_compat.h \ + unittest/unittest.h quota-common-utils.h rot-buffs.h \ +diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h +new file mode 100644 +index 0000000..e4ced02 +--- /dev/null ++++ b/libglusterfs/src/libglusterfs-messages.h +@@ -0,0 +1,1956 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++ */ ++ ++#ifndef _LG_MESSAGES_H_ ++#define _LG_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_LG_BASE GLFS_MSGID_COMP_LIBGLUSTERFS ++#define GLFS_LG_NUM_MESSAGES 228 ++#define GLFS_LG_MSGID_END (GLFS_LG_BASE + GLFS_LG_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_lg GLFS_LG_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++#define LG_MSG_BACK_POLL_EVENT (GLFS_LG_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_ASPRINTF_FAILED (GLFS_LG_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_ENTRY (GLFS_LG_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_BUF_NULL (GLFS_LG_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_COUNT_LESS_THAN_ZERO (GLFS_LG_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_COUNT_LESS_THAN_DATA_PAIRS (GLFS_LG_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PAIR_KEY_NULL (GLFS_LG_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PAIR_VALUE_NULL (GLFS_LG_BASE + 8) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO (GLFS_LG_BASE + 9) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PAIRS_LESS_THAN_COUNT (GLFS_LG_BASE + 10) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_KEY_OR_VALUE_NULL (GLFS_LG_BASE + 11) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FAILED_TO_LOG_DICT (GLFS_LG_BASE + 12) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_NULL_VALUE_IN_DICT (GLFS_LG_BASE + 13) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DIR_OP_FAILED (GLFS_LG_BASE + 14) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_STORE_HANDLE_CREATE_FAILED (GLFS_LG_BASE + 15) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SYNC_FAILED (GLFS_LG_BASE + 16) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_RENAME_FAILED (GLFS_LG_BASE + 17) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FILE_OP_FAILED (GLFS_LG_BASE + 18) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_STORE_KEY_VALUE_FAILED (GLFS_LG_BASE + 19) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FFLUSH_FAILED (GLFS_LG_BASE + 20) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FILE_STAT_FAILED (GLFS_LG_BASE + 21) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_LOCK_GAIN_FAILED (GLFS_LG_BASE + 22) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_LOCK_RELEASE_FAILED (GLFS_LG_BASE + 23) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_MOVE_FAILED (GLFS_LG_BASE + 24) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_SERIAL_FAILED (GLFS_LG_BASE + 25) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_UNSERIAL_FAILED (GLFS_LG_BASE + 26) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_NO_MEMORY (GLFS_LG_BASE + 27) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VOLUME_ERROR (GLFS_LG_BASE + 28) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SUB_VOLUME_ERROR (GLFS_LG_BASE + 29) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SYNTAX_ERROR (GLFS_LG_BASE + 30) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_BACKTICK_PARSE_FAILED (GLFS_LG_BASE + 31) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_BUFFER_ERROR (GLFS_LG_BASE + 32) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GETTIMEOFDAY_FUNCTION_FAILED (GLFS_LG_BASE + 33) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DUMP_CALL_POOL_FAILED (GLFS_LG_BASE + 34) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_STRDUP_ERROR (GLFS_LG_BASE + 35) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_HASH_FUNC_ERROR (GLFS_LG_BASE + 36) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INIT_BUCKET_FAILED (GLFS_LG_BASE + 37) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GET_ENTRY_FAILED (GLFS_LG_BASE + 38) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GET_BUCKET_FAILED (GLFS_LG_BASE + 39) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INSERT_FAILED (GLFS_LG_BASE + 40) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INIT_ENTRY_FAILED (GLFS_LG_BASE + 41) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_OUT_OF_RANGE (GLFS_LG_BASE + 42) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VALIDATE_RETURNS (GLFS_LG_BASE + 43) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VALIDATE_REC_FAILED (GLFS_LG_BASE + 44) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_RB_TABLE_CREATE_FAILED (GLFS_LG_BASE + 45) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ ++#define LG_MSG_PATH_NOT_FOUND (GLFS_LG_BASE + 46) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ ++#define LG_MSG_CONVERTION_FAILED (GLFS_LG_BASE + 47) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_EXPAND_FD_TABLE_FAILED (GLFS_LG_BASE + 48) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_MAPING_FAILED (GLFS_LG_BASE + 49) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INIT_IOBUF_FAILED (GLFS_LG_BASE + 50) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PAGE_SIZE_EXCEEDED (GLFS_LG_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_ARENA_NOT_FOUND (GLFS_LG_BASE + 52) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_IOBUF_NOT_FOUND (GLFS_LG_BASE + 53) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_POOL_NOT_FOUND (GLFS_LG_BASE + 54) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SET_ATTRIBUTE_FAILED (GLFS_LG_BASE + 55) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_READ_ATTRIBUTE_FAILED (GLFS_LG_BASE + 56) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UNMOUNT_FAILED (GLFS_LG_BASE + 57) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_LATENCY_MEASUREMENT_STATE (GLFS_LG_BASE + 58) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_NO_PERM (GLFS_LG_BASE + 59) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_NO_KEY (GLFS_LG_BASE + 60) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_NULL (GLFS_LG_BASE + 61) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INIT_TIMER_FAILED (GLFS_LG_BASE + 62) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_ANONYMOUS_FAILED (GLFS_LG_BASE + 63) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_CREATE_FAILED (GLFS_LG_BASE + 64) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_BUFFER_FULL (GLFS_LG_BASE + 65) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FWRITE_FAILED (GLFS_LG_BASE + 66) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PRINT_FAILED (GLFS_LG_BASE + 67) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_MEM_POOL_DESTROY (GLFS_LG_BASE + 68) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_EXPAND_CLIENT_TABLE_FAILED (GLFS_LG_BASE + 69) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DISCONNECT_CLIENT (GLFS_LG_BASE + 70) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PIPE_CREATE_FAILED (GLFS_LG_BASE + 71) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SET_PIPE_FAILED (GLFS_LG_BASE + 72) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_REGISTER_PIPE_FAILED (GLFS_LG_BASE + 73) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_POLL_IGNORE_MULTIPLE_THREADS (GLFS_LG_BASE + 74) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INDEX_NOT_FOUND (GLFS_LG_BASE + 75) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_EPOLL_FD_CREATE_FAILED (GLFS_LG_BASE + 76) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SLOT_NOT_FOUND (GLFS_LG_BASE + 77) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_ADD_FAILED (GLFS_LG_BASE + 78) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_DEL_FAILED (GLFS_LG_BASE + 79) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_MODIFY_FAILED (GLFS_LG_BASE + 80) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ #define LG_MSG_STALE_FD_FOUND (GLFS_LG_BASE + 81) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GENERATION_MISMATCH (GLFS_LG_BASE + 82) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_STARTED_THREAD (GLFS_LG_BASE + 83) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_EXITED_THREAD (GLFS_LG_BASE + 84) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_START_THREAD_FAILED (GLFS_LG_BASE + 85) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PTHREAD_KEY_CREATE_FAILED (GLFS_LG_BASE + 86) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_TRANSLATOR_INIT_FAILED (GLFS_LG_BASE + 87) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UUID_BUF_INIT_FAILED (GLFS_LG_BASE + 88) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_LKOWNER_BUF_INIT_FAILED (GLFS_LG_BASE + 89) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SYNCTASK_INIT_FAILED (GLFS_LG_BASE + 90) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SYNCOPCTX_INIT_FAILED (GLFS_LG_BASE + 91) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GLOBAL_INIT_FAILED (GLFS_LG_BASE + 92) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PTHREAD_FAILED (GLFS_LG_BASE + 93) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DIR_IS_SYMLINK (GLFS_LG_BASE + 94) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_RESOLVE_HOSTNAME_FAILED (GLFS_LG_BASE + 95) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GETADDRINFO_FAILED (GLFS_LG_BASE + 96) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GETNAMEINFO_FAILED (GLFS_LG_BASE + 97) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PATH_ERROR (GLFS_LG_BASE + 98) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INET_PTON_FAILED (GLFS_LG_BASE + 99) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_NEGATIVE_NUM_PASSED (GLFS_LG_BASE + 100) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GETHOSTNAME_FAILED (GLFS_LG_BASE + 101) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_RESERVED_PORTS_ERROR (GLFS_LG_BASE + 102) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INVALID_PORT (GLFS_LG_BASE + 103) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INVALID_FAMILY (GLFS_LG_BASE + 104) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CONVERSION_FAILED (GLFS_LG_BASE + 105) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_SKIP_HEADER_FAILED (GLFS_LG_BASE + 106) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INVALID_LOG (GLFS_LG_BASE + 107) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_UTIMES_FAILED (GLFS_LG_BASE + 108) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_BACKTRACE_SAVE_FAILED (GLFS_LG_BASE + 109) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INIT_FAILED (GLFS_LG_BASE + 110) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_VALIDATION_FAILED (GLFS_LG_BASE + 111) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GRAPH_ERROR (GLFS_LG_BASE + 112) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_UNKNOWN_OPTIONS_FAILED (GLFS_LG_BASE + 113) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_NOTIFICATION_FAILED (GLFS_LG_BASE + 114) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CTX_NULL (GLFS_LG_BASE + 115) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CTX_ACTIVE_NULL (GLFS_LG_BASE + 116) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_TMPFILE_CREATE_FAILED (GLFS_LG_BASE + 117) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DLOPEN_FAILED (GLFS_LG_BASE + 118) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_LOAD_FAILED (GLFS_LG_BASE + 119) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DLSYM_ERROR (GLFS_LG_BASE + 120) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_TREE_NOT_FOUND (GLFS_LG_BASE + 121) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PER_DENTRY (GLFS_LG_BASE + 122) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PARENT_NOT_FOUND (GLFS_LG_BASE + 123) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CYCLIC_LOOP (GLFS_LG_BASE + 124) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DENTRY (GLFS_LG_BASE + 125) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INFINITE_LOOP (GLFS_LG_BASE + 126) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GETIFADDRS_FAILED (GLFS_LG_BASE + 127) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_REGEX_OP_FAILED (GLFS_LG_BASE + 128) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_FRAME_ERROR (GLFS_LG_BASE + 129) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_SET_PARAM_FAILED (GLFS_LG_BASE + 130) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GET_PARAM_FAILED (GLFS_LG_BASE + 131) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PREPARE_FAILED (GLFS_LG_BASE + 132) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_EXEC_FAILED (GLFS_LG_BASE + 133) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_BINDING_FAILED (GLFS_LG_BASE + 134) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DELETE_FAILED (GLFS_LG_BASE + 135) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GET_ID_FAILED (GLFS_LG_BASE + 136) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CREATE_FAILED (GLFS_LG_BASE + 137) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_PARSE_FAILED (GLFS_LG_BASE + 138) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++ ++#define LG_MSG_GETCONTEXT_FAILED (GLFS_LG_BASE + 139) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_UPDATE_FAILED (GLFS_LG_BASE + 140) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_QUERY_CALL_BACK_FAILED (GLFS_LG_BASE + 141) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_GET_RECORD_FAILED (GLFS_LG_BASE + 142) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DB_ERROR (GLFS_LG_BASE + 143) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CONNECTION_ERROR (GLFS_LG_BASE + 144) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_NOT_MULTITHREAD_MODE (GLFS_LG_BASE + 145) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_SKIP_PATH (GLFS_LG_BASE + 146) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INVALID_FOP (GLFS_LG_BASE + 147) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_QUERY_FAILED (GLFS_LG_BASE + 148) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CLEAR_COUNTER_FAILED (GLFS_LG_BASE + 149) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_LOCK_LIST_FAILED (GLFS_LG_BASE + 150) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_UNLOCK_LIST_FAILED (GLFS_LG_BASE + 151) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_ADD_TO_LIST_FAILED (GLFS_LG_BASE + 152) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INIT_DB_FAILED (GLFS_LG_BASE + 153) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DELETE_FROM_LIST_FAILED (GLFS_LG_BASE + 154) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CLOSE_CONNECTION_FAILED (GLFS_LG_BASE + 155) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INSERT_OR_UPDATE_FAILED (GLFS_LG_BASE + 156) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_FIND_OP_FAILED (GLFS_LG_BASE + 157) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CONNECTION_INIT_FAILED (GLFS_LG_BASE + 158) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_COMPLETED_TASK (GLFS_LG_BASE + 159) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_WAKE_UP_ZOMBIE (GLFS_LG_BASE + 160) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_REWAITING_TASK (GLFS_LG_BASE + 161) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_SLEEP_ZOMBIE (GLFS_LG_BASE + 162) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_SWAP_FAILED (GLFS_LG_BASE + 163) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_UNSUPPORTED_PLUGIN (GLFS_LG_BASE + 164) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_INVALID_DB_TYPE (GLFS_LG_BASE + 165) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_NULL_INDEX_IN_BUF (GLFS_LG_BASE + 166) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_DATA_NULL (GLFS_LG_BASE + 167) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_OR_KEY_NULL (GLFS_LG_BASE + 168) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_OR_KEY_OR_DATA_NULL (GLFS_LG_BASE + 169) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_OR_KEY_VALUE_NULL (GLFS_LG_BASE + 170) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VALUE_NULL (GLFS_LG_BASE + 171) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UNDERSIZED_BUF (GLFS_LG_BASE + 172) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DATA_CONVERSION_ERROR (GLFS_LG_BASE + 173) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_OR_MATCH_OR_ACTION_NULL (GLFS_LG_BASE + 174) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_SIZE_ZERO (GLFS_LG_BASE + 175) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FILL_NULL (GLFS_LG_BASE + 176) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UNDESIRED_BUFF (GLFS_LG_BASE + 177) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_ERROR (GLFS_LG_BASE + 178) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_IOBUFS_NOT_FOUND (GLFS_LG_BASE + 179) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_ENTRIES_NULL (GLFS_LG_BASE + 180) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_COUNT_NULL (GLFS_LG_BASE + 181) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_NOT_FOUND_IN_FDTABLE (GLFS_LG_BASE + 182) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_NULL (GLFS_LG_BASE + 183) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INODE_NULL (GLFS_LG_BASE + 184) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FD_OR_INODE_NULL (GLFS_LG_BASE + 185) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_REALLOC_FOR_FD_PTR_FAILED (GLFS_LG_BASE + 186) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_XLATOR_OR_FD_NULL (GLFS_LG_BASE + 187) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DICT_SET_FAILED (GLFS_LG_BASE + 188) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_READ_HEADER_FAILED (GLFS_LG_BASE + 189) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_READ_FROM_QUOTA_FAILED (GLFS_LG_BASE + 190) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_ASSERTION_FAILED (GLFS_LG_BASE + 191) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_HOSTNAME_NULL (GLFS_LG_BASE + 192) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_IPV4_FORMAT (GLFS_LG_BASE + 193) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_CTX_CLEANUP_STARTED (GLFS_LG_BASE + 194) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_TIMER_REGISTER_ERROR (GLFS_LG_BASE + 195) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_PTR_HEADER_CORRUPTED (GLFS_LG_BASE + 196) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_UPLINK (GLFS_LG_BASE + 197) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define LG_MSG_CLIENTTABLE_NULL (GLFS_LG_BASE + 198) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_CLIENT_NULL (GLFS_LG_BASE + 199) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_XLATOR_DOES_NOT_IMPLEMENT (GLFS_LG_BASE + 200) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DENTRY_NOT_FOUND (GLFS_LG_BASE + 201) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INODE_NOT_FOUND (GLFS_LG_BASE + 202) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INODE_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 203) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INODE_OR_PARENT_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 204) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_TABLE_NOT_FOUND (GLFS_LG_BASE + 205) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_TABLE_OR_PARENT_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 206) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_DENTRY_CREATE_FAILED (GLFS_LG_BASE + 207) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INODE_CONTEXT_FREED (GLFS_LG_BASE + 208) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UNKNOWN_LOCK_TYPE (GLFS_LG_BASE + 209) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_UNLOCK_BEFORE_LOCK (GLFS_LG_BASE + 210) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_LOCK_OWNER_ERROR (GLFS_LG_BASE + 211) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_FDTABLE_NULL (GLFS_LG_BASE + 212) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_MEMPOOL_PTR_NULL (GLFS_LG_BASE + 213) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_VERSION (GLFS_LG_BASE + 214) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_WRITE_TO_QUOTA_FAILED (GLFS_LG_BASE + 215) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_QUOTA_XATTRS_MISSING (GLFS_LG_BASE + 216) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_STRING (GLFS_LG_BASE + 217) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_BIND_REF (GLFS_LG_BASE + 218) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_REF_COUNT (GLFS_LG_BASE + 219) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_ARG (GLFS_LG_BASE + 220) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VOL_OPTION_ADD (GLFS_LG_BASE + 221) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_XLATOR_OPTION_INVALID (GLFS_LG_BASE + 222) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GETTIMEOFDAY_FAILED (GLFS_LG_BASE + 223) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_GRAPH_INIT_FAILED (GLFS_LG_BASE + 224) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_EVENT_NOTIFY_FAILED (GLFS_LG_BASE + 225) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_ACTIVE_GRAPH_NULL (GLFS_LG_BASE + 226) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_VOLFILE_PARSE_ERROR (GLFS_LG_BASE + 227) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define LG_MSG_INVALID_VOLFILE_ENTRY (GLFS_LG_BASE + 228) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++ ++#define glfs_msg_end_lg GLFS_LG_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_LG_MESSAGES_H_ */ ++ ++ ++ +-- +1.7.1 + diff --git a/SOURCES/0144-core-add-gf_ref_t-for-common-refcounting-structures.patch b/SOURCES/0144-core-add-gf_ref_t-for-common-refcounting-structures.patch new file mode 100644 index 0000000..ffb0605 --- /dev/null +++ b/SOURCES/0144-core-add-gf_ref_t-for-common-refcounting-structures.patch @@ -0,0 +1,335 @@ +From 62ed8b36d67e073fd26c2c7353a8b7cc0961be20 Mon Sep 17 00:00:00 2001 +From: Niels de Vos +Date: Sun, 31 May 2015 15:16:41 +0200 +Subject: [PATCH 144/190] core: add "gf_ref_t" for common refcounting structures + +This is a backport of http://review.gluster.org/#/c/11022/ + +There were errors from checkpatch.pl, it is fixed as part of +this backport, below are the changes: +added additional parenthesis for macro definition + GF_REF_INIT + GF_REF_GET + GF_REF_PUT + +> Checks for compiler supported atomic operations comes from client_t.h. +> +> An example usage of this change can be found in adding reference +> counting to "struct auth_cache_entry" in http://review.gluster.org/11023 +> +> Basic usage looks like this: +> +> #include "refcount.h" +> +> struct my_struct { +> GF_REF_DECL; +> ... /* more members */ +> } +> +> void my_destructor (void *data) +> { +> struct my_struct *my_ptr = (struct my_struct *) data; +> +> ... /* do some more cleanups */ +> GF_FREE (my_ptr); +> } +> +> void init_ptr (struct parent *parent) +> { +> struct my_struct *my_ptr = malloc (sizeof (struct my_struct)); +> +> GF_REF_INIT (my_ptr, my_destructor); /* refcount is set to 1 */ +> +> ... /* my_ptr probably gets added to some parent structure */ +> parent_add_ptr (parent, my_ptr); +> } +> +> void do_something (struct parent *parent) +> { +> struct my_struct *my_ptr = NULL; +> +> /* likely need to lock parent, depends on its access pattern */ +> my_ptr = parent_remove_first_ptr (parent); +> /* unlock parent */ +> +> ... /* do something */ +> +> GF_REF_PUT (my_ptr); /* calls my_destructor on refcount = 0 */ +> } +> +> URL: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/11202 +> Change-Id: Idb98a5861a44c31676108ed8876db12c320912ef +> BUG: 1228157 +> Signed-off-by: Niels de Vos +> Reviewed-on: http://review.gluster.org/11022 +> Reviewed-by: Xavier Hernandez +> Reviewed-by: Krishnan Parthasarathi +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System + +Change-Id: I5630ff3fbd0e0021a83597d778e1037796be5355 +BUG: 1235628 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51605 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/Makefile.am | 4 +- + libglusterfs/src/refcount.c | 112 ++++++++++++++++++++++++++++++++++++++++++ + libglusterfs/src/refcount.h | 103 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 217 insertions(+), 2 deletions(-) + create mode 100644 libglusterfs/src/refcount.c + create mode 100644 libglusterfs/src/refcount.h + +diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am +index 80ce672..ed441d0 100644 +--- a/libglusterfs/src/Makefile.am ++++ b/libglusterfs/src/Makefile.am +@@ -22,7 +22,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \ + $(CONTRIBDIR)/rbtree/rb.c rbthash.c store.c latency.c \ + graph.c syncop.c graph-print.c trie.c run.c options.c fd-lk.c \ + circ-buff.c event-history.c gidcache.c ctx.c client_t.c event-poll.c \ +- event-epoll.c syncop-utils.c cluster-syncop.c \ ++ event-epoll.c syncop-utils.c cluster-syncop.c refcount.c \ + $(CONTRIBDIR)/libgen/basename_r.c \ + $(CONTRIBDIR)/libgen/dirname_r.c $(CONTRIBDIR)/stdlib/gf_mkostemp.c \ + strfd.c parse-utils.c $(CONTRIBDIR)/mount/mntent.c \ +@@ -40,7 +40,7 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec. + gf-dirent.h locking.h syscall.h iobuf.h globals.h statedump.h \ + checksum.h daemon.h $(CONTRIBDIR)/rbtree/rb.h store.h\ + rbthash.h iatt.h latency.h mem-types.h syncop.h cluster-syncop.h \ +- graph-utils.h trie.h \ ++ graph-utils.h trie.h refcount.h \ + run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \ + gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \ + template-component-messages.h strfd.h syncop-utils.h parse-utils.h \ +diff --git a/libglusterfs/src/refcount.c b/libglusterfs/src/refcount.c +new file mode 100644 +index 0000000..96edc10 +--- /dev/null ++++ b/libglusterfs/src/refcount.c +@@ -0,0 +1,112 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#include "common-utils.h" ++#include "refcount.h" ++ ++#ifndef REFCOUNT_NEEDS_LOCK ++ ++unsigned int ++_gf_ref_get (gf_ref_t *ref) ++{ ++ unsigned int cnt = __sync_fetch_and_add (&ref->cnt, 1); ++ ++ /* if cnt == 0, we're in a fatal position, the object will be free'd ++ * ++ * There is a race when two threads do a _gf_ref_get(). Only one of ++ * them may get a 0 returned. That is acceptible, because one ++ * _gf_ref_get() returning 0 should be handled as a fatal problem and ++ * when correct usage/locking is used, it should never happen. ++ */ ++ GF_ASSERT (cnt != 0); ++ ++ return cnt; ++} ++ ++unsigned int ++_gf_ref_put (gf_ref_t *ref) ++{ ++ unsigned int cnt = __sync_fetch_and_sub (&ref->cnt, 1); ++ ++ /* if cnt == 1, the last user just did a _gf_ref_put() ++ * ++ * When cnt == 0, one _gf_ref_put() was done too much and there has ++ * been a thread using the refcounted structure when it was not ++ * supposed to. ++ */ ++ GF_ASSERT (cnt != 0); ++ ++ if (cnt == 1 && ref->release) { ++ ref->release (ref->data); ++ /* set return value to 0 to inform the caller correctly */ ++ cnt = 0; ++ } ++ ++ return cnt; ++} ++ ++#else ++ ++unsigned int ++_gf_ref_get (gf_ref_t *ref) ++{ ++ unsigned int cnt = 0; ++ ++ LOCK (&ref->lk); ++ { ++ /* never can be 0, should have been free'd */ ++ if (ref->cnt > 0) ++ cnt = ++ref->cnt; ++ else ++ GF_ASSERT (ref->cnt > 0); ++ } ++ UNLOCK (&ref->lk); ++ ++ return cnt; ++} ++ ++unsigned int ++_gf_ref_put (gf_ref_t *ref) ++{ ++ unsigned int cnt = 0; ++ int release = 0; ++ ++ LOCK (&ref->lk); ++ { ++ if (ref->cnt != 0) { ++ cnt = --ref->cnt; ++ /* call release() only when cnt == 0 */ ++ release = (cnt == 0); ++ } else ++ GF_ASSERT (ref->cnt != 0); ++ } ++ UNLOCK (&ref->lk); ++ ++ if (release && ref->release) ++ ref->release (ref->data); ++ ++ return cnt; ++} ++ ++#endif /* REFCOUNT_NEEDS_LOCK */ ++ ++ ++void ++_gf_ref_init (gf_ref_t *ref, gf_ref_release_t release, void *data) ++{ ++ GF_ASSERT (ref); ++ ++#ifdef REFCOUNT_NEEDS_LOCK ++ LOCK_INIT (&ref->lk); ++#endif ++ ref->cnt = 1; ++ ref->release = release; ++ ref->data = data; ++} +diff --git a/libglusterfs/src/refcount.h b/libglusterfs/src/refcount.h +new file mode 100644 +index 0000000..c8113a2 +--- /dev/null ++++ b/libglusterfs/src/refcount.h +@@ -0,0 +1,103 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _REFCOUNT_H ++#define _REFCOUNT_H ++ ++/* check for compiler support for __sync_*_and_fetch() ++ * ++ * a more comprehensive feature test is shown at ++ * http://lists.iptel.org/pipermail/semsdev/2010-October/005075.html ++ * this is sufficient for RHEL5 i386 builds ++ */ ++#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && !defined(__i386__) ++#undef REFCOUNT_NEEDS_LOCK ++#else ++#define REFCOUNT_NEEDS_LOCK ++#include "locking.h" ++#endif /* compiler support for __sync_*_and_fetch() */ ++ ++typedef void (*gf_ref_release_t)(void *data); ++ ++struct _gf_ref_t { ++#ifdef REFCOUNT_NEEDS_LOCK ++ gf_lock_t lk; /* lock for atomically adjust cnt */ ++#endif ++ unsigned int cnt; /* number of users, free on 0 */ ++ ++ gf_ref_release_t release; /* cleanup when cnt == 0 */ ++ void *data; /* parameter passed to release() */ ++}; ++typedef struct _gf_ref_t gf_ref_t; ++ ++ ++/* _gf_ref_get -- increase the refcount and return the number of references ++ * ++ * @return: greater then 0 when a reference was taken, 0 when not ++ */ ++unsigned int ++_gf_ref_get (gf_ref_t *ref); ++ ++/* _gf_ref_put -- decrease the refcount and return the number of references ++ * ++ * @return: greater then 0 when there are still references, 0 when cleanup ++ * should be done ++ */ ++unsigned int ++_gf_ref_put (gf_ref_t *ref); ++ ++/* _gf_ref_init -- initalize an embedded refcount object ++ * ++ * @release: function to call when the refcount == 0 ++ * @data: parameter to be passed to @release ++ */ ++void ++_gf_ref_init (gf_ref_t *ref, gf_ref_release_t release, void *data); ++ ++ ++/* ++ * Strong suggestion to use the simplified GF_REF_* API. ++ */ ++ ++/* GF_REF_DECL -- declaration to put inside your structure ++ * ++ * Example: ++ * struct my_struct { ++ * GF_REF_DECL; ++ * ++ * ... // additional members ++ * }; ++ */ ++#define GF_REF_DECL gf_ref_t _ref ++ ++/* GF_REF_INIT -- initialize a GF_REF_DECL structure ++ * ++ * @p: allocated structure with GF_REF_DECL ++ * @d: destructor to call once refcounting reaches 0 ++ * ++ * Sets the refcount to 1. ++ */ ++#define GF_REF_INIT(p, d) (_gf_ref_init (&p->_ref, d, p)) ++ ++/* GF_REF_GET -- increase the refcount of a GF_REF_DECL structure ++ * ++ * @return: greater then 0 when a reference was taken, 0 when not ++ */ ++#define GF_REF_GET(p) (_gf_ref_get (&p->_ref)) ++ ++/* GF_REF_PUT -- decrease the refcount of a GF_REF_DECL structure ++ * ++ * @return: greater then 0 when there are still references, 0 when cleanup ++ * should be done ++ */ ++#define GF_REF_PUT(p) (_gf_ref_put (&p->_ref)) ++ ++ ++#endif /* _REFCOUNT_H */ +-- +1.7.1 + diff --git a/SOURCES/0145-quota-marker-fix-mem-leak-in-marker.patch b/SOURCES/0145-quota-marker-fix-mem-leak-in-marker.patch new file mode 100644 index 0000000..06f94bb --- /dev/null +++ b/SOURCES/0145-quota-marker-fix-mem-leak-in-marker.patch @@ -0,0 +1,559 @@ +From 9f819fe340a346844b75cde8a676470bd8b1b907 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Wed, 24 Jun 2015 11:56:30 +0530 +Subject: [PATCH 145/190] quota/marker: fix mem-leak in marker + +This is a backport of http://review.gluster.org/#/c/11361/ + +> When removing contribution xattr, we also need to free +> contribution node in memory. +> Use ref/unref mechanism to handle contribution node memory +> +> local->xdata should be freed in mq_local_unref +> +> There is another huge memory consumption happens +> in function mq_inspect_directory_xattr_task +> where dirty flag is not set. +> +> Change-Id: Ieca3ab4bf410c51259560e778bce4e81b9d888bf +> BUG: 1207735 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11361 +> Reviewed-by: Krishnan Parthasarathi +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G +> Tested-by: Raghavendra G + +Change-Id: Id82bd071433f8141c6fa1d4ad1a488604ff33978 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51565 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota-helper.c | 81 ++++++++---- + xlators/features/marker/src/marker-quota-helper.h | 18 ++- + xlators/features/marker/src/marker-quota.c | 137 +++++++++++++-------- + xlators/features/marker/src/marker-quota.h | 4 +- + 4 files changed, 157 insertions(+), 83 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c +index 67801c8..a103bb9 100644 +--- a/xlators/features/marker/src/marker-quota-helper.c ++++ b/xlators/features/marker/src/marker-quota-helper.c +@@ -130,6 +130,39 @@ out: + return ctx; + } + ++void ++mq_contri_fini (void *data) ++{ ++ inode_contribution_t *contri = data; ++ ++ LOCK_DESTROY (&contri->lock); ++ GF_FREE (contri); ++} ++ ++inode_contribution_t* ++mq_contri_init (inode_t *inode) ++{ ++ inode_contribution_t *contri = NULL; ++ int32_t ret = 0; ++ ++ QUOTA_ALLOC (contri, inode_contribution_t, ret); ++ if (ret == -1) ++ goto out; ++ ++ GF_REF_INIT (contri, mq_contri_fini); ++ ++ contri->contribution = 0; ++ contri->file_count = 0; ++ contri->dir_count = 0; ++ gf_uuid_copy (contri->gfid, inode->gfid); ++ ++ LOCK_INIT (&contri->lock); ++ INIT_LIST_HEAD (&contri->contri_list); ++ ++out: ++ return contri; ++} ++ + inode_contribution_t * + mq_get_contribution_node (inode_t *inode, quota_inode_ctx_t *ctx) + { +@@ -139,35 +172,26 @@ mq_get_contribution_node (inode_t *inode, quota_inode_ctx_t *ctx) + if (!inode || !ctx) + goto out; + +- list_for_each_entry (temp, &ctx->contribution_head, contri_list) { +- if (gf_uuid_compare (temp->gfid, inode->gfid) == 0) { +- contri = temp; +- goto out; ++ LOCK (&ctx->lock); ++ { ++ list_for_each_entry (temp, &ctx->contribution_head, ++ contri_list) { ++ if (gf_uuid_compare (temp->gfid, inode->gfid) == 0) { ++ contri = temp; ++ GF_REF_GET (contri); ++ break; ++ } + } + } ++ UNLOCK (&ctx->lock); + out: + return contri; + } + +- +-int32_t +-mq_delete_contribution_node (dict_t *dict, char *key, +- inode_contribution_t *contribution) +-{ +- if (dict_get (dict, key) != NULL) +- goto out; +- +- QUOTA_FREE_CONTRIBUTION_NODE (contribution); +-out: +- return 0; +-} +- +- + inode_contribution_t * + __mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, + loc_t *loc) + { +- int32_t ret = 0; + inode_contribution_t *contribution = NULL; + + if (!loc->parent) { +@@ -190,17 +214,10 @@ __mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, + } + } + +- QUOTA_ALLOC (contribution, inode_contribution_t, ret); +- if (ret == -1) ++ contribution = mq_contri_init (loc->parent); ++ if (contribution == NULL) + goto out; + +- contribution->contribution = 0; +- +- gf_uuid_copy (contribution->gfid, loc->parent->gfid); +- +- LOCK_INIT (&contribution->lock); +- INIT_LIST_HEAD (&contribution->contri_list); +- + list_add_tail (&contribution->contri_list, &ctx->contribution_head); + + out: +@@ -224,6 +241,8 @@ mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, + LOCK (&ctx->lock); + { + contribution = __mq_add_new_contribution_node (this, ctx, loc); ++ if (contribution) ++ GF_REF_GET (contribution); + } + UNLOCK (&ctx->lock); + +@@ -392,6 +411,12 @@ mq_local_unref (xlator_t *this, quota_local_t *local) + if (local->fd != NULL) + fd_unref (local->fd); + ++ if (local->contri) ++ GF_REF_PUT (local->contri); ++ ++ if (local->xdata) ++ dict_unref (local->xdata); ++ + loc_wipe (&local->loc); + + loc_wipe (&local->parent_loc); +diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h +index 161413d..f69447b 100644 +--- a/xlators/features/marker/src/marker-quota-helper.h ++++ b/xlators/features/marker/src/marker-quota-helper.h +@@ -18,10 +18,14 @@ + + #include "marker.h" + +-#define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \ +- do { \ +- list_del (&_contribution->contri_list); \ +- GF_FREE (_contribution); \ ++#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution) \ ++ do { \ ++ LOCK (&ctx->lock); \ ++ { \ ++ list_del (&_contribution->contri_list); \ ++ GF_REF_PUT (_contribution); \ ++ } \ ++ UNLOCK (&ctx->lock); \ + } while (0) + + #define QUOTA_SAFE_INCREMENT(lock, var) \ +@@ -67,6 +71,12 @@ mq_local_ref (quota_local_t *); + int32_t + mq_local_unref (xlator_t *, quota_local_t *); + ++void ++mq_contri_fini (void *data); ++ ++inode_contribution_t* ++mq_contri_init (inode_t *inode); ++ + inode_contribution_t * + mq_get_contribution_node (inode_t *, quota_inode_ctx_t *); + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index e183829..bbe2d9d 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -887,7 +887,10 @@ mq_update_dirty_inode (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + + local->ctx = ctx; + +- local->contri = contribution; ++ if (contribution) { ++ local->contri = contribution; ++ GF_REF_GET (local->contri); ++ } + + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; +@@ -1094,6 +1097,9 @@ free_value: + err: + dict_unref (dict); + ++ if (contri) ++ GF_REF_PUT (contri); ++ + out: + if (ret < 0) { + mq_xattr_creation_release_lock (frame, NULL, this, 0, 0, NULL); +@@ -1267,7 +1273,6 @@ mq_get_parent_inode_local (xlator_t *this, quota_local_t *local) + { + int32_t ret = -1; + quota_inode_ctx_t *ctx = NULL; +- inode_contribution_t *contribution = NULL; + + GF_VALIDATE_OR_GOTO ("marker", this, out); + GF_VALIDATE_OR_GOTO ("marker", local, out); +@@ -1332,9 +1337,8 @@ mq_get_parent_inode_local (xlator_t *this, quota_local_t *local) + contribution will be at the end of the list. So get the proper + parent's contribution, by searching the entire list. + */ +- contribution = mq_get_contribution_node (local->loc.parent, ctx); +- GF_ASSERT (contribution != NULL); +- local->contri = contribution; ++ local->contri = mq_get_contribution_node (local->loc.parent, ctx); ++ GF_ASSERT (local->contri != NULL); + + ret = 0; + out: +@@ -1997,7 +2001,10 @@ mq_prepare_txn_frame (xlator_t *this, loc_t *loc, + goto fr_destroy; + + local->ctx = ctx; +- local->contri = contri; ++ if (contri) { ++ local->contri = contri; ++ GF_REF_GET (local->contri); ++ } + + ret = 0; + *new_frame = frame; +@@ -2247,6 +2254,9 @@ out: + if (dict) + dict_unref (dict); + ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -2574,7 +2584,8 @@ out: + } + + int32_t +-mq_remove_contri (xlator_t *this, loc_t *loc, inode_contribution_t *contri) ++mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, ++ inode_contribution_t *contri, quota_meta_t *delta) + { + int32_t ret = -1; + char contri_key[CONTRI_KEY_MAX] = {0, }; +@@ -2588,7 +2599,8 @@ mq_remove_contri (xlator_t *this, loc_t *loc, inode_contribution_t *contri) + + ret = syncop_removexattr (FIRST_CHILD(this), loc, contri_key, 0, NULL); + if (ret < 0) { +- if (-ret == ENOENT || -ret == ESTALE || -ret == ENODATA) { ++ if (-ret == ENOENT || -ret == ESTALE || -ret == ENODATA || ++ -ret == ENOATTR) { + /* Remove contri in done when unlink operation is + * performed, so return success on ENOENT/ESTSLE + * rename operation removes xattr earlier, +@@ -2605,14 +2617,16 @@ mq_remove_contri (xlator_t *this, loc_t *loc, inode_contribution_t *contri) + + LOCK (&contri->lock); + { +- contri->contribution = 0; +- contri->file_count = 0; +- contri->dir_count = 0; ++ contri->contribution += delta->size; ++ contri->file_count += delta->file_count; ++ contri->dir_count += delta->dir_count; + } + UNLOCK (&contri->lock); + + ret = 0; ++ + out: ++ QUOTA_FREE_CONTRIBUTION_NODE (ctx, contri); + + return ret; + } +@@ -2809,10 +2823,12 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + gf_boolean_t status = _gf_true; + quota_meta_t delta = {0, }; + ++ GF_VALIDATE_OR_GOTO ("marker", contri, out); ++ GF_REF_GET (contri); ++ + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + GF_VALIDATE_OR_GOTO ("marker", ctx, out); +- GF_VALIDATE_OR_GOTO ("marker", contri, out); + + ret = mq_loc_copy (&child_loc, loc); + if (ret < 0) { +@@ -2907,6 +2923,8 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + ret = -1; + goto out; + } ++ ++ GF_REF_PUT (contri); + contri = mq_get_contribution_node (child_loc.parent, ctx); + GF_ASSERT (contri != NULL); + } +@@ -2923,6 +2941,8 @@ out: + + loc_wipe (&child_loc); + loc_wipe (&parent_loc); ++ if (contri) ++ GF_REF_PUT (contri); + + return ret; + } +@@ -3100,11 +3120,12 @@ mq_reduce_parent_size_task (void *opaque) + goto out; + dirty = _gf_true; + +- ret = mq_remove_contri (this, loc, contribution); ++ mq_sub_meta (&delta, NULL); ++ ++ ret = mq_remove_contri (this, loc, ctx, contribution, &delta); + if (ret < 0) + goto out; + +- mq_sub_meta (&delta, NULL); + ret = mq_update_size (this, &parent_loc, &delta); + if (ret < 0) + goto out; +@@ -3121,6 +3142,9 @@ out: + + loc_wipe (&parent_loc); + ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -3203,6 +3227,9 @@ mq_initiate_quota_task (void *opaque) + + ret = 0; + out: ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -3452,13 +3479,18 @@ mq_inspect_directory_xattr_task (void *opaque) + } + + ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY, &dirty); +- if (ret < 0) +- goto out; ++ if (ret < 0) { ++ /* dirty is set only on the first file write operation ++ * so ignore this error ++ */ ++ ret = 0; ++ dirty = 0; ++ } + + ret = _quota_dict_get_meta (this, dict, QUOTA_SIZE_KEY, &size, + IA_IFDIR, _gf_false); + if (ret < 0) +- goto out; ++ goto create_xattr; + + if (!loc_is_root(loc)) { + GET_CONTRI_KEY (contri_key, contribution->gfid, ret); +@@ -3468,7 +3500,7 @@ mq_inspect_directory_xattr_task (void *opaque) + ret = _quota_dict_get_meta (this, dict, contri_key, &contri, + IA_IFDIR, _gf_false); + if (ret < 0) +- goto out; ++ goto create_xattr; + + LOCK (&contribution->lock); + { +@@ -3499,11 +3531,15 @@ mq_inspect_directory_xattr_task (void *opaque) + mq_initiate_quota_blocking_txn (this, loc); + + ret = 0; +-out: ++ ++create_xattr: + if (ret < 0) + ret = mq_create_xattrs_blocking_txn (this, loc); + + err: ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -3575,41 +3611,32 @@ mq_inspect_file_xattr_task (void *opaque) + } + UNLOCK (&ctx->lock); + +- list_for_each_entry (contribution, &ctx->contribution_head, +- contri_list) { +- +- GET_CONTRI_KEY (contri_key, contribution->gfid, ret); +- if (ret < 0) +- continue; +- +- ret = _quota_dict_get_meta (this, dict, contri_key, &contri, +- IA_IFREG, _gf_true); +- if (ret < 0) { +- ret = mq_create_xattrs_blocking_txn (this, loc); +- } else { +- LOCK (&contribution->lock); +- { +- contribution->contribution = contri.size; +- contribution->file_count = contri.file_count; +- contribution->dir_count = contri.dir_count; +- } +- UNLOCK (&contribution->lock); ++ GET_CONTRI_KEY (contri_key, contribution->gfid, ret); ++ if (ret < 0) ++ goto out; + +- mq_compute_delta (&delta, &size, &contri); +- if (!quota_meta_is_null (&delta)) { +- mq_initiate_quota_blocking_txn (this, loc); +- /* TODO: revist this code when fixing hardlinks +- */ +- break; +- } ++ ret = _quota_dict_get_meta (this, dict, contri_key, &contri, ++ IA_IFREG, _gf_true); ++ if (ret < 0) { ++ ret = mq_create_xattrs_blocking_txn (this, loc); ++ } else { ++ LOCK (&contribution->lock); ++ { ++ contribution->contribution = contri.size; ++ contribution->file_count = contri.file_count; ++ contribution->dir_count = contri.dir_count; + } ++ UNLOCK (&contribution->lock); + +- /* TODO: loc->parent might need to be assigned to corresponding +- * contribution inode. We need to handle hard links here +- */ ++ mq_compute_delta (&delta, &size, &contri); ++ if (!quota_meta_is_null (&delta)) ++ mq_initiate_quota_blocking_txn (this, loc); + } ++ /* TODO: revist this code when fixing hardlinks */ + + out: ++ if (contribution) ++ GF_REF_PUT (contribution); + + return ret; + } +@@ -3952,7 +3979,10 @@ mq_reduce_parent_size (xlator_t *this, loc_t *loc, int64_t contri) + goto out; + + local->ctx = ctx; +- local->contri = contribution; ++ if (contribution) { ++ local->contri = contribution; ++ GF_REF_GET (local->contri); ++ } + + ret = mq_inode_loc_fill (NULL, loc->parent, &local->parent_loc); + if (ret < 0) { +@@ -3996,6 +4026,9 @@ out: + if (local != NULL) + mq_local_unref (this, local); + ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -4030,6 +4063,10 @@ mq_rename_update_newpath (xlator_t *this, loc_t *loc) + + mq_initiate_quota_txn (this, loc); + out: ++ ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +@@ -4045,7 +4082,7 @@ mq_forget (xlator_t *this, quota_inode_ctx_t *ctx) + list_for_each_entry_safe (contri, next, &ctx->contribution_head, + contri_list) { + list_del (&contri->contri_list); +- GF_FREE (contri); ++ GF_REF_PUT (contri); + } + + LOCK_DESTROY (&ctx->lock); +diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h +index a81db7f..2d03dfd 100644 +--- a/xlators/features/marker/src/marker-quota.h ++++ b/xlators/features/marker/src/marker-quota.h +@@ -17,6 +17,7 @@ + + #include "xlator.h" + #include "marker-mem-types.h" ++#include "refcount.h" + + #define QUOTA_XATTR_PREFIX "trusted.glusterfs" + #define QUOTA_DIRTY_KEY "trusted.glusterfs.quota.dirty" +@@ -109,7 +110,8 @@ struct inode_contribution { + int64_t file_count; + int64_t dir_count; + uuid_t gfid; +- gf_lock_t lock; ++ gf_lock_t lock; ++ GF_REF_DECL; + }; + typedef struct inode_contribution inode_contribution_t; + +-- +1.7.1 + diff --git a/SOURCES/0146-cluster-afr-set-pending-xattrs-for-replaced-brick.patch b/SOURCES/0146-cluster-afr-set-pending-xattrs-for-replaced-brick.patch new file mode 100644 index 0000000..22f9b53 --- /dev/null +++ b/SOURCES/0146-cluster-afr-set-pending-xattrs-for-replaced-brick.patch @@ -0,0 +1,357 @@ +From d77a9d1b2ba6aa582685d14e4301e4ea888f34bd Mon Sep 17 00:00:00 2001 +From: Anuradha Talur +Date: Fri, 26 Jun 2015 11:40:00 +0530 +Subject: [PATCH 146/190] cluster/afr : set pending xattrs for replaced brick + + Backport of: http://review.gluster.org/10448/ + +Patch for bug 1140649 was already merged downstream, +commit-id : a4f226f50a2ef943b5db095877bab5a3eebf7283 . + +There were a few amendments to be made. +This patch contains delta changes b/w : +1) http://review.gluster.org/10448/ & +2) https://code.engineering.redhat.com/gerrit/#/c/51021/ + +Change-Id: Iad0c89578706b0b7e424b271977908e830c5236b +BUG: 1140649 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51660 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + tests/basic/afr/replace-brick-self-heal.t | 33 +++++---- + xlators/cluster/afr/src/afr-inode-write.c | 102 ++++++++----------------- + xlators/cluster/afr/src/afr-messages.h | 12 +++- + xlators/cluster/afr/src/afr-self-heal-entry.c | 7 ++ + 4 files changed, 69 insertions(+), 85 deletions(-) + +diff --git a/tests/basic/afr/replace-brick-self-heal.t b/tests/basic/afr/replace-brick-self-heal.t +index 1901466..8ced7df 100644 +--- a/tests/basic/afr/replace-brick-self-heal.t ++++ b/tests/basic/afr/replace-brick-self-heal.t +@@ -3,16 +3,6 @@ + . $(dirname $0)/../../volume.rc + cleanup; + +-function match_dirs { +- diff <(ls $1 | sort) <(ls $2 | sort) +- if [ $? -eq 0 ]; +- then +- echo "Y" +- else +- echo "N" +- fi +-} +- + TEST glusterd + TEST pidof glusterd + TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +@@ -24,12 +14,15 @@ TEST $CLI volume set $V0 cluster.entry-self-heal off + TEST $CLI volume set $V0 self-heal-daemon off + TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; + +-#Create files ++# Create files + for i in {1..5} + do + echo $i > $M0/file$i.txt + done + ++# Metadata changes ++TEST setfattr -n user.test -v qwerty $M0/file5.txt ++ + # Replace brick1 + TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force + +@@ -45,15 +38,27 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 + + TEST $CLI volume set $V0 self-heal-daemon on + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 + +-# Check if heal has happened +-EXPECT_WITHIN $HEAL_TIMEOUT "Y" match_dirs $B0/${V0}0 $B0/${V0}1_new ++# Wait for heal to complete ++EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 + +-# To make sure that data was not lost from brick0 ++# Check if entry-heal has happened ++TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1_new | sort) ++ ++# To make sure that files were not lost from brick0 + TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1 | sort) + EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0 + + # Test if data was healed ++TEST diff $B0/${V0}0/file1.txt $B0/${V0}1_new/file1.txt ++# To make sure that data was not lost from brick0 + TEST diff $B0/${V0}0/file1.txt $B0/${V0}1/file1.txt ++ ++# Test if metadata was healed and exists on both the bricks ++EXPECT "qwerty" get_text_xattr user.test $B0/${V0}1_new/file5.txt ++EXPECT "qwerty" get_text_xattr user.test $B0/${V0}0/file5.txt ++ + cleanup; +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index 5d32927..8800b81 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -38,6 +38,7 @@ + #include "byte-order.h" + #include "afr-transaction.h" + #include "afr-self-heal.h" ++#include "afr-messages.h" + + static void + __afr_inode_write_finalize (call_frame_t *frame, xlator_t *this) +@@ -979,42 +980,26 @@ afr_rb_set_pending_changelog_cbk (call_frame_t *frame, void *cookie, + + { + afr_local_t *local = NULL; ++ afr_private_t *priv = NULL; + int i = 0; + + local = frame->local; ++ priv = this->private; + i = (long) cookie; + + local->replies[i].valid = 1; + local->replies[i].op_ret = op_ret; + local->replies[i].op_errno = op_errno; ++ gf_msg (this->name, op_ret ? GF_LOG_ERROR : GF_LOG_INFO, ++ op_ret ? op_errno : 0, ++ AFR_MSG_REPLACE_BRICK_STATUS, "Set of pending xattr %s on" ++ " %s.", op_ret ? "failed" : "succeeded", ++ priv->children[i]->name); + + syncbarrier_wake (&local->barrier); + return 0; + } + +-char * +-afr_opret_matrix_generate (afr_private_t *priv, afr_local_t *local) +-{ +- char *matrix = NULL; +- char *ptr = NULL; +- int i = 0; +- +- /* Allocate max amount of chars required, including -ve values +- * and spaces */ +- matrix = GF_CALLOC (priv->child_count, 3 * sizeof (char), +- gf_afr_mt_char); +- if (!matrix) +- return NULL; +- ptr = matrix; +- for (i = 0; i < priv->child_count; i++) { +- if (local->replies[i].valid) +- ptr += sprintf (ptr, "%d ", local->replies[i].op_ret); +- else +- ptr += sprintf (ptr, "-1 "); +- } +- return matrix; +-} +- + int + afr_rb_set_pending_changelog (call_frame_t *frame, xlator_t *this, + unsigned char *locked_nodes) +@@ -1022,7 +1007,6 @@ afr_rb_set_pending_changelog (call_frame_t *frame, xlator_t *this, + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + int ret = 0, i = 0; +- char *matrix = NULL; + + local = frame->local; + priv = this->private; +@@ -1033,22 +1017,18 @@ afr_rb_set_pending_changelog (call_frame_t *frame, xlator_t *this, + + /* It is sufficient if xattrop was successful on one child */ + for (i = 0; i < priv->child_count; i++) { +- if (local->replies[i].valid && +- local->replies[i].op_ret == 0) { +- matrix = afr_opret_matrix_generate (priv, local); +- gf_log (this->name, GF_LOG_DEBUG, "Successfully set " +- "pending changelog. op_ret matrix : [ %s].", +- matrix); ++ if (!local->replies[i].valid) ++ continue; ++ ++ if (local->replies[i].op_ret == 0) { + ret = 0; + goto out; ++ } else { ++ ret = afr_higher_errno (ret, ++ local->replies[i].op_errno); + } +- ret = afr_higher_errno (ret, local->replies[i].op_errno); + } +- gf_log (this->name, GF_LOG_ERROR, "Couldn't set pending xattr " +- "on any child. (%s)", strerror (ret)); + out: +- if (matrix) +- GF_FREE (matrix); + return -ret; + } + +@@ -1060,9 +1040,6 @@ _afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame, + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + unsigned char *locked_nodes = NULL; +- struct gf_flock flock = {0, }; +- struct gf_flock unflock = {0, }; +- int i = 0; + int count = 0; + int ret = -ENOMEM; + int idx = -1; +@@ -1079,10 +1056,7 @@ _afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame, + if (!local->pending) + goto out; + +- for (i = 0; i < priv->child_count; i++) { +- if (i == rb_index) +- local->pending[i][idx] = hton32 (1); +- } ++ local->pending[rb_index][idx] = hton32 (1); + + local->xdata_req = dict_new (); + if (!local->xdata_req) +@@ -1093,16 +1067,13 @@ _afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame, + goto out; + + if (AFR_ENTRY_TRANSACTION == type) { +- AFR_SEQ (frame, afr_selfheal_lock_cbk, entrylk, this->name, +- loc, NULL, ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL); ++ count = afr_selfheal_entrylk (frame, this, loc->inode, ++ this->name, NULL, locked_nodes); + } else { +- flock.l_type = F_WRLCK; +- flock.l_start = LLONG_MAX - 1; +- flock.l_len = 0; +- AFR_SEQ (frame, afr_selfheal_lock_cbk, inodelk, this->name, +- loc, F_SETLKW, &flock, NULL); ++ count = afr_selfheal_inodelk (frame, this, loc->inode, ++ this->name, LLONG_MAX - 1, 0, ++ locked_nodes); + } +- count = afr_locked_fill (frame, this, locked_nodes); + + if (!count) { + gf_log (this->name, GF_LOG_ERROR, "Couldn't acquire lock on" +@@ -1117,15 +1088,11 @@ _afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame, + ret = 0; + unlock: + if (AFR_ENTRY_TRANSACTION == type) { +- AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk, +- entrylk, this->name, loc, NULL, ENTRYLK_UNLOCK, +- ENTRYLK_WRLCK, NULL); ++ afr_selfheal_unentrylk (frame, this, loc->inode, this->name, ++ NULL, locked_nodes); + } else { +- unflock.l_type = F_UNLCK; +- unflock.l_start = LLONG_MAX - 1; +- unflock.l_len = 0; +- AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk, +- inodelk, this->name, loc, F_SETLK, &unflock, NULL); ++ afr_selfheal_uninodelk (frame, this, loc->inode, this->name, ++ LLONG_MAX - 1, 0, locked_nodes); + } + out: + return ret; +@@ -1162,6 +1129,8 @@ _afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, + + dict_unref (local->xdata_req); + afr_matrix_cleanup (local->pending, priv->child_count); ++ local->pending = NULL; ++ local->xdata_req = NULL; + + ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index, + AFR_ENTRY_TRANSACTION); +@@ -1379,21 +1348,14 @@ int + afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, + dict_t *dict) + { +- int len = 0; + int ret = -1; + int rb_index = -1; +- int op_errno = EPERM; +- void *value = NULL; + char *replace_brick = NULL; + +- ret = dict_get_ptr_and_len (dict, GF_AFR_REPLACE_BRICK, &value, +- &len); +- +- if (value) { +- replace_brick = alloca0 (len + 1); +- memcpy (replace_brick, value, len); ++ ret = dict_get_str (dict, GF_AFR_REPLACE_BRICK, &replace_brick); + +- if (!(frame->root->pid == GF_CLIENT_PID_AFR_SELF_HEALD)) { ++ if (!ret) { ++ if (frame->root->pid != GF_CLIENT_PID_AFR_SELF_HEALD) { + ret = 1; + goto out; + } +@@ -1412,8 +1374,8 @@ out: + if (ret == 1) { + gf_log (this->name, GF_LOG_ERROR, "'%s' is an internal" + " extended attribute : %s.", +- GF_AFR_REPLACE_BRICK, strerror (op_errno)); +- AFR_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); ++ GF_AFR_REPLACE_BRICK, strerror (EPERM)); ++ AFR_STACK_UNWIND (setxattr, frame, -1, EPERM, NULL); + ret = 0; + } + return ret; +diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h +index 52bdead..66b8ed1 100644 +--- a/xlators/cluster/afr/src/afr-messages.h ++++ b/xlators/cluster/afr/src/afr-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLFS_COMP_BASE_AFR GLFS_MSGID_COMP_AFR +-#define GLFS_NUM_MESSAGES 10 ++#define GLFS_NUM_MESSAGES 11 + #define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1) + + #define glfs_msg_start_x GLFS_COMP_BASE_AFR, "Invalid: Start of messages" +@@ -142,6 +142,16 @@ + #define AFR_MSG_INODE_UNLOCK_FAIL (GLFS_COMP_BASE_AFR + 10) + + ++/*! ++ * @messageid 108011 ++ * @diagnosis Setting of pending xattrs succeeded/failed during replace-brick ++ * operation. ++ * @recommendedaction In case of failure, error number in the log should give ++ * the reason why it failed. Also observe brick logs for more information. ++*/ ++#define AFR_MSG_REPLACE_BRICK_STATUS (GLFS_COMP_BASE_AFR + 11) ++ ++ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + #endif /* !_AFR_MESSAGES_H_ */ +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index e64b6e4..12da920 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -295,6 +295,13 @@ __afr_selfheal_merge_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, + return 0; + } + ++ /* Set all the sources as 1, otheriwse newentry_mark won't be set */ ++ for (i = 0; i < priv->child_count; i++) { ++ if (replies[i].valid && replies[i].op_ret == 0) { ++ sources[i] = 1; ++ } ++ } ++ + /* In case of a gfid or type mismatch on the entry, return -1.*/ + ret = afr_selfheal_detect_gfid_and_type_mismatch (this, replies, + fd->inode->gfid, +-- +1.7.1 + diff --git a/SOURCES/0147-common-utils-libglusterfs-Porting-to-a-new-logging-f.patch b/SOURCES/0147-common-utils-libglusterfs-Porting-to-a-new-logging-f.patch new file mode 100644 index 0000000..90ea158 --- /dev/null +++ b/SOURCES/0147-common-utils-libglusterfs-Porting-to-a-new-logging-f.patch @@ -0,0 +1,3073 @@ +From a1c3e736d46f0b9952918193dad78c05a07eaab0 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:28:30 +0530 +Subject: [PATCH 147/190] common-utils/libglusterfs : Porting to a new logging framework + +Change-Id: Iee1c083774c988375a7261cfd6d510ed4c574de2 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10824 +Tested-by: Gluster Build System +Reviewed-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/51146 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/common-utils.c | 332 +++++++++------- + libglusterfs/src/common-utils.h | 38 ++- + libglusterfs/src/libglusterfs-messages.h | 628 ++++++++++-------------------- + 3 files changed, 412 insertions(+), 586 deletions(-) + +diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c +index 4bcef6a..be5d897 100644 +--- a/libglusterfs/src/common-utils.c ++++ b/libglusterfs/src/common-utils.c +@@ -50,6 +50,7 @@ + #include "lkowner.h" + #include "syscall.h" + #include ++#include "libglusterfs-messages.h" + + #ifndef AI_ADDRCONFIG + #define AI_ADDRCONFIG 0 +@@ -95,8 +96,8 @@ mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) + dir[i] = '\0'; + ret = mkdir (dir, mode); + if (ret && errno != EEXIST) { +- gf_log ("", GF_LOG_ERROR, "Failed due to reason %s", +- strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, ++ "Failed due to reason %s", strerror (errno)); + goto out; + } + +@@ -107,8 +108,9 @@ mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) + + if (S_ISLNK (stbuf.st_mode)) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "%s is a symlink", +- dir); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ LG_MSG_DIR_IS_SYMLINK, "%s is a " ++ "symlink", dir); + goto out; + } + } +@@ -119,8 +121,9 @@ mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) + ret = stat (dir, &stbuf); + if (ret || !S_ISDIR (stbuf.st_mode)) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Failed to create directory, " +- "possibly some of the components were not directories"); ++ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_DIR_OP_FAILED, "Failed to " ++ "create directory, possibly some of the components " ++ "were not directories"); + goto out; + } + +@@ -196,16 +199,17 @@ gf_rev_dns_lookup (const char *ip) + sizeof (host_addr), NULL, 0, 0); + + if (ret != 0) { +- gf_log ("resolver", GF_LOG_INFO, "could not resolve hostname " +- "for %s: %s", ip, strerror (errno)); ++ gf_msg ("resolver", GF_LOG_INFO, errno, ++ LG_MSG_RESOLVE_HOSTNAME_FAILED, "could not resolve " ++ "hostname for %s: %s", ip, strerror (errno)); + goto out; + } + + /* Get the FQDN */ + fqdn = gf_strdup (host_addr); + if (!fqdn) +- gf_log ("resolver", GF_LOG_CRITICAL, "Allocation failed for " +- "the host address"); ++ gf_msg ("resolver", GF_LOG_CRITICAL, 0, LG_MSG_NO_MEMORY, ++ "Allocation failed for the host address"); + + out: + return fqdn; +@@ -227,7 +231,8 @@ gf_resolve_path_parent (const char *path) + GF_VALIDATE_OR_GOTO (THIS->name, path, out); + + if (strlen (path) <= 0) { +- gf_log_callingfn (THIS->name, GF_LOG_DEBUG, ++ gf_msg_callingfn (THIS->name, GF_LOG_DEBUG, 0, ++ LG_MSG_INVALID_STRING, + "invalid string for 'path'"); + goto out; + } +@@ -235,7 +240,7 @@ gf_resolve_path_parent (const char *path) + /* dup the parameter, we don't want to modify it */ + pathc = strdupa (path); + if (!pathc) { +- gf_log (THIS->name, GF_LOG_CRITICAL, ++ gf_msg (THIS->name, GF_LOG_CRITICAL, 0, LG_MSG_NO_MEMORY, + "Allocation failed for the parent"); + goto out; + } +@@ -247,7 +252,7 @@ gf_resolve_path_parent (const char *path) + + parent = gf_strdup (tmp); + if (!parent) +- gf_log (THIS->name, GF_LOG_CRITICAL, ++ gf_msg (THIS->name, GF_LOG_CRITICAL, 0, LG_MSG_NO_MEMORY, + "Allocation failed for the parent"); + out: + return parent; +@@ -266,7 +271,8 @@ gf_resolve_ip6 (const char *hostname, + char service[NI_MAXSERV], host[NI_MAXHOST]; + + if (!hostname) { +- gf_log_callingfn ("resolver", GF_LOG_WARNING, "hostname is NULL"); ++ gf_msg_callingfn ("resolver", GF_LOG_WARNING, 0, ++ LG_MSG_HOSTNAME_NULL, "hostname is NULL"); + return -1; + } + +@@ -281,15 +287,13 @@ gf_resolve_ip6 (const char *hostname, + if (cache->first && !cache->next) { + freeaddrinfo(cache->first); + cache->first = cache->next = NULL; +- gf_log ("resolver", GF_LOG_TRACE, +- "flushing DNS cache"); ++ gf_msg_trace ("resolver", 0, "flushing DNS cache"); + } + + if (!cache->first) { + char *port_str = NULL; +- gf_log ("resolver", GF_LOG_TRACE, +- "DNS cache not present, freshly probing hostname: %s", +- hostname); ++ gf_msg_trace ("resolver", 0, "DNS cache not present, freshly " ++ "probing hostname: %s", hostname); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = family; +@@ -300,12 +304,14 @@ gf_resolve_ip6 (const char *hostname, + + ret = gf_asprintf (&port_str, "%d", port); + if (-1 == ret) { +- gf_log ("resolver", GF_LOG_ERROR, "asprintf failed"); ++ gf_msg ("resolver", GF_LOG_ERROR, 0, ++ LG_MSG_ASPRINTF_FAILED, "asprintf failed"); + return -1; + } + if ((ret = getaddrinfo(hostname, port_str, &hints, &cache->first)) != 0) { +- gf_log ("resolver", GF_LOG_ERROR, +- "getaddrinfo failed (%s)", gai_strerror (ret)); ++ gf_msg ("resolver", GF_LOG_ERROR, ret, ++ LG_MSG_GETADDRINFO_FAILED, "getaddrinfo failed" ++ " (%s)", gai_strerror (ret)); + + GF_FREE (*dnscache); + *dnscache = NULL; +@@ -324,14 +330,15 @@ gf_resolve_ip6 (const char *hostname, + service, sizeof (service), + NI_NUMERICHOST); + if (ret != 0) { +- gf_log ("resolver", GF_LOG_ERROR, +- "getnameinfo failed (%s)", gai_strerror (ret)); ++ gf_msg ("resolver", GF_LOG_ERROR, 0, ++ LG_MSG_GETNAMEINFO_FAILED, "getnameinfo failed" ++ " (%s)", gai_strerror (ret)); + goto err; + } + +- gf_log ("resolver", GF_LOG_DEBUG, +- "returning ip-%s (port-%s) for hostname: %s and port: %d", +- host, service, hostname, port); ++ gf_msg_debug ("resolver", 0, "returning ip-%s (port-%s) for " ++ "hostname: %s and port: %d", host, service, ++ hostname, port); + + *addr_info = cache->next; + } +@@ -345,13 +352,14 @@ gf_resolve_ip6 (const char *hostname, + service, sizeof (service), + NI_NUMERICHOST); + if (ret != 0) { +- gf_log ("resolver", GF_LOG_ERROR, +- "getnameinfo failed (%s)", gai_strerror (ret)); ++ gf_msg ("resolver", GF_LOG_ERROR, 0, ++ LG_MSG_GETNAMEINFO_FAILED, "getnameinfo failed" ++ " (%s)", gai_strerror (ret)); + goto err; + } + +- gf_log ("resolver", GF_LOG_DEBUG, +- "next DNS query will return: ip-%s port-%s", host, service); ++ gf_msg_debug ("resolver", 0, "next DNS query will return: " ++ "ip-%s port-%s", host, service); + } + + return 0; +@@ -666,7 +674,8 @@ gf_strsplit (const char *str, const char *delim, + int j = 0; + + if (str == NULL || delim == NULL || tokens == NULL || token_count == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + return -1; + } + +@@ -731,7 +740,8 @@ gf_strstr (const char *str, const char *delim, const char *match) + tmp_str = strdup (str); + + if (str == NULL || delim == NULL || match == NULL || tmp_str == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + ret = -1; + goto out; + } +@@ -761,7 +771,8 @@ gf_volume_name_validate (const char *volume_name) + const char *vname = NULL; + + if (volume_name == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + return -1; + } + +@@ -786,7 +797,8 @@ gf_string2time (const char *str, uint32_t *n) + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -863,7 +875,8 @@ gf_string2percent (const char *str, double *n) + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -906,7 +919,8 @@ _gf_string2long (const char *str, long *n, int base) + int old_errno = 0; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -940,7 +954,8 @@ _gf_string2ulong (const char *str, unsigned long *n, int base) + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -982,7 +997,8 @@ _gf_string2uint (const char *str, unsigned int *n, int base) + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1023,7 +1039,8 @@ _gf_string2double (const char *str, double *n) + int old_errno = 0; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1056,7 +1073,8 @@ _gf_string2longlong (const char *str, long long *n, int base) + int old_errno = 0; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1090,7 +1108,8 @@ _gf_string2ulonglong (const char *str, unsigned long long *n, int base) + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1459,8 +1478,8 @@ gf_string2bytesize_range (const char *str, uint64_t *n, uint64_t max) + gf_boolean_t fraction = _gf_false; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1575,8 +1594,8 @@ gf_string2percent_or_bytesize (const char *str, double *n, + const char *s = NULL; + + if (str == NULL || n == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + errno = EINVAL; + return -1; + } +@@ -1673,7 +1692,8 @@ int + gf_string2boolean (const char *str, gf_boolean_t *b) + { + if (str == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + return -1; + } + +@@ -1791,8 +1811,8 @@ get_checksum_for_path (char *path, uint32_t *checksum) + fd = open (path, O_RDWR); + + if (fd == -1) { +- gf_log (THIS->name, GF_LOG_ERROR, "Unable to open %s, errno: %d", +- path, errno); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, LG_MSG_PATH_ERROR, ++ "Unable to open %s, errno: %d", path, errno); + goto out; + } + +@@ -1825,7 +1845,8 @@ get_file_mtime (const char *path, time_t *stamp) + + ret = stat (path, &f_stat); + if (ret < 0) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to stat %s: %s", ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ LG_MSG_FILE_STAT_FAILED, "failed to stat %s: %s", + path, strerror (errno)); + goto out; + } +@@ -1886,14 +1907,16 @@ gf_is_ip_in_net (const char *network, const char *ip_str) + /* Convert IP address to a long */ + ret = inet_pton (family, ip_str, &ip_buf); + if (ret < 0) +- gf_log ("common-utils", GF_LOG_ERROR, +- "inet_pton() failed with %s", strerror (errno)); ++ gf_msg ("common-utils", GF_LOG_ERROR, errno, ++ LG_MSG_INET_PTON_FAILED, "inet_pton() failed with %s", ++ strerror (errno)); + + /* Convert network IP address to a long */ + ret = inet_pton (family, net_ip, &net_ip_buf); + if (ret < 0) { +- gf_log ("common-utils", GF_LOG_ERROR, +- "inet_pton() failed with %s", strerror (errno)); ++ gf_msg ("common-utils", GF_LOG_ERROR, errno, ++ LG_MSG_INET_PTON_FAILED, "inet_pton() failed with %s", ++ strerror (errno)); + goto out; + } + +@@ -2123,8 +2146,8 @@ valid_ipv4_subnetwork (const char *address) + gf_boolean_t retv = _gf_true; + + if (address == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + return _gf_false; + } + +@@ -2138,8 +2161,9 @@ valid_ipv4_subnetwork (const char *address) + */ + slash = strchr(paddr, '/'); + if ((slash == NULL) || (slash[1] == '\0')) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "Invalid IPv4 subnetwork format"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_IPV4_FORMAT, "Invalid IPv4 " ++ "subnetwork format"); + retv = _gf_false; + goto out; + } +@@ -2147,7 +2171,8 @@ valid_ipv4_subnetwork (const char *address) + *slash = '\0'; + retv = valid_ipv4_address (paddr, strlen(paddr), _gf_false); + if (retv == _gf_false) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_IPV4_FORMAT, + "Invalid IPv4 subnetwork address"); + goto out; + } +@@ -2155,7 +2180,8 @@ valid_ipv4_subnetwork (const char *address) + prefixlen = strtol (slash + 1, &endptr, 10); + if ((errno != 0) || (*endptr != '\0') || + (prefixlen < 0) || (prefixlen > IPv4_ADDR_SIZE)) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_IPV4_FORMAT, + "Invalid IPv4 subnetwork mask"); + retv = _gf_false; + goto out; +@@ -2230,7 +2256,8 @@ valid_internet_address (char *address, gf_boolean_t wildcard_acc) + int length = 0; + + if (address == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + goto out; + } + +@@ -2270,8 +2297,8 @@ valid_mount_auth_address (char *address) + + /* 1. Check for "NULL and empty string */ + if ((address == NULL) || (address[0] == '\0')){ +- gf_log_callingfn (THIS->name, +- GF_LOG_WARNING, "argument invalid"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "argument invalid"); + return _gf_false; + } + +@@ -2318,8 +2345,8 @@ gf_sock_union_equal_addr (union gf_sock_union *a, + union gf_sock_union *b) + { + if (!a || !b) { +- gf_log ("common-utils", GF_LOG_ERROR, "Invalid arguments" +- " to gf_sock_union_equal_addr"); ++ gf_msg ("common-utils", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, ++ "Invalid arguments to gf_sock_union_equal_addr"); + return _gf_false; + } + +@@ -2342,8 +2369,8 @@ gf_sock_union_equal_addr (union gf_sock_union *a, + return _gf_true; + + default: +- gf_log ("common-utils", GF_LOG_DEBUG, +- "Unsupported/invalid address family"); ++ gf_msg_debug ("common-utils", 0, "Unsupported/invalid address " ++ "family"); + break; + } + +@@ -2482,8 +2509,8 @@ gf_roundup_power_of_two (int32_t nr) + int32_t result = 1; + + if (nr < 0) { +- gf_log ("common-utils", GF_LOG_WARNING, +- "negative number passed"); ++ gf_msg ("common-utils", GF_LOG_WARNING, 0, ++ LG_MSG_NEGATIVE_NUM_PASSED, "negative number passed"); + result = -1; + goto out; + } +@@ -2506,8 +2533,8 @@ gf_roundup_next_power_of_two (int32_t nr) + int32_t result = 1; + + if (nr < 0) { +- gf_log ("common-utils", GF_LOG_WARNING, +- "negative number passed"); ++ gf_msg ("common-utils", GF_LOG_WARNING, 0, ++ LG_MSG_NEGATIVE_NUM_PASSED, "negative number passed"); + result = -1; + goto out; + } +@@ -2673,7 +2700,7 @@ gf_canonicalize_path (char *path) + + out: + if (ret) +- gf_log ("common-utils", GF_LOG_ERROR, ++ gf_msg ("common-utils", GF_LOG_ERROR, 0, LG_MSG_PATH_ERROR, + "Path manipulation failed"); + + GF_FREE(tmppath); +@@ -2717,14 +2744,14 @@ generate_glusterfs_ctx_id (void) + char now_str[32]; + + if (gettimeofday (&tv, NULL) == -1) { +- gf_log ("glusterfsd", GF_LOG_ERROR, +- "gettimeofday: failed %s", +- strerror (errno)); ++ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, ++ LG_MSG_GETTIMEOFDAY_FAILED, "gettimeofday: " ++ "failed %s", strerror (errno)); + } + + if (gethostname (hostname, 256) == -1) { +- gf_log ("glusterfsd", GF_LOG_ERROR, +- "gethostname: failed %s", ++ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, ++ LG_MSG_GETHOSTNAME_FAILED, "gethostname: failed %s", + strerror (errno)); + } + +@@ -2757,18 +2784,19 @@ gf_get_reserved_ports () + * continue with older method of using any of the available + * port? For now 2nd option is considered. + */ +- gf_log ("glusterfs", GF_LOG_WARNING, "could not open " +- "the file /proc/sys/net/ipv4/ip_local_reserved_ports " +- "for getting reserved ports info (%s)", +- strerror (errno)); ++ gf_msg ("glusterfs", GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "could not open the file " ++ "/proc/sys/net/ipv4/ip_local_reserved_ports for " ++ "getting reserved ports info (%s)", strerror (errno)); + goto out; + } + + ret = read (proc_fd, buffer, sizeof (buffer)); + if (ret < 0) { +- gf_log ("glusterfs", GF_LOG_WARNING, "could not " +- "read the file %s for getting reserved ports " +- "info (%s)", proc_file, strerror (errno)); ++ gf_msg ("glusterfs", GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "could not read the file %s for" ++ " getting reserved ports info (%s)", proc_file, ++ strerror (errno)); + goto out; + } + ports_info = gf_strdup (buffer); +@@ -2791,8 +2819,9 @@ gf_process_reserved_ports (gf_boolean_t *ports) + + ports_info = gf_get_reserved_ports (); + if (!ports_info) { +- gf_log ("glusterfs", GF_LOG_WARNING, "Not able to get reserved " +- "ports, hence there is a possibility that glusterfs " ++ gf_msg ("glusterfs", GF_LOG_WARNING, 0, ++ LG_MSG_RESERVED_PORTS_ERROR, "Not able to get reserved" ++ " ports, hence there is a possibility that glusterfs " + "may consume reserved port"); + goto out; + } +@@ -2826,18 +2855,20 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports) + if (gf_string2int16 (blocked_port, &tmp_port1) == 0) { + if (tmp_port1 > (GF_CLIENT_PORT_CEILING - 1) + || tmp_port1 < 0) { +- gf_log ("glusterfs-socket", GF_LOG_WARNING, +- "invalid port %d", tmp_port1); ++ gf_msg ("glusterfs-socket", GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_PORT, "invalid port %d", ++ tmp_port1); + result = _gf_true; + goto out; + } else { +- gf_log ("glusterfs", GF_LOG_DEBUG, +- "blocking port %d", tmp_port1); ++ gf_msg_debug ("glusterfs", 0, "blocking port " ++ "%d", tmp_port1); + ports[tmp_port1] = _gf_true; + } + } else { +- gf_log ("glusterfs-socket", GF_LOG_WARNING, "%s is " +- "not a valid port identifier", blocked_port); ++ gf_msg ("glusterfs-socket", GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_PORT, "%s is not a valid port " ++ "identifier", blocked_port); + result = _gf_true; + goto out; + } +@@ -2868,8 +2899,8 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports) + if (tmp_port2 < 0) + tmp_port2 = 0; + } +- gf_log ("glusterfs", GF_LOG_DEBUG, "lower: %d, higher: %d", +- tmp_port1, tmp_port2); ++ gf_msg_debug ("glusterfs", 0, "lower: %d, higher: %d", ++ tmp_port1, tmp_port2); + for (; tmp_port1 <= tmp_port2; tmp_port1++) + ports[tmp_port1] = _gf_true; + } +@@ -2934,9 +2965,9 @@ gf_get_hostname_from_ip (char *client_ip, char **hostname) + client_hostname, sizeof (client_hostname), + NULL, 0, 0); + if (ret) { +- gf_log ("common-utils", GF_LOG_ERROR, +- "Could not lookup hostname of %s : %s", +- client_ip, gai_strerror (ret)); ++ gf_msg ("common-utils", GF_LOG_ERROR, 0, ++ LG_MSG_GETNAMEINFO_FAILED, "Could not lookup hostname " ++ "of %s : %s", client_ip, gai_strerror (ret)); + ret = -1; + goto out; + } +@@ -2965,8 +2996,8 @@ gf_interface_search (char *ip) + ret = getifaddrs (&ifaddr); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "getifaddrs() failed: %s\n", +- gai_strerror(ret)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, LG_MSG_GETIFADDRS_FAILED, ++ "getifaddrs() failed: %s\n", gai_strerror(ret)); + goto out; + } + +@@ -2990,9 +3021,9 @@ gf_interface_search (char *ip) + host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "getnameinfo() failed: %s\n", +- gai_strerror(ret)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ LG_MSG_GETNAMEINFO_FAILED, "getnameinfo() " ++ "failed: %s\n", gai_strerror(ret)); + goto out; + } + +@@ -3008,9 +3039,8 @@ gf_interface_search (char *ip) + } + + if (strncmp (ip, host, NI_MAXHOST) == 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "%s is local address at interface %s", +- ip, ifa->ifa_name); ++ gf_msg_debug (this->name, 0, "%s is local address at " ++ "interface %s", ip, ifa->ifa_name); + found = _gf_true; + goto out; + } +@@ -3042,12 +3072,14 @@ get_ip_from_addrinfo (struct addrinfo *addr, char **ip) + break; + + default: +- gf_log ("glusterd", GF_LOG_ERROR, "Invalid family"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_FAMILY, "Invalid family"); + return NULL; + } + + if (!inet_ntop(addr->ai_family, in_addr, buf, sizeof(buf))) { +- gf_log ("glusterd", GF_LOG_ERROR, "String conversion failed"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, LG_MSG_CONVERSION_FAILED, ++ "String conversion failed"); + return NULL; + } + +@@ -3083,8 +3115,9 @@ gf_is_loopback_localhost (const struct sockaddr *sa, char *hostname) + + default: + if (hostname) +- gf_log ("glusterd", GF_LOG_ERROR, +- "unknown address family %d for %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_FAMILY, "unknown " ++ "address family %d for %s", + sa->sa_family, hostname); + break; + } +@@ -3106,14 +3139,15 @@ gf_is_local_addr (char *hostname) + ret = getaddrinfo (hostname, NULL, NULL, &result); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "error in getaddrinfo: %s\n", +- gai_strerror(ret)); ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ LG_MSG_GETADDRINFO_FAILED, ++ "error in getaddrinfo: %s\n", gai_strerror(ret)); + goto out; + } + + for (res = result; res != NULL; res = res->ai_next) { +- gf_log (this->name, GF_LOG_DEBUG, "%s ", +- get_ip_from_addrinfo (res, &ip)); ++ gf_msg_debug (this->name, 0, "%s ", ++ get_ip_from_addrinfo (res, &ip)); + + found = gf_is_loopback_localhost (res->ai_addr, hostname) + || gf_interface_search (ip); +@@ -3129,7 +3163,7 @@ out: + freeaddrinfo (result); + + if (!found) +- gf_log (this->name, GF_LOG_DEBUG, "%s is not local", hostname); ++ gf_msg_debug (this->name, 0, "%s is not local", hostname); + + return found; + } +@@ -3146,15 +3180,17 @@ gf_is_same_address (char *name1, char *name2) + + gai_err = getaddrinfo(name1,NULL,NULL,&addr1); + if (gai_err != 0) { +- gf_log (name1, GF_LOG_WARNING, +- "error in getaddrinfo: %s\n", gai_strerror(gai_err)); ++ gf_msg (name1, GF_LOG_WARNING, gai_err, ++ LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " ++ "%s\n", gai_strerror(gai_err)); + goto out; + } + + gai_err = getaddrinfo(name2,NULL,NULL,&addr2); + if (gai_err != 0) { +- gf_log (name2, GF_LOG_WARNING, +- "error in getaddrinfo: %s\n", gai_strerror(gai_err)); ++ gf_msg (name2, GF_LOG_WARNING, gai_err, ++ LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " ++ "%s\n", gai_strerror(gai_err)); + goto out; + } + +@@ -3336,8 +3372,8 @@ gf_skip_header_section (int fd, int header_len) + + ret = lseek (fd, header_len, SEEK_SET); + if (ret == (off_t) -1) { +- gf_log ("", GF_LOG_ERROR, "Failed to skip header " +- "section"); ++ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_SKIP_HEADER_FAILED, ++ "Failed to skip header section"); + } else { + ret = 0; + } +@@ -3366,8 +3402,9 @@ gf_is_service_running (char *pidfile, int *pid) + + ret = fscanf (file, "%d", pid); + if (ret <= 0) { +- gf_log ("", GF_LOG_ERROR, "Unable to read pidfile: %s, %s", +- pidfile, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Unable to read pidfile: %s, %s", pidfile, ++ strerror (errno)); + *pid = -1; + } + +@@ -3418,8 +3455,8 @@ gf_check_log_format (const char *value) + log_format = gf_logformat_withmsgid; + + if (log_format == -1) +- gf_log (THIS->name, GF_LOG_ERROR, "Invalid log-format. " +- "possible values are " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_LOG, ++ "Invalid log-format. possible values are " + GF_LOG_FORMAT_NO_MSG_ID "|" GF_LOG_FORMAT_WITH_MSG_ID); + + return log_format; +@@ -3436,8 +3473,8 @@ gf_check_logger (const char *value) + logger = gf_logger_syslog; + + if (logger == -1) +- gf_log (THIS->name, GF_LOG_ERROR, "Invalid logger. " +- "possible values are " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_LOG, ++ "Invalid logger. possible values are " + GF_LOGGER_GLUSTER_LOG "|" GF_LOGGER_SYSLOG); + + return logger; +@@ -3496,7 +3533,8 @@ gf_set_timestamp (const char *src, const char* dest) + + ret = stat (src, &sb); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "stat on %s failed: %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ LG_MSG_FILE_STAT_FAILED, "stat on %s failed: %s", + src, strerror(errno)); + goto out; + } +@@ -3512,8 +3550,8 @@ gf_set_timestamp (const char *src, const char* dest) + */ + ret = utimes (dest, new_time); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "utimes on %s failed: %s", +- dest, strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, LG_MSG_UTIMES_FAILED, ++ "utimes on %s failed: %s", dest, strerror(errno)); + } + out: + return ret; +@@ -3631,7 +3669,8 @@ gf_backtrace_save (char *buf) + if ((0 == gf_backtrace_fillframes (bt))) + return bt; + +- gf_log (THIS->name, GF_LOG_WARNING, "Failed to save the backtrace."); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_BACKTRACE_SAVE_FAILED, ++ "Failed to save the backtrace."); + return NULL; + } + +@@ -3717,16 +3756,16 @@ gf_build_absolute_path (char *current_path, char *relative_path, char **path) + */ + currentpath_len = strlen (current_path); + if (current_path[0] != '/' || (currentpath_len > PATH_MAX)) { +- gf_log (THIS->name, GF_LOG_ERROR, "Wrong value for" +- " current path %s", current_path); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, ++ "Wrong value for current path %s", current_path); + ret = -EINVAL; + goto err; + } + + relativepath_len = strlen (relative_path); + if (relative_path[0] == '/' || (relativepath_len > PATH_MAX)) { +- gf_log (THIS->name, GF_LOG_ERROR, "Wrong value for" +- " relative path %s", relative_path); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, ++ "Wrong value for relative path %s", relative_path); + ret = -EINVAL; + goto err; + } +@@ -3826,8 +3865,8 @@ recursive_rmdir (const char *delete_path) + + dir = opendir (delete_path); + if (!dir) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to open directory %s." +- " Reason : %s", delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to open directory %s. " ++ "Reason : %s", delete_path, strerror (errno)); + ret = 0; + goto out; + } +@@ -3837,8 +3876,8 @@ recursive_rmdir (const char *delete_path) + snprintf (path, PATH_MAX, "%s/%s", delete_path, entry->d_name); + ret = lstat (path, &st); + if (ret == -1) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to stat " +- "entry %s : %s", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to stat entry %s :" ++ " %s", path, strerror (errno)); + goto out; + } + +@@ -3848,27 +3887,26 @@ recursive_rmdir (const char *delete_path) + ret = unlink (path); + + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, " Failed to remove " +- "%s. Reason : %s", path, strerror (errno)); ++ gf_msg_debug (this->name, 0, " Failed to remove %s. " ++ "Reason : %s", path, strerror (errno)); + } + +- gf_log (this->name, GF_LOG_DEBUG, "%s %s", +- ret ? "Failed to remove":"Removed", +- entry->d_name); ++ gf_msg_debug (this->name, 0, "%s %s", ret ? ++ "Failed to remove" : "Removed", entry->d_name); + + GF_FOR_EACH_ENTRY_IN_DIR (entry, dir); + } + + ret = closedir (dir); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to close dir %s. " +- "Reason : %s", delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to close dir %s. Reason :" ++ " %s", delete_path, strerror (errno)); + } + + ret = rmdir (delete_path); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s", +- delete_path, strerror (errno)); ++ gf_msg_debug (this->name, 0, "Failed to rmdir: %s,err: %s", ++ delete_path, strerror (errno)); + } + + out: +diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h +index c361405..ad87559 100644 +--- a/libglusterfs/src/common-utils.h ++++ b/libglusterfs/src/common-utils.h +@@ -42,6 +42,8 @@ void trap (void); + #include "locking.h" + #include "mem-pool.h" + #include "compat-uuid.h" ++#include "uuid.h" ++#include "libglusterfs-messages.h" + + #define STRINGIFY(val) #val + #define TOSTRING(val) STRINGIFY(val) +@@ -174,9 +176,10 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define VALIDATE_OR_GOTO(arg,label) do { \ + if (!arg) { \ + errno = EINVAL; \ +- gf_log_callingfn ((this ? (this->name) : \ ++ gf_msg_callingfn ((this ? (this->name) : \ + "(Govinda! Govinda!)"), \ +- GF_LOG_WARNING, \ ++ GF_LOG_WARNING, EINVAL, \ ++ LG_MSG_INVALID_ARG, \ + "invalid argument: " #arg); \ + goto label; \ + } \ +@@ -185,7 +188,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_VALIDATE_OR_GOTO(name,arg,label) do { \ + if (!arg) { \ + errno = EINVAL; \ +- gf_log_callingfn (name, GF_LOG_ERROR, \ ++ gf_msg_callingfn (name, GF_LOG_ERROR, errno, \ ++ LG_MSG_INVALID_ARG, \ + "invalid argument: " #arg); \ + goto label; \ + } \ +@@ -194,7 +198,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_VALIDATE_OR_GOTO_WITH_ERROR(name, arg, label, errno, error) do { \ + if (!arg) { \ + errno = error; \ +- gf_log_callingfn (name, GF_LOG_ERROR, \ ++ gf_msg_callingfn (name, GF_LOG_ERROR, EINVAL, \ ++ LG_MSG_INVALID_ARG, \ + "invalid argument: " #arg); \ + goto label; \ + } \ +@@ -210,7 +215,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_CHECK_ALLOC_AND_LOG(name, item, retval, msg, errlabel) do { \ + if (!(item)) { \ + (retval) = -ENOMEM; \ +- gf_log (name, GF_LOG_CRITICAL, (msg)); \ ++ gf_msg (name, GF_LOG_CRITICAL, ENOMEM, \ ++ LG_MSG_NO_MEMORY, (msg)); \ + goto errlabel; \ + } \ + } while (0) +@@ -228,7 +234,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + GF_VALIDATE_OR_GOTO (name, arg, label); \ + if ((arg[0]) != '/') { \ + errno = EINVAL; \ +- gf_log_callingfn (name, GF_LOG_ERROR, \ ++ gf_msg_callingfn (name, GF_LOG_ERROR, EINVAL, \ ++ LG_MSG_INVALID_ARG, \ + "invalid argument: " #arg); \ + goto label; \ + } \ +@@ -247,8 +254,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_REMOVE_INTERNAL_XATTR(pattern, dict) \ + do { \ + if (!dict) { \ +- gf_log (this->name, GF_LOG_ERROR, \ +- "dict is null"); \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ LG_MSG_DICT_NULL, "dict is null"); \ + break; \ + } \ + dict_foreach_fnmatch (dict, pattern, \ +@@ -259,7 +266,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_IF_INTERNAL_XATTR_GOTO(pattern, dict, op_errno, label) \ + do { \ + if (!dict) { \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ LG_MSG_DICT_NULL, \ + "setxattr dict is null"); \ + goto label; \ + } \ +@@ -267,7 +275,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + dict_null_foreach_fn, \ + NULL) > 0) { \ + op_errno = EPERM; \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, \ ++ LG_MSG_NO_PERM, \ + "attempt to set internal" \ + " xattr: %s: %s", pattern, \ + strerror (op_errno)); \ +@@ -278,13 +287,15 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_IF_NATIVE_XATTR_GOTO(pattern, key, op_errno, label) \ + do { \ + if (!key) { \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ LG_MSG_NO_KEY, \ + "no key for removexattr"); \ + goto label; \ + } \ + if (!fnmatch (pattern, key, 0)) { \ + op_errno = EPERM; \ +- gf_log (this->name, GF_LOG_ERROR, \ ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, \ ++ LG_MSG_NO_PERM, \ + "attempt to remove internal " \ + "xattr: %s: %s", key, \ + strerror (op_errno)); \ +@@ -302,7 +313,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + #define GF_ASSERT(x) \ + do { \ + if (!(x)) { \ +- gf_log_callingfn ("", GF_LOG_ERROR, \ ++ gf_msg_callingfn ("", GF_LOG_ERROR, 0, \ ++ LG_MSG_ASSERTION_FAILED, \ + "Assertion failed: " #x); \ + } \ + } while (0) +diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h +index e4ced02..8b8af36 100644 +--- a/libglusterfs/src/libglusterfs-messages.h ++++ b/libglusterfs/src/libglusterfs-messages.h +@@ -36,13 +36,13 @@ + */ + + #define GLFS_LG_BASE GLFS_MSGID_COMP_LIBGLUSTERFS +-#define GLFS_LG_NUM_MESSAGES 228 ++#define GLFS_LG_NUM_MESSAGES 201 + #define GLFS_LG_MSGID_END (GLFS_LG_BASE + GLFS_LG_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_lg GLFS_LG_BASE, "Invalid: Start of messages" + /*------------*/ + +-#define LG_MSG_BACK_POLL_EVENT (GLFS_LG_BASE + 1) ++#define LG_MSG_ASPRINTF_FAILED (GLFS_LG_BASE + 1) + + /*! + * @messageid +@@ -50,7 +50,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_ASPRINTF_FAILED (GLFS_LG_BASE + 2) ++#define LG_MSG_INVALID_ENTRY (GLFS_LG_BASE + 2) + + /*! + * @messageid +@@ -58,7 +58,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_ENTRY (GLFS_LG_BASE + 3) ++#define LG_MSG_COUNT_LESS_THAN_ZERO (GLFS_LG_BASE + 3) + + /*! + * @messageid +@@ -66,7 +66,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_BUF_NULL (GLFS_LG_BASE + 4) ++#define LG_MSG_COUNT_LESS_THAN_DATA_PAIRS (GLFS_LG_BASE + 4) + + /*! + * @messageid +@@ -74,7 +74,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_COUNT_LESS_THAN_ZERO (GLFS_LG_BASE + 5) ++#define LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO (GLFS_LG_BASE + 5) + + /*! + * @messageid +@@ -82,7 +82,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_COUNT_LESS_THAN_DATA_PAIRS (GLFS_LG_BASE + 6) ++#define LG_MSG_PAIRS_LESS_THAN_COUNT (GLFS_LG_BASE + 6) + + /*! + * @messageid +@@ -90,7 +90,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PAIR_KEY_NULL (GLFS_LG_BASE + 7) ++#define LG_MSG_KEY_OR_VALUE_NULL (GLFS_LG_BASE + 7) + + /*! + * @messageid +@@ -98,7 +98,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PAIR_VALUE_NULL (GLFS_LG_BASE + 8) ++#define LG_MSG_FAILED_TO_LOG_DICT (GLFS_LG_BASE + 8) + + /*! + * @messageid +@@ -106,15 +106,14 @@ + * @recommendedaction + * + */ +-#define LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO (GLFS_LG_BASE + 9) +- ++#define LG_MSG_NULL_VALUE_IN_DICT (GLFS_LG_BASE + 9) + /*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +-#define LG_MSG_PAIRS_LESS_THAN_COUNT (GLFS_LG_BASE + 10) ++#define LG_MSG_DIR_OP_FAILED (GLFS_LG_BASE + 10) + + /*! + * @messageid +@@ -122,7 +121,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_KEY_OR_VALUE_NULL (GLFS_LG_BASE + 11) ++#define LG_MSG_STORE_HANDLE_CREATE_FAILED (GLFS_LG_BASE + 11) + + /*! + * @messageid +@@ -130,7 +129,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FAILED_TO_LOG_DICT (GLFS_LG_BASE + 12) ++#define LG_MSG_FILE_OP_FAILED (GLFS_LG_BASE + 12) + + /*! + * @messageid +@@ -138,14 +137,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_NULL_VALUE_IN_DICT (GLFS_LG_BASE + 13) +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_DIR_OP_FAILED (GLFS_LG_BASE + 14) ++#define LG_MSG_FILE_STAT_FAILED (GLFS_LG_BASE + 13) + + /*! + * @messageid +@@ -153,7 +145,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_STORE_HANDLE_CREATE_FAILED (GLFS_LG_BASE + 15) ++#define LG_MSG_LOCK_GAIN_FAILED (GLFS_LG_BASE + 14) + + /*! + * @messageid +@@ -161,7 +153,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SYNC_FAILED (GLFS_LG_BASE + 16) ++#define LG_MSG_LOCK_RELEASE_FAILED (GLFS_LG_BASE + 15) + + /*! + * @messageid +@@ -169,7 +161,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_RENAME_FAILED (GLFS_LG_BASE + 17) ++#define LG_MSG_DICT_SERIAL_FAILED (GLFS_LG_BASE + 16) + + /*! + * @messageid +@@ -177,7 +169,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FILE_OP_FAILED (GLFS_LG_BASE + 18) ++#define LG_MSG_DICT_UNSERIAL_FAILED (GLFS_LG_BASE + 17) + + /*! + * @messageid +@@ -185,7 +177,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_STORE_KEY_VALUE_FAILED (GLFS_LG_BASE + 19) ++#define LG_MSG_NO_MEMORY (GLFS_LG_BASE + 18) + + /*! + * @messageid +@@ -193,7 +185,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FFLUSH_FAILED (GLFS_LG_BASE + 20) ++#define LG_MSG_VOLUME_ERROR (GLFS_LG_BASE + 19) + + /*! + * @messageid +@@ -201,7 +193,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FILE_STAT_FAILED (GLFS_LG_BASE + 21) ++#define LG_MSG_SUB_VOLUME_ERROR (GLFS_LG_BASE + 20) + + /*! + * @messageid +@@ -209,7 +201,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_LOCK_GAIN_FAILED (GLFS_LG_BASE + 22) ++#define LG_MSG_SYNTAX_ERROR (GLFS_LG_BASE + 21) + + /*! + * @messageid +@@ -217,7 +209,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_LOCK_RELEASE_FAILED (GLFS_LG_BASE + 23) ++#define LG_MSG_BACKTICK_PARSE_FAILED (GLFS_LG_BASE + 22) + + /*! + * @messageid +@@ -225,7 +217,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_MOVE_FAILED (GLFS_LG_BASE + 24) ++#define LG_MSG_BUFFER_ERROR (GLFS_LG_BASE + 23) + + /*! + * @messageid +@@ -233,7 +225,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_SERIAL_FAILED (GLFS_LG_BASE + 25) ++#define LG_MSG_STRDUP_ERROR (GLFS_LG_BASE + 24) + + /*! + * @messageid +@@ -241,7 +233,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_UNSERIAL_FAILED (GLFS_LG_BASE + 26) ++#define LG_MSG_HASH_FUNC_ERROR (GLFS_LG_BASE + 25) + + /*! + * @messageid +@@ -249,31 +241,15 @@ + * @recommendedaction + * + */ +-#define LG_MSG_NO_MEMORY (GLFS_LG_BASE + 27) +- ++#define LG_MSG_GET_BUCKET_FAILED (GLFS_LG_BASE + 26) + /*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +-#define LG_MSG_VOLUME_ERROR (GLFS_LG_BASE + 28) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_SUB_VOLUME_ERROR (GLFS_LG_BASE + 29) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_SYNTAX_ERROR (GLFS_LG_BASE + 30) ++#define LG_MSG_INSERT_FAILED (GLFS_LG_BASE + 27) + + /*! + * @messageid +@@ -281,7 +257,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_BACKTICK_PARSE_FAILED (GLFS_LG_BASE + 31) ++#define LG_MSG_OUT_OF_RANGE (GLFS_LG_BASE + 28) + + /*! + * @messageid +@@ -289,7 +265,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_BUFFER_ERROR (GLFS_LG_BASE + 32) ++#define LG_MSG_VALIDATE_RETURNS (GLFS_LG_BASE + 29) + + /*! + * @messageid +@@ -297,7 +273,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GETTIMEOFDAY_FUNCTION_FAILED (GLFS_LG_BASE + 33) ++#define LG_MSG_VALIDATE_REC_FAILED (GLFS_LG_BASE + 30) + + /*! + * @messageid +@@ -305,15 +281,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DUMP_CALL_POOL_FAILED (GLFS_LG_BASE + 34) +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ + +-#define LG_MSG_STRDUP_ERROR (GLFS_LG_BASE + 35) ++#define LG_MSG_RB_TABLE_CREATE_FAILED (GLFS_LG_BASE + 31) + + /*! + * @messageid +@@ -321,23 +290,9 @@ + * @recommendedaction + * + */ +-#define LG_MSG_HASH_FUNC_ERROR (GLFS_LG_BASE + 36) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_INIT_BUCKET_FAILED (GLFS_LG_BASE + 37) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_GET_ENTRY_FAILED (GLFS_LG_BASE + 38) ++#define LG_MSG_PATH_NOT_FOUND (GLFS_LG_BASE + 32) + + /*! + * @messageid +@@ -345,15 +300,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GET_BUCKET_FAILED (GLFS_LG_BASE + 39) +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ + +-#define LG_MSG_INSERT_FAILED (GLFS_LG_BASE + 40) ++#define LG_MSG_EXPAND_FD_TABLE_FAILED (GLFS_LG_BASE + 33) + + /*! + * @messageid +@@ -361,7 +309,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INIT_ENTRY_FAILED (GLFS_LG_BASE + 41) ++#define LG_MSG_MAPPING_FAILED (GLFS_LG_BASE + 34) + + /*! + * @messageid +@@ -369,7 +317,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_OUT_OF_RANGE (GLFS_LG_BASE + 42) ++#define LG_MSG_INIT_IOBUF_FAILED (GLFS_LG_BASE + 35) + + /*! + * @messageid +@@ -377,15 +325,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_VALIDATE_RETURNS (GLFS_LG_BASE + 43) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_VALIDATE_REC_FAILED (GLFS_LG_BASE + 44) ++#define LG_MSG_PAGE_SIZE_EXCEEDED (GLFS_LG_BASE + 36) + + /*! + * @messageid +@@ -393,8 +334,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_RB_TABLE_CREATE_FAILED (GLFS_LG_BASE + 45) ++#define LG_MSG_ARENA_NOT_FOUND (GLFS_LG_BASE + 37) + + /*! + * @messageid +@@ -402,9 +342,7 @@ + * @recommendedaction + * + */ +- +- +-#define LG_MSG_PATH_NOT_FOUND (GLFS_LG_BASE + 46) ++#define LG_MSG_IOBUF_NOT_FOUND (GLFS_LG_BASE + 38) + + /*! + * @messageid +@@ -412,9 +350,7 @@ + * @recommendedaction + * + */ +- +- +-#define LG_MSG_CONVERTION_FAILED (GLFS_LG_BASE + 47) ++#define LG_MSG_POOL_NOT_FOUND (GLFS_LG_BASE + 39) + + /*! + * @messageid +@@ -422,8 +358,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_EXPAND_FD_TABLE_FAILED (GLFS_LG_BASE + 48) ++#define LG_MSG_SET_ATTRIBUTE_FAILED (GLFS_LG_BASE + 40) + + /*! + * @messageid +@@ -431,7 +366,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_MAPING_FAILED (GLFS_LG_BASE + 49) ++#define LG_MSG_READ_ATTRIBUTE_FAILED (GLFS_LG_BASE + 41) + + /*! + * @messageid +@@ -439,7 +374,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INIT_IOBUF_FAILED (GLFS_LG_BASE + 50) ++#define LG_MSG_UNMOUNT_FAILED (GLFS_LG_BASE + 42) + + /*! + * @messageid +@@ -447,8 +382,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_PAGE_SIZE_EXCEEDED (GLFS_LG_BASE + 51) ++#define LG_MSG_LATENCY_MEASUREMENT_STATE (GLFS_LG_BASE + 43) + + /*! + * @messageid +@@ -456,7 +390,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_ARENA_NOT_FOUND (GLFS_LG_BASE + 52) ++#define LG_MSG_NO_PERM (GLFS_LG_BASE + 44) + + /*! + * @messageid +@@ -464,7 +398,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_IOBUF_NOT_FOUND (GLFS_LG_BASE + 53) ++#define LG_MSG_NO_KEY (GLFS_LG_BASE + 45) + + /*! + * @messageid +@@ -472,7 +406,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_POOL_NOT_FOUND (GLFS_LG_BASE + 54) ++#define LG_MSG_DICT_NULL (GLFS_LG_BASE + 46) + + /*! + * @messageid +@@ -480,7 +414,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SET_ATTRIBUTE_FAILED (GLFS_LG_BASE + 55) ++#define LG_MSG_INIT_TIMER_FAILED (GLFS_LG_BASE + 47) + + /*! + * @messageid +@@ -488,7 +422,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_READ_ATTRIBUTE_FAILED (GLFS_LG_BASE + 56) ++#define LG_MSG_FD_ANONYMOUS_FAILED (GLFS_LG_BASE + 48) + + /*! + * @messageid +@@ -496,7 +430,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_UNMOUNT_FAILED (GLFS_LG_BASE + 57) ++#define LG_MSG_FD_CREATE_FAILED (GLFS_LG_BASE + 49) + + /*! + * @messageid +@@ -504,7 +438,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_LATENCY_MEASUREMENT_STATE (GLFS_LG_BASE + 58) ++#define LG_MSG_BUFFER_FULL (GLFS_LG_BASE + 50) + + /*! + * @messageid +@@ -512,7 +446,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_NO_PERM (GLFS_LG_BASE + 59) ++#define LG_MSG_FWRITE_FAILED (GLFS_LG_BASE + 51) + + /*! + * @messageid +@@ -520,7 +454,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_NO_KEY (GLFS_LG_BASE + 60) ++#define LG_MSG_PRINT_FAILED (GLFS_LG_BASE + 52) + + /*! + * @messageid +@@ -528,7 +462,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_NULL (GLFS_LG_BASE + 61) ++#define LG_MSG_MEM_POOL_DESTROY (GLFS_LG_BASE + 53) + + /*! + * @messageid +@@ -536,7 +470,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INIT_TIMER_FAILED (GLFS_LG_BASE + 62) ++#define LG_MSG_EXPAND_CLIENT_TABLE_FAILED (GLFS_LG_BASE + 54) + + /*! + * @messageid +@@ -544,7 +478,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_ANONYMOUS_FAILED (GLFS_LG_BASE + 63) ++#define LG_MSG_DISCONNECT_CLIENT (GLFS_LG_BASE + 55) + + /*! + * @messageid +@@ -552,7 +486,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_CREATE_FAILED (GLFS_LG_BASE + 64) ++#define LG_MSG_PIPE_CREATE_FAILED (GLFS_LG_BASE + 56) + + /*! + * @messageid +@@ -560,7 +494,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_BUFFER_FULL (GLFS_LG_BASE + 65) ++#define LG_MSG_SET_PIPE_FAILED (GLFS_LG_BASE + 57) + + /*! + * @messageid +@@ -568,7 +502,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FWRITE_FAILED (GLFS_LG_BASE + 66) ++#define LG_MSG_REGISTER_PIPE_FAILED (GLFS_LG_BASE + 58) + + /*! + * @messageid +@@ -576,7 +510,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PRINT_FAILED (GLFS_LG_BASE + 67) ++#define LG_MSG_POLL_IGNORE_MULTIPLE_THREADS (GLFS_LG_BASE + 59) + + /*! + * @messageid +@@ -584,7 +518,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_MEM_POOL_DESTROY (GLFS_LG_BASE + 68) ++#define LG_MSG_INDEX_NOT_FOUND (GLFS_LG_BASE + 60) + + /*! + * @messageid +@@ -592,7 +526,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_EXPAND_CLIENT_TABLE_FAILED (GLFS_LG_BASE + 69) ++#define LG_MSG_EPOLL_FD_CREATE_FAILED (GLFS_LG_BASE + 61) + + /*! + * @messageid +@@ -600,7 +534,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DISCONNECT_CLIENT (GLFS_LG_BASE + 70) ++#define LG_MSG_SLOT_NOT_FOUND (GLFS_LG_BASE + 62) + + /*! + * @messageid +@@ -608,7 +542,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PIPE_CREATE_FAILED (GLFS_LG_BASE + 71) ++ #define LG_MSG_STALE_FD_FOUND (GLFS_LG_BASE + 63) + + /*! + * @messageid +@@ -616,7 +550,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SET_PIPE_FAILED (GLFS_LG_BASE + 72) ++#define LG_MSG_GENERATION_MISMATCH (GLFS_LG_BASE + 64) + + /*! + * @messageid +@@ -624,7 +558,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_REGISTER_PIPE_FAILED (GLFS_LG_BASE + 73) ++#define LG_MSG_PTHREAD_KEY_CREATE_FAILED (GLFS_LG_BASE + 65) + + /*! + * @messageid +@@ -632,7 +566,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_POLL_IGNORE_MULTIPLE_THREADS (GLFS_LG_BASE + 74) ++#define LG_MSG_TRANSLATOR_INIT_FAILED (GLFS_LG_BASE + 66) + + /*! + * @messageid +@@ -640,7 +574,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INDEX_NOT_FOUND (GLFS_LG_BASE + 75) ++#define LG_MSG_UUID_BUF_INIT_FAILED (GLFS_LG_BASE + 67) + + /*! + * @messageid +@@ -648,7 +582,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_EPOLL_FD_CREATE_FAILED (GLFS_LG_BASE + 76) ++#define LG_MSG_LKOWNER_BUF_INIT_FAILED (GLFS_LG_BASE + 68) + + /*! + * @messageid +@@ -656,7 +590,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SLOT_NOT_FOUND (GLFS_LG_BASE + 77) ++#define LG_MSG_SYNCTASK_INIT_FAILED (GLFS_LG_BASE + 69) + + /*! + * @messageid +@@ -664,7 +598,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_ADD_FAILED (GLFS_LG_BASE + 78) ++#define LG_MSG_SYNCOPCTX_INIT_FAILED (GLFS_LG_BASE + 70) + + /*! + * @messageid +@@ -672,7 +606,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_DEL_FAILED (GLFS_LG_BASE + 79) ++#define LG_MSG_GLOBAL_INIT_FAILED (GLFS_LG_BASE + 71) + + /*! + * @messageid +@@ -680,7 +614,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_MODIFY_FAILED (GLFS_LG_BASE + 80) ++#define LG_MSG_PTHREAD_FAILED (GLFS_LG_BASE + 72) + + /*! + * @messageid +@@ -688,7 +622,7 @@ + * @recommendedaction + * + */ +- #define LG_MSG_STALE_FD_FOUND (GLFS_LG_BASE + 81) ++#define LG_MSG_DIR_IS_SYMLINK (GLFS_LG_BASE + 73) + + /*! + * @messageid +@@ -696,15 +630,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GENERATION_MISMATCH (GLFS_LG_BASE + 82) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_STARTED_THREAD (GLFS_LG_BASE + 83) ++#define LG_MSG_RESOLVE_HOSTNAME_FAILED (GLFS_LG_BASE + 74) + + /*! + * @messageid +@@ -712,15 +639,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_EXITED_THREAD (GLFS_LG_BASE + 84) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_START_THREAD_FAILED (GLFS_LG_BASE + 85) ++#define LG_MSG_GETADDRINFO_FAILED (GLFS_LG_BASE + 75) + + /*! + * @messageid +@@ -728,15 +648,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PTHREAD_KEY_CREATE_FAILED (GLFS_LG_BASE + 86) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_TRANSLATOR_INIT_FAILED (GLFS_LG_BASE + 87) ++#define LG_MSG_GETNAMEINFO_FAILED (GLFS_LG_BASE + 76) + + /*! + * @messageid +@@ -744,15 +657,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_UUID_BUF_INIT_FAILED (GLFS_LG_BASE + 88) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_LKOWNER_BUF_INIT_FAILED (GLFS_LG_BASE + 89) ++#define LG_MSG_PATH_ERROR (GLFS_LG_BASE + 77) + + /*! + * @messageid +@@ -760,15 +666,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SYNCTASK_INIT_FAILED (GLFS_LG_BASE + 90) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_SYNCOPCTX_INIT_FAILED (GLFS_LG_BASE + 91) ++#define LG_MSG_INET_PTON_FAILED (GLFS_LG_BASE + 78) + + /*! + * @messageid +@@ -776,15 +675,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GLOBAL_INIT_FAILED (GLFS_LG_BASE + 92) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_PTHREAD_FAILED (GLFS_LG_BASE + 93) ++#define LG_MSG_NEGATIVE_NUM_PASSED (GLFS_LG_BASE + 79) + + /*! + * @messageid +@@ -792,70 +684,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DIR_IS_SYMLINK (GLFS_LG_BASE + 94) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_RESOLVE_HOSTNAME_FAILED (GLFS_LG_BASE + 95) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_GETADDRINFO_FAILED (GLFS_LG_BASE + 96) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_GETNAMEINFO_FAILED (GLFS_LG_BASE + 97) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_PATH_ERROR (GLFS_LG_BASE + 98) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_INET_PTON_FAILED (GLFS_LG_BASE + 99) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_NEGATIVE_NUM_PASSED (GLFS_LG_BASE + 100) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +- +-#define LG_MSG_GETHOSTNAME_FAILED (GLFS_LG_BASE + 101) ++#define LG_MSG_GETHOSTNAME_FAILED (GLFS_LG_BASE + 80) + + /*! + * @messageid +@@ -864,7 +694,7 @@ + * + */ + +-#define LG_MSG_RESERVED_PORTS_ERROR (GLFS_LG_BASE + 102) ++#define LG_MSG_RESERVED_PORTS_ERROR (GLFS_LG_BASE + 81) + + /*! + * @messageid +@@ -873,7 +703,7 @@ + * + */ + +-#define LG_MSG_INVALID_PORT (GLFS_LG_BASE + 103) ++#define LG_MSG_INVALID_PORT (GLFS_LG_BASE + 82) + + /*! + * @messageid +@@ -882,7 +712,7 @@ + * + */ + +-#define LG_MSG_INVALID_FAMILY (GLFS_LG_BASE + 104) ++#define LG_MSG_INVALID_FAMILY (GLFS_LG_BASE + 83) + + /*! + * @messageid +@@ -891,7 +721,7 @@ + * + */ + +-#define LG_MSG_CONVERSION_FAILED (GLFS_LG_BASE + 105) ++#define LG_MSG_CONVERSION_FAILED (GLFS_LG_BASE + 84) + + /*! + * @messageid +@@ -900,7 +730,7 @@ + * + */ + +-#define LG_MSG_SKIP_HEADER_FAILED (GLFS_LG_BASE + 106) ++#define LG_MSG_SKIP_HEADER_FAILED (GLFS_LG_BASE + 85) + + /*! + * @messageid +@@ -909,7 +739,7 @@ + * + */ + +-#define LG_MSG_INVALID_LOG (GLFS_LG_BASE + 107) ++#define LG_MSG_INVALID_LOG (GLFS_LG_BASE + 86) + + /*! + * @messageid +@@ -918,7 +748,7 @@ + * + */ + +-#define LG_MSG_UTIMES_FAILED (GLFS_LG_BASE + 108) ++#define LG_MSG_UTIMES_FAILED (GLFS_LG_BASE + 87) + + /*! + * @messageid +@@ -927,7 +757,7 @@ + * + */ + +-#define LG_MSG_BACKTRACE_SAVE_FAILED (GLFS_LG_BASE + 109) ++#define LG_MSG_BACKTRACE_SAVE_FAILED (GLFS_LG_BASE + 88) + + /*! + * @messageid +@@ -936,7 +766,7 @@ + * + */ + +-#define LG_MSG_INIT_FAILED (GLFS_LG_BASE + 110) ++#define LG_MSG_INIT_FAILED (GLFS_LG_BASE + 89) + + /*! + * @messageid +@@ -945,7 +775,7 @@ + * + */ + +-#define LG_MSG_VALIDATION_FAILED (GLFS_LG_BASE + 111) ++#define LG_MSG_VALIDATION_FAILED (GLFS_LG_BASE + 90) + + /*! + * @messageid +@@ -954,7 +784,7 @@ + * + */ + +-#define LG_MSG_GRAPH_ERROR (GLFS_LG_BASE + 112) ++#define LG_MSG_GRAPH_ERROR (GLFS_LG_BASE + 91) + + /*! + * @messageid +@@ -963,7 +793,7 @@ + * + */ + +-#define LG_MSG_UNKNOWN_OPTIONS_FAILED (GLFS_LG_BASE + 113) ++#define LG_MSG_UNKNOWN_OPTIONS_FAILED (GLFS_LG_BASE + 92) + + /*! + * @messageid +@@ -972,7 +802,7 @@ + * + */ + +-#define LG_MSG_NOTIFICATION_FAILED (GLFS_LG_BASE + 114) ++#define LG_MSG_CTX_NULL (GLFS_LG_BASE + 93) + + /*! + * @messageid +@@ -981,7 +811,7 @@ + * + */ + +-#define LG_MSG_CTX_NULL (GLFS_LG_BASE + 115) ++#define LG_MSG_TMPFILE_CREATE_FAILED (GLFS_LG_BASE + 94) + + /*! + * @messageid +@@ -990,7 +820,7 @@ + * + */ + +-#define LG_MSG_CTX_ACTIVE_NULL (GLFS_LG_BASE + 116) ++#define LG_MSG_DLOPEN_FAILED (GLFS_LG_BASE + 95) + + /*! + * @messageid +@@ -999,7 +829,7 @@ + * + */ + +-#define LG_MSG_TMPFILE_CREATE_FAILED (GLFS_LG_BASE + 117) ++#define LG_MSG_LOAD_FAILED (GLFS_LG_BASE + 96) + + /*! + * @messageid +@@ -1008,7 +838,7 @@ + * + */ + +-#define LG_MSG_DLOPEN_FAILED (GLFS_LG_BASE + 118) ++#define LG_MSG_DLSYM_ERROR (GLFS_LG_BASE + 97) + + /*! + * @messageid +@@ -1017,7 +847,7 @@ + * + */ + +-#define LG_MSG_LOAD_FAILED (GLFS_LG_BASE + 119) ++#define LG_MSG_TREE_NOT_FOUND (GLFS_LG_BASE + 98) + + /*! + * @messageid +@@ -1026,7 +856,7 @@ + * + */ + +-#define LG_MSG_DLSYM_ERROR (GLFS_LG_BASE + 120) ++#define LG_MSG_PER_DENTRY (GLFS_LG_BASE + 99) + + /*! + * @messageid +@@ -1035,7 +865,7 @@ + * + */ + +-#define LG_MSG_TREE_NOT_FOUND (GLFS_LG_BASE + 121) ++#define LG_MSG_DENTRY (GLFS_LG_BASE + 100) + + /*! + * @messageid +@@ -1044,7 +874,7 @@ + * + */ + +-#define LG_MSG_PER_DENTRY (GLFS_LG_BASE + 122) ++#define LG_MSG_GETIFADDRS_FAILED (GLFS_LG_BASE + 101) + + /*! + * @messageid +@@ -1053,7 +883,7 @@ + * + */ + +-#define LG_MSG_PARENT_NOT_FOUND (GLFS_LG_BASE + 123) ++#define LG_MSG_REGEX_OP_FAILED (GLFS_LG_BASE + 102) + + /*! + * @messageid +@@ -1062,7 +892,7 @@ + * + */ + +-#define LG_MSG_CYCLIC_LOOP (GLFS_LG_BASE + 124) ++#define LG_MSG_FRAME_ERROR (GLFS_LG_BASE + 103) + + /*! + * @messageid +@@ -1071,7 +901,7 @@ + * + */ + +-#define LG_MSG_DENTRY (GLFS_LG_BASE + 125) ++#define LG_MSG_SET_PARAM_FAILED (GLFS_LG_BASE + 104) + + /*! + * @messageid +@@ -1080,7 +910,7 @@ + * + */ + +-#define LG_MSG_INFINITE_LOOP (GLFS_LG_BASE + 126) ++#define LG_MSG_GET_PARAM_FAILED (GLFS_LG_BASE + 105) + + /*! + * @messageid +@@ -1089,7 +919,7 @@ + * + */ + +-#define LG_MSG_GETIFADDRS_FAILED (GLFS_LG_BASE + 127) ++#define LG_MSG_PREPARE_FAILED (GLFS_LG_BASE + 106) + + /*! + * @messageid +@@ -1098,7 +928,7 @@ + * + */ + +-#define LG_MSG_REGEX_OP_FAILED (GLFS_LG_BASE + 128) ++#define LG_MSG_EXEC_FAILED (GLFS_LG_BASE + 107) + + /*! + * @messageid +@@ -1107,7 +937,7 @@ + * + */ + +-#define LG_MSG_FRAME_ERROR (GLFS_LG_BASE + 129) ++#define LG_MSG_BINDING_FAILED (GLFS_LG_BASE + 108) + + /*! + * @messageid +@@ -1116,7 +946,7 @@ + * + */ + +-#define LG_MSG_SET_PARAM_FAILED (GLFS_LG_BASE + 130) ++#define LG_MSG_DELETE_FAILED (GLFS_LG_BASE + 109) + + /*! + * @messageid +@@ -1125,7 +955,7 @@ + * + */ + +-#define LG_MSG_GET_PARAM_FAILED (GLFS_LG_BASE + 131) ++#define LG_MSG_GET_ID_FAILED (GLFS_LG_BASE + 110) + + /*! + * @messageid +@@ -1134,7 +964,7 @@ + * + */ + +-#define LG_MSG_PREPARE_FAILED (GLFS_LG_BASE + 132) ++#define LG_MSG_CREATE_FAILED (GLFS_LG_BASE + 111) + + /*! + * @messageid +@@ -1143,7 +973,7 @@ + * + */ + +-#define LG_MSG_EXEC_FAILED (GLFS_LG_BASE + 133) ++#define LG_MSG_PARSE_FAILED (GLFS_LG_BASE + 112) + + /*! + * @messageid +@@ -1152,8 +982,8 @@ + * + */ + +-#define LG_MSG_BINDING_FAILED (GLFS_LG_BASE + 134) + ++#define LG_MSG_GETCONTEXT_FAILED (GLFS_LG_BASE + 113) + /*! + * @messageid + * @diagnosis +@@ -1161,7 +991,7 @@ + * + */ + +-#define LG_MSG_DELETE_FAILED (GLFS_LG_BASE + 135) ++#define LG_MSG_UPDATE_FAILED (GLFS_LG_BASE + 114) + + /*! + * @messageid +@@ -1170,7 +1000,7 @@ + * + */ + +-#define LG_MSG_GET_ID_FAILED (GLFS_LG_BASE + 136) ++#define LG_MSG_QUERY_CALL_BACK_FAILED (GLFS_LG_BASE + 115) + + /*! + * @messageid +@@ -1179,7 +1009,7 @@ + * + */ + +-#define LG_MSG_CREATE_FAILED (GLFS_LG_BASE + 137) ++#define LG_MSG_GET_RECORD_FAILED (GLFS_LG_BASE + 116) + + /*! + * @messageid +@@ -1188,7 +1018,7 @@ + * + */ + +-#define LG_MSG_PARSE_FAILED (GLFS_LG_BASE + 138) ++#define LG_MSG_DB_ERROR (GLFS_LG_BASE + 117) + + /*! + * @messageid +@@ -1197,8 +1027,8 @@ + * + */ + ++#define LG_MSG_CONNECTION_ERROR (GLFS_LG_BASE + 118) + +-#define LG_MSG_GETCONTEXT_FAILED (GLFS_LG_BASE + 139) + /*! + * @messageid + * @diagnosis +@@ -1206,7 +1036,7 @@ + * + */ + +-#define LG_MSG_UPDATE_FAILED (GLFS_LG_BASE + 140) ++#define LG_MSG_NOT_MULTITHREAD_MODE (GLFS_LG_BASE + 119) + + /*! + * @messageid +@@ -1215,7 +1045,7 @@ + * + */ + +-#define LG_MSG_QUERY_CALL_BACK_FAILED (GLFS_LG_BASE + 141) ++#define LG_MSG_SKIP_PATH (GLFS_LG_BASE + 120) + + /*! + * @messageid +@@ -1224,7 +1054,7 @@ + * + */ + +-#define LG_MSG_GET_RECORD_FAILED (GLFS_LG_BASE + 142) ++#define LG_MSG_INVALID_FOP (GLFS_LG_BASE + 121) + + /*! + * @messageid +@@ -1233,7 +1063,7 @@ + * + */ + +-#define LG_MSG_DB_ERROR (GLFS_LG_BASE + 143) ++#define LG_MSG_QUERY_FAILED (GLFS_LG_BASE + 122) + + /*! + * @messageid +@@ -1242,7 +1072,7 @@ + * + */ + +-#define LG_MSG_CONNECTION_ERROR (GLFS_LG_BASE + 144) ++#define LG_MSG_CLEAR_COUNTER_FAILED (GLFS_LG_BASE + 123) + + /*! + * @messageid +@@ -1251,7 +1081,7 @@ + * + */ + +-#define LG_MSG_NOT_MULTITHREAD_MODE (GLFS_LG_BASE + 145) ++#define LG_MSG_LOCK_LIST_FAILED (GLFS_LG_BASE + 124) + + /*! + * @messageid +@@ -1260,7 +1090,7 @@ + * + */ + +-#define LG_MSG_SKIP_PATH (GLFS_LG_BASE + 146) ++#define LG_MSG_UNLOCK_LIST_FAILED (GLFS_LG_BASE + 125) + + /*! + * @messageid +@@ -1269,7 +1099,7 @@ + * + */ + +-#define LG_MSG_INVALID_FOP (GLFS_LG_BASE + 147) ++#define LG_MSG_ADD_TO_LIST_FAILED (GLFS_LG_BASE + 126) + + /*! + * @messageid +@@ -1278,7 +1108,7 @@ + * + */ + +-#define LG_MSG_QUERY_FAILED (GLFS_LG_BASE + 148) ++#define LG_MSG_INIT_DB_FAILED (GLFS_LG_BASE + 127) + + /*! + * @messageid +@@ -1287,7 +1117,7 @@ + * + */ + +-#define LG_MSG_CLEAR_COUNTER_FAILED (GLFS_LG_BASE + 149) ++#define LG_MSG_DELETE_FROM_LIST_FAILED (GLFS_LG_BASE + 128) + + /*! + * @messageid +@@ -1296,7 +1126,7 @@ + * + */ + +-#define LG_MSG_LOCK_LIST_FAILED (GLFS_LG_BASE + 150) ++#define LG_MSG_CLOSE_CONNECTION_FAILED (GLFS_LG_BASE + 129) + + /*! + * @messageid +@@ -1305,7 +1135,7 @@ + * + */ + +-#define LG_MSG_UNLOCK_LIST_FAILED (GLFS_LG_BASE + 151) ++#define LG_MSG_INSERT_OR_UPDATE_FAILED (GLFS_LG_BASE + 130) + + /*! + * @messageid +@@ -1314,7 +1144,7 @@ + * + */ + +-#define LG_MSG_ADD_TO_LIST_FAILED (GLFS_LG_BASE + 152) ++#define LG_MSG_FIND_OP_FAILED (GLFS_LG_BASE + 131) + + /*! + * @messageid +@@ -1323,7 +1153,7 @@ + * + */ + +-#define LG_MSG_INIT_DB_FAILED (GLFS_LG_BASE + 153) ++#define LG_MSG_CONNECTION_INIT_FAILED (GLFS_LG_BASE + 132) + + /*! + * @messageid +@@ -1332,7 +1162,7 @@ + * + */ + +-#define LG_MSG_DELETE_FROM_LIST_FAILED (GLFS_LG_BASE + 154) ++#define LG_MSG_COMPLETED_TASK (GLFS_LG_BASE + 133) + + /*! + * @messageid +@@ -1341,7 +1171,7 @@ + * + */ + +-#define LG_MSG_CLOSE_CONNECTION_FAILED (GLFS_LG_BASE + 155) ++#define LG_MSG_WAKE_UP_ZOMBIE (GLFS_LG_BASE + 134) + + /*! + * @messageid +@@ -1350,7 +1180,7 @@ + * + */ + +-#define LG_MSG_INSERT_OR_UPDATE_FAILED (GLFS_LG_BASE + 156) ++#define LG_MSG_REWAITING_TASK (GLFS_LG_BASE + 135) + + /*! + * @messageid +@@ -1359,7 +1189,7 @@ + * + */ + +-#define LG_MSG_FIND_OP_FAILED (GLFS_LG_BASE + 157) ++#define LG_MSG_SLEEP_ZOMBIE (GLFS_LG_BASE + 136) + + /*! + * @messageid +@@ -1368,7 +1198,7 @@ + * + */ + +-#define LG_MSG_CONNECTION_INIT_FAILED (GLFS_LG_BASE + 158) ++#define LG_MSG_SWAP_FAILED (GLFS_LG_BASE + 137) + + /*! + * @messageid +@@ -1377,7 +1207,7 @@ + * + */ + +-#define LG_MSG_COMPLETED_TASK (GLFS_LG_BASE + 159) ++#define LG_MSG_UNSUPPORTED_PLUGIN (GLFS_LG_BASE + 138) + + /*! + * @messageid +@@ -1386,7 +1216,7 @@ + * + */ + +-#define LG_MSG_WAKE_UP_ZOMBIE (GLFS_LG_BASE + 160) ++#define LG_MSG_INVALID_DB_TYPE (GLFS_LG_BASE + 139) + + /*! + * @messageid +@@ -1394,8 +1224,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_REWAITING_TASK (GLFS_LG_BASE + 161) ++#define LG_MSG_UNDERSIZED_BUF (GLFS_LG_BASE + 140) + + /*! + * @messageid +@@ -1403,8 +1232,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_SLEEP_ZOMBIE (GLFS_LG_BASE + 162) ++#define LG_MSG_DATA_CONVERSION_ERROR (GLFS_LG_BASE + 141) + + /*! + * @messageid +@@ -1412,8 +1240,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_SWAP_FAILED (GLFS_LG_BASE + 163) ++#define LG_MSG_DICT_ERROR (GLFS_LG_BASE + 142) + + /*! + * @messageid +@@ -1421,8 +1248,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_UNSUPPORTED_PLUGIN (GLFS_LG_BASE + 164) ++#define LG_MSG_IOBUFS_NOT_FOUND (GLFS_LG_BASE + 143) + + /*! + * @messageid +@@ -1430,8 +1256,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_INVALID_DB_TYPE (GLFS_LG_BASE + 165) ++#define LG_MSG_ENTRIES_NULL (GLFS_LG_BASE + 144) + + /*! + * @messageid +@@ -1439,7 +1264,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_NULL_INDEX_IN_BUF (GLFS_LG_BASE + 166) ++#define LG_MSG_FD_NOT_FOUND_IN_FDTABLE (GLFS_LG_BASE + 145) + + /*! + * @messageid +@@ -1447,8 +1272,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_DATA_NULL (GLFS_LG_BASE + 167) ++#define LG_MSG_REALLOC_FOR_FD_PTR_FAILED (GLFS_LG_BASE + 146) + + /*! + * @messageid +@@ -1456,7 +1280,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_OR_KEY_NULL (GLFS_LG_BASE + 168) ++#define LG_MSG_DICT_SET_FAILED (GLFS_LG_BASE + 147) + + /*! + * @messageid +@@ -1464,7 +1288,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_OR_KEY_OR_DATA_NULL (GLFS_LG_BASE + 169) ++#define LG_MSG_NULL_PTR (GLFS_LG_BASE + 148) + + /*! + * @messageid +@@ -1472,7 +1296,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_OR_KEY_VALUE_NULL (GLFS_LG_BASE + 170) ++#define LG_MSG_RBTHASH_INIT_BUCKET_FAILED (GLFS_LG_BASE + 149) + + /*! + * @messageid +@@ -1480,7 +1304,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_VALUE_NULL (GLFS_LG_BASE + 171) ++#define LG_MSG_ASSERTION_FAILED (GLFS_LG_BASE + 150) + + /*! + * @messageid +@@ -1488,7 +1312,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_UNDERSIZED_BUF (GLFS_LG_BASE + 172) ++#define LG_MSG_HOSTNAME_NULL (GLFS_LG_BASE + 151) + + /*! + * @messageid +@@ -1496,7 +1320,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DATA_CONVERSION_ERROR (GLFS_LG_BASE + 173) ++#define LG_MSG_INVALID_IPV4_FORMAT (GLFS_LG_BASE + 152) + + /*! + * @messageid +@@ -1504,7 +1328,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_OR_MATCH_OR_ACTION_NULL (GLFS_LG_BASE + 174) ++#define LG_MSG_CTX_CLEANUP_STARTED (GLFS_LG_BASE + 153) + + /*! + * @messageid +@@ -1512,15 +1336,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_SIZE_ZERO (GLFS_LG_BASE + 175) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_FILL_NULL (GLFS_LG_BASE + 176) ++#define LG_MSG_TIMER_REGISTER_ERROR (GLFS_LG_BASE + 154) + + /*! + * @messageid +@@ -1528,7 +1345,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_UNDESIRED_BUFF (GLFS_LG_BASE + 177) ++#define LG_MSG_PTR_HEADER_CORRUPTED (GLFS_LG_BASE + 155) + + /*! + * @messageid +@@ -1536,7 +1353,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_ERROR (GLFS_LG_BASE + 178) ++#define LG_MSG_INVALID_UPLINK (GLFS_LG_BASE + 156) + + /*! + * @messageid +@@ -1544,15 +1361,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_IOBUFS_NOT_FOUND (GLFS_LG_BASE + 179) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_ENTRIES_NULL (GLFS_LG_BASE + 180) ++#define LG_MSG_CLIENT_NULL (GLFS_LG_BASE + 157) + + /*! + * @messageid +@@ -1560,7 +1370,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_COUNT_NULL (GLFS_LG_BASE + 181) ++#define LG_MSG_XLATOR_DOES_NOT_IMPLEMENT (GLFS_LG_BASE + 158) + + /*! + * @messageid +@@ -1568,7 +1378,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_NOT_FOUND_IN_FDTABLE (GLFS_LG_BASE + 182) ++#define LG_MSG_DENTRY_NOT_FOUND (GLFS_LG_BASE + 159) + + /*! + * @messageid +@@ -1576,7 +1386,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_NULL (GLFS_LG_BASE + 183) ++#define LG_MSG_INODE_NOT_FOUND (GLFS_LG_BASE + 160) + + /*! + * @messageid +@@ -1584,7 +1394,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INODE_NULL (GLFS_LG_BASE + 184) ++#define LG_MSG_INODE_TABLE_NOT_FOUND (GLFS_LG_BASE + 161) + + /*! + * @messageid +@@ -1592,7 +1402,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_FD_OR_INODE_NULL (GLFS_LG_BASE + 185) ++#define LG_MSG_DENTRY_CREATE_FAILED (GLFS_LG_BASE + 162) + + /*! + * @messageid +@@ -1600,7 +1410,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_REALLOC_FOR_FD_PTR_FAILED (GLFS_LG_BASE + 186) ++#define LG_MSG_INODE_CONTEXT_FREED (GLFS_LG_BASE + 163) + + /*! + * @messageid +@@ -1608,7 +1418,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_XLATOR_OR_FD_NULL (GLFS_LG_BASE + 187) ++#define LG_MSG_UNKNOWN_LOCK_TYPE (GLFS_LG_BASE + 164) + + /*! + * @messageid +@@ -1616,7 +1426,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DICT_SET_FAILED (GLFS_LG_BASE + 188) ++#define LG_MSG_UNLOCK_BEFORE_LOCK (GLFS_LG_BASE + 165) + + /*! + * @messageid +@@ -1624,7 +1434,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_READ_HEADER_FAILED (GLFS_LG_BASE + 189) ++#define LG_MSG_LOCK_OWNER_ERROR (GLFS_LG_BASE + 166) + + /*! + * @messageid +@@ -1632,7 +1442,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_READ_FROM_QUOTA_FAILED (GLFS_LG_BASE + 190) ++#define LG_MSG_MEMPOOL_PTR_NULL (GLFS_LG_BASE + 167) + + /*! + * @messageid +@@ -1640,7 +1450,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_ASSERTION_FAILED (GLFS_LG_BASE + 191) ++#define LG_MSG_QUOTA_XATTRS_MISSING (GLFS_LG_BASE + 168) + + /*! + * @messageid +@@ -1648,7 +1458,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_HOSTNAME_NULL (GLFS_LG_BASE + 192) ++#define LG_MSG_INVALID_STRING (GLFS_LG_BASE + 169) + + /*! + * @messageid +@@ -1656,7 +1466,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_IPV4_FORMAT (GLFS_LG_BASE + 193) ++#define LG_MSG_BIND_REF (GLFS_LG_BASE + 170) + + /*! + * @messageid +@@ -1664,7 +1474,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_CTX_CLEANUP_STARTED (GLFS_LG_BASE + 194) ++#define LG_MSG_REF_COUNT (GLFS_LG_BASE + 171) + + /*! + * @messageid +@@ -1672,8 +1482,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_TIMER_REGISTER_ERROR (GLFS_LG_BASE + 195) ++#define LG_MSG_INVALID_ARG (GLFS_LG_BASE + 172) + + /*! + * @messageid +@@ -1681,7 +1490,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_PTR_HEADER_CORRUPTED (GLFS_LG_BASE + 196) ++#define LG_MSG_VOL_OPTION_ADD (GLFS_LG_BASE + 173) + + /*! + * @messageid +@@ -1689,7 +1498,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_UPLINK (GLFS_LG_BASE + 197) ++#define LG_MSG_XLATOR_OPTION_INVALID (GLFS_LG_BASE + 174) + + /*! + * @messageid +@@ -1697,8 +1506,7 @@ + * @recommendedaction + * + */ +- +-#define LG_MSG_CLIENTTABLE_NULL (GLFS_LG_BASE + 198) ++#define LG_MSG_GETTIMEOFDAY_FAILED (GLFS_LG_BASE + 175) + + /*! + * @messageid +@@ -1706,7 +1514,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_CLIENT_NULL (GLFS_LG_BASE + 199) ++#define LG_MSG_GRAPH_INIT_FAILED (GLFS_LG_BASE + 176) + + /*! + * @messageid +@@ -1714,7 +1522,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_XLATOR_DOES_NOT_IMPLEMENT (GLFS_LG_BASE + 200) ++#define LG_MSG_EVENT_NOTIFY_FAILED (GLFS_LG_BASE + 177) + + /*! + * @messageid +@@ -1722,7 +1530,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DENTRY_NOT_FOUND (GLFS_LG_BASE + 201) ++#define LG_MSG_ACTIVE_GRAPH_NULL (GLFS_LG_BASE + 178) + + /*! + * @messageid +@@ -1730,7 +1538,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INODE_NOT_FOUND (GLFS_LG_BASE + 202) ++#define LG_MSG_VOLFILE_PARSE_ERROR (GLFS_LG_BASE + 179) + + /*! + * @messageid +@@ -1738,7 +1546,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INODE_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 203) ++#define LG_MSG_FD_INODE_NULL (GLFS_LG_BASE + 180) + + /*! + * @messageid +@@ -1746,7 +1554,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INODE_OR_PARENT_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 204) ++#define LG_MSG_INVALID_VOLFILE_ENTRY (GLFS_LG_BASE + 181) + + /*! + * @messageid +@@ -1754,7 +1562,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_TABLE_NOT_FOUND (GLFS_LG_BASE + 205) ++#define LG_MSG_PER_DENTRY_FAILED (GLFS_LG_BASE + 182) + + /*! + * @messageid +@@ -1762,7 +1570,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_TABLE_OR_PARENT_OR_NAME_NOT_FOUND (GLFS_LG_BASE + 206) ++#define LG_MSG_PARENT_DENTRY_NOT_FOUND (GLFS_LG_BASE + 183) + + /*! + * @messageid +@@ -1770,7 +1578,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_DENTRY_CREATE_FAILED (GLFS_LG_BASE + 207) ++#define LG_MSG_DENTRY_CYCLIC_LOOP (GLFS_LG_BASE + 184) + + /*! + * @messageid +@@ -1778,39 +1586,8 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INODE_CONTEXT_FREED (GLFS_LG_BASE + 208) + +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_UNKNOWN_LOCK_TYPE (GLFS_LG_BASE + 209) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_UNLOCK_BEFORE_LOCK (GLFS_LG_BASE + 210) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_LOCK_OWNER_ERROR (GLFS_LG_BASE + 211) +- +-/*! +- * @messageid +- * @diagnosis +- * @recommendedaction +- * +- */ +-#define LG_MSG_FDTABLE_NULL (GLFS_LG_BASE + 212) ++#define LG_MSG_INVALID_POLL_IN (GLFS_LG_BASE + 185) + + /*! + * @messageid +@@ -1818,7 +1595,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_MEMPOOL_PTR_NULL (GLFS_LG_BASE + 213) ++#define LG_MSG_INVALID_POLL_OUT (GLFS_LG_BASE + 186) + + /*! + * @messageid +@@ -1826,7 +1603,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_VERSION (GLFS_LG_BASE + 214) ++#define LG_MSG_EPOLL_FD_ADD_FAILED (GLFS_LG_BASE + 187) + + /*! + * @messageid +@@ -1834,7 +1611,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_WRITE_TO_QUOTA_FAILED (GLFS_LG_BASE + 215) ++#define LG_MSG_EPOLL_FD_DEL_FAILED (GLFS_LG_BASE + 188) + + /*! + * @messageid +@@ -1842,7 +1619,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_QUOTA_XATTRS_MISSING (GLFS_LG_BASE + 216) ++#define LG_MSG_EPOLL_FD_MODIFY_FAILED (GLFS_LG_BASE + 189) + + /*! + * @messageid +@@ -1850,7 +1627,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_STRING (GLFS_LG_BASE + 217) ++#define LG_MSG_STARTED_EPOLL_THREAD (GLFS_LG_BASE + 190) + + /*! + * @messageid +@@ -1858,7 +1635,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_BIND_REF (GLFS_LG_BASE + 218) ++#define LG_MSG_EXITED_EPOLL_THREAD (GLFS_LG_BASE + 191) + + /*! + * @messageid +@@ -1866,7 +1643,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_REF_COUNT (GLFS_LG_BASE + 219) ++#define LG_MSG_START_EPOLL_THREAD_FAILED (GLFS_LG_BASE + 192) + + /*! + * @messageid +@@ -1874,7 +1651,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_ARG (GLFS_LG_BASE + 220) ++#define LG_MSG_FALLBACK_TO_POLL (GLFS_LG_BASE + 193) + + /*! + * @messageid +@@ -1882,7 +1659,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_VOL_OPTION_ADD (GLFS_LG_BASE + 221) ++#define LG_MSG_QUOTA_CONF_ERROR (GLFS_LG_BASE + 194) + + /*! + * @messageid +@@ -1890,7 +1667,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_XLATOR_OPTION_INVALID (GLFS_LG_BASE + 222) ++#define LG_MSG_RBTHASH_GET_ENTRY_FAILED (GLFS_LG_BASE + 195) + + /*! + * @messageid +@@ -1898,7 +1675,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GETTIMEOFDAY_FAILED (GLFS_LG_BASE + 223) ++#define LG_MSG_RBTHASH_GET_BUCKET_FAILED (GLFS_LG_BASE + 196) + + /*! + * @messageid +@@ -1906,7 +1683,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_GRAPH_INIT_FAILED (GLFS_LG_BASE + 224) ++#define LG_MSG_RBTHASH_INSERT_FAILED (GLFS_LG_BASE + 197) + + /*! + * @messageid +@@ -1914,15 +1691,14 @@ + * @recommendedaction + * + */ +-#define LG_MSG_EVENT_NOTIFY_FAILED (GLFS_LG_BASE + 225) +- ++#define LG_MSG_RBTHASH_INIT_ENTRY_FAILED (GLFS_LG_BASE + 198) + /*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +-#define LG_MSG_ACTIVE_GRAPH_NULL (GLFS_LG_BASE + 226) ++#define LG_MSG_TMPFILE_DELETE_FAILED (GLFS_LG_BASE + 199) + + /*! + * @messageid +@@ -1930,7 +1706,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_VOLFILE_PARSE_ERROR (GLFS_LG_BASE + 227) ++#define LG_MSG_MEMPOOL_INVALID_FREE (GLFS_LG_BASE + 200) + + /*! + * @messageid +@@ -1938,7 +1714,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_INVALID_VOLFILE_ENTRY (GLFS_LG_BASE + 228) ++#define LG_MSG_LOCK_FAILURE (GLFS_LG_BASE + 201) + + /*! + * @messageid +-- +1.7.1 + diff --git a/SOURCES/0148-afr-Block-fops-when-file-is-in-split-brain.patch b/SOURCES/0148-afr-Block-fops-when-file-is-in-split-brain.patch new file mode 100644 index 0000000..6743f68 --- /dev/null +++ b/SOURCES/0148-afr-Block-fops-when-file-is-in-split-brain.patch @@ -0,0 +1,232 @@ +From 37535f45135b5f6f9b62c8e011b96fc0b90743f7 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Fri, 26 Jun 2015 17:29:20 +0530 +Subject: [PATCH 148/190] afr: Block fops when file is in split-brain + +Patch in master: http://review.gluster.org/#/c/11371/ +Patch in release-3.7: http://review.gluster.org/#/c/11420/ + +For directories, block metadata FOPS. +For non-directories, block data and metadata FOPS. +Do not block entry FOPS. + +Change-Id: I5d44bd8ece08ec683f930d797541eae719257857 +BUG: 1223738 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/51691 +--- + tests/bugs/glusterfs/bug-873962.t | 8 ++-- + xlators/cluster/afr/src/afr-common.c | 58 +++++++++++++++++++++++++++++ + xlators/cluster/afr/src/afr-read-txn.c | 22 ++++------- + xlators/cluster/afr/src/afr-transaction.c | 7 +++ + xlators/cluster/afr/src/afr.h | 3 + + 5 files changed, 80 insertions(+), 18 deletions(-) + +diff --git a/tests/bugs/glusterfs/bug-873962.t b/tests/bugs/glusterfs/bug-873962.t +index 492d028..7faa999 100755 +--- a/tests/bugs/glusterfs/bug-873962.t ++++ b/tests/bugs/glusterfs/bug-873962.t +@@ -65,8 +65,8 @@ TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=$V0 $ + #Files are in split-brain, so open should fail + TEST ! cat $M0/a; + TEST ! cat $M1/a; +-TEST cat $M0/b; +-TEST cat $M1/b; ++TEST ! cat $M0/b; ++TEST ! cat $M1/b; + + #Reset split-brain status + TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0}1/a; +@@ -92,8 +92,8 @@ TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=$V0 $ + #Files are in split-brain, so open should fail + TEST ! cat $M0/c + TEST ! cat $M1/c +-TEST cat $M0/d +-TEST cat $M1/d ++TEST ! cat $M0/d ++TEST ! cat $M1/d + + TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0}1/c + TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0}1/d +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 7150f0f..9129b27 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -341,6 +341,58 @@ out: + } + + int ++afr_inode_get_readable (call_frame_t *frame, inode_t *inode, xlator_t *this, ++ unsigned char *readable, int *event_p, int type) ++{ ++ ++ afr_private_t *priv = this->private; ++ afr_local_t *local = frame->local; ++ unsigned char *data = alloca0 (priv->child_count); ++ unsigned char *metadata = alloca0 (priv->child_count); ++ int data_count = 0; ++ int metadata_count = 0; ++ int event_generation = 0; ++ int ret = 0; ++ ++ /* We don't care about split-brains for entry transactions. */ ++ if (type == AFR_ENTRY_TRANSACTION || type == AFR_ENTRY_RENAME_TRANSACTION) ++ return 0; ++ ++ ret = afr_inode_read_subvol_get (inode, this, data, metadata, ++ &event_generation); ++ if (ret == -1) ++ return -EIO; ++ ++ data_count = AFR_COUNT (data, priv->child_count); ++ metadata_count = AFR_COUNT (metadata, priv->child_count); ++ ++ if (inode->ia_type == IA_IFDIR) { ++ /* For directories, allow even if it is in data split-brain. */ ++ if (type == AFR_METADATA_TRANSACTION) { ++ if (!metadata_count) ++ return -EIO; ++ } ++ } else { ++ /* For files, abort in case of data/metadata split-brain. */ ++ if (!data_count || !metadata_count) ++ return -EIO; ++ } ++ ++ if (type == AFR_METADATA_TRANSACTION && readable) ++ memcpy (readable, metadata, priv->child_count * sizeof *metadata); ++ if (type == AFR_DATA_TRANSACTION && readable) { ++ if (!data_count) ++ memcpy (readable, local->child_up, ++ priv->child_count * sizeof *readable); ++ else ++ memcpy (readable, data, priv->child_count * sizeof *data); ++ } ++ if (event_p) ++ *event_p = event_generation; ++ return 0; ++} ++ ++int + afr_inode_split_brain_choice_get (inode_t *inode, xlator_t *this, + int *spb_choice) + { +@@ -598,6 +650,8 @@ afr_accuse_smallfiles (xlator_t *this, struct afr_reply *replies, + for (i = 0; i < priv->child_count; i++) { + if (data_accused[i]) + continue; ++ if ((priv->arbiter_count == 1) && (i == ARBITER_BRICK_INDEX)) ++ continue; + if (replies[i].poststat.ia_size < maxsize) + data_accused[i] = 1; + } +@@ -1682,6 +1736,10 @@ afr_local_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + * the slowest local subvolume is far preferable to a remote one. + */ + if (is_local) { ++ /* Don't set arbiter as read child. */ ++ if ((priv->arbiter_count == 1) && ++ (child_index == ARBITER_BRICK_INDEX)) ++ goto out; + gf_log (this->name, GF_LOG_INFO, + "selecting local read_child %s", + priv->children[child_index]->name); +diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c +index 6121108..6e54549 100644 +--- a/xlators/cluster/afr/src/afr-read-txn.c ++++ b/xlators/cluster/afr/src/afr-read-txn.c +@@ -52,6 +52,9 @@ afr_read_txn_next_subvol (call_frame_t *frame, xlator_t *this) + local->op_ret = ret; \ + local->op_errno = errnum; \ + read_subvol = index; \ ++ gf_msg (this->name, GF_LOG_ERROR, EIO, AFR_MSG_SPLIT_BRAIN,\ ++ "Failing %s on gfid %s: split-brain observed.",\ ++ gf_fop_list[local->op], uuid_utoa (inode->gfid));\ + goto label; \ + } while (0) + +@@ -59,7 +62,6 @@ int + afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err) + { + afr_local_t *local = NULL; +- afr_private_t *priv = NULL; + int read_subvol = 0; + int event_generation = 0; + inode_t *inode = NULL; +@@ -68,27 +70,19 @@ afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err) + + local = frame->local; + inode = local->inode; +- priv = frame->this->private; + + if (err) + AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, -err, -1, readfn); + +- ret = afr_inode_read_subvol_type_get (inode, this, local->readable, +- &event_generation, +- local->transaction.type); ++ ret = afr_inode_get_readable (frame, inode, this, local->readable, ++ &event_generation, ++ local->transaction.type); + + if (ret == -1 || !event_generation) + /* Even after refresh, we don't have a good + read subvolume. Time to bail */ + AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, EIO, -1, readfn); + +- /* For directories in split-brain, we need to allow all fops +- * except (f)getxattr and access. */ +- if (!AFR_COUNT(local->readable, priv->child_count) && +- local->transaction.type == AFR_DATA_TRANSACTION && +- inode->ia_type == IA_IFDIR) +- memcpy (local->readable, local->child_up, priv->child_count); +- + read_subvol = afr_read_subvol_select_by_policy (inode, this, + local->readable, NULL); + if (read_subvol == -1) +@@ -237,8 +231,8 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + if (read_subvol < 0 || read_subvol > priv->child_count) { + gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_SPLIT_BRAIN, + "Unreadable subvolume %d found with event generation " +- "%d. (Possible split-brain)", +- read_subvol, event_generation); ++ "%d for gfid %s. (Possible split-brain)", ++ read_subvol, event_generation, uuid_utoa(inode->gfid)); + goto refresh; + } + +diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c +index a202388..b27cfed 100644 +--- a/xlators/cluster/afr/src/afr-transaction.c ++++ b/xlators/cluster/afr/src/afr-transaction.c +@@ -1967,6 +1967,13 @@ afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type) + if (ret < 0) + goto out; + ++ ret = afr_inode_get_readable (frame, local->inode, this, 0, 0, type); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, EIO, AFR_MSG_SPLIT_BRAIN, ++ "Failing %s on gfid %s: split-brain observed.", ++ gf_fop_list[local->op], uuid_utoa (local->inode->gfid)); ++ goto out; ++ } + afr_transaction_eager_lock_init (local, this); + + if (local->fd && local->transaction.eager_lock_on) +diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h +index e6e7f3e..729ae82 100644 +--- a/xlators/cluster/afr/src/afr.h ++++ b/xlators/cluster/afr/src/afr.h +@@ -766,6 +766,9 @@ typedef struct afr_read_subvol_args { + (op_errno == EBADFD))) + + int ++afr_inode_get_readable (call_frame_t *frame, inode_t *inode, xlator_t *this, ++ unsigned char *readable, int *event_p, int type); ++int + afr_inode_read_subvol_get (inode_t *inode, xlator_t *this, + unsigned char *data_subvols, + unsigned char *metadata_subvols, +-- +1.7.1 + diff --git a/SOURCES/0149-quota-marker-accounting-goes-bad-with-rename-while-w.patch b/SOURCES/0149-quota-marker-accounting-goes-bad-with-rename-while-w.patch new file mode 100644 index 0000000..9960f80 --- /dev/null +++ b/SOURCES/0149-quota-marker-accounting-goes-bad-with-rename-while-w.patch @@ -0,0 +1,171 @@ +From da4ec76974997af637db6987d8c8465d4c580e9c Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 25 Jun 2015 14:58:50 +0530 +Subject: [PATCH 149/190] quota: marker accounting goes bad with rename while writing a file + +This is a backport of http://review.gluster.org/#/c/11403/ + +> With below test-case, marker accounting becomes bad: +> 1) Create a volume with 1 brick +> 2) fuse mount +> 3) on one terminal write some data +> dd if=/dev/zero of=f1 bs=1M count=500 oflag=sync +> 4) on another terminal execute below rename operation while the write is +> still in progress +> for i in {1..50}; do +> ii=`expr $i + 1`; +> mv f$i f$ii; +> done +> +> remove-xattr is already on while doing rename operation, +> we should not be doing again in background when reducing the +> parent size +> +> Change-Id: I969a64bb559e2341315928b55b99203e9ddee3f2 +> BUG: 1235195 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11403 +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G +> Tested-by: Gluster Build System +> Tested-by: Raghavendra G + +Change-Id: If1c21d5a58fe5aec594efefe2425119dc98eed18 +BUG: 1235182 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51679 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + tests/bugs/quota/bug-1235182.t | 58 ++++++++++++++++++++++++++++ + xlators/features/marker/src/marker-quota.c | 17 +++++++- + 2 files changed, 72 insertions(+), 3 deletions(-) + create mode 100644 tests/bugs/quota/bug-1235182.t + +diff --git a/tests/bugs/quota/bug-1235182.t b/tests/bugs/quota/bug-1235182.t +new file mode 100644 +index 0000000..0bd43a9 +--- /dev/null ++++ b/tests/bugs/quota/bug-1235182.t +@@ -0,0 +1,58 @@ ++#!/bin/bash ++ ++# This regression test tries to ensure renaming a directory with content, and ++# no limit set, is accounted properly, when moved into a directory with quota ++# limit set. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++function usage() ++{ ++ local QUOTA_PATH=$1; ++ $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}' ++} ++ ++QDD=$(dirname $0)/quota ++# compile the test write program and run it ++build_tester $(dirname $0)/../../basic/quota.c -o $QDD ++ ++TEST glusterd ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 $H0:$B0/${V0}{1}; ++TEST $CLI volume start $V0; ++ ++TEST $CLI volume quota $V0 enable; ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST $CLI volume quota $V0 limit-usage / 1GB ++TEST $CLI volume quota $V0 hard-timeout 0 ++TEST $CLI volume quota $V0 soft-timeout 0 ++ ++$QDD $M0/f1 256 400& ++PID=$! ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $M0/f1 ++TESTS_EXPECTED_IN_LOOP=50 ++for i in {1..50}; do ++ ii=`expr $i + 1`; ++ TEST_IN_LOOP mv $M0/f$i $M0/f$ii; ++done ++ ++echo "Wait for process with pid $PID to complete" ++wait $PID ++echo "Process with pid $PID finished" ++ ++EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "100.0MB" usage "/" ++ ++TEST $CLI volume stop $V0 ++TEST $CLI volume delete $V0 ++EXPECT "1" get_aux ++ ++rm -f $QDD ++ ++cleanup; +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index bbe2d9d..0b015ef 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2585,11 +2585,15 @@ out: + + int32_t + mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, +- inode_contribution_t *contri, quota_meta_t *delta) ++ inode_contribution_t *contri, quota_meta_t *delta, ++ gf_boolean_t remove_xattr) + { + int32_t ret = -1; + char contri_key[CONTRI_KEY_MAX] = {0, }; + ++ if (remove_xattr == _gf_false) ++ goto done; ++ + GET_CONTRI_KEY (contri_key, contri->gfid, ret); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "get contri_key " +@@ -2615,6 +2619,7 @@ mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + } + } + ++done: + LOCK (&contri->lock); + { + contri->contribution += delta->size; +@@ -3042,6 +3047,7 @@ mq_reduce_parent_size_task (void *opaque) + xlator_t *this = NULL; + loc_t *loc = NULL; + int64_t contri = 0; ++ gf_boolean_t remove_xattr = _gf_true; + + GF_ASSERT (opaque); + +@@ -3068,7 +3074,11 @@ mq_reduce_parent_size_task (void *opaque) + } + + if (contri >= 0) { +- /* contri paramater is supplied only for rename operation */ ++ /* contri paramater is supplied only for rename operation. ++ * remove xattr is alreday performed, we need to skip ++ * removexattr for rename operation ++ */ ++ remove_xattr = _gf_false; + delta.size = contri; + delta.file_count = 1; + delta.dir_count = 0; +@@ -3122,7 +3132,8 @@ mq_reduce_parent_size_task (void *opaque) + + mq_sub_meta (&delta, NULL); + +- ret = mq_remove_contri (this, loc, ctx, contribution, &delta); ++ ret = mq_remove_contri (this, loc, ctx, contribution, &delta, ++ remove_xattr); + if (ret < 0) + goto out; + +-- +1.7.1 + diff --git a/SOURCES/0150-dht-Adding-log-messages-to-the-new-logging-framework.patch b/SOURCES/0150-dht-Adding-log-messages-to-the-new-logging-framework.patch new file mode 100644 index 0000000..bf6e631 --- /dev/null +++ b/SOURCES/0150-dht-Adding-log-messages-to-the-new-logging-framework.patch @@ -0,0 +1,2790 @@ +From 581e8f64292ec179532a00889fc49ba4f6ac9380 Mon Sep 17 00:00:00 2001 +From: arao +Date: Fri, 12 Jun 2015 16:35:53 +0530 +Subject: [PATCH 150/190] dht: Adding log messages to the new logging framework + +Change-Id: Ib3bb61c5223f409c23c68100f3fe884918d2dc3f +BUG: 1194640 +Signed-off-by: arao +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: Anusha +Reviewed-on: https://code.engineering.redhat.com/gerrit/51674 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 306 ++++++++------- + xlators/cluster/dht/src/dht-diskusage.c | 6 +- + xlators/cluster/dht/src/dht-helper.c | 73 +++-- + xlators/cluster/dht/src/dht-inode-read.c | 24 +- + xlators/cluster/dht/src/dht-inode-write.c | 36 +- + xlators/cluster/dht/src/dht-layout.c | 50 ++- + xlators/cluster/dht/src/dht-linkfile.c | 3 +- + xlators/cluster/dht/src/dht-messages.h | 604 +++++++++++++++++++++++++++-- + xlators/cluster/dht/src/dht-rebalance.c | 44 ++- + xlators/cluster/dht/src/dht-rename.c | 22 +- + xlators/cluster/dht/src/dht-selfheal.c | 47 ++- + xlators/cluster/dht/src/dht-shared.c | 36 +- + xlators/cluster/dht/src/nufa.c | 31 +- + xlators/cluster/dht/src/switch.c | 21 +- + xlators/cluster/dht/src/tier.c | 33 +- + 15 files changed, 995 insertions(+), 341 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 868cd79..8b2715f 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -51,7 +51,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; + } +@@ -61,7 +62,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; +@@ -69,7 +71,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; +@@ -119,8 +122,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) { +@@ -386,10 +390,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; + } +@@ -581,10 +584,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; + } +@@ -708,10 +710,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; +@@ -719,11 +721,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. +@@ -774,7 +777,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; +@@ -930,7 +934,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 : "", +@@ -983,7 +987,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 )); + +@@ -1008,7 +1013,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 )); + +@@ -1032,7 +1038,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", +@@ -1069,7 +1076,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)); + +@@ -1296,7 +1305,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); +@@ -1385,7 +1395,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 ? +@@ -1395,7 +1406,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 ? +@@ -1429,7 +1441,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 : +@@ -1646,7 +1659,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, +@@ -1744,10 +1758,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 +@@ -1761,14 +1775,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; +@@ -1791,7 +1807,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; +@@ -1908,9 +1925,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, +@@ -1936,13 +1953,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; +@@ -1987,9 +2004,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; + } + +@@ -2001,7 +2019,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; +@@ -2014,7 +2033,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, +@@ -2072,7 +2092,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); +@@ -2081,7 +2101,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); +@@ -2132,7 +2152,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; +@@ -2352,9 +2372,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; + } + +@@ -2398,10 +2418,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; + } + +@@ -2449,9 +2469,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; + } + +@@ -2515,9 +2535,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; +@@ -2602,7 +2622,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; +@@ -2644,9 +2665,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; +@@ -2655,8 +2676,9 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = dict_get_str (xattr, local->xsel, &uuid_list); + + 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; +@@ -2668,7 +2690,9 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + next_uuid_str = strtok_r (NULL, " ", &saveptr); + 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; +@@ -2676,13 +2700,14 @@ 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" +- "belong to this node", prev->this->name); ++ 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" +- " this node", prev->this->name); ++ gf_msg_debug (this->name, 0, "subvol %s belongs to" ++ " this node", prev->this->name); + break; + } + } +@@ -2727,9 +2752,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; + } +@@ -2740,7 +2765,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: +@@ -2787,9 +2813,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; + } + +@@ -2948,7 +2975,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."); +@@ -2967,9 +2995,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; + + } +@@ -2993,8 +3021,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); +@@ -3119,7 +3147,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; + } +@@ -3455,8 +3485,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, +@@ -3732,13 +3762,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); +@@ -3749,7 +3778,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, +@@ -3779,7 +3809,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; +@@ -3940,9 +3971,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; + } + +@@ -4028,7 +4059,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); + } +@@ -4116,7 +4148,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); + } +@@ -4154,9 +4187,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; + } + +@@ -4248,7 +4281,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; +@@ -4661,7 +4696,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; +@@ -4944,7 +4979,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; +@@ -5521,7 +5556,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, +@@ -5873,11 +5909,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; + } + +@@ -5953,11 +5989,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; + } + +@@ -6120,10 +6156,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); +@@ -6165,7 +6200,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; +@@ -6210,7 +6246,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; +@@ -6222,7 +6259,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; + } + +@@ -6291,7 +6329,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; + } + +@@ -6354,7 +6393,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); +@@ -6450,11 +6490,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; +@@ -6771,7 +6810,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, +diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c +index 621c613..000494c 100644 +--- a/xlators/cluster/dht/src/dht-diskusage.c ++++ b/xlators/cluster/dht/src/dht-diskusage.c +@@ -44,7 +44,8 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + prev = cookie; + + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_GET_DISK_INFO_ERROR, + "failed to get disk info from %s", prev->this->name); + goto out; + } +@@ -189,7 +190,8 @@ dht_get_du_info (call_frame_t *frame, xlator_t *this, loc_t *loc) + ret = dict_set_int8 (statfs_local->params, + GF_INTERNAL_IGNORE_DEEM_STATFS, 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_DICT_SET_FAILED, + "Failed to set " + GF_INTERNAL_IGNORE_DEEM_STATFS" in dict"); + goto err; +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index f24c62c..6742f29 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -255,7 +255,8 @@ dht_log_lk_array (char *name, gf_loglevel_t log_level, dht_lock_t **lk_array, + + for (i = 0; i < count; i++) { + lk_buf = dht_lock_asprintf (lk_array[i]); +- gf_log (name, log_level, "%d. %s", i, lk_buf); ++ gf_msg (name, log_level, 0, DHT_MSG_LK_ARRAY_INFO, ++ "%d. %s", i, lk_buf); + GF_FREE (lk_buf); + } + +@@ -966,19 +967,30 @@ dht_migration_complete_check_task (void *data) + + ret = syncop_lookup (this, &tmp_loc, &stbuf, 0, 0, 0); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to lookup the file on %s (%s)", +- tmp_loc.path, this->name, strerror (-ret)); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_FILE_LOOKUP_FAILED, ++ "%s: failed to lookup the file on %s", ++ tmp_loc.path, this->name); + local->op_errno = -ret; + ret = -1; + goto out; + } + ++ dst_node = dht_subvol_get_cached (this, tmp_loc.inode); ++ if (linkto_target && dst_node != linkto_target) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_INVALID_LINKFILE, ++ "linkto target (%s) is " ++ "different from cached-subvol (%s). Treating %s as " ++ "destination subvol", linkto_target->name, ++ dst_node->name, dst_node->name); ++ } ++ + if (gf_uuid_compare (stbuf.ia_gfid, tmp_loc.inode->gfid)) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- DHT_MSG_GFID_MISMATCH, +- "%s: gfid different on the target file on %s", +- tmp_loc.path, dst_node->name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_GFID_MISMATCH, ++ "%s: gfid different on the target file on %s", ++ tmp_loc.path, dst_node->name); + ret = -1; + local->op_errno = EIO; + goto out; +@@ -1035,7 +1047,8 @@ dht_migration_complete_check_task (void *data) + ~(O_CREAT | O_EXCL | O_TRUNC)), iter_fd, + NULL, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to open " ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_OPEN_FD_ON_DST_FAILED, "failed to open " + "the fd (%p, flags=0%o) on file %s @ %s", + iter_fd, iter_fd->flags, path, dst_node->name); + open_failed = 1; +@@ -1143,16 +1156,18 @@ dht_rebalance_inprogress_task (void *data) + } + + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: failed to get the 'linkto' xattr %s", +- local->loc.path, strerror (-ret)); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_GET_XATTR_FAILED, ++ "%s: failed to get the 'linkto' xattr", ++ local->loc.path); + ret = -1; + goto out; + } + + dst_node = dht_linkfile_subvol (this, NULL, NULL, dict); + if (!dst_node) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_SUBVOL_NOT_FOUND, + "%s: failed to get the 'linkto' xattr from dict", + local->loc.path); + ret = -1; +@@ -1166,7 +1181,8 @@ dht_rebalance_inprogress_task (void *data) + ret = syncop_lookup (dst_node, &local->loc, &stbuf, NULL, + NULL, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_FILE_LOOKUP_ON_DST_FAILED, + "%s: failed to lookup the file on %s", + local->loc.path, dst_node->name); + ret = -1; +@@ -1210,7 +1226,9 @@ dht_rebalance_inprogress_task (void *data) + ~(O_CREAT | O_EXCL | O_TRUNC)), iter_fd, + NULL, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to send open " ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_OPEN_FD_ON_DST_FAILED, ++ "failed to send open " + "the fd (%p, flags=0%o) on file %s @ %s", + iter_fd, iter_fd->flags, path, dst_node->name); + ret = -1; +@@ -1229,7 +1247,8 @@ dht_rebalance_inprogress_task (void *data) + done: + ret = dht_inode_ctx_set_mig_info (this, inode, src_node, dst_node); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_SET_INODE_CTX_FAILED, + "%s: failed to set inode-ctx target file at %s", + local->loc.path, dst_node->name); + goto out; +@@ -1485,10 +1504,11 @@ dht_unlock_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + uuid_utoa_r (local->lock.locks[lk_index]->loc.gfid, + gfid); + +- gf_log (this->name, GF_LOG_WARNING, +- "unlocking failed on %s:%s (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_UNLOCKING_FAILED, ++ "unlocking failed on %s:%s", + local->lock.locks[lk_index]->xl->name, +- gfid, strerror (op_errno)); ++ gfid); + } else { + local->lock.locks[lk_index]->locked = 0; + } +@@ -1538,7 +1558,8 @@ dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + + lock_frame = dht_lock_frame (frame); + if (lock_frame == NULL) { +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_UNLOCKING_FAILED, + "cannot allocate a frame, not unlocking following " + "locks:"); + +@@ -1549,7 +1570,8 @@ dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + + ret = dht_local_lock_init (lock_frame, lk_array, lk_count, inodelk_cbk); + if (ret < 0) { +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_UNLOCKING_FAILED, + "storing locks in local failed, not unlocking " + "following locks:"); + +@@ -1613,11 +1635,10 @@ dht_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + uuid_utoa_r (local->lock.locks[lk_index]->loc.inode->gfid, + gfid); + +- gf_log (this->name, GF_LOG_DEBUG, +- "inodelk failed on gfid: %s " +- "subvolume: %s (%s)", gfid, +- local->lock.locks[lk_index]->xl->name, +- strerror (op_errno)); ++ gf_msg_debug (this->name, op_errno, ++ "inodelk failed on gfid: %s " ++ "subvolume: %s", gfid, ++ local->lock.locks[lk_index]->xl->name); + } + + goto out; +diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c +index 5dd055a..257a2ea 100644 +--- a/xlators/cluster/dht/src/dht-inode-read.c ++++ b/xlators/cluster/dht/src/dht-inode-read.c +@@ -36,9 +36,9 @@ dht_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + local->op_errno = op_errno; + if ((op_ret == -1) && !dht_inode_missing(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 out; + } + +@@ -145,9 +145,9 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if ((op_ret == -1) && !dht_inode_missing(op_errno)) { + 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 out; + } + +@@ -231,9 +231,9 @@ dht_attr_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; + } +@@ -725,9 +725,9 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + + local->op_errno = op_errno; + if (op_ret == -1 && !dht_inode_missing(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 out; + } + +diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c +index 1846ece..b48fd79 100644 +--- a/xlators/cluster/dht/src/dht-inode-write.c ++++ b/xlators/cluster/dht/src/dht-inode-write.c +@@ -203,9 +203,9 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if ((op_ret == -1) && !dht_inode_missing(op_errno)) { + local->op_errno = op_errno; + local->op_ret = -1; +- 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 out; + } +@@ -397,9 +397,9 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if ((op_ret == -1) && !dht_inode_missing(op_errno)) { + local->op_errno = op_errno; + local->op_ret = -1; +- 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 out; + } +@@ -541,9 +541,9 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if ((op_ret == -1) && !dht_inode_missing(op_errno)) { + local->op_errno = op_errno; + local->op_ret = -1; +- 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 out; + } +@@ -681,9 +681,9 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + if ((op_ret == -1) && !dht_inode_missing(op_errno)) { + local->op_errno = op_errno; + local->op_ret = -1; +- 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 out; + } + +@@ -817,9 +817,9 @@ dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + local->op_errno = op_errno; + if ((op_ret == -1) && !dht_inode_missing(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 out; + } + +@@ -903,9 +903,9 @@ dht_setattr_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; + } + +diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c +index f88c786..1163068 100644 +--- a/xlators/cluster/dht/src/dht-layout.c ++++ b/xlators/cluster/dht/src/dht-layout.c +@@ -170,7 +170,8 @@ dht_layout_search (xlator_t *this, dht_layout_t *layout, const char *name) + + ret = dht_hash_compute (this, layout->type, name, &hash); + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_COMPUTE_HASH_FAILED, + "hash computation failed for type=%d name=%s", + layout->type, name); + goto out; +@@ -185,7 +186,8 @@ dht_layout_search (xlator_t *this, dht_layout_t *layout, const char *name) + } + + if (!subvol) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_HASHED_SUBVOL_GET_FAILED, + "no subvolume for hash (value) = %u", hash); + } + +@@ -668,7 +670,8 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout) + + ret = dht_layout_sort (layout); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_LAYOUT_SORT_FAILED, + "sort failed?! how the ...."); + goto out; + } +@@ -679,7 +682,8 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout) + &holes, &overlaps, + &missing, &down, &misc, NULL); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR, + "Error finding anomalies in %s, gfid = %s", + loc->path, gfid); + goto out; +@@ -691,7 +695,8 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout) + "Directory %s looked up first time" + " gfid = %s", loc->path, gfid); + } else { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_ANOMALIES_INFO, + "Found anomalies in %s (gfid = %s). " + "Holes=%d overlaps=%d", + loc->path, gfid, holes, overlaps ); +@@ -760,9 +765,17 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, + + if (!xattr) { + if (err == 0) { +- gf_log (this->name, GF_LOG_INFO, +- "%s: xattr dictionary is NULL", +- loc->path); ++ if (loc) { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_DICT_GET_FAILED, ++ "%s: xattr dictionary is NULL", ++ loc->path); ++ } else { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_DICT_GET_FAILED, ++ "path not found: " ++ "xattr dictionary is NULL"); ++ } + ret = -1; + } + goto out; +@@ -773,9 +786,18 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, + + if (dict_ret < 0) { + if (err == 0 && layout->list[pos].stop) { +- gf_log (this->name, GF_LOG_INFO, +- "%s: Disk layout missing, gfid = %s", +- loc->path, gfid); ++ if (loc) { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_DISK_LAYOUT_MISSING, ++ "%s: Disk layout missing, gfid = %s", ++ loc->path, gfid); ++ } else { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_DISK_LAYOUT_MISSING, ++ "path not found: " ++ "Disk layout missing, gfid = %s", ++ gfid); ++ } + ret = -1; + } + goto out; +@@ -790,7 +812,8 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, + if ((layout->list[pos].start != start_off) + || (layout->list[pos].stop != stop_off) + || (layout->list[pos].commit_hash != commit_hash)) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_LAYOUT_INFO, + "subvol: %s; inode layout - %"PRIu32" - %"PRIu32 + " - %"PRIu32"; " + "disk layout - %"PRIu32" - %"PRIu32" - %"PRIu32, +@@ -820,7 +843,8 @@ dht_layout_preset (xlator_t *this, xlator_t *subvol, inode_t *inode) + + layout = dht_layout_for_subvol (this, subvol); + if (!layout) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_NO_LAYOUT_INFO, + "no pre-set layout for subvolume %s", + subvol ? subvol->name : ""); + ret = -1; +diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c +index 923dde0..a247170 100644 +--- a/xlators/cluster/dht/src/dht-linkfile.c ++++ b/xlators/cluster/dht/src/dht-linkfile.c +@@ -44,7 +44,8 @@ dht_linkfile_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + is_linkfile = check_is_linkfile (inode, stbuf, xattr, + conf->link_xattr_name); + if (!is_linkfile) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_NOT_LINK_FILE_ERROR, + "got non-linkfile %s:%s, gfid = %s", + prev->this->name, local->loc.path, gfid); + out: +diff --git a/xlators/cluster/dht/src/dht-messages.h b/xlators/cluster/dht/src/dht-messages.h +index eb4c356..e0f0510 100644 +--- a/xlators/cluster/dht/src/dht-messages.h ++++ b/xlators/cluster/dht/src/dht-messages.h +@@ -1,4 +1,4 @@ +-/*Copyright (c) 2013 Red Hat, Inc. ++/*Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser +@@ -45,7 +45,7 @@ + */ + + #define GLFS_DHT_BASE GLFS_MSGID_COMP_DHT +-#define GLFS_DHT_NUM_MESSAGES 36 ++#define GLFS_DHT_NUM_MESSAGES 104 + #define GLFS_MSGID_END (GLFS_DHT_BASE + GLFS_DHT_NUM_MESSAGES + 1) + + /* Messages with message IDs */ +@@ -71,7 +71,7 @@ + * + */ + +-#define DHT_MSG_CREATE_LINK_FAILED (GLFS_DHT_BASE + 2) ++#define DHT_MSG_CREATE_LINK_FAILED (GLFS_DHT_BASE + 2) + + /*! + * @messageid 109003 +@@ -82,7 +82,7 @@ + * + */ + +-#define DHT_MSG_DICT_SET_FAILED (GLFS_DHT_BASE + 3) ++#define DHT_MSG_DICT_SET_FAILED (GLFS_DHT_BASE + 3) + + /*! + * @messageid 109004 +@@ -91,7 +91,7 @@ + * + */ + +-#define DHT_MSG_DIR_ATTR_HEAL_FAILED (GLFS_DHT_BASE + 4) ++#define DHT_MSG_DIR_ATTR_HEAL_FAILED (GLFS_DHT_BASE + 4) + + /*! + * @messageid 109005 +@@ -102,7 +102,7 @@ + * + */ + +-#define DHT_MSG_DIR_SELFHEAL_FAILED (GLFS_DHT_BASE + 5) ++#define DHT_MSG_DIR_SELFHEAL_FAILED (GLFS_DHT_BASE + 5) + + /*! + * @messageid 109006 +@@ -113,7 +113,7 @@ + * + */ + +-#define DHT_MSG_DIR_SELFHEAL_XATTR_FAILED (GLFS_DHT_BASE + 6) ++#define DHT_MSG_DIR_SELFHEAL_XATTR_FAILED (GLFS_DHT_BASE + 6) + + /*! + * @messageid 109007 +@@ -126,7 +126,7 @@ + * + */ + +-#define DHT_MSG_FILE_ON_MULT_SUBVOL (GLFS_DHT_BASE + 7) ++#define DHT_MSG_FILE_ON_MULT_SUBVOL (GLFS_DHT_BASE + 7) + + /*! + * @messageid 109008 +@@ -144,7 +144,7 @@ + * + */ + +-#define DHT_MSG_FILE_TYPE_MISMATCH (GLFS_DHT_BASE + 8) ++#define DHT_MSG_FILE_TYPE_MISMATCH (GLFS_DHT_BASE + 8) + + /*! + * @messageid 109009 +@@ -153,7 +153,7 @@ + * + */ + +-#define DHT_MSG_GFID_MISMATCH (GLFS_DHT_BASE + 9) ++#define DHT_MSG_GFID_MISMATCH (GLFS_DHT_BASE + 9) + + /*! + * @messageid 109010 +@@ -162,17 +162,15 @@ + * + */ + +-#define DHT_MSG_GFID_NULL (GLFS_DHT_BASE + 10) ++#define DHT_MSG_GFID_NULL (GLFS_DHT_BASE + 10) + +-/*! ++/* + * @messageid 109011 +- * @diagnosis The hashed subvolume could not be found for the specified +- * file/directory +- * @recommendedaction None +- * ++ * @diagnosis ++ * @recommendedaction None + */ + +-#define DHT_MSG_HASHED_SUBVOL_GET_FAILED (GLFS_DHT_BASE + 11) ++#define DHT_MSG_HASHED_SUBVOL_GET_FAILED (GLFS_DHT_BASE + 11) + + /*! + * @messageid 109012 +@@ -182,7 +180,7 @@ + * + */ + +-#define DHT_MSG_INIT_FAILED (GLFS_DHT_BASE + 12) ++#define DHT_MSG_INIT_FAILED (GLFS_DHT_BASE + 12) + + /*! + * @messageid 109013 +@@ -191,7 +189,7 @@ + * + */ + +-#define DHT_MSG_INVALID_CONFIGURATION (GLFS_DHT_BASE + 13) ++#define DHT_MSG_INVALID_CONFIGURATION (GLFS_DHT_BASE + 13) + + /*! + * @messageid 109014 +@@ -200,7 +198,7 @@ + * + */ + +-#define DHT_MSG_INVALID_DISK_LAYOUT (GLFS_DHT_BASE + 14) ++#define DHT_MSG_INVALID_DISK_LAYOUT (GLFS_DHT_BASE + 14) + + /*! + * @messageid 109015 +@@ -213,7 +211,7 @@ + * + */ + +-#define DHT_MSG_INVALID_OPTION (GLFS_DHT_BASE + 15) ++#define DHT_MSG_INVALID_OPTION (GLFS_DHT_BASE + 15) + + /*! + * @messageid 109016 +@@ -231,7 +229,7 @@ + * + */ + +-#define DHT_MSG_LAYOUT_MERGE_FAILED (GLFS_DHT_BASE + 17) ++#define DHT_MSG_LAYOUT_MERGE_FAILED (GLFS_DHT_BASE + 17) + + /*! + * @messageid 109018 +@@ -241,7 +239,7 @@ + * + */ + +-#define DHT_MSG_LAYOUT_MISMATCH (GLFS_DHT_BASE + 18) ++#define DHT_MSG_LAYOUT_MISMATCH (GLFS_DHT_BASE + 18) + + /*! + * @messageid 109019 +@@ -250,7 +248,7 @@ + * + */ + +-#define DHT_MSG_LAYOUT_NULL (GLFS_DHT_BASE + 19) ++#define DHT_MSG_LAYOUT_NULL (GLFS_DHT_BASE + 19) + + /*! + * @messageid 109020 +@@ -260,7 +258,7 @@ + * + */ + +-#define DHT_MSG_MIGRATE_DATA_COMPLETE (GLFS_DHT_BASE + 20) ++#define DHT_MSG_MIGRATE_DATA_COMPLETE (GLFS_DHT_BASE + 20) + + /*! + * @messageid 109021 +@@ -284,7 +282,7 @@ + * + */ + +-#define DHT_MSG_MIGRATE_FILE_COMPLETE (GLFS_DHT_BASE + 22) ++#define DHT_MSG_MIGRATE_FILE_COMPLETE (GLFS_DHT_BASE + 22) + + /*! + * @messageid 109023 +@@ -309,7 +307,7 @@ + * + */ + +-#define DHT_MSG_NO_MEMORY (GLFS_DHT_BASE + 24) ++#define DHT_MSG_NO_MEMORY (GLFS_DHT_BASE + 24) + + /*! + * @messageid 109025 +@@ -325,7 +323,7 @@ + * + */ + +-#define DHT_MSG_OPENDIR_FAILED (GLFS_DHT_BASE + 25) ++#define DHT_MSG_OPENDIR_FAILED (GLFS_DHT_BASE + 25) + + /*! + * @messageid 109026 +@@ -337,7 +335,7 @@ + * + */ + +-#define DHT_MSG_REBALANCE_FAILED (GLFS_DHT_BASE + 26) ++#define DHT_MSG_REBALANCE_FAILED (GLFS_DHT_BASE + 26) + + /*! + * @messageid 109027 +@@ -346,7 +344,7 @@ + * + */ + +-#define DHT_MSG_REBALANCE_START_FAILED (GLFS_DHT_BASE + 27) ++#define DHT_MSG_REBALANCE_START_FAILED (GLFS_DHT_BASE + 27) + + /*! + * @messageid 109028 +@@ -357,7 +355,7 @@ + * + */ + +-#define DHT_MSG_REBALANCE_STATUS (GLFS_DHT_BASE + 28) ++#define DHT_MSG_REBALANCE_STATUS (GLFS_DHT_BASE + 28) + + /*! + * @messageid 109029 +@@ -366,7 +364,7 @@ + * + */ + +-#define DHT_MSG_REBALANCE_STOPPED (GLFS_DHT_BASE + 29) ++#define DHT_MSG_REBALANCE_STOPPED (GLFS_DHT_BASE + 29) + + /*! + * @messageid 109030 +@@ -377,7 +375,7 @@ + * + */ + +-#define DHT_MSG_RENAME_FAILED (GLFS_DHT_BASE + 30) ++#define DHT_MSG_RENAME_FAILED (GLFS_DHT_BASE + 30) + + /*! + * @messageid 109031 +@@ -387,7 +385,7 @@ + * + */ + +-#define DHT_MSG_SETATTR_FAILED (GLFS_DHT_BASE + 31) ++#define DHT_MSG_SETATTR_FAILED (GLFS_DHT_BASE + 31) + + /*! + * @messageid 109032 +@@ -419,7 +417,7 @@ + the specific error that is encountered. + */ + +-#define DHT_MSG_UNLINK_FAILED (GLFS_DHT_BASE + 34) ++#define DHT_MSG_UNLINK_FAILED (GLFS_DHT_BASE + 34) + + + +@@ -430,7 +428,7 @@ + * + */ + +-#define DHT_MSG_LAYOUT_SET_FAILED (GLFS_DHT_BASE + 35) ++#define DHT_MSG_LAYOUT_SET_FAILED (GLFS_DHT_BASE + 35) + + /*! + * @messageid 109036 +@@ -439,7 +437,7 @@ + * @recommendedaction None + */ + +-#define DHT_MSG_LOG_FIXED_LAYOUT (GLFS_DHT_BASE + 36) ++#define DHT_MSG_LOG_FIXED_LAYOUT (GLFS_DHT_BASE + 36) + + /* + * @messageid 109037 +@@ -447,7 +445,7 @@ + * @recommendedaction None + */ + +-#define DHT_MSG_LOG_TIER_ERROR (GLFS_DHT_BASE + 37) ++#define DHT_MSG_LOG_TIER_ERROR (GLFS_DHT_BASE + 37) + + /* + * @messageid 109038 +@@ -455,11 +453,535 @@ + * @recommendedaction None + */ + +-#define DHT_MSG_LOG_TIER_STATUS (GLFS_DHT_BASE + 38) ++#define DHT_MSG_LOG_TIER_STATUS (GLFS_DHT_BASE + 38) + ++/* ++ * @messageid 109039 ++ * @diagnosis ++ * @recommendedaction None ++ */ + +-/*------------*/ +-#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++#define DHT_MSG_GET_XATTR_FAILED (GLFS_DHT_BASE + 39) ++ ++/* ++ * @messageid 109040 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FILE_LOOKUP_FAILED (GLFS_DHT_BASE + 40) ++ ++/* ++ * @messageid 109041 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_OPEN_FD_FAILED (GLFS_DHT_BASE + 41) ++ ++/* ++ * @messageid 109042 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SET_INODE_CTX_FAILED (GLFS_DHT_BASE + 42) ++ ++/* ++ * @messageid 109043 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_UNLOCKING_FAILED (GLFS_DHT_BASE + 43) ++ ++/* ++ * @messageid 109044 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_DISK_LAYOUT_NULL (GLFS_DHT_BASE + 44) ++ ++/* ++ * @messageid 109045 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_INFO (GLFS_DHT_BASE + 45) ++ ++/* ++ * @messageid 109046 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_CHUNK_SIZE_INFO (GLFS_DHT_BASE + 46) ++ ++/* ++ * @messageid 109047 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LAYOUT_FORM_FAILED (GLFS_DHT_BASE + 47) ++ ++/* ++ * @messageid 109048 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_ERROR (GLFS_DHT_BASE + 48) ++ ++/* ++ * @messageid 109049 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LAYOUT_SORT_FAILED (GLFS_DHT_BASE + 49) ++ ++/* ++ * @messageid 109050 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_REGEX_INFO (GLFS_DHT_BASE + 50) ++ ++/* ++ * @messageid 109051 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FOPEN_FAILED (GLFS_DHT_BASE + 51) ++ ++/* ++ * @messageid 109052 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SET_HOSTNAME_FAILED (GLFS_DHT_BASE + 52) ++ ++/* ++ * @messageid 109053 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_BRICK_ERROR (GLFS_DHT_BASE + 53) ++ ++/* ++ * @messageid 109054 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SYNCOP_FAILED (GLFS_DHT_BASE + 54) ++ ++/* ++ * @messageid 109055 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_MIGRATE_INFO (GLFS_DHT_BASE + 55) ++ ++/* ++ * @messageid 109056 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SOCKET_ERROR (GLFS_DHT_BASE + 56) ++ ++/* ++ * @messageid 109057 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_CREATE_FD_FAILED (GLFS_DHT_BASE + 57) ++ ++/* ++ * @messageid 109058 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_READDIR_ERROR (GLFS_DHT_BASE + 58) ++ ++/* ++ * @messageid 109059 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_CHILD_LOC_BUILD_FAILED (GLFS_DHT_BASE + 59) ++ ++/* ++ * @messageid 109060 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SET_SWITCH_PATTERN_ERROR (GLFS_DHT_BASE + 60) ++ ++/* ++ * @messageid 109061 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_COMPUTE_HASH_FAILED (GLFS_DHT_BASE + 61) ++ ++/* ++ * @messageid 109062 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR (GLFS_DHT_BASE + 62) ++ ++/* ++ * @messageid 109063 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_ANOMALIES_INFO (GLFS_DHT_BASE + 63) ++ ++/* ++ * @messageid 109064 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LAYOUT_INFO (GLFS_DHT_BASE + 64) ++ ++/* ++ * @messageid 109065 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_INODE_LK_ERROR (GLFS_DHT_BASE + 65) ++ ++/* ++ * @messageid 109066 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_RENAME_INFO (GLFS_DHT_BASE + 66) ++ ++/* ++ * @messageid 109067 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_DATA_NULL (GLFS_DHT_BASE + 67) ++ ++/* ++ * @messageid 109068 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_AGGREGATE_QUOTA_XATTR_FAILED (GLFS_DHT_BASE + 68) ++ ++/* ++ * @messageid 109069 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_UNLINK_LOOKUP_INFO (GLFS_DHT_BASE + 69) ++ ++/* ++ * @messageid 109070 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LINK_FILE_LOOKUP_INFO (GLFS_DHT_BASE + 70) ++ ++/* ++ * @messageid 109071 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_OPERATION_NOT_SUP (GLFS_DHT_BASE + 71) ++ ++/* ++ * @messageid 109072 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_NOT_LINK_FILE_ERROR (GLFS_DHT_BASE + 72) ++ ++/* ++ * @messageid 109073 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_CHILD_DOWN (GLFS_DHT_BASE + 73) ++ ++/* ++ * @messageid 109074 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_UUID_PARSE_ERROR (GLFS_DHT_BASE + 74) ++ ++/* ++ * @messageid 109075 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_GET_DISK_INFO_ERROR (GLFS_DHT_BASE + 75) ++ ++/* ++ * @messageid 109076 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_INVALID_VALUE (GLFS_DHT_BASE + 76) ++ ++/* ++ * @messageid 109077 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SWITCH_PATTERN_INFO (GLFS_DHT_BASE + 77) ++ ++/* ++ * @messageid 109078 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_OP_FAILED (GLFS_DHT_BASE + 78) ++ ++/* ++ * @messageid 109079 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LAYOUT_PRESET_FAILED (GLFS_DHT_BASE + 79) + ++/* ++ * @messageid 109080 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_INVALID_LINKFILE (GLFS_DHT_BASE + 80) ++ ++/* ++ * @messageid 109081 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FIX_LAYOUT_INFO (GLFS_DHT_BASE + 81) ++ ++/* ++ * @messageid 109082 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_GET_HOSTNAME_FAILED (GLFS_DHT_BASE + 82) ++ ++/* ++ * @messageid 109083 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_WRITE_FAILED (GLFS_DHT_BASE + 83) ++ ++/* ++ * @messageid 109084 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_MIGRATE_HARDLINK_FILE_FAILED (GLFS_DHT_BASE + 84) + ++/* ++ * @messageid 109085 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FSYNC_FAILED (GLFS_DHT_BASE + 85) ++ ++/* ++ * @messageid 109086 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_DECOMMISSION_INFO (GLFS_DHT_BASE + 86) ++ ++/* ++ * @messageid 109087 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_BRICK_QUERY_FAILED (GLFS_DHT_BASE + 87) ++ ++/* ++ * @messageid 109088 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_NO_LAYOUT_INFO (GLFS_DHT_BASE + 88) ++ ++/* ++ * @messageid 109089 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_OPEN_FD_ON_DST_FAILED (GLFS_DHT_BASE + 89) ++ ++/* ++ * @messageid 109090 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_NOT_FOUND (GLFS_DHT_BASE + 90) ++ ++/* ++ * @messageid 109190 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_FILE_LOOKUP_ON_DST_FAILED (GLFS_DHT_BASE + 91) ++ ++/* ++ * @messageid 109092 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_DISK_LAYOUT_MISSING (GLFS_DHT_BASE + 92) ++ ++/* ++ * @messageid 109093 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_DICT_GET_FAILED (GLFS_DHT_BASE + 93) ++ ++/* ++ * @messageid 109094 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_REVALIDATE_CBK_INFO (GLFS_DHT_BASE + 94) ++ ++/* ++ * @messageid 109095 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_UPGRADE_BRICKS (GLFS_DHT_BASE + 95) ++ ++/* ++ * @messageid 109096 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_LK_ARRAY_INFO (GLFS_DHT_BASE + 96) ++ ++/* ++ * @messageid 109097 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_RENAME_NOT_LOCAL (GLFS_DHT_BASE + 97) ++ ++/* ++ * @messageid 109098 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_RECONFIGURE_INFO (GLFS_DHT_BASE + 98) ++ ++/* ++ * @messageid 109099 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_INIT_LOCAL_SUBVOL_FAILED (GLFS_DHT_BASE + 99) ++ ++/* ++ * @messageid 109100 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SYS_CALL_GET_TIME_FAILED (GLFS_DHT_BASE + 100) ++ ++/* ++ * @messageid 109101 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_NO_DISK_USAGE_STATUS (GLFS_DHT_BASE + 101) ++ ++/* ++ * @messageid 109102 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_SUBVOL_DOWN_ERROR (GLFS_DHT_BASE + 102) ++ ++/* ++ * @messageid 109103 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_REBAL_THROTTLE_INFO (GLFS_DHT_BASE + 103) ++ ++/* ++ * @messageid 109104 ++ * @diagnosis ++ * @recommendedaction None ++ */ ++ ++#define DHT_MSG_COMMIT_HASH_INFO (GLFS_DHT_BASE + 104) ++ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* _DHT_MESSAGES_H_ */ +diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c +index 38db3a1..012d86b 100644 +--- a/xlators/cluster/dht/src/dht-rebalance.c ++++ b/xlators/cluster/dht/src/dht-rebalance.c +@@ -313,7 +313,9 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs, + } else { + linkto_subvol = dht_linkfile_subvol (this, NULL, NULL, xattrs); + if (!linkto_subvol) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to get " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_SUBVOL_ERROR, ++ "Failed to get " + "linkto subvol for %s", loc->name); + } else { + hashed_subvol = linkto_subvol; +@@ -326,10 +328,12 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs, + + loglevel = (op_errno == EEXIST) ? GF_LOG_DEBUG : \ + GF_LOG_ERROR; +- gf_log (this->name, loglevel, "link of %s -> %s" +- " failed on subvol %s (%s)", loc->name, ++ gf_msg (this->name, loglevel, op_errno, ++ DHT_MSG_MIGRATE_HARDLINK_FILE_FAILED, ++ "link of %s -> %s" ++ " failed on subvol %s", loc->name, + uuid_utoa(loc->gfid), +- hashed_subvol->name, strerror (op_errno)); ++ hashed_subvol->name); + if (op_errno != EEXIST) + goto out; + } +@@ -585,7 +589,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc, + xdata = dict_new (); + if (!xdata) { + errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, + "failed to allocate dictionary"); + goto out; + } +@@ -1407,9 +1412,10 @@ gf_listener_stop (xlator_t *this) + } + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to unlink listener " +- "socket %s, error: %s", cmd_args->sock_file, +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ DHT_MSG_SOCKET_ERROR, ++ "Failed to unlink listener " ++ "socket %s", cmd_args->sock_file); + } + return ret; + } +@@ -1762,8 +1768,8 @@ gf_defrag_task (void *opaque) + iterator = list_entry (q_head->next, + typeof(*iterator), list); + +- gf_log ("DHT", GF_LOG_DEBUG, "picking entry " +- "%s", iterator->df_entry->d_name); ++ gf_msg_debug ("DHT", 0, "picking entry " ++ "%s", iterator->df_entry->d_name); + + list_del_init (&(iterator->list)); + +@@ -1965,9 +1971,9 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container, + migration. Only the actual data file need to + be checked for migration criteria. + */ +- gf_log (this->name, GF_LOG_DEBUG, "Skipping linkfile" +- " %s on subvol: %s", entry_loc.path, +- conf->local_subvols[i]->name); ++ gf_msg_debug (this->name, 0, "Skipping linkfile" ++ " %s on subvol: %s", entry_loc.path, ++ conf->local_subvols[i]->name); + continue; + } + +@@ -2301,10 +2307,10 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc, + defrag->q_entry_count++; + ldfq_count = defrag->q_entry_count; + +- gf_log (this->name, GF_LOG_DEBUG, "added " +- "file:%s parent:%s to the queue ", +- container->df_entry->d_name, +- container->parent_loc->path); ++ gf_msg_debug (this->name, 0, "added " ++ "file:%s parent:%s to the queue ", ++ container->df_entry->d_name, ++ container->parent_loc->path); + + pthread_cond_signal ( + &defrag->parallel_migration_cond); +@@ -2738,8 +2744,8 @@ gf_defrag_start_crawl (void *data) + + thread_spawn_count = MAX ((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); + +- gf_log (this->name, GF_LOG_DEBUG, "thread_spawn_count: %d", +- thread_spawn_count); ++ gf_msg_debug (this->name, 0, "thread_spawn_count: %d", ++ thread_spawn_count); + + defrag->current_thread_count = thread_spawn_count; + +diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c +index 097ae9a..320f875 100644 +--- a/xlators/cluster/dht/src/dht-rename.c ++++ b/xlators/cluster/dht/src/dht-rename.c +@@ -450,7 +450,8 @@ dht_rename_unlock (call_frame_t *frame, xlator_t *this) + if (local->loc2.inode) + uuid_utoa_r (local->loc2.inode->gfid, dst_gfid); + +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_UNLOCKING_FAILED, + "winding unlock inodelk failed " + "rename (%s:%s:%s %s:%s:%s), " + "stale locks left on bricks", +@@ -493,7 +494,8 @@ dht_rename_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + prev = cookie; + + if (!local) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_INVALID_VALUE, + "!local, should not happen"); + goto out; + } +@@ -638,9 +640,10 @@ dht_rename_links_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + local = frame->local; + + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "link/file %s on %s failed (%s)", +- local->loc.path, prev->this->name, strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_CREATE_LINK_FAILED, ++ "link/file %s on %s failed", ++ local->loc.path, prev->this->name); + } + + if (local->linked == _gf_true) { +@@ -1218,10 +1221,10 @@ dht_rename_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (local->loc2.inode) + uuid_utoa_r (local->loc2.inode->gfid, dst_gfid); + +- gf_log (this->name, GF_LOG_WARNING, +- "acquiring inodelk failed (%s) " ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_INODE_LK_ERROR, ++ "acquiring inodelk failed " + "rename (%s:%s:%s %s:%s:%s), returning EBUSY", +- strerror (op_errno), + local->loc.path, src_gfid, local->src_cached->name, + local->loc2.path, dst_gfid, + local->dst_cached ? local->dst_cached->name : NULL); +@@ -1399,7 +1402,8 @@ dht_rename (call_frame_t *frame, xlator_t *this, + local->dst_hashed = dst_hashed; + local->dst_cached = dst_cached; + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_RENAME_INFO, + "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)", + oldloc->path, src_hashed->name, src_cached->name, + newloc->path, dst_hashed->name, +diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c +index c881a36..cfe7e5a 100644 +--- a/xlators/cluster/dht/src/dht-selfheal.c ++++ b/xlators/cluster/dht/src/dht-selfheal.c +@@ -145,7 +145,8 @@ dht_refresh_layout_done (call_frame_t *frame) + + ret = dht_layout_sort (refreshed); + if (ret == -1) { +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_LAYOUT_SORT_FAILED, + "sorting the layout failed"); + goto err; + } +@@ -197,10 +198,9 @@ dht_refresh_layout_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; + } +@@ -941,9 +941,9 @@ dht_selfheal_dir_xattr_for_nameless_lookup (call_frame_t *frame, loc_t *loc, + } + + +- gf_log (this->name, GF_LOG_TRACE, +- "%d subvolumes missing xattr for %s", +- missing_xattr, loc->path); ++ gf_msg_trace (this->name, 0, ++ "%d subvolumes missing xattr for %s", ++ missing_xattr, loc->path); + + if (missing_xattr == 0) { + dht_selfheal_dir_finish (frame, this, 0); +@@ -1218,7 +1218,8 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, + dht_selfheal_dir_mkdir_setacl (local->xattr, dict); + + if (!dict) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_DICT_SET_FAILED, + "dict is NULL, need to make sure gfids are same"); + + for (i = 0; i < layout->cnt; i++) { +@@ -1488,14 +1489,16 @@ dht_fix_layout_of_directory (call_frame_t *frame, loc_t *loc, + + if (priv->du_stats) { + for (i = 0; i < priv->subvolume_cnt; ++i) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_INFO, + "subvolume %d (%s): %u chunks", i, + priv->subvolumes[i]->name, + priv->du_stats[i].chunks); + } + } + else { +- gf_log (this->name, GF_LOG_WARNING, "no du stats ?!?"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_NO_DISK_USAGE_STATUS, "no du stats ?!?"); + } + + /* First give it a layout as though it is a new directory. This +@@ -1594,9 +1597,9 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc, + if (weight_by_size && total_size) { + /* We know total_size is not zero. */ + chunk = ((unsigned long) 0xffffffff) / total_size; +- gf_log (this->name, GF_LOG_DEBUG, +- "chunk size = 0xffffffff / %u = 0x%x", +- total_size, chunk); ++ gf_msg_debug (this->name, 0, ++ "chunk size = 0xffffffff / %u = 0x%x", ++ total_size, chunk); + } + else { + weight_by_size = _gf_false; +@@ -1633,9 +1636,10 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc, + else { + curr_size = 1; + } +- gf_log (this->name, GF_LOG_DEBUG, +- "assigning range size 0x%x to %s", chunk * curr_size, +- layout->list[i].xlator->name); ++ gf_msg_debug (this->name, 0, ++ "assigning range size 0x%x to %s", ++ chunk * curr_size, ++ layout->list[i].xlator->name); + DHT_SET_LAYOUT_RANGE(layout, i, start, chunk * curr_size, + loc->path); + if (++bricks_used >= bricks_to_use) { +@@ -1840,14 +1844,16 @@ dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame, + local->selfheal.layout = dht_layout_ref (this, layout); + + if (down) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_SUBVOL_DOWN_ERROR, + "%d subvolumes down -- not fixing", down); + ret = 0; + goto sorry_no_fix; + } + + if (misc) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_SUBVOL_ERROR, + "%d subvolumes have unrecoverable errors", misc); + ret = 0; + goto sorry_no_fix; +@@ -1857,7 +1863,8 @@ dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame, + ret = dht_selfheal_dir_getafix (frame, loc, layout); + + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_LAYOUT_FORM_FAILED, + "not able to form layout for the directory"); + goto sorry_no_fix; + } +diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c +index 456d831..ce0fd00 100644 +--- a/xlators/cluster/dht/src/dht-shared.c ++++ b/xlators/cluster/dht/src/dht-shared.c +@@ -264,8 +264,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_dht_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + out: +@@ -294,7 +295,8 @@ dht_parse_decommissioned_bricks (xlator_t *this, dht_conf_t *conf, + conf->decommissioned_bricks[i] = + conf->subvolumes[i]; + conf->decommission_subvols_cnt++; +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_DECOMMISSION_INFO, + "decommissioning subvolume %s", + conf->subvolumes[i]->name); + break; +@@ -359,12 +361,13 @@ dht_init_regex (xlator_t *this, dict_t *odict, char *name, + } + + if (regcomp(re,temp_str,REG_EXTENDED) == 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "using regex %s = %s", name, temp_str); ++ gf_msg_debug (this->name, 0, ++ "using regex %s = %s", name, temp_str); + *re_valid = _gf_true; + } + else { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_REGEX_INFO, + "compiling regex %s failed", temp_str); + } + } +@@ -458,7 +461,9 @@ dht_reconfigure (xlator_t *this, dict_t *options) + + if (conf->defrag) { + GF_DECIDE_DEFRAG_THROTTLE_COUNT (throttle_count, conf); +- gf_log ("DHT", GF_LOG_INFO, "conf->dthrottle: %s, " ++ gf_msg ("DHT", GF_LOG_INFO, 0, ++ DHT_MSG_REBAL_THROTTLE_INFO, ++ "conf->dthrottle: %s, " + "conf->defrag->recon_thread_count: %d", + conf->dthrottle, conf->defrag->recon_thread_count); + } +@@ -597,7 +602,8 @@ dht_init (xlator_t *this) + /* We get the commit-hash to set only for rebalance process */ + if (dict_get_uint32 (this->options, + "commit-hash", &commit_hash) == 0) { +- gf_log (this->name, GF_LOG_INFO, "%s using commit hash %u", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_COMMIT_HASH_INFO, "%s using commit hash %u", + __func__, commit_hash); + conf->vol_commit_hash = commit_hash; + conf->vch_forced = _gf_true; +@@ -722,7 +728,8 @@ dht_init (xlator_t *this) + if (cmd) { + ret = dht_init_local_subvolumes (this, conf); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_INIT_LOCAL_SUBVOL_FAILED, + "dht_init_local_subvolumes failed"); + goto err; + } +@@ -751,8 +758,8 @@ dht_init (xlator_t *this) + + this->local_pool = mem_pool_new (dht_local_t, 512); + if (!this->local_pool) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- DHT_MSG_INIT_FAILED, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, + " DHT initialisation failed. " + "failed to create local_t's memory pool"); + goto err; +@@ -767,9 +774,10 @@ dht_init (xlator_t *this) + + GF_DECIDE_DEFRAG_THROTTLE_COUNT(throttle_count, conf); + +- gf_log ("DHT", GF_LOG_DEBUG, "conf->dthrottle: %s, " +- "conf->defrag->recon_thread_count: %d", +- conf->dthrottle, conf->defrag->recon_thread_count); ++ gf_msg_debug ("DHT", 0, "conf->dthrottle: %s, " ++ "conf->defrag->recon_thread_count: %d", ++ conf->dthrottle, ++ conf->defrag->recon_thread_count); + } + + GF_OPTION_INIT ("xattr-name", conf->xattr_name, str, err); +diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c +index 72d6d9c..a7d259b 100644 +--- a/xlators/cluster/dht/src/nufa.c ++++ b/xlators/cluster/dht/src/nufa.c +@@ -206,7 +206,8 @@ nufa_lookup (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (local->xattr_req, + conf->xattr_name, 4 * 4); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_DICT_SET_FAILED, + "Failed to set dict value."); + op_errno = -1; + goto err; +@@ -227,7 +228,8 @@ nufa_lookup (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (local->xattr_req, + conf->xattr_name, 4 * 4); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_DICT_SET_FAILED, + "Failed to set dict value."); + op_errno = -1; + goto err; +@@ -236,7 +238,8 @@ nufa_lookup (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (local->xattr_req, + conf->link_xattr_name, 256); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_DICT_SET_FAILED, + "Failed to set dict value."); + op_errno = -1; + goto err; +@@ -508,7 +511,9 @@ nufa_find_local_brick (xlator_t *xl, void *data) + + if (strcmp (xl->name, local_volname) == 0) { + conf->private = xl; +- gf_log (this->name, GF_LOG_INFO, "Using specified subvol %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_INFO, ++ "Using specified subvol %s", + local_volname); + return; + } +@@ -521,7 +526,8 @@ nufa_find_local_brick (xlator_t *xl, void *data) + (gf_is_same_address (local_volname, brick_host) || + gf_is_local_addr (brick_host))) { + conf->private = xl; +- gf_log (this->name, GF_LOG_INFO, "Using the first local " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_INFO, "Using the first local " + "subvol %s", xl->name); + return; + } +@@ -551,7 +557,8 @@ nufa_find_local_subvol (xlator_t *this, + + xlator_foreach_depth_first (this, fn, data); + if (!conf->private) { +- gf_log (this->name, GF_LOG_ERROR, "Couldn't find a local " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_BRICK_ERROR, "Couldn't find a local " + "brick"); + return -1; + } +@@ -562,7 +569,8 @@ nufa_find_local_subvol (xlator_t *this, + + parent = trav->xlator; + if (strcmp (parent->type, "cluster/nufa") == 0) { +- gf_log (this->name, GF_LOG_INFO, "Found local subvol, " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_INFO, "Found local subvol, " + "%s", candidate->name); + ret = 0; + conf->private = candidate; +@@ -602,9 +610,9 @@ nufa_init (xlator_t *this) + local_volname = my_hostname; + + else +- gf_log (this->name, GF_LOG_WARNING, +- "could not find hostname (%s)", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ DHT_MSG_GET_HOSTNAME_FAILED, ++ "could not find hostname"); + + } + +@@ -613,7 +621,8 @@ nufa_init (xlator_t *this) + args.addr_match = addr_match; + ret = nufa_find_local_subvol (this, nufa_find_local_brick, &args); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ DHT_MSG_SUBVOL_INFO, + "Unable to find local subvolume, switching " + "to dht mode"); + nufa_to_dht (this); +diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c +index 0071dfa..9922a91 100644 +--- a/xlators/cluster/dht/src/switch.c ++++ b/xlators/cluster/dht/src/switch.c +@@ -295,7 +295,8 @@ switch_lookup (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (local->xattr_req, + conf->xattr_name, 4 * 4); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_DICT_SET_FAILED, + "failed to set dict value for %s", + conf->xattr_name); + +@@ -314,14 +315,16 @@ switch_lookup (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (local->xattr_req, + conf->xattr_name, 4 * 4); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_DICT_SET_FAILED, + "failed to set dict value for %s", + conf->xattr_name); + + ret = dict_set_uint32 (local->xattr_req, + conf->link_xattr_name, 256); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, ++ DHT_MSG_DICT_SET_FAILED, + "failed to set dict value for %s", + conf->link_xattr_name); + +@@ -662,7 +665,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, + pattern = strtok_r (dup_str, ":", &tmp_str1); + childs = strtok_r (NULL, ":", &tmp_str1); + if (strncmp (pattern, "*", 2) == 0) { +- gf_log ("switch", GF_LOG_INFO, ++ gf_msg ("switch", GF_LOG_INFO, 0, ++ DHT_MSG_SWITCH_PATTERN_INFO, + "'*' pattern will be taken by default " + "for all the unconfigured child nodes," + " hence neglecting current option"); +@@ -681,7 +685,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, + idx++; + child = strtok_r (NULL, ",", &tmp); + } else { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_SUBVOL_ERROR, + "%s is not a subvolume of %s. " + "pattern can only be scheduled " + "only to a subvolume of %s", +@@ -723,7 +728,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, + } + } else { + /* error */ +- gf_log ("switch", GF_LOG_ERROR, ++ gf_msg ("switch", GF_LOG_ERROR, 0, ++ DHT_MSG_SET_SWITCH_PATTERN_ERROR, + "Check \"scheduler.switch.case\" " + "option in unify volume. Exiting"); + goto err; +@@ -755,7 +761,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, + flag++; + } + if (!flag) { +- gf_log ("switch", GF_LOG_ERROR, ++ gf_msg ("switch", GF_LOG_ERROR, 0, ++ DHT_MSG_SET_SWITCH_PATTERN_ERROR, + "No nodes left for pattern '*'. Exiting"); + goto err; + } +diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c +index 7b4890c..8616233 100644 +--- a/xlators/cluster/dht/src/tier.c ++++ b/xlators/cluster/dht/src/tier.c +@@ -485,11 +485,11 @@ tier_process_brick_cbk (dict_t *brick_dict, char *key, data_t *value, + query_cbk_args->queryFILE = fopen(GET_QFILE_PATH + (gfdb_brick_dict_info->_gfdb_promote), "a+"); + if (!query_cbk_args->queryFILE) { +- gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, +- "Failed to open query file %s:%s", +- GET_QFILE_PATH +- (gfdb_brick_dict_info->_gfdb_promote), +- strerror(errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ DHT_MSG_LOG_TIER_ERROR, ++ "Failed to open query file %s", ++ GET_QFILE_PATH ++ (gfdb_brick_dict_info->_gfdb_promote)); + goto out; + } + if (!gfdb_brick_dict_info->_gfdb_promote) { +@@ -577,8 +577,9 @@ tier_build_migration_qfile (demotion_args_t *args, + + ret = gettimeofday (¤t_time, NULL); + if (ret == -1) { +- gf_log (args->this->name, GF_LOG_ERROR, +- "Failed to get current timen"); ++ gf_msg (args->this->name, GF_LOG_ERROR, errno, ++ DHT_MSG_SYS_CALL_GET_TIME_FAILED, ++ "Failed to get current time\n"); + goto out; + } + time_in_past.tv_sec = current_time.tv_sec - time_in_past.tv_sec; +@@ -589,8 +590,9 @@ tier_build_migration_qfile (demotion_args_t *args, + ret = dict_foreach (args->brick_list, tier_process_brick_cbk, + &gfdb_brick_dict_info); + if (ret) { +- gf_log (args->this->name, GF_LOG_ERROR, +- "Brick query failedn"); ++ gf_msg (args->this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_BRICK_QUERY_FAILED, ++ "Brick query failed\n"); + goto out; + } + out: +@@ -607,7 +609,8 @@ tier_migrate_files_using_qfile (demotion_args_t *comp, + + query_cbk_args->queryFILE = fopen (qfile, "r"); + if (!query_cbk_args->queryFILE) { +- gf_log ("tier", GF_LOG_ERROR, ++ gf_msg ("tier", GF_LOG_ERROR, 0, ++ DHT_MSG_FOPEN_FAILED, + "Failed opening %s for migration", qfile); + goto out; + } +@@ -812,10 +815,9 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + ret = 0; + defrag->defrag_status = + GF_DEFRAG_STATUS_COMPLETE; +- gf_msg (this->name, GF_LOG_DEBUG, 0, +- DHT_MSG_LOG_TIER_ERROR, +- "defrag->defrag_cmd == " +- "GF_DEFRAG_CMD_START_DETACH_TIER"); ++ gf_msg_debug (this->name, 0, ++ "defrag->defrag_cmd == " ++ "GF_DEFRAG_CMD_START_DETACH_TIER"); + goto out; + } + +@@ -830,7 +832,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) + * using a NTP server*/ + ret = gettimeofday (¤t_time, NULL); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ DHT_MSG_SYS_CALL_GET_TIME_FAILED, + "Failed to get current time"); + goto out; + } +-- +1.7.1 + diff --git a/SOURCES/0151-gfdb-libglusterfs-Porting-to-a-new-logging-framework.patch b/SOURCES/0151-gfdb-libglusterfs-Porting-to-a-new-logging-framework.patch new file mode 100644 index 0000000..cdf7adb --- /dev/null +++ b/SOURCES/0151-gfdb-libglusterfs-Porting-to-a-new-logging-framework.patch @@ -0,0 +1,1636 @@ +From b84240c596498105ca442be546bcc8fa51cbb872 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 14:55:38 +0530 +Subject: [PATCH 151/190] gfdb/libglusterfs : Porting to a new logging framework + +Change-Id: I61874561fdf2c175d2b3eec0c85c25f12dc60552 +BUG: 1231797 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10819 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Joseph Fernandes +Reviewed-on: https://code.engineering.redhat.com/gerrit/51212 +Reviewed-by: Dan Lambright +Tested-by: Dan Lambright +--- + libglusterfs/src/gfdb/gfdb_data_store.c | 91 +++++--- + libglusterfs/src/gfdb/gfdb_data_store_types.h | 28 ++- + libglusterfs/src/gfdb/gfdb_sqlite3.c | 193 +++++++++------- + libglusterfs/src/gfdb/gfdb_sqlite3.h | 6 +- + libglusterfs/src/gfdb/gfdb_sqlite3_helper.c | 306 ++++++++++++++----------- + 5 files changed, 352 insertions(+), 272 deletions(-) + +diff --git a/libglusterfs/src/gfdb/gfdb_data_store.c b/libglusterfs/src/gfdb/gfdb_data_store.c +index 5699b75..8559a62 100644 +--- a/libglusterfs/src/gfdb/gfdb_data_store.c ++++ b/libglusterfs/src/gfdb/gfdb_data_store.c +@@ -11,6 +11,7 @@ + #include "gfdb_sqlite3.h" + #include "gfdb_data_store.h" + #include "list.h" ++#include "libglusterfs-messages.h" + + /****************************************************************************** + * +@@ -89,8 +90,9 @@ add_connection_node (gfdb_conn_node_t *_conn_node) { + /*Lock the list*/ + ret = pthread_mutex_lock (&db_conn_mutex); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed lock db connection list %s", strerror(ret)); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ret, ++ LG_MSG_LOCK_LIST_FAILED, "Failed lock db connection " ++ "list %s", strerror(ret)); + ret = -1; + goto out; + } +@@ -105,8 +107,9 @@ add_connection_node (gfdb_conn_node_t *_conn_node) { + /*unlock the list*/ + ret = pthread_mutex_unlock (&db_conn_mutex); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed unlock db connection list %s", strerror(ret)); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ret, ++ LG_MSG_UNLOCK_LIST_FAILED, "Failed unlock db " ++ "connection list %s", strerror(ret)); + ret = -1; + /*TODO What if the unlock fails. + * Will it lead to deadlock? +@@ -131,8 +134,9 @@ delete_conn_node (gfdb_conn_node_t *_conn_node) + /*Lock of the list*/ + ret = pthread_mutex_lock (&db_conn_mutex); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed lock on db connection list %s", strerror(ret)); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ret, ++ LG_MSG_LOCK_LIST_FAILED, "Failed lock on db connection" ++ " list %s", strerror(ret)); + goto out; + } + +@@ -153,9 +157,9 @@ delete_conn_node (gfdb_conn_node_t *_conn_node) + /*Release the list lock*/ + ret = pthread_mutex_unlock (&db_conn_mutex); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_WARNING, +- "Failed unlock on db connection" +- " list %s", strerror(ret)); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_WARNING, ret, ++ LG_MSG_UNLOCK_LIST_FAILED, "Failed unlock on db " ++ "connection list %s", strerror(ret)); + /*TODO What if the unlock fails. + * Will it lead to deadlock? + * Most of the gluster code +@@ -190,11 +194,13 @@ init_db_operations (gfdb_db_type_t gfdb_db_type, + case GFDB_HYPERDEX: + case GFDB_HASH_FILE_STORE: + case GFDB_ROCKS_DB: +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, "Plugin not supported"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_UNSUPPORTED_PLUGIN, "Plugin not supported"); + break; + case GFDB_INVALID_DB: + case GFDB_DB_END: +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, "Invalid DB Type"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_DB_TYPE, "Invalid DB Type"); + break; + } + return ret; +@@ -228,8 +234,9 @@ init_db (dict_t *args, gfdb_db_type_t gfdb_db_type) + _conn_node = GF_CALLOC (1, sizeof(gfdb_conn_node_t), + gf_mt_db_conn_node_t); + if (!_conn_node) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed mem alloc for gfdb_conn_node_t!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ENOMEM, ++ LG_MSG_NO_MEMORY, "Failed mem alloc for " ++ "gfdb_conn_node_t!"); + goto alloc_failed; + } + +@@ -240,8 +247,9 @@ init_db (dict_t *args, gfdb_db_type_t gfdb_db_type) + /*Add created connection node to the list*/ + ret = add_connection_node (_conn_node); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed to add connection node to list"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_ADD_TO_LIST_FAILED, "Failed to add connection " ++ "node to list"); + goto _conn_failed; + } + +@@ -250,8 +258,9 @@ init_db (dict_t *args, gfdb_db_type_t gfdb_db_type) + /*init the db ops object of db connection object*/ + ret = init_db_operations(gfdb_db_type, db_operations_t); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed initializing database operation failed."); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_INIT_DB_FAILED, "Failed initializing database " ++ "operation failed."); + ret = -1; + goto init_db_failed; + } +@@ -261,8 +270,8 @@ init_db (dict_t *args, gfdb_db_type_t gfdb_db_type) + ret = db_operations_t->init_db_op (args, &_conn_node->gfdb_connection. + gf_db_connection); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed initializing database"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_INIT_DB_FAILED, "Failed initializing database"); + ret = -1; + goto init_db_failed; + } +@@ -278,8 +287,9 @@ init_db (dict_t *args, gfdb_db_type_t gfdb_db_type) + init_db_failed: + ret = delete_conn_node (_conn_node); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed deleting connection node from list"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FROM_LIST_FAILED, "Failed deleting " ++ "connection node from list"); + } + return NULL; + /*if adding to the list failed free connection node*/ +@@ -316,15 +326,17 @@ fini_db (gfdb_conn_node_t *_conn_node) + ret = db_operations_t->fini_db_op(&_conn_node->gfdb_connection. + gf_db_connection); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed close the db connection"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_CLOSE_CONNECTION_FAILED, "Failed close the db " ++ "connection"); + goto out; + } + + ret = delete_conn_node (_conn_node); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed deleting connection node from list"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FROM_LIST_FAILED, "Failed deleting " ++ "connection node from list"); + } + empty: + ret = 0; +@@ -370,8 +382,9 @@ insert_record (gfdb_conn_node_t *_conn_node, + ret = db_operations_t->insert_record_op (gf_db_connection, + gfdb_db_record); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Insert/Update operation failed!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_INSERT_OR_UPDATE_FAILED, "Insert/Update" ++ " operation failed!"); + } + } + +@@ -409,8 +422,9 @@ delete_record (gfdb_conn_node_t *_conn_node, + ret = db_operations_t->delete_record_op (gf_db_connection, + gfdb_db_record); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Delete operation failed!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FAILED, "Delete operation " ++ "failed!"); + } + + } +@@ -448,8 +462,9 @@ find_all(gfdb_conn_node_t *_conn_node, gf_query_callback_t query_callback, + query_callback, + _query_cbk_args); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Find all operation failed!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_FIND_OP_FAILED, "Find all operation " ++ "failed!"); + } + + } +@@ -494,8 +509,9 @@ find_unchanged_for_time(gfdb_conn_node_t *_conn_node, + _query_cbk_args, + for_time); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Find unchanged operation failed!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_FIND_OP_FAILED, "Find unchanged " ++ "operation failed!"); + } + + } +@@ -538,7 +554,8 @@ find_recently_changed_files(gfdb_conn_node_t *_conn_node, + _query_cbk_args, + from_time); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_FIND_OP_FAILED, + "Find changed operation failed!"); + } + +@@ -594,7 +611,8 @@ find_unchanged_for_time_freq(gfdb_conn_node_t *_conn_node, + read_freq_thresold, + _clear_counters); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_FIND_OP_FAILED, + "Find unchanged with freq operation failed!"); + } + +@@ -649,7 +667,8 @@ find_recently_changed_files_freq(gfdb_conn_node_t *_conn_node, + read_freq_thresold, + _clear_counters); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ LG_MSG_FIND_OP_FAILED, + "Find changed with freq operation failed!"); + } + +diff --git a/libglusterfs/src/gfdb/gfdb_data_store_types.h b/libglusterfs/src/gfdb/gfdb_data_store_types.h +index 72a1c89..f642c63 100644 +--- a/libglusterfs/src/gfdb/gfdb_data_store_types.h ++++ b/libglusterfs/src/gfdb/gfdb_data_store_types.h +@@ -24,6 +24,7 @@ + #include "compat-uuid.h" + #include "gfdb_mem-types.h" + #include "dict.h" ++#include "libglusterfs-messages.h" + + typedef enum gf_db_operation { + GFDB_INVALID_DB_OP = -1, +@@ -340,8 +341,9 @@ gfdb_query_record_init() + gfdb_query_record = GF_CALLOC (1, sizeof(gfdb_query_record_t), + gf_mt_gfdb_query_record_t); + if (!gfdb_query_record) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Error allocating memory to gfdb_query_record "); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ENOMEM, ++ LG_MSG_NO_MEMORY, "Error allocating memory to " ++ "gfdb_query_record "); + goto out; + } + ret = 0; +@@ -384,8 +386,9 @@ gfdb_link_info_init () + gfdb_link_info = GF_CALLOC (1, sizeof(gfdb_link_info_t), + gf_mt_gfdb_link_info_t); + if (!gfdb_link_info) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Error allocating memory to gfdb_link_info "); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, ENOMEM, ++ LG_MSG_NO_MEMORY, "Error allocating memory to " ++ "gfdb_link_info "); + } + + return gfdb_link_info; +@@ -697,9 +700,9 @@ typedef struct gfdb_connection { + goto error;\ + ret = dict_add (params_dict, param_key, data);\ + if (ret) {\ +- gf_log (comp_name, GF_LOG_ERROR,\ +- "Failed setting %s to params dictionary",\ +- param_key);\ ++ gf_msg (comp_name, GF_LOG_ERROR, 0,\ ++ LG_MSG_SET_PARAM_FAILED, "Failed setting %s "\ ++ "to params dictionary", param_key);\ + goto error;\ + };\ + } while (0) +@@ -711,8 +714,9 @@ typedef struct gfdb_connection { + data_t *data = NULL;\ + data = dict_get (params_dict, param_key);\ + if (!data) {\ +- gf_log (comp_name, GF_LOG_ERROR,\ +- "Failed to retrieve %s from params", param_key);\ ++ gf_msg (comp_name, GF_LOG_ERROR, 0,\ ++ LG_MSG_GET_PARAM_FAILED, "Failed to retrieve "\ ++ "%s from params", param_key);\ + goto error;\ + } else {\ + str_value = data->data;\ +@@ -729,9 +733,9 @@ typedef struct gfdb_connection { + data = dict_get (params_dict, param_key);\ + if (!data) {\ + str_value = _default_v;\ +- gf_log (comp_name, GF_LOG_WARNING,\ +- "Failed to retrieve %s from params."\ +- "Assigning default value: %s",\ ++ gf_msg (comp_name, GF_LOG_WARNING, 0,\ ++ LG_MSG_GET_PARAM_FAILED, "Failed to retrieve "\ ++ "%s from params.Assigning default value: %s",\ + param_key, _default_v);\ + } else {\ + str_value = data->data;\ +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c +index 02d6085..7eca03f 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c +@@ -10,6 +10,7 @@ + + #include "gfdb_sqlite3.h" + #include "gfdb_sqlite3_helper.h" ++#include "libglusterfs-messages.h" + + /****************************************************************************** + * +@@ -24,8 +25,9 @@ gf_sql_connection_init () + gf_sql_conn = GF_CALLOC (1, sizeof(gf_sql_connection_t), + gf_mt_sql_connection_t); + if (gf_sql_conn == NULL) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Error allocating memory to gf_sql_connection_t "); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, ENOMEM, ++ LG_MSG_NO_MEMORY, "Error allocating memory to " ++ "gf_sql_connection_t "); + } + + return gf_sql_conn; +@@ -156,8 +158,9 @@ sql_stmt_init () + gf_common_mt_char); + + if (!sql_stmt) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Error allocating memory to SQL Statement "); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, ENOMEM, ++ LG_MSG_NO_MEMORY, "Error allocating memory to SQL " ++ "Statement "); + goto out; + } + out: +@@ -189,7 +192,7 @@ gf_open_sqlite3_conn(char *sqlite3_db_path, int flags) + /*Creates DB if not created*/ + ret = sqlite3_open_v2(sqlite3_db_path, &sqlite3_db_conn, flags, NULL); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_DB_ERROR, + "FATAL: Could open %s : %s", + sqlite3_db_path, sqlite3_errmsg(sqlite3_db_conn)); + } +@@ -206,9 +209,10 @@ gf_close_sqlite3_conn(sqlite3 *sqlite3_db_conn) + if (sqlite3_db_conn) { + ret = sqlite3_close (sqlite3_db_conn); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "FATAL: sqlite3 close connection failed %s", +- sqlite3_errmsg(sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CONNECTION_ERROR, "FATAL: sqlite3 close" ++ " connection failed %s", ++ sqlite3_errmsg(sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -269,9 +273,8 @@ create_filetable (sqlite3 *sqlite3_db_conn) + ret = sqlite3_exec (sqlite3_db_conn, sql_stmt, NULL, NULL, + &sql_strerror); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed executing: %s : %s", +- sql_stmt, sql_strerror); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, ++ "Failed executing: %s : %s", sql_stmt, sql_strerror); + sqlite3_free (sql_strerror); + ret = -1; + goto out; +@@ -398,13 +401,15 @@ gf_sqlite3_init (dict_t *args, void **db_conn) { + GF_ASSERT (db_conn); + + if (*db_conn != NULL) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "DB Connection is not empty!"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CONNECTION_ERROR, "DB Connection is not " ++ "empty!"); + return 0; + } + + if (!sqlite3_threadsafe()) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_NOT_MULTITHREAD_MODE, + "sqlite3 is not in multithreaded mode"); + goto out; + } +@@ -430,7 +435,8 @@ gf_sqlite3_init (dict_t *args, void **db_conn) { + SQLITE_OPEN_READWRITE | + SQLITE_OPEN_CREATE); + if (!sql_conn->sqlite3_db_conn) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CONNECTION_ERROR, + "Failed creating db connection"); + goto out; + } +@@ -444,17 +450,18 @@ gf_sqlite3_init (dict_t *args, void **db_conn) { + /*Apply sqlite3 params to database*/ + ret = apply_sql_params_db(sql_conn, args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed applying sql params to %s", +- sql_conn->sqlite3_db_path); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_SET_PARAM_FAILED, "Failed applying sql params" ++ " to %s", sql_conn->sqlite3_db_path); + goto out; + } + + /*Create the schema if NOT present*/ + ret = create_filetable (sql_conn->sqlite3_db_conn); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed Creating %s Table", GF_FILE_TABLE); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Failed Creating %s Table", ++ GF_FILE_TABLE); + goto out; + } + +@@ -517,7 +524,7 @@ int gf_sqlite3_insert(void *db_conn, gfdb_db_record_t *gfdb_db_record) + /*This is for debugging bug. Will be removed with a bug fix*/ + if ((GFDB_FOP_WIND == gfdb_db_record->gfdb_fop_path) && + (strncmp(gfdb_db_record->file_path, "gfdb_fop_type); + goto out; +@@ -527,16 +534,16 @@ int gf_sqlite3_insert(void *db_conn, gfdb_db_record_t *gfdb_db_record) + case GFDB_FOP_WIND: + ret = gf_sql_insert_wind(sql_conn, gfdb_db_record); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed wind insert"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_INSERT_FAILED, "Failed wind insert"); + goto out; + } + break; + case GFDB_FOP_UNWIND: + ret = gf_sql_insert_unwind (sql_conn, gfdb_db_record); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed unwind insert"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_INSERT_FAILED, "Failed unwind insert"); + goto out; + } + break; +@@ -544,8 +551,9 @@ int gf_sqlite3_insert(void *db_conn, gfdb_db_record_t *gfdb_db_record) + case GFDB_FOP_WDEL: + ret = gf_sql_update_delete_wind(sql_conn, gfdb_db_record); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed updating delete during wind"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, "Failed updating delete " ++ "during wind"); + goto out; + } + break; +@@ -553,14 +561,14 @@ int gf_sqlite3_insert(void *db_conn, gfdb_db_record_t *gfdb_db_record) + case GFDB_FOP_UNDEL_ALL: + ret = gf_sql_delete_unwind(sql_conn, gfdb_db_record); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed deleting"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FAILED, "Failed deleting"); + goto out; + } + break; + case GFDB_FOP_INVALID: + default: +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_INVALID_FOP, + "Cannot record to DB: Invalid FOP"); + goto out; + } +@@ -620,8 +628,9 @@ gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback, + ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, query_str, -1, + &prep_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing statment %s : %s", query_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing statment %s :" ++ "%s", query_str, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -629,7 +638,7 @@ gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback, + + ret = gf_sql_query_function(prep_stmt, query_callback, query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, + "Failed Query %s", query_str); + goto out; + } +@@ -681,8 +690,9 @@ gf_sqlite3_find_recently_changed_files(void *db_conn, + ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, query_str, -1, + &prep_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing statment %s : %s", query_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing statment %s :" ++ " %s", query_str, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -691,9 +701,9 @@ gf_sqlite3_find_recently_changed_files(void *db_conn, + /*Bind write wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 1, from_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding from_time_usec %ld : %s", +- from_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding from_time_usec " ++ "%ld : %s", from_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -702,9 +712,9 @@ gf_sqlite3_find_recently_changed_files(void *db_conn, + /*Bind read wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 2, from_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding from_time_usec %ld : %s ", +- from_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding from_time_usec " ++ "%ld : %s ", from_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -713,7 +723,7 @@ gf_sqlite3_find_recently_changed_files(void *db_conn, + /*Execute the query*/ + ret = gf_sql_query_function(prep_stmt, query_callback, query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, + "Failed Query %s", query_str); + goto out; + } +@@ -765,8 +775,9 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, + ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, query_str, -1, + &prep_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing statment %s : %s", query_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing statment %s :" ++ " %s", query_str, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -775,8 +786,9 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, + /*Bind write wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 1, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -785,8 +797,9 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, + /*Bind read wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 2, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -795,7 +808,7 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, + /*Execute the query*/ + ret = gf_sql_query_function(prep_stmt, query_callback, query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, + "Failed Query %s", query_str); + goto out; + } +@@ -859,8 +872,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, query_str, -1, + &prep_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing statment %s : %s", query_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing statment %s :" ++ " %s", query_str, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -869,9 +883,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + /*Bind write wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 1, from_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding from_time_usec %ld : %s", +- from_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding from_time_usec " ++ "%ld : %s", from_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -880,8 +894,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + /*Bind write frequency thresold*/ + ret = sqlite3_bind_int(prep_stmt, 2, freq_write_cnt); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding freq_write_cnt %d : %s", freq_write_cnt, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding freq_write_cnt " ++ "%d : %s", freq_write_cnt, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -891,9 +906,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + /*Bind read wind time*/ + ret = sqlite3_bind_int64(prep_stmt, 3, from_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding from_time_usec %ld : %s", +- from_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding from_time_usec " ++ "%ld : %s", from_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -902,8 +917,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + /*Bind read frequency thresold*/ + ret = sqlite3_bind_int(prep_stmt, 4, freq_read_cnt); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding freq_read_cnt %d : %s", freq_read_cnt, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding freq_read_cnt " ++ "%d : %s", freq_read_cnt, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -912,7 +928,7 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + /*Execute the query*/ + ret = gf_sql_query_function(prep_stmt, query_callback, query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, + "Failed Query %s", query_str); + goto out; + } +@@ -923,8 +939,9 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, + if (clear_counters) { + ret = gf_sql_clear_counters(sql_conn); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed clearing counters!"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CLEAR_COUNTER_FAILED, "Failed clearing" ++ " counters!"); + goto out; + } + } +@@ -1000,8 +1017,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query_str, -1, + &prep_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing delete statment %s : %s", query_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing delete " ++ "statment %s : %s", query_str, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1010,9 +1028,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind write wind time*/ + ret = sqlite3_bind_int64 (prep_stmt, 1, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", +- for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1021,9 +1039,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind write frequency thresold*/ + ret = sqlite3_bind_int (prep_stmt, 2, freq_write_cnt); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding freq_write_cnt %d : %s", +- freq_write_cnt, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding freq_write_cnt" ++ " %d : %s", freq_write_cnt, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1032,9 +1050,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind write wind time*/ + ret = sqlite3_bind_int64 (prep_stmt, 3, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", +- for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1045,9 +1063,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind read wind time*/ + ret = sqlite3_bind_int64 (prep_stmt, 4, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", +- for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1056,9 +1074,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind read frequency thresold*/ + ret = sqlite3_bind_int (prep_stmt, 5, freq_read_cnt); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding freq_read_cnt %d : %s", +- freq_read_cnt, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding freq_read_cnt " ++ "%d : %s", freq_read_cnt, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1067,9 +1085,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Bind read wind time*/ + ret = sqlite3_bind_int64 (prep_stmt, 6, for_time_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding for_time_usec %ld : %s", +- for_time_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " ++ "%ld : %s", for_time_usec, + sqlite3_errmsg(sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -1078,7 +1096,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + /*Execute the query*/ + ret = gf_sql_query_function (prep_stmt, query_callback, query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, + "Failed Query %s", query_str); + goto out; + } +@@ -1088,8 +1106,9 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + if (clear_counters) { + ret = gf_sql_clear_counters (sql_conn); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed clearing counters!"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CLEAR_COUNTER_FAILED, "Failed clearing " ++ "counters!"); + goto out; + } + } +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.h b/libglusterfs/src/gfdb/gfdb_sqlite3.h +index 04bfde7..4c9489f 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3.h ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3.h +@@ -22,6 +22,7 @@ + #include "logging.h" + #include "gfdb_data_store_types.h" + #include "gfdb_mem-types.h" ++#include "libglusterfs-messages.h" + + #define GF_STMT_SIZE_MAX 2048 + +@@ -137,7 +138,8 @@ typedef struct gf_sql_connection { + do {\ + GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, sql_conn, out);\ + if (!sql_conn->sqlite3_db_conn) {\ +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,\ ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,\ ++ LG_MSG_CONNECTION_INIT_FAILED,\ + "sqlite3 connection not initialized");\ + goto out;\ + };\ +@@ -150,7 +152,7 @@ do {\ + ret = sqlite3_exec (sql_conn->sqlite3_db_conn, sqlite3_config_str,\ + NULL, NULL, NULL);\ + if (ret != SQLITE_OK) {\ +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR,\ ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED,\ + "Failed executing: %s : %s",\ + sqlite3_config_str, sqlite3_errmsg\ + (sql_conn->sqlite3_db_conn));\ +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c +index 03ebb1f..f3e0e97 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c +@@ -9,6 +9,7 @@ + */ + + #include "gfdb_sqlite3_helper.h" ++#include "libglusterfs-messages.h" + + #define GFDB_SQL_STMT_SIZE 256 + +@@ -44,9 +45,9 @@ gf_sql_delete_all (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, delete_link_str, -1, + &delete_link_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing delete statment %s : %s", +- delete_link_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing delete " ++ "statment %s : %s", delete_link_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -55,9 +56,9 @@ gf_sql_delete_all (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (delete_link_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -65,7 +66,7 @@ gf_sql_delete_all (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step (delete_link_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + delete_link_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -82,9 +83,9 @@ gf_sql_delete_all (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, delete_file_str, -1, + &delete_file_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing delete statment %s : %s", +- delete_file_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing delete " ++ "statment %s : %s", delete_file_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -93,16 +94,16 @@ gf_sql_delete_all (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (delete_file_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } + + /*Execute the prepare statement*/ + if (sqlite3_step (delete_file_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + delete_file_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -139,8 +140,9 @@ gf_sql_delete_link (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, delete_str, -1, + &delete_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing delete statment %s : %s", delete_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing delete " ++ "statment %s : %s", delete_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -149,7 +151,8 @@ gf_sql_delete_link (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (delete_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, + "Failed binding gfid %s : %s", gfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -159,8 +162,9 @@ gf_sql_delete_link (gf_sql_connection_t *sql_conn, + /*Bind pargfid*/ + ret = sqlite3_bind_text (delete_stmt, 2, pargfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent gfid %s : %s", pargfid, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent gfid %s " ++ ": %s", pargfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -169,8 +173,9 @@ gf_sql_delete_link (gf_sql_connection_t *sql_conn, + /*Bind basename*/ + ret = sqlite3_bind_text (delete_stmt, 3, basename, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding basename %s : %s", basename, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding basename %s : " ++ "%s", basename, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -178,7 +183,7 @@ gf_sql_delete_link (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step(delete_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + delete_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -227,8 +232,9 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, update_str, -1, + &update_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing update statment %s : %s", update_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing update " ++ "statment %s : %s", update_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -238,8 +244,9 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + /*Bind link_update*/ + ret = sqlite3_bind_int (update_stmt, 1, update_flag); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding update_flag %d : %s", update_flag, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding update_flag %d " ++ ": %s", update_flag, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -248,9 +255,9 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (update_stmt, 2, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -258,8 +265,9 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + /*Bind pargfid*/ + ret = sqlite3_bind_text (update_stmt, 3, pargfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent gfid %s : %s", pargfid, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent gfid %s " ++ ": %s", pargfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -268,8 +276,9 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + /*Bind basename*/ + ret = sqlite3_bind_text (update_stmt, 4, basename, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding basename %s : %s", basename, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding basename %s : " ++ "%s", basename, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -278,7 +287,7 @@ gf_sql_update_link_flags (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step(update_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + update_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -323,8 +332,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, insert_str, -1, + &insert_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing insert statment %s : %s", insert_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing insert " ++ "statment %s : %s", insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -333,9 +343,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (insert_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -343,8 +353,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind pargfid*/ + ret = sqlite3_bind_text (insert_stmt, 2, pargfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent gfid %s : %s", pargfid, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent gfid %s " ++ ": %s", pargfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -353,7 +364,8 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind basename*/ + ret = sqlite3_bind_text (insert_stmt, 3, basename, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, + "Failed binding basename %s : %s", basename, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -363,8 +375,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind basepath*/ + ret = sqlite3_bind_text (insert_stmt, 4, basepath, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding basepath %s : %s", basepath, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding basepath %s : " ++ "%s", basepath, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -372,10 +385,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step (insert_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s %s %s %s %s : %s", +- gfid, pargfid, basename, basepath, +- insert_str, ++ gfid, pargfid, basename, basepath, insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -426,8 +438,8 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + ret = gf_sql_delete_link (sql_conn, gfid, old_pargfid, + old_basename); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed deleting old link"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FAILED, "Failed deleting old link"); + goto out; + } + +@@ -440,8 +452,9 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, insert_str, -1, + &insert_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing insert statment %s : %s", insert_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing insert " ++ "statment %s : %s", insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -450,9 +463,9 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (insert_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -460,8 +473,9 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + /*Bind new pargfid*/ + ret = sqlite3_bind_text (insert_stmt, 2, pargfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent gfid %s : %s", pargfid, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent gfid %s " ++ ": %s", pargfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -470,8 +484,9 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + /*Bind new basename*/ + ret = sqlite3_bind_text (insert_stmt, 3, basename, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding basename %s : %s", basename, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding basename %s : " ++ "%s", basename, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -480,8 +495,9 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + /*Bind new basepath*/ + ret = sqlite3_bind_text (insert_stmt, 4, basepath, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding basename %s : %s", basepath, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding basename %s : " ++ "%s", basepath, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -489,7 +505,7 @@ gf_sql_update_link (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step (insert_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -527,8 +543,9 @@ gf_sql_insert_write_wind_time (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, insert_str, -1, + &insert_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing insert statment %s : %s", insert_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing insert " ++ "statment %s : %s", insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -537,9 +554,9 @@ gf_sql_insert_write_wind_time (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (insert_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } +@@ -547,9 +564,9 @@ gf_sql_insert_write_wind_time (gf_sql_connection_t *sql_conn, + /*Bind wind secs*/ + ret = sqlite3_bind_int (insert_stmt, 2, wind_time->tv_sec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent wind secs %ld : %s", +- wind_time->tv_sec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent wind " ++ "secs %ld : %s", wind_time->tv_sec, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -558,9 +575,9 @@ gf_sql_insert_write_wind_time (gf_sql_connection_t *sql_conn, + /*Bind wind msecs*/ + ret = sqlite3_bind_int (insert_stmt, 3, wind_time->tv_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent wind msecs %ld : %s", +- wind_time->tv_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent wind " ++ "msecs %ld : %s", wind_time->tv_usec, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -568,10 +585,9 @@ gf_sql_insert_write_wind_time (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step (insert_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt GFID:%s %s : %s", +- gfid, +- insert_str, ++ gfid, insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -653,8 +669,9 @@ gf_update_time (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, update_str, -1, + &update_stmt, 0); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed preparing insert statment %s : %s", update_str, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PREPARE_FAILED, "Failed preparing insert " ++ "statment %s : %s", update_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -663,9 +680,9 @@ gf_update_time (gf_sql_connection_t *sql_conn, + /*Bind time secs*/ + ret = sqlite3_bind_int (update_stmt, 1, update_time->tv_sec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent wind secs %ld : %s", +- update_time->tv_sec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent wind " ++ "secs %ld : %s", update_time->tv_sec, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -674,9 +691,9 @@ gf_update_time (gf_sql_connection_t *sql_conn, + /*Bind time msecs*/ + ret = sqlite3_bind_int (update_stmt, 2, update_time->tv_usec); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding parent wind msecs %ld : %s", +- update_time->tv_usec, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding parent wind " ++ "msecs %ld : %s", update_time->tv_usec, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -685,16 +702,16 @@ gf_update_time (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (update_stmt, 3, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed binding gfid %s : %s", gfid, +- sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; + } + + /*Execute the prepare statement*/ + if (sqlite3_step (update_stmt) != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing the prepared stmt %s : %s", + update_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); +@@ -735,8 +752,8 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + + gfid_str = gf_strdup (uuid_utoa (gfdb_db_record->gfid)); + if (!gfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating gfid string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating gfid string failed."); + goto out; + } + +@@ -747,8 +764,9 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + /*Parent GFID is always set*/ + pargfid_str = gf_strdup (uuid_utoa (gfdb_db_record->pargfid)); + if (!pargfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating gfid string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating gfid string " ++ "failed."); + goto out; + } + +@@ -761,8 +779,9 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + gfdb_db_record->file_path, + gfdb_db_record->link_consistency); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed inserting link in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_INSERT_FAILED, "Failed " ++ "inserting link in DB"); + goto out; + } + gfdb_db_record->islinkupdate = gfdb_db_record-> +@@ -775,8 +794,9 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + ret = gf_sql_insert_write_wind_time (sql_conn, gfid_str, + modtime); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed inserting wind time in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_INSERT_FAILED, "Failed " ++ "inserting wind time in DB"); + goto out; + } + goto out; +@@ -788,7 +808,8 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + old_pargfid_str = gf_strdup (uuid_utoa ( + gfdb_db_record->old_pargfid)); + if (!old_pargfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ 0, LG_MSG_CREATE_FAILED, + "Creating gfid string failed."); + goto out; + } +@@ -801,7 +822,8 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + gfdb_db_record-> + link_consistency); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ 0, LG_MSG_UPDATE_FAILED, + "Failed updating link"); + goto out; + } +@@ -816,8 +838,9 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + gfdb_db_record->file_path, + gfdb_db_record->link_consistency); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed inserting link in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ 0, LG_MSG_INSERT_FAILED, ++ "Failed inserting link in DB"); + goto out; + } + gfdb_db_record->islinkupdate = gfdb_db_record-> +@@ -834,8 +857,9 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + its_wind, + isreadfop (gfdb_db_record->gfdb_fop_type)); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed update wind time in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, "Failed update wind time" ++ " in DB"); + goto out; + } + } +@@ -867,8 +891,8 @@ gf_sql_insert_unwind (gf_sql_connection_t *sql_conn, + + gfid_str = gf_strdup (uuid_utoa(gfdb_db_record->gfid)); + if (!gfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating gfid string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating gfid string failed."); + goto out; + } + +@@ -881,8 +905,9 @@ gf_sql_insert_unwind (gf_sql_connection_t *sql_conn, + (!its_wind), + isreadfop (gfdb_db_record->gfdb_fop_type)); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed update unwind time in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, "Failed update unwind " ++ "time in DB"); + goto out; + } + } +@@ -893,7 +918,8 @@ gf_sql_insert_unwind (gf_sql_connection_t *sql_conn, + + pargfid_str = gf_strdup(uuid_utoa(gfdb_db_record->pargfid)); + if (!pargfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, + "Creating pargfid_str string failed."); + goto out; + } +@@ -901,8 +927,9 @@ gf_sql_insert_unwind (gf_sql_connection_t *sql_conn, + ret = gf_sql_update_link_flags (sql_conn, gfid_str, pargfid_str, + gfdb_db_record->file_name, 0, _gf_true); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed updating link flags in unwind"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, "Failed updating link " ++ "flags in unwind"); + goto out; + } + } +@@ -928,15 +955,16 @@ gf_sql_update_delete_wind (gf_sql_connection_t *sql_conn, + + gfid_str = gf_strdup (uuid_utoa(gfdb_db_record->gfid)); + if (!gfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating gfid string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating gfid string failed."); + goto out; + } + + pargfid_str = gf_strdup (uuid_utoa(gfdb_db_record->pargfid)); + if (!pargfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating pargfid_str string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating pargfid_str " ++ "string failed."); + goto out; + } + +@@ -945,7 +973,8 @@ gf_sql_update_delete_wind (gf_sql_connection_t *sql_conn, + gfdb_db_record->file_name, 1, + _gf_false); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, + "Failed updating link flags in wind"); + goto out; + } +@@ -972,8 +1001,8 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn, + + gfid_str = gf_strdup (uuid_utoa(gfdb_db_record->gfid)); + if (!gfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating gfid string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating gfid string failed."); + goto out; + } + +@@ -986,8 +1015,9 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn, + + pargfid_str = gf_strdup(uuid_utoa(gfdb_db_record->pargfid)); + if (!pargfid_str) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Creating pargfid_str string failed."); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Creating pargfid_str " ++ "string failed."); + goto out; + } + +@@ -1004,7 +1034,8 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn, + _gf_true, + isreadfop (gfdb_db_record->gfdb_fop_type)); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, + "Failed update wind time in DB"); + goto out; + } +@@ -1015,8 +1046,8 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn, + ret = gf_sql_delete_link(sql_conn, gfid_str, pargfid_str, + gfdb_db_record->file_name); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed deleting link"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_DELETE_FAILED, "Failed deleting link"); + goto out; + } + +@@ -1027,14 +1058,15 @@ gf_sql_delete_unwind (gf_sql_connection_t *sql_conn, + _gf_false, + isreadfop(gfdb_db_record->gfdb_fop_type)); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed update unwind time in DB"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_UPDATE_FAILED, "Failed update " ++ "unwind time in DB"); + goto out; + } + } + } else { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Invalid unlink option"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_UPLINK, "Invalid unlink option"); + goto out; + } + ret = 0; +@@ -1066,8 +1098,9 @@ gf_sql_query_function (sqlite3_stmt *prep_stmt, + + gfdb_query_record = gfdb_query_record_init (); + if (!gfdb_query_record) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed to create gfdb_query_record"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_CREATE_FAILED, "Failed to create " ++ "gfdb_query_record"); + goto out; + } + +@@ -1083,14 +1116,16 @@ gf_sql_query_function (sqlite3_stmt *prep_stmt, + text_column = (char *)sqlite3_column_text + (prep_stmt, 0); + if (!text_column) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed retriving GF_ID"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_GET_ID_FAILED, "Failed " ++ "retriving GF_ID"); + goto out; + } + ret = gf_uuid_parse (text_column, gfdb_query_record->gfid); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed parsing GF_ID"); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_PARSE_FAILED, "Failed parsing " ++ "GF_ID"); + goto out; + } + +@@ -1108,7 +1143,8 @@ gf_sql_query_function (sqlite3_stmt *prep_stmt, + ret = query_callback (gfdb_query_record, + _query_cbk_args); + if (ret) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_QUERY_CALL_BACK_FAILED, + "Query Call back failed!"); + goto out; + } +@@ -1118,9 +1154,9 @@ gf_sql_query_function (sqlite3_stmt *prep_stmt, + } + + if (ret != SQLITE_DONE) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, +- "Failed retriving records from db : %s", +- sqlite3_errmsg (db_conn)); ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, ++ LG_MSG_GET_RECORD_FAILED, "Failed retriving records " ++ "from db : %s", sqlite3_errmsg (db_conn)); + ret = -1; + goto out; + } +@@ -1150,7 +1186,7 @@ gf_sql_clear_counters (gf_sql_connection_t *sql_conn) + ret = sqlite3_exec (sql_conn->sqlite3_db_conn, query_str, NULL, NULL, + &sql_strerror); + if (ret != SQLITE_OK) { +- gf_log (GFDB_STR_SQLITE3, GF_LOG_ERROR, ++ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, + "Failed executing: %s : %s", + query_str, sql_strerror); + sqlite3_free (sql_strerror); +-- +1.7.1 + diff --git a/SOURCES/0152-changetimerecorder-Porting-to-new-logging-framework.patch b/SOURCES/0152-changetimerecorder-Porting-to-new-logging-framework.patch new file mode 100644 index 0000000..2ed0415 --- /dev/null +++ b/SOURCES/0152-changetimerecorder-Porting-to-new-logging-framework.patch @@ -0,0 +1,1481 @@ +From 3abdb22c4d9b3ba8738bfb565fb02b5d38b222b4 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Wed, 27 May 2015 15:20:59 +0530 +Subject: [PATCH 152/190] changetimerecorder : Porting to new logging framework + +Change-Id: I66e7ccc5e62482c3ecf0aab302568e6c9ecdc05d +BUG: 1231797 +Signed-off-by: Mohamed Ashiq Liyazudeen +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/51210 +Reviewed-by: Dan Lambright +Tested-by: Dan Lambright +--- + libglusterfs/src/Makefile.am | 2 +- + libglusterfs/src/ctr-messages.h | 501 ++++++++++++++++++++ + libglusterfs/src/glfs-message-id.h | 3 + + .../changetimerecorder/src/changetimerecorder.c | 213 +++++---- + .../features/changetimerecorder/src/ctr-helper.c | 32 +- + .../features/changetimerecorder/src/ctr-helper.h | 40 +- + .../changetimerecorder/src/ctr-xlator-ctx.c | 38 +- + 7 files changed, 703 insertions(+), 126 deletions(-) + create mode 100644 libglusterfs/src/ctr-messages.h + +diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am +index ed441d0..3862328 100644 +--- a/libglusterfs/src/Makefile.am ++++ b/libglusterfs/src/Makefile.am +@@ -44,7 +44,7 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec. + run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \ + gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \ + template-component-messages.h strfd.h syncop-utils.h parse-utils.h \ +- libglusterfs-messages.h \ ++ libglusterfs-messages.h ctr-messages.h \ + $(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h \ + $(CONTRIBDIR)/libexecinfo/execinfo_compat.h \ + unittest/unittest.h quota-common-utils.h rot-buffs.h \ +diff --git a/libglusterfs/src/ctr-messages.h b/libglusterfs/src/ctr-messages.h +new file mode 100644 +index 0000000..27de07a +--- /dev/null ++++ b/libglusterfs/src/ctr-messages.h +@@ -0,0 +1,501 @@ ++/* ++ Copyright (c) 2013 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++ */ ++ ++#ifndef _component_MESSAGES_H_ ++#define _component_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_COMP_BASE GLFS_MSGID_COMP_CTR ++#define GLFS_NUM_MESSAGES 56 ++#define GLFS_MSGID_END (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++#define CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND (GLFS_COMP_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND (GLFS_COMP_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND (GLFS_COMP_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_LINK_WIND_FAILED (GLFS_COMP_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_WRITEV_WIND_FAILED (GLFS_COMP_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_WRITEV_UNWIND_FAILED (GLFS_COMP_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_SETATTR_WIND_FAILED (GLFS_COMP_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_SETATTR_UNWIND_FAILED (GLFS_COMP_BASE + 8) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED (GLFS_COMP_BASE + 9) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED (GLFS_COMP_BASE + 10) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED (GLFS_COMP_BASE + 11) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED (GLFS_COMP_BASE + 12) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_TRUNCATE_WIND_FAILED (GLFS_COMP_BASE + 13) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED (GLFS_COMP_BASE + 14) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED (GLFS_COMP_BASE + 15) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED (GLFS_COMP_BASE + 16) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_RENAME_WIND_FAILED (GLFS_COMP_BASE + 17) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_RENAME_UNWIND_FAILED (GLFS_COMP_BASE + 18) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED (GLFS_COMP_BASE + 19) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_ADD_HARDLINK_FAILED (GLFS_COMP_BASE + 20) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_DELETE_HARDLINK_FAILED (GLFS_COMP_BASE + 21) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_UPDATE_HARDLINK_FAILED (GLFS_COMP_BASE + 22) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED (GLFS_COMP_BASE + 23) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED (GLFS_COMP_BASE + 24) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_UNLINK_UNWIND_FAILED (GLFS_COMP_BASE + 25) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_UNLINK_WIND_FAILED (GLFS_COMP_BASE + 26) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_XDATA_NULL (GLFS_COMP_BASE + 27) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FSYNC_WIND_FAILED (GLFS_COMP_BASE + 28) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_FSYNC_UNWIND_FAILED (GLFS_COMP_BASE + 29) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_MKNOD_UNWIND_FAILED (GLFS_COMP_BASE + 30) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_MKNOD_WIND_FAILED (GLFS_COMP_BASE + 31) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_CREATE_WIND_FAILED (GLFS_COMP_BASE + 32) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_CREATE_UNWIND_FAILED (GLFS_COMP_BASE + 33) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_RECORD_WIND_FAILED (GLFS_COMP_BASE + 34) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INSERT_READV_WIND_FAILED (GLFS_COMP_BASE + 35) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_GET_GFID_FROM_DICT_FAILED (GLFS_COMP_BASE + 36) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_SET (GLFS_COMP_BASE + 37) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_FATAL_ERROR (GLFS_COMP_BASE + 38) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_DANGLING_VOLUME (GLFS_COMP_BASE + 39) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_CALLOC_FAILED (GLFS_COMP_BASE + 40) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED (GLFS_COMP_BASE + 41) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INIT_DB_PARAMS_FAILED (GLFS_COMP_BASE + 42) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED (GLFS_COMP_BASE + 43) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_MEM_ACC_INIT_FAILED (GLFS_COMP_BASE + 44) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_CLOSE_DB_CONN_FAILED (GLFS_COMP_BASE + 45) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_FILL_UNWIND_TIME_REC_ERROR (GLFS_COMP_BASE + 46) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_WRONG_FOP_PATH (GLFS_COMP_BASE + 47) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_CONSTRUCT_DB_PATH_FAILED (GLFS_COMP_BASE + 48) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED (GLFS_COMP_BASE + 49) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_XLATOR_DISABLED (GLFS_COMP_BASE + 50) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_HARDLINK_MISSING_IN_LIST (GLFS_COMP_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED (GLFS_COMP_BASE + 52) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_INIT_LOCK_FAILED (GLFS_COMP_BASE + 53) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_COPY_FAILED (GLFS_COMP_BASE + 54) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED (GLFS_COMP_BASE + 55) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED (GLFS_COMP_BASE + 56) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_component_MESSAGES_H_ */ +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 69ed188..242e487 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -113,6 +113,9 @@ + #define GLFS_MSGID_COMP_QUOTA_END (GLFS_MSGID_COMP_QUOTA +\ + GLFS_MSGID_SEGMENT) + ++#define GLFS_MSGID_COMP_CTR GLFS_MSGID_COMP_QUOTA_END ++#define GLFS_MSGID_COMP_CTR_END (GLFS_MSGID_COMP_CTR+\ ++ GLFS_MSGID_SEGMENT) + + /* --- new segments for messages goes above this line --- */ + +diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c +index dc23132..1fdeb7c 100644 +--- a/xlators/features/changetimerecorder/src/changetimerecorder.c ++++ b/xlators/features/changetimerecorder/src/changetimerecorder.c +@@ -12,6 +12,7 @@ + + #include "gfdb_sqlite3.h" + #include "ctr-helper.h" ++#include "ctr-messages.h" + + /*******************************inode forget***********************************/ + +@@ -99,7 +100,8 @@ ctr_lookup_wind(call_frame_t *frame, + + frame->local = init_ctr_local_t (this); + if (!frame->local) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + "WIND: Error while creating ctr local"); + goto out; + }; +@@ -169,8 +171,9 @@ ctr_lookup_unwind (call_frame_t *frame, + ret = insert_record(_priv->_db_conn, + &ctr_local->gfdb_db_record); + if (ret == -1) { +- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error" +- "filling ctr local"); ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, ++ "UNWIND: Error filling ctr local"); + goto out; + } + } +@@ -204,8 +207,8 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + /* if the lookup failed lookup dont do anything*/ + if (op_ret == -1) { +- gf_log (this->name, GF_LOG_TRACE, "lookup failed with %s", +- strerror (op_errno)); ++ gf_msg_trace (this->name, 0, "lookup failed with %s", ++ strerror (op_errno)); + goto out; + } + +@@ -238,7 +241,7 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Add hard link to the list */ + ret = add_hard_link_ctx (frame, this, inode); + if (ret < 0) { +- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link"); ++ gf_msg_trace (this->name, 0, "Failed adding hard link"); + goto out; + } + +@@ -247,8 +250,7 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + * created by ctr_lookup_wind */ + ret = ctr_lookup_unwind(frame, this); + if (ret) { +- gf_log (this->name, GF_LOG_TRACE, +- "Failed inserting link wind"); ++ gf_msg_trace (this->name, 0, "Failed inserting link wind"); + } + + +@@ -302,8 +304,9 @@ ctr_lookup (call_frame_t *frame, xlator_t *this, + * No writing to the db yet */ + ret = ctr_lookup_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting link wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_LINK_WIND_FAILED, ++ "Failed inserting link wind"); + } + + out: +@@ -329,7 +332,8 @@ ctr_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_WRITEV_UNWIND_FAILED, + "Failed inserting writev unwind"); + } + +@@ -362,8 +366,9 @@ ctr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting writev wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_WRITEV_WIND_FAILED, ++ "Failed inserting writev wind"); + } + + out: +@@ -390,7 +395,8 @@ ctr_setattr_cbk (call_frame_t *frame, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, + "Failed inserting setattr unwind"); + } + +@@ -422,8 +428,9 @@ ctr_setattr (call_frame_t *frame, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting setattr wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_SETATTR_WIND_FAILED, ++ "Failed inserting setattr wind"); + } + out: + +@@ -448,7 +455,8 @@ ctr_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED, + "Failed inserting fremovexattr unwind"); + } + +@@ -478,8 +486,9 @@ ctr_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting fremovexattr wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED, ++ "Failed inserting fremovexattr wind"); + } + + out: +@@ -504,7 +513,8 @@ ctr_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED, + "Failed inserting removexattr unwind"); + } + +@@ -534,8 +544,9 @@ ctr_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting removexattr wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED, ++ "Failed inserting removexattr wind"); + } + + out: +@@ -560,7 +571,8 @@ ctr_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED, + "Failed inserting truncate unwind"); + } + +@@ -591,8 +603,9 @@ ctr_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting truncate wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_TRUNCATE_WIND_FAILED, ++ "Failed inserting truncate wind"); + } + out: + STACK_WIND (frame, ctr_truncate_cbk, FIRST_CHILD (this), +@@ -615,7 +628,8 @@ ctr_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED, + "Failed inserting ftruncate unwind"); + } + +@@ -645,8 +659,9 @@ ctr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting ftruncate wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED, ++ "Failed inserting ftruncate wind"); + } + + out: +@@ -672,7 +687,8 @@ ctr_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, + GFDB_FOP_DENTRY_WRITE, GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_RENAME_UNWIND_FAILED, + "Failed inserting rename unwind"); + } + +@@ -715,16 +731,17 @@ ctr_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting rename wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_RENAME_WIND_FAILED, ++ "Failed inserting rename wind"); + } else { + /* We are doing updation of hard link in inode context in wind + * As we dont get the "inode" in the call back for rename */ + ret = update_hard_link_ctx (frame, this, oldloc->inode); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed updating hard link in" +- "ctr inode context"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_UPDATE_HARDLINK_FAILED, "Failed " ++ "updating hard link in ctr inode context"); + } + } + +@@ -757,7 +774,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = dict_get_uint32 (xdata , CTR_RESPONSE_LINK_COUNT_XDATA, + &remaining_links); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, + "Failed to getting CTR_RESPONSE_LINK_COUNT_XDATA"); + remaining_links = -1; + } +@@ -768,7 +786,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, + GFDB_FOP_UNDEL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, + "Failed inserting unlink unwind"); + } + } +@@ -777,7 +796,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, + GFDB_FOP_UNDEL_ALL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, + "Failed inserting unlink unwind"); + } + } +@@ -818,16 +838,17 @@ ctr_unlink (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting unlink wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, ++ "Failed inserting unlink wind"); + } else { + /* We are doing delete of hard link in inode context in wind + * As we dont get the "inode" in the call back for rename */ + ret = delete_hard_link_ctx (frame, this, loc->inode); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed deleting hard link from ctr " +- "inode context"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_DELETE_HARDLINK_FAILED, "Failed " ++ "deleting hard link from ctr inode context"); + } + } + +@@ -843,17 +864,17 @@ ctr_unlink (call_frame_t *frame, xlator_t *this, + is_xdata_created = (xdata) ? _gf_true : _gf_false; + } + if (!xdata) { +- gf_log (this->name, GF_LOG_ERROR, +- "xdata is NULL :" +- "Cannot send CTR_REQUEST_LINK_COUNT_XDATA" +- "to posix"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_XDATA_NULL, "xdata is NULL :Cannot send " ++ "CTR_REQUEST_LINK_COUNT_XDATA to posix"); + goto out; + } + + ret = dict_set_int32 (xdata, CTR_REQUEST_LINK_COUNT_XDATA, 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed setting CTR_REQUEST_LINK_COUNT_XDATA"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, ++ "Failed setting CTR_REQUEST_LINK_COUNT_XDATA"); + if (is_xdata_created) { + dict_unref (xdata); + } +@@ -884,7 +905,8 @@ ctr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, + "Failed inserting fsync unwind"); + } + +@@ -914,8 +936,9 @@ ctr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting fsync wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FSYNC_WIND_FAILED, ++ "Failed inserting fsync wind"); + } + + out: +@@ -938,7 +961,8 @@ ctr_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, + "Failed inserting fsync unwind"); + } + +@@ -968,8 +992,9 @@ ctr_setxattr (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting setxattr wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_SETATTR_WIND_FAILED, ++ "Failed inserting setxattr wind"); + } + + out: +@@ -995,13 +1020,14 @@ ctr_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Add hard link to the list */ + ret = add_hard_link_ctx (frame, this, inode); + if (ret) { +- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link"); ++ gf_msg_trace (this->name, 0, "Failed adding hard link"); + } + + ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_MKNOD_UNWIND_FAILED, + "Failed inserting mknod unwind"); + } + +@@ -1034,8 +1060,7 @@ ctr_mknod (call_frame_t *frame, xlator_t *this, + /*get gfid from xdata dict*/ + ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to get gfid from dict"); ++ gf_msg_debug (this->name, 0, "failed to get gfid from dict"); + goto out; + } + gf_uuid_copy (gfid, uuid_req); +@@ -1054,8 +1079,9 @@ ctr_mknod (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting mknod wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_MKNOD_WIND_FAILED, ++ "Failed inserting mknod wind"); + } + + out: +@@ -1080,13 +1106,16 @@ ctr_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = add_hard_link_ctx (frame, this, inode); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed adding hard link"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_ADD_HARDLINK_FAILED, ++ "Failed adding hard link"); + } + + ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_CREATE_UNWIND_FAILED, + "Failed inserting create unwind"); + } + +@@ -1120,7 +1149,8 @@ ctr_create (call_frame_t *frame, xlator_t *this, + /*Get GFID from Xdata dict*/ + ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_GET_GFID_FROM_DICT_FAILED, + "failed to get gfid from dict"); + goto out; + } +@@ -1140,8 +1170,9 @@ ctr_create (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, &ctr_inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting create wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_CREATE_WIND_FAILED, ++ "Failed inserting create wind"); + } + out: + STACK_WIND (frame, ctr_create_cbk, FIRST_CHILD (this), +@@ -1165,13 +1196,14 @@ ctr_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Add hard link to the list */ + ret = add_hard_link_ctx (frame, this, inode); + if (ret) { +- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link"); ++ gf_msg_trace (this->name, 0, "Failed adding hard link"); + } + + ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_CREATE_UNWIND_FAILED, + "Failed inserting create unwind"); + } + +@@ -1211,8 +1243,9 @@ ctr_link (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting link wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_LINK_WIND_FAILED, ++ "Failed inserting link wind"); + } + + out: +@@ -1235,7 +1268,8 @@ int ctr_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_READ, + GFDB_FOP_UNWIND); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_CREATE_UNWIND_FAILED, + "Failed inserting create unwind"); + } + +@@ -1265,8 +1299,9 @@ ctr_readv (call_frame_t *frame, xlator_t *this, + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed inserting readv wind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_READV_WIND_FAILED, ++ "Failed inserting readv wind"); + } + + out: +@@ -1287,7 +1322,7 @@ reconfigure (xlator_t *this, dict_t *options) + _priv = this->private; + if (dict_get_str(options, "changetimerecorder.frequency", + &temp_str)) { +- gf_log(this->name, GF_LOG_INFO, "set!"); ++ gf_msg(this->name, GF_LOG_INFO, 0, CTR_MSG_SET, "set!"); + } + + GF_OPTION_RECONF ("ctr-enabled", _priv->enabled, options, +@@ -1322,19 +1357,22 @@ init (xlator_t *this) + GF_VALIDATE_OR_GOTO ("ctr", this, error); + + if (!this->children || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FATAL_ERROR, + "FATAL: ctr should have exactly one child"); + goto error; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ CTR_MSG_DANGLING_VOLUME, + "dangling volume. check volfile "); + } + + _priv = GF_CALLOC (1, sizeof (*_priv), gf_ctr_mt_private_t); + if (!_priv) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ CTR_MSG_CALLOC_FAILED, + "Calloc didnt work!!!"); + goto error; + } +@@ -1351,14 +1389,16 @@ init (xlator_t *this) + /*Extract ctr xlator options*/ + ret_db = extract_ctr_options (this, _priv); + if (ret_db) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED, + "Failed extracting ctr xlator options"); + goto error; + } + + params_dict = dict_new (); + if (!params_dict) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INIT_DB_PARAMS_FAILED, + "DB Params cannot initialized!"); + goto error; + } +@@ -1366,7 +1406,8 @@ init (xlator_t *this) + /*Extract db params options*/ + ret_db = extract_db_params(this, params_dict, _priv->gfdb_db_type); + if (ret_db) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED, + "Failed extracting db params options"); + goto error; + } +@@ -1374,7 +1415,8 @@ init (xlator_t *this) + /*Create a memory pool for ctr xlator*/ + this->local_pool = mem_pool_new (gf_ctr_local_t, 64); + if (!this->local_pool) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED, + "failed to create local memory pool"); + goto error; + } +@@ -1382,7 +1424,8 @@ init (xlator_t *this) + /*Initialize Database Connection*/ + _priv->_db_conn = init_db(params_dict, _priv->gfdb_db_type); + if (!_priv->_db_conn) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FATAL_ERROR, + "FATAL: Failed initializing data base"); + goto error; + } +@@ -1425,7 +1468,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_ctr_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_MEM_ACC_INIT_FAILED, "Memory accounting init" + "failed"); + return ret; + } +@@ -1443,8 +1487,9 @@ fini (xlator_t *this) + + if (priv) { + if (fini_db (priv->_db_conn)) { +- gf_log (this->name, GF_LOG_WARNING, "Failed closing " +- "db connection"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ CTR_MSG_CLOSE_DB_CONN_FAILED, "Failed closing " ++ "db connection"); + } + GF_FREE (priv->ctr_db_path); + } +diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c +index 005f909..c4d9769 100644 +--- a/xlators/features/changetimerecorder/src/ctr-helper.c ++++ b/xlators/features/changetimerecorder/src/ctr-helper.c +@@ -10,7 +10,7 @@ + + #include "gfdb_sqlite3.h" + #include "ctr-helper.h" +- ++#include "ctr-messages.h" + + /******************************************************************************* + * +@@ -35,8 +35,8 @@ fill_db_record_for_unwind(xlator_t *this, + + /*If not unwind path error*/ + if (!isunwindpath(fop_path)) { +- gf_log (this->name, GF_LOG_ERROR, "Wrong fop_path." +- "Should be unwind"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, CTR_MSG_WRONG_FOP_PATH, ++ "Wrong fop_path. Should be unwind"); + goto out; + } + +@@ -46,8 +46,9 @@ fill_db_record_for_unwind(xlator_t *this, + + ret = gettimeofday (ctr_uwtime, NULL); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "Error filling unwind time record %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, "Error " ++ "filling unwind time record %s", + strerror(errno)); + goto out; + } +@@ -89,7 +90,8 @@ fill_db_record_for_wind (xlator_t *this, + + /*if not wind path error!*/ + if (!iswindpath(ctr_inode_cx->fop_path)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_WRONG_FOP_PATH, + "Wrong fop_path. Should be wind"); + goto out; + } +@@ -101,7 +103,8 @@ fill_db_record_for_wind (xlator_t *this, + + ret = gettimeofday (ctr_wtime, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, + "Error filling wind time record %s", + strerror(errno)); + goto out; +@@ -182,8 +185,9 @@ extract_sql_params(xlator_t *this, dict_t *params_dict) + /*Construct full path of the db*/ + ret = gf_asprintf(&db_full_path, "%s/%s", db_path, db_name); + if (ret < 0) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Construction of full db path failed!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ CTR_MSG_CONSTRUCT_DB_PATH_FAILED, ++ "Construction of full db path failed!"); + goto out; + } + +@@ -194,8 +198,9 @@ extract_sql_params(xlator_t *this, dict_t *params_dict) + /*Extact rest of the sql params*/ + ret = gfdb_set_sql_params(this->name, this->options, params_dict); + if (ret) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "Failed setting values to sql param dict!"); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, ++ "Failed setting values to sql param dict!"); + } + + ret = 0; +@@ -246,8 +251,9 @@ int extract_ctr_options (xlator_t *this, gf_ctr_private_t *_priv) { + _priv->enabled = _gf_false; + GF_OPTION_INIT ("ctr-enabled", _priv->enabled, bool, out); + if (!_priv->enabled) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, +- "CTR Xlator is disabled."); ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ CTR_MSG_XLATOR_DISABLED, ++ "CTR Xlator is disabled."); + ret = 0; + goto out; + } +diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h +index 87b80e6..a3df971 100644 +--- a/xlators/features/changetimerecorder/src/ctr-helper.h ++++ b/xlators/features/changetimerecorder/src/ctr-helper.h +@@ -29,6 +29,7 @@ + + #include "gfdb_data_store.h" + #include "ctr-xlator-ctx.h" ++#include "ctr-messages.h" + + /*CTR Xlator Private structure*/ + typedef struct gf_ctr_private { +@@ -103,7 +104,8 @@ init_ctr_local_t (xlator_t *this) { + + ctr_local = mem_get0 (this->local_pool); + if (!ctr_local) { +- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR, ++ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, ++ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + "Error while creating ctr local"); + goto out; + } +@@ -346,7 +348,8 @@ ctr_insert_wind (call_frame_t *frame, + if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) { + frame->local = init_ctr_local_t (this); + if (!frame->local) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + "WIND: Error while creating ctr local"); + goto out; + }; +@@ -378,7 +381,8 @@ ctr_insert_wind (call_frame_t *frame, + /*Fill the db record for insertion*/ + ret = fill_db_record_for_wind (this, ctr_local, ctr_inode_cx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, + "WIND: Error filling ctr local"); + goto out; + } +@@ -387,7 +391,8 @@ ctr_insert_wind (call_frame_t *frame, + ret = insert_record (_priv->_db_conn, + &ctr_local->gfdb_db_record); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_INSERT_RECORD_WIND_FAILED, + "WIND: Inserting of record failed!"); + goto out; + } +@@ -443,16 +448,18 @@ ctr_insert_unwind (call_frame_t *frame, + ret = fill_db_record_for_unwind(this, ctr_local, fop_type, + fop_path); + if (ret == -1) { +- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error" +- "filling ctr local"); ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, ++ "UNWIND: Error filling ctr local"); + goto out; + } + + ret = insert_record(_priv->_db_conn, + &ctr_local->gfdb_db_record); + if (ret == -1) { +- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error" +- "filling ctr local"); ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, ++ "UNWIND: Error filling ctr local"); + goto out; + } + } +@@ -486,7 +493,8 @@ add_hard_link_ctx (call_frame_t *frame, + + ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode); + if (!ctr_xlator_ctx) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, + "Failed accessing ctr inode context"); + goto out; + } +@@ -510,7 +518,8 @@ add_hard_link_ctx (call_frame_t *frame, + CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, + "Failed to add hardlink to the ctr inode context"); + goto unlock; + } +@@ -551,7 +560,9 @@ delete_hard_link_ctx (call_frame_t *frame, + CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to delete hard link"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_DELETE_HARDLINK_FAILED, ++ "Failed to delete hard link"); + goto out; + } + +@@ -581,7 +592,8 @@ update_hard_link_ctx (call_frame_t *frame, + + ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode); + if (!ctr_xlator_ctx) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, + "Failed accessing ctr inode context"); + goto out; + } +@@ -592,7 +604,9 @@ update_hard_link_ctx (call_frame_t *frame, + CTR_DB_REC(ctr_local).old_pargfid, + CTR_DB_REC(ctr_local).old_file_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to delete hard link"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_DELETE_HARDLINK_FAILED, ++ "Failed to delete hard link"); + goto out; + } + +diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c +index 927c854..a91a2bb 100644 +--- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c ++++ b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c +@@ -9,6 +9,7 @@ + */ + + #include "ctr-xlator-ctx.h" ++#include "ctr-messages.h" + + #define IS_THE_ONLY_HARDLINK(ctr_hard_link)\ + (ctr_hard_link->list.next == ctr_hard_link->list.prev) +@@ -79,8 +80,9 @@ ctr_add_hard_link (xlator_t *this, + ctr_hard_link = GF_CALLOC (1, sizeof (*ctr_hard_link), + gf_ctr_mt_hard_link_t); + if (!ctr_hard_link) { +- gf_log (this->name, GF_LOG_ERROR, "Failed allocating " +- "ctr_hard_link"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ CTR_MSG_CALLOC_FAILED, "Failed allocating " ++ "ctr_hard_link"); + goto out; + } + +@@ -90,8 +92,9 @@ ctr_add_hard_link (xlator_t *this, + gf_uuid_copy (ctr_hard_link->pgfid, pgfid); + ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed copying basename" +- "to ctr_hard_link"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_COPY_FAILED, "Failed copying basename" ++ "to ctr_hard_link"); + goto error; + } + +@@ -139,8 +142,9 @@ ctr_delete_hard_link (xlator_t *this, + ctr_hard_link = ctr_search_hard_link_ctx (this, ctr_xlator_ctx, + pgfid, base_name); + if (!ctr_hard_link) { +- gf_log (this->name, GF_LOG_ERROR, "Hard link doesnt exist" +- " in the list"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_HARDLINK_MISSING_IN_LIST, ++ "Hard link doesnt exist in the list"); + goto out; + } + +@@ -178,15 +182,16 @@ ctr_update_hard_link (xlator_t *this, + ctr_hard_link = ctr_search_hard_link_ctx (this, ctr_xlator_ctx, + old_pgfid, old_base_name); + if (!ctr_hard_link) { +- gf_log (this->name, GF_LOG_TRACE, "Hard link doesnt exist" +- " in the list"); ++ gf_msg_trace (this->name, 0, "Hard link doesnt exist" ++ " in the list"); + /* Since the hard link is not present in the list + * we add it to the list */ + ret = ctr_add_hard_link (this, ctr_xlator_ctx, + pgfid, base_name); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed adding" +- "hard link to the list"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED, ++ "Failed adding hard link to the list"); + goto out; + } + ret = 0; +@@ -198,7 +203,8 @@ ctr_update_hard_link (xlator_t *this, + GF_FREE (&ctr_hard_link->base_name); + ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed copying basename" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ CTR_MSG_COPY_FAILED, "Failed copying basename" + "to ctr_hard_link"); + /* delete the corrupted entry */ + __delete_hard_link_from_list (&ctr_hard_link); +@@ -296,8 +302,9 @@ init_ctr_xlator_ctx (xlator_t *this, + + ret = LOCK_INIT (&ctr_xlator_ctx->lock); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed init lock %s", strerror(ret)); ++ gf_msg (this->name, GF_LOG_ERROR, ret, ++ CTR_MSG_INIT_LOCK_FAILED, ++ "Failed init lock %s", strerror(ret)); + goto out; + } + _addr = (uint64_t) ctr_xlator_ctx; +@@ -342,8 +349,9 @@ fini_ctr_xlator_ctx (xlator_t *this, + + ret = ctr_delete_all_hard_link (this, ctr_xlator_ctx); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING , "Failed deleting all hard" +- " links from inode context"); ++ gf_msg (this->name, GF_LOG_WARNING , 0, ++ CTR_MSG_DELETE_HARDLINK_FAILED, "Failed deleting all " ++ "hard links from inode context"); + } + + LOCK_DESTROY (&ctr_xlator_ctx->lock); +-- +1.7.1 + diff --git a/SOURCES/0153-features-bitrot-log-scrub-frequency-throttle-values.patch b/SOURCES/0153-features-bitrot-log-scrub-frequency-throttle-values.patch new file mode 100644 index 0000000..7890cce --- /dev/null +++ b/SOURCES/0153-features-bitrot-log-scrub-frequency-throttle-values.patch @@ -0,0 +1,66 @@ +From 8ffb04d40cd838f0a498a4f0c1451a64fc64f65d Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Thu, 11 Jun 2015 20:19:39 +0530 +Subject: [PATCH 153/190] features/bitrot: log scrub frequency & throttle values + + Backport of http://review.gluster.org/11190 + +Change-Id: I56d5236c37a413046b5766320184047a908f2c8d +BUG: 1225747 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51698 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 28 +++++++++++++++++++++ + 1 files changed, 28 insertions(+), 0 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index 26ad97a..2da4530 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -1141,6 +1141,32 @@ br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, dict_t *options) + return -1; + } + ++static void br_scrubber_log_option (xlator_t *this, ++ br_private_t *priv, gf_boolean_t scrubstall) ++{ ++ struct br_scrubber *fsscrub = &priv->fsscrub; ++ char *scrub_throttle_str[] = { ++ [BR_SCRUB_THROTTLE_LAZY] = "lazy", ++ [BR_SCRUB_THROTTLE_NORMAL] = "normal", ++ [BR_SCRUB_THROTTLE_AGGRESSIVE] = "aggressive", ++ }; ++ ++ char *scrub_freq_str[] = { ++ [BR_FSSCRUB_FREQ_HOURLY] = "hourly", ++ [BR_FSSCRUB_FREQ_DAILY] = "daily", ++ [BR_FSSCRUB_FREQ_WEEKLY] = "weekly", ++ [BR_FSSCRUB_FREQ_BIWEEKLY] = "biweekly", ++ [BR_FSSCRUB_FREQ_MONTHLY] = "monthly (30 days)", ++ }; ++ ++ if (scrubstall) ++ return; /* logged as pause */ ++ ++ gf_log (this->name, GF_LOG_INFO, "SCRUB TUNABLES:: [Frequency: %s, " ++ "Throttle: %s]", scrub_freq_str[fsscrub->frequency], ++ scrub_throttle_str[fsscrub->throttle]); ++} ++ + int32_t + br_scrubber_handle_options (xlator_t *this, br_private_t *priv, dict_t *options) + { +@@ -1159,6 +1185,8 @@ br_scrubber_handle_options (xlator_t *this, br_private_t *priv, dict_t *options) + if (ret) + goto error_return; + ++ br_scrubber_log_option (this, priv, scrubstall); ++ + return 0; + + error_return: +-- +1.7.1 + diff --git a/SOURCES/0154-tests-bitrot-Scrub-state-change-tests.patch b/SOURCES/0154-tests-bitrot-Scrub-state-change-tests.patch new file mode 100644 index 0000000..73331ed --- /dev/null +++ b/SOURCES/0154-tests-bitrot-Scrub-state-change-tests.patch @@ -0,0 +1,124 @@ +From e7c5666b7c8adf72a85a87b19f8aa4da602ae0dd Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Wed, 17 Jun 2015 22:59:17 +0530 +Subject: [PATCH 154/190] tests/bitrot: Scrub state change tests + +Change-Id: Ibb4b503e7d723c86ac381ad3747b1198334bd6ad +BUG: 1232309 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51699 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + tests/bitrot/br-state-check.t | 81 +++++++++++++++++++++++++++++++++++++++++ + tests/volume.rc | 4 +- + 2 files changed, 83 insertions(+), 2 deletions(-) + create mode 100644 tests/bitrot/br-state-check.t + +diff --git a/tests/bitrot/br-state-check.t b/tests/bitrot/br-state-check.t +new file mode 100644 +index 0000000..0390df5 +--- /dev/null ++++ b/tests/bitrot/br-state-check.t +@@ -0,0 +1,81 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../include.rc ++. $(dirname $0)/../volume.rc ++. $(dirname $0)/../nfs.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++ ++## Create a distribute volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 $H0:$B0/${V0}3; ++TEST $CLI volume start $V0; ++ ++## Enable bitrot on volume $V0 ++TEST $CLI volume bitrot $V0 enable ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_scrubd_count ++ ++## perform a series of scrub related state change tests. As of now, there' ++## no way to check if a given change has been correctly acknowledged by ++## the scrub process as there isn't an _interface_ to check scrub internal ++## state (yet). What's been verified here is scrub state machine execution ++## w.r.t. locking and faults. ++ ++## 0x0: verify scrub rescheduling ++TEST $CLI volume bitrot $V0 scrub-frequency monthly ++TEST $CLI volume bitrot $V0 scrub-frequency daily ++TEST $CLI volume bitrot $V0 scrub-frequency hourly ++ ++## 0x1: test reschedule after pause/resume ++TEST $CLI volume bitrot $V0 scrub pause ++TEST $CLI volume bitrot $V0 scrub-frequency daily ++TEST $CLI volume bitrot $V0 scrub resume ++ ++## 0x2: test reschedule w/ an offline brick ++TEST kill_brick $V0 $H0 $B0/${V0}1 ++ ++TEST $CLI volume bitrot $V0 scrub-frequency hourly ++TEST $CLI volume bitrot $V0 scrub-throttle aggressive ++ ++## 0x3: test pause/resume w/ an offline brick ++TEST $CLI volume bitrot $V0 scrub pause ++TEST $CLI volume bitrot $V0 scrub-frequency monthly ++TEST $CLI volume bitrot $V0 scrub resume ++ ++## 0x4: test "start" from a paused scrub state ++ ++TEST $CLI volume bitrot $V0 scrub pause ++TEST $CLI volume start $V0 force ++ ++## 0x4a: try pausing an already paused scrub ++TEST ! $CLI volume bitrot $V0 scrub pause ++ ++## 0x4b: perform configuration changes ++TEST $CLI volume bitrot $V0 scrub-frequency hourly ++TEST $CLI volume bitrot $V0 scrub-throttle lazy ++TEST $CLI volume bitrot $V0 scrub resume ++ ++## 0x5: test cleanup upon brick going offline ++TEST kill_brick $V0 $H0 $B0/${V0}1 ++TEST kill_brick $V0 $H0 $B0/${V0}2 ++TEST kill_brick $V0 $H0 $B0/${V0}3 ++ ++## 0x6: test cleanup upon brick going offline when srubber is paused ++## (initially paused and otherwise) ++ ++## 0x6a: initially paused case ++TEST $CLI volume bitrot $V0 scrub pause ++TEST $CLI volume start $V0 force ++TEST kill_brick $V0 $H0 $B0/${V0}3 ++TEST $CLI volume bitrot $V0 scrub resume ++ ++## 0x6b: paused _after_ execution ++TEST $CLI volume start $V0 force ++TEST $CLI volume bitrot $V0 scrub pause ++TEST kill_brick $V0 $H0 $B0/${V0}2 ++ ++cleanup; +diff --git a/tests/volume.rc b/tests/volume.rc +index 5a7d034..47ca722 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -536,10 +536,10 @@ fi + } + + function get_bitd_count { +- ps auxw | grep glusterfs | grep bitd.pid | grep -v grep | wc -l ++ ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | wc -l + } + + function get_scrubd_count { +- ps auxw | grep glusterfs | grep scrub.pid | grep -v grep | wc -l ++ ps auxww | grep glusterfs | grep scrub.pid | grep -v grep | wc -l + } + +-- +1.7.1 + diff --git a/SOURCES/0155-common-ha-fix-delete-node.patch b/SOURCES/0155-common-ha-fix-delete-node.patch new file mode 100644 index 0000000..02b76b7 --- /dev/null +++ b/SOURCES/0155-common-ha-fix-delete-node.patch @@ -0,0 +1,239 @@ +From 4bee60f04a395aae47856969526a8acac730b73b Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Fri, 26 Jun 2015 06:18:27 -0400 +Subject: [PATCH 155/190] common-ha: fix delete-node + +delete-node is a designed to be "disruptive" + +surgically delete a node from the config and stop nfs-ganesh on that +node. + +finish the implementation and fix a few minor issues + +backport +>> Change-Id: I964bb72a76ee635b5fc484ec5b541e69eeececcd +>> BUG: 1234474 +>> http://review.gluster.org/11353 +> Change-Id: Ic06952df8f42f80cfeb82d419757a8b99dff275a +> BUG: 1234584 +> http://review.gluster.org/11427 + +Change-Id: I1779d415a5b1797ac84975475ccf264b62e073e8 +BUG: 1224619 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/51681 +--- + extras/ganesha/scripts/ganesha-ha.sh | 101 +++++++++++++++++++--------------- + 1 files changed, 56 insertions(+), 45 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 3fa09bd..ccaa3d8 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -22,7 +22,7 @@ + + HA_NUM_SERVERS=0 + HA_SERVERS="" +-HA_CONFDIR="" ++HA_CONFDIR="/etc/ganesha" + HA_VOL_NAME="gluster_shared_storage" + HA_VOL_MNT="/var/run/gluster/shared_storage" + SERVICE_MAN="DISTRO_NOT_FOUND" +@@ -31,6 +31,7 @@ eval $(echo ${cfgline} | grep -F CONFFILE=) + GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + RHEL6_PCS_CNAME_OPTION="--name" ++SECRET_PEM="/var/lib/glusterd/nfs/secret.pem" + + usage() { + +@@ -69,10 +70,10 @@ manage_service () + if [ "$SERVICE_MAN" == "/usr/sbin/systemctl" ] + then + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha" ++${SECRET_PEM} root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha" + else + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}" ++${SECRET_PEM} root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}" + fi + } + +@@ -184,15 +185,12 @@ setup_copy_config() + local short_host=$(hostname -s) + local tganesha_conf=$(mktemp -u) + +- if [ -e /var/lib/glusterd/nfs/secret.pem ]; then ++ if [ -e ${SECRET_PEM} ]; then + while [[ ${1} ]]; do + current_host=`echo ${1} | cut -d "." -f 1` + if [ ${short_host} != ${current_host} ]; then +- cp ${HA_CONFDIR}/ganesha-ha.conf ${tganesha_conf} + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_conf}\ +- ${1}:${HA_CONFDIR}/ganesha-ha.conf +- rm -rf ${tganesha_conf} ++${SECRET_PEM} ${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/ + if [ $? -ne 0 ]; then + logger "warning: scp ganesha-ha.conf to ${1} failed" + fi +@@ -209,27 +207,24 @@ refresh_config () + local short_host=$(hostname -s) + local VOL=${1} + local HA_CONFDIR=${2} +- local tganesha_export=$(mktemp -u) + + removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\ + grep Export_Id | cut -d " " -f8` + +- if [ -e /var/lib/glusterd/nfs/secret.pem ]; then ++ if [ -e ${SECRET_PEM} ]; then + while [[ ${3} ]]; do + current_host=`echo ${3} | cut -d "." -f 1` + if [ ${short_host} != ${current_host} ]; then +- cp ${HA_CONFDIR}/exports/export.$VOL.conf ${tganesha_export} + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_export} \ +-${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf +- rm -rf ${tganesha_export} ++${SECRET_PEM} ${HA_CONFDIR}/exports/export.$VOL.conf \ ++${current_host}:${HA_CONFDIR}/exports/ + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --print-reply --system \ ++${SECRET_PEM} root@${current_host} "dbus-send --print-reply --system \ + --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ + org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id" + sleep 1 + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --system \ ++${SECRET_PEM} root@${current_host} "dbus-send --system \ + --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ + org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \ + string:\"EXPORT(Path=/$VOL)\"" +@@ -256,11 +251,23 @@ string:"EXPORT(Path=/$VOL)" + + copy_export_config () + { +- local new_node=${1} +- scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${GANESHA_CONF} ${new_node}:/etc/ganesha/ +- scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${new_node}:${HA_CONFDIR}/ ++ local new_node=${1} ++ local tganesha_conf=$(mktemp -u) ++ local tganesha_exports=$(mktemp -d) ++ ++ # avoid prompting for password, even with password-less scp ++ # scp $host1:$file $host2:$file prompts for the password ++ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++${SECRET_PEM} ${HA_VOL_SERVER}:${GANESHA_CONF} ${tganesha_conf} ++ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++${SECRET_PEM} ${tganesha_conf} ${new_node}:${GANESHA_CONF} ++ rm -f ${tganesha_conf} ++ ++ scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++${SECRET_PEM} ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${tganesha_exports} ++ scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ ++${SECRET_PEM} ${tganesha_exports} ${new_node}:${HA_CONFDIR}/ ++ rm -rf ${tganesha_exports} + } + + +@@ -706,7 +713,7 @@ deletenode_delete_resources() + # recompute their constraints + clear_resources ${cibfile} ${HA_SERVERS} + recreate_resources ${cibfile} ${ha_servers} +- HA_SERVERS="${ha_servers}" ++ HA_SERVERS=$(echo "${ha_servers}" | sed -e "s/ / /") + + create_virt_ip_constraints ${cibfile} ${HA_SERVERS} + +@@ -804,6 +811,7 @@ setup_state_volume() + } + + ++ + main() + { + +@@ -877,36 +885,36 @@ main() + node=${1}; shift + vip=${1}; shift + +- logger "adding ${node} with ${vip} to ${HA_NAME}" ++ logger "adding ${node} with ${vip} to ${HA_NAME}" + +- copy_export_config ${node} ${HA_CONFDIR} ++ copy_export_config ${node} ${HA_CONFDIR} + +- determine_service_manager ++ determine_service_manager + +- manage_service "start" ${node} ++ manage_service "start" ${node} + +- determine_servers "add" ++ determine_servers "add" + +- pcs cluster node add ${node} +- if [ $? -ne 0 ]; then ++ pcs cluster node add ${node} ++ if [ $? -ne 0 ]; then + logger "warning: pcs cluster node add ${node} failed" +- fi ++ fi + +- addnode_create_resources ${node} ${vip} +- #Subsequent add-node recreates resources for all the nodes +- #that already exist in the cluster. The nodes are picked up +- #from the entries in the ganesha-ha.conf file. Adding the +- #newly added node to the file so that the resources specfic +- #to this node is correctly recreated in the future. +- echo "VIP_$node=\"$vip\"" >> ${HA_CONFDIR}/ganesha-ha.conf ++ addnode_create_resources ${node} ${vip} ++ #Subsequent add-node recreates resources for all the nodes ++ #that already exist in the cluster. The nodes are picked up ++ #from the entries in the ganesha-ha.conf file. Adding the ++ #newly added node to the file so that the resources specfic ++ #to this node is correctly recreated in the future. ++ echo "VIP_$node=\"$vip\"" >> ${HA_CONFDIR}/ganesha-ha.conf + +- NEW_NODES="$HA_CLUSTER_NODES,$node" ++ NEW_NODES="$HA_CLUSTER_NODES,$node" + +- sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \ ++ sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \ + $HA_CONFDIR/ganesha-ha.conf +- HA_SERVERS="${HA_SERVERS} ${node}" ++ HA_SERVERS="${HA_SERVERS} ${node}" + +- setup_copy_config ${HA_SERVERS} ++ setup_copy_config ${HA_SERVERS} + ;; + + delete | --delete) +@@ -923,13 +931,16 @@ $HA_CONFDIR/ganesha-ha.conf + logger "warning: pcs cluster node remove ${node} failed" + fi + +- # TODO: delete node's directory in shared state ++ ha_servers=$(echo ${HA_SERVERS} | sed -e "s/ /,/") ++ sed -i "s/^HA_CLUSTER_NODES=.*$/HA_CLUSTER_NODES=\"${ha_servers// /,}\"/" ${HA_CONFDIR}/ganesha-ha.conf + +- determine_service_manager ++ setup_copy_config ${HA_SERVERS} + +- manage-service "stop" ++ rm -rf ${HA_VOL_MNT}/nfs-ganesha/{node} + +- cleanup_ganesha_config ${HA_CONFDIR} ++ determine_service_manager ++ ++ manage_service "stop" ${node} + ;; + + status | --status) +-- +1.7.1 + diff --git a/SOURCES/0156-features-bit-rot-check-for-both-inmemory-and-ondisk-.patch b/SOURCES/0156-features-bit-rot-check-for-both-inmemory-and-ondisk-.patch new file mode 100644 index 0000000..604a051 --- /dev/null +++ b/SOURCES/0156-features-bit-rot-check-for-both-inmemory-and-ondisk-.patch @@ -0,0 +1,312 @@ +From a3b9ad5909923b24bec518565d945003bfecee69 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Wed, 27 May 2015 17:00:36 +0530 +Subject: [PATCH 156/190] features/bit-rot: check for both inmemory and ondisk staleness. + +* Let bit-rot stub check both on disk ongoing version, signed version xattrs and + the in memory flags in the inode and then decide whether the inode is stale or + not. This information is used by one shot crawler in BitD to decide whether to + trigger the sign for the object or skip it. + + NOTE: The above check should be done only for BitD. For scrubber its still the + old way of comparing on disk ongoing version with signed version. + +* BitD's one shot crawler should not sign zero byte objects if they do not contain + signature. (Means the object was just created and nothing was written to it). + +Change-Id: I6941aefc2981bf79a6aeb476e660f79908e165a8 +BUG: 1232309 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/51738 +--- + xlators/features/bit-rot/src/bitd/bit-rot.c | 14 +- + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 143 ++++++++++++++++++++-- + 2 files changed, 138 insertions(+), 19 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index a4821ba..228cf34 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -858,7 +858,6 @@ br_check_object_need_sign (xlator_t *this, dict_t *xattr, br_child_t *child) + { + int32_t ret = -1; + gf_boolean_t need_sign = _gf_false; +- struct timeval tv = {0,}; + br_isignature_out_t *sign = NULL; + + GF_VALIDATE_OR_GOTO ("bit-rot", this, out); +@@ -873,11 +872,8 @@ br_check_object_need_sign (xlator_t *this, dict_t *xattr, br_child_t *child) + goto out; + } + +- tv.tv_sec = ntohl (sign->time[0]); +- tv.tv_usec = ntohl (sign->time[1]); +- + /* Object has been opened and hence dirty. Do not sign it */ +- if (sign->stale && !br_time_equal (child, &tv)) ++ if (sign->stale) + need_sign = _gf_true; + + out: +@@ -1007,7 +1003,11 @@ bitd_oneshot_crawl (xlator_t *subvol, + op_errno = -ret; + br_log_object (this, "getxattr", linked_inode->gfid, op_errno); + +- if (op_errno == ENODATA) ++ /** ++ * No need to sign the zero byte objects as the signing ++ * happens upon first modification of the object. ++ */ ++ if (op_errno == ENODATA && (iatt.ia_size != 0)) + need_signing = _gf_true; + if (op_errno == EINVAL) + gf_log (this->name, GF_LOG_WARNING, "Partial version " +@@ -1236,7 +1236,7 @@ br_brick_connect (xlator_t *this, br_child_t *child) + + memcpy (child->brick_path, stub->export, strlen (stub->export) + 1); + child->tv.tv_sec = ntohl (stub->timebuf[0]); +- child->tv.tv_usec = ntohl (stub->timebuf[0]); ++ child->tv.tv_usec = ntohl (stub->timebuf[1]); + + if (priv->iamscrubber) + ret = br_enact_scrubber (this, child); +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 4f0605d..d4aecdc 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -949,6 +949,79 @@ br_stub_listxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + } + ++/** ++ * ONE SHOT CRAWLER from BitD signs the objects that it encounters while ++ * crawling, if the object is identified as stale by the stub. Stub follows ++ * the below logic to mark an object as stale or not. ++ * If the ongoing version and the signed_version match, then the object is not ++ * stale. Just return. Otherwise if they does not match, then it means one ++ * of the below things. ++ * 1) If the inode does not need write back of the version and the sign state is ++ * is NORMAL, then some active i/o is going on the object. So skip it. ++ * A notification will be sent to trigger the sign once the release is ++ * received on the object. ++ * 2) If inode does not need writeback of the version and the sign state is ++ * either reopen wait or quick sign, then it means: ++ * A) BitD restarted and it is not sure whether the object it encountered ++ * while crawling is in its timer wheel or not. Since there is no way to ++ * scan the timer wheel as of now, ONE SHOT CRAWLER just goes ahead and ++ * signs the object. Since the inode does not need writeback, version will ++ * not be incremented and directly the object will be signed. ++ * 3) If the inode needs writeback, then it means the inode was forgotten after ++ * the versioning and it has to be signed now. ++ * ++ * This is the algorithm followed: ++ * if (ongoing_version == signed_version); then ++ * object_is_not_stale; ++ * return; ++ * else; then ++ * if (!inode_needs_writeback && inode_sign_state != NORMAL); then ++ * object_is_stale; ++ * if (inode_needs_writeback); then ++ * object_is_stale; ++ * ++ * For SCRUBBER, no need to check for the sign state and inode writeback. ++ * If the ondisk ongoingversion and the ondisk signed version does not match, ++ * then treat the object as stale. ++ */ ++char ++br_stub_is_object_stale (xlator_t *this, call_frame_t *frame, inode_t *inode, ++ br_version_t *obuf, br_signature_t *sbuf) ++{ ++ uint64_t ctx_addr = 0; ++ br_stub_inode_ctx_t *ctx = NULL; ++ int32_t ret = -1; ++ char stale = 0; ++ ++ if (obuf->ongoingversion == sbuf->signedversion) ++ goto out; ++ ++ if (frame->root->pid == GF_CLIENT_PID_SCRUB) { ++ stale = 1; ++ goto out; ++ } ++ ++ ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " ++ "context for %s", uuid_utoa (inode->gfid)); ++ goto out; ++ } ++ ++ ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; ++ ++ LOCK (&inode->lock); ++ { ++ if ((!__br_stub_is_inode_dirty (ctx) && ++ ctx->info_sign != BR_SIGN_NORMAL) || ++ __br_stub_is_inode_dirty (ctx)) ++ stale = 1; ++ } ++ UNLOCK (&inode->lock); ++ ++out: ++ return stale; ++} + + int + br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +@@ -961,12 +1034,18 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + br_signature_t *sbuf = NULL; + br_isignature_out_t *sign = NULL; + br_vxattr_status_t status; ++ br_stub_local_t *local = NULL; ++ inode_t *inode = NULL; + + if (op_ret < 0) + goto unwind; + if (cookie != (void *) BR_STUB_REQUEST_COOKIE) + goto unwind; + ++ local = frame->local; ++ frame->local = NULL; ++ inode = local->u.context.inode; ++ + op_ret = -1; + status = br_version_xattr_state (xattr, &obuf, &sbuf); + +@@ -1005,7 +1084,7 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + /* Object's dirty state & current signed version */ + sign->version = sbuf->signedversion; +- sign->stale = (obuf->ongoingversion != sbuf->signedversion) ? 1 : 0; ++ sign->stale = br_stub_is_object_stale (this, frame, inode, obuf, sbuf); + + /* Object's signature */ + sign->signaturelen = signaturelen; +@@ -1025,6 +1104,10 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + unwind: + STACK_UNWIND (frame, op_ret, op_errno, xattr, xdata); ++ if (local) { ++ br_stub_cleanup_local (local); ++ br_stub_dealloc_local (local); ++ } + return 0; + } + +@@ -1070,9 +1153,16 @@ int + br_stub_getxattr (call_frame_t *frame, xlator_t *this, + loc_t *loc, const char *name, dict_t *xdata) + { +- void *cookie = NULL; +- uuid_t rootgfid = {0, }; +- fop_getxattr_cbk_t cbk = br_stub_getxattr_cbk; ++ void *cookie = NULL; ++ uuid_t rootgfid = {0, }; ++ fop_getxattr_cbk_t cbk = br_stub_getxattr_cbk; ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ br_stub_local_t *local = NULL; ++ ++ GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, loc, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, loc->inode, unwind); + + rootgfid[15] = 1; + +@@ -1081,10 +1171,8 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, + goto wind; + } + +- if (br_stub_is_internal_xattr (name)) { +- STACK_UNWIND (frame, -1, EINVAL, NULL, NULL); +- return 0; +- } ++ if (br_stub_is_internal_xattr (name)) ++ goto unwind; + + /** + * this special extended attribute is allowed only on root +@@ -1104,6 +1192,18 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, + if (name && (strncmp (name, GLUSTERFS_GET_OBJECT_SIGNATURE, + strlen (GLUSTERFS_GET_OBJECT_SIGNATURE)) == 0)) { + cookie = (void *) BR_STUB_REQUEST_COOKIE; ++ ++ local = br_stub_alloc_local (this); ++ if (!local) { ++ op_ret = -1; ++ op_errno = ENOMEM; ++ goto unwind; ++ } ++ ++ br_stub_fill_local (local, NULL, NULL, loc->inode, ++ loc->inode->gfid, ++ BR_STUB_NO_VERSIONING, 0); ++ frame->local = local; + } + + wind: +@@ -1111,6 +1211,9 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, + (frame, cbk, cookie, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->getxattr, loc, name, xdata); + return 0; ++unwind: ++ STACK_UNWIND (frame, op_ret, op_errno, NULL, NULL); ++ return 0; + } + + int +@@ -1120,6 +1223,9 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, + void *cookie = NULL; + uuid_t rootgfid = {0, }; + fop_fgetxattr_cbk_t cbk = br_stub_getxattr_cbk; ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ br_stub_local_t *local = NULL; + + rootgfid[15] = 1; + +@@ -1128,10 +1234,8 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, + goto wind; + } + +- if (br_stub_is_internal_xattr (name)) { +- STACK_UNWIND (frame, -1, EINVAL, NULL, NULL); +- return 0; +- } ++ if (br_stub_is_internal_xattr (name)) ++ goto unwind; + + /** + * this special extended attribute is allowed only on root +@@ -1150,6 +1254,18 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, + if (name && (strncmp (name, GLUSTERFS_GET_OBJECT_SIGNATURE, + strlen (GLUSTERFS_GET_OBJECT_SIGNATURE)) == 0)) { + cookie = (void *) BR_STUB_REQUEST_COOKIE; ++ ++ local = br_stub_alloc_local (this); ++ if (!local) { ++ op_ret = -1; ++ op_errno = ENOMEM; ++ goto unwind; ++ } ++ ++ br_stub_fill_local (local, NULL, fd, fd->inode, ++ fd->inode->gfid, ++ BR_STUB_NO_VERSIONING, 0); ++ frame->local = local; + } + + wind: +@@ -1157,6 +1273,9 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, + (frame, cbk, cookie, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->fgetxattr, fd, name, xdata); + return 0; ++unwind: ++ STACK_UNWIND (frame, op_ret, op_errno, NULL, NULL); ++ return 0; + } + + /** +-- +1.7.1 + diff --git a/SOURCES/0157-bit-rot-New-logging-framework-for-bit-rot-log-messag.patch b/SOURCES/0157-bit-rot-New-logging-framework-for-bit-rot-log-messag.patch new file mode 100644 index 0000000..c9c1247 --- /dev/null +++ b/SOURCES/0157-bit-rot-New-logging-framework-for-bit-rot-log-messag.patch @@ -0,0 +1,1801 @@ +From 721e99e499ae3b2ac1903282eeef6fdd2676678d Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Fri, 17 Apr 2015 17:33:49 +0530 +Subject: [PATCH 157/190] bit-rot : New logging framework for bit-rot log message + + Backport of http://review.gluster.org/10297 + +Change-Id: I83c494f2bb60d29495cd643659774d430325af0a +BUG: 1231796 +Signed-off-by: Mohamed Ashiq +Reviewed-on: https://code.engineering.redhat.com/gerrit/51559 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + libglusterfs/src/glfs-message-id.h | 12 +- + xlators/features/bit-rot/src/bitd/Makefile.am | 2 +- + .../bit-rot/src/bitd/bit-rot-bitd-messages.h | 391 ++++++++++++++++++++ + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 101 +++--- + xlators/features/bit-rot/src/bitd/bit-rot.c | 239 +++++++----- + xlators/features/bit-rot/src/stub/Makefile.am | 2 +- + .../bit-rot/src/stub/bit-rot-stub-messages.h | 158 ++++++++ + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 116 ++++--- + xlators/features/bit-rot/src/stub/bit-rot-stub.h | 7 +- + 9 files changed, 821 insertions(+), 207 deletions(-) + create mode 100644 xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h + create mode 100644 xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 242e487..099ae2c 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -93,19 +93,19 @@ + #define GLFS_MSGID_COMP_PS_END (GLFS_MSGID_COMP_PS +\ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_PERF GLFS_MSGID_COMP_PS_END +-#define GLFS_MSGID_COMP_PERF_END (GLFS_MSGID_COMP_PERF +\ ++#define GLFS_MSGID_COMP_BITROT_STUB GLFS_MSGID_COMP_PS_END ++#define GLFS_MSGID_COMP_BITROT_STUB_END (GLFS_MSGID_COMP_BITROT_STUB +\ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_CHANGELOG GLFS_MSGID_COMP_PERF_END ++#define GLFS_MSGID_COMP_CHANGELOG GLFS_MSGID_COMP_BITROT_STUB_END + #define GLFS_MSGID_COMP_CHANGELOG_END (GLFS_MSGID_COMP_CHANGELOG +\ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_BITROT GLFS_MSGID_COMP_CHANGELOG_END +-#define GLFS_MSGID_COMP_BITROT_END (GLFS_MSGID_COMP_BITROT +\ ++#define GLFS_MSGID_COMP_BITROT_BITD GLFS_MSGID_COMP_CHANGELOG_END ++#define GLFS_MSGID_COMP_BITROT_BITD_END (GLFS_MSGID_COMP_BITROT_BITD +\ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_RPC_TRANS_SOCKET GLFS_MSGID_COMP_BITROT_END ++#define GLFS_MSGID_COMP_RPC_TRANS_SOCKET GLFS_MSGID_COMP_BITROT_BITD_END + #define GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END (GLFS_MSGID_COMP_RPC_TRANS_SOCKET + \ + GLFS_MSGID_SEGMENT) + +diff --git a/xlators/features/bit-rot/src/bitd/Makefile.am b/xlators/features/bit-rot/src/bitd/Makefile.am +index f67fa1a..fd42ebe 100644 +--- a/xlators/features/bit-rot/src/bitd/Makefile.am ++++ b/xlators/features/bit-rot/src/bitd/Makefile.am +@@ -13,7 +13,7 @@ bit_rot_la_SOURCES = bit-rot.c bit-rot-scrub.c bit-rot-tbf.c + bit_rot_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + $(top_builddir)/xlators/features/changelog/lib/src/libgfchangelog.la + +-noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h ++noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h bit-rot-bitd-messages.h + + AM_CFLAGS = -Wall $(GF_CFLAGS) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +new file mode 100644 +index 0000000..af3a74f +--- /dev/null ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +@@ -0,0 +1,391 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++ */ ++ ++#ifndef _BITROT_BITD_MESSAGES_H_ ++#define _BITROT_BITD_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/* file bit-rot-bitd-messages.h ++ * brief BIT-ROT log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_BITROT_BITD_BASE GLFS_MSGID_COMP_BITROT_BITD ++#define GLFS_BITROT_BITD_NUM_MESSAGES 48 ++#define GLFS_MSGID_END (GLFS_BITROT_BITD_BASE + \ ++ GLFS_BITROT_BITD_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x GLFS_BITROT_BITD_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++ ++#define BRB_MSG_FD_CREATE_FAILED (GLFS_BITROT_BITD_BASE + 1) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define BRB_MSG_READV_FAILED (GLFS_BITROT_BITD_BASE + 2) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define BRB_MSG_BLOCK_READ_FAILED (GLFS_BITROT_BITD_BASE + 3) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CALC_CHECKSUM_FAILED (GLFS_BITROT_BITD_BASE + 4) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_NO_MEMORY (GLFS_BITROT_BITD_BASE + 5) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_GET_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 6) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SET_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 7) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_OP_FAILED (GLFS_BITROT_BITD_BASE + 8) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_READ_AND_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 9) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 10) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_GET_SUBVOL_FAILED (GLFS_BITROT_BITD_BASE + 11) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SET_TIMER_FAILED (GLFS_BITROT_BITD_BASE + 12) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_GET_INFO_FAILED (GLFS_BITROT_BITD_BASE + 13) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_PATH_FAILED (GLFS_BITROT_BITD_BASE + 14) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_MARK_BAD_FILE (GLFS_BITROT_BITD_BASE + 15) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_TRIGGER_SIGN (GLFS_BITROT_BITD_BASE + 16) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_REGISTER_FAILED (GLFS_BITROT_BITD_BASE + 17) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CRAWLING_START (GLFS_BITROT_BITD_BASE + 18) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SPAWN_FAILED (GLFS_BITROT_BITD_BASE + 19) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_INVALID_SUBVOL_CHILD (GLFS_BITROT_BITD_BASE + 20) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SKIP_OBJECT (GLFS_BITROT_BITD_BASE + 21) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_NO_CHILD (GLFS_BITROT_BITD_BASE + 22) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CHECKSUM_MISMATCH (GLFS_BITROT_BITD_BASE + 23) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_MARK_CORRUPTED (GLFS_BITROT_BITD_BASE + 24) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CRAWLING_FINISH (GLFS_BITROT_BITD_BASE + 25) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CALC_ERROR (GLFS_BITROT_BITD_BASE + 26) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_LOOKUP_FAILED (GLFS_BITROT_BITD_BASE + 27) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_PARTIAL_VERSION_PRESENCE (GLFS_BITROT_BITD_BASE + 28) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_MEM_ACNT_FAILED (GLFS_BITROT_BITD_BASE + 29) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_TIMER_WHEEL_UNAVAILABLE (GLFS_BITROT_BITD_BASE + 30) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_BITROT_LOADED (GLFS_BITROT_BITD_BASE + 31) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCALE_DOWN_FAILED (GLFS_BITROT_BITD_BASE + 32) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCALE_UP_FAILED (GLFS_BITROT_BITD_BASE + 33) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCALE_DOWN_SCRUBBER (GLFS_BITROT_BITD_BASE + 34) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCALING_UP_SCRUBBER (GLFS_BITROT_BITD_BASE + 35) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define BRB_MSG_UNKNOWN_THROTTLE (GLFS_BITROT_BITD_BASE + 36) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_RATE_LIMIT_INFO (GLFS_BITROT_BITD_BASE + 37) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCRUB_INFO (GLFS_BITROT_BITD_BASE + 38) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_CONNECTED_TO_BRICK (GLFS_BITROT_BITD_BASE + 39) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_BRICK_INFO (GLFS_BITROT_BITD_BASE + 40) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SUBVOL_CONNECT_FAILED (GLFS_BITROT_BITD_BASE + 41) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_INVALID_SUBVOL (GLFS_BITROT_BITD_BASE + 42) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_RESCHEDULE_SCRUBBER_FAILED (GLFS_BITROT_BITD_BASE + 43) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ ++#define BRB_MSG_SCRUB_START (GLFS_BITROT_BITD_BASE + 44) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCRUB_FINISH (GLFS_BITROT_BITD_BASE + 45) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCRUB_RUNNING (GLFS_BITROT_BITD_BASE + 46) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCRUB_RESCHEDULED (GLFS_BITROT_BITD_BASE + 47) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRB_MSG_SCRUB_TUNABLE (GLFS_BITROT_BITD_BASE + 48) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++#endif /* !_BITROT_BITD_MESSAGES_H_ */ +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index 2da4530..45499de 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -23,6 +23,7 @@ + + #include "bit-rot-scrub.h" + #include ++#include "bit-rot-bitd-messages.h" + + struct br_scrubbers { + pthread_t scrubthread; +@@ -63,7 +64,7 @@ bitd_fetch_signature (xlator_t *this, br_child_t *child, + ret = dict_get_ptr + (*xattr, GLUSTERFS_GET_OBJECT_SIGNATURE, (void **) sign); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, + "failed to extract signature info [GFID: %s]", + uuid_utoa (fd->inode->gfid)); + goto unref_dict; +@@ -111,12 +112,12 @@ bitd_scrub_post_compute_check (xlator_t *this, + * The log entry looks pretty ugly, but helps in debugging.. + */ + if (signptr->stale || (signptr->version != version)) { +- gf_log (this->name, GF_LOG_DEBUG, +- " Object [GFID: %s] either has a stale " +- "signature OR underwent signing during checksumming " +- "{Stale: %d | Version: %lu,%lu}", +- uuid_utoa (fd->inode->gfid), (signptr->stale) ? 1 : 0, +- version, signptr->version); ++ gf_msg_debug (this->name, 0, " Object [GFID: %s] " ++ "either has a stale signature OR underwent " ++ "signing during checksumming {Stale: %d | " ++ "Version: %lu,%lu}", uuid_utoa (fd->inode->gfid), ++ (signptr->stale) ? 1 : 0, version, ++ signptr->version); + ret = -1; + goto unref_dict; + } +@@ -177,7 +178,7 @@ bitd_scrub_pre_compute_check (xlator_t *this, br_child_t *child, + int32_t ret = -1; + + if (bitd_is_bad_file (this, child, NULL, fd)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SKIP_OBJECT, + "Object [GFID: %s] is marked corrupted, skipping..", + uuid_utoa (fd->inode->gfid)); + goto out; +@@ -185,9 +186,9 @@ bitd_scrub_pre_compute_check (xlator_t *this, br_child_t *child, + + ret = bitd_signature_staleness (this, child, fd, &stale, version); + if (!ret && stale) { +- gf_log (this->name, GF_LOG_DEBUG, +- " Object [GFID: %s] has stale signature", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg_debug (this->name, 0, " Object [GFID: %s] " ++ "has stale signature", ++ uuid_utoa (fd->inode->gfid)); + ret = -1; + } + +@@ -215,13 +216,14 @@ bitd_compare_ckum (xlator_t *this, + + if (strncmp + (sign->signature, (char *) md, strlen (sign->signature)) == 0) { +- gf_log (this->name, GF_LOG_DEBUG, "%s [GFID: %s | Brick: %s] " +- "matches calculated checksum", loc->path, +- uuid_utoa (linked_inode->gfid), child->brick_path); ++ gf_msg_debug (this->name, 0, "%s [GFID: %s | Brick: %s] " ++ "matches calculated checksum", loc->path, ++ uuid_utoa (linked_inode->gfid), ++ child->brick_path); + return 0; + } + +- gf_log (this->name, GF_LOG_ALERT, ++ gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_CHECKSUM_MISMATCH, + "Object checksum mismatch: %s [GFID: %s | Brick: %s]", + loc->path, uuid_utoa (linked_inode->gfid), child->brick_path); + +@@ -234,19 +236,19 @@ bitd_compare_ckum (xlator_t *this, + + ret = dict_set_int32 (xattr, BITROT_OBJECT_BAD_KEY, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_MARK_BAD_FILE, + "Error setting bad-file marker for %s [GFID: %s | " + "Brick: %s]", loc->path, uuid_utoa (linked_inode->gfid), + child->brick_path); + goto dictfree; + } + +- gf_log (this->name, GF_LOG_INFO, "Marking %s [GFID: %s | Brick: %s] " +- "as corrupted..", loc->path, uuid_utoa (linked_inode->gfid), +- child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_MARK_CORRUPTED, "Marking %s" ++ " [GFID: %s | Brick: %s] as corrupted..", loc->path, ++ uuid_utoa (linked_inode->gfid), child->brick_path); + ret = syncop_fsetxattr (child->xl, fd, xattr, 0, NULL, NULL); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_MARK_BAD_FILE, + "Error marking object %s [GFID: %s] as corrupted", + loc->path, uuid_utoa (linked_inode->gfid)); + +@@ -308,12 +310,12 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) + if (linked_inode) + inode_lookup (linked_inode); + +- gf_log (this->name, GF_LOG_DEBUG, "Scrubbing object %s [GFID: %s]", +- entry->d_name, uuid_utoa (linked_inode->gfid)); ++ gf_msg_debug (this->name, 0, "Scrubbing object %s [GFID: %s]", ++ entry->d_name, uuid_utoa (linked_inode->gfid)); + + if (iatt.ia_type != IA_IFREG) { +- gf_log (this->name, GF_LOG_DEBUG, "%s is not a regular " +- "file", entry->d_name); ++ gf_msg_debug (this->name, 0, "%s is not a regular file", ++ entry->d_name); + ret = 0; + goto unref_inode; + } +@@ -323,8 +325,9 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) + */ + fd = fd_create (linked_inode, 0); + if (!fd) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create fd for " +- "inode %s", uuid_utoa (linked_inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, ++ "failed to create fd for inode %s", ++ uuid_utoa (linked_inode->gfid)); + goto unref_inode; + } + +@@ -355,8 +358,9 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) + + ret = br_calculate_obj_checksum (md, child, fd, &iatt); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "error calculating hash " +- "for object [GFID: %s]", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_CALC_ERROR, ++ "error calculating hash for object [GFID: %s]", ++ uuid_utoa (fd->inode->gfid)); + ret = -1; + goto free_md; + } +@@ -517,8 +521,15 @@ br_fsscanner_log_time (xlator_t *this, br_child_t *child, const char *sfx) + gettimeofday (&tv, NULL); + gf_time_fmt (timestr, sizeof (timestr), tv.tv_sec, gf_timefmt_FT); + +- gf_log (this->name, GF_LOG_INFO, +- "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, timestr); ++ if (strcasecmp (sfx, "started") == 0) { ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_START, ++ "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, ++ timestr); ++ } else { ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_FINISH, ++ "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, ++ timestr); ++ } + } + + static void +@@ -675,8 +686,8 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child, + + gf_time_fmt (timestr, sizeof (timestr), + (fsscan->boot + timo), gf_timefmt_FT); +- gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s scheduled to " +- "run at %s", child->brick_path, timestr); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, "Scrubbing for " ++ "%s scheduled to run at %s", child->brick_path, timestr); + + return 0; + +@@ -711,11 +722,12 @@ br_fsscan_reschedule (xlator_t *this, + ret = gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo); + + if (!ret && pendingcheck) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RUNNING, + "Scrubber for %s is currently running and would be " + "rescheduled after completion", child->brick_path); + else +- gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled " ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RESCHEDULED, ++ "Scrubbing for %s rescheduled " + "to run at %s", child->brick_path, timestr); + + return 0; +@@ -758,7 +770,7 @@ br_scrubber_calc_scale (xlator_t *this, + pow (M_E, BR_SCRUB_THREAD_SCALE_AGGRESSIVE); + break; + default: +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_UNKNOWN_THROTTLE, + "Unknown throttle %d", throttle); + } + +@@ -933,7 +945,7 @@ br_scrubber_scale_up (xlator_t *this, + + diff = (int)(v2 - v1); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCALING_UP_SCRUBBER, + "Scaling up scrubbers [%d => %d]", v1, v2); + + for (i = 0; i < diff; i++) { +@@ -956,7 +968,7 @@ br_scrubber_scale_up (xlator_t *this, + goto error_return; + + if (i != diff) /* degraded scaling.. */ +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SCALE_UP_FAILED, + "Could not fully scale up to %d scrubber(s). Spawned " + "%d/%d [total scrubber(s): %d]", v2, i, diff, (v1 + i)); + +@@ -978,7 +990,7 @@ br_scrubber_scale_down (xlator_t *this, + + diff = (int)(v1 - v2); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCALE_DOWN_SCRUBBER, + "Scaling down scrubbers [%d => %d]", v1, v2); + + for (i = 0 ; i < diff; i++) { +@@ -995,10 +1007,10 @@ br_scrubber_scale_down (xlator_t *this, + } + + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, +- "Could not fully scale down to %d scrubber(s). " +- "Terminated %d/%d [total scrubber(s): %d]", +- v1, i, diff, (v2 - i)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRB_MSG_SCALE_DOWN_FAILED, "Could not fully scale down " ++ "to %d scrubber(s). Terminated %d/%d [total " ++ "scrubber(s): %d]", v1, i, diff, (v2 - i)); + ret = 0; + } + +@@ -1162,8 +1174,9 @@ static void br_scrubber_log_option (xlator_t *this, + if (scrubstall) + return; /* logged as pause */ + +- gf_log (this->name, GF_LOG_INFO, "SCRUB TUNABLES:: [Frequency: %s, " +- "Throttle: %s]", scrub_freq_str[fsscrub->frequency], ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_TUNABLE, "SCRUB " ++ "TUNABLES:: [Frequency: %s, Throttle: %s]", ++ scrub_freq_str[fsscrub->frequency], + scrub_throttle_str[fsscrub->throttle]); + } + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index 228cf34..c06a5c1 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -24,6 +24,7 @@ + #include "bit-rot.h" + #include "bit-rot-scrub.h" + #include ++#include "bit-rot-bitd-messages.h" + + #include "tw.h" + +@@ -179,8 +180,8 @@ bitd_is_bad_file (xlator_t *this, br_child_t *child, loc_t *loc, fd_t *fd) + NULL); + + if (!ret) { +- gf_log (this->name, GF_LOG_DEBUG, "[GFID: %s] is marked " +- "corrupted", uuid_utoa (inode->gfid)); ++ gf_msg_debug (this->name, 0, "[GFID: %s] is marked corrupted", ++ uuid_utoa (inode->gfid)); + bad_file = _gf_true; + } + +@@ -257,8 +258,9 @@ br_object_open (xlator_t *this, + ret = -EINVAL; + fd = fd_create (inode, 0); + if (!fd) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create fd for the " +- "inode %s", uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, ++ "failed to create fd for the inode %s", ++ uuid_utoa (inode->gfid)); + goto out; + } + +@@ -313,8 +315,8 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child, + NULL); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "readv on %s failed (%s)", +- uuid_utoa (fd->inode->gfid), strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, BRB_MSG_READV_FAILED, ++ "readv on %s failed", uuid_utoa (fd->inode->gfid)); + ret = -1; + goto out; + } +@@ -364,7 +366,8 @@ br_calculate_obj_checksum (unsigned char *md, + ret = br_object_read_block_and_sign (this, fd, child, + offset, block, &sha256); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "reading block with " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_BLOCK_READ_FAILED, "reading block with " + "offset %lu of object %s failed", offset, + uuid_utoa (fd->inode->gfid)); + break; +@@ -408,24 +411,27 @@ br_object_read_sign (inode_t *linked_inode, fd_t *fd, br_object_t *object, + + md = GF_CALLOC (SHA256_DIGEST_LENGTH, sizeof (*md), gf_common_mt_char); + if (!md) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate memory " +- "for saving hash of the object %s", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, ++ "failed to allocate memory for saving hash of the " ++ "object %s", uuid_utoa (fd->inode->gfid)); + goto out; + } + + ret = br_object_checksum (md, object, fd, iatt); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "calculating checksum for " +- "the object %s failed", uuid_utoa (linked_inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_CALC_CHECKSUM_FAILED, "calculating checksum " ++ "for the object %s failed", ++ uuid_utoa (linked_inode->gfid)); + goto free_signature; + } + + sign = br_prepare_signature (md, SHA256_DIGEST_LENGTH, + BR_SIGNATURE_TYPE_SHA256, object); + if (!sign) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get the signature " +- "for the object %s", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, ++ "failed to get the signature for the object %s", ++ uuid_utoa (fd->inode->gfid)); + goto free_signature; + } + +@@ -434,16 +440,17 @@ br_object_read_sign (inode_t *linked_inode, fd_t *fd, br_object_t *object, + (void *)sign, signature_size (SHA256_DIGEST_LENGTH)); + + if (!xattr) { +- gf_log (this->name, GF_LOG_ERROR, "dict allocation for signing" +- " failed for the object %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_SIGN_FAILED, ++ "dict allocation for signing failed for the object %s", + uuid_utoa (fd->inode->gfid)); + goto free_isign; + } + + ret = syncop_fsetxattr (object->child->xl, fd, xattr, 0, NULL, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "fsetxattr of signature to " +- "the object %s failed", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_SIGN_FAILED, ++ "fsetxattr of signature to the object %s failed", ++ uuid_utoa (fd->inode->gfid)); + goto unref_dict; + } + +@@ -469,9 +476,14 @@ void + br_log_object (xlator_t *this, char *op, uuid_t gfid, int32_t op_errno) + { + int softerror = br_object_sign_softerror (op_errno); +- gf_log (this->name, (softerror) ? GF_LOG_DEBUG : GF_LOG_ERROR, +- "%s() failed on object %s [reason: %s]", +- op, uuid_utoa (gfid), strerror (op_errno)); ++ if (softerror) { ++ gf_msg_debug (this->name, 0, "%s() failed on object %s " ++ "[reason: %s]", op, uuid_utoa (gfid), ++ strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, BRB_MSG_OP_FAILED, ++ "%s() failed on object %s", op, uuid_utoa (gfid)); ++ } + } + + void +@@ -479,9 +491,13 @@ br_log_object_path (xlator_t *this, char *op, + const char *path, int32_t op_errno) + { + int softerror = br_object_sign_softerror (op_errno); +- gf_log (this->name, (softerror) ? GF_LOG_DEBUG : GF_LOG_ERROR, +- "%s() failed on object %s [reason: %s]", +- op, path, strerror (op_errno)); ++ if (softerror) { ++ gf_msg_debug (this->name, 0, "%s() failed on object %s " ++ "[reason: %s]", op, path, strerror (op_errno)); ++ } else { ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, BRB_MSG_OP_FAILED, ++ "%s() failed on object %s", op, path); ++ } + } + + static void +@@ -509,8 +525,9 @@ br_trigger_sign (xlator_t *this, br_child_t *child, + ret = -1; + fd = fd_create (linked_inode, 0); + if (!fd) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create fd " +- "[GFID %s]", uuid_utoa (linked_inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, ++ "Failed to create fd [GFID %s]", ++ uuid_utoa (linked_inode->gfid)); + goto cleanup_dict; + } + +@@ -534,7 +551,7 @@ br_trigger_sign (xlator_t *this, br_child_t *child, + dict_unref (dict); + out: + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_TRIGGER_SIGN, + "Could not trigger signingd for %s (reopen hint: %d)", + uuid_utoa (linked_inode->gfid), val); + } +@@ -610,13 +627,14 @@ static inline int32_t br_sign_object (br_object_t *object) + * we have an open file descriptor on the object. from here on, + * do not be generous to file operation errors. + */ +- gf_log (this->name, GF_LOG_DEBUG, +- "Signing object [%s]", uuid_utoa (linked_inode->gfid)); ++ gf_msg_debug (this->name, 0, "Signing object [%s]", ++ uuid_utoa (linked_inode->gfid)); + + ret = br_object_read_sign (linked_inode, fd, object, &iatt); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "reading and signing of the " +- "object %s failed", uuid_utoa (linked_inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_READ_AND_SIGN_FAILED, "reading and signing of " ++ "the object %s failed", uuid_utoa (linked_inode->gfid)); + goto unref_fd; + } + +@@ -670,8 +688,8 @@ br_process_object (void *arg) + + ret = br_sign_object (object); + if (ret && !br_object_sign_softerror (-ret)) +- gf_log (this->name, GF_LOG_ERROR, +- "SIGNING FAILURE [%s]", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_SIGN_FAILED, "SIGNING FAILURE [%s]", + uuid_utoa (object->gfid)); + GF_FREE (object); + } +@@ -795,32 +813,34 @@ br_brick_callback (void *xl, char *brick, + + gf_uuid_copy (gfid, ev->u.releasebr.gfid); + +- gf_log (this->name, GF_LOG_DEBUG, +- "RELEASE EVENT [GFID %s]", uuid_utoa (gfid)); ++ gf_msg_debug (this->name, 0, "RELEASE EVENT [GFID %s]", ++ uuid_utoa (gfid)); + + child = br_get_child_from_brick_path (this, brick); + if (!child) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get the subvolume " +- "for the brick %s", brick); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SUBVOL_FAILED, ++ "failed to get the subvolume for the brick %s", brick); + goto out; + } + + object = br_initialize_object (this, child, ev); + if (!object) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate " +- "object memory [GFID: %s]", uuid_utoa (gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, ++ "failed to allocate object memory [GFID: %s]", ++ uuid_utoa (gfid)); + goto out; + } + + timer = br_initialize_timer (this, object, child, ev); + if (!timer) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate " +- "object expiry timer [GFID: %s]", uuid_utoa (gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, ++ "failed to allocate object expiry timer [GFID: %s]", ++ uuid_utoa (gfid)); + goto free_object; + } + +- gf_log (this->name, GF_LOG_DEBUG, "->callback: brick [%s], type [%d]\n", +- brick, ev->ev_type); ++ gf_msg_debug (this->name, 0, "->callback: brick [%s], type [%d]\n", ++ brick, ev->ev_type); + + return; + +@@ -867,7 +887,7 @@ br_check_object_need_sign (xlator_t *this, dict_t *xattr, br_child_t *child) + ret = dict_get_ptr (xattr, GLUSTERFS_GET_OBJECT_SIGNATURE, + (void **)&sign); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, + "failed to get object signature info"); + goto out; + } +@@ -895,8 +915,8 @@ br_prepare_loc (xlator_t *this, br_child_t *child, loc_t *parent, + else { + loc->inode = inode; + if (loc->inode->ia_type != IA_IFREG) { +- gf_log (this->name, GF_LOG_DEBUG, "%s is not a regular " +- "file", entry->d_name); ++ gf_msg_debug (this->name, 0, "%s is not a regular " ++ "file", entry->d_name); + ret = 0; + goto out; + } +@@ -907,8 +927,8 @@ br_prepare_loc (xlator_t *this, br_child_t *child, loc_t *parent, + + ret = inode_path (parent->inode, entry->d_name, (char **)&loc->path); + if (ret < 0 || !loc->path) { +- gf_log (this->name, GF_LOG_ERROR, "inode_path on %s " +- "(parent: %s) failed", entry->d_name, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_PATH_FAILED, ++ "inode_path on %s (parent: %s) failed", entry->d_name, + uuid_utoa (parent->inode->gfid)); + goto out; + } +@@ -969,8 +989,8 @@ bitd_oneshot_crawl (xlator_t *subvol, + inode_lookup (linked_inode); + + if (iatt.ia_type != IA_IFREG) { +- gf_log (this->name, GF_LOG_DEBUG, +- "%s is not a regular file, skipping..", entry->d_name); ++ gf_msg_debug (this->name, 0, "%s is not a regular file, " ++ "skipping..", entry->d_name); + ret = 0; + goto unref_inode; + } +@@ -992,7 +1012,7 @@ bitd_oneshot_crawl (xlator_t *subvol, + */ + + if (bitd_is_bad_file (this, child, &loc, NULL)) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SKIP_OBJECT, + "Entry [%s] is marked corrupted.. skipping.", loc.path); + goto unref_inode; + } +@@ -1010,9 +1030,10 @@ bitd_oneshot_crawl (xlator_t *subvol, + if (op_errno == ENODATA && (iatt.ia_size != 0)) + need_signing = _gf_true; + if (op_errno == EINVAL) +- gf_log (this->name, GF_LOG_WARNING, "Partial version " +- "xattr presence detected, ignoring [GFID: %s]", +- uuid_utoa (linked_inode->gfid)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRB_MSG_PARTIAL_VERSION_PRESENCE, "Partial " ++ "version xattr presence detected, ignoring " ++ "[GFID: %s]", uuid_utoa (linked_inode->gfid)); + } else { + need_signing = br_check_object_need_sign (this, xattr, child); + } +@@ -1020,7 +1041,7 @@ bitd_oneshot_crawl (xlator_t *subvol, + if (!need_signing) + goto unref_dict; + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_TRIGGER_SIGN, + "Triggering signing for %s [GFID: %s | Brick: %s]", + loc.path, uuid_utoa (linked_inode->gfid), child->brick_path); + br_trigger_sign (this, child, linked_inode, &loc, _gf_true); +@@ -1053,8 +1074,9 @@ br_oneshot_signer (void *arg) + + THIS = this; + +- gf_log (this->name, GF_LOG_INFO, "Crawling brick [%s], scanning " +- "for unsigned objects", child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CRAWLING_START, ++ "Crawling brick [%s], scanning for unsigned objects", ++ child->brick_path); + + loc.inode = child->table->root; + (void) syncop_ftw_throttle +@@ -1062,7 +1084,7 @@ br_oneshot_signer (void *arg) + GF_CLIENT_PID_BITD, child, bitd_oneshot_crawl, + BR_CRAWL_THROTTLE_COUNT, BR_CRAWL_THROTTLE_ZZZ); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CRAWLING_FINISH, + "Completed crawling brick [%s]", child->brick_path); + + return NULL; +@@ -1097,15 +1119,16 @@ br_enact_signer (xlator_t *this, br_child_t *child, br_stub_init_t *stub) + ret = gf_changelog_register_generic + (brick, 1, 1, this->ctx->cmd_args.log_file, -1, this); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Register to changelog failed" +- " [Reason: %s]", strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ BRB_MSG_REGISTER_FAILED, "Register to changelog " ++ "failed"); + goto dealloc; + } + + child->threadrunning = 0; + ret = gf_thread_create (&child->thread, NULL, br_oneshot_signer, child); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SPAWN_FAILED, + "failed to spawn FS crawler thread"); + else + child->threadrunning = 1; +@@ -1148,8 +1171,9 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + + ret = gf_thread_create (&child->thread, NULL, br_fsscanner, child); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ALERT, "failed to spawn bitrot " +- "scrubber daemon [Brick: %s]", child->brick_path); ++ gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_SPAWN_FAILED, ++ "failed to spawn bitrot scrubber daemon [Brick: %s]", ++ child->brick_path); + goto error_return; + } + +@@ -1211,8 +1235,8 @@ br_brick_connect (xlator_t *this, br_child_t *child) + if (ret) { + op_errno = -ret; + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "lookup on root failed " +- "[Reason: %s]", strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ BRB_MSG_LOOKUP_FAILED, "lookup on root failed"); + goto wipeloc; + } + +@@ -1221,15 +1245,15 @@ br_brick_connect (xlator_t *this, br_child_t *child) + if (ret) { + op_errno = -ret; + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "failed to get stub info " +- "[Reason: %s]", strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, ++ BRB_MSG_GET_INFO_FAILED, "failed to get stub info"); + goto wipeloc; + } + + ret = dict_get_ptr (xattr, GLUSTERFS_GET_BR_STUB_INIT_TIME, + (void **)&stub); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_INFO_FAILED, + "failed to extract stub information"); + goto free_dict; + } +@@ -1244,7 +1268,7 @@ br_brick_connect (xlator_t *this, br_child_t *child) + ret = br_enact_signer (this, child, stub); + + if (!ret) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CONNECTED_TO_BRICK, + "Connected to brick %s..", child->brick_path); + + free_dict: +@@ -1293,8 +1317,9 @@ br_handle_events (void *arg) + + ret = br_brick_connect (this, child); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "failed to connect " +- "to subvolume %s", child->xl->name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_SUBVOL_CONNECT_FAILED, "failed to " ++ "connect to subvolume %s", child->xl->name); + } + + return NULL; +@@ -1311,8 +1336,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_br_stub_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, "Memory accounting" +- " init failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_MEM_ACNT_FAILED, ++ "Memory accounting init failed"); + return ret; + } + +@@ -1330,15 +1355,16 @@ notify (xlator_t *this, int32_t event, void *data, ...) + subvol = (xlator_t *)data; + priv = this->private; + +- gf_log (this->name, GF_LOG_TRACE, "Notification received: %d", event); ++ gf_msg_trace (this->name, 0, "Notification received: %d", event); + + idx = br_find_child_index (this, subvol); + + switch (event) { + case GF_EVENT_CHILD_UP: + if (idx < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "Got event %d from invalid subvolume", event); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_INVALID_SUBVOL, "Got event %d from " ++ "invalid subvolume", event); + goto out; + } + +@@ -1366,7 +1392,8 @@ notify (xlator_t *this, int32_t event, void *data, ...) + + case GF_EVENT_CHILD_DOWN: + if (idx < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_INVALID_SUBVOL_CHILD, + "Got event %d from invalid subvolume", event); + goto out; + } +@@ -1430,8 +1457,9 @@ br_init_signer (xlator_t *this, br_private_t *priv) + ret = gf_thread_create (&priv->obj_queue->workers[i], NULL, + br_process_object, this); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "thread creation failed (%s)", strerror (-ret)); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ BRB_MSG_SPAWN_FAILED, "thread creation" ++ " failed"); + ret = -1; + goto cleanup_threads; + } +@@ -1482,10 +1510,10 @@ br_rate_limit_signer (xlator_t *this, int child_count, int numbricks) + #endif + + if (!spec.rate) +- gf_log (this->name, +- GF_LOG_INFO, "[Rate Limit Info] \"FULL THROTTLE\""); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_RATE_LIMIT_INFO, ++ "[Rate Limit Info] \"FULL THROTTLE\""); + else +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_RATE_LIMIT_INFO, + "[Rate Limit Info] \"tokens/sec (rate): %lu, " + "maxlimit: %lu\"", spec.rate, spec.maxlimit); + +@@ -1540,17 +1568,18 @@ init (xlator_t *this) + { + int i = 0; + int32_t ret = -1; +- br_private_t *priv = NULL; ++ br_private_t *priv = NULL; + xlator_list_t *trav = NULL; + +- if (!this->children) { +- gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); +- goto out; +- } ++ if (!this->children) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_NO_CHILD, ++ "FATAL: no children"); ++ goto out; ++ } + + priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t); + if (!priv) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, + "failed to allocate memory (->priv)"); + goto out; + } +@@ -1571,8 +1600,9 @@ init (xlator_t *this) + priv->children[i].timer_pool = + mem_pool_new (struct gf_tw_timer_list, 4096); + if (!priv->children[i].timer_pool) { +- gf_log (this->name, GF_LOG_ERROR, +- "failed to allocate mem-pool for timer"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ BRB_MSG_NO_MEMORY, "failed to allocate mem-pool" ++ " for timer"); + errno = ENOMEM; + goto free_children; + } +@@ -1591,7 +1621,8 @@ init (xlator_t *this) + + priv->timer_wheel = glusterfs_global_timer_wheel (this); + if (!priv->timer_wheel) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_TIMER_WHEEL_UNAVAILABLE, + "global timer wheel unavailable"); + goto cleanup_mutex; + } +@@ -1613,13 +1644,13 @@ init (xlator_t *this) + + ret = gf_thread_create (&priv->thread, NULL, br_handle_events, this); + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "thread creation failed (%s)", strerror (-ret)); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ BRB_MSG_SPAWN_FAILED, "thread creation failed"); + ret = -1; + } + + if (!ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_BITROT_LOADED, + "bit-rot xlator loaded in \"%s\" mode", + (priv->iamscrubber) ? "SCRUBBER" : "SIGNER"); + return 0; +@@ -1691,11 +1722,11 @@ reconfigure (xlator_t *this, dict_t *options) + for (; i < priv->child_count; i++) { + child = &priv->children[i]; + if (!child->child_up) { +- gf_log (this->name, GF_LOG_INFO, +- "Brick %s is offline, skipping " +- "rescheduling (scrub would auto- " +- "schedule when brick is back online).", +- child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ BRB_MSG_BRICK_INFO, "Brick %s is " ++ "offline, skipping rescheduling (scrub" ++ " would auto- schedule when brick is " ++ "back online).", child->brick_path); + continue; + } + +@@ -1703,10 +1734,12 @@ reconfigure (xlator_t *this, dict_t *options) + ret = br_fsscan_reschedule (this, child, + fsscan, fsscrub, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Could not " +- "reschedule scrubber for brick: %s. " +- "Scubbing will continue according to " +- "old frequency.", child->brick_path); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, ++ "Could not reschedule scrubber for " ++ "brick: %s. Scubbing will continue " ++ "according to old frequency.", ++ child->brick_path); + } + } + } +diff --git a/xlators/features/bit-rot/src/stub/Makefile.am b/xlators/features/bit-rot/src/stub/Makefile.am +index 579dd1c..30e7ca7 100644 +--- a/xlators/features/bit-rot/src/stub/Makefile.am ++++ b/xlators/features/bit-rot/src/stub/Makefile.am +@@ -7,7 +7,7 @@ bitrot_stub_la_SOURCES = bit-rot-stub.c + bitrot_stub_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + + noinst_HEADERS = bit-rot-stub.h bit-rot-common.h bit-rot-stub-mem-types.h \ +- bit-rot-object-version.h ++ bit-rot-object-version.h bit-rot-stub-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +new file mode 100644 +index 0000000..d940b65 +--- /dev/null ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +@@ -0,0 +1,158 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++ */ ++ ++#ifndef _BITROT_STUB_MESSAGES_H_ ++#define _BITROT_STUB_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/* file bit-rot-stub-messages.h ++ * brief BIT-ROT log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_BITROT_STUB_BASE GLFS_MSGID_COMP_BITROT_STUB ++#define GLFS_BITROT_STUB_NUM_MESSAGES 15 ++#define GLFS_MSGID_END (GLFS_BITROT_STUB_BASE + \ ++ GLFS_BITROT_STUB_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x GLFS_BITROT_STUB_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++ ++#define BRS_MSG_NO_MEMORY (GLFS_BITROT_STUB_BASE + 1) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_SET_EVENT_FAILED (GLFS_BITROT_STUB_BASE + 2) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_MEM_ACNT_FAILED (GLFS_BITROT_STUB_BASE + 3) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_CREATE_FRAME_FAILED (GLFS_BITROT_STUB_BASE + 4) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_SET_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 5) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_CHANGE_VERSION_FAILED (GLFS_BITROT_STUB_BASE + 6) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_ADD_FD_TO_LIST_FAILED (GLFS_BITROT_STUB_BASE + 7) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_SET_FD_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 8) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_CREATE_ANONYMOUS_FD_FAILED (GLFS_BITROT_STUB_BASE + 9) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_NO_CHILD (GLFS_BITROT_STUB_BASE + 10) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_STUB_ALLOC_FAILED (GLFS_BITROT_STUB_BASE + 11) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_GET_INODE_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 12) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_CANCEL_SIGN_THREAD_FAILED (GLFS_BITROT_STUB_BASE + 13) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_ADD_FD_TO_INODE (GLFS_BITROT_STUB_BASE + 14) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_SIGN_VERSION_ERROR (GLFS_BITROT_STUB_BASE + 15) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++#endif /* !_BITROT_STUB_MESSAGES_H_ */ +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index d4aecdc..600eb80 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -25,7 +25,7 @@ + + #include "bit-rot-stub.h" + #include "bit-rot-stub-mem-types.h" +- ++#include "bit-rot-stub-messages.h" + #include "bit-rot-common.h" + + #define BR_STUB_REQUEST_COOKIE 0x1 +@@ -51,8 +51,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_br_stub_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_WARNING, "Memory accounting" +- " init failed"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_MEM_ACNT_FAILED, ++ "Memory accounting init failed"); + return ret; + } + +@@ -65,12 +65,13 @@ init (xlator_t *this) + int32_t ret = 0; + char *tmp = NULL; + struct timeval tv = {0,}; +- br_stub_private_t *priv = NULL; ++ br_stub_private_t *priv = NULL; + +- if (!this->children) { +- gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); +- goto error_return; +- } ++ if (!this->children) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_NO_CHILD, ++ "FATAL: no children"); ++ goto error_return; ++ } + + priv = GF_CALLOC (1, sizeof (*priv), gf_br_stub_mt_private_t); + if (!priv) +@@ -99,7 +100,7 @@ init (xlator_t *this) + if (ret != 0) + goto cleanup_lock; + +- gf_log (this->name, GF_LOG_DEBUG, "bit-rot stub loaded"); ++ gf_msg_debug (this->name, 0, "bit-rot stub loaded"); + this->private = priv; + + return 0; +@@ -127,7 +128,8 @@ fini (xlator_t *this) + + ret = gf_thread_cleanup_xint (priv->signth); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_CANCEL_SIGN_THREAD_FAILED, + "Could not cancel sign serializer thread"); + goto out; + } +@@ -340,8 +342,9 @@ br_stub_need_versioning (xlator_t *this, + + ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " +- "context for the inode %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " ++ "inode context for the inode %s", + uuid_utoa (fd->inode->gfid)); + goto error_return; + } +@@ -375,8 +378,9 @@ br_stub_anon_fd_ctx (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx) + if (!br_stub_fd) { + ret = br_stub_add_fd_to_inode (this, fd, ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " +- "add fd to the inode (gfid: %s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_ADD_FD_TO_INODE, "failed to add fd to " ++ "the inode (gfid: %s)", + uuid_utoa (fd->inode->gfid)); + goto out; + } +@@ -397,8 +401,9 @@ br_stub_versioning_prep (call_frame_t *frame, + + local = br_stub_alloc_local (this); + if (!local) { +- gf_log (this->name, GF_LOG_ERROR, "local allocation failed " +- "(gfid: %s)", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRS_MSG_NO_MEMORY, ++ "local allocation failed (gfid: %s)", ++ uuid_utoa (fd->inode->gfid)); + goto error_return; + } + +@@ -693,9 +698,10 @@ br_stub_compare_sign_version (xlator_t *this, + if (ctx->currentversion < sbuf->signedversion) { + invalid = _gf_true; + } else if (ctx->currentversion > sbuf->signedversion) { +- gf_log (this->name, GF_LOG_DEBUG, "\"Signing version\" " +- "(%lu) lower than \"Current version \" (%lu)", +- ctx->currentversion, sbuf->signedversion); ++ gf_msg_debug (this->name, 0, "\"Signing version\" " ++ "(%lu) lower than \"Current version \" " ++ "(%lu)", ctx->currentversion, ++ sbuf->signedversion); + *fakesuccess = 1; + } + } +@@ -703,9 +709,10 @@ br_stub_compare_sign_version (xlator_t *this, + + if (invalid) { + ret = -1; +- gf_log (this->name, GF_LOG_WARNING, +- "Signing version exceeds current version [%lu > %lu]", +- sbuf->signedversion, ctx->currentversion); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRS_MSG_SIGN_VERSION_ERROR, "Signing version exceeds " ++ "current version [%lu > %lu]", sbuf->signedversion, ++ ctx->currentversion); + } + + out: +@@ -875,9 +882,9 @@ br_stub_handle_object_reopen (call_frame_t *frame, + stub = fop_fsetxattr_cbk_stub (frame, br_stub_fsetxattr_resume, + 0, 0, NULL); + if (!stub) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " +- "fsetxattr fop (gfid: %s), unwinding", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, ++ "failed to allocate stub for fsetxattr fop (gfid: %s)," ++ " unwinding", uuid_utoa (fd->inode->gfid)); + goto cleanup_local; + } + +@@ -1003,8 +1010,9 @@ br_stub_is_object_stale (xlator_t *this, call_frame_t *frame, inode_t *inode, + + ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " +- "context for %s", uuid_utoa (inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " ++ "inode context for %s", uuid_utoa (inode->gfid)); + goto out; + } + +@@ -1389,9 +1397,9 @@ br_stub_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + offset, flags, iobref, xdata); + + if (!stub) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " +- "write fop (gfid: %s), unwinding", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, ++ "failed to allocate stub for write fop (gfid: %s), " ++ "unwinding", uuid_utoa (fd->inode->gfid)); + goto cleanup_local; + } + +@@ -1496,9 +1504,9 @@ br_stub_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + stub = fop_ftruncate_stub (frame, br_stub_ftruncate_resume, fd, offset, + xdata); + if (!stub) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " +- "ftruncate fop (gfid: %s), unwinding", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, ++ "failed to allocate stub for ftruncate fop (gfid: %s)," ++ " unwinding", uuid_utoa (fd->inode->gfid)); + goto cleanup_local; + } + +@@ -1597,8 +1605,10 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + + fd = fd_anonymous (loc->inode); + if (!fd) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create anonymous " +- "fd for the inode %s", uuid_utoa (loc->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, "failed to create " ++ "anonymous fd for the inode %s", ++ uuid_utoa (loc->inode->gfid)); + goto unwind; + } + +@@ -1624,9 +1634,9 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + stub = fop_truncate_stub (frame, br_stub_truncate_resume, loc, offset, + xdata); + if (!stub) { +- gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " +- "truncate fop (gfid: %s), unwinding", +- uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, ++ "failed to allocate stub for truncate fop (gfid: %s), " ++ "unwinding", uuid_utoa (fd->inode->gfid)); + goto cleanup_local; + } + +@@ -1690,8 +1700,9 @@ br_stub_open (call_frame_t *frame, xlator_t *this, + + ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " +- "context for the file %s (gfid: %s)", loc->path, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " ++ "inode context for the file %s (gfid: %s)", loc->path, + uuid_utoa (fd->inode->gfid)); + goto unwind; + } +@@ -1702,8 +1713,10 @@ br_stub_open (call_frame_t *frame, xlator_t *this, + + ret = br_stub_add_fd_to_inode (this, fd, ctx); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed add fd to the list " +- "(gfid: %s)", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_ADD_FD_TO_LIST_FAILED, ++ "failed add fd to the list (gfid: %s)", ++ uuid_utoa (fd->inode->gfid)); + goto unwind; + } + +@@ -1735,7 +1748,8 @@ br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx) + + ret = br_stub_require_release_call (this, fd, &br_stub_fd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "failed to set the fd " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_SET_FD_CONTEXT_FAILED, "failed to set the fd " + "context for the file (gfid: %s)", + uuid_utoa (fd->inode->gfid)); + goto out; +@@ -2123,7 +2137,7 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion, + + xdata = dict_new (); + if (!xdata) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, BRS_MSG_NO_MEMORY, + "dict allocation failed: cannot send IPC FOP " + "to changelog"); + goto out; +@@ -2132,14 +2146,16 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion, + ret = dict_set_static_bin (xdata, + "RELEASE-EVENT", &ev, CHANGELOG_EV_SIZE); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_SET_EVENT_FAILED, + "cannot set release event in dict"); + goto dealloc_dict; + } + + frame = create_frame (this, this->ctx->pool); + if (!frame) { +- gf_log (this->name, GF_LOG_WARNING, "create_frame() failure"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRS_MSG_CREATE_FRAME_FAILED, ++ "create_frame() failure"); + goto dealloc_dict; + } + +@@ -2245,10 +2261,10 @@ br_stub_release (xlator_t *this, fd_t *fd) + UNLOCK (&inode->lock); + + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, +- "releaseversion: %lu | flags: %d | signinfo: %d", +- (unsigned long) ntohl (releaseversion), +- flags, ntohl(signinfo)); ++ gf_msg_debug (this->name, 0, "releaseversion: %lu | flags: %d " ++ "| signinfo: %d", ++ (unsigned long) ntohl (releaseversion), flags, ++ ntohl(signinfo)); + br_stub_send_ipc_fop (this, fd, releaseversion, signinfo); + } + +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +index 9304ef8..48c7a37 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +@@ -24,6 +24,7 @@ + #include "bit-rot-stub-mem-types.h" + + #include "bit-rot-common.h" ++#include "bit-rot-stub-messages.h" + + typedef int (br_stub_version_cbk) (call_frame_t *, void *, + xlator_t *, int32_t, int32_t, dict_t *); +@@ -223,7 +224,8 @@ br_stub_require_release_call (xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) + + ret = br_stub_fd_ctx_set (this, fd, br_stub_fd); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRS_MSG_SET_CONTEXT_FAILED, + "could not set fd context (for release callback"); + else + *fd_ctx = br_stub_fd; +@@ -277,7 +279,8 @@ __br_stub_set_ongoing_version (br_stub_inode_ctx_t *ctx, unsigned long version) + if (ctx->currentversion < version) + ctx->currentversion = version; + else +- gf_log ("bit-rot-stub", GF_LOG_WARNING, "current version: %lu" ++ gf_msg ("bit-rot-stub", GF_LOG_WARNING, 0, ++ BRS_MSG_CHANGE_VERSION_FAILED, "current version: %lu" + "new version: %lu", ctx->currentversion, version); + } + +-- +1.7.1 + diff --git a/SOURCES/0158-features-bitrot-cleanup-v1.patch b/SOURCES/0158-features-bitrot-cleanup-v1.patch new file mode 100644 index 0000000..2be3e27 --- /dev/null +++ b/SOURCES/0158-features-bitrot-cleanup-v1.patch @@ -0,0 +1,665 @@ +From 069d8f649618fc1230ce6382ddd12c6b082262c3 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Tue, 2 Jun 2015 21:23:48 +0530 +Subject: [PATCH 158/190] features/bitrot: cleanup, v1 + + Backport of http://review.gluster.org/11147 + +This is a short series of patches (with other cleanups) aimed at +cleaning up some of the incorrect assumptions taken in reconfigure() +leading to crashes when subvolumes are not fully initialized (as +reported here[1] on gluster-devel@). Furthermore, there is some +amount of code cleanup to handle disconnection and cleanup up data +structure (as part of subsequent patch). + +[1] http://www.gluster.org/pipermail/gluster-devel/2015-June/045410.html + +Change-Id: I68ac4bccfbac4bf02fcc31615bd7d2d191021132 +BUG: 1232307 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51743 +Tested-by: Raghavendra Bhat +Reviewed-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/bit-rot.c | 364 +++++++++++++------- + xlators/features/bit-rot/src/bitd/bit-rot.h | 32 ++- + .../bit-rot/src/stub/bit-rot-stub-mem-types.h | 1 + + 3 files changed, 271 insertions(+), 126 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index c06a5c1..b855cd7 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -30,6 +30,18 @@ + + #define BR_HASH_CALC_READ_SIZE (128 * 1024) + ++typedef int32_t (br_child_handler)(xlator_t *, br_child_t *); ++ ++struct br_child_event { ++ xlator_t *this; ++ ++ br_child_t *child; ++ ++ br_child_handler *call; ++ ++ struct list_head list; ++}; ++ + static int + br_find_child_index (xlator_t *this, xlator_t *child) + { +@@ -54,26 +66,6 @@ out: + return index; + } + +-static void +-br_free_children (xlator_t *this) +-{ +- br_private_t *priv = NULL; +- int32_t i = 0; +- br_child_t *child = NULL; +- +- priv = this->private; +- +- for (i = 0; i < priv->child_count; i++) { +- child = &priv->children[i]; +- mem_pool_destroy (child->timer_pool); +- list_del_init (&priv->children[i].list); +- } +- +- GF_FREE (priv->children); +- +- priv->children = NULL; +-} +- + br_child_t * + br_get_child_from_brick_path (xlator_t *this, char *brick_path) + { +@@ -1090,6 +1082,16 @@ br_oneshot_signer (void *arg) + return NULL; + } + ++static void ++br_set_child_state (br_child_t *child, br_child_state_t state) ++{ ++ LOCK (&child->lock); ++ { ++ _br_set_child_state (child, state); ++ } ++ UNLOCK (&child->lock); ++} ++ + /** + * At this point a thread is spawned to crawl the filesystem (in + * tortoise pace) to sign objects that were not signed in previous run(s). +@@ -1177,7 +1179,12 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + goto error_return; + } + +- ret = br_fsscan_schedule (this, child, fsscan, fsscrub); ++ /* this needs to be serialized with reconfigure() */ ++ pthread_mutex_lock (&priv->lock); ++ { ++ ret = br_fsscan_schedule (this, child, fsscan, fsscrub); ++ } ++ pthread_mutex_unlock (&priv->lock); + if (ret) + goto error_return; + +@@ -1202,6 +1209,30 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + return -1; + } + ++static int32_t ++br_child_enaction (xlator_t *this, br_child_t *child, br_stub_init_t *stub) ++{ ++ int32_t ret = -1; ++ br_private_t *priv = this->private; ++ ++ LOCK (&child->lock); ++ { ++ if (priv->iamscrubber) ++ ret = br_enact_scrubber (this, child); ++ else ++ ret = br_enact_signer (this, child, stub); ++ ++ if (!ret) { ++ _br_set_child_state (child, BR_CHILD_STATE_CONNECTED); ++ gf_log (this->name, GF_LOG_INFO, ++ "Connected to brick %s..", child->brick_path); ++ } ++ } ++ UNLOCK (&child->lock); ++ ++ return ret; ++} ++ + /** + * This routine fetches various attributes associated with a child which + * is basically a subvolume. Attributes include brick path and the stub +@@ -1209,7 +1240,7 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + * by getxattr() on a virtual key. Depending on the configuration, the + * process either acts as a signer or a scrubber. + */ +-static inline int32_t ++int32_t + br_brick_connect (xlator_t *this, br_child_t *child) + { + int32_t ret = -1; +@@ -1218,14 +1249,13 @@ br_brick_connect (xlator_t *this, br_child_t *child) + struct iatt parent = {0, }; + br_stub_init_t *stub = NULL; + dict_t *xattr = NULL; +- br_private_t *priv = NULL; + int op_errno = 0; + + GF_VALIDATE_OR_GOTO ("bit-rot", this, out); + GF_VALIDATE_OR_GOTO (this->name, child, out); + GF_VALIDATE_OR_GOTO (this->name, this->private, out); + +- priv = this->private; ++ br_set_child_state (child, BR_CHILD_STATE_INITIALIZING); + + loc.inode = inode_ref (child->table->root); + gf_uuid_copy (loc.gfid, loc.inode->gfid); +@@ -1262,20 +1292,15 @@ br_brick_connect (xlator_t *this, br_child_t *child) + child->tv.tv_sec = ntohl (stub->timebuf[0]); + child->tv.tv_usec = ntohl (stub->timebuf[1]); + +- if (priv->iamscrubber) +- ret = br_enact_scrubber (this, child); +- else +- ret = br_enact_signer (this, child, stub); +- +- if (!ret) +- gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CONNECTED_TO_BRICK, +- "Connected to brick %s..", child->brick_path); ++ ret = br_child_enaction (this, child, stub); + + free_dict: + dict_unref (xattr); + wipeloc: + loc_wipe (&loc); + out: ++ if (ret) ++ br_set_child_state (child, BR_CHILD_STATE_CONNFAILED); + return ret; + } + +@@ -1290,7 +1315,8 @@ br_handle_events (void *arg) + int32_t ret = 0; + xlator_t *this = NULL; + br_private_t *priv = NULL; +- br_child_t *child = NULL; ++ br_child_t *child = NULL; ++ struct br_child_event *childev = NULL; + + this = arg; + priv = this->private; +@@ -1309,17 +1335,20 @@ br_handle_events (void *arg) + while (list_empty (&priv->bricks)) + pthread_cond_wait (&priv->cond, &priv->lock); + +- child = list_first_entry +- (&priv->bricks, br_child_t, list); +- list_del_init (&child->list); ++ childev = list_first_entry ++ (&priv->bricks, struct br_child_event, list); ++ list_del_init (&childev->list); + } + pthread_mutex_unlock (&priv->lock); + +- ret = br_brick_connect (this, child); ++ child = childev->child; ++ ret = childev->call (this, child); + if (ret) + gf_msg (this->name, GF_LOG_ERROR, 0, +- BRB_MSG_SUBVOL_CONNECT_FAILED, "failed to " +- "connect to subvolume %s", child->xl->name); ++ BRB_MSG_SUBVOL_CONNECT_FAILED, ++ "callback handler for subvolume [%s] failed", ++ child->xl->name); ++ GF_FREE (childev); + } + + return NULL; +@@ -1344,6 +1373,29 @@ mem_acct_init (xlator_t *this) + return ret; + } + ++static void ++_br_qchild_event (xlator_t *this, br_child_t *child, br_child_handler *call) ++{ ++ br_private_t *priv = NULL; ++ struct br_child_event *childev = NULL; ++ ++ priv = this->private; ++ ++ childev = GF_CALLOC (1, sizeof (*childev), gf_br_mt_br_child_event_t); ++ if (!childev) { ++ gf_log (this->name, GF_LOG_ERROR, "Event unhandled for " ++ "child.. [Brick: %s]", child->xl->name); ++ return; ++ } ++ ++ INIT_LIST_HEAD (&childev->list); ++ childev->this = this; ++ childev->child = child; ++ childev->call = call; ++ ++ list_add_tail (&childev->list, &priv->bricks); ++} ++ + int + notify (xlator_t *this, int32_t event, void *data, ...) + { +@@ -1373,14 +1425,14 @@ notify (xlator_t *this, int32_t event, void *data, ...) + child = &priv->children[idx]; + if (child->child_up == 1) + goto unblock; ++ priv->up_children++; + + child->child_up = 1; + child->xl = subvol; +- child->table = inode_table_new (4096, subvol); ++ if (!child->table) ++ child->table = inode_table_new (4096, subvol); + +- priv->up_children++; +- +- list_add_tail (&child->list, &priv->bricks); ++ _br_qchild_event (this, child, br_brick_connect); + pthread_cond_signal (&priv->cond); + } + unblock: +@@ -1410,6 +1462,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + if (priv->up_children == 0) + default_notify (this, event, data); + break; ++ + default: + default_notify (this, event, data); + } +@@ -1563,59 +1616,94 @@ br_signer_init (xlator_t *this, br_private_t *priv) + + } + +-int32_t +-init (xlator_t *this) ++static void ++br_free_children (xlator_t *this, br_private_t *priv, int count) + { +- int i = 0; +- int32_t ret = -1; +- br_private_t *priv = NULL; +- xlator_list_t *trav = NULL; ++ br_child_t *child = NULL; + +- if (!this->children) { +- gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_NO_CHILD, +- "FATAL: no children"); +- goto out; ++ for (--count; count >= 0; count--) { ++ child = &priv->children[count]; ++ mem_pool_destroy (child->timer_pool); ++ LOCK_DESTROY (&child->lock); + } + +- priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t); +- if (!priv) { +- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, +- "failed to allocate memory (->priv)"); +- goto out; +- } ++ GF_FREE (priv->children); ++ priv->children = NULL; ++} + +- GF_OPTION_INIT ("scrubber", priv->iamscrubber, bool, out); ++static int ++br_init_children (xlator_t *this, br_private_t *priv) ++{ ++ int i = 0; ++ br_child_t *child = NULL; ++ xlator_list_t *trav = NULL; + + priv->child_count = xlator_subvolume_count (this); + priv->children = GF_CALLOC (priv->child_count, sizeof (*priv->children), + gf_br_mt_br_child_t); + if (!priv->children) +- goto free_priv; ++ goto err; + + trav = this->children; + while (trav) { +- priv->children[i].this = this; +- priv->children[i].xl = trav->xlator; +- +- priv->children[i].timer_pool = +- mem_pool_new (struct gf_tw_timer_list, 4096); +- if (!priv->children[i].timer_pool) { +- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +- BRB_MSG_NO_MEMORY, "failed to allocate mem-pool" +- " for timer"); ++ child = &priv->children[i]; ++ ++ LOCK_INIT (&child->lock); ++ br_set_child_state (child, BR_CHILD_STATE_DISCONNECTED); ++ ++ child->this = this; ++ child->xl = trav->xlator; ++ ++ child->timer_pool = mem_pool_new ++ (struct gf_tw_timer_list, 4096); ++ if (!child->timer_pool) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "failed to allocate mem-pool for timer"); + errno = ENOMEM; +- goto free_children; ++ goto freechild; + } + ++ INIT_LIST_HEAD (&child->list); ++ + i++; + trav = trav->next; + } + ++ return 0; ++ ++ freechild: ++ br_free_children (this, priv, i); ++ err: ++ return -1; ++} ++ ++int32_t ++init (xlator_t *this) ++{ ++ int32_t ret = -1; ++ br_private_t *priv = NULL; ++ ++ if (!this->children) { ++ gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); ++ goto out; ++ } ++ ++ priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t); ++ if (!priv) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "failed to allocate memory (->priv)"); ++ goto out; ++ } ++ ++ GF_OPTION_INIT ("scrubber", priv->iamscrubber, bool, out); ++ ++ ret = br_init_children (this, priv); ++ if (ret) ++ goto free_priv; ++ + pthread_mutex_init (&priv->lock, NULL); + pthread_cond_init (&priv->cond, NULL); + +- for (i = 0; i < priv->child_count; i++) +- INIT_LIST_HEAD (&priv->children[i].list); + INIT_LIST_HEAD (&priv->bricks); + INIT_LIST_HEAD (&priv->signing); + +@@ -1624,7 +1712,7 @@ init (xlator_t *this) + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_TIMER_WHEEL_UNAVAILABLE, + "global timer wheel unavailable"); +- goto cleanup_mutex; ++ goto cleanup; + } + + this->private = priv; +@@ -1640,7 +1728,7 @@ init (xlator_t *this) + } + + if (ret) +- goto cleanup_mutex; ++ goto cleanup; + + ret = gf_thread_create (&priv->thread, NULL, br_handle_events, this); + if (ret != 0) { +@@ -1656,16 +1744,12 @@ init (xlator_t *this) + return 0; + } + +- cleanup_mutex: ++ cleanup: + (void) pthread_cond_destroy (&priv->cond); + (void) pthread_mutex_destroy (&priv->lock); +- free_children: +- for (i = 0; i < priv->child_count; i++) { +- if (priv->children[i].timer_pool) +- mem_pool_destroy (priv->children[i].timer_pool); +- } + +- GF_FREE (priv->children); ++ br_free_children (this, priv, priv->child_count); ++ + free_priv: + GF_FREE (priv); + out: +@@ -1683,7 +1767,7 @@ fini (xlator_t *this) + + if (!priv->iamscrubber) + br_fini_signer (this, priv); +- br_free_children (this); ++ br_free_children (this, priv, priv->child_count); + + this->private = NULL; + GF_FREE (priv); +@@ -1691,64 +1775,96 @@ fini (xlator_t *this) + return; + } + +-int +-reconfigure (xlator_t *this, dict_t *options) ++static void ++br_reconfigure_child (xlator_t *this, ++ br_child_t *child, struct br_scrubber *fsscrub) + { +- int i = 0; +- int32_t ret = -1; +- br_child_t *child = NULL; +- br_private_t *priv = NULL; +- struct br_scanfs *fsscan = NULL; ++ int32_t ret = 0; ++ struct br_scanfs *fsscan = &child->fsscan; ++ ++ ret = br_fsscan_reschedule (this, child, fsscan, fsscrub, _gf_true); ++ if (ret) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Could not reschedule scrubber for brick: %s. " ++ "Scubbing will continue according to old frequency.", ++ child->brick_path); ++ } ++} ++ ++static int ++br_reconfigure_scrubber (xlator_t *this, dict_t *options) ++{ ++ int i = 0; ++ int32_t ret = -1; ++ br_child_t *child = NULL; ++ br_private_t *priv = NULL; + struct br_scrubber *fsscrub = NULL; + + priv = this->private; ++ fsscrub = &priv->fsscrub; + +- if (!priv->iamscrubber) { +- ret = br_signer_handle_options (this, priv, options); +- if (ret) +- goto err; +- return 0; ++ pthread_mutex_lock (&priv->lock); ++ { ++ ret = br_scrubber_handle_options (this, priv, options); + } ++ pthread_mutex_unlock (&priv->lock); + +- ret = br_scrubber_handle_options (this, priv, options); + if (ret) + goto err; + +- fsscrub = &priv->fsscrub; +- + /* reschedule all _up_ subvolume(s) */ +- pthread_mutex_lock (&priv->lock); +- { +- for (; i < priv->child_count; i++) { +- child = &priv->children[i]; +- if (!child->child_up) { +- gf_msg (this->name, GF_LOG_INFO, 0, +- BRB_MSG_BRICK_INFO, "Brick %s is " +- "offline, skipping rescheduling (scrub" +- " would auto- schedule when brick is " +- "back online).", child->brick_path); +- continue; +- } ++ for (; i < priv->child_count; i++) { ++ child = &priv->children[i]; + +- fsscan = &child->fsscan; +- ret = br_fsscan_reschedule (this, child, +- fsscan, fsscrub, _gf_true); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, +- "Could not reschedule scrubber for " +- "brick: %s. Scubbing will continue " +- "according to old frequency.", +- child->brick_path); ++ LOCK (&child->lock); ++ { ++ if (_br_child_failed_conn (child)) { ++ gf_log (this->name, GF_LOG_INFO, ++ "Scrubber for brick [%s] failed " ++ "initialization, rescheduling is " ++ "skipped", child->brick_path); ++ goto unblock; + } ++ ++ if (_br_is_child_connected (child)) ++ br_reconfigure_child (this, child, fsscrub); ++ ++ /** ++ * for the rest.. either the child is in initialization ++ * phase or is disconnected. either way, updated values ++ * would be reflected on successful connection. ++ */ + } ++ unblock: ++ UNLOCK (&child->lock); + } +- pthread_mutex_unlock (&priv->lock); +- +- return 0; + + err: +- return -1; ++ return ret; ++} ++ ++static int ++br_reconfigure_signer (xlator_t *this, dict_t *options) ++{ ++ br_private_t *priv = this->private; ++ ++ return br_signer_handle_options (this, priv, options); ++} ++ ++int ++reconfigure (xlator_t *this, dict_t *options) ++{ ++ int ret = 0; ++ br_private_t *priv = NULL; ++ ++ priv = this->private; ++ ++ if (priv->iamscrubber) ++ ret = br_reconfigure_scrubber (this, options); ++ else ++ ret = br_reconfigure_signer (this, options); ++ ++ return ret; + } + + struct xlator_fops fops; +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h +index 562f17e..b8d9e3b 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.h +@@ -76,7 +76,18 @@ struct br_scanfs { + struct gf_tw_timer_list *timer; + }; + ++/* just need three states to track child status */ ++typedef enum br_child_state { ++ BR_CHILD_STATE_CONNECTED = 1, ++ BR_CHILD_STATE_INITIALIZING, ++ BR_CHILD_STATE_CONNFAILED, ++ BR_CHILD_STATE_DISCONNECTED, ++} br_child_state_t; ++ + struct br_child { ++ gf_lock_t lock; ++ br_child_state_t c_state; ++ + char child_up; /* Indicates whether this child is + up or not */ + xlator_t *xl; /* client xlator corresponding to +@@ -140,8 +151,8 @@ typedef struct br_obj_n_workers br_obj_n_workers_t; + struct br_private { + pthread_mutex_t lock; + +- struct list_head bricks; /* list of bricks from which CHILD_UP +- has been received */ ++ struct list_head bricks; /* list of bricks from which enents ++ have been received */ + + struct list_head signing; + +@@ -207,5 +218,22 @@ br_prepare_loc (xlator_t *, br_child_t *, loc_t *, gf_dirent_t *, loc_t *); + gf_boolean_t + bitd_is_bad_file (xlator_t *, br_child_t *, loc_t *, fd_t *); + ++static inline void ++_br_set_child_state (br_child_t *child, br_child_state_t state) ++{ ++ child->c_state = state; ++} ++ ++static inline int ++_br_is_child_connected (br_child_t *child) ++{ ++ return (child->c_state == BR_CHILD_STATE_CONNECTED); ++} ++ ++static inline int ++_br_child_failed_conn (br_child_t *child) ++{ ++ return (child->c_state == BR_CHILD_STATE_CONNFAILED); ++} + + #endif /* __BIT_ROT_H__ */ +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h +index fbb69ce..f70fafb 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h +@@ -31,6 +31,7 @@ enum br_mem_types { + gf_br_stub_mt_br_stub_fd_t, + gf_br_stub_mt_br_scanner_freq_t, + gf_br_stub_mt_sigstub_t, ++ gf_br_mt_br_child_event_t, + gf_br_stub_mt_end, + }; + +-- +1.7.1 + diff --git a/SOURCES/0159-features-bitrot-cleanup-v2.patch b/SOURCES/0159-features-bitrot-cleanup-v2.patch new file mode 100644 index 0000000..777b43c --- /dev/null +++ b/SOURCES/0159-features-bitrot-cleanup-v2.patch @@ -0,0 +1,568 @@ +From 11dd368eae316c3cb9a1e82e7b7213d0ee4224c6 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Thu, 4 Jun 2015 08:50:48 +0530 +Subject: [PATCH 159/190] features/bitrot: cleanup, v2 + + Backport of http://review.gluster.org/11148 + +This patch uses "cleanup, v1" infrastrcuture to cleanup scrubber +(data structures, threads, timers, etc..) on brick disconnection. +Signer is not cleaned up yet: probably would be done as part of +another patch. + +Change-Id: I78a92b8a7f02b2f39078aa9a5a6b101fc499fd70 +BUG: 1232309 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51744 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + contrib/timer-wheel/timer-wheel.c | 10 +- + contrib/timer-wheel/timer-wheel.h | 2 +- + libglusterfs/src/common-utils.c | 11 ++ + libglusterfs/src/common-utils.h | 3 + + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 27 ++- + xlators/features/bit-rot/src/bitd/bit-rot.c | 186 +++++++++++++++++--- + xlators/features/bit-rot/src/bitd/bit-rot.h | 12 +- + xlators/features/changelog/src/changelog-helpers.c | 30 +--- + 8 files changed, 214 insertions(+), 67 deletions(-) + +diff --git a/contrib/timer-wheel/timer-wheel.c b/contrib/timer-wheel/timer-wheel.c +index d9b2ccd..013c0f2 100644 +--- a/contrib/timer-wheel/timer-wheel.c ++++ b/contrib/timer-wheel/timer-wheel.c +@@ -218,14 +218,20 @@ void gf_tw_add_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) + /** + * Remove a timer from the timer wheel + */ +-void gf_tw_del_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) ++int gf_tw_del_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) + { ++ int ret = 0; ++ + pthread_spin_lock (&base->lock); + { +- if (timer_pending (timer)) ++ if (timer_pending (timer)) { ++ ret = 1; + __gf_tw_detach_timer (timer); ++ } + } + pthread_spin_unlock (&base->lock); ++ ++ return ret; + } + + int gf_tw_mod_timer_pending (struct tvec_base *base, +diff --git a/contrib/timer-wheel/timer-wheel.h b/contrib/timer-wheel/timer-wheel.h +index c52f2fc..faa941a 100644 +--- a/contrib/timer-wheel/timer-wheel.h ++++ b/contrib/timer-wheel/timer-wheel.h +@@ -66,7 +66,7 @@ struct gf_tw_timer_list { + struct tvec_base *gf_tw_init_timers (); + int gf_tw_cleanup_timers (struct tvec_base *); + void gf_tw_add_timer (struct tvec_base *, struct gf_tw_timer_list *); +-void gf_tw_del_timer (struct tvec_base *, struct gf_tw_timer_list *); ++int gf_tw_del_timer (struct tvec_base *, struct gf_tw_timer_list *); + + int gf_tw_mod_timer_pending (struct tvec_base *, + struct gf_tw_timer_list *, unsigned long); +diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c +index be5d897..cbc5230 100644 +--- a/libglusterfs/src/common-utils.c ++++ b/libglusterfs/src/common-utils.c +@@ -4026,3 +4026,14 @@ out: + return ret; + } + ++void ++_mask_cancellation (void) ++{ ++ (void) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); ++} ++ ++void ++_unmask_cancellation (void) ++{ ++ (void) pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); ++} +diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h +index ad87559..a64917f 100644 +--- a/libglusterfs/src/common-utils.h ++++ b/libglusterfs/src/common-utils.h +@@ -762,4 +762,7 @@ gf_nread (int fd, void *buf, size_t count); + ssize_t + gf_nwrite (int fd, const void *buf, size_t count); + ++void _mask_cancellation (void); ++void _unmask_cancellation (void); ++ + #endif /* _COMMON_UTILS_H */ +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index 45499de..d6ee413 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -393,6 +393,14 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) + } + + static void ++_br_lock_cleaner (void *arg) ++{ ++ pthread_mutex_t *mutex = arg; ++ ++ pthread_mutex_unlock (mutex); ++} ++ ++static void + wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan) + { + br_private_t *priv = NULL; +@@ -401,8 +409,10 @@ wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan) + priv = this->private; + fsscrub = &priv->fsscrub; + ++ pthread_cleanup_push (_br_lock_cleaner, &fsscan->waitlock); + pthread_mutex_lock (&fsscan->waitlock); + { ++ pthread_cleanup_push (_br_lock_cleaner, &fsscrub->mutex); + pthread_mutex_lock (&fsscrub->mutex); + { + list_replace_init (&fsscan->queued, &fsscan->ready); +@@ -411,12 +421,14 @@ wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan) + pthread_cond_broadcast (&fsscrub->cond); + } + pthread_mutex_unlock (&fsscrub->mutex); ++ pthread_cleanup_pop (0); + + while (fsscan->entries != 0) + pthread_cond_wait + (&fsscan->waitcond, &fsscan->waitlock); + } + pthread_mutex_unlock (&fsscan->waitlock); ++ pthread_cleanup_pop (0); + } + + static inline void +@@ -465,6 +477,8 @@ br_fsscanner_handle_entry (xlator_t *subvol, + this = child->this; + fsscan = &child->fsscan; + ++ _mask_cancellation (); ++ + fsentry = GF_CALLOC (1, sizeof (*fsentry), gf_br_mt_br_fsscan_entry_t); + if (!fsentry) + goto error_return; +@@ -499,6 +513,8 @@ br_fsscanner_handle_entry (xlator_t *subvol, + } + UNLOCK (&fsscan->entrylock); + ++ _unmask_cancellation (); ++ + if (scrub) + wait_for_scrubbing (this, fsscan); + +@@ -535,6 +551,7 @@ br_fsscanner_log_time (xlator_t *this, br_child_t *child, const char *sfx) + static void + br_fsscanner_wait_until_kicked (struct br_scanfs *fsscan) + { ++ pthread_cleanup_push (_br_lock_cleaner, &fsscan->wakelock); + pthread_mutex_lock (&fsscan->wakelock); + { + while (!fsscan->kick) +@@ -543,6 +560,7 @@ br_fsscanner_wait_until_kicked (struct br_scanfs *fsscan) + fsscan->kick = _gf_false; + } + pthread_mutex_unlock (&fsscan->wakelock); ++ pthread_cleanup_pop (0); + } + + void * +@@ -778,13 +796,6 @@ br_scrubber_calc_scale (xlator_t *this, + + } + +-static void +-br_scrubber_cleanup_handler (void *arg) +-{ +- struct br_scrubber *fsscrub = arg; +- pthread_mutex_unlock (&fsscrub->mutex); +-} +- + static inline br_child_t * + _br_scrubber_get_next_child (struct br_scrubber *fsscrub) + { +@@ -844,7 +855,7 @@ static void + br_scrubber_pick_entry (struct br_scrubber *fsscrub, + struct br_fsscan_entry **fsentry) + { +- pthread_cleanup_push (br_scrubber_cleanup_handler, fsscrub); ++ pthread_cleanup_push (_br_lock_cleaner, &fsscrub->mutex); + + pthread_mutex_lock (&fsscrub->mutex); + { +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index b855cd7..f2cd1d8 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -1103,7 +1103,7 @@ br_set_child_state (br_child_t *child, br_child_state_t state) + * Also, we register to the changelog library to subscribe for event + * notifications. + */ +-static inline int32_t ++static int32_t + br_enact_signer (xlator_t *this, br_child_t *child, br_stub_init_t *stub) + { + int32_t ret = 0; +@@ -1145,32 +1145,16 @@ br_enact_signer (xlator_t *this, br_child_t *child, br_stub_init_t *stub) + return -1; + } + +-static inline int32_t +-br_enact_scrubber (xlator_t *this, br_child_t *child) ++static int32_t ++br_launch_scrubber (xlator_t *this, br_child_t *child, ++ struct br_scanfs *fsscan, struct br_scrubber *fsscrub) + { +- int32_t ret = 0; ++ int32_t ret = -1; + br_private_t *priv = NULL; +- struct br_scanfs *fsscan = NULL; +- struct br_scrubber *fsscrub = NULL; + + priv = this->private; + +- fsscan = &child->fsscan; +- fsscrub = &priv->fsscrub; +- +- LOCK_INIT (&fsscan->entrylock); +- pthread_mutex_init (&fsscan->waitlock, NULL); +- pthread_cond_init (&fsscan->waitcond, NULL); +- +- fsscan->entries = 0; +- INIT_LIST_HEAD (&fsscan->queued); +- INIT_LIST_HEAD (&fsscan->ready); +- +- /* init scheduler related variables */ + fsscan->kick = _gf_false; +- pthread_mutex_init (&fsscan->wakelock, NULL); +- pthread_cond_init (&fsscan->wakecond, NULL); +- + ret = gf_thread_create (&child->thread, NULL, br_fsscanner, child); + if (ret != 0) { + gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_SPAWN_FAILED, +@@ -1186,7 +1170,7 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + } + pthread_mutex_unlock (&priv->lock); + if (ret) +- goto error_return; ++ goto cleanup_thread; + + /** + * Everything has been setup.. add this subvolume to scrubbers +@@ -1201,6 +1185,50 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) + + return 0; + ++ cleanup_thread: ++ (void) gf_thread_cleanup_xint (child->thread); ++ error_return: ++ return -1; ++} ++ ++static int32_t ++br_enact_scrubber (xlator_t *this, br_child_t *child) ++{ ++ int32_t ret = 0; ++ br_private_t *priv = NULL; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; ++ ++ priv = this->private; ++ ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; ++ ++ /** ++ * if this child already witnesses a successfull connection earlier ++ * there's no need to initialize mutexes, condvars, etc.. ++ */ ++ if (_br_child_witnessed_connection (child)) ++ return br_launch_scrubber (this, child, fsscan, fsscrub); ++ ++ LOCK_INIT (&fsscan->entrylock); ++ pthread_mutex_init (&fsscan->waitlock, NULL); ++ pthread_cond_init (&fsscan->waitcond, NULL); ++ ++ fsscan->entries = 0; ++ INIT_LIST_HEAD (&fsscan->queued); ++ INIT_LIST_HEAD (&fsscan->ready); ++ ++ /* init scheduler related variables */ ++ pthread_mutex_init (&fsscan->wakelock, NULL); ++ pthread_cond_init (&fsscan->wakecond, NULL); ++ ++ ret = br_launch_scrubber (this, child, fsscan, fsscrub); ++ if (ret) ++ goto error_return; ++ ++ return 0; ++ + error_return: + LOCK_DESTROY (&fsscan->entrylock); + pthread_mutex_destroy (&fsscan->waitlock); +@@ -1223,6 +1251,7 @@ br_child_enaction (xlator_t *this, br_child_t *child, br_stub_init_t *stub) + ret = br_enact_signer (this, child, stub); + + if (!ret) { ++ child->witnessed = 1; + _br_set_child_state (child, BR_CHILD_STATE_CONNECTED); + gf_log (this->name, GF_LOG_INFO, + "Connected to brick %s..", child->brick_path); +@@ -1304,6 +1333,100 @@ br_brick_connect (xlator_t *this, br_child_t *child) + return ret; + } + ++/* TODO: cleanup signer */ ++static int32_t ++br_cleanup_signer (xlator_t *this, br_child_t *child) ++{ ++ return 0; ++} ++ ++static int32_t ++br_cleanup_scrubber (xlator_t *this, br_child_t *child) ++{ ++ int32_t ret = 0; ++ br_private_t *priv = NULL; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; ++ ++ priv = this->private; ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; ++ ++ /** ++ * 0x0: child (brick) goes out of rotation ++ * ++ * This is fully safe w.r.t. entries for this child being actively ++ * scrubbed. Each of the scrubber thread(s) would finish scrubbing ++ * the entry (probably failing due to disconnection) and either ++ * putting the entry back into the queue or continuing further. ++ * Either way, pending entries for this child's queue need not be ++ * drained; entries just sit there in the queued/ready list to be ++ * consumed later upon re-connection. ++ */ ++ pthread_mutex_lock (&fsscrub->mutex); ++ { ++ list_del_init (&child->list); ++ } ++ pthread_mutex_unlock (&fsscrub->mutex); ++ ++ /** ++ * 0x1: cleanup scanner thread ++ * ++ * The pending timer needs to be removed _after_ cleaning up the ++ * filesystem scanner (scheduling the next scrub time is not a ++ * cancellation point). ++ */ ++ ret = gf_thread_cleanup_xint (child->thread); ++ if (ret) ++ gf_log (this->name, GF_LOG_ERROR, ++ "Error cleaning up scanner thread"); ++ ++ /** ++ * 0x2: free()up resources ++ */ ++ if (fsscan->timer) { ++ (void) gf_tw_del_timer (priv->timer_wheel, fsscan->timer); ++ ++ GF_FREE (fsscan->timer); ++ fsscan->timer = NULL; ++ } ++ ++ gf_log (this->name, GF_LOG_INFO, ++ "Cleaned up scrubber for brick [%s]", child->brick_path); ++ ++ return 0; ++} ++ ++/** ++ * OK.. this child has made it's mind to go down the drain. So, ++ * let's clean up what it touched. (NOTE: there's no need to clean ++ * the inode table, it's just reused taking care of stale inodes) ++ */ ++int32_t ++br_brick_disconnect (xlator_t *this, br_child_t *child) ++{ ++ int32_t ret = 0; ++ br_private_t *priv = this->private; ++ ++ LOCK (&child->lock); ++ { ++ if (!_br_is_child_connected (child)) ++ goto unblock; ++ ++ /* child is on death row.. */ ++ _br_set_child_state (child, BR_CHILD_STATE_DISCONNECTED); ++ ++ if (priv->iamscrubber) ++ ret = br_cleanup_scrubber (this, child); ++ else ++ ret = br_cleanup_signer (this, child); ++ } ++ unblock: ++ UNLOCK (&child->lock); ++ ++ return ret; ++} ++ + /** + * This function is executed in a separate thread. The thread gets the + * brick from where CHILD_UP has received from the queue and gets the +@@ -1424,7 +1547,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + { + child = &priv->children[idx]; + if (child->child_up == 1) +- goto unblock; ++ goto unblock_0; + priv->up_children++; + + child->child_up = 1; +@@ -1435,7 +1558,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + _br_qchild_event (this, child, br_brick_connect); + pthread_cond_signal (&priv->cond); + } +- unblock: ++ unblock_0: + pthread_mutex_unlock (&priv->lock); + + if (priv->up_children == priv->child_count) +@@ -1452,11 +1575,17 @@ notify (xlator_t *this, int32_t event, void *data, ...) + + pthread_mutex_lock (&priv->lock); + { +- if (priv->children[idx].child_up == 1) { +- priv->children[idx].child_up = 0; +- priv->up_children--; +- } ++ child = &priv->children[idx]; ++ if (child->child_up == 0) ++ goto unblock_1; ++ ++ child->child_up = 0; ++ priv->up_children--; ++ ++ _br_qchild_event (this, child, br_brick_disconnect); ++ pthread_cond_signal (&priv->cond); + } ++ unblock_1: + pthread_mutex_unlock (&priv->lock); + + if (priv->up_children == 0) +@@ -1649,6 +1778,7 @@ br_init_children (xlator_t *this, br_private_t *priv) + child = &priv->children[i]; + + LOCK_INIT (&child->lock); ++ child->witnessed = 0; + br_set_child_state (child, BR_CHILD_STATE_DISCONNECTED); + + child->this = this; +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h +index b8d9e3b..9a55773 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.h +@@ -85,8 +85,10 @@ typedef enum br_child_state { + } br_child_state_t; + + struct br_child { +- gf_lock_t lock; +- br_child_state_t c_state; ++ gf_lock_t lock; /* protects child state */ ++ char witnessed; /* witnessed at least one succesfull ++ connection */ ++ br_child_state_t c_state; /* current state of this child */ + + char child_up; /* Indicates whether this child is + up or not */ +@@ -236,4 +238,10 @@ _br_child_failed_conn (br_child_t *child) + return (child->c_state == BR_CHILD_STATE_CONNFAILED); + } + ++static inline int ++_br_child_witnessed_connection (br_child_t *child) ++{ ++ return (child->witnessed == 1); ++} ++ + #endif /* __BIT_ROT_H__ */ +diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c +index 2c0a645..144bf54 100644 +--- a/xlators/features/changelog/src/changelog-helpers.c ++++ b/xlators/features/changelog/src/changelog-helpers.c +@@ -27,28 +27,6 @@ + #include "changelog-rpc-common.h" + #include + +-static inline void +-__mask_cancellation (xlator_t *this) +-{ +- int ret = 0; +- +- ret = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); +- if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "failed to disable thread cancellation"); +-} +- +-static inline void +-__unmask_cancellation (xlator_t *this) +-{ +- int ret = 0; +- +- ret = pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); +- if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "failed to enable thread cancellation"); +-} +- + static void + changelog_cleanup_free_mutex (void *arg_mutex) + { +@@ -1338,7 +1316,7 @@ changelog_rollover (void *data) + continue; + } + +- __mask_cancellation (this); ++ _mask_cancellation (); + + LOCK (&priv->lock); + { +@@ -1348,7 +1326,7 @@ changelog_rollover (void *data) + } + UNLOCK (&priv->lock); + +- __unmask_cancellation (this); ++ _unmask_cancellation (); + } + + return NULL; +@@ -1376,14 +1354,14 @@ changelog_fsync_thread (void *data) + if (ret) + continue; + +- __mask_cancellation (this); ++ _mask_cancellation (); + + ret = changelog_inject_single_event (this, priv, &cld); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "failed to inject fsync event"); + +- __unmask_cancellation (this); ++ _unmask_cancellation (); + } + + return NULL; +-- +1.7.1 + diff --git a/SOURCES/0160-features-bitrot-handle-scrub-states-via-state-machin.patch b/SOURCES/0160-features-bitrot-handle-scrub-states-via-state-machin.patch new file mode 100644 index 0000000..179117f --- /dev/null +++ b/SOURCES/0160-features-bitrot-handle-scrub-states-via-state-machin.patch @@ -0,0 +1,702 @@ +From 4b38c3ac3178769ec593cbe0906ffa48d67587cb Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Tue, 9 Jun 2015 10:02:11 +0530 +Subject: [PATCH 160/190] features/bitrot: handle scrub states via state machine + + Backport of http://review.gluster.org/11149 + +A bunch of command line options for scrubber tempted the use of +state machine to track current state of scrubber under various +circumstances where the options could be in effect. + +Change-Id: Id614bb2e6af30a90d2391ea31ae0a3edeb4e0d69 +BUG: 1232309 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51745 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/Makefile.am | 4 +- + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 181 +++++++++++++++++---- + xlators/features/bit-rot/src/bitd/bit-rot-scrub.h | 9 +- + xlators/features/bit-rot/src/bitd/bit-rot-ssm.c | 91 +++++++++++ + xlators/features/bit-rot/src/bitd/bit-rot-ssm.h | 36 ++++ + xlators/features/bit-rot/src/bitd/bit-rot.c | 40 +++-- + xlators/features/bit-rot/src/bitd/bit-rot.h | 22 +++ + 7 files changed, 331 insertions(+), 52 deletions(-) + create mode 100644 xlators/features/bit-rot/src/bitd/bit-rot-ssm.c + create mode 100644 xlators/features/bit-rot/src/bitd/bit-rot-ssm.h + +diff --git a/xlators/features/bit-rot/src/bitd/Makefile.am b/xlators/features/bit-rot/src/bitd/Makefile.am +index fd42ebe..154cdfb 100644 +--- a/xlators/features/bit-rot/src/bitd/Makefile.am ++++ b/xlators/features/bit-rot/src/bitd/Makefile.am +@@ -9,11 +9,11 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(CONTRIBDIR)/timer-wheel \ + -I$(top_srcdir)/xlators/features/bit-rot/src/stub + +-bit_rot_la_SOURCES = bit-rot.c bit-rot-scrub.c bit-rot-tbf.c ++bit_rot_la_SOURCES = bit-rot.c bit-rot-scrub.c bit-rot-tbf.c bit-rot-ssm.c + bit_rot_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + $(top_builddir)/xlators/features/changelog/lib/src/libgfchangelog.la + +-noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h bit-rot-bitd-messages.h ++noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h bit-rot-bitd-messages.h bit-rot-ssm.h + + AM_CFLAGS = -Wall $(GF_CFLAGS) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index d6ee413..af31a3c 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -528,6 +528,33 @@ br_fsscanner_handle_entry (xlator_t *subvol, + return -1; + } + ++int32_t ++br_fsscan_deactivate (xlator_t *this, br_child_t *child) ++{ ++ int ret = 0; ++ br_private_t *priv = NULL; ++ br_scrub_state_t nstate = 0; ++ struct br_scanfs *fsscan = NULL; ++ ++ priv = this->private; ++ fsscan = &child->fsscan; ++ ++ ret = gf_tw_del_timer (priv->timer_wheel, fsscan->timer); ++ if (ret == 0) { ++ nstate = BR_SCRUB_STATE_STALLED; ++ gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active " ++ "scrubbing. Pausing scrub..", child->brick_path); ++ } else { ++ nstate = BR_SCRUB_STATE_PAUSED; ++ gf_log (this->name, GF_LOG_INFO, ++ "Scrubber paused [Brick: %s]", child->brick_path); ++ } ++ ++ _br_child_set_scrub_state (child, nstate); ++ ++ return 0; ++} ++ + static inline void + br_fsscanner_log_time (xlator_t *this, br_child_t *child, const char *sfx) + { +@@ -563,22 +590,51 @@ br_fsscanner_wait_until_kicked (struct br_scanfs *fsscan) + pthread_cleanup_pop (0); + } + ++static inline void ++br_fsscanner_entry_control (xlator_t *this, br_child_t *child) ++{ ++ struct br_scanfs *fsscan = &child->fsscan; ++ ++ LOCK (&child->lock); ++ { ++ if (fsscan->state == BR_SCRUB_STATE_PENDING) ++ fsscan->state = BR_SCRUB_STATE_ACTIVE; ++ br_fsscanner_log_time (this, child, "started"); ++ } ++ UNLOCK (&child->lock); ++} ++ ++static inline void ++br_fsscanner_exit_control (xlator_t *this, br_child_t *child) ++{ ++ struct br_scanfs *fsscan = &child->fsscan; ++ ++ LOCK (&child->lock); ++ { ++ fsscan->over = _gf_true; ++ br_fsscanner_log_time (this, child, "finished"); ++ ++ if (fsscan->state == BR_SCRUB_STATE_ACTIVE) { ++ (void) br_fsscan_activate (this, child); ++ } else { ++ gf_log (this->name, GF_LOG_INFO, "Brick [%s] waiting " ++ "to get rescheduled..", child->brick_path); ++ } ++ } ++ UNLOCK (&child->lock); ++} ++ + void * + br_fsscanner (void *arg) + { + loc_t loc = {0,}; + br_child_t *child = NULL; + xlator_t *this = NULL; +- br_private_t *priv = NULL; + struct br_scanfs *fsscan = NULL; +- struct br_scrubber *fsscrub = NULL; + + child = arg; + this = child->this; +- priv = this->private; +- + fsscan = &child->fsscan; +- fsscrub = &priv->fsscrub; + + THIS = this; + loc.inode = child->table->root; +@@ -586,8 +642,8 @@ br_fsscanner (void *arg) + while (1) { + br_fsscanner_wait_until_kicked (fsscan); + { +- /* log start time */ +- br_fsscanner_log_time (this, child, "started"); ++ /* precursor for scrub */ ++ br_fsscanner_entry_control (this, child); + + /* scrub */ + (void) syncop_ftw (child->xl, +@@ -596,15 +652,21 @@ br_fsscanner (void *arg) + if (!list_empty (&fsscan->queued)) + wait_for_scrubbing (this, fsscan); + +- /* log finish time */ +- br_fsscanner_log_time (this, child, "finished"); ++ /* scrub exit criteria */ ++ br_fsscanner_exit_control (this, child); + } +- br_fsscan_reschedule (this, child, fsscan, fsscrub, _gf_false); + } + + return NULL; + } + ++/** ++ * Keep this routine extremely simple and do not ever try to acquire ++ * child->lock here: it may lead to deadlock. Scrubber state is ++ * modified in br_fsscanner(). An intermediate state change to pause ++ * changes the scrub state to the _correct_ state by identifying a ++ * non-pending timer. ++ */ + void + br_kickstart_scanner (struct gf_tw_timer_list *timer, + void *data, unsigned long calltime) +@@ -666,28 +728,38 @@ br_fsscan_calculate_timeout (uint32_t boot, uint32_t now, scrub_freq_t freq) + break; + case BR_FSSCRUB_FREQ_MONTHLY: + timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_MONTHLY); ++ break; ++ default: ++ timo = 0; + } + + return timo; + } + + int32_t +-br_fsscan_schedule (xlator_t *this, br_child_t *child, +- struct br_scanfs *fsscan, struct br_scrubber *fsscrub) ++br_fsscan_schedule (xlator_t *this, br_child_t *child) + { + uint32_t timo = 0; + br_private_t *priv = NULL; + struct timeval tv = {0,}; + char timestr[1024] = {0,}; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; + struct gf_tw_timer_list *timer = NULL; + + priv = this->private; ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; + + (void) gettimeofday (&tv, NULL); + fsscan->boot = tv.tv_sec; + + timo = br_fsscan_calculate_timeout (fsscan->boot, + fsscan->boot, fsscrub->frequency); ++ if (timo == 0) { ++ gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ goto error_return; ++ } + + fsscan->timer = GF_CALLOC (1, sizeof (*fsscan->timer), + gf_br_stub_mt_br_scanner_freq_t); +@@ -700,7 +772,9 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child, + timer->data = child; + timer->expires = timo; + timer->function = br_kickstart_scanner; ++ + gf_tw_add_timer (priv->timer_wheel, timer); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING); + + gf_time_fmt (timestr, sizeof (timestr), + (fsscan->boot + timo), gf_timefmt_FT); +@@ -714,39 +788,76 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child, + } + + int32_t +-br_fsscan_reschedule (xlator_t *this, +- br_child_t *child, struct br_scanfs *fsscan, +- struct br_scrubber *fsscrub, gf_boolean_t pendingcheck) ++br_fsscan_activate (xlator_t *this, br_child_t *child) + { +- int32_t ret = 0; +- uint32_t timo = 0; +- char timestr[1024] = {0,}; +- struct timeval now = {0,}; +- br_private_t *priv = NULL; ++ uint32_t timo = 0; ++ char timestr[1024] = {0,}; ++ struct timeval now = {0,}; ++ br_private_t *priv = NULL; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; + + priv = this->private; ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; + + (void) gettimeofday (&now, NULL); + timo = br_fsscan_calculate_timeout (fsscan->boot, + now.tv_sec, fsscrub->frequency); ++ if (timo == 0) { ++ gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ return -1; ++ } + ++ fsscan->over = _gf_false; + gf_time_fmt (timestr, sizeof (timestr), + (now.tv_sec + timo), gf_timefmt_FT); ++ (void) gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo); + +- if (pendingcheck) +- ret = gf_tw_mod_timer_pending (priv->timer_wheel, +- fsscan->timer, timo); +- else +- ret = gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING); ++ gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled to run " ++ "at %s", child->brick_path, timestr); ++ ++ return 0; ++} ++ ++int32_t ++br_fsscan_reschedule (xlator_t *this, br_child_t *child) ++{ ++ int32_t ret = 0; ++ uint32_t timo = 0; ++ char timestr[1024] = {0,}; ++ struct timeval now = {0,}; ++ br_private_t *priv = NULL; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; ++ ++ priv = this->private; ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; ++ ++ (void) gettimeofday (&now, NULL); ++ timo = br_fsscan_calculate_timeout (fsscan->boot, ++ now.tv_sec, fsscrub->frequency); ++ if (timo == 0) { ++ gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ return -1; ++ } ++ ++ gf_time_fmt (timestr, sizeof (timestr), ++ (now.tv_sec + timo), gf_timefmt_FT); + +- if (!ret && pendingcheck) +- gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RUNNING, ++ fsscan->over = _gf_false; ++ ret = gf_tw_mod_timer_pending (priv->timer_wheel, fsscan->timer, timo); ++ if (ret == 0) ++ gf_log (this->name, GF_LOG_INFO, + "Scrubber for %s is currently running and would be " + "rescheduled after completion", child->brick_path); +- else +- gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RESCHEDULED, +- "Scrubbing for %s rescheduled " ++ else { ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING); ++ gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled " + "to run at %s", child->brick_path, timestr); ++ } + + return 0; + } +@@ -1131,7 +1242,8 @@ br_scrubber_handle_stall (xlator_t *this, br_private_t *priv, + } + + static int32_t +-br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, dict_t *options) ++br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, ++ dict_t *options, gf_boolean_t scrubstall) + { + int32_t ret = -1; + char *tmp = NULL; +@@ -1144,6 +1256,9 @@ br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, dict_t *options) + if (ret) + goto error_return; + ++ if (scrubstall) ++ tmp = BR_SCRUB_STALLED; ++ + if (strcasecmp (tmp, "hourly") == 0) { + frequency = BR_FSSCRUB_FREQ_HOURLY; + } else if (strcasecmp (tmp, "daily") == 0) { +@@ -1154,6 +1269,8 @@ br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, dict_t *options) + frequency = BR_FSSCRUB_FREQ_BIWEEKLY; + } else if (strcasecmp (tmp, "monthly") == 0) { + frequency = BR_FSSCRUB_FREQ_MONTHLY; ++ } else if (strcasecmp (tmp, BR_SCRUB_STALLED) == 0) { ++ frequency = BR_FSSCRUB_FREQ_STALLED; + } else + goto error_return; + +@@ -1205,7 +1322,7 @@ br_scrubber_handle_options (xlator_t *this, br_private_t *priv, dict_t *options) + if (ret) + goto error_return; + +- ret = br_scrubber_handle_freq (this, priv, options); ++ ret = br_scrubber_handle_freq (this, priv, options, scrubstall); + if (ret) + goto error_return; + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h +index 6c4254a..427153c 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h +@@ -16,11 +16,10 @@ + + void *br_fsscanner (void *); + +-int32_t br_fsscan_schedule (xlator_t *, br_child_t *, +- struct br_scanfs *, struct br_scrubber *); +-int32_t br_fsscan_reschedule (xlator_t *this, +- br_child_t *child, struct br_scanfs *, +- struct br_scrubber *, gf_boolean_t); ++int32_t br_fsscan_schedule (xlator_t *, br_child_t *); ++int32_t br_fsscan_reschedule (xlator_t *, br_child_t *); ++int32_t br_fsscan_activate (xlator_t *, br_child_t *); ++int32_t br_fsscan_deactivate (xlator_t *, br_child_t *); + + int32_t br_scrubber_handle_options (xlator_t *, br_private_t *, dict_t *); + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c +new file mode 100644 +index 0000000..c95e555 +--- /dev/null ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c +@@ -0,0 +1,91 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#include "bit-rot-ssm.h" ++#include "bit-rot-scrub.h" ++ ++int br_scrub_ssm_noop (xlator_t *this, br_child_t *child) ++{ ++ return 0; ++} ++ ++int ++br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child) ++{ ++ gf_log (this->name, GF_LOG_INFO, ++ "Scrubber paused [Brick: %s]", child->brick_path); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_PAUSED); ++ return 0; ++} ++ ++int ++br_scrub_ssm_state_ipause (xlator_t *this, br_child_t *child) ++{ ++ gf_log (this->name, GF_LOG_INFO, ++ "Scrubber paused [Brick: %s]", child->brick_path); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_IPAUSED); ++ return 0; ++} ++ ++int ++br_scrub_ssm_state_active (xlator_t *this, br_child_t *child) ++{ ++ struct br_scanfs *fsscan = &child->fsscan; ++ ++ if (fsscan->over) { ++ (void) br_fsscan_activate (this, child); ++ } else { ++ gf_log (this->name, GF_LOG_INFO, ++ "Scrubbing resumed [Brick %s]", child->brick_path); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_ACTIVE); ++ } ++ ++ return 0; ++} ++ ++int ++br_scrub_ssm_state_stall (xlator_t *this, br_child_t *child) ++{ ++ gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active " ++ "scrubbing. Pausing scrub..", child->brick_path); ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_STALLED); ++ return 0; ++} ++ ++static br_scrub_ssm_call * ++br_scrub_ssm[BR_SCRUB_MAXSTATES][BR_SCRUB_MAXEVENTS] = { ++ {br_fsscan_schedule, br_scrub_ssm_state_ipause}, /* INACTIVE */ ++ {br_fsscan_reschedule, br_fsscan_deactivate}, /* PENDING */ ++ {br_scrub_ssm_noop, br_scrub_ssm_state_stall}, /* ACTIVE */ ++ {br_fsscan_activate, br_scrub_ssm_noop}, /* PAUSED */ ++ {br_fsscan_schedule, br_scrub_ssm_noop}, /* IPAUSED */ ++ {br_scrub_ssm_state_active, br_scrub_ssm_noop}, /* STALLED */ ++}; ++ ++int32_t ++br_scrub_state_machine (xlator_t *this, br_child_t *child) ++{ ++ br_private_t *priv = NULL; ++ br_scrub_ssm_call *call = NULL; ++ struct br_scanfs *fsscan = NULL; ++ struct br_scrubber *fsscrub = NULL; ++ br_scrub_state_t currstate = 0; ++ br_scrub_event_t event = 0; ++ ++ priv = this->private; ++ fsscan = &child->fsscan; ++ fsscrub = &priv->fsscrub; ++ ++ currstate = fsscan->state; ++ event = _br_child_get_scrub_event (fsscrub); ++ ++ call = br_scrub_ssm[currstate][event]; ++ return call (this, child); ++} +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h +new file mode 100644 +index 0000000..72fd62b +--- /dev/null ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h +@@ -0,0 +1,36 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef __BIT_ROT_SSM_H__ ++#define __BIT_ROT_SSM_H__ ++ ++#include "xlator.h" ++ ++typedef enum br_scrub_state { ++ BR_SCRUB_STATE_INACTIVE = 0, ++ BR_SCRUB_STATE_PENDING, ++ BR_SCRUB_STATE_ACTIVE, ++ BR_SCRUB_STATE_PAUSED, ++ BR_SCRUB_STATE_IPAUSED, ++ BR_SCRUB_STATE_STALLED, ++ BR_SCRUB_MAXSTATES, ++} br_scrub_state_t; ++ ++typedef enum br_scrub_event { ++ BR_SCRUB_EVENT_SCHEDULE = 0, ++ BR_SCRUB_EVENT_PAUSE, ++ BR_SCRUB_MAXEVENTS, ++} br_scrub_event_t; ++ ++struct br_child; ++ ++int32_t br_scrub_state_machine (xlator_t *, struct br_child *); ++ ++#endif /* __BIT_ROT_SSM_H__ */ +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index f2cd1d8..3952f41 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -1092,6 +1092,16 @@ br_set_child_state (br_child_t *child, br_child_state_t state) + UNLOCK (&child->lock); + } + ++static void ++br_set_scrub_state (br_child_t *child, br_scrub_state_t state) ++{ ++ LOCK (&child->lock); ++ { ++ _br_child_set_scrub_state (child, state); ++ } ++ UNLOCK (&child->lock); ++} ++ + /** + * At this point a thread is spawned to crawl the filesystem (in + * tortoise pace) to sign objects that were not signed in previous run(s). +@@ -1155,6 +1165,7 @@ br_launch_scrubber (xlator_t *this, br_child_t *child, + priv = this->private; + + fsscan->kick = _gf_false; ++ fsscan->over = _gf_false; + ret = gf_thread_create (&child->thread, NULL, br_fsscanner, child); + if (ret != 0) { + gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_SPAWN_FAILED, +@@ -1166,7 +1177,7 @@ br_launch_scrubber (xlator_t *this, br_child_t *child, + /* this needs to be serialized with reconfigure() */ + pthread_mutex_lock (&priv->lock); + { +- ret = br_fsscan_schedule (this, child, fsscan, fsscrub); ++ ret = br_scrub_state_machine (this, child); + } + pthread_mutex_unlock (&priv->lock); + if (ret) +@@ -1391,6 +1402,11 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child) + fsscan->timer = NULL; + } + ++ /** ++ * 0x3: reset scrubber state ++ */ ++ _br_child_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE); ++ + gf_log (this->name, GF_LOG_INFO, + "Cleaned up scrubber for brick [%s]", child->brick_path); + +@@ -1779,6 +1795,8 @@ br_init_children (xlator_t *this, br_private_t *priv) + + LOCK_INIT (&child->lock); + child->witnessed = 0; ++ ++ br_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE); + br_set_child_state (child, BR_CHILD_STATE_DISCONNECTED); + + child->this = this; +@@ -1906,13 +1924,11 @@ fini (xlator_t *this) + } + + static void +-br_reconfigure_child (xlator_t *this, +- br_child_t *child, struct br_scrubber *fsscrub) ++br_reconfigure_child (xlator_t *this, br_child_t *child) + { + int32_t ret = 0; +- struct br_scanfs *fsscan = &child->fsscan; + +- ret = br_fsscan_reschedule (this, child, fsscan, fsscrub, _gf_true); ++ ret = br_scrub_state_machine (this, child); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Could not reschedule scrubber for brick: %s. " +@@ -1924,14 +1940,12 @@ br_reconfigure_child (xlator_t *this, + static int + br_reconfigure_scrubber (xlator_t *this, dict_t *options) + { +- int i = 0; +- int32_t ret = -1; +- br_child_t *child = NULL; +- br_private_t *priv = NULL; +- struct br_scrubber *fsscrub = NULL; ++ int i = 0; ++ int32_t ret = -1; ++ br_child_t *child = NULL; ++ br_private_t *priv = NULL; + + priv = this->private; +- fsscrub = &priv->fsscrub; + + pthread_mutex_lock (&priv->lock); + { +@@ -1942,7 +1956,7 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options) + if (ret) + goto err; + +- /* reschedule all _up_ subvolume(s) */ ++ /* change state for all _up_ subvolume(s) */ + for (; i < priv->child_count; i++) { + child = &priv->children[i]; + +@@ -1957,7 +1971,7 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options) + } + + if (_br_is_child_connected (child)) +- br_reconfigure_child (this, child, fsscrub); ++ br_reconfigure_child (this, child); + + /** + * for the rest.. either the child is in initialization +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h +index 9a55773..6cafd8b 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.h +@@ -7,6 +7,7 @@ + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. + */ ++ + #ifndef __BIT_ROT_H__ + #define __BIT_ROT_H__ + +@@ -26,6 +27,7 @@ + #include "timer-wheel.h" + + #include "bit-rot-tbf.h" ++#include "bit-rot-ssm.h" + + #include "bit-rot-common.h" + #include "bit-rot-stub-mem-types.h" +@@ -52,6 +54,7 @@ typedef enum scrub_freq { + BR_FSSCRUB_FREQ_WEEKLY, + BR_FSSCRUB_FREQ_BIWEEKLY, + BR_FSSCRUB_FREQ_MONTHLY, ++ BR_FSSCRUB_FREQ_STALLED, + } scrub_freq_t; + + #define signature_size(hl) (sizeof (br_isignature_t) + hl + 1) +@@ -69,6 +72,9 @@ struct br_scanfs { + /* scheduler */ + uint32_t boot; + gf_boolean_t kick; ++ gf_boolean_t over; ++ ++ br_scrub_state_t state; /* current scrub state */ + + pthread_mutex_t wakelock; + pthread_cond_t wakecond; +@@ -203,6 +209,7 @@ struct br_object { + }; + + typedef struct br_object br_object_t; ++typedef int32_t (br_scrub_ssm_call) (xlator_t *, br_child_t *); + + void + br_log_object (xlator_t *, char *, uuid_t, int32_t); +@@ -244,4 +251,19 @@ _br_child_witnessed_connection (br_child_t *child) + return (child->witnessed == 1); + } + ++/* scrub state */ ++static inline void ++_br_child_set_scrub_state (br_child_t *child, br_scrub_state_t state) ++{ ++ struct br_scanfs *fsscan = &child->fsscan; ++ fsscan->state = state; ++} ++ ++static inline br_scrub_event_t ++_br_child_get_scrub_event (struct br_scrubber *fsscrub) ++{ ++ return (fsscrub->frequency == BR_FSSCRUB_FREQ_STALLED) ++ ? BR_SCRUB_EVENT_PAUSE : BR_SCRUB_EVENT_SCHEDULE; ++} ++ + #endif /* __BIT_ROT_H__ */ +-- +1.7.1 + diff --git a/SOURCES/0161-geo-rep-Fix-add-user-in-mountbroker-user-management.patch b/SOURCES/0161-geo-rep-Fix-add-user-in-mountbroker-user-management.patch new file mode 100644 index 0000000..043a986 --- /dev/null +++ b/SOURCES/0161-geo-rep-Fix-add-user-in-mountbroker-user-management.patch @@ -0,0 +1,102 @@ +From c7eb7af261214e058f94af4f99eba5a8299d43ce Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Thu, 25 Jun 2015 00:18:01 +0530 +Subject: [PATCH 161/190] geo-rep: Fix add user in mountbroker user management + +The CLI 'gluster system:: execute mountbroker user ' +to set volumes associated with a user replaces existing user and associated +volumes upon setting with existing user. This patch fixes it by appending +the volumes if the user already exists. + +It also introduces following CLI to remove volume for a corresponding user. + +'gluster system:: execute mountbroker volumedel ' +: username +: comman separated list of volumes to delete + +If it is the last volume to be deleted associated with the user, +it will delete the user as well as it doesn't make sense to keep +only user without volumes associated. + +BUG: 1234869 +Change-Id: Ib60ef07b5fc2b4a4010bea6641fe7475b1497244 +Reviewed-On: http://review.gluster.org/11385 +Reviewed-On: http://review.gluster.org/11386 +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51611 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + geo-replication/src/peer_mountbroker.in | 34 ++++++++++++++++++++++++++++++- + 1 files changed, 33 insertions(+), 1 deletions(-) + +diff --git a/geo-replication/src/peer_mountbroker.in b/geo-replication/src/peer_mountbroker.in +index 4c97c69..8573abd 100644 +--- a/geo-replication/src/peer_mountbroker.in ++++ b/geo-replication/src/peer_mountbroker.in +@@ -86,8 +86,31 @@ class MountbrokerUserMgmt(object): + del(self._options[key]) + + def add_user(self, user, volumes): ++ vols = set() ++ for k, v in self._options.iteritems(): ++ if k.startswith("mountbroker-geo-replication.") \ ++ and user == k.split(".")[-1]: ++ vols.update(v.split(",")) ++ ++ vols.update(volumes) + self.set_opt("mountbroker-geo-replication.%s" % user, +- ",".join(volumes)) ++ ",".join(vols)) ++ ++ def remove_volume(self, user, volumes): ++ vols = set() ++ for k, v in self._options.iteritems(): ++ if k.startswith("mountbroker-geo-replication.") \ ++ and user == k.split(".")[-1]: ++ vols.update(v.split(",")) ++ ++ for v1 in volumes: ++ vols.discard(v1) ++ ++ if vols: ++ self.set_opt("mountbroker-geo-replication.%s" % user, ++ ",".join(vols)) ++ else: ++ self.remove_opt("mountbroker-geo-replication.%s" % user) + + def remove_user(self, user): + self.remove_opt("mountbroker-geo-replication.%s" % user) +@@ -129,6 +152,7 @@ def _get_args(): + subparsers = parser.add_subparsers(title='subcommands', dest='cmd') + parser_useradd = subparsers.add_parser('user') + parser_userdel = subparsers.add_parser('userdel') ++ parser_volumedel = subparsers.add_parser('volumedel') + subparsers.add_parser('info') + parser_opt = subparsers.add_parser('opt') + parser_optdel = subparsers.add_parser('optdel') +@@ -137,6 +161,10 @@ def _get_args(): + parser_useradd.add_argument('volumes', type=str, default='', + help="Volumes list. ',' seperated") + ++ parser_volumedel.add_argument('username', help="Username", type=str) ++ parser_volumedel.add_argument('volumes', type=str, default='', ++ help="Volumes list. ',' seperated") ++ + parser_userdel.add_argument('username', help="Username", type=str) + + parser_opt.add_argument('opt_name', help="Name", type=str) +@@ -163,6 +191,10 @@ def main(): + volumes = [v.strip() for v in args.volumes.split(",") + if v.strip() != ""] + m.add_user(args.username, volumes) ++ elif args.cmd == "volumedel": ++ volumes = [v.strip() for v in args.volumes.split(",") ++ if v.strip() != ""] ++ m.remove_volume(args.username, volumes) + elif args.cmd == "info": + info = m.info() + if not args.json: +-- +1.7.1 + diff --git a/SOURCES/0162-features-bitrot-convert-pending-gf_log-to-gf_msg.patch b/SOURCES/0162-features-bitrot-convert-pending-gf_log-to-gf_msg.patch new file mode 100644 index 0000000..87efa87 --- /dev/null +++ b/SOURCES/0162-features-bitrot-convert-pending-gf_log-to-gf_msg.patch @@ -0,0 +1,299 @@ +From 048c377cc54ba7a034e8f9eac4394857858ca1b7 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Thu, 25 Jun 2015 12:07:24 +0530 +Subject: [PATCH 162/190] features/bitrot: convert pending gf_log() to gf_msg() + + Backport of http://review.gluster.org/11396 + +Change-Id: Idfd245327b485459ccbda503510b8ca0127bb66c +BUG: 1232309 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/51746 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + .../bit-rot/src/bitd/bit-rot-bitd-messages.h | 27 ++++++++++++++++ + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 32 ++++++++++++-------- + xlators/features/bit-rot/src/bitd/bit-rot-ssm.c | 12 ++++--- + xlators/features/bit-rot/src/bitd/bit-rot.c | 32 ++++++++++++------- + 4 files changed, 73 insertions(+), 30 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +index af3a74f..b4746bb 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +@@ -387,5 +387,32 @@ + * + */ + /*------------*/ ++#define BRB_MSG_SCRUB_THREAD_CLEANUP (GLFS_BITROT_BITD_BASE + 49) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define BRB_MSG_SCRUBBER_CLEANED (GLFS_BITROT_BITD_BASE + 50) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define BRB_MSG_GENERIC_SSM_INFO (GLFS_BITROT_BITD_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++/*------------*/ ++#define BRB_MSG_ZERO_TIMEOUT_BUG (GLFS_BITROT_BITD_BASE + 52) ++ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_BITROT_BITD_MESSAGES_H_ */ +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index af31a3c..3a038ce 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -542,11 +542,12 @@ br_fsscan_deactivate (xlator_t *this, br_child_t *child) + ret = gf_tw_del_timer (priv->timer_wheel, fsscan->timer); + if (ret == 0) { + nstate = BR_SCRUB_STATE_STALLED; +- gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active " +- "scrubbing. Pausing scrub..", child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, ++ "Brick [%s] is under active scrubbing. Pausing scrub..", ++ child->brick_path); + } else { + nstate = BR_SCRUB_STATE_PAUSED; +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, + "Scrubber paused [Brick: %s]", child->brick_path); + } + +@@ -617,8 +618,9 @@ br_fsscanner_exit_control (xlator_t *this, br_child_t *child) + if (fsscan->state == BR_SCRUB_STATE_ACTIVE) { + (void) br_fsscan_activate (this, child); + } else { +- gf_log (this->name, GF_LOG_INFO, "Brick [%s] waiting " +- "to get rescheduled..", child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, ++ "Brick [%s] waiting to get rescheduled..", ++ child->brick_path); + } + } + UNLOCK (&child->lock); +@@ -757,7 +759,8 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child) + timo = br_fsscan_calculate_timeout (fsscan->boot, + fsscan->boot, fsscrub->frequency); + if (timo == 0) { +- gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, ++ "BUG: Zero schedule timeout"); + goto error_return; + } + +@@ -805,7 +808,8 @@ br_fsscan_activate (xlator_t *this, br_child_t *child) + timo = br_fsscan_calculate_timeout (fsscan->boot, + now.tv_sec, fsscrub->frequency); + if (timo == 0) { +- gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, ++ "BUG: Zero schedule timeout"); + return -1; + } + +@@ -815,8 +819,8 @@ br_fsscan_activate (xlator_t *this, br_child_t *child) + (void) gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo); + + _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING); +- gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled to run " +- "at %s", child->brick_path, timestr); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, "Scrubbing for " ++ "%s rescheduled to run at %s", child->brick_path, timestr); + + return 0; + } +@@ -840,7 +844,8 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child) + timo = br_fsscan_calculate_timeout (fsscan->boot, + now.tv_sec, fsscrub->frequency); + if (timo == 0) { +- gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, ++ "BUG: Zero schedule timeout"); + return -1; + } + +@@ -850,13 +855,14 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child) + fsscan->over = _gf_false; + ret = gf_tw_mod_timer_pending (priv->timer_wheel, fsscan->timer, timo); + if (ret == 0) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, + "Scrubber for %s is currently running and would be " + "rescheduled after completion", child->brick_path); + else { + _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING); +- gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled " +- "to run at %s", child->brick_path, timestr); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, ++ "Scrubbing for %s rescheduled to run at %s", ++ child->brick_path, timestr); + } + + return 0; +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c +index c95e555..fcffc04 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c +@@ -10,6 +10,7 @@ + + #include "bit-rot-ssm.h" + #include "bit-rot-scrub.h" ++#include "bit-rot-bitd-messages.h" + + int br_scrub_ssm_noop (xlator_t *this, br_child_t *child) + { +@@ -19,7 +20,7 @@ int br_scrub_ssm_noop (xlator_t *this, br_child_t *child) + int + br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child) + { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO, + "Scrubber paused [Brick: %s]", child->brick_path); + _br_child_set_scrub_state (child, BR_SCRUB_STATE_PAUSED); + return 0; +@@ -28,7 +29,7 @@ br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child) + int + br_scrub_ssm_state_ipause (xlator_t *this, br_child_t *child) + { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO, + "Scrubber paused [Brick: %s]", child->brick_path); + _br_child_set_scrub_state (child, BR_SCRUB_STATE_IPAUSED); + return 0; +@@ -42,7 +43,7 @@ br_scrub_ssm_state_active (xlator_t *this, br_child_t *child) + if (fsscan->over) { + (void) br_fsscan_activate (this, child); + } else { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO, + "Scrubbing resumed [Brick %s]", child->brick_path); + _br_child_set_scrub_state (child, BR_SCRUB_STATE_ACTIVE); + } +@@ -53,8 +54,9 @@ br_scrub_ssm_state_active (xlator_t *this, br_child_t *child) + int + br_scrub_ssm_state_stall (xlator_t *this, br_child_t *child) + { +- gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active " +- "scrubbing. Pausing scrub..", child->brick_path); ++ gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO, ++ "Brick [%s] is under active scrubbing. Pausing scrub..", ++ child->brick_path); + _br_child_set_scrub_state (child, BR_SCRUB_STATE_STALLED); + return 0; + } +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index 3952f41..cf9e8e2 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -1264,7 +1264,8 @@ br_child_enaction (xlator_t *this, br_child_t *child, br_stub_init_t *stub) + if (!ret) { + child->witnessed = 1; + _br_set_child_state (child, BR_CHILD_STATE_CONNECTED); +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, BRB_MSG_CONNECTED_TO_BRICK, + "Connected to brick %s..", child->brick_path); + } + } +@@ -1389,7 +1390,8 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child) + */ + ret = gf_thread_cleanup_xint (child->thread); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, BRB_MSG_SCRUB_THREAD_CLEANUP, + "Error cleaning up scanner thread"); + + /** +@@ -1407,7 +1409,8 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child) + */ + _br_child_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, BRB_MSG_SCRUBBER_CLEANED, + "Cleaned up scrubber for brick [%s]", child->brick_path); + + return 0; +@@ -1522,8 +1525,9 @@ _br_qchild_event (xlator_t *this, br_child_t *child, br_child_handler *call) + + childev = GF_CALLOC (1, sizeof (*childev), gf_br_mt_br_child_event_t); + if (!childev) { +- gf_log (this->name, GF_LOG_ERROR, "Event unhandled for " +- "child.. [Brick: %s]", child->xl->name); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, ++ "Event unhandled for child.. [Brick: %s]", ++ child->xl->name); + return; + } + +@@ -1805,7 +1809,8 @@ br_init_children (xlator_t *this, br_private_t *priv) + child->timer_pool = mem_pool_new + (struct gf_tw_timer_list, 4096); + if (!child->timer_pool) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, BRB_MSG_NO_MEMORY, + "failed to allocate mem-pool for timer"); + errno = ENOMEM; + goto freechild; +@@ -1832,13 +1837,14 @@ init (xlator_t *this) + br_private_t *priv = NULL; + + if (!this->children) { +- gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_NO_CHILD, ++ "FATAL: no children"); + goto out; + } + + priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t); + if (!priv) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, + "failed to allocate memory (->priv)"); + goto out; + } +@@ -1930,9 +1936,10 @@ br_reconfigure_child (xlator_t *this, br_child_t *child) + + ret = br_scrub_state_machine (this, child); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not reschedule scrubber for brick: %s. " +- "Scubbing will continue according to old frequency.", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, ++ "Could not reschedule scrubber for brick: %s. Scubbing " ++ "will continue according to old frequency.", + child->brick_path); + } + } +@@ -1963,7 +1970,8 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options) + LOCK (&child->lock); + { + if (_br_child_failed_conn (child)) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, BRB_MSG_BRICK_INFO, + "Scrubber for brick [%s] failed " + "initialization, rescheduling is " + "skipped", child->brick_path); +-- +1.7.1 + diff --git a/SOURCES/0163-geo-rep-ignore-ESTALE-as-ENOENT.patch b/SOURCES/0163-geo-rep-ignore-ESTALE-as-ENOENT.patch new file mode 100644 index 0000000..2a5dfa2 --- /dev/null +++ b/SOURCES/0163-geo-rep-ignore-ESTALE-as-ENOENT.patch @@ -0,0 +1,97 @@ +From 71bdc4203407f03cf82ecbca8601798c5575fc65 Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Wed, 17 Jun 2015 15:46:01 -0400 +Subject: [PATCH 163/190] geo-rep: ignore ESTALE as ENOENT + +When DHT can't resolve a File it raises ESTALE, ignore ESTALE errors +same as ENOENT after retry. + +Affected places: + Xattr.lgetxattr + os.listdir + os.link + Xattr.lsetxattr + os.chmod + os.chown + os.utime + os.readlink + +BUG: 1222856 +Change-Id: I4728eae6fc6419723bdca48809941a490c6ca2b4 +Reviewed-On: http://review.gluster.org/11296 +Reviewed-On: http://review.gluster.org/11430 +Original-Author: Aravinda VK +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51709 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + geo-replication/syncdaemon/master.py | 4 ++-- + geo-replication/syncdaemon/resource.py | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py +index 6c96a02..37be4fc 100644 +--- a/geo-replication/syncdaemon/master.py ++++ b/geo-replication/syncdaemon/master.py +@@ -18,7 +18,7 @@ import fcntl + import string + import errno + import tarfile +-from errno import ENOENT, ENODATA, EEXIST, EACCES, EAGAIN ++from errno import ENOENT, ENODATA, EEXIST, EACCES, EAGAIN, ESTALE + from threading import Condition, Lock + from datetime import datetime + from gconf import gconf +@@ -853,7 +853,7 @@ class GMasterChangelogMixin(GMasterCommon): + entry_update() + entries.append(edct(ty, stat=st, entry=en, gfid=gfid)) + elif ty == 'SYMLINK': +- rl = errno_wrap(os.readlink, [en], [ENOENT]) ++ rl = errno_wrap(os.readlink, [en], [ENOENT], [ESTALE]) + if isinstance(rl, int): + continue + entry_update() +diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py +index ba92a4a..c73347a 100644 +--- a/geo-replication/syncdaemon/resource.py ++++ b/geo-replication/syncdaemon/resource.py +@@ -377,7 +377,7 @@ class Server(object): + def gfid_mnt(cls, gfidpath): + return errno_wrap(Xattr.lgetxattr, + [gfidpath, 'glusterfs.gfid.string', +- cls.GX_GFID_CANONICAL_LEN], [ENOENT]) ++ cls.GX_GFID_CANONICAL_LEN], [ENOENT], [ESTALE]) + + @classmethod + @_pathguard +@@ -647,7 +647,7 @@ class Server(object): + return + + names = [] +- names = errno_wrap(os.listdir, [path], [ENOENT]) ++ names = errno_wrap(os.listdir, [path], [ENOENT], [ESTALE]) + if isinstance(names, int): + return + +@@ -708,7 +708,7 @@ class Server(object): + else: + cmd_ret = errno_wrap(os.link, + [slink, entry], +- [ENOENT, EEXIST]) ++ [ENOENT, EEXIST], [ESTALE]) + collect_failure(e, cmd_ret) + elif op == 'SYMLINK': + blob = entry_pack_symlink(gfid, bname, e['link'], e['stat']) +@@ -722,7 +722,7 @@ class Server(object): + else: + cmd_ret = errno_wrap(os.rename, + [entry, en], +- [ENOENT, EEXIST]) ++ [ENOENT, EEXIST], [ESTALE]) + collect_failure(e, cmd_ret) + if blob: + cmd_ret = errno_wrap(Xattr.lsetxattr, +-- +1.7.1 + diff --git a/SOURCES/0164-fd-inode-libglusterfs-porting-to-a-new-logging-frame.patch b/SOURCES/0164-fd-inode-libglusterfs-porting-to-a-new-logging-frame.patch new file mode 100644 index 0000000..6aec129 --- /dev/null +++ b/SOURCES/0164-fd-inode-libglusterfs-porting-to-a-new-logging-frame.patch @@ -0,0 +1,795 @@ +From b5e31df9cffbfc8ccedc0cc65e9c8af8ac91e462 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:34:43 +0530 +Subject: [PATCH 164/190] fd,inode/libglusterfs : porting to a new logging framework + +Change-Id: I4beba3b50456f802824374b6e3fa8079d72f2c00 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10825 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51214 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/fd-lk.c | 47 +++++++-------- + libglusterfs/src/fd.c | 82 ++++++++++++++++--------- + libglusterfs/src/inode.c | 150 ++++++++++++++++++++++++++++++---------------- + 3 files changed, 172 insertions(+), 107 deletions(-) + +diff --git a/libglusterfs/src/fd-lk.c b/libglusterfs/src/fd-lk.c +index 3c1befe..01c6c1a 100644 +--- a/libglusterfs/src/fd-lk.c ++++ b/libglusterfs/src/fd-lk.c +@@ -10,7 +10,7 @@ + + #include "fd-lk.h" + #include "common-utils.h" +- ++#include "libglusterfs-messages.h" + + int32_t + _fd_lk_delete_lock (fd_lk_ctx_node_t *lock) +@@ -89,8 +89,8 @@ fd_lk_ctx_t * + _fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx) + { + if (!lk_ctx) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, +- "invalid argument"); ++ gf_msg_callingfn ("fd-lk", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -105,8 +105,8 @@ fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx) + fd_lk_ctx_t *new_lk_ctx = NULL; + + if (!lk_ctx) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, +- "invalid argument"); ++ gf_msg_callingfn ("fd-lk", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -418,19 +418,18 @@ print_lock_list (fd_lk_ctx_t *lk_ctx) + { + fd_lk_ctx_node_t *lk = NULL; + +- gf_log ("fd-lk", GF_LOG_DEBUG, "lock list:"); ++ gf_msg_debug ("fd-lk", 0, "lock list:"); + + list_for_each_entry (lk, &lk_ctx->lk_list, next) +- gf_log ("fd-lk", GF_LOG_DEBUG, "owner = %s, " +- "cmd = %s fl_type = %s, fs_start = %"PRId64", " +- "fs_end = %"PRId64", user_flock: l_type = %s, " +- "l_start = %"PRId64", l_len = %"PRId64", ", +- lkowner_utoa (&lk->user_flock.l_owner), +- get_lk_cmd (lk->cmd), get_lk_type (lk->fl_type), +- lk->fl_start, lk->fl_end, +- get_lk_type (lk->user_flock.l_type), +- lk->user_flock.l_start, +- lk->user_flock.l_len); ++ gf_msg_debug ("fd-lk", 0, "owner = %s, cmd = %s fl_type = %s," ++ " fs_start = %"PRId64", fs_end = %"PRId64", " ++ "user_flock: l_type = %s, l_start = %"PRId64", " ++ "l_len = %"PRId64", ", ++ lkowner_utoa (&lk->user_flock.l_owner), ++ get_lk_cmd (lk->cmd), get_lk_type (lk->fl_type), ++ lk->fl_start, lk->fl_end, ++ get_lk_type (lk->user_flock.l_type), ++ lk->user_flock.l_start, lk->user_flock.l_len); + } + + int +@@ -447,15 +446,13 @@ fd_lk_insert_and_merge (fd_t *fd, int32_t cmd, + lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); + lk = fd_lk_ctx_node_new (cmd, flock); + +- gf_log ("fd-lk", GF_LOG_DEBUG, +- "new lock requrest: owner = %s, fl_type = %s, " +- "fs_start = %"PRId64", fs_end = %"PRId64", " +- "user_flock: l_type = %s, l_start = %"PRId64", " +- "l_len = %"PRId64, lkowner_utoa (&flock->l_owner), +- get_lk_type (lk->fl_type), lk->fl_start, +- lk->fl_end, get_lk_type (lk->user_flock.l_type), +- lk->user_flock.l_start, +- lk->user_flock.l_len); ++ gf_msg_debug ("fd-lk", 0, "new lock requrest: owner = %s, fl_type = %s" ++ ", fs_start = %"PRId64", fs_end = %"PRId64", user_flock:" ++ " l_type = %s, l_start = %"PRId64", l_len = %"PRId64, ++ lkowner_utoa (&flock->l_owner), ++ get_lk_type (lk->fl_type), lk->fl_start, lk->fl_end, ++ get_lk_type (lk->user_flock.l_type), ++ lk->user_flock.l_start, lk->user_flock.l_len); + + LOCK (&lk_ctx->lock); + { +diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c +index 613f901..85334bb 100644 +--- a/libglusterfs/src/fd.c ++++ b/libglusterfs/src/fd.c +@@ -13,7 +13,7 @@ + #include "inode.h" + #include "dict.h" + #include "statedump.h" +- ++#include "libglusterfs-messages.h" + + #ifndef _CONFIG_H + #define _CONFIG_H +@@ -35,7 +35,8 @@ gf_fd_chain_fd_entries (fdentry_t *entries, uint32_t startidx, + uint32_t i = 0; + + if (!entries) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!entries"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!entries"); + return -1; + } + +@@ -60,7 +61,8 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr) + int ret = -1; + + if (fdtable == NULL || nr > UINT32_MAX) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + ret = EINVAL; + goto out; + } +@@ -127,7 +129,8 @@ __gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count) + fdentry_t *fdentries = NULL; + + if (count == NULL) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!count"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!count"); + goto out; + } + +@@ -166,7 +169,8 @@ __gf_fd_fdtable_copy_all_fds (fdtable_t *fdtable, uint32_t *count) + int i = 0; + + if (count == NULL) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!count"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!count"); + goto out; + } + +@@ -218,7 +222,8 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable) + INIT_LIST_HEAD (&list); + + if (!fdtable) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!fdtable"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!fdtable"); + return; + } + +@@ -253,7 +258,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr) + int alloc_attempts = 0; + + if (fdtable == NULL || fdptr == NULL) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return EINVAL; + } + +@@ -271,7 +277,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr) + * seriously wrong with our data structures. + */ + if (alloc_attempts >= 2) { +- gf_log ("fd", GF_LOG_ERROR, ++ gf_msg ("fd", GF_LOG_ERROR, 0, ++ LG_MSG_EXPAND_FD_TABLE_FAILED, + "multiple attempts to expand fd table" + " have failed."); + goto out; +@@ -279,7 +286,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr) + error = gf_fd_fdtable_expand (fdtable, + fdtable->max_fds + 1); + if (error) { +- gf_log ("fd", GF_LOG_ERROR, ++ gf_msg ("fd", GF_LOG_ERROR, 0, ++ LG_MSG_EXPAND_FD_TABLE_FAILED, + "Cannot expand fdtable: %s", + strerror (error)); + goto out; +@@ -312,12 +320,14 @@ gf_fd_put (fdtable_t *fdtable, int32_t fd) + return; + + if (fdtable == NULL || fd < 0) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return; + } + + if (!(fd < fdtable->max_fds)) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return; + } + +@@ -354,7 +364,8 @@ gf_fdptr_put (fdtable_t *fdtable, fd_t *fd) + int32_t i = 0; + + if ((fdtable == NULL) || (fd == NULL)) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return; + } + +@@ -368,8 +379,10 @@ gf_fdptr_put (fdtable_t *fdtable, fd_t *fd) + } + + if (fde == NULL) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, +- "fd (%p) is not present in fdtable", fd); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, 0, ++ LG_MSG_FD_NOT_FOUND_IN_FDTABLE, ++ "fd (%p) is not present in fdtable", ++ fd); + goto unlock_out; + } + +@@ -401,13 +414,15 @@ gf_fd_fdptr_get (fdtable_t *fdtable, int64_t fd) + fd_t *fdptr = NULL; + + if (fdtable == NULL || fd < 0) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + errno = EINVAL; + return NULL; + } + + if (!(fd < fdtable->max_fds)) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + errno = EINVAL; + return NULL; + } +@@ -440,7 +455,8 @@ fd_ref (fd_t *fd) + fd_t *refed_fd = NULL; + + if (!fd) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "null fd"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "null fd"); + return NULL; + } + +@@ -475,12 +491,15 @@ fd_destroy (fd_t *fd) + xlator_t *old_THIS = NULL; + + if (fd == NULL){ +- gf_log_callingfn ("xlator", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("xlator", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + goto out; + } + + if (fd->inode == NULL){ +- gf_log_callingfn ("xlator", GF_LOG_ERROR, "fd->inode is NULL"); ++ gf_msg_callingfn ("xlator", GF_LOG_ERROR, 0, ++ LG_MSG_FD_INODE_NULL, ++ "fd->inode is NULL"); + goto out; + } + if (!fd->_ctx) +@@ -533,7 +552,8 @@ fd_unref (fd_t *fd) + int32_t refcount = 0; + + if (!fd) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "fd is NULL"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "fd is NULL"); + return; + } + +@@ -567,7 +587,8 @@ fd_t * + fd_bind (fd_t *fd) + { + if (!fd || !fd->inode) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "!fd || !fd->inode"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "!fd || !fd->inode"); + return NULL; + } + +@@ -587,7 +608,8 @@ __fd_create (inode_t *inode, uint64_t pid) + fd_t *fd = NULL; + + if (inode == NULL) { +- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -687,7 +709,8 @@ fd_lookup (inode_t *inode, pid_t pid) + fd_t *fd = NULL; + + if (!inode) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!inode"); + return NULL; + } + +@@ -706,7 +729,8 @@ fd_lookup_uint64 (inode_t *inode, uint64_t pid) + fd_t *fd = NULL; + + if (!inode) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!inode"); + return NULL; + } + +@@ -786,7 +810,8 @@ fd_lookup_anonymous (inode_t *inode) + fd_t *fd = NULL; + + if (!inode) { +- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode"); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!inode"); + return NULL; + } + +@@ -855,10 +880,6 @@ __fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value) + (sizeof (struct _fd_ctx) + * new_xl_count)); + if (tmp == NULL) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "realloc of fd->_ctx for fd " +- "(ptr: %p) failed, cannot set the key" +- , fd); + ret = -1; + goto out; + } +@@ -890,7 +911,8 @@ fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value) + int ret = 0; + + if (!fd || !xlator) { +- gf_log_callingfn ("", GF_LOG_WARNING, "%p %p", fd, xlator); ++ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "%p %p", fd, xlator); + return -1; + } + +diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c +index 7d3215e..7b49fbe 100644 +--- a/libglusterfs/src/inode.c ++++ b/libglusterfs/src/inode.c +@@ -23,6 +23,7 @@ + #include "list.h" + #include + #include ++#include "libglusterfs-messages.h" + + /* TODO: + move latest accessed dentry to list_head of inode +@@ -85,7 +86,8 @@ __dentry_hash (dentry_t *dentry) + int hash = 0; + + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "dentry not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_DENTRY_NOT_FOUND, "dentry not found"); + return; + } + +@@ -102,7 +104,8 @@ static int + __is_dentry_hashed (dentry_t *dentry) + { + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "dentry not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_DENTRY_NOT_FOUND, "dentry not found"); + return 0; + } + +@@ -114,7 +117,8 @@ static void + __dentry_unhash (dentry_t *dentry) + { + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "dentry not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_DENTRY_NOT_FOUND, "dentry not found"); + return; + } + +@@ -126,7 +130,8 @@ static void + __dentry_unset (dentry_t *dentry) + { + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "dentry not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_DENTRY_NOT_FOUND, "dentry not found"); + return; + } + +@@ -157,19 +162,24 @@ __foreach_ancestor_dentry (dentry_t *dentry, + int ret = 0; + + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "dentry not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_DENTRY_NOT_FOUND, "dentry not found"); + return 0; + } + + ret = per_dentry_fn (dentry, data); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, "per dentry fn returned %d", ret); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_PER_DENTRY_FAILED, "per dentry fn returned %d", ++ ret); + goto out; + } + + parent = dentry->parent; + if (!parent) { +- gf_log (THIS->name, GF_LOG_WARNING, "parent not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_PARENT_DENTRY_NOT_FOUND, ++ "parent not found"); + goto out; + } + +@@ -212,10 +222,10 @@ __is_dentry_cyclic (dentry_t *dentry) + if (dentry->name) + name = dentry->name; + +- gf_log (dentry->inode->table->name, GF_LOG_CRITICAL, +- "detected cyclic loop formation during inode linkage." +- " inode (%s) linking under itself as %s", +- uuid_utoa (inode->gfid), name); ++ gf_msg (dentry->inode->table->name, GF_LOG_CRITICAL, 0, ++ LG_MSG_DENTRY_CYCLIC_LOOP, "detected cyclic loop " ++ "formation during inode linkage. inode (%s) linking " ++ "under itself as %s", uuid_utoa (inode->gfid), name); + } + + return ret; +@@ -226,7 +236,8 @@ static void + __inode_unhash (inode_t *inode) + { + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -238,7 +249,8 @@ static int + __is_inode_hashed (inode_t *inode) + { + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return 0; + } + +@@ -253,7 +265,8 @@ __inode_hash (inode_t *inode) + int hash = 0; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -272,7 +285,9 @@ __dentry_search_for_inode (inode_t *inode, uuid_t pargfid, const char *name) + dentry_t *tmp = NULL; + + if (!inode || !name) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode || name not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, ++ "inode || name not found"); + return NULL; + } + +@@ -302,12 +317,14 @@ __inode_ctx_free (inode_t *inode) + xlator_t *old_THIS = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + + if (!inode->_ctx) { +- gf_log (THIS->name, GF_LOG_WARNING, "_ctx not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_CTX_NULL, ++ "_ctx not found"); + goto noctx; + } + +@@ -333,7 +350,8 @@ static void + __inode_destroy (inode_t *inode) + { + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -352,12 +370,14 @@ inode_ctx_merge (fd_t *fd, inode_t *inode, inode_t *linked_inode) + xlator_t *old_THIS = NULL; + + if (!fd || !inode || !linked_inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "invalid inode"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid inode"); + return; + } + + if (!inode->_ctx || !linked_inode->_ctx) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, + "invalid inode context"); + return; + } +@@ -394,7 +414,8 @@ __inode_passivate (inode_t *inode) + dentry_t *t = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -415,7 +436,8 @@ __inode_retire (inode_t *inode) + dentry_t *t = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -536,7 +558,8 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name) + dentry_t *newd = NULL; + + if (!inode || !parent || !name) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, + "inode || parent || name not found"); + return NULL; + } +@@ -573,7 +596,9 @@ __inode_create (inode_table_t *table) + inode_t *newi = NULL; + + if (!table) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "table not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_TABLE_NOT_FOUND, "table not " ++ "found"); + return NULL; + } + +@@ -616,7 +641,9 @@ inode_new (inode_table_t *table) + inode_t *inode = NULL; + + if (!table) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_TABLE_NOT_FOUND, "inode not " ++ "found"); + return NULL; + } + +@@ -727,8 +754,9 @@ inode_grep (inode_table_t *table, inode_t *parent, const char *name) + dentry_t *dentry = NULL; + + if (!table || !parent || !name) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "table || parent || name not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "table || parent || name" ++ " not found"); + return NULL; + } + +@@ -800,8 +828,9 @@ inode_grep_for_gfid (inode_table_t *table, inode_t *parent, const char *name, + int ret = -1; + + if (!table || !parent || !name) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, +- "table || parent || name not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "table || parent || name" ++ " not found"); + return ret; + } + +@@ -848,7 +877,9 @@ __inode_find (inode_table_t *table, uuid_t gfid) + int hash = 0; + + if (!table) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "table not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_TABLE_NOT_FOUND, "table not " ++ "found"); + goto out; + } + +@@ -875,7 +906,9 @@ inode_find (inode_table_t *table, uuid_t gfid) + inode_t *inode = NULL; + + if (!table) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "table not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_TABLE_NOT_FOUND, "table not " ++ "found"); + return NULL; + } + +@@ -976,7 +1009,8 @@ __inode_link (inode_t *inode, inode_t *parent, const char *name, + if (!old_dentry || old_dentry->inode != link_inode) { + dentry = __dentry_create (link_inode, parent, name); + if (!dentry) { +- gf_log_callingfn (THIS->name, GF_LOG_ERROR, ++ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0, ++ LG_MSG_DENTRY_CREATE_FAILED, + "dentry create failed on " + "inode %s with parent %s", + uuid_utoa (link_inode->gfid), +@@ -1006,7 +1040,8 @@ inode_link (inode_t *inode, inode_t *parent, const char *name, + inode_t *linked_inode = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return NULL; + } + +@@ -1033,7 +1068,8 @@ inode_lookup (inode_t *inode) + inode_table_t *table = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return -1; + } + +@@ -1055,7 +1091,8 @@ inode_ref_reduce_by_n (inode_t *inode, uint64_t nref) + inode_table_t *table = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return -1; + } + +@@ -1079,7 +1116,8 @@ inode_forget (inode_t *inode, uint64_t nlookup) + inode_table_t *table = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return -1; + } + +@@ -1109,7 +1147,8 @@ inode_invalidate(inode_t *inode) + xlator_t *old_THIS = NULL; + + if (!inode) { +- gf_log_callingfn(THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn(THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return -1; + } + +@@ -1161,8 +1200,9 @@ __inode_unlink (inode_t *inode, inode_t *parent, const char *name) + if (dentry) { + __dentry_unset (dentry); + } else { +- gf_log ("inode", GF_LOG_WARNING, "%s/%s: dentry not " +- "found in %s", uuid_utoa_r (parent->gfid, pgfid), name, ++ gf_msg ("inode", GF_LOG_WARNING, 0, LG_MSG_DENTRY_NOT_FOUND, ++ "%s/%s: dentry not found in %s", ++ uuid_utoa_r (parent->gfid, pgfid), name, + uuid_utoa_r (inode->gfid, gfid)); + } + +@@ -1175,7 +1215,8 @@ inode_unlink (inode_t *inode, inode_t *parent, const char *name) + inode_table_t *table = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return; + } + +@@ -1197,7 +1238,8 @@ inode_rename (inode_table_t *table, inode_t *srcdir, const char *srcname, + struct iatt *iatt) + { + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return -1; + } + +@@ -1251,7 +1293,8 @@ inode_parent (inode_t *inode, uuid_t pargfid, const char *name) + dentry_t *dentry = NULL; + + if (!inode) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); + return NULL; + } + +@@ -1290,7 +1333,8 @@ __inode_path (inode_t *inode, const char *name, char **bufp) + + if (!inode || gf_uuid_is_null (inode->gfid)) { + GF_ASSERT (0); +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "invalid inode"); ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid inode"); + return -EINVAL; + } + +@@ -1303,9 +1347,10 @@ __inode_path (inode_t *inode, const char *name, char **bufp) + i ++; /* "/" */ + i += strlen (trav->name); + if (i > PATH_MAX) { +- gf_log (table->name, GF_LOG_CRITICAL, +- "possible infinite loop detected, " +- "forcing break. name=(%s)", name); ++ gf_msg (table->name, GF_LOG_CRITICAL, 0, ++ LG_MSG_DENTRY_CYCLIC_LOOP, "possible infinite " ++ "loop detected, forcing break. name=(%s)", ++ name); + ret = -ENOENT; + goto out; + } +@@ -1623,12 +1668,13 @@ inode_table_ctx_free (inode_table_t *table) + + ret = purge_count + lru_count + active_count; + itable_size = table->active_size + table->lru_size + table->purge_size; +- gf_log_callingfn (this->name, GF_LOG_INFO, "total %d (itable size: %d) " +- "inode contexts have been freed (active: %d, " +- "(active size: %d), lru: %d, (lru size: %d), " +- " purge: %d, (purge size: %d))", ret, itable_size, +- active_count, table->active_size, lru_count, +- table->lru_size, purge_count, table->purge_size); ++ gf_msg_callingfn (this->name, GF_LOG_INFO, 0, ++ LG_MSG_INODE_CONTEXT_FREED, "total %d (itable size: " ++ "%d) inode contexts have been freed (active: %d, (" ++ "active size: %d), lru: %d, (lru size: %d), purge: " ++ "%d, (purge size: %d))", ret, itable_size, ++ active_count, table->active_size, lru_count, ++ table->lru_size, purge_count, table->purge_size); + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0165-call-stub-circ-buff-client_t-compat-dict-libglusterf.patch b/SOURCES/0165-call-stub-circ-buff-client_t-compat-dict-libglusterf.patch new file mode 100644 index 0000000..b7e3404 --- /dev/null +++ b/SOURCES/0165-call-stub-circ-buff-client_t-compat-dict-libglusterf.patch @@ -0,0 +1,1313 @@ +From 633fcaf2d954413d16d1282dc4791c0a53acec5f Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:53:19 +0530 +Subject: [PATCH 165/190] call-stub,circ-buff,client_t,compat,dict/libglusterfs : Porting to a new logging framework + +Change-Id: Ie7d180e0ab2fed1270d66504606d1b2522884020 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10828 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Pranith Kumar Karampuri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51686 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/call-stub.c | 14 +- + libglusterfs/src/circ-buff.c | 25 ++-- + libglusterfs/src/client_t.c | 67 +++++++---- + libglusterfs/src/compat.c | 58 +++++----- + libglusterfs/src/dict.c | 265 +++++++++++++++++++++++++----------------- + libglusterfs/src/dict.h | 9 +- + 6 files changed, 256 insertions(+), 182 deletions(-) + +diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c +index 128dcf9..f3c3095 100644 +--- a/libglusterfs/src/call-stub.c ++++ b/libglusterfs/src/call-stub.c +@@ -18,7 +18,7 @@ + + #include "call-stub.h" + #include "mem-types.h" +- ++#include "libglusterfs-messages.h" + + static call_stub_t * + stub_new (call_frame_t *frame, +@@ -2285,9 +2285,9 @@ call_resume_wind (call_stub_t *stub) + break; + + default: +- gf_log_callingfn ("call-stub", GF_LOG_ERROR, +- "Invalid value of FOP (%d)", +- stub->fop); ++ gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ENTRY, "Invalid value of FOP" ++ " (%d)", stub->fop); + break; + } + out: +@@ -2495,9 +2495,9 @@ call_resume_unwind (call_stub_t *stub) + break; + + default: +- gf_log_callingfn ("call-stub", GF_LOG_ERROR, +- "Invalid value of FOP (%d)", +- stub->fop); ++ gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ENTRY, "Invalid value of FOP" ++ " (%d)", stub->fop); + break; + } + out: +diff --git a/libglusterfs/src/circ-buff.c b/libglusterfs/src/circ-buff.c +index 484ce7d..6259282 100644 +--- a/libglusterfs/src/circ-buff.c ++++ b/libglusterfs/src/circ-buff.c +@@ -9,6 +9,7 @@ + */ + + #include "circ-buff.h" ++#include "libglusterfs-messages.h" + + void + cb_destroy_data (circular_buffer_t *cb, +@@ -32,8 +33,8 @@ __cb_add_entry_buffer (buffer_t *buffer, void *item) + + if (buffer->use_once == _gf_true && + buffer->used_len == buffer->size_buffer) { +- gf_log ("", GF_LOG_WARNING, "buffer %p is use once buffer", +- buffer); ++ gf_msg ("circ-buff", GF_LOG_WARNING, 0, LG_MSG_BUFFER_ERROR, ++ "buffer %p is use once buffer", buffer); + return -1; + } else { + if (buffer->used_len == buffer->size_buffer) { +@@ -59,8 +60,9 @@ __cb_add_entry_buffer (buffer_t *buffer, void *item) + buffer->cb[buffer->w_index]->data = item; + ret = gettimeofday (&buffer->cb[buffer->w_index]->tv, NULL); + if (ret == -1) +- gf_log_callingfn ("", GF_LOG_WARNING, "getting time of" +- "the day failed"); ++ gf_msg_callingfn ("circ-buff", GF_LOG_WARNING, 0, ++ LG_MSG_GETTIMEOFDAY_FAILED, ++ "getting time of the day failed"); + buffer->w_index++; + buffer->w_index %= buffer->size_buffer; + //used_buffer size cannot be greater than the total buffer size +@@ -90,10 +92,9 @@ cb_buffer_show (buffer_t *buffer) + { + pthread_mutex_lock (&buffer->lock); + { +- gf_log ("", GF_LOG_DEBUG, "w_index: %d, size: %"GF_PRI_SIZET +- " used_buffer: %d", buffer->w_index, +- buffer->size_buffer, +- buffer->used_len); ++ gf_msg_debug ("circ-buff", 0, "w_index: %d, size: %" ++ GF_PRI_SIZET" used_buffer: %d", buffer->w_index, ++ buffer->size_buffer, buffer->used_len); + } + pthread_mutex_unlock (&buffer->lock); + } +@@ -124,7 +125,9 @@ cb_buffer_dump (buffer_t *buffer, void *data, + if (entry) + fn (entry, data); + else +- gf_log_callingfn ("", GF_LOG_WARNING, ++ gf_msg_callingfn ("circ-buff", ++ GF_LOG_WARNING, 0, ++ LG_MSG_NULL_PTR, + "Null entry in " + "circular buffer at " + "index %d.", index); +@@ -150,8 +153,6 @@ cb_buffer_new (size_t buffer_size, gf_boolean_t use_once, + + buffer = GF_CALLOC (1, sizeof (*buffer), gf_common_mt_buffer_t); + if (!buffer) { +- gf_log ("", GF_LOG_ERROR, "could not allocate the " +- "buffer"); + goto out; + } + +@@ -159,8 +160,6 @@ cb_buffer_new (size_t buffer_size, gf_boolean_t use_once, + sizeof (circular_buffer_t *), + gf_common_mt_circular_buffer_t); + if (!buffer->cb) { +- gf_log ("", GF_LOG_ERROR, "could not allocate the " +- "memory for the circular buffer"); + GF_FREE (buffer); + buffer = NULL; + goto out; +diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c +index 84257e6..b7462fc 100644 +--- a/libglusterfs/src/client_t.c ++++ b/libglusterfs/src/client_t.c +@@ -14,7 +14,7 @@ + #include "client_t.h" + #include "list.h" + #include "rpcsvc.h" +- ++#include "libglusterfs-messages.h" + + #ifndef _CONFIG_H + #define _CONFIG_H +@@ -28,7 +28,8 @@ gf_client_chain_client_entries (cliententry_t *entries, uint32_t startidx, + uint32_t i = 0; + + if (!entries) { +- gf_log_callingfn ("client_t", GF_LOG_WARNING, "!entries"); ++ gf_msg_callingfn ("client_t", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!entries"); + return -1; + } + +@@ -53,7 +54,8 @@ gf_client_clienttable_expand (clienttable_t *clienttable, uint32_t nr) + int ret = -1; + + if (clienttable == NULL || nr <= clienttable->max_clients) { +- gf_log_callingfn ("client_t", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("client_t", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + ret = EINVAL; + goto out; + } +@@ -107,7 +109,8 @@ gf_clienttable_alloc (void) + result = gf_client_clienttable_expand (clienttable, + GF_CLIENTTABLE_INITIAL_SIZE); + if (result != 0) { +- gf_log ("client_t", GF_LOG_ERROR, ++ gf_msg ("client_t", GF_LOG_ERROR, 0, ++ LG_MSG_EXPAND_CLIENT_TABLE_FAILED, + "gf_client_clienttable_expand failed"); + GF_FREE (clienttable); + return NULL; +@@ -126,7 +129,8 @@ gf_client_clienttable_destroy (clienttable_t *clienttable) + int32_t i = 0; + + if (!clienttable) { +- gf_log_callingfn ("client_t", GF_LOG_WARNING, "!clienttable"); ++ gf_msg_callingfn ("client_t", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!clienttable"); + return; + } + +@@ -168,7 +172,8 @@ gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid) + unsigned int i = 0; + + if (this == NULL || client_uid == NULL) { +- gf_log_callingfn ("client_t", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("client_t", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + errno = EINVAL; + return NULL; + } +@@ -275,9 +280,10 @@ unlock: + UNLOCK (&clienttable->lock); + + if (client) +- gf_log_callingfn ("client_t", GF_LOG_DEBUG, "%s: bind_ref: %d, " +- "ref: %d", client->client_uid, +- client->ref.bind, client->ref.count); ++ gf_msg_callingfn ("client_t", GF_LOG_DEBUG, 0, LG_MSG_BIND_REF, ++ "%s: bind_ref: %d, ref: %d", ++ client->client_uid, client->ref.bind, ++ client->ref.count); + return client; + } + +@@ -294,8 +300,9 @@ gf_client_put (client_t *client, gf_boolean_t *detached) + if (bind_ref == 0) + unref = _gf_true; + +- gf_log_callingfn ("client_t", GF_LOG_DEBUG, "%s: bind_ref: %d, ref: %d," +- " unref: %d", client->client_uid, client->ref.bind, ++ gf_msg_callingfn ("client_t", GF_LOG_DEBUG, 0, LG_MSG_BIND_REF, "%s: " ++ "bind_ref: %d, ref: %d, unref: %d", ++ client->client_uid, client->ref.bind, + client->ref.count, unref); + if (unref) { + if (detached) +@@ -308,13 +315,15 @@ client_t * + gf_client_ref (client_t *client) + { + if (!client) { +- gf_log_callingfn ("client_t", GF_LOG_ERROR, "null client"); ++ gf_msg_callingfn ("client_t", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "null client"); + return NULL; + } + + INCREMENT_ATOMIC (client->ref.lock, client->ref.count); +- gf_log_callingfn ("client_t", GF_LOG_DEBUG, "%s: ref-count %d", +- client->client_uid, client->ref.count); ++ gf_msg_callingfn ("client_t", GF_LOG_DEBUG, 0, LG_MSG_REF_COUNT, "%s: " ++ "ref-count %d", client->client_uid, ++ client->ref.count); + return client; + } + +@@ -327,7 +336,8 @@ client_destroy (client_t *client) + xlator_t *xtrav = NULL; + + if (client == NULL){ +- gf_log_callingfn ("xlator", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("xlator", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + goto out; + } + +@@ -389,16 +399,18 @@ gf_client_unref (client_t *client) + int refcount; + + if (!client) { +- gf_log_callingfn ("client_t", GF_LOG_ERROR, "client is NULL"); ++ gf_msg_callingfn ("client_t", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "client is NULL"); + return; + } + + refcount = DECREMENT_ATOMIC (client->ref.lock, client->ref.count); +- gf_log_callingfn ("client_t", GF_LOG_DEBUG, "%s: ref-count %d", +- client->client_uid, (int)client->ref.count); ++ gf_msg_callingfn ("client_t", GF_LOG_DEBUG, 0, LG_MSG_REF_COUNT, "%s: " ++ "ref-count %d", client->client_uid, ++ (int)client->ref.count); + if (refcount == 0) { +- gf_log (THIS->name, GF_LOG_INFO, "Shutting down connection %s", +- client->client_uid); ++ gf_msg (THIS->name, GF_LOG_INFO, 0, LG_MSG_DISCONNECT_CLIENT, ++ "Shutting down connection %s", client->client_uid); + client_destroy (client); + } + } +@@ -582,7 +594,8 @@ clienttable_dump (clienttable_t *clienttable, char *prefix) + ret = TRY_LOCK (&clienttable->lock); + { + if (ret) { +- gf_log ("client_t", GF_LOG_WARNING, ++ gf_msg ("client_t", GF_LOG_WARNING, 0, ++ LG_MSG_LOCK_GAIN_FAILED, + "Unable to acquire lock"); + return; + } +@@ -679,7 +692,8 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict) + ret = TRY_LOCK (&clienttable->lock); + { + if (ret) { +- gf_log ("client_t", GF_LOG_WARNING, ++ gf_msg ("client_t", GF_LOG_WARNING, 0, ++ LG_MSG_LOCK_GAIN_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -721,7 +735,8 @@ gf_client_dump_fdtables (xlator_t *this) + ret = TRY_LOCK (&clienttable->lock); + { + if (ret) { +- gf_log ("client_t", GF_LOG_WARNING, ++ gf_msg ("client_t", GF_LOG_WARNING, 0, ++ LG_MSG_LOCK_GAIN_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -786,7 +801,8 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict) + ret = TRY_LOCK (&clienttable->lock); + { + if (ret) { +- gf_log ("client_t", GF_LOG_WARNING, ++ gf_msg ("client_t", GF_LOG_WARNING, 0, ++ LG_MSG_LOCK_GAIN_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -847,7 +863,8 @@ gf_client_dump_inodes (xlator_t *this) + ret = TRY_LOCK (&clienttable->lock); + { + if (ret) { +- gf_log ("client_t", GF_LOG_WARNING, ++ gf_msg ("client_t", GF_LOG_WARNING, 0, ++ LG_MSG_LOCK_GAIN_FAILED, + "Unable to acquire lock"); + goto out; + } +diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c +index 93e7b45..2eb9230 100644 +--- a/libglusterfs/src/compat.c ++++ b/libglusterfs/src/compat.c +@@ -30,6 +30,7 @@ + #include "iatt.h" + #include "inode.h" + #include "run.h" ++#include "libglusterfs-messages.h" + + #ifdef GF_SOLARIS_HOST_OS + int +@@ -46,9 +47,9 @@ solaris_fsetxattr(int fd, const char* key, const char *value, size_t size, + close (attrfd); + } else { + if (errno != ENOENT) +- gf_log ("libglusterfs", GF_LOG_ERROR, +- "Couldn't set extended attribute for %d (%d)", +- fd, errno); ++ gf_msg ("libglusterfs", GF_LOG_ERROR, errno, ++ LG_MSG_SET_ATTRIBUTE_FAILED, "Couldn't set " ++ "extended attribute for %d", fd); + return -1; + } + +@@ -74,9 +75,9 @@ solaris_fgetxattr(int fd, const char* key, char *value, size_t size) + close (attrfd); + } else { + if (errno != ENOENT) +- gf_log ("libglusterfs", GF_LOG_INFO, +- "Couldn't read extended attribute for the file %d (%d)", +- fd, errno); ++ gf_msg ("libglusterfs", GF_LOG_INFO, errno, ++ LG_MSG_READ_ATTRIBUTE_FAILED, "Couldn't read " ++ "extended attribute for the file %d", fd); + if (errno == ENOENT) + errno = ENODATA; + return -1; +@@ -173,7 +174,7 @@ solaris_xattr_resolve_path (const char *real_path, char **path) + if (lstat (export_path, &statbuf)) { + ret = mkdir (export_path, 0777); + if (ret && (errno != EEXIST)) { +- gf_log (THIS->name, GF_LOG_DEBUG, "mkdir failed," ++ gf_msg_debug (THIS->name, 0, "mkdir failed," + " errno: %d", errno); + goto out; + } +@@ -187,9 +188,9 @@ solaris_xattr_resolve_path (const char *real_path, char **path) + if (ret) { + ret = mknod (xattr_path, S_IFREG|O_WRONLY, 0); + if (ret && (errno != EEXIST)) { +- gf_log (THIS->name, GF_LOG_WARNING,"Failed to create " +- "mapped file %s, error %d", xattr_path, +- errno); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "Failed to " ++ "create mapped file %s", xattr_path); + goto out; + } + } +@@ -225,9 +226,9 @@ solaris_setxattr(const char *path, const char* key, const char *value, + ret = 0; + } else { + if (errno != ENOENT) +- gf_log ("libglusterfs", GF_LOG_ERROR, +- "Couldn't set extended attribute for %s (%d)", +- path, errno); ++ gf_msg ("libglusterfs", GF_LOG_ERROR, errno, ++ LG_MSG_SET_ATTRIBUTE_FAILED, "Couldn't set " ++ "extended attribute for %s", path); + ret = -1; + } + GF_FREE (mapped_path); +@@ -411,9 +412,9 @@ solaris_getxattr(const char *path, + close (attrfd); + } else { + if (errno != ENOENT) +- gf_log ("libglusterfs", GF_LOG_INFO, +- "Couldn't read extended attribute for the file %s (%s)", +- path, strerror (errno)); ++ gf_msg ("libglusterfs", GF_LOG_INFO, errno, ++ LG_MSG_READ_ATTRIBUTE_FAILED, "Couldn't read " ++ "extended attribute for the file %s", path); + if (errno == ENOENT) + errno = ENODATA; + ret = -1; +@@ -477,14 +478,16 @@ int solaris_unlink (const char *path) + + if (!ret && mapped_path) { + if (lstat(path, &stbuf)) { +- gf_log (THIS->name, GF_LOG_WARNING, "Stat failed on mapped" +- " file %s with error %d", mapped_path, errno); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "Stat failed on " ++ "mapped file %s", mapped_path); + goto out; + } + if (stbuf.st_nlink == 1) { + if(remove (mapped_path)) +- gf_log (THIS->name, GF_LOG_WARNING, "Failed to remove mapped " +- "file %s. Errno %d", mapped_path, errno); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "Failed to " ++ "remove mapped file %s", mapped_path); + } + + } +@@ -506,8 +509,9 @@ solaris_rename (const char *old_path, const char *new_path) + + if (!ret && mapped_path) { + if (!remove (mapped_path)) +- gf_log (THIS->name, GF_LOG_WARNING, "Failed to remove mapped " +- "file %s. Errno %d", mapped_path, errno); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "Failed to remove " ++ "mapped file %s.", mapped_path); + GF_FREE (mapped_path); + } + +@@ -565,18 +569,16 @@ gf_umount_lazy (char *xlname, char *path, int rmdir_flag) + #endif + ret = runner_run (&runner); + if (ret) { +- gf_log (xlname, GF_LOG_ERROR, +- "Lazy unmount of %s failed: %s", +- path, strerror (errno)); ++ gf_msg (xlname, GF_LOG_ERROR, errno, LG_MSG_UNMOUNT_FAILED, ++ "Lazy unmount of %s", path); + } + + #ifdef GF_LINUX_HOST_OS + if (!ret && rmdir_flag) { + ret = rmdir (path); + if (ret) +- gf_log (xlname, GF_LOG_WARNING, +- "rmdir %s failed: %s", +- path, strerror (errno)); ++ gf_msg (xlname, GF_LOG_WARNING, errno, ++ LG_MSG_DIR_OP_FAILED, "rmdir %s", path); + } + #endif + +diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c +index ffc92e7..fc8a42c 100644 +--- a/libglusterfs/src/dict.c ++++ b/libglusterfs/src/dict.c +@@ -30,6 +30,7 @@ + #include "byte-order.h" + #include "globals.h" + #include "statedump.h" ++#include "libglusterfs-messages.h" + + struct dict_cmp { + dict_t *dict; +@@ -117,7 +118,8 @@ is_data_equal (data_t *one, + data_t *two) + { + if (!one || !two || !one->data || !two->data) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, + "input arguments are provided " + "with value data_t as NULL"); + return -1; +@@ -157,11 +159,11 @@ key_value_cmp (dict_t *one, char *key1, data_t *value1, void *data) + } + + if (value2 == NULL) { +- gf_log (THIS->name, GF_LOG_DEBUG, +- "'%s' found only on one dict", key1); ++ gf_msg_debug (THIS->name, 0, "'%s' found only on one dict", ++ key1); + } else { +- gf_log (THIS->name, GF_LOG_DEBUG, "'%s' is different in two " +- "dicts (%u, %u)", key1, value1->len, value2->len); ++ gf_msg_debug (THIS->name, 0, "'%s' is different in two dicts " ++ "(%u, %u)", key1, value1->len, value2->len); + } + + return -1; +@@ -244,7 +246,7 @@ data_t * + data_copy (data_t *old) + { + if (!old) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, 0, LG_MSG_NULL_PTR, + "old is NULL"); + return NULL; + } +@@ -279,7 +281,8 @@ _dict_lookup (dict_t *this, char *key) + { + int hashval = 0; + if (!this || !key) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, + "!this || !key (%s)", key); + return NULL; + } +@@ -304,8 +307,9 @@ int32_t + dict_lookup (dict_t *this, char *key, data_t **data) + { + if (!this || !key || !data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "!this || !key || !data"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!this || !key || " ++ "!data"); + return -1; + } + +@@ -335,7 +339,6 @@ _dict_set (dict_t *this, char *key, data_t *value, gf_boolean_t replace) + if (!key) { + ret = gf_asprintf (&key, "ref:%p", value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_WARNING, "asprintf failed %s", key); + return -1; + } + key_free = 1; +@@ -421,8 +424,9 @@ dict_set (dict_t *this, + int32_t ret; + + if (!this || !value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "!this || !value for key=%s", key); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!this || !value for " ++ "key=%s", key); + return -1; + } + +@@ -442,7 +446,8 @@ dict_add (dict_t *this, char *key, data_t *value) + int32_t ret; + + if (!this || !value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, + "!this || !value for key=%s", key); + return -1; + } +@@ -463,7 +468,8 @@ dict_get (dict_t *this, char *key) + data_pair_t *pair; + + if (!this || !key) { +- gf_log_callingfn ("dict", GF_LOG_INFO, ++ gf_msg_callingfn ("dict", GF_LOG_INFO, EINVAL, ++ LG_MSG_INVALID_ARG, + "!this || key=%s", (key) ? key : "()"); + return NULL; + } +@@ -486,8 +492,8 @@ dict_del (dict_t *this, char *key) + int hashval = 0; + + if (!this || !key) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "!this || key=%s", key); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "!this || key=%s", key); + return; + } + +@@ -543,7 +549,8 @@ void + dict_destroy (dict_t *this) + { + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return; + } + +@@ -581,7 +588,8 @@ dict_unref (dict_t *this) + int32_t ref; + + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return; + } + +@@ -600,7 +608,8 @@ dict_t * + dict_ref (dict_t *this) + { + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return NULL; + } + +@@ -616,10 +625,12 @@ dict_ref (dict_t *this) + void + data_unref (data_t *this) + { ++ + int32_t ref; + + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return; + } + +@@ -638,7 +649,8 @@ data_t * + data_ref (data_t *this) + { + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return NULL; + } + +@@ -663,7 +675,7 @@ int_to_data (int64_t value) + + ret = gf_asprintf (&data->data, "%"PRId64, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + data->len = strlen (data->data) + 1; +@@ -682,7 +694,7 @@ data_from_int64 (int64_t value) + } + ret = gf_asprintf (&data->data, "%"PRId64, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + data->len = strlen (data->data) + 1; +@@ -701,7 +713,7 @@ data_from_int32 (int32_t value) + } + ret = gf_asprintf (&data->data, "%"PRId32, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + +@@ -721,7 +733,7 @@ data_from_int16 (int16_t value) + } + ret = gf_asprintf (&data->data, "%"PRId16, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + +@@ -741,7 +753,7 @@ data_from_int8 (int8_t value) + } + ret = gf_asprintf (&data->data, "%d", value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + +@@ -761,7 +773,7 @@ data_from_uint64 (uint64_t value) + } + ret = gf_asprintf (&data->data, "%"PRIu64, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + +@@ -803,7 +815,7 @@ data_from_uint32 (uint32_t value) + } + ret = gf_asprintf (&data->data, "%"PRIu32, value); + if (-1 == ret) { +- gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); ++ gf_msg_debug ("dict", 0, "asprintf failed"); + return NULL; + } + +@@ -837,7 +849,8 @@ data_t * + data_from_ptr (void *value) + { + if (!value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "value is NULL"); + return NULL; + } + +@@ -879,7 +892,8 @@ data_t * + str_to_data (char *value) + { + if (!value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "value is NULL"); + return NULL; + } + data_t *data = get_new_data (); +@@ -899,7 +913,8 @@ data_t * + data_from_dynstr (char *value) + { + if (!value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "value is NULL"); + return NULL; + } + +@@ -917,7 +932,8 @@ data_t * + data_from_dynmstr (char *value) + { + if (!value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "value is NULL"); + return NULL; + } + +@@ -950,7 +966,8 @@ data_t * + bin_to_data (void *value, int32_t len) + { + if (!value) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "value is NULL"); + return NULL; + } + +@@ -970,7 +987,8 @@ int64_t + data_to_int64 (data_t *data) + { + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return -1; + } + +@@ -987,7 +1005,8 @@ int32_t + data_to_int32 (data_t *data) + { + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return -1; + } + +@@ -1007,7 +1026,8 @@ data_to_int16 (data_t *data) + int16_t value = 0; + + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return -1; + } + +@@ -1023,9 +1043,9 @@ data_to_int16 (data_t *data) + + if ((value > SHRT_MAX) || (value < SHRT_MIN)) { + errno = ERANGE; +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "Error in data conversion: " +- "detected overflow"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, errno, ++ LG_MSG_DATA_CONVERSION_ERROR, "Error in data" ++ " conversion: detected overflow"); + return -1; + } + +@@ -1039,7 +1059,8 @@ data_to_int8 (data_t *data) + int8_t value = 0; + + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return -1; + } + +@@ -1055,9 +1076,9 @@ data_to_int8 (data_t *data) + + if ((value > SCHAR_MAX) || (value < SCHAR_MIN)) { + errno = ERANGE; +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "Error in data conversion: " +- "detected overflow"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, errno, ++ LG_MSG_DATA_CONVERSION_ERROR, "Error in data" ++ " conversion: detected overflow"); + return -1; + } + +@@ -1116,7 +1137,8 @@ data_to_uint16 (data_t *data) + + if ((USHRT_MAX - value) < 0) { + errno = ERANGE; +- gf_log_callingfn ("dict", GF_LOG_WARNING, ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, errno, ++ LG_MSG_DATA_CONVERSION_ERROR, + "Error in data conversion: " + "overflow detected"); + return -1; +@@ -1131,7 +1153,8 @@ data_to_uint8 (data_t *data) + uint32_t value = 0; + + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return -1; + } + +@@ -1147,9 +1170,9 @@ data_to_uint8 (data_t *data) + + if ((UCHAR_MAX - (uint8_t)value) < 0) { + errno = ERANGE; +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "data conversion overflow detected (%s)", +- strerror(errno)); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, errno, ++ LG_MSG_DATA_CONVERSION_ERROR, "data " ++ "conversion overflow detected"); + return -1; + } + +@@ -1160,7 +1183,8 @@ char * + data_to_str (data_t *data) + { + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return NULL; + } + return data->data; +@@ -1170,7 +1194,8 @@ void * + data_to_ptr (data_t *data) + { + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return NULL; + } + return data->data; +@@ -1180,7 +1205,8 @@ void * + data_to_bin (data_t *data) + { + if (!data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "data is NULL"); + return NULL; + } + return data->data; +@@ -1198,7 +1224,8 @@ dict_remove_foreach_fn (dict_t *d, char *k, + data_t *v, void *_tmp) + { + if (!d || !k) { +- gf_log ("glusterfs", GF_LOG_WARNING, "%s is NULL", ++ gf_msg ("glusterfs", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ENTRY, "%s is NULL", + d?"key":"dictionary"); + return -1; + } +@@ -1250,8 +1277,9 @@ dict_foreach_match (dict_t *dict, + void *action_data) + { + if (!dict || !match || !action) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, +- "dict|match|action is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict|match|action is " ++ "NULL"); + return -1; + } + +@@ -1353,7 +1381,8 @@ dict_copy (dict_t *dict, + dict_t *new) + { + if (!dict) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return NULL; + } + +@@ -1370,7 +1399,8 @@ dict_reset (dict_t *dict) + { + int32_t ret = -1; + if (!dict) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + goto out; + } + dict_foreach (dict, dict_remove_foreach_fn, NULL); +@@ -1417,7 +1447,8 @@ dict_get_with_ref (dict_t *this, char *key, data_t **data) + int ret = -ENOENT; + + if (!this || !key || !data) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, + "dict OR key (%s) is NULL", key); + ret = -EINVAL; + goto err; +@@ -2472,7 +2503,8 @@ _dict_serialized_length (dict_t *this) + count = this->count; + + if (count < 0) { +- gf_log ("dict", GF_LOG_ERROR, "count (%d) < 0!", count); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_COUNT_LESS_THAN_ZERO, "count (%d) < 0!", count); + goto out; + } + +@@ -2480,7 +2512,8 @@ _dict_serialized_length (dict_t *this) + + while (count) { + if (!pair) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_COUNT_LESS_THAN_DATA_PAIRS, + "less than count data pairs found!"); + goto out; + } +@@ -2488,22 +2521,23 @@ _dict_serialized_length (dict_t *this) + len += DICT_DATA_HDR_KEY_LEN + DICT_DATA_HDR_VAL_LEN; + + if (!pair->key) { +- gf_log ("dict", GF_LOG_ERROR, "pair->key is null!"); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_NULL_PTR, "pair->key is null!"); + goto out; + } + + len += strlen (pair->key) + 1 /* for '\0' */; + + if (!pair->value) { +- gf_log ("dict", GF_LOG_ERROR, +- "pair->value is null!"); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_NULL_PTR, "pair->value is null!"); + goto out; + } + + if (pair->value->len < 0) { +- gf_log ("dict", GF_LOG_ERROR, +- "value->len (%d) < 0", +- pair->value->len); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO, ++ "value->len (%d) < 0", pair->value->len); + goto out; + } + +@@ -2542,7 +2576,7 @@ _dict_serialize (dict_t *this, char *buf) + + + if (!buf) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, + "buf is null!"); + goto out; + } +@@ -2550,7 +2584,8 @@ _dict_serialize (dict_t *this, char *buf) + + count = this->count; + if (count < 0) { +- gf_log ("dict", GF_LOG_ERROR, "count (%d) < 0!", count); ++ gf_msg ("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO, ++ "count (%d) < 0!", count); + goto out; + } + +@@ -2561,13 +2596,14 @@ _dict_serialize (dict_t *this, char *buf) + + while (count) { + if (!pair) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_PAIRS_LESS_THAN_COUNT, + "less than count data pairs found!"); + goto out; + } + + if (!pair->key) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_PTR, + "pair->key is null!"); + goto out; + } +@@ -2578,7 +2614,8 @@ _dict_serialize (dict_t *this, char *buf) + buf += DICT_DATA_HDR_KEY_LEN; + + if (!pair->value) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_NULL_PTR, + "pair->value is null!"); + goto out; + } +@@ -2621,7 +2658,8 @@ dict_serialized_length (dict_t *this) + int ret = -EINVAL; + + if (!this) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is null!"); + goto out; + } + +@@ -2652,7 +2690,8 @@ dict_serialize (dict_t *this, char *buf) + int ret = -1; + + if (!this || !buf) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is null!"); + goto out; + } + +@@ -2694,32 +2733,33 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + buf = orig_buf; + + if (!buf) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "buf is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "buf is null!"); + goto out; + } + + if (size == 0) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "size is 0!"); ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "size is 0!"); + goto out; + } + + if (!fill) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "fill is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "fill is null!"); + goto out; + } + + if (!*fill) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "*fill is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "*fill is null!"); + goto out; + } + + if ((buf + DICT_HDR_LEN) > (orig_buf + size)) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "undersized buffer passed. " +- "available (%lu) < required (%lu)", ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, "undersized buffer " ++ "passed. available (%lu) < required (%lu)", + (long)(orig_buf + size), + (long)(buf + DICT_HDR_LEN)); + goto out; +@@ -2730,7 +2770,7 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + buf += DICT_HDR_LEN; + + if (count < 0) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO, + "count (%d) <= 0", count); + goto out; + } +@@ -2740,9 +2780,10 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + + for (i = 0; i < count; i++) { + if ((buf + DICT_DATA_HDR_KEY_LEN) > (orig_buf + size)) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "undersized buffer passed. " +- "available (%lu) < required (%lu)", ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, "undersized " ++ "buffer passed. available (%lu) < " ++ "required (%lu)", + (long)(orig_buf + size), + (long)(buf + DICT_DATA_HDR_KEY_LEN)); + goto out; +@@ -2752,9 +2793,10 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + buf += DICT_DATA_HDR_KEY_LEN; + + if ((buf + DICT_DATA_HDR_VAL_LEN) > (orig_buf + size)) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, +- "undersized buffer passed. " +- "available (%lu) < required (%lu)", ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, "undersized " ++ "buffer passed. available (%lu) < " ++ "required (%lu)", + (long)(orig_buf + size), + (long)(buf + DICT_DATA_HDR_VAL_LEN)); + goto out; +@@ -2764,7 +2806,8 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + buf += DICT_DATA_HDR_VAL_LEN; + + if ((buf + keylen) > (orig_buf + size)) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, + "undersized buffer passed. " + "available (%lu) < required (%lu)", + (long)(orig_buf + size), +@@ -2775,7 +2818,8 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + buf += keylen + 1; /* for '\0' */ + + if ((buf + vallen) > (orig_buf + size)) { +- gf_log_callingfn ("dict", GF_LOG_ERROR, ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, + "undersized buffer passed. " + "available (%lu) < required (%lu)", + (long)(orig_buf + size), +@@ -2784,7 +2828,7 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + } + value = get_new_data (); + value->len = vallen; +- value->data = memdup (buf, vallen); ++value->data = memdup (buf, vallen); + value->is_static = 0; + buf += vallen; + +@@ -2815,8 +2859,7 @@ dict_allocate_and_serialize (dict_t *this, char **buf, u_int *length) + ssize_t len = 0; + + if (!this || !buf) { +- gf_log_callingfn ("dict", GF_LOG_DEBUG, +- "dict OR buf is NULL"); ++ gf_msg_debug ("dict", 0, "dict OR buf is NULL"); + goto out; + } + +@@ -2874,13 +2917,15 @@ _dict_serialize_value_with_delim (dict_t *this, char *buf, int32_t *serz_len, + data_pair_t *pair = NULL; + + if (!buf) { +- gf_log ("dict", GF_LOG_ERROR, "buf is null"); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "buf is null"); + goto out; + } + + count = this->count; + if (count < 0) { +- gf_log ("dict", GF_LOG_ERROR, "count (%d) < 0", count); ++ gf_msg ("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, ++ "count (%d) < 0", count); + goto out; + } + +@@ -2888,19 +2933,22 @@ _dict_serialize_value_with_delim (dict_t *this, char *buf, int32_t *serz_len, + + while (count) { + if (!pair) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_PAIRS_LESS_THAN_COUNT, + "less than count data pairs found"); + goto out; + } + + if (!pair->key || !pair->value) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_KEY_OR_VALUE_NULL, + "key or value is null"); + goto out; + } + + if (!pair->value->data) { +- gf_log ("dict", GF_LOG_ERROR, ++ gf_msg ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_NULL_VALUE_IN_DICT, + "null value found in dict"); + goto out; + } +@@ -2934,7 +2982,8 @@ dict_serialize_value_with_delim (dict_t *this, char *buf, int32_t *serz_len, + int ret = -1; + + if (!this || !buf) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is null!"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is null!"); + goto out; + } + +@@ -2973,16 +3022,19 @@ dict_dump_to_log (dict_t *dict) + char *format = "(%s:%s)"; + + if (!dict) { +- gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return; + } + + ret = dict_dump_to_str (dict, dump, sizeof(dump), format); + if (ret) { +- gf_log ("dict", GF_LOG_WARNING, "Failed to log dictionary"); ++ gf_msg ("dict", GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT, ++ "Failed to log dictionary"); + return; + } +- gf_log_callingfn ("dict", GF_LOG_INFO, "dict=%p (%s)", dict, dump); ++ gf_msg_callingfn ("dict", GF_LOG_INFO, 0, LG_MSG_DICT_ERROR, ++ "dict=%p (%s)", dict, dump); + + return; + } +@@ -2996,14 +3048,15 @@ dict_dump_to_statedump (dict_t *dict, char *dict_name, char *domain) + char *format = "\n\t%s:%s"; + + if (!dict) { +- gf_log_callingfn (domain, GF_LOG_WARNING, "dict is NULL"); ++ gf_msg_callingfn (domain, GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "dict is NULL"); + return; + } + + ret = dict_dump_to_str (dict, dump, sizeof(dump), format); + if (ret) { +- gf_log (domain, GF_LOG_WARNING, "Failed to log dictionary %s", +- dict_name); ++ gf_msg (domain, GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT, ++ "Failed to log dictionary %s", dict_name); + return; + } + gf_proc_dump_build_key (key, domain, dict_name); +diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h +index a9004e9..b7e7b74 100644 +--- a/libglusterfs/src/dict.h ++++ b/libglusterfs/src/dict.h +@@ -21,6 +21,7 @@ + #include + + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + typedef struct _data data_t; + typedef struct _dict dict_t; +@@ -35,7 +36,8 @@ typedef struct _data_pair data_pair_t; + \ + ret = dict_allocate_and_serialize (from_dict, to, &len);\ + if (ret < 0) { \ +- gf_log (this->name, GF_LOG_WARNING, \ ++ gf_msg (this->name, GF_LOG_WARNING, 0, \ ++ LG_MSG_DICT_SERIAL_FAILED, \ + "failed to get serialized dict (%s)", \ + (#from_dict)); \ + ope = EINVAL; \ +@@ -50,9 +52,10 @@ typedef struct _data_pair data_pair_t; + to = dict_new(); \ + GF_VALIDATE_OR_GOTO (xl->name, to, labl); \ + \ +- ret = dict_unserialize (buff, len, &to); \ ++ ret = dict_unserialize (buff, len, &to); \ + if (ret < 0) { \ +- gf_log (xl->name, GF_LOG_WARNING, \ ++ gf_msg (xl->name, GF_LOG_WARNING, 0, \ ++ LG_MSG_DICT_UNSERIAL_FAILED, \ + "failed to unserialize dictionary (%s)", \ + (#to)); \ + \ +-- +1.7.1 + diff --git a/SOURCES/0166-graph-libglusterfs-porting-to-a-new-logging-framewor.patch b/SOURCES/0166-graph-libglusterfs-porting-to-a-new-logging-framewor.patch new file mode 100644 index 0000000..8737144 --- /dev/null +++ b/SOURCES/0166-graph-libglusterfs-porting-to-a-new-logging-framewor.patch @@ -0,0 +1,735 @@ +From 5fb84aeaca956f8b09605491c067a521f2f0942f Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:11:45 +0530 +Subject: [PATCH 166/190] graph/libglusterfs : porting to a new logging framework + +Change-Id: I57ed5c979c15559443712a61f0b1a61c7f5557d8 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10822 +Tested-by: NetBSD Build System +Reviewed-by: Pranith Kumar Karampuri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51692 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/graph-print.c | 16 +++--- + libglusterfs/src/graph.c | 108 +++++++++++++++++++++----------------- + libglusterfs/src/graph.l | 2 - + libglusterfs/src/graph.y | 113 +++++++++++++++++++--------------------- + 4 files changed, 124 insertions(+), 115 deletions(-) + +diff --git a/libglusterfs/src/graph-print.c b/libglusterfs/src/graph-print.c +index d860d63..7842093 100644 +--- a/libglusterfs/src/graph-print.c ++++ b/libglusterfs/src/graph-print.c +@@ -18,7 +18,7 @@ + #include "common-utils.h" + #include "xlator.h" + #include "graph-utils.h" +- ++#include "libglusterfs-messages.h" + + + struct gf_printer { +@@ -33,8 +33,8 @@ gp_write_file (struct gf_printer *gp, char *buf, size_t len) + FILE *f = gp->priv; + + if (fwrite (buf, len, 1, f) != 1) { +- gf_log ("graph-print", GF_LOG_ERROR, "fwrite failed (%s)", +- strerror (errno)); ++ gf_msg ("graph-print", GF_LOG_ERROR, errno, ++ LG_MSG_FWRITE_FAILED, "fwrite failed"); + + return -1; + } +@@ -48,7 +48,8 @@ gp_write_buf (struct gf_printer *gp, char *buf, size_t len) + struct iovec *iov = gp->priv; + + if (iov->iov_len < len) { +- gf_log ("graph-print", GF_LOG_ERROR, "buffer full"); ++ gf_msg ("graph-print", GF_LOG_ERROR, 0, LG_MSG_BUFFER_FULL, ++ "buffer full"); + + return -1; + } +@@ -139,7 +140,8 @@ glusterfs_graph_print (struct gf_printer *gp, glusterfs_graph_t *graph) + out: + len = gp->len; + if (ret == -1) { +- gf_log ("graph-print", GF_LOG_ERROR, "printing failed"); ++ gf_msg ("graph-print", GF_LOG_ERROR, 0, LG_MSG_PRINT_FAILED, ++ "printing failed"); + + return -1; + } +@@ -172,8 +174,8 @@ glusterfs_graph_print_buf (glusterfs_graph_t *graph) + + f = fopen ("/dev/null", "a"); + if (!f) { +- gf_log ("graph-print", GF_LOG_ERROR, +- "cannot open /dev/null (%s)", strerror (errno)); ++ gf_msg ("graph-print", GF_LOG_ERROR, errno, ++ LG_MSG_DIR_OP_FAILED, "cannot open /dev/null"); + + return NULL; + } +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 709ec3b..3f6e399 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -19,6 +19,7 @@ + #include + #include "defaults.h" + ++#include "libglusterfs-messages.h" + + #if 0 + static void +@@ -123,7 +124,7 @@ glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx, + xlator_t *ixl = NULL; + + if (!ctx->master) { +- gf_log ("glusterfs", GF_LOG_ERROR, ++ gf_msg ("glusterfs", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, + "volume \"%s\" can be added from command line only " + "on client side", type); + +@@ -147,7 +148,7 @@ glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx, + ixl->is_autoloaded = autoload; + + if (xlator_set_type (ixl, type) == -1) { +- gf_log ("glusterfs", GF_LOG_ERROR, ++ gf_msg ("glusterfs", GF_LOG_ERROR, 0, LG_MSG_INIT_FAILED, + "%s (%s) initialization failed", + name, type); + return -1; +@@ -262,17 +263,18 @@ gf_add_cmdline_options (glusterfs_graph_t *graph, cmd_args_t *cmd_args) + cmd_option->key, + cmd_option->value); + if (ret == 0) { +- gf_log (trav->name, GF_LOG_INFO, ++ gf_msg (trav->name, GF_LOG_INFO, 0, ++ LG_MSG_VOL_OPTION_ADD, + "adding option '%s' for " + "volume '%s' with value '%s'", + cmd_option->key, trav->name, + cmd_option->value); + } else { +- gf_log (trav->name, GF_LOG_WARNING, ++ gf_msg (trav->name, GF_LOG_WARNING, ++ -ret, LG_MSG_VOL_OPTION_ADD, + "adding option '%s' for " +- "volume '%s' failed: %s", +- cmd_option->key, trav->name, +- strerror (-ret)); ++ "volume '%s' failed", ++ cmd_option->key, trav->name); + } + } + } +@@ -296,8 +298,9 @@ glusterfs_graph_validate_options (glusterfs_graph_t *graph) + + ret = xlator_options_validate (trav, trav->options, &errstr); + if (ret) { +- gf_log (trav->name, GF_LOG_ERROR, +- "validation failed: %s", errstr); ++ gf_msg (trav->name, GF_LOG_ERROR, 0, ++ LG_MSG_VALIDATION_FAILED, "validation failed: " ++ "%s", errstr); + return ret; + } + trav = trav->next; +@@ -318,7 +321,8 @@ glusterfs_graph_init (glusterfs_graph_t *graph) + while (trav) { + ret = xlator_init (trav); + if (ret) { +- gf_log (trav->name, GF_LOG_ERROR, ++ gf_msg (trav->name, GF_LOG_ERROR, 0, ++ LG_MSG_TRANSLATOR_INIT_FAILED, + "initializing translator failed"); + return ret; + } +@@ -353,7 +357,8 @@ _log_if_unknown_option (dict_t *dict, char *key, data_t *value, void *data) + found = xlator_volume_option_get (xl, key); + + if (!found) { +- gf_log (xl->name, GF_LOG_WARNING, ++ gf_msg (xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_XLATOR_OPTION_INVALID, + "option '%s' is not recognized", key); + } + +@@ -384,15 +389,15 @@ fill_uuid (char *uuid, int size) + char now_str[64]; + + if (gettimeofday (&tv, NULL) == -1) { +- gf_log ("graph", GF_LOG_ERROR, +- "gettimeofday: failed %s", +- strerror (errno)); ++ gf_msg ("graph", GF_LOG_ERROR, errno, ++ LG_MSG_GETTIMEOFDAY_FAILED, "gettimeofday: " ++ "failed"); + } + + if (gethostname (hostname, 256) == -1) { +- gf_log ("graph", GF_LOG_ERROR, +- "gethostname: failed %s", +- strerror (errno)); ++ gf_msg ("graph", GF_LOG_ERROR, errno, ++ LG_MSG_GETHOSTNAME_FAILED, "gethostname: " ++ "failed"); + } + + gf_time_fmt (now_str, sizeof now_str, tv.tv_sec, gf_timefmt_dirent); +@@ -461,33 +466,37 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) + /* XXX: attach to -n volname */ + ret = glusterfs_graph_settop (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "glusterfs graph settop failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, ++ "glusterfs graph settop failed"); + return -1; + } + + /* XXX: WORM VOLUME */ + ret = glusterfs_graph_worm (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "glusterfs graph worm failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, ++ "glusterfs graph worm failed"); + return -1; + } + ret = glusterfs_graph_acl (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "glusterfs graph ACL failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, ++ "glusterfs graph ACL failed"); + return -1; + } + + /* XXX: MAC COMPAT */ + ret = glusterfs_graph_mac_compat (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "glusterfs graph mac compat failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, ++ "glusterfs graph mac compat failed"); + return -1; + } + + /* XXX: gfid-access */ + ret = glusterfs_graph_gfid_access (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, + "glusterfs graph 'gfid-access' failed"); + return -1; + } +@@ -495,7 +504,7 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) + /* XXX: topmost xlator */ + ret = glusterfs_graph_meta (graph, ctx); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, + "glusterfs graph meta failed"); + return -1; + } +@@ -651,20 +660,24 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) + /* XXX: all xlator options validation */ + ret = glusterfs_graph_validate_options (graph); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "validate options failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_VALIDATION_FAILED, ++ "validate options failed"); + return ret; + } + + /* XXX: perform init () */ + ret = glusterfs_graph_init (graph); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "init failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_INIT_FAILED, ++ "init failed"); + return ret; + } + + ret = glusterfs_graph_unknown_options (graph); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "unknown options failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, ++ LG_MSG_UNKNOWN_OPTIONS_FAILED, "unknown options " ++ "failed"); + return ret; + } + +@@ -677,7 +690,8 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) + if (ctx->master) { + ret = xlator_notify (ctx->master, GF_EVENT_GRAPH_NEW, graph); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, ++ gf_msg ("graph", GF_LOG_ERROR, 0, ++ LG_MSG_EVENT_NOTIFY_FAILED, + "graph new notification failed"); + return ret; + } +@@ -687,7 +701,8 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) + /* XXX: perform parent up */ + ret = glusterfs_graph_parent_up (graph); + if (ret) { +- gf_log ("graph", GF_LOG_ERROR, "parent up notification failed"); ++ gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_EVENT_NOTIFY_FAILED, ++ "parent up notification failed"); + return ret; + } + +@@ -703,7 +718,7 @@ xlator_equal_rec (xlator_t *xl1, xlator_t *xl2) + int ret = 0; + + if (xl1 == NULL || xl2 == NULL) { +- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument"); ++ gf_msg_debug ("xlator", 0, "invalid argument"); + return -1; + } + +@@ -713,8 +728,8 @@ xlator_equal_rec (xlator_t *xl1, xlator_t *xl2) + while (trav1 && trav2) { + ret = xlator_equal_rec (trav1->xlator, trav2->xlator); + if (ret) { +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "xlators children not equal"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "xlators children " ++ "not equal"); + goto out; + } + +@@ -758,15 +773,13 @@ is_graph_topology_equal (glusterfs_graph_t *graph1, glusterfs_graph_t *graph2) + ret = xlator_equal_rec (trav1, trav2); + + if (ret) { +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "graphs are not equal"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "graphs are not equal"); + ret = _gf_false; + goto out; + } + + ret = _gf_true; +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "graphs are equal"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "graphs are equal"); + + out: + return ret; +@@ -795,7 +808,7 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp, + } + + if (!ctx) { +- gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, ++ gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, 0, LG_MSG_CTX_NULL, + "ctx is NULL"); + goto out; + } +@@ -803,17 +816,19 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp, + oldvolfile_graph = ctx->active; + if (!oldvolfile_graph) { + active_graph_found = _gf_false; +- gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, ++ gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, 0, ++ LG_MSG_ACTIVE_GRAPH_NULL, + "glusterfs_ctx->active is NULL"); + + oldvolfile_fp = tmpfile (); + if (!oldvolfile_fp) { +- gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, "Unable to " +- "create temporary volfile: (%s)", +- strerror (errno)); ++ gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, errno, ++ LG_MSG_TMPFILE_CREATE_FAILED, "Unable to " ++ "create temporary volfile"); + goto out; + } + ++ + fwrite (oldvolfile, oldvollen, 1, oldvolfile_fp); + fflush (oldvolfile_fp); + if (ferror (oldvolfile_fp)) { +@@ -836,21 +851,20 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp, + newvolfile_graph)) { + + ret = 1; +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "Graph topology not equal(should call INIT)"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "Graph topology not " ++ "equal(should call INIT)"); + goto out; + } + +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "Only options have changed in the new " +- "graph"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "Only options have changed in the" ++ " new graph"); + + /* */ + ret = glusterfs_graph_reconfigure (oldvolfile_graph, + newvolfile_graph); + if (ret) { +- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, +- "Could not reconfigure new options in old graph"); ++ gf_msg_debug ("glusterfsd-mgmt", 0, "Could not reconfigure " ++ "new options in old graph"); + goto out; + } + +diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l +index e4eba9c..8af28a4 100644 +--- a/libglusterfs/src/graph.l ++++ b/libglusterfs/src/graph.l +@@ -36,8 +36,6 @@ void append_string(const char *str, int size) + text = GF_REALLOC (text, new_size); + } + if (!text) { +- gf_log ("parser", GF_LOG_ERROR, +- "out of memory"); + return; + } + text_asize = new_size; +diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y +index 42d638e..9fd0282 100644 +--- a/libglusterfs/src/graph.y ++++ b/libglusterfs/src/graph.y +@@ -25,6 +25,7 @@ + #include "xlator.h" + #include "graph-utils.h" + #include "logging.h" ++#include "libglusterfs-messages.h" + + static int new_volume (char *name); + static int volume_type (char *type); +@@ -81,7 +82,7 @@ type_error (void) + { + extern int graphyylineno; + +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR, + "Volume %s, before line %d: Please specify volume type", + curr->name, graphyylineno); + return; +@@ -93,7 +94,7 @@ sub_error (void) + { + extern int graphyylineno; + +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR, + "Volume %s, before line %d: Please specify subvolumes", + curr->name, graphyylineno); + return; +@@ -105,7 +106,7 @@ option_error (void) + { + extern int graphyylineno; + +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR, + "Volume %s, before line %d: Please specify " + "option ", + curr->name, graphyylineno); +@@ -121,14 +122,13 @@ new_volume (char *name) + int ret = 0; + + if (!name) { +- gf_log ("parser", GF_LOG_DEBUG, +- "Invalid argument name: '%s'", name); ++ gf_msg_debug ("parser", 0,"Invalid argument name: '%s'", name); + ret = -1; + goto out; + } + + if (curr) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "new volume (%s) definition in line %d unexpected", + name, graphyylineno); + ret = -1; +@@ -139,7 +139,6 @@ new_volume (char *name) + gf_common_mt_xlator_t); + + if (!curr) { +- gf_log ("parser", GF_LOG_ERROR, "Out of memory"); + ret = -1; + goto out; + } +@@ -148,9 +147,9 @@ new_volume (char *name) + + while (trav) { + if (!strcmp (name, trav->name)) { +- gf_log ("parser", GF_LOG_ERROR, +- "Line %d: volume '%s' defined again", +- graphyylineno, name); ++ gf_msg ("parser", GF_LOG_ERROR, 0, ++ LG_MSG_VOLFILE_PARSE_ERROR, "Line %d: volume " ++ "'%s' defined again", graphyylineno, name); + ret = -1; + goto out; + } +@@ -183,7 +182,7 @@ new_volume (char *name) + + construct->xl_count++; + +- gf_log ("parser", GF_LOG_TRACE, "New node for '%s'", name); ++ gf_msg_trace ("parser", 0, "New node for '%s'", name); + + out: + GF_FREE (name); +@@ -199,14 +198,14 @@ volume_type (char *type) + int32_t ret = 0; + + if (!type) { +- gf_log ("parser", GF_LOG_DEBUG, "Invalid argument type"); ++ gf_msg_debug ("parser", 0, "Invalid argument type"); + ret = -1; + goto out; + } + + ret = xlator_set_type (curr, type); + if (ret) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "Volume '%s', line %d: type '%s' is not valid or " + "not found on this machine", + curr->name, graphyylineno, type); +@@ -214,7 +213,7 @@ volume_type (char *type) + goto out; + } + +- gf_log ("parser", GF_LOG_TRACE, "Type:%s:%s", curr->name, type); ++ gf_msg_trace ("parser", 0, "Type:%s:%s", curr->name, type); + + out: + GF_FREE (type); +@@ -231,7 +230,8 @@ volume_option (char *key, char *value) + char *set_value = NULL; + + if (!key || !value){ +- gf_log ("parser", GF_LOG_ERROR, "Invalid argument"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_VOLFILE_ENTRY, "Invalid argument"); + ret = -1; + goto out; + } +@@ -240,16 +240,15 @@ volume_option (char *key, char *value) + ret = dict_set_dynstr (curr->options, key, set_value); + + if (ret == 1) { +- gf_log ("parser", GF_LOG_ERROR, +- "Volume '%s', line %d: duplicate entry " +- "('option %s') present", ++ gf_msg ("parser", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_VOLFILE_ENTRY, "Volume '%s', line %d: " ++ "duplicate entry ('option %s') present", + curr->name, graphyylineno, key); + ret = -1; + goto out; + } + +- gf_log ("parser", GF_LOG_TRACE, "Option:%s:%s:%s", +- curr->name, key, value); ++ gf_msg_trace ("parser", 0, "Option:%s:%s:%s", curr->name, key, value); + + out: + GF_FREE (key); +@@ -267,7 +266,8 @@ volume_sub (char *sub) + int ret = 0; + + if (!sub) { +- gf_log ("parser", GF_LOG_ERROR, "Invalid subvolumes argument"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, ++ "Invalid subvolumes argument"); + ret = -1; + goto out; + } +@@ -281,16 +281,15 @@ volume_sub (char *sub) + } + + if (!trav) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SUB_VOLUME_ERROR, + "Volume '%s', line %d: subvolume '%s' is not defined " +- "prior to usage", +- curr->name, graphyylineno, sub); ++ "prior to usage",curr->name, graphyylineno, sub); + ret = -1; + goto out; + } + + if (trav == curr) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "Volume '%s', line %d: has '%s' itself as subvolume", + curr->name, graphyylineno, sub); + ret = -1; +@@ -299,12 +298,11 @@ volume_sub (char *sub) + + ret = glusterfs_xlator_link (curr, trav); + if (ret) { +- gf_log ("parser", GF_LOG_ERROR, "Out of memory"); + ret = -1; + goto out; + } + +- gf_log ("parser", GF_LOG_TRACE, "child:%s->%s", curr->name, sub); ++ gf_msg_trace ("parser", 0, "child:%s->%s", curr->name, sub); + + out: + GF_FREE (sub); +@@ -317,11 +315,11 @@ static int + volume_end (void) + { + if (!curr->fops) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, + "\"type\" not specified for volume %s", curr->name); + return -1; + } +- gf_log ("parser", GF_LOG_TRACE, "end:%s", curr->name); ++ gf_msg_trace ("parser", 0, "end:%s", curr->name); + + curr = NULL; + return 0; +@@ -343,38 +341,35 @@ graphyyerror (const char *str) + + if (curr && curr->name && graphyytext) { + if (!strcmp (graphyytext, "volume")) { +- gf_log ("parser", GF_LOG_ERROR, +- "'end-volume' not defined for volume '%s'", +- curr->name); ++ gf_msg ("parser", GF_LOG_ERROR, 0, ++ LG_MSG_VOLUME_ERROR, "'end-volume' not" ++ " defined for volume '%s'", curr->name); + } else if (!strcmp (graphyytext, "type")) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, + "line %d: duplicate 'type' defined for " +- "volume '%s'", +- graphyylineno, curr->name); ++ "volume '%s'", graphyylineno, curr->name); + } else if (!strcmp (graphyytext, "subvolumes")) { +- gf_log ("parser", GF_LOG_ERROR, +- "line %d: duplicate 'subvolumes' defined for " +- "volume '%s'", ++ gf_msg ("parser", GF_LOG_ERROR, 0, ++ LG_MSG_SUB_VOLUME_ERROR, "line %d: duplicate " ++ "'subvolumes' defined for volume '%s'", + graphyylineno, curr->name); + } else if (curr) { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR, + "syntax error: line %d (volume '%s'): \"%s\"" + "\nallowed tokens are 'volume', 'type', " + "'subvolumes', 'option', 'end-volume'()", +- graphyylineno, curr->name, +- graphyytext); ++ graphyylineno, curr->name, graphyytext); + } else { +- gf_log ("parser", GF_LOG_ERROR, ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR, + "syntax error: line %d (just after volume " + "'%s'): \"%s\"\n(%s)", +- graphyylineno, curr->name, +- graphyytext, ++ graphyylineno, curr->name, graphyytext, + "allowed tokens are 'volume', 'type', " + "'subvolumes', 'option', 'end-volume'"); + } + } else { +- gf_log ("parser", GF_LOG_ERROR, +- "syntax error in line %d: \"%s\" \n" ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR, ++ "syntax error in line %d: \"%s\"\n" + "(allowed tokens are 'volume', 'type', " + "'subvolumes', 'option', 'end-volume')\n", + graphyylineno, graphyytext); +@@ -395,7 +390,8 @@ execute_cmd (char *cmd, char **result, size_t size) + + fpp = popen (cmd, "r"); + if (!fpp) { +- gf_log ("parser", GF_LOG_ERROR, "%s: failed to popen", cmd); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_FILE_OP_FAILED, ++ "%s: failed to popen", cmd); + return -1; + } + +@@ -445,7 +441,6 @@ preprocess (FILE *srcfp, FILE *dstfp) + cmd = GF_CALLOC (cmd_buf_size, 1, + gf_common_mt_char); + if (cmd == NULL) { +- gf_log ("parser", GF_LOG_ERROR, "Out of memory"); + return -1; + } + +@@ -453,7 +448,6 @@ preprocess (FILE *srcfp, FILE *dstfp) + gf_common_mt_char); + if (result == NULL) { + GF_FREE (cmd); +- gf_log ("parser", GF_LOG_ERROR, "Out of memory"); + return -1; + } + +@@ -515,9 +509,9 @@ preprocess (FILE *srcfp, FILE *dstfp) + } + + if (in_backtick) { +- gf_log ("parser", GF_LOG_ERROR, +- "Unterminated backtick in volume specfication file at line (%d), column (%d).", +- line, column); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, ++ "Unterminated backtick in volume specfication file at " ++ "line (%d), column (%d).", line, column); + ret = -1; + } + +@@ -573,8 +567,8 @@ glusterfs_graph_construct (FILE *fp) + + ret = unlink (template); + if (ret < 0) { +- gf_log ("parser", GF_LOG_WARNING, "Unable to delete file: %s", +- template); ++ gf_msg ("parser", GF_LOG_WARNING, 0, LG_MSG_FILE_OP_FAILED, ++ "Unable to delete file: %s", template); + } + + tmp_file = fdopen (tmp_fd, "w+b"); +@@ -583,7 +577,8 @@ glusterfs_graph_construct (FILE *fp) + + ret = preprocess (fp, tmp_file); + if (ret < 0) { +- gf_log ("parser", GF_LOG_ERROR, "parsing of backticks failed"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_BACKTICK_PARSE_FAILED, ++ "parsing of backticks failed"); + goto err; + } + +@@ -597,9 +592,8 @@ glusterfs_graph_construct (FILE *fp) + pthread_mutex_unlock (&graph_mutex); + + if (ret == 1) { +- gf_log ("parser", GF_LOG_DEBUG, +- "parsing of volfile failed, please review it " +- "once more"); ++ gf_msg_debug ("parser", 0, "parsing of volfile failed, please " ++ "review it once more"); + goto err; + } + +@@ -609,7 +603,8 @@ err: + if (tmp_file) { + fclose (tmp_file); + } else { +- gf_log ("parser", GF_LOG_ERROR, "cannot create temporary file"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_FILE_OP_FAILED, ++ "cannot create temporary file"); + if (-1 != tmp_fd) + close (tmp_fd); + } +-- +1.7.1 + diff --git a/SOURCES/0167-defaults-globals-iobuf-latency-logging-options-xlato.patch b/SOURCES/0167-defaults-globals-iobuf-latency-logging-options-xlato.patch new file mode 100644 index 0000000..b3d6aa1 --- /dev/null +++ b/SOURCES/0167-defaults-globals-iobuf-latency-logging-options-xlato.patch @@ -0,0 +1,1276 @@ +From 8b74a04e2f030e8b1bad6004103d99c9d2b866ee Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:40:30 +0530 +Subject: [PATCH 167/190] defaults,globals,iobuf,latency,logging,options,xlator/libglusterfs : porting to a new logging framework + +Change-Id: If6a55186cddc3d1c4d22e3d56b45358b84feeb49 +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10826 +Tested-by: NetBSD Build System +Reviewed-by: Pranith Kumar Karampuri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51693 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/defaults.c | 10 ++- + libglusterfs/src/globals.c | 23 ++++--- + libglusterfs/src/iobuf.c | 59 ++++++++++------- + libglusterfs/src/latency.c | 5 +- + libglusterfs/src/logging.c | 41 ++++++----- + libglusterfs/src/options.c | 156 +++++++++++++++++++++++++------------------ + libglusterfs/src/options.h | 31 +++++---- + libglusterfs/src/xlator.c | 85 ++++++++++++----------- + 8 files changed, 231 insertions(+), 179 deletions(-) + +diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c +index 1414da9..b617c43 100644 +--- a/libglusterfs/src/defaults.c ++++ b/libglusterfs/src/defaults.c +@@ -27,6 +27,7 @@ + + #include "xlator.h" + #include "defaults.h" ++#include "libglusterfs-messages.h" + + /* FAILURE_CBK function section */ + +@@ -2196,7 +2197,8 @@ default_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) + int32_t + default_forget (xlator_t *this, inode_t *inode) + { +- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not " ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, ++ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not " + "implement forget_cbk"); + return 0; + } +@@ -2205,7 +2207,8 @@ default_forget (xlator_t *this, inode_t *inode) + int32_t + default_releasedir (xlator_t *this, fd_t *fd) + { +- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not " ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, ++ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not " + "implement releasedir_cbk"); + return 0; + } +@@ -2213,7 +2216,8 @@ default_releasedir (xlator_t *this, fd_t *fd) + int32_t + default_release (xlator_t *this, fd_t *fd) + { +- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not " ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, ++ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not " + "implement release_cbk"); + return 0; + } +diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c +index bd1165e..8943637 100644 +--- a/libglusterfs/src/globals.c ++++ b/libglusterfs/src/globals.c +@@ -20,6 +20,7 @@ + #include "xlator.h" + #include "mem-pool.h" + #include "syncop.h" ++#include "libglusterfs-messages.h" + + const char *gf_fop_list[GF_FOP_MAXVALUE] = { + [GF_FOP_NULL] = "NULL", +@@ -113,7 +114,9 @@ glusterfs_this_init () + + ret = pthread_key_create (&this_xlator_key, glusterfs_this_destroy); + if (ret != 0) { +- gf_log ("", GF_LOG_WARNING, "failed to create the pthread key"); ++ gf_msg ("", GF_LOG_WARNING, ret, ++ LG_MSG_PTHREAD_KEY_CREATE_FAILED, "failed to create " ++ "the pthread key"); + return ret; + } + +@@ -338,43 +341,43 @@ gf_globals_init_once () + + ret = glusterfs_this_init (); + if (ret) { +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_TRANSLATOR_INIT_FAILED, + "ERROR: glusterfs-translator init failed"); + goto out; + } + + ret = glusterfs_uuid_buf_init (); + if(ret) { +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_UUID_BUF_INIT_FAILED, + "ERROR: glusterfs uuid buffer init failed"); + goto out; + } + + ret = glusterfs_lkowner_buf_init (); + if(ret) { +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_LKOWNER_BUF_INIT_FAILED, + "ERROR: glusterfs lkowner buffer init failed"); + goto out; + } + + ret = synctask_init (); + if (ret) { +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCTASK_INIT_FAILED, + "ERROR: glusterfs synctask init failed"); + goto out; + } + + ret = syncopctx_init (); + if (ret) { +- gf_log ("", GF_LOG_CRITICAL, ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCOPCTX_INIT_FAILED, + "ERROR: glusterfs syncopctx init failed"); + goto out; + } + out: + + if (ret) { +- gf_log ("", GF_LOG_CRITICAL, "Exiting as global " +- "initialization failed"); ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_GLOBAL_INIT_FAILED, ++ "Exiting as global initialization failed"); + exit (ret); + } + } +@@ -389,8 +392,8 @@ glusterfs_globals_init (glusterfs_ctx_t *ctx) + ret = pthread_once (&globals_inited, gf_globals_init_once); + + if (ret) +- gf_log ("", GF_LOG_CRITICAL, "pthread_once failed with: %d", +- ret); ++ gf_msg ("", GF_LOG_CRITICAL, ret, LG_MSG_PTHREAD_FAILED, ++ "pthread_once failed"); + + return ret; + } +diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c +index 9dbf19b..a4d3669 100644 +--- a/libglusterfs/src/iobuf.c ++++ b/libglusterfs/src/iobuf.c +@@ -12,7 +12,7 @@ + #include "iobuf.h" + #include "statedump.h" + #include +- ++#include "libglusterfs-messages.h" + + /* + TODO: implement destroy margins and prefetching of arenas +@@ -119,7 +119,8 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena) + iobuf_cnt = iobuf_arena->page_count; + + if (!iobuf_arena->iobufs) { +- gf_log_callingfn (THIS->name, GF_LOG_ERROR, "iobufs not found"); ++ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0, ++ LG_MSG_IOBUFS_NOT_FOUND, "iobufs not found"); + return; + } + +@@ -192,7 +193,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool, size_t page_size, + PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (iobuf_arena->mem_base == MAP_FAILED) { +- gf_log (THIS->name, GF_LOG_WARNING, "maping failed"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_MAPPING_FAILED, ++ "mapping failed"); + goto err; + } + +@@ -205,7 +207,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool, size_t page_size, + + __iobuf_arena_init_iobufs (iobuf_arena); + if (!iobuf_arena->iobufs) { +- gf_log (THIS->name, GF_LOG_ERROR, "init failed"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INIT_IOBUF_FAILED, ++ "init failed"); + goto err; + } + +@@ -232,9 +235,9 @@ __iobuf_arena_unprune (struct iobuf_pool *iobuf_pool, size_t page_size) + + index = gf_iobuf_get_arena_index (page_size); + if (index == -1) { +- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of " +- "iobufs in arena being added is greater than max " +- "available", page_size); ++ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED, ++ "page_size (%zu) of iobufs in arena being added is " ++ "greater than max available", page_size); + return NULL; + } + +@@ -257,9 +260,9 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool, size_t page_size, + + index = gf_iobuf_get_arena_index (page_size); + if (index == -1) { +- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of " +- "iobufs in arena being added is greater than max " +- "available", page_size); ++ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED, ++ "page_size (%zu) of iobufs in arena being added is " ++ "greater than max available", page_size); + return NULL; + } + +@@ -270,7 +273,8 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool, size_t page_size, + num_pages); + + if (!iobuf_arena) { +- gf_log (THIS->name, GF_LOG_WARNING, "arena not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND, ++ "arena not found"); + return NULL; + } + list_add (&iobuf_arena->list, &iobuf_pool->arenas[index]); +@@ -499,9 +503,9 @@ __iobuf_select_arena (struct iobuf_pool *iobuf_pool, size_t page_size) + + index = gf_iobuf_get_arena_index (page_size); + if (index == -1) { +- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of " +- "iobufs in arena being added is greater than max " +- "available", page_size); ++ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED, ++ "page_size (%zu) of iobufs in arena being added is " ++ "greater than max available", page_size); + return NULL; + } + +@@ -570,8 +574,9 @@ __iobuf_get (struct iobuf_arena *iobuf_arena, size_t page_size) + if (iobuf_arena->passive_cnt == 0) { + index = gf_iobuf_get_arena_index (page_size); + if (index == -1) { +- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of " +- "iobufs in arena being added is greater " ++ gf_msg ("iobuf", GF_LOG_ERROR, 0, ++ LG_MSG_PAGE_SIZE_EXCEEDED, "page_size (%zu) of" ++ " iobufs in arena being added is greater " + "than max available", page_size); + goto out; + } +@@ -645,7 +650,7 @@ iobuf_get2 (struct iobuf_pool *iobuf_pool, size_t page_size) + memory allocations */ + iobuf = iobuf_get_from_stdalloc (iobuf_pool, page_size); + +- gf_log ("iobuf", GF_LOG_DEBUG, "request for iobuf of size %zu " ++ gf_msg_debug ("iobuf", 0, "request for iobuf of size %zu " + "is serviced using standard calloc() (%p) as it " + "exceeds the maximum available buffer size", + page_size, iobuf); +@@ -687,14 +692,16 @@ iobuf_get (struct iobuf_pool *iobuf_pool) + iobuf_arena = __iobuf_select_arena (iobuf_pool, + iobuf_pool->default_page_size); + if (!iobuf_arena) { +- gf_log (THIS->name, GF_LOG_WARNING, "arena not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_ARENA_NOT_FOUND, "arena not found"); + goto unlock; + } + + iobuf = __iobuf_get (iobuf_arena, + iobuf_pool->default_page_size); + if (!iobuf) { +- gf_log (THIS->name, GF_LOG_WARNING, "iobuf not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_IOBUF_NOT_FOUND, "iobuf not found"); + goto unlock; + } + +@@ -720,7 +727,7 @@ __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena) + + index = gf_iobuf_get_arena_index (iobuf_arena->page_size); + if (index == -1) { +- gf_log ("iobuf", GF_LOG_DEBUG, "freeing the iobuf (%p) " ++ gf_msg_debug ("iobuf", 0, "freeing the iobuf (%p) " + "allocated with standard calloc()", iobuf); + + /* free up properly without bothering about lists and all */ +@@ -761,13 +768,15 @@ iobuf_put (struct iobuf *iobuf) + + iobuf_arena = iobuf->iobuf_arena; + if (!iobuf_arena) { +- gf_log (THIS->name, GF_LOG_WARNING, "arena not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND, ++ "arena not found"); + return; + } + + iobuf_pool = iobuf_arena->iobuf_pool; + if (!iobuf_pool) { +- gf_log (THIS->name, GF_LOG_WARNING, "iobuf pool not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_POOL_NOT_FOUND, "iobuf pool not found"); + return; + } + +@@ -1040,12 +1049,14 @@ iobuf_size (struct iobuf *iobuf) + GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out); + + if (!iobuf->iobuf_arena) { +- gf_log (THIS->name, GF_LOG_WARNING, "arena not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND, ++ "arena not found"); + goto out; + } + + if (!iobuf->iobuf_arena->iobuf_pool) { +- gf_log (THIS->name, GF_LOG_WARNING, "pool not found"); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_POOL_NOT_FOUND, ++ "pool not found"); + goto out; + } + +diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c +index b22f729..6116159 100644 +--- a/libglusterfs/src/latency.c ++++ b/libglusterfs/src/latency.c +@@ -19,7 +19,7 @@ + #include "xlator.h" + #include "common-utils.h" + #include "statedump.h" +- ++#include "libglusterfs-messages.h" + + void + gf_set_fop_from_fn_pointer (call_frame_t *frame, struct xlator_fops *fops, void *fn) +@@ -182,7 +182,8 @@ gf_latency_toggle (int signum, glusterfs_ctx_t *ctx) + { + if (ctx) { + ctx->measure_latency = !ctx->measure_latency; +- gf_log ("[core]", GF_LOG_INFO, ++ gf_msg ("[core]", GF_LOG_INFO, 0, ++ LG_MSG_LATENCY_MEASUREMENT_STATE, + "Latency measurement turned %s", + ctx->measure_latency ? "on" : "off"); + } +diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c +index 774dd09..61b986c 100644 +--- a/libglusterfs/src/logging.c ++++ b/libglusterfs/src/logging.c +@@ -44,6 +44,7 @@ + #include "defaults.h" + #include "glusterfs.h" + #include "timer.h" ++#include "libglusterfs-messages.h" + + /* Do not replace gf_log in TEST_LOG with gf_msg, as there is a slight chance + * that it could lead to an infinite recursion.*/ +@@ -381,17 +382,18 @@ gf_log_rotate(glusterfs_ctx_t *ctx) + fd = open (ctx->log.filename, + O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + if (fd < 0) { +- gf_log ("logrotate", GF_LOG_ERROR, +- "%s", strerror (errno)); ++ gf_msg ("logrotate", GF_LOG_ERROR, errno, ++ LG_MSG_FILE_OP_FAILED, "failed to open " ++ "logfile"); + return; + } + close (fd); + + new_logfile = fopen (ctx->log.filename, "a"); + if (!new_logfile) { +- gf_log ("logrotate", GF_LOG_CRITICAL, +- "failed to open logfile %s (%s)", +- ctx->log.filename, strerror (errno)); ++ gf_msg ("logrotate", GF_LOG_CRITICAL, errno, ++ LG_MSG_FILE_OP_FAILED, "failed to open logfile" ++ " %s", ctx->log.filename); + return; + } + +@@ -2171,17 +2173,19 @@ _gf_log (const char *domain, const char *file, const char *function, int line, + fd = open (ctx->log.filename, + O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + if (fd < 0) { +- gf_log ("logrotate", GF_LOG_ERROR, +- "%s", strerror (errno)); ++ gf_msg ("logrotate", GF_LOG_ERROR, errno, ++ LG_MSG_FILE_OP_FAILED, ++ "failed to open logfile"); + return -1; + } + close (fd); + + new_logfile = fopen (ctx->log.filename, "a"); + if (!new_logfile) { +- gf_log ("logrotate", GF_LOG_CRITICAL, +- "failed to open logfile %s (%s)", +- ctx->log.filename, strerror (errno)); ++ gf_msg ("logrotate", GF_LOG_CRITICAL, errno, ++ LG_MSG_FILE_OP_FAILED, ++ "failed to open logfile %s", ++ ctx->log.filename); + goto log; + } + +@@ -2323,15 +2327,13 @@ gf_cmd_log_init (const char *filename) + ctx = this->ctx; + + if (!filename){ +- gf_log (this->name, GF_LOG_CRITICAL, "gf_cmd_log_init: no " +- "filename specified\n"); ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, LG_MSG_INVALID_ENTRY, ++ "gf_cmd_log_init: no filename specified\n"); + return -1; + } + + ctx->log.cmd_log_filename = gf_strdup (filename); + if (!ctx->log.cmd_log_filename) { +- gf_log (this->name, GF_LOG_CRITICAL, +- "gf_cmd_log_init: strdup error\n"); + return -1; + } + /* close and reopen cmdlogfile for log rotate*/ +@@ -2343,17 +2345,18 @@ gf_cmd_log_init (const char *filename) + fd = open (ctx->log.cmd_log_filename, + O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + if (fd < 0) { +- gf_log (this->name, GF_LOG_CRITICAL, +- "%s", strerror (errno)); ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ LG_MSG_FILE_OP_FAILED, "failed to open cmd_log_file"); + return -1; + } + close (fd); + + ctx->log.cmdlogfile = fopen (ctx->log.cmd_log_filename, "a"); + if (!ctx->log.cmdlogfile){ +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ LG_MSG_FILE_OP_FAILED, + "gf_cmd_log_init: failed to open logfile \"%s\" " +- "(%s)\n", ctx->log.cmd_log_filename, strerror (errno)); ++ "\n", ctx->log.cmd_log_filename); + return -1; + } + return 0; +@@ -2378,7 +2381,7 @@ gf_cmd_log (const char *domain, const char *fmt, ...) + + + if (!domain || !fmt) { +- gf_log ("glusterd", GF_LOG_TRACE, ++ gf_msg_trace ("glusterd", 0, + "logging: invalid argument\n"); + return -1; + } +diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c +index 75dce0e..4786a27 100644 +--- a/libglusterfs/src/options.c ++++ b/libglusterfs/src/options.c +@@ -17,6 +17,7 @@ + + #include "xlator.h" + #include "defaults.h" ++#include "libglusterfs-messages.h" + + #define GF_OPTION_LIST_EMPTY(_opt) (_opt->value[0] == NULL) + +@@ -32,7 +33,8 @@ xlator_option_validate_path (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "invalid path given '%s'", + value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -42,7 +44,8 @@ xlator_option_validate_path (xlator_t *xl, const char *key, const char *value, + "option %s %s: '%s' is not an " + "absolute path name", + key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -67,7 +70,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "invalid number format \"%s\" in option \"%s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -76,15 +80,15 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "invalid number format \"%s\" in option \"%s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + + if ((opt->min == 0) && (opt->max == 0) && + (opt->validate == GF_OPT_VALIDATE_BOTH)) { +- gf_log (xl->name, GF_LOG_TRACE, +- "no range check required for 'option %s %s'", +- key, value); ++ gf_msg_trace (xl->name, 0, "no range check required for " ++ "'option %s %s'", key, value); + ret = 0; + goto out; + } +@@ -95,7 +99,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, + "'%lld' in 'option %s %s' is smaller than " + "minimum value '%.0f'", inputll, key, + value, opt->min); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + } else if (opt->validate == GF_OPT_VALIDATE_MAX) { +@@ -104,7 +109,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, + "'%lld' in 'option %s %s' is greater than " + "maximum value '%.0f'", inputll, key, + value, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + } else if ((inputll < opt->min) || (inputll > opt->max)) { +@@ -112,7 +118,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, + "'%lld' in 'option %s %s' is out of range " + "[%.0f - %.0f]", + inputll, key, value, opt->min, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s", ++ errstr); + goto out; + } + +@@ -137,15 +144,15 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "invalid number format \"%s\" in option \"%s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + ret = -1; + goto out; + } + + if ((opt->min == 0) && (opt->max == 0)) { +- gf_log (xl->name, GF_LOG_TRACE, +- "no range check required for 'option %s %s'", +- key, value); ++ gf_msg_trace (xl->name, 0, "no range check required for " ++ "'option %s %s'", key, value); + goto out; + } + +@@ -155,13 +162,15 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, "Cache size %" GF_PRI_SIZET " is out of " + "range [%.0f - %.0f]", + size, opt->min, opt->max); +- gf_log (xl->name, GF_LOG_WARNING, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_OUT_OF_RANGE, "%s", errstr); + } else { + snprintf (errstr, 256, + "'%" GF_PRI_SIZET "' in 'option %s %s' " + "is out of range [%.0f - %.0f]", + size, key, value, opt->min, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_OUT_OF_RANGE, "%s", errstr); + ret = -1; + } + } +@@ -189,7 +198,8 @@ xlator_option_validate_bool (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "option %s %s: '%s' is not a valid boolean value", + key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -227,7 +237,8 @@ xlator_option_validate_xlator (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "option %s %s: '%s' is not a valid volume name", + key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -326,7 +337,8 @@ xlator_option_validate_str (xlator_t *xl, const char *key, const char *value, + out: + if (ret) { + set_error_str (errstr, sizeof (errstr), opt, key, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + if (op_errstr) + *op_errstr = gf_strdup (errstr); + } +@@ -347,7 +359,8 @@ xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value + snprintf (errstr, 256, + "invalid percent format \"%s\" in \"option %s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + +@@ -355,7 +368,8 @@ xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value + snprintf (errstr, 256, + "'%lf' in 'option %s %s' is out of range [0 - 100]", + percent, key, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s", ++ errstr); + goto out; + } + +@@ -401,7 +415,8 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key, + "'%lf' in 'option %s %s' is out" + " of range [0 - 100]", size, key, + value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_OUT_OF_RANGE, "%s", errstr); + goto out; + } + ret = 0; +@@ -415,16 +430,15 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key, + " %s' should not be fractional value. Use " + "valid unsigned integer value.", size, key, + value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + + /* Check the range */ + if ((opt->min == 0) && (opt->max == 0)) { +- gf_log (xl->name, GF_LOG_TRACE, +- "no range check required for " +- "'option %s %s'", +- key, value); ++ gf_msg_trace (xl->name, 0, "no range check required " ++ "for 'option %s %s'", key, value); + ret = 0; + goto out; + } +@@ -433,7 +447,8 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key, + "'%lf' in 'option %s %s'" + " is out of range [%.0f - %.0f]", + size, key, value, opt->min, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, ++ "%s", errstr); + goto out; + } + ret = 0; +@@ -445,7 +460,7 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key, + snprintf (errstr, 256, + "invalid number format \"%s\" in \"option %s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", errstr); + + + out: +@@ -469,15 +484,14 @@ xlator_option_validate_time (xlator_t *xl, const char *key, const char *value, + "invalid time format \"%s\" in " + "\"option %s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + + if ((opt->min == 0) && (opt->max == 0)) { +- gf_log (xl->name, GF_LOG_TRACE, +- "no range check required for " +- "'option %s %s'", +- key, value); ++ gf_msg_trace (xl->name, 0, "no range check required for " ++ "'option %s %s'", key, value); + ret = 0; + goto out; + } +@@ -488,7 +502,8 @@ xlator_option_validate_time (xlator_t *xl, const char *key, const char *value, + "out of range [%.0f - %.0f]", + input_time, key, value, + opt->min, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s", ++ errstr); + goto out; + } + +@@ -513,15 +528,15 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, + snprintf (errstr, 256, + "invalid number format \"%s\" in option \"%s\"", + value, key); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + goto out; + } + + if ((opt->min == 0) && (opt->max == 0) && + (opt->validate == GF_OPT_VALIDATE_BOTH)) { +- gf_log (xl->name, GF_LOG_TRACE, +- "no range check required for 'option %s %s'", +- key, value); ++ gf_msg_trace (xl->name, 0, "no range check required for " ++ "'option %s %s'", key, value); + ret = 0; + goto out; + } +@@ -532,7 +547,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, + "'%f' in 'option %s %s' is smaller than " + "minimum value '%f'", input, key, + value, opt->min); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + } else if (opt->validate == GF_OPT_VALIDATE_MAX) { +@@ -541,7 +557,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, + "'%f' in 'option %s %s' is greater than " + "maximum value '%f'", input, key, + value, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_ENTRY, "%s", errstr); + goto out; + } + } else if ((input < opt->min) || (input > opt->max)) { +@@ -549,7 +566,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, + "'%f' in 'option %s %s' is out of range " + "[%f - %f]", + input, key, value, opt->min, opt->max); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s", ++ errstr); + goto out; + } + +@@ -573,7 +591,8 @@ xlator_option_validate_addr (xlator_t *xl, const char *key, const char *value, + "option %s %s: '%s' is not a valid internet-address," + " it does not conform to standards.", + key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + if (op_errstr) + *op_errstr = gf_strdup (errstr); + } +@@ -613,7 +632,8 @@ out: + if (ret) { + snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not " + "a valid internet-address-list", key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + if (op_errstr) + *op_errstr = gf_strdup (errstr); + } +@@ -652,7 +672,8 @@ out: + if (ret) { + snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not " + "a valid mount-auth-address", key, value, value); +- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", ++ errstr); + if (op_errstr) + *op_errstr = gf_strdup (errstr); + } +@@ -678,7 +699,7 @@ gf_validate_size (const char *sizestr, volume_option_t *opt) + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -722,9 +743,9 @@ validate_list_elements (const char *string, volume_option_t *opt, + if (!key || + (key_validator && key_validator(key))) { + ret = -1; +- gf_log (THIS->name, GF_LOG_WARNING, +- "invalid list '%s', key '%s' not valid.", +- string, key); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_ENTRY, "invalid list '%s', key " ++ "'%s' not valid.", string, key); + goto out; + } + +@@ -732,9 +753,9 @@ validate_list_elements (const char *string, volume_option_t *opt, + if (!value || + (value_validator && value_validator(value, opt))) { + ret = -1; +- gf_log (THIS->name, GF_LOG_WARNING, +- "invalid list '%s', value '%s' not valid.", +- string, key); ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_ENTRY, "invalid list '%s', " ++ "value '%s' not valid.", string, key); + goto out; + } + +@@ -744,7 +765,7 @@ validate_list_elements (const char *string, volume_option_t *opt, + + out: + GF_FREE (dup_string); +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; + } + +@@ -836,7 +857,7 @@ xlator_option_validate (xlator_t *xl, char *key, char *value, + }; + + if (opt->type > GF_OPTION_TYPE_MAX) { +- gf_log (xl->name, GF_LOG_ERROR, ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "unknown option type '%d'", opt->type); + goto out; + } +@@ -923,17 +944,17 @@ xl_opt_validate (dict_t *dict, char *key, data_t *value, void *data) + + ret = xlator_option_validate (xl, key, value->data, opt, &errstr); + if (ret) +- gf_log (xl->name, GF_LOG_WARNING, "validate of %s returned %d", +- key, ret); ++ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_VALIDATE_RETURNS, ++ "validate of %s returned %d", key, ret); + + if (errstr) + /* possible small leak of previously set stub->errstr */ + stub->errstr = errstr; + + if (fnmatch (opt->key[0], key, FNM_NOESCAPE) != 0) { +- gf_log (xl->name, GF_LOG_WARNING, "option '%s' is deprecated, " +- "preferred is '%s', continuing with correction", +- key, opt->key[0]); ++ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_INVALID_ENTRY, ++ "option '%s' is deprecated, preferred is '%s', " ++ "continuing with correction", key, opt->key[0]); + dict_set (dict, opt->key[0], value); + dict_del (dict, key); + } +@@ -975,7 +996,7 @@ xlator_options_validate (xlator_t *xl, dict_t *options, char **op_errstr) + + + if (!xl) { +- gf_log (THIS->name, GF_LOG_DEBUG, "'this' not a valid ptr"); ++ gf_msg_debug (THIS->name, 0, "'this' not a valid ptr"); + ret = -1; + goto out; + } +@@ -1005,7 +1026,9 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr) + + while (trav) { + if (xlator_validate_rec (trav->xlator, op_errstr)) { +- gf_log ("xlator", GF_LOG_WARNING, "validate_rec failed"); ++ gf_msg ("xlator", GF_LOG_WARNING, 0, ++ LG_MSG_VALIDATE_REC_FAILED, "validate_rec " ++ "failed"); + goto out; + } + +@@ -1013,7 +1036,7 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr) + } + + if (xlator_dynload (xlator)) +- gf_log (xlator->name, GF_LOG_DEBUG, "Did not load the symbols"); ++ gf_msg_debug (xlator->name, 0, "Did not load the symbols"); + + old_THIS = THIS; + THIS = xlator; +@@ -1029,11 +1052,12 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr) + THIS = old_THIS; + + if (ret) { +- gf_log (xlator->name, GF_LOG_INFO, "%s", *op_errstr); ++ gf_msg (xlator->name, GF_LOG_INFO, 0, LG_MSG_INVALID_ENTRY, ++ "%s", *op_errstr); + goto out; + } + +- gf_log (xlator->name, GF_LOG_DEBUG, "Validated options"); ++ gf_msg_debug (xlator->name, 0, "Validated options"); + + ret = 0; + out: +@@ -1076,7 +1100,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) + if (ret) + goto out; + +- gf_log (trav1->xlator->name, GF_LOG_DEBUG, "reconfigured"); ++ gf_msg_debug (trav1->xlator->name, 0, "reconfigured"); + + trav1 = trav1->next; + trav2 = trav2->next; +@@ -1093,7 +1117,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) + if (ret) + goto out; + } else { +- gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found"); ++ gf_msg_debug (old_xl->name, 0, "No reconfigure() found"); + } + + ret = 0; +diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h +index 05a3d43..fa798db 100644 +--- a/libglusterfs/src/options.h ++++ b/libglusterfs/src/options.h +@@ -21,6 +21,7 @@ + #include + + #include "xlator.h" ++#include "libglusterfs-messages.h" + /* Add possible new type of option you may need */ + typedef enum { + GF_OPTION_TYPE_ANY = 0, +@@ -133,7 +134,8 @@ xlator_option_init_##type (xlator_t *this, dict_t *options, char *key, \ + \ + opt = xlator_volume_option_get (this, key); \ + if (!opt) { \ +- gf_log (this->name, GF_LOG_WARNING, \ ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, \ ++ LG_MSG_INVALID_ENTRY, \ + "unknown option: %s", key); \ + ret = -1; \ + return ret; \ +@@ -146,27 +148,26 @@ xlator_option_init_##type (xlator_t *this, dict_t *options, char *key, \ + if (set_value) \ + value = set_value; \ + if (!value) { \ +- gf_log (this->name, GF_LOG_TRACE, "option %s not set", \ ++ gf_msg_trace (this->name, 0, "option %s not set", \ + key); \ + *val_p = (type_t)0; \ + return 0; \ + } \ + if (value == def_value) { \ +- gf_log (this->name, GF_LOG_TRACE, \ +- "option %s using default value %s", \ +- key, value); \ ++ gf_msg_trace (this->name, 0, "option %s using default" \ ++ " value %s", key, value); \ + } else { \ +- gf_log (this->name, GF_LOG_DEBUG, \ +- "option %s using set value %s", \ +- key, value); \ ++ gf_msg_debug (this->name, 0, "option %s using set" \ ++ " value %s", key, value); \ + } \ + old_THIS = THIS; \ + THIS = this; \ + ret = conv (value, val_p); \ + THIS = old_THIS; \ + if (ret) { \ +- gf_log (this->name, GF_LOG_INFO, \ +- "option %s convertion failed value %s", \ ++ gf_msg (this->name, GF_LOG_INFO, 0, \ ++ LG_MSG_CONVERSION_FAILED, \ ++ "option %s conversion failed value %s", \ + key, value); \ + return ret; \ + } \ +@@ -219,7 +220,8 @@ xlator_option_reconf_##type (xlator_t *this, dict_t *options, char *key, \ + \ + opt = xlator_volume_option_get (this, key); \ + if (!opt) { \ +- gf_log (this->name, GF_LOG_WARNING, \ ++ gf_msg (this->name, GF_LOG_WARNING, EINVAL, \ ++ LG_MSG_INVALID_ENTRY, \ + "unknown option: %s", key); \ + ret = -1; \ + return ret; \ +@@ -232,17 +234,16 @@ xlator_option_reconf_##type (xlator_t *this, dict_t *options, char *key, \ + if (set_value) \ + value = set_value; \ + if (!value) { \ +- gf_log (this->name, GF_LOG_TRACE, "option %s not set", \ +- key); \ ++ gf_msg_trace (this->name, 0, "option %s not set", key); \ + *val_p = (type_t)0; \ + return 0; \ + } \ + if (value == def_value) { \ +- gf_log (this->name, GF_LOG_TRACE, \ ++ gf_msg_trace (this->name, 0, \ + "option %s using default value %s", \ + key, value); \ + } else { \ +- gf_log (this->name, GF_LOG_DEBUG, \ ++ gf_msg_debug (this->name, 0, \ + "option %s using set value %s", \ + key, value); \ + } \ +diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c +index 628f349..52f96c9 100644 +--- a/libglusterfs/src/xlator.c ++++ b/libglusterfs/src/xlator.c +@@ -18,6 +18,7 @@ + #include + #include + #include "defaults.h" ++#include "libglusterfs-messages.h" + + #define SET_DEFAULT_FOP(fn) do { \ + if (!xl->fops->fn) \ +@@ -34,7 +35,8 @@ static void + fill_defaults (xlator_t *xl) + { + if (xl == NULL) { +- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument"); ++ gf_msg_callingfn ("xlator", GF_LOG_WARNING, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return; + } + +@@ -128,23 +130,23 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle, + + ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xlator_type); + if (-1 == ret) { +- gf_log ("xlator", GF_LOG_ERROR, "asprintf failed"); + goto out; + } + + ret = -1; + +- gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name); ++ gf_msg_trace ("xlator", 0, "attempt to load file %s", name); + + handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL); + if (!handle) { +- gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ()); ++ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, ++ "%s", dlerror ()); + goto out; + } + + if (!(opt_list->given_opt = dlsym (handle, "options"))) { + dlerror (); +- gf_log ("xlator", GF_LOG_ERROR, ++ gf_msg ("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED, + "Failed to load xlator opt table"); + goto out; + } +@@ -158,7 +160,7 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle, + if (handle) + dlclose (handle); + +- gf_log ("xlator", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("xlator", 0, "Returning %d", ret); + return ret; + + } +@@ -179,30 +181,30 @@ xlator_dynload (xlator_t *xl) + + ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xl->type); + if (-1 == ret) { +- gf_log ("xlator", GF_LOG_ERROR, "asprintf failed"); + goto out; + } + + ret = -1; + +- gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name); ++ gf_msg_trace ("xlator", 0, "attempt to load file %s", name); + + handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL); + if (!handle) { +- gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ()); ++ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, ++ "%s", dlerror ()); + goto out; + } + xl->dlhandle = handle; + + if (!(xl->fops = dlsym (handle, "fops"))) { +- gf_log ("xlator", GF_LOG_WARNING, "dlsym(fops) on %s", +- dlerror ()); ++ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, ++ "dlsym(fops) on %s", dlerror ()); + goto out; + } + + if (!(xl->cbks = dlsym (handle, "cbks"))) { +- gf_log ("xlator", GF_LOG_WARNING, "dlsym(cbks) on %s", +- dlerror ()); ++ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, ++ "dlsym(cbks) on %s", dlerror ()); + goto out; + } + +@@ -220,39 +222,38 @@ xlator_dynload (xlator_t *xl) + } + else { + if (!(*VOID(&xl->init) = dlsym (handle, "init"))) { +- gf_log ("xlator", GF_LOG_WARNING, "dlsym(init) on %s", ++ gf_msg ("xlator", GF_LOG_WARNING, 0, ++ LG_MSG_DLSYM_ERROR, "dlsym(init) on %s", + dlerror ()); + goto out; + } + + if (!(*VOID(&(xl->fini)) = dlsym (handle, "fini"))) { +- gf_log ("xlator", GF_LOG_WARNING, "dlsym(fini) on %s", ++ gf_msg ("xlator", GF_LOG_WARNING, 0, ++ LG_MSG_DLSYM_ERROR, "dlsym(fini) on %s", + dlerror ()); + goto out; + } + if (!(*VOID(&(xl->reconfigure)) = dlsym (handle, + "reconfigure"))) { +- gf_log ("xlator", GF_LOG_TRACE, +- "dlsym(reconfigure) on %s -- neglecting", +- dlerror()); ++ gf_msg_trace ("xlator", 0, "dlsym(reconfigure) on %s " ++ "-- neglecting", dlerror()); + } + if (!(*VOID(&(xl->notify)) = dlsym (handle, "notify"))) { +- gf_log ("xlator", GF_LOG_TRACE, +- "dlsym(notify) on %s -- neglecting", +- dlerror ()); ++ gf_msg_trace ("xlator", 0, "dlsym(notify) on %s -- " ++ "neglecting", dlerror ()); + } + + } + + if (!(xl->dumpops = dlsym (handle, "dumpops"))) { +- gf_log ("xlator", GF_LOG_TRACE, +- "dlsym(dumpops) on %s -- neglecting", dlerror ()); ++ gf_msg_trace ("xlator", 0, "dlsym(dumpops) on %s -- " ++ "neglecting", dlerror ()); + } + + if (!(*VOID(&(xl->mem_acct_init)) = dlsym (handle, "mem_acct_init"))) { +- gf_log (xl->name, GF_LOG_TRACE, +- "dlsym(mem_acct_init) on %s -- neglecting", +- dlerror ()); ++ gf_msg_trace (xl->name, 0, "dlsym(mem_acct_init) on %s -- " ++ "neglecting", dlerror ()); + } + + vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), +@@ -264,8 +265,8 @@ xlator_dynload (xlator_t *xl) + + if (!(vol_opt->given_opt = dlsym (handle, "options"))) { + dlerror (); +- gf_log (xl->name, GF_LOG_TRACE, +- "Strict option validation not enforced -- neglecting"); ++ gf_msg_trace (xl->name, 0, "Strict option validation not " ++ "enforced -- neglecting"); + } + INIT_LIST_HEAD (&vol_opt->list); + list_add_tail (&vol_opt->list, &xl->volume_options); +@@ -299,8 +300,9 @@ xlator_set_inode_lru_limit (xlator_t *this, void *data) + + if (this->itable) { + if (!data) { +- gf_log (this->name, GF_LOG_WARNING, "input data is " +- "NULL. Cannot update the lru limit of the inode" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ LG_MSG_INVALID_ENTRY, "input data is NULL. " ++ "Cannot update the lru limit of the inode" + " table. Continuing with older value"); + goto out; + } +@@ -413,17 +415,17 @@ xlator_init (xlator_t *xl) + xl->mem_acct_init (xl); + + if (!xl->init) { +- gf_log (xl->name, GF_LOG_WARNING, "No init() found"); ++ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_INIT_FAILED, ++ "No init() found"); + goto out; + } + + ret = __xlator_init (xl); + + if (ret) { +- gf_log (xl->name, GF_LOG_ERROR, ++ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, + "Initialization of volume '%s' failed," +- " review your volfile again", +- xl->name); ++ " review your volfile again", xl->name); + goto out; + } + +@@ -451,7 +453,7 @@ xlator_fini_rec (xlator_t *xl) + } + + xlator_fini_rec (trav->xlator); +- gf_log (trav->xlator->name, GF_LOG_DEBUG, "fini done"); ++ gf_msg_debug (trav->xlator->name, 0, "fini done"); + trav = trav->next; + } + +@@ -467,7 +469,7 @@ xlator_fini_rec (xlator_t *xl) + + THIS = old_THIS; + } else { +- gf_log (xl->name, GF_LOG_DEBUG, "No fini() found"); ++ gf_msg_debug (xl->name, 0, "No fini() found"); + } + xl->init_succeeded = 0; + } +@@ -646,7 +648,8 @@ xlator_tree_free_members (xlator_t *tree) + xlator_t *prev = tree; + + if (!tree) { +- gf_log ("parser", GF_LOG_ERROR, "Translator tree not found"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND, ++ "Translator tree not found"); + return -1; + } + +@@ -666,7 +669,8 @@ xlator_tree_free_memacct (xlator_t *tree) + xlator_t *prev = tree; + + if (!tree) { +- gf_log ("parser", GF_LOG_ERROR, "Translator tree not found"); ++ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND, ++ "Translator tree not found"); + return -1; + } + +@@ -1042,8 +1046,9 @@ glusterd_check_log_level (const char *value) + } + + if (log_level == -1) +- gf_log (THIS->name, GF_LOG_ERROR, "Invalid log-level. possible values " +- "are DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE"); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INIT_FAILED, ++ "Invalid log-level. possible values are " ++ "DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE"); + + return log_level; + } +-- +1.7.1 + diff --git a/SOURCES/0168-event-parse-utils-quota-common-utils-rbthash-libglus.patch b/SOURCES/0168-event-parse-utils-quota-common-utils-rbthash-libglus.patch new file mode 100644 index 0000000..a04f4a9 --- /dev/null +++ b/SOURCES/0168-event-parse-utils-quota-common-utils-rbthash-libglus.patch @@ -0,0 +1,736 @@ +From 1814b75a778d8b2cfb51ac45215495c6b17a5720 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:21:46 +0530 +Subject: [PATCH 168/190] event,parse-utils,quota-common-utils,rbthash/libglusterfs : Porting to new logging framework + +Change-Id: I13ae9a97fe442c06cf50fe77c63718ea0858dc4d +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10823 +Tested-by: NetBSD Build System +Reviewed-by: Pranith Kumar Karampuri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51695 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/event-epoll.c | 80 +++++++++++++++++---------------- + libglusterfs/src/event-history.c | 9 ++-- + libglusterfs/src/event-poll.c | 46 ++++++++++--------- + libglusterfs/src/event.c | 3 +- + libglusterfs/src/parse-utils.c | 7 +-- + libglusterfs/src/quota-common-utils.c | 29 +++++++----- + libglusterfs/src/rbthash.c | 56 ++++++++++++++--------- + 7 files changed, 126 insertions(+), 104 deletions(-) + +diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c +index 92420f3..9403217 100644 +--- a/libglusterfs/src/event-epoll.c ++++ b/libglusterfs/src/event-epoll.c +@@ -20,6 +20,7 @@ + #include "event.h" + #include "mem-pool.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + #ifndef _CONFIG_H + #define _CONFIG_H +@@ -252,8 +253,9 @@ event_pool_new_epoll (int count, int eventthreadcount) + epfd = epoll_create (count); + + if (epfd == -1) { +- gf_log ("epoll", GF_LOG_ERROR, "epoll fd creation failed (%s)", +- strerror (errno)); ++ gf_msg ("epoll", GF_LOG_ERROR, errno, ++ LG_MSG_EPOLL_FD_CREATE_FAILED, "epoll fd creation " ++ "failed"); + GF_FREE (event_pool->reg); + GF_FREE (event_pool); + event_pool = NULL; +@@ -287,7 +289,7 @@ __slot_update_events (struct event_slot_epoll *slot, int poll_in, int poll_out) + /* do nothing */ + break; + default: +- gf_log ("epoll", GF_LOG_ERROR, ++ gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_INVALID_POLL_IN, + "invalid poll_in value %d", poll_in); + break; + } +@@ -303,7 +305,7 @@ __slot_update_events (struct event_slot_epoll *slot, int poll_in, int poll_out) + /* do nothing */ + break; + default: +- gf_log ("epoll", GF_LOG_ERROR, ++ gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_INVALID_POLL_OUT, + "invalid poll_out value %d", poll_out); + break; + } +@@ -345,7 +347,7 @@ event_register_epoll (struct event_pool *event_pool, int fd, + + idx = event_slot_alloc (event_pool, fd); + if (idx == -1) { +- gf_log ("epoll", GF_LOG_ERROR, ++ gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for fd=%d", fd); + return -1; + } +@@ -384,10 +386,9 @@ event_register_epoll (struct event_pool *event_pool, int fd, + UNLOCK (&slot->lock); + + if (ret == -1) { +- gf_log ("epoll", GF_LOG_ERROR, +- "failed to add fd(=%d) to epoll fd(=%d) (%s)", +- fd, event_pool->fd, strerror (errno)); +- ++ gf_msg ("epoll", GF_LOG_ERROR, errno, ++ LG_MSG_EPOLL_FD_ADD_FAILED, "failed to add fd(=%d) to " ++ "epoll fd(=%d)", fd, event_pool->fd); + event_slot_unref (event_pool, slot, idx); + idx = -1; + } +@@ -416,9 +417,10 @@ event_unregister_epoll_common (struct event_pool *event_pool, int fd, + ret = epoll_ctl (event_pool->fd, EPOLL_CTL_DEL, fd, NULL); + + if (ret == -1) { +- gf_log ("epoll", GF_LOG_ERROR, +- "fail to del fd(=%d) from epoll fd(=%d) (%s)", +- fd, event_pool->fd, strerror (errno)); ++ gf_msg ("epoll", GF_LOG_ERROR, errno, ++ LG_MSG_EPOLL_FD_DEL_FAILED, "fail to del " ++ "fd(=%d) from epoll fd(=%d)", fd, ++ event_pool->fd); + goto unlock; + } + +@@ -500,9 +502,10 @@ event_select_on_epoll (struct event_pool *event_pool, int fd, int idx, + ret = epoll_ctl (event_pool->fd, EPOLL_CTL_MOD, fd, + &epoll_event); + if (ret == -1) { +- gf_log ("epoll", GF_LOG_ERROR, +- "failed to modify fd(=%d) events to %d", +- fd, epoll_event.events); ++ gf_msg ("epoll", GF_LOG_ERROR, errno, ++ LG_MSG_EPOLL_FD_MODIFY_FAILED, "failed to " ++ "modify fd(=%d) events to %d", fd, ++ epoll_event.events); + } + } + unlock: +@@ -541,19 +544,19 @@ event_dispatch_epoll_handler (struct event_pool *event_pool, + { + fd = slot->fd; + if (fd == -1) { +- gf_log ("epoll", GF_LOG_ERROR, +- "stale fd found on idx=%d, gen=%d, events=%d, " +- "slot->gen=%d", ++ gf_msg ("epoll", GF_LOG_ERROR, 0, ++ LG_MSG_STALE_FD_FOUND, "stale fd found on " ++ "idx=%d, gen=%d, events=%d, slot->gen=%d", + idx, gen, event->events, slot->gen); + /* fd got unregistered in another thread */ + goto pre_unlock; + } + + if (gen != slot->gen) { +- gf_log ("epoll", GF_LOG_ERROR, +- "generation mismatch on idx=%d, gen=%d, " +- "slot->gen=%d, slot->fd=%d", +- idx, gen, slot->gen, slot->fd); ++ gf_msg ("epoll", GF_LOG_ERROR, 0, ++ LG_MSG_GENERATION_MISMATCH, "generation " ++ "mismatch on idx=%d, gen=%d, slot->gen=%d, " ++ "slot->fd=%d", idx, gen, slot->gen, slot->fd); + /* slot was re-used and therefore is another fd! */ + goto pre_unlock; + } +@@ -582,11 +585,10 @@ pre_unlock: + /* event_unregister() happened while we were + in handler() + */ +- gf_log ("epoll", GF_LOG_DEBUG, +- "generation bumped on idx=%d from " +- "gen=%d to slot->gen=%d, fd=%d, " +- "slot->fd=%d", +- idx, gen, slot->gen, fd, slot->fd); ++ gf_msg_debug ("epoll", 0, "generation bumped on idx=%d" ++ " from gen=%d to slot->gen=%d, fd=%d, " ++ "slot->fd=%d", idx, gen, slot->gen, fd, ++ slot->fd); + goto post_unlock; + } + +@@ -626,7 +628,8 @@ event_dispatch_epoll_worker (void *data) + + GF_VALIDATE_OR_GOTO ("event", event_pool, out); + +- gf_log ("epoll", GF_LOG_INFO, "Started thread with index %d", myindex); ++ gf_msg ("epoll", GF_LOG_INFO, 0, LG_MSG_STARTED_EPOLL_THREAD, "Started" ++ " thread with index %d", myindex); + + pthread_mutex_lock (&event_pool->mutex); + { +@@ -655,8 +658,9 @@ event_dispatch_epoll_worker (void *data) + } + pthread_mutex_unlock (&event_pool->mutex); + if (timetodie) { +- gf_log ("epoll", GF_LOG_INFO, +- "Exited thread with index %d", myindex); ++ gf_msg ("epoll", GF_LOG_INFO, 0, ++ LG_MSG_EXITED_EPOLL_THREAD, "Exited " ++ "thread with index %d", myindex); + goto out; + } + } +@@ -709,8 +713,6 @@ event_dispatch_epoll (struct event_pool *event_pool) + ev_data = GF_CALLOC (1, sizeof (*ev_data), + gf_common_mt_event_pool); + if (!ev_data) { +- gf_log ("epoll", GF_LOG_WARNING, +- "Allocation failure for index %d", i); + if (i == 0) { + /* Need to suceed creating 0'th + * thread, to joinable and wait */ +@@ -738,7 +740,8 @@ event_dispatch_epoll (struct event_pool *event_pool) + if (i != 0) + pthread_detach (event_pool->pollers[i]); + } else { +- gf_log ("epoll", GF_LOG_WARNING, ++ gf_msg ("epoll", GF_LOG_WARNING, 0, ++ LG_MSG_START_EPOLL_THREAD_FAILED, + "Failed to start thread for index %d", + i); + if (i == 0) { +@@ -804,9 +807,6 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) + sizeof (*ev_data), + gf_common_mt_event_pool); + if (!ev_data) { +- gf_log ("epoll", GF_LOG_WARNING, +- "Allocation failure for" +- " index %d", i); + continue; + } + +@@ -817,9 +817,11 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) + event_dispatch_epoll_worker, + ev_data); + if (ret) { +- gf_log ("epoll", GF_LOG_WARNING, +- "Failed to start thread for" +- " index %d", i); ++ gf_msg ("epoll", GF_LOG_WARNING, ++ 0, ++ LG_MSG_START_EPOLL_THREAD_FAILED, ++ "Failed to start thread" ++ " for index %d", i); + GF_FREE (ev_data); + } else { + pthread_detach (t_id); +diff --git a/libglusterfs/src/event-history.c b/libglusterfs/src/event-history.c +index e89df09..95484a4 100644 +--- a/libglusterfs/src/event-history.c ++++ b/libglusterfs/src/event-history.c +@@ -9,6 +9,7 @@ + */ + + #include "event-history.h" ++#include "libglusterfs-messages.h" + + eh_t * + eh_new (size_t buffer_size, gf_boolean_t use_buffer_once, +@@ -19,14 +20,12 @@ eh_new (size_t buffer_size, gf_boolean_t use_buffer_once, + + history = GF_CALLOC (1, sizeof (eh_t), gf_common_mt_eh_t); + if (!history) { +- gf_log ("", GF_LOG_ERROR, "allocating history failed."); + goto out; + } + + buffer = cb_buffer_new (buffer_size, use_buffer_once, + destroy_buffer_data); + if (!buffer) { +- gf_log ("", GF_LOG_ERROR, "allocating circular buffer failed"); + GF_FREE (history); + history = NULL; + goto out; +@@ -44,7 +43,7 @@ eh_dump (eh_t *history, void *data, + int (dump_fn) (circular_buffer_t *buffer, void *data)) + { + if (!history) { +- gf_log ("", GF_LOG_DEBUG, "history is NULL"); ++ gf_msg_debug ("event-history", 0, "history is NULL"); + goto out; + } + +@@ -68,8 +67,8 @@ int + eh_destroy (eh_t *history) + { + if (!history) { +- gf_log ("", GF_LOG_INFO, "history for the xlator is " +- "NULL"); ++ gf_msg ("event-history", GF_LOG_INFO, 0, LG_MSG_INVALID_ARG, ++ "history for the xlator is NULL"); + return -1; + } + +diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c +index 0daceb0..008da10 100644 +--- a/libglusterfs/src/event-poll.c ++++ b/libglusterfs/src/event-poll.c +@@ -20,6 +20,7 @@ + #include "event.h" + #include "mem-pool.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + #ifndef _CONFIG_H + #define _CONFIG_H +@@ -55,9 +56,9 @@ __flush_fd (int fd, int idx, void *data, + do { + ret = read (fd, buf, 64); + if (ret == -1 && errno != EAGAIN) { +- gf_log ("poll", GF_LOG_ERROR, +- "read on %d returned error (%s)", +- fd, strerror (errno)); ++ gf_msg ("poll", GF_LOG_ERROR, errno, ++ LG_MSG_FILE_OP_FAILED, "read on %d returned " ++ "error", fd); + } + } while (ret == 64); + +@@ -121,8 +122,8 @@ event_pool_new_poll (int count, int eventthreadcount) + ret = pipe (event_pool->breaker); + + if (ret == -1) { +- gf_log ("poll", GF_LOG_ERROR, +- "pipe creation failed (%s)", strerror (errno)); ++ gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_PIPE_CREATE_FAILED, ++ "pipe creation failed"); + GF_FREE (event_pool->reg); + GF_FREE (event_pool); + return NULL; +@@ -130,9 +131,8 @@ event_pool_new_poll (int count, int eventthreadcount) + + ret = fcntl (event_pool->breaker[0], F_SETFL, O_NONBLOCK); + if (ret == -1) { +- gf_log ("poll", GF_LOG_ERROR, +- "could not set pipe to non blocking mode (%s)", +- strerror (errno)); ++ gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_SET_PIPE_FAILED, ++ "could not set pipe to non blocking mode"); + close (event_pool->breaker[0]); + close (event_pool->breaker[1]); + event_pool->breaker[0] = event_pool->breaker[1] = -1; +@@ -144,9 +144,8 @@ event_pool_new_poll (int count, int eventthreadcount) + + ret = fcntl (event_pool->breaker[1], F_SETFL, O_NONBLOCK); + if (ret == -1) { +- gf_log ("poll", GF_LOG_ERROR, +- "could not set pipe to non blocking mode (%s)", +- strerror (errno)); ++ gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_SET_PIPE_FAILED, ++ "could not set pipe to non blocking mode"); + + close (event_pool->breaker[0]); + close (event_pool->breaker[1]); +@@ -160,7 +159,7 @@ event_pool_new_poll (int count, int eventthreadcount) + ret = event_register_poll (event_pool, event_pool->breaker[0], + __flush_fd, NULL, 1, 0); + if (ret == -1) { +- gf_log ("poll", GF_LOG_ERROR, ++ gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_REGISTER_PIPE_FAILED, + "could not register pipe fd with poll event loop"); + close (event_pool->breaker[0]); + close (event_pool->breaker[1]); +@@ -172,9 +171,10 @@ event_pool_new_poll (int count, int eventthreadcount) + } + + if (eventthreadcount > 1) { +- gf_log ("poll", GF_LOG_INFO, +- "Currently poll does not use multiple event processing" +- " threads, thread count (%d) ignored", eventthreadcount); ++ gf_msg ("poll", GF_LOG_INFO, 0, ++ LG_MSG_POLL_IGNORE_MULTIPLE_THREADS, "Currently poll " ++ "does not use multiple event processing threads, " ++ "thread count (%d) ignored", eventthreadcount); + } + + return event_pool; +@@ -221,7 +221,8 @@ event_register_poll (struct event_pool *event_pool, int fd, + /* do nothing */ + break; + default: +- gf_log ("poll", GF_LOG_ERROR, ++ gf_msg ("poll", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_POLL_IN, + "invalid poll_in value %d", poll_in); + break; + } +@@ -237,7 +238,8 @@ event_register_poll (struct event_pool *event_pool, int fd, + /* do nothing */ + break; + default: +- gf_log ("poll", GF_LOG_ERROR, ++ gf_msg ("poll", GF_LOG_ERROR, 0, ++ LG_MSG_INVALID_POLL_OUT, + "invalid poll_out value %d", poll_out); + break; + } +@@ -265,7 +267,7 @@ event_unregister_poll (struct event_pool *event_pool, int fd, int idx_hint) + idx = __event_getindex (event_pool, fd, idx_hint); + + if (idx == -1) { +- gf_log ("poll", GF_LOG_ERROR, ++ gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_INDEX_NOT_FOUND, + "index not found for fd=%d (idx_hint=%d)", + fd, idx_hint); + errno = ENOENT; +@@ -310,7 +312,7 @@ event_select_on_poll (struct event_pool *event_pool, int fd, int idx_hint, + idx = __event_getindex (event_pool, fd, idx_hint); + + if (idx == -1) { +- gf_log ("poll", GF_LOG_ERROR, ++ gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_INDEX_NOT_FOUND, + "index not found for fd=%d (idx_hint=%d)", + fd, idx_hint); + errno = ENOENT; +@@ -375,9 +377,9 @@ event_dispatch_poll_handler (struct event_pool *event_pool, + idx = __event_getindex (event_pool, ufds[i].fd, i); + + if (idx == -1) { +- gf_log ("poll", GF_LOG_ERROR, +- "index not found for fd=%d (idx_hint=%d)", +- ufds[i].fd, i); ++ gf_msg ("poll", GF_LOG_ERROR, 0, ++ LG_MSG_INDEX_NOT_FOUND, "index not found for " ++ "fd=%d (idx_hint=%d)", ufds[i].fd, i); + goto unlock; + } + +diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c +index 35564e4..c20355c 100644 +--- a/libglusterfs/src/event.c ++++ b/libglusterfs/src/event.c +@@ -20,6 +20,7 @@ + #include "event.h" + #include "mem-pool.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + #ifndef _CONFIG_H + #define _CONFIG_H +@@ -42,7 +43,7 @@ event_pool_new (int count, int eventthreadcount) + if (event_pool) { + event_pool->ops = &event_ops_epoll; + } else { +- gf_log ("event", GF_LOG_WARNING, ++ gf_msg ("event", GF_LOG_WARNING, 0, LG_MSG_FALLBACK_TO_POLL, + "falling back to poll based event handling"); + } + #endif +diff --git a/libglusterfs/src/parse-utils.c b/libglusterfs/src/parse-utils.c +index f7e9988..304232f 100644 +--- a/libglusterfs/src/parse-utils.c ++++ b/libglusterfs/src/parse-utils.c +@@ -20,6 +20,7 @@ + #include "parse-utils.h" + #include "mem-pool.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + /** + * parser_init: Initialize a parser with the a string to parse and +@@ -46,8 +47,6 @@ parser_init (const char *regex) + + parser->regex = gf_strdup (regex); + if (!parser->regex) { +- gf_log (GF_PARSE, GF_LOG_INFO, +- "Failed to duplicate regex string!"); + GF_FREE (parser); + parser = NULL; + goto out; +@@ -55,7 +54,7 @@ parser_init (const char *regex) + + rc = regcomp (&parser->preg, parser->regex, REG_EXTENDED); + if (rc != 0) { +- gf_log (GF_PARSE, GF_LOG_INFO, ++ gf_msg (GF_PARSE, GF_LOG_INFO, 0, LG_MSG_REGEX_OP_FAILED, + "Failed to compile regex pattern."); + parser_deinit (parser); + parser = NULL; +@@ -160,7 +159,7 @@ parser_get_next_match (struct parser *parser) + + rc = regexec (&parser->preg, parser->_rstr, 1, parser->pmatch, 0); + if (rc != 0) { +- gf_log (GF_PARSE, GF_LOG_DEBUG, ++ gf_msg_debug (GF_PARSE, 0, + "Could not match %s with regex %s", + parser->_rstr, parser->regex); + goto out; +diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c +index 012f80f..8c528c8 100644 +--- a/libglusterfs/src/quota-common-utils.c ++++ b/libglusterfs/src/quota-common-utils.c +@@ -14,6 +14,7 @@ + #include "byte-order.h" + #include "quota-common-utils.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + int32_t + quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta) +@@ -42,8 +43,9 @@ quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta) + * Older version of glusterfs will not have inode count. + * Return failure, this will be healed as part of lookup + */ +- gf_log_callingfn ("quota", GF_LOG_DEBUG, "Object quota xattrs " +- "missing: len = %d", data->len); ++ gf_msg_callingfn ("quota", GF_LOG_DEBUG, 0, ++ LG_MSG_QUOTA_XATTRS_MISSING, "Object quota " ++ "xattrs missing: len = %d", data->len); + ret = -2; + goto out; + } +@@ -83,8 +85,6 @@ quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta, + + value = GF_CALLOC (1, sizeof (quota_meta_t), gf_common_quota_meta_t); + if (value == NULL) { +- gf_log_callingfn ("quota", GF_LOG_ERROR, +- "Memory allocation failed"); + goto out; + } + +@@ -105,7 +105,8 @@ quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta, + } + + if (ret < 0) { +- gf_log_callingfn ("quota", GF_LOG_ERROR, "dict set failed"); ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ LG_MSG_DICT_SET_FAILED, "dict set failed"); + GF_FREE (value); + } + +@@ -133,7 +134,8 @@ quota_conf_read_header (int fd, char *buf) + + out: + if (ret < 0) +- gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read " ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ LG_MSG_QUOTA_CONF_ERROR, "failed to read " + "header from a quota conf"); + + return ret; +@@ -159,8 +161,9 @@ quota_conf_read_version (int fd, float *version) + value = strtof ((buf + strlen(buf) - 3), &tail); + if (tail[0] != '\0') { + ret = -1; +- gf_log_callingfn ("quota", GF_LOG_ERROR, "invalid quota conf " +- "version"); ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ LG_MSG_QUOTA_CONF_ERROR, "invalid quota conf" ++ " version"); + goto out; + } + +@@ -170,8 +173,9 @@ out: + if (ret >= 0) + *version = value; + else +- gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read " +- "version from a quota conf header"); ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ LG_MSG_QUOTA_CONF_ERROR, "failed to " ++ "read version from a quota conf header"); + + return ret; + } +@@ -203,8 +207,9 @@ quota_conf_read_gfid (int fd, void *buf, char *type, float version) + + out: + if (ret < 0) +- gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read " +- "gfid from a quota conf"); ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ LG_MSG_QUOTA_CONF_ERROR, "failed to " ++ "read gfid from a quota conf"); + + return ret; + } +diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c +index 0d7b9e5..47c6d01 100644 +--- a/libglusterfs/src/rbthash.c ++++ b/libglusterfs/src/rbthash.c +@@ -14,6 +14,7 @@ + #include "locking.h" + #include "mem-pool.h" + #include "logging.h" ++#include "libglusterfs-messages.h" + + #include + #include +@@ -57,8 +58,9 @@ __rbthash_init_buckets (rbthash_table_t *tbl, int buckets) + LOCK_INIT (&tbl->buckets[i].bucketlock); + tbl->buckets[i].bucket = rb_create ((rb_comparison_func *)rbthash_comparator, tbl, NULL); + if (!tbl->buckets[i].bucket) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to create rb" +- " table bucket"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RB_TABLE_CREATE_FAILED, "Failed to " ++ "create rb table bucket"); + ret = -1; + goto err; + } +@@ -90,18 +92,19 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc, + int ret = -1; + + if (!hfunc) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Hash function not given"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_HASH_FUNC_ERROR, ++ "Hash function not given"); + return NULL; + } + + if (!entrypool && !expected_entries) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "Both mem-pool and expected entries not provided"); + return NULL; + } + + if (entrypool && expected_entries) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, + "Both mem-pool and expected entries are provided"); + return NULL; + } +@@ -122,8 +125,6 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc, + newtab->entrypool = + mem_pool_new (rbthash_entry_t, expected_entries); + if (!newtab->entrypool) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, +- "Failed to allocate mem-pool"); + goto free_buckets; + } + newtab->pool_alloced = _gf_true; +@@ -137,11 +138,13 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc, + ret = __rbthash_init_buckets (newtab, buckets); + + if (ret == -1) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to init buckets"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_INIT_BUCKET_FAILED, ++ "Failed to init buckets"); + if (newtab->pool_alloced) + mem_pool_destroy (newtab->entrypool); + } else { +- gf_log (GF_RBTHASH, GF_LOG_TRACE, "Inited hash table: buckets:" ++ gf_msg_trace (GF_RBTHASH, 0, "Inited hash table: buckets:" + " %d", buckets); + } + +@@ -172,8 +175,9 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen) + + entry = mem_get (tbl->entrypool); + if (!entry) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get entry from" +- " mem-pool"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_GET_ENTRY_FAILED, ++ "Failed to get entry from mem-pool"); + goto ret; + } + +@@ -187,7 +191,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen) + memcpy (entry->key, key, keylen); + entry->keylen = keylen; + entry->keyhash = tbl->hashfunc (entry->key, entry->keylen); +- gf_log (GF_RBTHASH, GF_LOG_TRACE, "HASH: %u", entry->keyhash); ++ gf_msg_trace (GF_RBTHASH, 0, "HASH: %u", entry->keyhash); + + ret = 0; + free_entry: +@@ -233,7 +237,7 @@ rbthash_entry_bucket (rbthash_table_t *tbl, rbthash_entry_t * entry) + int nbucket = 0; + + nbucket = (entry->keyhash % tbl->numbuckets); +- gf_log (GF_RBTHASH, GF_LOG_TRACE, "BUCKET: %d", nbucket); ++ gf_msg_trace (GF_RBTHASH, 0, "BUCKET: %d", nbucket); + return &tbl->buckets[nbucket]; + } + +@@ -249,7 +253,9 @@ rbthash_insert_entry (rbthash_table_t *tbl, rbthash_entry_t *entry) + + bucket = rbthash_entry_bucket (tbl, entry); + if (!bucket) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_GET_BUCKET_FAILED, ++ "Failed to get bucket"); + goto err; + } + +@@ -257,7 +263,8 @@ rbthash_insert_entry (rbthash_table_t *tbl, rbthash_entry_t *entry) + LOCK (&bucket->bucketlock); + { + if (!rb_probe (bucket->bucket, (void *)entry)) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to insert" ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_INSERT_FAILED, "Failed to insert" + " entry"); + ret = -1; + } +@@ -280,14 +287,18 @@ rbthash_insert (rbthash_table_t *tbl, void *data, void *key, int keylen) + + entry = rbthash_init_entry (tbl, data, key, keylen); + if (!entry) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to init entry"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_INIT_ENTRY_FAILED, ++ "Failed to init entry"); + goto err; + } + + ret = rbthash_insert_entry (tbl, entry); + + if (ret == -1) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to insert entry"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_INSERT_FAILED, ++ "Failed to insert entry"); + rbthash_deinit_entry (tbl, entry); + } + +@@ -311,9 +322,9 @@ rbthash_key_bucket (rbthash_table_t *tbl, void *key, int keylen) + return NULL; + + keyhash = tbl->hashfunc (key, keylen); +- gf_log (GF_RBTHASH, GF_LOG_TRACE, "HASH: %u", keyhash); ++ gf_msg_trace (GF_RBTHASH, 0, "HASH: %u", keyhash); + nbucket = (keyhash % tbl->numbuckets); +- gf_log (GF_RBTHASH, GF_LOG_TRACE, "BUCKET: %u", nbucket); ++ gf_msg_trace (GF_RBTHASH, 0, "BUCKET: %u", nbucket); + + return &tbl->buckets[nbucket]; + } +@@ -331,7 +342,8 @@ rbthash_get (rbthash_table_t *tbl, void *key, int keylen) + + bucket = rbthash_key_bucket (tbl, key, keylen); + if (!bucket) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_GET_BUCKET_FAILED, ++ "Failed to get bucket"); + return NULL; + } + +@@ -363,7 +375,9 @@ rbthash_remove (rbthash_table_t *tbl, void *key, int keylen) + + bucket = rbthash_key_bucket (tbl, key, keylen); + if (!bucket) { +- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket"); ++ gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, ++ LG_MSG_RBTHASH_GET_BUCKET_FAILED, ++ "Failed to get bucket"); + return NULL; + } + +-- +1.7.1 + diff --git a/SOURCES/0169-cluster-afr-truncate-all-sinks-files.patch b/SOURCES/0169-cluster-afr-truncate-all-sinks-files.patch new file mode 100644 index 0000000..da98706 --- /dev/null +++ b/SOURCES/0169-cluster-afr-truncate-all-sinks-files.patch @@ -0,0 +1,127 @@ +From 212caab4f8db39845c4c391e97103be82c0e8d88 Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Tue, 16 Jun 2015 15:57:30 +0530 +Subject: [PATCH 169/190] cluster/afr : truncate all sinks files + + Backport of: http://review.gluster.org/11252/ + +Problem : During data self-heal of sparse files, +sparseness of files is lost. + +Cause : Earlier, only files with larger ia_size in sinks +were being truncated to ia_size of source. This caused +checksum mismatch of sparse blocks when ia_size of files +in sinks were lesser than ia_size of source file. +Leading to unnecessary healing of sparse blocks. +As a result of which sparseness of files was lost. + +Solution : truncate files in all the sinks irrespective of +their size with respect to the source file. After this change, +checksum won't mismatch for sparse blocks and heal won't +be triggered. As a result, sparseness of the files will +be preserved. + +Other fixes in this patch : +1) in afr_does_size_mismatch(), check for mismatch only +in sources. Previously, the check was being done for all +children in a replica. + +2) in __afr_selfheal_data_checksums_match(), check checksum +mismatch only for children with valid responses. + +Upstream URLs: +1) master : http://review.gluster.org/11252/ +2) 3.7 : http://review.gluster.org/11423/ + +Change-Id: Ifcdb1cdc9b16c4a8a7867aecf9fa94b66e5301c2 +BUG: 1223677 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51673 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + tests/bugs/glusterfs/bug-853690.t | 2 +- + xlators/cluster/afr/src/afr-self-heal-data.c | 25 +++++++++++-------------- + 2 files changed, 12 insertions(+), 15 deletions(-) + +diff --git a/tests/bugs/glusterfs/bug-853690.t b/tests/bugs/glusterfs/bug-853690.t +index d81be01..59facfc 100755 +--- a/tests/bugs/glusterfs/bug-853690.t ++++ b/tests/bugs/glusterfs/bug-853690.t +@@ -65,7 +65,7 @@ TEST glusterfs --volfile=$B0/test.vol --attribute-timeout=0 --entry-timeout=0 $M + # Send a single write, guaranteed to be short on one replica, and attempt to + # read the data back. Failure to detect the short write results in different + # file sizes and immediate split-brain (EIO). +-TEST dd if=/dev/zero of=$M0/file bs=128k count=1 ++TEST dd if=/dev/urandom of=$M0/file bs=128k count=1 + TEST dd if=$M0/file of=/dev/null bs=128k count=1 + ######## + # +diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c +index 7567fe9..4ab6f00 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-data.c ++++ b/xlators/cluster/afr/src/afr-self-heal-data.c +@@ -102,10 +102,12 @@ __afr_selfheal_data_checksums_match (call_frame_t *frame, xlator_t *this, + for (i = 0; i < priv->child_count; i++) { + if (i == source) + continue; +- if (memcmp (local->replies[source].checksum, +- local->replies[i].checksum, +- MD5_DIGEST_LENGTH)) +- return _gf_false; ++ if (local->replies[i].valid) { ++ if (memcmp (local->replies[source].checksum, ++ local->replies[i].checksum, ++ MD5_DIGEST_LENGTH)) ++ return _gf_false; ++ } + } + + return _gf_true; +@@ -383,23 +385,16 @@ out: + static int + __afr_selfheal_truncate_sinks (call_frame_t *frame, xlator_t *this, + fd_t *fd, unsigned char *healed_sinks, +- struct afr_reply *replies, uint64_t size) ++ uint64_t size) + { + afr_local_t *local = NULL; + afr_private_t *priv = NULL; +- unsigned char *larger_sinks = 0; + int i = 0; + + local = frame->local; + priv = this->private; + +- larger_sinks = alloca0 (priv->child_count); +- for (i = 0; i < priv->child_count; i++) { +- if (healed_sinks[i] && replies[i].poststat.ia_size > size) +- larger_sinks[i] = 1; +- } +- +- AFR_ONLIST (larger_sinks, frame, attr_cbk, ftruncate, fd, size, NULL); ++ AFR_ONLIST (healed_sinks, frame, attr_cbk, ftruncate, fd, size, NULL); + + for (i = 0; i < priv->child_count; i++) + if (healed_sinks[i] && local->replies[i].op_ret == -1) +@@ -444,6 +439,9 @@ afr_does_size_mismatch (xlator_t *this, unsigned char *sources, + if (replies[i].op_ret < 0) + continue; + ++ if (!sources[i]) ++ continue; ++ + if (!min) + min = &replies[i].poststat; + +@@ -691,7 +689,6 @@ __afr_selfheal_data (call_frame_t *frame, xlator_t *this, fd_t *fd, + } + + ret = __afr_selfheal_truncate_sinks (frame, this, fd, healed_sinks, +- locked_replies, + locked_replies[source].poststat.ia_size); + if (ret < 0) + goto unlock; +-- +1.7.1 + diff --git a/SOURCES/0170-features-changelog-Always-log-directory-rename-opera.patch b/SOURCES/0170-features-changelog-Always-log-directory-rename-opera.patch new file mode 100644 index 0000000..2d08e9e --- /dev/null +++ b/SOURCES/0170-features-changelog-Always-log-directory-rename-opera.patch @@ -0,0 +1,41 @@ +From 636bc6d1e558b2da71a0013c423c043025703ecf Mon Sep 17 00:00:00 2001 +From: Vijay Bellur +Date: Mon, 22 Jun 2015 19:01:39 -0400 +Subject: [PATCH 170/190] features/changelog: Always log directory rename operations + +Directory renames are being ignored as special renames. special +renames can happen only on files. Hence always log directory +rename operations in changelog. + +Change-Id: I4fbdb3e02e634a39a8846fb2f7a4c6cc2ba74400 +BUG: 1235236 +Reviewed-On: http://review.gluster.org/11356 +Reviewed-On: http://review.gluster.org/11378 +Signed-off-by: Vijay Bellur +Signed-off-by: Saravanakumar Arumugam +Reviewed-on: https://code.engineering.redhat.com/gerrit/51496 +Reviewed-by: Kotresh Hiremath Ravishankar +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + xlators/features/changelog/src/changelog.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c +index 47696f4..428ed1d 100644 +--- a/xlators/features/changelog/src/changelog.c ++++ b/xlators/features/changelog/src/changelog.c +@@ -381,7 +381,9 @@ changelog_rename (call_frame_t *frame, xlator_t *this, + CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); + + ret = dict_get_bin (xdata, DHT_CHANGELOG_RENAME_OP_KEY, (void **)&info); +- if (ret) { /* xdata "NOT" set, Special rename => avoid logging */ ++ if (ret && oldloc->inode->ia_type != IA_IFDIR) { ++ /* xdata "NOT" set for a non-directory, ++ * Special rename => avoid logging */ + goto wind; + } + +-- +1.7.1 + diff --git a/SOURCES/0171-cluster-ec-Fix-incorrect-check-for-iatt-differences.patch b/SOURCES/0171-cluster-ec-Fix-incorrect-check-for-iatt-differences.patch new file mode 100644 index 0000000..03d29dc --- /dev/null +++ b/SOURCES/0171-cluster-ec-Fix-incorrect-check-for-iatt-differences.patch @@ -0,0 +1,84 @@ +From e41916c72748a0997dbdd56e2f33525322944ac5 Mon Sep 17 00:00:00 2001 +From: Xavier Hernandez +Date: Sun, 31 May 2015 19:53:41 +0200 +Subject: [PATCH 171/190] cluster/ec: Fix incorrect check for iatt differences + +A previous patch (http://review.gluster.org/10974) introduced a +bug that caused that some metadata differences could not be +detected in some circumstances. This could cause that self-heal +is not triggered and the file not repaired. + +We also need to consider all differences for lookup requests, even +if there isn't any lock. Special handling of differences in lookup +is already done in lookup specific code. + +Backporting patch http://review.gluster.org/#/c/11018/ + +cherry-pick of commit 29d5bd5fc8a7b24865801de9f2e3f10d55af6e85 +>Change-Id: I3766b0f412b3201ae8a04664349578713572edc6 +>BUG: 1225793 +>Signed-off-by: Xavier Hernandez +>Reviewed-on: http://review.gluster.org/11018 +>Tested-by: Gluster Build System +>Tested-by: NetBSD Build System +>Reviewed-by: Pranith Kumar Karampuri + +Change-Id: I3766b0f412b3201ae8a04664349578713572edc6 +BUG: 1226149 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/51747 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/ec/src/ec-combine.c | 24 +++++++++++++++++++----- + 1 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c +index bf698d9..d55e42a 100644 +--- a/xlators/cluster/ec/src/ec-combine.c ++++ b/xlators/cluster/ec/src/ec-combine.c +@@ -131,6 +131,15 @@ ec_iatt_is_trusted(ec_fop_data_t *fop, struct iatt *iatt) + fop = fop->parent; + } + ++ /* Lookups are special requests always done without locks taken but they ++ * require to be able to identify differences between bricks. Special ++ * handling of these differences is already done in lookup specific code ++ * so we shouldn't ignore any difference here and consider all iatt ++ * structures as trusted. */ ++ if (fop->id == GF_FOP_LOOKUP) { ++ return _gf_true; ++ } ++ + /* Check if the iatt references an inode locked by the current fop */ + for (i = 0; i < fop->lock_count; i++) { + ino = gfid_to_ino(fop->locks[i].lock->loc.inode->gfid); +@@ -168,15 +177,20 @@ int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src, + (dst[i].ia_size != src[i].ia_size)) || + (st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type) != + st_mode_from_ia(src[i].ia_prot, src[i].ia_type)))) { +- if (!ec_iatt_is_trusted(fop, dst)) { +- /* If the iatt contains information from an inode that is not +- * locked, we ignore these differences and don't care which ++ if (ec_iatt_is_trusted(fop, dst)) { ++ /* If the iatt contains information from an inode that is ++ * locked, these differences are real problems, so we need to ++ * report them. Otherwise we ignore them and don't care which + * data is returned. */ +- failed = _gf_false; ++ failed = _gf_true; ++ } else { ++ gf_log(fop->xl->name, GF_LOG_DEBUG, ++ "Ignoring iatt differences because inode is not " ++ "locked"); + } + } + if (failed) { +- gf_log(THIS->name, GF_LOG_WARNING, ++ gf_log(fop->xl->name, GF_LOG_WARNING, + "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, " + "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, " + "mode: %o-%o)", +-- +1.7.1 + diff --git a/SOURCES/0172-ec-Porting-messages-to-new-logging-framework.patch b/SOURCES/0172-ec-Porting-messages-to-new-logging-framework.patch new file mode 100644 index 0000000..0807f80 --- /dev/null +++ b/SOURCES/0172-ec-Porting-messages-to-new-logging-framework.patch @@ -0,0 +1,4195 @@ +From 409aa54928764cddf17a3937b5d37619ea08c394 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 30 Apr 2015 14:28:10 +0530 +Subject: [PATCH 172/190] ec: Porting messages to new logging framework + +This is a backport of http://review.gluster.org/#/c/10465/ + +cherry-picked from commit b0b9eaea9dbb4e9a535f5e969defc4556a9e2204 +>Change-Id: Ia05ae750a245a37d48978e5f37b52f4fb0507a8c +>BUG: 1194640 +>Signed-off-by: Nandaja Varma + +Change-Id: Ia05ae750a245a37d48978e5f37b52f4fb0507a8c +BUG: 1231773 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/51705 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/glfs-message-id.h | 4 + + xlators/cluster/ec/src/Makefile.am | 1 + + xlators/cluster/ec/src/ec-combine.c | 76 +++-- + xlators/cluster/ec/src/ec-common.c | 103 ++++--- + xlators/cluster/ec/src/ec-data.c | 22 +- + xlators/cluster/ec/src/ec-dir-read.c | 56 ++-- + xlators/cluster/ec/src/ec-dir-write.c | 117 +++++--- + xlators/cluster/ec/src/ec-generic.c | 130 +++++--- + xlators/cluster/ec/src/ec-heal.c | 112 ++++--- + xlators/cluster/ec/src/ec-heald.c | 18 +- + xlators/cluster/ec/src/ec-helpers.c | 51 ++- + xlators/cluster/ec/src/ec-inode-read.c | 181 +++++++---- + xlators/cluster/ec/src/ec-inode-write.c | 181 +++++++---- + xlators/cluster/ec/src/ec-locks.c | 153 ++++++--- + xlators/cluster/ec/src/ec-messages.h | 519 +++++++++++++++++++++++++++++++ + xlators/cluster/ec/src/ec.c | 66 +++-- + 16 files changed, 1327 insertions(+), 463 deletions(-) + create mode 100644 xlators/cluster/ec/src/ec-messages.h + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 099ae2c..53b004d 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -117,6 +117,10 @@ + #define GLFS_MSGID_COMP_CTR_END (GLFS_MSGID_COMP_CTR+\ + GLFS_MSGID_SEGMENT) + ++#define GLFS_MSGID_COMP_EC GLFS_MSGID_COMP_CTR_END ++#define GLFS_MSGID_COMP_EC_END (GLFS_MSGID_COMP_EC +\ ++ GLFS_MSGID_SEGMENT) ++ + /* --- new segments for messages goes above this line --- */ + + #endif /* !_GLFS_MESSAGE_ID_H_ */ +diff --git a/xlators/cluster/ec/src/Makefile.am b/xlators/cluster/ec/src/Makefile.am +index 12d87f9..3ebd5ec 100644 +--- a/xlators/cluster/ec/src/Makefile.am ++++ b/xlators/cluster/ec/src/Makefile.am +@@ -27,6 +27,7 @@ ec_headers += ec-combine.h + ec_headers += ec-gf.h + ec_headers += ec-method.h + ec_headers += ec-heald.h ++ec_headers += ec-messages.h + + ec_ext_sources = $(top_builddir)/xlators/lib/src/libxlator.c + +diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c +index d55e42a..f3905ce 100644 +--- a/xlators/cluster/ec/src/ec-combine.c ++++ b/xlators/cluster/ec/src/ec-combine.c +@@ -17,6 +17,7 @@ + #include "ec-helpers.h" + #include "ec-common.h" + #include "ec-combine.h" ++#include "ec-messages.h" + #include "quota-common-utils.h" + + #define EC_QUOTA_PREFIX "trusted.glusterfs.quota." +@@ -78,16 +79,18 @@ ec_combine_write (ec_fop_data_t *fop, ec_cbk_data_t *dst, + valid = 5; + break; + default: +- gf_log_callingfn (fop->xl->name, GF_LOG_WARNING, "Invalid fop " +- "%d", fop->id); ++ gf_msg_callingfn (fop->xl->name, GF_LOG_WARNING, EINVAL, ++ EC_MSG_INVALID_FOP, ++ "Invalid fop %d", fop->id); + return 0; + break; + } + + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, valid)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " +- "answers of '%s'", gf_fop_list[fop->id]); +- ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, ++ "Mismatching iatt in " ++ "answers of '%s'", gf_fop_list[fop->id]); + return 0; + } + return 1; +@@ -184,22 +187,23 @@ int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src, + * data is returned. */ + failed = _gf_true; + } else { +- gf_log(fop->xl->name, GF_LOG_DEBUG, ++ gf_msg_debug (fop->xl->name, 0, + "Ignoring iatt differences because inode is not " + "locked"); + } + } + if (failed) { +- gf_log(fop->xl->name, GF_LOG_WARNING, +- "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, " +- "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, " +- "mode: %o-%o)", +- dst[i].ia_ino, src[i].ia_ino, dst[i].ia_nlink, +- src[i].ia_nlink, dst[i].ia_uid, src[i].ia_uid, +- dst[i].ia_gid, src[i].ia_gid, dst[i].ia_rdev, +- src[i].ia_rdev, dst[i].ia_size, src[i].ia_size, +- st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type), +- st_mode_from_ia(src[i].ia_prot, dst[i].ia_type)); ++ gf_msg (fop->xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_IATT_COMBINE_FAIL, ++ "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, " ++ "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, " ++ "mode: %o-%o)", ++ dst[i].ia_ino, src[i].ia_ino, dst[i].ia_nlink, ++ src[i].ia_nlink, dst[i].ia_uid, src[i].ia_uid, ++ dst[i].ia_gid, src[i].ia_gid, dst[i].ia_rdev, ++ src[i].ia_rdev, dst[i].ia_size, src[i].ia_size, ++ st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type), ++ st_mode_from_ia(src[i].ia_prot, dst[i].ia_type)); + + return 0; + } +@@ -291,8 +295,10 @@ int32_t ec_dict_list(data_t ** list, int32_t * count, ec_cbk_data_t * cbk, + { + if (i >= max) + { +- gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "Unexpected number of " +- "dictionaries"); ++ gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_DICT_NUMS, ++ "Unexpected number of " ++ "dictionaries"); + + return 0; + } +@@ -339,7 +345,9 @@ char * ec_concat_prepare(xlator_t * xl, char ** sep, char ** post, + return str; + + out: +- gf_log(xl->name, GF_LOG_ERROR, "Invalid concat format"); ++ gf_msg (xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_FORMAT, ++ "Invalid concat format"); + + GF_FREE(str); + +@@ -652,8 +660,10 @@ int32_t ec_dict_data_stime(ec_cbk_data_t * cbk, int32_t which, char * key) + { + if (gf_get_max_stime(cbk->fop->xl, dict, key, data[i]) != 0) + { +- gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "STIME combination " +- "failed"); ++ gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_STIME_COMBINE_FAIL, ++ "STIME combination " ++ "failed"); + + return -1; + } +@@ -731,8 +741,10 @@ int32_t ec_dict_combine(ec_cbk_data_t * cbk, int32_t which) + if ((dict != NULL) && + (dict_foreach(dict, ec_dict_data_combine, &data) != 0)) + { +- gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "Dictionary combination " +- "failed"); ++ gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_COMBINE_FAIL, ++ "Dictionary combination " ++ "failed"); + + return 0; + } +@@ -835,9 +847,10 @@ void ec_statvfs_combine(struct statvfs * dst, struct statvfs * src) + + if (dst->f_flag != src->f_flag) + { +- gf_log(THIS->name, GF_LOG_DEBUG, "Mismatching file system flags " +- "(%lX, %lX)", +- dst->f_flag, src->f_flag); ++ gf_msg_debug (THIS->name, 0, ++ "Mismatching file system flags " ++ "(%lX, %lX)", ++ dst->f_flag, src->f_flag); + } + dst->f_flag &= src->f_flag; + } +@@ -849,7 +862,7 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, + + if (dst->op_ret != src->op_ret) + { +- gf_log(fop->xl->name, GF_LOG_DEBUG, "Mismatching return code in " ++ gf_msg_debug (fop->xl->name, 0, "Mismatching return code in " + "answers of '%s': %d <-> %d", + ec_fop_name(fop->id), dst->op_ret, src->op_ret); + +@@ -859,7 +872,7 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, + { + if (dst->op_errno != src->op_errno) + { +- gf_log(fop->xl->name, GF_LOG_DEBUG, "Mismatching errno code in " ++ gf_msg_debug (fop->xl->name, 0, "Mismatching errno code in " + "answers of '%s': %d <-> %d", + ec_fop_name(fop->id), dst->op_errno, src->op_errno); + +@@ -869,9 +882,10 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, + + if (!ec_dict_compare(dst->xdata, src->xdata)) + { +- gf_log(fop->xl->name, GF_LOG_WARNING, "Mismatching xdata in answers " +- "of '%s'", +- ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_XDATA_MISMATCH, ++ "Mismatching xdata in answers " ++ "of '%s'", ec_fop_name(fop->id)); + + return 0; + } +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 4dbbe28..455df99 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -18,6 +18,7 @@ + #include "ec-fops.h" + #include "ec-method.h" + #include "ec.h" ++#include "ec-messages.h" + + int32_t ec_child_valid(ec_t * ec, ec_fop_data_t * fop, int32_t idx) + { +@@ -117,14 +118,15 @@ int32_t ec_heal_report(call_frame_t * frame, void * cookie, xlator_t * this, + uintptr_t good, uintptr_t bad, dict_t * xdata) + { + if (op_ret < 0) { +- gf_log(this->name, GF_LOG_WARNING, "Heal failed (error %d)", +- op_errno); ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ EC_MSG_HEAL_FAIL, "Heal failed"); + } else { + if ((mask & ~good) != 0) { +- gf_log(this->name, GF_LOG_INFO, "Heal succeeded on %d/%d " +- "subvolumes", +- ec_bits_count(mask & ~(good | bad)), +- ec_bits_count(mask & ~good)); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_HEAL_SUCCESS, "Heal succeeded on %d/%d " ++ "subvolumes", ++ ec_bits_count(mask & ~(good | bad)), ++ ec_bits_count(mask & ~good)); + } + } + +@@ -156,10 +158,12 @@ void ec_check_status(ec_fop_data_t * fop) + return; + } + +- gf_log(fop->xl->name, GF_LOG_WARNING, "Operation failed on some " +- "subvolumes (up=%lX, mask=%lX, " +- "remaining=%lX, good=%lX, bad=%lX)", +- ec->xl_up, fop->mask, fop->remaining, fop->good, fop->bad); ++ gf_msg (fop->xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_OP_FAIL_ON_SUBVOLS, ++ "Operation failed on some " ++ "subvolumes (up=%lX, mask=%lX, " ++ "remaining=%lX, good=%lX, bad=%lX)", ++ ec->xl_up, fop->mask, fop->remaining, fop->good, fop->bad); + + if (fop->use_fd) + { +@@ -414,9 +418,11 @@ int32_t ec_child_select(ec_fop_data_t * fop) + + if ((fop->mask & ~mask) != 0) + { +- gf_log(fop->xl->name, GF_LOG_WARNING, "Executing operation with " +- "some subvolumes unavailable " +- "(%lX)", fop->mask & ~mask); ++ gf_msg (fop->xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_OP_EXEC_UNAVAIL, ++ "Executing operation with " ++ "some subvolumes unavailable " ++ "(%lX)", fop->mask & ~mask); + + fop->mask &= mask; + } +@@ -453,9 +459,11 @@ int32_t ec_child_select(ec_fop_data_t * fop) + num = ec_bits_count(fop->mask); + if ((num < fop->minimum) && (num < ec->fragments)) + { +- gf_log(ec->xl->name, GF_LOG_ERROR, "Insufficient available childs " +- "for this request (have %d, need " +- "%d)", num, fop->minimum); ++ gf_msg (ec->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_CHILDS_INSUFFICIENT, ++ "Insufficient available childs " ++ "for this request (have %d, need " ++ "%d)", num, fop->minimum); + + return 0; + } +@@ -618,8 +626,10 @@ ec_lock_t *ec_lock_allocate(xlator_t *xl, loc_t *loc) + if ((loc->inode == NULL) || + (gf_uuid_is_null(loc->gfid) && gf_uuid_is_null(loc->inode->gfid))) + { +- gf_log(xl->name, GF_LOG_ERROR, "Trying to lock based on an invalid " +- "inode"); ++ gf_msg (xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_INODE, ++ "Trying to lock based on an invalid " ++ "inode"); + + return NULL; + } +@@ -845,11 +855,15 @@ ec_config_check (ec_fop_data_t *fop, ec_config_t *config) + !ec_is_power_of_2(config->gf_word_size) || + ((config->chunk_size * 8) % (config->gf_word_size * data_bricks) + != 0)) { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Invalid or corrupted config"); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_CONFIG, ++ "Invalid or corrupted config"); + } else { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unsupported config " +- "(V=%u, A=%u, W=%u, " +- "N=%u, R=%u, S=%u)", ++ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_CONFIG, ++ "Unsupported config " ++ "(V=%u, A=%u, W=%u, " ++ "N=%u, R=%u, S=%u)", + config->version, config->algorithm, + config->gf_word_size, config->bricks, + config->redundancy, config->chunk_size); +@@ -876,9 +890,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, + ctx = lock->ctx; + + if (op_ret < 0) { +- gf_log(this->name, GF_LOG_WARNING, +- "Failed to get size and version (error %d: %s)", op_errno, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ EC_MSG_SIZE_VERS_GET_FAIL, ++ "Failed to get size and version"); + + goto out; + } +@@ -889,7 +903,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, + + if (ec_dict_del_array(dict, EC_XATTR_VERSION, ctx->pre_version, + EC_VERSION_SIZE) != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Unable to get version xattr"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_VER_XATTR_GET_FAIL, ++ "Unable to get version xattr"); + + goto unlock; + } +@@ -900,7 +916,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, + + if (lock->loc.inode->ia_type == IA_IFREG) { + if (ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size) != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Unable to get size xattr"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_SIZE_XATTR_GET_FAIL, "Unable to get size xattr"); + + goto unlock; + } +@@ -910,7 +927,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, + + if ((ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config) != 0) || + !ec_config_check(parent, &ctx->config)) { +- gf_log(this->name, GF_LOG_ERROR, "Unable to get config xattr"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_CONFIG_XATTR_GET_FAIL, ++ "Unable to get config xattr"); + + goto unlock; + } +@@ -1235,7 +1254,9 @@ int32_t ec_locked(call_frame_t *frame, void *cookie, xlator_t *this, + ec_lock_acquired(link); + ec_lock(fop->parent); + } else { +- gf_log(this->name, GF_LOG_WARNING, "Failed to complete preop lock"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ EC_MSG_PREOP_LOCK_FAILED, ++ "Failed to complete preop lock"); + } + + return 0; +@@ -1400,8 +1421,10 @@ int32_t ec_unlocked(call_frame_t *frame, void *cookie, xlator_t *this, + ec_lock_link_t *link = fop->data; + + if (op_ret < 0) { +- gf_log(this->name, GF_LOG_WARNING, "entry/inode unlocking failed (%s)", +- ec_fop_name(link->fop->id)); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ EC_MSG_UNLOCK_FAILED, ++ "entry/inode unlocking failed (%s)", ++ ec_fop_name(link->fop->id)); + } else { + ec_trace("UNLOCKED", link->fop, "lock=%p", link->lock); + } +@@ -1447,9 +1470,9 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie, + ec_inode_t *ctx; + + if (op_ret < 0) { +- gf_log(fop->xl->name, fop_log_level (fop->id, op_errno), +- "Failed to update version and" +- " size (error %d)", op_errno); ++ gf_msg(fop->xl->name, fop_log_level (fop->id, op_errno), op_errno, ++ EC_MSG_SIZE_VERS_UPDATE_FAIL, ++ "Failed to update version and size"); + } else { + fop->parent->mask &= fop->good; + link = fop->data; +@@ -1574,7 +1597,9 @@ out: + + ec_fop_set_error(fop, EIO); + +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to update version and size"); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_SIZE_VERS_UPDATE_FAIL, ++ "Unable to update version and size"); + } + + gf_boolean_t +@@ -1706,8 +1731,10 @@ void ec_unlock_timer_add(ec_lock_link_t *link) + lock->timer = gf_timer_call_after(fop->xl->ctx, delay, + ec_unlock_timer_cbk, link); + if (lock->timer == NULL) { +- gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to delay an " +- "unlock"); ++ gf_msg(fop->xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_UNLOCK_DELAY_FAILED, ++ "Unable to delay an " ++ "unlock"); + + lock->release = now = _gf_true; + } +@@ -1777,7 +1804,7 @@ void ec_lock_reuse(ec_fop_data_t *fop) + release = _gf_true; + } + if (release) { +- gf_log(fop->xl->name, GF_LOG_DEBUG, ++ gf_msg_debug (fop->xl->name, 0, + "Lock contention detected"); + } + } +diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c +index 72f3b0b..0632371 100644 +--- a/xlators/cluster/ec/src/ec-data.c ++++ b/xlators/cluster/ec/src/ec-data.c +@@ -12,6 +12,7 @@ + #include "ec-helpers.h" + #include "ec-common.h" + #include "ec-data.h" ++#include "ec-messages.h" + + ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, + ec_fop_data_t * fop, int32_t id, +@@ -23,15 +24,16 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, + + if (fop->xl != this) + { +- gf_log(this->name, GF_LOG_ERROR, "Mismatching xlators between request " +- "and answer (req=%s, ans=%s).", +- fop->xl->name, this->name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_XLATOR_MISMATCH, "Mismatching xlators between request " ++ "and answer (req=%s, ans=%s).", fop->xl->name, this->name); + + return NULL; + } + if (fop->frame != frame) + { +- gf_log(this->name, GF_LOG_ERROR, "Mismatching frames between request " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FRAME_MISMATCH, "Mismatching frames between request " + "and answer (req=%p, ans=%p).", + fop->frame, frame); + +@@ -39,7 +41,8 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, + } + if (fop->id != id) + { +- gf_log(this->name, GF_LOG_ERROR, "Mismatching fops between request " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FOP_MISMATCH, "Mismatching fops between request " + "and answer (req=%d, ans=%d).", + fop->id, id); + +@@ -49,7 +52,8 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, + cbk = mem_get0(ec->cbk_pool); + if (cbk == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to allocate memory for an " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to allocate memory for an " + "answer."); + } + +@@ -123,7 +127,8 @@ ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, + fop = mem_get0(ec->fop_pool); + if (fop == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to allocate memory for a " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to allocate memory for a " + "request."); + + return NULL; +@@ -155,7 +160,8 @@ ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, + } + if (fop->frame == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to create a private frame " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to create a private frame " + "for a request"); + + mem_put(fop); +diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c +index 69df4d2..dee2066 100644 +--- a/xlators/cluster/ec/src/ec-dir-read.c ++++ b/xlators/cluster/ec/src/ec-dir-read.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + + /* FOP: opendir */ + +@@ -24,9 +25,10 @@ int32_t ec_combine_opendir(ec_fop_data_t * fop, ec_cbk_data_t * dst, + { + if (dst->fd != src->fd) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching fd in answers " +- "of 'GF_FOP_OPENDIR': %p <-> %p", +- dst->fd, src->fd); ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_FD_MISMATCH, "Mismatching fd in answers " ++ "of 'GF_FOP_OPENDIR': %p <-> %p", ++ dst->fd, src->fd); + + return 0; + } +@@ -63,8 +65,9 @@ int32_t ec_opendir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->fd = fd_ref(fd); + if (cbk->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -75,7 +78,8 @@ int32_t ec_opendir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -216,8 +220,9 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -231,7 +236,7 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(OPENDIR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(OPENDIR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -249,7 +254,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -259,7 +265,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -270,7 +277,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -308,7 +316,8 @@ ec_deitransform (xlator_t *this, off_t offset) + + out: + if (idx < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_REQUEST, + "Invalid index %d in readdirp request", client_id); + } + return idx; +@@ -521,8 +530,9 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) + + return EC_STATE_END; + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -536,7 +546,7 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(READDIR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(READDIR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -560,7 +570,8 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -571,7 +582,8 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -610,7 +622,7 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(READDIRP) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(READDIRP) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -634,7 +646,8 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -645,7 +658,8 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c +index ce09138..5fe97c8 100644 +--- a/xlators/cluster/ec/src/ec-dir-write.c ++++ b/xlators/cluster/ec/src/ec-dir-write.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + + int + ec_dir_write_cbk (call_frame_t *frame, xlator_t *this, +@@ -266,8 +267,9 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -282,7 +284,7 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(CREATE) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(CREATE) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -306,7 +308,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -316,7 +319,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -327,7 +331,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -465,8 +470,9 @@ int32_t ec_manager_link(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -480,7 +486,7 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(LINK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(LINK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -497,7 +503,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], oldloc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -506,7 +513,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[1], newloc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -516,7 +524,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -667,8 +676,9 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -682,7 +692,7 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(MKDIR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(MKDIR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -704,7 +714,8 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -714,7 +725,8 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -894,8 +906,9 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -909,7 +922,7 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(MKNOD) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(MKNOD) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -932,7 +945,8 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -942,7 +956,8 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1082,8 +1097,9 @@ int32_t ec_manager_rename(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1097,7 +1113,7 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(RENAME) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(RENAME) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1116,7 +1132,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], oldloc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1125,7 +1142,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[1], newloc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1135,7 +1153,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1259,8 +1278,9 @@ int32_t ec_manager_rmdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1274,7 +1294,7 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(RMDIR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(RMDIR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1295,7 +1315,8 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1305,7 +1326,8 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1440,8 +1462,9 @@ int32_t ec_manager_symlink(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1456,7 +1479,7 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(SYMLINK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(SYMLINK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1478,7 +1501,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[0] = gf_strdup(linkname); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to duplicate a string."); + + goto out; + } +@@ -1487,7 +1511,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1497,7 +1522,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1622,8 +1648,9 @@ int32_t ec_manager_unlink(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1637,7 +1664,7 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(UNLINK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(UNLINK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1658,7 +1685,8 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1668,7 +1696,8 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c +index a455dad..f27f65b 100644 +--- a/xlators/cluster/ec/src/ec-generic.c ++++ b/xlators/cluster/ec/src/ec-generic.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + #include "byte-order.h" + + /* FOP: flush */ +@@ -46,7 +47,8 @@ int32_t ec_flush_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -163,8 +165,9 @@ int32_t ec_manager_flush(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -178,7 +181,7 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FLUSH) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FLUSH) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -199,7 +202,8 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -210,7 +214,8 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -236,7 +241,8 @@ int32_t ec_combine_fsync(ec_fop_data_t * fop, ec_cbk_data_t * dst, + ec_cbk_data_t * src) + { + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 2)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, "Mismatching iatt in " + "answers of 'GF_FOP_FSYNC'"); + + return 0; +@@ -283,7 +289,8 @@ int32_t ec_fsync_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -411,8 +418,9 @@ int32_t ec_manager_fsync(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -426,7 +434,7 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FSYNC) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FSYNC) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -449,7 +457,8 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -460,7 +469,8 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -508,7 +518,8 @@ int32_t ec_fsyncdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -625,8 +636,9 @@ int32_t ec_manager_fsyncdir(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -640,7 +652,7 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FSYNCDIR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FSYNCDIR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -663,7 +675,8 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -674,7 +687,8 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -813,7 +827,8 @@ int32_t ec_combine_lookup(ec_fop_data_t * fop, ec_cbk_data_t * dst, + ec_cbk_data_t * src) + { + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 2)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, "Mismatching iatt in " + "answers of 'GF_FOP_LOOKUP'"); + + return 0; +@@ -852,8 +867,9 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->inode = inode_ref(inode); + if (cbk->inode == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, +- "Failed to reference an inode."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_INODE_REF_FAIL, ++ "Failed to reference an inode."); + + goto out; + } +@@ -872,7 +888,8 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -914,8 +931,9 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) + fop->xdata = dict_new(); + if (fop->xdata == NULL) + { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare " +- "lookup request"); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, EIO, ++ EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare " ++ "lookup request"); + + fop->error = EIO; + +@@ -941,7 +959,8 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) + (dict_set_uint64(fop->xdata, EC_XATTR_VERSION, 0) != 0) || + (dict_set_uint64(fop->xdata, EC_XATTR_DIRTY, 0) != 0)) + { +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare lookup " ++ gf_msg (fop->xl->name, GF_LOG_ERROR, EIO, ++ EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare lookup " + "request"); + + fop->error = EIO; +@@ -1025,8 +1044,9 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1040,7 +1060,7 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(LOOKUP) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(LOOKUP) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1058,7 +1078,8 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1068,7 +1089,8 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1132,7 +1154,8 @@ int32_t ec_statfs_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1232,8 +1255,9 @@ int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1247,7 +1271,7 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(STATFS) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(STATFS) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1265,7 +1289,8 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1275,7 +1300,8 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1302,7 +1328,8 @@ int32_t ec_combine_xattrop(ec_fop_data_t *fop, ec_cbk_data_t *dst, + { + if (!ec_dict_compare(dst->dict, src->dict)) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching dictionary in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_DICT_MISMATCH, "Mismatching dictionary in " + "answers of 'GF_FOP_XATTROP'"); + + return 0; +@@ -1491,8 +1518,9 @@ int32_t ec_manager_xattrop(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1507,7 +1535,7 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(XATTROP) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(XATTROP) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1528,7 +1556,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1538,7 +1567,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->dict = dict_ref(xattr); + if (fop->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1549,7 +1579,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1587,7 +1618,7 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FXATTROP) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FXATTROP) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1611,7 +1642,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -1622,7 +1654,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->dict = dict_ref(xattr); + if (fop->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1633,7 +1666,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index c2b8e11..7067ed9 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -21,6 +21,7 @@ + #include "ec-mem-types.h" + #include "ec-data.h" + #include "byte-order.h" ++#include "ec-messages.h" + #include "syncop.h" + #include "syncop-utils.h" + #include "cluster-syncop.h" +@@ -500,9 +501,9 @@ ec_heal_init (ec_fop_data_t * fop) + + inode = heal->loc.inode; + if (inode == NULL) { +- gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to start inode healing " +- "because there is not enough " +- "information"); ++ gf_msg (fop->xl->name, GF_LOG_WARNING, ENODATA, ++ EC_MSG_DATA_UNAVAILABLE, "Unable to start inode healing " ++ "because there is not enough information"); + + error = ENODATA; + goto out; +@@ -528,8 +529,10 @@ ec_heal_init (ec_fop_data_t * fop) + } + + if (list_empty(&ctx->heal)) { +- gf_log("ec", GF_LOG_INFO, "Healing '%s', gfid %s", heal->loc.path, +- uuid_utoa(heal->loc.gfid)); ++ gf_msg ("ec", GF_LOG_INFO, 0, ++ EC_MSG_HEALING_INFO, ++ "Healing '%s', gfid %s", heal->loc.path, ++ uuid_utoa(heal->loc.gfid)); + } else { + ec_sleep(fop); + } +@@ -679,10 +682,9 @@ void ec_heal_remove_others(ec_heal_t * heal) + if ((cbk->op_errno != ENOENT) && (cbk->op_errno != ENOTDIR) && + (cbk->op_errno != ESTALE)) + { +- gf_log(heal->xl->name, GF_LOG_WARNING, "Don't know how to " +- "remove inode with " +- "error %d", +- cbk->op_errno); ++ gf_msg (heal->xl->name, GF_LOG_WARNING, cbk->op_errno, ++ EC_MSG_INODE_REMOVE_FAIL, "Don't know how to " ++ "remove inode"); + } + + ec_heal_exclude(heal, cbk->mask); +@@ -713,9 +715,9 @@ void ec_heal_prepare_others(ec_heal_t * heal) + } + else + { +- gf_log(heal->xl->name, GF_LOG_ERROR, "Don't know how to " +- "heal error %d", +- cbk->op_errno); ++ gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, ++ EC_MSG_HEAL_FAIL, "Don't know how to " ++ "heal"); + + ec_heal_exclude(heal, cbk->mask); + } +@@ -802,9 +804,8 @@ void ec_heal_prepare(ec_heal_t * heal) + } + else + { +- gf_log(heal->xl->name, GF_LOG_ERROR, "Don't know how to heal " +- "error %d", +- cbk->op_errno); ++ gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, ++ EC_MSG_HEAL_FAIL, "Don't know how to heal "); + } + } + else +@@ -814,7 +815,8 @@ void ec_heal_prepare(ec_heal_t * heal) + heal->fd = fd_create(heal->loc.inode, heal->fop->frame->root->pid); + if (heal->fd == NULL) + { +- gf_log(heal->xl->name, GF_LOG_ERROR, "Unable to create a new " ++ gf_msg (heal->xl->name, GF_LOG_ERROR, errno, ++ EC_MSG_FD_CREATE_FAIL, "Unable to create a new " + "file descriptor"); + + goto out; +@@ -1088,7 +1090,7 @@ ec_heal_writev_cbk (call_frame_t *frame, void *cookie, + + ec_trace("WRITE_CBK", cookie, "ret=%d, errno=%d", op_ret, op_errno); + +- gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: write op_ret %d, op_errno %s" ++ gf_msg_debug (fop->xl->name, 0, "%s: write op_ret %d, op_errno %s" + " at %"PRIu64, uuid_utoa (heal->fd->inode->gfid), op_ret, + strerror (op_errno), heal->offset); + +@@ -1112,7 +1114,7 @@ int32_t ec_heal_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + + if (op_ret > 0) + { +- gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read succeeded, proceeding " ++ gf_msg_debug (fop->xl->name, 0, "%s: read succeeded, proceeding " + "to write at %"PRIu64, uuid_utoa (heal->fd->inode->gfid), + heal->offset); + ec_writev(heal->fop->frame, heal->xl, heal->bad, EC_MINIMUM_ONE, +@@ -1121,7 +1123,7 @@ int32_t ec_heal_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + } + else + { +- gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read failed %s, failing " ++ gf_msg_debug (fop->xl->name, 0, "%s: read failed %s, failing " + "to heal block at %"PRIu64, + uuid_utoa (heal->fd->inode->gfid), strerror (op_errno), + heal->offset); +@@ -1563,8 +1565,9 @@ ec_manager_heal (ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1578,7 +1581,7 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, this->private, out); +@@ -1597,7 +1600,8 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1607,7 +1611,8 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1658,7 +1663,7 @@ void ec_fheal(call_frame_t * frame, xlator_t * this, uintptr_t target, + + if (ctx != NULL) + { +- gf_log("ec", GF_LOG_DEBUG, "FHEAL ctx: flags=%X, open=%lX, bad=%lX", ++ gf_msg_trace ("ec", 0, "FHEAL ctx: flags=%X, open=%lX, bad=%lX", + ctx->flags, ctx->open, ctx->bad); + ec_heal(frame, this, target, minimum, func, data, &ctx->loc, partial, + xdata); +@@ -2107,7 +2112,7 @@ ec_heal_metadata (call_frame_t *frame, ec_t *ec, inode_t *inode, + 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (inode->gfid), ret); + ret = -ENOTCONN; +@@ -2274,7 +2279,7 @@ ec_delete_stale_name (dict_t *gfid_db, char *key, data_t *d, void *data) + dict_del (gfid_db, key); + out: + if (ret < 0) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s/%s: heal failed %s", + uuid_utoa (name_data->parent->gfid), name_data->name, + strerror (-ret)); + } +@@ -2456,7 +2461,7 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, + ret = 0; + out: + if (ret < 0) +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s/%s: heal failed %s", + uuid_utoa (parent->gfid), name, strerror (-ret)); + cluster_replies_wipe (replies, ec->nodes); + loc_wipe (&loc); +@@ -2552,7 +2557,8 @@ __ec_heal_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, + } + + if (gfid_db->count > 1) { +- gf_log (ec->xl->name, GF_LOG_INFO, "%s/%s: Not able to heal", ++ gf_msg (ec->xl->name, GF_LOG_INFO, 0, ++ EC_MSG_HEAL_FAIL, "%s/%s: Not able to heal", + uuid_utoa (parent->gfid), name); + memset (participants, 0, ec->nodes); + goto out; +@@ -2602,7 +2608,7 @@ ec_heal_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, + 0, 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: Skipping " ++ gf_msg_debug (ec->xl->name, 0, "%s/%s: Skipping " + "heal as only %d number of subvolumes could " + "be locked", uuid_utoa (parent->gfid), name, + ret); +@@ -2703,7 +2709,7 @@ __ec_heal_entry (call_frame_t *frame, ec_t *ec, inode_t *inode, + 0, 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (inode->gfid), ret); + ret = -ENOTCONN; +@@ -2768,7 +2774,7 @@ ec_heal_entry (call_frame_t *frame, ec_t *ec, inode_t *inode, + 0, 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (inode->gfid), ret); + ret = -ENOTCONN; +@@ -2968,10 +2974,10 @@ out: + dict_unref (xattrs); + cluster_replies_wipe (replies, ec->nodes); + if (ret < 0) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", + uuid_utoa (fd->inode->gfid), strerror (-ret)); + } else { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " ++ gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " + "%d", uuid_utoa (fd->inode->gfid), + EC_COUNT (sources, ec->nodes), + EC_COUNT (healed_sinks, ec->nodes)); +@@ -3041,7 +3047,7 @@ out: + if (xattrs) + dict_unref (xattrs); + if (ret < 0) +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", + uuid_utoa (fd->inode->gfid), strerror (-ret)); + return ret; + } +@@ -3061,7 +3067,7 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) + return EC_STATE_HEAL_DATA_COPY; + + case EC_STATE_HEAL_DATA_COPY: +- gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read/write starting", ++ gf_msg_debug (fop->xl->name, 0, "%s: read/write starting", + uuid_utoa (heal->fd->inode->gfid)); + ec_heal_data_block (heal); + +@@ -3093,8 +3099,9 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) + + return -EC_STATE_END; + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -3109,7 +3116,7 @@ ec_heal_block (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t *fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); ++ gf_msg_trace("ec", 0, "EC(HEAL) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, this->private, out); +@@ -3185,7 +3192,7 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, + + for (heal->offset = 0; (heal->offset < size) && !heal->done; + heal->offset += heal->size) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " ++ gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " + "%d, offset: %"PRIu64" bsize: %"PRIu64, + uuid_utoa (fd->inode->gfid), + EC_COUNT (sources, ec->nodes), +@@ -3200,7 +3207,7 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, + LOCK_DESTROY (&heal->lock); + syncbarrier_destroy (heal->data); + if (ret < 0) +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", + uuid_utoa (fd->inode->gfid), strerror (-ret)); + return ret; + } +@@ -3237,7 +3244,7 @@ __ec_heal_trim_sinks (call_frame_t *frame, ec_t *ec, fd_t *fd, + out: + cluster_replies_wipe (replies, ec->nodes); + if (ret < 0) +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", ++ gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", + uuid_utoa (fd->inode->gfid), strerror (-ret)); + return ret; + } +@@ -3392,7 +3399,7 @@ ec_restore_time_and_adjust_versions (call_frame_t *frame, ec_t *ec, fd_t *fd, + fd->inode, 0, 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (fd->inode->gfid), ret); + ret = -ENOTCONN; +@@ -3457,7 +3464,7 @@ __ec_heal_data (call_frame_t *frame, ec_t *ec, fd_t *fd, unsigned char *heal_on, + fd->inode, 0, 0); + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (fd->inode->gfid), ret); + ret = -ENOTCONN; +@@ -3484,7 +3491,7 @@ unlock: + if (ret < 0) + goto out; + +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " ++ gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " + "%d", uuid_utoa (fd->inode->gfid), + EC_COUNT (sources, ec->nodes), + EC_COUNT (healed_sinks, ec->nodes)); +@@ -3552,7 +3559,7 @@ ec_heal_data (call_frame_t *frame, ec_t *ec, gf_boolean_t block, inode_t *inode, + } + { + if (ret <= ec->fragments) { +- gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " ++ gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " + "as only %d number of subvolumes could " + "be locked", uuid_utoa (inode->gfid), ret); + ret = -ENOTCONN; +@@ -3614,12 +3621,15 @@ ec_heal_do (xlator_t *this, void *data, loc_t *loc, int32_t partial) + ret = ec_heal_name (frame, ec, loc->parent, (char *)loc->name, + participants); + if (ret == 0) { +- gf_log (this->name, GF_LOG_INFO, "%s: name heal " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_HEAL_SUCCESS, "%s: name heal " + "successful on %lX", loc->path, +- ec_char_array_to_mask (participants, ec->nodes)); ++ ec_char_array_to_mask (participants, ++ ec->nodes)); + } else { +- gf_log (this->name, GF_LOG_INFO, "%s: name heal " +- "failed on %s", loc->path, strerror (-ret)); ++ gf_msg (this->name, GF_LOG_INFO, -ret, ++ EC_MSG_HEAL_FAIL, "%s: name heal " ++ "failed", loc->path); + } + } + +@@ -3691,7 +3701,7 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t *fop = NULL; + int ret = 0; + +- gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); + + VALIDATE_OR_GOTO(this, fail); + GF_VALIDATE_OR_GOTO(this->name, this->private, fail); +diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c +index bfdf959..75f5848 100644 +--- a/xlators/cluster/ec/src/ec-heald.c ++++ b/xlators/cluster/ec/src/ec-heald.c +@@ -12,6 +12,7 @@ + #include "defaults.h" + #include "compat-errno.h" + #include "ec.h" ++#include "ec-messages.h" + #include "ec-heald.h" + #include "ec-mem-types.h" + #include "syncop.h" +@@ -182,7 +183,7 @@ ec_shd_index_inode (xlator_t *this, xlator_t *subvol) + if (ret) + goto out; + +- gf_log (this->name, GF_LOG_DEBUG, "index-dir gfid for %s: %s", ++ gf_msg_debug (this->name, 0, "index-dir gfid for %s: %s", + subvol->name, uuid_utoa (index_gfid)); + + inode = ec_shd_inode_find (this, subvol, index_gfid); +@@ -232,7 +233,7 @@ ec_shd_index_heal (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, + if (!ec->shd.enabled) + return -EBUSY; + +- gf_log (healer->this->name, GF_LOG_DEBUG, "got entry: %s", ++ gf_msg_debug (healer->this->name, 0, "got entry: %s", + entry->d_name); + + ret = gf_uuid_parse (entry->d_name, loc.gfid); +@@ -274,7 +275,8 @@ ec_shd_index_sweep (struct subvol_healer *healer) + + loc.inode = ec_shd_index_inode (healer->this, subvol); + if (!loc.inode) { +- gf_log (healer->this->name, GF_LOG_WARNING, ++ gf_msg (healer->this->name, GF_LOG_WARNING, errno, ++ EC_MSG_INDEX_DIR_GET_FAIL, + "unable to get index-dir on %s", subvol->name); + return -errno; + } +@@ -357,13 +359,13 @@ ec_shd_index_healer (void *data) + + ASSERT_LOCAL(this, healer); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "starting index sweep on subvol %s", + ec_subvol_name (this, healer->subvol)); + + ec_shd_index_sweep (healer); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "finished index sweep on subvol %s", + ec_subvol_name (this, healer->subvol)); + } +@@ -397,13 +399,15 @@ ec_shd_full_healer (void *data) + + ASSERT_LOCAL(this, healer); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_FULL_SWEEP_START, + "starting full sweep on subvol %s", + ec_subvol_name (this, healer->subvol)); + + ec_shd_full_sweep (healer, this->itable->root); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_FULL_SWEEP_STOP, + "finished full sweep on subvol %s", + ec_subvol_name (this, healer->subvol)); + } +diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c +index 48251c8..372633d 100644 +--- a/xlators/cluster/ec/src/ec-helpers.c ++++ b/xlators/cluster/ec/src/ec-helpers.c +@@ -15,6 +15,7 @@ + #include "ec-mem-types.h" + #include "ec-fops.h" + #include "ec-helpers.h" ++#include "ec-messages.h" + + #ifndef ffsll + #define ffsll(x) __builtin_ffsll(x) +@@ -79,7 +80,7 @@ void ec_trace(const char * event, ec_fop_data_t * fop, const char * fmt, ...) + msg = ""; + } + +- gf_log("ec", GF_LOG_TRACE, "%s(%s) %p(%p) [refs=%d, winds=%d, jobs=%d] " ++ gf_msg_trace ("ec", 0, "%s(%s) %p(%p) [refs=%d, winds=%d, jobs=%d] " + "frame=%p/%p, min/exp=%d/%d, err=%d state=%d " + "{%s:%s:%s} %s", + event, ec_fop_name(fop->id), fop, fop->parent, fop->refs, +@@ -250,8 +251,10 @@ int32_t ec_dict_set_config(dict_t * dict, char * key, ec_config_t * config) + + if (config->version > EC_CONFIG_VERSION) + { +- gf_log("ec", GF_LOG_ERROR, "Trying to store an unsupported config " +- "version (%u)", config->version); ++ gf_msg ("ec", GF_LOG_ERROR, EINVAL, ++ EC_MSG_UNSUPPORTED_VERSION, ++ "Trying to store an unsupported config " ++ "version (%u)", config->version); + + return -1; + } +@@ -291,8 +294,10 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config) + config->version = (data >> 56) & 0xff; + if (config->version > EC_CONFIG_VERSION) + { +- gf_log("ec", GF_LOG_ERROR, "Found an unsupported config version (%u)", +- config->version); ++ gf_msg ("ec", GF_LOG_ERROR, EINVAL, ++ EC_MSG_UNSUPPORTED_VERSION, ++ "Found an unsupported config version (%u)", ++ config->version); + + return -1; + } +@@ -324,7 +329,9 @@ int32_t ec_loc_gfid_check(xlator_t * xl, uuid_t dst, uuid_t src) + + if (gf_uuid_compare(dst, src) != 0) + { +- gf_log(xl->name, GF_LOG_WARNING, "Mismatching GFID's in loc"); ++ gf_msg (xl->name, GF_LOG_WARNING, 0, ++ EC_MSG_GFID_MISMATCH, ++ "Mismatching GFID's in loc"); + + return 0; + } +@@ -369,8 +376,10 @@ int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc) + } else if (loc->path && strchr (loc->path, '/')) { + path = gf_strdup(loc->path); + if (path == NULL) { +- gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", +- loc->path); ++ gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Unable to duplicate path '%s'", ++ loc->path); + + goto out; + } +@@ -422,8 +431,10 @@ int32_t ec_loc_setup_path(xlator_t *xl, loc_t *loc) + + if (loc->name != NULL) { + if (strcmp(loc->name, name) != 0) { +- gf_log(xl->name, GF_LOG_ERROR, "Invalid name '%s' in loc", +- loc->name); ++ gf_msg (xl->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_LOC_NAME, ++ "Invalid name '%s' in loc", ++ loc->name); + + goto out; + } +@@ -458,17 +469,21 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) + if (loc->path && strchr (loc->path, '/')) { + str = gf_strdup(loc->path); + if (str == NULL) { +- gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", +- loc->path); ++ gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Unable to duplicate path '%s'", ++ loc->path); + +- goto out; ++ goto out; + } + parent->path = gf_strdup(dirname(str)); + if (parent->path == NULL) { +- gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", +- dirname(str)); ++ gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Unable to duplicate path '%s'", ++ dirname(str)); + +- goto out; ++ goto out; + } + } + +@@ -480,7 +495,9 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) + + if ((parent->inode == NULL) && (parent->path == NULL) && + gf_uuid_is_null(parent->gfid)) { +- gf_log(xl->name, GF_LOG_ERROR, "Parent inode missing for loc_t"); ++ gf_msg (xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_PARENT_INODE_MISSING, ++ "Parent inode missing for loc_t"); + + goto out; + } +diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c +index 1f91391..29e61ba 100644 +--- a/xlators/cluster/ec/src/ec-inode-read.c ++++ b/xlators/cluster/ec/src/ec-inode-read.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + + /* FOP: access */ + +@@ -131,8 +132,10 @@ ec_manager_access(ec_fop_data_t *fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -146,7 +149,7 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(ACCESS) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(ACCESS) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -166,7 +169,9 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -176,8 +181,10 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -203,7 +210,8 @@ int32_t ec_combine_getxattr(ec_fop_data_t * fop, ec_cbk_data_t * dst, + { + if (!ec_dict_compare(dst->dict, src->dict)) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching dictionary in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_DICT_MISMATCH, "Mismatching dictionary in " + "answers of 'GF_FOP_GETXATTR'"); + + return 0; +@@ -241,8 +249,10 @@ int32_t ec_getxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->dict = dict_ref(dict); + if (cbk->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -253,8 +263,10 @@ int32_t ec_getxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -404,8 +416,10 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -473,7 +487,7 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(GETXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(GETXATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -500,7 +514,9 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -510,7 +526,9 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->str[0] = gf_strdup(name); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -520,8 +538,10 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -568,8 +588,10 @@ int32_t ec_fgetxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->dict = dict_ref(dict); + if (cbk->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -580,8 +602,10 @@ int32_t ec_fgetxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -618,7 +642,7 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FGETXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FGETXATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -640,8 +664,10 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -651,7 +677,8 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->str[0] = gf_strdup(name); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to duplicate a string."); + + goto out; + } +@@ -661,7 +688,8 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -685,7 +713,8 @@ int32_t ec_combine_open(ec_fop_data_t * fop, ec_cbk_data_t * dst, + { + if (dst->fd != src->fd) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching fd in answers " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_FD_MISMATCH, "Mismatching fd in answers " + "of 'GF_FOP_OPEN': %p <-> %p", + dst->fd, src->fd); + +@@ -724,7 +753,8 @@ int32_t ec_open_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->fd = fd_ref(fd); + if (cbk->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -736,7 +766,8 @@ int32_t ec_open_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -902,8 +933,9 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -917,7 +949,7 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(OPEN) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(OPEN) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -937,7 +969,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -947,7 +980,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -958,7 +992,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -984,7 +1019,8 @@ int32_t ec_combine_readlink(ec_fop_data_t * fop, ec_cbk_data_t * dst, + ec_cbk_data_t * src) + { + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, "Mismatching iatt in " + "answers of 'GF_FOP_READLINK'"); + + return 0; +@@ -1064,8 +1100,9 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1079,7 +1116,7 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(READLINK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(READLINK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1099,7 +1136,8 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1109,7 +1147,8 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1250,14 +1289,16 @@ int32_t ec_combine_readv(ec_fop_data_t * fop, ec_cbk_data_t * dst, + { + if (!ec_vector_compare(dst->vector, dst->int32, src->vector, src->int32)) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching vector in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_VECTOR_MISMATCH, "Mismatching vector in " + "answers of 'GF_FOP_READ'"); + + return 0; + } + + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, "Mismatching iatt in " + "answers of 'GF_FOP_READ'"); + + return 0; +@@ -1299,7 +1340,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->vector = iov_dup(vector, count); + if (cbk->vector == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to duplicate a " + "vector list."); + + goto out; +@@ -1315,7 +1357,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->buffers = iobref_ref(iobref); + if (cbk->buffers == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_BUF_REF_FAIL, "Failed to reference a " + "buffer."); + + goto out; +@@ -1327,7 +1370,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1462,8 +1506,9 @@ int32_t ec_manager_readv(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1477,7 +1522,7 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(READ) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(READ) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1502,7 +1547,8 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -1513,7 +1559,8 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1539,7 +1586,8 @@ int32_t ec_combine_stat(ec_fop_data_t * fop, ec_cbk_data_t * dst, + ec_cbk_data_t * src) + { + if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_IATT_MISMATCH, "Mismatching iatt in " + "answers of 'GF_FOP_STAT'"); + + return 0; +@@ -1582,7 +1630,8 @@ int32_t ec_stat_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1726,8 +1775,9 @@ int32_t ec_manager_stat(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1741,7 +1791,7 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(STAT) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(STAT) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1759,7 +1809,8 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); + + goto out; + } +@@ -1769,7 +1820,8 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1825,7 +1877,8 @@ int32_t ec_fstat_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +@@ -1861,7 +1914,7 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FSTAT) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FSTAT) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1882,7 +1935,8 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); + + goto out; +@@ -1893,7 +1947,8 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, "Failed to reference a " + "dictionary."); + + goto out; +diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c +index 368b3ae..ff8e89e 100644 +--- a/xlators/cluster/ec/src/ec-inode-write.c ++++ b/xlators/cluster/ec/src/ec-inode-write.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + + int + ec_inode_write_cbk (call_frame_t *frame, xlator_t *this, void *cookie, +@@ -192,8 +193,10 @@ ec_manager_xattr (ec_fop_data_t *fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -208,7 +211,7 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(REMOVEXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(REMOVEXATTR) %p", frame); + + VALIDATE_OR_GOTO (this, out); + GF_VALIDATE_OR_GOTO (this->name, frame, out); +@@ -227,7 +230,9 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -237,7 +242,9 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->str[0] = gf_strdup(name); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -247,8 +254,10 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -292,7 +301,7 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FREMOVEXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FREMOVEXATTR) %p", frame); + + VALIDATE_OR_GOTO (this, out); + GF_VALIDATE_OR_GOTO (this->name, frame, out); +@@ -314,8 +323,10 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -325,7 +336,9 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->str[0] = gf_strdup(name); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -335,8 +348,10 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -495,8 +510,10 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -511,7 +528,7 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(SETATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(SETATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -532,7 +549,9 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -546,8 +565,10 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -594,7 +615,7 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FSETATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FSETATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -618,8 +639,10 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -633,8 +656,10 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -680,7 +705,7 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(SETXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(SETXATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -701,7 +726,9 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -711,8 +738,10 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->dict = dict_ref(dict); + if (fop->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -722,8 +751,10 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -768,8 +799,10 @@ ec_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -805,7 +838,7 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FSETXATTR) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FSETXATTR) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -829,8 +862,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -840,8 +875,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->dict = dict_ref(dict); + if (fop->dict == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -851,8 +888,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -1117,8 +1156,10 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1132,7 +1173,7 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(TRUNCATE) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(TRUNCATE) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1153,7 +1194,9 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -1163,8 +1206,10 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -1211,7 +1256,7 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FTRUNCATE) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FTRUNCATE) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1235,8 +1280,10 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -1246,8 +1293,10 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -1645,8 +1694,10 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1661,7 +1712,7 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(WRITE) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(WRITE) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1687,8 +1738,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -1698,8 +1751,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->vector = iov_dup(vector, count); + if (fop->vector == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a " +- "vector list."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a " ++ "vector list."); + + goto out; + } +@@ -1710,8 +1765,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->buffers = iobref_ref(iobref); + if (fop->buffers == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "buffer."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_BUF_REF_FAIL, ++ "Failed to reference a " ++ "buffer."); + + goto out; + } +@@ -1721,8 +1778,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c +index 22b6fa4..dd79514 100644 +--- a/xlators/cluster/ec/src/ec-locks.c ++++ b/xlators/cluster/ec/src/ec-locks.c +@@ -16,6 +16,7 @@ + #include "ec-combine.h" + #include "ec-method.h" + #include "ec-fops.h" ++#include "ec-messages.h" + + #define EC_LOCK_MODE_NONE 0 + #define EC_LOCK_MODE_INC 1 +@@ -91,7 +92,9 @@ int32_t ec_lock_unlocked(call_frame_t * frame, void * cookie, + { + if (op_ret < 0) + { +- gf_log(this->name, GF_LOG_WARNING, "Failed to unlock an entry/inode"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ EC_MSG_UNLOCK_FAILED, ++ "Failed to unlock an entry/inode"); + } + + return 0; +@@ -103,7 +106,9 @@ int32_t ec_lock_lk_unlocked(call_frame_t * frame, void * cookie, + { + if (op_ret < 0) + { +- gf_log(this->name, GF_LOG_WARNING, "Failed to unlock an lk"); ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ EC_MSG_LK_UNLOCK_FAILED, ++ "Failed to unlock an lk"); + } + + return 0; +@@ -137,8 +142,10 @@ int32_t ec_entrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -277,8 +284,10 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -293,7 +302,7 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(ENTRYLK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(ENTRYLK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -316,7 +325,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[0] = gf_strdup(volume); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -325,7 +336,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -335,7 +348,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[1] = gf_strdup(basename); + if (fop->str[1] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -345,8 +360,10 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -393,8 +410,10 @@ int32_t ec_fentrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -431,7 +450,7 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FENTRYLK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FENTRYLK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -456,7 +475,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[0] = gf_strdup(volume); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -466,8 +487,10 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -477,7 +500,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[1] = gf_strdup(basename); + if (fop->str[1] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -487,8 +512,10 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -535,8 +562,10 @@ int32_t ec_inodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -687,8 +716,10 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -703,7 +734,7 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(INODELK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(INODELK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -725,7 +756,9 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[0] = gf_strdup(volume); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -734,7 +767,9 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + { + if (loc_copy(&fop->loc[0], loc) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_LOC_COPY_FAIL, ++ "Failed to copy a location."); + + goto out; + } +@@ -758,8 +793,10 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -806,8 +843,10 @@ int32_t ec_finodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -844,7 +883,7 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(FINODELK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(FINODELK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -868,7 +907,9 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->str[0] = gf_strdup(volume); + if (fop->str[0] == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, ++ "Failed to duplicate a string."); + + goto out; + } +@@ -878,8 +919,10 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -903,8 +946,10 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -930,8 +975,10 @@ int32_t ec_combine_lk(ec_fop_data_t * fop, ec_cbk_data_t * dst, + { + if (!ec_flock_compare(&dst->flock, &src->flock)) + { +- gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching lock in " +- "answers of 'GF_FOP_LK'"); ++ gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, ++ EC_MSG_LOCK_MISMATCH, ++ "Mismatching lock in " ++ "answers of 'GF_FOP_LK'"); + + return 0; + } +@@ -983,8 +1030,10 @@ int32_t ec_lk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + cbk->xdata = dict_ref(xdata); + if (cbk->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +@@ -1105,8 +1154,10 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) + return EC_STATE_END; + + default: +- gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); ++ gf_msg (fop->xl->name, GF_LOG_ERROR, 0, ++ EC_MSG_UNHANDLED_STATE, ++ "Unhandled state %d for %s", ++ state, ec_fop_name(fop->id)); + + return EC_STATE_END; + } +@@ -1120,7 +1171,7 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, + ec_fop_data_t * fop = NULL; + int32_t error = EIO; + +- gf_log("ec", GF_LOG_TRACE, "EC(LK) %p", frame); ++ gf_msg_trace ("ec", 0, "EC(LK) %p", frame); + + VALIDATE_OR_GOTO(this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); +@@ -1143,8 +1194,10 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->fd = fd_ref(fd); + if (fop->fd == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "file descriptor."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_FILE_DESC_REF_FAIL, ++ "Failed to reference a " ++ "file descriptor."); + + goto out; + } +@@ -1168,8 +1221,10 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, + fop->xdata = dict_ref(xdata); + if (fop->xdata == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " +- "dictionary."); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_DICT_REF_FAIL, ++ "Failed to reference a " ++ "dictionary."); + + goto out; + } +diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h +new file mode 100644 +index 0000000..81ae3bb +--- /dev/null ++++ b/xlators/cluster/ec/src/ec-messages.h +@@ -0,0 +1,519 @@ ++/* ++ Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _EC_MESSAGES_H_ ++#define _EC_MESSAGES_H_ ++ ++#ifndef _CONFIG_H ++#define _CONFIG_H ++#include "config.h" ++#endif ++ ++#include "glfs-message-id.h" ++ ++/*! \file ec-messages.h ++ * \brief Glusterd log-message IDs and their descriptions ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_EC_COMP_BASE GLFS_MSGID_COMP_EC ++#define GLFS_NUM_MESSAGES 65 ++#define GLFS_MSGID_END (GLFS_EC_COMP_BASE + GLFS_NUM_MESSAGES + 1) ++/* Messaged with message IDs */ ++#define glfs_msg_start_x GLFS_EC_COMP_BASE, "Invalid: Start of messages" ++/*------------*/ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_CONFIG (GLFS_EC_COMP_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_HEAL_FAIL (GLFS_EC_COMP_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_DICT_COMBINE_FAIL (GLFS_EC_COMP_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_STIME_COMBINE_FAIL (GLFS_EC_COMP_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_DICT_NUMS (GLFS_EC_COMP_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_IATT_COMBINE_FAIL (GLFS_EC_COMP_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_FORMAT (GLFS_EC_COMP_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_DICT_GET_FAILED (GLFS_EC_COMP_BASE + 8) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_UNHANDLED_STATE (GLFS_EC_COMP_BASE + 9) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FILE_DESC_REF_FAIL (GLFS_EC_COMP_BASE + 10) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LOC_COPY_FAIL (GLFS_EC_COMP_BASE + 11) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_BUF_REF_FAIL (GLFS_EC_COMP_BASE + 12) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_DICT_REF_FAIL (GLFS_EC_COMP_BASE + 13) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LK_UNLOCK_FAILED (GLFS_EC_COMP_BASE + 14) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_UNLOCK_FAILED (GLFS_EC_COMP_BASE + 15) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LOC_PARENT_INODE_MISSING (GLFS_EC_COMP_BASE + 16) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_LOC_NAME (GLFS_EC_COMP_BASE + 17) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_NO_MEMORY (GLFS_EC_COMP_BASE + 18) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_GFID_MISMATCH (GLFS_EC_COMP_BASE + 19) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_UNSUPPORTED_VERSION (GLFS_EC_COMP_BASE + 20) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FD_CREATE_FAIL (GLFS_EC_COMP_BASE + 21) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_READDIRP_REQ_PREP_FAIL (GLFS_EC_COMP_BASE + 22) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LOOKUP_REQ_PREP_FAIL (GLFS_EC_COMP_BASE + 23) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INODE_REF_FAIL (GLFS_EC_COMP_BASE + 24) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LOOKUP_READAHEAD_FAIL (GLFS_EC_COMP_BASE + 25) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FRAME_MISMATCH (GLFS_EC_COMP_BASE + 26) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_XLATOR_MISMATCH (GLFS_EC_COMP_BASE + 27) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_VECTOR_MISMATCH (GLFS_EC_COMP_BASE + 28) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_IATT_MISMATCH (GLFS_EC_COMP_BASE + 29) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FD_MISMATCH (GLFS_EC_COMP_BASE + 30) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_DICT_MISMATCH (GLFS_EC_COMP_BASE + 31) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INDEX_DIR_GET_FAIL (GLFS_EC_COMP_BASE + 32) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_PREOP_LOCK_FAILED (GLFS_EC_COMP_BASE + 33) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_CHILDS_INSUFFICIENT (GLFS_EC_COMP_BASE + 34) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_OP_EXEC_UNAVAIL (GLFS_EC_COMP_BASE + 35) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_UNLOCK_DELAY_FAILED (GLFS_EC_COMP_BASE + 36) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_SIZE_VERS_UPDATE_FAIL (GLFS_EC_COMP_BASE + 37) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_REQUEST (GLFS_EC_COMP_BASE + 38) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_LOCK_TYPE (GLFS_EC_COMP_BASE + 39) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_SIZE_VERS_GET_FAIL (GLFS_EC_COMP_BASE + 40) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FILE_SIZE_GET_FAIL (GLFS_EC_COMP_BASE + 41) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FOP_MISMATCH (GLFS_EC_COMP_BASE + 42) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_SUBVOL_ID_DICT_SET_FAIL (GLFS_EC_COMP_BASE + 43) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_SUBVOL_BUILD_FAIL (GLFS_EC_COMP_BASE + 44) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_XLATOR_INIT_FAIL (GLFS_EC_COMP_BASE + 45) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_NO_PARENTS (GLFS_EC_COMP_BASE + 46) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_TIMER_CREATE_FAIL (GLFS_EC_COMP_BASE + 47) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_TOO_MANY_SUBVOLS (GLFS_EC_COMP_BASE + 48) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_DATA_UNAVAILABLE (GLFS_EC_COMP_BASE + 49) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INODE_REMOVE_FAIL (GLFS_EC_COMP_BASE + 50) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_REDUNDANCY (GLFS_EC_COMP_BASE + 51) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_XLATOR_PARSE_OPT_FAIL (GLFS_EC_COMP_BASE + 52) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_OP_FAIL_ON_SUBVOLS (GLFS_EC_COMP_BASE + 53) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_INODE (GLFS_EC_COMP_BASE + 54) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_LOCK_MISMATCH (GLFS_EC_COMP_BASE + 55) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_XDATA_MISMATCH (GLFS_EC_COMP_BASE + 56) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_HEALING_INFO (GLFS_EC_COMP_BASE + 57) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_HEAL_SUCCESS (GLFS_EC_COMP_BASE + 58) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FULL_SWEEP_START (GLFS_EC_COMP_BASE + 59) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_FULL_SWEEP_STOP (GLFS_EC_COMP_BASE + 59) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_INVALID_FOP (GLFS_EC_COMP_BASE + 60) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_EC_UP (GLFS_EC_COMP_BASE + 61) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_EC_DOWN (GLFS_EC_COMP_BASE + 62) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_SIZE_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 63) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_VER_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 64) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ */ ++#define EC_MSG_CONFIG_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 65) ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++#endif /* !_EC_MESSAGES_H_ */ +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index 797c390..64ab91b 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -18,6 +18,7 @@ + #include "ec-fops.h" + #include "ec-method.h" + #include "ec.h" ++#include "ec-messages.h" + #include "ec-heald.h" + + #define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS +@@ -51,8 +52,10 @@ int32_t ec_parse_options(xlator_t * this) + if ((ec->redundancy < 1) || (ec->redundancy >= ec->fragments) || + (ec->fragments > EC_MAX_FRAGMENTS)) + { +- gf_log(this->name, GF_LOG_ERROR, "Invalid redundancy (must be between " +- "1 and %d)", (ec->nodes - 1) / 2); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_INVALID_REDUNDANCY, ++ "Invalid redundancy (must be between " ++ "1 and %d)", (ec->nodes - 1) / 2); + + goto out; + } +@@ -68,7 +71,7 @@ int32_t ec_parse_options(xlator_t * this) + ec->fragment_size = EC_METHOD_CHUNK_SIZE; + ec->stripe_size = ec->fragment_size * ec->fragments; + +- gf_log("ec", GF_LOG_DEBUG, "Initialized with: nodes=%u, fragments=%u, " ++ gf_msg_debug ("ec", 0, "Initialized with: nodes=%u, fragments=%u, " + "stripe_size=%u, node_mask=%lX", + ec->nodes, ec->fragments, ec->stripe_size, ec->node_mask); + +@@ -90,7 +93,8 @@ int32_t ec_prepare_childs(xlator_t * this) + } + if (count > EC_MAX_NODES) + { +- gf_log(this->name, GF_LOG_ERROR, "Too many subvolumes"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_TOO_MANY_SUBVOLS, "Too many subvolumes"); + + return EINVAL; + } +@@ -99,7 +103,8 @@ int32_t ec_prepare_childs(xlator_t * this) + ec->xl_list = GF_CALLOC(count, sizeof(ec->xl_list[0]), ec_mt_xlator_t); + if (ec->xl_list == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Allocation of xlator list failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Allocation of xlator list failed"); + + return ENOMEM; + } +@@ -204,7 +209,8 @@ int32_t mem_acct_init(xlator_t * this) + { + if (xlator_mem_acct_init(this, ec_mt_end + 1) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting initialization " ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Memory accounting initialization " + "failed."); + + return -1; +@@ -258,7 +264,8 @@ ec_up (xlator_t *this, ec_t *ec) + } + + ec->up = 1; +- gf_log(this->name, GF_LOG_INFO, "Going UP"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_EC_UP, "Going UP"); + } + + void +@@ -270,7 +277,8 @@ ec_down (xlator_t *this, ec_t *ec) + } + + ec->up = 0; +- gf_log(this->name, GF_LOG_INFO, "Going DOWN"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ EC_MSG_EC_DOWN, "Going DOWN"); + } + + void +@@ -325,13 +333,14 @@ ec_launch_notify_timer (xlator_t *this, ec_t *ec) + { + struct timespec delay = {0, }; + +- gf_log (this->name, GF_LOG_DEBUG, "Initiating child-down timer"); ++ gf_msg_debug (this->name, 0, "Initiating child-down timer"); + delay.tv_sec = 10; + delay.tv_nsec = 0; + ec->timer = gf_timer_call_after (this->ctx, delay, ec_notify_cbk, ec); + if (ec->timer == NULL) { +- gf_log(this->name, GF_LOG_ERROR, "Cannot create timer " +- "for delayed initialization"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_TIMER_CREATE_FAIL, "Cannot create timer " ++ "for delayed initialization"); + } + } + +@@ -358,7 +367,7 @@ ec_handle_down (xlator_t *this, ec_t *ec, int32_t idx) + } + + if (((ec->xl_up >> idx) & 1) != 0) { /* Duplicate event */ +- gf_log(this->name, GF_LOG_DEBUG, "Child %d is DOWN", idx); ++ gf_msg_debug (this->name, 0, "Child %d is DOWN", idx); + + ec->xl_up ^= 1ULL << idx; + ec->xl_up_count--; +@@ -419,7 +428,7 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2) + dict_t *output = NULL; + gf_boolean_t propagate = _gf_true; + +- gf_log (this->name, GF_LOG_TRACE, "NOTIFY(%d): %p, %p", ++ gf_msg_trace (this->name, 0, "NOTIFY(%d): %p, %p", + event, data, data2); + + if (event == GF_EVENT_TRANSLATOR_OP) { +@@ -514,13 +523,15 @@ init (xlator_t *this) + + if (this->parents == NULL) + { +- gf_log(this->name, GF_LOG_WARNING, "Volume does not have parents."); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ EC_MSG_NO_PARENTS, "Volume does not have parents."); + } + + ec = GF_MALLOC(sizeof(*ec), ec_mt_ec_t); + if (ec == NULL) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to allocate private memory."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to allocate private memory."); + + return -1; + } +@@ -539,21 +550,24 @@ init (xlator_t *this) + if ((ec->fop_pool == NULL) || (ec->cbk_pool == NULL) || + (ec->lock_pool == NULL)) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to create memory pools."); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ EC_MSG_NO_MEMORY, "Failed to create memory pools."); + + goto failed; + } + + if (ec_prepare_childs(this) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to initialize xlator"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_XLATOR_INIT_FAIL, "Failed to initialize xlator"); + + goto failed; + } + + if (ec_parse_options(this) != 0) + { +- gf_log(this->name, GF_LOG_ERROR, "Failed to parse xlator options"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ EC_MSG_XLATOR_PARSE_OPT_FAIL, "Failed to parse xlator options"); + + goto failed; + } +@@ -564,21 +578,23 @@ init (xlator_t *this) + + if (ec->shd.iamshd) + ec_selfheal_daemon_init (this); +- gf_log(this->name, GF_LOG_DEBUG, "Disperse translator initialized."); ++ gf_msg_debug (this->name, 0, "Disperse translator initialized."); + + ec->leaf_to_subvolid = dict_new (); + if (!ec->leaf_to_subvolid) + goto failed; + if (glusterfs_reachable_leaves (this, ec->leaf_to_subvolid)) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol " +- "dictionary"); +- goto failed; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_SUBVOL_BUILD_FAIL, "Failed to build subvol " ++ "dictionary"); ++ goto failed; + } + + if (ec_subvol_to_subvol_id_transform (ec, ec->leaf_to_subvolid) < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol-id " +- "dictionary"); +- goto failed; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ EC_MSG_SUBVOL_ID_DICT_SET_FAIL, "Failed to build subvol-id " ++ "dictionary"); ++ goto failed; + } + + return 0; +-- +1.7.1 + diff --git a/SOURCES/0173-glusterd-Porting-left-out-log-messages-to-new-framew.patch b/SOURCES/0173-glusterd-Porting-left-out-log-messages-to-new-framew.patch new file mode 100644 index 0000000..e455421 --- /dev/null +++ b/SOURCES/0173-glusterd-Porting-left-out-log-messages-to-new-framew.patch @@ -0,0 +1,5321 @@ +From f803a73a41bf5c60135919965c3ce114db1483c2 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 25 Jun 2015 00:57:00 +0530 +Subject: [PATCH 173/190] glusterd: Porting left out log messages to new framework + +Backport of http://review.gluster.org/#/c/11388/ + +>Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 +>BUG: 1194640 +>Signed-off-by: Nandaja Varma + +Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 +BUG: 1231771 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/51682 +Reviewed-by: Anand Nekkunti +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-bitd-svc.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-bitrot.c | 87 ++- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 54 +- + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 90 ++- + xlators/mgmt/glusterd/src/glusterd-handler.c | 93 ++- + xlators/mgmt/glusterd/src/glusterd-hooks.c | 50 +- + xlators/mgmt/glusterd/src/glusterd-log-ops.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-messages.h | 830 +++++++++++++++++++- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 80 ++- + xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-quota.c | 20 +- + xlators/mgmt/glusterd/src/glusterd-rebalance.c | 11 +- + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 37 +- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 30 +- + xlators/mgmt/glusterd/src/glusterd-scrub-svc.c | 7 +- + xlators/mgmt/glusterd/src/glusterd-sm.c | 5 +- + .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 42 +- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-store.c | 28 +- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 10 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 189 +++-- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 349 ++++++--- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 35 +- + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 19 +- + xlators/mgmt/glusterd/src/glusterd.c | 68 +- + 25 files changed, 1677 insertions(+), 476 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +index c1acd40..1b71b6c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +@@ -43,12 +43,14 @@ glusterd_bitdsvc_create_volfile () + ret = glusterd_create_global_volfile (build_bitd_graph, + filepath, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create volfile"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, ++ "Failed to create volfile"); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -84,7 +86,7 @@ glusterd_bitdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitrot.c b/xlators/mgmt/glusterd/src/glusterd-bitrot.c +index 1563102..142f7e2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitrot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-bitrot.c +@@ -26,6 +26,7 @@ + #include "byte-order.h" + #include "compat-errno.h" + #include "glusterd-scrub-svc.h" ++#include "glusterd-messages.h" + + #include + #include +@@ -75,7 +76,8 @@ __glusterd_handle_bitrot (rpcsvc_request_t *req) + cli_req.dict.dict_len, + &dict); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " + "unserialize req-buffer to dictionary"); + snprintf (msg, sizeof (msg), "Unable to decode the " + "command"); +@@ -88,7 +90,8 @@ __glusterd_handle_bitrot (rpcsvc_request_t *req) + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (msg, sizeof (msg), "Unable to get volume name"); +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name, " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name, " + "while handling bitrot command"); + goto out; + } +@@ -96,7 +99,8 @@ __glusterd_handle_bitrot (rpcsvc_request_t *req) + ret = dict_get_int32 (dict, "type", &type); + if (ret) { + snprintf (msg, sizeof (msg), "Unable to get type of command"); +- gf_log (this->name, GF_LOG_ERROR, "Unable to get type of cmd, " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get type of cmd, " + "while handling bitrot command"); + goto out; + } +@@ -143,7 +147,8 @@ glusterd_bitrot_scrub_throttle (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "scrub-throttle-value", &scrub_throttle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch scrub-" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch scrub-" + "throttle value"); + goto out; + } +@@ -151,14 +156,17 @@ glusterd_bitrot_scrub_throttle (glusterd_volinfo_t *volinfo, dict_t *dict, + option = gf_strdup (scrub_throttle); + ret = dict_set_dynstr (volinfo->dict, key, option); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set option %s", + key); + goto out; + } + + ret = glusterd_scrubsvc_reconfigure (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to reconfigure scrub " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUBSVC_RECONF_FAIL, ++ "Failed to reconfigure scrub " + "services"); + goto out; + } +@@ -181,7 +189,8 @@ glusterd_bitrot_scrub_freq (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "scrub-frequency-value", &scrub_freq); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch scrub-" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch scrub-" + "freq value"); + goto out; + } +@@ -189,14 +198,17 @@ glusterd_bitrot_scrub_freq (glusterd_volinfo_t *volinfo, dict_t *dict, + option = gf_strdup (scrub_freq); + ret = dict_set_dynstr (volinfo->dict, key, option); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set option %s", + key); + goto out; + } + + ret = glusterd_scrubsvc_reconfigure (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to reconfigure scrub " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUBSVC_RECONF_FAIL, ++ "Failed to reconfigure scrub " + "services"); + goto out; + } +@@ -219,7 +231,8 @@ glusterd_bitrot_scrub (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_str (dict, "scrub-value", &scrub_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch scrub" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_GET_FAILED, "Unable to fetch scrub" + "value"); + goto out; + } +@@ -232,14 +245,17 @@ glusterd_bitrot_scrub (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_set_dynstr (volinfo->dict, key, option); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set option %s", + key); + goto out; + } + + ret = glusterd_scrubsvc_reconfigure (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to reconfigure scrub " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUBSVC_RECONF_FAIL, ++ "Failed to reconfigure scrub " + "services"); + goto out; + } +@@ -263,7 +279,8 @@ glusterd_bitrot_expiry_time (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_get_uint32 (dict, "expiry-time", &expiry_time); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get bitrot expiry" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get bitrot expiry" + " timer value."); + goto out; + } +@@ -273,14 +290,17 @@ glusterd_bitrot_expiry_time (glusterd_volinfo_t *volinfo, dict_t *dict, + + ret = dict_set_dynstr (volinfo->dict, key, key_value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option %s", ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set option %s", + key); + goto out; + } + + ret = glusterd_bitdsvc_reconfigure (); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to reconfigure bitrot" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BITDSVC_RECONF_FAIL, ++ "Failed to reconfigure bitrot" + "services"); + goto out; + } +@@ -317,7 +337,8 @@ glusterd_bitrot_enable (glusterd_volinfo_t *volinfo, char **op_errstr) + ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_BITROT, + "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + +@@ -325,7 +346,8 @@ glusterd_bitrot_enable (glusterd_volinfo_t *volinfo, char **op_errstr) + ret = dict_set_dynstr_with_alloc (volinfo->dict, "features.scrub", + "Active"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set option " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set option " + "features.scrub value"); + goto out; + } +@@ -353,7 +375,8 @@ glusterd_bitrot_disable (glusterd_volinfo_t *volinfo, char **op_errstr) + ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_BITROT, + "off"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "dict set failed"); + goto out; + } + +@@ -361,7 +384,8 @@ glusterd_bitrot_disable (glusterd_volinfo_t *volinfo, char **op_errstr) + ret = dict_set_dynstr_with_alloc (volinfo->dict, "features.scrub", + "Inactive"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set " + "features.scrub value"); + goto out; + } +@@ -463,7 +487,8 @@ glusterd_op_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -475,7 +500,8 @@ glusterd_op_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_int32 (dict, "type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get type from " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get type from " + "dict"); + goto out; + } +@@ -538,7 +564,8 @@ glusterd_op_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to re-create " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Unable to re-create " + "volfiles"); + ret = -1; + goto out; +@@ -547,7 +574,7 @@ glusterd_op_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to store volinfo for " ++ gf_msg_debug (this->name, 0, "Failed to store volinfo for " + "bitrot"); + goto out; + } +@@ -579,7 +606,8 @@ glusterd_op_stage_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); + goto out; + } + +@@ -598,7 +626,8 @@ glusterd_op_stage_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + ret = dict_get_int32 (dict, "type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to get type for " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to get type for " + "operation"); + + *op_errstr = gf_strdup ("Staging stage failed for bitrot " +@@ -621,7 +650,8 @@ glusterd_op_stage_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (!ret) { + ret = dict_get_str (dict, "scrub-value", &scrub_cmd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Unable to " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "Unable to " + "get scrub-value"); + *op_errstr = gf_strdup ("Staging failed for " + "bitrot operation. " +@@ -648,8 +678,9 @@ glusterd_op_stage_bitrot (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + out: + if (ret && op_errstr && *op_errstr) +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_BITROT_FAIL, "%s", *op_errstr); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index 7dc34c2..41080ec 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -130,7 +130,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + if ((volinfo->brick_count * stripe_count) == total_bricks) { + /* Change the volume type */ + *type = GF_CLUSTER_TYPE_STRIPE; +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_TYPE_CHANGING_INFO, + "Changing the type of volume %s from " + "'distribute' to 'stripe'", volinfo->volname); + ret = 0; +@@ -149,7 +150,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + if (!(total_bricks % (volinfo->replica_count * stripe_count))) { + /* Change the volume type */ + *type = GF_CLUSTER_TYPE_STRIPE_REPLICATE; +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_TYPE_CHANGING_INFO, + "Changing the type of volume %s from " + "'replicate' to 'replicate-stripe'", + volinfo->volname); +@@ -193,7 +195,8 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, + volinfo->replica_count)) == + (total_bricks * volinfo->dist_leaf_count)) { + /* Change the dist_leaf_count */ +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_STRIPE_COUNT_CHANGE_INFO, + "Changing the stripe count of " + "volume %s from %d to %d", + volinfo->volname, +@@ -229,7 +232,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + if ((volinfo->brick_count * replica_count) == total_bricks) { + /* Change the volume type */ + *type = GF_CLUSTER_TYPE_REPLICATE; +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_TYPE_CHANGING_INFO, + "Changing the type of volume %s from " + "'distribute' to 'replica'", volinfo->volname); + ret = 0; +@@ -294,7 +298,8 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, + (volinfo->brick_count * (replica_count * + volinfo->stripe_count))) { + /* Change the dist_leaf_count */ +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_REPLICA_COUNT_CHANGE_INFO, + "Changing the replica count of " + "volume %s from %d to %d", + volinfo->volname, volinfo->replica_count, +@@ -426,7 +431,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received add brick req"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_ADD_BRICK_REQ_RECVD, "Received add brick req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -510,13 +516,15 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + snprintf (err_str, sizeof (err_str), + "Volume %s is already a tier.", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_ALREADY_TIER, "%s", err_str); + ret = -1; + goto out; + } + + if (glusterd_is_tiering_supported(err_str) == _gf_false) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERSION_UNSUPPORTED, + "Tiering not supported at this version"); + ret = -1; + goto out; +@@ -524,7 +532,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + + ret = dict_get_int32 (dict, "hot-type", &type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to get type from dictionary"); + goto out; + } +@@ -536,7 +545,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Add-brick operation is " + "not supported on a tiered volume %s", volname); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_UNSUPPORTED, "%s", err_str); + goto out; + } + +@@ -804,7 +814,9 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received rem brick req"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_REM_BRICK_REQ_RECVD, ++ "Received rem brick req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -853,7 +865,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + + if ((volinfo->type == GF_CLUSTER_TYPE_TIER) && + (glusterd_is_tiering_supported(err_str) == _gf_false)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VERSION_UNSUPPORTED, + "Tiering not supported at this version"); + ret = -1; + goto out; +@@ -863,7 +876,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), "Unable to get cmd " + "ccommand"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "%s", err_str); + goto out; + } + +@@ -871,7 +885,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) + if (ret) { + snprintf (err_str, sizeof (err_str), + "Removing brick from a Tier volume is not allowed"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_UNSUPPORTED, "%s", err_str); + goto out; + } + +@@ -1735,7 +1750,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + snprintf (msg, sizeof(msg), "volume %s is not a tier " + "volume", volinfo->volname); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_TIER, "%s", errstr); + goto out; + } + +@@ -1833,7 +1849,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + snprintf (msg, sizeof(msg), "volume %s is not a tier " + "volume", volinfo->volname); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_TIER, "%s", errstr); + goto out; + } + +@@ -1892,7 +1909,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + snprintf (msg, sizeof(msg), "volume %s is not a tier " + "volume", volinfo->volname); + errstr = gf_strdup (msg); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_NOT_TIER, "%s", errstr); + goto out; + } + case GF_OP_CMD_COMMIT_FORCE: +@@ -2073,7 +2091,7 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr) + } + + if (dict_get(dict, "attach-tier")) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Adding tier"); ++ gf_msg_debug (THIS->name, 0, "Adding tier"); + glusterd_op_perform_attach_tier (dict, volinfo, count, bricks); + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +index df2dd6d..f0b20a0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c ++++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +@@ -21,6 +21,7 @@ + #include "glusterd-utils.h" + #include "glusterd-nfs-svc.h" + #include "glusterd-volgen.h" ++#include "glusterd-messages.h" + #define MAXBUF 1024 + #define DELIM "=\"" + #define SHARED_STORAGE_MNT "/var/run/gluster/shared_storage/nfs-ganesha" +@@ -80,7 +81,7 @@ manage_service (char *action) + while (sc_list[i].binary != NULL) { + ret = stat (sc_list[i].binary, &stbuf); + if (ret == 0) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "%s found.", sc_list[i].binary); + if (strcmp (sc_list[i].binary, "/usr/bin/systemctl") == 0) + ret = sc_systemctl_action (&sc_list[i], action); +@@ -91,7 +92,8 @@ manage_service (char *action) + } + i++; + } +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_UNRECOGNIZED_SVC_MNGR, + "Could not %s NFS-Ganesha.Service manager for distro" + " not recognized.", action); + return ret; +@@ -108,7 +110,7 @@ glusterd_check_ganesha_export (glusterd_volinfo_t *volinfo) { + ret = glusterd_volinfo_get (volinfo, "ganesha.enable", &value); + if ((ret == 0) && value) { + if (strcmp (value, "on") == 0) { +- gf_log (THIS->name, GF_LOG_DEBUG, "ganesha.enable set" ++ gf_msg_debug (THIS->name, 0, "ganesha.enable set" + " to %s", value); + is_exported = _gf_true; + } +@@ -137,7 +139,9 @@ glusterd_check_ganesha_cmd (char *key, char *value, char **errstr, dict_t *dict) + } + ret = glusterd_handle_ganesha_op (dict, errstr, key, value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Handling NFS-Ganesha" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_GNS_OP_HANDLE_FAIL, ++ "Handling NFS-Ganesha" + " op failed."); + } + } +@@ -169,7 +173,8 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr) + + value = dict_get_str_boolean (dict, "value", _gf_false); + if (value == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "value not present."); + goto out; + } +@@ -177,7 +182,8 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr) + /*Ignoring the ret value and proceeding */ + ret = dict_get_str (priv->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, &str); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "Global dict not present."); ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, "Global dict not present."); + ret = 0; + goto out; + } +@@ -193,7 +199,8 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr) + if (value) { + ret = start_ganesha (op_errstr); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_GNS_START_FAIL, + "Could not start NFS-Ganesha"); + + } +@@ -204,11 +211,11 @@ out: + if (ret) { + if (!(*op_errstr)) { + *op_errstr = gf_strdup ("Error, Validation Failed"); +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Error, Cannot Validate option :%s", + GLUSTERD_STORE_KEY_GANESHA_GLOBAL); + } else { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Error, Cannot Validate option"); + } + } +@@ -236,22 +243,25 @@ glusterd_op_set_ganesha (dict_t *dict, char **errstr) + + ret = dict_get_str (dict, "key", &key); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Couldn't get key in global option set"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, ++ "Couldn't get key in global option set"); + goto out; + } + + ret = dict_get_str (dict, "value", &value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Couldn't get value in global option set"); + goto out; + } + + ret = glusterd_handle_ganesha_op (dict, errstr, key, value); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Initial NFS-Ganesha set up failed"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_GNS_SETUP_FAIL, ++ "Initial NFS-Ganesha set up failed"); + ret = -1; + goto out; + } +@@ -259,14 +269,15 @@ glusterd_op_set_ganesha (dict_t *dict, char **errstr) + GLUSTERD_STORE_KEY_GANESHA_GLOBAL, + value); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to set" ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set" + " nfs-ganesha in dict."); + goto out; + } + ret = glusterd_get_next_global_opt_version_str (priv->opts, + &next_version); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, "Could not fetch " ++ gf_msg_debug (THIS->name, 0, "Could not fetch " + " global op version"); + goto out; + } +@@ -277,13 +288,13 @@ glusterd_op_set_ganesha (dict_t *dict, char **errstr) + + ret = glusterd_store_options (this, priv->opts); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Failed to store options"); +- goto out; ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_STORE_FAIL, "Failed to store options"); ++ goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); ++ gf_msg_debug (this->name, 0, "returning %d", ret); + return ret; + } + +@@ -312,7 +323,8 @@ is_ganesha_host (void) + fp = fopen (GANESHA_HA_CONF, "r"); + + if (fp == NULL) { +- gf_log (this->name, GF_LOG_INFO, "couldn't open the file %s", ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_FILE_OP_FAILED, "couldn't open the file %s", + GANESHA_HA_CONF); + return _gf_false; + } +@@ -331,7 +343,9 @@ is_ganesha_host (void) + + ret = gf_is_local_addr (host_from_file); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, "ganesha host found " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_NFS_GNS_HOST_FOUND, ++ "ganesha host found " + "Hostname is %s", host_from_file); + } + +@@ -360,7 +374,8 @@ check_host_list (void) + fp = fopen (GANESHA_HA_CONF, "r"); + + if (fp == NULL) { +- gf_log (this->name, GF_LOG_INFO, "couldn't open the file %s", ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_FILE_OP_FAILED, "couldn't open the file %s", + GANESHA_HA_CONF); + return 0; + } +@@ -382,7 +397,9 @@ check_host_list (void) + while (hostname != NULL) { + ret = gf_is_local_addr (hostname); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, "ganesha host found " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_NFS_GNS_HOST_FOUND, ++ "ganesha host found " + "Hostname is %s", hostname); + break; + } +@@ -440,19 +457,22 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr) + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get volume name"); + goto out; + } + ret = gf_string2boolean (value, &option); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "invalid value."); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "invalid value."); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_VOL_NOT_FOUND, + FMTSTR_CHECK_VOL_EXISTS, volname); + goto out; + } +@@ -475,7 +495,7 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr) + ret = dict_get_str_boolean (priv->opts, + GLUSTERD_STORE_KEY_GANESHA_GLOBAL, _gf_false); + if (ret == -1) { +- gf_log (this->name, GF_LOG_DEBUG, "Failed to get " ++ gf_msg_debug (this->name, 0, "Failed to get " + "global option dict."); + gf_asprintf (op_errstr, "The option " + "nfs-ganesha should be " +@@ -494,7 +514,9 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr) + if (option) { + ret = create_export_config (volname, op_errstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_EXPORT_FILE_CREATE_FAIL, ++ "Failed to create" + "export file for NFS-Ganesha\n"); + goto out; + } +@@ -585,7 +607,7 @@ teardown (char **op_errstr) + "cleanup", CONFDIR, NULL); + ret = runner_run (&runner); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, "Could not clean up" ++ gf_msg_debug (THIS->name, 0, "Could not clean up" + " NFS-Ganesha related config"); + + cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) { +@@ -594,7 +616,8 @@ teardown (char **op_errstr) + unexported, hence setting the appropriate key */ + ret = dict_set_str (vol_opts, "ganesha.enable", "off"); + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_SET_FAILED, + "Could not set ganesha.enable to off"); + } + out: +@@ -667,8 +690,9 @@ pre_setup (char **op_errstr) + ret = mkdir (SHARED_STORAGE_MNT, 0775); + + if ((-1 == ret) && (EEXIST != errno)) { +- gf_log ("THIS->name", GF_LOG_ERROR, "mkdir() failed on path %s," +- "errno: %s", SHARED_STORAGE_MNT, strerror (errno)); ++ gf_msg ("THIS->name", GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "mkdir() failed on path %s,", ++ SHARED_STORAGE_MNT); + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 0923d4b..3bc39c9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -697,7 +697,8 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx, + * not be held */ + ret = dict_get_str (dict, "volname", &tmp); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, errno, ++ GD_MSG_DICT_GET_FAILED, + "No Volume name present. " + "Locks not being held."); + goto local_locking_done; +@@ -1162,7 +1163,9 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received CLI probe req %s %d", ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_CLI_REQ_RECVD, ++ "Received CLI probe req %s %d", + hostname, port); + + if (dict_get_str(this->options,"transport.socket.bind-address", +@@ -1273,7 +1276,9 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req) + } + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received CLI deprobe req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_CLI_REQ_RECVD, ++ "Received CLI deprobe req"); + + ret = dict_get_str (dict, "hostname", &hostname); + if (ret) { +@@ -1392,7 +1397,9 @@ __glusterd_handle_cli_list_friends (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received cli list req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_CLI_REQ_RECVD, ++ "Received cli list req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -1451,7 +1458,9 @@ __glusterd_handle_cli_get_volume (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received get vol req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_GET_VOL_REQ_RCVD, ++ "Received get vol req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -1843,7 +1852,7 @@ __glusterd_handle_ganesha_cmd (rpcsvc_request_t *req) + } + } + +- gf_log (this->name, GF_LOG_TRACE, "Received global option request"); ++ gf_msg_trace (this->name, 0, "Received global option request"); + + ret = glusterd_op_begin_synctask (req, GD_OP_GANESHA, dict); + out: +@@ -2123,7 +2132,8 @@ __glusterd_handle_sync_volume (rpcsvc_request_t *req) + } + } + +- gf_log (this->name, GF_LOG_INFO, "Received volume sync req " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_SYNC_REQ_RCVD, "Received volume sync req " + "for volume %s", (flags & GF_CLI_SYNC_ALL) ? "all" : volname); + + if (gf_is_local_addr (hostname)) { +@@ -2515,7 +2525,8 @@ __glusterd_handle_incoming_friend_req (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PROBE_RCVD, + "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, +@@ -2564,7 +2575,8 @@ __glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_UNFRIEND_REQ_RCVD, + "Received unfriend from uuid: %s", uuid_utoa (friend_req.uuid)); + + ret = glusterd_remote_hostname_get (req, remote_hostname, +@@ -2689,7 +2701,8 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_FRIEND_UPDATE_RCVD, + "Received friend update from uuid: %s", uuid_utoa (friend_req.uuid)); + + if (friend_req.friends.friends_len) { +@@ -2733,7 +2746,8 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) + gf_uuid_parse (uuid_buf, uuid); + + if (!gf_uuid_compare (uuid, MY_UUID)) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_UUID_RECEIVED, + "Received my uuid as Friend"); + i++; + continue; +@@ -2856,7 +2870,8 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + else + port = GF_DEFAULT_BASE_PORT; + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PROBE_RCVD, + "Received probe from uuid: %s", uuid_utoa (probe_req.uuid)); + + /* Check for uuid collision and handle it in a user friendly way by +@@ -2889,7 +2904,9 @@ __glusterd_handle_probe_query (rpcsvc_request_t *req) + rsp.op_ret = -1; + rsp.op_errno = GF_PROBE_ANOTHER_CLUSTER; + } else if (peerinfo == NULL) { +- gf_log ("glusterd", GF_LOG_INFO, "Unable to find peerinfo" ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PEER_NOT_FOUND, ++ "Unable to find peerinfo" + " for host: %s (%d)", remote_hostname, port); + args.mode = GD_MODE_ON; + ret = glusterd_friend_add (remote_hostname, port, +@@ -2915,7 +2932,8 @@ respond: + (xdrproc_t)xdr_gd1_mgmt_probe_rsp); + ret = 0; + +- gf_log ("glusterd", GF_LOG_INFO, "Responded to %s, op_ret: %d, " ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, "Responded to %s, op_ret: %d, " + "op_errno: %d, ret: %d", remote_hostname, + rsp.op_ret, rsp.op_errno, ret); + +@@ -2976,7 +2994,9 @@ __glusterd_handle_cli_profile_volume (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received volume profile req " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_PROFILE_REQ_RCVD, ++ "Received volume profile req " + "for volume %s", volname); + ret = dict_get_int32 (dict, "op", &op); + if (ret) { +@@ -3025,7 +3045,8 @@ __glusterd_handle_getwd (rpcsvc_request_t *req) + priv = THIS->private; + GF_ASSERT (priv); + +- gf_log ("glusterd", GF_LOG_INFO, "Received getwd req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_GETWD_REQ_RCVD, "Received getwd req"); + + rsp.wd = priv->workdir; + +@@ -3070,7 +3091,9 @@ __glusterd_handle_mount (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received mount req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_MOUNT_REQ_RCVD, ++ "Received mount req"); + + if (mnt_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -3154,7 +3177,9 @@ __glusterd_handle_umount (rpcsvc_request_t *req) + goto out; + } + +- gf_log ("glusterd", GF_LOG_INFO, "Received umount req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_UMOUNT_REQ_RCVD, ++ "Received umount req"); + + if (dict_get_str (this->options, "mountbroker-root", + &mountbroker_root) != 0) { +@@ -3476,7 +3501,8 @@ glusterd_friend_add (const char *hoststr, int port, + } + + out: +- gf_log (this->name, GF_LOG_INFO, "connect returned %d", ret); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_CONNECT_RETURNED, "connect returned %d", ret); + return ret; + } + +@@ -3525,7 +3551,9 @@ glusterd_friend_add_from_peerinfo (glusterd_peerinfo_t *friend, + } + + out: +- gf_log (this->name, GF_LOG_INFO, "connect returned %d", ret); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_CONNECT_RETURNED, ++ "connect returned %d", ret); + return ret; + } + +@@ -3544,7 +3572,8 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port, + peerinfo = glusterd_peerinfo_find (NULL, hoststr); + + if (peerinfo == NULL) { +- gf_log ("glusterd", GF_LOG_INFO, "Unable to find peerinfo" ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PEER_NOT_FOUND, "Unable to find peerinfo" + " for host: %s (%d)", hoststr, port); + args.mode = GD_MODE_ON; + args.req = req; +@@ -3608,7 +3637,8 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port, + peerinfo = glusterd_peerinfo_find (uuid, hoststr); + if (peerinfo == NULL) { + ret = -1; +- gf_log ("glusterd", GF_LOG_INFO, "Unable to find peerinfo" ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PEER_NOT_FOUND, "Unable to find peerinfo" + " for host: %s %d", hoststr, port); + goto out; + } +@@ -3689,7 +3719,8 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int por + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_friend_rsp); + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, + "Responded to %s (%d), ret: %d", hostname, port, ret); + return ret; + } +@@ -3721,7 +3752,8 @@ glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *myhostname, + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gd1_mgmt_friend_rsp); + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, + "Responded to %s (%d), ret: %d", remote_hostname, port, ret); + GF_FREE (rsp.hostname); + return ret; +@@ -4207,7 +4239,8 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) + GD_MSG_VOL_NOT_FOUND, "%s", err_str); + goto out; + } +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_STATUS_VOL_REQ_RCVD, + "Received status volume req for volume %s", volname); + + } +@@ -4330,7 +4363,8 @@ __glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received clear-locks volume req " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_CLRCLK_VOL_REQ_RCVD, "Received clear-locks volume req " + "for volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_CLEARLOCKS_VOLUME, dict); +@@ -4452,7 +4486,9 @@ __glusterd_handle_barrier (rpcsvc_request_t *req) + "dict"); + goto out; + } +- gf_log (this->name, GF_LOG_INFO, "Received barrier volume request for " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_BARRIER_VOL_REQ_RCVD, ++ "Received barrier volume request for " + "volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_BARRIER, dict); +@@ -4807,7 +4843,8 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, + * need to stop the brick + */ + if (brickinfo->snap_status == -1) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_SNAPSHOT_PENDING, + "Snapshot is pending on %s:%s. " + "Hence not starting the brick", + brickinfo->hostname, +diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c +index 3e3f189..220c6b0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-hooks.c ++++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c +@@ -28,6 +28,7 @@ + #include "glusterd-utils.h" + #include "glusterd-store.h" + #include "glusterd-hooks.h" ++#include "glusterd-messages.h" + + #include + +@@ -89,16 +90,18 @@ glusterd_hooks_create_hooks_directory (char *basedir) + snprintf (path, sizeof (path), "%s/hooks", basedir); + ret = mkdir_p (path, 0777, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due" +- "to %s", path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Unable to create %s", ++ path); + goto out; + } + + GLUSTERD_GET_HOOKS_DIR (version_dir, GLUSTERD_HOOK_VER, priv); + ret = mkdir_p (version_dir, 0777, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due " +- "to %s", version_dir, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, "Unable to create %s", ++ version_dir); + goto out; + } + +@@ -111,9 +114,10 @@ glusterd_hooks_create_hooks_directory (char *basedir) + cmd_subdir); + ret = mkdir_p (path, 0777, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_CRITICAL, +- "Unable to create %s due to %s", +- path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, ++ "Unable to create %s", ++ path); + goto out; + } + +@@ -123,9 +127,10 @@ glusterd_hooks_create_hooks_directory (char *basedir) + version_dir, cmd_subdir, type_subdir[type]); + ret = mkdir_p (path, 0777, _gf_true); + if (ret) { +- gf_log (THIS->name, GF_LOG_CRITICAL, +- "Unable to create %s due to %s", +- path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, ++ "Unable to create %s", ++ path); + goto out; + } + } +@@ -176,10 +181,10 @@ glusterd_hooks_add_custom_args (dict_t *dict, runner_t *runner) + + ret = dict_get_str (dict, "hooks_args", &hooks_args); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "No Hooks Arguments."); + else +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Hooks Args = %s", hooks_args); + + if (hooks_args) +@@ -337,7 +342,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, + + ret = dict_get_str (op_ctx, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Failed to get volname " ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_DICT_GET_FAILED, "Failed to get volname " + "from operation context"); + goto out; + } +@@ -345,8 +351,10 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, + hookdir = opendir (hooks_path); + if (!hookdir) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s, due " +- "to %s", hooks_path, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, ++ "Failed to open dir %s", ++ hooks_path); + goto out; + } + +@@ -390,7 +398,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, + runner_argprintf (&runner, "--volname=%s", volname); + ret = glusterd_hooks_add_op_args (&runner, op, op_ctx, type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to add " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_ADD_OP_ARGS_FAIL, "Failed to add " + "command specific arguments"); + goto out; + } +@@ -480,7 +489,8 @@ glusterd_hooks_stub_init (glusterd_hooks_stub_t **stub, char *scriptdir, + ret = 0; + out: + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to initialize " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_POST_HOOK_STUB_INIT_FAIL, "Failed to initialize " + "post hooks stub"); + glusterd_hooks_stub_cleanup (hooks_stub); + } +@@ -492,7 +502,8 @@ void + glusterd_hooks_stub_cleanup (glusterd_hooks_stub_t *stub) + { + if (!stub) { +- gf_log_callingfn (THIS->name, GF_LOG_WARNING, ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_HOOK_STUB_NULL, + "hooks_stub is NULL"); + return; + } +@@ -582,7 +593,8 @@ glusterd_hooks_spawn_worker (xlator_t *this) + ret = pthread_create (&hooks_priv->worker, NULL, hooks_worker, + (void *)this); + if (ret) +- gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn post " ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_SPAWN_THREADS_FAIL, "Failed to spawn post " + "hooks worker thread"); + out: + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c +index 7611637..b2d4582 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c +@@ -72,7 +72,9 @@ __glusterd_handle_log_rotate (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received log rotate req " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_LOG_ROTATE_REQ_RECVD, ++ "Received log rotate req " + "for volume %s", volname); + + ret = dict_set_uint64 (dict, "rotate-key", (uint64_t)time (NULL)); +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index b7729fb..ea44e18 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD +-#define GLFS_NUM_MESSAGES 459 ++#define GLFS_NUM_MESSAGES 563 + #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" +@@ -3728,7 +3728,833 @@ + * @recommendedaction + * + */ ++#define GD_MSG_BITROT_NOT_RUNNING (GLUSTERD_COMP_BASE + 460) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SCRUBBER_NOT_RUNNING (GLUSTERD_COMP_BASE + 461) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SRC_BRICK_PORT_UNAVAIL (GLUSTERD_COMP_BASE + 462) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BITD_INIT_FAIL (GLUSTERD_COMP_BASE + 463) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SCRUB_INIT_FAIL (GLUSTERD_COMP_BASE + 464) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VAR_RUN_DIR_INIT_FAIL (GLUSTERD_COMP_BASE + 465) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VAR_RUN_DIR_FIND_FAIL (GLUSTERD_COMP_BASE + 466) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SCRUBSVC_RECONF_FAIL (GLUSTERD_COMP_BASE + 467) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BITDSVC_RECONF_FAIL (GLUSTERD_COMP_BASE + 468) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_START_FAIL (GLUSTERD_COMP_BASE + 469) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_SETUP_FAIL (GLUSTERD_COMP_BASE + 470) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_UNRECOGNIZED_SVC_MNGR (GLUSTERD_COMP_BASE + 471) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_OP_HANDLE_FAIL (GLUSTERD_COMP_BASE + 472) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_EXPORT_FILE_CREATE_FAIL (GLUSTERD_COMP_BASE + 473) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_HOST_FOUND (GLUSTERD_COMP_BASE + 474) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REBALANCE_CMD_IN_TIER_VOL (GLUSTERD_COMP_BASE + 475) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_INCOMPATIBLE_VALUE (GLUSTERD_COMP_BASE + 476) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GENERATED_UUID (GLUSTERD_COMP_BASE + 477) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_FILE_DESC_LIMIT_SET (GLUSTERD_COMP_BASE + 478) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_CURR_WORK_DIR_INFO (GLUSTERD_COMP_BASE + 479) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STRIPE_COUNT_CHANGE_INFO (GLUSTERD_COMP_BASE + 480) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REPLICA_COUNT_CHANGE_INFO (GLUSTERD_COMP_BASE + 481) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ADD_BRICK_REQ_RECVD (GLUSTERD_COMP_BASE + 482) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_ALREADY_TIER (GLUSTERD_COMP_BASE + 483) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REM_BRICK_REQ_RECVD (GLUSTERD_COMP_BASE + 484) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_NOT_TIER (GLUSTERD_COMP_BASE + 485) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_LOG_ROTATE_REQ_RECVD (GLUSTERD_COMP_BASE + 486) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_CLI_REQ_RECVD (GLUSTERD_COMP_BASE + 487) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GET_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 488) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_SYNC_REQ_RCVD (GLUSTERD_COMP_BASE + 489) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_PROBE_RCVD (GLUSTERD_COMP_BASE + 490) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_UNFRIEND_REQ_RCVD (GLUSTERD_COMP_BASE + 491) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_FRIEND_UPDATE_RCVD (GLUSTERD_COMP_BASE + 492) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_RESPONSE_INFO (GLUSTERD_COMP_BASE + 493) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_PROFILE_REQ_RCVD (GLUSTERD_COMP_BASE + 494) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GETWD_REQ_RCVD (GLUSTERD_COMP_BASE + 495) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_MOUNT_REQ_RCVD (GLUSTERD_COMP_BASE + 496) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_UMOUNT_REQ_RCVD (GLUSTERD_COMP_BASE + 497) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_CONNECT_RETURNED (GLUSTERD_COMP_BASE + 498) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STATUS_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 499) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_CLRCLK_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 500) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BARRIER_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 501) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_UUID_RECEIVED (GLUSTERD_COMP_BASE + 502) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REPLACE_BRK_COMMIT_FORCE_REQ_RCVD (GLUSTERD_COMP_BASE + 503) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BRK_PORT_NO_ADD_INDO (GLUSTERD_COMP_BASE + 504) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REPLACE_BRK_REQ_RCVD (GLUSTERD_COMP_BASE + 505) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ADD_OP_ARGS_FAIL (GLUSTERD_COMP_BASE + 506) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_POST_HOOK_STUB_INIT_FAIL (GLUSTERD_COMP_BASE + 507) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_HOOK_STUB_NULL (GLUSTERD_COMP_BASE + 508) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SPAWN_THREADS_FAIL (GLUSTERD_COMP_BASE + 509) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STALE_VOL_DELETE_INFO (GLUSTERD_COMP_BASE + 510) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_PROBE_REQ_RESP_RCVD (GLUSTERD_COMP_BASE + 511) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_HOST_PRESENT_ALREADY (GLUSTERD_COMP_BASE + 512) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_VERS_INFO (GLUSTERD_COMP_BASE + 513) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_VERS_SET_INFO (GLUSTERD_COMP_BASE + 514) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NEW_NODE_STATE_CREATION (GLUSTERD_COMP_BASE + 515) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ALREADY_MOUNTED (GLUSTERD_COMP_BASE + 516) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SHARED_STRG_VOL_OPT_VALIDATE_FAIL (GLUSTERD_COMP_BASE + 517) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_STOP_FAIL (GLUSTERD_COMP_BASE + 518) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_RESET_FAIL (GLUSTERD_COMP_BASE + 519) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SHARED_STRG_SET_FAIL (GLUSTERD_COMP_BASE + 520) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_TRANSPORT_TYPE_CHANGE (GLUSTERD_COMP_BASE + 521) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_PEER_COUNT_GET_FAIL (GLUSTERD_COMP_BASE + 522) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_INSUFFICIENT_UP_NODES (GLUSTERD_COMP_BASE + 523) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_STATS_VOL_FAIL (GLUSTERD_COMP_BASE + 524) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOL_ID_SET_FAIL (GLUSTERD_COMP_BASE + 525) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_RESET_VOL_FAIL (GLUSTERD_COMP_BASE + 526) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_BITROT_FAIL (GLUSTERD_COMP_BASE + 527) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_QUOTA_FAIL (GLUSTERD_COMP_BASE + 528) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_DELETE_VOL_FAIL (GLUSTERD_COMP_BASE + 529) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_HANDLE_HEAL_CMD_FAIL (GLUSTERD_COMP_BASE + 530) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_CLRCLK_SND_CMD_FAIL (GLUSTERD_COMP_BASE + 531) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_DISPERSE_CLUSTER_FOUND (GLUSTERD_COMP_BASE + 532) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_HEAL_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 533) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STATEDUMP_VOL_REQ_RCVD (GLUSTERD_COMP_BASE + 534) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_THINPOOLS_FOR_THINLVS (GLUSTERD_COMP_BASE + 535) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_CREATE_VOL_FAIL (GLUSTERD_COMP_BASE + 536) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_OP_STAGE_START_VOL_FAIL (GLUSTERD_COMP_BASE + 537) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_NFS_GNS_UNEXPRT_VOL_FAIL (GLUSTERD_COMP_BASE + 538) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_TASK_ID_INFO (GLUSTERD_COMP_BASE + 539) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_DEREGISTER_SUCCESS (GLUSTERD_COMP_BASE + 540) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STATEDUMP_OPTS_RCVD (GLUSTERD_COMP_BASE + 541) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_STATEDUMP_INFO (GLUSTERD_COMP_BASE + 542) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_RECOVERING_CORRUPT_CONF (GLUSTERD_COMP_BASE + 543) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_RETRIEVED_UUID (GLUSTERD_COMP_BASE + 544) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XLATOR_CREATE_FAIL (GLUSTERD_COMP_BASE + 545) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GRAPH_ENTRY_ADD_FAIL (GLUSTERD_COMP_BASE + 546) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ERROR_ENCOUNTERED (GLUSTERD_COMP_BASE + 547) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_FILTER_RUN_FAILED (GLUSTERD_COMP_BASE + 548) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_DEFAULT_OPT_INFO (GLUSTERD_COMP_BASE + 549) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_MARKER_STATUS_GET_FAIL (GLUSTERD_COMP_BASE + 550) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_MARKER_DISABLE_FAIL (GLUSTERD_COMP_BASE + 551) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GRAPH_FEATURE_ADD_FAIL (GLUSTERD_COMP_BASE + 552) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XLATOR_SET_OPT_FAIL (GLUSTERD_COMP_BASE + 553) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_BUILD_GRAPH_FAILED (GLUSTERD_COMP_BASE + 554) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XML_TEXT_WRITE_FAIL (GLUSTERD_COMP_BASE + 555) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XML_DOC_START_FAIL (GLUSTERD_COMP_BASE + 556) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XML_ELE_CREATE_FAIL (GLUSTERD_COMP_BASE + 557) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_VOLUME_INCONSISTENCY (GLUSTERD_COMP_BASE + 558) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_XLATOR_LINK_FAIL (GLUSTERD_COMP_BASE + 559) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_REMOTE_HOST_GET_FAIL (GLUSTERD_COMP_BASE + 560) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_GRAPH_SET_OPT_FAIL (GLUSTERD_COMP_BASE + 561) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ROOT_SQUASH_ENABLED (GLUSTERD_COMP_BASE + 562) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_ROOT_SQUASH_FAILED (GLUSTERD_COMP_BASE + 563) ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" +- + #endif /* !_GLUSTERD_MESSAGES_H_ */ ++ +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 8e5c4bb..c8acc86 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -236,7 +236,8 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + GF_ASSERT (priv); + + if (!txn_id || !opinfo) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, + "Empty transaction id or opinfo received."); + ret = -1; + goto out; +@@ -246,7 +247,8 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + uuid_utoa (*txn_id), + (void **) &opinfo_obj); + if (ret) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Unable to get transaction opinfo " + "for transaction ID : %s", + uuid_utoa (*txn_id)); +@@ -279,7 +281,8 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + GF_ASSERT (priv); + + if (!txn_id) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, + "Empty transaction id received."); + ret = -1; + goto out; +@@ -300,7 +303,8 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + uuid_utoa (*txn_id), opinfo_obj, + sizeof(glusterd_txn_opinfo_obj)); + if (ret) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Unable to set opinfo for transaction" + " ID : %s", uuid_utoa (*txn_id)); + goto out; +@@ -737,7 +741,8 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr) + snprintf (errstr, PATH_MAX, + "Invalid option(%s). Valid options " + "are 'enable' and 'disable'", value); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", errstr); + ret = -1; + goto out; + } +@@ -751,7 +756,8 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr) + snprintf (errstr, PATH_MAX, + "Shared storage volume("GLUSTER_SHARED_STORAGE + ") already exists."); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_ALREADY_EXIST, "%s", errstr); + ret = -1; + goto out; + } +@@ -760,7 +766,8 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr) + if (ret) { + snprintf (errstr, PATH_MAX, + "Failed to calculate number of connected peers."); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_COUNT_GET_FAIL, "%s", errstr); + goto out; + } + +@@ -768,7 +775,8 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr) + snprintf (errstr, PATH_MAX, + "More than one node should " + "be up/present in the cluster to enable this option"); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_INSUFFICIENT_UP_NODES, "%s", errstr); + ret = -1; + goto out; + } +@@ -1116,7 +1124,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + + ret = glusterd_validate_shared_storage (key, value, errstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SHARED_STRG_VOL_OPT_VALIDATE_FAIL, + "Failed to validate shared " + "storage volume options"); + goto out; +@@ -1381,7 +1390,8 @@ out: + GF_FREE (key_fixed); + + if (msg[0] != '\0') { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_RESET_VOL_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + +@@ -1712,7 +1722,8 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr) + ret = 0; + out: + if (msg[0] != '\0') { +- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_STATS_VOL_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + gf_msg_debug ("glusterd", 0, "Returning %d", ret); +@@ -1890,11 +1901,13 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) + if (option) { + ret = tear_down_cluster(); + if (ret == -1) +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "Could not tear down NFS-Ganesha cluster"); + ret = stop_ganesha (&op_errstr); + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_NFS_GNS_STOP_FAIL, + "Could not stop NFS-Ganesha service"); + } + +@@ -2009,7 +2022,8 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) + if (ret) { + ret = ganesha_manage_export (dict, "off", op_rspstr); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_NFS_GNS_RESET_FAIL, + "Could not reset ganesha.enable key"); + ret = 0; + } +@@ -2120,7 +2134,8 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, + + ret = glusterd_set_shared_storage (dict, key, value, op_errstr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SHARED_STRG_SET_FAIL, + "Failed to set shared storage option"); + goto out; + } +@@ -2237,7 +2252,8 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value, + "storage brick(%s). " + "Reason: %s", ss_brick_path, + strerror (errno)); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, "%s", errstr); + ret = -1; + goto out; + } +@@ -2249,7 +2265,8 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value, + "storage brick(%s). " + "Reason: %s", ss_brick_path, + strerror (errno)); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_CREATE_DIR_FAILED, "%s", errstr); + goto out; + } + +@@ -2265,7 +2282,8 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value, + + ret = dict_set_dynstr_with_alloc (dict, "hooks_args", hooks_args); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set" + " hooks_args in dict."); + goto out; + } +@@ -2387,7 +2405,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + } + + if (strcmp (key, "config.transport") == 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_VOL_TRANSPORT_TYPE_CHANGE, + "changing transport-type for volume %s to %s", + volname, value); + ret = 0; +@@ -3543,7 +3562,8 @@ glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_mgmt_v3_lock (globalname, lock_ctx->uuid, + &op_errno, "global"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Unable to acquire lock for %s", + globalname); + +@@ -3606,7 +3626,8 @@ glusterd_op_ac_unlock (glusterd_op_sm_event_t *event, void *ctx) + ret = glusterd_mgmt_v3_unlock (globalname, lock_ctx->uuid, + "global"); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_UNLOCK_FAIL, + "Unable to release lock for %s", + globalname); + +@@ -3698,7 +3719,8 @@ glusterd_dict_set_volid (dict_t *dict, char *volname, char **op_errstr) + } + out: + if (msg[0] != '\0') { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_ID_SET_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + return ret; +@@ -3938,7 +3960,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) + if (do_common) { + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, -ret, ++ GD_MSG_DICT_GET_FAILED, + "volname is not present in " + "operation ctx"); + goto out; +@@ -5594,14 +5617,15 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, + + ret = dict_get_int32 (dict, "count", &count); + if (ret) { +- gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, -ret, + GD_MSG_DICT_GET_FAILED, "Unable to get count"); + goto out; + } + + ret = dict_get_int32 (dict, "command", &command); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get command"); ++ gf_msg ("glusterd", GF_LOG_ERROR, -ret, ++ GD_MSG_DICT_GET_FAILED, "Unable to get command"); + goto out; + } + +@@ -6508,7 +6532,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + ret = 0; + } else if ((cmd & GF_CLI_STATUS_BITD) != 0) { + if (!priv->bitd_svc.online) { +- gf_log (this->name, GF_LOG_ERROR, "Bitrot is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BITROT_NOT_RUNNING, "Bitrot is not " + "running"); + ret = -1; + goto out; +@@ -6527,7 +6552,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, + ret = 0; + } else if ((cmd & GF_CLI_STATUS_SCRUB) != 0) { + if (!priv->scrub_svc.online) { +- gf_log (this->name, GF_LOG_ERROR, "Scrubber is not " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUBBER_NOT_RUNNING, "Scrubber is not " + "running"); + ret = -1; + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +index 5ece68c..155add4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +@@ -990,7 +990,7 @@ glusterd_peerinfo_find_by_generation (uint32_t generation) { + cds_list_for_each_entry_rcu (entry, &priv->peers, uuid_list) { + if (entry->generation == generation) { + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Friend found... state: %s", + glusterd_friend_sm_state_name_get (entry->state.state)); + found = entry; /* Probably should be rcu_dereferenced */ +@@ -1000,7 +1000,7 @@ glusterd_peerinfo_find_by_generation (uint32_t generation) { + rcu_read_unlock (); + + if (!found) +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Friend with generation: %"PRIu32", not found", + generation); + return found; +diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c +index f4fc831..22dd3d3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quota.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quota.c +@@ -405,7 +405,9 @@ glusterd_inode_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr, + ret = dict_set_dynstr_with_alloc (volinfo->dict, + VKEY_FEATURES_INODE_QUOTA, "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, ++ "dict set failed"); + goto out; + } + +@@ -471,7 +473,8 @@ glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr, + "features.quota-deem-statfs", + "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "setting quota-deem-statfs" ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "setting quota-deem-statfs" + "in volinfo failed"); + goto out; + } +@@ -843,21 +846,25 @@ out: + } else if (!ret) { + ret = gf_store_rename_tmppath (volinfo->quota_conf_shandle); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to rename " ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "Failed to rename " + "quota conf file"); + return ret; + } + + ret = glusterd_compute_cksum (volinfo, _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_CKSUM_COMPUTE_FAIL, "Failed to " + "compute cksum for quota conf file"); + return ret; + } + + ret = glusterd_store_save_quota_version_and_cksum (volinfo); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CKSUM_VER_STORE_FAIL, "Failed to " + "store quota version and cksum"); + } + +@@ -1828,7 +1835,8 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + out: + if (ret && op_errstr && *op_errstr) +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_QUOTA_FAIL, "%s", *op_errstr); + gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +index 8449bb2..f1d4cb5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c +@@ -430,7 +430,9 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, + + ret = glusterd_disallow_op_for_tier (*volinfo, GD_OP_REBALANCE, cmd); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance command " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REBALANCE_CMD_IN_TIER_VOL, ++ "Received rebalance command " + "on Tier volume %s", volname); + snprintf (op_errstr, len, "Rebalance operations are not " + "supported on a tiered volume"); +@@ -556,13 +558,16 @@ glusterd_brick_validation (dict_t *dict, char *key, data_t *value, + ret = glusterd_volume_brickinfo_get_by_brick (value->data, volinfo, + &brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Incorrect brick %s for " ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_BRICK_NOT_FOUND, ++ "Incorrect brick %s for " + "volume %s", value->data, volinfo->volname); + return ret; + } + + if (!brickinfo->decommissioned) { +- gf_log (this->name, GF_LOG_ERROR, "Incorrect brick %s for " ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_BRICK_NOT_FOUND, "Incorrect brick %s for " + "volume %s", value->data, volinfo->volname); + ret = -1; + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index b063284..a6120c8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -140,7 +140,9 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received replace brick req"); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_REPLACE_BRK_REQ_RCVD, ++ "Received replace brick req"); + + if (cli_req.dict.dict_len) { + /* Unserialize the dictionary */ +@@ -197,7 +199,9 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req) + } + + gf_msg_debug (this->name, 0, "dst brick=%s", dst_brick); +- gf_log (this->name, GF_LOG_INFO, "Received replace brick commit-force " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_REPLACE_BRK_COMMIT_FORCE_REQ_RCVD, ++ "Received replace brick commit-force " + "request operation"); + + ret = glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (req, +@@ -392,7 +396,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + ret = dict_set_int32 (rsp_dict, "src-brick-port", + src_brickinfo->port); + if (ret) { +- gf_msg_debug ("", 0, ++ gf_msg_debug (this->name, 0, + "Could not set src-brick-port=%d", + src_brickinfo->port); + } +@@ -431,7 +435,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr, + if (ret) { + *op_errstr = gf_strdup (msg); + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BRICK_VALIDATE_FAIL, "%s", *op_errstr); + goto out; + } + +@@ -567,7 +572,8 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + src_brickinfo->port = src_port; + + if (gf_is_local_addr (src_brickinfo->hostname)) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_BRK_PORT_NO_ADD_INDO, + "adding src-brick port no"); + + if (volinfo->transport_type == GF_TRANSPORT_RDMA) { +@@ -580,7 +586,8 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + src_brickinfo->port = pmap_registry_search (this, + brickname, GF_PMAP_PORT_BRICKSERVER); + if (!src_brickinfo->port) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SRC_BRICK_PORT_UNAVAIL, + "Src brick port not available"); + ret = -1; + goto out; +@@ -590,7 +597,7 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + ret = dict_set_int32 (rsp_dict, "src-brick-port", + src_brickinfo->port); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Could not set src-brick port no"); + goto out; + } +@@ -600,7 +607,7 @@ rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, + ret = dict_set_int32 (req_dict, "src-brick-port", + src_brickinfo->port); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Could not set src-brick port no"); + goto out; + } +@@ -626,14 +633,15 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + dst_brickinfo->port = dst_port; + + if (gf_is_local_addr (dst_brickinfo->hostname)) { +- gf_log ("", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_BRK_PORT_NO_ADD_INDO, + "adding dst-brick port no"); + + if (rsp_dict) { + ret = dict_set_int32 (rsp_dict, "dst-brick-port", + dst_brickinfo->port); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not set dst-brick port no in rsp dict"); + goto out; + } +@@ -643,7 +651,7 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + ret = dict_set_int32 (req_dict, "dst-brick-port", + dst_brickinfo->port); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not set dst-brick port no"); + goto out; + } +@@ -737,7 +745,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo, + + out: + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -842,7 +850,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + } + + if (gf_is_local_addr (dst_brickinfo->hostname)) { +- gf_log (this->name, GF_LOG_DEBUG, "I AM THE DESTINATION HOST"); ++ gf_msg_debug (this->name, 0, "I AM THE DESTINATION HOST"); + ret = rb_kill_destination_brick (volinfo, dst_brickinfo); + if (ret) { + gf_msg (this->name, GF_LOG_CRITICAL, 0, +@@ -854,7 +862,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + + ret = glusterd_svcs_stop (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_NFS_SERVER_STOP_FAIL, + "Unable to stop nfs server, ret: %d", ret); + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 2ce65dc..e380e43 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -248,7 +248,8 @@ __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_PROBE_REQ_RESP_RCVD, + "Received probe resp from uuid: %s, host: %s", + uuid_utoa (rsp.uuid), rsp.hostname); + if (rsp.op_ret != 0) { +@@ -275,7 +276,8 @@ __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, + peerinfo = glusterd_peerinfo_find (rsp.uuid, rsp.hostname); + if (peerinfo == NULL) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not find peerd %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peerd %s(%s)", + rsp.hostname, uuid_utoa (rsp.uuid)); + goto unlock; + } +@@ -358,7 +360,8 @@ reply: + goto unlock; + + } else if (strncasecmp (rsp.hostname, peerinfo->hostname, 1024)) { +- gf_log (THIS->name, GF_LOG_INFO, "Host: %s with uuid: %s " ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_HOST_PRESENT_ALREADY, "Host: %s with uuid: %s " + "already present in cluster with alias hostname: %s", + rsp.hostname, uuid_utoa (rsp.uuid), peerinfo->hostname); + +@@ -407,7 +410,8 @@ cont: + ret = glusterd_friend_sm_inject_event (event); + + +- gf_log ("glusterd", GF_LOG_INFO, "Received resp to probe req"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_PROBE_REQ_RESP_RCVD, "Received resp to probe req"); + + unlock: + rcu_read_unlock (); +@@ -468,7 +472,8 @@ __glusterd_friend_add_cbk (struct rpc_req * req, struct iovec *iov, + op_ret = rsp.op_ret; + op_errno = rsp.op_errno; + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, + "Received %s from uuid: %s, host: %s, port: %d", + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port); + +@@ -585,7 +590,8 @@ __glusterd_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, + op_ret = rsp.op_ret; + op_errno = rsp.op_errno; + +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, + "Received %s from uuid: %s, host: %s, port: %d", + (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port); + +@@ -681,7 +687,8 @@ __glusterd_friend_update_cbk (struct rpc_req *req, struct iovec *iov, + + ret = 0; + out: +- gf_log (this->name, GF_LOG_INFO, "Received %s from uuid: %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_RESPONSE_INFO, "Received %s from uuid: %s", + (ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); + + GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe)); +@@ -1521,7 +1528,8 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + if (!peerinfo) { + rcu_read_unlock (); + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + goto out; + } +@@ -1545,7 +1553,8 @@ glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, + "hostname_in_cluster", + peerinfo->hostname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Unable to add hostname of the peer"); + goto out; + } +@@ -1618,7 +1627,8 @@ glusterd_rpc_friend_remove (call_frame_t *frame, xlator_t *this, + if (!peerinfo) { + rcu_read_unlock (); + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)", + event->peername, uuid_utoa (event->peerid)); + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +index 8d1133f..36863e2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +@@ -44,12 +44,13 @@ glusterd_scrubsvc_create_volfile () + ret = glusterd_create_global_volfile (build_scrub_graph, + filepath, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create volfile"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volfile"); + goto out; + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -80,7 +81,7 @@ glusterd_scrubsvc_manager (glusterd_svc_t *svc, void *data, int flags) + } + + out: +- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (THIS->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 1a90aae..902e770 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -619,7 +619,8 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + */ + if (!glusterd_friend_contains_vol_bricks (volinfo, + MY_UUID)) { +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_STALE_VOL_DELETE_INFO, + "Deleting stale volume %s", volinfo->volname); + ret = glusterd_delete_volume (volinfo); + if (ret) { +@@ -870,7 +871,7 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) + ret = dict_get_str (ev_ctx->vols, "hostname_in_cluster", + &hostname); + if (ret || !hostname) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Unable to fetch local hostname from peer"); + } else + strncpy (local_node_hostname, hostname, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +index 8e17e44..acc4e42 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +@@ -1995,7 +1995,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + uint64_t voldisplaycount = 0; + + if (!dst || !src) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_EMPTY, "Source or Destination " + "dict is empty."); + goto out; +@@ -2003,7 +2003,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (dst, "config-command", &config_command); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "failed to get config-command type"); + goto out; +@@ -2019,7 +2019,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, + hard_limit); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set snap_max_hard_limit"); + goto out; +@@ -2034,7 +2034,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT, + &soft_limit); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get snap_max_soft_limit"); + goto out; +@@ -2044,7 +2044,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT, + soft_limit); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set snap_max_soft_limit"); + goto out; +@@ -2053,7 +2053,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + ret = dict_get_uint64 (src, "voldisplaycount", + &voldisplaycount); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get voldisplaycount"); + goto out; +@@ -2062,7 +2062,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + ret = dict_set_uint64 (dst, "voldisplaycount", + voldisplaycount); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set voldisplaycount"); + goto out; +@@ -2073,14 +2073,14 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + "volume%"PRIu64"-volname", i); + ret = dict_get_str (src, buf, &volname); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get %s", buf); + goto out; + } + ret = dict_set_str (dst, buf, volname); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set %s", buf); + goto out; +@@ -2090,14 +2090,14 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + "volume%"PRIu64"-snap-max-hard-limit", i); + ret = dict_get_uint64 (src, buf, &value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get %s", buf); + goto out; + } + ret = dict_set_uint64 (dst, buf, value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set %s", buf); + goto out; +@@ -2107,14 +2107,14 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + "volume%"PRIu64"-active-hard-limit", i); + ret = dict_get_uint64 (src, buf, &value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get %s", buf); + goto out; + } + ret = dict_set_uint64 (dst, buf, value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set %s", buf); + goto out; +@@ -2124,14 +2124,14 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + "volume%"PRIu64"-snap-max-soft-limit", i); + ret = dict_get_uint64 (src, buf, &value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get %s", buf); + goto out; + } + ret = dict_set_uint64 (dst, buf, value); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, + "Unable to set %s", buf); + goto out; +@@ -2145,7 +2145,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) + + ret = 0; + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -2382,7 +2382,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src) + int32_t snap_command = 0; + + if (!dst || !src) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_EMPTY, "Source or Destination " + "dict is empty."); + goto out; +@@ -2390,7 +2390,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (dst, "type", &snap_command); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "unable to get the type of " + "the snapshot command"); + goto out; +@@ -2402,7 +2402,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src) + case GF_SNAP_OPTION_TYPE_CLONE: + ret = glusterd_snap_create_use_rsp_dict (dst, src); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_RSP_DICT_USE_FAIL, + "Unable to use rsp dict"); + goto out; +@@ -2411,7 +2411,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src) + case GF_SNAP_OPTION_TYPE_CONFIG: + ret = glusterd_snap_config_use_rsp_dict (dst, src); + if (ret) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_RSP_DICT_USE_FAIL, + "Unable to use rsp dict"); + goto out; +@@ -2426,7 +2426,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src) + + ret = 0; + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 654310c..839b274 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -2257,7 +2257,8 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr, + out: + + if (ret && err_str[0] != '\0') { +- gf_log (this->name, loglevel, "%s", err_str); ++ gf_msg (this->name, loglevel, 0, ++ GD_MSG_SNAP_CLONE_PREVAL_FAILED, "%s", err_str); + *op_errstr = gf_strdup (err_str); + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index 9e110e5..db7d1d4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -2031,7 +2031,8 @@ glusterd_restore_op_version (xlator_t *this) + goto out; + } + conf->op_version = op_version; +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_OP_VERS_INFO, + "retrieved op-version: %d", conf->op_version); + goto out; + } +@@ -2051,11 +2052,15 @@ glusterd_restore_op_version (xlator_t *this) + */ + ret = glusterd_retrieve_uuid(); + if (ret) { +- gf_log (this->name, GF_LOG_INFO, "Detected new install. Setting" ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_OP_VERS_SET_INFO, ++ "Detected new install. Setting" + " op-version to maximum : %d", GD_OP_VERSION_MAX); + conf->op_version = GD_OP_VERSION_MAX; + } else { +- gf_log (this->name, GF_LOG_INFO, "Upgrade detected. Setting" ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_OP_VERS_SET_INFO, ++ "Upgrade detected. Setting" + " op-version to minimum : %d", GD_OP_VERSION_MIN); + conf->op_version = GD_OP_VERSION_MIN; + } +@@ -2814,7 +2819,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) + /* Initialize the snapd service */ + ret = glusterd_snapdsvc_init (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize snapd " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd " + "service for volume %s", volinfo->volname); + goto out; + } +@@ -3029,7 +3035,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) + ret = glusterd_store_retrieve_node_state (volinfo); + if (ret) { + /* Backward compatibility */ +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_NEW_NODE_STATE_CREATION, + "Creating a new node_state " + "for volume: %s.", entry->d_name); + glusterd_store_create_nodestate_sh_on_absence (volinfo); +@@ -3133,7 +3140,8 @@ glusterd_mount_brick_paths (char *brick_mount_path, + entry = glusterd_get_mnt_entry_info (brick_mount_path, buff, + sizeof (buff), &save_entry); + if (entry) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_ALREADY_MOUNTED, + "brick_mount_path (%s) already mounted.", + brick_mount_path); + ret = 0; +@@ -4461,7 +4469,9 @@ glusterd_quota_conf_write_header (int fd) + + out: + if (ret < 0) +- gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to write " ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "failed to write " + "header to a quota conf"); + + return ret; +@@ -4499,7 +4509,9 @@ glusterd_quota_conf_write_gfid (int fd, void *buf, char type) + + out: + if (ret < 0) +- gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to write " ++ gf_msg_callingfn ("quota", GF_LOG_ERROR, 0, ++ GD_MSG_QUOTA_CONF_WRITE_FAIL, ++ "failed to write " + "gfid %s to a quota conf", uuid_utoa (buf)); + + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index faf255a..a54073e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -569,7 +569,9 @@ _gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov, + peerinfo->locked = _gf_true; + } else { + rsp.op_ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer with " ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_PEER_NOT_FOUND, ++ "Could not find peer with " + "ID %s", uuid_utoa (*peerid)); + } + rcu_read_unlock (); +@@ -662,7 +664,8 @@ _gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov, + peerinfo->locked = _gf_false; + } else { + rsp.op_ret = -1; +- gf_log (this->name, GF_LOG_ERROR, "Could not find peer with " ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_PEER_NOT_FOUND, "Could not find peer with " + "ID %s", uuid_utoa (*peerid)); + } + rcu_read_unlock (); +@@ -1839,7 +1842,8 @@ global: + ret = glusterd_mgmt_v3_lock (global, MY_UUID, &op_errno, + "global"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_MGMTV3_LOCK_GET_FAIL, + "Unable to acquire lock for %s", global); + gf_asprintf (&op_errstr, + "Another transaction is in progress " +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index ab68f71..3bb72b1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -1295,7 +1295,7 @@ glusterd_volume_brickinfo_get_by_brick (char *brick, + brickinfo); + (void) glusterd_brickinfo_delete (tmp_brickinfo); + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1383,7 +1383,9 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, + GF_ASSERT (this); + if (!gf_is_service_running (pidfile, &pid)) { + ret = 0; +- gf_log (this->name, GF_LOG_INFO, "%s already stopped", service); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_ALREADY_STOPPED, ++ "%s already stopped", service); + goto out; + } + gf_msg_debug (this->name, 0, "Stopping gluster %s running in pid: " +@@ -1506,7 +1508,7 @@ glusterd_brick_connect (glusterd_volinfo_t *volinfo, + } + out: + +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -1560,7 +1562,8 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, + GF_ASSERT (priv); + + if (brickinfo->snap_status == -1) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_SNAPSHOT_PENDING, + "Snapshot is pending on %s:%s. " + "Hence not starting the brick", + brickinfo->hostname, +@@ -1674,7 +1677,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, + if (volinfo->memory_accounting) + runner_add_arg (&runner, "--mem-accounting"); + +- runner_log (&runner, "", GF_LOG_DEBUG, "Starting GlusterFS"); ++ runner_log (&runner, "", 0, "Starting GlusterFS"); + if (wait) { + synclock_unlock (&priv->big_lock); + ret = runner_run (&runner); +@@ -1735,7 +1738,8 @@ glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo) + GF_ASSERT (brickinfo); + + if (!brickinfo) { +- gf_log_callingfn ("glusterd", GF_LOG_WARNING, "!brickinfo"); ++ gf_msg_callingfn ("glusterd", GF_LOG_WARNING, EINVAL, ++ GD_MSG_BRICK_NOT_FOUND, "!brickinfo"); + return -1; + } + +@@ -2759,7 +2763,7 @@ out: + if (msg[0]) + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_IMPORT_PRDICT_DICT, "%s", msg); +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + + } +@@ -2838,7 +2842,7 @@ out: + if (msg[0]) + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_OPTS_IMPORT_FAIL, "%s", msg); +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -2926,7 +2930,7 @@ out: + if (msg[0]) + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_BRICK_IMPORT_FAIL, "%s", msg); +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -2966,7 +2970,7 @@ glusterd_import_bricks (dict_t *peer_data, int32_t vol_count, + } + ret = 0; + out: +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3280,7 +3284,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_brick_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'hot_type' key is not a error +@@ -3290,7 +3294,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_type); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'hot_replica_count' key is not a error +@@ -3300,7 +3304,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_replica_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_brick_count' key is not a error +@@ -3310,7 +3314,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_brick_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_type' key is not a error +@@ -3320,7 +3324,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_type); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_replica_count' key is not a error +@@ -3330,7 +3334,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_replica_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_disperse_count' key is not a error +@@ -3340,7 +3344,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_disperse_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_redundancy_count' key is not a error +@@ -3351,7 +3355,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_redundancy_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + /* not having a 'cold_dist_count' key is not a error +@@ -3361,7 +3365,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_dist_leaf_count); + if (ret) +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "peer is possibly old version"); + + new_volinfo->subvol_count = new_volinfo->brick_count/ +@@ -3517,7 +3521,7 @@ out: + if (msg[0]) + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOLINFO_IMPORT_FAIL, "%s", msg); +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3624,7 +3628,7 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo, + } + ret = 0; + out: +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -3804,7 +3808,8 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + + ret = glusterd_snapdsvc_init (new_volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " + "snapdsvc for volume %s", new_volinfo->volname); + goto out; + } +@@ -3819,7 +3824,8 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + + ret = glusterd_store_volinfo (new_volinfo, GLUSTERD_VOLINFO_VER_AC_NONE); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to store " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLINFO_STORE_FAIL, "Failed to store " + "volinfo for volume %s", new_volinfo->volname); + goto out; + } +@@ -3837,7 +3843,7 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + glusterd_compare_volume_name); + + out: +- gf_msg_debug ("", 0, "Returning with ret: %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with ret: %d", ret); + return ret; + } + +@@ -3862,7 +3868,7 @@ glusterd_import_friend_volumes (dict_t *peer_data) + } + + out: +- gf_msg_debug ("", 0, "Returning with %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning with %d", ret); + return ret; + } + +@@ -4124,42 +4130,54 @@ void + glusterd_nfs_pmap_deregister () + { + if (pmap_unset (MOUNT_PROGRAM, MOUNTV3_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered MOUNTV3 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered MOUNTV3 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, + "De-register MOUNTV3 is unsuccessful"); + + if (pmap_unset (MOUNT_PROGRAM, MOUNTV1_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered MOUNTV1 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered MOUNTV1 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, + "De-register MOUNTV1 is unsuccessful"); + + if (pmap_unset (NFS_PROGRAM, NFSV3_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered NFSV3 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered NFSV3 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, + "De-register NFSV3 is unsuccessful"); + + if (pmap_unset (NLM_PROGRAM, NLMV4_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered NLM v4 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered NLM v4 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, + "De-registration of NLM v4 failed"); + + if (pmap_unset (NLM_PROGRAM, NLMV1_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered NLM v1 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered NLM v1 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, + "De-registration of NLM v1 failed"); + + if (pmap_unset (ACL_PROGRAM, ACLV3_VERSION)) +- gf_log ("", GF_LOG_INFO, "De-registered ACL v3 successfully"); ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEREGISTER_SUCCESS, ++ "De-registered ACL v3 successfully"); + else + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_PMAP_UNSET_FAIL, +@@ -4384,7 +4402,7 @@ glusterd_volume_count_get (void) + } + + +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -4635,7 +4653,8 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + * not started, do not restart the geo-rep session */ + if ((!strcmp (buf, "Created")) || + (!strcmp (buf, "Stopped"))) { +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_GEO_REP_START_FAILED, + "Geo-Rep Session was not started between " + "%s and %s::%s. Not Restarting", volinfo->volname, + slave_url, slave_vol); +@@ -4643,7 +4662,8 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) + } else if (strstr(buf, "Paused")) { + is_paused = _gf_true; + } else if ((!strcmp (buf, "Config Corrupted"))) { +- gf_log (this1->name, GF_LOG_INFO, ++ gf_msg (this1->name, GF_LOG_INFO, 0, ++ GD_MSG_RECOVERING_CORRUPT_CONF, + "Recovering from a corrupted config. " + "Not Restarting. Use start (force) to " + "start the session between %s and %s::%s.", +@@ -5405,7 +5425,7 @@ glusterd_all_volume_cond_check (glusterd_condition_func func, int status, + } + ret = 0; + out: +- gf_msg_debug ("", 0, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -5569,7 +5589,7 @@ glusterd_rb_check_bricks (glusterd_volinfo_t *volinfo, + + if (strcmp (rb->src_brick->hostname, src->hostname) || + strcmp (rb->src_brick->path, src->path)) { +- gf_msg("", GF_LOG_ERROR, 0, ++ gf_msg("glusterd", GF_LOG_ERROR, 0, + GD_MSG_RB_SRC_BRICKS_MISMATCH, + "Replace brick src bricks differ"); + return -1; +@@ -5796,7 +5816,7 @@ glusterd_sm_tr_log_transition_add_to_dict (dict_t *dict, + goto out; + + out: +- gf_msg_debug ("", 0, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -5837,7 +5857,7 @@ glusterd_sm_tr_log_add_to_dict (dict_t *dict, + ret = dict_set_int32 (dict, key, log->count); + + out: +- gf_msg_debug ("", 0, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -5868,7 +5888,7 @@ glusterd_sm_tr_log_init (glusterd_sm_tr_log_t *log, + ret = 0; + + out: +- gf_msg_debug ("", 0, "returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "returning %d", ret); + return ret; + } + +@@ -6029,7 +6049,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + path_tokens = GF_CALLOC (sizeof(char*), volinfo->brick_count, + gf_gld_mt_charptr); + if (!path_tokens) { +- gf_msg_debug ("", 0, "Could not allocate memory."); ++ gf_msg_debug ("glusterd", 0, "Could not allocate memory."); + ret = -1; + goto out; + } +@@ -6046,7 +6066,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + path[sizeof(path)-1] = '\0'; + path_tokens[count] = gf_strdup (path); + if (!path_tokens[count]) { +- gf_msg_debug ("", 0, ++ gf_msg_debug ("glusterd", 0, + "Could not allocate memory."); + ret = -1; + goto out; +@@ -6058,7 +6078,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist) + tmp_path_list = GF_CALLOC (sizeof(char), total_len + 1, + gf_gld_mt_char); + if (!tmp_path_list) { +- gf_msg_debug ("", 0, "Could not allocate memory."); ++ gf_msg_debug ("glusterd", 0, "Could not allocate memory."); + ret = -1; + goto out; + } +@@ -6081,12 +6101,12 @@ out: + path_tokens = NULL; + + if (ret == 0) { +- gf_msg_debug ("", 0, "No Local Bricks Present."); ++ gf_msg_debug ("glusterd", 0, "No Local Bricks Present."); + GF_FREE (tmp_path_list); + tmp_path_list = NULL; + } + +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -6114,7 +6134,7 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave, + + if (!path_list) { + ret = 0; +- gf_msg_debug ("", 0, "No Bricks in this node." ++ gf_msg_debug ("glusterd", 0, "No Bricks in this node." + " Not starting gsyncd."); + goto out; + } +@@ -6177,7 +6197,7 @@ out: + "the " GEOREP " session"); + } + +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -6331,7 +6351,9 @@ glusterd_set_dump_options (char *dumpoptions_path, char *options, + goto out; + } + dup_options = gf_strdup (options); +- gf_log ("", GF_LOG_INFO, "Received following statedump options: %s", ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_STATEDUMP_OPTS_RCVD, ++ "Received following statedump options: %s", + dup_options); + option = strtok_r (dup_options, " ", &tmpptr); + while (option) { +@@ -6422,7 +6444,9 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, + goto out; + } + +- gf_log ("", GF_LOG_INFO, "Performing statedump on brick with pid %d", ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_STATEDUMP_INFO, ++ "Performing statedump on brick with pid %d", + pid); + + kill (pid, SIGUSR1); +@@ -6500,7 +6524,9 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr) + goto out; + } + +- gf_log ("", GF_LOG_INFO, "Performing statedump on nfs server with " ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_STATEDUMP_INFO, ++ "Performing statedump on nfs server with " + "pid %d", pid); + + kill (pid, SIGUSR1); +@@ -6579,7 +6605,9 @@ glusterd_quotad_statedump (char *options, int option_cnt, char **op_errstr) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Performing statedump on quotad with " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_STATEDUMP_INFO, ++ "Performing statedump on quotad with " + "pid %d", pid); + + kill (pid, SIGUSR1); +@@ -6645,7 +6673,8 @@ glusterd_friend_remove_cleanup_vols (uuid_t uuid) + cds_list_for_each_entry_safe (volinfo, tmp_volinfo, &priv->volumes, + vol_list) { + if (glusterd_friend_contains_vol_bricks (volinfo, uuid) == 2) { +- gf_log (THIS->name, GF_LOG_INFO, ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_STALE_VOL_DELETE_INFO, + "Deleting stale volume %s", volinfo->volname); + ret = glusterd_delete_volume (volinfo); + if (ret) { +@@ -6933,12 +6962,12 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, + + ret = dict_get_uint64 (rsp_dict, "promoted", &promoted); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get promoted count"); + + ret = dict_get_uint64 (rsp_dict, "demoted", &demoted); + if (ret) +- gf_log (this->name, GF_LOG_TRACE, ++ gf_msg_trace (this->name, 0, + "failed to get demoted count"); + + ret = dict_get_double (rsp_dict, "run-time", &run_time); +@@ -7237,7 +7266,7 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (src, "gsync-count", &src_count); + if (ret || !src_count) { +- gf_msg_debug ("", 0, "Source brick empty"); ++ gf_msg_debug ("glusterd", 0, "Source brick empty"); + ret = 0; + goto out; + } +@@ -7271,7 +7300,7 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) + ret = dict_set_int32 (dst, "gsync-count", dst_count+src_count); + + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -7375,7 +7404,7 @@ glusterd_gsync_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict, char *op_errstr) + + ret = 0; + out: +- gf_msg_debug ("", 0, "Returning %d ", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d ", ret); + return ret; + } + +@@ -7407,13 +7436,13 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + if (rsp_dict) { + ret = dict_get_int32 (rsp_dict, "src-brick-port", &src_port); + if (ret == 0) { +- gf_msg_debug ("", 0, ++ gf_msg_debug ("glusterd", 0, + "src-brick-port=%d found", src_port); + } + + ret = dict_get_int32 (rsp_dict, "dst-brick-port", &dst_port); + if (ret == 0) { +- gf_msg_debug ("", 0, ++ gf_msg_debug ("glusterd", 0, + "dst-brick-port=%d found", dst_port); + } + +@@ -7431,7 +7460,7 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_int32 (ctx, "src-brick-port", + src_port); + if (ret) { +- gf_msg_debug ("", 0, ++ gf_msg_debug ("glusterd", 0, + "Could not set src-brick"); + goto out; + } +@@ -7441,7 +7470,7 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = dict_set_int32 (ctx, "dst-brick-port", + dst_port); + if (ret) { +- gf_msg_debug ("", 0, ++ gf_msg_debug ("glusterd", 0, + "Could not set dst-brick"); + goto out; + } +@@ -7885,28 +7914,32 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = dict_get_int32 (rsp_dict, "hot_brick_count", &hot_brick_count); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get hot brick count from rsp_dict"); + goto out; + } + + ret = dict_set_int32 (ctx_dict, "hot_brick_count", hot_brick_count); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to update hot_brick_count"); + goto out; + } + + ret = dict_get_int32 (rsp_dict, "type", &type); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "Failed to get type from rsp_dict"); + goto out; + } + + ret = dict_set_int32 (ctx_dict, "type", type); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to update type"); + goto out; + } +@@ -8118,7 +8151,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "demoted-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set demoted count"); + } + } +@@ -8130,7 +8163,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + snprintf (key, 256, "promoted-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { +- gf_log (THIS->name, GF_LOG_DEBUG, ++ gf_msg_debug (THIS->name, 0, + "failed to set promoted count"); + } + } +@@ -8164,7 +8197,7 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + + ret = dict_get_int32 (src, "output_count", &src_output_count); + if (ret) { +- gf_msg_debug ("", 0, "No output from source"); ++ gf_msg_debug ("glusterd", 0, "No output from source"); + ret = 0; + goto out; + } +@@ -8198,7 +8231,7 @@ glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src) + ret = dict_set_int32 (dst, "output_count", + dst_output_count+src_output_count); + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -8779,14 +8812,16 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, + snprintf (key, 256, "promoted-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.promoted); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set lookedup file count"); + + memset (key, 0 , 256); + snprintf (key, 256, "demoted-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.demoted); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "failed to set lookedup file count"); + + out: +@@ -8825,7 +8860,7 @@ glusterd_handle_node_rsp (dict_t *req_dict, void *pending_entry, + break; + } + +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -8919,7 +8954,8 @@ glusterd_generate_and_set_task_id (dict_t *dict, char *key) + key); + goto out; + } +- gf_log (this->name, GF_LOG_INFO, "Generated task-id %s for key %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_TASK_ID_INFO, "Generated task-id %s for key %s", + uuid_str, key); + + out: +@@ -9506,7 +9542,8 @@ glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option) + ret = dict_set_dynstr_with_alloc (volinfo->dict, + "performance.readdir-ahead", "on"); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set option " + "'performance.readdir-ahead' on volume " + "%s", volinfo->volname); +@@ -9979,7 +10016,7 @@ glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + case GD_OP_ADD_BRICK: + case GD_OP_REPLACE_BRICK: + ret = -1; +- gf_log (this->name, GF_LOG_DEBUG, "Operation not " ++ gf_msg_debug (this->name, 0, "Operation not " + "permitted on tiered volume %s", + volinfo->volname); + break; +@@ -9993,7 +10030,7 @@ glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + ret = 0; + break; + default: +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Rebalance Operation not permitted" + " on tiered volume %s", + volinfo->volname); +@@ -10010,7 +10047,7 @@ glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + ret = 0; + break; + default: +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Remove brick operation not " + "permitted on tiered volume %s", + volinfo->volname); +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index a79e129..09671a8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -88,7 +88,9 @@ xlator_instantiate_va (const char *type, const char *format, va_list arg) + return xl; + + error: +- gf_log ("", GF_LOG_ERROR, "creating xlator of type %s failed", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XLATOR_CREATE_FAIL, ++ "creating xlator of type %s failed", + type); + GF_FREE (volname); + if (xl) +@@ -119,7 +121,8 @@ volgen_xlator_link (xlator_t *pxl, xlator_t *cxl) + + ret = glusterfs_xlator_link (pxl, cxl); + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Out of memory, cannot link xlators %s <- %s", + pxl->name, cxl->name); + } +@@ -136,7 +139,9 @@ volgen_graph_link (volgen_graph_t *graph, xlator_t *xl) + if (graph->graph.first) + ret = volgen_xlator_link (xl, graph->graph.first); + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, "failed to add graph entry %s", ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_GRAPH_ENTRY_ADD_FAIL, ++ "failed to add graph entry %s", + xl->name); + + return -1; +@@ -211,7 +216,8 @@ xlator_set_option (xlator_t *xl, char *key, char *value) + + dval = gf_strdup (value); + if (!dval) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_NO_MEMORY, + "failed to set xlator opt: %s[%s] = %s", + xl->name, key, value); + +@@ -582,7 +588,8 @@ volgen_dict_get (dict_t *dict, char *key, char **value) + ret = volgen_graph_set_options_generic (NULL, dict, &vme, + &optget_option_handler); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of memory"); + + return -1; + } +@@ -643,7 +650,9 @@ glusterd_volinfo_get_boolean (glusterd_volinfo_t *volinfo, char *key) + if (val) + ret = gf_string2boolean (val, &enabled); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "value for %s option is not valid", key); ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, ++ "value for %s option is not valid", key); + + return -1; + } +@@ -750,7 +759,8 @@ glusterd_check_option_exists (char *key, char **completion) + if (completion) { + ret = option_complete (key, completion); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, + "Out of memory"); + return -1; + } +@@ -777,7 +787,8 @@ glusterd_check_option_exists (char *key, char **completion) + trie: + ret = volopt_trie (key, completion); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_ERROR_ENCOUNTERED, + "Some error occurred during keyword hinting"); + } + +@@ -794,7 +805,8 @@ glusterd_volopt_validate (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + xlator_t *this = THIS; + + if (!dict || !key || !value) { +- gf_log_callingfn (this->name, GF_LOG_WARNING, "Invalid " ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Invalid " + "Arguments (dict=%p, key=%s, value=%s)", dict, + key, value); + return -1; +@@ -829,7 +841,8 @@ glusterd_get_trans_type_rb (gf_transport_type ttype) + gf_asprintf (&trans_type, "tcp"); + break; + default: +- gf_log (THIS->name, GF_LOG_ERROR, "Unknown " ++ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Unknown " + "transport type"); + } + +@@ -849,7 +862,7 @@ _xl_link_children (xlator_t *parent, xlator_t *children, size_t child_count) + for (trav = children; --seek; trav = trav->next); + for (; child_count--; trav = trav->prev) { + ret = volgen_xlator_link (parent, trav); +- gf_log (THIS->name, GF_LOG_DEBUG, "%s:%s", parent->name, ++ gf_msg_debug (THIS->name, 0, "%s:%s", parent->name, + trav->name); + if (ret) + goto out; +@@ -928,8 +941,10 @@ volgen_apply_filters (char *orig_volfile) + goto free_fp; + } + if (runcmd(filterpath,orig_volfile,NULL)) { +- gf_log("",GF_LOG_ERROR,"failed to run filter %.*s", +- (int)sizeof(entry.d_name), entry.d_name); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_FILTER_RUN_FAILED, ++ "failed to run filter %.*s", ++ (int)sizeof(entry.d_name), entry.d_name); + } + free_fp: + GF_FREE(filterpath); +@@ -956,8 +971,8 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename) + + fd = creat (ftmp, S_IRUSR | S_IWUSR); + if (fd < 0) { +- gf_log (this->name, GF_LOG_ERROR, "%s", +- strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "file creation failed"); + goto error; + } + +@@ -971,8 +986,9 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename) + goto error; + + if (fclose (f) != 0) { +- gf_log (THIS->name, GF_LOG_ERROR, "fclose on the file %s " +- "failed (%s)", ftmp, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, "fclose on the file %s " ++ "failed", ftmp); + /* + * Even though fclose has failed here, we have to set f to NULL. + * Otherwise when the code path goes to error, there again we +@@ -1000,7 +1016,8 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename) + if (f) + fclose (f); + +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "failed to create volfile %s", filename); + + return -1; +@@ -1098,7 +1115,8 @@ get_vol_nfs_transport_type (glusterd_volinfo_t *volinfo, char *tt) + { + if (volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) { + strcpy (tt, "tcp"); +- gf_log ("glusterd", GF_LOG_INFO, ++ gf_msg ("glusterd", GF_LOG_INFO, 0, ++ GD_MSG_DEFAULT_OPT_INFO, + "The default transport type for tcp,rdma volume " + "is tcp if option is not defined by the user "); + } else +@@ -1205,7 +1223,9 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme, + + ret = glusterd_volinfo_get_boolean (volinfo, VKEY_MARKER_XTIME); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "failed to get the marker status"); ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_MARKER_STATUS_GET_FAIL, ++ "failed to get the marker status"); + ret = -1; + goto out; + } +@@ -1215,7 +1235,9 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme, + glusterd_check_geo_rep_configured (volinfo, &enabled); + + if (enabled) { +- gf_log ("", GF_LOG_WARNING, GEOREP" sessions active" ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_MARKER_DISABLE_FAIL, ++ GEOREP" sessions active" + "for the volume %s, cannot disable marker " + ,volinfo->volname); + set_graph_errstr (graph, +@@ -1228,7 +1250,7 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme, + + ret = 0; + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -1352,8 +1374,9 @@ volgen_graph_set_xl_options (volgen_graph_t *graph, dict_t *dict) + + for (trav = first_of (graph); trav; trav = trav->next) { + if (fnmatch(xlator_match, trav->type, FNM_NOESCAPE) == 0) { +- gf_log ("glusterd", GF_LOG_DEBUG, "Setting log level for xlator: %s", +- trav->type); ++ gf_msg_debug ("glusterd", 0, ++ "Setting log level for xlator: %s", ++ trav->type); + ret = xlator_set_option (trav, "log-level", loglevel); + if (ret) + break; +@@ -1884,7 +1907,8 @@ brick_graph_add_ro (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + + if (dict_get_str_boolean (set_dict, "features.read-only", 0) && + dict_get_str_boolean (set_dict, "features.worm", 0)) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "read-only and worm cannot be set together"); + ret = -1; + goto out; +@@ -1915,7 +1939,8 @@ brick_graph_add_worm (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + + if (dict_get_str_boolean (set_dict, "features.read-only", 0) && + dict_get_str_boolean (set_dict, "features.worm", 0)) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_INCOMPATIBLE_VALUE, + "read-only and worm cannot be set together"); + ret = -1; + goto out; +@@ -1993,7 +2018,8 @@ brick_graph_add_upcall (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + + xl = volgen_graph_add (graph, "features/upcall", volinfo->volname); + if (!xl) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_FEATURE_ADD_FAIL, + "failed to add features/upcall to graph"); + goto out; + } +@@ -2045,7 +2071,8 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cert-depth", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_XLATOR_SET_OPT_FAIL, + "failed to set ssl-cert-depth"); + return -1; + } +@@ -2054,7 +2081,8 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cipher-list", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_XLATOR_SET_OPT_FAIL, + "failed to set ssl-cipher-list"); + return -1; + } +@@ -2137,7 +2165,8 @@ brick_graph_add_pump (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) { + ret = xlator_set_option (rbxl, "ssl-cert-depth", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to set ssl-cert-depth"); + return -1; + } +@@ -2147,7 +2176,8 @@ brick_graph_add_pump (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ret = xlator_set_option (rbxl, "ssl-cipher-list", + value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to set ssl-cipher-list"); + return -1; + } +@@ -2329,7 +2359,8 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ret = server_graph_table[i].builder (graph, volinfo, set_dict, + param); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "Builing graph " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_BUILD_GRAPH_FAILED, "Builing graph " + "failed for server graph table entry: %d", i); + goto out; + } +@@ -2350,7 +2381,8 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (!ret) { + ret = dict_get_str (set_dict, "loglevel", &loglevel); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "could not get both" ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "could not get both" + " translator name and loglevel for log level request"); + goto out; + } +@@ -2436,21 +2468,23 @@ end_sethelp_xml_doc (xmlTextWriterPtr writer) + + ret = xmlTextWriterEndElement(writer); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an " +- "xmlElemetnt"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_TEXT_WRITE_FAIL, "Could not end an " ++ "xmlElement"); + ret = -1; + goto out; + } + ret = xmlTextWriterEndDocument (writer); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_TEXT_WRITE_FAIL, "Could not end an " + "xmlDocument"); + ret = -1; + goto out; + } + ret = 0; + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -2462,7 +2496,8 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf) + + *buf = xmlBufferCreateSize (8192); + if (buf == NULL) { +- gf_log ("glusterd", GF_LOG_ERROR, "Error creating the xml " ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Error creating the xml " + "buffer"); + ret = -1; + goto out; +@@ -2472,7 +2507,8 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf) + + *writer = xmlNewTextWriterMemory(*buf, 0); + if (writer == NULL) { +- gf_log ("glusterd", GF_LOG_ERROR, " Error creating the xml " ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, " Error creating the xml " + "writer"); + ret = -1; + goto out; +@@ -2480,15 +2516,17 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf) + + ret = xmlTextWriterStartDocument(*writer, "1.0", "UTF-8", "yes"); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Error While starting the " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_DOC_START_FAIL, "Error While starting the " + "xmlDoc"); + goto out; + } + + ret = xmlTextWriterStartElement(*writer, (xmlChar *)"options"); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an " +- "xmlElemetnt"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an " ++ "xmlElement"); + ret = -1; + goto out; + } +@@ -2497,7 +2535,7 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf) + ret = 0; + + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -2513,7 +2551,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + + ret = xmlTextWriterStartElement(writer, (xmlChar *) "option"); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an " + "xmlElemetnt"); + ret = -1; + goto out; +@@ -2522,7 +2561,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + ret = xmlTextWriterWriteFormatElement(writer, (xmlChar*)"defaultValue", + "%s", def_val); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an " + "xmlElemetnt"); + ret = -1; + goto out; +@@ -2531,7 +2571,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"description", + "%s", dscrpt ); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an " + "xmlElemetnt"); + ret = -1; + goto out; +@@ -2540,7 +2581,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *) "name", "%s", + name); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an " + "xmlElemetnt"); + ret = -1; + goto out; +@@ -2548,7 +2590,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + + ret = xmlTextWriterEndElement(writer); + if (ret < 0) { +- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_XML_ELE_CREATE_FAIL, "Could not end an " + "xmlElemetnt"); + ret = -1; + goto out; +@@ -2556,7 +2599,7 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name, + + ret = 0; + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + + } +@@ -2599,10 +2642,11 @@ _get_xlator_opt_key_from_vme ( struct volopt_map_entry *vme, char **key) + } + } + if (ret) +- gf_log ("glusterd", GF_LOG_ERROR, "Wrong entry found in " ++ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "Wrong entry found in " + "glusterd_volopt_map entry %s", vme->key); + else +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; + } +@@ -2699,7 +2743,8 @@ volgen_graph_build_client (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cert-depth", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to set ssl-cert-depth"); + goto err; + } +@@ -2708,7 +2753,8 @@ volgen_graph_build_client (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cipher-list", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, + "failed to set ssl-cipher-list"); + goto err; + } +@@ -2733,7 +2779,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + volname = volinfo->volname; + + if (volinfo->brick_count == 0) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLUME_INCONSISTENCY, + "volume inconsistency: brick count is 0"); + goto out; + } +@@ -2741,7 +2788,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if ((volinfo->type != GF_CLUSTER_TYPE_TIER) && + (volinfo->dist_leaf_count < volinfo->brick_count) && + ((volinfo->brick_count % volinfo->dist_leaf_count) != 0)) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLUME_INCONSISTENCY, + "volume inconsistency: " + "total number of bricks (%d) is not divisible with " + "number of bricks per cluster (%d) in a multi-cluster " +@@ -2770,7 +2818,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + } + + if (i != volinfo->brick_count) { +- gf_log ("", GF_LOG_ERROR, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLUME_INCONSISTENCY, + "volume inconsistency: actual number of bricks (%d) " + "differs from brick count (%d)", i, + volinfo->brick_count); +@@ -2913,14 +2962,16 @@ volgen_graph_build_snapview_client (volgen_graph_t *graph, + **/ + ret = volgen_xlator_link (graph->graph.first, prev_top); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to link the " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_XLATOR_LINK_FAIL, "failed to link the " + "snapview-client to distribute"); + goto out; + } + + ret = volgen_xlator_link (graph->graph.first, prot_clnt); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "failed to link the " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_XLATOR_LINK_FAIL, "failed to link the " + "snapview-client to snapview-server"); + goto out; + } +@@ -2941,14 +2992,18 @@ _xl_is_client_decommissioned (xlator_t *xl, glusterd_volinfo_t *volinfo) + ret = xlator_get_option (xl, "remote-host", &hostname); + if (ret) { + GF_ASSERT (0); +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get remote-host " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REMOTE_HOST_GET_FAIL, ++ "Failed to get remote-host " + "from client %s", xl->name); + goto out; + } + ret = xlator_get_option (xl, "remote-subvolume", &path); + if (ret) { + GF_ASSERT (0); +- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get remote-host " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_REMOTE_HOST_GET_FAIL, ++ "Failed to get remote-host " + "from client %s", xl->name); + goto out; + } +@@ -3038,7 +3093,8 @@ volgen_graph_build_dht_cluster (volgen_graph_t *graph, + /* NUFA and Switch section */ + if (dict_get_str_boolean (volinfo->dict, "cluster.nufa", 0) && + dict_get_str_boolean (volinfo->dict, "cluster.switch", 0)) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, + "nufa and switch cannot be set together"); + ret = -1; + goto out; +@@ -3235,7 +3291,9 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph, + + break; + default: +- gf_log ("", GF_LOG_ERROR, "volume inconsistency: " ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_VOLUME_INCONSISTENCY, ++ "volume inconsistency: " + "unrecognized clustering type"); + goto out; + } +@@ -3290,38 +3348,50 @@ graph_set_generic_options (xlator_t *this, volgen_graph_t *graph, + &loglevel_option_handler); + + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "changing %s log level" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "changing %s log level" + " failed", identifier); + + ret = volgen_graph_set_options_generic (graph, set_dict, "client", + &sys_loglevel_option_handler); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "changing %s syslog " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "changing %s syslog " + "level failed", identifier); + + ret = volgen_graph_set_options_generic (graph, set_dict, "client", + &logger_option_handler); + + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "changing %s logger" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "changing %s logger" + " failed", identifier); + + ret = volgen_graph_set_options_generic (graph, set_dict, "client", + &log_format_option_handler); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "changing %s log format" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "changing %s log format" + " failed", identifier); + + ret = volgen_graph_set_options_generic (graph, set_dict, "client", + &log_buf_size_option_handler); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "Failed to change " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "Failed to change " + "log-buf-size option"); + + ret = volgen_graph_set_options_generic (graph, set_dict, "client", + &log_flush_timeout_option_handler); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "Failed to change " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, ++ "Failed to change " + "log-flush-timeout option"); + return 0; + } +@@ -3496,7 +3566,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (volinfo->is_snap_volume) { + xl = volgen_graph_add (graph, "features/read-only", volname); + if (!xl) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to add " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GRAPH_FEATURE_ADD_FAIL, ++ "Failed to add " + "read-only feature to the graph of %s " + "snapshot with %s origin volume", + volname, volinfo->parent_volname); +@@ -3574,7 +3646,8 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ob = _gf_false; + ret = gf_string2boolean (tmp, &ob); + if (!ret && ob) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_ROOT_SQUASH_ENABLED, + "root-squash is enabled. Please turn it" + " off to change read-after-open " + "option"); +@@ -3643,7 +3716,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ret = 0; + } + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "setting " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_ROOT_SQUASH_FAILED, ++ "setting " + "open behind option as part of root " + "squash failed"); + goto out; +@@ -3655,8 +3730,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ret = dict_set_str (set_dict, "client.send-gids", + ret ? "false" : "true"); + if (ret) +- gf_log (THIS->name, GF_LOG_WARNING, "changing client" +- " protocol option failed"); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_SET_FAILED, "changing client" ++ " protocol option failed"); + } + + ret = client_graph_set_perf_options(graph, volinfo, set_dict); +@@ -3686,7 +3762,8 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + ret = dict_get_str_boolean (set_dict, "ganesha.enable", _gf_false); + + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, "setting ganesha.enable" ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_DICT_GET_FAILED, "setting ganesha.enable" + "option failed."); + goto out; + } +@@ -3695,8 +3772,10 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + xl = volgen_graph_add (graph, "features/ganesha", volname); + + if (!xl) { +- gf_log (this->name, GF_LOG_ERROR, "failed to add" +- "add features/ganesha to graph"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_GRAPH_FEATURE_ADD_FAIL, ++ "failed to add" ++ "add features/ganesha to graph"); + ret = -1; + goto out; + } +@@ -4243,7 +4322,9 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict) + + set_dict = dict_new (); + if (!set_dict) { +- gf_log ("", GF_LOG_ERROR, "Out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, ++ "Out of memory"); + return -1; + } + +@@ -4274,7 +4355,8 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict) + ret = gf_asprintf (&skey, "rpc-auth.addr.%s.allow", + voliter->volname); + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, "Out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of memory"); + goto out; + } + ret = xlator_set_option (nfsxl, skey, "*"); +@@ -4285,7 +4367,8 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict) + ret = gf_asprintf (&skey, "nfs3.%s.volume-id", + voliter->volname); + if (ret == -1) { +- gf_log ("", GF_LOG_ERROR, "Out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_NO_MEMORY, "Out of memory"); + goto out; + } + ret = xlator_set_option (nfsxl, skey, uuid_utoa (voliter->volume_id)); +@@ -4373,12 +4456,13 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict) + } + + if (ret) +- gf_log ("glusterd", GF_LOG_WARNING, "Could not set " ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_GRAPH_SET_OPT_FAIL, "Could not set " + "vol-options for the volume %s", voliter->volname); + } + + out: +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + dict_destroy (set_dict); + + return ret; +@@ -4424,14 +4508,18 @@ glusterd_is_valid_volfpath (char *volname, char *brick) + + ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to create brickinfo" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_BRICKINFO_CREATE_FAIL, ++ "Failed to create brickinfo" + " for brick %s", brick ); + ret = 0; + goto out; + } + ret = glusterd_volinfo_new (&volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, "Failed to create volinfo"); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOLINFO_STORE_FAIL, ++ "Failed to create volinfo"); + ret = 0; + goto out; + } +@@ -4519,7 +4607,8 @@ build_quotad_graph (volgen_graph_t *graph, dict_t *mod_dict) + + ret = gf_asprintf(&skey, "%s.volume-id", voliter->volname); + if (ret == -1) { +- gf_log("", GF_LOG_ERROR, "Out of memory"); ++ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM, ++ GD_MSG_NO_MEMORY, "Out of memory"); + goto out; + } + ret = xlator_set_option(quotad_xl, skey, voliter->volname); +@@ -4624,13 +4713,15 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo) + if (ret) { + ret = open (tstamp_file, O_WRONLY|O_CREAT|O_EXCL, 0600); + if (ret == -1 && errno == EEXIST) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "timestamp file exist"); + ret = -2; + } + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "failed to create " +- "%s (%s)", tstamp_file, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "failed to create " ++ "%s", tstamp_file); + return -1; + } + if (ret >= 0) { +@@ -4646,7 +4737,8 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo) + ret = gf_set_timestamp (parent_tstamp_file, + tstamp_file); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TSTAMP_SET_FAIL, + "Unable to set atime and mtime" + " of %s as of %s", tstamp_file, + parent_tstamp_file); +@@ -4659,14 +4751,16 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo) + if (ret == -1 && errno == ENOENT) + ret = 0; + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, "failed to unlink " +- "%s (%s)", tstamp_file, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "failed to unlink " ++ "%s", tstamp_file); + return -1; + } + } + + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "Found a brick - %s:%s", brickinfo->hostname, + brickinfo->path); + +@@ -4679,7 +4773,7 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo) + ret = 0; + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -4755,7 +4849,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, + type); + } + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, + "Received invalid transport-type"); + goto out; + } +@@ -4770,7 +4865,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, + /* Generate volfile for rebalance process */ + ret = dict_set_int32 (dict, "rebalance-volfile-creation", _gf_true); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, + "Failed to set rebalance-volfile-creation"); + goto out; + } +@@ -4781,7 +4877,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, + filepath, + dict); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Failed to create rebalance volfile for %s", + volinfo->volname); + goto out; +@@ -4791,7 +4888,7 @@ out: + if (dict) + dict_unref (dict); + +- gf_log ("", GF_LOG_TRACE, "Returning %d", ret); ++ gf_msg_trace ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -4817,7 +4914,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, + if (!ret) { + ret = dict_get_str (set_dict, "loglevel", &loglevel); + if (ret) { +- gf_log ("glusterd", GF_LOG_ERROR, "could not get both" ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_DICT_GET_FAILED, "could not get both" + " translator name and loglevel for log level " + "request"); + return -1; +@@ -4854,7 +4952,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, + if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cert-depth", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_XLATOR_SET_OPT_FAIL, + "failed to set ssl-cert-depth"); + return -1; + } +@@ -4863,7 +4962,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, + if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) { + ret = xlator_set_option (xl, "ssl-cipher-list", value); + if (ret) { +- gf_log ("glusterd", GF_LOG_WARNING, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, ++ GD_MSG_XLATOR_SET_OPT_FAIL, + "failed to set ssl-cipher-list"); + return -1; + } +@@ -5265,21 +5365,24 @@ glusterd_create_volfiles (glusterd_volinfo_t *volinfo) + + ret = generate_brick_volfiles (volinfo); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Could not generate volfiles for bricks"); + goto out; + } + + ret = generate_client_volfiles (volinfo, GF_CLIENT_TRUSTED); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Could not generate trusted client volfiles"); + goto out; + } + + ret = generate_client_volfiles (volinfo, GF_CLIENT_OTHER); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOLFILE_CREATE_FAIL, + "Could not generate client volfiles"); + + out: +@@ -5334,8 +5437,10 @@ glusterd_delete_volfile (glusterd_volinfo_t *volinfo, + get_brick_filepath (filename, volinfo, brickinfo); + ret = unlink (filename); + if (ret) +- gf_log ("glusterd", GF_LOG_ERROR, "failed to delete file: %s, " +- "reason: %s", filename, strerror (errno)); ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, ++ GD_MSG_FILE_OP_FAILED, ++ "failed to delete file: %s", ++ filename); + return ret; + } + +@@ -5362,7 +5467,7 @@ validate_shdopts (glusterd_volinfo_t *volinfo, + + volgen_graph_free (&graph); + +- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + out: + dict_del (val_dict, "graph-check"); + return ret; +@@ -5391,7 +5496,8 @@ validate_nfsopts (glusterd_volinfo_t *volinfo, + snprintf (err_str, sizeof (err_str), "Changing nfs " + "transport type is allowed only for volumes " + "of transport type tcp,rdma"); +- gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_UNSUPPORTED, "%s", err_str); + *op_errstr = gf_strdup (err_str); + ret = -1; + goto out; +@@ -5407,7 +5513,8 @@ validate_nfsopts (glusterd_volinfo_t *volinfo, + + ret = dict_set_str (val_dict, "volume-name", volinfo->volname); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to set volume name"); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, "Failed to set volume name"); + goto out; + } + +@@ -5420,7 +5527,7 @@ validate_nfsopts (glusterd_volinfo_t *volinfo, + out: + if (dict_get (val_dict, "volume-name")) + dict_del (val_dict, "volume-name"); +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } + +@@ -5443,7 +5550,7 @@ validate_clientopts (glusterd_volinfo_t *volinfo, + + volgen_graph_free (&graph); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -5466,7 +5573,7 @@ validate_brickopts (glusterd_volinfo_t *volinfo, + + volgen_graph_free (&graph); + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -5479,7 +5586,7 @@ glusterd_validate_brickreconf (glusterd_volinfo_t *volinfo, + int ret = -1; + + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Validating %s", brickinfo->hostname); + + ret = validate_brickopts (volinfo, brickinfo, val_dict, +@@ -5522,32 +5629,32 @@ glusterd_validate_globalopts (glusterd_volinfo_t *volinfo, + ret = glusterd_validate_brickreconf (volinfo, val_dict, op_errstr); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not Validate bricks"); + goto out; + } + + ret = validate_clientopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not Validate client"); + goto out; + } + + ret = validate_nfsopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs"); ++ gf_msg_debug ("glusterd", 0, "Could not Validate nfs"); + goto out; + } + + ret = validate_shdopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald"); ++ gf_msg_debug ("glusterd", 0, "Could not Validate self-heald"); + goto out; + } + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -5579,34 +5686,34 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict, + ret = glusterd_validate_brickreconf (volinfo, val_dict, op_errstr); + + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not Validate bricks"); + goto out; + } + + ret = validate_clientopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, ++ gf_msg_debug ("glusterd", 0, + "Could not Validate client"); + goto out; + } + + ret = validate_nfsopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs"); ++ gf_msg_debug ("glusterd", 0, "Could not Validate nfs"); + goto out; + } + + + ret = validate_shdopts (volinfo, val_dict, op_errstr); + if (ret) { +- gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald"); ++ gf_msg_debug ("glusterd", 0, "Could not Validate self-heald"); + goto out; + } + + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 4f6a8dc..a65495d 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -167,7 +167,8 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + " not retrieve disperse count"); + goto out; + } +- gf_log (this->name, GF_LOG_INFO, "Disperse cluster type" ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_DISPERSE_CLUSTER_FOUND, "Disperse cluster type" + " found. Checking brick order."); + } + +@@ -782,7 +783,8 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received heal vol req " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_HEAL_VOL_REQ_RCVD, "Received heal vol req " + "for volume %s", volname); + + ret = glusterd_volinfo_find (volname, &volinfo); +@@ -917,7 +919,8 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req) + goto out; + } + +- gf_log (this->name, GF_LOG_INFO, "Received statedump request for " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_STATEDUMP_VOL_REQ_RCVD, "Received statedump request for " + "volume %s with options %s", volname, options); + + ret = glusterd_op_begin_synctask (req, GD_OP_STATEDUMP_VOLUME, dict); +@@ -1018,7 +1021,9 @@ next: + continue; + if (!strcmp (prop.value.string, "thin-pool")) { + brick->caps |= CAPS_THIN; +- gf_log (THIS->name, GF_LOG_INFO, "Thin Pool " ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_THINPOOLS_FOR_THINLVS, ++ "Thin Pool " + "\"%s\" will be used for thin LVs", + lvm_lv_get_name (lv_list->lv)); + break; +@@ -1259,7 +1264,8 @@ out: + glusterd_brickinfo_delete (brick_info); + + if (msg[0] != '\0') { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_CREATE_VOL_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + gf_msg_debug (this->name, 0, "Returning %d", ret); +@@ -1507,7 +1513,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, + ret = 0; + out: + if (ret && (msg[0] != '\0')) { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_START_VOL_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + return ret; +@@ -1578,7 +1585,8 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) + if (ret) { + ret = ganesha_manage_export(dict, "off", op_errstr); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, "Could not " ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_NFS_GNS_UNEXPRT_VOL_FAIL, "Could not " + "unexport volume via NFS-Ganesha"); + ret = 0; + } +@@ -1663,7 +1671,8 @@ glusterd_op_stage_delete_volume (dict_t *dict, char **op_errstr) + + out: + if (msg[0] != '\0') { +- gf_log (this->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OP_STAGE_DELETE_VOL_FAIL, "%s", msg); + *op_errstr = gf_strdup (msg); + } + gf_msg_debug (this->name, 0, "Returning %d", ret); +@@ -1748,7 +1757,8 @@ glusterd_handle_heal_cmd (xlator_t *this, glusterd_volinfo_t *volinfo, + } + out: + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "%s", *op_errstr); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_HANDLE_HEAL_CMD_FAIL, "%s", *op_errstr); + return ret; + } + +@@ -2905,7 +2915,9 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + if (ret) + ret = 0; + +- gf_log (THIS->name, GF_LOG_INFO, "Received clear-locks request for " ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ GD_MSG_CLRCLK_VOL_REQ_RCVD, ++ "Received clear-locks request for " + "volume %s with kind %s type %s and options %s", volname, + kind, type, opts); + +@@ -2962,7 +2974,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict) + ret = glusterd_clearlocks_send_cmd (volinfo, cmd_str, path, result, + msg, sizeof (msg), mntpt); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_CLRCLK_SND_CMD_FAIL, "%s", msg); + goto umount; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index af26584..ecaf04f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -32,7 +32,8 @@ validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + snprintf (errstr, sizeof (errstr), "Volume %s is not a tier " + "volume. Option %s is only valid for tier volume.", + volinfo->volname, key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; +@@ -49,7 +50,8 @@ validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + snprintf (errstr, sizeof (errstr), "%s is not a compatible " + "value. %s expects an integer value.", + value, key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; +@@ -62,7 +64,8 @@ validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + "compatible value. %s expects a positive " + "integer value.", + value, key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; +@@ -73,7 +76,8 @@ validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + "compatible value. %s expects a non-negative" + " integer value.", + value, key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; +@@ -81,7 +85,7 @@ validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + } + + out: +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +@@ -164,11 +168,12 @@ validate_defrag_throttle_option (glusterd_volinfo_t *volinfo, dict_t *dict, + ret = -1; + snprintf (errstr, sizeof (errstr), "%s should be " + "{lazy|normal|aggressive}", key); +- gf_log (this->name, GF_LOG_ERROR, "%s", errstr); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, "%s", errstr); + *op_errstr = gf_strdup (errstr); + } + +- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 57592c8..4203705 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -152,7 +152,8 @@ glusterd_uuid_init () + + ret = glusterd_retrieve_uuid (); + if (ret == 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_RETRIEVED_UUID, + "retrieved UUID: %s", uuid_utoa (priv->uuid)); + return 0; + } +@@ -183,7 +184,8 @@ glusterd_uuid_generate_save () + + gf_uuid_generate (priv->uuid); + +- gf_log (this->name, GF_LOG_INFO, "generated UUID: %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_GENERATED_UUID, "generated UUID: %s", + uuid_utoa (priv->uuid)); + + ret = glusterd_store_global_info (this); +@@ -395,7 +397,7 @@ glusterd_rpcsvc_options_build (dict_t *options) + goto out; + } + +- gf_msg_debug ("", 0, "listen-backlog value: %d", backlog); ++ gf_msg_debug ("glusterd", 0, "listen-backlog value: %d", backlog); + + out: + return ret; +@@ -478,7 +480,7 @@ group_write_allow (char *path, gid_t gid) + + out: + if (ret == -1) +- gf_msg ("", GF_LOG_CRITICAL, errno, ++ gf_msg ("glusterd", GF_LOG_CRITICAL, errno, + GD_MSG_WRITE_ACCESS_GRANT_FAIL, + "failed to set up write access to %s for group %d (%s)", + path, gid, strerror (errno)); +@@ -590,7 +592,7 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) + } + + out: +- gf_msg_debug ("", 0, "Returning %d", ret); ++ gf_msg_debug ("glusterd", 0, "Returning %d", ret); + return ret; + } + +@@ -842,7 +844,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + ret = fstat (dfd, &st); + } + if (ret == -1 || !S_ISDIR (st.st_mode)) { +- gf_msg ("", GF_LOG_ERROR, errno, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, + "cannot access mountbroker-root directory %s", + mountbroker_root); +@@ -851,7 +853,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + } + if (st.st_uid != 0 || + (st.st_mode & (S_IWGRP|S_IWOTH))) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DIR_PERM_LIBERAL, + "permissions on mountbroker-root directory %s are " + "too liberal", mountbroker_root); +@@ -859,7 +861,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + goto out; + } + if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { +- gf_msg ("", GF_LOG_WARNING, 0, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, + GD_MSG_DIR_PERM_STRICT, + "permissions on mountbroker-root directory %s are " + "probably too strict", mountbroker_root); +@@ -874,7 +876,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + ret = fstat (dfd2, &st2); + } + if (ret == -1) { +- gf_msg ("", GF_LOG_ERROR, errno, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, + "error while checking mountbroker-root ancestors " + "%d (%s)", errno, strerror (errno)); +@@ -887,7 +889,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + if (st2.st_uid != 0 || + ((st2.st_mode & (S_IWGRP|S_IWOTH)) && + !(st2.st_mode & S_ISVTX))) { +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DIR_PERM_LIBERAL, + "permissions on ancestors of mountbroker-root " + "directory are too liberal"); +@@ -895,7 +897,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + goto out; + } + if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { +- gf_msg ("", GF_LOG_WARNING, 0, ++ gf_msg ("glusterd", GF_LOG_WARNING, 0, + GD_MSG_DIR_PERM_STRICT, + "permissions on ancestors of mountbroker-root " + "directory are probably too strict"); +@@ -912,7 +914,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) + if (ret != -1) + ret = sys_fstatat (dfd0, MB_HIVE, &st, AT_SYMLINK_NOFOLLOW); + if (ret == -1 || st.st_mode != (S_IFDIR|0711)) { +- gf_msg ("", GF_LOG_ERROR, errno, ++ gf_msg ("glusterd", GF_LOG_ERROR, errno, + GD_MSG_CREATE_DIR_FAILED, + "failed to set up mountbroker-root directory %s", + mountbroker_root); +@@ -1004,7 +1006,7 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data) + return 0; + err: + +- gf_msg ("", GF_LOG_ERROR, 0, ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_MOUNT_SPEC_INSTALL_FAIL, + "adding %smount spec failed: label: %s desc: %s", + georep ? GEOREP" " : "", label, pdesc); +@@ -1159,7 +1161,7 @@ glusterd_stop_listener (xlator_t *this) + conf = this->private; + GF_VALIDATE_OR_GOTO (this->name, conf, out); + +- gf_log (this->name, GF_LOG_DEBUG, ++ gf_msg_debug (this->name, 0, + "%s function called ", __func__); + + for (i = 0; i < gd_inet_programs_count; i++) { +@@ -1311,19 +1313,21 @@ glusterd_svc_init_all () + /* Init BitD svc */ + ret = glusterd_bitdsvc_init (&(priv->bitd_svc)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to initialized BitD " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_BITD_INIT_FAIL, "Failed to initialized BitD " + "service"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "BitD service initialized"); ++ gf_msg_debug (THIS->name, 0, "BitD service initialized"); + + ret = glusterd_scrubsvc_init (&(priv->scrub_svc)); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to initialized scrub " ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUB_INIT_FAIL, "Failed to initialized scrub " + "service"); + goto out; + } +- gf_log (THIS->name, GF_LOG_DEBUG, "scrub service initialized"); ++ gf_msg_debug (THIS->name, 0, "scrub service initialized"); + + out: + return ret; +@@ -1365,9 +1369,10 @@ init (xlator_t *this) + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_SETXATTR_FAIL, + "Failed to set 'ulimit -n " +- " 65536': %s", strerror(errno)); ++ " 65536'"); + } else { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_FILE_DESC_LIMIT_SET, + "Maximum allowed open file descriptors " + "set to 65536"); + } +@@ -1416,12 +1421,14 @@ init (xlator_t *this) + } + + setenv ("GLUSTERD_WORKDIR", workdir, 1); +- gf_log (this->name, GF_LOG_INFO, "Using %s as working directory", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_CURR_WORK_DIR_INFO, "Using %s as working directory", + workdir); + + ret = glusterd_find_correct_var_run_dir (this, var_run_dir); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to find " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_VAR_RUN_DIR_FIND_FAIL, "Unable to find " + "the correct var run dir"); + exit (1); + } +@@ -1441,7 +1448,8 @@ init (xlator_t *this) + ret = glusterd_init_var_run_dirs (this, var_run_dir, + GLUSTER_SHARED_STORAGE_BRICK_DIR); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, "Unable to create " ++ gf_msg (this->name, GF_LOG_CRITICAL, 0, ++ GD_MSG_VAR_RUN_DIR_INIT_FAIL, "Unable to create " + "shared storage brick"); + exit (1); + } +@@ -1519,18 +1527,20 @@ init (xlator_t *this) + snprintf (storedir, PATH_MAX, "%s/bitd", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, +- "Unable to create bitrot directory %s" +- " ,errno = %d", storedir, errno); ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, ++ "Unable to create bitrot directory %s", ++ storedir); + exit (1); + } + + snprintf (storedir, PATH_MAX, "%s/scrub", workdir); + ret = mkdir (storedir, 0777); + if ((-1 == ret) && (errno != EEXIST)) { +- gf_log (this->name, GF_LOG_CRITICAL, +- "Unable to create scrub directory %s" +- " ,errno = %d", storedir, errno); ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_CREATE_DIR_FAILED, ++ "Unable to create scrub directory %s", ++ storedir); + exit (1); + } + +-- +1.7.1 + diff --git a/SOURCES/0174-ganesha-volinfo-is-not-persisted-after-modifying-opt.patch b/SOURCES/0174-ganesha-volinfo-is-not-persisted-after-modifying-opt.patch new file mode 100644 index 0000000..1f78be2 --- /dev/null +++ b/SOURCES/0174-ganesha-volinfo-is-not-persisted-after-modifying-opt.patch @@ -0,0 +1,46 @@ +From 58457c3949cd9b1244263ce67b556ae62818c668 Mon Sep 17 00:00:00 2001 +From: Rajesh Joseph +Date: Thu, 25 Jun 2015 16:10:29 +0530 +Subject: [PATCH 174/190] ganesha: volinfo is not persisted after modifying options + +ganesha disables gluster NFS when it is enabled. Gluster NFS +is disabled by storing nfs.disable as "on" in volinfo of each +volume in the cluster. But volinfo is not persisted after the +change. + +Due to which wrong info is passed in handshake leading to volume +checksum mismatch. + +Bug: 1235540 +Change-Id: I3e8bceea731d744744eb55792c1d5ee819848894 +Reviewed-on: http://review.gluster.org/11412/ +Signed-off-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/51703 +Reviewed-by: Soumya Koduri +Tested-by: Soumya Koduri +--- + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 8 ++++++++ + 1 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +index f0b20a0..4d2efb9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c ++++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +@@ -661,6 +661,14 @@ start_ganesha (char **op_errstr) + ret = dict_set_str (vol_opts, "nfs.disable", "on"); + if (ret) + goto out; ++ ++ ret = glusterd_store_volinfo (volinfo, ++ GLUSTERD_VOLINFO_VER_AC_INCREMENT); ++ if (ret) { ++ *op_errstr = gf_strdup ("Failed to store the " ++ "Volume information"); ++ goto out; ++ } + } + + ret = priv->nfs_svc.stop (&(priv->nfs_svc), SIGKILL); +-- +1.7.1 + diff --git a/SOURCES/0175-common-utils-libglusterfs-removing-strerror-to-avoid.patch b/SOURCES/0175-common-utils-libglusterfs-removing-strerror-to-avoid.patch new file mode 100644 index 0000000..9fe4cf1 --- /dev/null +++ b/SOURCES/0175-common-utils-libglusterfs-removing-strerror-to-avoid.patch @@ -0,0 +1,121 @@ +From 7efac5ddf05c8d6da3d609b9ba09dcc82f22cdb5 Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq Liyazudeen +Date: Thu, 25 Jun 2015 12:52:57 +0530 +Subject: [PATCH 175/190] common-utils/libglusterfs : removing strerror to avoid duplicate printing of error message + +Change-Id: I0a1c99ae7a2efc657e3465b21dd238e725ae236c +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/11400 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/51749 +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/common-utils.c | 30 +++++++++++++----------------- + libglusterfs/src/common-utils.h | 3 +-- + 2 files changed, 14 insertions(+), 19 deletions(-) + +diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c +index cbc5230..2057bd8 100644 +--- a/libglusterfs/src/common-utils.c ++++ b/libglusterfs/src/common-utils.c +@@ -120,10 +120,12 @@ mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) + + ret = stat (dir, &stbuf); + if (ret || !S_ISDIR (stbuf.st_mode)) { ++ if (ret == 0) ++ errno = 0; + ret = -1; +- gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_DIR_OP_FAILED, "Failed to " +- "create directory, possibly some of the components " +- "were not directories"); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "Failed" ++ " to create directory, possibly some of the components" ++ " were not directories"); + goto out; + } + +@@ -304,12 +306,10 @@ gf_resolve_ip6 (const char *hostname, + + ret = gf_asprintf (&port_str, "%d", port); + if (-1 == ret) { +- gf_msg ("resolver", GF_LOG_ERROR, 0, +- LG_MSG_ASPRINTF_FAILED, "asprintf failed"); + return -1; + } + if ((ret = getaddrinfo(hostname, port_str, &hints, &cache->first)) != 0) { +- gf_msg ("resolver", GF_LOG_ERROR, ret, ++ gf_msg ("resolver", GF_LOG_ERROR, 0, + LG_MSG_GETADDRINFO_FAILED, "getaddrinfo failed" + " (%s)", gai_strerror (ret)); + +@@ -3139,8 +3139,7 @@ gf_is_local_addr (char *hostname) + ret = getaddrinfo (hostname, NULL, NULL, &result); + + if (ret != 0) { +- gf_msg (this->name, GF_LOG_ERROR, ret, +- LG_MSG_GETADDRINFO_FAILED, ++ gf_msg (this->name, GF_LOG_ERROR, 0, LG_MSG_GETADDRINFO_FAILED, + "error in getaddrinfo: %s\n", gai_strerror(ret)); + goto out; + } +@@ -3180,17 +3179,15 @@ gf_is_same_address (char *name1, char *name2) + + gai_err = getaddrinfo(name1,NULL,NULL,&addr1); + if (gai_err != 0) { +- gf_msg (name1, GF_LOG_WARNING, gai_err, +- LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " +- "%s\n", gai_strerror(gai_err)); ++ gf_msg (name1, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED, ++ "error in getaddrinfo: %s\n", gai_strerror(gai_err)); + goto out; + } + + gai_err = getaddrinfo(name2,NULL,NULL,&addr2); + if (gai_err != 0) { +- gf_msg (name2, GF_LOG_WARNING, gai_err, +- LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " +- "%s\n", gai_strerror(gai_err)); ++ gf_msg (name2, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED, ++ "error in getaddrinfo: %s\n", gai_strerror(gai_err)); + goto out; + } + +@@ -3534,8 +3531,7 @@ gf_set_timestamp (const char *src, const char* dest) + ret = stat (src, &sb); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, errno, +- LG_MSG_FILE_STAT_FAILED, "stat on %s failed: %s", +- src, strerror(errno)); ++ LG_MSG_FILE_STAT_FAILED, "stat on %s", src); + goto out; + } + new_time[0].tv_sec = sb.st_atime; +@@ -3551,7 +3547,7 @@ gf_set_timestamp (const char *src, const char* dest) + ret = utimes (dest, new_time); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, errno, LG_MSG_UTIMES_FAILED, +- "utimes on %s failed: %s", dest, strerror(errno)); ++ "utimes on %s", dest); + } + out: + return ret; +diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h +index a64917f..5b5d451 100644 +--- a/libglusterfs/src/common-utils.h ++++ b/libglusterfs/src/common-utils.h +@@ -278,8 +278,7 @@ int gf_set_log_ident (cmd_args_t *cmd_args); + gf_msg (this->name, GF_LOG_ERROR, op_errno, \ + LG_MSG_NO_PERM, \ + "attempt to set internal" \ +- " xattr: %s: %s", pattern, \ +- strerror (op_errno)); \ ++ " xattr: %s", pattern); \ + goto label; \ + } \ + } while (0) +-- +1.7.1 + diff --git a/SOURCES/0176-NFS-Ganesha-Automatically-export-volume-after-volume.patch b/SOURCES/0176-NFS-Ganesha-Automatically-export-volume-after-volume.patch new file mode 100644 index 0000000..2f280ce --- /dev/null +++ b/SOURCES/0176-NFS-Ganesha-Automatically-export-volume-after-volume.patch @@ -0,0 +1,37 @@ +From 650c75a77d865e9e2b49744049d5b88d0b501431 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Fri, 26 Jun 2015 11:27:18 +0530 +Subject: [PATCH 176/190] NFS-Ganesha : Automatically export volume after volume restart + +The export file was not getting created in the correct +path. Fixing the path in this patch. + +This patch is merged upstream, +http://review.gluster.org/#/c/11432/ + +Change-Id: I46e5d4219d7f302dfe4ff725e09fc0ae7a8a641d +BUG: 1226863 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/51748 +Reviewed-by: Soumya Koduri +Tested-by: Soumya Koduri +--- + extras/hook-scripts/start/post/S31ganesha-start.sh | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh +index 7ba8af1..dc3eaea 100755 +--- a/extras/hook-scripts/start/post/S31ganesha-start.sh ++++ b/extras/hook-scripts/start/post/S31ganesha-start.sh +@@ -105,7 +105,7 @@ function start_ganesha() + cut -d"=" -f2) + if [ "$ganesha_value" = "on" ] + then +- write_conf $VOL ++ write_conf $VOL > $GANESHA_DIR/exports/export.$VOL.conf + start_ganesha $VOL + else + exit 0 +-- +1.7.1 + diff --git a/SOURCES/0177-storage-posix-Check-xdata-for-NULL-before-dict_get.patch b/SOURCES/0177-storage-posix-Check-xdata-for-NULL-before-dict_get.patch new file mode 100644 index 0000000..cc29858 --- /dev/null +++ b/SOURCES/0177-storage-posix-Check-xdata-for-NULL-before-dict_get.patch @@ -0,0 +1,65 @@ +From 8861e84d3fb7518cae2c1f2fa733ba85a2ab560d Mon Sep 17 00:00:00 2001 +From: Raghavendra Talur +Date: Thu, 25 Jun 2015 02:18:42 +0530 +Subject: [PATCH 177/190] storage/posix: Check xdata for NULL before dict_get + + Backport of http://review.gluster.org/#/c/11417/ + Backport of http://review.gluster.org/#/c/11390 + +Performing a dict_get on xdata can lead to +frequent logging if xdata is NULL. + +Change-Id: I1666f0cc958c639ccd816e3738dd4a1efebbff82 +BUG: 1235940 +Signed-off-by: Raghavendra Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51689 +Reviewed-by: Nithya Balachandran +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/storage/posix/src/posix.c | 8 ++++---- + 1 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index a2e484e..91e95ef 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3295,7 +3295,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + * This is used by DHT to redirect FOPs if the file is being migrated + * Ignore errors for now + */ +- if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { + ret = posix_pstat(this, loc->gfid, real_path, &stbuf); + if (ret) + goto out; +@@ -4399,7 +4399,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, + } + } + +- if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { + ret = posix_fdstat (this, pfd->fd, &stbuf); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, +@@ -4540,7 +4540,7 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { + ret = posix_pstat(this, loc->gfid, real_path, &stbuf); + if (ret) + goto out; +@@ -4612,7 +4612,7 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { ++ if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) { + ret = posix_fdstat (this, pfd->fd, &stbuf); + if (ret) + goto out; +-- +1.7.1 + diff --git a/SOURCES/0178-protocol-server-Include-a-check-to-validate-xprt-cli.patch b/SOURCES/0178-protocol-server-Include-a-check-to-validate-xprt-cli.patch new file mode 100644 index 0000000..aa21144 --- /dev/null +++ b/SOURCES/0178-protocol-server-Include-a-check-to-validate-xprt-cli.patch @@ -0,0 +1,43 @@ +From 1bbdf818b7e7fc04741710613ea1adcb0f26bd31 Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Thu, 25 Jun 2015 19:49:59 +0530 +Subject: [PATCH 178/190] protocol/server: Include a check to validate xprt->client + +rpc_transport entries(xprt) are added to the conf->xprt_list +during client connection with the server. But the client object is created +and assigned to that transport object only during GF_HANDSK_SETVOLUME. Hence +till that period, there could be xprt entries in the xprt_list without client +associated with it. Added a check to validate the client object during upcall +notify. + +This is backport of the fix - +http://review.gluster.org/#/c/11411/ + +Change-Id: I11e2fcd8b0a67e35302ede478b777b72d1973456 +BUG: 1235544 +Signed-off-by: Soumya Koduri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51718 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/protocol/server/src/server.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c +index ca00dc0..55b3018 100644 +--- a/xlators/protocol/server/src/server.c ++++ b/xlators/protocol/server/src/server.c +@@ -1159,7 +1159,9 @@ server_process_event_upcall (xlator_t *this, void *data) + list_for_each_entry (xprt, &conf->xprt_list, list) { + client = xprt->xl_private; + +- if (strcmp(client->client_uid, client_uid)) ++ /* 'client' is not atomically added during xprt entry ++ * addition to the list. */ ++ if (!client || strcmp(client->client_uid, client_uid)) + continue; + + rpcsvc_request_submit(conf->rpc, xprt, +-- +1.7.1 + diff --git a/SOURCES/0179-Upcall-Fix-an-issue-with-invalidating-parent-entries.patch b/SOURCES/0179-Upcall-Fix-an-issue-with-invalidating-parent-entries.patch new file mode 100644 index 0000000..917e683 --- /dev/null +++ b/SOURCES/0179-Upcall-Fix-an-issue-with-invalidating-parent-entries.patch @@ -0,0 +1,105 @@ +From c005cdaf42edda9e515cd3a7657635a16a332987 Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Thu, 25 Jun 2015 00:47:19 +0530 +Subject: [PATCH 179/190] Upcall: Fix an issue with invalidating parent entries + +Any directory or file creation should result in cache-invalidation +requests sent to parent directory. However that is not the case +currently due to a bug while processing these requests in the +upcall xlator. We need to do invalidation checks on parent inode. + +Fixed the same. Also fixed an issue with null client entries while +sending upcall notifications. + +This is backport of the below upstream fix +http://review.gluster.org/11387 + +Change-Id: I3da7c79091291ba36fd8f8ebcfebcd77a192f250 +BUG: 1235544 +Signed-off-by: Soumya Koduri +Reviewed-on: https://code.engineering.redhat.com/gerrit/51717 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/features/upcall/src/upcall.c | 16 ++++++++-------- + 1 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c +index 331db52..ceeb99c 100644 +--- a/xlators/features/upcall/src/upcall.c ++++ b/xlators/features/upcall/src/upcall.c +@@ -640,7 +640,7 @@ up_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + /* invalidate parent's entry too */ +- flags = UP_PARENT_DENTRY_FLAGS; ++ flags = UP_TIMES; + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postparent, NULL); + +@@ -660,7 +660,7 @@ up_mkdir (call_frame_t *frame, xlator_t *this, + + EXIT_IF_UPCALL_OFF (this, out); + +- local = upcall_local_init (frame, this, loc->inode); ++ local = upcall_local_init (frame, this, loc->parent); + if (!local) { + op_errno = ENOMEM; + goto err; +@@ -702,7 +702,7 @@ up_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + /* As its a new file create, no need of sending notification */ + /* However invalidate parent's entry */ +- flags = UP_PARENT_DENTRY_FLAGS; ++ flags = UP_TIMES; + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postparent, NULL); + +@@ -723,7 +723,7 @@ up_create (call_frame_t *frame, xlator_t *this, + + EXIT_IF_UPCALL_OFF (this, out); + +- local = upcall_local_init (frame, this, loc->inode); ++ local = upcall_local_init (frame, this, loc->parent); + + if (!local) { + op_errno = ENOMEM; +@@ -1052,7 +1052,7 @@ up_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + /* invalidate parent's entry too */ +- flags = UP_PARENT_DENTRY_FLAGS; ++ flags = UP_TIMES; + upcall_cache_invalidate (frame, this, client, local->inode, flags, + buf, postparent, NULL); + +@@ -1072,7 +1072,7 @@ up_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, + + EXIT_IF_UPCALL_OFF (this, out); + +- local = upcall_local_init (frame, this, loc->inode); ++ local = upcall_local_init (frame, this, loc->parent); + if (!local) { + op_errno = ENOMEM; + goto err; +@@ -1113,7 +1113,7 @@ up_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + /* invalidate parent's entry too */ +- flags = UP_PARENT_DENTRY_FLAGS; ++ flags = UP_TIMES; + upcall_cache_invalidate (frame, this, client, local->inode, flags, + buf, postparent, NULL); + +@@ -1134,7 +1134,7 @@ up_symlink (call_frame_t *frame, xlator_t *this, + + EXIT_IF_UPCALL_OFF (this, out); + +- local = upcall_local_init (frame, this, loc->inode); ++ local = upcall_local_init (frame, this, loc->parent); + if (!local) { + op_errno = ENOMEM; + goto err; +-- +1.7.1 + diff --git a/SOURCES/0180-mem-pool-stack-store-syncop-timer-libglusterfs-Porti.patch b/SOURCES/0180-mem-pool-stack-store-syncop-timer-libglusterfs-Porti.patch new file mode 100644 index 0000000..d83a5a7 --- /dev/null +++ b/SOURCES/0180-mem-pool-stack-store-syncop-timer-libglusterfs-Porti.patch @@ -0,0 +1,1044 @@ +From 658994a4914d8134c4c9f5a9273706c46d88360d Mon Sep 17 00:00:00 2001 +From: Mohamed Ashiq +Date: Tue, 19 May 2015 15:46:01 +0530 +Subject: [PATCH 180/190] mem-pool,stack,store,syncop,timer/libglusterfs : Porting to a new logging framework + +Change-Id: Idd3dcaf7eeea5207b3a5210676ce3df64153197f +BUG: 1231792 +Signed-off-by: Mohamed Ashiq Liyazudeen +Reviewed-on: http://review.gluster.org/10827 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: NetBSD Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/51751 +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/client_t.c | 10 +- + libglusterfs/src/libglusterfs-messages.h | 6 +- + libglusterfs/src/mem-pool.c | 36 +++++--- + libglusterfs/src/stack.c | 11 ++- + libglusterfs/src/stack.h | 14 ++-- + libglusterfs/src/store.c | 139 ++++++++++++++++-------------- + libglusterfs/src/syncop-utils.c | 21 +++-- + libglusterfs/src/syncop.c | 91 +++++++++++--------- + libglusterfs/src/timer.c | 29 ++++-- + 9 files changed, 202 insertions(+), 155 deletions(-) + +diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c +index b7462fc..035658f 100644 +--- a/libglusterfs/src/client_t.c ++++ b/libglusterfs/src/client_t.c +@@ -595,7 +595,7 @@ clienttable_dump (clienttable_t *clienttable, char *prefix) + { + if (ret) { + gf_msg ("client_t", GF_LOG_WARNING, 0, +- LG_MSG_LOCK_GAIN_FAILED, ++ LG_MSG_LOCK_FAILED, + "Unable to acquire lock"); + return; + } +@@ -693,7 +693,7 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict) + { + if (ret) { + gf_msg ("client_t", GF_LOG_WARNING, 0, +- LG_MSG_LOCK_GAIN_FAILED, ++ LG_MSG_LOCK_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -736,7 +736,7 @@ gf_client_dump_fdtables (xlator_t *this) + { + if (ret) { + gf_msg ("client_t", GF_LOG_WARNING, 0, +- LG_MSG_LOCK_GAIN_FAILED, ++ LG_MSG_LOCK_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -802,7 +802,7 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict) + { + if (ret) { + gf_msg ("client_t", GF_LOG_WARNING, 0, +- LG_MSG_LOCK_GAIN_FAILED, ++ LG_MSG_LOCK_FAILED, + "Unable to acquire lock"); + return -1; + } +@@ -864,7 +864,7 @@ gf_client_dump_inodes (xlator_t *this) + { + if (ret) { + gf_msg ("client_t", GF_LOG_WARNING, 0, +- LG_MSG_LOCK_GAIN_FAILED, ++ LG_MSG_LOCK_FAILED, + "Unable to acquire lock"); + goto out; + } +diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h +index 8b8af36..25cca8b 100644 +--- a/libglusterfs/src/libglusterfs-messages.h ++++ b/libglusterfs/src/libglusterfs-messages.h +@@ -145,7 +145,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_LOCK_GAIN_FAILED (GLFS_LG_BASE + 14) ++#define LG_MSG_LOCK_FAILED (GLFS_LG_BASE + 14) + + /*! + * @messageid +@@ -153,7 +153,7 @@ + * @recommendedaction + * + */ +-#define LG_MSG_LOCK_RELEASE_FAILED (GLFS_LG_BASE + 15) ++#define LG_MSG_UNLOCK_FAILED (GLFS_LG_BASE + 15) + + /*! + * @messageid +@@ -1198,7 +1198,7 @@ + * + */ + +-#define LG_MSG_SWAP_FAILED (GLFS_LG_BASE + 137) ++#define LG_MSG_SWAPCONTEXT_FAILED (GLFS_LG_BASE + 137) + + /*! + * @messageid +diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c +index 7d95364..1ed1aba 100644 +--- a/libglusterfs/src/mem-pool.c ++++ b/libglusterfs/src/mem-pool.c +@@ -25,6 +25,7 @@ + #define GLUSTERFS_ENV_MEM_ACCT_STR "GLUSTERFS_DISABLE_MEM_ACCT" + + #include "unittest/unittest.h" ++#include "libglusterfs-messages.h" + + void + gf_mem_acct_enable_set (void *data) +@@ -350,7 +351,8 @@ mem_pool_new_fn (unsigned long sizeof_type, + glusterfs_ctx_t *ctx = NULL; + + if (!sizeof_type || !count) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + padded_sizeof_type = sizeof_type + GF_MEM_POOL_PAD_BOUNDARY; +@@ -411,7 +413,8 @@ mem_get0 (struct mem_pool *mem_pool) + void *ptr = NULL; + + if (!mem_pool) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -432,7 +435,8 @@ mem_get (struct mem_pool *mem_pool) + struct mem_pool **pool_ptr = NULL; + + if (!mem_pool) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -503,7 +507,8 @@ static int + __is_member (struct mem_pool *pool, void *ptr) + { + if (!pool || !ptr) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return -1; + } + +@@ -528,21 +533,24 @@ mem_put (void *ptr) + struct mem_pool *pool = NULL; + + if (!ptr) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return; + } + + list = head = mem_pool_ptr2chunkhead (ptr); + tmp = mem_pool_from_ptr (head); + if (!tmp) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, 0, ++ LG_MSG_PTR_HEADER_CORRUPTED, + "ptr header is corrupted"); + return; + } + + pool = *tmp; + if (!pool) { +- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, ++ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, 0, ++ LG_MSG_MEMPOOL_PTR_NULL, + "mem-pool ptr is NULL"); + return; + } +@@ -555,9 +563,12 @@ mem_put (void *ptr) + in_use = (head + GF_MEM_POOL_LIST_BOUNDARY + + GF_MEM_POOL_PTR); + if (!is_mem_chunk_in_use(in_use)) { +- gf_log_callingfn ("mem-pool", GF_LOG_CRITICAL, +- "mem_put called on freed ptr %p of mem " +- "pool %p", ptr, pool); ++ gf_msg_callingfn ("mem-pool", GF_LOG_CRITICAL, ++ 0, ++ LG_MSG_MEMPOOL_INVALID_FREE, ++ "mem_put called on freed ptr" ++ " %p of mem pool %p", ptr, ++ pool); + break; + } + pool->hot_count--; +@@ -600,8 +611,9 @@ mem_pool_destroy (struct mem_pool *pool) + if (!pool) + return; + +- gf_log (THIS->name, GF_LOG_INFO, "size=%lu max=%d total=%"PRIu64, +- pool->padded_sizeof_type, pool->max_alloc, pool->alloc_count); ++ gf_msg (THIS->name, GF_LOG_INFO, 0, LG_MSG_MEM_POOL_DESTROY, "size=%lu " ++ "max=%d total=%"PRIu64, pool->padded_sizeof_type, ++ pool->max_alloc, pool->alloc_count); + + list_del (&pool->global_list); + +diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c +index a7fb951..12d5759 100644 +--- a/libglusterfs/src/stack.c ++++ b/libglusterfs/src/stack.c +@@ -10,6 +10,7 @@ + + #include "statedump.h" + #include "stack.h" ++#include "libglusterfs-messages.h" + + static inline + int call_frames_count (call_frame_t *call_frame) +@@ -46,8 +47,9 @@ create_frame (xlator_t *xl, call_pool_t *pool) + + if (stack->ctx->measure_latency) { + if (gettimeofday (&stack->tv, NULL) == -1) +- gf_log ("stack", GF_LOG_ERROR, "gettimeofday () failed." +- " (%s)", strerror (errno)); ++ gf_msg ("stack", GF_LOG_ERROR, errno, ++ LG_MSG_GETTIMEOFDAY_FAILED, ++ "gettimeofday () failed"); + memcpy (&stack->frames.begin, &stack->tv, sizeof (stack->tv)); + } + +@@ -399,8 +401,9 @@ gf_proc_dump_pending_frames_to_dict (call_pool_t *call_pool, dict_t *dict) + + ret = TRY_LOCK (&call_pool->lock); + if (ret) { +- gf_log (THIS->name, GF_LOG_WARNING, "Unable to dump call pool" +- " to dict. errno: %d", errno); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_LOCK_FAILURE, "Unable to dump call " ++ "pool to dict."); + return; + } + +diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h +index f2d2ef9..38ca3ee 100644 +--- a/libglusterfs/src/stack.h ++++ b/libglusterfs/src/stack.h +@@ -37,6 +37,7 @@ typedef struct call_pool call_pool_t; + #include "globals.h" + #include "lkowner.h" + #include "client_t.h" ++#include "libglusterfs-messages.h" + + #define NFS_PID 1 + #define LOW_PRIO_PROC_PID -1 +@@ -233,7 +234,6 @@ STACK_RESET (call_stack_t *stack) + \ + _new = mem_get0 (frame->root->pool->frame_mem_pool); \ + if (!_new) { \ +- gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \ + break; \ + } \ + typeof(fn##_cbk) tmp_cbk = rfn; \ +@@ -288,7 +288,6 @@ STACK_RESET (call_stack_t *stack) + \ + _new = mem_get0 (frame->root->pool->frame_mem_pool); \ + if (!_new) { \ +- gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \ + break; \ + } \ + typeof(fn##_cbk) tmp_cbk = rfn; \ +@@ -328,7 +327,8 @@ STACK_RESET (call_stack_t *stack) + call_frame_t *_parent = NULL; \ + xlator_t *old_THIS = NULL; \ + if (!frame) { \ +- gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \ ++ gf_msg ("stack", GF_LOG_CRITICAL, 0, \ ++ LG_MSG_FRAME_ERROR, "!frame"); \ + break; \ + } \ + fn = frame->ret; \ +@@ -357,7 +357,8 @@ STACK_RESET (call_stack_t *stack) + xlator_t *old_THIS = NULL; \ + \ + if (!frame) { \ +- gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \ ++ gf_msg ("stack", GF_LOG_CRITICAL, 0, \ ++ LG_MSG_FRAME_ERROR, "!frame"); \ + break; \ + } \ + fn = (fop_##op##_cbk_t )frame->ret; \ +@@ -435,8 +436,9 @@ copy_frame (call_frame_t *frame) + + if (newstack->ctx->measure_latency) { + if (gettimeofday (&newstack->tv, NULL) == -1) +- gf_log ("stack", GF_LOG_ERROR, "gettimeofday () failed." +- " (%s)", strerror (errno)); ++ gf_msg ("stack", GF_LOG_ERROR, errno, ++ LG_MSG_GETTIMEOFDAY_FAILED, ++ "gettimeofday () failed."); + memcpy (&newstack->frames.begin, &newstack->tv, + sizeof (newstack->tv)); + } +diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c +index 351741f..7c8b29d 100644 +--- a/libglusterfs/src/store.c ++++ b/libglusterfs/src/store.c +@@ -20,7 +20,7 @@ + #include "store.h" + #include "dict.h" + #include "xlator.h" +- ++#include "libglusterfs-messages.h" + int32_t + gf_store_mkdir (char *path) + { +@@ -29,8 +29,8 @@ gf_store_mkdir (char *path) + ret = mkdir (path, 0777); + + if ((-1 == ret) && (EEXIST != errno)) { +- gf_log ("", GF_LOG_ERROR, "mkdir() failed on path %s," +- "errno: %s", path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "mkdir()" ++ " failed on path %s.", path); + } else { + ret = 0; + } +@@ -49,8 +49,9 @@ gf_store_handle_create_on_absence (gf_store_handle_t **shandle, + ret = gf_store_handle_new (path, shandle); + + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Unable to create store" +- " handle for path: %s", path); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ LG_MSG_STORE_HANDLE_CREATE_FAILED, "Unable to" ++ " create store handle for path: %s", path); + } + } + return ret; +@@ -67,8 +68,8 @@ gf_store_mkstemp (gf_store_handle_t *shandle) + snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); + shandle->tmp_fd = open (tmppath, O_RDWR | O_CREAT | O_TRUNC, 0600); + if (shandle->tmp_fd < 0) { +- gf_log ("", GF_LOG_ERROR, "Failed to open %s, error: %s", +- tmppath, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to open %s.", tmppath); + } + out: + return shandle->tmp_fd; +@@ -92,15 +93,15 @@ gf_store_sync_direntry (char *path) + pdir = dirname (dir); + dirfd = open (pdir, O_RDONLY); + if (dirfd == -1) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to open directory " +- "%s, due to %s", pdir, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, ++ "Failed to open directory %s.", pdir); + goto out; + } + + ret = fsync (dirfd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to fsync %s, due to " +- "%s", pdir, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ LG_MSG_DIR_OP_FAILED, "Failed to fsync %s.", pdir); + goto out; + } + +@@ -109,8 +110,9 @@ out: + if (dirfd >= 0) { + ret = close (dirfd); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to close " +- "%s, due to %s", pdir, strerror (errno)); ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ LG_MSG_DIR_OP_FAILED, "Failed to close %s", ++ pdir); + } + } + +@@ -131,15 +133,16 @@ gf_store_rename_tmppath (gf_store_handle_t *shandle) + + ret = fsync (shandle->tmp_fd); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to fsync %s, " +- "error: %s", shandle->path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to fsync %s", shandle->path); + goto out; + } + snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); + ret = rename (tmppath, shandle->path); + if (ret) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to rename %s to %s, " +- "error: %s", tmppath, shandle->path, strerror (errno)); ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to rename %s to %s", tmppath, ++ shandle->path); + goto out; + } + +@@ -164,8 +167,9 @@ gf_store_unlink_tmppath (gf_store_handle_t *shandle) + snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); + ret = unlink (tmppath); + if (ret && (errno != ENOENT)) { +- gf_log ("", GF_LOG_ERROR, "Failed to mv %s to %s, error: %s", +- tmppath, shandle->path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to mv %s to %s", tmppath, ++ shandle->path); + } else { + ret = 0; + } +@@ -248,8 +252,8 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value) + lseek (handle->fd, 0, SEEK_SET); + + if (handle->fd == -1) { +- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %s", +- handle->path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Unable to open file %s", handle->path); + goto out; + } + if (!handle->read) +@@ -258,15 +262,15 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value) + fseek (handle->read, 0, SEEK_SET); + + if (!handle->read) { +- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %s", +- handle->path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Unable to open file %s", handle->path); + goto out; + } + + ret = fstat (handle->fd, &st); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "stat on file %s failed", +- handle->path); ++ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ "stat on file %s failed", handle->path); + ret = -1; + store_errno = GD_STORE_STAT_FAILED; + goto out; +@@ -292,16 +296,16 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value) + &iter_key, &iter_val, + &store_errno); + if (ret < 0) { +- gf_log ("", GF_LOG_TRACE, "error while reading key " +- "'%s': %s", key, +- gf_store_strerror (store_errno)); ++ gf_msg_trace ("", 0, "error while reading key '%s': " ++ "%s", key, ++ gf_store_strerror (store_errno)); + goto out; + } + +- gf_log ("", GF_LOG_TRACE, "key %s read", iter_key); ++ gf_msg_trace ("", 0, "key %s read", iter_key); + + if (!strcmp (key, iter_key)) { +- gf_log ("", GF_LOG_DEBUG, "key %s found", key); ++ gf_msg_debug ("", 0, "key %s found", key); + ret = 0; + if (iter_val) + *value = gf_strdup (iter_val); +@@ -341,25 +345,25 @@ gf_store_save_value (int fd, char *key, char *value) + + fp = fdopen (dup_fd, "a+"); + if (fp == NULL) { +- gf_log ("", GF_LOG_WARNING, "fdopen failed."); ++ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ "fdopen failed."); + ret = -1; + goto out; + } + + ret = fprintf (fp, "%s=%s\n", key, value); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "Unable to store key: %s," +- "value: %s, error: %s", key, value, +- strerror (errno)); ++ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ "Unable to store key: %s, value: %s.", ++ key, value); + ret = -1; + goto out; + } + + ret = fflush (fp); + if (feof (fp)) { +- gf_log ("", GF_LOG_WARNING, +- "fflush failed, error: %s", +- strerror (errno)); ++ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ "fflush failed."); + ret = -1; + goto out; + } +@@ -369,7 +373,7 @@ out: + if (fp) + fclose (fp); + +- gf_log ("", GF_LOG_DEBUG, "returning: %d", ret); ++ gf_msg_debug ("", 0, "returning: %d", ret); + return ret; + } + +@@ -391,8 +395,8 @@ gf_store_handle_new (const char *path, gf_store_handle_t **handle) + + fd = open (path, O_RDWR | O_CREAT | O_APPEND, 0600); + if (fd < 0) { +- gf_log ("", GF_LOG_ERROR, "Failed to open file: %s, error: %s", +- path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to open file: %s.", path); + goto out; + } + +@@ -415,7 +419,7 @@ out: + GF_FREE (shandle); + } + +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -427,14 +431,13 @@ gf_store_handle_retrieve (char *path, gf_store_handle_t **handle) + + ret = stat (path, &statbuf); + if (ret) { +- gf_log ("", GF_LOG_ERROR, "Path corresponding to " +- "%s, returned error: (%s)", +- path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_PATH_NOT_FOUND, "Path " ++ "corresponding to %s.", path); + goto out; + } + ret = gf_store_handle_new (path, handle); + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + return ret; + } + +@@ -455,7 +458,7 @@ gf_store_handle_destroy (gf_store_handle_t *handle) + ret = 0; + + out: +- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); ++ gf_msg_debug ("", 0, "Returning %d", ret); + + return ret; + } +@@ -472,8 +475,8 @@ gf_store_iter_new (gf_store_handle_t *shandle, gf_store_iter_t **iter) + + fp = fopen (shandle->path, "r"); + if (!fp) { +- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %d", +- shandle->path, errno); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Unable to open file %s", shandle->path); + goto out; + } + +@@ -496,7 +499,7 @@ out: + + GF_FREE (tmp_iter); + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -511,19 +514,21 @@ gf_store_validate_key_value (char *storepath, char *key, char *val, + + if ((key == NULL) && (val == NULL)) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, " +- "Invalid key and value (null) in %s", storepath); ++ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd " ++ "store may be corrupted, Invalid key and value (null)" ++ " in %s", storepath); + *op_errno = GD_STORE_KEY_VALUE_NULL; + } else if (key == NULL) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, " +- "Invalid key (null) in %s", storepath); ++ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd " ++ "store may be corrupted, Invalid key (null) in %s", ++ storepath); + *op_errno = GD_STORE_KEY_NULL; + } else if (val == NULL) { + ret = -1; +- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, " +- "Invalid value (null) for key %s in %s", key, +- storepath); ++ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd " ++ "store may be corrupted, Invalid value (null) for key" ++ " %s in %s", key, storepath); + *op_errno = GD_STORE_VALUE_NULL; + } else { + ret = 0; +@@ -550,7 +555,8 @@ gf_store_iter_get_next (gf_store_iter_t *iter, char **key, char **value, + + ret = stat (iter->filepath, &st); + if (ret < 0) { +- gf_log ("", GF_LOG_WARNING, "stat on file failed"); ++ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ "stat on file failed"); + ret = -1; + store_errno = GD_STORE_STAT_FAILED; + goto out; +@@ -605,7 +611,7 @@ out: + if (op_errno) + *op_errno = store_errno; + +- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); ++ gf_msg_debug ("", 0, "Returning with %d", ret); + return ret; + } + +@@ -646,8 +652,9 @@ gf_store_iter_destroy (gf_store_iter_t *iter) + * being NULL*/ + ret = fclose (iter->file); + if (ret) +- gf_log ("", GF_LOG_ERROR, "Unable to close file: %s, ret: %d, " +- "errno: %d" ,iter->filepath, ret, errno); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, "Unable" ++ " to close file: %s, ret: %d" , ++ iter->filepath, ret); + + GF_FREE (iter); + return ret; +@@ -685,15 +692,15 @@ gf_store_lock (gf_store_handle_t *sh) + + sh->fd = open (sh->path, O_RDWR); + if (sh->fd == -1) { +- gf_log ("", GF_LOG_ERROR, "Failed to open '%s': %s", sh->path, +- strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, ++ "Failed to open '%s'", sh->path); + return -1; + } + + ret = lockf (sh->fd, F_LOCK, 0); + if (ret) +- gf_log ("", GF_LOG_ERROR, "Failed to gain lock on '%s': %s", +- sh->path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_LOCK_FAILED, ++ "Failed to gain lock on '%s'", sh->path); + else + /* sh->locked is protected by the lockf(sh->fd) above */ + sh->locked = F_LOCK; +@@ -711,8 +718,8 @@ gf_store_unlock (gf_store_handle_t *sh) + + /* does not matter if this fails, locks are released on close anyway */ + if (lockf (sh->fd, F_ULOCK, 0) == -1) +- gf_log ("", GF_LOG_ERROR, "Failed to release lock on '%s': %s", +- sh->path, strerror (errno)); ++ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_UNLOCK_FAILED, ++ "Failed to release lock on '%s'", sh->path); + + close (sh->fd); + } +diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c +index 349fa92..8ab6bef 100644 +--- a/libglusterfs/src/syncop-utils.c ++++ b/libglusterfs/src/syncop-utils.c +@@ -15,6 +15,7 @@ + + #include "syncop.h" + #include "common-utils.h" ++#include "libglusterfs-messages.h" + + int + syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid) +@@ -27,9 +28,9 @@ syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid) + + dirfd = fd_create (loc->inode, pid); + if (!dirfd) { +- gf_log (subvol->name, GF_LOG_ERROR, +- "fd_create of %s failed: %s", +- uuid_utoa (loc->gfid), strerror(errno)); ++ gf_msg (subvol->name, GF_LOG_ERROR, errno, ++ LG_MSG_FD_CREATE_FAILED, "fd_create of %s", ++ uuid_utoa (loc->gfid)); + ret = -errno; + goto out; + } +@@ -49,18 +50,18 @@ syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid) + fd_unref (dirfd); + dirfd = fd_anonymous (loc->inode); + if (!dirfd) { +- gf_log(subvol->name, GF_LOG_ERROR, +- "fd_anonymous of %s failed: %s", +- uuid_utoa (loc->gfid), strerror(errno)); ++ gf_msg (subvol->name, GF_LOG_ERROR, errno, ++ LG_MSG_FD_ANONYMOUS_FAILED, "fd_anonymous of " ++ "%s", uuid_utoa (loc->gfid)); + ret = -errno; + goto out; + } + ret = 0; + #else /* GF_LINUX_HOST_OS */ + fd_unref (dirfd); +- gf_log (subvol->name, GF_LOG_ERROR, +- "opendir of %s failed: %s", +- uuid_utoa (loc->gfid), strerror(errno)); ++ gf_msg (subvol->name, GF_LOG_ERROR, errno, ++ LG_MSG_DIR_OP_FAILED, "opendir of %s", ++ uuid_utoa (loc->gfid)); + goto out; + #endif /* GF_LINUX_HOST_OS */ + } +@@ -304,7 +305,7 @@ syncop_is_subvol_local (xlator_t *this, loc_t *loc, gf_boolean_t *is_local) + + ret = glusterfs_is_local_pathinfo (pathinfo, is_local); + +- gf_log (this->name, GF_LOG_DEBUG, "subvol %s is %slocal", ++ gf_msg_debug (this->name, 0, "subvol %s is %slocal", + this->name, is_local ? "" : "not "); + + out: +diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c +index 48daa32..26a4737 100644 +--- a/libglusterfs/src/syncop.c ++++ b/libglusterfs/src/syncop.c +@@ -14,6 +14,7 @@ + #endif + + #include "syncop.h" ++#include "libglusterfs-messages.h" + + int + syncopctx_setfsuid (void *uid) +@@ -262,20 +263,21 @@ __run (struct synctask *task) + case SYNCTASK_SUSPEND: + break; + case SYNCTASK_RUN: +- gf_log (task->xl->name, GF_LOG_DEBUG, +- "re-running already running task"); ++ gf_msg_debug (task->xl->name, 0, "re-running already running" ++ " task"); + env->runcount--; + break; + case SYNCTASK_WAIT: + env->waitcount--; + break; + case SYNCTASK_DONE: +- gf_log (task->xl->name, GF_LOG_WARNING, +- "running completed task"); ++ gf_msg (task->xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_COMPLETED_TASK, "running completed task"); + return; + case SYNCTASK_ZOMBIE: +- gf_log (task->xl->name, GF_LOG_WARNING, +- "attempted to wake up zombie!!"); ++ gf_msg (task->xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_WAKE_UP_ZOMBIE, "attempted to wake up " ++ "zombie!!"); + return; + } + +@@ -301,16 +303,19 @@ __wait (struct synctask *task) + env->runcount--; + break; + case SYNCTASK_WAIT: +- gf_log (task->xl->name, GF_LOG_WARNING, +- "re-waiting already waiting task"); ++ gf_msg (task->xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_REWAITING_TASK, "re-waiting already waiting " ++ "task"); + env->waitcount--; + break; + case SYNCTASK_DONE: +- gf_log (task->xl->name, GF_LOG_WARNING, ++ gf_msg (task->xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_COMPLETED_TASK, + "running completed task"); + return; + case SYNCTASK_ZOMBIE: +- gf_log (task->xl->name, GF_LOG_WARNING, ++ gf_msg (task->xl->name, GF_LOG_WARNING, 0, ++ LG_MSG_SLEEP_ZOMBIE, + "attempted to sleep a zombie!!"); + return; + } +@@ -336,8 +341,9 @@ synctask_yield (struct synctask *task) + (void) gf_backtrace_save (task->btbuf); + } + if (swapcontext (&task->ctx, &task->proc->sched) < 0) { +- gf_log ("syncop", GF_LOG_ERROR, +- "swapcontext failed (%s)", strerror (errno)); ++ gf_msg ("syncop", GF_LOG_ERROR, errno, ++ LG_MSG_SWAPCONTEXT_FAILED, "swapcontext failed (%s)", ++ strerror (errno)); + } + + THIS = oldTHIS; +@@ -488,16 +494,14 @@ synctask_create (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, + INIT_LIST_HEAD (&newtask->waitq); + + if (getcontext (&newtask->ctx) < 0) { +- gf_log ("syncop", GF_LOG_ERROR, +- "getcontext failed (%s)", ++ gf_msg ("syncop", GF_LOG_ERROR, errno, ++ LG_MSG_GETCONTEXT_FAILED, "getcontext failed (%s)", + strerror (errno)); + goto err; + } + + newtask->stack = CALLOC (1, env->stacksize); + if (!newtask->stack) { +- gf_log ("syncop", GF_LOG_ERROR, +- "out of memory for stack"); + goto err; + } + +@@ -648,8 +652,8 @@ synctask_switchto (struct synctask *task) + #endif + + if (swapcontext (&task->proc->sched, &task->ctx) < 0) { +- gf_log ("syncop", GF_LOG_ERROR, +- "swapcontext failed (%s)", strerror (errno)); ++ gf_msg ("syncop", GF_LOG_ERROR, errno, ++ LG_MSG_SWAPCONTEXT_FAILED, "swapcontext failed"); + } + + if (task->state == SYNCTASK_DONE) { +@@ -874,22 +878,25 @@ __synclock_lock (struct synclock *lock) + case LOCK_TASK: + if (task == lock->owner) { + lock->lock++; +- gf_log ("", GF_LOG_TRACE, "Recursive lock called by " +- "sync task.owner= %p,lock=%d", lock->owner, lock->lock); ++ gf_msg_trace ("", 0, "Recursive lock called by" ++ " sync task.owner= %p,lock=%d", ++ lock->owner, lock->lock); + return 0; + } + break; + case LOCK_THREAD: + if (pthread_self () == lock->owner_tid) { + lock->lock++; +- gf_log ("", GF_LOG_TRACE, "Recursive lock called by " +- "thread ,owner=%u lock=%d", (unsigned int) lock->owner_tid, +- lock->lock); ++ gf_msg_trace ("", 0, "Recursive lock called by" ++ " thread ,owner=%u lock=%d", ++ (unsigned int) lock->owner_tid, ++ lock->lock); + return 0; + } + break; + default: +- gf_log ("", GF_LOG_CRITICAL, "unknown lock type"); ++ gf_msg ("", GF_LOG_CRITICAL, 0, ++ LG_MSG_UNKNOWN_LOCK_TYPE, "unknown lock type"); + break; + } + } +@@ -974,7 +981,8 @@ __synclock_unlock (synclock_t *lock) + return -1; + + if (lock->lock == 0) { +- gf_log ("", GF_LOG_CRITICAL, "Unlock called before lock "); ++ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_UNLOCK_BEFORE_LOCK, ++ "Unlock called before lock "); + return -1; + } + curr = synctask_get (); +@@ -986,23 +994,27 @@ __synclock_unlock (synclock_t *lock) + case LOCK_TASK: + if (curr == lock->owner) { + lock->lock--; +- gf_log ("", GF_LOG_TRACE, "Unlock success %p, remaining" +- " locks=%d", lock->owner, lock->lock); ++ gf_msg_trace ("", 0, "Unlock success %p, remaining" ++ " locks=%d", lock->owner, lock->lock); + } else { +- gf_log ("", GF_LOG_WARNING, "Unlock called by %p, but" +- " lock held by %p", curr, lock->owner); ++ gf_msg ("", GF_LOG_WARNING, 0, LG_MSG_LOCK_OWNER_ERROR, ++ "Unlock called by %p, but lock held by %p", ++ curr, lock->owner); + } + + break; + case LOCK_THREAD: + if (pthread_self () == lock->owner_tid) { + lock->lock--; +- gf_log ("", GF_LOG_TRACE, "Unlock success %u, remaining" +- " locks=%d", (unsigned int)lock->owner_tid, lock->lock); ++ gf_msg_trace ("", 0, "Unlock success %u, remaining " ++ "locks=%d", ++ (unsigned int)lock->owner_tid, ++ lock->lock); + } else { +- gf_log ("", GF_LOG_WARNING, "Unlock called by %u, but" +- " lock held by %u", (unsigned int) pthread_self(), +- (unsigned int) lock->owner_tid); ++ gf_msg ("", GF_LOG_WARNING, 0, LG_MSG_LOCK_OWNER_ERROR, ++ "Unlock called by %u, but lock held by %u", ++ (unsigned int) pthread_self(), ++ (unsigned int) lock->owner_tid); + } + + break; +@@ -1244,9 +1256,8 @@ syncop_readdirp_cbk (call_frame_t *frame, + if (op_ret >= 0) { + list_for_each_entry (entry, &entries->list, list) { + tmp = entry_copy (entry); +- gf_log (this->name, GF_LOG_TRACE, +- "adding entry=%s, count=%d", +- tmp->d_name, count); ++ gf_msg_trace (this->name, 0, "adding entry=%s, " ++ "count=%d", tmp->d_name, count); + list_add_tail (&tmp->list, &(args->entries.list)); + count++; + } +@@ -1313,9 +1324,9 @@ syncop_readdir_cbk (call_frame_t *frame, + if (op_ret >= 0) { + list_for_each_entry (entry, &entries->list, list) { + tmp = entry_copy (entry); +- gf_log (this->name, GF_LOG_TRACE, +- "adding entry=%s, count=%d", +- tmp->d_name, count); ++ gf_msg_trace (this->name, 0, "adding " ++ "entry=%s, count=%d", tmp->d_name, ++ count); + list_add_tail (&tmp->list, &(args->entries.list)); + count++; + } +diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c +index 0d845cd..8344c9b 100644 +--- a/libglusterfs/src/timer.c ++++ b/libglusterfs/src/timer.c +@@ -18,6 +18,7 @@ + #include "common-utils.h" + #include "globals.h" + #include "timespec.h" ++#include "libglusterfs-messages.h" + + gf_timer_t * + gf_timer_call_after (glusterfs_ctx_t *ctx, +@@ -32,7 +33,8 @@ gf_timer_call_after (glusterfs_ctx_t *ctx, + + if (ctx == NULL) + { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +@@ -41,14 +43,17 @@ gf_timer_call_after (glusterfs_ctx_t *ctx, + * when cleanup_started is set after checking for it + */ + if (ctx->cleanup_started) { +- gf_log_callingfn ("timer", GF_LOG_INFO, "ctx cleanup started"); ++ gf_msg_callingfn ("timer", GF_LOG_INFO, 0, ++ LG_MSG_CTX_CLEANUP_STARTED, "ctx cleanup " ++ "started"); + return NULL; + } + + reg = gf_timer_registry_init (ctx); + + if (!reg) { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "!reg"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, 0, ++ LG_MSG_TIMER_REGISTER_ERROR, "!reg"); + return NULL; + } + +@@ -85,7 +90,8 @@ gf_timer_call_stale (gf_timer_registry_t *reg, + { + if (reg == NULL || event == NULL) + { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return 0; + } + +@@ -107,13 +113,15 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx, + + if (ctx == NULL || event == NULL) + { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return 0; + } + + reg = gf_timer_registry_init (ctx); + if (!reg) { +- gf_log ("timer", GF_LOG_ERROR, "!reg"); ++ gf_msg ("timer", GF_LOG_ERROR, 0, LG_MSG_INIT_TIMER_FAILED, ++ "!reg"); + GF_FREE (event); + return 0; + } +@@ -145,13 +153,15 @@ gf_timer_proc (void *ctx) + + if (ctx == NULL) + { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + + reg = gf_timer_registry_init (ctx); + if (!reg) { +- gf_log ("timer", GF_LOG_ERROR, "!reg"); ++ gf_msg ("timer", GF_LOG_ERROR, 0, LG_MSG_INIT_TIMER_FAILED, ++ "!reg"); + return NULL; + } + +@@ -223,7 +233,8 @@ gf_timer_registry_t * + gf_timer_registry_init (glusterfs_ctx_t *ctx) + { + if (ctx == NULL) { +- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument"); ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); + return NULL; + } + +-- +1.7.1 + diff --git a/SOURCES/0181-quota-Fix-statfs-values-in-EC-when-quota_deem_statfs.patch b/SOURCES/0181-quota-Fix-statfs-values-in-EC-when-quota_deem_statfs.patch new file mode 100644 index 0000000..5112871 --- /dev/null +++ b/SOURCES/0181-quota-Fix-statfs-values-in-EC-when-quota_deem_statfs.patch @@ -0,0 +1,108 @@ +From 8bd65e3d197d9f7f9789590ef00837426eca5e37 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 18 Jun 2015 16:31:57 +0530 +Subject: [PATCH 181/190] quota: Fix statfs values in EC when quota_deem_statfs is enabled + +This is backport of http://review.gluster.org/#/c/11315/ + +> When quota_deem_statfs is enabled, quota sends aggregated statfs values +> In EC we should not multiply statfs values with fragment number +> +> Change-Id: I7ef8ea1598d84b86ba5c5941a2bbe0a6ab43c101 +> BUG: 1233162 +> Signed-off-by: vmallika + +Change-Id: Ic2e7254697c053a0311ae288da0c7ab9ef91497d +BUG: 1227869 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/51737 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/bugs/disperse/bug-1227869.t | 39 +++++++++++++++++++++++++++++++++++ + xlators/cluster/ec/src/ec-generic.c | 16 ++++++++++--- + 2 files changed, 51 insertions(+), 4 deletions(-) + create mode 100644 tests/bugs/disperse/bug-1227869.t + +diff --git a/tests/bugs/disperse/bug-1227869.t b/tests/bugs/disperse/bug-1227869.t +new file mode 100644 +index 0000000..83dc765 +--- /dev/null ++++ b/tests/bugs/disperse/bug-1227869.t +@@ -0,0 +1,39 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup ++ ++QDD=$(dirname $0)/quota ++# compile the test write program and run it ++build_tester $(dirname $0)/../../basic/quota.c -o $QDD ++ ++function usage() ++{ ++ local QUOTA_PATH=$1; ++ $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}' ++} ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 disperse 3 $H0:$B0/${V0}{1..3} ++EXPECT "Created" volinfo_field $V0 'Status' ++ ++TEST $CLI volume start $V0 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Started" volinfo_field $V0 'Status' ++ ++TEST $CLI volume quota $V0 enable ++TEST $CLI volume quota $V0 limit-usage / 100MB ++ ++TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 ++ ++TEST $QDD $M0/file 256 40 ++ ++EXPECT "10.0MB" usage "/" ++ ++EXPECT "0" echo $(df -k $M0 | grep -q '10240 '; echo $?) ++EXPECT "0" echo $(df -k $M0 | grep -q '92160 '; echo $?) ++ ++rm -f $QDD ++cleanup +diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c +index f27f65b..45b65c9 100644 +--- a/xlators/cluster/ec/src/ec-generic.c ++++ b/xlators/cluster/ec/src/ec-generic.c +@@ -1185,7 +1185,9 @@ void ec_wind_statfs(ec_t * ec, ec_fop_data_t * fop, int32_t idx) + + int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state) + { +- ec_cbk_data_t * cbk; ++ ec_cbk_data_t *cbk = NULL; ++ gf_boolean_t deem_statfs_enabled = _gf_false; ++ int ret = 0; + + switch (state) + { +@@ -1215,9 +1217,15 @@ int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state) + { + ec_t * ec = fop->xl->private; + +- cbk->statvfs.f_blocks *= ec->fragments; +- cbk->statvfs.f_bfree *= ec->fragments; +- cbk->statvfs.f_bavail *= ec->fragments; ++ if (cbk->xdata) ++ ret = dict_get_int8 (cbk->xdata, "quota-deem-statfs", ++ (int8_t *)&deem_statfs_enabled); ++ ++ if (ret != 0 || deem_statfs_enabled == _gf_false) { ++ cbk->statvfs.f_blocks *= ec->fragments; ++ cbk->statvfs.f_bfree *= ec->fragments; ++ cbk->statvfs.f_bavail *= ec->fragments; ++ } + } + } + else +-- +1.7.1 + diff --git a/SOURCES/0182-Logging-Porting-the-performance-translator.patch b/SOURCES/0182-Logging-Porting-the-performance-translator.patch new file mode 100644 index 0000000..c05d581 --- /dev/null +++ b/SOURCES/0182-Logging-Porting-the-performance-translator.patch @@ -0,0 +1,2748 @@ +From 5c79ddf3d88bcc6d6492f7eae9eaa9931e338072 Mon Sep 17 00:00:00 2001 +From: arao +Date: Mon, 22 Jun 2015 11:10:05 +0530 +Subject: [PATCH 182/190] Logging: Porting the performance translator + logs to new logging framework. + +BUG: 1231784 +Change-Id: Id7535930442f6fc67fbe0cd93308f8fda534aa6f +Signed-off-by: Anusha +Reviewed-on: https://code.engineering.redhat.com/gerrit/51752 +Reviewed-by: Nithya Balachandran +Tested-by: Nithya Balachandran +--- + libglusterfs/src/glfs-message-id.h | 50 ++++++-- + .../performance/io-cache/src/io-cache-messages.h | 111 +++++++++++++++ + xlators/performance/io-cache/src/io-cache.c | 150 ++++++++++++-------- + xlators/performance/io-cache/src/io-cache.h | 45 +++--- + xlators/performance/io-cache/src/ioc-inode.c | 22 ++-- + xlators/performance/io-cache/src/page.c | 103 +++++++------- + .../io-threads/src/io-threads-messages.h | 103 ++++++++++++++ + xlators/performance/io-threads/src/io-threads.c | 56 +++++--- + .../performance/md-cache/src/md-cache-messages.h | 66 +++++++++ + xlators/performance/md-cache/src/md-cache.c | 13 +- + .../open-behind/src/open-behind-messages.h | 85 +++++++++++ + xlators/performance/open-behind/src/open-behind.c | 15 ++- + .../quick-read/src/quick-read-messages.h | 119 ++++++++++++++++ + xlators/performance/quick-read/src/quick-read.c | 41 +++--- + xlators/performance/read-ahead/src/page.c | 11 +- + .../read-ahead/src/read-ahead-messages.h | 94 ++++++++++++ + xlators/performance/read-ahead/src/read-ahead.c | 67 +++++---- + .../readdir-ahead/src/readdir-ahead-messages.h | 105 ++++++++++++++ + .../performance/readdir-ahead/src/readdir-ahead.c | 21 ++- + .../symlink-cache/src/symlink-cache-messages.h | 93 ++++++++++++ + .../performance/symlink-cache/src/symlink-cache.c | 69 +++++---- + .../write-behind/src/write-behind-messages.h | 121 ++++++++++++++++ + .../performance/write-behind/src/write-behind.c | 26 +++- + 23 files changed, 1308 insertions(+), 278 deletions(-) + create mode 100644 xlators/performance/io-cache/src/io-cache-messages.h + create mode 100644 xlators/performance/io-threads/src/io-threads-messages.h + create mode 100644 xlators/performance/md-cache/src/md-cache-messages.h + create mode 100644 xlators/performance/open-behind/src/open-behind-messages.h + create mode 100644 xlators/performance/quick-read/src/quick-read-messages.h + create mode 100644 xlators/performance/read-ahead/src/read-ahead-messages.h + create mode 100644 xlators/performance/readdir-ahead/src/readdir-ahead-messages.h + create mode 100644 xlators/performance/symlink-cache/src/symlink-cache-messages.h + create mode 100644 xlators/performance/write-behind/src/write-behind-messages.h + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 53b004d..0087440 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -109,17 +109,49 @@ + #define GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END (GLFS_MSGID_COMP_RPC_TRANS_SOCKET + \ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_QUOTA GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END +-#define GLFS_MSGID_COMP_QUOTA_END (GLFS_MSGID_COMP_QUOTA +\ +- GLFS_MSGID_SEGMENT) +- +-#define GLFS_MSGID_COMP_CTR GLFS_MSGID_COMP_QUOTA_END +-#define GLFS_MSGID_COMP_CTR_END (GLFS_MSGID_COMP_CTR+\ ++#define GLFS_MSGID_COMP_QUOTA GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END ++#define GLFS_MSGID_COMP_QUOTA_END (GLFS_MSGID_COMP_QUOTA +\ + GLFS_MSGID_SEGMENT) + +-#define GLFS_MSGID_COMP_EC GLFS_MSGID_COMP_CTR_END +-#define GLFS_MSGID_COMP_EC_END (GLFS_MSGID_COMP_EC +\ +- GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_IO_CACHE GLFS_MSGID_COMP_EC_END ++#define GLFS_MSGID_COMP_IO_CACHE_END (GLFS_MSGID_COMP_IO_CACHE+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_IO_THREADS GLFS_MSGID_COMP_IO_CACHE_END ++#define GLFS_MSGID_COMP_IO_THREADS_END (GLFS_MSGID_COMP_IO_THREADS+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_MD_CACHE GLFS_MSGID_COMP_IO_THREADS_END ++#define GLFS_MSGID_COMP_MD_CACHE_END (GLFS_MSGID_COMP_MD_CACHE+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_OPEN_BEHIND GLFS_MSGID_COMP_MD_CACHE_END ++#define GLFS_MSGID_COMP_OPEN_BEHIND_END (GLFS_MSGID_COMP_OPEN_BEHIND+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_QUICK_READ GLFS_MSGID_COMP_OPEN_BEHIND_END ++#define GLFS_MSGID_COMP_QUICK_READ_END (GLFS_MSGID_COMP_QUICK_READ+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_READ_AHEAD GLFS_MSGID_COMP_QUICK_READ_END ++#define GLFS_MSGID_COMP_READ_AHEAD_END (GLFS_MSGID_COMP_READ_AHEAD+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_READDIR_AHEAD GLFS_MSGID_COMP_READ_AHEAD_END ++#define GLFS_MSGID_COMP_READDIR_AHEAD_END (GLFS_MSGID_COMP_READDIR_AHEAD+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_SYMLINK_CACHE \ ++GLFS_MSGID_COMP_READDIR_AHEAD_END ++#define GLFS_MSGID_COMP_SYMLINK_CACHE_END \ ++(GLFS_MSGID_COMP_SYMLINK_CACHE+ \ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_WRITE_BEHIND \ ++GLFS_MSGID_COMP_SYMLINK_CACHE_END ++#define GLFS_MSGID_COMP_WRITE_BEHIND_END (GLFS_MSGID_COMP_WRITE_BEHIND+\ ++ GLFS_MSGID_SEGMENT) + + /* --- new segments for messages goes above this line --- */ + +diff --git a/xlators/performance/io-cache/src/io-cache-messages.h b/xlators/performance/io-cache/src/io-cache-messages.h +new file mode 100644 +index 0000000..5c4fbea +--- /dev/null ++++ b/xlators/performance/io-cache/src/io-cache-messages.h +@@ -0,0 +1,111 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _IO_CACHE_MESSAGES_H_ ++#define _IO_CACHE_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file io-cache-messages.h ++ * \brief IO_CACHE log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_IO_CACHE_BASE GLFS_MSGID_COMP_IO_CACHE ++#define GLFS_IO_CACHE_NUM_MESSAGES 6 ++#define GLFS_MSGID_END (GLFS_IO_CACHE_BASE + GLFS_IO_CACHE_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_IO_CACHE_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_ENFORCEMENT_FAILED (GLFS_IO_CACHE_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_INVALID_ARGUMENT (GLFS_IO_CACHE_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED (GLFS_IO_CACHE_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_NO_MEMORY (GLFS_IO_CACHE_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_VOL_MISCONFIGURED (GLFS_IO_CACHE_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_CACHE_MSG_INODE_NULL (GLFS_IO_CACHE_BASE + 6) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _IO_CACHE_MESSAGES_H_ */ +diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c +index bfda85d..7eea867 100644 +--- a/xlators/performance/io-cache/src/io-cache.c ++++ b/xlators/performance/io-cache/src/io-cache.c +@@ -22,7 +22,7 @@ + #include "statedump.h" + #include + #include +- ++#include "io-cache-messages.h" + int ioc_log2_page_size; + + uint32_t +@@ -272,14 +272,16 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + local = mem_get0 (this->local_pool); + if (local == NULL) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto unwind; + } + + ret = loc_copy (&local->file_loc, loc); + if (ret != 0) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto unwind; + } + +@@ -360,9 +362,9 @@ ioc_cache_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if ((op_ret == -1) || + ((op_ret >= 0) && !ioc_cache_still_valid(ioc_inode, stbuf))) { +- gf_log (ioc_inode->table->xl->name, GF_LOG_DEBUG, +- "cache for inode(%p) is invalid. flushing all pages", +- ioc_inode); ++ gf_msg_debug (ioc_inode->table->xl->name, 0, ++ "cache for inode(%p) is invalid. flushing all pages", ++ ioc_inode); + /* NOTE: only pages with no waiting frames are flushed by + * ioc_inode_flush. page_fault will be generated for all + * the pages which have waiting frames by ioc_inode_wakeup() +@@ -430,7 +432,8 @@ ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page) + waiter = GF_CALLOC (1, sizeof (ioc_waitq_t), + gf_ioc_mt_ioc_waitq_t); + if (waiter == NULL) { +- gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, ++ gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "out of memory"); + ret = -ENOMEM; + goto out; +@@ -468,8 +471,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd, + ret = -1; + local->op_ret = -1; + local->op_errno = ENOMEM; +- gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, +- "out of memory"); ++ gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto out; + } + +@@ -479,8 +482,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd, + local->op_ret = -1; + local->op_errno = ENOMEM; + mem_put (validate_local); +- gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, +- "out of memory"); ++ gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto out; + } + +@@ -560,8 +563,10 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + + //TODO: see why inode context is NULL and handle it. + if (!ioc_inode) { +- gf_log (this->name, GF_LOG_ERROR, "inode context is " +- "NULL (%s)", uuid_utoa (fd->inode->gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, ++ EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED, ++ "inode context is NULL (%s)", ++ uuid_utoa (fd->inode->gfid)); + goto out; + } + +@@ -660,7 +665,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + && (table->max_file_size < ioc_inode->ia_size))) { + ret = fd_ctx_set (fd, this, 1); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "%s: failed to set fd ctx", + local->file_loc.path); + } +@@ -677,7 +683,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + * as a whole */ + ret = fd_ctx_set (fd, this, 1); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "%s: failed to set fd ctx", + local->file_loc.path); + } +@@ -687,7 +694,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* we allow a pattern-matched cache disable this way */ + ret = fd_ctx_set (fd, this, 1); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "%s: failed to set fd ctx", + local->file_loc.path); + } +@@ -767,14 +775,16 @@ ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + local = mem_get0 (this->local_pool); + if (local == NULL) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto unwind; + } + + ret = loc_copy (&local->file_loc, loc); + if (ret != 0) { + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto unwind; + } + +@@ -816,7 +826,8 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + + local = mem_get0 (this->local_pool); + if (local == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL, NULL); + return 0; + } +@@ -852,7 +863,8 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + + local = mem_get0 (this->local_pool); + if (local == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL, + NULL, NULL, NULL, NULL); + return 0; +@@ -991,8 +1003,9 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd, + trav_offset); + fault = 1; + if (!trav) { +- gf_log (frame->this->name, ++ gf_msg (frame->this->name, + GF_LOG_CRITICAL, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "out of memory"); + local->op_ret = -1; + local->op_errno = ENOMEM; +@@ -1008,10 +1021,13 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd, + /* page found in cache */ + if (!might_need_validate && !ioc_inode->waitq) { + /* fresh enough */ +- gf_log (frame->this->name, GF_LOG_TRACE, +- "cache hit for trav_offset=%" +- PRId64"/local_offset=%"PRId64"", +- trav_offset, local_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "cache hit for " ++ "trav_offset=%" ++ PRId64"/local_" ++ "offset=%"PRId64"", ++ trav_offset, ++ local_offset); + waitq = __ioc_page_wakeup (trav, + trav->op_errno); + } else { +@@ -1055,10 +1071,10 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd, + + if (need_validate) { + need_validate = 0; +- gf_log (frame->this->name, GF_LOG_TRACE, +- "sending validate request for " +- "inode(%s) at offset=%"PRId64"", +- uuid_utoa (fd->inode->gfid), trav_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "sending validate request for " ++ "inode(%s) at offset=%"PRId64"", ++ uuid_utoa (fd->inode->gfid), trav_offset); + ret = ioc_cache_validate (frame, ioc_inode, fd, trav); + if (ret == -1) { + ioc_inode_lock (ioc_inode); +@@ -1128,7 +1144,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + table = this->private; + + if (!table) { +- gf_log (this->name, GF_LOG_ERROR, "table is null"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ IO_CACHE_MSG_ENFORCEMENT_FAILED, "table is null"); + op_errno = EINVAL; + goto out; + } +@@ -1162,7 +1179,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + + local = mem_get0 (this->local_pool); + if (local == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + op_errno = ENOMEM; + goto out; + } +@@ -1176,9 +1194,10 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, + local->size = size; + local->inode = ioc_inode; + +- gf_log (this->name, GF_LOG_TRACE, +- "NEW REQ (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET"", +- frame, offset, size); ++ gf_msg_trace (this->name, 0, ++ "NEW REQ (%p) offset " ++ "= %"PRId64" && size = %"GF_PRI_SIZET"", ++ frame, offset, size); + + weight = ioc_inode->weight; + +@@ -1248,7 +1267,8 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + + local = mem_get0 (this->local_pool); + if (local == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory"); + + STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL, NULL); + return 0; +@@ -1383,8 +1403,8 @@ ioc_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, + inode_ctx_get (fd->inode, this, &tmp_inode); + ioc_inode = (ioc_inode_t *)(long)tmp_inode; + if (!ioc_inode) { +- gf_log (this->name, GF_LOG_DEBUG, +- "inode context is NULL: returning EBADFD"); ++ gf_msg_debug (this->name, EBADFD, ++ "inode context is NULL: returning EBADFD"); + STACK_UNWIND_STRICT (lk, frame, -1, EBADFD, NULL, NULL); + return 0; + } +@@ -1537,10 +1557,9 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first) + goto out; + } + +- gf_log ("io-cache", GF_LOG_TRACE, +- "ioc priority : pattern %s : priority %s", +- pattern, +- priority); ++ gf_msg_trace ("io-cache", 0, ++ "ioc priority : pattern %s : priority %s", ++ pattern, priority); + + curr->pattern = gf_strdup (pattern); + if (curr->pattern == NULL) { +@@ -1588,8 +1607,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_ioc_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + +@@ -1609,7 +1629,8 @@ check_cache_size_ok (xlator_t *this, uint64_t cache_size) + opt = xlator_volume_option_get (this, "cache-size"); + if (!opt) { + ret = _gf_false; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED, + "could not get cache-size option"); + goto out; + } +@@ -1620,12 +1641,14 @@ check_cache_size_ok (xlator_t *this, uint64_t cache_size) + else + max_cache_size = total_mem; + +- gf_log (this->name, GF_LOG_DEBUG, "Max cache size is %"PRIu64, +- max_cache_size); ++ gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64, ++ max_cache_size); + + if (cache_size > max_cache_size) { + ret = _gf_false; +- gf_log (this->name, GF_LOG_ERROR, "Cache size %"PRIu64 ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_INVALID_ARGUMENT, ++ "Cache size %"PRIu64 + " is greater than the max size of %"PRIu64, + cache_size, max_cache_size); + goto out; +@@ -1655,8 +1678,8 @@ reconfigure (xlator_t *this, dict_t *options) + if (data) { + char *option_list = data_to_str (data); + +- gf_log (this->name, GF_LOG_TRACE, +- "option path %s", option_list); ++ gf_msg_trace (this->name, 0, ++ "option path %s", option_list); + /* parse the list of pattern:priority */ + table->max_pri = ioc_get_priority_list (option_list, + &table->priority_list); +@@ -1675,7 +1698,8 @@ reconfigure (xlator_t *this, dict_t *options) + + if ((table->max_file_size <= UINT64_MAX) && + (table->min_file_size > table->max_file_size)) { +- gf_log (this->name, GF_LOG_ERROR, "minimum size (%" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%" + PRIu64") of a file that can be cached is " + "greater than maximum size (%"PRIu64"). " + "Hence Defaulting to old value", +@@ -1687,7 +1711,8 @@ reconfigure (xlator_t *this, dict_t *options) + options, size_uint64, unlock); + if (!check_cache_size_ok (this, cache_size_new)) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, IO_CACHE_MSG_INVALID_ARGUMENT, + "Not reconfiguring cache-size"); + goto unlock; + } +@@ -1721,20 +1746,23 @@ init (xlator_t *this) + xl_options = this->options; + + if (!this->children || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: io-cache not configured with exactly " + "one child"); + goto out; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ IO_CACHE_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); + } + + table = (void *) GF_CALLOC (1, sizeof (*table), gf_ioc_mt_ioc_table_t); + if (table == NULL) { +- gf_log (this->name, GF_LOG_ERROR, "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ IO_CACHE_MSG_NO_MEMORY, "out of memory"); + goto out; + } + +@@ -1759,8 +1787,8 @@ init (xlator_t *this) + data = dict_get (xl_options, "priority"); + if (data) { + char *option_list = data_to_str (data); +- gf_log (this->name, GF_LOG_TRACE, +- "option path %s", option_list); ++ gf_msg_trace (this->name, 0, ++ "option path %s", option_list); + /* parse the list of pattern:priority */ + table->max_pri = ioc_get_priority_list (option_list, + &table->priority_list); +@@ -1775,7 +1803,8 @@ init (xlator_t *this) + + if ((table->max_file_size <= UINT64_MAX) + && (table->min_file_size > table->max_file_size)) { +- gf_log ("io-cache", GF_LOG_ERROR, "minimum size (%" ++ gf_msg ("io-cache", GF_LOG_ERROR, 0, ++ IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%" + PRIu64") of a file that can be cached is " + "greater than maximum size (%"PRIu64")", + table->min_file_size, table->max_file_size); +@@ -1795,7 +1824,8 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (ioc_local_t, 64); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "failed to create local_t's memory pool"); + goto out; + } +@@ -1809,8 +1839,8 @@ init (xlator_t *this) + + table->mem_pool = mem_pool_new (rbthash_entry_t, num_pages); + if (!table->mem_pool) { +- gf_log (this->name, GF_LOG_ERROR, +- "Unable to allocate mem_pool"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ IO_CACHE_MSG_NO_MEMORY, "Unable to allocate mem_pool"); + goto out; + } + +diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h +index 46d758a..1bdd66b 100644 +--- a/xlators/performance/io-cache/src/io-cache.h ++++ b/xlators/performance/io-cache/src/io-cache.h +@@ -29,6 +29,7 @@ + #include "hashfn.h" + #include + #include ++#include "io-cache-messages.h" + + #define IOC_PAGE_SIZE (1024 * 128) /* 128KB */ + #define IOC_CACHE_SIZE (32 * 1024 * 1024) +@@ -224,64 +225,64 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset, + + #define ioc_inode_lock(ioc_inode) \ + do { \ +- gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, \ +- "locked inode(%p)", ioc_inode); \ ++ gf_msg_trace (ioc_inode->table->xl->name, 0, \ ++ "locked inode(%p)", ioc_inode); \ + pthread_mutex_lock (&ioc_inode->inode_lock); \ + } while (0) + + + #define ioc_inode_unlock(ioc_inode) \ + do { \ +- gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, \ +- "unlocked inode(%p)", ioc_inode); \ ++ gf_msg_trace (ioc_inode->table->xl->name, 0, \ ++ "unlocked inode(%p)", ioc_inode); \ + pthread_mutex_unlock (&ioc_inode->inode_lock); \ + } while (0) + + +-#define ioc_table_lock(table) \ +- do { \ +- gf_log (table->xl->name, GF_LOG_TRACE, \ +- "locked table(%p)", table); \ +- pthread_mutex_lock (&table->table_lock); \ ++#define ioc_table_lock(table) \ ++ do { \ ++ gf_msg_trace (table->xl->name, 0, \ ++ "locked table(%p)", table); \ ++ pthread_mutex_lock (&table->table_lock); \ + } while (0) + + +-#define ioc_table_unlock(table) \ +- do { \ +- gf_log (table->xl->name, GF_LOG_TRACE, \ +- "unlocked table(%p)", table); \ +- pthread_mutex_unlock (&table->table_lock); \ ++#define ioc_table_unlock(table) \ ++ do { \ ++ gf_msg_trace (table->xl->name, 0, \ ++ "unlocked table(%p)", table); \ ++ pthread_mutex_unlock (&table->table_lock); \ + } while (0) + + + #define ioc_local_lock(local) \ + do { \ +- gf_log (local->inode->table->xl->name, GF_LOG_TRACE, \ +- "locked local(%p)", local); \ ++ gf_msg_trace (local->inode->table->xl->name, 0, \ ++ "locked local(%p)", local); \ + pthread_mutex_lock (&local->local_lock); \ + } while (0) + + + #define ioc_local_unlock(local) \ + do { \ +- gf_log (local->inode->table->xl->name, GF_LOG_TRACE, \ +- "unlocked local(%p)", local); \ ++ gf_msg_trace (local->inode->table->xl->name, 0, \ ++ "unlocked local(%p)", local); \ + pthread_mutex_unlock (&local->local_lock); \ + } while (0) + + + #define ioc_page_lock(page) \ + do { \ +- gf_log (page->inode->table->xl->name, GF_LOG_TRACE, \ +- "locked page(%p)", page); \ ++ gf_msg_trace (page->inode->table->xl->name, 0, \ ++ "locked page(%p)", page); \ + pthread_mutex_lock (&page->page_lock); \ + } while (0) + + + #define ioc_page_unlock(page) \ + do { \ +- gf_log (page->inode->table->xl->name, GF_LOG_TRACE, \ +- "unlocked page(%p)", page); \ ++ gf_msg_trace (page->inode->table->xl->name, 0, \ ++ "unlocked page(%p)", page); \ + pthread_mutex_unlock (&page->page_lock); \ + } while (0) + +diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c +index 86a54bb..fcaab96 100644 +--- a/xlators/performance/io-cache/src/ioc-inode.c ++++ b/xlators/performance/io-cache/src/ioc-inode.c +@@ -82,7 +82,8 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode, + if (ioc_inode == NULL) { + local->op_ret = -1; + local->op_errno = EINVAL; +- gf_log (frame->this->name, GF_LOG_WARNING, "ioc_inode is NULL"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ IO_CACHE_MSG_INODE_NULL, "ioc_inode is NULL"); + goto out; + } + +@@ -130,12 +131,15 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode, + waiter_page->ready = 0; + need_fault = 1; + } else { +- gf_log (frame->this->name, +- GF_LOG_TRACE, +- "validate frame(%p) is " +- "waiting for in-transit" +- " page = %p", frame, +- waiter_page); ++ gf_msg_trace (frame->this->name, ++ 0, ++ "validate " ++ "frame(%p) is " ++ "waiting for " ++ "in-transit" ++ " page = %p", ++ frame, ++ waiter_page); + } + } + ioc_inode_unlock (ioc_inode); +@@ -198,8 +202,8 @@ ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight) + } + ioc_table_unlock (table); + +- gf_log (table->xl->name, GF_LOG_TRACE, +- "adding to inode_lru[%d]", weight); ++ gf_msg_trace (table->xl->name, 0, ++ "adding to inode_lru[%d]", weight); + + out: + return ioc_inode; +diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c +index 416cd5f..4019ec0 100644 +--- a/xlators/performance/io-cache/src/page.c ++++ b/xlators/performance/io-cache/src/page.c +@@ -21,7 +21,7 @@ + #include "ioc-mem-types.h" + #include + #include +- ++#include "io-cache-messages.h" + char + ioc_empty (struct ioc_cache *cache) + { +@@ -108,10 +108,10 @@ __ioc_page_destroy (ioc_page_t *page) + sizeof (page->offset)); + list_del (&page->page_lru); + +- gf_log (page->inode->table->xl->name, GF_LOG_TRACE, +- "destroying page = %p, offset = %"PRId64" " +- "&& inode = %p", +- page, page->offset, page->inode); ++ gf_msg_trace (page->inode->table->xl->name, 0, ++ "destroying page = %p, offset = %"PRId64" " ++ "&& inode = %p", ++ page, page->offset, page->inode); + + if (page->vector){ + iobref_unref (page->iobref); +@@ -174,10 +174,11 @@ __ioc_inode_prune (ioc_inode_t *curr, uint64_t *size_pruned, + if (ret != -1) + table->cache_used -= ret; + +- gf_log (table->xl->name, GF_LOG_TRACE, +- "index = %d && table->cache_used = %"PRIu64" && table->" +- "cache_size = %"PRIu64, index, table->cache_used, +- table->cache_size); ++ gf_msg_trace (table->xl->name, 0, ++ "index = %d && " ++ "table->cache_used = %"PRIu64" && table->" ++ "cache_size = %"PRIu64, index, table->cache_used, ++ table->cache_size); + + if ((*size_pruned) >= size_to_prune) + break; +@@ -284,8 +285,8 @@ __ioc_page_create (ioc_inode_t *ioc_inode, off_t offset) + + page = newpage; + +- gf_log ("io-cache", GF_LOG_TRACE, +- "returning new page %p", page); ++ gf_msg_trace ("io-cache", 0, ++ "returning new page %p", page); + + out: + return page; +@@ -315,7 +316,8 @@ __ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset, + if (page == NULL) { + local->op_ret = -1; + local->op_errno = ENOMEM; +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, ++ 0, IO_CACHE_MSG_NO_MEMORY, + "asked to wait on a NULL page"); + goto out; + } +@@ -327,10 +329,10 @@ __ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset, + goto out; + } + +- gf_log (frame->this->name, GF_LOG_TRACE, +- "frame(%p) waiting on page = %p, offset=%"PRId64", " +- "size=%"GF_PRI_SIZET"", +- frame, page, offset, size); ++ gf_msg_trace (frame->this->name, 0, ++ "frame(%p) waiting on page = %p, offset=%"PRId64", " ++ "size=%"GF_PRI_SIZET"", ++ frame, page, offset, size); + + waitq->data = frame; + waitq->next = page->waitq; +@@ -444,9 +446,9 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (op_ret == -1 || !(zero_filled || + ioc_cache_still_valid(ioc_inode, + stbuf))) { +- gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, +- "cache for inode(%p) is invalid. flushing " +- "all pages", ioc_inode); ++ gf_msg_trace (ioc_inode->table->xl->name, 0, ++ "cache for inode(%p) is invalid. flushing " ++ "all pages", ioc_inode); + destroy_size = __ioc_inode_flush (ioc_inode); + } + +@@ -464,8 +466,8 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + waitq = __ioc_page_error (page, op_ret, + op_errno); + } else { +- gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, +- "op_ret = %d", op_ret); ++ gf_msg_trace (ioc_inode->table->xl->name, 0, ++ "op_ret = %d", op_ret); + page = __ioc_page_get (ioc_inode, offset); + if (!page) { + /* page was flushed */ +@@ -500,8 +502,9 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } else { + /* TODO: we have got a response to + * our request and no data */ +- gf_log (frame->this->name, ++ gf_msg (frame->this->name, + GF_LOG_CRITICAL, ++ ENOMEM, IO_CACHE_MSG_NO_MEMORY, + "frame>root>rsp_refs is null"); + } /* if(frame->root->rsp_refs) */ + +@@ -553,8 +556,8 @@ unlock: + ioc_prune (ioc_inode->table); + } + +- gf_log (frame->this->name, GF_LOG_TRACE, "fault frame %p returned", +- frame); ++ gf_msg_trace (frame->this->name, 0, "fault frame %p returned", ++ frame); + pthread_mutex_destroy (&local->local_lock); + + fd_unref (local->fd); +@@ -588,7 +591,8 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd, + if (frame == NULL) { + op_ret = -1; + op_errno = EINVAL; +- gf_log ("io-cache", GF_LOG_WARNING, ++ gf_msg ("io-cache", GF_LOG_WARNING, ++ EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED, + "page fault on a NULL frame"); + goto err; + } +@@ -622,9 +626,9 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd, + fault_local->pending_size = table->page_size; + fault_local->inode = ioc_inode; + +- gf_log (frame->this->name, GF_LOG_TRACE, +- "stack winding page fault for offset = %"PRId64" with " +- "frame %p", offset, fault_frame); ++ gf_msg_trace (frame->this->name, 0, ++ "stack winding page fault for offset = %"PRId64" with " ++ "frame %p", offset, fault_frame); + + STACK_WIND (fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this), + FIRST_CHILD(fault_frame->this)->fops->readv, fd, +@@ -667,7 +671,8 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset, + GF_VALIDATE_OR_GOTO (frame->this->name, local, out); + + if (page == NULL) { +- gf_log (frame->this->name, GF_LOG_WARNING, ++ gf_msg (frame->this->name, GF_LOG_WARNING, 0, ++ IO_CACHE_MSG_ENFORCEMENT_FAILED, + "NULL page has been provided to serve read request"); + local->op_ret = -1; + local->op_errno = EINVAL; +@@ -676,10 +681,10 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset, + + ioc_inode = page->inode; + +- gf_log (frame->this->name, GF_LOG_TRACE, +- "frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" " +- "&& page->size = %"GF_PRI_SIZET" && wait_count = %d", +- frame, offset, size, page->size, local->wait_count); ++ gf_msg_trace (frame->this->name, 0, ++ "frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" " ++ "&& page->size = %"GF_PRI_SIZET" && wait_count = %d", ++ frame, offset, size, page->size, local->wait_count); + + /* immediately move this page to the end of the page_lru list */ + list_move_tail (&page->page_lru, &ioc_inode->cache.page_lru); +@@ -713,10 +718,10 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset, + copy_size = src_offset = 0; + } + +- gf_log (page->inode->table->xl->name, GF_LOG_TRACE, +- "copy_size = %"GF_PRI_SIZET" && src_offset = " +- "%"PRId64" && dst_offset = %"PRId64"", +- copy_size, src_offset, dst_offset); ++ gf_msg_trace (page->inode->table->xl->name, 0, ++ "copy_size = %"GF_PRI_SIZET" && src_offset = " ++ "%"PRId64" && dst_offset = %"PRId64"", ++ copy_size, src_offset, dst_offset); + + { + new = GF_CALLOC (1, sizeof (*new), +@@ -814,8 +819,8 @@ ioc_frame_unwind (call_frame_t *frame) + + local = frame->local; + if (local == NULL) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "local is NULL"); ++ gf_msg (frame->this->name, GF_LOG_WARNING, ENOMEM, ++ IO_CACHE_MSG_NO_MEMORY, "local is NULL"); + op_ret = -1; + op_errno = ENOMEM; + goto unwind; +@@ -835,10 +840,10 @@ ioc_frame_unwind (call_frame_t *frame) + } + + if (list_empty (&local->fill_list)) { +- gf_log (frame->this->name, GF_LOG_TRACE, +- "frame(%p) has 0 entries in local->fill_list " +- "(offset = %"PRId64" && size = %"GF_PRI_SIZET")", +- frame, local->offset, local->size); ++ gf_msg_trace (frame->this->name, 0, ++ "frame(%p) has 0 entries in local->fill_list " ++ "(offset = %"PRId64" && size = %"GF_PRI_SIZET")", ++ frame, local->offset, local->size); + } + + list_for_each_entry (fill, &local->fill_list, list) { +@@ -876,8 +881,8 @@ ioc_frame_unwind (call_frame_t *frame) + } + + unwind: +- gf_log (frame->this->name, GF_LOG_TRACE, +- "frame(%p) unwinding with op_ret=%d", frame, op_ret); ++ gf_msg_trace (frame->this->name, 0, ++ "frame(%p) unwinding with op_ret=%d", frame, op_ret); + + // ioc_local_unlock (local); + +@@ -951,8 +956,8 @@ __ioc_page_wakeup (ioc_page_t *page, int32_t op_errno) + + page->ready = 1; + +- gf_log (page->inode->table->xl->name, GF_LOG_TRACE, +- "page is %p && waitq = %p", page, waitq); ++ gf_msg_trace (page->inode->table->xl->name, 0, ++ "page is %p && waitq = %p", page, waitq); + + for (trav = waitq; trav; trav = trav->next) { + frame = trav->data; +@@ -994,8 +999,8 @@ __ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno) + waitq = page->waitq; + page->waitq = NULL; + +- gf_log (page->inode->table->xl->name, GF_LOG_DEBUG, +- "page error for page = %p & waitq = %p", page, waitq); ++ gf_msg_debug (page->inode->table->xl->name, 0, ++ "page error for page = %p & waitq = %p", page, waitq); + + for (trav = waitq; trav; trav = trav->next) { + +diff --git a/xlators/performance/io-threads/src/io-threads-messages.h b/xlators/performance/io-threads/src/io-threads-messages.h +new file mode 100644 +index 0000000..ab1f672 +--- /dev/null ++++ b/xlators/performance/io-threads/src/io-threads-messages.h +@@ -0,0 +1,103 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _IO_THREADS_MESSAGES_H_ ++#define _IO_THREADS_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file io-threads-messages.h ++ * \brief IO_THREADS log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_IO_THREADS_BASE GLFS_MSGID_COMP_IO_THREADS ++#define GLFS_IO_THREADS_NUM_MESSAGES 5 ++#define GLFS_MSGID_END (GLFS_IO_THREADS_BASE + \ ++ GLFS_IO_THREADS_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_IO_THREADS_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_THREADS_MSG_INIT_FAILED (GLFS_IO_THREADS_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED (GLFS_IO_THREADS_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_THREADS_MSG_NO_MEMORY (GLFS_IO_THREADS_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_THREADS_MSG_VOL_MISCONFIGURED (GLFS_IO_THREADS_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define IO_THREADS_MSG_SIZE_NOT_SET (GLFS_IO_THREADS_BASE + 5) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _IO_THREADS_MESSAGES_H_ */ +diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c +index 148e55a..0234587 100644 +--- a/xlators/performance/io-threads/src/io-threads.c ++++ b/xlators/performance/io-threads/src/io-threads.c +@@ -24,6 +24,7 @@ + #include + #include + #include "locking.h" ++#include "io-threads-messages.h" + + void *iot_worker (void *arg); + int iot_workers_scale (iot_conf_t *conf); +@@ -192,9 +193,9 @@ iot_worker (void *data) + if (conf->curr_count > IOT_MIN_THREADS) { + conf->curr_count--; + bye = 1; +- gf_log (conf->this->name, GF_LOG_DEBUG, +- "timeout, terminated. conf->curr_count=%d", +- conf->curr_count); ++ gf_msg_debug (conf->this->name, 0, ++ "timeout, terminated. conf->curr_count=%d", ++ conf->curr_count); + } else { + timeout = 0; + } +@@ -346,8 +347,8 @@ iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub) + return -EINVAL; + } + out: +- gf_log (this->name, GF_LOG_DEBUG, "%s scheduled as %s fop", +- gf_fop_list[stub->fop], iot_get_pri_meaning (pri)); ++ gf_msg_debug (this->name, 0, "%s scheduled as %s fop", ++ gf_fop_list[stub->fop], iot_get_pri_meaning (pri)); + ret = do_iot_schedule (this->private, stub, pri); + return ret; + } +@@ -768,9 +769,10 @@ __iot_workers_scale (iot_conf_t *conf) + ret = gf_thread_create (&thread, &conf->w_attr, iot_worker, conf); + if (ret == 0) { + conf->curr_count++; +- gf_log (conf->this->name, GF_LOG_DEBUG, +- "scaled threads to %d (queue_size=%d/%d)", +- conf->curr_count, conf->queue_size, scale); ++ gf_msg_debug (conf->this->name, 0, ++ "scaled threads to %d (queue_size=%d/%d)", ++ conf->curr_count, ++ conf->queue_size, scale); + } else { + break; + } +@@ -815,11 +817,13 @@ set_stack_size (iot_conf_t *conf) + if (err == EINVAL) { + err = pthread_attr_getstacksize (&conf->w_attr, &stacksize); + if (!err) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ 0, IO_THREADS_MSG_SIZE_NOT_SET, + "Using default thread stack size %zd", + stacksize); + else +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ 0, IO_THREADS_MSG_SIZE_NOT_SET, + "Using default thread stack size"); + } + +@@ -838,8 +842,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_iot_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, IO_THREADS_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + +@@ -930,32 +935,37 @@ init (xlator_t *this) + int i = 0; + + if (!this->children || this->children->next) { +- gf_log ("io-threads", GF_LOG_ERROR, +- "FATAL: iot not configured with exactly one child"); ++ gf_msg ("io-threads", GF_LOG_ERROR, 0, ++ IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED, ++ "FATAL: iot not configured " ++ "with exactly one child"); + goto out; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, +- "dangling volume. check volfile "); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ IO_THREADS_MSG_VOL_MISCONFIGURED, ++ "dangling volume. check volfile "); + } + + conf = (void *) GF_CALLOC (1, sizeof (*conf), + gf_iot_mt_iot_conf_t); + if (conf == NULL) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ IO_THREADS_MSG_NO_MEMORY, "out of memory"); + goto out; + } + + if ((ret = pthread_cond_init(&conf->cond, NULL)) != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_THREADS_MSG_INIT_FAILED, + "pthread_cond_init failed (%d)", ret); + goto out; + } + + if ((ret = pthread_mutex_init(&conf->mutex, NULL)) != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_THREADS_MSG_INIT_FAILED, + "pthread_mutex_init failed (%d)", ret); + goto out; + } +@@ -983,7 +993,8 @@ init (xlator_t *this) + GF_OPTION_INIT("least-rate-limit", conf->throttle.rate_limit, int32, + out); + if ((ret = pthread_mutex_init(&conf->throttle.lock, NULL)) != 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_THREADS_MSG_INIT_FAILED, + "pthread_mutex_init failed (%d)", ret); + goto out; + } +@@ -997,7 +1008,8 @@ init (xlator_t *this) + ret = iot_workers_scale (conf); + + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ IO_THREADS_MSG_INIT_FAILED, + "cannot initialize worker threads, exiting init"); + goto out; + } +diff --git a/xlators/performance/md-cache/src/md-cache-messages.h b/xlators/performance/md-cache/src/md-cache-messages.h +new file mode 100644 +index 0000000..2fe8d45 +--- /dev/null ++++ b/xlators/performance/md-cache/src/md-cache-messages.h +@@ -0,0 +1,66 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _MD_CACHE_MESSAGES_H_ ++#define _MD_CACHE_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file md-cache-messages.h ++ * \brief MD_CACHE log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_MD_CACHE_BASE GLFS_MSGID_COMP_MD_CACHE ++#define GLFS_MD_CACHE_NUM_MESSAGES 1 ++#define GLFS_MSGID_END (GLFS_MD_CACHE_BASE + GLFS_MD_CACHE_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_MD_CACHE_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define MD_CACHE_MSG_NO_MEMORY (GLFS_MD_CACHE_BASE + 1) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _MD_CACHE_MESSAGES_H_ */ +diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c +index 51c0733..c3b4dfe 100644 +--- a/xlators/performance/md-cache/src/md-cache.c ++++ b/xlators/performance/md-cache/src/md-cache.c +@@ -22,6 +22,7 @@ + #include "glusterfs-acl.h" + #include + #include ++#include "md-cache-messages.h" + + + /* TODO: +@@ -292,8 +293,8 @@ mdc_inode_prep (xlator_t *this, inode_t *inode) + + mdc = GF_CALLOC (sizeof (*mdc), 1, gf_mdc_mt_md_cache_t); + if (!mdc) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory :("); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ MD_CACHE_MSG_NO_MEMORY, "out of memory"); + goto unlock; + } + +@@ -301,8 +302,8 @@ mdc_inode_prep (xlator_t *this, inode_t *inode) + + ret = __mdc_inode_ctx_set (this, inode, mdc); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory :("); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ MD_CACHE_MSG_NO_MEMORY, "out of memory"); + GF_FREE (mdc); + mdc = NULL; + } +@@ -2247,8 +2248,8 @@ init (xlator_t *this) + + conf = GF_CALLOC (sizeof (*conf), 1, gf_mdc_mt_mdc_conf_t); + if (!conf) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ MD_CACHE_MSG_NO_MEMORY, "out of memory"); + return -1; + } + +diff --git a/xlators/performance/open-behind/src/open-behind-messages.h b/xlators/performance/open-behind/src/open-behind-messages.h +new file mode 100644 +index 0000000..57e63ea +--- /dev/null ++++ b/xlators/performance/open-behind/src/open-behind-messages.h +@@ -0,0 +1,85 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _OPEN_BEHIND_MESSAGES_H_ ++#define _OPEN_BEHIND_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file open-behind-messages.h ++ * \brief OPEN_BEHIND log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_OPEN_BEHIND_BASE GLFS_MSGID_COMP_OPEN_BEHIND ++#define GLFS_OPEN_BEHIND_NUM_MESSAGES 3 ++#define GLFS_MSGID_END (GLFS_OPEN_BEHIND_BASE + \ ++ GLFS_OPEN_BEHIND_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_OPEN_BEHIND_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define OPEN_BEHIND_MSG_XLATOR_CHILD_MISCONFIGURED (GLFS_OPEN_BEHIND_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define OPEN_BEHIND_MSG_VOL_MISCONFIGURED (GLFS_OPEN_BEHIND_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define OPEN_BEHIND_MSG_NO_MEMORY (GLFS_OPEN_BEHIND_BASE + 3) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _OPEN_BEHIND_MESSAGES_H_ */ +diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c +index 742e4df..97c12fa 100644 +--- a/xlators/performance/open-behind/src/open-behind.c ++++ b/xlators/performance/open-behind/src/open-behind.c +@@ -13,6 +13,7 @@ + #include "statedump.h" + #include "call-stub.h" + #include "defaults.h" ++#include "open-behind-messages.h" + + typedef struct ob_conf { + gf_boolean_t use_anonymous_fd; /* use anonymous FDs wherever safe +@@ -340,8 +341,8 @@ ob_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + + return 0; + err: +- gf_log (this->name, GF_LOG_ERROR, "%s: %s", loc->path, +- strerror (op_errno)); ++ gf_msg (this->name, GF_LOG_ERROR, op_errno, OPEN_BEHIND_MSG_NO_MEMORY, ++ "%s", loc->path); + + STACK_UNWIND_STRICT (open, frame, -1, op_errno, 0, 0); + +@@ -887,7 +888,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_ob_mt_end + 1); + + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ OPEN_BEHIND_MSG_NO_MEMORY, ++ "Memory accounting failed"); + + return ret; + } +@@ -920,14 +923,16 @@ init (xlator_t *this) + ob_conf_t *conf = NULL; + + if (!this->children || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ OPEN_BEHIND_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: volume (%s) not configured with exactly one " + "child", this->name); + return -1; + } + + if (!this->parents) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ OPEN_BEHIND_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); + + conf = GF_CALLOC (1, sizeof (*conf), gf_ob_mt_conf_t); +diff --git a/xlators/performance/quick-read/src/quick-read-messages.h b/xlators/performance/quick-read/src/quick-read-messages.h +new file mode 100644 +index 0000000..d7444dd +--- /dev/null ++++ b/xlators/performance/quick-read/src/quick-read-messages.h +@@ -0,0 +1,119 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _QUICK_READ_MESSAGES_H_ ++#define _QUICK_READ_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file quick-read-messages.h ++ * \brief QUICK_READ log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_QUICK_READ_BASE GLFS_MSGID_COMP_QUICK_READ ++#define GLFS_QUICK_READ_NUM_MESSAGES 7 ++#define GLFS_MSGID_END (GLFS_QUICK_READ_BASE +\ ++ GLFS_QUICK_READ_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_QUICK_READ_BASE, "Invalid: Start of messages" ++ ++ ++#define QUICK_READ_MSG_ENFORCEMENT_FAILED (GLFS_QUICK_READ_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_INVALID_ARGUMENT (GLFS_QUICK_READ_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_XLATOR_CHILD_MISCONFIGURED\ ++ (GLFS_QUICK_READ_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_NO_MEMORY (GLFS_QUICK_READ_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_VOL_MISCONFIGURED (GLFS_QUICK_READ_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_DICT_SET_FAILED (GLFS_QUICK_READ_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define QUICK_READ_MSG_INVALID_CONFIG (GLFS_QUICK_READ_BASE + 7) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _QUICK_READ_MESSAGES_H_ */ +diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c +index 53f9a5d..c6913ee 100644 +--- a/xlators/performance/quick-read/src/quick-read.c ++++ b/xlators/performance/quick-read/src/quick-read.c +@@ -10,6 +10,7 @@ + + #include "quick-read.h" + #include "statedump.h" ++#include "quick-read-messages.h" + + qr_inode_t *qr_inode_ctx_get (xlator_t *this, inode_t *inode); + void __qr_inode_prune (qr_inode_table_t *table, qr_inode_t *qr_inode); +@@ -471,8 +472,9 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) + ret = dict_set (xdata, GF_CONTENT_KEY, + data_from_uint64 (conf->max_file_size)); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, +- "cannot set key in request dict (%s)", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ QUICK_READ_MSG_DICT_SET_FAILED, ++ "cannot set key in request dict (%s)", + loc->path); + wind: + frame->local = inode_ref (loc->inode); +@@ -784,8 +786,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_qr_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ QUICK_READ_MSG_NO_MEMORY, ++ "Memory accounting init failed"); + return ret; + } + +@@ -805,7 +808,8 @@ check_cache_size_ok (xlator_t *this, int64_t cache_size) + opt = xlator_volume_option_get (this, "cache-size"); + if (!opt) { + ret = _gf_false; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ QUICK_READ_MSG_INVALID_ARGUMENT, + "could not get cache-size option"); + goto out; + } +@@ -816,11 +820,12 @@ check_cache_size_ok (xlator_t *this, int64_t cache_size) + else + max_cache_size = total_mem; + +- gf_log (this->name, GF_LOG_DEBUG, "Max cache size is %"PRIu64, +- max_cache_size); ++ gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64, ++ max_cache_size); + if (cache_size > max_cache_size) { + ret = _gf_false; +- gf_log (this->name, GF_LOG_ERROR, "Cache size %"PRIu64 ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ QUICK_READ_MSG_INVALID_ARGUMENT, "Cache size %"PRIu64 + " is greater than the max size of %"PRIu64, + cache_size, max_cache_size); + goto out; +@@ -854,7 +859,8 @@ reconfigure (xlator_t *this, dict_t *options) + GF_OPTION_RECONF ("cache-size", cache_size_new, options, size_uint64, out); + if (!check_cache_size_ok (this, cache_size_new)) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ QUICK_READ_MSG_INVALID_CONFIG, + "Not reconfiguring cache-size"); + goto out; + } +@@ -923,10 +929,9 @@ qr_get_priority_list (const char *opt_str, struct list_head *first) + goto out; + } + +- gf_log ("quick-read", GF_LOG_TRACE, +- "quick-read priority : pattern %s : priority %s", +- pattern, +- priority); ++ gf_msg_trace ("quick-read", 0, ++ "quick-read priority : pattern %s : priority %s", ++ pattern, priority); + + curr->pattern = gf_strdup (pattern); + if (curr->pattern == NULL) { +@@ -972,14 +977,16 @@ init (xlator_t *this) + qr_conf_t *conf = NULL; + + if (!this->children || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ QUICK_READ_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: volume (%s) not configured with exactly one " + "child", this->name); + return -1; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ QUICK_READ_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); + } + +@@ -1007,8 +1014,8 @@ init (xlator_t *this) + if (dict_get (this->options, "priority")) { + char *option_list = data_to_str (dict_get (this->options, + "priority")); +- gf_log (this->name, GF_LOG_TRACE, +- "option path %s", option_list); ++ gf_msg_trace (this->name, 0, ++ "option path %s", option_list); + /* parse the list of pattern:priority */ + conf->max_pri = qr_get_priority_list (option_list, + &conf->priority_list); +diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c +index 6e5b52c..f96a23c 100644 +--- a/xlators/performance/read-ahead/src/page.c ++++ b/xlators/performance/read-ahead/src/page.c +@@ -19,6 +19,7 @@ + #include "xlator.h" + #include "read-ahead.h" + #include ++#include "read-ahead-messages.h" + + ra_page_t * + ra_page_get (ra_file_t *file, off_t offset) +@@ -155,7 +156,8 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + pending_offset = local->pending_offset; + + if (file == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, EBADF, ++ READ_AHEAD_MSG_FD_CONTEXT_NOT_SET, + "read-ahead context not set in fd (%p)", fd); + op_ret = -1; + op_errno = EBADF; +@@ -170,9 +172,10 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + page = ra_page_get (file, pending_offset); + + if (!page) { +- gf_log (this->name, GF_LOG_TRACE, +- "wasted copy: %"PRId64"[+%"PRId64"] file=%p", +- pending_offset, file->page_size, file); ++ gf_msg_trace (this->name, 0, ++ "wasted copy: " ++ "%"PRId64"[+%"PRId64"] file=%p", ++ pending_offset, file->page_size, file); + goto unlock; + } + +diff --git a/xlators/performance/read-ahead/src/read-ahead-messages.h b/xlators/performance/read-ahead/src/read-ahead-messages.h +new file mode 100644 +index 0000000..a205cee +--- /dev/null ++++ b/xlators/performance/read-ahead/src/read-ahead-messages.h +@@ -0,0 +1,94 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _READ_AHEAD_MESSAGES_H_ ++#define _READ_AHEAD_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file read-ahead-messages.h ++ * \brief READ_AHEAD log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_READ_AHEAD_BASE GLFS_MSGID_COMP_READ_AHEAD ++#define GLFS_READ_AHEAD_NUM_MESSAGES 4 ++#define GLFS_MSGID_END (GLFS_READ_AHEAD_BASE +\ ++ GLFS_READ_AHEAD_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_READ_AHEAD_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED (GLFS_READ_AHEAD_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READ_AHEAD_MSG_VOL_MISCONFIGURED (GLFS_READ_AHEAD_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READ_AHEAD_MSG_NO_MEMORY (GLFS_READ_AHEAD_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READ_AHEAD_MSG_FD_CONTEXT_NOT_SET (GLFS_READ_AHEAD_BASE + 4) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _READ_AHEAD_MESSAGES_H_ */ +diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c +index 7ea9f40..f33263c 100644 +--- a/xlators/performance/read-ahead/src/read-ahead.c ++++ b/xlators/performance/read-ahead/src/read-ahead.c +@@ -28,6 +28,7 @@ + #include "statedump.h" + #include + #include ++#include "read-ahead-messages.h" + + static void + read_ahead (call_frame_t *frame, ra_file_t *file); +@@ -89,8 +90,10 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = fd_ctx_set (fd, this, (uint64_t)(long)file); + if (ret == -1) { +- gf_log (frame->this->name, GF_LOG_WARNING, +- "cannot set read-ahead context information in fd (%p)", ++ gf_msg (frame->this->name, GF_LOG_WARNING, ++ 0, READ_AHEAD_MSG_NO_MEMORY, ++ "cannot set read-ahead context" ++ "information in fd (%p)", + fd); + ra_file_destroy (file); + op_ret = -1; +@@ -161,8 +164,10 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + ret = fd_ctx_set (fd, this, (uint64_t)(long)file); + if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "cannot set read ahead context information in fd (%p)", ++ gf_msg (this->name, GF_LOG_WARNING, ++ 0, READ_AHEAD_MSG_NO_MEMORY, ++ "cannot set read ahead context" ++ "information in fd (%p)", + fd); + ra_file_destroy (file); + op_ret = -1; +@@ -329,8 +334,8 @@ read_ahead (call_frame_t *frame, ra_file_t *file) + } + + if (fault) { +- gf_log (frame->this->name, GF_LOG_TRACE, +- "RA at offset=%"PRId64, trav_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "RA at offset=%"PRId64, trav_offset); + ra_page_fault (file, frame, trav_offset); + } + trav_offset += file->page_size; +@@ -396,14 +401,15 @@ dispatch_requests (call_frame_t *frame, ra_file_t *file) + trav->dirty = 0; + + if (trav->ready) { +- gf_log (frame->this->name, GF_LOG_TRACE, +- "HIT at offset=%"PRId64".", +- trav_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "HIT at offset=%"PRId64".", ++ trav_offset); + ra_frame_fill (trav, frame); + } else { +- gf_log (frame->this->name, GF_LOG_TRACE, +- "IN-TRANSIT at offset=%"PRId64".", +- trav_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "IN-TRANSIT at " ++ "offset=%"PRId64".", ++ trav_offset); + ra_wait_on_page (trav, frame); + need_atime_update = 0; + } +@@ -416,9 +422,9 @@ dispatch_requests (call_frame_t *frame, ra_file_t *file) + } + + if (fault) { +- gf_log (frame->this->name, GF_LOG_TRACE, +- "MISS at offset=%"PRId64".", +- trav_offset); ++ gf_msg_trace (frame->this->name, 0, ++ "MISS at offset=%"PRId64".", ++ trav_offset); + ra_page_fault (file, frame, trav_offset); + } + +@@ -476,9 +482,9 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + + conf = this->private; + +- gf_log (this->name, GF_LOG_TRACE, +- "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"", +- offset, size); ++ gf_msg_trace (this->name, 0, ++ "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"", ++ offset, size); + + fd_ctx_get (fd, this, &tmp_file); + file = (ra_file_t *)(long)tmp_file; +@@ -488,15 +494,16 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + } + + if (file->offset != offset) { +- gf_log (this->name, GF_LOG_TRACE, +- "unexpected offset (%"PRId64" != %"PRId64") resetting", +- file->offset, offset); ++ gf_msg_trace (this->name, 0, ++ "unexpected offset (%"PRId64" != %"PRId64") " ++ "resetting", ++ file->offset, offset); + + expected_offset = file->expected = file->page_count = 0; + } else { +- gf_log (this->name, GF_LOG_TRACE, +- "expected offset (%"PRId64") when page_count=%d", +- offset, file->page_count); ++ gf_msg_trace (this->name, 0, ++ "expected offset (%"PRId64") when page_count=%d", ++ offset, file->page_count); + + if (file->expected < (file->page_size * conf->page_count)) { + file->expected += size; +@@ -1103,7 +1110,8 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ READ_AHEAD_MSG_NO_MEMORY, "Memory accounting init" + "failed"); + } + +@@ -1141,14 +1149,16 @@ init (xlator_t *this) + GF_VALIDATE_OR_GOTO ("read-ahead", this, out); + + if (!this->children || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: read-ahead not configured with exactly one" + " child"); + goto out; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ READ_AHEAD_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); + } + +@@ -1173,7 +1183,8 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (ra_local_t, 64); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, READ_AHEAD_MSG_NO_MEMORY, + "failed to create local_t's memory pool"); + goto out; + } +diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h b/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h +new file mode 100644 +index 0000000..0e19348 +--- /dev/null ++++ b/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h +@@ -0,0 +1,105 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _READDIR_AHEAD_MESSAGES_H_ ++#define _READDIR_AHEAD_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file readdir-ahead-messages.h ++ * \brief READDIR_AHEAD log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_READDIR_AHEAD_BASE GLFS_MSGID_COMP_READDIR_AHEAD ++#define GLFS_READDIR_AHEAD_NUM_MESSAGES 5 ++#define GLFS_MSGID_END (GLFS_READDIR_AHEAD_BASE +\ ++ GLFS_READDIR_AHEAD_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_READDIR_AHEAD_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED\ ++ (GLFS_READDIR_AHEAD_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READDIR_AHEAD_MSG_VOL_MISCONFIGURED (GLFS_READDIR_AHEAD_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READDIR_AHEAD_MSG_NO_MEMORY (GLFS_READDIR_AHEAD_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB \ ++ (GLFS_READDIR_AHEAD_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define READDIR_AHEAD_MSG_OUT_OF_SEQUENCE (GLFS_READDIR_AHEAD_BASE + 5) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _READDIR_AHEAD_MESSAGES_H_ */ +diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c +index 1a567a0..75f30d9 100644 +--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c ++++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c +@@ -34,7 +34,7 @@ + #include "readdir-ahead.h" + #include "readdir-ahead-mem-types.h" + #include "defaults.h" +- ++#include "readdir-ahead-messages.h" + static int rda_fill_fd(call_frame_t *, xlator_t *, fd_t *); + + /* +@@ -262,8 +262,9 @@ rda_fill_fd_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + /* Verify that the preload buffer is still pending on this data. */ + if (ctx->next_offset != local->offset) { +- gf_log(this->name, GF_LOG_ERROR, +- "Out of sequence directory preload."); ++ gf_msg(this->name, GF_LOG_ERROR, ++ 0, READDIR_AHEAD_MSG_OUT_OF_SEQUENCE, ++ "Out of sequence directory preload."); + ctx->state |= (RDA_FD_BYPASS|RDA_FD_ERROR); + ctx->op_errno = EUCLEAN; + +@@ -434,8 +435,9 @@ rda_releasedir(xlator_t *this, fd_t *fd) + STACK_DESTROY(ctx->fill_frame->root); + + if (ctx->stub) +- gf_log(this->name, GF_LOG_ERROR, +- "released a directory with a pending stub"); ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB, ++ "released a directory with a pending stub"); + + GF_FREE(ctx); + return 0; +@@ -452,7 +454,8 @@ mem_acct_init(xlator_t *this) + ret = xlator_mem_acct_init(this, gf_rda_mt_end + 1); + + if (ret != 0) +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" ++ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, ++ READDIR_AHEAD_MSG_NO_MEMORY, "Memory accounting init" + "failed"); + + out: +@@ -484,14 +487,16 @@ init(xlator_t *this) + GF_VALIDATE_OR_GOTO("readdir-ahead", this, err); + + if (!this->children || this->children->next) { +- gf_log(this->name, GF_LOG_ERROR, ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: readdir-ahead not configured with exactly one" + " child"); + goto err; + } + + if (!this->parents) { +- gf_log(this->name, GF_LOG_WARNING, ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ READDIR_AHEAD_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); + } + +diff --git a/xlators/performance/symlink-cache/src/symlink-cache-messages.h b/xlators/performance/symlink-cache/src/symlink-cache-messages.h +new file mode 100644 +index 0000000..89ea118 +--- /dev/null ++++ b/xlators/performance/symlink-cache/src/symlink-cache-messages.h +@@ -0,0 +1,93 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _SYMLINK_CACHE_MESSAGES_H_ ++#define _SYMLINK_CACHE_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file symlink_cache-messages.h ++ * \brief SYMLINK_CACHE log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_SYMLINK_CACHE_BASE GLFS_MSGID_COMP_SYMLINK_CACHE ++#define GLFS_SYMLINK_CACHE_NUM_MESSAGES 5 ++#define GLFS_MSGID_END (GLFS_SYMLINK_CACHE_BASE +\ ++ GLFS_SYMLINK_CACHE_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_SYMLINK_CACHE_BASE, "Invalid: Start of messages" ++ ++#define SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED\ ++ (GLFS_SYMLINK_CACHE_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define SYMLINK_CACHE_MSG_VOL_MISCONFIGURED (GLFS_SYMLINK_CACHE_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define SYMLINK_CACHE_MSG_NO_MEMORY (GLFS_SYMLINK_CACHE_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define SYMLINK_CACHE_MSG_DICT_GET_FAILED (GLFS_SYMLINK_CACHE_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define SYMLINK_CACHE_MSG_DICT_SET_FAILED (GLFS_SYMLINK_CACHE_BASE + 5) ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _SYMLINK_CACHE_MESSAGES_H_ */ +diff --git a/xlators/performance/symlink-cache/src/symlink-cache.c b/xlators/performance/symlink-cache/src/symlink-cache.c +index c65629b..6ecfad4 100644 +--- a/xlators/performance/symlink-cache/src/symlink-cache.c ++++ b/xlators/performance/symlink-cache/src/symlink-cache.c +@@ -22,6 +22,7 @@ + #include "compat.h" + #include "compat-errno.h" + #include "common-utils.h" ++#include "symlink-cache-messages.h" + + struct symlink_cache { + time_t ctime; +@@ -36,7 +37,8 @@ symlink_inode_ctx_get (inode_t *inode, xlator_t *this, void **ctx) + uint64_t tmp_ctx = 0; + ret = inode_ctx_get (inode, this, &tmp_ctx); + if (-1 == ret) +- gf_log (this->name, GF_LOG_ERROR, "dict get failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ SYMLINK_CACHE_MSG_DICT_GET_FAILED, "dict get failed"); + else + *ctx = (void *)(long)tmp_ctx; + +@@ -50,7 +52,8 @@ symlink_inode_ctx_set (inode_t *inode, xlator_t *this, void *ctx) + int ret = 0; + ret = inode_ctx_put (inode, this, (uint64_t)(long) ctx); + if (-1 == ret) +- gf_log (this->name, GF_LOG_ERROR, "dict set failed"); ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ SYMLINK_CACHE_MSG_DICT_SET_FAILED, "dict set failed"); + + return 0; + } +@@ -66,15 +69,15 @@ sc_cache_update (xlator_t *this, inode_t *inode, const char *link) + return 0; + + if (!sc->readlink) { +- gf_log (this->name, GF_LOG_DEBUG, +- "updating cache: %s", link); ++ gf_msg_debug (this->name, 0, ++ "updating cache: %s", link); + + sc->readlink = strdup (link); +- } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "not updating existing cache: %s with %s", +- sc->readlink, link); +- } ++ } else ++ gf_msg_debug (this->name, 0, ++ "not updating existing cache: %s with %s", ++ sc->readlink, link); ++ + + return 0; + } +@@ -94,16 +97,17 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf, + need_set = 1; + sc = CALLOC (1, sizeof (*sc)); + if (!sc) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory :("); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ SYMLINK_CACHE_MSG_NO_MEMORY, ++ "out of memory :("); + goto err; + } + } + + if (sc->readlink) { +- gf_log (this->name, GF_LOG_DEBUG, +- "replacing old cache: %s with new cache: %s", +- sc->readlink, link); ++ gf_msg_debug (this->name, 0, ++ "replacing old cache: %s with new cache: %s", ++ sc->readlink, link); + FREE (sc->readlink); + sc->readlink = NULL; + } +@@ -111,24 +115,25 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf, + if (link) { + sc->readlink = strdup (link); + if (!sc->readlink) { +- gf_log (this->name, GF_LOG_ERROR, +- "out of memory :("); ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ SYMLINK_CACHE_MSG_NO_MEMORY, ++ "out of memory :("); + goto err; + } + } + + sc->ctime = buf->ia_ctime; + +- gf_log (this->name, GF_LOG_DEBUG, +- "setting symlink cache: %s", link); ++ gf_msg_debug (this->name, 0, ++ "setting symlink cache: %s", link); + + if (need_set) { + ret = symlink_inode_ctx_set (inode, this, sc); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "could not set inode context (%s)", +- strerror (-ret)); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, SYMLINK_CACHE_MSG_NO_MEMORY, ++ "could not set inode context "); + goto err; + } + } +@@ -156,8 +161,8 @@ sc_cache_flush (xlator_t *this, inode_t *inode) + return 0; + + if (sc->readlink) { +- gf_log (this->name, GF_LOG_DEBUG, +- "flushing cache: %s", sc->readlink); ++ gf_msg_debug (this->name, 0, ++ "flushing cache: %s", sc->readlink); + + FREE (sc->readlink); + sc->readlink = NULL; +@@ -199,8 +204,8 @@ sc_cache_validate (xlator_t *this, inode_t *inode, struct iatt *buf) + + /* STALE */ + if (sc->readlink) { +- gf_log (this->name, GF_LOG_DEBUG, +- "flushing cache: %s", sc->readlink); ++ gf_msg_debug (this->name, 0, ++ "flushing cache: %s", sc->readlink); + + FREE (sc->readlink); + sc->readlink = NULL; +@@ -257,9 +262,9 @@ sc_readlink (call_frame_t *frame, xlator_t *this, + + if (link) { + /* cache hit */ +- gf_log (this->name, GF_LOG_DEBUG, +- "cache hit %s -> %s", +- loc->path, link); ++ gf_msg_debug (this->name, 0, ++ "cache hit %s -> %s", ++ loc->path, link); + + /* + libglusterfsclient, nfs or any other translators +@@ -361,15 +366,17 @@ init (xlator_t *this) + { + if (!this->children || this->children->next) + { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED, + "FATAL: volume (%s) not configured with exactly one " + "child", this->name); + return -1; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, +- "dangling volume. check volfile "); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ SYMLINK_CACHE_MSG_VOL_MISCONFIGURED, ++ "dangling volume. check volfile "); + } + + return 0; +diff --git a/xlators/performance/write-behind/src/write-behind-messages.h b/xlators/performance/write-behind/src/write-behind-messages.h +new file mode 100644 +index 0000000..d0934cf +--- /dev/null ++++ b/xlators/performance/write-behind/src/write-behind-messages.h +@@ -0,0 +1,121 @@ ++/*Copyright (c) 2015 Red Hat, Inc. ++ This file is part of GlusterFS. ++ ++ This file is licensed to you under your choice of the GNU Lesser ++ General Public License, version 3 or any later version (LGPLv3 or ++ later), or the GNU General Public License, version 2 (GPLv2), in all ++ cases as published by the Free Software Foundation. ++*/ ++ ++#ifndef _WRITE_BEHIND_MESSAGES_H_ ++#define _WRITE_BEHIND_MESSAGES_H_ ++ ++#include "glfs-message-id.h" ++ ++/*! \file write-behind-messages.h ++ * \brief WRITE_BEHIND log-message IDs and their descriptions ++ * ++ */ ++ ++/* NOTE: Rules for message additions ++ * 1) Each instance of a message is _better_ left with a unique message ID, even ++ * if the message format is the same. Reasoning is that, if the message ++ * format needs to change in one instance, the other instances are not ++ * impacted or the new change does not change the ID of the instance being ++ * modified. ++ * 2) Addition of a message, ++ * - Should increment the GLFS_NUM_MESSAGES ++ * - Append to the list of messages defined, towards the end ++ * - Retain macro naming as glfs_msg_X (for redability across developers) ++ * NOTE: Rules for message format modifications ++ * 3) Check acorss the code if the message ID macro in question is reused ++ * anywhere. If reused then then the modifications should ensure correctness ++ * everywhere, or needs a new message ID as (1) above was not adhered to. If ++ * not used anywhere, proceed with the required modification. ++ * NOTE: Rules for message deletion ++ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used ++ * anywhere, then can be deleted, but will leave a hole by design, as ++ * addition rules specify modification to the end of the list and not filling ++ * holes. ++ */ ++ ++#define GLFS_WRITE_BEHIND_BASE GLFS_MSGID_COMP_WRITE_BEHIND ++#define GLFS_WRITE_BEHIND_NUM_MESSAGES 7 ++#define GLFS_MSGID_END (GLFS_WRITE_BEHIND_BASE +\ ++ GLFS_WRITE_BEHIND_NUM_MESSAGES + 1) ++ ++/* Messages with message IDs */ ++#define glfs_msg_start_x GLFS_WRITE_BEHIND_BASE, "Invalid: Start of messages" ++ ++ ++ ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE (GLFS_WRITE_BEHIND_BASE + 1) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_INIT_FAILED (GLFS_WRITE_BEHIND_BASE + 2) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_INVALID_ARGUMENT (GLFS_WRITE_BEHIND_BASE + 3) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_NO_MEMORY (GLFS_WRITE_BEHIND_BASE + 4) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_SIZE_NOT_SET (GLFS_WRITE_BEHIND_BASE + 5) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_VOL_MISCONFIGURED (GLFS_WRITE_BEHIND_BASE + 6) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction None ++ * ++ */ ++ ++#define WRITE_BEHIND_MSG_RES_UNAVAILABLE (GLFS_WRITE_BEHIND_BASE + 7) ++ ++ ++/*------------*/ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++ ++ ++#endif /* _WRITE_BEHIND_MESSAGES_H_ */ +diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c +index 3cb0d44..84e444d 100644 +--- a/xlators/performance/write-behind/src/write-behind.c ++++ b/xlators/performance/write-behind/src/write-behind.c +@@ -26,6 +26,7 @@ + #include "statedump.h" + #include "defaults.h" + #include "write-behind-mem-types.h" ++#include "write-behind-messages.h" + + #define MAX_VECTOR_COUNT 8 + #define WB_AGGREGATE_SIZE 131072 /* 128 KB */ +@@ -356,7 +357,8 @@ __wb_request_unref (wb_request_t *req) + wb_inode = req->wb_inode; + + if (req->refcount <= 0) { +- gf_log ("wb-request", GF_LOG_WARNING, ++ gf_msg ("wb-request", GF_LOG_WARNING, ++ 0, WRITE_BEHIND_MSG_RES_UNAVAILABLE, + "refcount(%d) is <= 0", req->refcount); + goto out; + } +@@ -422,7 +424,8 @@ __wb_request_ref (wb_request_t *req) + GF_VALIDATE_OR_GOTO ("write-behind", req, out); + + if (req->refcount < 0) { +- gf_log ("wb-request", GF_LOG_WARNING, ++ gf_msg ("wb-request", GF_LOG_WARNING, 0, ++ WRITE_BEHIND_MSG_RES_UNAVAILABLE, + "refcount(%d) is < 0", req->refcount); + req = NULL; + goto out; +@@ -993,7 +996,8 @@ __wb_collapse_small_writes (wb_request_t *holder, wb_request_t *req) + + ret = iobref_add (iobref, iobuf); + if (ret != 0) { +- gf_log (req->wb_inode->this->name, GF_LOG_WARNING, ++ gf_msg (req->wb_inode->this->name, GF_LOG_WARNING, ++ -ret, WRITE_BEHIND_MSG_INVALID_ARGUMENT, + "cannot add iobuf (%p) into iobref (%p)", + iobuf, iobref); + iobuf_unref (iobuf); +@@ -2099,7 +2103,9 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_wb_mt_end + 1); + + if (ret != 0) { +- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ WRITE_BEHIND_MSG_NO_MEMORY, ++ "Memory accounting init" + "failed"); + } + +@@ -2143,14 +2149,16 @@ init (xlator_t *this) + + if ((this->children == NULL) + || this->children->next) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ WRITE_BEHIND_MSG_INIT_FAILED, + "FATAL: write-behind (%s) not configured with exactly " + "one child", this->name); + goto out; + } + + if (this->parents == NULL) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ WRITE_BEHIND_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfilex"); + } + +@@ -2166,7 +2174,8 @@ init (xlator_t *this) + GF_OPTION_INIT ("cache-size", conf->window_size, size_uint64, out); + + if (!conf->window_size && conf->aggregate_size) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ WRITE_BEHIND_MSG_SIZE_NOT_SET, + "setting window-size to be equal to " + "aggregate-size(%"PRIu64")", + conf->aggregate_size); +@@ -2174,7 +2183,8 @@ init (xlator_t *this) + } + + if (conf->window_size < conf->aggregate_size) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE, + "aggregate-size(%"PRIu64") cannot be more than " + "window-size(%"PRIu64")", conf->aggregate_size, + conf->window_size); +-- +1.7.1 + diff --git a/SOURCES/0183-afr-Porting-messages-to-new-logging-framework.patch b/SOURCES/0183-afr-Porting-messages-to-new-logging-framework.patch new file mode 100644 index 0000000..883d5c6 --- /dev/null +++ b/SOURCES/0183-afr-Porting-messages-to-new-logging-framework.patch @@ -0,0 +1,2853 @@ +From 36027983e277235ad30a6c03f00ad8c8fe56bed9 Mon Sep 17 00:00:00 2001 +From: arao +Date: Fri, 6 Mar 2015 12:33:05 +0530 +Subject: [PATCH 183/190] afr: Porting messages to new logging framework + updated + +Change-Id: I71bacc6285242cd765c1c3c4fa8ba88f41e92b6a +BUG: 1231779 +Signed-off-by: Anusha +Reviewed-on: http://review.gluster.org/9897 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51256 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/afr/src/afr-common.c | 64 +++-- + xlators/cluster/afr/src/afr-inode-read.c | 47 ++-- + xlators/cluster/afr/src/afr-inode-write.c | 14 +- + xlators/cluster/afr/src/afr-lk-common.c | 115 ++++---- + xlators/cluster/afr/src/afr-messages.h | 193 ++++++++++++- + xlators/cluster/afr/src/afr-open.c | 22 +- + xlators/cluster/afr/src/afr-read-txn.c | 12 +- + xlators/cluster/afr/src/afr-self-heal-common.c | 61 ++-- + xlators/cluster/afr/src/afr-self-heal-data.c | 22 +- + xlators/cluster/afr/src/afr-self-heal-entry.c | 71 +++-- + xlators/cluster/afr/src/afr-self-heal-metadata.c | 24 +- + xlators/cluster/afr/src/afr-self-heal-name.c | 47 ++-- + xlators/cluster/afr/src/afr-self-heald.c | 107 ++++--- + xlators/cluster/afr/src/afr-transaction.c | 48 ++-- + xlators/cluster/afr/src/afr.c | 34 ++- + xlators/cluster/afr/src/pump.c | 340 +++++++++++----------- + 16 files changed, 748 insertions(+), 473 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 9129b27..31c6eff 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -972,7 +972,8 @@ afr_xattr_req_prepare (xlator_t *this, dict_t *xattr_req) + ret = dict_set_uint64 (xattr_req, priv->pending_key[i], + AFR_NUM_CHANGE_LOGS * sizeof(int)); + if (ret < 0) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "Unable to set dict value for %s", + priv->pending_key[i]); + /* 3 = data+metadata+entry */ +@@ -980,14 +981,14 @@ afr_xattr_req_prepare (xlator_t *this, dict_t *xattr_req) + ret = dict_set_uint64 (xattr_req, AFR_DIRTY, + AFR_NUM_CHANGE_LOGS * sizeof(int)); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "failed to set dirty " +- "query flag"); ++ gf_msg_debug (this->name, -ret, "failed to set dirty " ++ "query flag"); + } + + ret = dict_set_int32 (xattr_req, "list-xattr", 1); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Unable to set list-xattr in dict "); ++ gf_msg_debug (this->name, -ret, ++ "Unable to set list-xattr in dict "); + } + + return ret; +@@ -1009,27 +1010,26 @@ afr_lookup_xattr_req_prepare (afr_local_t *local, xlator_t *this, + dict_copy (xattr_req, local->xattr_req); + + ret = afr_xattr_req_prepare (this, local->xattr_req); +- if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, +- "%s: Unable to prepare xattr_req", loc->path); +- } + + ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_INODELK_COUNT, 0); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "%s: Unable to set dict value for %s", + loc->path, GLUSTERFS_INODELK_COUNT); + } + ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_ENTRYLK_COUNT, 0); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "%s: Unable to set dict value for %s", + loc->path, GLUSTERFS_ENTRYLK_COUNT); + } + + ret = dict_set_uint32 (local->xattr_req, GLUSTERFS_PARENT_ENTRYLK, 0); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "%s: Unable to set dict value for %s", + loc->path, GLUSTERFS_PARENT_ENTRYLK); + } +@@ -1740,9 +1740,10 @@ afr_local_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if ((priv->arbiter_count == 1) && + (child_index == ARBITER_BRICK_INDEX)) + goto out; +- gf_log (this->name, GF_LOG_INFO, +- "selecting local read_child %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_LOCAL_CHILD, "selecting local read_child %s", + priv->children[child_index]->name); ++ + priv->read_child = child_index; + } + out: +@@ -2053,7 +2054,8 @@ afr_discover_done (call_frame_t *frame, xlator_t *this) + + read_subvol = afr_data_subvol_get (local->inode, this, 0, 0, NULL); + if (read_subvol == -1) { +- gf_log (this->name, GF_LOG_WARNING, "no read subvols for %s", ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_READ_SUBVOL_ERROR, "no read subvols for %s", + local->loc.path); + + for (i = 0; i < priv->child_count; i++) { +@@ -2492,8 +2494,8 @@ __afr_fd_ctx_set (xlator_t *this, fd_t *fd) + + ret = __fd_ctx_set (fd, this, (uint64_t)(long) fd_ctx); + if (ret) +- gf_log (this->name, GF_LOG_DEBUG, +- "failed to set fd ctx (%p)", fd); ++ gf_msg_debug (this->name, 0, ++ "failed to set fd ctx (%p)", fd); + out: + return ret; + } +@@ -2623,7 +2625,8 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd) + if (fd_ctx) { + //no need to take any locks + if (!list_empty (&fd_ctx->eager_locked)) +- gf_log (this->name, GF_LOG_WARNING, "%s: Stale " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_INVALID_DATA, "%s: Stale " + "Eager-lock stubs found", + uuid_utoa (fd->inode->gfid)); + +@@ -3048,7 +3051,9 @@ afr_unlock_partial_inodelk_cbk (call_frame_t *frame, void *cookie, + + if (op_ret < 0 && op_errno != ENOTCONN) { + loc_gfid (&local->loc, gfid); +- gf_log (this->name, GF_LOG_ERROR, "%s: Failed to unlock %s " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INODE_UNLOCK_FAIL, ++ "%s: Failed to unlock %s " + "with lk_owner: %s (%s)", uuid_utoa (gfid), + priv->children[child_index]->name, + lkowner_utoa (&frame->root->lk_owner), +@@ -4122,7 +4127,8 @@ afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno) + sizeof (*local->child_up) * priv->child_count); + local->call_count = AFR_COUNT (local->child_up, priv->child_count); + if (local->call_count == 0) { +- gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up"); ++ gf_msg (THIS->name, GF_LOG_INFO, 0, ++ AFR_MSG_ALL_SUBVOLS_DOWN, "no subvolumes up"); + if (op_errno) + *op_errno = ENOTCONN; + goto out; +@@ -4680,20 +4686,23 @@ afr_set_heal_info (char *status) + if (!strcmp (status, "heal")) { + ret = dict_set_str (dict, "heal-info", "heal"); + if (ret) +- gf_log ("", GF_LOG_WARNING, +- "Failed to set heal-info key to" ++ gf_msg ("", GF_LOG_WARNING, -ret, ++ AFR_MSG_DICT_SET_FAILED, ++ "Failed to set heal-info key to " + "heal"); + } else if (!strcmp (status, "split-brain")) { + ret = dict_set_str (dict, "heal-info", "split-brain"); + if (ret) +- gf_log ("", GF_LOG_WARNING, +- "Failed to set heal-info key to" ++ gf_msg ("", GF_LOG_WARNING, -ret, ++ AFR_MSG_DICT_SET_FAILED, ++ "Failed to set heal-info key to " + "split-brain"); + } else if (!strcmp (status, "possibly-healing")) { + ret = dict_set_str (dict, "heal-info", "possibly-healing"); + if (ret) +- gf_log ("", GF_LOG_WARNING, +- "Failed to set heal-info key to" ++ gf_msg ("", GF_LOG_WARNING, -ret, ++ AFR_MSG_DICT_SET_FAILED, ++ "Failed to set heal-info key to " + "possibly-healing"); + } + out: +@@ -4932,7 +4941,8 @@ afr_heal_splitbrain_file(call_frame_t *frame, xlator_t *this, loc_t *loc) + ret = dict_set_str (dict, "sh-fail-msg", + "File not in split-brain"); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "Failed to set sh-fail-msg in dict"); + ret = 0; + goto out; +diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c +index 7fed62a..1ebe5e5 100644 +--- a/xlators/cluster/afr/src/afr-inode-read.c ++++ b/xlators/cluster/afr/src/afr-inode-read.c +@@ -38,6 +38,7 @@ + #include "quota-common-utils.h" + + #include "afr-transaction.h" ++#include "afr-messages.h" + + /* + * Quota size xattrs are not maintained by afr. There is a +@@ -594,8 +595,6 @@ unlock: + if (ret) { + op_ret = -1; + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, +- "Error serializing dictionary"); + goto unwind; + } + if (serz_len == -1) +@@ -606,7 +605,8 @@ unlock: + if (ret) { + op_ret = -1; + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, AFR_MSG_DICT_SET_FAILED, + "Error setting dictionary"); + goto unwind; + } +@@ -682,8 +682,6 @@ unlock: + if (ret) { + op_ret = -1; + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, +- "Error serializing dictionary"); + goto unwind; + } + if (serz_len == -1) +@@ -694,7 +692,8 @@ unlock: + if (ret) { + op_ret = -1; + op_errno = ENOMEM; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOMEM, AFR_MSG_DICT_SET_FAILED, + "Error setting dictionary"); + goto unwind; + } +@@ -1047,7 +1046,8 @@ afr_fgetxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, + int32_t tlen = 0; + + if (!frame || !frame->local || !this) { +- gf_log ("", GF_LOG_ERROR, "possible NULL deref"); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_ARG, "possible NULL deref"); + goto out; + } + +@@ -1086,7 +1086,8 @@ afr_fgetxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, + ret = dict_set_dynstr (local->dict, + xattr_cky, xattr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, + "Cannot set xattr cookie key"); + goto unlock; + } +@@ -1127,8 +1128,6 @@ unlock: + + strlen (xattr_serz), + &tlen, ' '); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Error serializing" +- " dictionary"); + goto unwind; + } + +@@ -1139,8 +1138,9 @@ unlock: + ret = dict_set_dynstr (nxattr, local->cont.getxattr.name, + xattr_serz); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Cannot set pathinfo" +- " key in dict"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Cannot set pathinfo key in dict"); + + unwind: + AFR_STACK_UNWIND (fgetxattr, frame, local->op_ret, +@@ -1171,7 +1171,8 @@ afr_getxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, + int32_t tlen = 0; + + if (!frame || !frame->local || !this) { +- gf_log ("", GF_LOG_ERROR, "possible NULL deref"); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_ARG, "possible NULL deref"); + goto out; + } + +@@ -1210,8 +1211,11 @@ afr_getxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, + ret = dict_set_dynstr (local->dict, + xattr_cky, xattr); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Cannot set xattr cookie key"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, ++ AFR_MSG_DICT_SET_FAILED, ++ "Cannot set xattr " ++ "cookie key"); + goto unlock; + } + +@@ -1248,8 +1252,6 @@ unlock: + xattr_serz + strlen (xattr_serz), + &tlen, ' '); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Error serializing" +- " dictionary"); + goto unwind; + } + +@@ -1260,8 +1262,9 @@ unlock: + ret = dict_set_dynstr (nxattr, local->cont.getxattr.name, + xattr_serz); + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Cannot set pathinfo" +- " key in dict"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Cannot set pathinfo key in dict"); + + unwind: + AFR_STACK_UNWIND (getxattr, frame, local->op_ret, +@@ -1295,7 +1298,8 @@ afr_common_getxattr_stime_cbk (call_frame_t *frame, void *cookie, + int32_t callcnt = 0; + + if (!frame || !frame->local || !this) { +- gf_log ("", GF_LOG_ERROR, "possible NULL deref"); ++ gf_msg ("", GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_ARG, "possible NULL deref"); + goto out; + } + +@@ -1465,9 +1469,6 @@ afr_getxattr (call_frame_t *frame, xlator_t *this, + + if (!strncmp (name, AFR_XATTR_PREFIX, + strlen (AFR_XATTR_PREFIX))) { +- gf_log (this->name, GF_LOG_INFO, +- "%s: no data present for key %s", +- loc->path, name); + op_errno = ENODATA; + goto out; + } +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index 8800b81..be83781 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -1186,7 +1186,8 @@ afr_split_brain_resolve_do (call_frame_t *frame, xlator_t *this, loc_t *loc, + */ + ret = afr_inode_split_brain_choice_set (loc->inode, this, -1); + if (ret) +- gf_log (this->name, GF_LOG_WARNING, "Failed to set" ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR, "Failed to set" + "split-brain choice to -1"); + afr_heal_splitbrain_file (frame, this, loc); + ret = 0; +@@ -1211,7 +1212,8 @@ afr_get_split_brain_child_index (xlator_t *this, void *value, size_t len) + spb_child_index = afr_get_child_index_from_name (this, + spb_child_str); + if (spb_child_index < 0) { +- gf_log (this->name, GF_LOG_ERROR, "Invalid subvol: %s", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, "Invalid subvol: %s", + spb_child_str); + } + return spb_child_index; +@@ -1234,7 +1236,9 @@ afr_can_set_split_brain_choice (void *opaque) + &data->d_spb, &data->m_spb); + + if (ret) +- gf_log (this->name, GF_LOG_ERROR, "Failed to determine if %s" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR, ++ "Failed to determine if %s" + " is in split-brain. " + "Aborting split-brain-choice set.", + uuid_utoa (loc->gfid)); +@@ -1292,7 +1296,9 @@ afr_handle_split_brain_commands (xlator_t *this, call_frame_t *frame, + afr_can_set_split_brain_choice, + afr_set_split_brain_choice, NULL, data); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Failed to create" ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR, ++ "Failed to create" + " synctask. Aborting split-brain choice set" + " for %s", loc->name); + ret = 1; +diff --git a/xlators/cluster/afr/src/afr-lk-common.c b/xlators/cluster/afr/src/afr-lk-common.c +index dc4dfbc..8175a21 100644 +--- a/xlators/cluster/afr/src/afr-lk-common.c ++++ b/xlators/cluster/afr/src/afr-lk-common.c +@@ -14,6 +14,7 @@ + + #include "afr.h" + #include "afr-transaction.h" ++#include "afr-messages.h" + + #include + +@@ -111,9 +112,9 @@ afr_set_lock_number (call_frame_t *frame, xlator_t *this) + void + afr_set_lk_owner (call_frame_t *frame, xlator_t *this, void *lk_owner) + { +- gf_log (this->name, GF_LOG_TRACE, +- "Setting lk-owner=%llu", +- (unsigned long long) (unsigned long)lk_owner); ++ gf_msg_trace (this->name, 0, ++ "Setting lk-owner=%llu", ++ (unsigned long long) (unsigned long)lk_owner); + + set_lk_owner_from_ptr (&frame->root->lk_owner, lk_owner); + } +@@ -308,7 +309,7 @@ afr_trace_inodelk_out (call_frame_t *frame, xlator_t *this, + + afr_print_verdict (op_ret, op_errno, verdict); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_LOCK_INFO, + "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}", + lock_call_type_str, + lk_op_type == AFR_LOCK_OP ? "LOCK REPLY" : "UNLOCK REPLY", +@@ -338,7 +339,7 @@ afr_trace_inodelk_in (call_frame_t *frame, xlator_t *this, + + afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_LOCK_INFO, + "[%s %s] Lock={%s} Lockee={%s} Number={%llu}", + lock_call_type_str, + lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST" : "UNLOCK REQUEST", +@@ -379,7 +380,7 @@ afr_trace_entrylk_in (call_frame_t *frame, xlator_t *this, + + afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_LOCK_INFO, + "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}", + lock_call_type_str, + lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST" : "UNLOCK REQUEST", +@@ -423,7 +424,7 @@ afr_trace_entrylk_out (call_frame_t *frame, xlator_t *this, + + afr_print_verdict (op_ret, op_errno, verdict); + +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_LOCK_INFO, + "[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}", + lock_call_type_str, + lk_op_type == AFR_LOCK_OP ? "LOCK REPLY" : "UNLOCK REPLY", +@@ -443,20 +444,20 @@ transaction_lk_op (afr_local_t *local) + int_lock = &local->internal_lock; + + if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK) { +- gf_log (THIS->name, GF_LOG_DEBUG, +- "lk op is for a transaction"); ++ gf_msg_debug (THIS->name, 0, ++ "lk op is for a transaction"); + ret = 1; + } + else if (int_lock->transaction_lk_type == AFR_SELFHEAL_LK) { +- gf_log (THIS->name, GF_LOG_DEBUG, +- "lk op is for a self heal"); ++ gf_msg_debug (THIS->name, 0, ++ "lk op is for a self heal"); + + ret = 0; + } + + if (ret == -1) +- gf_log (THIS->name, GF_LOG_DEBUG, +- "lk op is not set"); ++ gf_msg_debug (THIS->name, 0, ++ "lk op is not set"); + + return ret; + +@@ -626,8 +627,9 @@ afr_unlock_common_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + UNLOCK (&frame->lock); + + if (call_count == 0) { +- gf_log (this->name, GF_LOG_TRACE, +- "All internal locks unlocked"); ++ gf_msg_trace (this->name, 0, ++ "All internal locks unlocked"); ++ + int_lock->lock_cbk (frame, this); + } + +@@ -708,8 +710,9 @@ afr_unlock_inodelk (call_frame_t *frame, xlator_t *this) + int_lock->lk_call_count = call_count; + + if (!call_count) { +- gf_log (this->name, GF_LOG_TRACE, +- "No internal locks unlocked"); ++ gf_msg_trace (this->name, 0, ++ "No internal locks unlocked"); ++ + int_lock->lock_cbk (frame, this); + goto out; + } +@@ -842,8 +845,8 @@ afr_unlock_entrylk (call_frame_t *frame, xlator_t *this) + int_lock->lk_call_count = call_count; + + if (!call_count){ +- gf_log (this->name, GF_LOG_TRACE, +- "No internal locks unlocked"); ++ gf_msg_trace (this->name, 0, ++ "No internal locks unlocked"); + int_lock->lock_cbk (frame, this); + goto out; + } +@@ -899,7 +902,8 @@ afr_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (op_ret == -1) { + if (op_errno == ENOSYS) { + /* return ENOTSUP */ +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOSYS, ++ AFR_MSG_LOCK_XLATOR_NOT_LOADED, + "subvolume does not support locking. " + "please load features/locks xlator on server"); + local->op_ret = op_ret; +@@ -1058,7 +1062,8 @@ afr_lock_blocking (call_frame_t *frame, xlator_t *this, int cookie) + ret = fd_ctx_get (local->fd, this, &ctx); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_FD_CTX_GET_FAILED, + "unable to get fd ctx for fd=%p", + local->fd); + +@@ -1076,7 +1081,8 @@ afr_lock_blocking (call_frame_t *frame, xlator_t *this, int cookie) + if (int_lock->lk_expected_count == int_lock->lk_attempted_count) { + if ((is_entrylk && int_lock->entrylk_lock_count == 0) || + (!is_entrylk && int_lock->lock_count == 0)) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_BLOCKING_LKS_FAILED, + "unable to lock on even one child"); + + local->op_ret = -1; +@@ -1093,8 +1099,8 @@ afr_lock_blocking (call_frame_t *frame, xlator_t *this, int cookie) + if (int_lock->lk_expected_count == int_lock->lk_attempted_count) { + /* we're done locking */ + +- gf_log (this->name, GF_LOG_DEBUG, +- "we're done locking"); ++ gf_msg_debug (this->name, 0, ++ "we're done locking"); + + afr_copy_locked_nodes (frame, this); + +@@ -1246,9 +1252,11 @@ afr_nonblocking_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (op_ret < 0 ) { + if (op_errno == ENOSYS) { + /* return ENOTSUP */ +- gf_log (this->name, GF_LOG_ERROR, +- "subvolume does not support locking. " +- "please load features/locks xlator on server"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ ENOSYS, AFR_MSG_LOCK_XLATOR_NOT_LOADED, ++ "subvolume does not support " ++ "locking. please load features/locks" ++ " xlator on server"); + local->op_ret = op_ret; + int_lock->lock_op_ret = op_ret; + +@@ -1267,22 +1275,23 @@ afr_nonblocking_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + UNLOCK (&frame->lock); + + if (call_count == 0) { +- gf_log (this->name, GF_LOG_TRACE, +- "Last locking reply received"); ++ gf_msg_trace (this->name, 0, ++ "Last locking reply received"); + /* all locks successful. Proceed to call FOP */ + if (int_lock->entrylk_lock_count == + int_lock->lk_expected_count) { +- gf_log (this->name, GF_LOG_TRACE, +- "All servers locked. Calling the cbk"); ++ gf_msg_trace (this->name, 0, ++ "All servers locked. Calling the cbk"); + int_lock->lock_op_ret = 0; + int_lock->lock_cbk (frame, this); + } + /* Not all locks were successful. Unlock and try locking + again, this time with serially blocking locks */ + else { +- gf_log (this->name, GF_LOG_TRACE, +- "%d servers locked. Trying again with blocking calls", +- int_lock->lock_count); ++ gf_msg_trace (this->name, 0, ++ "%d servers locked. Trying again " ++ "with blocking calls", ++ int_lock->lock_count); + + afr_unlock(frame, this); + } +@@ -1314,7 +1323,8 @@ afr_nonblocking_entrylk (call_frame_t *frame, xlator_t *this) + if (local->fd) { + fd_ctx = afr_fd_ctx_get (local->fd, this); + if (!fd_ctx) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_FD_CTX_GET_FAILED, + "unable to get fd ctx for fd=%p", + local->fd); + +@@ -1332,7 +1342,8 @@ afr_nonblocking_entrylk (call_frame_t *frame, xlator_t *this) + int_lock->lk_expected_count = call_count; + + if (!call_count) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_INFO_COMMON, + "fd not open on any subvolumes. aborting."); + afr_unlock (frame, this); + goto out; +@@ -1421,10 +1432,11 @@ afr_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (op_ret < 0) { + if (op_errno == ENOSYS) { + /* return ENOTSUP */ +- gf_log (this->name, GF_LOG_ERROR, +- "subvolume does not support locking. " +- "please load features/locks xlator on " +- "server"); ++ gf_msg (this->name, GF_LOG_ERROR, ENOSYS, ++ AFR_MSG_LOCK_XLATOR_NOT_LOADED, ++ "subvolume does not support " ++ "locking. please load features/locks" ++ " xlator on server"); + local->op_ret = op_ret; + int_lock->lock_op_ret = op_ret; + int_lock->lock_op_errno = op_errno; +@@ -1454,21 +1466,22 @@ afr_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + UNLOCK (&frame->lock); + + if (call_count == 0) { +- gf_log (this->name, GF_LOG_TRACE, +- "Last inode locking reply received"); ++ gf_msg_trace (this->name, 0, ++ "Last inode locking reply received"); + /* all locks successful. Proceed to call FOP */ + if (inodelk->lock_count == int_lock->lk_expected_count) { +- gf_log (this->name, GF_LOG_TRACE, +- "All servers locked. Calling the cbk"); ++ gf_msg_trace (this->name, 0, ++ "All servers locked. Calling the cbk"); + int_lock->lock_op_ret = 0; + int_lock->lock_cbk (frame, this); + } + /* Not all locks were successful. Unlock and try locking + again, this time with serially blocking locks */ + else { +- gf_log (this->name, GF_LOG_TRACE, +- "%d servers locked. Trying again with blocking calls", +- int_lock->lock_count); ++ gf_msg_trace (this->name, 0, ++ "%d servers locked. " ++ "Trying again with blocking calls", ++ int_lock->lock_count); + + afr_unlock(frame, this); + } +@@ -1510,7 +1523,8 @@ afr_nonblocking_inodelk (call_frame_t *frame, xlator_t *this) + if (local->fd) { + fd_ctx = afr_fd_ctx_get (local->fd, this); + if (!fd_ctx) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_FD_CTX_GET_FAILED, + "unable to get fd ctx for fd=%p", + local->fd); + +@@ -1529,8 +1543,9 @@ afr_nonblocking_inodelk (call_frame_t *frame, xlator_t *this) + int_lock->lk_expected_count = call_count; + + if (!call_count) { +- gf_log (this->name, GF_LOG_INFO, +- "fd not open on any subvolumes. aborting."); ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_ALL_SUBVOLS_DOWN, ++ "All bricks are down, aborting."); + afr_unlock (frame, this); + goto out; + } +diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h +index 66b8ed1..e4bf85b 100644 +--- a/xlators/cluster/afr/src/afr-messages.h ++++ b/xlators/cluster/afr/src/afr-messages.h +@@ -1,5 +1,5 @@ + /* +- Copyright (c) 2014 Red Hat, Inc. ++ Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser +@@ -44,9 +44,9 @@ + * holes. + */ + +-#define GLFS_COMP_BASE_AFR GLFS_MSGID_COMP_AFR +-#define GLFS_NUM_MESSAGES 11 +-#define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1) ++#define GLFS_COMP_BASE_AFR GLFS_MSGID_COMP_AFR ++#define GLFS_NUM_MESSAGES 37 ++#define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1) + + #define glfs_msg_start_x GLFS_COMP_BASE_AFR, "Invalid: Start of messages" + +@@ -141,7 +141,6 @@ + */ + #define AFR_MSG_INODE_UNLOCK_FAIL (GLFS_COMP_BASE_AFR + 10) + +- + /*! + * @messageid 108011 + * @diagnosis Setting of pending xattrs succeeded/failed during replace-brick +@@ -151,7 +150,189 @@ + */ + #define AFR_MSG_REPLACE_BRICK_STATUS (GLFS_COMP_BASE_AFR + 11) + ++/*! ++ * @messageid 108012 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_GFID_NULL (GLFS_COMP_BASE_AFR + 12) + +-#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" ++/*! ++ * @messageid 108013 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_FD_CREATE_FAILED (GLFS_COMP_BASE_AFR + 13) ++ ++/*! ++ * @messageid 108014 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_DICT_SET_FAILED (GLFS_COMP_BASE_AFR + 14) ++ ++/*! ++ * @messageid 108015 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_EXPUNGING_FILE_OR_DIR (GLFS_COMP_BASE_AFR + 15) ++ ++/*! ++ * @messageid 108016 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_MIGRATION_IN_PROGRESS (GLFS_COMP_BASE_AFR + 16) ++ ++/*! ++ * @messageid 108017 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_CHILD_MISCONFIGURED (GLFS_COMP_BASE_AFR + 17) ++ ++/*! ++ * @messageid 108018 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_VOL_MISCONFIGURED (GLFS_COMP_BASE_AFR + 18) + ++/*! ++ * @messageid 108019 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_BLOCKING_LKS_FAILED (GLFS_COMP_BASE_AFR + 19) ++ ++/*! ++ * @messageid 108020 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INVALID_FD (GLFS_COMP_BASE_AFR + 20) ++ ++/*! ++ * @messageid 108021 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_LOCK_INFO (GLFS_COMP_BASE_AFR + 21) ++ ++/*! ++ * @messageid 108022 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_LOCK_XLATOR_NOT_LOADED (GLFS_COMP_BASE_AFR + 22) ++ ++/*! ++ * @messageid 108023 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_FD_CTX_GET_FAILED (GLFS_COMP_BASE_AFR + 23) ++ ++/*! ++ * @messageid 108024 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INVALID_SUBVOL (GLFS_COMP_BASE_AFR + 24) ++ ++/*! ++ * @messageid 108025 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_PUMP_XLATOR_ERROR (GLFS_COMP_BASE_AFR + 25) ++ ++/*! ++ * @messageid 108026 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_SELF_HEAL_INFO (GLFS_COMP_BASE_AFR + 26) ++ ++/*! ++ * @messageid 108027 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_READ_SUBVOL_ERROR (GLFS_COMP_BASE_AFR + 27) ++ ++/*! ++ * @messageid 108028 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_DICT_GET_FAILED (GLFS_COMP_BASE_AFR + 28) ++ ++ ++/*! ++ * @messageid 108029 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INFO_COMMON (GLFS_COMP_BASE_AFR + 29) ++ ++/*! ++ * @messageid 108030 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR (GLFS_COMP_BASE_AFR + 30) ++ ++/*! ++ * @messageid 108031 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_LOCAL_CHILD (GLFS_COMP_BASE_AFR + 31) ++ ++/*! ++ * @messageid 108032 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INVALID_DATA (GLFS_COMP_BASE_AFR + 32) ++ ++/*! ++ * @messageid 108033 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INVALID_ARG (GLFS_COMP_BASE_AFR + 33) ++ ++/*! ++ * @messageid 108034 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_INDEX_DIR_GET_FAILED (GLFS_COMP_BASE_AFR + 34) ++ ++/*! ++ * @messageid 108035 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_FSYNC_FAILED (GLFS_COMP_BASE_AFR + 35) ++ ++/*! ++ * @messageid 108036 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_FAVORITE_CHILD (GLFS_COMP_BASE_AFR + 36) ++/*! ++ * @messageid 108037 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_SELF_HEAL_FAILED (GLFS_COMP_BASE_AFR + 37) ++ ++ ++ ++#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_AFR_MESSAGES_H_ */ +diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c +index f1da8b0..9c90544 100644 +--- a/xlators/cluster/afr/src/afr-open.c ++++ b/xlators/cluster/afr/src/afr-open.c +@@ -182,9 +182,9 @@ afr_openfd_fix_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + local = frame->local; + + if (op_ret >= 0) { +- gf_log (this->name, GF_LOG_DEBUG, "fd for %s opened " +- "successfully on subvolume %s", local->loc.path, +- priv->children[child_index]->name); ++ gf_msg_debug (this->name, 0, "fd for %s opened " ++ "successfully on subvolume %s", local->loc.path, ++ priv->children[child_index]->name); + } else { + gf_msg (this->name, fop_log_level (GF_FOP_OPEN, op_errno), + op_errno, AFR_MSG_OPEN_FAIL, "Failed to open %s on " +@@ -291,17 +291,17 @@ afr_fix_open (fd_t *fd, xlator_t *this) + + local->call_count = call_count; + +- gf_log (this->name, GF_LOG_DEBUG, "need open count: %d", +- call_count); ++ gf_msg_debug (this->name, 0, "need open count: %d", ++ call_count); + + for (i = 0; i < priv->child_count; i++) { + if (!need_open[i]) + continue; + + if (IA_IFDIR == fd->inode->ia_type) { +- gf_log (this->name, GF_LOG_DEBUG, +- "opening fd for dir %s on subvolume %s", +- local->loc.path, priv->children[i]->name); ++ gf_msg_debug (this->name, 0, ++ "opening fd for dir %s on subvolume %s", ++ local->loc.path, priv->children[i]->name); + + STACK_WIND_COOKIE (frame, afr_openfd_fix_open_cbk, + (void*) (long) i, +@@ -310,9 +310,9 @@ afr_fix_open (fd_t *fd, xlator_t *this) + &local->loc, local->fd, + NULL); + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "opening fd for file %s on subvolume %s", +- local->loc.path, priv->children[i]->name); ++ gf_msg_debug (this->name, 0, ++ "opening fd for file %s on subvolume %s", ++ local->loc.path, priv->children[i]->name); + + STACK_WIND_COOKIE (frame, afr_openfd_fix_open_cbk, + (void *)(long) i, +diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c +index 6e54549..a998cce 100644 +--- a/xlators/cluster/afr/src/afr-read-txn.c ++++ b/xlators/cluster/afr/src/afr-read-txn.c +@@ -10,6 +10,7 @@ + + #include "afr.h" + #include "afr-transaction.h" ++#include "afr-messages.h" + + int + afr_read_txn_next_subvol (call_frame_t *frame, xlator_t *this) +@@ -216,9 +217,9 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + /* very first transaction on this inode */ + goto refresh; + +- gf_log (this->name, GF_LOG_DEBUG, "%s: generation now vs cached: %d, " +- "%d", uuid_utoa (inode->gfid), local->event_generation, +- event_generation); ++ gf_msg_debug (this->name, 0, "%s: generation now vs cached: %d, " ++ "%d", uuid_utoa (inode->gfid), local->event_generation, ++ event_generation); + if (local->event_generation != event_generation) + /* servers have disconnected / reconnected, and possibly + rebooted, very likely changing the state of freshness +@@ -229,7 +230,7 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + local->readable, NULL); + + if (read_subvol < 0 || read_subvol > priv->child_count) { +- gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_SPLIT_BRAIN, ++ gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_SPLIT_BRAIN, + "Unreadable subvolume %d found with event generation " + "%d for gfid %s. (Possible split-brain)", + read_subvol, event_generation, uuid_utoa(inode->gfid)); +@@ -238,7 +239,8 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + + if (!local->child_up[read_subvol]) { + /* should never happen, just in case */ +- gf_log (this->name, GF_LOG_WARNING, "subvolume %d is the " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_READ_SUBVOL_ERROR, "subvolume %d is the " + "read subvolume in this generation, but is not up", + read_subvol); + goto refresh; +diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c +index 1e46226..c9010df 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-common.c ++++ b/xlators/cluster/afr/src/afr-self-heal-common.c +@@ -18,6 +18,7 @@ + #include "afr-self-heal.h" + #include "byte-order.h" + #include "protocol-common.h" ++#include "afr-messages.h" + + int + afr_selfheal_post_op_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +@@ -167,8 +168,6 @@ afr_selfheal_undo_pending (call_frame_t *frame, xlator_t *this, inode_t *inode, + xattr = afr_selfheal_output_xattr (this, type, output_dirty, + output_matrix, i); + if (!xattr) { +- gf_log (this->name, GF_LOG_ERROR, +- "unable to allocate xdata for subvol %d", i); + continue; + } + +@@ -646,7 +645,8 @@ afr_log_selfheal (uuid_t gfid, xlator_t *this, int ret, char *type, + loglevel = GF_LOG_INFO; + } + +- gf_log (this->name, loglevel, "%s %s selfheal on %s. " ++ gf_msg (this->name, loglevel, 0, ++ AFR_MSG_SELF_HEAL_INFO, "%s %s selfheal on %s. " + "source=%d sinks=%s", status, type, uuid_utoa (gfid), + source, sinks_str); + } +@@ -1124,7 +1124,7 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, + } + + if (!IA_EQUAL (first, replies[i].poststat, type)) { +- gf_msg (this->name, GF_LOG_ERROR, 0, ++ gf_msg (this->name, GF_LOG_ERROR, 0, + AFR_MSG_SPLIT_BRAIN, + "TYPE mismatch %d vs %d on %s for gfid:%s", + (int) first.ia_type, +@@ -1136,36 +1136,40 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, + } + + if (!IA_EQUAL (first, replies[i].poststat, uid)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "UID mismatch %d vs %d on %s for gfid:%s", +- (int) first.ia_uid, +- (int) replies[i].poststat.ia_uid, +- priv->children[i]->name, +- uuid_utoa (replies[i].poststat.ia_gfid)); ++ gf_msg_debug (this->name, 0, ++ "UID mismatch " ++ "%d vs %d on %s for gfid:%s", ++ (int) first.ia_uid, ++ (int) replies[i].poststat.ia_uid, ++ priv->children[i]->name, ++ uuid_utoa (replies[i].poststat.ia_gfid)); + + if (metadata_selfheal) + *metadata_selfheal = _gf_true; + } + + if (!IA_EQUAL (first, replies[i].poststat, gid)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "GID mismatch %d vs %d on %s for gfid:%s", +- (int) first.ia_uid, +- (int) replies[i].poststat.ia_uid, +- priv->children[i]->name, +- uuid_utoa (replies[i].poststat.ia_gfid)); ++ gf_msg_debug (this->name, 0, ++ "GID mismatch " ++ "%d vs %d on %s for gfid:%s", ++ (int) first.ia_uid, ++ (int) replies[i].poststat.ia_uid, ++ priv->children[i]->name, ++ uuid_utoa (replies[i].poststat.ia_gfid)); + + if (metadata_selfheal) + *metadata_selfheal = _gf_true; + } + + if (!IA_EQUAL (first, replies[i].poststat, prot)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "MODE mismatch %d vs %d on %s for gfid:%s", +- (int) st_mode_from_ia (first.ia_prot, 0), +- (int) st_mode_from_ia (replies[i].poststat.ia_prot, 0), +- priv->children[i]->name, +- uuid_utoa (replies[i].poststat.ia_gfid)); ++ gf_msg_debug (this->name, 0, ++ "MODE mismatch " ++ "%d vs %d on %s for gfid:%s", ++ (int) st_mode_from_ia (first.ia_prot, 0), ++ (int) st_mode_from_ia ++ (replies[i].poststat.ia_prot, 0), ++ priv->children[i]->name, ++ uuid_utoa (replies[i].poststat.ia_gfid)); + + if (metadata_selfheal) + *metadata_selfheal = _gf_true; +@@ -1173,12 +1177,13 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, + + if (IA_ISREG(first.ia_type) && + !IA_EQUAL (first, replies[i].poststat, size)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "SIZE mismatch %lld vs %lld on %s for gfid:%s", +- (long long) first.ia_size, +- (long long) replies[i].poststat.ia_size, +- priv->children[i]->name, +- uuid_utoa (replies[i].poststat.ia_gfid)); ++ gf_msg_debug (this->name, 0, ++ "SIZE mismatch " ++ "%lld vs %lld on %s for gfid:%s", ++ (long long) first.ia_size, ++ (long long) replies[i].poststat.ia_size, ++ priv->children[i]->name, ++ uuid_utoa (replies[i].poststat.ia_gfid)); + + if (data_selfheal) + *data_selfheal = _gf_true; +diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c +index 4ab6f00..f4aae3f 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-data.c ++++ b/xlators/cluster/afr/src/afr-self-heal-data.c +@@ -18,6 +18,7 @@ + #include "afr-self-heal.h" + #include "byte-order.h" + #include "protocol-common.h" ++#include "afr-messages.h" + + enum { + AFR_SELFHEAL_DATA_FULL = 0, +@@ -660,10 +661,12 @@ __afr_selfheal_data (call_frame_t *frame, xlator_t *this, fd_t *fd, + data_lock); + { + if (ret < AFR_SH_MIN_PARTICIPANTS) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "self-heal as only %d number of subvolumes " +- "could be locked", uuid_utoa (fd->inode->gfid), +- ret); ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "self-heal as only %d number " ++ "of subvolumes " ++ "could be locked", ++ uuid_utoa (fd->inode->gfid), ++ ret); + ret = -ENOTCONN; + goto unlock; + } +@@ -778,8 +781,8 @@ afr_selfheal_data (call_frame_t *frame, xlator_t *this, inode_t *inode) + + fd = afr_selfheal_data_open (this, inode); + if (!fd) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Failed to open", +- uuid_utoa (inode->gfid)); ++ gf_msg_debug (this->name, 0, "%s: Failed to open", ++ uuid_utoa (inode->gfid)); + return -EIO; + } + +@@ -789,9 +792,10 @@ afr_selfheal_data (call_frame_t *frame, xlator_t *this, inode_t *inode) + locked_on); + { + if (ret < AFR_SH_MIN_PARTICIPANTS) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "self-heal as only %d number of subvolumes " +- "could be locked", uuid_utoa (fd->inode->gfid), ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "self-heal as only %d number of " ++ "subvolumes could be locked", ++ uuid_utoa (fd->inode->gfid), + ret); + /* Either less than two subvols available, or another + selfheal (from another server) is in progress. Skip +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index 12da920..13a280f 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -18,6 +18,7 @@ + #include "afr-self-heal.h" + #include "byte-order.h" + #include "afr-transaction.h" ++#include "afr-messages.h" + + /* Max file name length is 255 this filename is of length 256. No file with + * this name can ever come, entry-lock with this name is going to prevent +@@ -51,7 +52,8 @@ afr_selfheal_entry_delete (xlator_t *this, inode_t *dir, const char *name, + if (replies[child].valid && replies[child].op_ret == 0) { + switch (replies[child].poststat.ia_type) { + case IA_IFDIR: +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_EXPUNGING_FILE_OR_DIR, + "expunging dir %s/%s (%s) on %s", + uuid_utoa (dir->gfid), name, + uuid_utoa_r (replies[child].poststat.ia_gfid, g), +@@ -59,7 +61,8 @@ afr_selfheal_entry_delete (xlator_t *this, inode_t *dir, const char *name, + ret = syncop_rmdir (subvol, &loc, 1, NULL, NULL); + break; + default: +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_EXPUNGING_FILE_OR_DIR, + "expunging file %s/%s (%s) on %s", + uuid_utoa (dir->gfid), name, + uuid_utoa_r (replies[child].poststat.ia_gfid, g), +@@ -239,7 +242,8 @@ afr_selfheal_detect_gfid_and_type_mismatch (xlator_t *this, + + if (gf_uuid_compare (replies[src_idx].poststat.ia_gfid, + replies[i].poststat.ia_gfid)) { +- gf_log (this->name, GF_LOG_ERROR, "Gfid mismatch " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SPLIT_BRAIN, "Gfid mismatch " + "detected for <%s/%s>, %s on %s and %s on %s. " + "Skipping conservative merge on the file.", + uuid_utoa (pargfid), bname, +@@ -252,7 +256,8 @@ afr_selfheal_detect_gfid_and_type_mismatch (xlator_t *this, + + if ((replies[src_idx].poststat.ia_type) != + (replies[i].poststat.ia_type)) { +- gf_log (this->name, GF_LOG_ERROR, "Type mismatch " ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SPLIT_BRAIN, "Type mismatch " + "detected for <%s/%s>, %d on %s and %d on %s. " + "Skipping conservative merge on the file.", + uuid_utoa (pargfid), bname, +@@ -462,10 +467,11 @@ afr_selfheal_entry_dirent (call_frame_t *frame, xlator_t *this, + locked_on); + { + if (ret < AFR_SH_MIN_PARTICIPANTS) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "entry self-heal as only %d sub-volumes could " +- "be locked in %s domain", +- uuid_utoa (fd->inode->gfid), ret, this->name); ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "entry self-heal as only %d sub-volumes " ++ " could be locked in %s domain", ++ uuid_utoa (fd->inode->gfid), ++ ret, this->name); + ret = -ENOTCONN; + goto unlock; + } +@@ -578,7 +584,8 @@ afr_selfheal_entry_do (call_frame_t *frame, xlator_t *this, fd_t *fd, + + priv = this->private; + +- gf_log (this->name, GF_LOG_INFO, "performing entry selfheal on %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_SELF_HEAL_INFO, "performing entry selfheal on %s", + uuid_utoa (fd->inode->gfid)); + + for (i = 0; i < priv->child_count; i++) { +@@ -628,11 +635,11 @@ __afr_selfheal_entry (call_frame_t *frame, xlator_t *this, fd_t *fd, + data_lock); + { + if (ret < AFR_SH_MIN_PARTICIPANTS) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "entry self-heal as only %d sub-volumes could " +- "be locked in %s domain", +- uuid_utoa (fd->inode->gfid), ret, +- this->name); ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "entry self-heal as only %d sub-volumes could " ++ "be locked in %s domain", ++ uuid_utoa (fd->inode->gfid), ret, ++ this->name); + ret = -ENOTCONN; + goto unlock; + } +@@ -671,12 +678,13 @@ unlock: + postop_lock); + { + if (AFR_CMP (data_lock, postop_lock, priv->child_count) != 0) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "post-op after entry self-heal as %d " +- "sub-volumes, as opposed to %d, could be locked" +- " in %s domain", uuid_utoa (fd->inode->gfid), +- ret, AFR_COUNT (data_lock, priv->child_count), +- this->name); ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "post-op after entry self-heal as %d " ++ "sub-volumes, as opposed to %d, " ++ "could be locked in %s domain", ++ uuid_utoa (fd->inode->gfid), ++ ret, AFR_COUNT (data_lock, ++ priv->child_count), this->name); + ret = -ENOTCONN; + goto postop_unlock; + } +@@ -751,11 +759,11 @@ afr_selfheal_entry (call_frame_t *frame, xlator_t *this, inode_t *inode) + locked_on); + { + if (ret < AFR_SH_MIN_PARTICIPANTS) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping " +- "entry self-heal as only %d sub-volumes could " +- "be locked in %s domain", +- uuid_utoa (fd->inode->gfid), ret, +- priv->sh_domain); ++ gf_msg_debug (this->name, 0, "%s: Skipping " ++ "entry self-heal as only %d sub-volumes could " ++ "be locked in %s domain", ++ uuid_utoa (fd->inode->gfid), ret, ++ priv->sh_domain); + /* Either less than two subvols available, or another + selfheal (from another server) is in progress. Skip + for now in any case there isn't anything to do. +@@ -768,12 +776,13 @@ afr_selfheal_entry (call_frame_t *frame, xlator_t *this, inode_t *inode) + LONG_FILENAME, long_name_locked); + { + if (ret < 1) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: Skipping" +- " entry self-heal as only %d " +- "sub-volumes could be locked in " +- "special-filename domain", +- uuid_utoa (fd->inode->gfid), +- ret); ++ gf_msg_debug (this->name, 0, "%s: Skipping" ++ " entry self-heal as only %d " ++ "sub-volumes could be " ++ "locked in special-filename " ++ "domain", ++ uuid_utoa (fd->inode->gfid), ++ ret); + ret = -ENOTCONN; + goto unlock; + } +diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c +index 11c0c9c..c4993f1 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c ++++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c +@@ -51,7 +51,8 @@ __afr_selfheal_metadata_do (call_frame_t *frame, xlator_t *this, inode_t *inode, + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + +- gf_log (this->name, GF_LOG_INFO, "performing metadata selfheal on %s", ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_SELF_HEAL_INFO, "performing metadata selfheal on %s", + uuid_utoa (inode->gfid)); + + ret = syncop_getxattr (priv->children[source], &loc, &xattr, NULL, +@@ -232,7 +233,8 @@ __afr_selfheal_metadata_finalize_source (call_frame_t *frame, xlator_t *this, + source = afr_dirtime_splitbrain_source (frame, this, + replies, locked_on); + if (source != -1) { +- gf_log (this->name, GF_LOG_NOTICE, "clear time " ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_SPLIT_BRAIN, "clear time " + "split brain on %s", + uuid_utoa (replies[source].poststat.ia_gfid)); + sources[source] = 1; +@@ -277,10 +279,11 @@ __afr_selfheal_metadata_finalize_source (call_frame_t *frame, xlator_t *this, + !IA_EQUAL (first, replies[i].poststat, uid) || + !IA_EQUAL (first, replies[i].poststat, gid) || + !IA_EQUAL (first, replies[i].poststat, prot)) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: iatt mismatch " +- "for source(%d) vs (%d)", +- uuid_utoa (replies[source].poststat.ia_gfid), +- source, i); ++ gf_msg_debug (this->name, 0, "%s: iatt mismatch " ++ "for source(%d) vs (%d)", ++ uuid_utoa ++ (replies[source].poststat.ia_gfid), ++ source, i); + sources[i] = 0; + healed_sinks[i] = 1; + } +@@ -291,10 +294,11 @@ __afr_selfheal_metadata_finalize_source (call_frame_t *frame, xlator_t *this, + continue; + if (!afr_xattrs_are_equal (replies[source].xdata, + replies[i].xdata)) { +- gf_log (this->name, GF_LOG_DEBUG, "%s: xattr mismatch " +- "for source(%d) vs (%d)", +- uuid_utoa (replies[source].poststat.ia_gfid), +- source, i); ++ gf_msg_debug (this->name, 0, "%s: xattr mismatch " ++ "for source(%d) vs (%d)", ++ uuid_utoa ++ (replies[source].poststat.ia_gfid), ++ source, i); + sources[i] = 0; + healed_sinks[i] = 1; + } +diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c +index ba9c3ee..190be64 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-name.c ++++ b/xlators/cluster/afr/src/afr-self-heal-name.c +@@ -16,6 +16,7 @@ + + #include "afr.h" + #include "afr-self-heal.h" ++#include "afr-messages.h" + + int + __afr_selfheal_assign_gfid (xlator_t *this, inode_t *parent, uuid_t pargfid, +@@ -172,20 +173,24 @@ __afr_selfheal_name_expunge (xlator_t *this, inode_t *parent, uuid_t pargfid, + + switch (replies[i].poststat.ia_type) { + case IA_IFDIR: +- gf_log (this->name, GF_LOG_WARNING, +- "expunging dir %s/%s (%s) on %s", +- uuid_utoa (pargfid), bname, +- uuid_utoa_r (replies[i].poststat.ia_gfid, g), +- priv->children[i]->name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_EXPUNGING_FILE_OR_DIR, ++ "expunging dir %s/%s (%s) on %s", ++ uuid_utoa (pargfid), bname, ++ uuid_utoa_r (replies[i].poststat.ia_gfid, g), ++ priv->children[i]->name); ++ + ret |= syncop_rmdir (priv->children[i], &loc, 1, NULL, + NULL); + break; + default: +- gf_log (this->name, GF_LOG_WARNING, +- "expunging file %s/%s (%s) on %s", +- uuid_utoa (pargfid), bname, +- uuid_utoa_r (replies[i].poststat.ia_gfid, g), +- priv->children[i]->name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_EXPUNGING_FILE_OR_DIR, ++ "expunging file %s/%s (%s) on %s", ++ uuid_utoa (pargfid), bname, ++ uuid_utoa_r (replies[i].poststat.ia_gfid, g), ++ priv->children[i]->name); ++ + ret |= syncop_unlink (priv->children[i], &loc, NULL, + NULL); + break; +@@ -294,15 +299,16 @@ afr_selfheal_name_type_mismatch_check (xlator_t *this, struct afr_reply *replies + if (sources[i] || source == -1) { + if ((sources[type_idx] || source == -1) && + (inode_type != replies[i].poststat.ia_type)) { +- gf_msg (this->name, GF_LOG_WARNING, 0, +- AFR_MSG_SPLIT_BRAIN, +- "Type mismatch for /%s: " +- "%d on %s and %d on %s", +- uuid_utoa(pargfid), bname, +- replies[i].poststat.ia_type, +- priv->children[i]->name, +- replies[type_idx].poststat.ia_type, +- priv->children[type_idx]->name); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_SPLIT_BRAIN, ++ "Type mismatch for /%s: " ++ "%d on %s and %d on %s", ++ uuid_utoa(pargfid), bname, ++ replies[i].poststat.ia_type, ++ priv->children[i]->name, ++ replies[type_idx].poststat.ia_type, ++ priv->children[type_idx]->name); ++ + return -EIO; + } + inode_type = replies[i].poststat.ia_type; +@@ -342,7 +348,7 @@ afr_selfheal_name_gfid_mismatch_check (xlator_t *this, struct afr_reply *replies + if (sources[i] || source == -1) { + if ((sources[gfid_idx_iter] || source == -1) && + gf_uuid_compare (gfid, replies[i].poststat.ia_gfid)) { +- gf_msg (this->name, GF_LOG_WARNING, 0, ++ gf_msg (this->name, GF_LOG_WARNING, 0, + AFR_MSG_SPLIT_BRAIN, + "GFID mismatch for /%s " + "%s on %s and %s on %s", +@@ -351,6 +357,7 @@ afr_selfheal_name_gfid_mismatch_check (xlator_t *this, struct afr_reply *replies + priv->children[i]->name, + uuid_utoa_r (replies[gfid_idx_iter].poststat.ia_gfid, g2), + priv->children[gfid_idx_iter]->name); ++ + return -EIO; + } + +diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c +index fe93675..7bc39a1 100644 +--- a/xlators/cluster/afr/src/afr-self-heald.c ++++ b/xlators/cluster/afr/src/afr-self-heald.c +@@ -19,6 +19,7 @@ + #include "afr-self-heald.h" + #include "protocol-common.h" + #include "syncop-utils.h" ++#include "afr-messages.h" + + #define SHD_INODE_LRU_LIMIT 2048 + #define AFR_EH_SPLIT_BRAIN_LIMIT 1024 +@@ -209,8 +210,8 @@ afr_shd_index_inode (xlator_t *this, xlator_t *subvol) + if (ret) + goto out; + +- gf_log (this->name, GF_LOG_DEBUG, "index-dir gfid for %s: %s", +- subvol->name, uuid_utoa (index_gfid)); ++ gf_msg_debug (this->name, 0, "index-dir gfid for %s: %s", ++ subvol->name, uuid_utoa (index_gfid)); + + inode = afr_shd_inode_find (this, subvol, index_gfid); + +@@ -405,8 +406,8 @@ afr_shd_index_heal (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, + if (!priv->shd.enabled) + return -EBUSY; + +- gf_log (healer->this->name, GF_LOG_DEBUG, "got entry: %s", +- entry->d_name); ++ gf_msg_debug (healer->this->name, 0, "got entry: %s", ++ entry->d_name); + + ret = gf_uuid_parse (entry->d_name, gfid); + if (ret) +@@ -440,8 +441,9 @@ afr_shd_index_sweep (struct subvol_healer *healer) + + loc.inode = afr_shd_index_inode (healer->this, subvol); + if (!loc.inode) { +- gf_log (healer->this->name, GF_LOG_WARNING, +- "unable to get index-dir on %s", subvol->name); ++ gf_msg (healer->this->name, GF_LOG_WARNING, ++ 0, AFR_MSG_INDEX_DIR_GET_FAILED, ++ "unable to get index-dir on %s", subvol->name); + return -errno; + } + +@@ -507,9 +509,9 @@ afr_shd_index_healer (void *data) + ASSERT_LOCAL(this, healer); + + do { +- gf_log (this->name, GF_LOG_DEBUG, +- "starting index sweep on subvol %s", +- afr_subvol_name (this, healer->subvol)); ++ gf_msg_debug (this->name, 0, ++ "starting index sweep on subvol %s", ++ afr_subvol_name (this, healer->subvol)); + + afr_shd_sweep_prepare (healer); + +@@ -524,9 +526,9 @@ afr_shd_index_healer (void *data) + could not be healed thus far. + */ + +- gf_log (this->name, GF_LOG_DEBUG, +- "finished index sweep on subvol %s", +- afr_subvol_name (this, healer->subvol)); ++ gf_msg_debug (this->name, 0, ++ "finished index sweep on subvol %s", ++ afr_subvol_name (this, healer->subvol)); + /* + Give a pause before retrying to avoid a busy loop + in case the only entry in index is because of +@@ -564,9 +566,9 @@ afr_shd_full_healer (void *data) + + ASSERT_LOCAL(this, healer); + +- gf_log (this->name, GF_LOG_INFO, +- "starting full sweep on subvol %s", +- afr_subvol_name (this, healer->subvol)); ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_SELF_HEAL_INFO, ++ "starting full sweep on subvol %s", ++ afr_subvol_name (this, healer->subvol)); + + afr_shd_sweep_prepare (healer); + +@@ -574,9 +576,9 @@ afr_shd_full_healer (void *data) + + afr_shd_sweep_done (healer); + +- gf_log (this->name, GF_LOG_INFO, +- "finished full sweep on subvol %s", +- afr_subvol_name (this, healer->subvol)); ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_SELF_HEAL_INFO, ++ "finished full sweep on subvol %s", ++ afr_subvol_name (this, healer->subvol)); + } + + return NULL; +@@ -681,7 +683,8 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + + ret = dict_get_int32 (output, this->name, &xl_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "xl does not have id"); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ AFR_MSG_DICT_GET_FAILED, "xl does not have id"); + goto out; + } + +@@ -693,8 +696,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + xl_id, child, count); + ret = dict_set_uint64(output, key, healed_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_healed_count to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_healed_count to outout"); + goto out; + } + +@@ -702,8 +706,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + xl_id, child, count); + ret = dict_set_uint64 (output, key, split_brain_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_split_brain_count to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_split_brain_count to outout"); + goto out; + } + +@@ -711,8 +716,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + xl_id, child, count); + ret = dict_set_str (output, key, crawl_type); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_crawl_type to output"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_crawl_type to output"); + goto out; + } + +@@ -720,8 +726,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + xl_id, child, count); + ret = dict_set_uint64 (output, key, heal_failed_count); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_healed_failed_count to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_healed_failed_count to outout"); + goto out; + } + +@@ -729,8 +736,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + xl_id, child, count); + ret = dict_set_dynstr (output, key, start_time_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_crawl_start_time to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_crawl_start_time to outout"); + goto out; + } else { + start_time_str = NULL; +@@ -747,8 +755,9 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + end_time_str = gf_strdup ("Could not determine the end time"); + ret = dict_set_dynstr (output, key, end_time_str); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_crawl_end_time to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_crawl_end_time to outout"); + goto out; + } else { + end_time_str = NULL; +@@ -759,16 +768,18 @@ afr_shd_dict_add_crawl_event (xlator_t *this, dict_t *output, + + ret = dict_set_int32 (output, key, progress); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not add statistics_inprogress to outout"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not add statistics_inprogress to outout"); + goto out; + } + + snprintf (key, sizeof (key), "statistics-%d-%d-count", xl_id, child); + ret = dict_set_uint64 (output, key, count + 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not increment the counter."); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not increment the counter."); + goto out; + } + out: +@@ -789,7 +800,8 @@ afr_shd_dict_add_path (xlator_t *this, dict_t *output, int child, char *path, + + ret = dict_get_int32 (output, this->name, &xl_id); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "xl does not have id"); ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ AFR_MSG_DICT_GET_FAILED, "xl does not have id"); + goto out; + } + +@@ -800,7 +812,8 @@ afr_shd_dict_add_path (xlator_t *this, dict_t *output, int child, char *path, + ret = dict_set_dynstr (output, key, path); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s: Could not add to output", ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ AFR_MSG_DICT_SET_FAILED, "%s: Could not add to output", + path); + goto out; + } +@@ -810,8 +823,10 @@ afr_shd_dict_add_path (xlator_t *this, dict_t *output, int child, char *path, + child, count); + ret = dict_set_uint32 (output, key, tv->tv_sec); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "%s: Could not set time", +- path); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "%s: Could not set time", ++ path); + goto out; + } + } +@@ -820,7 +835,9 @@ afr_shd_dict_add_path (xlator_t *this, dict_t *output, int child, char *path, + + ret = dict_set_uint64 (output, key, count + 1); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, "Could not increment count"); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_DICT_SET_FAILED, ++ "Could not increment count"); + goto out; + } + +@@ -844,8 +861,8 @@ afr_shd_gather_entry (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, + this = THIS; + priv = this->private; + +- gf_log (this->name, GF_LOG_DEBUG, "got entry: %s", +- entry->d_name); ++ gf_msg_debug (this->name, 0, "got entry: %s", ++ entry->d_name); + + ret = gf_uuid_parse (entry->d_name, gfid); + if (ret) +@@ -882,7 +899,8 @@ afr_shd_gather_index_entries (xlator_t *this, int child, dict_t *output) + + loc.inode = afr_shd_index_inode (this, subvol); + if (!loc.inode) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ 0, AFR_MSG_INDEX_DIR_GET_FAILED, + "unable to get index-dir on %s", subvol->name); + return -errno; + } +@@ -1187,7 +1205,8 @@ afr_xl_op (xlator_t *this, dict_t *input, dict_t *output) + break; + + default: +- gf_log (this->name, GF_LOG_ERROR, "Unknown set op %d", op); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_ARG, "Unknown set op %d", op); + break; + } + out: +diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c +index b27cfed..ba50abd 100644 +--- a/xlators/cluster/afr/src/afr-transaction.c ++++ b/xlators/cluster/afr/src/afr-transaction.c +@@ -16,6 +16,8 @@ + #include "afr.h" + #include "afr-transaction.h" + #include "afr-self-heal.h" ++#include "afr-messages.h" ++ + #include + + gf_boolean_t +@@ -1220,13 +1222,14 @@ afr_post_blocking_inodelk_cbk (call_frame_t *frame, xlator_t *this) + int_lock = &local->internal_lock; + + if (int_lock->lock_op_ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, AFR_MSG_BLOCKING_LKS_FAILED, + "Blocking inodelks failed."); + local->transaction.done (frame, this); + } else { + +- gf_log (this->name, GF_LOG_DEBUG, +- "Blocking inodelks done. Proceeding to FOP"); ++ gf_msg_debug (this->name, 0, ++ "Blocking inodelks done. Proceeding to FOP"); + afr_internal_lock_finish (frame, this); + } + +@@ -1245,14 +1248,14 @@ afr_post_nonblocking_inodelk_cbk (call_frame_t *frame, xlator_t *this) + + /* Initiate blocking locks if non-blocking has failed */ + if (int_lock->lock_op_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Non blocking inodelks failed. Proceeding to blocking"); ++ gf_msg_debug (this->name, 0, ++ "Non blocking inodelks failed. Proceeding to blocking"); + int_lock->lock_cbk = afr_post_blocking_inodelk_cbk; + afr_blocking_lock (frame, this); + } else { + +- gf_log (this->name, GF_LOG_DEBUG, +- "Non blocking inodelks done. Proceeding to FOP"); ++ gf_msg_debug (this->name, 0, ++ "Non blocking inodelks done. Proceeding to FOP"); + afr_internal_lock_finish (frame, this); + } + +@@ -1270,13 +1273,14 @@ afr_post_blocking_entrylk_cbk (call_frame_t *frame, xlator_t *this) + int_lock = &local->internal_lock; + + if (int_lock->lock_op_ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_BLOCKING_LKS_FAILED, + "Blocking entrylks failed."); + local->transaction.done (frame, this); + } else { + +- gf_log (this->name, GF_LOG_DEBUG, +- "Blocking entrylks done. Proceeding to FOP"); ++ gf_msg_debug (this->name, 0, ++ "Blocking entrylks done. Proceeding to FOP"); + afr_internal_lock_finish (frame, this); + } + +@@ -1295,14 +1299,15 @@ afr_post_nonblocking_entrylk_cbk (call_frame_t *frame, xlator_t *this) + + /* Initiate blocking locks if non-blocking has failed */ + if (int_lock->lock_op_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Non blocking entrylks failed. Proceeding to blocking"); ++ gf_msg_debug (this->name, 0, ++ "Non blocking entrylks failed. Proceeding to blocking"); + int_lock->lock_cbk = afr_post_blocking_entrylk_cbk; + afr_blocking_lock (frame, this); + } else { + +- gf_log (this->name, GF_LOG_DEBUG, +- "Non blocking entrylks done. Proceeding to FOP"); ++ gf_msg_debug (this->name, 0, ++ "Non blocking entrylks done. Proceeding to FOP"); ++ + afr_internal_lock_finish (frame, this); + } + +@@ -1320,13 +1325,16 @@ afr_post_blocking_rename_cbk (call_frame_t *frame, xlator_t *this) + int_lock = &local->internal_lock; + + if (int_lock->lock_op_ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ AFR_MSG_BLOCKING_LKS_FAILED, + "Blocking entrylks failed."); ++ + local->transaction.done (frame, this); + } else { + +- gf_log (this->name, GF_LOG_DEBUG, +- "Blocking entrylks done. Proceeding to FOP"); ++ gf_msg_debug (this->name, 0, ++ "Blocking entrylks done. Proceeding to FOP"); ++ + afr_internal_lock_finish (frame, this); + } + return 0; +@@ -1477,7 +1485,8 @@ afr_are_multiple_fds_opened (fd_t *fd, xlator_t *this) + /* If false is returned, it may keep on taking eager-lock + * which may lead to starvation, so return true to avoid that. + */ +- gf_log_callingfn (this->name, GF_LOG_ERROR, "Invalid fd"); ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, EBADF, ++ AFR_MSG_INVALID_ARG, "Invalid fd"); + return _gf_true; + } + /* Lets say mount1 has eager-lock(full-lock) and after the eager-lock +@@ -1597,7 +1606,8 @@ afr_changelog_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + /* Failure of fsync() is as good as failure of previous + write(). So treat it like one. + */ +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ op_errno, AFR_MSG_FSYNC_FAILED, + "fsync(%s) failed on subvolume %s. Transaction was %s", + uuid_utoa (local->fd->inode->gfid), + priv->children[child_index]->name, +diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c +index 26efe93..5ef920a 100644 +--- a/xlators/cluster/afr/src/afr.c ++++ b/xlators/cluster/afr/src/afr.c +@@ -20,6 +20,7 @@ + #include "config.h" + #endif + #include "afr-common.c" ++#include "afr-messages.h" + + struct volume_options options[]; + +@@ -50,8 +51,6 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_afr_mt_end + 1); + + if (ret != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); + return ret; + } + +@@ -162,7 +161,8 @@ reconfigure (xlator_t *this, dict_t *options) + if (read_subvol) { + index = xlator_subvolume_index (this, read_subvol); + if (index == -1) { +- gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, "%s not a subvolume", + read_subvol->name); + goto out; + } +@@ -174,8 +174,9 @@ reconfigure (xlator_t *this, dict_t *options) + if (read_subvol_index >-1) { + index=read_subvol_index; + if (index >= priv->child_count) { +- gf_log (this->name, GF_LOG_ERROR, "%d not a subvolume-index", +- index); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, ++ "%d not a subvolume-index", index); + goto out; + } + priv->read_child = index; +@@ -249,15 +250,16 @@ init (xlator_t *this) + char *qtype = NULL; + + if (!this->children) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_CHILD_MISCONFIGURED, + "replicate translator needs more than one " + "subvolume defined."); + return -1; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, +- "Volume is dangling."); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_VOL_MISCONFIGURED, "Volume is dangling."); + } + + this->private = GF_CALLOC (1, sizeof (afr_private_t), +@@ -287,7 +289,8 @@ init (xlator_t *this) + if (read_subvol) { + priv->read_child = xlator_subvolume_index (this, read_subvol); + if (priv->read_child == -1) { +- gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, "%s not a subvolume", + read_subvol->name); + goto out; + } +@@ -295,8 +298,9 @@ init (xlator_t *this) + GF_OPTION_INIT ("read-subvolume-index",read_subvol_index,int32,out); + if (read_subvol_index > -1) { + if (read_subvol_index >= priv->child_count) { +- gf_log (this->name, GF_LOG_ERROR, "%d not a subvolume-index", +- read_subvol_index); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, ++ "%d not a subvolume-index", read_subvol_index); + goto out; + } + priv->read_child = read_subvol_index; +@@ -310,11 +314,13 @@ init (xlator_t *this) + if (fav_child) { + priv->favorite_child = xlator_subvolume_index (this, fav_child); + if (priv->favorite_child == -1) { +- gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume", ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INVALID_SUBVOL, "%s not a subvolume, " ++ "cannot set it as favorite child", + fav_child->name); + goto out; + } +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_FAVORITE_CHILD, + favorite_child_warning_str, fav_child->name, + fav_child->name, fav_child->name); + } +@@ -444,8 +450,6 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (afr_local_t, 512); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "failed to create local_t's memory pool"); + goto out; + } + +diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c +index ff8f586..2b4a150 100644 +--- a/xlators/cluster/afr/src/pump.c ++++ b/xlators/cluster/afr/src/pump.c +@@ -22,6 +22,7 @@ + #include "defaults.c" + #include "glusterfs.h" + #include "pump.h" ++#include "afr-messages.h" + + + static int +@@ -42,7 +43,8 @@ afr_set_dict_gfid (dict_t *dict, uuid_t gfid) + + ret = dict_set_dynptr (dict, "gfid-req", pgfid, sizeof (uuid_t)); + if (ret) +- gf_log (THIS->name, GF_LOG_ERROR, "gfid set failed"); ++ gf_msg (THIS->name, GF_LOG_ERROR, -ret, ++ AFR_MSG_DICT_SET_FAILED, "gfid set failed"); + + out: + if (ret && pgfid) +@@ -88,8 +90,6 @@ afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name) + name); + + if (-1 == ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "asprintf failed while setting child path"); + } + + child->name = strrchr (child->path, '/'); +@@ -231,10 +231,9 @@ pump_change_state (xlator_t *this, pump_state_t state) + } + UNLOCK (&pump_priv->pump_state_lock); + +- gf_log (this->name, GF_LOG_DEBUG, +- "Pump changing state from %d to %d", +- state_old, +- state_new); ++ gf_msg_debug (this->name, 0, ++ "Pump changing state from %d to %d", ++ state_old, state_new); + + return 0; + } +@@ -284,18 +283,19 @@ pump_save_path (xlator_t *this, const char *path) + dict = dict_new (); + dict_ret = dict_set_str (dict, PUMP_PATH, (char *)path); + if (dict_ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, ++ -dict_ret, AFR_MSG_DICT_SET_FAILED, + "%s: failed to set the key %s", path, PUMP_PATH); + + ret = syncop_setxattr (PUMP_SOURCE_CHILD (this), &loc, dict, 0, NULL, + NULL); + + if (ret < 0) { +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, -ret, AFR_MSG_INFO_COMMON, + "setxattr failed - could not save path=%s", path); + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "setxattr succeeded - saved path=%s", path); ++ gf_msg_debug (this->name, 0, ++ "setxattr succeeded - saved path=%s", path); + } + + dict_unref (dict); +@@ -333,8 +333,8 @@ pump_check_and_update_status (xlator_t *this) + } + default: + { +- gf_log (this->name, GF_LOG_DEBUG, +- "Unknown pump state"); ++ gf_msg_debug (this->name, 0, ++ "Unknown pump state"); + ret = -1; + break; + } +@@ -371,19 +371,21 @@ pump_update_resume_state (xlator_t *this, const char *path) + if (state == PUMP_STATE_RESUME) { + resume_path = pump_get_resume_path (this); + if (strcmp (resume_path, "/") == 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Reached the resume path (/). Proceeding to change state" +- " to running"); ++ gf_msg_debug (this->name, 0, ++ "Reached the resume path (/). Proceeding to change state" ++ " to running"); ++ + pump_change_state (this, PUMP_STATE_RUNNING); + } else if (strcmp (resume_path, path) == 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Reached the resume path. Proceeding to change state" +- " to running"); ++ gf_msg_debug (this->name, 0, ++ "Reached the resume path. Proceeding to change state" ++ " to running"); ++ + pump_change_state (this, PUMP_STATE_RUNNING); + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not yet hit the resume path:res-path=%s,path=%s", +- resume_path, path); ++ gf_msg_debug (this->name, 0, ++ "Not yet hit the resume path:res-path=%s,path=%s", ++ resume_path, path); + } + } + +@@ -402,12 +404,12 @@ is_pump_traversal_allowed (xlator_t *this, const char *path) + if (state == PUMP_STATE_RESUME) { + resume_path = pump_get_resume_path (this); + if (strstr (resume_path, path)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "On the right path to resumption path"); ++ gf_msg_debug (this->name, 0, ++ "On the right path to resumption path"); + ret = _gf_true; + } else { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not the right path to resuming=> ignoring traverse"); ++ gf_msg_debug (this->name, 0, ++ "Not the right path to resuming=> ignoring traverse"); + ret = _gf_false; + } + } +@@ -460,39 +462,40 @@ gf_pump_traverse_directory (loc_t *loc) + + fd = fd_create (loc->inode, pump_pid); + if (!fd) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, AFR_MSG_FD_CREATE_FAILED, + "Failed to create fd for %s", loc->path); + goto out; + } + + ret = syncop_opendir (this, loc, fd, NULL, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "opendir failed on %s", loc->path); ++ gf_msg_debug (this->name, 0, ++ "opendir failed on %s", loc->path); + goto out; + } + +- gf_log (this->name, GF_LOG_TRACE, +- "pump opendir on %s returned=%d", +- loc->path, ret); ++ gf_msg_trace (this->name, 0, ++ "pump opendir on %s returned=%d", ++ loc->path, ret); + + while (syncop_readdirp (this, fd, 131072, offset, &entries, NULL, + NULL)) { + free_entries = _gf_true; + + if (list_empty (&entries.list)) { +- gf_log (this->name, GF_LOG_TRACE, +- "no more entries in directory"); ++ gf_msg_trace (this->name, 0, ++ "no more entries in directory"); + goto out; + } + + list_for_each_entry_safe (entry, tmp, &entries.list, list) { +- gf_log (this->name, GF_LOG_DEBUG, +- "found readdir entry=%s", entry->d_name); ++ gf_msg_debug (this->name, 0, ++ "found readdir entry=%s", entry->d_name); + + offset = entry->d_off; + if (gf_uuid_is_null (entry->d_stat.ia_gfid)) { +- gf_log (this->name, GF_LOG_WARNING, "%s/%s: No " ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_GFID_NULL, "%s/%s: No " + "gfid present skipping", + loc->path, entry->d_name); + continue; +@@ -508,35 +511,39 @@ gf_pump_traverse_directory (loc_t *loc) + continue; + + is_directory_empty = _gf_false; +- gf_log (this->name, GF_LOG_DEBUG, +- "lookup %s => %"PRId64, +- entry_loc.path, +- iatt.ia_ino); ++ gf_msg_debug (this->name, 0, ++ "lookup %s => %"PRId64, ++ entry_loc.path, ++ iatt.ia_ino); + + ret = syncop_lookup (this, &entry_loc, &iatt, &parent, + NULL, &xattr_rsp); + + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: lookup failed", entry_loc.path); ++ gf_msg (this->name, GF_LOG_ERROR, ++ -ret, AFR_MSG_INFO_COMMON, ++ "%s: lookup failed", entry_loc.path); + continue; + } + + ret = afr_selfheal_name (this, loc->gfid, entry->d_name, + NULL); + if (ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: name self-heal failed (%s/%s)", +- entry_loc.path, uuid_utoa (loc->gfid), +- entry->d_name); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SELF_HEAL_FAILED, ++ "%s: name self-heal failed (%s/%s)", ++ entry_loc.path, uuid_utoa (loc->gfid), ++ entry->d_name); + continue; + } + + ret = afr_selfheal (this, iatt.ia_gfid); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, +- "%s: self-heal failed (%s)", +- entry_loc.path, uuid_utoa (iatt.ia_gfid)); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SELF_HEAL_FAILED, ++ "%s: self-heal failed (%s)", ++ entry_loc.path, ++ uuid_utoa (iatt.ia_gfid)); + continue; + } + +@@ -549,15 +556,16 @@ gf_pump_traverse_directory (loc_t *loc) + + ret = pump_check_and_update_status (this); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Pump beginning to exit out"); ++ gf_msg_debug (this->name, 0, ++ "Pump beginning to exit out"); + goto out; + } + + if (IA_ISDIR (iatt.ia_type)) { + if (is_pump_traversal_allowed (this, entry_loc.path)) { +- gf_log (this->name, GF_LOG_TRACE, +- "entering dir=%s", entry->d_name); ++ gf_msg_trace (this->name, 0, ++ "entering dir=%s", ++ entry->d_name); + gf_pump_traverse_directory (&entry_loc); + } + } +@@ -565,19 +573,19 @@ gf_pump_traverse_directory (loc_t *loc) + + gf_dirent_free (&entries); + free_entries = _gf_false; +- gf_log (this->name, GF_LOG_TRACE, "offset incremented to %d", +- (int32_t ) offset); ++ gf_msg_trace (this->name, 0, "offset incremented to %d", ++ (int32_t) offset); + + } + + ret = syncop_close (fd); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, "closing the fd failed"); ++ gf_msg_debug (this->name, 0, "closing the fd failed"); + + if (is_directory_empty && (strcmp (loc->path, "/") == 0)) { + pump_change_state (this, PUMP_STATE_RUNNING); +- gf_log (this->name, GF_LOG_INFO, "Empty source brick. " +- "Nothing to be done."); ++ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_INFO_COMMON, ++ "Empty source brick. Nothing to be done."); + } + + out: +@@ -596,13 +604,13 @@ pump_update_resume_path (xlator_t *this) + resume_path = pump_get_resume_path (this); + + if (resume_path) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Found a path to resume from: %s", +- resume_path); ++ gf_msg_debug (this->name, 0, ++ "Found a path to resume from: %s", ++ resume_path); + + }else { +- gf_log (this->name, GF_LOG_DEBUG, +- "Did not find a path=> setting to '/'"); ++ gf_msg_debug (this->name, 0, ++ "Did not find a path=> setting to '/'"); + pump_set_resume_path (this, "/"); + } + +@@ -636,8 +644,8 @@ pump_xattr_cleaner (call_frame_t *frame, void *cookie, xlator_t *this, + ret = syncop_removexattr (priv->children[i], &loc, + PUMP_SOURCE_COMPLETE, 0, NULL); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "removexattr " +- "failed with %s", strerror (-ret)); ++ gf_msg_debug (this->name, 0, "removexattr " ++ "failed with %s", strerror (-ret)); + } + } + +@@ -667,41 +675,45 @@ pump_complete_migration (xlator_t *this) + + state = pump_get_state (); + if (state == PUMP_STATE_RUNNING) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Pump finished pumping"); ++ gf_msg_debug (this->name, 0, ++ "Pump finished pumping"); + + pump_priv->pump_finished = _gf_true; + + dict_ret = dict_set_str (dict, PUMP_SOURCE_COMPLETE, "jargon"); + if (dict_ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -dict_ret, ++ AFR_MSG_DICT_SET_FAILED, + "%s: failed to set the key %s", + loc.path, PUMP_SOURCE_COMPLETE); + + ret = syncop_setxattr (PUMP_SOURCE_CHILD (this), &loc, dict, 0, + NULL, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "setxattr failed - while notifying source complete"); ++ gf_msg_debug (this->name, 0, ++ "setxattr failed - while " ++ "notifying source complete"); + } + dict_ret = dict_set_str (dict, PUMP_SINK_COMPLETE, "jargon"); + if (dict_ret) +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, -dict_ret, ++ AFR_MSG_DICT_SET_FAILED, + "%s: failed to set the key %s", + loc.path, PUMP_SINK_COMPLETE); + + ret = syncop_setxattr (PUMP_SINK_CHILD (this), &loc, dict, 0, + NULL, NULL); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "setxattr failed - while notifying sink complete"); ++ gf_msg_debug (this->name, 0, ++ "setxattr failed - while " ++ "notifying sink complete"); + } + + pump_save_path (this, "/"); + + } else if (state == PUMP_STATE_ABORT) { +- gf_log (this->name, GF_LOG_DEBUG, "Starting cleanup " +- "of pump internal xattrs"); ++ gf_msg_debug (this->name, 0, "Starting cleanup " ++ "of pump internal xattrs"); + call_resume (pump_priv->cleaner); + } + +@@ -730,8 +742,8 @@ pump_lookup_sink (loc_t *loc) + xattr_req, &xattr_rsp); + + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Lookup on sink child failed"); ++ gf_msg_debug (this->name, 0, ++ "Lookup on sink child failed"); + ret = -1; + goto out; + } +@@ -765,8 +777,8 @@ pump_task (void *data) + afr_build_root_loc (this, &loc); + xattr_req = dict_new (); + if (!xattr_req) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Out of memory"); ++ gf_msg_debug (this->name, ENOMEM, ++ "Out of memory"); + ret = -1; + goto out; + } +@@ -775,9 +787,9 @@ pump_task (void *data) + ret = syncop_lookup (this, &loc, &iatt, &parent, + xattr_req, &xattr_rsp); + +- gf_log (this->name, GF_LOG_TRACE, +- "lookup: path=%s gfid=%s", +- loc.path, uuid_utoa (loc.inode->gfid)); ++ gf_msg_trace (this->name, 0, ++ "lookup: path=%s gfid=%s", ++ loc.path, uuid_utoa (loc.inode->gfid)); + + ret = pump_check_and_update_status (this); + if (ret < 0) { +@@ -818,8 +830,8 @@ pump_task_completion (int ret, call_frame_t *sync_frame, void *data) + inode_unref (priv->root_inode); + STACK_DESTROY (sync_frame->root); + +- gf_log (this->name, GF_LOG_DEBUG, +- "Pump xlator exiting"); ++ gf_msg_debug (this->name, 0, ++ "Pump xlator exiting"); + return 0; + } + +@@ -841,15 +853,12 @@ pump_start (call_frame_t *pump_frame, xlator_t *this) + pump_task_completion, + pump_frame, NULL); + if (ret == -1) { +- gf_log (this->name, GF_LOG_ERROR, +- "starting pump failed"); +- pump_change_state (this, PUMP_STATE_ABORT); + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "setting pump as started lk_owner: %s %"PRIu64, +- lkowner_utoa (&pump_frame->root->lk_owner), pump_pid); ++ gf_msg_debug (this->name, 0, ++ "setting pump as started lk_owner: %s %"PRIu64, ++ lkowner_utoa (&pump_frame->root->lk_owner), pump_pid); + + priv->use_afr_in_pump = 1; + out: +@@ -864,8 +873,6 @@ pump_start_synctask (xlator_t *this) + + frame = create_frame (this, this->ctx->pool); + if (!frame) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory"); + ret = -1; + goto out; + } +@@ -893,16 +900,17 @@ pump_cmd_start_setxattr_cbk (call_frame_t *frame, + local = frame->local; + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_INFO_COMMON, + "Could not initiate destination " + "brick connect"); + ret = op_ret; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Successfully initiated destination " +- "brick connect"); ++ gf_msg_debug (this->name, 0, ++ "Successfully initiated destination " ++ "brick connect"); + + pump_mark_start_pending (this); + +@@ -940,7 +948,8 @@ pump_initiate_sink_connect (call_frame_t *frame, xlator_t *this) + data = data_ref (dict_get (local->dict, RB_PUMP_CMD_START)); + if (!data) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ AFR_MSG_DICT_GET_FAILED, + "Could not get destination brick value"); + goto out; + } +@@ -959,12 +968,13 @@ pump_initiate_sink_connect (call_frame_t *frame, xlator_t *this) + + memcpy (clnt_cmd, data->data, data->len); + clnt_cmd[data->len] = '\0'; +- gf_log (this->name, GF_LOG_DEBUG, "Got destination brick %s\n", +- clnt_cmd); ++ gf_msg_debug (this->name, 0, "Got destination brick %s\n", ++ clnt_cmd); + + ret = dict_set_dynstr (dict, CLIENT_CMD_CONNECT, clnt_cmd); + if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ AFR_MSG_DICT_SET_FAILED, + "Could not inititiate destination brick " + "connect"); + goto out; +@@ -1023,14 +1033,14 @@ pump_cmd_start_getxattr_cbk (call_frame_t *frame, + local = frame->local; + + if (op_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "getxattr failed - changing pump " +- "state to RUNNING with '/'"); ++ gf_msg_debug (this->name, 0, ++ "getxattr failed - changing pump " ++ "state to RUNNING with '/'"); + path = "/"; + ret = op_ret; + } else { +- gf_log (this->name, GF_LOG_TRACE, +- "getxattr succeeded"); ++ gf_msg_trace (this->name, 0, ++ "getxattr succeeded"); + + dict_ret = dict_get_str (dict, PUMP_PATH, &path); + if (dict_ret < 0) +@@ -1040,7 +1050,8 @@ pump_cmd_start_getxattr_cbk (call_frame_t *frame, + state = pump_get_state (); + if ((state == PUMP_STATE_RUNNING) || + (state == PUMP_STATE_RESUME)) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, AFR_MSG_PUMP_XLATOR_ERROR, + "Pump is already started"); + ret = -1; + goto out; +@@ -1054,8 +1065,8 @@ pump_cmd_start_getxattr_cbk (call_frame_t *frame, + else { + /* We're re-starting pump from a previous + pause */ +- gf_log (this->name, GF_LOG_DEBUG, +- "about to start synctask"); ++ gf_msg_debug (this->name, 0, ++ "about to start synctask"); + ret = pump_start_synctask (this); + need_unwind = 1; + } +@@ -1098,8 +1109,6 @@ pump_execute_status (call_frame_t *frame, xlator_t *this) + + dict_str = GF_CALLOC (1, PATH_MAX + 256, gf_afr_mt_char); + if (!dict_str) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory"); + op_ret = -1; + op_errno = ENOMEM; + goto out; +@@ -1120,8 +1129,8 @@ pump_execute_status (call_frame_t *frame, xlator_t *this) + + ret = dict_set_dynstr (dict, RB_PUMP_CMD_STATUS, dict_str); + if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "dict_set_dynstr returned negative value"); ++ gf_msg_debug (this->name, 0, ++ "dict_set_dynstr returned negative value"); + } else { + dict_str = NULL; + } +@@ -1168,7 +1177,8 @@ pump_execute_start (call_frame_t *frame, xlator_t *this) + local = frame->local; + + if (!priv->root_inode) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, AFR_MSG_PUMP_XLATOR_ERROR, + "Pump xlator cannot be started without an initial " + "lookup"); + ret = -1; +@@ -1235,13 +1245,14 @@ pump_execute_commit (call_frame_t *frame, xlator_t *this) + ret = synctask_new (pump_priv->env, pump_cleanup_helper, + pump_cleanup_done, sync_frame, frame); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Couldn't create " +- "synctask for cleaning up xattrs."); ++ gf_msg_debug (this->name, 0, "Couldn't create " ++ "synctask for cleaning up xattrs."); + } + + } else { +- gf_log (this->name, GF_LOG_ERROR, "Commit can't proceed. " +- "Migration in progress"); ++ gf_msg (this->name, GF_LOG_ERROR, EINPROGRESS, ++ AFR_MSG_MIGRATION_IN_PROGRESS, ++ "Commit can't proceed. Migration in progress"); + local->op_ret = -1; + local->op_errno = EINPROGRESS; + pump_command_reply (frame, this); +@@ -1277,8 +1288,8 @@ pump_execute_abort (call_frame_t *frame, xlator_t *this) + ret = synctask_new (pump_priv->env, pump_cleanup_helper, + pump_cleanup_done, sync_frame, frame); + if (ret) { +- gf_log (this->name, GF_LOG_DEBUG, "Couldn't create " +- "synctask for cleaning up xattrs."); ++ gf_msg_debug (this->name, 0, "Couldn't create " ++ "synctask for cleaning up xattrs."); + } + + } else { +@@ -1299,14 +1310,14 @@ pump_command_status (xlator_t *this, dict_t *dict) + + dict_ret = dict_get_str (dict, RB_PUMP_CMD_STATUS, &cmd); + if (dict_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not a pump status command"); ++ gf_msg_debug (this->name, 0, ++ "Not a pump status command"); + ret = _gf_false; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit a pump command - status"); ++ gf_msg_debug (this->name, 0, ++ "Hit a pump command - status"); + ret = _gf_true; + + out: +@@ -1323,14 +1334,14 @@ pump_command_pause (xlator_t *this, dict_t *dict) + + dict_ret = dict_get_str (dict, RB_PUMP_CMD_PAUSE, &cmd); + if (dict_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not a pump pause command"); ++ gf_msg_debug (this->name, 0, ++ "Not a pump pause command"); + ret = _gf_false; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit a pump command - pause"); ++ gf_msg_debug (this->name, 0, ++ "Hit a pump command - pause"); + ret = _gf_true; + + out: +@@ -1347,14 +1358,14 @@ pump_command_commit (xlator_t *this, dict_t *dict) + + dict_ret = dict_get_str (dict, RB_PUMP_CMD_COMMIT, &cmd); + if (dict_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not a pump commit command"); ++ gf_msg_debug (this->name, 0, ++ "Not a pump commit command"); + ret = _gf_false; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit a pump command - commit"); ++ gf_msg_debug (this->name, 0, ++ "Hit a pump command - commit"); + ret = _gf_true; + + out: +@@ -1371,14 +1382,14 @@ pump_command_abort (xlator_t *this, dict_t *dict) + + dict_ret = dict_get_str (dict, RB_PUMP_CMD_ABORT, &cmd); + if (dict_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not a pump abort command"); ++ gf_msg_debug (this->name, 0, ++ "Not a pump abort command"); + ret = _gf_false; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit a pump command - abort"); ++ gf_msg_debug (this->name, 0, ++ "Hit a pump command - abort"); + ret = _gf_true; + + out: +@@ -1395,14 +1406,14 @@ pump_command_start (xlator_t *this, dict_t *dict) + + dict_ret = dict_get_str (dict, RB_PUMP_CMD_START, &cmd); + if (dict_ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Not a pump start command"); ++ gf_msg_debug (this->name, 0, ++ "Not a pump start command"); + ret = _gf_false; + goto out; + } + +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit a pump command - start"); ++ gf_msg_debug (this->name, 0, ++ "Hit a pump command - start"); + ret = _gf_true; + + out: +@@ -1438,8 +1449,8 @@ pump_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + } + + if (!strcmp (name, RB_PUMP_CMD_STATUS)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "Hit pump command - status"); ++ gf_msg_debug (this->name, 0, ++ "Hit pump command - status"); + pump_execute_status (frame, this); + goto out; + } +@@ -1461,10 +1472,12 @@ pump_command_reply (call_frame_t *frame, xlator_t *this) + local = frame->local; + + if (local->op_ret < 0) +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, AFR_MSG_INFO_COMMON, + "Command failed"); + else +- gf_log (this->name, GF_LOG_INFO, ++ gf_msg (this->name, GF_LOG_INFO, ++ 0, AFR_MSG_INFO_COMMON, + "Command succeeded"); + + AFR_STACK_UNWIND (setxattr, +@@ -2153,8 +2166,6 @@ mem_acct_init (xlator_t *this) + ret = xlator_mem_acct_init (this, gf_afr_mt_end + 1); + + if (ret != 0) { +- gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" +- "failed"); + return ret; + } + +@@ -2193,13 +2204,13 @@ notify (xlator_t *this, int32_t event, + case GF_EVENT_CHILD_UP: + if (is_xlator_pump_sink (child_xl)) + if (is_pump_start_pending (this)) { +- gf_log (this->name, GF_LOG_DEBUG, +- "about to start synctask"); ++ gf_msg_debug (this->name, 0, ++ "about to start synctask"); + ret = pump_start_synctask (this); + if (ret < 0) +- gf_log (this->name, GF_LOG_DEBUG, +- "Could not start pump " +- "synctask"); ++ gf_msg_debug (this->name, 0, ++ "Could not start pump " ++ "synctask"); + else + pump_remove_start_pending (this); + } +@@ -2222,15 +2233,16 @@ init (xlator_t *this) + int source_child = 0; + + if (!this->children) { +- gf_log (this->name, GF_LOG_ERROR, +- "pump translator needs a source and sink" ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, AFR_MSG_CHILD_MISCONFIGURED, ++ "pump translator needs a source and sink" + "subvolumes defined."); + return -1; + } + + if (!this->parents) { +- gf_log (this->name, GF_LOG_WARNING, +- "Volume is dangling."); ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ AFR_MSG_VOL_MISCONFIGURED, "Volume is dangling."); + } + + priv = GF_CALLOC (1, sizeof (afr_private_t), gf_afr_mt_afr_private_t); +@@ -2241,7 +2253,8 @@ init (xlator_t *this) + + child_count = xlator_subvolume_count (this); + if (child_count != 2) { +- gf_log (this->name, GF_LOG_ERROR, ++ gf_msg (this->name, GF_LOG_ERROR, ++ 0, AFR_MSG_CHILD_MISCONFIGURED, + "There should be exactly 2 children - one source " + "and one sink"); + return -1; +@@ -2274,8 +2287,6 @@ init (xlator_t *this) + priv->child_up = GF_CALLOC (sizeof (unsigned char), child_count, + gf_afr_mt_char); + if (!priv->child_up) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory."); + op_errno = ENOMEM; + goto out; + } +@@ -2283,8 +2294,6 @@ init (xlator_t *this) + priv->children = GF_CALLOC (sizeof (xlator_t *), child_count, + gf_afr_mt_xlator_t); + if (!priv->children) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory."); + op_errno = ENOMEM; + goto out; + } +@@ -2293,8 +2302,6 @@ init (xlator_t *this) + child_count, + gf_afr_mt_char); + if (!priv->pending_key) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory."); + op_errno = ENOMEM; + goto out; + } +@@ -2308,8 +2315,6 @@ init (xlator_t *this) + AFR_XATTR_PREFIX, + trav->xlator->name); + if (-1 == ret) { +- gf_log (this->name, GF_LOG_ERROR, +- "asprintf failed to set pending key"); + op_errno = ENOMEM; + goto out; + } +@@ -2336,8 +2341,6 @@ init (xlator_t *this) + pump_priv = GF_CALLOC (1, sizeof (*pump_priv), + gf_afr_mt_pump_priv); + if (!pump_priv) { +- gf_log (this->name, GF_LOG_ERROR, +- "Out of memory"); + op_errno = ENOMEM; + goto out; + } +@@ -2348,15 +2351,12 @@ init (xlator_t *this) + pump_priv->resume_path = GF_CALLOC (1, PATH_MAX, + gf_afr_mt_char); + if (!pump_priv->resume_path) { +- gf_log (this->name, GF_LOG_ERROR, "Out of memory"); + ret = -1; + goto out; + } + + pump_priv->env = this->ctx->env; + if (!pump_priv->env) { +- gf_log (this->name, GF_LOG_ERROR, +- "Could not create new sync-environment"); + ret = -1; + goto out; + } +@@ -2365,8 +2365,6 @@ init (xlator_t *this) + this->local_pool = mem_pool_new (afr_local_t, 128); + if (!this->local_pool) { + ret = -1; +- gf_log (this->name, GF_LOG_ERROR, +- "failed to create local_t's memory pool"); + goto out; + } + +-- +1.7.1 + diff --git a/SOURCES/0184-features-performace-Updating-the-glfs-components.patch b/SOURCES/0184-features-performace-Updating-the-glfs-components.patch new file mode 100644 index 0000000..3013bff --- /dev/null +++ b/SOURCES/0184-features-performace-Updating-the-glfs-components.patch @@ -0,0 +1,38 @@ +From 0028aafa7c82936737b2cb93eeb4626db27dd9ba Mon Sep 17 00:00:00 2001 +From: Anusha +Date: Sat, 27 Jun 2015 16:38:39 +0530 +Subject: [PATCH 184/190] features/performace: Updating the glfs components + which were accidentally deleted + +BUG: 1231784 +Change-Id: I536fac2b0b71fcc1e1eeccf5187bbc1173468743 +Signed-off-by: Anusha +Reviewed-on: https://code.engineering.redhat.com/gerrit/51755 +Reviewed-by: Nithya Balachandran +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glfs-message-id.h | 7 +++++++ + 1 files changed, 7 insertions(+), 0 deletions(-) + +diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h +index 0087440..d6705b4 100644 +--- a/libglusterfs/src/glfs-message-id.h ++++ b/libglusterfs/src/glfs-message-id.h +@@ -113,6 +113,13 @@ + #define GLFS_MSGID_COMP_QUOTA_END (GLFS_MSGID_COMP_QUOTA +\ + GLFS_MSGID_SEGMENT) + ++#define GLFS_MSGID_COMP_CTR GLFS_MSGID_COMP_QUOTA_END ++#define GLFS_MSGID_COMP_CTR_END (GLFS_MSGID_COMP_CTR+\ ++ GLFS_MSGID_SEGMENT) ++ ++#define GLFS_MSGID_COMP_EC GLFS_MSGID_COMP_CTR_END ++#define GLFS_MSGID_COMP_EC_END (GLFS_MSGID_COMP_EC +\ ++ GLFS_MSGID_SEGMENT) + + #define GLFS_MSGID_COMP_IO_CACHE GLFS_MSGID_COMP_EC_END + #define GLFS_MSGID_COMP_IO_CACHE_END (GLFS_MSGID_COMP_IO_CACHE+\ +-- +1.7.1 + diff --git a/SOURCES/0185-features-bit-rot-stub-deny-access-to-bad-objects.patch b/SOURCES/0185-features-bit-rot-stub-deny-access-to-bad-objects.patch new file mode 100644 index 0000000..2df345a --- /dev/null +++ b/SOURCES/0185-features-bit-rot-stub-deny-access-to-bad-objects.patch @@ -0,0 +1,804 @@ +From 27465e9f8b567db4a5265b1cfd0f08f300667416 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Tue, 26 May 2015 19:22:14 +0530 +Subject: [PATCH 185/190] features/bit-rot-stub: deny access to bad objects + + Backport of http://review.gluster.org/11126 + +* Access to bad objects (especially operations such as open, readv, writev) + should be denied to prevent applications from getting wrong data. + +* Do not allow anyone apart from scrubber to set bad object xattr. + +* Do not allow bad object xattr to be removed. + +Change-Id: Id4e43b8318a7b0822231485c60bbc551b9adf7e8 +BUG: 1224227 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/51757 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + libglusterfs/src/glusterfs.h | 3 + + xlators/features/bit-rot/src/bitd/bit-rot.c | 7 +- + xlators/features/bit-rot/src/stub/bit-rot-common.h | 15 +- + .../bit-rot/src/stub/bit-rot-stub-messages.h | 28 ++ + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 310 ++++++++++++++++++-- + xlators/features/bit-rot/src/stub/bit-rot-stub.h | 94 ++++++ + xlators/performance/quick-read/src/quick-read.c | 5 + + 7 files changed, 430 insertions(+), 32 deletions(-) + +diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h +index c00bf55..97965ab 100644 +--- a/libglusterfs/src/glusterfs.h ++++ b/libglusterfs/src/glusterfs.h +@@ -127,6 +127,9 @@ + #define BITROT_CURRENT_VERSION_KEY "trusted.bit-rot.version" + #define BITROT_SIGNING_VERSION_KEY "trusted.bit-rot.signature" + ++/* globally usable bad file marker */ ++#define GLUSTERFS_BAD_INODE "glusterfs.bad-inode" ++ + /* on-disk size of signing xattr (not the signature itself) */ + #define BITROT_SIGNING_XATTR_SIZE_KEY "trusted.glusterfs.bit-rot.size" + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index cf9e8e2..94063cb 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -164,11 +164,10 @@ bitd_is_bad_file (xlator_t *this, br_child_t *child, loc_t *loc, fd_t *fd) + + if (fd) + ret = syncop_fgetxattr (child->xl, fd, &xattr, +- "trusted.glusterfs.bad-file", NULL, +- NULL); ++ BITROT_OBJECT_BAD_KEY, NULL, NULL); + else if (loc) +- ret = syncop_getxattr (child->xl, loc, &xattr, +- "trusted.glusterfs.bad-file", NULL, ++ ret = syncop_getxattr (child->xl, loc, ++ &xattr, BITROT_OBJECT_BAD_KEY, NULL, + NULL); + + if (!ret) { +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-common.h b/xlators/features/bit-rot/src/stub/bit-rot-common.h +index a8285d2..f8d03de 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-common.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-common.h +@@ -41,12 +41,23 @@ typedef enum br_sign_state { + } br_sign_state_t; + + static inline br_vxattr_status_t +-br_version_xattr_state (dict_t *xattr, +- br_version_t **obuf, br_signature_t **sbuf) ++br_version_xattr_state (dict_t *xattr, br_version_t **obuf, ++ br_signature_t **sbuf, gf_boolean_t *objbad) + { + int32_t ret = 0; + int32_t vxattr = 0; + br_vxattr_status_t status; ++ void *data = NULL; ++ ++ /** ++ * The key being present in the dict indicates the xattr was set on ++ * disk. The presence of xattr itself as of now is suffecient to say ++ * the the object is bad. ++ */ ++ *objbad = _gf_false; ++ ret = dict_get_bin (xattr, BITROT_OBJECT_BAD_KEY, (void **)&data); ++ if (!ret) ++ *objbad = _gf_true; + + ret = dict_get_bin (xattr, BITROT_CURRENT_VERSION_KEY, (void **)obuf); + if (ret) +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +index d940b65..db5736a 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +@@ -153,6 +153,34 @@ + * @recommendedaction + * + */ ++#define BRS_MSG_BAD_OBJ_MARK_FAIL (GLFS_BITROT_STUB_BASE + 16) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_NON_SCRUB_BAD_OBJ_MARK (GLFS_BITROT_STUB_BASE + 17) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_REMOVE_BAD_OBJECT_XATTR (GLFS_BITROT_STUB_BASE + 18) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_BAD_OBJECT_ACCESS (GLFS_BITROT_STUB_BASE + 20) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_BITROT_STUB_MESSAGES_H_ */ +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 600eb80..de81510 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -237,7 +237,8 @@ br_stub_prepare_signing_request (dict_t *dict, + */ + static inline int + br_stub_init_inode_versions (xlator_t *this, fd_t *fd, inode_t *inode, +- unsigned long version, gf_boolean_t markdirty) ++ unsigned long version, gf_boolean_t markdirty, ++ gf_boolean_t bad_object) + { + int32_t ret = 0; + br_stub_inode_ctx_t *ctx = NULL; +@@ -252,17 +253,21 @@ br_stub_init_inode_versions (xlator_t *this, fd_t *fd, inode_t *inode, + : __br_stub_mark_inode_synced (ctx); + __br_stub_set_ongoing_version (ctx, version); + ++ if (bad_object) ++ __br_stub_mark_object_bad (ctx); ++ + if (fd) { + ret = br_stub_add_fd_to_inode (this, fd, ctx); + if (ret) + goto free_ctx; + } ++ + ret = br_stub_set_inode_ctx (this, inode, ctx); + if (ret) + goto free_ctx; + return 0; + +- free_ctx: ++free_ctx: + GF_FREE (ctx); + error_return: + return -1; +@@ -290,7 +295,7 @@ br_stub_mod_inode_versions (xlator_t *this, + + ret = 0; + } +- unblock: ++unblock: + UNLOCK (&inode->lock); + + return ret; +@@ -623,7 +628,7 @@ int32_t + br_stub_perform_objsign (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, int flags, dict_t *xdata) + { +- STACK_WIND (frame, default_setxattr_cbk, ++ STACK_WIND (frame, default_fsetxattr_cbk, + FIRST_CHILD (this), FIRST_CHILD (this)->fops->fsetxattr, fd, + dict, flags, xdata); + +@@ -900,13 +905,101 @@ br_stub_handle_object_reopen (call_frame_t *frame, + STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL); + } + ++/** ++ * This function only handles bad file identification. Instead of checking in ++ * fops like open, readv, writev whether the object is bad or not by doing ++ * getxattr calls, better to catch them when scrubber marks it as bad. ++ * So this callback is called only when the fsetxattr is sent by the scrubber ++ * to mark the object as bad. ++ */ ++int ++br_stub_fsetxattr_bad_object_cbk (call_frame_t *frame, void *cookie, ++ xlator_t *this, int32_t op_ret, ++ int32_t op_errno, dict_t *xdata) ++{ ++ br_stub_local_t *local = NULL; ++ int32_t ret = -1; ++ ++ local = frame->local; ++ frame->local = NULL; ++ ++ if (op_ret < 0) ++ goto unwind; ++ ++ /* ++ * What to do if marking the object as bad fails? (i.e. in memory ++ * marking within the inode context. If we are here means fsetxattr ++ * fop has succeeded on disk and the bad object xattr has been set). ++ * We can return failure to scruber, but there is nothing the scrubber ++ * can do with it (it might assume that the on disk setxattr itself has ++ * failed). The main purpose of this operation is to help identify the ++ * bad object by checking the inode context itself (thus avoiding the ++ * necessity of doing a getxattr fop on the disk). ++ * ++ * So as of now, success itself is being returned even though inode ++ * context set operation fails. ++ * In future if there is any change in the policy which can handle this, ++ * then appropriate response should be sent (i.e. success or error). ++ */ ++ ret = br_stub_mark_object_bad (this, local->u.context.inode); ++ if (ret) ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_BAD_OBJ_MARK_FAIL, ++ "failed to mark object %s as bad", ++ uuid_utoa (local->u.context.inode->gfid)); ++ ++unwind: ++ STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, xdata); ++ br_stub_cleanup_local (local); ++ br_stub_dealloc_local (local); ++ return 0; ++} ++ ++static int32_t ++br_stub_handle_bad_object_key (call_frame_t *frame, xlator_t *this, fd_t *fd, ++ dict_t *dict, int flags, dict_t *xdata) ++{ ++ br_stub_local_t *local = NULL; ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ ++ if (frame->root->pid != GF_CLIENT_PID_SCRUB) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_NON_SCRUB_BAD_OBJ_MARK, "bad object marking " ++ "on %s is not from the scrubber", ++ uuid_utoa (fd->inode->gfid)); ++ goto unwind; ++ } ++ ++ local = br_stub_alloc_local (this); ++ if (!local) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_NO_MEMORY, ++ "failed to allocate memory for fsetxattr on %s", ++ uuid_utoa (fd->inode->gfid)); ++ op_ret = -1; ++ op_errno = ENOMEM; ++ goto unwind; ++ } ++ ++ br_stub_fill_local (local, NULL, fd, fd->inode, ++ fd->inode->gfid, BR_STUB_NO_VERSIONING, 0); ++ frame->local = local; ++ ++ STACK_WIND (frame, br_stub_fsetxattr_bad_object_cbk, FIRST_CHILD (this), ++ FIRST_CHILD (this)->fops->fsetxattr, fd, dict, flags, ++ xdata); ++ return 0; ++unwind: ++ STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL); ++ return 0; ++} ++ + int + br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, int flags, dict_t *xdata) + { +- int32_t ret = 0; +- uint32_t val = 0; +- br_isignature_t *sign = NULL; ++ int32_t ret = 0; ++ uint32_t val = 0; ++ br_isignature_t *sign = NULL; + + if (!IA_ISREG (fd->inode->ia_type)) + goto wind; +@@ -927,11 +1020,18 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + goto done; + } + +- wind: +- STACK_WIND (frame, default_setxattr_cbk, +- FIRST_CHILD (this), FIRST_CHILD (this)->fops->fsetxattr, fd, +- dict, flags, xdata); +- done: ++ /* handle bad object */ ++ if (dict_get (dict, BITROT_OBJECT_BAD_KEY)) { ++ br_stub_handle_bad_object_key (frame, this, fd, ++ dict, flags, xdata); ++ goto done; ++ } ++ ++wind: ++ STACK_WIND (frame, default_fsetxattr_cbk, FIRST_CHILD (this), ++ FIRST_CHILD (this)->fops->fsetxattr, fd, dict, flags, ++ xdata); ++done: + return 0; + } + +@@ -940,6 +1040,59 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + + /** {{{ */ + ++/* {f}removexattr() */ ++ ++int32_t ++br_stub_removexattr (call_frame_t *frame, xlator_t *this, ++ loc_t *loc, const char *name, dict_t *xdata) ++{ ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ ++ if (!strcmp (BITROT_OBJECT_BAD_KEY, name)) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRS_MSG_REMOVE_BAD_OBJECT_XATTR, "Remove xattr called" ++ " on bad object xattr for file %s", loc->path); ++ goto unwind; ++ } ++ ++ STACK_WIND_TAIL (frame, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->removexattr, ++ loc, name, xdata); ++ return 0; ++unwind: ++ STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, NULL); ++ return 0; ++} ++ ++int32_t ++br_stub_fremovexattr (call_frame_t *frame, xlator_t *this, ++ fd_t *fd, const char *name, dict_t *xdata) ++{ ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ ++ if (!strcmp (BITROT_OBJECT_BAD_KEY, name)) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ BRS_MSG_REMOVE_BAD_OBJECT_XATTR, "Remove xattr called" ++ " on bad object xattr for inode %s", ++ uuid_utoa (fd->inode->gfid)); ++ goto unwind; ++ } ++ ++ STACK_WIND_TAIL (frame, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->fremovexattr, ++ fd, name, xdata); ++ return 0; ++unwind: ++ STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, NULL); ++ return 0; ++} ++ ++/** }}} */ ++ ++/** {{{ */ ++ + /* {f}getxattr() */ + + int +@@ -1044,6 +1197,7 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + br_vxattr_status_t status; + br_stub_local_t *local = NULL; + inode_t *inode = NULL; ++ gf_boolean_t bad_object = _gf_false; + + if (op_ret < 0) + goto unwind; +@@ -1055,7 +1209,11 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode = local->u.context.inode; + + op_ret = -1; +- status = br_version_xattr_state (xattr, &obuf, &sbuf); ++ status = br_version_xattr_state (xattr, &obuf, &sbuf, &bad_object); ++ ++ op_errno = EIO; ++ if (bad_object) ++ goto delkeys; + + op_errno = EINVAL; + if (status == BR_VXATTR_STATUS_INVALID) +@@ -1286,6 +1444,31 @@ unwind: + return 0; + } + ++int32_t ++br_stub_readv (call_frame_t *frame, xlator_t *this, ++ fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) ++{ ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ ++ GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, frame, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, fd, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, fd->inode, unwind); ++ ++ BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ ++ STACK_WIND_TAIL (frame, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->readv, fd, size, offset, ++ flags, xdata); ++ return 0; ++ ++unwind: ++ STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, NULL, 0, NULL, ++ NULL, NULL); ++ return 0; ++} ++ + /** + * The first write response on the first fd in the list of fds will set + * the flag to indicate that the inode is modified. The subsequent write +@@ -1367,6 +1550,8 @@ br_stub_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (ret) + goto unwind; + ++ BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ + /** + * The inode is not dirty and also witnessed atleast one successful + * modification operation. Therefore, subsequent operations need not +@@ -1486,6 +1671,8 @@ br_stub_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (ret) + goto unwind; + ++ BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ + if (!inc_version && modified) + goto wind; + +@@ -1616,6 +1803,8 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + if (ret) + goto cleanup_fd; + ++ BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ + if (!inc_version && modified) + goto wind; + +@@ -1689,15 +1878,14 @@ br_stub_open (call_frame_t *frame, xlator_t *this, + int32_t ret = -1; + br_stub_inode_ctx_t *ctx = NULL; + uint64_t ctx_addr = 0; ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; + + GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc, unwind); + GF_VALIDATE_OR_GOTO (this->name, fd, unwind); + GF_VALIDATE_OR_GOTO (this->name, fd->inode, unwind); + +- if (frame->root->pid == GF_CLIENT_PID_SCRUB) +- goto wind; +- + ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +@@ -1708,6 +1896,12 @@ br_stub_open (call_frame_t *frame, xlator_t *this, + } + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; ++ ++ BR_STUB_HANDLE_BAD_OBJECT (this, loc->inode, op_ret, op_errno, unwind); ++ ++ if (frame->root->pid == GF_CLIENT_PID_SCRUB) ++ goto wind; ++ + if (flags == O_RDONLY) + goto wind; + +@@ -1725,7 +1919,7 @@ wind: + FIRST_CHILD (this)->fops->open, loc, flags, fd, xdata); + return 0; + unwind: +- STACK_UNWIND_STRICT (open, frame, -1, EINVAL, NULL, NULL); ++ STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, NULL, NULL); + return 0; + } + +@@ -1784,7 +1978,7 @@ br_stub_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); + if (ret < 0) { + ret = br_stub_init_inode_versions (this, fd, inode, version, +- _gf_true); ++ _gf_true, _gf_false); + if (ret) { + op_ret = -1; + op_errno = EINVAL; +@@ -1834,7 +2028,7 @@ br_stub_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto unwind; + + ret = br_stub_init_inode_versions (this, NULL, inode, version, +- _gf_true); ++ _gf_true, _gf_false); + /** + * Like lookup, if init_inode_versions fail, return EINVAL + */ +@@ -1869,6 +2063,23 @@ unwind: + + /** }}} */ + ++/** ++ * As of now, only lookup searches for bad object xattr and marks the ++ * object as bad in its inode context if the xattr is present. But there ++ * is a possibility that, at the time of the lookup the object was not ++ * marked bad (i.e. bad object xattr was not set), and later its marked ++ * as bad. In this case, object is not bad, so when a fop such as open or ++ * readv or writev comes on the object, the fop will be sent downward instead ++ * of sending as error upwards. ++ * The solution for this is to do a getxattr for the below list of fops. ++ * lookup, readdirp, open, readv, writev. ++ * But doing getxattr for each of the above fops might be costly. ++ * So another method followed is to catch the bad file marking by the scrubber ++ * and set that info within the object's inode context. In this way getxattr ++ * calls can be avoided and bad objects can be caught instantly. Fetching the ++ * xattr is needed only in lookups when there is a brick restart or inode ++ * forget. ++ */ + static inline int32_t + br_stub_lookup_version (xlator_t *this, + uuid_t gfid, inode_t *inode, dict_t *xattr) +@@ -1877,6 +2088,7 @@ br_stub_lookup_version (xlator_t *this, + br_version_t *obuf = NULL; + br_signature_t *sbuf = NULL; + br_vxattr_status_t status; ++ gf_boolean_t bad_object = _gf_false; + + /** + * versioning xattrs were requested from POSIX. if available, figure +@@ -1886,13 +2098,13 @@ br_stub_lookup_version (xlator_t *this, + * operation (such as write(), etc..) triggers synchronization to + * disk. + */ +- status = br_version_xattr_state (xattr, &obuf, &sbuf); +- ++ status = br_version_xattr_state (xattr, &obuf, &sbuf, &bad_object); + version = ((status == BR_VXATTR_STATUS_FULL) + || (status == BR_VXATTR_STATUS_UNSIGNED)) + ? obuf->ongoingversion : BITROT_DEFAULT_CURRENT_VERSION; +- return br_stub_init_inode_versions (this, NULL, +- inode, version, _gf_true); ++ ++ return br_stub_init_inode_versions (this, NULL, inode, version, ++ _gf_true, bad_object); + } + + +@@ -1975,6 +2187,9 @@ br_stub_readdirp (call_frame_t *frame, xlator_t *this, + ret = dict_set_uint32 (dict, BITROT_SIGNING_VERSION_KEY, 0); + if (ret) + goto unwind; ++ ret = dict_set_uint32 (dict, BITROT_OBJECT_BAD_KEY, 0); ++ if (ret) ++ goto unwind; + + STACK_WIND (frame, br_stub_readdirp_cbk, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->readdirp, fd, size, +@@ -2009,18 +2224,51 @@ br_stub_lookup_cbk (call_frame_t *frame, void *cookie, + goto unwind; + if (!IA_ISREG (stbuf->ia_type)) + goto unwind; +- if (cookie != (void *) BR_STUB_REQUEST_COOKIE) ++ ++ /** ++ * If the object is bad, then "bad inode" marker has to be sent back ++ * in resoinse, for revalidated lookups as well. Some xlators such as ++ * quick-read might cache the data in revalidated lookup as fresh ++ * lookup would anyway have sent "bad inode" marker. ++ * In general send bad inode marker for every lookup operation on the ++ * bad object. ++ */ ++ if (cookie != (void *) BR_STUB_REQUEST_COOKIE) { ++ ret = br_stub_mark_xdata_bad_object (this, inode, xattr); ++ if (ret) { ++ op_ret = -1; ++ op_errno = EIO; ++ goto unwind; ++ } ++ + goto delkey; ++ } + + ret = br_stub_lookup_version (this, stbuf->ia_gfid, inode, xattr); + if (ret < 0) { + op_ret = -1; + op_errno = EINVAL; ++ goto delkey; ++ } ++ ++ /** ++ * If the object is bad, send "bad inode" marker back in response ++ * for xlator(s) to act accordingly (such as quick-read, etc..) ++ */ ++ ret = br_stub_mark_xdata_bad_object (this, inode, xattr); ++ if (ret) { ++ /** ++ * aaha! bad object, but sorry we would not ++ * satisfy the request on allocation failures. ++ */ ++ op_ret = -1; ++ op_errno = EIO; ++ goto unwind; + } + +- delkey: ++delkey: + br_stub_remove_vxattrs (xattr); +- unwind: ++unwind: + STACK_UNWIND_STRICT (lookup, frame, + op_ret, op_errno, inode, stbuf, xattr, postparent); + +@@ -2037,6 +2285,10 @@ br_stub_lookup (call_frame_t *frame, + uint64_t ctx_addr = 0; + gf_boolean_t xref = _gf_false; + ++ GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, loc, unwind); ++ GF_VALIDATE_OR_GOTO (this->name, loc->inode, unwind); ++ + ret = br_stub_get_inode_ctx (this, loc->inode, &ctx_addr); + if (ret < 0) + ctx_addr = 0; +@@ -2069,6 +2321,9 @@ br_stub_lookup (call_frame_t *frame, + ret = dict_set_uint32 (xdata, BITROT_SIGNING_VERSION_KEY, 0); + if (ret) + goto unwind; ++ ret = dict_set_uint32 (xdata, BITROT_OBJECT_BAD_KEY, 0); ++ if (ret) ++ goto unwind; + cookie = (void *) BR_STUB_REQUEST_COOKIE; + + wind: +@@ -2335,6 +2590,9 @@ struct xlator_fops fops = { + .truncate = br_stub_truncate, + .ftruncate = br_stub_ftruncate, + .mknod = br_stub_mknod, ++ .readv = br_stub_readv, ++ .removexattr = br_stub_removexattr, ++ .fremovexattr = br_stub_fremovexattr, + }; + + struct xlator_cbks cbks = { +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +index 48c7a37..e5649fc 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +@@ -37,6 +37,7 @@ typedef struct br_stub_inode_ctx { + int info_sign; + struct list_head fd_list; /* list of open fds or fds participating in + write operations */ ++ gf_boolean_t bad_object; + } br_stub_inode_ctx_t; + + typedef struct br_stub_fd { +@@ -85,6 +86,18 @@ typedef struct br_stub_private { + struct mem_pool *local_pool; + } br_stub_private_t; + ++static inline gf_boolean_t ++__br_stub_is_bad_object (br_stub_inode_ctx_t *ctx) ++{ ++ return ctx->bad_object; ++} ++ ++static inline void ++__br_stub_mark_object_bad (br_stub_inode_ctx_t *ctx) ++{ ++ ctx->bad_object = _gf_true; ++} ++ + /* inode writeback helpers */ + static inline void + __br_stub_mark_inode_dirty (br_stub_inode_ctx_t *ctx) +@@ -370,12 +383,93 @@ static inline void + br_stub_remove_vxattrs (dict_t *xattr) + { + if (xattr) { ++ dict_del (xattr, BITROT_OBJECT_BAD_KEY); + dict_del (xattr, BITROT_CURRENT_VERSION_KEY); + dict_del (xattr, BITROT_SIGNING_VERSION_KEY); + dict_del (xattr, BITROT_SIGNING_XATTR_SIZE_KEY); + } + } + ++#define BR_STUB_HANDLE_BAD_OBJECT(this, inode, op_ret, op_errno, label) \ ++ do { \ ++ if (br_stub_is_bad_object (this, inode)) { \ ++ gf_msg (this->name, GF_LOG_ERROR, 0, \ ++ BRS_MSG_BAD_OBJECT_ACCESS, \ ++ "%s is a bad object. Returning", \ ++ uuid_utoa (inode->gfid)); \ ++ op_ret = -1; \ ++ op_errno = EIO; \ ++ goto label; \ ++ } \ ++ } while (0) ++ ++static inline gf_boolean_t ++br_stub_is_bad_object (xlator_t *this, inode_t *inode) ++{ ++ gf_boolean_t bad_object = _gf_false; ++ uint64_t ctx_addr = 0; ++ br_stub_inode_ctx_t *ctx = NULL; ++ int32_t ret = -1; ++ ++ ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_SET_CONTEXT_FAILED, ++ "failed to get the inode context for the inode %s", ++ uuid_utoa (inode->gfid)); ++ goto out; ++ } ++ ++ ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; ++ ++ LOCK (&inode->lock); ++ { ++ bad_object = __br_stub_is_bad_object (ctx); ++ } ++ UNLOCK (&inode->lock); ++ ++out: ++ return bad_object; ++} ++ ++static inline int32_t ++br_stub_mark_object_bad (xlator_t *this, inode_t *inode) ++{ ++ int32_t ret = -1; ++ uint64_t ctx_addr = 0; ++ br_stub_inode_ctx_t *ctx = NULL; ++ ++ ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " ++ "inode context for the inode %s", ++ uuid_utoa (inode->gfid)); ++ goto out; ++ } ++ ++ ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; ++ ++ LOCK (&inode->lock); ++ { ++ __br_stub_mark_object_bad (ctx); ++ } ++ UNLOCK (&inode->lock); ++ ++out: ++ return ret; ++} ++ ++static inline int32_t ++br_stub_mark_xdata_bad_object (xlator_t *this, inode_t *inode, dict_t *xdata) ++{ ++ int32_t ret = 0; ++ ++ if (br_stub_is_bad_object (this, inode)) ++ ret = dict_set_int32 (xdata, GLUSTERFS_BAD_INODE, 1); ++ ++ return ret; ++} ++ + int32_t + br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx); + +diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c +index c6913ee..1426ae5 100644 +--- a/xlators/performance/quick-read/src/quick-read.c ++++ b/xlators/performance/quick-read/src/quick-read.c +@@ -409,6 +409,11 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + } + ++ if (dict_get (xdata, GLUSTERFS_BAD_INODE)) { ++ qr_inode_prune (this, inode); ++ goto out; ++ } ++ + if (dict_get (xdata, "sh-failed")) { + qr_inode_prune (this, inode); + goto out; +-- +1.7.1 + diff --git a/SOURCES/0186-features-bit-rot-stub-do-not-allow-setxattr-and-remo.patch b/SOURCES/0186-features-bit-rot-stub-do-not-allow-setxattr-and-remo.patch new file mode 100644 index 0000000..76bc9aa --- /dev/null +++ b/SOURCES/0186-features-bit-rot-stub-do-not-allow-setxattr-and-remo.patch @@ -0,0 +1,208 @@ +From b1de5fd8f480bb6cd034242c49a1f85ff6c21e51 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Wed, 24 Jun 2015 20:06:01 +0530 +Subject: [PATCH 186/190] features/bit-rot-stub: do not allow setxattr and removexattr on bit-rot xattrs + + Backport of http://review.gluster.org/11389 + +* setxattr and {f}removexattr of versioning, signature and bad-file xattrs are + returned with error. + +Change-Id: I21b25e06b6b78309c0ddd155345fec8765e03352 +BUG: 1224227 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51758 +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + .../bit-rot/src/stub/bit-rot-stub-messages.h | 10 ++- + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 103 ++++++++++++++++++- + 2 files changed, 106 insertions(+), 7 deletions(-) + +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +index db5736a..532c2be 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +@@ -167,7 +167,14 @@ + * @recommendedaction + * + */ +-#define BRS_MSG_REMOVE_BAD_OBJECT_XATTR (GLFS_BITROT_STUB_BASE + 18) ++#define BRS_MSG_REMOVE_INTERNAL_XATTR (GLFS_BITROT_STUB_BASE + 18) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define BRS_MSG_SET_INTERNAL_XATTR (GLFS_BITROT_STUB_BASE + 19) + /*! + * @messageid + * @diagnosis +@@ -182,5 +189,6 @@ + * + */ + /*------------*/ ++ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_BITROT_STUB_MESSAGES_H_ */ +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index de81510..41c8359 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -993,6 +993,37 @@ unwind: + return 0; + } + ++ ++/** ++ * As of now, versioning is done by the stub (though as a setxattr ++ * operation) as part of inode modification operations such as writev, ++ * truncate, ftruncate. And signing is done by BitD by a fsetxattr call. ++ * So any kind of setxattr coming on the versioning and the signing xattr is ++ * not allowed (i.e. BITROT_CURRENT_VERSION_KEY and BITROT_SIGNING_VERSION_KEY). ++ * In future if BitD/scrubber are allowed to change the versioning ++ * xattrs (though I cannot see a reason for it as of now), then the below ++ * function can be modified to block setxattr on version for only applications. ++ * ++ * NOTE: BitD sends sign request on GLUSTERFS_SET_OBJECT_SIGNATURE key. ++ * BITROT_SIGNING_VERSION_KEY is the xattr used to save the signature. ++ * ++ */ ++static int32_t ++br_stub_handle_internal_xattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ++ char *key) ++{ ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_SET_INTERNAL_XATTR, "setxattr called" ++ " on the internal xattr %s for inode %s", key, ++ uuid_utoa (fd->inode->gfid)); ++ ++ STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL); ++ return 0; ++} ++ + int + br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, int flags, dict_t *xdata) +@@ -1013,6 +1044,20 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + goto done; + } + ++ /* signing xattr */ ++ if (dict_get(dict, BITROT_SIGNING_VERSION_KEY)) { ++ br_stub_handle_internal_xattr (frame, this, fd, ++ BITROT_SIGNING_VERSION_KEY); ++ goto done; ++ } ++ ++ /* version xattr */ ++ if (dict_get(dict, BITROT_CURRENT_VERSION_KEY)) { ++ br_stub_handle_internal_xattr (frame, this, fd, ++ BITROT_CURRENT_VERSION_KEY); ++ goto done; ++ } ++ + /* object reopen request */ + ret = dict_get_uint32 (dict, BR_REOPEN_SIGN_HINT_KEY, &val); + if (!ret) { +@@ -1035,6 +1080,45 @@ done: + return 0; + } + ++ ++/** ++ * Currently BitD and scrubber are doing fsetxattr to either sign the object ++ * or to mark it as bad. Hence setxattr on any of those keys is denied directly ++ * without checking from where the fop is coming. ++ * Later, if BitD or Scrubber does setxattr of those keys, then appropriate ++ * check has to be added below. ++ */ ++int ++br_stub_setxattr (call_frame_t *frame, xlator_t *this, ++ loc_t *loc, dict_t *dict, int flags, dict_t *xdata) ++{ ++ int32_t op_ret = -1; ++ int32_t op_errno = EINVAL; ++ char dump[64*1024] = {0,}; ++ char *format = "(%s:%s)"; ++ ++ if (dict_get (dict, GLUSTERFS_SET_OBJECT_SIGNATURE) || ++ dict_get (dict, BR_REOPEN_SIGN_HINT_KEY) || ++ dict_get (dict, BITROT_OBJECT_BAD_KEY) || ++ dict_get (dict, BITROT_SIGNING_VERSION_KEY) || ++ dict_get (dict, BITROT_CURRENT_VERSION_KEY)) { ++ dict_dump_to_str (dict, dump, sizeof(dump), format); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_SET_INTERNAL_XATTR, "setxattr called on " ++ "internal xattr %s", dump); ++ goto unwind; ++ } ++ ++ ++ STACK_WIND_TAIL (frame, FIRST_CHILD (this), ++ FIRST_CHILD (this)->fops->setxattr, loc, dict, flags, ++ xdata); ++ return 0; ++unwind: ++ STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL); ++ return 0; ++} ++ + /** }}} */ + + +@@ -1049,13 +1133,16 @@ br_stub_removexattr (call_frame_t *frame, xlator_t *this, + int32_t op_ret = -1; + int32_t op_errno = EINVAL; + +- if (!strcmp (BITROT_OBJECT_BAD_KEY, name)) { ++ if (!strcmp (BITROT_OBJECT_BAD_KEY, name) || ++ !strcmp (BITROT_SIGNING_VERSION_KEY, name) || ++ !strcmp (BITROT_CURRENT_VERSION_KEY, name)) { + gf_msg (this->name, GF_LOG_WARNING, 0, +- BRS_MSG_REMOVE_BAD_OBJECT_XATTR, "Remove xattr called" +- " on bad object xattr for file %s", loc->path); ++ BRS_MSG_REMOVE_INTERNAL_XATTR, "removexattr called" ++ " on internal xattr %s for file %s", name, loc->path); + goto unwind; + } + ++ + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->removexattr, + loc, name, xdata); +@@ -1072,14 +1159,17 @@ br_stub_fremovexattr (call_frame_t *frame, xlator_t *this, + int32_t op_ret = -1; + int32_t op_errno = EINVAL; + +- if (!strcmp (BITROT_OBJECT_BAD_KEY, name)) { ++ if (!strcmp (BITROT_OBJECT_BAD_KEY, name) || ++ !strcmp (BITROT_SIGNING_VERSION_KEY, name) || ++ !strcmp (BITROT_CURRENT_VERSION_KEY, name)) { + gf_msg (this->name, GF_LOG_WARNING, 0, +- BRS_MSG_REMOVE_BAD_OBJECT_XATTR, "Remove xattr called" +- " on bad object xattr for inode %s", ++ BRS_MSG_REMOVE_INTERNAL_XATTR, "removexattr called" ++ " on internal xattr %s for inode %s", name, + uuid_utoa (fd->inode->gfid)); + goto unwind; + } + ++ + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, + fd, name, xdata); +@@ -2593,6 +2683,7 @@ struct xlator_fops fops = { + .readv = br_stub_readv, + .removexattr = br_stub_removexattr, + .fremovexattr = br_stub_fremovexattr, ++ .setxattr = br_stub_setxattr, + }; + + struct xlator_cbks cbks = { +-- +1.7.1 + diff --git a/SOURCES/0187-tier-ctr-Ignore-creation-of-T-file-and-Ctr-Lookup-he.patch b/SOURCES/0187-tier-ctr-Ignore-creation-of-T-file-and-Ctr-Lookup-he.patch new file mode 100644 index 0000000..c5ced61 --- /dev/null +++ b/SOURCES/0187-tier-ctr-Ignore-creation-of-T-file-and-Ctr-Lookup-he.patch @@ -0,0 +1,877 @@ +From e9fd069cea243707a47d9892f04e488ddae6012c Mon Sep 17 00:00:00 2001 +From: Dan Lambright +Date: Sat, 27 Jun 2015 07:36:36 -0400 +Subject: [PATCH 187/190] tier/ctr: Ignore creation of T file and Ctr Lookup heal improvememnts + +This is a back port of 11334 + +1) Ignore creation of T file in ctr_mknod +2) Ignore lookup for T file in ctr_lookup +3) Ctr_lookup: + a. If the gfid and pgfid in empty dont record + b. Decreased log level for multiple heal attempts + c. Inode/File heal happens after an expiry period, which is configurable. + d. Hardlink heal happens after an expiry period, which is configurable. + +> Change-Id: Id8eb5092e78beaec22d05f5283645081619e2452 +> BUG: 1235269 +> Signed-off-by: Joseph Fernandes +> Reviewed-on: http://review.gluster.org/11334 +> Tested-by: Gluster Build System +> Reviewed-by: Dan Lambright +> Tested-by: Dan Lambright + +Change-Id: I244f3155bdb27227c060cd256c5801ec8ea7cc90 +BUG: 1232625 +Signed-off-by: Dan Lambright +Reviewed-on: https://code.engineering.redhat.com/gerrit/51756 +Reviewed-by: Joseph Fernandes +Tested-by: Joseph Fernandes +--- + libglusterfs/src/gfdb/gfdb_data_store_types.h | 15 ++- + libglusterfs/src/gfdb/gfdb_sqlite3.c | 2 - + libglusterfs/src/gfdb/gfdb_sqlite3_helper.c | 49 ++++++--- + xlators/cluster/dht/src/tier.h | 5 +- + .../changetimerecorder/src/changetimerecorder.c | 121 +++++++++++++++++--- + .../features/changetimerecorder/src/ctr-helper.c | 10 ++ + .../features/changetimerecorder/src/ctr-helper.h | 108 +++++++++++++++++- + .../changetimerecorder/src/ctr-xlator-ctx.c | 35 ++++++- + .../changetimerecorder/src/ctr-xlator-ctx.h | 4 + + xlators/mgmt/glusterd/src/glusterd-volgen.c | 8 ++ + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 24 ++++ + 11 files changed, 336 insertions(+), 45 deletions(-) + +diff --git a/libglusterfs/src/gfdb/gfdb_data_store_types.h b/libglusterfs/src/gfdb/gfdb_data_store_types.h +index f642c63..fb41c38 100644 +--- a/libglusterfs/src/gfdb/gfdb_data_store_types.h ++++ b/libglusterfs/src/gfdb/gfdb_data_store_types.h +@@ -26,6 +26,16 @@ + #include "dict.h" + #include "libglusterfs-messages.h" + ++/* ++ * Helps in dynamically choosing log level ++ * */ ++static inline gf_loglevel_t ++_gfdb_log_level (gf_loglevel_t given_level, ++ gf_boolean_t ignore_level) ++{ ++ return (ignore_level) ? GF_LOG_DEBUG : given_level; ++} ++ + typedef enum gf_db_operation { + GFDB_INVALID_DB_OP = -1, + /* Query DB OPS : All the Query DB_OP should be added */ +@@ -71,8 +81,6 @@ typedef enum gf_db_operation { + #define GF_COL_LINK_UPDATE "LINK_UPDATE" + + +- +- + /***********************Time related********************************/ + /*1 sec = 1000000 microsec*/ + #define GFDB_MICROSEC 1000000 +@@ -305,6 +313,9 @@ typedef struct gfdb_db_record { + /* Global flag to Record/Not Record wind or wind time. + * This flag will overrule do_record_uwind_time*/ + gf_boolean_t do_record_times; ++ /* Ignoring errors while inserting. ++ * */ ++ gf_boolean_t ignore_errors; + } gfdb_db_record_t; + + +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c +index 7eca03f..94553fb 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c +@@ -176,8 +176,6 @@ sql_stmt_fini (char **sql_stmt) + + /****************************************************************************** + * DB Essential functions used by +- * create/insert/delete/update/query functions +- * > execute_sqlstmt () + * > gf_open_sqlite3_conn () + * > gf_close_sqlite3_conn () + * ***************************************************************************/ +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c +index f3e0e97..40ee24c 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3_helper.c +@@ -9,7 +9,7 @@ + */ + + #include "gfdb_sqlite3_helper.h" +-#include "libglusterfs-messages.h" ++ + + #define GFDB_SQL_STMT_SIZE 256 + +@@ -309,7 +309,8 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + char *pargfid, + char *basename, + char *basepath, +- gf_boolean_t link_consistency) ++ gf_boolean_t link_consistency, ++ gf_boolean_t ignore_errors) + { + int ret = -1; + sqlite3_stmt *insert_stmt = NULL; +@@ -332,8 +333,11 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, insert_str, -1, + &insert_stmt, 0); + if (ret != SQLITE_OK) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, +- LG_MSG_PREPARE_FAILED, "Failed preparing insert " ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), ++ 0, ++ LG_MSG_PREPARE_FAILED, ++ "Failed preparing insert " + "statment %s : %s", insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -343,8 +347,11 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind gfid*/ + ret = sqlite3_bind_text (insert_stmt, 1, gfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, +- LG_MSG_BINDING_FAILED, "Failed binding gfid %s : %s", ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), ++ 0, ++ LG_MSG_BINDING_FAILED, ++ "Failed binding gfid %s : %s", + gfid, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; + goto out; +@@ -353,8 +360,10 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind pargfid*/ + ret = sqlite3_bind_text (insert_stmt, 2, pargfid, -1, NULL); + if (ret != SQLITE_OK) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, +- LG_MSG_BINDING_FAILED, "Failed binding parent gfid %s " ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), ++ 0, LG_MSG_BINDING_FAILED, ++ "Failed binding parent gfid %s " + ": %s", pargfid, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -364,8 +373,9 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind basename*/ + ret = sqlite3_bind_text (insert_stmt, 3, basename, -1, NULL); + if (ret != SQLITE_OK) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, +- LG_MSG_BINDING_FAILED, ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), ++ 0, LG_MSG_BINDING_FAILED, + "Failed binding basename %s : %s", basename, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -375,8 +385,10 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + /*Bind basepath*/ + ret = sqlite3_bind_text (insert_stmt, 4, basepath, -1, NULL); + if (ret != SQLITE_OK) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, +- LG_MSG_BINDING_FAILED, "Failed binding basepath %s : " ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), 0, ++ LG_MSG_BINDING_FAILED, ++ "Failed binding basepath %s : " + "%s", basepath, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -385,8 +397,11 @@ gf_sql_insert_link (gf_sql_connection_t *sql_conn, + + /*Execute the prepare statement*/ + if (sqlite3_step (insert_stmt) != SQLITE_DONE) { +- gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_EXEC_FAILED, +- "Failed executing the prepared stmt %s %s %s %s %s : %s", ++ gf_msg (GFDB_STR_SQLITE3, ++ _gfdb_log_level (GF_LOG_ERROR, ignore_errors), ++ 0, LG_MSG_EXEC_FAILED, ++ "Failed executing the prepared " ++ "stmt %s %s %s %s %s : %s", + gfid, pargfid, basename, basepath, insert_str, + sqlite3_errmsg (sql_conn->sqlite3_db_conn)); + ret = -1; +@@ -777,7 +792,8 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + gfid_str, pargfid_str, + gfdb_db_record->file_name, + gfdb_db_record->file_path, +- gfdb_db_record->link_consistency); ++ gfdb_db_record->link_consistency, ++ gfdb_db_record->ignore_errors); + if (ret) { + gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, + LG_MSG_INSERT_FAILED, "Failed " +@@ -836,7 +852,8 @@ gf_sql_insert_wind (gf_sql_connection_t *sql_conn, + gfid_str, pargfid_str, + gfdb_db_record->file_name, + gfdb_db_record->file_path, +- gfdb_db_record->link_consistency); ++ gfdb_db_record->link_consistency, ++ gfdb_db_record->ignore_errors); + if (ret) { + gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, + 0, LG_MSG_INSERT_FAILED, +diff --git a/xlators/cluster/dht/src/tier.h b/xlators/cluster/dht/src/tier.h +index 7d4ea6b..34631b0 100644 +--- a/xlators/cluster/dht/src/tier.h ++++ b/xlators/cluster/dht/src/tier.h +@@ -27,9 +27,8 @@ + + #define DEFAULT_PROMOTE_FREQ_SEC 120 + #define DEFAULT_DEMOTE_FREQ_SEC 120 +-#define DEFAULT_WRITE_FREQ_SEC 120 +-#define DEFAULT_READ_FREQ_SEC 120 +- ++#define DEFAULT_WRITE_FREQ_SEC 0 ++#define DEFAULT_READ_FREQ_SEC 0 + /* + * Size of timer wheel. We would not promote or demote less + * frequently than this number. +diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c +index 1fdeb7c..703df49 100644 +--- a/xlators/features/changetimerecorder/src/changetimerecorder.c ++++ b/xlators/features/changetimerecorder/src/changetimerecorder.c +@@ -114,7 +114,7 @@ ctr_lookup_wind(call_frame_t *frame, + /*Don't record time at all*/ + CTR_DB_REC(ctr_local).do_record_times = _gf_false; + +- /*Copy gfid into db record*/ ++ /* Copy gfid into db record*/ + gf_uuid_copy (CTR_DB_REC(ctr_local).gfid, + *(ctr_inode_cx->gfid)); + +@@ -131,6 +131,12 @@ ctr_lookup_wind(call_frame_t *frame, + strcpy (CTR_DB_REC(ctr_local).file_path, + NEW_LINK_CX(ctr_inode_cx)->basepath); + ++ /* Since we are in lookup we can ignore errors while ++ * Inserting in the DB, because there may be many ++ * to write to the DB attempts for healing. ++ * We dont want to log all failed attempts and ++ * bloat the log*/ ++ ctr_local->gfdb_db_record.ignore_errors = _gf_true; + } + + ret = 0; +@@ -171,8 +177,11 @@ ctr_lookup_unwind (call_frame_t *frame, + ret = insert_record(_priv->_db_conn, + &ctr_local->gfdb_db_record); + if (ret == -1) { +- gf_msg(this->name, GF_LOG_ERROR, 0, +- CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, ++ gf_msg (this->name, ++ _gfdb_log_level (GF_LOG_ERROR, ++ ctr_local-> ++ gfdb_db_record.ignore_errors), ++ 0, CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, + "UNWIND: Error filling ctr local"); + goto out; + } +@@ -198,9 +207,11 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, dict_t *dict, struct iatt *postparent) + { +- int ret = -1; +- ctr_xlator_ctx_t *ctr_xlator_ctx; +- gf_ctr_local_t *ctr_local = NULL; ++ int ret = -1; ++ ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; ++ gf_ctr_local_t *ctr_local = NULL; ++ ctr_heal_ret_val_t ret_val = CTR_CTX_ERROR; ++ gf_boolean_t _is_heal_needed = _gf_false; + + CTR_IS_DISABLED_THEN_GOTO(this, out); + CTR_IF_INTERNAL_FOP_THEN_GOTO (frame, dict, out); +@@ -223,34 +234,70 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + } + ++ /* if the lookup is for dht link donot record*/ ++ if (dht_is_linkfile (buf, dict)) { ++ gf_msg_trace (this->name, 0, "Ignoring Lookup " ++ "for dht link file"); ++ goto out; ++ } ++ + ctr_local = frame->local; + /*Assign the proper inode type*/ + ctr_local->ia_inode_type = inode->ia_type; + ++ /* Copy gfid directly from inode */ ++ gf_uuid_copy (CTR_DB_REC(ctr_local).gfid, inode->gfid); ++ ++ /* Checking if gfid and parent gfid is valid */ ++ if (gf_uuid_is_null(CTR_DB_REC(ctr_local).gfid) || ++ gf_uuid_is_null(CTR_DB_REC(ctr_local).pargfid)) { ++ gf_msg_trace (this->name, 0, ++ "Invalid GFID"); ++ goto out; ++ } ++ + /* if its a first entry + * then mark the ctr_record for create + * A create will attempt a file and a hard link created in the db*/ + ctr_xlator_ctx = get_ctr_xlator_ctx (this, inode); + if (!ctr_xlator_ctx) { ++ /* This marks inode heal */ + CTR_DB_REC(ctr_local).gfdb_fop_type = GFDB_FOP_CREATE_WRITE; ++ _is_heal_needed = _gf_true; + } + + /* Copy the correct gfid from resolved inode */ + gf_uuid_copy (CTR_DB_REC(ctr_local).gfid, inode->gfid); + + /* Add hard link to the list */ +- ret = add_hard_link_ctx (frame, this, inode); +- if (ret < 0) { +- gf_msg_trace (this->name, 0, "Failed adding hard link"); ++ ret_val = add_hard_link_ctx (frame, this, inode); ++ if (ret_val == CTR_CTX_ERROR) { ++ gf_msg_trace (this->name, 0, ++ "Failed adding hardlink to list"); + goto out; + } ++ /* If inode needs healing then heal the hardlink also */ ++ else if (ret_val & CTR_TRY_INODE_HEAL) { ++ /* This marks inode heal */ ++ CTR_DB_REC(ctr_local).gfdb_fop_type = GFDB_FOP_CREATE_WRITE; ++ _is_heal_needed = _gf_true; ++ } ++ /* If hardlink needs healing */ ++ else if (ret_val & CTR_TRY_HARDLINK_HEAL) { ++ _is_heal_needed = _gf_true; ++ } + +- /* Inserts the ctr_db_record populated by ctr_lookup_wind ++ /* If lookup heal needed */ ++ if (!_is_heal_needed) ++ goto out; ++ ++ /* FINALLY HEAL : Inserts the ctr_db_record populated by ctr_lookup_wind + * in to the db. It also destroys the frame->local + * created by ctr_lookup_wind */ + ret = ctr_lookup_unwind(frame, this); + if (ret) { +- gf_msg_trace (this->name, 0, "Failed inserting link wind"); ++ gf_msg_trace (this->name, 0, ++ "Failed healing/inserting link"); + } + + +@@ -793,6 +840,7 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + /*Last link that was deleted*/ + else if (remaining_links == 1) { ++ + ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, + GFDB_FOP_UNDEL_ALL); + if (ret) { +@@ -819,6 +867,7 @@ ctr_unlink (call_frame_t *frame, xlator_t *this, + gf_ctr_link_context_t ctr_link_cx; + gf_ctr_link_context_t *_link_cx = &ctr_link_cx; + gf_boolean_t is_xdata_created = _gf_false; ++ struct iatt dummy_stat = {0}; + + GF_ASSERT (frame); + +@@ -835,6 +884,12 @@ ctr_unlink (call_frame_t *frame, xlator_t *this, + /*Internal FOP*/ + _inode_cx->is_internal_fop = CTR_IS_INTERNAL_FOP(frame, xdata); + ++ /* If its a internal FOP and dht link file donot record*/ ++ if (_inode_cx->is_internal_fop && ++ dht_is_linkfile (&dummy_stat, xdata)) { ++ goto out; ++ } ++ + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +@@ -1014,12 +1069,13 @@ ctr_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + struct iatt *postparent, dict_t *xdata) + { + int ret = -1; ++ ctr_heal_ret_val_t ret_val = CTR_CTX_ERROR; + + CTR_IS_DISABLED_THEN_GOTO(this, out); + + /* Add hard link to the list */ +- ret = add_hard_link_ctx (frame, this, inode); +- if (ret) { ++ ret_val = add_hard_link_ctx (frame, this, inode); ++ if (ret_val == CTR_CTX_ERROR) { + gf_msg_trace (this->name, 0, "Failed adding hard link"); + } + +@@ -1053,6 +1109,7 @@ ctr_mknod (call_frame_t *frame, xlator_t *this, + uuid_t *ptr_gfid = &gfid; + + CTR_IS_DISABLED_THEN_GOTO(this, out); ++ CTR_IF_INTERNAL_FOP_THEN_GOTO (frame, xdata, out); + + GF_ASSERT(frame); + GF_ASSERT(frame->root); +@@ -1073,9 +1130,6 @@ ctr_mknod (call_frame_t *frame, xlator_t *this, + *ptr_gfid, _link_cx, NULL, + GFDB_FOP_CREATE_WRITE, GFDB_FOP_WIND); + +- /*Internal FOP*/ +- _inode_cx->is_internal_fop = CTR_IS_INTERNAL_FOP(frame, xdata); +- + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +@@ -1140,6 +1194,7 @@ ctr_create (call_frame_t *frame, xlator_t *this, + void *uuid_req = NULL; + uuid_t gfid = {0,}; + uuid_t *ptr_gfid = &gfid; ++ struct iatt dummy_stat = {0}; + + CTR_IS_DISABLED_THEN_GOTO(this, out); + +@@ -1167,6 +1222,12 @@ ctr_create (call_frame_t *frame, xlator_t *this, + /*Internal FOP*/ + _inode_cx->is_internal_fop = CTR_IS_INTERNAL_FOP(frame, xdata); + ++ /* If its a internal FOP and dht link file donot record*/ ++ if (_inode_cx->is_internal_fop && ++ dht_is_linkfile (&dummy_stat, xdata)) { ++ goto out; ++ } ++ + /*record into the database*/ + ret = ctr_insert_wind(frame, this, &ctr_inode_cx); + if (ret) { +@@ -1222,6 +1283,7 @@ ctr_link (call_frame_t *frame, xlator_t *this, + gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; + gf_ctr_link_context_t ctr_link_cx; + gf_ctr_link_context_t *_link_cx = &ctr_link_cx; ++ struct iatt dummy_stat = {0}; + + CTR_IS_DISABLED_THEN_GOTO(this, out); + +@@ -1240,6 +1302,13 @@ ctr_link (call_frame_t *frame, xlator_t *this, + /*Internal FOP*/ + _inode_cx->is_internal_fop = CTR_IS_INTERNAL_FOP(frame, xdata); + ++ /* If its a internal FOP and dht link file donot record*/ ++ if (_inode_cx->is_internal_fop && ++ dht_is_linkfile (&dummy_stat, xdata)) { ++ goto out; ++ } ++ ++ + /*record into the database*/ + ret = ctr_insert_wind(frame, this, _inode_cx); + if (ret) { +@@ -1334,6 +1403,14 @@ reconfigure (xlator_t *this, dict_t *options) + GF_OPTION_RECONF ("ctr_link_consistency", _priv->ctr_link_consistency, + options, bool, out); + ++ GF_OPTION_RECONF ("ctr_inode_heal_expire_period", ++ _priv->ctr_inode_heal_expire_period, ++ options, uint64, out); ++ ++ GF_OPTION_RECONF ("ctr_hardlink_heal_expire_period", ++ _priv->ctr_hardlink_heal_expire_period, ++ options, uint64, out); ++ + GF_OPTION_RECONF ("record-exit", _priv->ctr_record_unwind, options, + bool, out); + +@@ -1385,6 +1462,10 @@ init (xlator_t *this) + _priv->gfdb_sync_type = GFDB_DB_SYNC; + _priv->enabled = _gf_true; + _priv->_db_conn = NULL; ++ _priv->ctr_hardlink_heal_expire_period = ++ CTR_DEFAULT_HARDLINK_EXP_PERIOD; ++ _priv->ctr_inode_heal_expire_period = ++ CTR_DEFAULT_INODE_EXP_PERIOD; + + /*Extract ctr xlator options*/ + ret_db = extract_ctr_options (this, _priv); +@@ -1549,6 +1630,14 @@ struct volume_options options[] = { + .value = {"on", "off"}, + .default_value = "off" + }, ++ { .key = {"ctr_hardlink_heal_expire_period"}, ++ .type = GF_OPTION_TYPE_INT, ++ .default_value = "300" ++ }, ++ { .key = {"ctr_inode_heal_expire_period"}, ++ .type = GF_OPTION_TYPE_INT, ++ .default_value = "300" ++ }, + { .key = {"hot-brick"}, + .type = GF_OPTION_TYPE_BOOL, + .value = {"on", "off"}, +diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c +index c4d9769..f5d4c47 100644 +--- a/xlators/features/changetimerecorder/src/ctr-helper.c ++++ b/xlators/features/changetimerecorder/src/ctr-helper.c +@@ -276,6 +276,16 @@ int extract_ctr_options (xlator_t *this, gf_ctr_private_t *_priv) { + GF_OPTION_INIT ("ctr_link_consistency", _priv->ctr_link_consistency, + bool, out); + ++ /*Extract ctr_inode_heal_expire_period */ ++ GF_OPTION_INIT ("ctr_inode_heal_expire_period", ++ _priv->ctr_inode_heal_expire_period, ++ uint64, out); ++ ++ /*Extract ctr_hardlink_heal_expire_period*/ ++ GF_OPTION_INIT ("ctr_hardlink_heal_expire_period", ++ _priv->ctr_hardlink_heal_expire_period, ++ uint64, out); ++ + /*Extract flag for hot tier brick*/ + GF_OPTION_INIT ("hot-brick", _priv->ctr_hot_brick, bool, out); + +diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h +index a3df971..82a0c8b 100644 +--- a/xlators/features/changetimerecorder/src/ctr-helper.h ++++ b/xlators/features/changetimerecorder/src/ctr-helper.h +@@ -31,6 +31,9 @@ + #include "ctr-xlator-ctx.h" + #include "ctr-messages.h" + ++#define CTR_DEFAULT_HARDLINK_EXP_PERIOD 300 /* Five mins */ ++#define CTR_DEFAULT_INODE_EXP_PERIOD 300 /* Five mins */ ++ + /*CTR Xlator Private structure*/ + typedef struct gf_ctr_private { + gf_boolean_t enabled; +@@ -43,6 +46,8 @@ typedef struct gf_ctr_private { + gfdb_db_type_t gfdb_db_type; + gfdb_sync_type_t gfdb_sync_type; + gfdb_conn_node_t *_db_conn; ++ uint64_t ctr_hardlink_heal_expire_period; ++ uint64_t ctr_inode_heal_expire_period; + } gf_ctr_private_t; + + +@@ -472,19 +477,91 @@ out: + + /******************************* Hard link function ***************************/ + +-static inline int ++static inline gf_boolean_t ++__is_inode_expired (ctr_xlator_ctx_t *ctr_xlator_ctx, ++ gf_ctr_private_t *_priv, ++ gfdb_time_t *current_time) ++{ ++ gf_boolean_t ret = _gf_false; ++ uint64_t time_diff = 0; ++ ++ GF_ASSERT (ctr_xlator_ctx); ++ GF_ASSERT (_priv); ++ GF_ASSERT (current_time); ++ ++ time_diff = current_time->tv_sec - ++ ctr_xlator_ctx->inode_heal_period; ++ ++ ret = (time_diff >= _priv->ctr_inode_heal_expire_period) ? ++ _gf_true : _gf_false; ++ return ret; ++} ++ ++static inline gf_boolean_t ++__is_hardlink_expired (ctr_hard_link_t *ctr_hard_link, ++ gf_ctr_private_t *_priv, ++ gfdb_time_t *current_time) ++{ ++ gf_boolean_t ret = _gf_false; ++ uint64_t time_diff = 0; ++ ++ GF_ASSERT (ctr_hard_link); ++ GF_ASSERT (_priv); ++ GF_ASSERT (current_time); ++ ++ time_diff = current_time->tv_sec - ++ ctr_hard_link->hardlink_heal_period; ++ ++ ret = ret || (time_diff >= _priv->ctr_hardlink_heal_expire_period) ? ++ _gf_true : _gf_false; ++ ++ return ret; ++} ++ ++ ++/* Return values of heal*/ ++typedef enum ctr_heal_ret_val { ++ CTR_CTX_ERROR = -1, ++ /* No healing required */ ++ CTR_TRY_NO_HEAL = 0, ++ /* Try healing hard link */ ++ CTR_TRY_HARDLINK_HEAL = 1, ++ /* Try healing inode */ ++ CTR_TRY_INODE_HEAL = 2, ++} ctr_heal_ret_val_t; ++ ++ ++ ++/** ++ * @brief Function to add hard link to the inode context variable. ++ * The inode context maintainences a in-memory list. This is used ++ * smart healing of database. ++ * @param frame of the FOP ++ * @param this is the Xlator instant ++ * @param inode ++ * @return Return ctr_heal_ret_val_t ++ */ ++ ++static inline ctr_heal_ret_val_t + add_hard_link_ctx (call_frame_t *frame, + xlator_t *this, + inode_t *inode) + { ++ ctr_heal_ret_val_t ret_val = CTR_TRY_NO_HEAL; + int ret = -1; + gf_ctr_local_t *ctr_local = NULL; + ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; + ctr_hard_link_t *ctr_hard_link = NULL; ++ gf_ctr_private_t *_priv = NULL; ++ gfdb_time_t current_time = {0}; ++ + + GF_ASSERT (frame); + GF_ASSERT (this); + GF_ASSERT (inode); ++ GF_ASSERT (this->private); ++ ++ _priv = this->private; + + ctr_local = frame->local; + if (!ctr_local) { +@@ -509,7 +586,29 @@ add_hard_link_ctx (call_frame_t *frame, + CTR_DB_REC(ctr_local).file_name); + /* if there then ignore */ + if (ctr_hard_link) { +- ret = 1; ++ ++ ret = gettimeofday (¤t_time, NULL); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to get current time"); ++ ret_val = CTR_CTX_ERROR; ++ goto unlock; ++ } ++ ++ if (__is_hardlink_expired (ctr_hard_link, ++ _priv, ¤t_time)) { ++ ctr_hard_link->hardlink_heal_period = ++ current_time.tv_sec; ++ ret_val = ret_val | CTR_TRY_HARDLINK_HEAL; ++ } ++ ++ if (__is_inode_expired (ctr_xlator_ctx, ++ _priv, ¤t_time)) { ++ ctr_xlator_ctx->inode_heal_period = ++ current_time.tv_sec; ++ ret_val = ret_val | CTR_TRY_INODE_HEAL; ++ } ++ + goto unlock; + } + +@@ -521,14 +620,15 @@ add_hard_link_ctx (call_frame_t *frame, + gf_msg (this->name, GF_LOG_ERROR, 0, + CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, + "Failed to add hardlink to the ctr inode context"); ++ ret_val = CTR_CTX_ERROR; + goto unlock; + } + +- ret = 0; ++ ret_val = CTR_TRY_NO_HEAL; + unlock: + UNLOCK (&ctr_xlator_ctx->lock); + out: +- return ret; ++ return ret_val; + } + + static inline int +diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c +index a91a2bb..b8f6f03 100644 +--- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c ++++ b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c +@@ -10,6 +10,8 @@ + + #include "ctr-xlator-ctx.h" + #include "ctr-messages.h" ++#include ++#include + + #define IS_THE_ONLY_HARDLINK(ctr_hard_link)\ + (ctr_hard_link->list.next == ctr_hard_link->list.prev) +@@ -63,13 +65,14 @@ out: + + /* Please lock the ctr_xlator_ctx before using this function */ + int +-ctr_add_hard_link (xlator_t *this, ++ctr_add_hard_link (xlator_t *this, + ctr_xlator_ctx_t *ctr_xlator_ctx, + uuid_t pgfid, + const char *base_name) + { + int ret = -1; + ctr_hard_link_t *ctr_hard_link = NULL; ++ struct timeval current_time = {0}; + + GF_ASSERT (this); + GF_ASSERT (ctr_xlator_ctx); +@@ -98,10 +101,19 @@ ctr_add_hard_link (xlator_t *this, + goto error; + } + ++ ret = gettimeofday (¤t_time, NULL); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to get current time"); ++ goto error; ++ } ++ + /*Add the hard link to the list*/ + list_add_tail (&ctr_hard_link->list, + &ctr_xlator_ctx->hardlink_list); + ++ ctr_hard_link->hardlink_heal_period = current_time.tv_sec; ++ + /*aal izz well!*/ + ret = 0; + goto out; +@@ -169,8 +181,9 @@ ctr_update_hard_link (xlator_t *this, + uuid_t old_pgfid, + const char *old_base_name) + { +- int ret = -1; ++ int ret = -1; + ctr_hard_link_t *ctr_hard_link = NULL; ++ struct timeval current_time = {0}; + + GF_ASSERT (this); + GF_ASSERT (ctr_xlator_ctx); +@@ -212,6 +225,15 @@ ctr_update_hard_link (xlator_t *this, + goto out; + } + ++ ret = gettimeofday (¤t_time, NULL); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to get current time"); ++ ctr_hard_link->hardlink_heal_period = 0; ++ } else { ++ ctr_hard_link->hardlink_heal_period = current_time.tv_sec; ++ } ++ + ret = 0; + + out: +@@ -284,6 +306,7 @@ init_ctr_xlator_ctx (xlator_t *this, + int ret = -1; + uint64_t _addr = 0; + ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; ++ struct timeval current_time = {0}; + + GF_ASSERT (this); + GF_ASSERT (inode); +@@ -316,6 +339,14 @@ init_ctr_xlator_ctx (xlator_t *this, + + INIT_LIST_HEAD (&ctr_xlator_ctx->hardlink_list); + ++ ret = gettimeofday (¤t_time, NULL); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "Failed to get current time"); ++ goto out; ++ } ++ ++ ctr_xlator_ctx->inode_heal_period = current_time.tv_sec; + } + ret = 0; + out: +diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h +index bc93501..7f1c6cb 100644 +--- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h ++++ b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h +@@ -25,6 +25,9 @@ + typedef struct ctr_hard_link { + uuid_t pgfid; + char *base_name; ++ /* Hardlink expiry : Defines the expiry period after which a ++ * database heal is attempted. */ ++ uint64_t hardlink_heal_period; + struct list_head list; + } ctr_hard_link_t; + +@@ -32,6 +35,7 @@ typedef struct ctr_xlator_ctx { + /* This represents the looked up hardlinks + * NOTE: This doesn't represent all physical hardlinks of the inode*/ + struct list_head hardlink_list; ++ uint64_t inode_heal_period; + gf_lock_t lock; + } ctr_xlator_ctx_t; + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index 09671a8..c3ec10b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -1717,6 +1717,14 @@ brick_graph_add_changetimerecorder (volgen_graph_t *graph, + if (ret) + goto out; + ++ ret = xlator_set_option (xl, "ctr_hardlink_heal_expire_period", "300"); ++ if (ret) ++ goto out; ++ ++ ret = xlator_set_option (xl, "ctr_inode_heal_expire_period", "300"); ++ if (ret) ++ goto out; ++ + ret = xlator_set_option (xl, "record-entry", "on"); + if (ret) + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index ecaf04f..7bbd729 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1910,6 +1910,30 @@ struct volopt_map_entry glusterd_volopt_map[] = { + "updates by Change Time Recorder Xlator. When recording in a crash " + "consistent way the data operations will experience more latency." + }, ++ { .key = "features.ctr_hardlink_heal_expire_period", ++ .voltype = "features/changetimerecorder", ++ .value = "300", ++ .option = "ctr_hardlink_heal_expire_period", ++ .op_version = GD_OP_VERSION_3_7_2, ++ .description = "Defines the expiry period of in-memory " ++ "hardlink of an inode," ++ "used by lookup heal in Change Time Recorder." ++ "Once the expiry period" ++ "hits an attempt to heal the database per " ++ "hardlink is done and the " ++ "in-memory hardlink period is reset" ++ }, ++ { .key = "features.ctr_inode_heal_expire_period", ++ .voltype = "features/changetimerecorder", ++ .value = "300", ++ .option = "ctr_inode_heal_expire_period", ++ .op_version = GD_OP_VERSION_3_7_2, ++ .description = "Defines the expiry period of in-memory inode," ++ "used by lookup heal in Change Time Recorder. " ++ "Once the expiry period" ++ "hits an attempt to heal the database per " ++ "inode is done" ++ }, + #endif /* USE_GFDB */ + { .key = "locks.trace", + .voltype = "features/locks", +-- +1.7.1 + diff --git a/SOURCES/0188-glusterd-Correction-in-Error-message-for-disperse-vo.patch b/SOURCES/0188-glusterd-Correction-in-Error-message-for-disperse-vo.patch new file mode 100644 index 0000000..5567cac --- /dev/null +++ b/SOURCES/0188-glusterd-Correction-in-Error-message-for-disperse-vo.patch @@ -0,0 +1,57 @@ +From a12da1b2111c87e4da3faae6ac17acfc22c70dbc Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Tue, 16 Jun 2015 15:18:50 +0530 +Subject: [PATCH 188/190] glusterd: Correction in Error message for disperse volume create + + Problem: If all the bricks are on same server and + creating "disperse" volume without using "force", + it throws a failure message mentioning "replicate" + as volume. + + Solution: Adding failure message for disperse volume too + Review link for master - + http://review.gluster.org/11250/ + +Change-Id: I9e466b1fe9dae8cf556903b1a2c4f0b270159841 +BUG: 1223225 +Signed-off-by: Ashish Pandey + +Signed-off-by: Ashish Pandey +Change-Id: I490dad35caa13feec3000d061b48deff59a9cff4 +Reviewed-on: https://code.engineering.redhat.com/gerrit/51762 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 9 +++++++-- + 1 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index a65495d..2ad1614 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -101,7 +101,7 @@ glusterd_check_brick_order(dict_t *dict, char *err_str) + const char failed_string[2048] = "Failed to perform brick order " + "check. Use 'force' at the end of the command" + " if you want to override this behavior. "; +- const char found_string[2048] = "Multiple bricks of a replicate " ++ const char found_string[2048] = "Multiple bricks of a %s " + "volume are present on the same server. This " + "setup is not optimal. Use 'force' at the " + "end of the command if you want to override " +@@ -248,7 +248,12 @@ check_failed: + found_bad_brick_order: + gf_msg (this->name, GF_LOG_INFO, 0, + GD_MSG_BAD_BRKORDER, "Bad brick order found"); +- snprintf (err_str, sizeof (found_string), found_string); ++ if (type == GF_CLUSTER_TYPE_DISPERSE) { ++ snprintf (err_str, sizeof (found_string), found_string, "disperse"); ++ } else { ++ snprintf (err_str, sizeof (found_string), found_string, "replicate"); ++ } ++ + ret = -1; + out: + ai_list_tmp2 = NULL; +-- +1.7.1 + diff --git a/SOURCES/0189-gfapi-symlink-resolution-for-glfs_object.patch b/SOURCES/0189-gfapi-symlink-resolution-for-glfs_object.patch new file mode 100644 index 0000000..f264f95 --- /dev/null +++ b/SOURCES/0189-gfapi-symlink-resolution-for-glfs_object.patch @@ -0,0 +1,156 @@ +From 8decf90c08992a1e5e34b0281c606354f76b6bab Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Thu, 25 Jun 2015 15:04:18 +0530 +Subject: [PATCH 189/190] gfapi : symlink resolution for glfs_object + +Generally posix expects symlink should be resolved, before performing an +acl related operation. This patch introduces a new api glfs_h_resolve_symlink() +which will do the same. + +backport of http://review.gluster.org/#/c/11410/ + +>Change-Id: Ieee645154455a732edfb2c28834021bab4248810 +>BUG: 1209735 +>Signed-off-by: Jiffin Tony Thottan + +Change-Id: Ic6c251076a9d6b6c19093ff86ace996b29badba4 +BUG: 1235147 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/51750 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + api/src/glfs-handleops.c | 25 +++++++++++++++++++++++-- + api/src/glfs-internal.h | 3 +++ + api/src/glfs-resolve.c | 37 +++++++++++++++++++++++++++++++++++++ + 3 files changed, 63 insertions(+), 2 deletions(-) + +diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c +index c010f0c..47f2139 100644 +--- a/api/src/glfs-handleops.c ++++ b/api/src/glfs-handleops.c +@@ -1987,6 +1987,7 @@ pub_glfs_h_acl_set (struct glfs *fs, struct glfs_object *object, + int ret = -1; + char *acl_s = NULL; + const char *acl_key = NULL; ++ struct glfs_object *new_object = NULL; + + DECLARE_OLD_THIS; + +@@ -2006,12 +2007,22 @@ pub_glfs_h_acl_set (struct glfs *fs, struct glfs_object *object, + if (!acl_s) + goto out; + +- ret = pub_glfs_h_setxattrs (fs, object, acl_key, acl_s, ++ if (IA_ISLNK (object->inode->ia_type)) { ++ new_object = glfs_h_resolve_symlink (fs, object); ++ if (new_object == NULL) ++ goto out; ++ } else ++ new_object = object; ++ ++ ret = pub_glfs_h_setxattrs (fs, new_object, acl_key, acl_s, + strlen (acl_s) + 1, 0); + + acl_free (acl_s); + + out: ++ if (IA_ISLNK (object->inode->ia_type) && new_object) ++ glfs_h_close (new_object); ++ + __GLFS_EXIT_FS; + + invalid_fs: +@@ -2027,6 +2038,7 @@ pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, + char *acl_s = NULL; + dict_t *xattr = NULL; + const char *acl_key = NULL; ++ struct glfs_object *new_object = NULL; + + DECLARE_OLD_THIS; + +@@ -2041,7 +2053,14 @@ pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, + if (!acl_key) + goto out; + +- ret = glfs_h_getxattrs_common (fs, object, &xattr, acl_key); ++ if (IA_ISLNK (object->inode->ia_type)) { ++ new_object = glfs_h_resolve_symlink (fs, object); ++ if (new_object == NULL) ++ goto out; ++ } else ++ new_object = object; ++ ++ ret = glfs_h_getxattrs_common (fs, new_object, &xattr, acl_key); + if (ret) + goto out; + +@@ -2053,6 +2072,8 @@ pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, + + out: + GF_FREE (acl_s); ++ if (IA_ISLNK (object->inode->ia_type) && new_object) ++ glfs_h_close (new_object); + + __GLFS_EXIT_FS; + +diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h +index 84935f5..83b4ade 100644 +--- a/api/src/glfs-internal.h ++++ b/api/src/glfs-internal.h +@@ -365,4 +365,7 @@ glfs_anonymous_pwritev (struct glfs *fs, struct glfs_object *object, + const struct iovec *iovec, int iovcnt, + off_t offset, int flags); + ++struct glfs_object * ++glfs_h_resolve_symlink (struct glfs *fs, struct glfs_object *object); ++ + #endif /* !_GLFS_INTERNAL_H */ +diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c +index 60e285d..2767abf 100644 +--- a/api/src/glfs-resolve.c ++++ b/api/src/glfs-resolve.c +@@ -1026,3 +1026,40 @@ glfs_create_object (loc_t *loc, struct glfs_object **retobject) + + return 0; + } ++ ++struct glfs_object * ++glfs_h_resolve_symlink (struct glfs *fs, struct glfs_object *object) ++{ ++ ++ xlator_t *subvol = NULL; ++ loc_t sym_loc = {0,}; ++ struct iatt iatt = {0,}; ++ char *lpath = NULL; ++ int ret = 0; ++ struct glfs_object *target_object = NULL; ++ ++ subvol = glfs_active_subvol (fs); ++ if (!subvol) { ++ ret = -1; ++ errno = EIO; ++ goto out; ++ } ++ ++ ret = glfs_resolve_symlink (fs, subvol, object->inode, &lpath); ++ if (ret < 0) ++ goto out; ++ ++ ret = glfs_resolve_at (fs, subvol, NULL, lpath, ++ &sym_loc, &iatt, ++ /* always recurisvely follow while ++ following symlink ++ */ ++ 1, 0); ++ if (ret == 0) ++ ret = glfs_create_object (&sym_loc, &target_object); ++ ++out: ++ loc_wipe (&sym_loc); ++ GF_FREE (lpath); ++ return target_object; ++} +-- +1.7.1 + diff --git a/SOURCES/0190-feature-performace-Fix-broken-build.patch b/SOURCES/0190-feature-performace-Fix-broken-build.patch new file mode 100644 index 0000000..889774f --- /dev/null +++ b/SOURCES/0190-feature-performace-Fix-broken-build.patch @@ -0,0 +1,149 @@ +From e872bee3a6b5d61b6f70245f16d3faa47566d138 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Sun, 28 Jun 2015 13:45:31 +0530 +Subject: [PATCH 190/190] feature/performace: Fix broken build + +Fix the build broken because of upstream patch +http://review.gluster.org/#/c/9822/ and +corresponding downstream patch +https://code.engineering.redhat.com/gerrit/51256 + +BUG: 1231784 +Change-Id: Ie172bc0b5c6a9f8feb94c58df82d1fe1b87f2c0e +Reviewed-On: http://review.gluster.org/11451 +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/51768 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/performance/io-cache/src/Makefile.am | 2 +- + xlators/performance/io-threads/src/Makefile.am | 2 +- + xlators/performance/md-cache/src/Makefile.am | 2 +- + xlators/performance/open-behind/src/Makefile.am | 2 +- + xlators/performance/quick-read/src/Makefile.am | 2 +- + xlators/performance/read-ahead/src/Makefile.am | 2 +- + xlators/performance/readdir-ahead/src/Makefile.am | 2 +- + xlators/performance/symlink-cache/src/Makefile.am | 2 ++ + xlators/performance/write-behind/src/Makefile.am | 2 +- + 9 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/xlators/performance/io-cache/src/Makefile.am b/xlators/performance/io-cache/src/Makefile.am +index 155be99..2176ea7 100644 +--- a/xlators/performance/io-cache/src/Makefile.am ++++ b/xlators/performance/io-cache/src/Makefile.am +@@ -6,7 +6,7 @@ io_cache_la_LDFLAGS = -module -avoid-version + io_cache_la_SOURCES = io-cache.c page.c ioc-inode.c + io_cache_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = io-cache.h ioc-mem-types.h ++noinst_HEADERS = io-cache.h ioc-mem-types.h io-cache-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(CONTRIBDIR)/rbtree +diff --git a/xlators/performance/io-threads/src/Makefile.am b/xlators/performance/io-threads/src/Makefile.am +index d63042e..36a7331 100644 +--- a/xlators/performance/io-threads/src/Makefile.am ++++ b/xlators/performance/io-threads/src/Makefile.am +@@ -6,7 +6,7 @@ io_threads_la_LDFLAGS = -module -avoid-version + io_threads_la_SOURCES = io-threads.c + io_threads_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = io-threads.h iot-mem-types.h ++noinst_HEADERS = io-threads.h iot-mem-types.h io-threads-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/performance/md-cache/src/Makefile.am b/xlators/performance/md-cache/src/Makefile.am +index 6f3d68b..8260b2b 100644 +--- a/xlators/performance/md-cache/src/Makefile.am ++++ b/xlators/performance/md-cache/src/Makefile.am +@@ -6,7 +6,7 @@ md_cache_la_LDFLAGS = -module -avoid-version + md_cache_la_SOURCES = md-cache.c + md_cache_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = md-cache-mem-types.h ++noinst_HEADERS = md-cache-mem-types.h md-cache-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(CONTRIBDIR)/rbtree +diff --git a/xlators/performance/open-behind/src/Makefile.am b/xlators/performance/open-behind/src/Makefile.am +index 1252857..eb6dfb1 100644 +--- a/xlators/performance/open-behind/src/Makefile.am ++++ b/xlators/performance/open-behind/src/Makefile.am +@@ -6,7 +6,7 @@ open_behind_la_LDFLAGS = -module -avoid-version + open_behind_la_SOURCES = open-behind.c + open_behind_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = open-behind-mem-types.h ++noinst_HEADERS = open-behind-mem-types.h open-behind-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/performance/quick-read/src/Makefile.am b/xlators/performance/quick-read/src/Makefile.am +index 4906f40..6344aaf 100644 +--- a/xlators/performance/quick-read/src/Makefile.am ++++ b/xlators/performance/quick-read/src/Makefile.am +@@ -6,7 +6,7 @@ quick_read_la_LDFLAGS = -module -avoid-version + quick_read_la_SOURCES = quick-read.c + quick_read_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = quick-read.h quick-read-mem-types.h ++noinst_HEADERS = quick-read.h quick-read-mem-types.h quick-read-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/performance/read-ahead/src/Makefile.am b/xlators/performance/read-ahead/src/Makefile.am +index be80ae7..56823b3 100644 +--- a/xlators/performance/read-ahead/src/Makefile.am ++++ b/xlators/performance/read-ahead/src/Makefile.am +@@ -6,7 +6,7 @@ read_ahead_la_LDFLAGS = -module -avoid-version + read_ahead_la_SOURCES = read-ahead.c page.c + read_ahead_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = read-ahead.h read-ahead-mem-types.h ++noinst_HEADERS = read-ahead.h read-ahead-mem-types.h read-ahead-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/performance/readdir-ahead/src/Makefile.am b/xlators/performance/readdir-ahead/src/Makefile.am +index 539d6ed..70525f4 100644 +--- a/xlators/performance/readdir-ahead/src/Makefile.am ++++ b/xlators/performance/readdir-ahead/src/Makefile.am +@@ -6,7 +6,7 @@ readdir_ahead_la_LDFLAGS = -module -avoid-version + readdir_ahead_la_SOURCES = readdir-ahead.c + readdir_ahead_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = readdir-ahead.h readdir-ahead-mem-types.h ++noinst_HEADERS = readdir-ahead.h readdir-ahead-mem-types.h readdir-ahead-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +diff --git a/xlators/performance/symlink-cache/src/Makefile.am b/xlators/performance/symlink-cache/src/Makefile.am +index 4091c32..4be8968 100644 +--- a/xlators/performance/symlink-cache/src/Makefile.am ++++ b/xlators/performance/symlink-cache/src/Makefile.am +@@ -6,6 +6,8 @@ symlink_cache_la_LDFLAGS = -module -avoid-version + symlink_cache_la_SOURCES = symlink-cache.c + symlink_cache_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + ++noinst_HEADERS = symlink-cache-messages.h ++ + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + + AM_CFLAGS = -Wall $(GF_CFLAGS) +diff --git a/xlators/performance/write-behind/src/Makefile.am b/xlators/performance/write-behind/src/Makefile.am +index 6c829d8..8f2b664 100644 +--- a/xlators/performance/write-behind/src/Makefile.am ++++ b/xlators/performance/write-behind/src/Makefile.am +@@ -6,7 +6,7 @@ write_behind_la_LDFLAGS = -module -avoid-version + write_behind_la_SOURCES = write-behind.c + write_behind_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la + +-noinst_HEADERS = write-behind-mem-types.h ++noinst_HEADERS = write-behind-mem-types.h write-behind-messages.h + + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + +-- +1.7.1 + diff --git a/SOURCES/0191-rdma-removing-duplicate-printing-of-error-string-in-.patch b/SOURCES/0191-rdma-removing-duplicate-printing-of-error-string-in-.patch new file mode 100644 index 0000000..1da267a --- /dev/null +++ b/SOURCES/0191-rdma-removing-duplicate-printing-of-error-string-in-.patch @@ -0,0 +1,254 @@ +From 2ca720351ebd7f2382252e3313274c5edf636b47 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Fri, 26 Jun 2015 14:56:53 +0530 +Subject: [PATCH 191/200] rdma : removing duplicate printing of error string in gf_msg + +Change-Id: I206cf80392d430f35558cc11699402c4cef12527 +BUG: 1231782 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: http://review.gluster.org/11426 +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Tested-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/51759 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-transport/rdma/src/name.c | 9 +++--- + rpc/rpc-transport/rdma/src/rdma.c | 53 ++++++++++++++++--------------------- + 2 files changed, 27 insertions(+), 35 deletions(-) + +diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c +index 97b2e37..8b403ed 100644 +--- a/rpc/rpc-transport/rdma/src/name.c ++++ b/rpc/rpc-transport/rdma/src/name.c +@@ -397,8 +397,8 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, + if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, ret, + TRANS_MSG_GET_ADDR_INFO_FAILED, +- "getaddrinfo failed for host %s, service %s (%s)", +- listen_host, service, gai_strerror (ret)); ++ "getaddrinfo failed for host %s, service %s", ++ listen_host, service); + ret = -1; + goto out; + } +@@ -432,8 +432,7 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_PORT_BIND_FAILED, + "cannot bind rdma_cm_id to port " +- "less than %d (%s)", GF_CLIENT_PORT_CEILING, +- strerror (errno)); ++ "less than %d", GF_CLIENT_PORT_CEILING); + if (sockaddr->sa_family == AF_INET6) { + ((struct sockaddr_in6 *)sockaddr)->sin6_port + = htons (0); +@@ -637,7 +636,7 @@ fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *add + if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, ret, + TRANS_MSG_GET_NAME_INFO_FAILED, +- "getnameinfo failed (%s)", gai_strerror (ret)); ++ "getnameinfo failed"); + } + + sprintf (identifier, "%s:%s", host, service); +diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c +index 89fb6cb..630a660 100644 +--- a/rpc/rpc-transport/rdma/src/rdma.c ++++ b/rpc/rpc-transport/rdma/src/rdma.c +@@ -120,8 +120,7 @@ gf_rdma_new_post (rpc_transport_t *this, gf_rdma_device_t *device, int32_t len, + if (!post->mr) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_MR_ALOC_FAILED, +- "memory registration failed (%s)", +- strerror (errno)); ++ "memory registration failed"); + goto out; + } + +@@ -1034,8 +1033,8 @@ gf_rdma_cm_handle_connect_request (struct rdma_cm_event *event) + if (ret < 0) { + gf_msg (listener->name, GF_LOG_WARNING, errno, + RDMA_MSG_ACCEPT_FAILED, "rdma_accept failed peer:%s " +- "me:%s (%s)", this->peerinfo.identifier, +- this->myinfo.identifier, strerror (errno)); ++ "me:%s", this->peerinfo.identifier, ++ this->myinfo.identifier); + gf_rdma_cm_handle_disconnect (this); + goto out; + } +@@ -1087,7 +1086,7 @@ gf_rdma_cm_handle_route_resolved (struct rdma_cm_event *event) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_CONNECT_FAILED, +- "rdma_connect failed (%s)", strerror (errno)); ++ "rdma_connect failed"); + gf_rdma_cm_handle_disconnect (this); + goto out; + } +@@ -1130,9 +1129,8 @@ gf_rdma_cm_handle_addr_resolved (struct rdma_cm_event *event) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_ROUTE_RESOLVE_FAILED, "rdma_resolve_route " +- "failed (me:%s peer:%s) (%s)", +- this->myinfo.identifier, this->peerinfo.identifier, +- strerror (errno)); ++ "failed (me:%s peer:%s)", ++ this->myinfo.identifier, this->peerinfo.identifier); + gf_rdma_cm_handle_disconnect (this); + } + +@@ -1257,8 +1255,7 @@ gf_rdma_cm_event_handler (void *data) + if (ret != 0) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_CM_EVENT_FAILED, +- "rdma_cm_get_event failed (%s)", +- strerror (errno)); ++ "rdma_cm_get_event failed"); + break; + } + +@@ -1464,8 +1461,7 @@ __gf_rdma_create_read_chunks_from_vector (gf_rdma_peer_t *peer, + if (!mr) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_MR_ALOC_FAILED, +- "memory registration failed (%s) (peer:%s)", +- strerror (errno), ++ "memory registration failed (peer:%s)", + peer->trans->peerinfo.identifier); + goto out; + } +@@ -1611,8 +1607,7 @@ __gf_rdma_create_write_chunks_from_vector (gf_rdma_peer_t *peer, + if (!mr) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_MR_ALOC_FAILED, "memory " +- "registration failed (%s) (peer:%s)", +- strerror (errno), ++ "registration failed (peer:%s)", + peer->trans->peerinfo.identifier); + goto out; + } +@@ -2331,7 +2326,7 @@ __gf_rdma_register_local_mr_for_rdma (gf_rdma_peer_t *peer, + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_MR_ALOC_FAILED, + "registering memory for IBV_ACCESS_LOCAL_WRITE" +- " failed (%s)", strerror (errno)); ++ " failed"); + goto out; + } + +@@ -3231,8 +3226,8 @@ gf_rdma_create_qp (rpc_transport_t *this) + ret = rdma_create_qp(peer->cm_id, device->pd, &init_attr); + if (ret != 0) { + gf_msg (peer->trans->name, GF_LOG_CRITICAL, errno, +- RDMA_MSG_CREAT_QP_FAILED, "%s: could not create QP " +- "(%s)", this->name, strerror (errno)); ++ RDMA_MSG_CREAT_QP_FAILED, "%s: could not create QP", ++ this->name); + ret = -1; + goto out; + } +@@ -4121,7 +4116,7 @@ gf_rdma_async_event_thread (void *context) + if (ret && errno != EINTR) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_EVENT_ERROR, "Error getting " +- "event (%s)", strerror (errno)); ++ "event"); + } + } while (ret && errno == EINTR); + +@@ -4592,7 +4587,7 @@ __gf_rdma_ctx_create (void) + if (rdma_ctx->rdma_cm_event_channel == NULL) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, errno, + RDMA_MSG_CM_EVENT_FAILED, "rdma_cm event channel " +- "creation failed (%s)", strerror (errno)); ++ "creation failed"); + goto out; + } + +@@ -4602,7 +4597,7 @@ __gf_rdma_ctx_create (void) + if (ret != 0) { + gf_msg (GF_RDMA_LOG_NAME, GF_LOG_WARNING, ret, + RDMA_MSG_CM_EVENT_FAILED, "creation of thread to " +- "handle rdma-cm events failed (%s)", strerror (ret)); ++ "handle rdma-cm events failed"); + goto out; + } + +@@ -4727,7 +4722,7 @@ gf_rdma_connect (struct rpc_transport *this, int port) + if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + RDMA_MSG_CM_EVENT_FAILED, "creation of " +- "rdma_cm_id failed (%s)", strerror (errno)); ++ "rdma_cm_id failed"); + ret = -errno; + goto unlock; + } +@@ -4749,7 +4744,7 @@ gf_rdma_connect (struct rpc_transport *this, int port) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_CLIENT_BIND_FAILED, +- "client bind failed: %s", strerror (errno)); ++ "client bind failed"); + goto unlock; + } + +@@ -4758,8 +4753,7 @@ gf_rdma_connect (struct rpc_transport *this, int port) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_RDMA_RESOLVE_ADDR_FAILED, +- "rdma_resolve_addr failed (%s)", +- strerror (errno)); ++ "rdma_resolve_addr failed"); + goto unlock; + } + +@@ -4814,7 +4808,7 @@ gf_rdma_listen (rpc_transport_t *this) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_CM_EVENT_FAILED, "creation of rdma_cm_id " +- "failed (%s)", strerror (errno)); ++ "failed"); + goto err; + } + +@@ -4829,7 +4823,7 @@ gf_rdma_listen (rpc_transport_t *this) + if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, ret, + TRANS_MSG_GET_NAME_INFO_FAILED, +- "getnameinfo failed (%s)", gai_strerror (ret)); ++ "getnameinfo failed"); + goto err; + } + +@@ -4840,8 +4834,7 @@ gf_rdma_listen (rpc_transport_t *this) + (void *)&optval, sizeof(optval)); + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, +- RDMA_MSG_OPTION_SET_FAILED, "rdma option set failed " +- "(%s)", strerror (errno)); ++ RDMA_MSG_OPTION_SET_FAILED, "rdma option set failed"); + goto err; + } + +@@ -4849,7 +4842,7 @@ gf_rdma_listen (rpc_transport_t *this) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_RDMA_BIND_ADDR_FAILED, +- "rdma_bind_addr failed (%s)", strerror (errno)); ++ "rdma_bind_addr failed"); + goto err; + } + +@@ -4857,7 +4850,7 @@ gf_rdma_listen (rpc_transport_t *this) + if (ret != 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_LISTEN_FAILED, +- "rdma_listen failed (%s)", strerror (errno)); ++ "rdma_listen failed"); + goto err; + } + +-- +1.7.1 + diff --git a/SOURCES/0192-NFS-Ganesha-Exporting-volume-fails.patch b/SOURCES/0192-NFS-Ganesha-Exporting-volume-fails.patch new file mode 100644 index 0000000..de90e58 --- /dev/null +++ b/SOURCES/0192-NFS-Ganesha-Exporting-volume-fails.patch @@ -0,0 +1,54 @@ +From 4cb6e56e64737efdc853b9357023f656f34ef389 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Mon, 29 Jun 2015 06:16:47 +0530 +Subject: [PATCH 192/200] NFS-Ganesha : Exporting volume fails + +Due to a recent fix, the dbus-send.sh looked +for a .export_added file even before it was +created. This resulted in the ganesha.enable +option failing consistently. Fixing it. + +This is the backport of the fix merged upstream, +http://review.gluster.org/#/c/11456/ + +Change-Id: I2bba25247763b88ab7b964d0f94fcecca98b0c9f +BUG: 1236556 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/51927 +Reviewed-by: Soumya Koduri +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + extras/ganesha/scripts/dbus-send.sh | 2 +- + extras/hook-scripts/start/post/S31ganesha-start.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh +index b96bba9..d838cab 100755 +--- a/extras/ganesha/scripts/dbus-send.sh ++++ b/extras/ganesha/scripts/dbus-send.sh +@@ -22,7 +22,7 @@ function check_cmd_status() + function dynamic_export_add() + { + count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l` +- if [ "$count" = "0" ] ; ++ if [ "$count" = "1" ] ; + then + EXPORT_ID=2 + else +diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh +index dc3eaea..f1ca72b 100755 +--- a/extras/hook-scripts/start/post/S31ganesha-start.sh ++++ b/extras/hook-scripts/start/post/S31ganesha-start.sh +@@ -61,7 +61,7 @@ function write_conf() + function export_add() + { + count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l` +- if [ "$count" = "0" ] ; ++ if [ "$count" = "1" ] ; + then + EXPORT_ID=2 + else +-- +1.7.1 + diff --git a/SOURCES/0193-common-ha-Fix-var-lib-nfs-statd-state-path-creation.patch b/SOURCES/0193-common-ha-Fix-var-lib-nfs-statd-state-path-creation.patch new file mode 100644 index 0000000..311f7e9 --- /dev/null +++ b/SOURCES/0193-common-ha-Fix-var-lib-nfs-statd-state-path-creation.patch @@ -0,0 +1,52 @@ +From 233f6e2adb9f28291cbb00636fa1e215fe1dae7d Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Tue, 30 Jun 2015 19:26:27 +0530 +Subject: [PATCH 193/200] common-ha: Fix '/var/lib/nfs/statd/state' path creation + +'/var/lib/nfs/statd/state' which contains NSM state number +should be a file instead of directory. + +This is a backport of the below fix +http://review.gluster.org/#/c/11468/ + +Change-Id: Id008b4f4dd810fe6d6b4d2599cbc0b488010384b +BUG: 1237165 +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/11468 +Reviewed-by: Kaleb KEITHLEY +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/52070 +Tested-by: Niels de Vos +--- + extras/ganesha/scripts/ganesha-ha.sh | 8 +++++--- + 1 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index ccaa3d8..69794a3 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -783,7 +783,9 @@ setup_state_volume() + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd + fi +- touch ${mnt}/nfs-ganesha/${dirname}/nfs/state ++ if [ ! -e ${mnt}/nfs-ganesha/${dirname}/nfs/state ]; then ++ touch ${mnt}/nfs-ganesha/${dirname}/nfs/state ++ fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov + fi +@@ -796,8 +798,8 @@ setup_state_volume() + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak + fi +- if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state ]; then +- mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state ++ if [ ! -e ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state ]; then ++ touch ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state + fi + for server in ${HA_SERVERS} ; do + if [ ${server} != ${dirname} ]; then +-- +1.7.1 + diff --git a/SOURCES/0194-cluster-ec-Add-throttling-in-background-healing.patch b/SOURCES/0194-cluster-ec-Add-throttling-in-background-healing.patch new file mode 100644 index 0000000..2b65273 --- /dev/null +++ b/SOURCES/0194-cluster-ec-Add-throttling-in-background-healing.patch @@ -0,0 +1,246 @@ +From 5c118fff47dc494a4fe0cbeaaeb9c291536b19ac Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 30 Jun 2015 18:45:36 +0530 +Subject: [PATCH 194/200] cluster/ec: Add throttling in background healing + + Backport of http://review.gluster.org/11471 + +- 8 parallel heals can happen. +- 128 heals will wait for their turn +- Heals will be rejected if 128 heals are already waiting. + +Change-Id: I2e99bf064db7bce71838ed9901a59ffd565ac390 +BUG: 1227197 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52178 +--- + xlators/cluster/ec/src/ec-common.h | 1 + + xlators/cluster/ec/src/ec-data.c | 2 + + xlators/cluster/ec/src/ec-data.h | 1 + + xlators/cluster/ec/src/ec-heal.c | 109 ++++++++++++++++++++++++++++++++++-- + xlators/cluster/ec/src/ec.c | 2 + + xlators/cluster/ec/src/ec.h | 4 + + 6 files changed, 114 insertions(+), 5 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h +index 3334a7b..4c7fe0c 100644 +--- a/xlators/cluster/ec/src/ec-common.h ++++ b/xlators/cluster/ec/src/ec-common.h +@@ -112,5 +112,6 @@ void ec_resume_parent(ec_fop_data_t * fop, int32_t error); + + void ec_manager(ec_fop_data_t * fop, int32_t error); + gf_boolean_t ec_is_recoverable_error (int32_t op_errno); ++void ec_handle_healers_done (ec_fop_data_t *fop); + + #endif /* __EC_COMMON_H__ */ +diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c +index 0632371..2a34f78 100644 +--- a/xlators/cluster/ec/src/ec-data.c ++++ b/xlators/cluster/ec/src/ec-data.c +@@ -135,6 +135,7 @@ ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, + } + + INIT_LIST_HEAD(&fop->cbk_list); ++ INIT_LIST_HEAD(&fop->healer); + INIT_LIST_HEAD(&fop->answer_list); + INIT_LIST_HEAD(&fop->pending_list); + INIT_LIST_HEAD(&fop->locks[0].wait_list); +@@ -300,6 +301,7 @@ void ec_fop_data_release(ec_fop_data_t * fop) + + ec = fop->xl->private; + ec_handle_last_pending_fop_completion (fop, ¬ify); ++ ec_handle_healers_done (fop); + mem_put(fop); + if (notify) { + ec_pending_fops_completed(ec); +diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h +index 670b3b8..135ccdf 100644 +--- a/xlators/cluster/ec/src/ec-data.h ++++ b/xlators/cluster/ec/src/ec-data.h +@@ -213,6 +213,7 @@ struct _ec_fop_data + ec_cbk_t cbks; + void *data; + ec_heal_t *heal; ++ struct list_head healer; + + uint64_t user_size; + uint32_t head; +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 7067ed9..bf4d0cd 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -26,6 +26,9 @@ + #include "syncop-utils.h" + #include "cluster-syncop.h" + ++#define EC_MAX_BACKGROUND_HEALS 8 ++#define EC_MAX_HEAL_WAITERS 128 ++ + #define alloca0(size) ({void *__ptr; __ptr = alloca(size); memset(__ptr, 0, size); __ptr; }) + #define EC_COUNT(array, max) ({int __i; int __res = 0; for (__i = 0; __i < max; __i++) if (array[__i]) __res++; __res; }) + #define EC_INTERSECT(dst, src1, src2, max) ({int __i; for (__i = 0; __i < max; __i++) dst[__i] = src1[__i] && src2[__i]; }) +@@ -3692,6 +3695,106 @@ ec_heal_done (int ret, call_frame_t *heal, void *opaque) + return 0; + } + ++ec_fop_data_t* ++__ec_dequeue_heals (ec_t *ec) ++{ ++ ec_fop_data_t *fop = NULL; ++ ++ if (list_empty (&ec->heal_waiting)) ++ goto none; ++ ++ if (ec->healers == EC_MAX_BACKGROUND_HEALS) ++ goto none; ++ ++ GF_ASSERT (ec->healers < EC_MAX_BACKGROUND_HEALS); ++ fop = list_entry(ec->heal_waiting.next, ec_fop_data_t, healer); ++ ec->heal_waiters--; ++ list_del_init(&fop->healer); ++ list_add(&fop->healer, &ec->healing); ++ ec->healers++; ++ return fop; ++none: ++ gf_msg_debug (ec->xl->name, 0, "Num healers: %d, Num Waiters: %d", ++ ec->healers, ec->heal_waiters); ++ return NULL; ++} ++ ++void ++ec_heal_fail (ec_t *ec, ec_fop_data_t *fop) ++{ ++ if (fop->cbks.heal) { ++ fop->cbks.heal (fop->req_frame, NULL, ec->xl, -1, EIO, 0, 0, ++ 0, NULL); ++ } ++ if (fop) ++ ec_fop_data_release (fop); ++} ++ ++void ++ec_launch_heal (ec_t *ec, ec_fop_data_t *fop) ++{ ++ int ret = 0; ++ ++ ret = synctask_new (ec->xl->ctx->env, ec_synctask_heal_wrap, ++ ec_heal_done, NULL, fop); ++ if (ret < 0) { ++ ec_heal_fail (ec, fop); ++ } ++} ++ ++void ++ec_handle_healers_done (ec_fop_data_t *fop) ++{ ++ ec_t *ec = fop->xl->private; ++ ec_fop_data_t *heal_fop = NULL; ++ ++ if (list_empty (&fop->healer)) ++ return; ++ ++ LOCK (&ec->lock); ++ { ++ list_del_init (&fop->healer); ++ ec->healers--; ++ heal_fop = __ec_dequeue_heals (ec); ++ } ++ UNLOCK (&ec->lock); ++ ++ if (heal_fop) ++ ec_launch_heal (ec, heal_fop); ++ ++} ++ ++void ++ec_heal_throttle (xlator_t *this, ec_fop_data_t *fop) ++{ ++ gf_boolean_t can_heal = _gf_true; ++ ec_t *ec = this->private; ++ ++ if (fop->req_frame == NULL) { ++ ++ LOCK (&ec->lock); ++ { ++ if (ec->heal_waiters >= EC_MAX_HEAL_WAITERS) { ++ can_heal = _gf_false; ++ } else { ++ list_add_tail(&fop->healer, &ec->heal_waiting); ++ ec->heal_waiters++; ++ fop = __ec_dequeue_heals (ec); ++ } ++ } ++ UNLOCK (&ec->lock); ++ } ++ ++ if (can_heal) { ++ if (fop) ++ ec_launch_heal (ec, fop); ++ } else { ++ gf_msg_debug (this->name, 0, "Max number of heals are pending, " ++ "background self-heal rejected"); ++ ec_heal_fail (ec, fop); ++ } ++} ++ + void + ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_heal_cbk_t func, void *data, loc_t *loc, +@@ -3699,7 +3802,6 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, + { + ec_cbk_t callback = { .heal = func }; + ec_fop_data_t *fop = NULL; +- int ret = 0; + + gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); + +@@ -3727,10 +3829,7 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, + if (xdata) + fop->xdata = dict_ref(xdata); + +- ret = synctask_new (this->ctx->env, ec_synctask_heal_wrap, +- ec_heal_done, NULL, fop); +- if (ret < 0) +- goto fail; ++ ec_heal_throttle (this, fop); + return; + fail: + if (fop) +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index 64ab91b..dd51630 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -543,6 +543,8 @@ init (xlator_t *this) + LOCK_INIT(&ec->lock); + + INIT_LIST_HEAD(&ec->pending_fops); ++ INIT_LIST_HEAD(&ec->heal_waiting); ++ INIT_LIST_HEAD(&ec->healing); + + ec->fop_pool = mem_pool_new(ec_fop_data_t, 1024); + ec->cbk_pool = mem_pool_new(ec_cbk_data_t, 4096); +diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h +index fdedb89..7f14020 100644 +--- a/xlators/cluster/ec/src/ec.h ++++ b/xlators/cluster/ec/src/ec.h +@@ -28,6 +28,8 @@ + struct _ec + { + xlator_t * xl; ++ int32_t healers; ++ int32_t heal_waiters; + int32_t nodes; + int32_t bits_for_nodes; + int32_t fragments; +@@ -46,6 +48,8 @@ struct _ec + gf_timer_t * timer; + gf_boolean_t shutdown; + struct list_head pending_fops; ++ struct list_head heal_waiting; ++ struct list_head healing; + struct mem_pool * fop_pool; + struct mem_pool * cbk_pool; + struct mem_pool * lock_pool; +-- +1.7.1 + diff --git a/SOURCES/0195-cluster-ec-Remove-dead-code.patch b/SOURCES/0195-cluster-ec-Remove-dead-code.patch new file mode 100644 index 0000000..bc7b687 --- /dev/null +++ b/SOURCES/0195-cluster-ec-Remove-dead-code.patch @@ -0,0 +1,1458 @@ +From 846a1e96d331577c72df32d9b605a87ece655443 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 30 Jun 2015 22:09:57 +0530 +Subject: [PATCH 195/200] cluster/ec: Remove dead code + + Backport of http://review.gluster.org/11472 + +Change-Id: I99d7a038f29cebe823e17a8dda40d335441185bc +BUG: 1227197 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52179 +--- + xlators/cluster/ec/src/ec-heal.c | 1378 +------------------------------------- + 1 files changed, 2 insertions(+), 1376 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index bf4d0cd..3168535 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -87,99 +87,6 @@ ec_sh_key_match (dict_t *dict, char *key, data_t *val, void *mdata) + } + /* FOP: heal */ + +-void ec_heal_exclude(ec_heal_t * heal, uintptr_t mask) +-{ +- LOCK(&heal->lock); +- +- heal->bad &= ~mask; +- +- UNLOCK(&heal->lock); +-} +- +-void ec_heal_lookup_resume(ec_fop_data_t * fop) +-{ +- ec_heal_t * heal = fop->data; +- ec_cbk_data_t * cbk; +- uintptr_t good = 0, bad = 0; +- +- if (heal->lookup != NULL) +- { +- ec_fop_data_release(heal->lookup); +- } +- ec_fop_data_acquire(fop); +- +- list_for_each_entry(cbk, &fop->cbk_list, list) +- { +- if ((cbk->op_ret < 0) && (cbk->op_errno == ENOTCONN)) +- { +- continue; +- } +- +- if (cbk == fop->answer) +- { +- if (cbk->op_ret >= 0) +- { +- heal->iatt = cbk->iatt[0]; +- heal->version[0] = cbk->version[0]; +- heal->version[1] = cbk->version[1]; +- heal->raw_size = cbk->size; +- +- GF_ASSERT(ec_set_inode_size(fop, cbk->inode, cbk->size)); +- +- if (ec_loc_update(heal->xl, &heal->loc, cbk->inode, +- &cbk->iatt[0]) != 0) +- { +- fop->answer = NULL; +- fop->error = EIO; +- +- bad |= cbk->mask; +- +- continue; +- } +- } +- +- good |= cbk->mask; +- } +- else +- { +- bad |= cbk->mask; +- } +- } +- +- /* Heal lookups are not executed concurrently with anything else. So, when +- * a lookup finishes, it's safe to access heal->good and heal->bad without +- * acquiring any lock. +- */ +- heal->good = good; +- heal->bad = bad; +- +- heal->lookup = fop; +- +- ec_resume_parent(fop, fop->answer != NULL ? 0 : fop->error); +-} +- +-int32_t ec_heal_entry_lookup_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, +- int32_t op_errno, inode_t * inode, +- struct iatt * buf, dict_t * xdata, +- struct iatt * postparent) +-{ +- ec_heal_lookup_resume(cookie); +- +- return 0; +-} +- +-int32_t ec_heal_inode_lookup_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, +- int32_t op_errno, inode_t * inode, +- struct iatt * buf, dict_t * xdata, +- struct iatt * postparent) +-{ +- ec_heal_lookup_resume(cookie); +- +- return 0; +-} +- + uintptr_t ec_heal_check(ec_fop_data_t * fop, uintptr_t * pgood) + { + ec_cbk_data_t * cbk; +@@ -232,326 +139,6 @@ void ec_heal_avoid(ec_fop_data_t * fop) + UNLOCK(&heal->lock); + } + +-int32_t ec_heal_mkdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, +- int32_t op_ret, int32_t op_errno, inode_t * inode, +- struct iatt * buf, struct iatt * preparent, +- struct iatt * postparent, dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_mknod_cbk(call_frame_t * frame, void * cookie, xlator_t * this, +- int32_t op_ret, int32_t op_errno, inode_t * inode, +- struct iatt * buf, struct iatt * preparent, +- struct iatt * postparent, dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_symlink_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- inode_t * inode, struct iatt * buf, +- struct iatt * preparent, struct iatt * postparent, +- dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_setattr_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- struct iatt * preop_stbuf, +- struct iatt * postop_stbuf, +- dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_setxattr_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_removexattr_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, +- int32_t op_errno, dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- +- return 0; +-} +- +-int32_t ec_heal_target_open_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, +- int32_t op_errno, fd_t * fd, dict_t * xdata) +-{ +- ec_heal_update(cookie, 1); +- +- return 0; +-} +- +-int32_t ec_heal_source_open_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, +- int32_t op_errno, fd_t * fd, dict_t * xdata) +-{ +- ec_heal_avoid(cookie); +- +- return 0; +-} +- +-int32_t ec_heal_reopen_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- fd_t * fd, dict_t * xdata) +-{ +- ec_fop_data_t * fop = cookie; +- ec_fd_t * ctx; +- uintptr_t good; +- +- ec_heal_check(fop, &good); +- +- if (good != 0) +- { +- LOCK(&fd->lock); +- +- ctx = __ec_fd_get(fd, fop->xl); +- if (ctx != NULL) { +- ctx->bad &= ~good; +- ctx->open |= good; +- } +- +- UNLOCK(&fd->lock); +- } +- +- return 0; +-} +- +-int32_t ec_heal_create (ec_heal_t *heal, uintptr_t mask) +-{ +- dict_t * xdata; +- int error = 0; +- +- xdata = dict_new(); +- if (xdata == NULL) +- return ENOMEM; +- +- if (dict_set_static_bin(xdata, "gfid-req", heal->iatt.ia_gfid, +- sizeof(uuid_t))) { +- error = ENOMEM; +- goto out; +- } +- +- switch (heal->iatt.ia_type) +- { +- case IA_IFDIR: +- ec_mkdir(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_mkdir_cbk, heal, &heal->loc, +- st_mode_from_ia(heal->iatt.ia_prot, heal->iatt.ia_type), +- 0, xdata); +- +- break; +- +- case IA_IFLNK: +- ec_symlink(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_symlink_cbk, heal, heal->symlink, &heal->loc, +- 0, xdata); +- +- break; +- +- default: +- /* If mknod comes with the presence of GLUSTERFS_INTERNAL_FOP_KEY +- * then posix_mknod checks if there are already any gfid-links and +- * does link() instead of mknod. There still can be a race where +- * two posix_mknods with same gfid see that gfid-link file is not +- * present and proceeds with mknods and result in two different +- * files with same gfid. which is yet to be fixed in posix.*/ +- if (dict_set_int32 (xdata, GLUSTERFS_INTERNAL_FOP_KEY, 1)) { +- error = ENOMEM; +- goto out; +- } +- +- ec_mknod(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_mknod_cbk, heal, &heal->loc, +- st_mode_from_ia(heal->iatt.ia_prot, heal->iatt.ia_type), +- heal->iatt.ia_rdev, 0, xdata); +- +- break; +- } +- error = 0; +- +-out: +- if (xdata) +- dict_unref(xdata); +- +- return error; +-} +- +-int32_t ec_heal_parent_cbk(call_frame_t *frame, void *cookie, xlator_t *xl, +- int32_t op_ret, int32_t op_errno, uintptr_t mask, +- uintptr_t good, uintptr_t bad, dict_t *xdata) +-{ +- ec_fop_data_t *fop = cookie; +- ec_heal_t *heal = fop->data; +- +- /* Even if parent self-heal has failed, we try to heal the current entry */ +- ec_heal_create(heal, fop->mask); +- +- return 0; +-} +- +-void ec_heal_parent(ec_heal_t *heal, uintptr_t mask) +-{ +- loc_t parent; +- int32_t healing = 0; +- +- /* First we try to do a partial heal of the parent directory to avoid +- * ENOENT/ENOTDIR errors caused by missing parents */ +- if (ec_loc_parent(heal->xl, &heal->loc, &parent) == 0) { +- if (!__is_root_gfid(parent.gfid)) { +- ec_heal(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_parent_cbk, heal, &parent, 1, NULL); +- +- healing = 1; +- } +- loc_wipe(&parent); +- } +- +- if (!healing) { +- ec_heal_create(heal, mask); +- } +-} +- +-void ec_heal_recreate(ec_fop_data_t * fop) +-{ +- ec_cbk_data_t * cbk; +- ec_heal_t * heal = fop->data; +- uintptr_t mask = 0; +- +- if (heal->iatt.ia_type == IA_INVAL) +- { +- return; +- } +- +- list_for_each_entry(cbk, &fop->cbk_list, list) +- { +- if ((cbk->op_ret >= 0) || (cbk->op_errno == ENOENT) || +- (cbk->op_errno == ENOTDIR)) +- { +- mask |= cbk->mask; +- } +- } +- +- if (mask != 0) +- { +- ec_heal_parent(heal, mask); +- } +-} +- +-int32_t ec_heal_rmdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, +- int32_t op_ret, int32_t op_errno, +- struct iatt * preparent, struct iatt * postparent, +- dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- ec_heal_recreate(cookie); +- +- return 0; +-} +- +-int32_t ec_heal_unlink_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- struct iatt * preparent, struct iatt * postparent, +- dict_t * xdata) +-{ +- ec_heal_update(cookie, 0); +- ec_heal_recreate(cookie); +- +- return 0; +-} +- +-int32_t +-ec_heal_init (ec_fop_data_t * fop) +-{ +- ec_t * ec = fop->xl->private; +- struct iobuf_pool * pool; +- inode_t * inode; +- ec_inode_t * ctx; +- ec_heal_t * heal = NULL; +- int32_t error = 0; +- +- heal = GF_MALLOC(sizeof(ec_heal_t), ec_mt_ec_heal_t); +- if (heal == NULL) +- { +- return ENOMEM; +- } +- +- memset(heal, 0, sizeof(ec_heal_t)); +- +- if (ec_loc_from_loc(fop->xl, &heal->loc, &fop->loc[0]) != 0) { +- error = ENOMEM; +- goto out; +- } +- +- inode = heal->loc.inode; +- if (inode == NULL) { +- gf_msg (fop->xl->name, GF_LOG_WARNING, ENODATA, +- EC_MSG_DATA_UNAVAILABLE, "Unable to start inode healing " +- "because there is not enough information"); +- +- error = ENODATA; +- goto out; +- } +- +- LOCK_INIT(&heal->lock); +- +- heal->xl = fop->xl; +- heal->fop = fop; +- pool = fop->xl->ctx->iobuf_pool; +- heal->size = iobpool_default_pagesize(pool) * ec->fragments; +- heal->partial = fop->int32; +- fop->heal = heal; +- +- LOCK(&inode->lock); +- +- ctx = __ec_inode_get(inode, fop->xl); +- if (ctx == NULL) +- { +- error = EIO; +- +- goto unlock; +- } +- +- if (list_empty(&ctx->heal)) { +- gf_msg ("ec", GF_LOG_INFO, 0, +- EC_MSG_HEALING_INFO, +- "Healing '%s', gfid %s", heal->loc.path, +- uuid_utoa(heal->loc.gfid)); +- } else { +- ec_sleep(fop); +- } +- +- list_add_tail(&heal->list, &ctx->heal); +- heal = NULL; +- +-unlock: +- UNLOCK(&inode->lock); +- +-out: +- GF_FREE(heal); +- +- return error; +-} +- + int32_t ec_heal_lock_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) + { +@@ -604,21 +191,6 @@ void ec_heal_lock(ec_heal_t *heal, int32_t type, fd_t *fd, loc_t *loc, + } + } + +-void ec_heal_entrylk(ec_heal_t *heal, int32_t type) +-{ +- loc_t loc; +- +- if (ec_loc_parent(heal->xl, &heal->loc, &loc) != 0) { +- ec_fop_set_error(heal->fop, EIO); +- +- return; +- } +- +- ec_heal_lock(heal, type, NULL, &loc, 0, 0); +- +- loc_wipe(&loc); +-} +- + void ec_heal_inodelk(ec_heal_t *heal, int32_t type, int32_t use_fd, + off_t offset, size_t size) + { +@@ -626,327 +198,6 @@ void ec_heal_inodelk(ec_heal_t *heal, int32_t type, int32_t use_fd, + size); + } + +-void ec_heal_lookup(ec_heal_t *heal, uintptr_t mask) +-{ +- dict_t * xdata; +- int32_t error = ENOMEM; +- +- xdata = dict_new(); +- if (xdata == NULL) +- { +- goto out; +- } +- if (dict_set_uint64(xdata, "list-xattr", 0) != 0) +- { +- goto out; +- } +- +- ec_lookup(heal->fop->frame, heal->xl, mask, EC_MINIMUM_MIN, +- ec_heal_inode_lookup_cbk, heal, &heal->loc, xdata); +- +- error = 0; +- +-out: +- if (xdata != NULL) +- { +- dict_unref(xdata); +- } +- +- ec_fop_set_error(heal->fop, error); +-} +- +-void ec_heal_remove(ec_heal_t * heal, ec_cbk_data_t * cbk) +-{ +- if (cbk->iatt[0].ia_type == IA_IFDIR) +- { +- ec_rmdir(heal->fop->frame, heal->xl, cbk->mask, EC_MINIMUM_ONE, +- ec_heal_rmdir_cbk, heal, &heal->loc, 1, NULL); +- } +- else +- { +- ec_unlink(heal->fop->frame, heal->xl, cbk->mask, EC_MINIMUM_ONE, +- ec_heal_unlink_cbk, heal, &heal->loc, 0, NULL); +- } +-} +- +-void ec_heal_remove_others(ec_heal_t * heal) +-{ +- struct list_head * item; +- ec_cbk_data_t * cbk; +- +- item = heal->lookup->cbk_list.next; +- do +- { +- item = item->next; +- cbk = list_entry(item, ec_cbk_data_t, list); +- +- if (cbk->op_ret < 0) +- { +- if ((cbk->op_errno != ENOENT) && (cbk->op_errno != ENOTDIR) && +- (cbk->op_errno != ESTALE)) +- { +- gf_msg (heal->xl->name, GF_LOG_WARNING, cbk->op_errno, +- EC_MSG_INODE_REMOVE_FAIL, "Don't know how to " +- "remove inode"); +- } +- +- ec_heal_exclude(heal, cbk->mask); +- +- continue; +- } +- +- ec_heal_remove(heal, cbk); +- } while (item->next != &heal->lookup->cbk_list); +-} +- +-void ec_heal_prepare_others(ec_heal_t * heal) +-{ +- struct list_head * item; +- ec_cbk_data_t * cbk; +- +- item = heal->lookup->cbk_list.next; +- while (item->next != &heal->lookup->cbk_list) +- { +- item = item->next; +- cbk = list_entry(item, ec_cbk_data_t, list); +- +- if (cbk->op_ret < 0) +- { +- if ((cbk->op_errno == ENOENT) || (cbk->op_errno == ESTALE)) +- { +- ec_heal_create(heal, cbk->mask); +- } +- else +- { +- gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, +- EC_MSG_HEAL_FAIL, "Don't know how to " +- "heal"); +- +- ec_heal_exclude(heal, cbk->mask); +- } +- } +- else +- { +- if ((heal->iatt.ia_type != cbk->iatt[0].ia_type) || +- (gf_uuid_compare(heal->iatt.ia_gfid, cbk->iatt[0].ia_gfid) != 0)) +- { +- ec_heal_remove(heal, cbk); +- } +- } +- } +-} +- +-int32_t ec_heal_readlink_cbk(call_frame_t * frame, void * cookie, +- xlator_t * this, int32_t op_ret, int32_t op_errno, +- const char * path, struct iatt * buf, +- dict_t * xdata) +-{ +- ec_fop_data_t * fop = cookie; +- ec_heal_t * heal = fop->data; +- +- if (op_ret >= 0) +- { +- heal->symlink = gf_strdup(path); +- if (heal->symlink != NULL) +- { +- ec_heal_prepare_others(heal); +- } +- else +- { +- ec_fop_set_error(fop, EIO); +- } +- } +- +- return 0; +-} +- +-ec_cbk_data_t * ec_heal_lookup_check(ec_heal_t * heal, uintptr_t * pgood, +- uintptr_t * pbad) +-{ +- ec_fop_data_t * fop = heal->lookup; +- ec_cbk_data_t * cbk = NULL, * ans = NULL; +- uintptr_t good = 0, bad = 0; +- +- list_for_each_entry(ans, &fop->cbk_list, list) +- { +- if ((ans->op_ret < 0) && (ans->op_errno == ENOTCONN)) +- { +- continue; +- } +- +- if (ans == fop->answer) +- { +- good |= ans->mask; +- cbk = ans; +- } +- else +- { +- bad |= ans->mask; +- } +- } +- +- *pgood = good; +- *pbad = bad; +- +- return cbk; +-} +- +-void ec_heal_prepare(ec_heal_t * heal) +-{ +- ec_cbk_data_t * cbk; +- int32_t error = ENOMEM; +- +- heal->available = heal->good; +- +- cbk = heal->lookup->answer; +- if (cbk->op_ret < 0) +- { +- if ((cbk->op_errno == ENOENT) || (cbk->op_errno == ENOTDIR)) +- { +- ec_heal_remove_others(heal); +- } +- else +- { +- gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, +- EC_MSG_HEAL_FAIL, "Don't know how to heal "); +- } +- } +- else +- { +- if (heal->iatt.ia_type == IA_IFREG) +- { +- heal->fd = fd_create(heal->loc.inode, heal->fop->frame->root->pid); +- if (heal->fd == NULL) +- { +- gf_msg (heal->xl->name, GF_LOG_ERROR, errno, +- EC_MSG_FD_CREATE_FAIL, "Unable to create a new " +- "file descriptor"); +- +- goto out; +- } +- } +- +- if (heal->iatt.ia_type == IA_IFLNK) +- { +- ec_readlink(heal->fop->frame, heal->xl, cbk->mask, EC_MINIMUM_ONE, +- ec_heal_readlink_cbk, heal, &heal->loc, +- heal->iatt.ia_size, NULL); +- } +- else +- { +- ec_heal_prepare_others(heal); +- } +- } +- +- error = 0; +- +-out: +- ec_fop_set_error(heal->fop, error); +-} +- +-int32_t ec_heal_open_others(ec_heal_t * heal) +-{ +- struct list_head * item; +- ec_cbk_data_t * cbk; +- uintptr_t mask = 0, open = heal->open; +- +- item = heal->lookup->cbk_list.next; +- while (item->next != &heal->lookup->cbk_list) +- { +- item = item->next; +- cbk = list_entry(item, ec_cbk_data_t, list); +- +- if ((cbk->op_ret < 0) || (cbk->iatt[0].ia_type != IA_IFREG) || +- (gf_uuid_compare(heal->iatt.ia_gfid, cbk->iatt[0].ia_gfid) != 0)) +- { +- ec_heal_exclude(heal, cbk->mask); +- } +- else +- { +- mask |= cbk->mask & ~heal->open; +- } +- } +- +- if (mask != 0) +- { +- ec_open(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_target_open_cbk, heal, &heal->loc, O_RDWR | O_TRUNC, +- heal->fd, NULL); +- +- open |= mask; +- } +- +- return (open != 0); +-} +- +-uintptr_t ec_heal_needs_data_rebuild(ec_heal_t *heal) +-{ +- ec_fop_data_t *fop = heal->lookup; +- ec_cbk_data_t *cbk = NULL; +- uintptr_t bad = 0; +- +- if ((heal->fop->error != 0) || (heal->good == 0) || +- (heal->iatt.ia_type != IA_IFREG)) { +- return 0; +- } +- +- list_for_each_entry(cbk, &fop->cbk_list, list) { +- if ((cbk->op_ret >= 0) && +- ((cbk->size != heal->raw_size) || +- (cbk->version != heal->version))) { +- bad |= cbk->mask; +- } +- } +- +- return bad; +-} +- +-void ec_heal_setxattr_others(ec_heal_t * heal) +-{ +- ec_cbk_data_t * cbk; +- dict_t * xdata; +- int32_t error = ENOMEM; +- +- if ((heal->good != 0) && (heal->bad != 0)) +- { +- cbk = heal->lookup->answer; +- xdata = cbk->xdata; +- +- if (dict_foreach_match (xdata, ec_ignorable_key_match, NULL, +- dict_remove_foreach_fn, NULL) == -1) +- goto out; +- +- if ((cbk->iatt[0].ia_type == IA_IFREG) || +- (cbk->iatt[0].ia_type == IA_IFDIR)) +- { +- if (ec_dict_set_array(xdata, EC_XATTR_VERSION, +- cbk->version, EC_VERSION_SIZE) != 0) +- { +- goto out; +- } +- if (cbk->iatt[0].ia_type == IA_IFREG) +- { +- uint64_t dirty; +- +- dirty = ec_heal_needs_data_rebuild(heal) != 0; +- if ((ec_dict_set_number(xdata, EC_XATTR_SIZE, +- cbk->iatt[0].ia_size) != 0) || +- (ec_dict_set_number(xdata, EC_XATTR_DIRTY, dirty) != 0)) { +- goto out; +- } +- } +- } +- +- ec_setxattr(heal->fop->frame, heal->xl, heal->bad, EC_MINIMUM_ONE, +- ec_heal_setxattr_cbk, heal, &heal->loc, xdata, 0, NULL); +- } +- +- error = 0; +- +-out: +- ec_fop_set_error(heal->fop, error); +-} +- + int32_t + ec_heal_xattr_clean (dict_t *dict, char *key, data_t *data, + void *arg) +@@ -964,124 +215,6 @@ ec_heal_xattr_clean (dict_t *dict, char *key, data_t *data, + return 0; + } + +-void ec_heal_removexattr_others(ec_heal_t * heal) +-{ +- struct list_head * item; +- ec_cbk_data_t * cbk; +- dict_t * xdata; +- +- if ((heal->good == 0) || (heal->bad == 0)) +- { +- return; +- } +- +- xdata = heal->lookup->answer->xdata; +- item = heal->lookup->cbk_list.next; +- while (item->next != &heal->lookup->cbk_list) +- { +- item = item->next; +- cbk = list_entry(item, ec_cbk_data_t, list); +- +- if (cbk->op_ret >= 0) +- { +- if (dict_foreach(cbk->xdata, ec_heal_xattr_clean, xdata) == 0) +- { +- ec_removexattr(heal->fop->frame, heal->xl, cbk->mask, +- EC_MINIMUM_ONE, ec_heal_removexattr_cbk, heal, +- &heal->loc, "", cbk->xdata); +- } +- } +- } +-} +- +-void ec_heal_attr(ec_heal_t * heal) +-{ +- if ((heal->good != 0) && (heal->bad != 0)) +- { +- ec_setattr(heal->fop->frame, heal->xl, heal->bad, EC_MINIMUM_ONE, +- ec_heal_setattr_cbk, heal, &heal->loc, &heal->iatt, +- GF_SET_ATTR_MODE | GF_SET_ATTR_UID | GF_SET_ATTR_GID | +- GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME, NULL); +- } +-} +- +-void +-ec_heal_open (ec_heal_t * heal) +-{ +- heal->bad = ec_heal_needs_data_rebuild(heal); +- if (heal->bad == 0) { +- return; +- } +- +- if (!heal->fd) { +- /* name-less loc heal */ +- heal->fd = fd_create (heal->loc.inode, +- heal->fop->frame->root->pid); +- } +- +- if (!heal->fd) { +- ec_fop_set_error(heal->fop, ENOMEM); +- return; +- } +- +- if (ec_heal_open_others(heal)) +- { +- ec_open(heal->fop->frame, heal->xl, heal->good, EC_MINIMUM_MIN, +- ec_heal_source_open_cbk, heal, &heal->loc, O_RDONLY, heal->fd, +- NULL); +- } +-} +- +-void ec_heal_reopen_fd(ec_heal_t * heal) +-{ +- inode_t * inode; +- fd_t * fd; +- ec_fd_t *ctx_fd; +- ec_inode_t *ctx_inode; +- uintptr_t mask; +- int32_t flags; +- +- inode = heal->loc.inode; +- +- LOCK(&inode->lock); +- +- ctx_inode = __ec_inode_get(inode, heal->xl); +- if (ctx_inode != NULL) { +- ctx_inode->bad &= ~(heal->good | heal->bad); +- } +- +- list_for_each_entry(fd, &inode->fd_list, inode_list) +- { +- ctx_fd = ec_fd_get(fd, heal->xl); +- if (ctx_fd != NULL) { +- mask = heal->bad & ~ctx_fd->open; +- if (mask != 0) +- { +- UNLOCK(&inode->lock); +- +- if (heal->iatt.ia_type == IA_IFDIR) +- { +- ec_opendir(heal->fop->frame, heal->xl, mask, +- EC_MINIMUM_ONE, ec_heal_reopen_cbk, NULL, +- &heal->loc, fd, NULL); +- } +- else +- { +- flags = ctx_fd->flags & ~(O_TRUNC | O_APPEND); +- +- ec_open(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, +- ec_heal_reopen_cbk, NULL, &heal->loc, flags, fd, +- NULL); +- } +- +- LOCK(&inode->lock); +- } +- } +- } +- +- UNLOCK(&inode->lock); +-} +- + int32_t + ec_heal_writev_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno, +@@ -1149,515 +282,8 @@ void ec_heal_data_block(ec_heal_t *heal) + } + } + +-void ec_heal_update_dirty(ec_heal_t *heal, uintptr_t mask) +-{ +- dict_t *dict; +- +- dict = dict_new(); +- if (dict == NULL) { +- ec_fop_set_error(heal->fop, EIO); +- +- return; +- } +- +- if (ec_dict_set_number(dict, EC_XATTR_DIRTY, -1) != 0) { +- dict_unref(dict); +- ec_fop_set_error(heal->fop, EIO); +- +- return; +- } +- +- ec_fxattrop(heal->fop->frame, heal->xl, mask, EC_MINIMUM_ONE, NULL, NULL, +- heal->fd, GF_XATTROP_ADD_ARRAY64, dict, NULL); +- +- dict_unref(dict); +-} +- +-void ec_heal_dispatch(ec_heal_t *heal) +-{ +- ec_fop_data_t *fop; +- ec_cbk_data_t *cbk; +- inode_t *inode; +- ec_inode_t *ctx; +- ec_heal_t *next = NULL; +- struct list_head list; +- int32_t error; +- +- inode = heal->loc.inode; +- +- INIT_LIST_HEAD(&list); +- +- LOCK(&inode->lock); +- +- /* done == 0 means that self-heal is still running (it shouldn't happen) +- * done == 1 means that self-heal has just completed +- * done == 2 means that self-heal has completed and reported */ +- if (heal->done == 1) { +- heal->done = 2; +- list_del_init(&heal->list); +- ctx = __ec_inode_get(inode, heal->xl); +- if (ctx != NULL) { +- ctx->bad &= ~heal->good; +- +- if (heal->partial) { +- /* Collect all partial heal requests. All of them will receive +- * the same answer. 'next' will contain a pointer to the first +- * full request (if any) after this partial heal request.*/ +- while (!list_empty(&ctx->heal)) { +- next = list_entry(ctx->heal.next, ec_heal_t, list); +- if (!next->partial) { +- break; +- } +- +- /* Setting 'done' to 2 avoids executing all heal logic and +- * directly reports the result to the caller. */ +- next->done = 2; +- +- list_move_tail(&next->list, &list); +- } +- if (list_empty(&ctx->heal)) { +- next = NULL; +- } +- } else { +- /* This is a full heal request, so take all received heal +- * requests to answer them now. */ +- list_splice_init(&ctx->heal, &list); +- } +- } +- } +- +- UNLOCK(&inode->lock); +- +- fop = heal->fop; +- error = fop->error; +- +- cbk = ec_cbk_data_allocate(fop->frame, heal->xl, fop, fop->id, 0, +- error == 0 ? 0 : -1, error); +- if (cbk != NULL) { +- cbk->uintptr[0] = heal->available; +- cbk->uintptr[1] = heal->good; +- cbk->uintptr[2] = heal->fixed; +- +- ec_combine(cbk, NULL); +- +- fop->answer = cbk; +- } else if (error == 0) { +- error = ENOMEM; +- } +- +- if (heal->lookup != NULL) +- { +- ec_fop_data_release(heal->lookup); +- } +- if (heal->fd != NULL) +- { +- fd_unref(heal->fd); +- } +- GF_FREE(heal->symlink); +- loc_wipe(&heal->loc); +- +- LOCK_DESTROY(&heal->lock); +- +- GF_FREE(heal); +- +- ec_fop_set_error(fop, error); +- +- /* Resume all pending heal requests, setting the same data obtained by +- * this heal execution. */ +- while (!list_empty(&list)) { +- heal = list_entry(list.next, ec_heal_t, list); +- list_del_init(&heal->list); +- +- heal->available = cbk->uintptr[0]; +- heal->good = cbk->uintptr[1]; +- heal->fixed = cbk->uintptr[2]; +- +- ec_resume(heal->fop, error); +- } +- +- /* If there is a pending full request, resume it. */ +- if (next != NULL) { +- ec_resume(next->fop, 0); +- } +-} +- +-void ec_wind_heal(ec_t * ec, ec_fop_data_t * fop, int32_t idx) +-{ +- ec_cbk_data_t * cbk; +- ec_heal_t *heal = fop->heal; +- +- ec_trace("WIND", fop, "idx=%d", idx); +- +- cbk = ec_cbk_data_allocate(fop->frame, fop->xl, fop, EC_FOP_HEAL, idx, +- fop->error == 0 ? 0 : -1, fop->error); +- if (cbk != NULL) +- { +- cbk->uintptr[0] = heal->available; +- cbk->uintptr[1] = heal->good; +- cbk->uintptr[2] = heal->bad; +- +- ec_combine(cbk, NULL); +- } +- +- ec_complete(fop); +-} +- +-int32_t +-ec_manager_heal (ec_fop_data_t * fop, int32_t state) +-{ +- ec_cbk_data_t * cbk; +- ec_heal_t *heal = fop->heal; +- +- switch (state) +- { +- case EC_STATE_INIT: +- ec_owner_set(fop->frame, fop->frame->root); +- +- fop->error = ec_heal_init(fop); +- if (fop->error != 0) +- { +- return EC_STATE_REPORT; +- } +- +- heal = fop->heal; +- /* root loc doesn't have pargfid/parent */ +- if (loc_is_root (&heal->loc) || +- !gf_uuid_is_null(heal->loc.pargfid) || heal->loc.parent) { +- heal->nameheal = _gf_true; +- return EC_STATE_DISPATCH; +- } else { +- /* No need to perform 'name' heal.*/ +- return EC_STATE_HEAL_PRE_INODELK_LOCK; +- } +- +- case EC_STATE_DISPATCH: +- if (heal->done != 0) { +- return EC_STATE_HEAL_DISPATCH; +- } +- +- ec_heal_entrylk(heal, F_WRLCK); +- +- return EC_STATE_HEAL_ENTRY_LOOKUP; +- +- case EC_STATE_HEAL_ENTRY_LOOKUP: +- ec_lookup(fop->frame, heal->xl, fop->mask, EC_MINIMUM_MIN, +- ec_heal_entry_lookup_cbk, heal, &heal->loc, NULL); +- +- return EC_STATE_HEAL_ENTRY_PREPARE; +- +- case EC_STATE_HEAL_ENTRY_PREPARE: +- if (!heal->partial || (heal->iatt.ia_type == IA_IFDIR)) { +- ec_heal_prepare(heal); +- } +- +- if (heal->partial) { +- return EC_STATE_HEAL_UNLOCK_ENTRY; +- } +- +- return EC_STATE_HEAL_PRE_INODELK_LOCK; +- +- case EC_STATE_HEAL_PRE_INODELK_LOCK: +- if (heal->done) +- return EC_STATE_HEAL_DISPATCH; +- +- /* Only heal data/metadata if enough information is supplied. */ +- if (gf_uuid_is_null(heal->loc.gfid)) +- { +- ec_heal_entrylk(heal, F_UNLCK); +- +- return EC_STATE_HEAL_DISPATCH; +- } +- +- ec_heal_inodelk(heal, F_WRLCK, 0, 0, 0); +- +- return EC_STATE_HEAL_PRE_INODE_LOOKUP; +- +- case EC_STATE_HEAL_PRE_INODE_LOOKUP: +- ec_heal_lookup(heal, heal->fop->mask); +- +- return EC_STATE_HEAL_XATTRIBUTES_REMOVE; +- +- case EC_STATE_HEAL_XATTRIBUTES_REMOVE: +- ec_heal_removexattr_others(heal); +- +- return EC_STATE_HEAL_XATTRIBUTES_SET; +- +- case EC_STATE_HEAL_XATTRIBUTES_SET: +- ec_heal_setxattr_others(heal); +- +- return EC_STATE_HEAL_ATTRIBUTES; +- +- case EC_STATE_HEAL_ATTRIBUTES: +- ec_heal_attr(heal); +- +- return EC_STATE_HEAL_OPEN; +- +- case EC_STATE_HEAL_OPEN: +- ec_heal_open(heal); +- +- return EC_STATE_HEAL_REOPEN_FD; +- +- case EC_STATE_HEAL_REOPEN_FD: +- ec_heal_reopen_fd(heal); +- +- return EC_STATE_HEAL_UNLOCK; +- +- case -EC_STATE_HEAL_XATTRIBUTES_REMOVE: +- case -EC_STATE_HEAL_XATTRIBUTES_SET: +- case -EC_STATE_HEAL_ATTRIBUTES: +- case -EC_STATE_HEAL_OPEN: +- case -EC_STATE_HEAL_REOPEN_FD: +- case -EC_STATE_HEAL_UNLOCK: +- case EC_STATE_HEAL_UNLOCK: +- ec_heal_inodelk(heal, F_UNLCK, 0, 0, 0); +- +- /* Fall through */ +- +- case -EC_STATE_HEAL_ENTRY_PREPARE: +- case -EC_STATE_HEAL_PRE_INODELK_LOCK: +- case -EC_STATE_HEAL_PRE_INODE_LOOKUP: +- case -EC_STATE_HEAL_UNLOCK_ENTRY: +- case EC_STATE_HEAL_UNLOCK_ENTRY: +- if (heal->nameheal) +- ec_heal_entrylk(heal, F_UNLCK); +- +- heal->bad = ec_heal_needs_data_rebuild(heal); +- if (heal->bad != 0) +- { +- return EC_STATE_HEAL_DATA_LOCK; +- } +- +- return EC_STATE_HEAL_DISPATCH; +- +- case EC_STATE_HEAL_DATA_LOCK: +- if (heal->done != 0) +- { +- return EC_STATE_HEAL_POST_INODELK_LOCK; +- } +- +- ec_heal_inodelk(heal, F_WRLCK, 1, heal->offset, heal->size); +- +- return EC_STATE_HEAL_DATA_COPY; +- +- case EC_STATE_HEAL_DATA_COPY: +- ec_heal_data_block(heal); +- +- return EC_STATE_HEAL_DATA_UNLOCK; +- +- case -EC_STATE_HEAL_DATA_COPY: +- case -EC_STATE_HEAL_DATA_UNLOCK: +- case EC_STATE_HEAL_DATA_UNLOCK: +- ec_heal_inodelk(heal, F_UNLCK, 1, heal->offset, heal->size); +- +- heal->offset += heal->size; +- +- return EC_STATE_HEAL_DATA_LOCK; +- +- case EC_STATE_HEAL_POST_INODELK_LOCK: +- ec_heal_inodelk(heal, F_WRLCK, 1, 0, 0); +- +- return EC_STATE_HEAL_POST_INODE_LOOKUP; +- +- case EC_STATE_HEAL_POST_INODE_LOOKUP: +- heal->fixed = heal->bad; +- ec_heal_update_dirty(heal, heal->bad); +- ec_heal_lookup(heal, heal->good); +- +- return EC_STATE_HEAL_SETATTR; +- +- case EC_STATE_HEAL_SETATTR: +- ec_setattr(heal->fop->frame, heal->xl, heal->fixed, EC_MINIMUM_ONE, +- ec_heal_setattr_cbk, heal, &heal->loc, &heal->iatt, +- GF_SET_ATTR_MODE | GF_SET_ATTR_UID | GF_SET_ATTR_GID | +- GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME, NULL); +- +- return EC_STATE_HEAL_POST_INODELK_UNLOCK; +- +- case -EC_STATE_HEAL_SETATTR: +- case -EC_STATE_HEAL_POST_INODELK_UNLOCK: +- case EC_STATE_HEAL_POST_INODELK_UNLOCK: +- ec_heal_inodelk(heal, F_UNLCK, 1, 0, 0); +- +- return EC_STATE_HEAL_DISPATCH; +- +- case -EC_STATE_HEAL_POST_INODELK_LOCK: +- case -EC_STATE_HEAL_POST_INODE_LOOKUP: +- case -EC_STATE_HEAL_ENTRY_LOOKUP: +- case -EC_STATE_HEAL_DATA_LOCK: +- case -EC_STATE_HEAL_DISPATCH: +- case EC_STATE_HEAL_DISPATCH: +- ec_heal_dispatch(heal); +- +- return EC_STATE_PREPARE_ANSWER; +- +- case EC_STATE_PREPARE_ANSWER: +- cbk = fop->answer; +- if (cbk != NULL) +- { +- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA)) +- { +- if (cbk->op_ret >= 0) +- { +- cbk->op_ret = -1; +- cbk->op_errno = EIO; +- } +- } +- if (cbk->op_ret < 0) +- { +- ec_fop_set_error(fop, cbk->op_errno); +- } +- } +- else +- { +- ec_fop_set_error(fop, EIO); +- } +- +- return EC_STATE_REPORT; +- +- case EC_STATE_REPORT: +- cbk = fop->answer; +- +- GF_ASSERT(cbk != NULL); +- +- if (fop->id == EC_FOP_HEAL) +- { +- if (fop->cbks.heal != NULL) +- { +- fop->cbks.heal(fop->req_frame, fop, fop->xl, cbk->op_ret, +- cbk->op_errno, cbk->uintptr[0], +- cbk->uintptr[1], cbk->uintptr[2], +- cbk->xdata); +- } +- } +- else +- { +- if (fop->cbks.fheal != NULL) +- { +- fop->cbks.fheal(fop->req_frame, fop, fop->xl, cbk->op_ret, +- cbk->op_errno, cbk->uintptr[0], +- cbk->uintptr[1], cbk->uintptr[2], +- cbk->xdata); +- } +- } +- +- return EC_STATE_END; +- +- case -EC_STATE_INIT: +- case -EC_STATE_DISPATCH: +- case -EC_STATE_PREPARE_ANSWER: +- case -EC_STATE_REPORT: +- GF_ASSERT(fop->error != 0); +- +- if (fop->id == EC_FOP_HEAL) +- { +- if (fop->cbks.heal != NULL) +- { +- fop->cbks.heal(fop->req_frame, fop, fop->xl, -1, +- fop->error, 0, 0, 0, NULL); +- } +- } +- else +- { +- if (fop->cbks.fheal != NULL) +- { +- fop->cbks.fheal(fop->req_frame, fop, fop->xl, -1, +- fop->error, 0, 0, 0, NULL); +- } +- } +- +- return EC_STATE_END; +- +- default: +- gf_msg (fop->xl->name, GF_LOG_ERROR, 0, +- EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", +- state, ec_fop_name(fop->id)); +- +- return EC_STATE_END; +- } +-} +- +-void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, +- int32_t minimum, fop_heal_cbk_t func, void *data, loc_t *loc, +- int32_t partial, dict_t *xdata) +-{ +- ec_cbk_t callback = { .heal = func }; +- ec_fop_data_t * fop = NULL; +- int32_t error = EIO; +- +- gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); +- +- VALIDATE_OR_GOTO(this, out); +- GF_VALIDATE_OR_GOTO(this->name, this->private, out); +- +- fop = ec_fop_data_allocate(frame, this, EC_FOP_HEAL, +- EC_FLAG_UPDATE_LOC_INODE, target, minimum, +- ec_wind_heal, ec_manager_heal, callback, data); +- if (fop == NULL) +- { +- goto out; +- } +- +- fop->int32 = partial; +- +- if (loc != NULL) +- { +- if (loc_copy(&fop->loc[0], loc) != 0) +- { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); +- +- goto out; +- } +- } +- if (xdata != NULL) +- { +- fop->xdata = dict_ref(xdata); +- if (fop->xdata == NULL) +- { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- EC_MSG_DICT_REF_FAIL, "Failed to reference a " +- "dictionary."); +- +- goto out; +- } +- } +- +- error = 0; +- +-out: +- if (fop != NULL) +- { +- ec_manager(fop, error); +- } +- else +- { +- func(frame, NULL, this, -1, EIO, 0, 0, 0, NULL); +- } +-} +- + /* FOP: fheal */ + +-void ec_wind_fheal(ec_t * ec, ec_fop_data_t * fop, int32_t idx) +-{ +- ec_cbk_data_t * cbk; +- ec_heal_t *heal = fop->heal; +- +- ec_trace("WIND", fop, "idx=%d", idx); +- +- cbk = ec_cbk_data_allocate(fop->frame, fop->xl, fop, EC_FOP_FHEAL, idx, +- fop->error == 0 ? 0 : -1, fop->error); +- if (cbk != NULL) +- { +- cbk->uintptr[0] = heal->available; +- cbk->uintptr[1] = heal->good; +- cbk->uintptr[2] = heal->bad; +- +- ec_combine(cbk, NULL); +- } +- +- ec_complete(fop); +-} +- + void ec_fheal(call_frame_t * frame, xlator_t * this, uintptr_t target, + int32_t minimum, fop_fheal_cbk_t func, void * data, fd_t * fd, + int32_t partial, dict_t *xdata) +@@ -3126,7 +1752,7 @@ ec_heal_block (call_frame_t *frame, xlator_t *this, uintptr_t target, + + fop = ec_fop_data_allocate (frame, this, EC_FOP_HEAL, + EC_FLAG_UPDATE_LOC_INODE, target, minimum, +- ec_wind_heal, ec_manager_heal_block, callback, ++ NULL, ec_manager_heal_block, callback, + heal); + if (fop == NULL) + goto out; +@@ -3815,7 +2441,7 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, + goto fail; + fop = ec_fop_data_allocate (frame, this, EC_FOP_HEAL, + EC_FLAG_UPDATE_LOC_INODE, target, minimum, +- ec_wind_heal, ec_manager_heal, callback, data); ++ NULL, NULL, callback, data); + if (fop == NULL) + goto fail; + +-- +1.7.1 + diff --git a/SOURCES/0196-protocol-server-Correctly-reconfigure-auth.ssl-allow.patch b/SOURCES/0196-protocol-server-Correctly-reconfigure-auth.ssl-allow.patch new file mode 100644 index 0000000..c27e3dd --- /dev/null +++ b/SOURCES/0196-protocol-server-Correctly-reconfigure-auth.ssl-allow.patch @@ -0,0 +1,46 @@ +From 64cedb3e2d282c2ef53de4b99a41574525ab4928 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Wed, 1 Jul 2015 11:44:53 +0530 +Subject: [PATCH 196/200] protocol/server: Correctly reconfigure auth.ssl-allow + +auth.ssl-allow wasn't being handled during reconfigure. This prevented +the ssl-allow list from being live reloaded. + +Change-Id: If3435793a5684881b012de77cb254b1847b37810 +BUG: 1228127 +Signed-off-by: Kaushal M +Reviewed-upstream-on: http://review.gluster.org/11487 +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/52103 +Reviewed-by: Raghavendra Gowdappa +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/protocol/server/src/server.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c +index 55b3018..9e644df 100644 +--- a/xlators/protocol/server/src/server.c ++++ b/xlators/protocol/server/src/server.c +@@ -616,6 +616,7 @@ _delete_auth_opt (dict_t *this, char *key, data_t *value, void *data) + { + char *auth_option_pattern[] = { "auth.addr.*.allow", + "auth.addr.*.reject", ++ "auth.login.*.ssl-allow", + NULL}; + int i = 0; + +@@ -635,6 +636,7 @@ _copy_auth_opt (dict_t *unused, char *key, data_t *value, void *xl_dict) + { + char *auth_option_pattern[] = { "auth.addr.*.allow", + "auth.addr.*.reject", ++ "auth.login.*.ssl-allow", + NULL}; + int i = 0; + +-- +1.7.1 + diff --git a/SOURCES/0197-cluster-dht-use-refcount-to-manage-memory-used-to-st.patch b/SOURCES/0197-cluster-dht-use-refcount-to-manage-memory-used-to-st.patch new file mode 100644 index 0000000..dcec86a --- /dev/null +++ b/SOURCES/0197-cluster-dht-use-refcount-to-manage-memory-used-to-st.patch @@ -0,0 +1,164 @@ +From 8f811b1ef400035eaf1adf38db24cc33a8726aab Mon Sep 17 00:00:00 2001 +From: Raghavendra G +Date: Fri, 26 Jun 2015 11:53:11 +0530 +Subject: [PATCH 197/200] cluster/dht: use refcount to manage memory used to store migration + information. + +Without refcounting, we might free up memory while other fops are +still accessing it. + +BUG: 1238167 +Change-Id: Ia4fa4a651cd6fe2394a0c20cef83c8d2cbc8750f +Signed-off-by: Raghavendra G +Reviewed-on: http://review.gluster.org/11418 +Reviewed-by: Shyamsundar Ranganathan +Tested-by: Gluster Build System +Reviewed-by: N Balachandran +Tested-by: NetBSD Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/52107 +Reviewed-by: Nithya Balachandran +--- + xlators/cluster/dht/src/dht-common.h | 2 + + xlators/cluster/dht/src/dht-helper.c | 65 +++++++++++++++++++++++----------- + 2 files changed, 46 insertions(+), 21 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index c04e85d..5e86b32 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -20,6 +20,7 @@ + #include "dht-messages.h" + #include "libxlator.h" + #include "syncop.h" ++#include "refcount.h" + + #ifndef _DHT_H + #define _DHT_H +@@ -506,6 +507,7 @@ struct dir_dfmeta { + typedef struct dht_migrate_info { + xlator_t *src_subvol; + xlator_t *dst_subvol; ++ GF_REF_DECL; + } dht_migrate_info_t; + + #define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT) +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index 6742f29..d8cc61d 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -19,6 +19,17 @@ + #include "dht-common.h" + #include "dht-helper.h" + ++void ++dht_free_mig_info (void *data) ++{ ++ dht_migrate_info_t *miginfo = NULL; ++ ++ miginfo = data; ++ GF_FREE (miginfo); ++ ++ return; ++} ++ + static inline int + dht_inode_ctx_set_mig_info (xlator_t *this, inode_t *inode, + xlator_t *src_subvol, xlator_t *dst_subvol) +@@ -33,12 +44,13 @@ dht_inode_ctx_set_mig_info (xlator_t *this, inode_t *inode, + + miginfo->src_subvol = src_subvol; + miginfo->dst_subvol = dst_subvol; ++ GF_REF_INIT (miginfo, dht_free_mig_info); + + value = (uint64_t) miginfo; + + ret = inode_ctx_set1 (inode, this, &value); + if (ret < 0) { +- GF_FREE (miginfo); ++ GF_REF_PUT (miginfo); + } + + out: +@@ -54,11 +66,18 @@ dht_inode_ctx_get_mig_info (xlator_t *this, inode_t *inode, + uint64_t tmp_miginfo = 0; + dht_migrate_info_t *miginfo = NULL; + +- ret = inode_ctx_get1 (inode, this, &tmp_miginfo); +- if ((ret < 0) || (tmp_miginfo == 0)) +- goto out; ++ LOCK (&inode->lock); ++ { ++ ret = __inode_ctx_get1 (inode, this, &tmp_miginfo); ++ if ((ret < 0) || (tmp_miginfo == 0)) { ++ UNLOCK (&inode->lock); ++ goto out; ++ } + +- miginfo = (dht_migrate_info_t *)tmp_miginfo; ++ miginfo = (dht_migrate_info_t *)tmp_miginfo; ++ GF_REF_GET (miginfo); ++ } ++ UNLOCK (&inode->lock); + + if (src_subvol) + *src_subvol = miginfo->src_subvol; +@@ -66,6 +85,8 @@ dht_inode_ctx_get_mig_info (xlator_t *this, inode_t *inode, + if (dst_subvol) + *dst_subvol = miginfo->dst_subvol; + ++ GF_REF_PUT (miginfo); ++ + out: + return ret; + } +@@ -900,21 +921,22 @@ out: + int + dht_migration_complete_check_task (void *data) + { +- int ret = -1; +- xlator_t *src_node = NULL; +- xlator_t *dst_node = NULL, *linkto_target = NULL; +- dht_local_t *local = NULL; +- dict_t *dict = NULL; +- struct iatt stbuf = {0,}; +- xlator_t *this = NULL; +- call_frame_t *frame = NULL; +- loc_t tmp_loc = {0,}; +- char *path = NULL; +- dht_conf_t *conf = NULL; +- inode_t *inode = NULL; +- fd_t *iter_fd = NULL; +- uint64_t tmp_miginfo = 0; +- int open_failed = 0; ++ int ret = -1; ++ xlator_t *src_node = NULL; ++ xlator_t *dst_node = NULL, *linkto_target = NULL; ++ dht_local_t *local = NULL; ++ dict_t *dict = NULL; ++ struct iatt stbuf = {0,}; ++ xlator_t *this = NULL; ++ call_frame_t *frame = NULL; ++ loc_t tmp_loc = {0,}; ++ char *path = NULL; ++ dht_conf_t *conf = NULL; ++ inode_t *inode = NULL; ++ fd_t *iter_fd = NULL; ++ uint64_t tmp_miginfo = 0; ++ dht_migrate_info_t *miginfo = NULL; ++ int open_failed = 0; + + this = THIS; + frame = data; +@@ -1018,7 +1040,8 @@ dht_migration_complete_check_task (void *data) + done on all the fd of inode */ + ret = inode_ctx_reset1 (inode, this, &tmp_miginfo); + if (tmp_miginfo) { +- GF_FREE ((void *)tmp_miginfo); ++ miginfo = (void *)tmp_miginfo; ++ GF_REF_PUT (miginfo); + goto out; + } + +-- +1.7.1 + diff --git a/SOURCES/0198-protocol-server-fail-setvolume-if-any-of-xlators-is-.patch b/SOURCES/0198-protocol-server-fail-setvolume-if-any-of-xlators-is-.patch new file mode 100644 index 0000000..208f9ba --- /dev/null +++ b/SOURCES/0198-protocol-server-fail-setvolume-if-any-of-xlators-is-.patch @@ -0,0 +1,92 @@ +From 6d2085143a37b6f765ce2a260f0316f24b043a80 Mon Sep 17 00:00:00 2001 +From: Raghavendra G +Date: Wed, 1 Jul 2015 16:54:55 +0530 +Subject: [PATCH 198/200] protocol/server: fail setvolume if any of xlators is not initialized yet + +We can only start recieving fops only when all xlators in graph are +initialized. + +upstream-patch: http://review.gluster.org/#/c/11490/1 +Change-Id: Id79100bab5878bb2518ed133c1118554fbb35229 +BUG: 1235735 +Signed-off-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/52206 +--- + xlators/protocol/server/src/server-handshake.c | 17 +++++++++++++++++ + xlators/protocol/server/src/server.c | 11 +++++++++++ + xlators/protocol/server/src/server.h | 2 ++ + 3 files changed, 30 insertions(+), 0 deletions(-) + +diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c +index 556b0e2..4aaa933 100644 +--- a/xlators/protocol/server/src/server-handshake.c ++++ b/xlators/protocol/server/src/server-handshake.c +@@ -372,6 +372,23 @@ server_setvolume (rpcsvc_request_t *req) + config_params = dict_copy_with_ref (this->options, NULL); + conf = this->private; + ++ if (conf->parent_up == _gf_false) { ++ /* PARENT_UP indicates that all xlators in graph are inited ++ * successfully ++ */ ++ op_ret = -1; ++ op_errno = EAGAIN; ++ ++ ret = dict_set_str (reply, "ERROR", ++ "xlator graph in server is not initialised " ++ "yet. Try again later"); ++ if (ret < 0) ++ gf_msg_debug (this->name, 0, "failed to set error: " ++ "xlator graph in server is not " ++ "initialised yet. Try again later"); ++ goto fail; ++ } ++ + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + op_ret = -1; +diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c +index 9e644df..9c10a50 100644 +--- a/xlators/protocol/server/src/server.c ++++ b/xlators/protocol/server/src/server.c +@@ -1188,6 +1188,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) + int32_t val = 0; + dict_t *dict = NULL; + dict_t *output = NULL; ++ server_conf_t *conf = NULL; + va_list ap; + + dict = data; +@@ -1208,6 +1209,16 @@ notify (xlator_t *this, int32_t event, void *data, ...) + } + break; + } ++ ++ case GF_EVENT_PARENT_UP: ++ { ++ conf = this->private; ++ ++ conf->parent_up = _gf_true; ++ ++ /* fall through and notify the event to children */ ++ } ++ + default: + default_notify (this, event, data); + break; +diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h +index dc64edd..6caf449 100644 +--- a/xlators/protocol/server/src/server.h ++++ b/xlators/protocol/server/src/server.h +@@ -66,6 +66,8 @@ struct server_conf { + + int event_threads; /* # of event threads + * configured */ ++ ++ gf_boolean_t parent_up; + }; + typedef struct server_conf server_conf_t; + +-- +1.7.1 + diff --git a/SOURCES/0199-NFS-Ganesha-Unexport-fails-after-S31ganesha-start-sc.patch b/SOURCES/0199-NFS-Ganesha-Unexport-fails-after-S31ganesha-start-sc.patch new file mode 100644 index 0000000..20b2cdc --- /dev/null +++ b/SOURCES/0199-NFS-Ganesha-Unexport-fails-after-S31ganesha-start-sc.patch @@ -0,0 +1,112 @@ +From c8d348dd59e729b8f59bd87149aa52cc16159279 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Tue, 30 Jun 2015 23:47:39 +0530 +Subject: [PATCH 199/200] NFS-Ganesha : Unexport fails after S31ganesha-start script is run + +The dbus-send script extracts the export ID from the export config file. +It expects the export ID to be written in a particular format. The post-phase +hook-script created the export file in a different format,and the dbus-send +never gets the correct export ID because of this. +Fixing the issue by replacing the write_conf function in the +S31ganesha-start hook-script.Also, NFS-Ganesha service stops when dbus signal is sent more +than once on the same export. Consecutive start/stop operations creates problems. +Fixing all the issues at once. + +This is a backport of the fix upstream, +http://review.gluster.org/#/c/11477/ + +Change-Id: I3a80a8454f781896e85b8be7d9c3d979968afcf6 +BUG: 1237053 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52233 +Reviewed-by: Niels de Vos +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + extras/ganesha/scripts/create-export-ganesha.sh | 3 +- + extras/hook-scripts/start/post/S31ganesha-start.sh | 46 +++++++++++-------- + 2 files changed, 28 insertions(+), 21 deletions(-) + +diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh +index 9762c0d..668f357 100755 +--- a/extras/ganesha/scripts/create-export-ganesha.sh ++++ b/extras/ganesha/scripts/create-export-ganesha.sh +@@ -32,8 +32,7 @@ function write_conf() + { + echo -e "# WARNING : Using Gluster CLI will overwrite manual + # changes made to this file. To avoid it, edit the +-# file, copy it over to all the NFS-Ganesha nodes +-# and run ganesha-ha.sh --refresh-config." ++# file and run ganesha-ha.sh --refresh-config." + + echo "EXPORT{" + echo " Export_Id = 2;" +diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh +index f1ca72b..a657b00 100755 +--- a/extras/hook-scripts/start/post/S31ganesha-start.sh ++++ b/extras/hook-scripts/start/post/S31ganesha-start.sh +@@ -37,24 +37,27 @@ function parse_args () + #This function generates a new export entry as export.volume_name.conf + function write_conf() + { +- echo "EXPORT{ +- " +- echo "Export_Id = ;" +- echo "Path=\"/$1\";" +- echo "FSAL { +- " +- echo "name = "GLUSTER";" +- echo "hostname="localhost";" +- echo "volume=\"$1\";" +- echo "}" +- echo "Access_type = RW;" +- echo "Squash = No_root_squash;" +- echo "Disable_ACL = TRUE;" +- echo "Pseudo=\"/$1\";" +- echo "Protocols = \"3\",\"4\" ;" +- echo "Transports = \"UDP\",\"TCP\" ;" +- echo "SecType = \"sys\";" +- echo "}" ++echo -e "# WARNING : Using Gluster CLI will overwrite manual ++# changes made to this file. To avoid it, edit the ++# file, copy it over to all the NFS-Ganesha nodes ++# and run ganesha-ha.sh --refresh-config." ++ ++echo "EXPORT{" ++echo " Export_Id = 2;" ++echo " Path = \"/$VOL\";" ++echo " FSAL {" ++echo " name = \"GLUSTER\";" ++echo " hostname=\"localhost\";" ++echo " volume=\"$VOL\";" ++echo " }" ++echo " Access_type = RW;" ++echo " Disable_ACL = true;" ++echo " Squash=\"No_root_squash\";" ++echo " Pseudo=\"/$VOL\";" ++echo " Protocols = \"3\", \"4\" ;" ++echo " Transports = \"UDP\",\"TCP\";" ++echo " SecType = \"sys\";" ++echo "}" + } + + #This function keeps track of export IDs and increments it with every new entry +@@ -101,9 +104,14 @@ function start_ganesha() + } + + parse_args $@ ++ is_exported="no" ++ if showmount -e localhost | cut -d "" -f1 | grep -q "/$VOL[[:space:]]" ++ then ++ is_exported="yes" ++ fi + ganesha_value=$(grep $ganesha_key $GLUSTERD_WORKDIR/vols/$VOL/info |\ + cut -d"=" -f2) +- if [ "$ganesha_value" = "on" ] ++ if [ "$ganesha_value" = "on" -a "$is_exported" = "no" ] + then + write_conf $VOL > $GANESHA_DIR/exports/export.$VOL.conf + start_ganesha $VOL +-- +1.7.1 + diff --git a/SOURCES/0200-cluster-ec-Make-background-healing-optional-behavior.patch b/SOURCES/0200-cluster-ec-Make-background-healing-optional-behavior.patch new file mode 100644 index 0000000..3d090ff --- /dev/null +++ b/SOURCES/0200-cluster-ec-Make-background-healing-optional-behavior.patch @@ -0,0 +1,617 @@ +From 836b89d895539c2c214d145fcd74b25abd598530 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 30 Jun 2015 23:01:36 +0530 +Subject: [PATCH 200/200] cluster/ec: Make background healing optional behavior + + Backport of http://review.gluster.com/11473 + +Provide options to control number of active background heal count and qlen. + +Change-Id: Idc2419219d881f47e7d2e9bbc1dcdd999b372033 +BUG: 1230612 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52256 +--- + libglusterfs/src/globals.h | 12 +++-- + tests/basic/afr/arbiter.t | 2 +- + tests/basic/afr/client-side-heal.t | 10 ++-- + tests/basic/afr/replace-brick-self-heal.t | 2 +- + tests/basic/afr/root-squash-self-heal.t | 2 +- + tests/basic/afr/self-heal.t | 16 +++--- + tests/basic/afr/self-heald.t | 24 +++++----- + tests/basic/afr/sparse-file-self-heal.t | 4 +- + tests/basic/afr/split-brain-resolution.t | 4 +- + tests/bugs/glusterfs/bug-861015-index.t | 2 +- + tests/bugs/quota/afr-quota-xattr-mdata-heal.t | 2 +- + tests/bugs/replicate/bug-1180545.t | 2 +- + .../bug-1190069-afr-stale-index-entries.t | 2 +- + tests/bugs/replicate/bug-918437-sh-mtime.t | 2 +- + tests/volume.rc | 2 +- + xlators/cluster/ec/src/ec-heal.c | 14 ++--- + xlators/cluster/ec/src/ec.c | 50 ++++++++++++++++++- + xlators/cluster/ec/src/ec.h | 2 + + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 8 +++ + 19 files changed, 109 insertions(+), 53 deletions(-) + +diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h +index 07185a8..9aca3c3 100644 +--- a/libglusterfs/src/globals.h ++++ b/libglusterfs/src/globals.h +@@ -24,7 +24,7 @@ + * RHS-2.1 u5 - 20105 + * RHS-3.0 - 30000 + * RHS-3.0.4 - 30004 +- * RHGS-3.1 - 30702 ++ * RHGS-3.1 - 30703 + * + * + * NOTE: +@@ -42,9 +42,11 @@ + */ + #define GD_OP_VERSION_MIN 1 /* MIN is the fresh start op-version, mostly + should not change */ +-#define GD_OP_VERSION_MAX 30702 /* MAX VERSION is the maximum count in VME +- table, should keep changing with +- introduction of newer versions */ ++#define GD_OP_VERSION_MAX GD_OP_VERSION_3_7_3 /* MAX VERSION is the maximum ++ count in VME table, should ++ keep changing with ++ introduction of newer ++ versions */ + + #define GD_OP_VERSION_RHS_3_0 30000 /* Op-Version of RHS 3.0 */ + +@@ -60,6 +62,8 @@ + + #define GD_OP_VERSION_3_7_2 30702 /* Op-version for GlusterFS 3.7.2 */ + ++#define GD_OP_VERSION_3_7_3 30703 /* Op-version for GlusterFS 3.7.3 */ ++ + #include "xlator.h" + + /* THIS */ +diff --git a/tests/basic/afr/arbiter.t b/tests/basic/afr/arbiter.t +index 8a983fb..f06fdb1 100644 +--- a/tests/basic/afr/arbiter.t ++++ b/tests/basic/afr/arbiter.t +@@ -60,7 +60,7 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2 + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 + TEST $CLI volume heal $V0 +-EXPECT 0 afr_get_pending_heal_count $V0 ++EXPECT 0 get_pending_heal_count $V0 + + # I/O can resume again. + TEST cat $M0/file +diff --git a/tests/basic/afr/client-side-heal.t b/tests/basic/afr/client-side-heal.t +index c9b3e35..18f7626 100644 +--- a/tests/basic/afr/client-side-heal.t ++++ b/tests/basic/afr/client-side-heal.t +@@ -33,7 +33,7 @@ TEST chmod +x $M0/mdatafile + #pending entry heal. Also causes pending metadata/data heals on file{1..5} + TEST touch $M0/dir/file{1..5} + +-EXPECT 8 afr_get_pending_heal_count $V0 ++EXPECT 8 get_pending_heal_count $V0 + + #After brick comes back up, access from client should not trigger heals + TEST $CLI volume start $V0 force +@@ -54,7 +54,7 @@ TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; + TEST ls $M0/dir + + #No heal must have happened +-EXPECT 8 afr_get_pending_heal_count $V0 ++EXPECT 8 get_pending_heal_count $V0 + + #Enable heal client side heal options and trigger heals + TEST $CLI volume set $V0 cluster.data-self-heal on +@@ -63,7 +63,7 @@ TEST $CLI volume set $V0 cluster.entry-self-heal on + + #Metadata heal is triggered by lookup without need for inode refresh. + TEST ls $M0/mdatafile +-EXPECT 7 afr_get_pending_heal_count $V0 ++EXPECT 7 get_pending_heal_count $V0 + + #Inode refresh must trigger data and entry heals. + #To trigger inode refresh for sure, the volume is unmounted and mounted each time. +@@ -74,7 +74,7 @@ TEST cat $M0/datafile + EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; + TEST ls $M0/dir +-EXPECT 5 afr_get_pending_heal_count $V0 ++EXPECT 5 get_pending_heal_count $V0 + + TEST cat $M0/dir/file1 + TEST cat $M0/dir/file2 +@@ -82,5 +82,5 @@ TEST cat $M0/dir/file3 + TEST cat $M0/dir/file4 + TEST cat $M0/dir/file5 + +-EXPECT 0 afr_get_pending_heal_count $V0 ++EXPECT 0 get_pending_heal_count $V0 + cleanup; +diff --git a/tests/basic/afr/replace-brick-self-heal.t b/tests/basic/afr/replace-brick-self-heal.t +index 8ced7df..fef671a 100644 +--- a/tests/basic/afr/replace-brick-self-heal.t ++++ b/tests/basic/afr/replace-brick-self-heal.t +@@ -43,7 +43,7 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 + + # Wait for heal to complete +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + # Check if entry-heal has happened + TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1_new | sort) +diff --git a/tests/basic/afr/root-squash-self-heal.t b/tests/basic/afr/root-squash-self-heal.t +index fa9a163..8337432 100644 +--- a/tests/basic/afr/root-squash-self-heal.t ++++ b/tests/basic/afr/root-squash-self-heal.t +@@ -20,6 +20,6 @@ echo abc > $M0/a + TEST $CLI volume start $V0 force + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 + find $M0 | xargs stat > /dev/null +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + cleanup +diff --git a/tests/basic/afr/self-heal.t b/tests/basic/afr/self-heal.t +index dbd8961..e1ac17c 100644 +--- a/tests/basic/afr/self-heal.t ++++ b/tests/basic/afr/self-heal.t +@@ -53,7 +53,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check all files created/deleted on brick1 are also replicated on brick 0 + #(i.e. no reverse heal has happened) +@@ -82,7 +82,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + TEST test -d $B0/brick0/file +@@ -105,7 +105,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + EXPECT "777" stat -c %a $B0/brick0/file +@@ -129,7 +129,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + EXPECT "$NEW_UID$NEW_GID" stat -c %u%g $B0/brick0/file +@@ -160,7 +160,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + EXPECT 0 stat -c %s $B0/brick1/file +@@ -183,7 +183,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + EXPECT "$GFID" gf_get_gfid_xattr $B0/brick0/file +@@ -207,7 +207,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #check heal has happened in the correct direction + TEST test -f $B0/brick0/hard_link_to_file +@@ -233,7 +233,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + TEST diff <(echo "user.myattr_1=\"My_attribute_1_modified\"") <(getfattr -n user.myattr_1 $B0/brick1/file|grep user.myattr_1) + TEST diff <(echo "user.myattr_3=\"My_attribute_3\"") <(getfattr -n user.myattr_3 $B0/brick1/file|grep user.myattr_3) +diff --git a/tests/basic/afr/self-heald.t b/tests/basic/afr/self-heald.t +index ee0afaf..b8bee5c 100644 +--- a/tests/basic/afr/self-heald.t ++++ b/tests/basic/afr/self-heald.t +@@ -68,7 +68,7 @@ done + HEAL_FILES=$(($HEAL_FILES + 3)) + + cd ~ +-EXPECT "$HEAL_FILES" afr_get_pending_heal_count $V0 ++EXPECT "$HEAL_FILES" get_pending_heal_count $V0 + + #When bricks are down, it says Transport End point Not connected for them + EXPECT "3" disconnected_brick_count $V0 +@@ -78,12 +78,12 @@ EXPECT "3" disconnected_brick_count $V0 + #replica pair. + for i in {11..20}; do echo abc > $M0/$i; done + HEAL_FILES=$(($HEAL_FILES + 10)) #count extra 10 files +-EXPECT "$HEAL_FILES" afr_get_pending_heal_count $V0 ++EXPECT "$HEAL_FILES" get_pending_heal_count $V0 + #delete the files now, so that stale indices will remain. + for i in {11..20}; do rm -f $M0/$i; done + #After deleting files they should not appear in heal info + HEAL_FILES=$(($HEAL_FILES - 10)) +-EXPECT "$HEAL_FILES" afr_get_pending_heal_count $V0 ++EXPECT "$HEAL_FILES" get_pending_heal_count $V0 + + + TEST ! $CLI volume heal $V0 +@@ -99,10 +99,10 @@ check_bricks_up $V0 + TEST $CLI volume heal $V0 + sleep 5 #Until the heal-statistics command implementation + #check that this heals the contents partially +-TEST [ $HEAL_FILES -gt $(afr_get_pending_heal_count $V0) ] ++TEST [ $HEAL_FILES -gt $(get_pending_heal_count $V0) ] + + TEST $CLI volume heal $V0 full +-EXPECT_WITHIN 30 "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN 30 "0" get_pending_heal_count $V0 + + #Test that ongoing IO is not considered as Pending heal + (dd if=/dev/zero of=$M0/file1 bs=1k 2>/dev/null 1>/dev/null)& +@@ -115,7 +115,7 @@ back_pid3=$!; + back_pid4=$!; + (dd if=/dev/zero of=$M0/file5 bs=1k 2>/dev/null 1>/dev/null)& + back_pid5=$!; +-EXPECT 0 afr_get_pending_heal_count $V0 ++EXPECT 0 get_pending_heal_count $V0 + kill -SIGTERM $back_pid1; + kill -SIGTERM $back_pid2; + kill -SIGTERM $back_pid3; +@@ -132,13 +132,13 @@ TEST $CLI volume set $V0 cluster.data-self-heal off + EXPECT "off" volume_option $V0 cluster.data-self-heal + kill_multiple_bricks $V0 $H0 $B0 + echo abc > $M0/f +-EXPECT 1 afr_get_pending_heal_count $V0 ++EXPECT 1 get_pending_heal_count $V0 + TEST $CLI volume start $V0 force + EXPECT_WITHIN 20 "Y" glustershd_up_status + check_bricks_up $V0 + + TEST $CLI volume heal $V0 +-EXPECT_WITHIN 30 "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN 30 "0" get_pending_heal_count $V0 + TEST $CLI volume set $V0 cluster.data-self-heal on + + #METADATA +@@ -147,13 +147,13 @@ EXPECT "off" volume_option $V0 cluster.metadata-self-heal + kill_multiple_bricks $V0 $H0 $B0 + + TEST chmod 777 $M0/f +-EXPECT 1 afr_get_pending_heal_count $V0 ++EXPECT 1 get_pending_heal_count $V0 + TEST $CLI volume start $V0 force + EXPECT_WITHIN 20 "Y" glustershd_up_status + check_bricks_up $V0 + + TEST $CLI volume heal $V0 +-EXPECT_WITHIN 30 "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN 30 "0" get_pending_heal_count $V0 + TEST $CLI volume set $V0 cluster.metadata-self-heal on + + #ENTRY +@@ -163,13 +163,13 @@ kill_multiple_bricks $V0 $H0 $B0 + TEST touch $M0/d/a + # 4 if mtime/ctime is modified for d in bricks without a + # 2 otherwise +-PENDING=$( afr_get_pending_heal_count $V0 ) ++PENDING=$( get_pending_heal_count $V0 ) + TEST test $PENDING -eq 2 -o $PENDING -eq 4 + TEST $CLI volume start $V0 force + EXPECT_WITHIN 20 "Y" glustershd_up_status + check_bricks_up $V0 + TEST $CLI volume heal $V0 +-EXPECT_WITHIN 30 "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN 30 "0" get_pending_heal_count $V0 + TEST $CLI volume set $V0 cluster.entry-self-heal on + + #Negative test cases +diff --git a/tests/basic/afr/sparse-file-self-heal.t b/tests/basic/afr/sparse-file-self-heal.t +index 1bc915e..4101e6d 100644 +--- a/tests/basic/afr/sparse-file-self-heal.t ++++ b/tests/basic/afr/sparse-file-self-heal.t +@@ -49,7 +49,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST gluster volume heal $V0 full +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + big_md5sum_0=$(md5sum $B0/${V0}0/big | awk '{print $1}') + small_md5sum_0=$(md5sum $B0/${V0}0/small | awk '{print $1}') +@@ -114,7 +114,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST gluster volume heal $V0 full +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + big_md5sum_0=$(md5sum $B0/${V0}0/big | awk '{print $1}') + small_md5sum_0=$(md5sum $B0/${V0}0/small | awk '{print $1}') +diff --git a/tests/basic/afr/split-brain-resolution.t b/tests/basic/afr/split-brain-resolution.t +index fa1342e..84b2cc8 100644 +--- a/tests/basic/afr/split-brain-resolution.t ++++ b/tests/basic/afr/split-brain-resolution.t +@@ -38,7 +38,7 @@ TEST $CLI volume start $V0 force + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 + +-EXPECT 4 afr_get_pending_heal_count $V0 ++EXPECT 4 get_pending_heal_count $V0 + + TEST ! cat $M0/data-split-brain.txt + TEST ! getfattr -n user.test $M0/metadata-split-brain.txt +@@ -82,6 +82,6 @@ TEST setfattr -n replica.split-brain-heal-finalize -v $V0-client-1 $M0/data-spli + EXPECT "brick0" get_text_xattr user.test $M0/metadata-split-brain.txt + EXPECT "brick1_alive" cat $M0/data-split-brain.txt + +-EXPECT 0 afr_get_pending_heal_count $V0 ++EXPECT 0 get_pending_heal_count $V0 + + cleanup; +diff --git a/tests/bugs/glusterfs/bug-861015-index.t b/tests/bugs/glusterfs/bug-861015-index.t +index 05f3e8b..74ffc45 100644 +--- a/tests/bugs/glusterfs/bug-861015-index.t ++++ b/tests/bugs/glusterfs/bug-861015-index.t +@@ -25,7 +25,7 @@ done + HEAL_FILES=$(($HEAL_FILES+3)) #count brick root distribute-subvol num of times + + cd ~ +-EXPECT "$HEAL_FILES" afr_get_pending_heal_count $V0 ++EXPECT "$HEAL_FILES" get_pending_heal_count $V0 + TEST rm -f $M0/* + EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + TEST $CLI volume heal $V0 info +diff --git a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t +index 486b038..6aa2d83 100644 +--- a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t ++++ b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t +@@ -55,7 +55,7 @@ TEST $CLI volume set $V0 cluster.self-heal-daemon on + TEST $CLI volume start $V0 force + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + + #Check external xattrs match + EXPECT "bar" echo $(getfattr -d -m. -e text $B0/${V0}0/d | grep trusted.foo) +diff --git a/tests/bugs/replicate/bug-1180545.t b/tests/bugs/replicate/bug-1180545.t +index 748d5de..e953162 100644 +--- a/tests/bugs/replicate/bug-1180545.t ++++ b/tests/bugs/replicate/bug-1180545.t +@@ -43,6 +43,6 @@ TEST $CLI volume heal $V0 + EXPECT_WITHIN $HEAL_TIMEOUT '2' count_sh_entries $B0/brick0 + EXPECT_WITHIN $HEAL_TIMEOUT '2' count_sh_entries $B0/brick1 + #Two entries for DIR and two for FILE +-EXPECT_WITHIN $HEAL_TIMEOUT "4" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "4" get_pending_heal_count $V0 + TEST diff <(ls $B0/brick0/DIR) <(ls $B0/brick1/DIR) + cleanup +diff --git a/tests/bugs/replicate/bug-1190069-afr-stale-index-entries.t b/tests/bugs/replicate/bug-1190069-afr-stale-index-entries.t +index a476563..2da960f 100644 +--- a/tests/bugs/replicate/bug-1190069-afr-stale-index-entries.t ++++ b/tests/bugs/replicate/bug-1190069-afr-stale-index-entries.t +@@ -50,7 +50,7 @@ TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0 + TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000000 $B0/${V0}1/mdatafile + + TEST $CLI volume heal $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 + EXPECT_WITHIN $HEAL_TIMEOUT '0' echo $(count_sh_entries $B0/$V0"0") + EXPECT_WITHIN $HEAL_TIMEOUT '0' echo $(count_sh_entries $B0/$V0"1") + +diff --git a/tests/bugs/replicate/bug-918437-sh-mtime.t b/tests/bugs/replicate/bug-918437-sh-mtime.t +index 04ac02f..6a194b1 100644 +--- a/tests/bugs/replicate/bug-918437-sh-mtime.t ++++ b/tests/bugs/replicate/bug-918437-sh-mtime.t +@@ -54,7 +54,7 @@ TEST stat $M0/b + TEST gluster volume heal $V0 full + EXPECT_WITHIN $HEAL_TIMEOUT "Y" file_exists $B0/gfs0/brick01/a + EXPECT_WITHIN $HEAL_TIMEOUT "Y" file_exists $B0/gfs0/brick02/b +-EXPECT_WITHIN $HEAL_TIMEOUT 0 afr_get_pending_heal_count $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT 0 get_pending_heal_count $V0 + + size=`stat -c '%s' /etc/passwd` + EXPECT $size stat -c '%s' $B0/gfs0/brick01/a +diff --git a/tests/volume.rc b/tests/volume.rc +index 47ca722..2d8dd72 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -216,7 +216,7 @@ function afr_get_changelog_xattr { + echo $xval + } + +-function afr_get_pending_heal_count { ++function get_pending_heal_count { + local vol=$1 + gluster volume heal $vol info | grep "Number of entries" | awk '{ sum+=$4} END {print sum}' + } +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 3168535..6ee1f9e 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -26,9 +26,6 @@ + #include "syncop-utils.h" + #include "cluster-syncop.h" + +-#define EC_MAX_BACKGROUND_HEALS 8 +-#define EC_MAX_HEAL_WAITERS 128 +- + #define alloca0(size) ({void *__ptr; __ptr = alloca(size); memset(__ptr, 0, size); __ptr; }) + #define EC_COUNT(array, max) ({int __i; int __res = 0; for (__i = 0; __i < max; __i++) if (array[__i]) __res++; __res; }) + #define EC_INTERSECT(dst, src1, src2, max) ({int __i; for (__i = 0; __i < max; __i++) dst[__i] = src1[__i] && src2[__i]; }) +@@ -2329,10 +2326,9 @@ __ec_dequeue_heals (ec_t *ec) + if (list_empty (&ec->heal_waiting)) + goto none; + +- if (ec->healers == EC_MAX_BACKGROUND_HEALS) ++ if ((ec->background_heals > 0) && (ec->healers >= ec->background_heals)) + goto none; + +- GF_ASSERT (ec->healers < EC_MAX_BACKGROUND_HEALS); + fop = list_entry(ec->heal_waiting.next, ec_fop_data_t, healer); + ec->heal_waiters--; + list_del_init(&fop->healer); +@@ -2400,12 +2396,14 @@ ec_heal_throttle (xlator_t *this, ec_fop_data_t *fop) + + LOCK (&ec->lock); + { +- if (ec->heal_waiters >= EC_MAX_HEAL_WAITERS) { +- can_heal = _gf_false; +- } else { ++ if ((ec->background_heals > 0) && ++ (ec->heal_wait_qlen + ec->background_heals) > ++ (ec->heal_waiters + ec->healers)) { + list_add_tail(&fop->healer, &ec->heal_waiting); + ec->heal_waiters++; + fop = __ec_dequeue_heals (ec); ++ } else { ++ can_heal = _gf_false; + } + } + UNLOCK (&ec->lock); +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index dd51630..e28f402 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -219,15 +219,35 @@ int32_t mem_acct_init(xlator_t * this) + return 0; + } + ++void ++ec_configure_background_heal_opts (ec_t *ec, int background_heals, ++ int heal_wait_qlen) ++{ ++ if (background_heals == 0) { ++ ec->heal_wait_qlen = 0; ++ } else { ++ ec->heal_wait_qlen = heal_wait_qlen; ++ } ++ ec->background_heals = background_heals; ++} ++ + int32_t + reconfigure (xlator_t *this, dict_t *options) + { +- ec_t *ec = this->private; ++ ec_t *ec = this->private; ++ uint32_t heal_wait_qlen = 0; ++ uint32_t background_heals = 0; + +- GF_OPTION_RECONF ("self-heal-daemon", ec->shd.enabled, options, bool, failed); ++ GF_OPTION_RECONF ("self-heal-daemon", ec->shd.enabled, options, bool, ++ failed); + GF_OPTION_RECONF ("iam-self-heal-daemon", ec->shd.iamshd, options, + bool, failed); +- ++ GF_OPTION_RECONF ("background-heals", background_heals, options, ++ uint32, failed); ++ GF_OPTION_RECONF ("heal-wait-qlength", heal_wait_qlen, options, ++ uint32, failed); ++ ec_configure_background_heal_opts (ec, background_heals, ++ heal_wait_qlen); + return 0; + failed: + return -1; +@@ -577,6 +597,10 @@ init (xlator_t *this) + ec_method_initialize(); + GF_OPTION_INIT ("self-heal-daemon", ec->shd.enabled, bool, failed); + GF_OPTION_INIT ("iam-self-heal-daemon", ec->shd.iamshd, bool, failed); ++ GF_OPTION_INIT ("background-heals", ec->background_heals, uint32, failed); ++ GF_OPTION_INIT ("heal-wait-qlength", ec->heal_wait_qlen, uint32, failed); ++ ec_configure_background_heal_opts (ec, ec->background_heals, ++ ec->heal_wait_qlen); + + if (ec->shd.iamshd) + ec_selfheal_daemon_init (this); +@@ -1188,6 +1212,10 @@ int32_t ec_dump_private(xlator_t *this) + gf_proc_dump_write("childs_up", "%u", ec->xl_up_count); + gf_proc_dump_write("childs_up_mask", "%s", + ec_bin(tmp, sizeof(tmp), ec->xl_up, ec->nodes)); ++ gf_proc_dump_write("background-heals", "%d", ec->background_heals); ++ gf_proc_dump_write("heal-wait-qlength", "%d", ec->heal_wait_qlen); ++ gf_proc_dump_write("healers", "%d", ec->healers); ++ gf_proc_dump_write("heal-waiters", "%d", ec->heal_waiters); + + return 0; + } +@@ -1271,5 +1299,21 @@ struct volume_options options[] = + "translator is running as part of self-heal-daemon " + "or not." + }, ++ { .key = {"background-heals"}, ++ .type = GF_OPTION_TYPE_INT, ++ .min = 0,/*Disabling background heals*/ ++ .max = 256, ++ .default_value = "8", ++ .description = "This option can be used to control number of parallel" ++ " heals", ++ }, ++ { .key = {"heal-wait-qlength"}, ++ .type = GF_OPTION_TYPE_INT, ++ .min = 0, ++ .max = 65536, /*Around 100MB as of now with sizeof(ec_fop_data_t) at 1800*/ ++ .default_value = "128", ++ .description = "This option can be used to control number of heals" ++ " that can wait", ++ }, + { } + }; +diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h +index 7f14020..f335fd5 100644 +--- a/xlators/cluster/ec/src/ec.h ++++ b/xlators/cluster/ec/src/ec.h +@@ -47,6 +47,8 @@ struct _ec + gf_lock_t lock; + gf_timer_t * timer; + gf_boolean_t shutdown; ++ uint32_t background_heals; ++ uint32_t heal_wait_qlen; + struct list_head pending_fops; + struct list_head heal_waiting; + struct list_head healing; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index 7bbd729..b536d18 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -2015,6 +2015,14 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .voltype = "features/upcall", + .op_version = GD_OP_VERSION_3_7_0, + }, ++ { .key = "disperse.background-heals", ++ .voltype = "cluster/disperse", ++ .op_version = GD_OP_VERSION_3_7_3, ++ }, ++ { .key = "disperse.heal-wait-qlength", ++ .voltype = "cluster/disperse", ++ .op_version = GD_OP_VERSION_3_7_3, ++ }, + { .key = NULL + } + }; +-- +1.7.1 + diff --git a/SOURCES/0201-access-control-validating-context-of-access-control-.patch b/SOURCES/0201-access-control-validating-context-of-access-control-.patch new file mode 100644 index 0000000..f04ada0 --- /dev/null +++ b/SOURCES/0201-access-control-validating-context-of-access-control-.patch @@ -0,0 +1,381 @@ +From 974475da2773f93ddb7045c3ae53b9bc42b3d1df Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Wed, 10 Jun 2015 00:08:39 +0530 +Subject: [PATCH 201/212] access-control : validating context of access control translator + +By introduction of new acl conversion from http://review.gluster.org/#/c/9627/, +an acl can be set using GF_POSIX_ACL_*_KEY xattrs without notifying the +access-control translator. So evenif an acl is set correctly at the backend, it +might not work properly because access-control holds wrong acl information in +its context about that file. + +Note : This is a simple workaround. The actual solution consists of three steps: +1.) Use new acl api's for acl conversion. +2.) Move the acl conversion part from access-control translator +3.) Introduces standard acl structures and libaries in access-translator +for caching, enforcing purposes. + +Backport of http://review.gluster.org/#/c/11144/ + +Upstream reference: +>Change-Id: Iacb6b323810ebe82f7f171f20be16429463cbcf0 +>BUG: 1229860 +>Signed-off-by: Jiffin Tony Thottan +>Reviewed-on: http://review.gluster.org/11144 +>Reviewed-by: Niels de Vos +>Tested-by: Gluster Build System +>Reviewed-by: Kaleb KEITHLEY +>cherry-picked from 81cb71e9317e380b1d414038223c72643b35e664 + +Change-Id: I64bc681ddd5f97f7146248fff2058885e73064a8 +BUG: 1229567 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52284 +Reviewed-by: Niels de Vos +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + xlators/storage/posix/src/posix-messages.h | 8 ++ + xlators/storage/posix/src/posix.c | 103 +++++++++++++++++++++++- + xlators/storage/posix/src/posix.h | 2 + + xlators/system/posix-acl/src/posix-acl.c | 121 +++++++++++++++++++++++++++- + 4 files changed, 227 insertions(+), 7 deletions(-) + +diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h +index 9916aed..9f267df 100644 +--- a/xlators/storage/posix/src/posix-messages.h ++++ b/xlators/storage/posix/src/posix-messages.h +@@ -893,6 +893,14 @@ + * + */ + ++#define P_MSG_BUFFER_OVERFLOW (POSIX_COMP_BASE + 105) ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 91e95ef..df90eb6 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3250,8 +3250,10 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + int32_t op_ret = -1; + int32_t op_errno = 0; + char * real_path = NULL; ++ char *acl_xattr = NULL; + struct iatt stbuf = {0}; + int32_t ret = 0; ++ size_t acl_size = 0; + dict_t *xattr = NULL; + posix_xattr_filler_t filler = {0,}; + +@@ -3290,6 +3292,10 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + goto out; + } + ++ xattr = dict_new(); ++ if (!xattr) ++ goto out; ++ + /* + * FIXFIX: Send the stbuf info in the xdata for now + * This is used by DHT to redirect FOPs if the file is being migrated +@@ -3300,10 +3306,98 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + if (ret) + goto out; + +- xattr = dict_new(); +- if (!xattr) ++ ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } ++ ++/* ++ * ACL can be set on a file/folder using GF_POSIX_ACL_*_KEY xattrs which ++ * won't aware of access-control xlator. To update its context correctly, ++ * POSIX_ACL_*_XATTR stored in xdata which is send in the call_back path. ++ */ ++ if (dict_get (dict, GF_POSIX_ACL_ACCESS)) { ++ ++ /* ++ * The size of buffer will be know after calling sys_lgetxattr, ++ * so first we allocate buffer with large size(~4k), then we ++ * reduced into required size using GF_REALLO(). ++ */ ++ acl_xattr = GF_CALLOC (1, ACL_BUFFER_MAX, gf_posix_mt_char); ++ if (!acl_xattr) { ++ ret = -1; + goto out; +- ret = posix_set_iatt_in_dict (xattr, &stbuf); ++ } ++ ++ acl_size = sys_lgetxattr (real_path, POSIX_ACL_ACCESS_XATTR, ++ acl_xattr, ACL_BUFFER_MAX); ++ ++ if (acl_size < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_XATTR_FAILED, "Posix acl is not set " ++ "properly at the backend"); ++ ret = -1; ++ goto out; ++ } ++ ++ /* If acl_size is more than max buffer size, just ignore it */ ++ if (acl_size >= ACL_BUFFER_MAX) { ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ P_MSG_BUFFER_OVERFLOW, "size of acl is more" ++ "than the buffer"); ++ ret = -1; ++ goto out; ++ } ++ ++ acl_xattr = GF_REALLOC (acl_xattr, acl_size); ++ ret = dict_set_bin (xattr, POSIX_ACL_ACCESS_XATTR, ++ acl_xattr, acl_size); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_SET_XDATA_FAIL, "failed to set" ++ "xdata for acl"); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ GF_FREE (acl_xattr); ++ acl_xattr = NULL; ++ ++ if (dict_get (dict, GF_POSIX_ACL_DEFAULT)) { ++ ++ acl_xattr = GF_CALLOC (1, ACL_BUFFER_MAX, gf_posix_mt_char); ++ if (!acl_xattr) { ++ ret = -1; ++ goto out; ++ } ++ acl_size = sys_lgetxattr (real_path, POSIX_ACL_DEFAULT_XATTR, ++ acl_xattr, ACL_BUFFER_MAX); ++ ++ if (acl_size < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ P_MSG_XATTR_FAILED, "Posix acl is not set " ++ "properly at the backend"); ++ ret = -1; ++ goto out; ++ } ++ ++ if (acl_size >= ACL_BUFFER_MAX) { ++ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, ++ P_MSG_BUFFER_OVERFLOW, "size of acl is more" ++ "than the buffer"); ++ ret = -1; ++ goto out; ++ } ++ ++ acl_xattr = GF_REALLOC (acl_xattr, acl_size); ++ ret = dict_set_bin (xattr, POSIX_ACL_DEFAULT_XATTR, ++ acl_xattr, acl_size); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ P_MSG_SET_XDATA_FAIL, "failed to set" ++ "xdata for acl"); ++ ret = -1; ++ goto out; ++ } + } + out: + SET_TO_OLD_FS_ID (); +@@ -3313,6 +3407,9 @@ out: + if (xattr) + dict_unref(xattr); + ++ if (acl_xattr) ++ GF_FREE (acl_xattr); ++ + return 0; + } + +diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h +index d53a488..cf1465a 100644 +--- a/xlators/storage/posix/src/posix.h ++++ b/xlators/storage/posix/src/posix.h +@@ -53,6 +53,8 @@ + #define VECTOR_SIZE 64 * 1024 /* vector size 64KB*/ + #define MAX_NO_VECT 1024 + ++#define ACL_BUFFER_MAX 4096 /* size of character buffer */ ++ + #define LINKTO "trusted.glusterfs.dht.linkto" + + #define POSIX_GFID_HANDLE_SIZE(base_path_len) (base_path_len + SLEN("/") \ +diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c +index 0560869..da2ccbd 100644 +--- a/xlators/system/posix-acl/src/posix-acl.c ++++ b/xlators/system/posix-acl/src/posix-acl.c +@@ -306,6 +306,26 @@ posix_acl_ctx_get (inode_t *inode, xlator_t *this) + return ctx; + } + ++int ++__posix_acl_set_specific (inode_t *inode, xlator_t *this, ++ gf_boolean_t is_access, struct posix_acl *acl) ++{ ++ int ret = 0; ++ struct posix_acl_ctx *ctx = NULL; ++ ++ ctx = posix_acl_ctx_get (inode, this); ++ if (!ctx) { ++ ret = -1; ++ goto out; ++ } ++ ++ if (is_access) ++ ctx->acl_access = acl; ++ else ++ ctx->acl_default = acl; ++out: ++ return ret; ++} + + int + __posix_acl_set (inode_t *inode, xlator_t *this, struct posix_acl *acl_access, +@@ -426,6 +446,36 @@ posix_acl_unref (xlator_t *this, struct posix_acl *acl) + posix_acl_destroy (this, acl); + } + ++int ++posix_acl_set_specific (inode_t *inode, xlator_t *this, struct posix_acl *acl, ++ gf_boolean_t is_access) ++{ ++ int ret = 0; ++ int oldret = 0; ++ struct posix_acl *old_acl = NULL; ++ struct posix_acl_conf *conf = NULL; ++ ++ conf = this->private; ++ ++ LOCK (&conf->acl_lock); ++ { ++ if (is_access) ++ oldret = __posix_acl_get (inode, this, &old_acl, NULL); ++ else ++ oldret = __posix_acl_get (inode, this, NULL, &old_acl); ++ if (acl) ++ acl->refcnt++; ++ ret = __posix_acl_set_specific (inode, this, is_access, acl); ++ } ++ UNLOCK (&conf->acl_lock); ++ ++ if (oldret == 0) { ++ if (old_acl) ++ posix_acl_unref (this, old_acl); ++ } ++ ++ return ret; ++} + + int + posix_acl_set (inode_t *inode, xlator_t *this, struct posix_acl *acl_access, +@@ -497,7 +547,6 @@ unlock: + return ret; + } + +- + mode_t + posix_acl_inherit_mode (struct posix_acl *acl, mode_t modein) + { +@@ -1883,11 +1932,71 @@ posix_acl_setxattr_update (xlator_t *this, inode_t *inode, dict_t *xattr) + return ret; + } + ++/* * ++ * Posix acl can be set using other xattr such as GF_POSIX_ACL_ACCESS/ ++ * GF_POSIX_ACL_DEFAULT which requires to update the context of ++ * access-control translator ++ */ ++int ++handling_other_acl_related_xattr (xlator_t *this, inode_t *inode, dict_t *xattr) ++{ ++ struct posix_acl *acl = NULL; ++ struct posix_acl_ctx *ctx = NULL; ++ data_t *data = NULL; ++ int ret = 0; ++ ++ ctx = posix_acl_ctx_get (inode, this); ++ if (!ctx) { ++ ret = -1; ++ goto out; ++ } ++ ++ data = dict_get (xattr, POSIX_ACL_ACCESS_XATTR); ++ if (data) { ++ ctx = posix_acl_ctx_get (inode, this); ++ if (!ctx) { ++ ret = -1; ++ goto out; ++ } ++ ++ acl = posix_acl_from_xattr (this, data->data, data->len); + ++ ret = posix_acl_set_specific (inode, this, acl, _gf_true); ++ if (ret) ++ goto out; ++ ++ if (acl) ++ posix_acl_access_set_mode (acl, ctx); ++ ++ } ++ ++ if (acl) ++ posix_acl_unref (this, acl); ++ ++ data = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR); ++ if (data) { ++ acl = posix_acl_from_xattr (this, data->data, data->len); ++ ++ ret = posix_acl_set_specific (inode, this, acl, _gf_false); ++ } ++ ++out: ++ if (acl) ++ posix_acl_unref (this, acl); ++ ++ return ret; ++} + int + posix_acl_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata) + { ++ ++ /* ++ * Update the context of posix_acl_translator, if any of ++ * POSIX_ACL_*_XATTR set in the call back ++ */ ++ handling_other_acl_related_xattr (this, (inode_t *)cookie, xdata); ++ + STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xdata); + + return 0; +@@ -1907,9 +2016,13 @@ posix_acl_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + + posix_acl_setxattr_update (this, loc->inode, xattr); + +- STACK_WIND (frame, posix_acl_setxattr_cbk, +- FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr, +- loc, xattr, flags, xdata); ++ /* ++ * inode is required in call back function to update the context ++ * this translator ++ */ ++ STACK_WIND_COOKIE (frame, posix_acl_setxattr_cbk, loc->inode, ++ FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr, ++ loc, xattr, flags, xdata); + return 0; + red: + STACK_UNWIND_STRICT (setxattr, frame, -1, op_errno, xdata); +-- +1.7.1 + diff --git a/SOURCES/0202-tools-glusterfind-RENAME-and-MODIFY-issues.patch b/SOURCES/0202-tools-glusterfind-RENAME-and-MODIFY-issues.patch new file mode 100644 index 0000000..198e443 --- /dev/null +++ b/SOURCES/0202-tools-glusterfind-RENAME-and-MODIFY-issues.patch @@ -0,0 +1,119 @@ +From 2a4e3b9ca03e5d751ce51549408c774e71defcb6 Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Fri, 3 Jul 2015 12:02:11 +0530 +Subject: [PATCH 202/212] tools/glusterfind: RENAME and MODIFY issues + +If Modification happens before RENAME, GFID to Path Conversion +converts it into New Path. Delete Modify Entry and insert again +So that MODIFY comes after RENAME. + +Default value of pgfids and basenames changed to "" instead of NULL +Also fixed RENAME issue of displaying "RENAME ". +Also fixed RENAME followed by missing MODIFY + +Change-Id: Ie67219cc049a427e95ab6426bb890b02ffc1a853 +BUG: 1228247 +Reviewed-On: http://review.gluster.org/#/c/11443/ +Signed-off-by: Milind Changire +Reviewed-on: https://code.engineering.redhat.com/gerrit/52285 +Reviewed-by: Kotresh Hiremath Ravishankar +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + tools/glusterfind/src/changelogdata.py | 39 +++++++++++++++++++++++--------- + tools/glusterfind/src/main.py | 3 +- + 2 files changed, 30 insertions(+), 12 deletions(-) + +diff --git a/tools/glusterfind/src/changelogdata.py b/tools/glusterfind/src/changelogdata.py +index c42aa2a..08d711b 100644 +--- a/tools/glusterfind/src/changelogdata.py ++++ b/tools/glusterfind/src/changelogdata.py +@@ -100,10 +100,10 @@ class ChangelogData(object): + ts VARCHAR, + type VARCHAR, + gfid VARCHAR(40), +- pgfid1 VARCHAR(40), +- bn1 VARCHAR(500), +- pgfid2 VARCHAR(40), +- bn2 VARCHAR(500), ++ pgfid1 VARCHAR(40) DEFAULT '', ++ bn1 VARCHAR(500) DEFAULT '', ++ pgfid2 VARCHAR(40) DEFAULT '', ++ bn2 VARCHAR(500) DEFAULT '', + path1 VARCHAR DEFAULT '', + path2 VARCHAR DEFAULT '' + ) +@@ -283,7 +283,7 @@ class ChangelogData(object): + + def append_path1(self, path, inode): + # || is for concatenate in SQL +- query = """UPDATE gfidpath SET path1 = ',' || ? ++ query = """UPDATE gfidpath SET path1 = path1 || ',' || ? + WHERE gfid IN (SELECT gfid FROM inodegfid WHERE inode = ?)""" + self.cursor.execute(query, (path, inode)) + +@@ -344,16 +344,32 @@ class ChangelogData(object): + "pgfid1": pgfid1, "bn1": bn1}) + elif self.gfidpath_exists({"gfid": data[1], "type": "RENAME", + "pgfid2": pgfid1, "bn2": bn1}): +- # If / is same as /(may be previous +- # RENAME) then UPDATE / as / +- self.gfidpath_update({"pgfid2": pgfid2, "bn2": bn2}, +- {"gfid": data[1], "type": "RENAME", +- "pgfid2": pgfid1, "bn2": bn1}) ++ # If we are renaming file back to original name then just ++ # delete the entry since it will effectively be a no-op ++ if self.gfidpath_exists({"gfid": data[1], "type": "RENAME", ++ "pgfid2": pgfid1, "bn2": bn1, ++ "pgfid1": pgfid2, "bn1": bn2}): ++ self.gfidpath_delete({"gfid": data[1], "type": "RENAME", ++ "pgfid2": pgfid1, "bn2": bn1}) ++ else: ++ # If / is same as / ++ # (may be previous RENAME) ++ # then UPDATE / as / ++ self.gfidpath_update({"pgfid2": pgfid2, "bn2": bn2}, ++ {"gfid": data[1], "type": "RENAME", ++ "pgfid2": pgfid1, "bn2": bn1}) + else: + # Else insert as RENAME + self.gfidpath_add(changelogfile, RecordType.RENAME, data[1], + pgfid1, bn1, pgfid2, bn2) + ++ if self.gfidpath_exists({"gfid": data[1], "type": "MODIFY"}): ++ # If MODIFY exists already for that GFID, remove it and insert ++ # again so that MODIFY entry comes after RENAME entry ++ # Output will have MODIFY ++ self.gfidpath_delete({"gfid": data[1], "type": "MODIFY"}) ++ self.gfidpath_add(changelogfile, RecordType.MODIFY, data[1]) ++ + def when_link_symlink(self, changelogfile, data): + # E / + # Add as New record in Db as Type NEW +@@ -366,7 +382,8 @@ class ChangelogData(object): + + def when_data_meta(self, changelogfile, data): + # If GFID row exists, Ignore else Add to Db +- if not self.gfidpath_exists({"gfid": data[1]}): ++ if not self.gfidpath_exists({"gfid": data[1], "type": "NEW"}) and \ ++ not self.gfidpath_exists({"gfid": data[1], "type": "MODIFY"}): + self.gfidpath_add(changelogfile, RecordType.MODIFY, data[1]) + + def when_unlink_rmdir(self, changelogfile, data): +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 8d32295..9a6a2ac 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -433,7 +433,8 @@ def mode_pre(session_dir, args): + # Multiple paths in case of Hardlinks + paths = row[1].split(",") + for p in paths: +- if p == "": ++ if p == "" or p.replace("%2F%2F","%2F") == \ ++ row[2].replace("%2F%2F","%2F"): + continue + f.write("%s %s %s\n" % (row[0], p, row[2])) + +-- +1.7.1 + diff --git a/SOURCES/0203-cluster-afr-expunge-first-impunge-next-in-entry-self.patch b/SOURCES/0203-cluster-afr-expunge-first-impunge-next-in-entry-self.patch new file mode 100644 index 0000000..a759562 --- /dev/null +++ b/SOURCES/0203-cluster-afr-expunge-first-impunge-next-in-entry-self.patch @@ -0,0 +1,155 @@ +From b7b17674507090e9b161a64c3d5a6f77224fa608 Mon Sep 17 00:00:00 2001 +From: Anuradha Talur +Date: Fri, 3 Jul 2015 11:35:46 +0530 +Subject: [PATCH 203/212] cluster/afr : expunge first, impunge next in entry selfheal + + Backport of: http://review.gluster.org/11544/ + +When entry self-heals are performed, the files/directories +that are to be expunged should be removed first and then +impunge should be done. + +Consider the following scenario : +A volume with 2 bricks : b0 and b1. +1) With following hierarchy on both bricks: +olddir +|__ oldfile + +2) Bring down b1 and do 'mv olddir newdir'. + +3) Bring up b1 and self-heal. + +4) Without patch, during self-heal the events occur in +following order, + a) Creation of newdir on the sink brick. Notice that +gfid of olddir and newdir are same. As a result of which +gfid-link file in .glusterfs directory still points to olddir +and not to newdir. + + b) Deletion of olddir on the sink brick. As a part of +this deletion, the gfid link file is also deleted. Now, there +is no link file pointing to newdir. + +5) Files under newdir will not get listed as part of readdir. + +To tackle this kind of scenario, an expunge should be done first +and impunge later; which is the purpose of this patch. + +Change-Id: Idc8546f652adf11a13784ff989077cf79986bbd5 +BUG: 1231732 +Reviewed-on: http://review.gluster.org/11498 +Reviewed-by: Ravishankar N +Tested-by: Gluster Build System +Reviewed-by: Krutika Dhananjay +Reviewed-by: Pranith Kumar Karampuri +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/52357 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + tests/bugs/replicate/bug-1130892.t | 2 + + tests/bugs/replicate/bug-1238508-self-heal.t | 51 +++++++++++++++++++++++++ + xlators/cluster/afr/src/afr-self-heal-entry.c | 7 ++- + 3 files changed, 58 insertions(+), 2 deletions(-) + create mode 100644 tests/bugs/replicate/bug-1238508-self-heal.t + +diff --git a/tests/bugs/replicate/bug-1130892.t b/tests/bugs/replicate/bug-1130892.t +index 945ee49..7442ab8 100644 +--- a/tests/bugs/replicate/bug-1130892.t ++++ b/tests/bugs/replicate/bug-1130892.t +@@ -54,6 +54,8 @@ EXPECT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$ + TEST gluster volume set $V0 self-heal-daemon on + + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + TEST $CLI volume heal $V0 + EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one + EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one/two +diff --git a/tests/bugs/replicate/bug-1238508-self-heal.t b/tests/bugs/replicate/bug-1238508-self-heal.t +new file mode 100644 +index 0000000..24fb07d +--- /dev/null ++++ b/tests/bugs/replicate/bug-1238508-self-heal.t +@@ -0,0 +1,51 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume start $V0 ++ ++# Disable self-heal-daemon ++TEST $CLI volume set $V0 cluster.self-heal-daemon off ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST mkdir $M0/olddir; ++TEST `echo "some-data" > $M0/olddir/oldfile` ++ ++TEST kill_brick $V0 $H0 $B0/${V0}1 ++TEST mv $M0/olddir/oldfile $M0/olddir/newfile; ++TEST mv $M0/olddir $M0/newdir; ++ ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++TEST $CLI volume set $V0 cluster.self-heal-daemon on ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 ++ ++TEST $CLI volume heal $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 ++ ++# Test if the files are present on both the bricks ++EXPECT "newdir" ls $B0/${V0}0/ ++EXPECT "newdir" ls $B0/${V0}1/ ++EXPECT "newfile" ls $B0/${V0}0/newdir/ ++EXPECT "newfile" ls $B0/${V0}1/newdir/ ++ ++# Test if gfid-link files in .glusterfs also provide correct info ++brick0gfid=$(gf_get_gfid_backend_file_path $B0/${V0}0 newdir) ++brick1gfid=$(gf_get_gfid_backend_file_path $B0/${V0}1 newdir) ++EXPECT "newfile" ls $brick0gfid ++EXPECT "newfile" ls $brick1gfid ++ ++# Test if the files are accessible from the mount ++EXPECT "newdir" ls $M0/ ++EXPECT "newfile" ls $M0/newdir ++ ++cleanup; +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index 13a280f..f192931 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -589,17 +589,20 @@ afr_selfheal_entry_do (call_frame_t *frame, xlator_t *this, fd_t *fd, + uuid_utoa (fd->inode->gfid)); + + for (i = 0; i < priv->child_count; i++) { +- if (i != source && !healed_sinks[i]) ++ if (!healed_sinks[i]) + continue; + ret = afr_selfheal_entry_do_subvol (frame, this, fd, i); + if (ret == -1) { + /* gfid or type mismatch. */ + mismatch = _gf_true; +- continue; ++ ret = 0; + } + if (ret) + break; + } ++ if (!ret && source != -1) ++ ret = afr_selfheal_entry_do_subvol (frame, this, fd, source); ++ + if (mismatch == _gf_true) + /* undo pending will be skipped */ + ret = -1; +-- +1.7.1 + diff --git a/SOURCES/0204-glusterd-shared_storage-Use-var-lib-glusterd-ss_bric.patch b/SOURCES/0204-glusterd-shared_storage-Use-var-lib-glusterd-ss_bric.patch new file mode 100644 index 0000000..f42a55b --- /dev/null +++ b/SOURCES/0204-glusterd-shared_storage-Use-var-lib-glusterd-ss_bric.patch @@ -0,0 +1,140 @@ +From 0f3b3f4e3c24c391e8a9ed2a44e32c7499c50fa4 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Sun, 5 Jul 2015 12:21:31 +0530 +Subject: [PATCH 204/212] glusterd/shared_storage: Use /var/lib/glusterd/ss_brick as shared storage's brick + +The brick path we use to create shared storage is +/var/run/gluster/ss_brick. + +The problem with using this brick path is /var/run/gluster +is a tmpfs and all the brick/shared storage data will be wiped +off when the node restarts. Hence using /var/lib/glusterd/ss_brick +as the brick path for shared storage volume as this brick and +the shared storage volume is internally created by us (albeit on +user's request), and contains only internal state data and no user data. + +>Reviewed-on: http://review.gluster.org/11533 +Change-Id: I808d1aa3e204a5d2022086d23bdbfdd44a2cfb1c +BUG: 1223205 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/52414 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + .../set/post/S32gluster_enable_shared_storage.sh | 2 +- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 9 ++++----- + xlators/mgmt/glusterd/src/glusterd.c | 10 +++------- + xlators/mgmt/glusterd/src/glusterd.h | 8 ++++---- + 4 files changed, 12 insertions(+), 17 deletions(-) + +diff --git a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +index 68bc44d..9080219 100755 +--- a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh ++++ b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh +@@ -74,7 +74,7 @@ create_cmd="gluster --mode=script --wignore volume create \ + # Adding the brick names in the command + for i in "${connected_peer[@]}" + do +- create_cmd=$create_cmd" "$i:/var/run/gluster/ss_brick ++ create_cmd=$create_cmd" "$i:"$GLUSTERD_WORKDIR"/ss_brick + done + + if [ "$option" == "disable" ]; then +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index c8acc86..4619f57 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -56,7 +56,6 @@ + #include + #include + +-extern char ss_brick_path[PATH_MAX]; + extern char local_node_hostname[PATH_MAX]; + static int + glusterd_set_shared_storage (dict_t *dict, char *key, char *value, +@@ -2245,12 +2244,12 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value, + /* Re-create the brick path so as to be * + * able to re-use it * + */ +- ret = recursive_rmdir (ss_brick_path); ++ ret = recursive_rmdir (GLUSTER_SHARED_STORAGE_BRICK_DIR); + if (ret) { + snprintf (errstr, PATH_MAX, + "Failed to remove shared " + "storage brick(%s). " +- "Reason: %s", ss_brick_path, ++ "Reason: %s", GLUSTER_SHARED_STORAGE_BRICK_DIR, + strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "%s", errstr); +@@ -2258,12 +2257,12 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value, + goto out; + } + +- ret = mkdir_p (ss_brick_path, 0777, _gf_true); ++ ret = mkdir_p (GLUSTER_SHARED_STORAGE_BRICK_DIR, 0777, _gf_true); + if (-1 == ret) { + snprintf (errstr, PATH_MAX, + "Failed to create shared " + "storage brick(%s). " +- "Reason: %s", ss_brick_path, ++ "Reason: %s", GLUSTER_SHARED_STORAGE_BRICK_DIR, + strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_CREATE_DIR_FAILED, "%s", errstr); +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 4203705..9754e8b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -68,7 +68,6 @@ extern struct rpc_clnt_program gd_brick_prog; + extern struct rpcsvc_program glusterd_mgmt_hndsk_prog; + + extern char snap_mount_dir[PATH_MAX]; +-char ss_brick_path[PATH_MAX]; + + rpcsvc_cbk_program_t glusterd_cbk_prog = { + .progname = "Gluster Callback", +@@ -1445,18 +1444,15 @@ init (xlator_t *this) + snprintf (snap_mount_dir, sizeof(snap_mount_dir), "%s%s", + var_run_dir, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); + +- ret = glusterd_init_var_run_dirs (this, var_run_dir, +- GLUSTER_SHARED_STORAGE_BRICK_DIR); ++ ret = mkdir_p (GLUSTER_SHARED_STORAGE_BRICK_DIR, 0777, ++ _gf_true); + if (ret) { + gf_msg (this->name, GF_LOG_CRITICAL, 0, +- GD_MSG_VAR_RUN_DIR_INIT_FAIL, "Unable to create " ++ GD_MSG_DIR_OP_FAILED, "Unable to create " + "shared storage brick"); + exit (1); + } + +- snprintf (ss_brick_path, sizeof(ss_brick_path), "%s%s", +- var_run_dir, GLUSTER_SHARED_STORAGE_BRICK_DIR); +- + snprintf (cmd_log_filename, PATH_MAX, "%s/cmd_history.log", + DEFAULT_LOG_FILE_DIRECTORY); + ret = gf_cmd_log_init (cmd_log_filename); +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index cfe7a7b..c72c569 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -513,10 +513,10 @@ typedef enum { + #define GLUSTERD_MISSED_SNAPS_LIST_FILE "missed_snaps_list" + #define GLUSTERD_VOL_SNAP_DIR_PREFIX "snaps" + +-#define GLUSTERD_DEFAULT_SNAPS_BRICK_DIR "/gluster/snaps" +-#define GLUSTER_SHARED_STORAGE_BRICK_DIR "/gluster/ss_brick" +-#define GLUSTERD_VAR_RUN_DIR "/var/run" +-#define GLUSTERD_RUN_DIR "/run" ++#define GLUSTERD_DEFAULT_SNAPS_BRICK_DIR "/gluster/snaps" ++#define GLUSTER_SHARED_STORAGE_BRICK_DIR GLUSTERD_DEFAULT_WORKDIR"/ss_brick" ++#define GLUSTERD_VAR_RUN_DIR "/var/run" ++#define GLUSTERD_RUN_DIR "/run" + + /* definitions related to replace brick */ + #define RB_CLIENT_MOUNTPOINT "rb_mount" +-- +1.7.1 + diff --git a/SOURCES/0205-cluster-ec-Don-t-read-from-bad-subvols.patch b/SOURCES/0205-cluster-ec-Don-t-read-from-bad-subvols.patch new file mode 100644 index 0000000..608ed23 --- /dev/null +++ b/SOURCES/0205-cluster-ec-Don-t-read-from-bad-subvols.patch @@ -0,0 +1,84 @@ +From ad552c08bab5cb17cc0aecff3fa782d6ec1e2eb4 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Mon, 6 Jul 2015 14:23:56 +0530 +Subject: [PATCH 205/212] cluster/ec: Don't read from bad subvols + + Backport of http://review.gluster.org/11531 + +Change-Id: Ic22813371faca4e8198c9b0b20518e68d275f3c1 +BUG: 1230513 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52367 +--- + xlators/cluster/ec/src/ec-common.c | 41 ++++++++++++++++++++--------------- + 1 files changed, 23 insertions(+), 18 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 455df99..200aeda 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -382,6 +382,24 @@ void ec_complete(ec_fop_data_t * fop) + ec_fop_data_release(fop); + } + ++/* There could be already granted locks sitting on the bricks, unlock for which ++ * must be wound at all costs*/ ++static gf_boolean_t ++ec_must_wind (ec_fop_data_t *fop) ++{ ++ if ((fop->id == GF_FOP_INODELK) || (fop->id == GF_FOP_FINODELK) || ++ (fop->id == GF_FOP_LK)) { ++ if (fop->flock.l_type == F_UNLCK) ++ return _gf_true; ++ } else if ((fop->id == GF_FOP_ENTRYLK) || ++ (fop->id == GF_FOP_FENTRYLK)) { ++ if (fop->entrylk_cmd == ENTRYLK_UNLOCK) ++ return _gf_true; ++ } ++ ++ return _gf_false; ++} ++ + int32_t ec_child_select(ec_fop_data_t * fop) + { + ec_t * ec = fop->xl->private; +@@ -391,6 +409,11 @@ int32_t ec_child_select(ec_fop_data_t * fop) + ec_fop_cleanup(fop); + + fop->mask &= ec->node_mask; ++ /* Wind the fop on same subvols as parent for any internal extra fops like ++ * head/tail read in case of writev fop. Unlocks shouldn't do this because ++ * unlock should go on all subvols where lock is performed*/ ++ if (fop->parent && !ec_must_wind (fop)) ++ fop->mask &= fop->parent->mask; + + mask = ec->xl_up; + if (fop->parent == NULL) +@@ -1868,24 +1891,6 @@ void ec_lock_reuse(ec_fop_data_t *fop) + } + } + +-/* There could be already granted locks sitting on the bricks, unlock for which +- * must be wound at all costs*/ +-static gf_boolean_t +-ec_must_wind (ec_fop_data_t *fop) +-{ +- if ((fop->id == GF_FOP_INODELK) || (fop->id == GF_FOP_FINODELK) || +- (fop->id == GF_FOP_LK)) { +- if (fop->flock.l_type == F_UNLCK) +- return _gf_true; +- } else if ((fop->id == GF_FOP_ENTRYLK) || +- (fop->id == GF_FOP_FENTRYLK)) { +- if (fop->entrylk_cmd == ENTRYLK_UNLOCK) +- return _gf_true; +- } +- +- return _gf_false; +-} +- + void __ec_manager(ec_fop_data_t * fop, int32_t error) + { + ec_t *ec = fop->xl->private; +-- +1.7.1 + diff --git a/SOURCES/0206-cluster-ec-Remove-failed-subvols-from-source-sink-co.patch b/SOURCES/0206-cluster-ec-Remove-failed-subvols-from-source-sink-co.patch new file mode 100644 index 0000000..524e4ec --- /dev/null +++ b/SOURCES/0206-cluster-ec-Remove-failed-subvols-from-source-sink-co.patch @@ -0,0 +1,57 @@ +From 650f9b02e96c5b4721f19c5b7515e238edac64f5 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Mon, 6 Jul 2015 12:22:20 +0530 +Subject: [PATCH 206/212] cluster/ec: Remove failed subvols from source/sink computation + + Backport of http://review.gluster.com/11546 + +Change-Id: Ib0de34c86ee25de361ec821d4015296c514742e0 +BUG: 1240168 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52360 +--- + xlators/cluster/ec/src/ec-heal.c | 7 ++++++- + 1 files changed, 6 insertions(+), 1 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 6ee1f9e..6f82203 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -471,6 +471,8 @@ ec_heal_metadata_find_direction (ec_t *ec, default_args_cbk_t *replies, + for (i = 0; i < ec->nodes; i++) { + if (!replies[i].valid) + continue; ++ if (replies[i].op_ret < 0) ++ continue; + ret = ec_dict_del_array (replies[i].xdata, EC_XATTR_VERSION, + xattr, EC_VERSION_SIZE); + if (ret == 0) { +@@ -489,6 +491,8 @@ ec_heal_metadata_find_direction (ec_t *ec, default_args_cbk_t *replies, + same_count = 1; + source_ia = replies[i].stat; + for (j = i + 1; j < ec->nodes; j++) { ++ if (!replies[j].valid || replies[j].op_ret < 0) ++ continue; + child_ia = replies[j].stat; + if (!IA_EQUAL(source_ia, child_ia, gfid) || + !IA_EQUAL(source_ia, child_ia, type) || +@@ -517,7 +521,7 @@ ec_heal_metadata_find_direction (ec_t *ec, default_args_cbk_t *replies, + for (i = 0; i < ec->nodes; i++) { + if (groups[i] == groups[same_source]) + sources[i] = 1; +- else if (replies[i].valid) ++ else if (replies[i].valid && replies[i].op_ret >= 0) + healed_sinks[i] = 1; + } + ret = same_source; +@@ -606,6 +610,7 @@ __ec_removexattr_sinks (call_frame_t *frame, ec_t *ec, inode_t *inode, + if (ret < 0) { + sources[i] = 0; + healed_sinks[i] = 0; ++ continue; + } + + if (replies[i].xdata->count == 0) { +-- +1.7.1 + diff --git a/SOURCES/0207-protocol-server-Add-null-check-to-gf_client_put.patch b/SOURCES/0207-protocol-server-Add-null-check-to-gf_client_put.patch new file mode 100644 index 0000000..fba20f5 --- /dev/null +++ b/SOURCES/0207-protocol-server-Add-null-check-to-gf_client_put.patch @@ -0,0 +1,57 @@ +From 09643c44a83dc0bba80286b3a7b460e419d3d79a Mon Sep 17 00:00:00 2001 +From: Raghavendra G +Date: Mon, 6 Jul 2015 15:45:45 +0530 +Subject: [PATCH 207/212] protocol/server: Add null check to gf_client_put + +Change-Id: I8bab3cd7387f89743e15e7569f0bc83a7df3c754 +BUG: 1239280 +Signed-off-by: Raghavendra G +Reviewed-on: http://review.gluster.org/11550 +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/52470 +--- + libglusterfs/src/client_t.c | 6 ++++++ + xlators/protocol/server/src/server-handshake.c | 2 +- + 2 files changed, 7 insertions(+), 1 deletions(-) + +diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c +index 035658f..c6997c0 100644 +--- a/libglusterfs/src/client_t.c ++++ b/libglusterfs/src/client_t.c +@@ -293,6 +293,9 @@ gf_client_put (client_t *client, gf_boolean_t *detached) + gf_boolean_t unref = _gf_false; + int bind_ref; + ++ if (client == NULL) ++ goto out; ++ + if (detached) + *detached = _gf_false; + +@@ -309,6 +312,9 @@ gf_client_put (client_t *client, gf_boolean_t *detached) + *detached = _gf_true; + gf_client_unref (client); + } ++ ++out: ++ return; + } + + client_t * +diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c +index 4aaa933..89e0c1a 100644 +--- a/xlators/protocol/server/src/server-handshake.c ++++ b/xlators/protocol/server/src/server-handshake.c +@@ -705,7 +705,7 @@ fail: + * list of connections the server is maintaining and might segfault + * during statedump when bound_xl of the connection is accessed. + */ +- if (op_ret && !xl) { ++ if (op_ret && !xl && (client != NULL)) { + /* We would have set the xl_private of the transport to the + * @conn. But if we have put the connection i.e shutting down + * the connection, then we should set xl_private to NULL as it +-- +1.7.1 + diff --git a/SOURCES/0208-quota-fix-mem-leak-in-quota-enforcer.patch b/SOURCES/0208-quota-fix-mem-leak-in-quota-enforcer.patch new file mode 100644 index 0000000..9bc29a9 --- /dev/null +++ b/SOURCES/0208-quota-fix-mem-leak-in-quota-enforcer.patch @@ -0,0 +1,40 @@ +From 542bc8e5dc68a78802e212c53e198ee665a84319 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Fri, 3 Jul 2015 17:32:04 +0530 +Subject: [PATCH 208/212] quota: fix mem leak in quota enforcer + +This is a backport of review.gluster.org/#/c/11526/ + +Do inode_unref on parent + +> Change-Id: I21d82eb8716dd73aa2dc291b3ae8506e4fb4ea8b +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: I534b2830357a0c79365cde70822c6863cc6c2ee3 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52305 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index 3212cb0..df0572f 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -955,8 +955,8 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + + list_for_each_entry (entry, parents, next) { + parent = inode_find (inode->table, entry->par); +- + quota_check_limit (frame, parent, this, NULL, NULL); ++ inode_unref (parent); + } + + out: +-- +1.7.1 + diff --git a/SOURCES/0209-posix-fix-mem-leak-in-posix_get_ancestry-error-path.patch b/SOURCES/0209-posix-fix-mem-leak-in-posix_get_ancestry-error-path.patch new file mode 100644 index 0000000..fbcc0e9 --- /dev/null +++ b/SOURCES/0209-posix-fix-mem-leak-in-posix_get_ancestry-error-path.patch @@ -0,0 +1,56 @@ +From 973a0528d4034f593a3f97d1373f259d32914c89 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Fri, 3 Jul 2015 15:16:57 +0530 +Subject: [PATCH 209/212] posix: fix mem-leak in posix_get_ancestry error path + +This is a backport of http://review.gluster.org/#/c/11522/ + +> Change-Id: I47c8a8f170151f6374fc0420278aedf3ff5443ee +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: Id85db72e16c76d33b988267389193cd286aabc06 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52304 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/storage/posix/src/posix.c | 7 +++++++ + 1 files changed, 7 insertions(+), 0 deletions(-) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index df90eb6..27c3457 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3582,6 +3582,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + + strlen (temppath) + 1 ); + if (!tempv) { + GF_FREE (*path); ++ *path = NULL; + op_ret = -1; + *op_errno = ENOMEM; + goto out; +@@ -3596,6 +3597,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + count--; + } + ++ op_ret = 0; + out: + if (dirp) { + op_ret = closedir (dirp); +@@ -3786,6 +3788,11 @@ posix_get_ancestry (xlator_t *this, inode_t *leaf_inode, + } + + out: ++ if (ret && path && *path) { ++ GF_FREE (*path); ++ *path = NULL; ++ } ++ + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0210-quota-marker-fix-mem-leak-in-marker.patch b/SOURCES/0210-quota-marker-fix-mem-leak-in-marker.patch new file mode 100644 index 0000000..ffe1488 --- /dev/null +++ b/SOURCES/0210-quota-marker-fix-mem-leak-in-marker.patch @@ -0,0 +1,749 @@ +From 648be4ccf9e3f077ec0e9849e99c6be98769716f Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Mon, 29 Jun 2015 19:12:28 +0530 +Subject: [PATCH 210/212] quota/marker: fix mem leak in marker + +This is a backport of http://review.gluster.org/#/c/11457/ + +Problem-1) +Now the marker accounting happens in background, +There is a possibility that before completing +create_xattr_txn another create txn can be initiated +for the same inode. +suppose if few 100 txns are initiated +before completion, this can block all synctask threads +waiting on a lock and this can also consume lot of memory +and can take more time to complete the background accounting +operation. + +This patch improves the locking mechanism which +can improve the performance as well reduce memory +consumption + +Problem-2) +For every lookup and for all inodes in readdirp +we were initiating a new txn, this can result +in more txn pending in synctask queue and +lead to huge memory consumption. inspect +file/dir should start a txn only if there +is some delta + +Problem-3) +When there are multiple write operations on +same inode and all the synctask threads are busy. +As we are checking for updation_status +flag in background, all txn will be move to synctask queue. +This can increase the mem usage. + +Only one txn for inode in a queue will be sufficient, +so check and set updation falg before moving txn to +background + +> Change-Id: Ic42ce00f0a50ce51c7128ba68a1b6a0699a1cd14 +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: Iee464d51d4ebe70c2ec7cf66540198f8af16f57e +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52303 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 389 ++++++++++++++++------------ + xlators/features/marker/src/marker-quota.h | 6 +- + 2 files changed, 224 insertions(+), 171 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index 0b015ef..97946f8 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -128,6 +128,49 @@ out: + return ret; + } + ++int32_t ++mq_set_ctx_create_status (quota_inode_ctx_t *ctx, ++ gf_boolean_t status) ++{ ++ int32_t ret = -1; ++ ++ if (ctx == NULL) ++ goto out; ++ ++ LOCK (&ctx->lock); ++ { ++ ctx->create_status = status; ++ } ++ UNLOCK (&ctx->lock); ++ ++ ret = 0; ++out: ++ return ret; ++} ++ ++int32_t ++mq_test_and_set_ctx_create_status (quota_inode_ctx_t *ctx, ++ gf_boolean_t *status) ++{ ++ int32_t ret = -1; ++ gf_boolean_t temp = _gf_false; ++ ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); ++ GF_VALIDATE_OR_GOTO ("marker", status, out); ++ ++ LOCK (&ctx->lock); ++ { ++ temp = *status; ++ *status = ctx->create_status; ++ ctx->create_status = temp; ++ } ++ UNLOCK (&ctx->lock); ++ ++ ret = 0; ++out: ++ return ret; ++} ++ + void + mq_assign_lk_owner (xlator_t *this, call_frame_t *frame) + { +@@ -2184,30 +2227,19 @@ out: + } + + int32_t +-mq_create_xattrs (xlator_t *this, loc_t *loc, gf_boolean_t objects) ++mq_create_xattrs (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, ++ gf_boolean_t objects) + { + quota_meta_t size = {0, }; + quota_meta_t contri = {0, }; + int32_t ret = -1; + char key[CONTRI_KEY_MAX] = {0, }; + dict_t *dict = NULL; +- quota_inode_ctx_t *ctx = NULL; + inode_contribution_t *contribution = NULL; + + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- ctx = mq_inode_ctx_new (loc->inode, this); +- if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "mq_inode_ctx_new failed"); +- ret = -1; +- goto out; +- } +- } +- + dict = dict_new (); + if (!dict) { + gf_log (this->name, GF_LOG_ERROR, "dict_new failed"); +@@ -2765,8 +2797,6 @@ mq_synctask_cleanup (int ret, call_frame_t *frame, void *opaque) + + args = (quota_synctask_t *) opaque; + loc_wipe (&args->loc); +- if (args->dict) +- dict_unref (args->dict); + + if (!args->is_static) + GF_FREE (args); +@@ -2776,7 +2806,7 @@ mq_synctask_cleanup (int ret, call_frame_t *frame, void *opaque) + + int + mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc, +- dict_t *dict, struct iatt *buf, int64_t contri) ++ int64_t contri) + { + int32_t ret = -1; + quota_synctask_t *args = NULL; +@@ -2793,11 +2823,6 @@ mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc, + args->this = this; + loc_copy (&args->loc, loc); + args->contri = contri; +- if (dict) +- args->dict = dict_ref (dict); +- if (buf) +- args->buf = *buf; +- + + if (spawn) { + ret = synctask_new (this->ctx->env, task, mq_synctask_cleanup, +@@ -2825,7 +2850,7 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + loc_t parent_loc = {0,}; + gf_boolean_t locked = _gf_false; + gf_boolean_t dirty = _gf_false; +- gf_boolean_t status = _gf_true; ++ gf_boolean_t status = _gf_false; + quota_meta_t delta = {0, }; + + GF_VALIDATE_OR_GOTO ("marker", contri, out); +@@ -2855,9 +2880,16 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + /* To improve performance, abort current transaction + * if one is already in progress for same inode + */ +- ret = mq_test_and_set_ctx_updation_status (ctx, &status); +- if (ret < 0 || status == _gf_true) +- goto out; ++ if (status == _gf_true) { ++ /* status will alreday set before txn start, ++ * so it should not be set in first ++ * loop iteration ++ */ ++ ret = mq_test_and_set_ctx_updation_status (ctx, ++ &status); ++ if (ret < 0 || status == _gf_true) ++ goto out; ++ } + + ret = mq_inode_loc_fill (NULL, child_loc.parent, &parent_loc); + if (ret < 0) { +@@ -2941,7 +2973,7 @@ out: + if (locked) + ret = mq_lock (this, &parent_loc, F_UNLCK); + +- if (status == _gf_false) ++ if (ctx && status == _gf_false) + mq_set_ctx_updation_status (ctx, _gf_false); + + loc_wipe (&child_loc); +@@ -2949,7 +2981,7 @@ out: + if (contri) + GF_REF_PUT (contri); + +- return ret; ++ return 0; + } + + int +@@ -2961,8 +2993,10 @@ mq_create_xattrs_task (void *opaque) + gf_boolean_t objects = _gf_false; + gf_boolean_t need_txn = _gf_false; + quota_synctask_t *args = NULL; ++ quota_inode_ctx_t *ctx = NULL; + xlator_t *this = NULL; + loc_t *loc = NULL; ++ gf_boolean_t status = _gf_false; + + GF_ASSERT (opaque); + +@@ -2981,16 +3015,29 @@ mq_create_xattrs_task (void *opaque) + goto out; + } + +- ret = mq_lock (this, loc, F_WRLCK); +- if (ret < 0) ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_WARNING, "Failed to" ++ "get inode ctx, aborting quota create txn"); + goto out; +- locked = _gf_true; ++ } ++ ++ if (loc->inode->ia_type == IA_IFDIR) { ++ /* lock not required for files */ ++ ret = mq_lock (this, loc, F_WRLCK); ++ if (ret < 0) ++ goto out; ++ locked = _gf_true; ++ } + + ret = mq_are_xattrs_set (this, loc, &xattrs_set, &objects); + if (ret < 0 || xattrs_set) + goto out; + +- ret = mq_create_xattrs (this, loc, objects); ++ mq_set_ctx_create_status (ctx, _gf_false); ++ status = _gf_true; ++ ++ ret = mq_create_xattrs (this, ctx, loc, objects); + if (ret < 0) + goto out; + +@@ -2999,12 +3046,44 @@ out: + if (locked) + ret = mq_lock (this, loc, F_UNLCK); + ++ if (status == _gf_false) ++ mq_set_ctx_create_status (ctx, _gf_false); ++ + if (need_txn) + ret = mq_initiate_quota_blocking_txn (this, loc); + + return ret; + } + ++static int ++_mq_create_xattrs_txn (xlator_t *this, loc_t *loc, gf_boolean_t spawn) ++{ ++ int32_t ret = -1; ++ quota_inode_ctx_t *ctx = NULL; ++ gf_boolean_t status = _gf_true; ++ ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) { ++ ctx = mq_inode_ctx_new (loc->inode, this); ++ if (ctx == NULL) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "mq_inode_ctx_new failed"); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ ret = mq_test_and_set_ctx_create_status (ctx, &status); ++ if (ret < 0 || status == _gf_true) ++ goto out; ++ ++ ret = mq_synctask (this, mq_create_xattrs_task, spawn, loc, 0); ++out: ++ if (ret < 0 && status == _gf_false) ++ mq_set_ctx_create_status (ctx, _gf_false); ++ ++ return ret; ++} + int + mq_create_xattrs_txn (xlator_t *this, loc_t *loc) + { +@@ -3013,8 +3092,7 @@ mq_create_xattrs_txn (xlator_t *this, loc_t *loc) + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_synctask (this, mq_create_xattrs_task, _gf_true, loc, NULL, +- NULL, 0); ++ ret = _mq_create_xattrs_txn (this, loc, _gf_true); + out: + return ret; + } +@@ -3027,8 +3105,7 @@ mq_create_xattrs_blocking_txn (xlator_t *this, loc_t *loc) + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_synctask (this, mq_create_xattrs_task, _gf_false, loc, NULL, +- NULL, 0); ++ ret = _mq_create_xattrs_txn (this, loc, _gf_false); + out: + return ret; + } +@@ -3169,7 +3246,7 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *loc, int64_t contri) + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + + ret = mq_synctask (this, mq_reduce_parent_size_task, _gf_true, loc, +- NULL, NULL, contri); ++ contri); + out: + return ret; + } +@@ -3195,7 +3272,6 @@ mq_initiate_quota_task (void *opaque) + if (ret == -1) { + gf_log (this->name, GF_LOG_WARNING, + "inode ctx get failed, aborting quota txn"); +- ret = -1; + goto out; + } + +@@ -3230,6 +3306,7 @@ mq_initiate_quota_task (void *opaque) + loc->parent ? + uuid_utoa (loc->parent->gfid) : + NULL); ++ ret = -1; + goto out; + } + } +@@ -3241,6 +3318,36 @@ out: + if (contribution) + GF_REF_PUT (contribution); + ++ if (ctx && ret < 0) ++ mq_set_ctx_updation_status (ctx, _gf_false); ++ ++ return ret; ++} ++ ++int ++_mq_initiate_quota_txn (xlator_t *this, loc_t *loc, gf_boolean_t spawn) ++{ ++ int32_t ret = -1; ++ quota_inode_ctx_t *ctx = NULL; ++ gf_boolean_t status = _gf_true; ++ ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret == -1) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "inode ctx get failed, aborting quota txn"); ++ goto out; ++ } ++ ++ ret = mq_test_and_set_ctx_updation_status (ctx, &status); ++ if (ret < 0 || status == _gf_true) ++ goto out; ++ ++ ret = mq_synctask (this, mq_initiate_quota_task, spawn, loc, 0); ++ ++out: ++ if (ret < 0 && status == _gf_false) ++ mq_set_ctx_updation_status (ctx, _gf_false); ++ + return ret; + } + +@@ -3253,8 +3360,7 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc) + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_synctask (this, mq_initiate_quota_task, _gf_true, loc, NULL, +- NULL, 0); ++ ret = _mq_initiate_quota_txn (this, loc, _gf_true); + out: + return ret; + } +@@ -3268,43 +3374,38 @@ mq_initiate_quota_blocking_txn (xlator_t *this, loc_t *loc) + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_synctask (this, mq_initiate_quota_task, _gf_false, loc, NULL, +- NULL, 0); ++ ret = _mq_initiate_quota_txn (this, loc, _gf_false); + out: + return ret; + } + +-/* return 1 when dirty updation is performed +- * return 0 other wise +- */ +-int32_t +-mq_update_dirty_inode_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, +- inode_contribution_t *contribution) ++int ++mq_update_dirty_inode_task (void *opaque) + { +- int32_t ret = -1; +- fd_t *fd = NULL; +- off_t offset = 0; +- loc_t child_loc = {0, }; +- gf_dirent_t entries; +- gf_dirent_t *entry = NULL; +- gf_boolean_t status = _gf_true; +- gf_boolean_t locked = _gf_false; +- gf_boolean_t free_entries = _gf_false; +- gf_boolean_t updated = _gf_false; +- int32_t dirty = 0; +- quota_meta_t contri = {0, }; +- quota_meta_t size = {0, }; +- quota_meta_t contri_sum = {0, }; +- quota_meta_t delta = {0, }; ++ int32_t ret = -1; ++ fd_t *fd = NULL; ++ off_t offset = 0; ++ loc_t child_loc = {0, }; ++ gf_dirent_t entries; ++ gf_dirent_t *entry = NULL; ++ gf_boolean_t locked = _gf_false; ++ gf_boolean_t free_entries = _gf_false; ++ gf_boolean_t updated = _gf_false; ++ int32_t dirty = 0; ++ quota_meta_t contri = {0, }; ++ quota_meta_t size = {0, }; ++ quota_meta_t contri_sum = {0, }; ++ quota_meta_t delta = {0, }; ++ quota_synctask_t *args = NULL; ++ xlator_t *this = NULL; ++ loc_t *loc = NULL; + +- GF_VALIDATE_OR_GOTO ("marker", loc, out); +- GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); ++ GF_ASSERT (opaque); + +- ret = mq_get_ctx_updation_status (ctx, &status); +- if (ret == -1 || status == _gf_true) { +- ret = 0; +- goto out; +- } ++ args = (quota_synctask_t *) opaque; ++ loc = &args->loc; ++ this = args->this; ++ THIS = this; + + if (gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (loc->gfid, loc->inode->gfid); +@@ -3431,19 +3532,31 @@ out: + if (locked) + mq_lock (this, loc, F_UNLCK); + +- if (status == _gf_false) +- mq_set_ctx_updation_status (ctx, _gf_false); +- + loc_wipe(&child_loc); + + if (updated) +- return 1; +- else +- return 0; ++ mq_initiate_quota_blocking_txn (this, loc); ++ ++ return ret; + } + + int32_t +-mq_inspect_directory_xattr_task (void *opaque) ++mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc) ++{ ++ int32_t ret = -1; ++ ++ GF_VALIDATE_OR_GOTO ("marker", loc, out); ++ GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); ++ ++ ret = mq_synctask (this, mq_update_dirty_inode_task, _gf_true, ++ loc, 0); ++out: ++ return ret; ++} ++ ++int32_t ++mq_inspect_directory_xattr (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, ++ dict_t *dict, struct iatt buf) + { + int32_t ret = 0; + int8_t dirty = -1; +@@ -3451,31 +3564,7 @@ mq_inspect_directory_xattr_task (void *opaque) + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; +- quota_inode_ctx_t *ctx = NULL; + inode_contribution_t *contribution = NULL; +- quota_synctask_t *args = NULL; +- xlator_t *this = NULL; +- loc_t *loc = NULL; +- dict_t *dict = NULL; +- +- GF_ASSERT (opaque); +- +- args = (quota_synctask_t *) opaque; +- loc = &args->loc; +- dict = args->dict; +- this = args->this; +- THIS = this; +- +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- ctx = mq_inode_ctx_new (loc->inode, this); +- if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "mq_inode_ctx_new failed"); +- ret = -1; +- goto err; +- } +- } + + if (!loc_is_root(loc)) { + contribution = mq_add_new_contribution_node (this, ctx, loc); +@@ -3485,7 +3574,7 @@ mq_inspect_directory_xattr_task (void *opaque) + "cannot add a new contribution node " + "(%s)", uuid_utoa (loc->inode->gfid)); + ret = -1; +- goto err; ++ goto out; + } + } + +@@ -3506,7 +3595,7 @@ mq_inspect_directory_xattr_task (void *opaque) + if (!loc_is_root(loc)) { + GET_CONTRI_KEY (contri_key, contribution->gfid, ret); + if (ret < 0) +- goto err; ++ goto out; + + ret = _quota_dict_get_meta (this, dict, contri_key, &contri, + IA_IFDIR, _gf_false); +@@ -3527,27 +3616,29 @@ mq_inspect_directory_xattr_task (void *opaque) + ctx->size = size.size; + ctx->file_count = size.file_count; + ctx->dir_count = size.dir_count; +- ctx->dirty = dirty; + } + UNLOCK (&ctx->lock); + + mq_compute_delta (&delta, &size, &contri); + +- if (dirty) +- ret = mq_update_dirty_inode_v2 (this, loc, ctx, contribution); ++ if (dirty) { ++ if (ctx->dirty == 0) ++ ret = mq_update_dirty_inode_txn (this, loc); + +- if ((!dirty || ret == 1) && +- !loc_is_root(loc) && ++ goto out; ++ } ++ ++ if (!loc_is_root(loc) && + !quota_meta_is_null (&delta)) +- mq_initiate_quota_blocking_txn (this, loc); ++ mq_initiate_quota_txn (this, loc); + + ret = 0; + + create_xattr: + if (ret < 0) +- ret = mq_create_xattrs_blocking_txn (this, loc); ++ ret = mq_create_xattrs_txn (this, loc); + +-err: ++out: + if (contribution) + GF_REF_PUT (contribution); + +@@ -3555,52 +3646,15 @@ err: + } + + int32_t +-mq_inspect_directory_xattr_txn (xlator_t *this, loc_t *loc, dict_t *dict, +- struct iatt buf) +-{ +- int32_t ret = -1; +- +- ret = mq_synctask (this, mq_inspect_directory_xattr_task, _gf_true, +- loc, dict, &buf, 0); +- +- return ret; +-} +- +-int32_t +-mq_inspect_file_xattr_task (void *opaque) ++mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, ++ dict_t *dict, struct iatt buf) + { + int32_t ret = -1; + quota_meta_t size = {0, }; + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; +- quota_inode_ctx_t *ctx = NULL; + inode_contribution_t *contribution = NULL; +- quota_synctask_t *args = NULL; +- xlator_t *this = NULL; +- loc_t *loc = NULL; +- dict_t *dict = NULL; +- struct iatt buf = {0,}; +- +- GF_ASSERT (opaque); +- +- args = (quota_synctask_t *) opaque; +- loc = &args->loc; +- dict = args->dict; +- buf = args->buf; +- this = args->this; +- THIS = this; +- +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- ctx = mq_inode_ctx_new (loc->inode, this); +- if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "mq_inode_ctx_new failed"); +- ret = -1; +- goto out; +- } +- } + + contribution = mq_add_new_contribution_node (this, ctx, loc); + if (contribution == NULL) { +@@ -3629,7 +3683,7 @@ mq_inspect_file_xattr_task (void *opaque) + ret = _quota_dict_get_meta (this, dict, contri_key, &contri, + IA_IFREG, _gf_true); + if (ret < 0) { +- ret = mq_create_xattrs_blocking_txn (this, loc); ++ ret = mq_create_xattrs_txn (this, loc); + } else { + LOCK (&contribution->lock); + { +@@ -3641,7 +3695,7 @@ mq_inspect_file_xattr_task (void *opaque) + + mq_compute_delta (&delta, &size, &contri); + if (!quota_meta_is_null (&delta)) +- mq_initiate_quota_blocking_txn (this, loc); ++ mq_initiate_quota_txn (this, loc); + } + /* TODO: revist this code when fixing hardlinks */ + +@@ -3653,27 +3707,30 @@ out: + } + + int32_t +-mq_inspect_file_xattr_txn (xlator_t *this, loc_t *loc, dict_t *dict, +- struct iatt buf) ++mq_xattr_state (xlator_t *this, loc_t *loc, dict_t *dict, struct iatt buf) + { +- int32_t ret = -1; ++ int32_t ret = -1; ++ quota_inode_ctx_t *ctx = NULL; + +- ret = mq_synctask (this, mq_inspect_file_xattr_task, _gf_true, +- loc, dict, &buf, 0); +- +- return ret; +-} ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) { ++ ctx = mq_inode_ctx_new (loc->inode, this); ++ if (ctx == NULL) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "mq_inode_ctx_new failed"); ++ ret = -1; ++ goto out; ++ } ++ } + +-int32_t +-mq_xattr_state (xlator_t *this, loc_t *loc, dict_t *dict, struct iatt buf) +-{ + if (((buf.ia_type == IA_IFREG) && !dht_is_linkfile (&buf, dict)) + || (buf.ia_type == IA_IFLNK)) { +- mq_inspect_file_xattr_txn (this, loc, dict, buf); ++ mq_inspect_file_xattr (this, ctx, loc, dict, buf); + } else if (buf.ia_type == IA_IFDIR) +- mq_inspect_directory_xattr_txn (this, loc, dict, buf); ++ mq_inspect_directory_xattr (this, loc, ctx, dict, buf); + +- return 0; ++out: ++ return ret; + } + + int32_t +diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h +index 2d03dfd..89ac559 100644 +--- a/xlators/features/marker/src/marker-quota.h ++++ b/xlators/features/marker/src/marker-quota.h +@@ -88,6 +88,7 @@ struct quota_inode_ctx { + int64_t file_count; + int64_t dir_count; + int8_t dirty; ++ gf_boolean_t create_status; + gf_boolean_t updation_status; + gf_lock_t lock; + struct list_head contribution_head; +@@ -97,8 +98,6 @@ typedef struct quota_inode_ctx quota_inode_ctx_t; + struct quota_synctask { + xlator_t *this; + loc_t loc; +- dict_t *dict; +- struct iatt buf; + int64_t contri; + gf_boolean_t is_static; + }; +@@ -153,8 +152,5 @@ int32_t + mq_rename_update_newpath (xlator_t *, loc_t *); + + int32_t +-mq_inspect_file_xattr (xlator_t *this, loc_t *loc, dict_t *dict, struct iatt buf); +- +-int32_t + mq_forget (xlator_t *, quota_inode_ctx_t *); + #endif +-- +1.7.1 + diff --git a/SOURCES/0211-glusterd-Removing-sync-lock-and-unlock-inside-rcu-re.patch b/SOURCES/0211-glusterd-Removing-sync-lock-and-unlock-inside-rcu-re.patch new file mode 100644 index 0000000..244e80f --- /dev/null +++ b/SOURCES/0211-glusterd-Removing-sync-lock-and-unlock-inside-rcu-re.patch @@ -0,0 +1,103 @@ +From 1619231c0313666282b4145db9e1c1ceb40d708f Mon Sep 17 00:00:00 2001 +From: anand +Date: Wed, 17 Jun 2015 16:11:48 +0530 +Subject: [PATCH 211/212] glusterd: Removing sync lock and unlock inside rcu read critical section + +Issue : Glsuterd was crashing during peer probe. + +RCA : In glusterd, we are using big lock which is implemented based on sync +task frame work for thread synchronization, sync task frame work swap the threads +if there is no worker pool threads available. Due to this rcu lock and rcu unlock +was happening in different threads (urcu-bp will not allow this), resulting into +glusterd crash. + +fix : Removing sync lock and unlock inside rcu read critical section, which was left out by +http://review.gluster.org/#/c/10285/ patch. +Backport of: +>Change-Id: Id358dfcc797335bcd3b491c3129017b2caa826eb +>BUG: 1232693 +>Signed-off-by: anand +>Reviewed-on: http://review.gluster.org/11276 +>Reviewed-by: Atin Mukherjee +>Reviewed-by: Krishnan Parthasarathi +>Tested-by: NetBSD Build System + +Change-Id: I8489d915b2f21442e49230e82096a12900d889ef +BUG: 1231635 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/52439 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 28 +++---------------------- + 2 files changed, 5 insertions(+), 26 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index e380e43..0a144b9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -1637,13 +1637,12 @@ glusterd_rpc_friend_remove (call_frame_t *frame, xlator_t *this, + req.hostname = gf_strdup (peerinfo->hostname); + req.port = peerinfo->port; + +- rcu_read_unlock (); +- + ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->peer, + GLUSTERD_FRIEND_REMOVE, NULL, + this, glusterd_friend_remove_cbk, + (xdrproc_t)xdr_gd1_mgmt_friend_req); + ++ rcu_read_unlock (); + out: + GF_FREE (req.hostname); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 3bb72b1..7347fb2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -241,11 +241,10 @@ glusterd_get_uuid (uuid_t *uuid) + } + + int +-glusterd_submit_request_unlocked (struct rpc_clnt *rpc, void *req, +- call_frame_t *frame, rpc_clnt_prog_t *prog, +- int procnum, struct iobref *iobref, +- xlator_t *this, fop_cbk_fn_t cbkfn, +- xdrproc_t xdrproc) ++glusterd_submit_request (struct rpc_clnt *rpc, void *req, ++ call_frame_t *frame, rpc_clnt_prog_t *prog, ++ int procnum, struct iobref *iobref, ++ xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) + { + char new_iobref = 0; + int ret = -1; +@@ -309,25 +308,6 @@ out: + } + + +-int +-glusterd_submit_request (struct rpc_clnt *rpc, void *req, +- call_frame_t *frame, rpc_clnt_prog_t *prog, +- int procnum, struct iobref *iobref, +- xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) +-{ +- glusterd_conf_t *priv = THIS->private; +- int ret = -1; +- +- synclock_unlock (&priv->big_lock); +- { +- ret = glusterd_submit_request_unlocked (rpc, req, frame, prog, +- procnum, iobref, this, +- cbkfn, xdrproc); +- } +- synclock_lock (&priv->big_lock); +- +- return ret; +-} + + + struct iobuf * +-- +1.7.1 + diff --git a/SOURCES/0212-cluster-ec-Fix-use-after-free-bug.patch b/SOURCES/0212-cluster-ec-Fix-use-after-free-bug.patch new file mode 100644 index 0000000..d2c0f1f --- /dev/null +++ b/SOURCES/0212-cluster-ec-Fix-use-after-free-bug.patch @@ -0,0 +1,69 @@ +From cd0cfcf3a825c6ea4c943d609fb5a3e391f81b01 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Tue, 7 Jul 2015 12:40:42 +0530 +Subject: [PATCH 212/212] cluster/ec: Fix use after free bug + + Backport of http://review.gluster.org/11558 + +In ec_lock() there is a chance that ec_resume is called on fop even before +ec_sleep. This can result in refs == 0 for fop leading to use after free in +this function when it calls ec_sleep so do ec_sleep at start and ec_resume at +end of this function. + +Change-Id: I879b2667bf71eaa56be1b53b5bdc91b7bb56c650 +BUG: 1240245 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52473 +--- + xlators/cluster/ec/src/ec-common.c | 8 ++++++++ + xlators/cluster/ec/src/ec-data.c | 1 + + 2 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 200aeda..439773e 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -244,6 +244,7 @@ void ec_sleep(ec_fop_data_t *fop) + { + LOCK(&fop->lock); + ++ GF_ASSERT (fop->refs > 0); + fop->refs++; + fop->jobs++; + +@@ -1319,6 +1320,12 @@ void ec_lock(ec_fop_data_t *fop) + ec_lock_link_t *timer_link = NULL; + ec_lock_t *lock; + ++ /* There is a chance that ec_resume is called on fop even before ec_sleep. ++ * Which can result in refs == 0 for fop leading to use after free in this ++ * function when it calls ec_sleep so do ec_sleep at start and ec_resume at ++ * the end of this function.*/ ++ ec_sleep (fop); ++ + while (fop->locked < fop->lock_count) { + /* Since there are only up to 2 locks per fop, this xor will change + * the order of the locks if fop->first_lock is 1. */ +@@ -1383,6 +1390,7 @@ void ec_lock(ec_fop_data_t *fop) + timer_link = NULL; + } + } ++ ec_resume (fop, 0); + + if (timer_link != NULL) { + ec_resume(timer_link->fop, 0); +diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c +index 2a34f78..78c505c 100644 +--- a/xlators/cluster/ec/src/ec-data.c ++++ b/xlators/cluster/ec/src/ec-data.c +@@ -258,6 +258,7 @@ void ec_fop_data_release(ec_fop_data_t * fop) + + ec_trace("RELEASE", fop, ""); + ++ GF_ASSERT (fop->refs > 0); + refs = --fop->refs; + + UNLOCK(&fop->lock); +-- +1.7.1 + diff --git a/SOURCES/0213-glusterd-geo-rep-Fix-failure-of-geo-rep-pause.patch b/SOURCES/0213-glusterd-geo-rep-Fix-failure-of-geo-rep-pause.patch new file mode 100644 index 0000000..6a7482e --- /dev/null +++ b/SOURCES/0213-glusterd-geo-rep-Fix-failure-of-geo-rep-pause.patch @@ -0,0 +1,63 @@ +From 41c0ac66b7e9e8a608b1bbaa00180d5c86b69ea0 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Mon, 6 Jul 2015 15:05:43 +0530 +Subject: [PATCH 213/234] glusterd/geo-rep: Fix failure of geo-rep pause + +Geo-replication pause fails if one or more of the nodes +in the master cluster is not part of master volume. +If the master volume bricks are not part of the node, +it should be ignored. The check is added to fix the issue. + +BUG: 1240196 +Change-Id: Iae08c8141778bfcf0a83723a623b29648e5a17a9 +Reviewed-on: http://review.gluster.org/11549 +Tested-by: NetBSD Build System +Reviewed-by: Avra Sengupta +Reviewed-by: Krishnan Parthasarathi +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/52479 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Venky Shankar +Tested-by: Venky Shankar +--- + xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 21 +++++++++++++++++---- + 1 files changed, 17 insertions(+), 4 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +index f7f0086..2f2ad86 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c ++++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +@@ -3018,13 +3018,26 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) + + ret = glusterd_op_verify_gsync_running (volinfo, slave, + conf_path, op_errstr); +- if (ret) +- goto out; ++ if (ret) { ++ ret = glusterd_get_local_brickpaths (volinfo, ++ &path_list); ++ if (path_list) { ++ ret = -1; ++ goto out; ++ } ++ } ++ + if (!is_force) { + ret = gd_pause_resume_validation (type, volinfo, slave, + statefile, op_errstr); +- if (ret) +- goto out; ++ if (ret) { ++ ret = glusterd_get_local_brickpaths (volinfo, ++ &path_list); ++ if (path_list) { ++ ret = -1; ++ goto out; ++ } ++ } + } + break; + +-- +1.7.1 + diff --git a/SOURCES/0214-glusterd-Get-the-local-txn_info-based-on-trans_id-in.patch b/SOURCES/0214-glusterd-Get-the-local-txn_info-based-on-trans_id-in.patch new file mode 100644 index 0000000..b20bf28 --- /dev/null +++ b/SOURCES/0214-glusterd-Get-the-local-txn_info-based-on-trans_id-in.patch @@ -0,0 +1,314 @@ +From 9d29714514da25b3c94fd7c0acb804920500680c Mon Sep 17 00:00:00 2001 +From: anand +Date: Mon, 8 Jun 2015 00:19:00 +0530 +Subject: [PATCH 214/234] glusterd: Get the local txn_info based on trans_id in op_sm call backs. + +Issue: when two or more transactions are running concurrently in op_sm, +global op_info might get corrupted. + +Fix: Get local txn_info based on trans_id instead of using global txn_info for +commands (replace_brick, re-balance, profile ) which are using op_sm in originator. + +TODO: Handle errors properly in call backs and completely remove the global op_info from +op_sm. + +Backportof: +>Change-Id: I9d61388acc125841ddc77e2bd560cb7f17ae0a5a +>BUG: 1229139 +>Signed-off-by: anand + +Change-Id: I34dd174b5c71779664d71a0f15995a205271c42f +BUG: 1230525 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/52564 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 15 ++++++- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 55 ++++++++++++-------------- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 17 -------- + xlators/mgmt/glusterd/src/glusterd-utils.c | 32 +++++++-------- + xlators/mgmt/glusterd/src/glusterd-utils.h | 4 -- + 5 files changed, 53 insertions(+), 70 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 4619f57..b1ee5e3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -3996,6 +3996,7 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + char *op_errstr = NULL; + glusterd_op_t op = GD_OP_NONE; + uint32_t pending_count = 0; ++ glusterd_op_info_t txn_op_info = {{0},}; + + this = THIS; + GF_ASSERT (this); +@@ -4047,8 +4048,18 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + goto out; + } + +- if (op == GD_OP_REPLACE_BRICK) +- glusterd_rb_use_rsp_dict (NULL, rsp_dict); ++ if (op == GD_OP_REPLACE_BRICK) { ++ ret = glusterd_get_txn_opinfo (&event->txn_id, &txn_op_info); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Failed to get txn_op_info " ++ "for txn_id = %s", uuid_utoa (event->txn_id)); ++ goto out; ++ } ++ ++ glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, rsp_dict); ++ } + + rcu_read_lock (); + cds_list_for_each_entry_rcu (peerinfo, &priv->peers, uuid_list) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 0a144b9..50820d7 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -1131,6 +1131,7 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + uuid_t *txn_id = NULL; ++ glusterd_op_info_t txn_op_info = {{0},}; + + this = THIS; + GF_ASSERT (this); +@@ -1200,6 +1201,14 @@ out: + gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + ++ ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Failed to get txn_op_info " ++ "for txn_id = %s", uuid_utoa (*txn_id)); ++ } ++ + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +@@ -1233,7 +1242,7 @@ out: + + switch (rsp.op) { + case GD_OP_REPLACE_BRICK: +- glusterd_rb_use_rsp_dict (NULL, dict); ++ glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict); + break; + } + +@@ -1268,7 +1277,7 @@ int32_t + __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + int count, void *myframe) + { +- gd1_mgmt_commit_op_rsp rsp = {{0},}; ++ gd1_mgmt_commit_op_rsp rsp = {{0},}; + int ret = -1; + int32_t op_ret = -1; + glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; +@@ -1279,6 +1288,7 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + uuid_t *txn_id = NULL; ++ glusterd_op_info_t txn_op_info = {{0},}; + + this = THIS; + GF_ASSERT (this); +@@ -1348,6 +1358,14 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + ++ ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Failed to get txn_op_info " ++ "for txn_id = %s", uuid_utoa (*txn_id)); ++ } ++ + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +@@ -1377,49 +1395,26 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + } + } else { + event_type = GD_OP_EVENT_RCVD_ACC; ++ GF_ASSERT (rsp.op == txn_op_info.op); ++ + switch (rsp.op) { + case GD_OP_REPLACE_BRICK: +- ret = glusterd_rb_use_rsp_dict (NULL, dict); +- if (ret) +- goto unlock; +- break; +- +- case GD_OP_SYNC_VOLUME: +- ret = glusterd_sync_use_rsp_dict (NULL, dict); ++ ret = glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict); + if (ret) + goto unlock; + break; + + case GD_OP_PROFILE_VOLUME: +- ret = glusterd_profile_volume_use_rsp_dict (NULL, dict); +- if (ret) +- goto unlock; +- break; +- +- case GD_OP_GSYNC_SET: +- ret = glusterd_gsync_use_rsp_dict (NULL, dict, rsp.op_errstr); +- if (ret) +- goto unlock; +- break; +- +- case GD_OP_STATUS_VOLUME: +- ret = glusterd_volume_status_copy_to_op_ctx_dict (NULL, dict); ++ ret = glusterd_profile_volume_use_rsp_dict (txn_op_info.op_ctx, dict); + if (ret) + goto unlock; + break; + + case GD_OP_REBALANCE: + case GD_OP_DEFRAG_BRICK_VOLUME: +- ret = glusterd_volume_rebalance_use_rsp_dict (NULL, dict); +- if (ret) +- goto unlock; +- break; +- +- case GD_OP_HEAL_VOLUME: +- ret = glusterd_volume_heal_use_rsp_dict (NULL, dict); ++ ret = glusterd_volume_rebalance_use_rsp_dict (txn_op_info.op_ctx, dict); + if (ret) + goto unlock; +- + break; + + default: +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index a54073e..1d5deb8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -245,11 +245,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) + } + break; + +- case GD_OP_REPLACE_BRICK: +- ret = glusterd_rb_use_rsp_dict (aggr, rsp); +- if (ret) +- goto out; +- break; + + case GD_OP_SYNC_VOLUME: + ret = glusterd_sync_use_rsp_dict (aggr, rsp); +@@ -257,12 +252,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) + goto out; + break; + +- case GD_OP_PROFILE_VOLUME: +- ret = glusterd_profile_volume_use_rsp_dict (aggr, rsp); +- if (ret) +- goto out; +- break; +- + case GD_OP_GSYNC_CREATE: + break; + +@@ -278,12 +267,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) + goto out; + break; + +- case GD_OP_REBALANCE: +- case GD_OP_DEFRAG_BRICK_VOLUME: +- ret = glusterd_volume_rebalance_use_rsp_dict (aggr, rsp); +- if (ret) +- goto out; +- break; + + case GD_OP_HEAL_VOLUME: + ret = glusterd_volume_heal_use_rsp_dict (aggr, rsp); +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 7347fb2..770cbf7 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -7404,13 +7404,11 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ctx = aggr; + + } else { +- ctx = glusterd_op_get_ctx (); +- if (!ctx) { +- gf_msg ("glusterd", GF_LOG_ERROR, 0, +- GD_MSG_OPCTX_GET_FAIL, +- "Operation Context is not present"); +- GF_ASSERT (0); +- } ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, ++ "Operation Context is not present"); ++ ret = -1; ++ goto out; + } + + if (rsp_dict) { +@@ -7518,14 +7516,15 @@ glusterd_profile_volume_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + ret = 0; //no bricks in the rsp + goto out; + } +- +- op = glusterd_op_get_op (); +- GF_ASSERT (GD_OP_PROFILE_VOLUME == op); + if (aggr) { + ctx_dict = aggr; + + } else { +- ctx_dict = glusterd_op_get_ctx (); ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, ++ "Operation Context is not present"); ++ ret = -1; ++ goto out; + } + + ret = dict_get_int32 (ctx_dict, "count", &count); +@@ -7962,16 +7961,15 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + GF_ASSERT (rsp_dict); + conf = THIS->private; + +- op = glusterd_op_get_op (); +- GF_ASSERT ((GD_OP_REBALANCE == op) || +- (GD_OP_DEFRAG_BRICK_VOLUME == op)); +- + if (aggr) { + ctx_dict = aggr; + + } else { +- ctx_dict = glusterd_op_get_ctx (op); +- ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_OPCTX_GET_FAIL, ++ "Operation Context is not present"); ++ ret = -1; ++ goto out; + } + + if (!ctx_dict) +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h +index 27c51fa..44fcdd3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.h +@@ -425,10 +425,6 @@ int32_t + glusterd_handle_node_rsp (dict_t *req_ctx, void *pending_entry, + glusterd_op_t op, dict_t *rsp_dict, dict_t *op_ctx, + char **op_errstr, gd_node_type type); +-int +-glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict); +-int +-glusterd_volume_heal_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict); + + int32_t + glusterd_check_if_quota_trans_enabled (glusterd_volinfo_t *volinfo); +-- +1.7.1 + diff --git a/SOURCES/0215-snapshot-scheduler-Use-var-run-gluster-shared_storag.patch b/SOURCES/0215-snapshot-scheduler-Use-var-run-gluster-shared_storag.patch new file mode 100644 index 0000000..6153bdd --- /dev/null +++ b/SOURCES/0215-snapshot-scheduler-Use-var-run-gluster-shared_storag.patch @@ -0,0 +1,72 @@ +From b6e94e46e4a44fe0bc73f60f2993c8151b91b33a Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Sun, 5 Jul 2015 12:57:39 +0530 +Subject: [PATCH 215/234] snapshot/scheduler: Use /var/run/gluster/shared_storage/snaps/tmp_file for writing data into tmp file and then making an atomic rename to the required filename + +The reason for using this location is that it adheres to +the selinux policies. + +Also moving the update of the current_scheduler file, +under the lock so as to avoid multiple writes + +>Reviewed-on: http://review.gluster.org/11536 +Change-Id: I61e62b5daf6f1bce2319f64f7b1dfb8b93726077 +BUG: 1231647 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/52559 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/snap_scheduler.py | 12 ++++++------ + 1 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index 09015c5..ce808cf 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -423,7 +423,7 @@ def edit_schedules(jobname, schedule, volname): + + def initialise_scheduler(): + try: +- with open("/tmp/crontab", "w+", 0644) as f: ++ with open(TMP_FILE, "w+", 0644) as f: + updater = ("* * * * * root PATH=$PATH:/usr/local/sbin:" + "/usr/sbin gcron.py --update\n") + f.write("%s\n" % updater) +@@ -431,11 +431,11 @@ def initialise_scheduler(): + os.fsync(f.fileno()) + f.close() + except IOError as (errno, strerror): +- log.error("Failed to open /tmp/crontab. Error: %s.", strerror) ++ log.error("Failed to open %s. Error: %s.", TMP_FILE, strerror) + ret = INIT_FAILED + return ret + +- shutil.move("/tmp/crontab", GCRON_UPDATE_TASK) ++ shutil.move(TMP_FILE, GCRON_UPDATE_TASK) + + if not os.path.lexists(GCRON_TASKS): + try: +@@ -491,6 +491,9 @@ def syntax_checker(args): + + + def perform_operation(args): ++ if not os.path.exists(CURRENT_SCHEDULER): ++ update_current_scheduler("none") ++ + # Initialise snapshot scheduler on local node + if args.action == "init": + ret = initialise_scheduler() +@@ -651,9 +654,6 @@ def main(argv): + % (LOCK_FILE_DIR, strerror)) + return INTERNAL_ERROR + +- if not os.path.exists(CURRENT_SCHEDULER): +- update_current_scheduler("none") +- + try: + f = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK, 0644) + try: +-- +1.7.1 + diff --git a/SOURCES/0216-glusterd-correct-replace-brick-flow.patch b/SOURCES/0216-glusterd-correct-replace-brick-flow.patch new file mode 100644 index 0000000..b4907ef --- /dev/null +++ b/SOURCES/0216-glusterd-correct-replace-brick-flow.patch @@ -0,0 +1,125 @@ +From 6333e300cba4a2611815dd6fd53e0e246c2b0167 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Thu, 9 Jul 2015 12:17:59 +0530 +Subject: [PATCH 216/234] glusterd: correct replace-brick flow + +commit 9d2971 assumed that replace-brick is a op-sm transaction. This patch +fixes the replace brick flow as its a syncop transaction now. + +Change-Id: I4c18a9c8db6173632b6d94d8609a7af3b912ae48 +BUG: 1230525 +Signed-off-by: Atin Mukherjee +Reviewed-on: https://code.engineering.redhat.com/gerrit/52639 +Reviewed-by: Anand Nekkunti +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 14 -------------- + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 21 --------------------- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 5 +++++ + 3 files changed, 5 insertions(+), 35 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index b1ee5e3..dbdaec0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -3996,7 +3996,6 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + char *op_errstr = NULL; + glusterd_op_t op = GD_OP_NONE; + uint32_t pending_count = 0; +- glusterd_op_info_t txn_op_info = {{0},}; + + this = THIS; + GF_ASSERT (this); +@@ -4048,19 +4047,6 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) + goto out; + } + +- if (op == GD_OP_REPLACE_BRICK) { +- ret = glusterd_get_txn_opinfo (&event->txn_id, &txn_op_info); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_TRANS_OPINFO_GET_FAIL, +- "Failed to get txn_op_info " +- "for txn_id = %s", uuid_utoa (event->txn_id)); +- goto out; +- } +- +- glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, rsp_dict); +- } +- + rcu_read_lock (); + cds_list_for_each_entry_rcu (peerinfo, &priv->peers, uuid_list) { + /* Only send requests to peers who were available before the +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 50820d7..0890b02 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -1131,7 +1131,6 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + uuid_t *txn_id = NULL; +- glusterd_op_info_t txn_op_info = {{0},}; + + this = THIS; + GF_ASSERT (this); +@@ -1201,14 +1200,6 @@ out: + gf_msg_debug (this->name, 0, "transaction ID = %s", + uuid_utoa (*txn_id)); + +- ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_TRANS_OPINFO_GET_FAIL, +- "Failed to get txn_op_info " +- "for txn_id = %s", uuid_utoa (*txn_id)); +- } +- + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +@@ -1240,12 +1231,6 @@ out: + + rcu_read_unlock (); + +- switch (rsp.op) { +- case GD_OP_REPLACE_BRICK: +- glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict); +- break; +- } +- + ret = glusterd_op_sm_inject_event (event_type, txn_id, NULL); + + if (!ret) { +@@ -1398,12 +1383,6 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + GF_ASSERT (rsp.op == txn_op_info.op); + + switch (rsp.op) { +- case GD_OP_REPLACE_BRICK: +- ret = glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict); +- if (ret) +- goto unlock; +- break; +- + case GD_OP_PROFILE_VOLUME: + ret = glusterd_profile_volume_use_rsp_dict (txn_op_info.op_ctx, dict); + if (ret) +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index 1d5deb8..5a1ffb4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -245,6 +245,11 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) + } + break; + ++ case GD_OP_REPLACE_BRICK: ++ ret = glusterd_rb_use_rsp_dict (aggr, rsp); ++ if (ret) ++ goto out; ++ break; + + case GD_OP_SYNC_VOLUME: + ret = glusterd_sync_use_rsp_dict (aggr, rsp); +-- +1.7.1 + diff --git a/SOURCES/0217-glusterd-snapd-Stop-snapd-daemon-when-glusterd-is-re.patch b/SOURCES/0217-glusterd-snapd-Stop-snapd-daemon-when-glusterd-is-re.patch new file mode 100644 index 0000000..e6377b4 --- /dev/null +++ b/SOURCES/0217-glusterd-snapd-Stop-snapd-daemon-when-glusterd-is-re.patch @@ -0,0 +1,39 @@ +From 4e46b44d2fed2766bb95c3daf6371650ca4a87ac Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 8 Jul 2015 14:18:19 +0530 +Subject: [PATCH 217/234] glusterd/snapd: Stop snapd daemon when glusterd is restarting + +Stop snapd daemon when glusterd is coming back, if uss +is disabled, or volume is stopped. + +> Reviewed-on: http://review.gluster.org/11575 +Change-Id: I4313ecaff19de30f3e9ea76881994509402ed5b0 +BUG: 1240338 +Signed-off-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/52635 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-utils.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 770cbf7..d2a110c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -3682,6 +3682,12 @@ glusterd_delete_stale_volume (glusterd_volinfo_t *stale_volinfo, + (void) gf_store_handle_destroy (stale_volinfo->shandle); + stale_volinfo->shandle = NULL; + } ++ ++ /* Marking volume as stopped, so that svc manager stops snapd ++ * and we are deleting the volume. ++ */ ++ stale_volinfo->status = GLUSTERD_STATUS_STOPPED; ++ + if (!stale_volinfo->is_snap_volume) { + svc = &(stale_volinfo->snapd.svc); + (void) svc->manager (svc, stale_volinfo, PROC_START_NO_WAIT); +-- +1.7.1 + diff --git a/SOURCES/0218-quotad-create-sock-listener-only-after-graph-init-is.patch b/SOURCES/0218-quotad-create-sock-listener-only-after-graph-init-is.patch new file mode 100644 index 0000000..44fd00c --- /dev/null +++ b/SOURCES/0218-quotad-create-sock-listener-only-after-graph-init-is.patch @@ -0,0 +1,124 @@ +From 08f9a81283ca783513b11c4a0b99519671f489d8 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Mon, 6 Jul 2015 16:18:45 +0530 +Subject: [PATCH 218/234] quotad: create sock listener only after graph init is complete + +This is a backport of http://review.gluster.org/#/c/11552/ + +If FOPs are received before completing graph initialization, +FOP path can crash while accessing uninitialized variables + +This patch fixes issue by not creating listener until +graph initialization is complete and hence not receiving +FOP request + +> Change-Id: I4771e376410843dff44bfe819329a4632523d266 +> BUG: 1240254 +> Signed-off-by: vmallika + +Change-Id: I2158684bee24f6e653c9e4f7652b048c2a99564b +BUG: 1239317 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52532 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quotad-aggregator.c | 10 +++++++ + xlators/features/quota/src/quotad.c | 32 +++++++++++++++++++++--- + 2 files changed, 38 insertions(+), 4 deletions(-) + +diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c +index 6c9c40a..8a7cfdc 100644 +--- a/xlators/features/quota/src/quotad-aggregator.c ++++ b/xlators/features/quota/src/quotad-aggregator.c +@@ -374,6 +374,11 @@ quotad_aggregator_init (xlator_t *this) + + priv = this->private; + ++ if (priv->rpcsvc) { ++ /* Listener already created */ ++ return 0; ++ } ++ + ret = dict_set_str (this->options, "transport.address-family", "unix"); + if (ret) + goto out; +@@ -423,6 +428,11 @@ quotad_aggregator_init (xlator_t *this) + + ret = 0; + out: ++ if (ret && priv->rpcsvc) { ++ GF_FREE (priv->rpcsvc); ++ priv->rpcsvc = NULL; ++ } ++ + return ret; + } + +diff --git a/xlators/features/quota/src/quotad.c b/xlators/features/quota/src/quotad.c +index 243b943..028c804 100644 +--- a/xlators/features/quota/src/quotad.c ++++ b/xlators/features/quota/src/quotad.c +@@ -11,6 +11,18 @@ + #include "quotad-aggregator.h" + #include "common-utils.h" + ++int ++qd_notify (xlator_t *this, int32_t event, void *data, ...) ++{ ++ switch (event) { ++ case GF_EVENT_PARENT_UP: ++ quotad_aggregator_init (this); ++ } ++ ++ default_notify (this, event, data); ++ return 0; ++} ++ + int32_t + mem_acct_init (xlator_t *this) + { +@@ -147,6 +159,21 @@ qd_reconfigure (xlator_t *this, dict_t *options) + void + qd_fini (xlator_t *this) + { ++ quota_priv_t *priv = NULL; ++ ++ if (this == NULL || this->private == NULL) ++ goto out; ++ ++ priv = this->private; ++ ++ if (priv->rpcsvc) { ++ GF_FREE (priv->rpcsvc); ++ priv->rpcsvc = NULL; ++ } ++ ++ GF_FREE (priv); ++ ++out: + return; + } + +@@ -169,10 +196,6 @@ qd_init (xlator_t *this) + + this->private = priv; + +- ret = quotad_aggregator_init (this); +- if (ret < 0) +- goto err; +- + ret = 0; + err: + if (ret) { +@@ -185,6 +208,7 @@ class_methods_t class_methods = { + .init = qd_init, + .fini = qd_fini, + .reconfigure = qd_reconfigure, ++ .notify = qd_notify + }; + + struct xlator_fops fops = { +-- +1.7.1 + diff --git a/SOURCES/0219-common-ha-ganesha-ha.sh-status-tries-to-read-ganesha.patch b/SOURCES/0219-common-ha-ganesha-ha.sh-status-tries-to-read-ganesha.patch new file mode 100644 index 0000000..c75e93b --- /dev/null +++ b/SOURCES/0219-common-ha-ganesha-ha.sh-status-tries-to-read-ganesha.patch @@ -0,0 +1,80 @@ +From f76bbb74e489bc9d34eee082f28ce71b606a3b5d Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Wed, 8 Jul 2015 10:36:04 -0400 +Subject: [PATCH 219/234] common-ha: ganesha-ha.sh status tries to read ganesha-ha.conf + +status doesn't need to read the config + +backports +>> Change-Id: Id02252abe52820dbc263f4a880bde72a23b121bd +>> BUG: 1241133 +>> http://review.gluster.org/#/c/11581/ +> Change-Id: I036fd3072f38958373b1a85b0dc5c97245a72af4 +> BUG: 1241134 +> http://review.gluster.org/#/c/11582/ + +Change-Id: I001203364cd0b2e1ca4b24edc41b5d043962ba23 +BUG: 1224610 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/52593 +--- + extras/ganesha/scripts/ganesha-ha.sh | 40 +++++++++++++++++----------------- + 1 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 69794a3..c1f0757 100755 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -818,29 +818,29 @@ main() + { + + local cmd=${1}; shift +- if [[ ${cmd} == *help ]] +- then ++ if [[ ${cmd} == *help ]]; then + usage + exit 0 + fi +- +- HA_CONFDIR=${1}; shift +- local ha_conf=${HA_CONFDIR}/ganesha-ha.conf +- local node="" +- local vip="" +- +- # ignore any comment lines +- cfgline=$(grep ^HA_NAME= ${ha_conf}) +- eval $(echo ${cfgline} | grep -F HA_NAME=) +- cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf}) +- eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=) +- cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf}) +- eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=) +- +- # we'll pretend that nobody ever edits /etc/os-release +- if [ -e /etc/os-release ]; then +- eval $(grep -F "REDHAT_SUPPORT_PRODUCT=" /etc/os-release) +- [ "$REDHAT_SUPPORT_PRODUCT" == "Fedora" ] && RHEL6_PCS_CNAME_OPTION="" ++ if [[ ${cmd} != *status ]]; then ++ HA_CONFDIR=${1}; shift ++ local ha_conf=${HA_CONFDIR}/ganesha-ha.conf ++ local node="" ++ local vip="" ++ ++ # ignore any comment lines ++ cfgline=$(grep ^HA_NAME= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_NAME=) ++ cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=) ++ cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf}) ++ eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=) ++ ++ # we'll pretend that nobody ever edits /etc/os-release ++ if [ -e /etc/os-release ]; then ++ eval $(grep -F "REDHAT_SUPPORT_PRODUCT=" /etc/os-release) ++ [ "$REDHAT_SUPPORT_PRODUCT" == "Fedora" ] && RHEL6_PCS_CNAME_OPTION="" ++ fi + fi + + case "${cmd}" in +-- +1.7.1 + diff --git a/SOURCES/0220-quota-marker-fix-mem-leak-in-marker.patch b/SOURCES/0220-quota-marker-fix-mem-leak-in-marker.patch new file mode 100644 index 0000000..9c3bb33 --- /dev/null +++ b/SOURCES/0220-quota-marker-fix-mem-leak-in-marker.patch @@ -0,0 +1,296 @@ +From 2f31a7673b559f7764f9bb44a89e161cb4242711 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 9 Jul 2015 15:14:14 +0530 +Subject: [PATCH 220/234] quota/marker: fix mem leak in marker + +This is a backport of http://review.gluster.org/#/c/11457/ +Part of the fix is available in: +https://code.engineering.redhat.com/gerrit/#/c/52303/ + +This patch optimizes the me consumption. +create syntask txn only for linked inodes + +Change-Id: I2f9eefc115ce36b3fac29746655fa3c8cecbbcab +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52658 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 161 +++++++++++++++++----------- + 1 files changed, 96 insertions(+), 65 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index 97946f8..400e9ae 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2841,6 +2841,49 @@ out: + return ret; + } + ++int32_t ++mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc, ++ quota_inode_ctx_t **ctx) ++{ ++ int32_t ret = -1; ++ quota_inode_ctx_t *ctxtmp = NULL; ++ ++ if (origin_loc == NULL || origin_loc->inode == NULL || ++ (gf_uuid_is_null(origin_loc->gfid) && ++ gf_uuid_is_null(origin_loc->inode->gfid))) ++ goto out; ++ ++ loc_copy (loc, origin_loc); ++ ++ if (gf_uuid_is_null (loc->gfid)) ++ gf_uuid_copy (loc->gfid, loc->inode->gfid); ++ ++ if (ctx) ++ ret = mq_inode_ctx_get (loc->inode, this, ctx); ++ else ++ ret = mq_inode_ctx_get (loc->inode, this, &ctxtmp); ++ ++ if (ret < 0) { ++ if (ctx) { ++ *ctx = mq_inode_ctx_new (loc->inode, this); ++ if (*ctx == NULL) { ++ gf_log_callingfn (this->name, GF_LOG_WARNING, ++ "mq_inode_ctx_new failed for " ++ "%s", loc->path); ++ ret = -1; ++ goto out; ++ } ++ } else { ++ gf_log_callingfn (this->name, GF_LOG_WARNING, "ctx for " ++ "is NULL for %s", loc->path); ++ } ++ } ++ ++ ret = 0; ++out: ++ return ret; ++} ++ + int + mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + inode_contribution_t *contri) +@@ -2866,16 +2909,6 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + goto out; + } + +- if (gf_uuid_is_null (child_loc.gfid)) +- gf_uuid_copy (child_loc.gfid, child_loc.inode->gfid); +- +- if (gf_uuid_is_null (child_loc.gfid)) { +- ret = -1; +- gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", +- child_loc.path); +- goto out; +- } +- + while (!__is_root_gfid (child_loc.gfid)) { + /* To improve performance, abort current transaction + * if one is already in progress for same inode +@@ -3005,16 +3038,6 @@ mq_create_xattrs_task (void *opaque) + this = args->this; + THIS = this; + +- if (gf_uuid_is_null (loc->gfid)) +- gf_uuid_copy (loc->gfid, loc->inode->gfid); +- +- if (gf_uuid_is_null (loc->gfid)) { +- ret = -1; +- gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", +- loc->path); +- goto out; +- } +- + ret = mq_inode_ctx_get (loc->inode, this, &ctx); + if (ret < 0) { + gf_log (this->name, GF_LOG_WARNING, "Failed to" +@@ -3056,34 +3079,30 @@ out: + } + + static int +-_mq_create_xattrs_txn (xlator_t *this, loc_t *loc, gf_boolean_t spawn) ++_mq_create_xattrs_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn) + { + int32_t ret = -1; + quota_inode_ctx_t *ctx = NULL; + gf_boolean_t status = _gf_true; ++ loc_t loc = {0, }; + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- ctx = mq_inode_ctx_new (loc->inode, this); +- if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "mq_inode_ctx_new failed"); +- ret = -1; +- goto out; +- } +- } ++ ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx); ++ if (ret < 0) ++ goto out; + + ret = mq_test_and_set_ctx_create_status (ctx, &status); + if (ret < 0 || status == _gf_true) + goto out; + +- ret = mq_synctask (this, mq_create_xattrs_task, spawn, loc, 0); ++ ret = mq_synctask (this, mq_create_xattrs_task, spawn, &loc, 0); + out: + if (ret < 0 && status == _gf_false) + mq_set_ctx_create_status (ctx, _gf_false); + ++ loc_wipe (&loc); + return ret; + } ++ + int + mq_create_xattrs_txn (xlator_t *this, loc_t *loc) + { +@@ -3237,17 +3256,33 @@ out: + } + + int32_t +-mq_reduce_parent_size_txn (xlator_t *this, loc_t *loc, int64_t contri) ++mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, int64_t contri) + { + int32_t ret = -1; ++ loc_t loc = {0, }; + + GF_VALIDATE_OR_GOTO ("marker", this, out); +- GF_VALIDATE_OR_GOTO ("marker", loc, out); +- GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); ++ GF_VALIDATE_OR_GOTO ("marker", origin_loc, out); ++ ++ ret = mq_prevalidate_txn (this, origin_loc, &loc, NULL); ++ if (ret < 0) ++ goto out; ++ ++ if (loc_is_root(&loc)) { ++ ret = 0; ++ goto out; ++ } + +- ret = mq_synctask (this, mq_reduce_parent_size_task, _gf_true, loc, ++ if (loc.parent == NULL) { ++ gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, " ++ "aborting reduce parent size txn", loc.path); ++ goto out; ++ } ++ ++ ret = mq_synctask (this, mq_reduce_parent_size_task, _gf_true, &loc, + contri); + out: ++ loc_wipe (&loc); + return ret; + } + +@@ -3325,16 +3360,25 @@ out: + } + + int +-_mq_initiate_quota_txn (xlator_t *this, loc_t *loc, gf_boolean_t spawn) ++_mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn) + { + int32_t ret = -1; + quota_inode_ctx_t *ctx = NULL; + gf_boolean_t status = _gf_true; ++ loc_t loc = {0,}; + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "inode ctx get failed, aborting quota txn"); ++ ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx); ++ if (ret < 0) ++ goto out; ++ ++ if (loc_is_root(&loc)) { ++ ret = 0; ++ goto out; ++ } ++ ++ if (loc.parent == NULL) { ++ gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, " ++ "aborting updation txn", loc.path); + goto out; + } + +@@ -3342,12 +3386,13 @@ _mq_initiate_quota_txn (xlator_t *this, loc_t *loc, gf_boolean_t spawn) + if (ret < 0 || status == _gf_true) + goto out; + +- ret = mq_synctask (this, mq_initiate_quota_task, spawn, loc, 0); ++ ret = mq_synctask (this, mq_initiate_quota_task, spawn, &loc, 0); + + out: + if (ret < 0 && status == _gf_false) + mq_set_ctx_updation_status (ctx, _gf_false); + ++ loc_wipe (&loc); + return ret; + } + +@@ -3407,16 +3452,6 @@ mq_update_dirty_inode_task (void *opaque) + this = args->this; + THIS = this; + +- if (gf_uuid_is_null (loc->gfid)) +- gf_uuid_copy (loc->gfid, loc->inode->gfid); +- +- if (gf_uuid_is_null (loc->gfid)) { +- ret = -1; +- gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", +- loc->path); +- goto out; +- } +- + ret = mq_lock (this, loc, F_WRLCK); + if (ret < 0) + goto out; +@@ -3707,29 +3742,25 @@ out: + } + + int32_t +-mq_xattr_state (xlator_t *this, loc_t *loc, dict_t *dict, struct iatt buf) ++mq_xattr_state (xlator_t *this, loc_t *origin_loc, dict_t *dict, ++ struct iatt buf) + { + int32_t ret = -1; + quota_inode_ctx_t *ctx = NULL; ++ loc_t loc = {0, }; + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- ctx = mq_inode_ctx_new (loc->inode, this); +- if (ctx == NULL) { +- gf_log (this->name, GF_LOG_WARNING, +- "mq_inode_ctx_new failed"); +- ret = -1; +- goto out; +- } +- } ++ ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx); ++ if (ret < 0) ++ goto out; + + if (((buf.ia_type == IA_IFREG) && !dht_is_linkfile (&buf, dict)) + || (buf.ia_type == IA_IFLNK)) { +- mq_inspect_file_xattr (this, ctx, loc, dict, buf); ++ mq_inspect_file_xattr (this, ctx, &loc, dict, buf); + } else if (buf.ia_type == IA_IFDIR) +- mq_inspect_directory_xattr (this, loc, ctx, dict, buf); ++ mq_inspect_directory_xattr (this, &loc, ctx, dict, buf); + + out: ++ loc_wipe (&loc); + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0221-quota-marker-use-smaller-stacksize-in-synctask-for-m.patch b/SOURCES/0221-quota-marker-use-smaller-stacksize-in-synctask-for-m.patch new file mode 100644 index 0000000..a3e4cbb --- /dev/null +++ b/SOURCES/0221-quota-marker-use-smaller-stacksize-in-synctask-for-m.patch @@ -0,0 +1,165 @@ +From 472722768af68d8e5faf34a3ecfc7cbbd9767205 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 9 Jul 2015 15:41:50 +0530 +Subject: [PATCH 221/234] quota/marker: use smaller stacksize in synctask for marker updation + +This is a backport of http://review.gluster.org/#/c/11499 + +Default stacksize that synctask uses is 2M. +For marker we set it to 16k + +Also move market xlator close to io-threads +to have smaller stack + +> Change-Id: I8730132a6365cc9e242a3564a1e615d94ef2c651 +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: I4e0b68cc94fe133846c69d4858598599c2f5c51c +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52660 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/syncop.c | 26 ++++++++++++++----- + libglusterfs/src/syncop.h | 10 +++++-- + xlators/features/marker/src/marker-quota.c | 4 +- + .../features/qemu-block/src/coroutine-synctask.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 2 +- + 5 files changed, 30 insertions(+), 14 deletions(-) + +diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c +index 26a4737..db45674 100644 +--- a/libglusterfs/src/syncop.c ++++ b/libglusterfs/src/syncop.c +@@ -443,8 +443,8 @@ synctask_setid (struct synctask *task, uid_t uid, gid_t gid) + + + struct synctask * +-synctask_create (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, +- call_frame_t *frame, void *opaque) ++synctask_create (struct syncenv *env, size_t stacksize, synctask_fn_t fn, ++ synctask_cbk_t cbk, call_frame_t *frame, void *opaque) + { + struct synctask *newtask = NULL; + xlator_t *this = THIS; +@@ -500,13 +500,19 @@ synctask_create (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, + goto err; + } + +- newtask->stack = CALLOC (1, env->stacksize); ++ if (stacksize <= 0) { ++ newtask->stack = CALLOC (1, env->stacksize); ++ newtask->ctx.uc_stack.ss_size = env->stacksize; ++ } else { ++ newtask->stack = CALLOC (1, stacksize); ++ newtask->ctx.uc_stack.ss_size = stacksize; ++ } ++ + if (!newtask->stack) { + goto err; + } + + newtask->ctx.uc_stack.ss_sp = newtask->stack; +- newtask->ctx.uc_stack.ss_size = env->stacksize; + + makecontext (&newtask->ctx, (void (*)(void)) synctask_wrap, 2, newtask); + +@@ -561,13 +567,13 @@ synctask_join (struct synctask *task) + + + int +-synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, +- call_frame_t *frame, void *opaque) ++synctask_new1 (struct syncenv *env, size_t stacksize, synctask_fn_t fn, ++ synctask_cbk_t cbk, call_frame_t *frame, void *opaque) + { + struct synctask *newtask = NULL; + int ret = 0; + +- newtask = synctask_create (env, fn, cbk, frame, opaque); ++ newtask = synctask_create (env, stacksize, fn, cbk, frame, opaque); + if (!newtask) + return -1; + +@@ -577,6 +583,12 @@ synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, + return ret; + } + ++int ++synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, ++ call_frame_t *frame, void *opaque) ++{ ++ return synctask_new1 (env, 0, fn, cbk, frame, opaque); ++} + + struct synctask * + syncenv_task (struct syncproc *proc) +diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h +index f41706a..ca25d98 100644 +--- a/libglusterfs/src/syncop.h ++++ b/libglusterfs/src/syncop.h +@@ -264,9 +264,13 @@ struct syncenv * syncenv_new (size_t stacksize, int procmin, int procmax); + void syncenv_destroy (struct syncenv *); + void syncenv_scale (struct syncenv *env); + +-int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, call_frame_t* frame, void *); +-struct synctask *synctask_create (struct syncenv *, synctask_fn_t, +- synctask_cbk_t, call_frame_t *, void *); ++int synctask_new1 (struct syncenv *, size_t stacksize, synctask_fn_t, ++ synctask_cbk_t, call_frame_t *frame, void *); ++int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, ++ call_frame_t *frame, void *); ++struct synctask *synctask_create (struct syncenv *, size_t stacksize, ++ synctask_fn_t, synctask_cbk_t, call_frame_t *, ++ void *); + int synctask_join (struct synctask *task); + void synctask_wake (struct synctask *task); + void synctask_yield (struct synctask *task); +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index 400e9ae..18e6405 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2825,8 +2825,8 @@ mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc, + args->contri = contri; + + if (spawn) { +- ret = synctask_new (this->ctx->env, task, mq_synctask_cleanup, +- NULL, args); ++ ret = synctask_new1 (this->ctx->env, 1024 * 16, task, ++ mq_synctask_cleanup, NULL, args); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to spawn " + "new synctask"); +diff --git a/xlators/features/qemu-block/src/coroutine-synctask.c b/xlators/features/qemu-block/src/coroutine-synctask.c +index e43988a..5b7ca0c 100644 +--- a/xlators/features/qemu-block/src/coroutine-synctask.c ++++ b/xlators/features/qemu-block/src/coroutine-synctask.c +@@ -105,7 +105,7 @@ qb_coroutine (call_frame_t *frame, synctask_fn_t fn) + LOCK(&qb_co.lock); + + if (!qb_co.task) +- qb_co.task = synctask_create(qb_conf->env, qb_synctask_wrap, ++ qb_co.task = synctask_create(qb_conf->env, 0, qb_synctask_wrap, + synctask_nop_cbk, frame, NULL); + + list_add_tail(&qb_local->list, &qb_co.queue); +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index c3ec10b..ee5cf68 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -2234,9 +2234,9 @@ static volgen_brick_xlator_t server_graph_table[] = { + {brick_graph_add_ro, NULL}, + {brick_graph_add_worm, NULL}, + {brick_graph_add_quota, "quota"}, +- {brick_graph_add_marker, "marker"}, + {brick_graph_add_index, "index"}, + {brick_graph_add_barrier, NULL}, ++ {brick_graph_add_marker, "marker"}, + {brick_graph_add_iot, "io-threads"}, + {brick_graph_add_upcall, "upcall"}, + {brick_graph_add_pump, NULL}, +-- +1.7.1 + diff --git a/SOURCES/0222-quota-marker-set-lk_owner-when-taking-lock-on-parent.patch b/SOURCES/0222-quota-marker-set-lk_owner-when-taking-lock-on-parent.patch new file mode 100644 index 0000000..89d4439 --- /dev/null +++ b/SOURCES/0222-quota-marker-set-lk_owner-when-taking-lock-on-parent.patch @@ -0,0 +1,74 @@ +From af8db4cac8a47da28304b20d07cbeb7cb5a26f45 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Tue, 7 Jul 2015 16:03:26 +0530 +Subject: [PATCH 222/234] quota/marker: set lk_owner when taking lock on parent in rename + +This is a backport of http://review.gluster.org/#/c/11561/ + +Before doing a rename operation marker takes inode lock on the file +parent, +here lk_owner is NULL and this can cause accounting problem with +multiple rename on the same directory + +This patch fix the problem by setting lk_owner + +> Change-Id: Ibb789e39b2833e425d0a5fca85282ff1465206cb +> BUG: 1240598 +> Signed-off-by: vmallika + +Change-Id: Ia9c8697b0bd5a9c2ee2df971acb23fa7a3a0403b +BUG: 1241048 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52662 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/lkowner.h | 19 +++++++++++++++++++ + xlators/features/marker/src/marker.c | 3 +++ + 2 files changed, 22 insertions(+), 0 deletions(-) + +diff --git a/libglusterfs/src/lkowner.h b/libglusterfs/src/lkowner.h +index 969d13e..cf1e471 100644 +--- a/libglusterfs/src/lkowner.h ++++ b/libglusterfs/src/lkowner.h +@@ -80,4 +80,23 @@ is_same_lkowner (gf_lkowner_t *l1, gf_lkowner_t *l2) + return ((l1->len == l2->len) && !memcmp(l1->data, l2->data, l1->len)); + } + ++static inline int ++is_lk_owner_null (gf_lkowner_t *lkowner) ++{ ++ int is_null = 1; ++ int i = 0; ++ ++ if (lkowner == NULL || lkowner->len == 0) ++ goto out; ++ ++ for (i = 0; i < lkowner->len; i++) { ++ if (lkowner->data[i] != 0) { ++ is_null = 0; ++ break; ++ } ++ } ++out: ++ return is_null; ++} ++ + #endif /* _LK_OWNER_H */ +diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c +index 414177a..c7c9fd3 100644 +--- a/xlators/features/marker/src/marker.c ++++ b/xlators/features/marker/src/marker.c +@@ -1598,6 +1598,9 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + + local->xdata = dict_ref (xdata); + ++ if (is_lk_owner_null (&frame->root->lk_owner)) ++ set_lk_owner_from_ptr (&frame->root->lk_owner, frame->root); ++ + STACK_WIND (frame, + marker_rename_inodelk_cbk, + FIRST_CHILD(this), +-- +1.7.1 + diff --git a/SOURCES/0223-quota-marker-fix-spurious-failure-afr-quota-xattr-md.patch b/SOURCES/0223-quota-marker-fix-spurious-failure-afr-quota-xattr-md.patch new file mode 100644 index 0000000..598f043 --- /dev/null +++ b/SOURCES/0223-quota-marker-fix-spurious-failure-afr-quota-xattr-md.patch @@ -0,0 +1,215 @@ +From 20200b205c1aafd6cb131afafdc7ea47e63dd062 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Fri, 10 Jul 2015 13:34:12 +0530 +Subject: [PATCH 223/234] quota/marker: fix spurious failure afr-quota-xattr-mdata-heal.t + +This is a backport of http://review.gluster.org/#/c/11583/ + +During quota-update process if inode info is present in size-xattr and +missing in contri-xattrs, then in function '_mq_get_metadata', we set +contri-size as zero (on error -2, which means usage info present, but +inode info missing). +With this we are calculating wrong delta and updating the same. + +With this patch we are ignoring errors if inode info in xattrs are +missing + +> Change-Id: I7940a0e299b8bb425b5b43746b1f13f775c7fb92 +> BUG: 1241153 +> Signed-off-by: vmallika + +Change-Id: I4fcfc8410e1e7d386065949d2402e7e3e6efdb0e +BUG: 1241150 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52758 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + cli/src/cli-rpc-ops.c | 16 ++++++---------- + libglusterfs/src/quota-common-utils.c | 14 +++++++++++++- + libglusterfs/src/quota-common-utils.h | 3 +++ + tests/bugs/quota/afr-quota-xattr-mdata-heal.t | 3 +++ + tests/bugs/quota/inode-quota.t | 14 -------------- + tests/volume.rc | 18 ++++++++++++++++++ + xlators/features/marker/src/marker-quota.c | 12 +++++------- + 7 files changed, 48 insertions(+), 32 deletions(-) + +diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c +index 57e11fa..dfc5c6b 100644 +--- a/cli/src/cli-rpc-ops.c ++++ b/cli/src/cli-rpc-ops.c +@@ -3292,16 +3292,12 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict) + limits.hl = ntoh64 (size_limits->hl); + limits.sl = ntoh64 (size_limits->sl); + +- ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, &used_space); +- if (ret == -2 && type == GF_QUOTA_OPTION_TYPE_LIST) { +- ret = 0; +- /* quota_dict_get_meta returns -2 if metadata for inode +- * quotas is missing. +- * This can happen when glusterfs is upgraded from 3.6 to 3.7 +- * and the xattr healing is not completed. +- * We can contiue as success if we are listing only file usage +- */ +- } ++ if (type == GF_QUOTA_OPTION_TYPE_LIST) ++ ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, ++ &used_space); ++ else ++ ret = quota_dict_get_inode_meta (rsp_dict, QUOTA_SIZE_KEY, ++ &used_space); + + if (ret < 0) { + gf_log ("cli", GF_LOG_WARNING, +diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c +index 8c528c8..0c93303 100644 +--- a/libglusterfs/src/quota-common-utils.c ++++ b/libglusterfs/src/quota-common-utils.c +@@ -57,7 +57,7 @@ out: + } + + int32_t +-quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta) ++quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta) + { + int32_t ret = -1; + data_t *data = NULL; +@@ -77,6 +77,18 @@ out: + } + + int32_t ++quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta) ++{ ++ int32_t ret = -1; ++ ++ ret = quota_dict_get_inode_meta (dict, key, meta); ++ if (ret == -2) ++ ret = 0; ++ ++ return ret; ++} ++ ++int32_t + quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta, + ia_type_t ia_type) + { +diff --git a/libglusterfs/src/quota-common-utils.h b/libglusterfs/src/quota-common-utils.h +index 2c3632b..c930db8 100644 +--- a/libglusterfs/src/quota-common-utils.h ++++ b/libglusterfs/src/quota-common-utils.h +@@ -41,6 +41,9 @@ int32_t + quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta); + + int32_t ++quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta); ++ ++int32_t + quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta); + + int32_t +diff --git a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t +index 6aa2d83..82921ff 100644 +--- a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t ++++ b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t +@@ -15,6 +15,9 @@ TEST mkdir $M0/d + TEST $CLI volume quota $V0 limit-usage /d 1MB + TEST touch $M0/d/a + echo abc > $M0/d/a ++ ++EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "512Bytes" quota_usage "/" ++ + #Set the acl xattrs directly on backend, for some reason on mount it gives error + acl_access_val="0x0200000001000600ffffffff04000400ffffffff10000400ffffffff20000400ffffffff" + acl_file_val="0x0000000400000001ffffffff0006000000000004ffffffff0004000000000010ffffffff0004000000000020ffffffff00040000" +diff --git a/tests/bugs/quota/inode-quota.t b/tests/bugs/quota/inode-quota.t +index 55a26fa..1b04f40 100644 +--- a/tests/bugs/quota/inode-quota.t ++++ b/tests/bugs/quota/inode-quota.t +@@ -4,20 +4,6 @@ + . $(dirname $0)/../../volume.rc + . $(dirname $0)/../../nfs.rc + +-function quota_list_field () { +- local QUOTA_PATH=$1 +- local FIELD=$2 +- $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\ +- | awk '{print $FIELD}' +-} +- +-function quota_object_list_field () { +- local QUOTA_PATH=$1 +- local FIELD=$2 +- $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\ +- | awk '{print $FIELD}' +-} +- + cleanup; + + QDD=$(dirname $0)/quota +diff --git a/tests/volume.rc b/tests/volume.rc +index 2d8dd72..09a8d51 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -543,3 +543,21 @@ function get_scrubd_count { + ps auxww | grep glusterfs | grep scrub.pid | grep -v grep | wc -l + } + ++function quota_list_field () { ++ local QUOTA_PATH=$1 ++ local FIELD=$2 ++ $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\ ++ | awk '{print $FIELD}' ++} ++ ++function quota_object_list_field () { ++ local QUOTA_PATH=$1 ++ local FIELD=$2 ++ $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\ ++ | awk '{print $FIELD}' ++} ++ ++function quota_usage() ++{ ++ quota_list_field $1 4 ++} +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index 18e6405..ca59c1b 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2095,9 +2095,9 @@ _quota_dict_get_meta (xlator_t *this, dict_t *dict, char *key, + + priv = this->private; + +- ret = quota_dict_get_meta (dict, key, meta); ++ ret = quota_dict_get_inode_meta (dict, key, meta); + if (ret == -2 && (priv->feature_enabled & GF_INODE_QUOTA) == 0) { +- /* quota_dict_get_meta returns -2 if ++ /* quota_dict_get_inode_meta returns -2 if + * inode quota xattrs are not present. + * if inode quota self heal is turned off, + * then we should skip healing inode quotas +@@ -2466,9 +2466,8 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, + + if (size) { + if (loc->inode->ia_type == IA_IFDIR) { +- ret = _quota_dict_get_meta (this, rsp_dict, +- QUOTA_SIZE_KEY, &meta, +- IA_IFDIR, _gf_true); ++ ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, ++ &meta); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, + "dict_get failed."); +@@ -2486,8 +2485,7 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, + } + + if (contri && !loc_is_root(loc)) { +- ret = _quota_dict_get_meta (this, rsp_dict, contri_key, &meta, +- loc->inode->ia_type, _gf_false); ++ ret = quota_dict_get_meta (rsp_dict, contri_key, &meta); + if (ret < 0) { + contri->size = 0; + contri->file_count = 0; +-- +1.7.1 + diff --git a/SOURCES/0224-gfapi-Update-loc-inode-accordingly-in-glfs_loc_link.patch b/SOURCES/0224-gfapi-Update-loc-inode-accordingly-in-glfs_loc_link.patch new file mode 100644 index 0000000..b5de50d --- /dev/null +++ b/SOURCES/0224-gfapi-Update-loc-inode-accordingly-in-glfs_loc_link.patch @@ -0,0 +1,91 @@ +From bddbe778a64dd826d074f4008f3c8b1a4a495996 Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Wed, 8 Jul 2015 12:08:25 +0530 +Subject: [PATCH 224/234] gfapi: Update loc->inode accordingly in 'glfs_loc_link' + +In case if the inode already exits in the cache, inode_link +returns the pointer to the exiting one instead of using loc->inode. +This will result in issues if that invalid inodei(loc->inode) is referenced +further. Fixed the same. + +This is backport of the below fix - +http://review.gluster.org/#/c/11572/ + +Change-Id: I7d4a06043e4e731c8404532c47d482175dc2c277 +BUG: 1235121 +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/11572 +Reviewed-by: Kaleb KEITHLEY +Reviewed-by: Shyamsundar Ranganathan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52713 +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + api/src/glfs-fops.c | 16 +++++++++++----- + api/src/glfs-handleops.c | 10 ---------- + 2 files changed, 11 insertions(+), 15 deletions(-) + +diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c +index e1762ae..9d829a1 100644 +--- a/api/src/glfs-fops.c ++++ b/api/src/glfs-fops.c +@@ -76,17 +76,23 @@ int + glfs_loc_link (loc_t *loc, struct iatt *iatt) + { + int ret = -1; +- inode_t *linked_inode = NULL; ++ inode_t *old_inode = NULL; + + if (!loc->inode) { + errno = EINVAL; + return -1; + } + +- linked_inode = inode_link (loc->inode, loc->parent, loc->name, iatt); +- if (linked_inode) { +- inode_lookup (linked_inode); +- inode_unref (linked_inode); ++ old_inode = loc->inode; ++ ++ /* If the inode already exists in the cache, the inode ++ * returned here points to the existing one. We need ++ * to update loc.inode accordingly. ++ */ ++ loc->inode = inode_link (loc->inode, loc->parent, loc->name, iatt); ++ if (loc->inode) { ++ inode_lookup (loc->inode); ++ inode_unref (old_inode); + ret = 0; + } else { + ret = -1; +diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c +index 47f2139..9a85f19 100644 +--- a/api/src/glfs-handleops.c ++++ b/api/src/glfs-handleops.c +@@ -746,11 +746,6 @@ pub_glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, + + /* populate out args */ + if (ret == 0) { +- /* TODO: If the inode existed in the cache (say file already +- exists), then the glfs_loc_link will not update the +- loc.inode, as a result we will have a 0000 GFID that we +- would copy out to the object, this needs to be fixed. +- */ + ret = glfs_loc_link (&loc, &iatt); + if (ret != 0) { + goto out; +@@ -1466,11 +1461,6 @@ pub_glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, + + /* populate out args */ + if (ret == 0) { +- /* TODO: If the inode existed in the cache (say file already +- * exists), then the glfs_loc_link will not update the +- * loc.inode, as a result we will have a 0000 GFID that we +- * would copy out to the object, this needs to be fixed. +- */ + ret = glfs_loc_link (&loc, &iatt); + if (ret != 0) { + goto out; +-- +1.7.1 + diff --git a/SOURCES/0225-glusterd-Fix-management-encryption-issues-with-Glust.patch b/SOURCES/0225-glusterd-Fix-management-encryption-issues-with-Glust.patch new file mode 100644 index 0000000..d24a937 --- /dev/null +++ b/SOURCES/0225-glusterd-Fix-management-encryption-issues-with-Glust.patch @@ -0,0 +1,92 @@ +From 2cee2186043fb8b2a80ce3540e41492b1744bd22 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Tue, 7 Jul 2015 12:52:30 +0530 +Subject: [PATCH 225/234] glusterd: Fix management encryption issues with GlusterD + + Backport of commit 01b82c6 from upstream master + +Management encryption was enabled incorrectly in GlusterD leading to +issues of cluster deadlocks. This has been fixed with this commit. The +fix is in two parts, + +1. Correctly enable encrytion for the TCP listener in GlusterD and +re-enable own-threads for encrypted connections. + Without this, GlusterD could try to esatblish the blocking SSL + connects in the epoll thread, for eg. when handling friend updates, + which could lead to cluster deadlocks. + +2. Explicitly enable encryption for outgoing peer connections. + Without enabling encryption explicitly for outgoing connections was + causing SSL socket events to be handled in the epoll thread. Some + events, like disconnects during peer detach, could lead to connection + attempts to happen in the epoll thread, leading to deadlocks again. + +Change-Id: I438c2b43f7b1965c0e04d95c000144118d36272c +BUG: 1239108 +Signed-off-by: Kaushal M +Reviewed-upstream-on: http://review.gluster.org/11559 +Reviewed-on: https://code.engineering.redhat.com/gerrit/52746 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 14 ++++++++++++++ + xlators/mgmt/glusterd/src/glusterd.c | 13 +++++-------- + 2 files changed, 19 insertions(+), 8 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 3bc39c9..82bd7b1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -3430,6 +3430,20 @@ glusterd_friend_rpc_create (xlator_t *this, glusterd_peerinfo_t *peerinfo, + } + } + ++ /* Enable encryption for the client connection if management encryption ++ * is enabled ++ */ ++ if (this->ctx->secure_mgmt) { ++ ret = dict_set_str (options, "transport.socket.ssl-enabled", ++ "on"); ++ if (ret) { ++ gf_msg ("glusterd", GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, ++ "failed to set ssl-enabled in dict"); ++ goto out; ++ } ++ } ++ + ret = glusterd_rpc_create (&peerinfo->rpc, options, + glusterd_peer_rpc_notify, peerctx); + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 9754e8b..05723b9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -1589,19 +1589,16 @@ init (xlator_t *this) + goto out; + } + ++ /* Enable encryption for the TCP listener is management encryption is ++ * enabled ++ */ + if (this->ctx->secure_mgmt) { +- /* +- * The socket code will turn on SSL based on the same check, +- * but that will by default turn on own-thread as well and +- * we're not multi-threaded enough to handle that. Thus, we +- * override the value here. +- */ + ret = dict_set_str (this->options, +- "transport.socket.own-thread", "off"); ++ "transport.socket.ssl-enabled", "on"); + if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, +- "failed to clear own-thread"); ++ "failed to set ssl-enabled in dict"); + goto out; + } + /* +-- +1.7.1 + diff --git a/SOURCES/0226-NFS-Ganesha-Export-fails-on-RHEL-7.1.patch b/SOURCES/0226-NFS-Ganesha-Export-fails-on-RHEL-7.1.patch new file mode 100644 index 0000000..2a38a87 --- /dev/null +++ b/SOURCES/0226-NFS-Ganesha-Export-fails-on-RHEL-7.1.patch @@ -0,0 +1,188 @@ +From ec94f1bf72f4c9dafff3897471bb819c23fc9a85 Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Thu, 9 Jul 2015 03:34:07 +0530 +Subject: [PATCH 226/234] NFS-Ganesha : Export fails on RHEL 7.1 + +We grep for CONFFILE parameter in "/etc/syconfig/ganesha" +file to find out the path of the ganesha config file. +In RHEL 7.1, this parameter does not exist in the file and +we can't find out the ganesha config file. Export +fails invariably due to this. Changing this pattern to +a more generic one and default it to "/etc/ganesha/ganesha.conf" + +This is a backport of the fix merged upstream, +http://review.gluster.org/#/c/11594/ + +Change-Id: If90dcf5d6408f7513f9c350363d4789adbc1b186 +BUG: 1239057 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52780 +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + extras/ganesha/scripts/create-export-ganesha.sh | 32 +++++++++++++++++-- + extras/ganesha/scripts/dbus-send.sh | 31 ++++++++++++++++++- + extras/ganesha/scripts/ganesha-ha.sh | 38 ++++++++++++++++++++-- + 3 files changed, 93 insertions(+), 8 deletions(-) + mode change 100755 => 100644 extras/ganesha/scripts/ganesha-ha.sh + +diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh +index 668f357..ab7c282 100755 +--- a/extras/ganesha/scripts/create-export-ganesha.sh ++++ b/extras/ganesha/scripts/create-export-ganesha.sh +@@ -5,8 +5,10 @@ + #An export file specific to a volume + #is created in GANESHA_DIR/exports. + +-GANESHA_DIR=$1 ++GANESHA_DIR=${1%/} + VOL=$2 ++CONF= ++CONFFILE= + + function check_cmd_status() + { +@@ -24,9 +26,33 @@ if [ ! -d "$GANESHA_DIR/exports" ]; + check_cmd_status `echo $?` + fi + +-CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=") +-check_cmd_status `echo $?` ++function find_rhel7_conf ++{ ++ while [[ $# > 0 ]] ++ do ++ key="$1" ++ case $key in ++ -f) ++ CONFFILE="$2" ++ ;; ++ *) ++ ;; ++ esac ++ shift ++ done ++} ++ ++cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) ++eval $(echo ${cfgline} | grep -F ^CONFFILE=) + ++if [ -z $CONFFILE ] ++ then ++ cfgline=$(grep ^OPTIONS= /etc/sysconfig/ganesha) ++ eval $(echo ${cfgline} | grep -F ^OPTIONS=) ++ find_rhel7_conf $cfgline ++ ++fi ++CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + function write_conf() + { +diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh +index d838cab..4840be8 100755 +--- a/extras/ganesha/scripts/dbus-send.sh ++++ b/extras/ganesha/scripts/dbus-send.sh +@@ -4,8 +4,37 @@ declare -i EXPORT_ID + GANESHA_DIR=${1%/} + OPTION=$2 + VOL=$3 ++CONF= ++CONFFILE= ++ ++function find_rhel7_conf ++{ ++ while [[ $# > 0 ]] ++ do ++ key="$1" ++ case $key in ++ -f) ++ CONFFILE="$2" ++ break; ++ ;; ++ *) ++ ;; ++ esac ++ shift ++ done ++} ++ + cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) +-eval $(echo ${cfgline} | grep -F CONFFILE=) ++eval $(echo ${cfgline} | grep -F ^CONFFILE=) ++ ++if [ -z $CONFFILE ] ++ then ++ cfgline=$(grep ^OPTIONS= /etc/sysconfig/ganesha) ++ eval $(echo ${cfgline} | grep -F ^OPTIONS=) ++ find_rhel7_conf $cfgline ++ ++fi ++ + CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + function check_cmd_status() +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +old mode 100755 +new mode 100644 +index c1f0757..9e03eb6 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -26,13 +26,43 @@ HA_CONFDIR="/etc/ganesha" + HA_VOL_NAME="gluster_shared_storage" + HA_VOL_MNT="/var/run/gluster/shared_storage" + SERVICE_MAN="DISTRO_NOT_FOUND" +-cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) +-eval $(echo ${cfgline} | grep -F CONFFILE=) +-GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} + + RHEL6_PCS_CNAME_OPTION="--name" + SECRET_PEM="/var/lib/glusterd/nfs/secret.pem" + ++GANESHA_CONF= ++CONFFILE= ++ ++function find_rhel7_conf ++{ ++ while [[ $# > 0 ]] ++ do ++ key="$1" ++ case $key in ++ -f) ++ CONFFILE="$2" ++ break; ++ ;; ++ *) ++ ;; ++ esac ++ shift ++ done ++} ++ ++cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha) ++eval $(echo ${cfgline} | grep -F ^CONFFILE=) ++ ++if [ -z $CONFFILE ] ++ then ++ cfgline=$(grep ^OPTIONS= /etc/sysconfig/ganesha) ++ eval $(echo ${cfgline} | grep -F ^OPTIONS=) ++ find_rhel7_conf $cfgline ++ ++fi ++ ++GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf} ++ + usage() { + + echo "Usage : add|delete|status" +@@ -823,7 +853,7 @@ main() + exit 0 + fi + if [[ ${cmd} != *status ]]; then +- HA_CONFDIR=${1}; shift ++ HA_CONFDIR=${1%/}; shift + local ha_conf=${HA_CONFDIR}/ganesha-ha.conf + local node="" + local vip="" +-- +1.7.1 + diff --git a/SOURCES/0227-libgfdb-sql-Fixing-broken-query-of-find_unchanged.patch b/SOURCES/0227-libgfdb-sql-Fixing-broken-query-of-find_unchanged.patch new file mode 100644 index 0000000..bd15ca9 --- /dev/null +++ b/SOURCES/0227-libgfdb-sql-Fixing-broken-query-of-find_unchanged.patch @@ -0,0 +1,50 @@ +From 7bf79190a0e43e91ce96d0b0726afd590967f9cd Mon Sep 17 00:00:00 2001 +From: Joseph Fernandes +Date: Wed, 8 Jul 2015 14:35:45 +0530 +Subject: [PATCH 227/234] libgfdb/sql: Fixing broken query of find_unchanged + +The find_unchanged query should be + + "write_heat <= defined_heat" AND "read_heat <= defined_heat" + and not + "write_heat <= defined_heat" OR "read_heat <= defined_heat" + +>> Backport of http://review.gluster.org/#/c/11577/ +>> Change-Id: Ie82e02aafbb7ea14563007307de3350ea022049a +>> BUG: 1240970 +Signed-off-by: Joseph Fernandes + +Change-Id: I6d7a148925f13cc2048c3713e944f45e8b1a6853 +BUG: 1240925 +Reviewed-on: https://code.engineering.redhat.com/gerrit/52745 +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + libglusterfs/src/gfdb/gfdb_sqlite3.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c +index 94553fb..349ff60 100644 +--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c ++++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c +@@ -763,7 +763,7 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, + /*First condition: For writes*/ + "((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " + GF_COL_TB_WMSEC ") <= ? )" +- " OR " ++ " AND " + /*Second condition: For reads*/ + "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " + GF_COL_TB_RWMSEC ") <= ?)"; +@@ -996,7 +996,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, + "( (" GF_COL_TB_WFC " < ? ) AND" + "((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " + GF_COL_TB_WMSEC ") >= ? ) ) )" +- " OR " ++ " AND " + /*Second condition: For Reads + * Files that have read wind time smaller than for_time + * OR +-- +1.7.1 + diff --git a/SOURCES/0228-glusterd-use-a-real-host-name-instead-of-numeric-whe.patch b/SOURCES/0228-glusterd-use-a-real-host-name-instead-of-numeric-whe.patch new file mode 100644 index 0000000..b565cf7 --- /dev/null +++ b/SOURCES/0228-glusterd-use-a-real-host-name-instead-of-numeric-whe.patch @@ -0,0 +1,47 @@ +From b3352ec7322fc590cc9fa9090eb2a7a9dcd198cc Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Fri, 10 Jul 2015 19:19:39 +0530 +Subject: [PATCH 228/234] glusterd: use a real host name (instead of numeric) when we have one + +Change-Id: Ie9cc201204d3d613e3e585cab066a07283db902c +BUG: 1241904 +Signed-off-by: Jeff Darcy +Reviewed-on: http://review.gluster.org/11587 +Reviewed-by: Shyamsundar Ranganathan +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/52786 +Reviewed-by: Shyam Ranganathan +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-utils.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index d2a110c..7781773 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -4283,6 +4283,7 @@ glusterd_remote_hostname_get (rpcsvc_request_t *req, char *remote_host, int len) + char *name = NULL; + char *hostname = NULL; + char *tmp_host = NULL; ++ char *canon = NULL; + int ret = 0; + + name = req->trans->peerinfo.identifier; +@@ -4297,6 +4298,11 @@ glusterd_remote_hostname_get (rpcsvc_request_t *req, char *remote_host, int len) + goto out; + } + ++ if ((gf_get_hostname_from_ip(hostname, &canon) == 0) && canon) { ++ GF_FREE(tmp_host); ++ tmp_host = hostname = canon; ++ } ++ + strncpy (remote_host, hostname, strlen (hostname)); + + +-- +1.7.1 + diff --git a/SOURCES/0229-glusterd-Send-friend-update-even-for-EVENT_RCVD_ACC.patch b/SOURCES/0229-glusterd-Send-friend-update-even-for-EVENT_RCVD_ACC.patch new file mode 100644 index 0000000..df31da9 --- /dev/null +++ b/SOURCES/0229-glusterd-Send-friend-update-even-for-EVENT_RCVD_ACC.patch @@ -0,0 +1,67 @@ +From 25eaee83b236d1761a317d52bd4dd084275860a7 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Fri, 10 Jul 2015 14:50:29 +0530 +Subject: [PATCH 229/234] glusterd: Send friend update even for EVENT_RCVD_ACC + +In a multi-network cluster, a new peer being probed into the cluster +will not get all the addresses of the peer that initiated the probe in +some cases as it doesn't recieve friend updates from other peers in the +cluster. + +This happens when the new peer establishes connection with the other +peers before the other peers connect to the new peer. + +Assuming, F is the initiator peer, O is one of the other peers in the +cluster and N is the new peer, the following series of events occur on O +when N establishes the connection first. N is already in the BEFRIENDED +state on O, and the actions happening will refer the BEFRIENDED state +table. + + EVENT_RCV_FRIEND_REQ -> results in handle_friend_add_req being called + which injects a LOCAL_ACC + EVENT_RCVC_LOCAL_ACC -> results in send_friend_update being called + which should have sent an update to N, but O + has still not established a connection to N, + so the update isn't sent + EVENT_CONNECTED -> O now connects to N, this results in O sending a + friend_add req to N + EVENT_RCVD_ACC -> friend_add_cbk inject this event, but this event + results in a NOOP when in BEFRIENDED + +As a result this O doesn't recieve all the addresses of F. If the +cluster contains any volumes with bricks attached to the missing +addresses of F and O is restarted in this condition, GlusterD will fail +to start as it wouldn't be able to resolve those bricks. + +This commit changes the EVENT_RCVD_ACC action for the BEFRIENDED state +from a NOOP to send_friend_update. This makes sure that the new peer +recieves the updates from the other existing peers, irrespective of who +establishes the connection first, thus solving the problem. + +BUG: 1234725 +Change-Id: I2bfb7f5e9456a792a15f09bd1ca58f6dc8f2fc1a +Signed-off-by: Kaushal M +Reviewed-upstream-on: https://review.gluster.org/11625 +Reviewed-on: https://code.engineering.redhat.com/gerrit/52812 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-sm.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 902e770..e8e9b3a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -1024,7 +1024,7 @@ glusterd_sm_t glusterd_state_befriended [] = { + {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none}, //EVENT_NONE, + {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none}, //EVENT_PROBE, + {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none}, //EVENT_INIT_FRIEND_REQ, +- {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none}, //EVENT_RCVD_ACC ++ {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_send_friend_update}, //EVENT_RCVD_ACC + {GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_send_friend_update}, //EVENT_RCVD_LOCAL_ACC + {GD_FRIEND_STATE_REJECTED, glusterd_ac_none}, //EVENT_RCVD_RJT + {GD_FRIEND_STATE_REJECTED, glusterd_ac_none}, //EVENT_RCVD_LOCAL_RJT +-- +1.7.1 + diff --git a/SOURCES/0230-logging-Fixed-incorrect-buffer-size.patch b/SOURCES/0230-logging-Fixed-incorrect-buffer-size.patch new file mode 100644 index 0000000..ab8826e --- /dev/null +++ b/SOURCES/0230-logging-Fixed-incorrect-buffer-size.patch @@ -0,0 +1,36 @@ +From 7043d7f0bcd419d5e6e960b8f79ba154c40d95ef Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Fri, 10 Jul 2015 13:41:29 +0530 +Subject: [PATCH 230/234] logging: Fixed incorrect buffer size + + Backport of http://review.gluster.org/11521 + +An incorrect buffer size passed in to_gf_msg_backtrace +prevented the callers from being logged. + +Change-Id: I90550c46ee87c7c078f7ba3fb2bd7fa12f5a70af +BUG: 1241830 +Signed-off-by: Nithya Balachandran +Reviewed-on: https://code.engineering.redhat.com/gerrit/52760 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/logging.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c +index 61b986c..c81c5b1 100644 +--- a/libglusterfs/src/logging.c ++++ b/libglusterfs/src/logging.c +@@ -2045,7 +2045,7 @@ _gf_msg (const char *domain, const char *file, const char *function, + + if (trace) { + ret = _gf_msg_backtrace (GF_LOG_BACKTRACE_DEPTH, callstr, +- GF_LOG_BACKTRACE_DEPTH); ++ GF_LOG_BACKTRACE_SIZE); + if (ret >= 0) + passcallstr = 1; + else +-- +1.7.1 + diff --git a/SOURCES/0231-quota-marker-inspect-file-dir-invoked-without-having.patch b/SOURCES/0231-quota-marker-inspect-file-dir-invoked-without-having.patch new file mode 100644 index 0000000..20fdd54 --- /dev/null +++ b/SOURCES/0231-quota-marker-inspect-file-dir-invoked-without-having.patch @@ -0,0 +1,74 @@ +From dbec1f6a22f79b3b7d86401fefc1a2f6fb0dc820 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Fri, 10 Jul 2015 16:04:16 +0530 +Subject: [PATCH 231/234] quota/marker: inspect file/dir invoked without having quota xattrs requested + +In a lookup and build ancestry quota xattrs are +not requested, it gives wrong assumption that +quota xattrs are missing and tries to do +healing process + +> Change-Id: I7135101ec0edc72a6310dbb304227eaa3b16cb46 +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: I819e1fd01a85d8dc6238b278662062b3ed9bc280 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52778 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/features/marker/src/marker.c | 14 +++++++++++--- + 1 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c +index c7c9fd3..db6943c 100644 +--- a/xlators/features/marker/src/marker.c ++++ b/xlators/features/marker/src/marker.c +@@ -2719,6 +2719,10 @@ marker_lookup (call_frame_t *frame, xlator_t *this, + + priv = this->private; + ++ xattr_req = xattr_req ? dict_ref (xattr_req) : dict_new (); ++ if (!xattr_req) ++ goto err; ++ + if (priv->feature_enabled == 0) + goto wind; + +@@ -2732,15 +2736,21 @@ marker_lookup (call_frame_t *frame, xlator_t *this, + if (ret == -1) + goto err; + +- if ((priv->feature_enabled & GF_QUOTA) && xattr_req) ++ if ((priv->feature_enabled & GF_QUOTA)) + mq_req_xattr (this, loc, xattr_req, NULL); + wind: + STACK_WIND (frame, marker_lookup_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->lookup, loc, xattr_req); ++ ++ dict_unref (xattr_req); ++ + return 0; + err: + STACK_UNWIND_STRICT (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL); + ++ if (xattr_req) ++ dict_unref (xattr_req); ++ + return 0; + } + +@@ -2780,8 +2790,6 @@ marker_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + continue; + } + +- mq_xattr_state (this, &loc, entry->dict, entry->d_stat); +- + inode_unref (parent); + parent = inode_ref (entry->inode); + loc_wipe (&loc); +-- +1.7.1 + diff --git a/SOURCES/0232-NFS-Ganesha-Add-node-does-not-copy-exports-directory.patch b/SOURCES/0232-NFS-Ganesha-Add-node-does-not-copy-exports-directory.patch new file mode 100644 index 0000000..021e573 --- /dev/null +++ b/SOURCES/0232-NFS-Ganesha-Add-node-does-not-copy-exports-directory.patch @@ -0,0 +1,65 @@ +From 6f02dd76d760cc493e0988bfe047a1b74ca518eb Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Fri, 10 Jul 2015 04:23:31 +0530 +Subject: [PATCH 232/234] NFS-Ganesha : Add-node does not copy "exports" directory correctly + +Add-node logic has to copy the "exports" directory into the +new node in the same path. There was an error in copying to the correct +path. Fixing it. + +This is a backport of the patch merged upstream, +http://review.gluster.org/#/c/11618/ + +Change-Id: I6781e978e3ee815dc91a5f3b293082002433c24b +BUG: 1241366 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52815 +Reviewed-by: Soumya Koduri +Tested-by: Soumya Koduri +--- + extras/ganesha/scripts/ganesha-ha.sh | 12 ++++++------ + 1 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 9e03eb6..9c82c09 100644 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -243,7 +243,7 @@ grep Export_Id | cut -d " " -f8` + + if [ -e ${SECRET_PEM} ]; then + while [[ ${3} ]]; do +- current_host=`echo ${3} | cut -d "." -f 1` ++ current_host=`echo ${3} | cut -d "." -f 1` + if [ ${short_host} != ${current_host} ]; then + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ + ${SECRET_PEM} ${HA_CONFDIR}/exports/export.$VOL.conf \ +@@ -282,21 +282,21 @@ string:"EXPORT(Path=/$VOL)" + copy_export_config () + { + local new_node=${1} +- local tganesha_conf=$(mktemp -u) ++ local tganesha_conf=$(mktemp) + local tganesha_exports=$(mktemp -d) +- ++ local short_host=$(hostname -s) + # avoid prompting for password, even with password-less scp + # scp $host1:$file $host2:$file prompts for the password + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-${SECRET_PEM} ${HA_VOL_SERVER}:${GANESHA_CONF} ${tganesha_conf} ++${SECRET_PEM} ${HA_VOL_SERVER}:${GANESHA_CONF} $short_host:${tganesha_conf} + scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ + ${SECRET_PEM} ${tganesha_conf} ${new_node}:${GANESHA_CONF} + rm -f ${tganesha_conf} + + scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-${SECRET_PEM} ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${tganesha_exports} ++${SECRET_PEM} ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ $short_host:${tganesha_exports} + scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +-${SECRET_PEM} ${tganesha_exports} ${new_node}:${HA_CONFDIR}/ ++${SECRET_PEM} ${tganesha_exports}/exports ${new_node}:${HA_CONFDIR}/ + rm -rf ${tganesha_exports} + } + +-- +1.7.1 + diff --git a/SOURCES/0233-access_control-avoid-double-unrefing-of-acl-variable.patch b/SOURCES/0233-access_control-avoid-double-unrefing-of-acl-variable.patch new file mode 100644 index 0000000..4f04d95 --- /dev/null +++ b/SOURCES/0233-access_control-avoid-double-unrefing-of-acl-variable.patch @@ -0,0 +1,88 @@ +From f0f811e8075703f007063937877ebdb77219765d Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Sat, 11 Jul 2015 15:47:18 +0530 +Subject: [PATCH 233/234] access_control : avoid double unrefing of acl variable in its context. + +In handling_other_acl_related_xattr(), acl variable is unrefered twice +after updating the context of access_control translator.So the acl variable +stored in the inmemory context will become invalid one. When the variable +accessed again , it will result in brick crash. This patch fixes the same. + +Backport of http://review.gluster.org/#/c/11632/ + +Upstream reference +>Change-Id: Ib95d2e3d67b0fb20d201244a206379d6261aeb23 +>BUG: 1242041 +>Signed-off-by: Jiffin Tony Thottan + +Change-Id: Ib3bcf6f2f46adffb758ba24c680ce4ff879d6626 +BUG: 1242046 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52817 +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + xlators/system/posix-acl/src/posix-acl.c | 31 +++++++++++++++-------------- + 1 files changed, 16 insertions(+), 15 deletions(-) + +diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c +index da2ccbd..b1d3df3 100644 +--- a/xlators/system/posix-acl/src/posix-acl.c ++++ b/xlators/system/posix-acl/src/posix-acl.c +@@ -1945,37 +1945,38 @@ handling_other_acl_related_xattr (xlator_t *this, inode_t *inode, dict_t *xattr) + data_t *data = NULL; + int ret = 0; + +- ctx = posix_acl_ctx_get (inode, this); +- if (!ctx) { +- ret = -1; +- goto out; +- } +- + data = dict_get (xattr, POSIX_ACL_ACCESS_XATTR); + if (data) { +- ctx = posix_acl_ctx_get (inode, this); +- if (!ctx) { ++ ++ ++ acl = posix_acl_from_xattr (this, data->data, data->len); ++ if (!acl) { + ret = -1; + goto out; + } + +- acl = posix_acl_from_xattr (this, data->data, data->len); +- + ret = posix_acl_set_specific (inode, this, acl, _gf_true); + if (ret) + goto out; + +- if (acl) +- posix_acl_access_set_mode (acl, ctx); +- +- } ++ ctx = posix_acl_ctx_get (inode, this); ++ if (!ctx) { ++ ret = -1; ++ goto out; ++ } + +- if (acl) ++ posix_acl_access_set_mode (acl, ctx); + posix_acl_unref (this, acl); ++ acl = NULL; ++ } + + data = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR); + if (data) { + acl = posix_acl_from_xattr (this, data->data, data->len); ++ if (!acl) { ++ ret = -1; ++ goto out; ++ } + + ret = posix_acl_set_specific (inode, this, acl, _gf_false); + } +-- +1.7.1 + diff --git a/SOURCES/0234-features-posix-Avoid-double-free-of-a-variable-in-po.patch b/SOURCES/0234-features-posix-Avoid-double-free-of-a-variable-in-po.patch new file mode 100644 index 0000000..aae2b57 --- /dev/null +++ b/SOURCES/0234-features-posix-Avoid-double-free-of-a-variable-in-po.patch @@ -0,0 +1,149 @@ +From 6c524781cef0e6b00f4602da4ac7a4e03891997c Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Fri, 10 Jul 2015 23:12:28 +0530 +Subject: [PATCH 234/234] features/posix : Avoid double free of a variable in posix_setxattr() + +The buffer acl_xattr is introduced in posix_setxattr() as part of +http://review.gluster.org/#/c/11519/. This variable can be freed +twice in the code path , one in dict_unref() and another by explicit +GF_FREE() call in the code. This patch avoids the same. + +Backport of http://review.gluster.org/#/c/11627/ + +Upstream reference +>Change-Id: I31c6384e37ab8d8baaed7a53de668c2eb5d82338 +>BUG: 1242030 +>Signed-off-by: Jiffin Tony Thottan + +Change-Id: I4c4156575602a9a5c41a34cfc8f92e1e249538ea +BUG: 1241839 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/52816 +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + xlators/storage/posix/src/posix.c | 48 ++++++++++++++++++------------------ + 1 files changed, 24 insertions(+), 24 deletions(-) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 27c3457..58f68eb 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3322,10 +3322,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + * reduced into required size using GF_REALLO(). + */ + acl_xattr = GF_CALLOC (1, ACL_BUFFER_MAX, gf_posix_mt_char); +- if (!acl_xattr) { +- ret = -1; ++ if (!acl_xattr) + goto out; +- } + + acl_size = sys_lgetxattr (real_path, POSIX_ACL_ACCESS_XATTR, + acl_xattr, ACL_BUFFER_MAX); +@@ -3334,7 +3332,6 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_XATTR_FAILED, "Posix acl is not set " + "properly at the backend"); +- ret = -1; + goto out; + } + +@@ -3343,32 +3340,33 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + gf_msg (this->name, GF_LOG_WARNING, ENOMEM, + P_MSG_BUFFER_OVERFLOW, "size of acl is more" + "than the buffer"); +- ret = -1; + goto out; + } + + acl_xattr = GF_REALLOC (acl_xattr, acl_size); ++ if (!acl_xattr) ++ goto out; ++ + ret = dict_set_bin (xattr, POSIX_ACL_ACCESS_XATTR, + acl_xattr, acl_size); +- if (ret) { ++ if (ret) + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_SET_XDATA_FAIL, "failed to set" + "xdata for acl"); +- ret = -1; +- goto out; +- } +- } + +- GF_FREE (acl_xattr); +- acl_xattr = NULL; ++ /* ++ * dict_unref() will call GF_FREE() indirectly, so to avoid ++ * double freeing acl_xattr in out, just set it as NULL here ++ */ ++ acl_xattr = NULL; ++ } + + if (dict_get (dict, GF_POSIX_ACL_DEFAULT)) { + + acl_xattr = GF_CALLOC (1, ACL_BUFFER_MAX, gf_posix_mt_char); +- if (!acl_xattr) { +- ret = -1; ++ if (!acl_xattr) + goto out; +- } ++ + acl_size = sys_lgetxattr (real_path, POSIX_ACL_DEFAULT_XATTR, + acl_xattr, ACL_BUFFER_MAX); + +@@ -3376,7 +3374,6 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_XATTR_FAILED, "Posix acl is not set " + "properly at the backend"); +- ret = -1; + goto out; + } + +@@ -3384,20 +3381,25 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + gf_msg (this->name, GF_LOG_WARNING, ENOMEM, + P_MSG_BUFFER_OVERFLOW, "size of acl is more" + "than the buffer"); +- ret = -1; + goto out; + } + + acl_xattr = GF_REALLOC (acl_xattr, acl_size); ++ if (!acl_xattr) ++ goto out; ++ + ret = dict_set_bin (xattr, POSIX_ACL_DEFAULT_XATTR, + acl_xattr, acl_size); +- if (ret) { ++ if (ret) + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_SET_XDATA_FAIL, "failed to set" + "xdata for acl"); +- ret = -1; +- goto out; +- } ++ ++ /* ++ * dict_unref() will call GF_FREE() indirectly, so to avoid ++ * double freeing acl_xattr in out, just set it as NULL here ++ */ ++ acl_xattr = NULL; + } + out: + SET_TO_OLD_FS_ID (); +@@ -3406,9 +3408,7 @@ out: + + if (xattr) + dict_unref(xattr); +- +- if (acl_xattr) +- GF_FREE (acl_xattr); ++ GF_FREE (acl_xattr); + + return 0; + } +-- +1.7.1 + diff --git a/SOURCES/0235-cluster-ec-Propogate-correct-errno-in-case-of-failur.patch b/SOURCES/0235-cluster-ec-Propogate-correct-errno-in-case-of-failur.patch new file mode 100644 index 0000000..7affbeb --- /dev/null +++ b/SOURCES/0235-cluster-ec-Propogate-correct-errno-in-case-of-failur.patch @@ -0,0 +1,63 @@ +From 67b33479a3423ccff4b6ccf21636d8bd036f8dd6 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Sun, 12 Jul 2015 18:37:43 +0530 +Subject: [PATCH 235/244] cluster/ec: Propogate correct errno in case of failures + + Backport of http://review.gluster.com/11639 + +- Also remove internal-fop setting in create/mknod etc xattrs. + +Rebalance was failing because ec was giving EIO when lock acquiring fails as +the file/dir doesn't exist. Posix_create/mknod are not setting config xattr +because internal-fop key is present in dict and setxattr for this fails leading +to failure in setting rest of xattrs. + +Change-Id: Ifb429c8db9df7cd51e4f8ce53fdf1e1b975c9993 +BUG: 1240617 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52918 +--- + xlators/cluster/ec/src/ec-locks.c | 5 ++++- + xlators/storage/posix/src/posix-helpers.c | 3 +++ + 2 files changed, 7 insertions(+), 1 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c +index dd79514..9c41e11 100644 +--- a/xlators/cluster/ec/src/ec-locks.c ++++ b/xlators/cluster/ec/src/ec-locks.c +@@ -77,7 +77,10 @@ int32_t ec_lock_check(ec_fop_data_t *fop, uintptr_t *mask) + } + } + } else { +- error = EIO; ++ if (fop->answer && fop->answer->op_ret < 0) ++ error = fop->answer->op_errno; ++ else ++ error = EIO; + } + } + +diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c +index e2c5eb2..cae56e7 100644 +--- a/xlators/storage/posix/src/posix-helpers.c ++++ b/xlators/storage/posix/src/posix-helpers.c +@@ -69,6 +69,8 @@ static char* posix_ignore_xattrs[] = { + GLUSTERFS_POSIXLK_COUNT, + GLUSTERFS_PARENT_ENTRYLK, + GF_GFIDLESS_LOOKUP, ++ GLUSTERFS_INODELK_DOM_COUNT, ++ GLUSTERFS_INTERNAL_FOP_KEY, + NULL + }; + +@@ -1517,6 +1519,7 @@ _handle_entry_create_keyvalue_pair (dict_t *d, char *k, data_t *v, + !strcmp ("gfid-req", k) || + !strcmp (POSIX_ACL_DEFAULT_XATTR, k) || + !strcmp (POSIX_ACL_ACCESS_XATTR, k) || ++ posix_xattr_ignorable (k) || + ZR_FILE_CONTENT_REQUEST(k)) { + return 0; + } +-- +1.7.1 + diff --git a/SOURCES/0236-cluster-ec-Prevent-data-corruptions.patch b/SOURCES/0236-cluster-ec-Prevent-data-corruptions.patch new file mode 100644 index 0000000..69267d5 --- /dev/null +++ b/SOURCES/0236-cluster-ec-Prevent-data-corruptions.patch @@ -0,0 +1,187 @@ +From a06d455f2f3ad30e7aab2a6ac9594281dd1386c7 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Wed, 8 Jul 2015 17:52:11 +0530 +Subject: [PATCH 236/244] cluster/ec: Prevent data corruptions + + Backport of http://review.gluster.org/11580 + Backport of http://review.gluster.com/11640 + +- Don't read from bricks that are healing +- On lock reuse preserve 'healing' bits +- Don't set ctx->size outside locks in healing code +- Allow xattrop internal fops also on the fop->mask. + +Change-Id: I35503039e4723cf7f33d6797f0ba90dd0aca130b +BUG: 1230513 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/52663 +--- + xlators/cluster/ec/src/ec-common.c | 25 +++++++++++++++++++++---- + xlators/cluster/ec/src/ec-data.h | 1 + + xlators/cluster/ec/src/ec-heal.c | 22 +++++++++++----------- + xlators/cluster/ec/src/ec.c | 2 +- + 4 files changed, 34 insertions(+), 16 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 439773e..b2d0348 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -401,6 +401,18 @@ ec_must_wind (ec_fop_data_t *fop) + return _gf_false; + } + ++static gf_boolean_t ++ec_internal_op (ec_fop_data_t *fop) ++{ ++ if (ec_must_wind (fop)) ++ return _gf_true; ++ if (fop->id == GF_FOP_XATTROP) ++ return _gf_true; ++ if (fop->id == GF_FOP_FXATTROP) ++ return _gf_true; ++ return _gf_false; ++} ++ + int32_t ec_child_select(ec_fop_data_t * fop) + { + ec_t * ec = fop->xl->private; +@@ -413,8 +425,9 @@ int32_t ec_child_select(ec_fop_data_t * fop) + /* Wind the fop on same subvols as parent for any internal extra fops like + * head/tail read in case of writev fop. Unlocks shouldn't do this because + * unlock should go on all subvols where lock is performed*/ +- if (fop->parent && !ec_must_wind (fop)) +- fop->mask &= fop->parent->mask; ++ if (fop->parent && !ec_internal_op (fop)) { ++ fop->mask &= (fop->parent->mask & ~fop->parent->healing); ++ } + + mask = ec->xl_up; + if (fop->parent == NULL) +@@ -972,6 +985,7 @@ out: + parent->mask &= fop->good; + + /*As of now only data healing marks bricks as healing*/ ++ lock->healing |= fop->healing; + if (ec_is_data_fop (parent->id)) { + parent->healing |= fop->healing; + } +@@ -996,9 +1010,13 @@ void ec_get_size_version(ec_lock_link_t *link) + + lock = link->lock; + ctx = lock->ctx; ++ fop = link->fop; + + /* If ec metadata has already been retrieved, do not try again. */ + if (ctx->have_info) { ++ if (ec_is_data_fop (fop->id)) { ++ fop->healing |= lock->healing; ++ } + return; + } + +@@ -1008,8 +1026,6 @@ void ec_get_size_version(ec_lock_link_t *link) + return; + } + +- fop = link->fop; +- + uid = fop->frame->root->uid; + gid = fop->frame->root->gid; + +@@ -1274,6 +1290,7 @@ int32_t ec_locked(call_frame_t *frame, void *cookie, xlator_t *this, + link = fop->data; + lock = link->lock; + lock->mask = lock->good_mask = fop->good; ++ lock->healing = 0; + + ec_lock_acquired(link); + ec_lock(fop->parent); +diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h +index 135ccdf..ec470e9 100644 +--- a/xlators/cluster/ec/src/ec-data.h ++++ b/xlators/cluster/ec/src/ec-data.h +@@ -146,6 +146,7 @@ struct _ec_lock + the next unlock/lock cycle. */ + uintptr_t mask; + uintptr_t good_mask; ++ uintptr_t healing; + int32_t refs; + int32_t refs_frozen; + int32_t inserted; +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 6f82203..a7c97a5 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -256,10 +256,13 @@ int32_t ec_heal_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, + } + else + { +- gf_msg_debug (fop->xl->name, 0, "%s: read failed %s, failing " +- "to heal block at %"PRIu64, +- uuid_utoa (heal->fd->inode->gfid), strerror (op_errno), +- heal->offset); ++ if (op_ret < 0) { ++ gf_msg_debug (fop->xl->name, 0, "%s: read failed %s, failing " ++ "to heal block at %"PRIu64, ++ uuid_utoa (heal->fd->inode->gfid), strerror (op_errno), ++ heal->offset); ++ heal->bad = 0; ++ } + heal->done = 1; + } + +@@ -1709,10 +1712,7 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) + case EC_STATE_HEAL_DATA_UNLOCK: + ec_heal_inodelk(heal, F_UNLCK, 1, 0, 0); + +- if (state < 0) +- return -EC_STATE_REPORT; +- else +- return EC_STATE_REPORT; ++ return EC_STATE_REPORT; + + case EC_STATE_REPORT: + if (fop->cbks.heal) { +@@ -1728,7 +1728,7 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) + EIO, 0, 0, 0, NULL); + } + +- return -EC_STATE_END; ++ return EC_STATE_END; + default: + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", +@@ -1759,8 +1759,6 @@ ec_heal_block (call_frame_t *frame, xlator_t *this, uintptr_t target, + if (fop == NULL) + goto out; + +- GF_ASSERT(ec_set_inode_size(fop, heal->fd->inode, heal->total_size)); +- + error = 0; + + out: +@@ -1834,6 +1832,8 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, + break; + + } ++ memset (healed_sinks, 0, ec->nodes); ++ ec_mask_to_char_array (heal->bad, healed_sinks, ec->nodes); + fd_unref (heal->fd); + LOCK_DESTROY (&heal->lock); + syncbarrier_destroy (heal->data); +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index e28f402..4673c11 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -1303,7 +1303,7 @@ struct volume_options options[] = + .type = GF_OPTION_TYPE_INT, + .min = 0,/*Disabling background heals*/ + .max = 256, +- .default_value = "8", ++ .default_value = "0", + .description = "This option can be used to control number of parallel" + " heals", + }, +-- +1.7.1 + diff --git a/SOURCES/0237-rpc-transport-socket_poller-fixes-for-proper-working.patch b/SOURCES/0237-rpc-transport-socket_poller-fixes-for-proper-working.patch new file mode 100644 index 0000000..417e160 --- /dev/null +++ b/SOURCES/0237-rpc-transport-socket_poller-fixes-for-proper-working.patch @@ -0,0 +1,95 @@ +From 3974aeb48b7c4040c9c0b1839e1eed754d466328 Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Mon, 13 Jul 2015 16:16:00 +0530 +Subject: [PATCH 237/244] rpc-transport: socket_poller fixes for proper working of mgmt encryption + +socket_poller, the polling function used by ssl own_thread, had two +issues which lead to GlusterD crashes when using management encryption + +Issue 1 +------- +socket_poller calls functions which require THIS to be set. But, THIS +was being set conditionally. Because of this, functions could sometimes +be called without THIS being set. For example, rpc_transport_notify +could be called for an accepted client socket without THIS being set, as +THIS was only set it the transport wasn't yet connected. This would +cause the process to crash when THIS was accessed by the called +functions. + +To fix this, THIS is being set at the start of socket_poller +unconditionally. + +Issue 2 +------- +DISCONNECT notify was being sent on the listener transport instead of +the client transport. The DISCONNECT event was converted to a +LISTENER_DEAD event in rpcsvc_handle_disconnect, as it could not find +the listener socket of the listener socket. GlusterD was notified of a +LISTENER_DEAD event instead of a DISCONNECT and failed to remove the +client transport from its xprt_list. The transport would subsequently +be freed, leaving the xprt_list with a corrupted/invalid entry. Later, +when GlusterD would iterate over the xprt_list to send notifications, it +would crash when the invalid entry was accessed. + +To fix this, DISCONNECT notification in socket_poller is sent on the +client socket, as it is done in the epoll handler. + +Change-Id: I0370b7c6d7eb13de10ebf08d91a4a39dc7d64c7a +BUG: 1242367 +Reviewed-upstream-on: https://review.gluster.org/11650 +Signed-off-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/52909 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-transport/socket/src/socket.c | 13 ++++++++----- + 1 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c +index a39c16d..eef5bd2 100644 +--- a/rpc/rpc-transport/socket/src/socket.c ++++ b/rpc/rpc-transport/socket/src/socket.c +@@ -2427,6 +2427,12 @@ socket_poller (void *ctx) + uint32_t gen = 0; + char *cname = NULL; + ++ GF_ASSERT (this); ++ /* Set THIS early on in the life of this thread, instead of setting it ++ * conditionally ++ */ ++ THIS = this->xl; ++ + priv->ot_state = OT_RUNNING; + + if (priv->use_ssl) { +@@ -2455,7 +2461,6 @@ socket_poller (void *ctx) + } + + if (priv->connected == 0) { +- THIS = this->xl; + ret = socket_connect_finish (this); + if (ret != 0) { + gf_log (this->name, GF_LOG_WARNING, +@@ -2496,8 +2501,7 @@ socket_poller (void *ctx) + "poll error on pipe"); + break; + } +- /* Only glusterd actually seems to need this. */ +- THIS = this->xl; ++ + if (pfd[1].revents & POLL_MASK_INPUT) { + ret = socket_event_poll_in(this); + if (ret >= 0) { +@@ -2575,8 +2579,7 @@ err: + priv->sock = -1; + priv->ot_state = OT_IDLE; + pthread_mutex_unlock(&priv->lock); +- rpc_transport_notify (this->listener, RPC_TRANSPORT_DISCONNECT, +- this); ++ rpc_transport_notify (this, RPC_TRANSPORT_DISCONNECT, this); + rpc_transport_unref (this); + return NULL; + } +-- +1.7.1 + diff --git a/SOURCES/0238-glusterd-Fix-failure-in-replace-brick-when-src-brick.patch b/SOURCES/0238-glusterd-Fix-failure-in-replace-brick-when-src-brick.patch new file mode 100644 index 0000000..773a506 --- /dev/null +++ b/SOURCES/0238-glusterd-Fix-failure-in-replace-brick-when-src-brick.patch @@ -0,0 +1,149 @@ +From 3eccc2118df5add1ff319b3c0568c114f8e0172d Mon Sep 17 00:00:00 2001 +From: Anuradha Talur +Date: Mon, 13 Jul 2015 23:34:17 +0530 +Subject: [PATCH 238/244] glusterd: Fix failure in replace-brick when src-brick is offline + + Backport of: http://review.gluster.org/#/c/11656/ + +Change-Id: I0fdb58e15da15c40c3fc9767f2fe4df0ea9d2350 +BUG: 1242543 +Reviewed-on: http://review.gluster.org/11651 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Krishnan Parthasarathi +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/52938 +Tested-by: Krishnan Parthasarathi +--- + tests/bugs/glusterd/bug-1242543-replace-brick.t | 25 +++++++ + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 75 -------------------- + 2 files changed, 25 insertions(+), 75 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1242543-replace-brick.t + +diff --git a/tests/bugs/glusterd/bug-1242543-replace-brick.t b/tests/bugs/glusterd/bug-1242543-replace-brick.t +new file mode 100644 +index 0000000..0b1087f +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1242543-replace-brick.t +@@ -0,0 +1,25 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume start $V0 ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++# Replace brick1 without killing the brick ++TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++TEST kill_brick $V0 $H0 $B0/${V0}1_new ++ ++# Replace brick1 after killing the brick ++TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1_new $H0:$B0/${V0}1_newer commit force ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index a6120c8..8325508 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -550,76 +550,6 @@ rb_kill_destination_brick (glusterd_volinfo_t *volinfo, + return glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_true); + } + +-/* Set src-brick's port number to be used in the maintenance mount +- * after all commit acks are received. +- */ +-static int +-rb_update_srcbrick_port (glusterd_volinfo_t *volinfo, +- glusterd_brickinfo_t *src_brickinfo, +- dict_t *rsp_dict, dict_t *req_dict, char *replace_op) +-{ +- xlator_t *this = NULL; +- int ret = 0; +- int dict_ret = 0; +- int src_port = 0; +- char brickname[PATH_MAX] = {0,}; +- +- this = THIS; +- GF_ASSERT (this); +- +- dict_ret = dict_get_int32 (req_dict, "src-brick-port", &src_port); +- if (src_port) +- src_brickinfo->port = src_port; +- +- if (gf_is_local_addr (src_brickinfo->hostname)) { +- gf_msg (this->name, GF_LOG_INFO, 0, +- GD_MSG_BRK_PORT_NO_ADD_INDO, +- "adding src-brick port no"); +- +- if (volinfo->transport_type == GF_TRANSPORT_RDMA) { +- snprintf (brickname, sizeof(brickname), "%s.rdma", +- src_brickinfo->path); +- } else +- snprintf (brickname, sizeof(brickname), "%s", +- src_brickinfo->path); +- +- src_brickinfo->port = pmap_registry_search (this, +- brickname, GF_PMAP_PORT_BRICKSERVER); +- if (!src_brickinfo->port) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SRC_BRICK_PORT_UNAVAIL, +- "Src brick port not available"); +- ret = -1; +- goto out; +- } +- +- if (rsp_dict) { +- ret = dict_set_int32 (rsp_dict, "src-brick-port", +- src_brickinfo->port); +- if (ret) { +- gf_msg_debug (this->name, 0, +- "Could not set src-brick port no"); +- goto out; +- } +- } +- +- if (req_dict) { +- ret = dict_set_int32 (req_dict, "src-brick-port", +- src_brickinfo->port); +- if (ret) { +- gf_msg_debug (this->name, 0, +- "Could not set src-brick port no"); +- goto out; +- } +- } +- +- } +- +-out: +- return ret; +- +-} +- + static int + rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict, + dict_t *req_dict, char *replace_op) +@@ -834,11 +764,6 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict) + goto out; + } + +- ret = rb_update_srcbrick_port (volinfo, src_brickinfo, rsp_dict, +- dict, replace_op); +- if (ret) +- goto out; +- + ret = rb_update_dstbrick_port (dst_brickinfo, rsp_dict, + dict, replace_op); + if (ret) +-- +1.7.1 + diff --git a/SOURCES/0239-quota-marker-fix-mem-leak-in-marker.patch b/SOURCES/0239-quota-marker-fix-mem-leak-in-marker.patch new file mode 100644 index 0000000..4d2bdc7 --- /dev/null +++ b/SOURCES/0239-quota-marker-fix-mem-leak-in-marker.patch @@ -0,0 +1,332 @@ +From 732680245cf72caa23b3f66da0960920d5c7027e Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Sun, 12 Jul 2015 21:03:54 +0530 +Subject: [PATCH 239/244] quota/marker: fix mem-leak in marker + +This is a backport of http://review.gluster.org/#/c/11617/ + +Free local in error paths + +> Change-Id: I76f69e7d746af8eedea34354ff5a6bf50234e50e +> BUG: 1207735 +> Signed-off-by: vmallika + +Change-Id: Ic2d3aefe2e090ecfad87747a90c7d95eff968d42 +BUG: 1224177 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/52779 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker.c | 81 +++++++++++++-------------------- + xlators/features/marker/src/marker.h | 12 +++++ + 2 files changed, 44 insertions(+), 49 deletions(-) + +diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c +index db6943c..ba599da 100644 +--- a/xlators/features/marker/src/marker.c ++++ b/xlators/features/marker/src/marker.c +@@ -343,10 +343,6 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) + { +- marker_local_t *local = NULL; +- local = frame->local; +- +- + if (cookie) { + gf_log (this->name, GF_LOG_DEBUG, + "Filtering the quota extended attributes"); +@@ -372,9 +368,7 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + marker_filter_internal_xattrs (frame->this, dict); + } + +- frame->local = NULL; +- STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, xdata); +- marker_local_unref (local); ++ MARKER_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata); + return 0; + } + +@@ -422,9 +416,7 @@ marker_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + + return 0; + out: +- frame->local = NULL; +- STACK_UNWIND_STRICT (getxattr, frame, -1, ENOMEM, NULL, NULL); +- marker_local_unref (local); ++ MARKER_STACK_UNWIND (getxattr, frame, -1, ENOMEM, NULL, NULL); + return 0; + } + +@@ -661,8 +653,9 @@ wind: + + return 0; + err: +- STACK_UNWIND_STRICT (mkdir, frame, -1, ENOMEM, NULL, ++ MARKER_STACK_UNWIND (mkdir, frame, -1, ENOMEM, NULL, + NULL, NULL, NULL, NULL); ++ + return 0; + } + +@@ -735,7 +728,7 @@ wind: + fd, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, ++ MARKER_STACK_UNWIND (create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, + NULL, NULL); + + return 0; +@@ -811,7 +804,7 @@ wind: + flags, iobref, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (writev, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -879,7 +872,7 @@ wind: + FIRST_CHILD(this)->fops->rmdir, loc, flags, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (rmdir, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (rmdir, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -958,9 +951,7 @@ unlink_wind: + FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata); + return 0; + err: +- frame->local = NULL; +- STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, NULL, NULL, NULL); +- marker_local_unref (local); ++ MARKER_STACK_UNWIND (unlink, frame, -1, ENOMEM, NULL, NULL, NULL); + return 0; + } + +@@ -1034,7 +1025,7 @@ wind: + FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, ++ MARKER_STACK_UNWIND (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, + NULL); + + return 0; +@@ -1616,8 +1607,9 @@ rename_wind: + + return 0; + err: +- STACK_UNWIND_STRICT (rename, frame, -1, ENOMEM, NULL, ++ MARKER_STACK_UNWIND (rename, frame, -1, ENOMEM, NULL, + NULL, NULL, NULL, NULL, NULL); ++ marker_local_unref (oplocal); + + return 0; + } +@@ -1686,7 +1678,7 @@ wind: + FIRST_CHILD(this)->fops->truncate, loc, offset, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (truncate, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (truncate, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -1754,7 +1746,7 @@ wind: + FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -1828,8 +1820,9 @@ wind: + xdata); + return 0; + err: +- STACK_UNWIND_STRICT (symlink, frame, -1, ENOMEM, NULL, ++ MARKER_STACK_UNWIND (symlink, frame, -1, ENOMEM, NULL, + NULL, NULL, NULL, NULL); ++ + return 0; + } + +@@ -1904,8 +1897,9 @@ wind: + xdata); + return 0; + err: +- STACK_UNWIND_STRICT (mknod, frame, -1, ENOMEM, NULL, ++ MARKER_STACK_UNWIND (mknod, frame, -1, ENOMEM, NULL, + NULL, NULL, NULL, NULL); ++ + return 0; + } + +@@ -1973,7 +1967,7 @@ wind: + xdata); + return 0; + err: +- STACK_UNWIND_STRICT (fallocate, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (fallocate, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -2041,7 +2035,7 @@ wind: + FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (discard, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (discard, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -2108,7 +2102,7 @@ wind: + FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (zerofill, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (zerofill, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -2229,16 +2223,11 @@ quota_xattr_cleaner_cbk (int ret, call_frame_t *frame, void *args) + dict_t *xdata = args; + int op_ret = -1; + int op_errno = 0; +- marker_local_t *local = NULL; +- +- local = frame->local; +- frame->local = NULL; + + op_ret = (ret < 0)? -1: 0; + op_errno = -ret; + +- STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xdata); +- marker_local_unref (local); ++ MARKER_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata); + return ret; + } + +@@ -2312,11 +2301,9 @@ marker_do_xattr_cleanup (call_frame_t *frame, xlator_t *this, dict_t *xdata, + + ret = 0; + out: +- if (ret) { +- frame->local = NULL; +- STACK_UNWIND_STRICT (setxattr, frame, -1, ENOMEM, xdata); +- marker_local_unref (local); +- } ++ if (ret) ++ MARKER_STACK_UNWIND (setxattr, frame, -1, ENOMEM, xdata); ++ + return ret; + } + +@@ -2371,7 +2358,7 @@ wind: + FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (setxattr, frame, -1, op_errno, NULL); ++ MARKER_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + + return 0; + } +@@ -2438,7 +2425,7 @@ wind: + FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (fsetxattr, frame, -1, ENOMEM, NULL); ++ MARKER_STACK_UNWIND (fsetxattr, frame, -1, ENOMEM, NULL); + + return 0; + } +@@ -2504,7 +2491,7 @@ wind: + FIRST_CHILD (this)->fops->fsetattr, fd, stbuf, valid, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -2571,7 +2558,7 @@ wind: + FIRST_CHILD (this)->fops->setattr, loc, stbuf, valid, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (setattr, frame, -1, ENOMEM, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (setattr, frame, -1, ENOMEM, NULL, NULL, NULL); + + return 0; + } +@@ -2636,7 +2623,7 @@ wind: + FIRST_CHILD(this)->fops->removexattr, loc, name, xdata); + return 0; + err: +- STACK_UNWIND_STRICT (removexattr, frame, -1, ENOMEM, NULL); ++ MARKER_STACK_UNWIND (removexattr, frame, -1, ENOMEM, NULL); + + return 0; + } +@@ -2746,7 +2733,7 @@ wind: + + return 0; + err: +- STACK_UNWIND_STRICT (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL); ++ MARKER_STACK_UNWIND (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL); + + if (xattr_req) + dict_unref (xattr_req); +@@ -2858,11 +2845,7 @@ marker_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + unwind: +- local = frame->local; +- frame->local = NULL; +- +- STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata); +- marker_local_unref (local); ++ MARKER_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata); + + return 0; + } +@@ -2906,7 +2889,7 @@ marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + dict_unref (dict); + return 0; + unwind: +- STACK_UNWIND_STRICT (readdirp, frame, -1, ENOMEM, NULL, NULL); ++ MARKER_STACK_UNWIND (readdirp, frame, -1, ENOMEM, NULL, NULL); + return 0; + } + +diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h +index aadd877..f198859 100644 +--- a/xlators/features/marker/src/marker.h ++++ b/xlators/features/marker/src/marker.h +@@ -80,6 +80,18 @@ enum { + frame->cookie = NULL; \ + } while (0) + ++#define MARKER_STACK_UNWIND(fop, frame, params...) \ ++ do { \ ++ quota_local_t *_local = NULL; \ ++ if (frame) { \ ++ _local = frame->local; \ ++ frame->local = NULL; \ ++ } \ ++ STACK_UNWIND_STRICT (fop, frame, params); \ ++ if (_local) \ ++ marker_local_unref (_local); \ ++ } while (0) ++ + struct marker_local{ + uint32_t timebuf[2]; + pid_t pid; +-- +1.7.1 + diff --git a/SOURCES/0240-features-bitrot-move-inode-state-just-at-the-last-mo.patch b/SOURCES/0240-features-bitrot-move-inode-state-just-at-the-last-mo.patch new file mode 100644 index 0000000..2800542 --- /dev/null +++ b/SOURCES/0240-features-bitrot-move-inode-state-just-at-the-last-mo.patch @@ -0,0 +1,145 @@ +From c5ec2f7b76ce128c93413ab260c7bb7b59027219 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Tue, 30 Jun 2015 13:10:46 +0530 +Subject: [PATCH 240/244] features/bitrot: move inode state just at the last moment + + Backport of http://review.gluster.org/11461 + +Which was done at half the set expiry time resulting in actual +IOs incrementing the object version. Now this is done just at +the last moment with re-notification now cut-shorting into +checksum calculation without waiting in the timer-wheel. + +BUG: 1242585 +Change-Id: If655b77d822ebf7b2a4f65e1b5583dd3609306e7 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/52926 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/bit-rot.c | 61 ++++++++++++++++++-------- + 1 files changed, 42 insertions(+), 19 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c +index 94063cb..4a050c8 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot.c +@@ -594,15 +594,12 @@ static inline int32_t br_sign_object (br_object_t *object) + goto out; + } + +- /* sanity check */ +- sign_info = ntohl (object->sign_info); +- GF_ASSERT (sign_info != BR_SIGN_NORMAL); +- + /** + * For fd's that have notified for reopening, we send an explicit + * open() followed by a dummy write() call. This triggers the + * actual signing of the object. + */ ++ sign_info = ntohl (object->sign_info); + if (sign_info == BR_SIGN_REOPEN_WAIT) { + br_object_resign (this, object, linked_inode); + goto unref_inode; +@@ -722,7 +719,8 @@ br_add_object_to_queue (struct gf_tw_timer_list *timer, + } + pthread_mutex_unlock (&priv->lock); + +- mem_put (timer); ++ if (timer) ++ mem_put (timer); + return; + } + +@@ -762,7 +760,7 @@ br_initialize_timer (xlator_t *this, br_object_t *object, br_child_t *child, + goto out; + INIT_LIST_HEAD (&timer->entry); + +- timer->expires = (priv->expiry_time >> 1); ++ timer->expires = priv->expiry_time; + if (!timer->expires) + timer->expires = 1; + +@@ -774,6 +772,27 @@ out: + return timer; + } + ++static int32_t ++br_schedule_object_reopen (xlator_t *this, br_object_t *object, ++ br_child_t *child, changelog_event_t *ev) ++{ ++ struct gf_tw_timer_list *timer = NULL; ++ ++ timer = br_initialize_timer (this, object, child, ev); ++ if (!timer) ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, ++ "Failed to allocate object expiry timer [GFID: %s]", ++ uuid_utoa (object->gfid)); ++ return timer ? 0 : -1; ++} ++ ++static int32_t ++br_object_quicksign (xlator_t *this, br_object_t *object) ++{ ++ br_add_object_to_queue (NULL, object, 0ULL); ++ return 0; ++} ++ + /** + * This callback function registered with the changelog is executed + * whenever a notification from the changelog is received. This should +@@ -787,11 +806,12 @@ void + br_brick_callback (void *xl, char *brick, + void *data, changelog_event_t *ev) + { +- uuid_t gfid = {0,}; +- xlator_t *this = NULL; +- br_object_t *object = NULL; +- br_child_t *child = NULL; +- struct gf_tw_timer_list *timer = NULL; ++ int32_t ret = 0; ++ uuid_t gfid = {0,}; ++ xlator_t *this = NULL; ++ br_object_t *object = NULL; ++ br_child_t *child = NULL; ++ br_sign_state_t sign_info = BR_SIGN_INVALID; + + this = xl; + +@@ -822,22 +842,25 @@ br_brick_callback (void *xl, char *brick, + goto out; + } + +- timer = br_initialize_timer (this, object, child, ev); +- if (!timer) { +- gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, +- "failed to allocate object expiry timer [GFID: %s]", +- uuid_utoa (gfid)); ++ /* sanity check */ ++ sign_info = ntohl (object->sign_info); ++ GF_ASSERT (sign_info != BR_SIGN_NORMAL); ++ ++ if (sign_info == BR_SIGN_REOPEN_WAIT) ++ ret = br_schedule_object_reopen (this, object, child, ev); ++ else ++ ret = br_object_quicksign (this, object); ++ ++ if (ret) + goto free_object; +- } + + gf_msg_debug (this->name, 0, "->callback: brick [%s], type [%d]\n", + brick, ev->ev_type); +- + return; + + free_object: + GF_FREE (object); +-out: ++ out: + return; + } + +-- +1.7.1 + diff --git a/SOURCES/0241-features-bitrot-throttle-signer.patch b/SOURCES/0241-features-bitrot-throttle-signer.patch new file mode 100644 index 0000000..2adfde5 --- /dev/null +++ b/SOURCES/0241-features-bitrot-throttle-signer.patch @@ -0,0 +1,40 @@ +From f288faff1ddfbcaff9b37740ee7bb61c91166b66 Mon Sep 17 00:00:00 2001 +From: Venky Shankar +Date: Mon, 13 Jul 2015 11:59:33 +0530 +Subject: [PATCH 241/244] features/bitrot: throttle signer + + Backport of http://review.gluster.org/11641/ + +Pass -DDBR_RATE_LIMIT_SIGNER CFLAGS to enable fixed value throttling +based on TBF to rate limit signer. The following messags is dumped +in bitd log file that this change introduces. + +[ + [Rate Limit Info] "tokens/sec (rate): 131072, maxlimit: 524288" +] + +Bug: 1242585 +Change-Id: I063e41d4c7bcddd7a940cc175e89536cd4fe2804 +Signed-off-by: Venky Shankar +Reviewed-on: https://code.engineering.redhat.com/gerrit/52934 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/Makefile.am | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/Makefile.am b/xlators/features/bit-rot/src/bitd/Makefile.am +index 154cdfb..f06cf9e 100644 +--- a/xlators/features/bit-rot/src/bitd/Makefile.am ++++ b/xlators/features/bit-rot/src/bitd/Makefile.am +@@ -15,6 +15,6 @@ bit_rot_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + + noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h bit-rot-bitd-messages.h bit-rot-ssm.h + +-AM_CFLAGS = -Wall $(GF_CFLAGS) ++AM_CFLAGS = -Wall -DBR_RATE_LIMIT_SIGNER $(GF_CFLAGS) + + CLEANFILES = +-- +1.7.1 + diff --git a/SOURCES/0242-extras-hooks-Fix-parsing-of-args-in-S30samba-set.sh.patch b/SOURCES/0242-extras-hooks-Fix-parsing-of-args-in-S30samba-set.sh.patch new file mode 100644 index 0000000..3ec8b51 --- /dev/null +++ b/SOURCES/0242-extras-hooks-Fix-parsing-of-args-in-S30samba-set.sh.patch @@ -0,0 +1,65 @@ +From 207b9db5123f4c1aaaf533ddaff907a305cfc903 Mon Sep 17 00:00:00 2001 +From: Raghavendra Talur +Date: Tue, 14 Jul 2015 23:24:55 +0530 +Subject: [PATCH 242/244] extras/hooks: Fix parsing of args in S30samba-set.sh + + Backport of http://review.gluster.org/#/c/11668/ + +Change-Id: I75756f44757a144b0ed229fcc0e29a273fc75886 +BUG: 1242767 +Signed-off-by: Raghavendra Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/52988 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + extras/hook-scripts/set/post/S30samba-set.sh | 18 +++++++++++------- + 1 files changed, 11 insertions(+), 7 deletions(-) + +diff --git a/extras/hook-scripts/set/post/S30samba-set.sh b/extras/hook-scripts/set/post/S30samba-set.sh +index b8c5acf..277b7b0 100755 +--- a/extras/hook-scripts/set/post/S30samba-set.sh ++++ b/extras/hook-scripts/set/post/S30samba-set.sh +@@ -28,7 +28,7 @@ USERSMB_SET="" + USERCIFS_SET="" + + function parse_args () { +- ARGS=$(getopt -l $OPTSPEC -o "o" -name $PROGNAME $@) ++ ARGS=$(getopt -l $OPTSPEC --name $PROGNAME -o "o:" -- $@) + eval set -- "$ARGS" + + while true; do +@@ -41,10 +41,13 @@ function parse_args () { + shift + GLUSTERD_WORKDIR=$1 + ;; +- *) ++ --) + shift +- for pair in $@; do +- read key value < <(echo "$pair" | tr "=" " ") ++ break ++ ;; ++ -o) ++ shift ++ read key value < <(echo "$1" | tr "=" " ") + case "$key" in + "user.cifs") + USERCIFS_SET="YES" +@@ -55,10 +58,11 @@ function parse_args () { + *) + ;; + esac +- done +- shift +- break + ;; ++ *) ++ shift ++ break ++ ;; + esac + shift + done +-- +1.7.1 + diff --git a/SOURCES/0243-timer-fix-race-between-gf_timer_call_cancel-and-gf_t.patch b/SOURCES/0243-timer-fix-race-between-gf_timer_call_cancel-and-gf_t.patch new file mode 100644 index 0000000..4b42d10 --- /dev/null +++ b/SOURCES/0243-timer-fix-race-between-gf_timer_call_cancel-and-gf_t.patch @@ -0,0 +1,151 @@ +From 9b237463a8f5c75cff66364d07278217f8e4e586 Mon Sep 17 00:00:00 2001 +From: Anand Avati +Date: Fri, 6 Dec 2013 17:31:57 -0800 +Subject: [PATCH 243/244] timer: fix race between gf_timer_call_cancel() and gf_timer_proc() + + Backport of http://review.gluster.org/6459 + +Change-Id: Ie264d3d591352e4a8ddaa90ae2174d9c552396f1 +BUG: 1242423 +Signed-off-by: Anand Avati +Reviewed-on: https://code.engineering.redhat.com/gerrit/53060 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + libglusterfs/src/timer.c | 53 ++++++++++++++------------------------------- + libglusterfs/src/timer.h | 2 +- + 2 files changed, 18 insertions(+), 37 deletions(-) + +diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c +index 8344c9b..a4d1890 100644 +--- a/libglusterfs/src/timer.c ++++ b/libglusterfs/src/timer.c +@@ -85,31 +85,11 @@ gf_timer_call_after (glusterfs_ctx_t *ctx, + } + + int32_t +-gf_timer_call_stale (gf_timer_registry_t *reg, +- gf_timer_t *event) +-{ +- if (reg == NULL || event == NULL) +- { +- gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, +- LG_MSG_INVALID_ARG, "invalid argument"); +- return 0; +- } +- +- event->next->prev = event->prev; +- event->prev->next = event->next; +- event->next = ®->stale; +- event->prev = event->next->prev; +- event->next->prev = event; +- event->prev->next = event; +- +- return 0; +-} +- +-int32_t + gf_timer_call_cancel (glusterfs_ctx_t *ctx, + gf_timer_t *event) + { + gf_timer_registry_t *reg = NULL; ++ gf_boolean_t fired = _gf_false; + + if (ctx == NULL || event == NULL) + { +@@ -128,13 +108,21 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx, + + pthread_mutex_lock (®->lock); + { ++ fired = event->fired; ++ if (fired) ++ goto unlock; ++ + event->next->prev = event->prev; + event->prev->next = event->next; + } ++unlock: + pthread_mutex_unlock (®->lock); + +- GF_FREE (event); +- return 0; ++ if (!fired) { ++ GF_FREE (event); ++ return 0; ++ } ++ return -1; + } + + static inline void __delete_entry (gf_timer_t *event) { +@@ -181,7 +169,9 @@ gf_timer_proc (void *ctx) + at = TS (event->at); + if (event != ®->active && now >= at) { + need_cbk = 1; +- gf_timer_call_stale (reg, event); ++ event->next->prev = event->prev; ++ event->prev->next = event->next; ++ event->fired = 1; + } + } + pthread_mutex_unlock (®->lock); +@@ -192,15 +182,13 @@ gf_timer_proc (void *ctx) + THIS = event->xl; + } + event->callbk (event->data); +- /*This callbk above would have freed the event +- * by calling timer_cancel, don't ever touch it +- * again*/ ++ GF_FREE (event); + if (old_THIS) { + THIS = old_THIS; + } +- } +- else ++ } else { + break; ++ } + } + nanosleep (&sleepts, NULL); + } +@@ -216,11 +204,6 @@ gf_timer_proc (void *ctx) + * list_head*/ + __delete_entry (event); + } +- +- while (reg->stale.next != ®->stale) { +- event = reg->stale.next; +- __delete_entry (event); +- } + } + pthread_mutex_unlock (®->lock); + pthread_mutex_destroy (®->lock); +@@ -249,8 +232,6 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx) + pthread_mutex_init (®->lock, NULL); + reg->active.next = ®->active; + reg->active.prev = ®->active; +- reg->stale.next = ®->stale; +- reg->stale.prev = ®->stale; + + ctx->timer = reg; + gf_thread_create (®->th, NULL, gf_timer_proc, ctx); +diff --git a/libglusterfs/src/timer.h b/libglusterfs/src/timer.h +index e64b350..35d99be 100644 +--- a/libglusterfs/src/timer.h ++++ b/libglusterfs/src/timer.h +@@ -29,12 +29,12 @@ struct _gf_timer { + gf_timer_cbk_t callbk; + void *data; + xlator_t *xl; ++ gf_boolean_t fired; + }; + + struct _gf_timer_registry { + pthread_t th; + char fin; +- struct _gf_timer stale; + struct _gf_timer active; + pthread_mutex_t lock; + }; +-- +1.7.1 + diff --git a/SOURCES/0244-cluster-ec-Handle-race-between-unlock-timer-new-lock.patch b/SOURCES/0244-cluster-ec-Handle-race-between-unlock-timer-new-lock.patch new file mode 100644 index 0000000..7333568 --- /dev/null +++ b/SOURCES/0244-cluster-ec-Handle-race-between-unlock-timer-new-lock.patch @@ -0,0 +1,151 @@ +From f0e823dfc224c9c3c7a1179453ef6fe087171787 Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Wed, 15 Jul 2015 06:16:54 +0530 +Subject: [PATCH 244/244] cluster/ec: Handle race between unlock-timer, new lock + + Backport of http://review.gluster.org/11670 + +Problem: +New lock could come at the time timer is on the way to unlock. This was leading +to crash in timer thread because thread executing new lock can free up the +timer_link->fop and then timer thread will try to access structures already +freed. + +Fix: +If the timer event is fired, set lock->release to true and wait for unlock to +complete. + +Thanks to Xavi and Bhaskar for helping in confirming that this race is the RC. +Thanks to Kritika for pointing out and explaining how Avati's patch can be used +to fix this bug. + +Change-Id: I45fa5470bbc1f03b5f3d133e26d1e0ab24303378 +BUG: 1242423 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/53061 +--- + xlators/cluster/ec/src/ec-common.c | 33 ++++++++++++++------------------- + xlators/cluster/ec/src/ec-common.h | 1 - + xlators/cluster/ec/src/ec.c | 33 +++------------------------------ + 3 files changed, 17 insertions(+), 50 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index b2d0348..ec6a4aa 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -1358,13 +1358,20 @@ void ec_lock(ec_fop_data_t *fop) + if (lock->timer != NULL) { + GF_ASSERT (lock->release == _gf_false); + timer_link = lock->timer->data; +- ec_trace("UNLOCK_CANCELLED", timer_link->fop, "lock=%p", lock); +- gf_timer_call_cancel(fop->xl->ctx, lock->timer); +- lock->timer = NULL; +- +- lock->refs--; +- /* There should remain at least 1 ref, the current one. */ +- GF_ASSERT(lock->refs > 0); ++ if (gf_timer_call_cancel(fop->xl->ctx, lock->timer) == 0) { ++ ec_trace("UNLOCK_CANCELLED", timer_link->fop, ++ "lock=%p", lock); ++ lock->timer = NULL; ++ lock->refs--; ++ /* There should remain at least 1 ref, the current one. */ ++ GF_ASSERT(lock->refs > 0); ++ } else { ++ /* Timer expired and on the way to unlock. ++ * Set lock->release to _gf_true, so that this ++ * lock will be put in frozen list*/ ++ timer_link = NULL; ++ lock->release = _gf_true; ++ } + } + + GF_ASSERT(list_empty(&link->wait_list)); +@@ -1815,18 +1822,6 @@ void ec_unlock(ec_fop_data_t *fop) + } + } + +-void +-ec_unlock_force(ec_fop_data_t *fop) +-{ +- int32_t i; +- +- for (i = 0; i < fop->lock_count; i++) { +- ec_trace("UNLOCK_FORCED", fop, "lock=%p", &fop->locks[i]); +- +- ec_unlock_timer_del(&fop->locks[i]); +- } +-} +- + void ec_flush_size_version(ec_fop_data_t *fop) + { + GF_ASSERT(fop->lock_count == 1); +diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h +index 4c7fe0c..a851fb3 100644 +--- a/xlators/cluster/ec/src/ec-common.h ++++ b/xlators/cluster/ec/src/ec-common.h +@@ -91,7 +91,6 @@ void ec_lock_prepare_fd(ec_fop_data_t *fop, fd_t *fd, uint32_t flags); + void ec_lock(ec_fop_data_t * fop); + void ec_lock_reuse(ec_fop_data_t *fop); + void ec_unlock(ec_fop_data_t * fop); +-void ec_unlock_force(ec_fop_data_t *fop); + + gf_boolean_t ec_get_inode_size(ec_fop_data_t *fop, inode_t *inode, + uint64_t *size); +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index 4673c11..2885b01 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -395,38 +395,11 @@ ec_handle_down (xlator_t *this, ec_t *ec, int32_t idx) + } + + gf_boolean_t +-ec_force_unlocks(ec_t *ec) ++ec_disable_delays(ec_t *ec) + { +- struct list_head list; +- ec_fop_data_t *fop; +- +- if (list_empty(&ec->pending_fops)) { +- return _gf_true; +- } +- +- INIT_LIST_HEAD(&list); +- +- /* All pending fops when GF_EVENT_PARENT_DOWN is received should only +- * be fops waiting for a delayed unlock. However the unlock can +- * generate new fops. We don't want to trverse these new fops while +- * forcing unlocks, so we move all fops to a temporal list. To process +- * them without interferences.*/ +- list_splice_init(&ec->pending_fops, &list); +- +- while (!list_empty(&list)) { +- fop = list_entry(list.next, ec_fop_data_t, pending_list); +- list_move_tail(&fop->pending_list, &ec->pending_fops); +- +- UNLOCK(&ec->lock); +- +- ec_unlock_force(fop); +- +- LOCK(&ec->lock); +- } +- + ec->shutdown = _gf_true; + +- return list_empty(&ec->pending_fops); ++ return list_empty (&ec->pending_fops); + } + + void +@@ -482,7 +455,7 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2) + } else if (event == GF_EVENT_PARENT_DOWN) { + /* If there aren't pending fops running after we have waken up + * them, we immediately propagate the notification. */ +- propagate = ec_force_unlocks(ec); ++ propagate = ec_disable_delays(ec); + goto unlock; + } + +-- +1.7.1 + diff --git a/SOURCES/0245-Revert-timer-fix-race-between-gf_timer_call_cancel-a.patch b/SOURCES/0245-Revert-timer-fix-race-between-gf_timer_call_cancel-a.patch new file mode 100644 index 0000000..3da3453 --- /dev/null +++ b/SOURCES/0245-Revert-timer-fix-race-between-gf_timer_call_cancel-a.patch @@ -0,0 +1,142 @@ +From 92952a767ffe126e1dfa548be003ce2b0461065e Mon Sep 17 00:00:00 2001 +From: Pranith Kumar K +Date: Sat, 18 Jul 2015 10:04:13 +0530 +Subject: [PATCH 245/245] Revert "timer: fix race between gf_timer_call_cancel() and gf_timer_proc()" + +This reverts commit 9b237463a8f5c75cff66364d07278217f8e4e586. + +BUG: 1244187 +Change-Id: Ibb6c04ab6167071e62c7a33e114b3dd5931825c8 +Signed-off-by: Pranith Kumar K +Reviewed-on: https://code.engineering.redhat.com/gerrit/53266 +Reviewed-by: Krishnan Parthasarathi +Reviewed-by: Kaushal Madappa +--- + libglusterfs/src/timer.c | 48 +++++++++++++++++++++++++++++++-------------- + libglusterfs/src/timer.h | 2 +- + 2 files changed, 34 insertions(+), 16 deletions(-) + +diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c +index a4d1890..e103f05 100644 +--- a/libglusterfs/src/timer.c ++++ b/libglusterfs/src/timer.c +@@ -85,11 +85,30 @@ gf_timer_call_after (glusterfs_ctx_t *ctx, + } + + int32_t ++gf_timer_call_stale (gf_timer_registry_t *reg, ++ gf_timer_t *event) ++{ ++ if (reg == NULL || event == NULL) { ++ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL, ++ LG_MSG_INVALID_ARG, "invalid argument"); ++ return 0; ++ } ++ ++ event->next->prev = event->prev; ++ event->prev->next = event->next; ++ event->next = ®->stale; ++ event->prev = event->next->prev; ++ event->next->prev = event; ++ event->prev->next = event; ++ ++ return 0; ++} ++ ++int32_t + gf_timer_call_cancel (glusterfs_ctx_t *ctx, + gf_timer_t *event) + { + gf_timer_registry_t *reg = NULL; +- gf_boolean_t fired = _gf_false; + + if (ctx == NULL || event == NULL) + { +@@ -108,21 +127,13 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx, + + pthread_mutex_lock (®->lock); + { +- fired = event->fired; +- if (fired) +- goto unlock; +- + event->next->prev = event->prev; + event->prev->next = event->next; + } +-unlock: + pthread_mutex_unlock (®->lock); + +- if (!fired) { +- GF_FREE (event); +- return 0; +- } +- return -1; ++ GF_FREE (event); ++ return 0; + } + + static inline void __delete_entry (gf_timer_t *event) { +@@ -169,9 +180,7 @@ gf_timer_proc (void *ctx) + at = TS (event->at); + if (event != ®->active && now >= at) { + need_cbk = 1; +- event->next->prev = event->prev; +- event->prev->next = event->next; +- event->fired = 1; ++ gf_timer_call_stale (reg, event); + } + } + pthread_mutex_unlock (®->lock); +@@ -182,7 +191,9 @@ gf_timer_proc (void *ctx) + THIS = event->xl; + } + event->callbk (event->data); +- GF_FREE (event); ++ /*This callbk above would have freed the event ++ * by calling timer_cancel, don't ever touch it ++ * again*/ + if (old_THIS) { + THIS = old_THIS; + } +@@ -204,6 +215,11 @@ gf_timer_proc (void *ctx) + * list_head*/ + __delete_entry (event); + } ++ ++ while (reg->stale.next != ®->stale) { ++ event = reg->stale.next; ++ __delete_entry (event); ++ } + } + pthread_mutex_unlock (®->lock); + pthread_mutex_destroy (®->lock); +@@ -232,6 +248,8 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx) + pthread_mutex_init (®->lock, NULL); + reg->active.next = ®->active; + reg->active.prev = ®->active; ++ reg->stale.next = ®->stale; ++ reg->stale.prev = ®->stale; + + ctx->timer = reg; + gf_thread_create (®->th, NULL, gf_timer_proc, ctx); +diff --git a/libglusterfs/src/timer.h b/libglusterfs/src/timer.h +index 35d99be..e64b350 100644 +--- a/libglusterfs/src/timer.h ++++ b/libglusterfs/src/timer.h +@@ -29,12 +29,12 @@ struct _gf_timer { + gf_timer_cbk_t callbk; + void *data; + xlator_t *xl; +- gf_boolean_t fired; + }; + + struct _gf_timer_registry { + pthread_t th; + char fin; ++ struct _gf_timer stale; + struct _gf_timer active; + pthread_mutex_t lock; + }; +-- +1.7.1 + diff --git a/SOURCES/0246-glusterd-Porting-the-left-out-gf_log_callingfns-to-n.patch b/SOURCES/0246-glusterd-Porting-the-left-out-gf_log_callingfns-to-n.patch new file mode 100644 index 0000000..2303580 --- /dev/null +++ b/SOURCES/0246-glusterd-Porting-the-left-out-gf_log_callingfns-to-n.patch @@ -0,0 +1,235 @@ +From 2ed703a6f9b28e02bbdccd72cea578074d575596 Mon Sep 17 00:00:00 2001 +From: Nandaja Varma +Date: Thu, 9 Jul 2015 11:37:16 +0530 +Subject: [PATCH 246/279] glusterd: Porting the left out gf_log_callingfns to new framework. + +Back port of patch http://review.gluster.org/11719 + +cherry-picked from commit 68059dbe0116150cac06958f95832fd1bda54cfb: +> Change-Id: I1b0ad54238895475ddbacc4fffacac8dc6e887fe +> BUG: 1244721 +> Signed-off-by: Nandaja Varma +> Reviewed-on: http://review.gluster.org/11719 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Atin Mukherjee + +Change-Id: I1b0ad54238895475ddbacc4fffacac8dc6e887fe +BUG: 1241649 +Signed-off-by: Nandaja Varma +Reviewed-on: https://code.engineering.redhat.com/gerrit/54934 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-locks.c | 15 +++++-- + xlators/mgmt/glusterd/src/glusterd-messages.h | 42 +++++++++++++++++++- + xlators/mgmt/glusterd/src/glusterd-mgmt.c | 6 ++- + xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 11 +++-- + xlators/mgmt/glusterd/src/glusterd-statedump.c | 5 ++- + 5 files changed, 66 insertions(+), 13 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c +index a16e499..272dd07 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-locks.c ++++ b/xlators/mgmt/glusterd/src/glusterd-locks.c +@@ -541,7 +541,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + + is_valid = glusterd_mgmt_v3_is_type_valid (type); + if (is_valid != _gf_true) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, ++ EINVAL, GD_MSG_INVALID_ENTRY, + "Invalid entity. Cannot perform locking " + "operation on %s types", type); + ret = -1; +@@ -570,7 +571,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + /* If the lock has already been held for the given volume + * we fail */ + if (!gf_uuid_is_null (owner)) { +- gf_log_callingfn (this->name, GF_LOG_WARNING, ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, ++ 0, GD_MSG_LOCK_ALREADY_HELD, + "Lock for %s held by %s", + name, uuid_utoa (owner)); + ret = -1; +@@ -645,7 +647,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + + is_valid = glusterd_mgmt_v3_is_type_valid (type); + if (is_valid != _gf_true) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL, ++ GD_MSG_INVALID_ENTRY, + "Invalid entity. Cannot perform unlocking " + "operation on %s types", type); + ret = -1; +@@ -673,7 +676,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + } + + if (gf_uuid_is_null (owner)) { +- gf_log_callingfn (this->name, GF_LOG_WARNING, ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, ++ 0, GD_MSG_LOCK_NOT_HELD, + "Lock for %s %s not held", type, name); + ret = -1; + goto out; +@@ -681,7 +685,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) + + ret = gf_uuid_compare (uuid, owner); + if (ret) { +- gf_log_callingfn (this->name, GF_LOG_WARNING, ++ gf_msg_callingfn (this->name, GF_LOG_WARNING, ++ 0, GD_MSG_LOCK_OWNER_MISMATCH, + "Lock owner mismatch. " + "Lock for %s %s held by %s", + type, name, uuid_utoa (owner)); +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index ea44e18..8f80e99 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD +-#define GLFS_NUM_MESSAGES 563 ++#define GLFS_NUM_MESSAGES 568 + #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) + /* Messaged with message IDs */ + #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" +@@ -4554,6 +4554,46 @@ + */ + #define GD_MSG_ROOT_SQUASH_FAILED (GLUSTERD_COMP_BASE + 563) + ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_LOCK_OWNER_MISMATCH (GLUSTERD_COMP_BASE + 564) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_LOCK_NOT_HELD (GLUSTERD_COMP_BASE + 565) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_LOCK_ALREADY_HELD (GLUSTERD_COMP_BASE + 566) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SVC_START_SUCCESS (GLUSTERD_COMP_BASE + 567) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SVC_STOP_SUCCESS (GLUSTERD_COMP_BASE + 568) ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_GLUSTERD_MESSAGES_H_ */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +index 607d2c5..326d868 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c +@@ -173,7 +173,8 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, + ret = glusterd_op_stage_replace_brick (dict, op_errstr, + rsp_dict); + if (ret) { +- gf_log (this->name, GF_LOG_WARNING, ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_PRE_VALIDATION_FAIL, + "Replace-brick prevalidation failed."); + goto out; + } +@@ -860,7 +861,8 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, + { + ret = dict_get_str (dict, "volname", &volname); + if (ret) { +- gf_log (this->name, GF_LOG_CRITICAL, ++ gf_msg (this->name, GF_LOG_CRITICAL, errno, ++ GD_MSG_DICT_GET_FAILED, + "volname is not present in " + "operation ctx"); + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +index 8325508..fa86ca0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c ++++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +@@ -62,13 +62,15 @@ glusterd_handle_replicate_replace_brick (glusterd_volinfo_t *volinfo, + ret = sys_lsetxattr (brickinfo->path, GF_AFR_DIRTY, dirty, + sizeof (dirty), 0); + if (ret == -1) { +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_SETXATTR_FAIL, "Failed to set extended" + " attribute %s : %s.", GF_AFR_DIRTY, strerror (errno)); + goto out; + } + + if (mkdtemp (tmpmount) == NULL) { +- gf_log (THIS->name, GF_LOG_ERROR, ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_DIR_OP_FAILED, + "failed to create a temporary mount directory."); + ret = -1; + goto out; +@@ -99,7 +101,8 @@ glusterd_handle_replicate_replace_brick (glusterd_volinfo_t *volinfo, + brickinfo->brick_id, sizeof (brickinfo->brick_id), + 0); + if (ret == -1) +- gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" ++ gf_msg (THIS->name, GF_LOG_ERROR, errno, ++ GD_MSG_SETXATTR_FAIL, "Failed to set extended" + " attribute %s : %s", GF_AFR_REPLACE_BRICK, + strerror (errno)); + gf_umount_lazy (THIS->name, tmpmount, 1); +@@ -108,7 +111,7 @@ lock: + out: + if (pid) + GF_FREE (pid); +- gf_log ("", GF_LOG_DEBUG, "Returning with ret"); ++ gf_msg_debug ("glusterd", 0, "Returning with ret"); + return ret; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c +index 24a479e..83207dc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c ++++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c +@@ -19,6 +19,7 @@ + #include "glusterd-quotad-svc.h" + #include "glusterd-nfs-svc.h" + #include "glusterd-locks.h" ++#include "glusterd-messages.h" + + static void + glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *input_key, int index, +@@ -155,7 +156,9 @@ glusterd_dict_mgmt_v3_lock_statedump (dict_t *dict) + char dump[64*1024] = {0,}; + + if (!dict) { +- gf_log_callingfn ("glusterd", GF_LOG_WARNING, "dict NULL"); ++ gf_msg_callingfn ("glusterd", GF_LOG_WARNING, EINVAL, ++ GD_MSG_DICT_EMPTY, ++ "dict NULL"); + goto out; + } + for (trav = dict->members_list; trav; trav = trav->next) { +-- +1.7.1 + diff --git a/SOURCES/0247-glusterd-Pass-NULL-in-glusterd_svc_manager-in-gluste.patch b/SOURCES/0247-glusterd-Pass-NULL-in-glusterd_svc_manager-in-gluste.patch new file mode 100644 index 0000000..d63e8d5 --- /dev/null +++ b/SOURCES/0247-glusterd-Pass-NULL-in-glusterd_svc_manager-in-gluste.patch @@ -0,0 +1,104 @@ +From 8d7cb72921b983fbe2ab0a2bf166d5c57036e402 Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Wed, 12 Aug 2015 14:27:58 +0530 +Subject: [PATCH 247/279] glusterd: Pass NULL in glusterd_svc_manager in glusterd_restart_bricks + +On restarting glusterd quota daemon is not started when more than one +volumes are configured and quota is enabled only on 2nd volume. +This is because of while restarting glusterd it will restart all the bricks. +During brick restart it will start respective daemon by passing volinfo of +first volume. Passing volinfo to glusterd_svc_manager will imply daemon +managers will take action based on the same volume's configuration which +is incorrect for per node daemons. + +Fix is to pass volinfo NULL while restarting bricks. + +Change-Id: I69f0df80dc56e1d2e2598ab143bf487743042d5d +BUG: 1238071 +Signed-off-by: Gaurav Kumar Garg +Backport of: http://review.gluster.org/#/c/11658/ +Reviewed-on: https://code.engineering.redhat.com/gerrit/54970 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + .../bug-1242875-do-not-pass-volinfo-quota.t | 38 ++++++++++++++++++++ + tests/volume.rc | 4 ++ + xlators/mgmt/glusterd/src/glusterd-utils.c | 2 +- + 3 files changed, 43 insertions(+), 1 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1242875-do-not-pass-volinfo-quota.t + +diff --git a/tests/bugs/glusterd/bug-1242875-do-not-pass-volinfo-quota.t b/tests/bugs/glusterd/bug-1242875-do-not-pass-volinfo-quota.t +new file mode 100644 +index 0000000..c229d43 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1242875-do-not-pass-volinfo-quota.t +@@ -0,0 +1,38 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup; ++ ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create volume V0 and start the volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 ++TEST $CLI volume start $V0 ++ ++## Lets create volume V1 and start the volume ++TEST $CLI volume create $V1 $H0:$B0/${V0}2 $H0:$B0/${V0}3 ++TEST $CLI volume start $V1 ++ ++## Enable quota on 2nd volume ++TEST $CLI volume quota $V1 enable ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_quotad_count ++ ++## Killing all gluster process ++pkill gluster; ++ ++## there should not be any quota daemon running after killing quota process ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_quotad_count ++ ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Quotad daemon should start on restarting the glusterd ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_quotad_count ++ ++cleanup; +diff --git a/tests/volume.rc b/tests/volume.rc +index 09a8d51..570d87d 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -543,6 +543,10 @@ function get_scrubd_count { + ps auxww | grep glusterfs | grep scrub.pid | grep -v grep | wc -l + } + ++function get_quotad_count { ++ ps auxww | grep glusterfs | grep quotad.pid | grep -v grep | wc -l ++} ++ + function quota_list_field () { + local QUOTA_PATH=$1 + local FIELD=$2 +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 7781773..5b9d5e3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -4488,7 +4488,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf) + continue; + if (start_svcs == _gf_false) { + start_svcs = _gf_true; +- glusterd_svcs_manager (volinfo); ++ glusterd_svcs_manager (NULL); + } + gf_msg_debug (this->name, 0, "starting the volume %s", + volinfo->volname); +-- +1.7.1 + diff --git a/SOURCES/0248-glusterd-Do-not-log-failure-if-glusterd_get_txn_opin.patch b/SOURCES/0248-glusterd-Do-not-log-failure-if-glusterd_get_txn_opin.patch new file mode 100644 index 0000000..67a6662 --- /dev/null +++ b/SOURCES/0248-glusterd-Do-not-log-failure-if-glusterd_get_txn_opin.patch @@ -0,0 +1,101 @@ +From 758ff1daa0aa29ddc144cd008b3c19e5eccc4269 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Fri, 3 Jul 2015 11:34:20 +0530 +Subject: [PATCH 248/279] glusterd: Do not log failure if glusterd_get_txn_opinfo fails in gluster volume status + +Backport of http://review.gluster.org/#/c/11520/ + +The first RPC call of gluster volume status fetches the list of the volume names +from GlusterD and during that time since no volume name is set in the dictionary +gluserd_get_txn_opinfo fails resulting into a failure log which is annoying to +the user considering this command is triggered frequently. + +Fix is to have callers log it depending on the need + +Change-Id: Ib60a56725208182175513c505c61bcb28148b2d0 +BUG: 1134288 +Signed-off-by: Atin Mukherjee +Reviewed-on: http://review.gluster.org/11520 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/55037 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 23 +++++++++++------------ + xlators/mgmt/glusterd/src/glusterd-utils.c | 7 ++++--- + 2 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index dbdaec0..5e916eb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -245,14 +245,8 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) + ret = dict_get_bin(priv->glusterd_txn_opinfo, + uuid_utoa (*txn_id), + (void **) &opinfo_obj); +- if (ret) { +- gf_msg_callingfn (this->name, GF_LOG_ERROR, errno, +- GD_MSG_DICT_GET_FAILED, +- "Unable to get transaction opinfo " +- "for transaction ID : %s", +- uuid_utoa (*txn_id)); ++ if (ret) + goto out; +- } + + (*opinfo) = opinfo_obj->opinfo; + +@@ -348,9 +342,11 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id) + + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_GET_FAIL, +- "Transaction opinfo not found"); ++ "Unable to get transaction opinfo " ++ "for transaction ID : %s", ++ uuid_utoa (*txn_id)); + goto out; + } + +@@ -7262,9 +7258,12 @@ glusterd_op_sm () + ret = glusterd_get_txn_opinfo (&event->txn_id, + &txn_op_info); + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_TRANS_OPINFO_GET_FAIL, +- "Unable to get transaction's opinfo"); ++ gf_msg_callingfn (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_OPINFO_GET_FAIL, ++ "Unable to get transaction " ++ "opinfo for transaction ID :" ++ "%s", ++ uuid_utoa (event->txn_id)); + glusterd_destroy_op_event_ctx (event); + GF_FREE (event); + continue; +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 5b9d5e3..1af9902 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -8261,10 +8261,11 @@ glusterd_volume_heal_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) + + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_GET_FAIL, +- "Failed to get txn_op_info " +- "for txn_id = %s", uuid_utoa (*txn_id)); ++ "Unable to get transaction opinfo " ++ "for transaction ID : %s", ++ uuid_utoa (*txn_id)); + goto out; + } + +-- +1.7.1 + diff --git a/SOURCES/0249-cluster-afr-Fix-incorrect-logging-in-read-transactio.patch b/SOURCES/0249-cluster-afr-Fix-incorrect-logging-in-read-transactio.patch new file mode 100644 index 0000000..6d49fb4 --- /dev/null +++ b/SOURCES/0249-cluster-afr-Fix-incorrect-logging-in-read-transactio.patch @@ -0,0 +1,56 @@ +From 7783b35987db2a7cdebb7d7f02e0073c632c49c6 Mon Sep 17 00:00:00 2001 +From: Krutika Dhananjay +Date: Thu, 23 Jul 2015 18:08:34 +0530 +Subject: [PATCH 249/279] cluster/afr: Fix incorrect logging in read transactions + + Backport of: http://review.gluster.org/11756 + +afr_read_txn_refresh_done() at its entry point can fail for +reasons like ENOENT/ESTALE but seldom due to EIO, which is something +_AFR_ would internally generate and not receive in response from +a child translator. AFR is reporting "split-brain" for _any_ +kind of failure in read txn, of the following kind: + +[2015-07-07 18:04:34.787612] E [MSGID: 108008] +[afr-read-txn.c:76:afr_read_txn_refresh_done] 0-vol3-replicate-3: +Failing STAT on gfid 18a973c4-73d3-48b8-942c-33a6f1a8e6b4: +split-brain observed. [Input/output error] + +This patch fixes such misleading errors. + +To-Do: +Avoid logging EIO error if/when split-brain choice is set. +Will do that as part of a separate commit. + +Change-Id: I4d75b9ebfd79805e23f8e8265a62a06558411493 +BUG: 1240657 +Signed-off-by: Krutika Dhananjay +Reviewed-on: https://code.engineering.redhat.com/gerrit/53813 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + xlators/cluster/afr/src/afr-read-txn.c | 8 ++++++-- + 1 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c +index a998cce..1b2faf3 100644 +--- a/xlators/cluster/afr/src/afr-read-txn.c ++++ b/xlators/cluster/afr/src/afr-read-txn.c +@@ -72,8 +72,12 @@ afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err) + local = frame->local; + inode = local->inode; + +- if (err) +- AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, -err, -1, readfn); ++ if (err) { ++ local->op_errno = -err; ++ local->op_ret = -1; ++ read_subvol = -1; ++ goto readfn; ++ } + + ret = afr_inode_get_readable (frame, inode, this, local->readable, + &event_generation, +-- +1.7.1 + diff --git a/SOURCES/0250-heal-Do-not-invoke-glfs_fini-for-glfs-heal-commands.patch b/SOURCES/0250-heal-Do-not-invoke-glfs_fini-for-glfs-heal-commands.patch new file mode 100644 index 0000000..8fe61d9 --- /dev/null +++ b/SOURCES/0250-heal-Do-not-invoke-glfs_fini-for-glfs-heal-commands.patch @@ -0,0 +1,71 @@ +From c9338497aa163a54c32c70869a0035aa875312cc Mon Sep 17 00:00:00 2001 +From: Anuradha +Date: Fri, 5 Jun 2015 16:49:14 +0530 +Subject: [PATCH 250/279] heal : Do not invoke glfs_fini for glfs-heal commands + +backport of http://review.gluster.org/11001 & +http://review.gluster.org/11115 + +Change-Id: I2fa6789488c4ecebbed049f46c189441fba48535 +BUG: 1236990 +Signed-off-by: Anuradha +Reviewed-on: http://review.gluster.org/11103 +Tested-by: Gluster Build System +Reviewed-by: Vijay Bellur +Reviewed-on: http://review.gluster.org/11115 +Tested-by: NetBSD Build System +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/51934 +Reviewed-by: Ravishankar Narayanankutty +Tested-by: Ravishankar Narayanankutty +--- + heal/src/glfs-heal.c | 20 +++++++++++++++++--- + 1 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c +index cbdb593..bc76518 100644 +--- a/heal/src/glfs-heal.c ++++ b/heal/src/glfs-heal.c +@@ -674,6 +674,21 @@ out: + return ret; + } + ++static void ++cleanup (glfs_t *fs) ++{ ++ if (!fs) ++ return; ++#if 0 ++ /* glfs fini path is still racy and crashing the program. Since ++ * this program any way has to die, we are not gonna call fini ++ * in the released versions. i.e. final builds. For all ++ * internal testing lets enable this so that glfs_fini code ++ * path becomes stable. */ ++ glfs_fini (fs); ++#endif ++} ++ + int + main (int argc, char **argv) + { +@@ -818,15 +833,14 @@ main (int argc, char **argv) + + loc_wipe (&rootloc); + glfs_subvol_done (fs, top_subvol); +- glfs_fini (fs); ++ cleanup (fs); + + return ret; + out: + if (fs && top_subvol) + glfs_subvol_done (fs, top_subvol); + loc_wipe (&rootloc); +- if (fs) +- glfs_fini (fs); ++ cleanup (fs); + + return ret; + } +-- +1.7.1 + diff --git a/SOURCES/0251-dht-send-lookup-even-for-fd-based-operations-during-.patch b/SOURCES/0251-dht-send-lookup-even-for-fd-based-operations-during-.patch new file mode 100644 index 0000000..c262c12 --- /dev/null +++ b/SOURCES/0251-dht-send-lookup-even-for-fd-based-operations-during-.patch @@ -0,0 +1,135 @@ +From 306faa19df543fd00748e5ff01deba7898d94e89 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Fri, 17 Jul 2015 16:04:01 +0530 +Subject: [PATCH 251/279] dht: send lookup even for fd based operations during rebalance + +Patch in master: http://review.gluster.org/#/c/11713/ +Patch in release-3.7: http://review.gluster.org/#/c/11744/ + +Problem: +dht_rebalance_inprogress_task() was not sending lookups to the +destination subvolume for a file undergoing writes during rebalance. Due to +this, afr was not able to populate the read_subvol and failed the write +with EIO. + +Fix: +Send lookup for fd based operations as well. + +Thanks to Raghavendra G for helping with the RCA. +Change-Id: Ic450f2c72a6e39e53e0d6b458ab3bcaf13309f0b +BUG: 1243542 + +Signed-off-by: Ravishankar N +Change-Id: I24baf32dbf3d3b8aad535f04aa717d719956fa02 +Reviewed-on: https://code.engineering.redhat.com/gerrit/53818 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-helper.c | 53 +++++++++++++++++++-------------- + 1 files changed, 30 insertions(+), 23 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index d8cc61d..2e4a53c 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -992,7 +992,8 @@ dht_migration_complete_check_task (void *data) + gf_msg (this->name, GF_LOG_ERROR, -ret, + DHT_MSG_FILE_LOOKUP_FAILED, + "%s: failed to lookup the file on %s", +- tmp_loc.path, this->name); ++ tmp_loc.path ? tmp_loc.path : uuid_utoa (tmp_loc.gfid), ++ this->name); + local->op_errno = -ret; + ret = -1; + goto out; +@@ -1012,7 +1013,8 @@ dht_migration_complete_check_task (void *data) + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_GFID_MISMATCH, + "%s: gfid different on the target file on %s", +- tmp_loc.path, dst_node->name); ++ tmp_loc.path ? tmp_loc.path : ++ uuid_utoa (tmp_loc.gfid), dst_node->name); + ret = -1; + local->op_errno = EIO; + goto out; +@@ -1200,28 +1202,34 @@ dht_rebalance_inprogress_task (void *data) + local->rebalance.target_node = dst_node; + + if (local->loc.inode) { +- /* lookup on dst */ +- ret = syncop_lookup (dst_node, &local->loc, &stbuf, NULL, +- NULL, NULL); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, -ret, +- DHT_MSG_FILE_LOOKUP_ON_DST_FAILED, +- "%s: failed to lookup the file on %s", +- local->loc.path, dst_node->name); +- ret = -1; +- goto out; +- } ++ loc_copy (&tmp_loc, &local->loc); ++ } else { ++ tmp_loc.inode = inode_ref (inode); ++ gf_uuid_copy (tmp_loc.gfid, inode->gfid); ++ } + +- if (gf_uuid_compare (stbuf.ia_gfid, local->loc.inode->gfid)) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- DHT_MSG_GFID_MISMATCH, +- "%s: gfid different on the target file on %s", +- local->loc.path, dst_node->name); +- ret = -1; +- goto out; +- } ++ /* lookup on dst */ ++ ret = syncop_lookup (dst_node, &tmp_loc, &stbuf, NULL, ++ NULL, NULL); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, -ret, ++ DHT_MSG_FILE_LOOKUP_ON_DST_FAILED, ++ "%s: failed to lookup the file on %s", ++ tmp_loc.path ? tmp_loc.path : uuid_utoa (tmp_loc.gfid), ++ dst_node->name); ++ ret = -1; ++ goto out; + } + ++ if (gf_uuid_compare (stbuf.ia_gfid, tmp_loc.inode->gfid)) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_GFID_MISMATCH, ++ "%s: gfid different on the target file on %s", ++ tmp_loc.path ? tmp_loc.path : uuid_utoa (tmp_loc.gfid), ++ dst_node->name); ++ ret = -1; ++ goto out; ++ } + ret = 0; + + if (list_empty (&inode->fd_list)) +@@ -1232,7 +1240,6 @@ dht_rebalance_inprogress_task (void *data) + */ + SYNCTASK_SETID (0, 0); + +- tmp_loc.inode = inode; + inode_path (inode, NULL, &path); + if (path) + tmp_loc.path = path; +@@ -1258,7 +1265,6 @@ dht_rebalance_inprogress_task (void *data) + open_failed = 1; + } + } +- GF_FREE (path); + + SYNCTASK_SETID (frame->root->uid, frame->root->gid); + +@@ -1279,6 +1285,7 @@ done: + + ret = 0; + out: ++ loc_wipe (&tmp_loc); + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0252-geo-rep-Fix-fd-referenced-before-assignment.patch b/SOURCES/0252-geo-rep-Fix-fd-referenced-before-assignment.patch new file mode 100644 index 0000000..39af60c --- /dev/null +++ b/SOURCES/0252-geo-rep-Fix-fd-referenced-before-assignment.patch @@ -0,0 +1,64 @@ +From baf8189686402c1dc74405afd2ffe45338540031 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Fri, 19 Jun 2015 01:41:27 +0530 +Subject: [PATCH 252/279] geo-rep: Fix fd referenced before assignment + +Fix fd reference before assignment in mgmt_lock +function. + +BUG: 1232216 +Change-Id: I5c4a7009570e4ac18fbf417f655765f09d1bcab6 +Reviewed-on: http://review.gluster.org/11318 +Reviewed-on: http://review.gluster.org/11563 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Milind Changire +Reviewed-by: Venky Shankar +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/55050 +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + geo-replication/syncdaemon/master.py | 8 ++++++-- + 1 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py +index 37be4fc..5b8abc5 100644 +--- a/geo-replication/syncdaemon/master.py ++++ b/geo-replication/syncdaemon/master.py +@@ -442,6 +442,7 @@ class GMasterCommon(object): + + def mgmt_lock(self): + """Take management volume lock """ ++ fd = None + bname = str(self.uuid) + "_" + str(gconf.slave_id) + "_subvol_" \ + + str(gconf.subvol_num) + ".lock" + mgmt_lock_dir = os.path.join(gconf.meta_volume_mnt, "geo-rep") +@@ -455,18 +456,21 @@ class GMasterCommon(object): + logging.info("Creating geo-rep directory in meta volume...") + try: + os.makedirs(mgmt_lock_dir) +- fd = os.open(path, os.O_CREAT | os.O_RDWR) + except OSError: + ex = sys.exc_info()[1] + if ex.errno == EEXIST: + pass + else: + raise ++ fd = os.open(path, os.O_CREAT | os.O_RDWR) ++ else: ++ raise + try: + fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except: + ex = sys.exc_info()[1] +- os.close(fd) ++ if fd: ++ os.close(fd) + if isinstance(ex, IOError) and ex.errno in (EACCES, EAGAIN): + # cannot grab, it's taken + logging.debug("Lock held by someother worker process") +-- +1.7.1 + diff --git a/SOURCES/0253-geo-rep-Fix-history-failure.patch b/SOURCES/0253-geo-rep-Fix-history-failure.patch new file mode 100644 index 0000000..c1e7239 --- /dev/null +++ b/SOURCES/0253-geo-rep-Fix-history-failure.patch @@ -0,0 +1,107 @@ +From 679e4ed49d453899e6700e3fc1f4fa1e39900793 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Fri, 3 Jul 2015 16:32:56 +0530 +Subject: [PATCH 253/279] geo-rep: Fix history failure + +Both ACTIVE and PASSIVE workers register to changelog +at almost same time. When PASSIVE worker becomes ACTIVE, +the start and end time would be current stime and register_time +repectively for history API. Hence register_time would be less +then stime for which history obviously fails. But it will +be successful for the next restart as new register_time > stime. + +Fix is to pass current time as the end time to history call +instead of the register_time. + +Also improvised the logging for ACTIVE/PASSIVE switching. + +BUG: 1236546 +Change-Id: I5d7f38200980914bd0b2ee34da4d2e6674b3a67e +Reviewed-on: http://review.gluster.org/11524 +Reviewed-on: http://review.gluster.org/11784 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Aravinda VK +Reviewed-by: Venky Shankar +Reviewed-by: Milind Changire +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/55051 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + geo-replication/syncdaemon/gconf.py | 6 ++++++ + geo-replication/syncdaemon/master.py | 18 +++++++++++++----- + 2 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/geo-replication/syncdaemon/gconf.py b/geo-replication/syncdaemon/gconf.py +index 1fc7c38..39a70a6 100644 +--- a/geo-replication/syncdaemon/gconf.py ++++ b/geo-replication/syncdaemon/gconf.py +@@ -21,5 +21,11 @@ class GConf(object): + log_exit = False + permanent_handles = [] + log_metadata = {} ++ """One variable is sufficient to track the ++ switching of worker to ACTIVE. Two variables ++ are intentionally used to track worker going ++ to PASSIVE as well mainly for debugging""" ++ active_earlier = False ++ passive_earlier = False + + gconf = GConf() +diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py +index 5b8abc5..1bc2450 100644 +--- a/geo-replication/syncdaemon/master.py ++++ b/geo-replication/syncdaemon/master.py +@@ -441,6 +441,7 @@ class GMasterCommon(object): + t.start() + + def mgmt_lock(self): ++ + """Take management volume lock """ + fd = None + bname = str(self.uuid) + "_" + str(gconf.slave_id) + "_subvol_" \ +@@ -473,10 +474,16 @@ class GMasterCommon(object): + os.close(fd) + if isinstance(ex, IOError) and ex.errno in (EACCES, EAGAIN): + # cannot grab, it's taken +- logging.debug("Lock held by someother worker process") ++ if not gconf.passive_earlier: ++ gconf.passive_earlier = True ++ logging.info("Didn't get lock : %s : Becoming PASSIVE" ++ % gconf.local_path) + return False + raise +- logging.debug("Got the lock") ++ ++ if not gconf.active_earlier: ++ gconf.active_earlier = True ++ logging.info("Got lock : %s : Becoming ACTIVE" % gconf.local_path) + return True + + def should_crawl(self): +@@ -1123,8 +1130,9 @@ class GMasterChangeloghistoryMixin(GMasterChangelogMixin): + self.status.set_worker_crawl_status("History Crawl") + purge_time = self.get_purge_time() + +- logging.info('starting history crawl... turns: %s, stime: %s' +- % (self.history_turns, repr(purge_time))) ++ end_time = int(time.time()) ++ logging.info('starting history crawl... turns: %s, stime: %s, etime: %s' ++ % (self.history_turns, repr(purge_time), repr(end_time))) + + if not purge_time or purge_time == URXTIME: + logging.info("stime not available, abandoning history crawl") +@@ -1138,7 +1146,7 @@ class GMasterChangeloghistoryMixin(GMasterChangelogMixin): + ret, actual_end = self.changelog_agent.history( + changelog_path, + purge_time[0], +- self.changelog_register_time, ++ end_time, + int(gconf.sync_jobs)) + + # scan followed by getchanges till scan returns zero. +-- +1.7.1 + diff --git a/SOURCES/0254-geo-rep-Do-not-crash-worker-on-ESTALE.patch b/SOURCES/0254-geo-rep-Do-not-crash-worker-on-ESTALE.patch new file mode 100644 index 0000000..404363c --- /dev/null +++ b/SOURCES/0254-geo-rep-Do-not-crash-worker-on-ESTALE.patch @@ -0,0 +1,50 @@ +From 3a2ae0066f85e0f25ff59d0fab281c23d918e9fa Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Tue, 28 Jul 2015 14:37:47 +0530 +Subject: [PATCH 254/279] geo-rep: Do not crash worker on ESTALE + +Handle ESTALE returned by lstat gracefully +by retrying it. Do not crash the worker. + +BUG: 1239075 +Change-Id: Iad983f43923aa2ed809aa29cc55a76bcbeb96472 +Reviewed-on: http://review.gluster.org/11772 +Reviewed-on: http://review.gluster.org/11820 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Aravinda VK +Reviewed-by: Venky Shankar +Reviewed-by: Milind Changire +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/55052 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + geo-replication/syncdaemon/syncdutils.py | 10 +--------- + 1 files changed, 1 insertions(+), 9 deletions(-) + +diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py +index b565ec6..3feadb8 100644 +--- a/geo-replication/syncdaemon/syncdutils.py ++++ b/geo-replication/syncdaemon/syncdutils.py +@@ -489,15 +489,7 @@ def errno_wrap(call, arg=[], errnos=[], retry_errnos=[]): + + + def lstat(e): +- try: +- return os.lstat(e) +- except (IOError, OSError): +- ex = sys.exc_info()[1] +- if ex.errno == ENOENT: +- return ex.errno +- else: +- raise +- ++ return errno_wrap(os.lstat, [e], [ENOENT], [ESTALE]) + + class NoPurgeTimeAvailable(Exception): + pass +-- +1.7.1 + diff --git a/SOURCES/0255-glusterd-getting-txn_id-from-frame-cookie-in-op_sm-c.patch b/SOURCES/0255-glusterd-getting-txn_id-from-frame-cookie-in-op_sm-c.patch new file mode 100644 index 0000000..1ab7f0a --- /dev/null +++ b/SOURCES/0255-glusterd-getting-txn_id-from-frame-cookie-in-op_sm-c.patch @@ -0,0 +1,244 @@ +From 12b3a9ec4c661ae6bc8fc546eb29114191c9c404 Mon Sep 17 00:00:00 2001 +From: anand +Date: Tue, 21 Jul 2015 15:42:24 +0530 +Subject: [PATCH 255/279] glusterd: getting txn_id from frame->cookie in op_sm call back + +RCA: If rebalance start is triggered from one node and one of other nodes in the cluster goes down simultaneously +we might end up in a case where callback will use the txn_id from priv->global_txn_id which is always zeros and +this means injecting an event with an incorrect txn_id will result into op-sm getting stuck. + +fix: set txn_id in frame->cookie during sumbit_and_request, so that we can get txn_id in call back +functions. + +>Change-Id: I519176c259ea9d37897791a77a7c92eb96d10052 +>BUG: 1245142 +>Signed-off-by: anand +>Reviewed-on: http://review.gluster.org/11728 +>Reviewed-by: Atin Mukherjee +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Signed-off-by: Anand + +Change-Id: I4f5df48890953651fc80bc3c3e66711b230d8fd1 +BUG: 1244527 +Signed-off-by: Anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/55080 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + tests/bugs/glusterd/bug-1245142-rebalance_test.t | 28 ++++++++ + xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 77 +++++++++++++++++----- + 2 files changed, 89 insertions(+), 16 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1245142-rebalance_test.t + +diff --git a/tests/bugs/glusterd/bug-1245142-rebalance_test.t b/tests/bugs/glusterd/bug-1245142-rebalance_test.t +new file mode 100644 +index 0000000..a28810e +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1245142-rebalance_test.t +@@ -0,0 +1,28 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../cluster.rc ++. $(dirname $0)/../../volume.rc ++ ++ ++cleanup; ++TEST launch_cluster 2; ++TEST $CLI_1 peer probe $H2; ++ ++EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count ++ ++$CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 ++EXPECT 'Created' cluster_volinfo_field 1 $V0 'Status'; ++ ++$CLI_1 volume start $V0 ++EXPECT 'Started' cluster_volinfo_field 1 $V0 'Status'; ++ ++$CLI_1 volume rebalance $V0 start & ++#kill glusterd2 after requst sent, so that call back is called ++#with rpc->status fail ,so roughly 1sec delay is introduced to get this scenario. ++sleep 1 ++kill_glusterd 2 ++#check glusterd commands are working after rebalance start command ++EXPECT 'Started' cluster_volinfo_field 1 $V0 'Status'; ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +index 0890b02..bcdffdc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +@@ -1131,14 +1131,17 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + uuid_t *txn_id = NULL; ++ call_frame_t *frame = NULL; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (req); + priv = this->private; + GF_ASSERT (priv); ++ GF_ASSERT(myframe); + +- txn_id = &priv->global_txn_id; ++ frame = myframe; ++ txn_id = frame->cookie; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; +@@ -1196,10 +1199,6 @@ out: + uuid_utoa (rsp.uuid)); + } + +- ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_msg_debug (this->name, 0, "transaction ID = %s", +- uuid_utoa (*txn_id)); +- + rcu_read_lock (); + peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL); + if (peerinfo == NULL) { +@@ -1246,6 +1245,7 @@ out: + } else { + free (rsp.dict.dict_val); //malloced by xdr + } ++ GF_FREE (frame->cookie); + GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe)); + return ret; + } +@@ -1274,14 +1274,17 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + glusterd_conf_t *priv = NULL; + uuid_t *txn_id = NULL; + glusterd_op_info_t txn_op_info = {{0},}; ++ call_frame_t *frame = NULL; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (req); + priv = this->private; + GF_ASSERT (priv); ++ GF_ASSERT(myframe); + +- txn_id = &priv->global_txn_id; ++ frame = myframe; ++ txn_id = frame->cookie; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; +@@ -1339,9 +1342,6 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, + "Received commit ACC from uuid: %s", + uuid_utoa (rsp.uuid)); + } +- ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id); +- gf_msg_debug (this->name, 0, "transaction ID = %s", +- uuid_utoa (*txn_id)); + + ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); + if (ret) { +@@ -1414,6 +1414,7 @@ out: + if (dict) + dict_unref (dict); + free (rsp.op_errstr); //malloced by xdr ++ GF_FREE (frame->cookie); + GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe)); + return ret; + } +@@ -1898,9 +1899,9 @@ glusterd_stage_op (call_frame_t *frame, xlator_t *this, + int ret = -1; + glusterd_peerinfo_t *peerinfo = NULL; + glusterd_conf_t *priv = NULL; +- call_frame_t *dummy_frame = NULL; + dict_t *dict = NULL; + gf_boolean_t is_alloc = _gf_true; ++ uuid_t *txn_id = NULL; + + if (!this) { + goto out; +@@ -1930,13 +1931,34 @@ glusterd_stage_op (call_frame_t *frame, xlator_t *this, + "to request buffer"); + goto out; + } ++ /* Sending valid transaction ID to peers */ ++ ret = dict_get_bin (dict, "transaction_id", ++ (void **)&txn_id); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, ++ "Failed to get transaction id."); ++ goto out; ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Transaction_id = %s", uuid_utoa (*txn_id)); ++ } + ++ if (!frame) ++ frame = create_frame (this, this->ctx->pool); + +- dummy_frame = create_frame (this, this->ctx->pool); +- if (!dummy_frame) ++ if (!frame) { ++ ret = -1; + goto out; ++ } ++ frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t); ++ if (!frame->cookie) { ++ ret = -1; ++ goto out; ++ } ++ gf_uuid_copy (frame->cookie, *txn_id); + +- ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, ++ ret = glusterd_submit_request (peerinfo->rpc, &req, frame, + peerinfo->mgmt, GLUSTERD_MGMT_STAGE_OP, + NULL, + this, glusterd_stage_op_cbk, +@@ -1961,6 +1983,7 @@ glusterd_commit_op (call_frame_t *frame, xlator_t *this, + call_frame_t *dummy_frame = NULL; + dict_t *dict = NULL; + gf_boolean_t is_alloc = _gf_true; ++ uuid_t *txn_id = NULL; + + if (!this) { + goto out; +@@ -1989,12 +2012,34 @@ glusterd_commit_op (call_frame_t *frame, xlator_t *this, + "request buffer"); + goto out; + } ++ /* Sending valid transaction ID to peers */ ++ ret = dict_get_bin (dict, "transaction_id", ++ (void **)&txn_id); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_TRANS_ID_GET_FAIL, ++ "Failed to get transaction id."); ++ goto out; ++ } else { ++ gf_msg_debug (this->name, 0, ++ "Transaction_id = %s", uuid_utoa (*txn_id)); ++ } + +- dummy_frame = create_frame (this, this->ctx->pool); +- if (!dummy_frame) ++ if (!frame) ++ frame = create_frame (this, this->ctx->pool); ++ ++ if (!frame) { ++ ret = -1; + goto out; ++ } ++ frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t); ++ if (!frame->cookie) { ++ ret = -1; ++ goto out; ++ } ++ gf_uuid_copy (frame->cookie, *txn_id); + +- ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, ++ ret = glusterd_submit_request (peerinfo->rpc, &req, frame, + peerinfo->mgmt, GLUSTERD_MGMT_COMMIT_OP, + NULL, + this, glusterd_commit_op_cbk, +-- +1.7.1 + diff --git a/SOURCES/0256-client-rpc-make-ping-timeout-configurable-for-gluste.patch b/SOURCES/0256-client-rpc-make-ping-timeout-configurable-for-gluste.patch new file mode 100644 index 0000000..c8e4ffe --- /dev/null +++ b/SOURCES/0256-client-rpc-make-ping-timeout-configurable-for-gluste.patch @@ -0,0 +1,111 @@ +From a6db1b71102835ada48a9d4785d1588f365ea990 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Mon, 3 Aug 2015 13:28:09 +0530 +Subject: [PATCH 256/279] client, rpc: make ping-timeout configurable for glusterfs clients + +Change-Id: Idd94adb0457aaffce7330f56f98cebafa2c4dae8 +BUG: 1252359 +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: http://review.gluster.org/11818 +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Tested-by: NetBSD Build System +(cherry picked from commit 3403370ebeaf16567b79022c6ac48b2e0cd50db5) +Reviewed-on: http://review.gluster.org/11848 +Reviewed-on: https://code.engineering.redhat.com/gerrit/55045 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-lib/src/rpc-clnt.c | 15 +++++++++++++++ + rpc/rpc-lib/src/rpc-clnt.h | 1 + + xlators/protocol/client/src/client.c | 23 ++++++++++++++--------- + 3 files changed, 30 insertions(+), 9 deletions(-) + +diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c +index 2878372..5fbe072 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.c ++++ b/rpc/rpc-lib/src/rpc-clnt.c +@@ -1802,6 +1802,21 @@ out: + void + rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config) + { ++ if (config->ping_timeout) { ++ if (config->ping_timeout != rpc->conn.ping_timeout) ++ gf_log (rpc->conn.name, GF_LOG_INFO, ++ "changing ping timeout to %d (from %d)", ++ config->ping_timeout, ++ rpc->conn.ping_timeout); ++ ++ pthread_mutex_lock (&rpc->conn.lock); ++ { ++ rpc->conn.ping_timeout = config->ping_timeout; ++ } ++ pthread_mutex_unlock (&rpc->conn.lock); ++ ++ } ++ + if (config->rpc_timeout) { + if (config->rpc_timeout != rpc->conn.config.rpc_timeout) + gf_log (rpc->conn.name, GF_LOG_INFO, +diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h +index faae485..ee46a9a 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.h ++++ b/rpc/rpc-lib/src/rpc-clnt.h +@@ -125,6 +125,7 @@ struct rpc_clnt_config { + int rpc_timeout; + int remote_port; + char * remote_host; ++ int ping_timeout; + }; + + +diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c +index fb45128..db7a07a 100644 +--- a/xlators/protocol/client/src/client.c ++++ b/xlators/protocol/client/src/client.c +@@ -2374,21 +2374,22 @@ client_check_event_threads (xlator_t *this, clnt_conf_t *conf, int32_t old, + int + reconfigure (xlator_t *this, dict_t *options) + { +- clnt_conf_t *conf = NULL; +- int ret = -1; +- int subvol_ret = 0; +- char *old_remote_subvol = NULL; +- char *new_remote_subvol = NULL; +- char *old_remote_host = NULL; +- char *new_remote_host = NULL; +- int32_t new_nthread = 0; ++ clnt_conf_t *conf = NULL; ++ int ret = -1; ++ int subvol_ret = 0; ++ char *old_remote_subvol = NULL; ++ char *new_remote_subvol = NULL; ++ char *old_remote_host = NULL; ++ char *new_remote_host = NULL; ++ int32_t new_nthread = 0; ++ struct rpc_clnt_config rpc_config = {0,}; + + conf = this->private; + + GF_OPTION_RECONF ("frame-timeout", conf->rpc_conf.rpc_timeout, + options, int32, out); + +- GF_OPTION_RECONF ("ping-timeout", conf->opt.ping_timeout, ++ GF_OPTION_RECONF ("ping-timeout", rpc_config.ping_timeout, + options, int32, out); + + GF_OPTION_RECONF ("event-threads", new_nthread, options, +@@ -2430,6 +2431,10 @@ reconfigure (xlator_t *this, dict_t *options) + } + } + ++ /* Reconfiguring client xlator's @rpc with new frame-timeout ++ * and ping-timeout */ ++ rpc_clnt_reconfig (conf->rpc, &rpc_config); ++ + GF_OPTION_RECONF ("filter-O_DIRECT", conf->filter_o_direct, + options, bool, out); + +-- +1.7.1 + diff --git a/SOURCES/0257-quota-marker-contribution-with-list_del-can-cause-me.patch b/SOURCES/0257-quota-marker-contribution-with-list_del-can-cause-me.patch new file mode 100644 index 0000000..3e724b8 --- /dev/null +++ b/SOURCES/0257-quota-marker-contribution-with-list_del-can-cause-me.patch @@ -0,0 +1,75 @@ +From 63bd03660e88fe2aab59b0c3d86e079855cf87c1 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 13 Aug 2015 14:11:59 +0530 +Subject: [PATCH 257/279] quota/marker: contribution with list_del can cause mem corruption + +This is a backport of http://review.gluster.org/11706 + +There is a possibility that contribution is removed twice from list +during unlink operation (with hard links) or during rename operation + +Use list_del_init for a thread safe deltion of member from list + +> Change-Id: Iff5e0c03cc8f0ed85da0db1739b84b695abf9ea6 +> BUG: 1244109 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11706 +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System +> Reviewed-by: Krishnan Parthasarathi +> Reviewed-by: Raghavendra G + +BUG: 1236672 +Change-Id: Ic40d7342039a0512345418ab146d67682b87be21 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55061 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota-helper.h | 16 ++++++++-------- + xlators/features/marker/src/marker-quota.c | 2 +- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h +index f69447b..1f9faf5 100644 +--- a/xlators/features/marker/src/marker-quota-helper.h ++++ b/xlators/features/marker/src/marker-quota-helper.h +@@ -18,14 +18,14 @@ + + #include "marker.h" + +-#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution) \ +- do { \ +- LOCK (&ctx->lock); \ +- { \ +- list_del (&_contribution->contri_list); \ +- GF_REF_PUT (_contribution); \ +- } \ +- UNLOCK (&ctx->lock); \ ++#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution) \ ++ do { \ ++ LOCK (&ctx->lock); \ ++ { \ ++ list_del_init (&_contribution->contri_list); \ ++ GF_REF_PUT (_contribution); \ ++ } \ ++ UNLOCK (&ctx->lock); \ + } while (0) + + #define QUOTA_SAFE_INCREMENT(lock, var) \ +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index ca59c1b..f65ed77 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -4178,7 +4178,7 @@ mq_forget (xlator_t *this, quota_inode_ctx_t *ctx) + + list_for_each_entry_safe (contri, next, &ctx->contribution_head, + contri_list) { +- list_del (&contri->contri_list); ++ list_del_init (&contri->contri_list); + GF_REF_PUT (contri); + } + +-- +1.7.1 + diff --git a/SOURCES/0258-quota-Fix-crash-in-quota-enforcer.patch b/SOURCES/0258-quota-Fix-crash-in-quota-enforcer.patch new file mode 100644 index 0000000..3f7059b --- /dev/null +++ b/SOURCES/0258-quota-Fix-crash-in-quota-enforcer.patch @@ -0,0 +1,836 @@ +From 3d8c0c9d3cabc61172b1d5d767a33cf334ddf59c Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 13 Aug 2015 14:09:22 +0530 +Subject: [PATCH 258/279] quota: Fix crash in quota enforcer + +This is a backport of http://review.gluster.org/11510 + +With multiple hardlinks check_quota_limit is invoked for each parent +each of this check_limit can invoke validation +this can cause frame->local to get corrupted during validation. + +Testcase tests/bugs/quota/bug-1235182.t fails spuriously with +this problem + +> Change-Id: I53adc54b431fb5f43e67a94248102ddaf0d7978f +> BUG: 1238747 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11510 +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G + +BUG: 1238049 +Change-Id: Iac8d3c54c81536c8d4ba07c2c34ea79d0701b714 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55060 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + tests/bugs/quota/bug-1235182.t | 10 +- + xlators/features/quota/src/quota.c | 408 +++++++++++++++++++++++++----------- + xlators/features/quota/src/quota.h | 9 +- + 3 files changed, 297 insertions(+), 130 deletions(-) + +diff --git a/tests/bugs/quota/bug-1235182.t b/tests/bugs/quota/bug-1235182.t +index 0bd43a9..e28b557 100644 +--- a/tests/bugs/quota/bug-1235182.t ++++ b/tests/bugs/quota/bug-1235182.t +@@ -9,12 +9,6 @@ + + cleanup; + +-function usage() +-{ +- local QUOTA_PATH=$1; +- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}' +-} +- + QDD=$(dirname $0)/quota + # compile the test write program and run it + build_tester $(dirname $0)/../../basic/quota.c -o $QDD +@@ -23,7 +17,7 @@ TEST glusterd + TEST pidof glusterd; + TEST $CLI volume info; + +-TEST $CLI volume create $V0 $H0:$B0/${V0}{1}; ++TEST $CLI volume create $V0 $H0:$B0/${V0}; + TEST $CLI volume start $V0; + + TEST $CLI volume quota $V0 enable; +@@ -47,7 +41,7 @@ echo "Wait for process with pid $PID to complete" + wait $PID + echo "Process with pid $PID finished" + +-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "100.0MB" usage "/" ++EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "100.0MB" quotausage "/" + + TEST $CLI volume stop $V0 + TEST $CLI volume delete $V0 +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index df0572f..16ad0fc 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -155,7 +155,7 @@ err: + + + int32_t +-quota_local_cleanup (xlator_t *this, quota_local_t *local) ++quota_local_cleanup (quota_local_t *local) + { + if (local == NULL) { + goto out; +@@ -243,6 +243,31 @@ out: + return; + } + ++void ++__quota_dentry_del (quota_inode_ctx_t *ctx, const char *name, uuid_t par) ++{ ++ quota_dentry_t *dentry = NULL; ++ quota_dentry_t *tmp = NULL; ++ ++ list_for_each_entry_safe (dentry, tmp, &ctx->parents, next) { ++ if ((strcmp (dentry->name, name) == 0) && ++ (gf_uuid_compare (dentry->par, par) == 0)) { ++ __quota_dentry_free (dentry); ++ break; ++ } ++ } ++} ++ ++void ++quota_dentry_del (quota_inode_ctx_t *ctx, const char *name, uuid_t par) ++{ ++ LOCK (&ctx->lock); ++ { ++ __quota_dentry_del (ctx, name, par); ++ } ++ UNLOCK (&ctx->lock); ++} ++ + static inline inode_t* + __quota_inode_parent (inode_t *inode, uuid_t pargfid, const char *name) + { +@@ -485,10 +510,18 @@ out: + } + + static inline void +-quota_link_count_decrement (quota_local_t *local) ++quota_link_count_decrement (call_frame_t *frame) + { +- call_stub_t *stub = NULL; +- int link_count = -1; ++ call_frame_t *tmpframe = NULL; ++ quota_local_t *local = NULL; ++ call_stub_t *stub = NULL; ++ int link_count = -1; ++ ++ local = frame->local; ++ if (local && local->par_frame) { ++ local = local->par_frame->local; ++ tmpframe = frame; ++ } + + if (local == NULL) + goto out; +@@ -506,14 +539,30 @@ quota_link_count_decrement (quota_local_t *local) + if (stub != NULL) { + call_resume (stub); + } ++ + out: ++ if (tmpframe) { ++ local = tmpframe->local; ++ tmpframe->local = NULL; ++ ++ STACK_DESTROY (frame->root); ++ if (local) ++ quota_local_cleanup (local); ++ } ++ + return; + } + + static inline void +-quota_handle_validate_error (quota_local_t *local, int32_t op_ret, ++quota_handle_validate_error (call_frame_t *frame, int32_t op_ret, + int32_t op_errno) + { ++ quota_local_t *local; ++ ++ local = frame->local; ++ if (local && local->par_frame) ++ local = local->par_frame->local; ++ + if (local == NULL) + goto out; + +@@ -527,7 +576,7 @@ quota_handle_validate_error (quota_local_t *local, int32_t op_ret, + UNLOCK (&local->lock); + + /* we abort checking limits on this path to root */ +- quota_link_count_decrement (local); ++ quota_link_count_decrement (frame); + out: + return; + } +@@ -595,7 +644,7 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + + unwind: +- quota_handle_validate_error (local, op_ret, op_errno); ++ quota_handle_validate_error (frame, op_ret, op_errno); + return 0; + } + +@@ -622,27 +671,65 @@ quota_timeout (struct timeval *tv, int32_t timeout) + return timed_out; + } + +-static inline void +-quota_add_parent (quota_dentry_t *dentry, struct list_head *list) ++/* Return: 1 if new entry added ++ * 0 no entry added ++ */ ++static inline int32_t ++quota_add_parent (struct list_head *list, char *name, uuid_t pgfid) + { + quota_dentry_t *entry = NULL; + gf_boolean_t found = _gf_false; + +- if ((dentry == NULL) || (list == NULL)) { ++ if (list == NULL) { + goto out; + } + + list_for_each_entry (entry, list, next) { +- if (gf_uuid_compare (dentry->par, entry->par) == 0) { ++ if (gf_uuid_compare (pgfid, entry->par) == 0) { + found = _gf_true; + goto out; + } + } + +- list_add_tail (&dentry->next, list); ++ entry = __quota_dentry_new (NULL, name, pgfid); ++ list_add_tail (&entry->next, list); + + out: +- return; ++ if (found) ++ return 0; ++ else ++ return 1; ++ ++} ++ ++/* This function iterates the parent list in inode ++ * context and add unique parent to the list ++ * Returns number of dentry added to the list ++ */ ++static inline int32_t ++quota_add_parents_from_ctx (quota_inode_ctx_t *ctx, struct list_head *list) ++{ ++ int ret = 0; ++ quota_dentry_t *dentry = NULL; ++ int32_t count = 0; ++ ++ if (ctx == NULL || list == NULL) ++ goto out; ++ ++ LOCK (&ctx->lock); ++ { ++ list_for_each_entry (dentry, &ctx->parents, next) { ++ ret = quota_add_parent (list, dentry->name, ++ dentry->par); ++ ++ if (ret == 1) ++ count++; ++ } ++ } ++ UNLOCK (&ctx->lock); ++ ++out: ++ return count; + } + + int32_t +@@ -708,23 +795,7 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + quota_inode_ctx_get (local->loc.inode, this, &ctx, 0); + +- if (ctx != NULL) { +- LOCK (&ctx->lock); +- { +- list_for_each_entry (dentry, &ctx->parents, next) { +- /* we built ancestry for a non-directory */ +- tmp = __quota_dentry_new (NULL, dentry->name, +- dentry->par); +- quota_add_parent (tmp, &parents); +- +- if (list_empty (&tmp->next)) { +- __quota_dentry_free (tmp); +- tmp = NULL; +- } +- } +- } +- UNLOCK (&ctx->lock); +- } ++ quota_add_parents_from_ctx (ctx, &parents); + + if (list_empty (&parents)) { + /* we built ancestry for a directory */ +@@ -735,8 +806,7 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + GF_ASSERT (&entry->list != &entries->list); + +- tmp = __quota_dentry_new (NULL, entry->d_name, parent->gfid); +- quota_add_parent (tmp, &parents); ++ quota_add_parent (&parents, entry->d_name, parent->gfid); + } + + local->ancestry_cbk (&parents, local->loc.inode, 0, 0, +@@ -748,7 +818,7 @@ err: + + cleanup: + STACK_DESTROY (frame->root); +- quota_local_cleanup (this, local); ++ quota_local_cleanup (local); + + if (parent != NULL) { + inode_unref (parent); +@@ -838,7 +908,7 @@ err: + } + + if (local) +- quota_local_cleanup (this, local); ++ quota_local_cleanup (local); + } + + return 0; +@@ -919,6 +989,7 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + call_frame_t *frame = NULL; + xlator_t *this = NULL; + quota_local_t *local = NULL; ++ quota_local_t *par_local = NULL; + quota_dentry_t *entry = NULL; + inode_t *parent = NULL; + int parent_count = 0; +@@ -927,6 +998,12 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + local = frame->local; + this = THIS; + ++ if (local->par_frame) ++ par_local = local->par_frame->local; ++ else ++ par_local = local; ++ ++ + if ((op_ret < 0) || list_empty (parents)) { + if (op_ret >= 0) { + gf_msg (this->name, GF_LOG_WARNING, EIO, +@@ -939,7 +1016,7 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + op_errno = EIO; + } + +- quota_handle_validate_error (local, -1, op_errno); ++ quota_handle_validate_error (frame, -1, op_errno); + goto out; + } + +@@ -947,16 +1024,27 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + parent_count++; + } + +- LOCK (&local->lock); ++ LOCK (&par_local->lock); + { +- local->link_count += (parent_count - 1); ++ par_local->link_count += (parent_count - 1); + } +- UNLOCK (&local->lock); ++ UNLOCK (&par_local->lock); + +- list_for_each_entry (entry, parents, next) { +- parent = inode_find (inode->table, entry->par); +- quota_check_limit (frame, parent, this, NULL, NULL); +- inode_unref (parent); ++ if (local->par_frame) { ++ list_for_each_entry (entry, parents, next) { ++ parent = inode_find (inode->table, entry->par); ++ quota_check_limit (frame, parent, this, NULL, NULL); ++ inode_unref (parent); ++ } ++ } else { ++ list_for_each_entry (entry, parents, next) { ++ parent = do_quota_check_limit (frame, inode, this, ++ entry); ++ if (parent) ++ inode_unref (parent); ++ else ++ quota_link_count_decrement (frame); ++ } + } + + out: +@@ -1129,6 +1217,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + quota_inode_ctx_t *ctx = NULL; + quota_priv_t *priv = NULL; + quota_local_t *local = NULL; ++ quota_local_t *par_local = NULL; + char need_validate = 0; + char just_validated = 0; + gf_boolean_t hard_limit_exceeded = 0; +@@ -1144,9 +1233,16 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + local = frame->local; + GF_VALIDATE_OR_GOTO (this->name, local, err); + +- delta = local->delta; ++ if (local->par_frame) { ++ par_local = local->par_frame->local; ++ GF_VALIDATE_OR_GOTO (this->name, par_local, err); ++ } else { ++ par_local = local; ++ } ++ ++ delta = par_local->delta; + +- GF_VALIDATE_OR_GOTO (this->name, local->stub, err); ++ GF_VALIDATE_OR_GOTO (this->name, par_local->stub, err); + /* Allow all the trusted clients + * Don't block the gluster internal processes like rebalance, gsyncd, + * self heal etc from the disk quotas. +@@ -1157,7 +1253,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + */ + if (0 > frame->root->pid) { + ret = 0; +- quota_link_count_decrement (local); ++ quota_link_count_decrement (frame); + goto done; + } + +@@ -1182,15 +1278,16 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + do { + /* In a rename operation, enforce should be stopped at common + ancestor */ +- if (!gf_uuid_is_null (local->common_ancestor) && +- !gf_uuid_compare (_inode->gfid, local->common_ancestor)) { +- quota_link_count_decrement (local); ++ if (!gf_uuid_is_null (par_local->common_ancestor) && ++ !gf_uuid_compare (_inode->gfid, par_local->common_ancestor) ++ ) { ++ quota_link_count_decrement (frame); + break; + } + + ret = quota_check_object_limit (frame, ctx, priv, _inode, this, + &op_errno, just_validated, +- local, &skip_check); ++ par_local, &skip_check); + if (skip_check == _gf_true) + goto done; + +@@ -1203,7 +1300,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + + ret = quota_check_size_limit (frame, ctx, priv, _inode, this, + &op_errno, just_validated, delta, +- local, &skip_check); ++ par_local, &skip_check); + if (skip_check == _gf_true) + goto done; + +@@ -1215,7 +1312,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + } + + if (__is_root_gfid (_inode->gfid)) { +- quota_link_count_decrement (local); ++ quota_link_count_decrement (frame); + break; + } + +@@ -1228,8 +1325,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + + if (parent == NULL) { + ret = quota_build_ancestry (_inode, +- quota_check_limit_continuation, +- frame); ++ quota_check_limit_continuation, ++ frame); + if (ret < 0) { + op_errno = -ret; + goto err; +@@ -1247,7 +1344,6 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + ctx = (quota_inode_ctx_t *)(unsigned long)value; + } while (1); + +- + done: + if (_inode != NULL) { + inode_unref (_inode); +@@ -1256,12 +1352,66 @@ done: + return 0; + + err: +- quota_handle_validate_error (local, -1, op_errno); ++ quota_handle_validate_error (frame, -1, op_errno); + + inode_unref (_inode); + return 0; + } + ++inode_t * ++do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, ++ quota_dentry_t *dentry) ++{ ++ int32_t ret = -1; ++ inode_t *parent = NULL; ++ call_frame_t *new_frame = NULL; ++ quota_local_t *local = NULL; ++ quota_local_t *new_local = NULL; ++ ++ local = frame->local; ++ ++ parent = inode_parent (inode, dentry->par, dentry->name); ++ if (parent == NULL) ++ parent = inode_find (inode->table, dentry->par); ++ if (parent == NULL) ++ goto out; ++ ++ new_frame = create_frame (this, this->ctx->pool); ++ if (new_frame == NULL) ++ goto out; ++ ++ new_local = quota_local_new (); ++ if (new_local == NULL) ++ goto out; ++ ++ new_frame->root->uid = new_frame->root->gid = 0; ++ new_frame->local = new_local; ++ new_local->par_frame = frame; ++ ++ quota_check_limit (new_frame, parent, this, NULL, NULL); ++ ++ ret = 0; ++out: ++ if (ret < 0) { ++ if (parent) { ++ /* Caller should decrement link_count, in case parent is ++ * NULL ++ */ ++ quota_handle_validate_error (frame, -1, ENOMEM); ++ } ++ ++ if (new_frame) { ++ new_frame->local = NULL; ++ STACK_DESTROY (new_frame->root); ++ } ++ ++ if (new_local) ++ quota_local_cleanup (new_local); ++ } ++ ++ return parent; ++} ++ + static inline int + quota_get_limits (xlator_t *this, dict_t *dict, int64_t *hard_lim, + int64_t *soft_lim, int64_t *object_hard_limit, +@@ -1440,7 +1590,7 @@ out: + if (this_inode) + inode_unref (this_inode); + +- quota_local_cleanup (this, local); ++ quota_local_cleanup (local); + + return 0; + } +@@ -1632,15 +1782,17 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + struct iovec *vector, int32_t count, off_t off, + uint32_t flags, struct iobref *iobref, dict_t *xdata) + { +- quota_priv_t *priv = NULL; +- int32_t ret = -1, op_errno = EINVAL; +- int32_t parents = 0; +- uint64_t size = 0; +- quota_local_t *local = NULL; +- quota_inode_ctx_t *ctx = NULL; +- quota_dentry_t *dentry = NULL, *tmp = NULL; +- call_stub_t *stub = NULL; +- struct list_head head = {0, }; ++ quota_priv_t *priv = NULL; ++ int32_t ret = -1, op_errno = EINVAL; ++ int32_t parents = 0; ++ int32_t fail_count = 0; ++ uint64_t size = 0; ++ quota_local_t *local = NULL; ++ quota_inode_ctx_t *ctx = NULL; ++ quota_dentry_t *dentry = NULL, *tmp = NULL; ++ call_stub_t *stub = NULL; ++ struct list_head head = {0, }; ++ inode_t *par_inode = NULL; + + priv = this->private; + +@@ -1679,18 +1831,8 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + GF_VALIDATE_OR_GOTO (this->name, priv, unwind); + + size = iov_length (vector, count); +- if (ctx != NULL) { +- LOCK (&ctx->lock); +- { +- list_for_each_entry (dentry, &ctx->parents, next) { +- tmp = __quota_dentry_new (NULL, dentry->name, +- dentry->par); +- list_add_tail (&tmp->next, &head); +- parents++; +- } +- } +- UNLOCK (&ctx->lock); +- } ++ ++ parents = quota_add_parents_from_ctx (ctx, &head); + + LOCK (&local->lock); + { +@@ -1707,10 +1849,33 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + quota_check_limit (frame, fd->inode, this, NULL, NULL); + } else { + list_for_each_entry_safe (dentry, tmp, &head, next) { +- quota_check_limit (frame, fd->inode, this, dentry->name, +- dentry->par); ++ par_inode = do_quota_check_limit (frame, fd->inode, ++ this, dentry); ++ if (par_inode == NULL) { ++ /* remove stale entry from inode ctx */ ++ quota_dentry_del (ctx, dentry->name, ++ dentry->par); ++ parents--; ++ fail_count++; ++ } else { ++ inode_unref (par_inode); ++ } + __quota_dentry_free (dentry); + } ++ ++ if (parents == 0) { ++ LOCK (&local->lock); ++ { ++ local->link_count++; ++ } ++ UNLOCK (&local->lock); ++ quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ } ++ ++ while (fail_count != 0) { ++ quota_link_count_decrement (frame); ++ fail_count--; ++ } + } + + return 0; +@@ -1986,8 +2151,6 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + quota_local_t *local = NULL; + quota_inode_ctx_t *ctx = NULL; + uint64_t value = 0; +- quota_dentry_t *dentry = NULL; +- quota_dentry_t *old_dentry = NULL; + + if (op_ret < 0) { + goto out; +@@ -2006,20 +2169,7 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + } + +- LOCK (&ctx->lock); +- { +- list_for_each_entry (dentry, &ctx->parents, next) { +- if ((strcmp (dentry->name, local->loc.name) == 0) && +- (gf_uuid_compare (local->loc.parent->gfid, +- dentry->par) == 0)) { +- old_dentry = dentry; +- break; +- } +- } +- if (old_dentry) +- __quota_dentry_free (old_dentry); +- } +- UNLOCK (&ctx->lock); ++ quota_dentry_del (ctx, local->loc.name, local->loc.parent->gfid); + + out: + QUOTA_STACK_UNWIND (unlink, frame, op_ret, op_errno, preparent, +@@ -2267,7 +2417,7 @@ off: + FIRST_CHILD(this)->fops->link, &(local->oldloc), + &(local->newloc), local->xdata); + +- quota_local_cleanup (this, local); ++ quota_local_cleanup (local); + return; + } + +@@ -2526,7 +2676,7 @@ quota_rename_get_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + + out: +- quota_handle_validate_error (local, -1, op_errno); ++ quota_handle_validate_error (frame, -1, op_errno); + return 0; + } + +@@ -4230,7 +4380,7 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + UNLOCK (&ctx->lock); + + resume: +- quota_link_count_decrement (local); ++ quota_link_count_decrement (frame); + return 0; + } + +@@ -4260,7 +4410,7 @@ quota_get_limit_dir_continuation (struct list_head *parents, inode_t *inode, + op_errno = EIO; + } + +- quota_handle_validate_error (local, -1, op_errno); ++ quota_handle_validate_error (frame, -1, op_errno); + goto out; + } + +@@ -4290,7 +4440,7 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode) + ret = quota_validate (frame, local->inode, this, + quota_statfs_validate_cbk); + if (0 > ret) +- quota_handle_validate_error (local, -1, -ret); ++ quota_handle_validate_error (frame, -1, -ret); + } + + void +@@ -4642,13 +4792,17 @@ int32_t + quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata) + { +- int32_t ret = -1, op_errno = EINVAL; +- int32_t parents = 0; +- quota_local_t *local = NULL; +- quota_inode_ctx_t *ctx = NULL; +- quota_priv_t *priv = NULL; +- quota_dentry_t *dentry = NULL; +- call_stub_t *stub = NULL; ++ int32_t ret = -1, op_errno = EINVAL; ++ int32_t parents = 0; ++ int32_t fail_count = 0; ++ quota_local_t *local = NULL; ++ quota_inode_ctx_t *ctx = NULL; ++ quota_priv_t *priv = NULL; ++ quota_dentry_t *dentry = NULL; ++ quota_dentry_t *tmp = NULL; ++ call_stub_t *stub = NULL; ++ struct list_head head = {0, }; ++ inode_t *par_inode = NULL; + + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, unwind); +@@ -4685,15 +4839,7 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, unwind); + +- if (ctx != NULL) { +- LOCK (&ctx->lock); +- { +- list_for_each_entry (dentry, &ctx->parents, next) { +- parents++; +- } +- } +- UNLOCK (&ctx->lock); +- } ++ parents = quota_add_parents_from_ctx (ctx, &head); + + /* + * Note that by using len as the delta we're assuming the range from +@@ -4708,9 +4854,33 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + local->link_count = 1; + quota_check_limit (frame, fd->inode, this, NULL, NULL); + } else { +- list_for_each_entry (dentry, &ctx->parents, next) { +- quota_check_limit (frame, fd->inode, this, dentry->name, +- dentry->par); ++ list_for_each_entry_safe (dentry, tmp, &head, next) { ++ par_inode = do_quota_check_limit (frame, fd->inode, ++ this, dentry); ++ if (par_inode == NULL) { ++ /* remove stale entry from inode_ctx */ ++ quota_dentry_del (ctx, dentry->name, ++ dentry->par); ++ parents--; ++ fail_count++; ++ } else { ++ inode_unref (par_inode); ++ } ++ __quota_dentry_free (dentry); ++ } ++ ++ if (parents == 0) { ++ LOCK (&local->lock); ++ { ++ local->link_count++; ++ } ++ UNLOCK (&local->lock); ++ quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ } ++ ++ while (fail_count != 0) { ++ quota_link_count_decrement (frame); ++ fail_count--; + } + } + +diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h +index 56876f0..0f8cecd 100644 +--- a/xlators/features/quota/src/quota.h ++++ b/xlators/features/quota/src/quota.h +@@ -102,7 +102,7 @@ + STACK_WIND_TAIL (frame, params); \ + \ + if (_local) \ +- quota_local_cleanup (_this, _local); \ ++ quota_local_cleanup (_local); \ + } while (0) + + #define QUOTA_STACK_UNWIND(fop, frame, params...) \ +@@ -115,7 +115,7 @@ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT (fop, frame, params); \ +- quota_local_cleanup (_this, _local); \ ++ quota_local_cleanup (_local); \ + } while (0) + + #define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \ +@@ -193,7 +193,6 @@ typedef void + + struct quota_local { + gf_lock_t lock; +- uint32_t validate_count; + uint32_t link_count; + loc_t loc; + loc_t oldloc; +@@ -219,6 +218,7 @@ struct quota_local { + dict_t *validate_xdata; + int32_t quotad_conn_retry; + xlator_t *this; ++ call_frame_t *par_frame; + }; + typedef struct quota_local quota_local_t; + +@@ -266,6 +266,9 @@ int32_t + quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + char *name, uuid_t par); + ++inode_t * ++do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, ++ quota_dentry_t *dentry); + int + quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict, + loc_t *loc, struct iatt *buf, int32_t *op_errno); +-- +1.7.1 + diff --git a/SOURCES/0259-quota-don-t-log-error-when-disk-quota-exceeded.patch b/SOURCES/0259-quota-don-t-log-error-when-disk-quota-exceeded.patch new file mode 100644 index 0000000..51646b5 --- /dev/null +++ b/SOURCES/0259-quota-don-t-log-error-when-disk-quota-exceeded.patch @@ -0,0 +1,72 @@ +From 74697128b4bbf2c6bb501ce6f75cad103faa8e68 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Mon, 15 Jun 2015 11:21:12 +0530 +Subject: [PATCH 259/279] quota: don't log error when disk quota exceeded + +This is a backport of http://review.gluster.org/11135 + +When disk quota exceeded, quota enforcer logs +alert message, so no need to log error message +as this can fill up the log file + +> Change-Id: Ia913f47bc0cedb7c0a9c611330ee5124d3bb6c9d +> BUG: 1229609 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11135 +> Tested-by: Gluster Build System +> Reviewed-by: Raghavendra G +> Tested-by: Raghavendra G + +BUG: 1229606 +Change-Id: I3d0b6a2aec45b350093625db3c1b053d0c331846 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55059 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 15 +++++++++------ + 1 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index 16ad0fc..a444713 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -1108,6 +1108,7 @@ quota_check_object_limit (call_frame_t *frame, quota_inode_ctx_t *ctx, + local->op_ret = -1; + local->op_errno = EDQUOT; + *op_errno = EDQUOT; ++ goto out; + } + + /*We log usage only if quota limit is configured on +@@ -1292,9 +1293,10 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + goto done; + + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- Q_MSG_ENFORCEMENT_FAILED, "Failed to check " +- "quota object limit"); ++ if (op_errno != EDQUOT) ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_ENFORCEMENT_FAILED, "Failed to " ++ "check quota object limit"); + goto err; + } + +@@ -1305,9 +1307,10 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + goto done; + + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- Q_MSG_ENFORCEMENT_FAILED, "Failed to check " +- "quota size limit"); ++ if (op_errno != EDQUOT) ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ Q_MSG_ENFORCEMENT_FAILED, "Failed to " ++ "check quota size limit"); + goto err; + } + +-- +1.7.1 + diff --git a/SOURCES/0260-posix-posix_make_ancestryfromgfid-shouldn-t-log-ENOE.patch b/SOURCES/0260-posix-posix_make_ancestryfromgfid-shouldn-t-log-ENOE.patch new file mode 100644 index 0000000..0988308 --- /dev/null +++ b/SOURCES/0260-posix-posix_make_ancestryfromgfid-shouldn-t-log-ENOE.patch @@ -0,0 +1,133 @@ +From 7660b98f1987c24746fe912065a474c7fa189644 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Fri, 7 Aug 2015 15:51:53 +0530 +Subject: [PATCH 260/279] posix: posix_make_ancestryfromgfid shouldn't log ENOENT + +This is a backport of http://review.gluster.org/11861 + +posix_make_ancestryfromgfid shouldn't log ENOENT +and it should set proper op_errno + +> Change-Id: I8a87f30bc04d33cab06c91c74baa9563a1c7b45d +> BUG: 1251449 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11861 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Manikandan Selvaganesh +> Reviewed-by: Raghavendra G + +Change-Id: I5e17413b09ef726b1eeec46adbbce1e5f0503da9 +BUG: 1229621 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55078 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/storage/posix/src/posix-handle.c | 17 ++++++++++++----- + xlators/storage/posix/src/posix-handle.h | 2 +- + xlators/storage/posix/src/posix.c | 5 +++-- + 3 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c +index 281d52f..96e7098 100644 +--- a/xlators/storage/posix/src/posix-handle.c ++++ b/xlators/storage/posix/src/posix-handle.c +@@ -102,7 +102,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + gf_dirent_t *head, int type, uuid_t gfid, + const size_t handle_size, + const char *priv_base_path, inode_table_t *itable, +- inode_t **parent, dict_t *xdata) ++ inode_t **parent, dict_t *xdata, int32_t *op_errno) + { + char *linkname = NULL; /* "../..///" */ +@@ -117,6 +117,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + uuid_t tmp_gfid = {0, }; + + if (!path || !parent || !priv_base_path || gf_uuid_is_null (gfid)) { ++ *op_errno = EINVAL; + goto out; + } + +@@ -138,6 +139,8 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + ret = posix_make_ancestral_node (priv_base_path, path, pathsize, + head, "/", &iabuf, inode, type, + xdata); ++ if (ret < 0) ++ *op_errno = ENOMEM; + return ret; + } + +@@ -149,9 +152,12 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + + len = readlink (dir_handle, linkname, PATH_MAX); + if (len < 0) { +- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED, +- "could not read the link from the gfid handle %s ", +- dir_handle); ++ gf_msg (this->name, (errno == ENOENT || errno == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, errno, ++ P_MSG_READLINK_FAILED, "could not read the link from " ++ "the gfid handle %s ", dir_handle); ++ ret = -1; ++ *op_errno = errno; + goto out; + } + +@@ -165,7 +171,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + ret = posix_make_ancestryfromgfid (this, path, pathsize, head, type, + tmp_gfid, handle_size, + priv_base_path, itable, parent, +- xdata); ++ xdata, op_errno); + if (ret < 0) { + goto out; + } +@@ -174,6 +180,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + + inode = posix_resolve (this, itable, *parent, dir_name, &iabuf); + if (inode == NULL) { ++ *op_errno = ESTALE; + ret = -1; + goto out; + } +diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h +index 356b7b9..76ef854 100644 +--- a/xlators/storage/posix/src/posix-handle.h ++++ b/xlators/storage/posix/src/posix-handle.h +@@ -260,7 +260,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, + const size_t handle_size, + const char *priv_base_path, + inode_table_t *table, inode_t **parent, +- dict_t *xdata); ++ dict_t *xdata, int32_t *op_errno); + int + posix_handle_path_safe (xlator_t *this, uuid_t gfid, const char *basename, + char *buf, size_t len); +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 58f68eb..60acac4 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3482,7 +3482,8 @@ posix_get_ancestry_directory (xlator_t *this, inode_t *leaf_inode, + type | POSIX_ANCESTRY_PATH, + leaf_inode->gfid, + handle_size, priv->base_path, +- leaf_inode->table, &inode, xdata); ++ leaf_inode->table, &inode, xdata, ++ op_errno); + if (ret < 0) + goto out; + +@@ -3736,7 +3737,7 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, + handle_size, + priv->base_path, + leaf_inode->table, +- &parent, xdata); ++ &parent, xdata, op_errno); + if (op_ret < 0) { + goto next; + } +-- +1.7.1 + diff --git a/SOURCES/0261-quota-validating-soft-limit-percentage.patch b/SOURCES/0261-quota-validating-soft-limit-percentage.patch new file mode 100644 index 0000000..ff414ae --- /dev/null +++ b/SOURCES/0261-quota-validating-soft-limit-percentage.patch @@ -0,0 +1,41 @@ +From db45f6f3cf571a518788e451f758c59249da949a Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Tue, 7 Jul 2015 18:37:42 +0530 +Subject: [PATCH 261/279] quota : validating soft limit percentage + +> Reviewed-on: http://review.gluster.org/11566 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Vijaikumar Mallikarjuna +> Reviewed-by: Raghavendra G + +Change-Id: I14c049c84c468b6415a1de45441b2fed94e8ed4b +BUG: 1064265 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: https://code.engineering.redhat.com/gerrit/55071 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + cli/src/cli-cmd-parser.c | 6 ++++-- + 1 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 51da792..8f3396f 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -1116,8 +1116,10 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) + if (wordcount == 7) { + + ret = gf_string2percent (words[6], &percent); +- if (ret != 0) { +- cli_err ("Please enter a correct value"); ++ if (ret != 0 || percent > 100) { ++ ret = -1; ++ cli_err ("Please enter a correct value " ++ "in the range of 0 to 100"); + goto out; + } + +-- +1.7.1 + diff --git a/SOURCES/0262-quota-marker-set-log-level-to-debug-for-ESTALE-ENOEN.patch b/SOURCES/0262-quota-marker-set-log-level-to-debug-for-ESTALE-ENOEN.patch new file mode 100644 index 0000000..6672fda --- /dev/null +++ b/SOURCES/0262-quota-marker-set-log-level-to-debug-for-ESTALE-ENOEN.patch @@ -0,0 +1,225 @@ +From a7243a35ee2f6f1c891ebd12bd38dadb22d4709b Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 13 Aug 2015 14:16:45 +0530 +Subject: [PATCH 262/279] quota/marker: set log-level to debug for ESTALE/ENOENT for marker txn + +This is a backport of http://review.gluster.org/11736 + +For all marker txn, it is possible that while the txn in progress +file can be removed. + +So log all ENOENT/ESTALE error in debug level + +> Change-Id: I776ba3cda33fe992f9dcc7baede7206c4ce19553 +> BUG: 1245544 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11736 +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G + +BUG: 1245542 +Change-Id: I44fdb860fb941f877e6ed12e8e9690369f45b9fa +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55063 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 91 ++++++++++------------------ + 1 files changed, 33 insertions(+), 58 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index f65ed77..6ccd974 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2183,9 +2183,9 @@ mq_are_xattrs_set (xlator_t *this, loc_t *loc, gf_boolean_t *result, + ret = syncop_lookup (FIRST_CHILD(this), loc, &stbuf, NULL, + dict, &rsp_dict); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2272,13 +2272,13 @@ mq_create_xattrs (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, + goto out; + } + +- ret = syncop_xattrop(FIRST_CHILD(this), loc, GF_XATTROP_ADD_ARRAY64, +- dict, NULL, NULL); ++ ret = syncop_xattrop (FIRST_CHILD(this), loc, GF_XATTROP_ADD_ARRAY64, ++ dict, NULL, NULL); + + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2312,9 +2312,9 @@ mq_lock (xlator_t *this, loc_t *loc, short l_type) + ret = syncop_inodelk (FIRST_CHILD(this), this->name, loc, F_SETLKW, + &lock, NULL, NULL); + if (ret < 0) +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "inodelk failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "inodelk failed " ++ "for %s: %s", loc->path, strerror (-ret)); + + out: + +@@ -2345,9 +2345,9 @@ mq_get_dirty (xlator_t *this, loc_t *loc, int32_t *dirty) + ret = syncop_lookup (FIRST_CHILD(this), loc, &stbuf, NULL, + dict, &rsp_dict); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2391,7 +2391,7 @@ mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) + + ret = syncop_setxattr (FIRST_CHILD(this), loc, dict, 0, NULL, NULL); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) + ? GF_LOG_DEBUG:GF_LOG_ERROR, "setxattr dirty = %d " + "failed for %s: %s", dirty, loc->path, strerror (-ret)); + goto out; +@@ -2458,9 +2458,9 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, + ret = syncop_lookup (FIRST_CHILD(this), loc, &stbuf, NULL, + dict, &rsp_dict); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "lookup failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2527,11 +2527,8 @@ mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, + } + + ret = _mq_get_metadata (this, loc, contri, size, contribution->gfid); +- if (ret < 0) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, "Failed to get " +- "metadata for %s", loc->path); ++ if (ret < 0) + goto out; +- } + + if (size) { + LOCK (&ctx->lock); +@@ -2560,34 +2557,14 @@ out: + int32_t + mq_get_size (xlator_t *this, loc_t *loc, quota_meta_t *size) + { +- int32_t ret = -1; +- +- ret = _mq_get_metadata (this, loc, NULL, size, 0); +- if (ret < 0) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, "Failed to get " +- "metadata for %s", loc->path); +- goto out; +- } +- +-out: +- return ret; ++ return _mq_get_metadata (this, loc, NULL, size, 0); + } + + int32_t + mq_get_contri (xlator_t *this, loc_t *loc, quota_meta_t *contri, + uuid_t contri_gfid) + { +- int32_t ret = -1; +- +- ret = _mq_get_metadata (this, loc, contri, NULL, contri_gfid); +- if (ret < 0) { +- gf_log_callingfn (this->name, GF_LOG_ERROR, "Failed to get " +- "metadata for %s", loc->path); +- goto out; +- } +- +-out: +- return ret; ++ return _mq_get_metadata (this, loc, contri, NULL, contri_gfid); + } + + int32_t +@@ -2642,9 +2619,10 @@ mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + */ + ret = 0; + } else { +- gf_log (this->name, GF_LOG_ERROR, "removexattr %s " +- "failed for %s: %s", contri_key, loc->path, +- strerror (-ret)); ++ gf_log_callingfn (this->name, GF_LOG_ERROR, ++ "removexattr %s failed for %s: %s", ++ contri_key, loc->path, ++ strerror (-ret)); + goto out; + } + } +@@ -2706,9 +2684,9 @@ mq_update_contri (xlator_t *this, loc_t *loc, inode_contribution_t *contri, + ret = syncop_xattrop(FIRST_CHILD(this), loc, GF_XATTROP_ADD_ARRAY64, + dict, NULL, NULL); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2765,9 +2743,9 @@ mq_update_size (xlator_t *this, loc_t *loc, quota_meta_t *delta) + ret = syncop_xattrop(FIRST_CHILD(this), loc, GF_XATTROP_ADD_ARRAY64, + dict, NULL, NULL); + if (ret < 0) { +- gf_log (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " +- "for %s: %s", loc->path, strerror (-ret)); ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + +@@ -2949,15 +2927,12 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + dirty = _gf_true; + + ret = mq_update_contri (this, &child_loc, contri, &delta); +- if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "contri " +- "update failed for %s", child_loc.path); ++ if (ret < 0) + goto out; +- } + + ret = mq_update_size (this, &parent_loc, &delta); + if (ret < 0) { +- gf_log (this->name, GF_LOG_WARNING, "rollback " ++ gf_log (this->name, GF_LOG_DEBUG, "rollback " + "contri updation"); + mq_sub_meta (&delta, NULL); + mq_update_contri (this, &child_loc, contri, &delta); +-- +1.7.1 + diff --git a/SOURCES/0263-quota-fix-parents-caching-during-build-ancestry.patch b/SOURCES/0263-quota-fix-parents-caching-during-build-ancestry.patch new file mode 100644 index 0000000..f1c908a --- /dev/null +++ b/SOURCES/0263-quota-fix-parents-caching-during-build-ancestry.patch @@ -0,0 +1,494 @@ +From 753f881856efa3d55ea16dd5b088423da683c7f6 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 13 Aug 2015 14:14:41 +0530 +Subject: [PATCH 263/279] quota: fix parents caching during build ancestry + +This is a backport of http://review.gluster.org/11574 + +In build ancestry, we get the list of parents for a file, +these parents are cached in inode ctx. +This caching is not happening because posix is not setting +d_stat information in the leaf node entry +This patch fixes the issue + +Inode-ctx is not updated with new parent when +rename performed on same directory. +This patch fixes the issue + +There is a possibility of caching stale entries, +consider below example: +1) build_ancestry invoked on a file +2) rename is invoked on the same file +3) buils_ancestry prepared entries of old parent +4) rename completed and in cbk old parent is replaced with + new parent in inode ctx +5) now build_ancestry cbk adds old parent to inode ctx + +In this patch we also remove stale entries in writev and fallocate + +> Change-Id: Ib1854a41b47b14eb775326588352015c83d034de +> BUG: 1240949 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11574 +> Tested-by: Gluster Build System +> Reviewed-by: Raghavendra G + +BUG: 1245448 +Change-Id: I71f514aa9285bb3493b9aee9443009b32d2c5a77 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55062 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/quota/src/quota.c | 147 ++++++++++++++++++------------------ + xlators/features/quota/src/quota.h | 5 +- + xlators/storage/posix/src/posix.c | 9 +- + 3 files changed, 82 insertions(+), 79 deletions(-) + +diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c +index a444713..30445c4 100644 +--- a/xlators/features/quota/src/quota.c ++++ b/xlators/features/quota/src/quota.c +@@ -640,7 +640,7 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + UNLOCK (&ctx->lock); + +- quota_check_limit (frame, local->validate_loc.inode, this, NULL, NULL); ++ quota_check_limit (frame, local->validate_loc.inode, this); + return 0; + + unwind: +@@ -1033,13 +1033,13 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode, + if (local->par_frame) { + list_for_each_entry (entry, parents, next) { + parent = inode_find (inode->table, entry->par); +- quota_check_limit (frame, parent, this, NULL, NULL); ++ quota_check_limit (frame, parent, this); + inode_unref (parent); + } + } else { + list_for_each_entry (entry, parents, next) { + parent = do_quota_check_limit (frame, inode, this, +- entry); ++ entry, _gf_true); + if (parent) + inode_unref (parent); + else +@@ -1210,8 +1210,7 @@ out: + + + int32_t +-quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, +- char *name, uuid_t par) ++quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this) + { + int32_t ret = -1, op_errno = EINVAL; + inode_t *_inode = NULL, *parent = NULL; +@@ -1224,7 +1223,6 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + gf_boolean_t hard_limit_exceeded = 0; + int64_t delta = 0; + uint64_t value = 0; +- uuid_t trav_uuid = {0,}; + gf_boolean_t skip_check = _gf_false; + + GF_VALIDATE_OR_GOTO ("quota", this, err); +@@ -1272,10 +1270,6 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + } + UNLOCK (&local->lock); + +- if ( par != NULL ) { +- gf_uuid_copy (trav_uuid, par); +- } +- + do { + /* In a rename operation, enforce should be stopped at common + ancestor */ +@@ -1319,13 +1313,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + break; + } + +- parent = inode_parent (_inode, trav_uuid, name); +- +- if (name != NULL) { +- name = NULL; +- gf_uuid_clear (trav_uuid); +- } +- ++ parent = inode_parent (_inode, 0, NULL); + if (parent == NULL) { + ret = quota_build_ancestry (_inode, + quota_check_limit_continuation, +@@ -1363,7 +1351,7 @@ err: + + inode_t * + do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, +- quota_dentry_t *dentry) ++ quota_dentry_t *dentry, gf_boolean_t force) + { + int32_t ret = -1; + inode_t *parent = NULL; +@@ -1374,8 +1362,12 @@ do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + local = frame->local; + + parent = inode_parent (inode, dentry->par, dentry->name); +- if (parent == NULL) +- parent = inode_find (inode->table, dentry->par); ++ if (parent == NULL) { ++ if (force) ++ parent = inode_find (inode->table, dentry->par); ++ else ++ goto out; ++ } + if (parent == NULL) + goto out; + +@@ -1391,7 +1383,7 @@ do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, + new_frame->local = new_local; + new_local->par_frame = frame; + +- quota_check_limit (new_frame, parent, this, NULL, NULL); ++ quota_check_limit (new_frame, parent, this); + + ret = 0; + out: +@@ -1849,11 +1841,12 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + /* nameless lookup on this inode, allow quota to reconstruct + * ancestry as part of check_limit. + */ +- quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ quota_check_limit (frame, fd->inode, this); + } else { + list_for_each_entry_safe (dentry, tmp, &head, next) { + par_inode = do_quota_check_limit (frame, fd->inode, +- this, dentry); ++ this, dentry, ++ _gf_false); + if (par_inode == NULL) { + /* remove stale entry from inode ctx */ + quota_dentry_del (ctx, dentry->name, +@@ -1872,7 +1865,7 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + local->link_count++; + } + UNLOCK (&local->lock); +- quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ quota_check_limit (frame, fd->inode, this); + } + + while (fail_count != 0) { +@@ -1981,7 +1974,7 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + } + UNLOCK (&local->lock); + +- quota_check_limit (frame, loc->parent, this, NULL, NULL); ++ quota_check_limit (frame, loc->parent, this); + return 0; + + err: +@@ -2130,7 +2123,7 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + } + UNLOCK (&local->lock); + +- quota_check_limit (frame, loc->parent, this, NULL, NULL); ++ quota_check_limit (frame, loc->parent, this); + return 0; + err: + QUOTA_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL, +@@ -2373,20 +2366,22 @@ quota_link_continue (call_frame_t *frame) + * This needs re-vist if marker accounts only once + * for the links created across directories + */ +- src_parent = inode_parent (local->oldloc.inode, 0, NULL); +- dst_parent = inode_parent (local->newloc.inode, 0, NULL); ++ if (local->oldloc.parent) ++ src_parent = inode_ref (local->oldloc.parent); ++ else ++ src_parent = inode_parent (local->oldloc.inode, 0, ++ NULL); ++ dst_parent = local->newloc.parent; + + /* No need to check quota limit if src and dst parents are same + */ + if (src_parent == dst_parent || + gf_uuid_compare (src_parent->gfid, dst_parent->gfid) == 0) { + inode_unref (src_parent); +- inode_unref (dst_parent); +- goto off; ++ goto wind; + } + + inode_unref (src_parent); +- inode_unref (dst_parent); + } + + quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0); +@@ -2405,7 +2400,7 @@ quota_link_continue (call_frame_t *frame) + } + UNLOCK (&local->lock); + +- quota_check_limit (frame, local->newloc.parent, this, NULL, NULL); ++ quota_check_limit (frame, local->newloc.parent, this); + return; + + err: +@@ -2413,14 +2408,10 @@ err: + NULL, NULL, NULL); + return; + +-off: +- frame->local = NULL; +- +- STACK_WIND_TAIL (frame, FIRST_CHILD(this), +- FIRST_CHILD(this)->fops->link, &(local->oldloc), +- &(local->newloc), local->xdata); +- +- quota_local_cleanup (local); ++wind: ++ STACK_WIND (frame, quota_link_cbk, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->link, &(local->oldloc), ++ &(local->newloc), local->xdata); + return; + } + +@@ -2438,15 +2429,6 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + + WIND_IF_QUOTAOFF (priv->is_quota_on, off); + +- /* No need to check quota limit if src and dst parents are same */ +- if (oldloc->parent && newloc->parent && +- !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { +- gf_msg_debug (this->name, GF_LOG_DEBUG, "link %s -> %s are " +- "in the same directory, so skip check limit", +- oldloc->path, newloc->path); +- goto off; +- } +- + local = quota_local_new (); + if (local == NULL) { + goto err; +@@ -2478,6 +2460,15 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + goto err; + } + ++ /* No need to check quota limit if src and dst parents are same */ ++ if (oldloc->parent && newloc->parent && ++ !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { ++ gf_msg_debug (this->name, GF_LOG_DEBUG, "link %s -> %s are " ++ "in the same directory, so skip check limit", ++ oldloc->path, newloc->path); ++ goto wind; ++ } ++ + stub = fop_link_stub (frame, quota_link_helper, oldloc, newloc, xdata); + if (stub == NULL) { + goto err; +@@ -2494,7 +2485,11 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + check_ancestory (frame, newloc->parent); + + /* source parent can be NULL, so do check_ancestory on a file */ +- check_ancestory (frame, oldloc->inode); ++ if (oldloc->parent) ++ check_ancestory (frame, oldloc->parent); ++ else ++ check_ancestory (frame, oldloc->inode); ++ + return 0; + + err: +@@ -2507,6 +2502,12 @@ off: + FIRST_CHILD(this)->fops->link, oldloc, + newloc, xdata); + return 0; ++ ++wind: ++ STACK_WIND (frame, quota_link_cbk, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->link, oldloc, ++ newloc, xdata); ++ return 0; + } + + +@@ -2532,13 +2533,10 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + GF_VALIDATE_OR_GOTO ("quota", local, out); + +- if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) { ++ if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) + size = buf->ia_blocks * 512; +- } +- +- if (!QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) { ++ else + goto out; +- } + + ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0); + if ((ret == -1) || (ctx == NULL)) { +@@ -2674,8 +2672,7 @@ quota_rename_get_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + } + local->delta = ntoh64 (*size); +- quota_check_limit (frame, local->newloc.parent, this, +- NULL, NULL); ++ quota_check_limit (frame, local->newloc.parent, this); + return 0; + + out: +@@ -2759,7 +2756,7 @@ quota_rename_continue (call_frame_t *frame) + return; + } + +- quota_check_limit (frame, local->newloc.parent, this, NULL, NULL); ++ quota_check_limit (frame, local->newloc.parent, this); + return; + + err: +@@ -2783,15 +2780,6 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + + WIND_IF_QUOTAOFF (priv->is_quota_on, off); + +- /* No need to check quota limit if src and dst parents are same */ +- if (oldloc->parent && newloc->parent && +- !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { +- gf_msg_debug (this->name, 0, "rename %s -> %s are " +- "in the same directory, so skip check limit", +- oldloc->path, newloc->path); +- goto off; +- } +- + local = quota_local_new (); + if (local == NULL) { + goto err; +@@ -2813,6 +2801,15 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + goto err; + } + ++ /* No need to check quota limit if src and dst parents are same */ ++ if (oldloc->parent && newloc->parent && ++ !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) { ++ gf_msg_debug (this->name, 0, "rename %s -> %s are " ++ "in the same directory, so skip check limit", ++ oldloc->path, newloc->path); ++ goto wind; ++ } ++ + stub = fop_rename_stub (frame, quota_rename_helper, oldloc, newloc, + xdata); + if (stub == NULL) { +@@ -2843,7 +2840,12 @@ off: + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rename, oldloc, + newloc, xdata); ++ return 0; + ++wind: ++ STACK_WIND (frame, quota_rename_cbk, ++ FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename, oldloc, ++ newloc, xdata); + return 0; + } + +@@ -2973,7 +2975,7 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, + } + UNLOCK (&local->lock); + +- quota_check_limit (frame, loc->parent, this, NULL, NULL); ++ quota_check_limit (frame, loc->parent, this); + return 0; + + err: +@@ -3915,7 +3917,7 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + } + UNLOCK (&local->lock); + +- quota_check_limit (frame, loc->parent, this, NULL, NULL); ++ quota_check_limit (frame, loc->parent, this); + return 0; + + err: +@@ -4855,11 +4857,12 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + + if (parents == 0) { + local->link_count = 1; +- quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ quota_check_limit (frame, fd->inode, this); + } else { + list_for_each_entry_safe (dentry, tmp, &head, next) { + par_inode = do_quota_check_limit (frame, fd->inode, +- this, dentry); ++ this, dentry, ++ _gf_false); + if (par_inode == NULL) { + /* remove stale entry from inode_ctx */ + quota_dentry_del (ctx, dentry->name, +@@ -4878,7 +4881,7 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + local->link_count++; + } + UNLOCK (&local->lock); +- quota_check_limit (frame, fd->inode, this, NULL, NULL); ++ quota_check_limit (frame, fd->inode, this); + } + + while (fail_count != 0) { +diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h +index 0f8cecd..db27e1e 100644 +--- a/xlators/features/quota/src/quota.h ++++ b/xlators/features/quota/src/quota.h +@@ -263,12 +263,11 @@ void + quota_get_limit_dir (call_frame_t *frame, inode_t *cur_inode, xlator_t *this); + + int32_t +-quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, +- char *name, uuid_t par); ++quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this); + + inode_t * + do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, +- quota_dentry_t *dentry); ++ quota_dentry_t *dentry, gf_boolean_t force); + int + quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict, + loc_t *loc, struct iatt *buf, int32_t *op_errno); +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 60acac4..3f4af01 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3504,7 +3504,7 @@ out: + + int32_t + posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, +- inode_t *parent, uint64_t ino, ++ inode_t *parent, struct stat *stbuf, + gf_dirent_t *head, char **path, + int type, dict_t *xdata, int32_t *op_errno) + { +@@ -3540,7 +3540,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + if ((result == NULL) || *op_errno) + break; + +- if (entry->d_ino != ino) ++ if (entry->d_ino != stbuf->st_ino) + continue; + + linked_inode = inode_link (leaf_inode, parent, +@@ -3564,6 +3564,8 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + gf_entry->dict + = posix_xattr_fill (this, temppath, &loc, NULL, + -1, xdata, NULL); ++ iatt_from_stat (&(gf_entry->d_stat), stbuf); ++ + list_add_tail (&gf_entry->list, &head->list); + loc_wipe (&loc); + } +@@ -3745,8 +3747,7 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, + dirpath[strlen (dirpath) - 1] = '\0'; + + posix_links_in_same_directory (dirpath, nlink_samepgfid, +- leaf_inode, +- parent, stbuf.st_ino, head, ++ leaf_inode, parent, &stbuf, head, + path, type, xdata, op_errno); + + if (parent != NULL) { +-- +1.7.1 + diff --git a/SOURCES/0264-posix-fix-mem-leak-in-posix-xattrop.patch b/SOURCES/0264-posix-fix-mem-leak-in-posix-xattrop.patch new file mode 100644 index 0000000..027f1d2 --- /dev/null +++ b/SOURCES/0264-posix-fix-mem-leak-in-posix-xattrop.patch @@ -0,0 +1,46 @@ +From 8ab7cb15f1b92ebf720e88fd811df63d63a0ed4f Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 16 Jul 2015 19:24:00 +0530 +Subject: [PATCH 264/279] posix: fix mem-leak in posix xattrop + +> Change-Id: I1dd70f74a98c5875eb316f3c3e560047f128685b +> BUG: 1243890 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11700 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Pranith Kumar Karampuri + +Change-Id: I8966d2778af4d7a1083ed84e28ecd5d4382305de +BUG: 1243886 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/53207 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/storage/posix/src/posix.c | 6 ++++-- + 1 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 3f4af01..535e5ff 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -4971,11 +4971,13 @@ unlock: + array = NULL; + } + +- array = NULL; +- + out: + if (op_ret < 0) + filler->op_errno = op_errno; ++ ++ if (array) ++ GF_FREE (array); ++ + return op_ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0265-rpc-server-glusterd-Init-transport-list-for-accepted.patch b/SOURCES/0265-rpc-server-glusterd-Init-transport-list-for-accepted.patch new file mode 100644 index 0000000..391cd70 --- /dev/null +++ b/SOURCES/0265-rpc-server-glusterd-Init-transport-list-for-accepted.patch @@ -0,0 +1,89 @@ +From dab35e6c44c8c54c05350dc2ba4ef0e02830586b Mon Sep 17 00:00:00 2001 +From: Kaushal M +Date: Thu, 16 Jul 2015 14:52:36 +0530 +Subject: [PATCH 265/279] rpc,server,glusterd: Init transport list for accepted transport + +GlusterD or a brick would crash when encrypted transport was enabled and +an unencrypted client tried to connect to them. The crash occured when +GlusterD/server tried to remove the transport from their xprt_list due +to a DISCONNECT event. But as the client transport's list head wasn't +inited, the process would crash when list_del was performed. + +Initing the client transports list head during acceptence, prevents this +crash. + +Also, an extra check has been added to the GlusterD and Server +notification handlers for client DISCONNECT events. The handlers will +now first check if the client transport is a member of any list. +GlusterD and Server DISCONNECT event handlers could be called without +the ACCEPT handler, which adds the transport to the list, being called. +This situation also occurs when an unencrypted client tries to establish +a connection with an encrypted server. + +Change-Id: Icc24a08d60e978aaa1d3322e0cbed680dcbda2b4 +BUG: 1243722 +Reviewed-upstream-on: https://review.gluster.org/11692 +Signed-off-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/53141 +Reviewed-by: Krishnan Parthasarathi +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + rpc/rpc-transport/socket/src/socket.c | 1 + + xlators/mgmt/glusterd/src/glusterd.c | 8 ++++++++ + xlators/protocol/server/src/server.c | 8 ++++++++ + 3 files changed, 17 insertions(+), 0 deletions(-) + +diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c +index eef5bd2..635be2a 100644 +--- a/rpc/rpc-transport/socket/src/socket.c ++++ b/rpc/rpc-transport/socket/src/socket.c +@@ -2689,6 +2689,7 @@ socket_server_event_handler (int fd, int idx, void *data, + GF_FREE (new_trans); + goto unlock; + } ++ INIT_LIST_HEAD (&new_trans->list); + + new_trans->name = gf_strdup (this->name); + +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 05723b9..1286488 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -343,6 +343,14 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + } + case RPCSVC_EVENT_DISCONNECT: + { ++ /* A DISCONNECT event could come without an ACCEPT event ++ * happening for this transport. This happens when the server is ++ * expecting encrypted connections by the client tries to ++ * connect unecnrypted ++ */ ++ if (list_empty (&xprt->list)) ++ break; ++ + pthread_mutex_lock (&priv->xprt_lock); + list_del (&xprt->list); + pthread_mutex_unlock (&priv->xprt_lock); +diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c +index 9c10a50..9ddd045 100644 +--- a/xlators/protocol/server/src/server.c ++++ b/xlators/protocol/server/src/server.c +@@ -518,6 +518,14 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, + break; + } + case RPCSVC_EVENT_DISCONNECT: ++ /* A DISCONNECT event could come without an ACCEPT event ++ * happening for this transport. This happens when the server is ++ * expecting encrypted connections by the client tries to ++ * connect unecnrypted ++ */ ++ if (list_empty (&trans->list)) ++ break; ++ + /* transport has to be removed from the list upon disconnect + * irrespective of whether lock self heal is off or on, since + * new transport will be created upon reconnect. +-- +1.7.1 + diff --git a/SOURCES/0266-uss-Take-ref-on-root-inode.patch b/SOURCES/0266-uss-Take-ref-on-root-inode.patch new file mode 100644 index 0000000..073b0a2 --- /dev/null +++ b/SOURCES/0266-uss-Take-ref-on-root-inode.patch @@ -0,0 +1,57 @@ +From 9e6cd8779bd8ceab1327856b85fedc80412c5252 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Mon, 11 May 2015 12:36:33 +0530 +Subject: [PATCH 266/279] uss: Take ref on root inode + +If we recieve a statfs call on snap directory, we will redirect +the call into the root, by creating a new root loc. So it is better to +take a ref on the root inode +(http://review.gluster.org/#/c/10358/5/xlators/features/ +snapview-client/src/snapview-client.c) + +Back port of : +>Change-Id: I5649addac442d391b2550346b115dec58fed5b86 +>Signed-off-by: Mohammed Rafi KC +>Reviewed-on: http://review.gluster.org/10750 +>Tested-by: NetBSD Build System +>Reviewed-by: Raghavendra Bhat + +Change-Id: Idd575a5313bcbc3d7bfdd954c7bfecce371f3add +BUG: 1245919 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: http://review.gluster.org/11094 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Avra Sengupta +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/55133 +Tested-by: Rajesh Joseph +--- + .../features/snapview-client/src/snapview-client.c | 5 +++-- + 1 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c +index 2f304aa..81e3b20 100644 +--- a/xlators/features/snapview-client/src/snapview-client.c ++++ b/xlators/features/snapview-client/src/snapview-client.c +@@ -539,14 +539,15 @@ svc_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, + root_loc.path = "/"; + gf_uuid_clear(root_loc.gfid); + root_loc.gfid[15] = 1; +- root_loc.inode = loc->inode->table->root; +- root_loc.inode->ia_type = IA_IFDIR; ++ root_loc.inode = inode_ref (loc->inode->table->root); + temp_loc = &root_loc; + } + } + + STACK_WIND_TAIL (frame, subvolume, subvolume->fops->statfs, + temp_loc, xdata); ++ if (temp_loc) ++ loc_wipe (temp_loc); + + wind = _gf_true; + out: +-- +1.7.1 + diff --git a/SOURCES/0267-glusterd-initialize-the-daemon-services-on-demand.patch b/SOURCES/0267-glusterd-initialize-the-daemon-services-on-demand.patch new file mode 100644 index 0000000..0449b00 --- /dev/null +++ b/SOURCES/0267-glusterd-initialize-the-daemon-services-on-demand.patch @@ -0,0 +1,798 @@ +From cae9e746422dc54126eca96c4bacf11f24921cf2 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Wed, 1 Jul 2015 14:47:48 +0530 +Subject: [PATCH 267/275] glusterd: initialize the daemon services on demand + +backport of http://review.gluster.org/#/c/11488/ + +As of now all the daemon services are initialized at glusterD init path. Since +socket file path of per node daemon demands the uuid of the node, MY_UUID macro +is invoked as part of the initialization. + +The above flow breaks the usecases where a gluster image is built following a +template could be Dockerfile, Vagrantfile or any kind of virtualization +environment. This means bringing instances of this image would have same UUIDs +for the node resulting in peer probe failure. + +Solution is to lazily initialize the services on demand. + +Change-Id: If7caa533026c83e98c7c7678bded67085d0bbc1e +BUG: 1245536 +Signed-off-by: Atin Mukherjee +Reviewed-on: http://review.gluster.org/11488 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Gaurav Kumar Garg +Reviewed-by: Kaushal M +Reviewed-on: https://code.engineering.redhat.com/gerrit/55044 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + doc/developer-guide/daemon-management-framework.md | 9 ++- + ...-1238135-lazy-daemon-initialization-on-demand.t | 16 +++++ + xlators/mgmt/glusterd/src/glusterd-bitd-svc.c | 27 +++++++- + xlators/mgmt/glusterd/src/glusterd-bitd-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 19 ++++-- + xlators/mgmt/glusterd/src/glusterd-nfs-svc.c | 26 +++++++- + xlators/mgmt/glusterd/src/glusterd-nfs-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-quotad-svc.c | 27 +++++++- + xlators/mgmt/glusterd/src/glusterd-quotad-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-scrub-svc.c | 27 +++++++- + xlators/mgmt/glusterd/src/glusterd-scrub-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 26 +++++++- + xlators/mgmt/glusterd/src/glusterd-shd-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-snapd-svc.c | 26 +++++++- + xlators/mgmt/glusterd/src/glusterd-snapd-svc.h | 3 + + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 10 --- + xlators/mgmt/glusterd/src/glusterd-store.c | 9 --- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 15 +---- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h | 9 ++- + xlators/mgmt/glusterd/src/glusterd-utils.c | 25 ++------ + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 6 -- + xlators/mgmt/glusterd/src/glusterd.c | 67 ++++---------------- + 22 files changed, 212 insertions(+), 150 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1238135-lazy-daemon-initialization-on-demand.t + +diff --git a/tests/bugs/glusterd/bug-1238135-lazy-daemon-initialization-on-demand.t b/tests/bugs/glusterd/bug-1238135-lazy-daemon-initialization-on-demand.t +new file mode 100644 +index 0000000..54c3187 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1238135-lazy-daemon-initialization-on-demand.t +@@ -0,0 +1,16 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++ ++cleanup; ++ ++TEST glusterd; ++TEST pidof glusterd; ++ ++GDWD=$($CLI system getwd) ++ ++# glusterd.info file will be created on either first peer probe or volume ++# creation, hence we expect file to be not present in this case ++TEST ! -e $GDWD/glusterd.info ++ ++cleanup; +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +index 1b71b6c..6b606f8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +@@ -15,13 +15,18 @@ + #include "glusterd-volgen.h" + #include "glusterd-bitd-svc.h" + ++void ++glusterd_bitdsvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_bitdsvc_manager; ++ svc->start = glusterd_bitdsvc_start; ++ svc->stop = glusterd_bitdsvc_stop; ++} ++ + int + glusterd_bitdsvc_init (glusterd_svc_t *svc) + { +- return glusterd_svc_init (svc, bitd_svc_name, +- glusterd_bitdsvc_manager, +- glusterd_bitdsvc_start, +- glusterd_bitdsvc_stop); ++ return glusterd_svc_init (svc, bitd_svc_name); + } + + static int +@@ -65,6 +70,20 @@ glusterd_bitdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + this = THIS; + GF_ASSERT (this); + ++ if (!svc->inited) { ++ ret = glusterd_bitdsvc_init (svc); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_BITD_INIT_FAIL, "Failed to init " ++ "bitd service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (this->name, 0, "BitD service " ++ "initialized"); ++ } ++ } ++ + if (glusterd_should_i_stop_bitd ()) { + ret = svc->stop (svc, SIGTERM); + } else { +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.h b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.h +index e6f5d51..103d404 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.h +@@ -20,6 +20,9 @@ + + #define bitd_svc_name "bitd" + ++void ++glusterd_bitdsvc_build (glusterd_svc_t *svc); ++ + int + glusterd_bitdsvc_init (glusterd_svc_t *svc); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +index 4d2efb9..8cd2aa6 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c ++++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c +@@ -671,14 +671,19 @@ start_ganesha (char **op_errstr) + } + } + +- ret = priv->nfs_svc.stop (&(priv->nfs_svc), SIGKILL); +- if (ret) { +- ret = -1; +- gf_asprintf (op_errstr, "Gluster-NFS service could" +- "not be stopped, exiting."); +- goto out; ++ /* If the nfs svc is not initialized it means that the service is not ++ * running, hence we can skip the process of stopping gluster-nfs ++ * service ++ */ ++ if (priv->nfs_svc.inited) { ++ ret = priv->nfs_svc.stop (&(priv->nfs_svc), SIGKILL); ++ if (ret) { ++ ret = -1; ++ gf_asprintf (op_errstr, "Gluster-NFS service could" ++ "not be stopped, exiting."); ++ goto out; ++ } + } +- + if (check_host_list()) { + ret = manage_service ("start"); + if (ret) +diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +index 0c4d3c1..b1d9814 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +@@ -18,6 +18,14 @@ + + char *nfs_svc_name = "nfs"; + ++void ++glusterd_nfssvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_nfssvc_manager; ++ svc->start = glusterd_nfssvc_start; ++ svc->stop = glusterd_nfssvc_stop; ++} ++ + static gf_boolean_t + glusterd_nfssvc_need_start () + { +@@ -43,10 +51,7 @@ glusterd_nfssvc_need_start () + int + glusterd_nfssvc_init (glusterd_svc_t *svc) + { +- return glusterd_svc_init (svc, nfs_svc_name, +- glusterd_nfssvc_manager, +- glusterd_nfssvc_start, +- glusterd_nfssvc_stop); ++ return glusterd_svc_init (svc, nfs_svc_name); + } + + static int +@@ -167,6 +172,19 @@ glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags) + { + int ret = -1; + ++ if (!svc->inited) { ++ ret = glusterd_nfssvc_init (svc); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_NFSSVC, "Failed to init nfs " ++ "service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (THIS->name, 0, "nfs service initialized"); ++ } ++ } ++ + ret = svc->stop (svc, SIGKILL); + if (ret) + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.h b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.h +index 210336c..c1c0330 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.h +@@ -18,6 +18,9 @@ + + #include "glusterd-svc-mgmt.h" + ++void ++glusterd_nfssvc_build (glusterd_svc_t *svc); ++ + int + glusterd_nfssvc_init (glusterd_svc_t *svc); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +index 37824f6..59a7671 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +@@ -18,16 +18,21 @@ + + char *quotad_svc_name = "quotad"; + ++void ++glusterd_quotadsvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_quotadsvc_manager; ++ svc->start = glusterd_quotadsvc_start; ++ svc->stop = glusterd_svc_stop; ++} ++ + int glusterd_quotadsvc_init (glusterd_svc_t *svc) + { + int ret = -1; + char volfile[PATH_MAX] = {0,}; + glusterd_conf_t *conf = THIS->private; + +- ret = glusterd_svc_init (svc, quotad_svc_name, +- glusterd_quotadsvc_manager, +- glusterd_quotadsvc_start, +- glusterd_svc_stop); ++ ret = glusterd_svc_init (svc, quotad_svc_name); + if (ret) + goto out; + +@@ -60,6 +65,20 @@ glusterd_quotadsvc_manager (glusterd_svc_t *svc, void *data, int flags) + int ret = 0; + glusterd_volinfo_t *volinfo = NULL; + ++ if (!svc->inited) { ++ ret = glusterd_quotadsvc_init (svc); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init " ++ "quotad service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (THIS->name, 0, "quotad service " ++ "initialized"); ++ } ++ } ++ + volinfo = data; + + /* If all the volumes are stopped or all shd compatible volumes +diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h +index 945d47e..c275aa4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h +@@ -18,6 +18,9 @@ + + #include "glusterd-svc-mgmt.h" + ++void ++glusterd_quotadsvc_build (glusterd_svc_t *svc); ++ + int + glusterd_quotadsvc_init (glusterd_svc_t *svc); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +index 36863e2..b5c9785 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +@@ -17,13 +17,18 @@ + + char *scrub_svc_name = "scrub"; + ++void ++glusterd_scrubsvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_scrubsvc_manager; ++ svc->start = glusterd_scrubsvc_start; ++ svc->stop = glusterd_scrubsvc_stop; ++} ++ + int + glusterd_scrubsvc_init (glusterd_svc_t *svc) + { +- return glusterd_svc_init (svc, scrub_svc_name, +- glusterd_scrubsvc_manager, +- glusterd_scrubsvc_start, +- glusterd_scrubsvc_stop); ++ return glusterd_svc_init (svc, scrub_svc_name); + } + + static int +@@ -60,6 +65,20 @@ glusterd_scrubsvc_manager (glusterd_svc_t *svc, void *data, int flags) + { + int ret = -EINVAL; + ++ if (!svc->inited) { ++ ret = glusterd_scrubsvc_init (svc); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SCRUB_INIT_FAIL, "Failed to init " ++ "scrub service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (THIS->name, 0, "scrub service " ++ "initialized"); ++ } ++ } ++ + if (glusterd_should_i_stop_bitd ()) { + ret = svc->stop (svc, SIGTERM); + } else { +diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.h b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.h +index e2e3b0d..aeea00d 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.h +@@ -25,6 +25,9 @@ struct glusterd_scrubsvc_{ + gf_store_handle_t *handle; + }; + ++void ++glusterd_scrubsvc_build (glusterd_svc_t *svc); ++ + int + glusterd_scrubsvc_init (glusterd_svc_t *svc); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 49454cc..f9f4189 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -18,13 +18,18 @@ + + char *shd_svc_name = "glustershd"; + ++void ++glusterd_shdsvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_shdsvc_manager; ++ svc->start = glusterd_shdsvc_start; ++ svc->stop = glusterd_svc_stop; ++} ++ + int + glusterd_shdsvc_init (glusterd_svc_t *svc) + { +- return glusterd_svc_init (svc, shd_svc_name, +- glusterd_shdsvc_manager, +- glusterd_shdsvc_start, +- glusterd_svc_stop); ++ return glusterd_svc_init (svc, shd_svc_name); + } + + static int +@@ -80,6 +85,19 @@ glusterd_shdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + int ret = 0; + glusterd_volinfo_t *volinfo = NULL; + ++ if (!svc->inited) { ++ ret = glusterd_shdsvc_init (svc); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_FAILED_INIT_SHDSVC, "Failed to init shd " ++ "service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (THIS->name, 0, "shd service initialized"); ++ } ++ } ++ + volinfo = data; + + /* If all the volumes are stopped or all shd compatible volumes +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc.h +index 469ed5d..7dbb247 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.h +@@ -18,6 +18,9 @@ + + #include "glusterd-svc-mgmt.h" + ++void ++glusterd_shdsvc_build (glusterd_svc_t *svc); ++ + int + glusterd_shdsvc_init (glusterd_svc_t *svc); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +index 757c7f6..2ec7200 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +@@ -36,6 +36,13 @@ glusterd_svc_build_snapd_logfile (char *logfile, char *logdir, size_t len) + snprintf (logfile, len, "%s/snapd.log", logdir); + } + ++void ++glusterd_snapdsvc_build (glusterd_svc_t *svc) ++{ ++ svc->manager = glusterd_snapdsvc_manager; ++ svc->start = glusterd_snapdsvc_start; ++ svc->stop = glusterd_svc_stop; ++} + + int + glusterd_snapdsvc_init (void *data) +@@ -69,10 +76,6 @@ glusterd_snapdsvc_init (void *data) + if (ret < 0) + goto out; + +- svc->manager = glusterd_snapdsvc_manager; +- svc->start = glusterd_snapdsvc_start; +- svc->stop = glusterd_svc_stop; +- + notify = glusterd_snapdsvc_rpc_notify; + + glusterd_svc_build_snapd_rundir (volinfo, rundir, sizeof (rundir)); +@@ -123,6 +126,21 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) + + volinfo = data; + ++ if (!svc->inited) { ++ ret = glusterd_snapdsvc_init (volinfo); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " ++ "snapd service for volume %s", ++ volinfo->volname); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug (THIS->name, 0, "snapd service " ++ "initialized"); ++ } ++ } ++ + ret = glusterd_is_snapd_enabled (volinfo); + if (ret == -1) { + gf_msg (this->name, GF_LOG_ERROR, 0, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.h b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.h +index bc5d39f..fae31e8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.h +@@ -26,6 +26,9 @@ struct glusterd_snapdsvc_{ + gf_store_handle_t *handle; + }; + ++void ++glusterd_snapdsvc_build (glusterd_svc_t *svc); ++ + int + glusterd_snapdsvc_init (void *data); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 839b274..34cafd8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -6492,7 +6492,6 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr, + snap->snapname); + goto out; + } +- ret = glusterd_snapdsvc_init (snap_vol); + + glusterd_list_add_order (&snap_vol->vol_list, &priv->volumes, + glusterd_compare_volume_name); +@@ -9525,15 +9524,6 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict, + goto out; + } + +- /* Initialize the snapd service */ +- ret = glusterd_snapdsvc_init (new_volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd " +- "service for volume %s", orig_vol->volname); +- goto out; +- } +- + ret = 0; + out: + if (ret) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index db7d1d4..7a605dd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -2816,15 +2816,6 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) + if (snap) + volinfo->is_snap_volume = _gf_true; + +- /* Initialize the snapd service */ +- ret = glusterd_snapdsvc_init (volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd " +- "service for volume %s", volinfo->volname); +- goto out; +- } +- + ret = glusterd_store_update_volinfo (volinfo); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +index 04096a4..130bc56 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +@@ -49,9 +49,6 @@ static int + glusterd_svc_init_common (glusterd_svc_t *svc, + char *svc_name, char *workdir, + char *rundir, char *logdir, +- glusterd_svc_manager_t manager, +- glusterd_svc_start_t start, +- glusterd_svc_stop_t stop, + glusterd_conn_notify_t notify) + { + int ret = -1; +@@ -74,10 +71,6 @@ glusterd_svc_init_common (glusterd_svc_t *svc, + if (ret < 0) + goto out; + +- svc->manager = manager; +- svc->start = start; +- svc->stop = stop; +- + if (!notify) + notify = glusterd_svc_common_rpc_notify; + +@@ -126,10 +119,7 @@ svc_add_args (dict_t *cmdline, char *arg, data_t *value, void *data) + return 0; + } + +-int glusterd_svc_init (glusterd_svc_t *svc, char *svc_name, +- glusterd_svc_manager_t manager, +- glusterd_svc_start_t start, +- glusterd_svc_stop_t stop) ++int glusterd_svc_init (glusterd_svc_t *svc, char *svc_name) + { + int ret = -1; + char rundir[PATH_MAX] = {0,}; +@@ -145,8 +135,7 @@ int glusterd_svc_init (glusterd_svc_t *svc, char *svc_name, + glusterd_svc_build_rundir (svc_name, priv->workdir, rundir, + sizeof (rundir)); + ret = glusterd_svc_init_common (svc, svc_name, priv->workdir, rundir, +- DEFAULT_LOG_FILE_DIRECTORY, manager, +- start, stop, NULL); ++ DEFAULT_LOG_FILE_DIRECTORY, NULL); + + return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +index bb4f6f1..22028d3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +@@ -22,6 +22,8 @@ + struct glusterd_svc_; + typedef struct glusterd_svc_ glusterd_svc_t; + ++typedef void (*glusterd_svc_build_t) (glusterd_svc_t *svc); ++ + typedef int (*glusterd_svc_manager_t) (glusterd_svc_t *svc, + void *data, int flags); + typedef int (*glusterd_svc_start_t) (glusterd_svc_t *svc, int flags); +@@ -31,20 +33,19 @@ struct glusterd_svc_ { + char name[PATH_MAX]; + glusterd_conn_t conn; + glusterd_proc_t proc; ++ glusterd_svc_build_t build; + glusterd_svc_manager_t manager; + glusterd_svc_start_t start; + glusterd_svc_stop_t stop; + gf_boolean_t online; ++ gf_boolean_t inited; + }; + + int + glusterd_svc_create_rundir (char *rundir); + + int +-glusterd_svc_init (glusterd_svc_t *svc, char *svc_name, +- glusterd_svc_manager_t manager, +- glusterd_svc_start_t start, +- glusterd_svc_stop_t stop); ++glusterd_svc_init (glusterd_svc_t *svc, char *svc_name); + + int + glusterd_svc_start (glusterd_svc_t *svc, int flags, dict_t *cmdline); +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 1af9902..0101ec5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -500,6 +500,9 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo) + + new_volinfo->xl = THIS; + ++ new_volinfo->snapd.svc.build = glusterd_snapdsvc_build; ++ new_volinfo->snapd.svc.build (&(new_volinfo->snapd.svc)); ++ + pthread_mutex_init (&new_volinfo->reflock, NULL); + *volinfo = glusterd_volinfo_ref (new_volinfo); + +@@ -3776,35 +3779,17 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count) + + ret = glusterd_volinfo_find (new_volinfo->volname, &old_volinfo); + if (0 == ret) { +- /* snapdsvc initialization of old_volinfo is also required here +- * as glusterd_delete_stale_volume () invokes snapdsvc manager +- */ +- ret = glusterd_snapdsvc_init (old_volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize" +- " snapdsvc for old volume %s", +- old_volinfo->volname); +- goto out; +- } + (void) gd_check_and_update_rebalance_info (old_volinfo, + new_volinfo); + (void) glusterd_delete_stale_volume (old_volinfo, new_volinfo); + } + +- ret = glusterd_snapdsvc_init (new_volinfo); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " +- "snapdsvc for volume %s", new_volinfo->volname); +- goto out; +- } +- + if (glusterd_is_volume_started (new_volinfo)) { + (void) glusterd_start_bricks (new_volinfo); + if (glusterd_is_snapd_enabled (new_volinfo)) { + svc = &(new_volinfo->snapd.svc); +- (void) svc->start (svc, PROC_START_NO_WAIT); ++ (void) svc->manager (svc, new_volinfo, ++ PROC_START_NO_WAIT); + } + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 2ad1614..b52f832 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -2302,12 +2302,6 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) + goto out; + } + +- ret = glusterd_snapdsvc_init (volinfo); +- if (ret) { +- *op_errstr = gf_strdup ("Failed to initialize snapd service"); +- goto out; +- } +- + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { + *op_errstr = gf_strdup ("Failed to create volume files"); +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 1286488..2c75545 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -1274,10 +1274,9 @@ out: + return ret; + } + +-static int +-glusterd_svc_init_all () ++static void ++glusterd_svcs_build () + { +- int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + +@@ -1287,59 +1286,22 @@ glusterd_svc_init_all () + priv = this->private; + GF_ASSERT (priv); + +- /* Init SHD svc */ +- ret = glusterd_shdsvc_init (&(priv->shd_svc)); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, +- GD_MSG_FAILED_INIT_SHDSVC, +- "Failed to init shd service"); +- goto out; +- } +- gf_msg_debug (THIS->name, 0, "shd service initialized"); ++ priv->shd_svc.build = glusterd_shdsvc_build; ++ priv->shd_svc.build (&(priv->shd_svc)); + +- /* Init NFS svc */ +- ret = glusterd_nfssvc_init (&(priv->nfs_svc)); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, +- GD_MSG_FAILED_INIT_NFSSVC, +- "Failed to init nfs service"); +- goto out; +- } +- gf_msg_debug (THIS->name, 0, "nfs service initialized"); ++ priv->nfs_svc.build = glusterd_nfssvc_build; ++ priv->nfs_svc.build (&(priv->nfs_svc)); + +- /* Init QuotaD svc */ +- ret = glusterd_quotadsvc_init (&(priv->quotad_svc)); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, +- GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init quotad " +- "service"); +- goto out; +- } +- gf_msg_debug (THIS->name, 0, "quotad service initialized"); ++ priv->quotad_svc.build = glusterd_quotadsvc_build; ++ priv->quotad_svc.build (&(priv->quotad_svc)); + +- /* Init BitD svc */ +- ret = glusterd_bitdsvc_init (&(priv->bitd_svc)); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, +- GD_MSG_BITD_INIT_FAIL, "Failed to initialized BitD " +- "service"); +- goto out; +- } +- gf_msg_debug (THIS->name, 0, "BitD service initialized"); ++ priv->bitd_svc.build = glusterd_bitdsvc_build; ++ priv->bitd_svc.build (&(priv->bitd_svc)); + +- ret = glusterd_scrubsvc_init (&(priv->scrub_svc)); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_ERROR, 0, +- GD_MSG_SCRUB_INIT_FAIL, "Failed to initialized scrub " +- "service"); +- goto out; +- } +- gf_msg_debug (THIS->name, 0, "scrub service initialized"); ++ priv->scrub_svc.build = glusterd_scrubsvc_build; ++ priv->scrub_svc.build (&(priv->scrub_svc)); + +-out: +- return ret; + } +- + /* + * init - called during glusterd initialization + * +@@ -1740,6 +1702,7 @@ init (xlator_t *this) + this->private = conf; + glusterd_mgmt_v3_lock_init (); + glusterd_txn_opinfo_dict_init (); ++ glusterd_svcs_build (); + + /* Make install copies few of the hook-scripts by creating hooks + * directory. Hence purposefully not doing the check for the presence of +@@ -1789,10 +1752,6 @@ init (xlator_t *this) + goto out; + } + +- ret = glusterd_svc_init_all (); +- if (ret) +- goto out; +- + ret = glusterd_restore (); + if (ret < 0) + goto out; +-- +1.7.1 + diff --git a/SOURCES/0268-glusterd-Stop-restart-notify-to-daemons-svcs-during-.patch b/SOURCES/0268-glusterd-Stop-restart-notify-to-daemons-svcs-during-.patch new file mode 100644 index 0000000..9cb232a --- /dev/null +++ b/SOURCES/0268-glusterd-Stop-restart-notify-to-daemons-svcs-during-.patch @@ -0,0 +1,1030 @@ +From 0a96e3d6d8dfbc81b63609c8c85e01abb6157bbb Mon Sep 17 00:00:00 2001 +From: anand +Date: Wed, 20 May 2015 19:52:11 +0530 +Subject: [PATCH 268/279] glusterd: Stop/restart/notify to daemons(svcs) during reset/set on a volume + +problem : Reset/set commands were not working properly. reset command returns +success but it not sending notification to svcs if corresponding graph modified. + +Fix: Whenever reset/set command issued, generate the temp graph and compare +with original graph and do the fallowing actions +1.) If both graph are identical nothing to do with svcs. +2.) If any changes in graph topology restart/stop service by calling +svc manager. +3) If changes in options send notify signal by calling glusterd_fetchspec_notify. + +>Change-Id: I852c4602eafed1ae6e6a02424814fe3a83e3d4c7 +>BUG: 1209329 +>Signed-off-by: anand +>Reviewed-on: http://review.gluster.org/10850 +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: Atin Mukherjee +>Signed-off-by: anand + +Change-Id: I306922d9fac8820e0f6159742c871d53dbd7b25f +BUG: 1230532 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/55146 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + .../bug-1209329_daemon-svcs-on-reset-volume.t | 69 +++++++++++ + tests/volume.rc | 8 ++ + xlators/mgmt/glusterd/src/glusterd-bitd-svc.c | 64 ++++++++++- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-handshake.c | 11 +-- + xlators/mgmt/glusterd/src/glusterd-nfs-svc.c | 116 ++---------------- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 15 ++- + xlators/mgmt/glusterd/src/glusterd-quotad-svc.c | 82 ++++++++++--- + xlators/mgmt/glusterd/src/glusterd-quotad-svc.h | 3 - + xlators/mgmt/glusterd/src/glusterd-scrub-svc.c | 69 ++++++++++- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 66 ++++++++++- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 129 +++++++++++++++++--- + xlators/mgmt/glusterd/src/glusterd-svc-helper.h | 13 ++- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 6 +- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-volgen.h | 12 +-- + 16 files changed, 497 insertions(+), 171 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1209329_daemon-svcs-on-reset-volume.t + +diff --git a/tests/bugs/glusterd/bug-1209329_daemon-svcs-on-reset-volume.t b/tests/bugs/glusterd/bug-1209329_daemon-svcs-on-reset-volume.t +new file mode 100644 +index 0000000..aa24cf1 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1209329_daemon-svcs-on-reset-volume.t +@@ -0,0 +1,69 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../nfs.rc ++ ++cleanup; ++ ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}; ++ ++## Verify volume is created ++EXPECT "$V0" volinfo_field $V0 'Volume Name'; ++EXPECT 'Created' volinfo_field $V0 'Status'; ++ ++## Start volume and verify ++TEST $CLI volume start $V0; ++EXPECT 'Started' volinfo_field $V0 'Status'; ++ ++##enable the bitrot and verify bitd is running or not ++TEST $CLI volume bitrot $V0 enable ++EXPECT 'on' volinfo_field $V0 'features.bitrot' ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++ ++##Do reset force which set the bitrot options to default ++TEST $CLI volume reset $V0 force; ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_bitd_count ++ ++##enable the uss option and verify snapd is running or not ++TEST $CLI volume set $V0 features.uss on ++EXPECT 'on' volinfo_field $V0 'features.uss' ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_snapd_count ++ ++##Do reset force which set the uss options to default ++TEST $CLI volume reset $V0 force; ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_snapd_count ++ ++#enable nfs.disable options and verify ++TEST $CLI volume set $V0 nfs.disable on ++EXPECT 'on' volinfo_field $V0 'nfs.disable' ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_nfs_count ++ ++##Do reset force which set the nfs.option to default ++TEST $CLI volume reset $V0 force; ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_nfs_count ++ ++##enable the uss option and verify snapd is running or not ++TEST $CLI volume set $V0 features.uss on ++EXPECT 'on' volinfo_field $V0 'features.uss' ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_snapd_count ++ ++##Disable the uss option using set command and verify snapd ++TEST $CLI volume set $V0 features.uss off ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_snapd_count ++ ++##enable nfs.disable and verify ++TEST $CLI volume set $V0 nfs.disable on ++EXPECT 'on' volinfo_field $V0 'nfs.disable' ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_nfs_count ++ ++## disable nfs.disable option using set command ++TEST $CLI volume set $V0 nfs.disable off ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_nfs_count ++ ++cleanup; +diff --git a/tests/volume.rc b/tests/volume.rc +index 570d87d..aeffa4a 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -565,3 +565,11 @@ function quota_usage() + { + quota_list_field $1 4 + } ++ ++function get_nfs_count { ++ ps auxww | grep glusterfs | grep nfs.pid | grep -v grep | wc -l ++} ++ ++function get_snapd_count { ++ ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l ++} +diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +index 6b606f8..ee96ccb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +@@ -14,6 +14,7 @@ + #include "glusterd-utils.h" + #include "glusterd-volgen.h" + #include "glusterd-bitd-svc.h" ++#include "glusterd-svc-helper.h" + + void + glusterd_bitdsvc_build (glusterd_svc_t *svc) +@@ -141,5 +142,66 @@ glusterd_bitdsvc_stop (glusterd_svc_t *svc, int sig) + int + glusterd_bitdsvc_reconfigure () + { +- return glusterd_svc_reconfigure (glusterd_bitdsvc_create_volfile); ++ int ret = -1; ++ xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; ++ gf_boolean_t identical = _gf_false; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO (this->name, this, out); ++ ++ priv = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, priv, out); ++ ++ if (glusterd_should_i_stop_bitd ()) ++ goto manager; ++ /* ++ * Check both OLD and NEW volfiles, if they are SAME by size ++ * and cksum i.e. "character-by-character". If YES, then ++ * NOTHING has been changed, just return. ++ */ ++ ret = glusterd_svc_check_volfile_identical (priv->bitd_svc.name, ++ build_bitd_graph, ++ &identical); ++ if (ret) ++ goto out; ++ if (identical) { ++ ret = 0; ++ goto out; ++ } ++ ++ /* ++ * They are not identical. Find out if the topology is changed ++ * OR just the volume options. If just the options which got ++ * changed, then inform the xlator to reconfigure the options. ++ */ ++ identical = _gf_false; /* RESET the FLAG */ ++ ret = glusterd_svc_check_topology_identical (priv->bitd_svc.name, ++ build_bitd_graph, ++ &identical); ++ if (ret) ++ goto out; /*not able to compare due to some corruption */ ++ ++ /* Topology is not changed, but just the options. But write the ++ * options to bitd volfile, so that bitd will be reconfigured. ++ */ ++ if (identical) { ++ ret = glusterd_bitdsvc_create_volfile (); ++ if (ret == 0) {/* Only if above PASSES */ ++ ret = glusterd_fetchspec_notify (THIS); ++ } ++ goto out; ++ } ++ ++manager: ++ /* ++ * bitd volfile's topology has been changed. bitd server needs ++ * to be RESTARTED to ACT on the changed volfile. ++ */ ++ ret = priv->bitd_svc.manager (&(priv->bitd_svc), NULL, ++ PROC_START_NO_WAIT); ++ ++out: ++ gf_msg_debug (this->name, 0, "Returning %d", ret); ++ return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index 41080ec..caf51a4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -2411,7 +2411,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) + + if (start_remove && + volinfo->status == GLUSTERD_STATUS_STARTED) { +- ret = glusterd_svcs_reconfigure (volinfo); ++ ret = glusterd_svcs_reconfigure (); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_NFS_RECONF_FAIL, +diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c +index 5267874..fac2747 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c +@@ -216,14 +216,9 @@ build_volfile_path (char *volume_id, char *path, + } + volid_ptr++; + +- if (strcmp (volid_ptr, "quotad") == 0) +- glusterd_quotadsvc_build_volfile_path (volid_ptr, +- priv->workdir, +- path, path_len); +- else +- glusterd_svc_build_volfile_path (volid_ptr, +- priv->workdir, +- path, path_len); ++ glusterd_svc_build_volfile_path (volid_ptr, ++ priv->workdir, ++ path, path_len); + ret = 0; + goto out; + +diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +index b1d9814..ea24c1e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +@@ -15,6 +15,7 @@ + #include "glusterd-volgen.h" + #include "glusterd-nfs-svc.h" + #include "glusterd-messages.h" ++#include "glusterd-svc-helper.h" + + char *nfs_svc_name = "nfs"; + +@@ -66,107 +67,6 @@ glusterd_nfssvc_create_volfile () + filepath, NULL); + } + +-static int +-glusterd_nfssvc_check_volfile_identical (gf_boolean_t *identical) +-{ +- char nfsvol[PATH_MAX] = {0,}; +- char tmpnfsvol[PATH_MAX] = {0,}; +- glusterd_conf_t *conf = NULL; +- xlator_t *this = NULL; +- int ret = -1; +- int need_unlink = 0; +- int tmp_fd = -1; +- +- this = THIS; +- +- GF_ASSERT (this); +- GF_ASSERT (identical); +- conf = this->private; +- +- glusterd_svc_build_volfile_path (nfs_svc_name, conf->workdir, +- nfsvol, sizeof (nfsvol)); +- +- snprintf (tmpnfsvol, sizeof (tmpnfsvol), "/tmp/gnfs-XXXXXX"); +- +- tmp_fd = mkstemp (tmpnfsvol); +- if (tmp_fd < 0) { +- gf_msg (this->name, GF_LOG_WARNING, errno, +- GD_MSG_FILE_OP_FAILED, "Unable to create temp file" +- " %s:(%s)", tmpnfsvol, strerror (errno)); +- goto out; +- } +- +- need_unlink = 1; +- +- ret = glusterd_create_global_volfile (build_nfs_graph, +- tmpnfsvol, NULL); +- if (ret) +- goto out; +- +- ret = glusterd_check_files_identical (nfsvol, tmpnfsvol, +- identical); +- if (ret) +- goto out; +- +-out: +- if (need_unlink) +- unlink (tmpnfsvol); +- +- if (tmp_fd >= 0) +- close (tmp_fd); +- +- return ret; +-} +- +-static int +-glusterd_nfssvc_check_topology_identical (gf_boolean_t *identical) +-{ +- char nfsvol[PATH_MAX] = {0,}; +- char tmpnfsvol[PATH_MAX] = {0,}; +- glusterd_conf_t *conf = NULL; +- xlator_t *this = THIS; +- int ret = -1; +- int tmpclean = 0; +- int tmpfd = -1; +- +- if ((!identical) || (!this) || (!this->private)) +- goto out; +- +- conf = (glusterd_conf_t *) this->private; +- GF_ASSERT (conf); +- +- /* Fetch the original NFS volfile */ +- glusterd_svc_build_volfile_path (conf->nfs_svc.name, conf->workdir, +- nfsvol, sizeof (nfsvol)); +- +- /* Create the temporary NFS volfile */ +- snprintf (tmpnfsvol, sizeof (tmpnfsvol), "/tmp/gnfs-XXXXXX"); +- tmpfd = mkstemp (tmpnfsvol); +- if (tmpfd < 0) { +- gf_msg (this->name, GF_LOG_WARNING, errno, +- GD_MSG_FILE_OP_FAILED, "Unable to create temp file" +- " %s: (%s)", tmpnfsvol, strerror (errno)); +- goto out; +- } +- +- tmpclean = 1; /* SET the flag to unlink() tmpfile */ +- +- ret = glusterd_create_global_volfile (build_nfs_graph, +- tmpnfsvol, NULL); +- if (ret) +- goto out; +- +- /* Compare the topology of volfiles */ +- ret = glusterd_check_topology_identical (nfsvol, tmpnfsvol, +- identical); +-out: +- if (tmpfd >= 0) +- close (tmpfd); +- if (tmpclean) +- unlink (tmpnfsvol); +- return ret; +-} +- + int + glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags) + { +@@ -246,17 +146,18 @@ glusterd_nfssvc_reconfigure () + gf_boolean_t identical = _gf_false; + + this = THIS; +- GF_ASSERT (this); ++ GF_VALIDATE_OR_GOTO (this->name, this, out); + + priv = this->private; +- GF_ASSERT (priv); +- ++ GF_VALIDATE_OR_GOTO (this->name, priv, out); + /* + * Check both OLD and NEW volfiles, if they are SAME by size + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ +- ret = glusterd_nfssvc_check_volfile_identical (&identical); ++ ret = glusterd_svc_check_volfile_identical (priv->nfs_svc.name, ++ build_nfs_graph, ++ &identical); + if (ret) + goto out; + +@@ -271,7 +172,9 @@ glusterd_nfssvc_reconfigure () + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ +- ret = glusterd_nfssvc_check_topology_identical (&identical); ++ ret = glusterd_svc_check_topology_identical (priv->nfs_svc.name, ++ build_nfs_graph, ++ &identical); + if (ret) + goto out; + +@@ -294,6 +197,7 @@ glusterd_nfssvc_reconfigure () + PROC_START_NO_WAIT); + + out: ++ gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 5e916eb..e7ad7f4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -1785,6 +1785,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + data_t *value = NULL; + char *key_fixed = NULL; + xlator_t *this = NULL; ++ glusterd_svc_t *svc = NULL; + + this = THIS; + GF_ASSERT (this); +@@ -1820,6 +1821,12 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + } + + gd_update_volume_op_versions (volinfo); ++ if (!volinfo->is_snap_volume) { ++ svc = &(volinfo->snapd.svc); ++ ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT); ++ if (ret) ++ goto out; ++ } + + ret = glusterd_create_volfiles_and_notify_services (volinfo); + if (ret) { +@@ -1836,7 +1843,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure (volinfo); ++ ret = glusterd_svcs_reconfigure (); + if (ret) + goto out; + } +@@ -2519,7 +2526,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure (volinfo); ++ ret = glusterd_svcs_reconfigure (); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SVC_RESTART_FAIL, +@@ -2557,7 +2564,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure (volinfo); ++ ret = glusterd_svcs_reconfigure (); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_NFS_SERVER_START_FAIL, +@@ -2773,7 +2780,7 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) +- ret = glusterd_svcs_reconfigure (volinfo); ++ ret = glusterd_svcs_reconfigure (); + + ret = 0; + +diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +index 59a7671..f3475a3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +@@ -15,6 +15,7 @@ + #include "glusterd-volgen.h" + #include "glusterd-quotad-svc.h" + #include "glusterd-messages.h" ++#include "glusterd-svc-helper.h" + + char *quotad_svc_name = "quotad"; + +@@ -36,13 +37,6 @@ int glusterd_quotadsvc_init (glusterd_svc_t *svc) + if (ret) + goto out; + +- /* glusterd_svc_build_volfile_path () doesn't put correct quotad volfile +- * path in proc object at service initialization. Re-initialize +- * the correct path +- */ +- glusterd_quotadsvc_build_volfile_path (quotad_svc_name, conf->workdir, +- volfile, sizeof (volfile)); +- snprintf (svc->proc.volfile, sizeof (svc->proc.volfile), "%s", volfile); + out: + return ret; + } +@@ -53,8 +47,8 @@ glusterd_quotadsvc_create_volfile () + char filepath[PATH_MAX] = {0,}; + glusterd_conf_t *conf = THIS->private; + +- glusterd_quotadsvc_build_volfile_path (quotad_svc_name, conf->workdir, +- filepath, sizeof (filepath)); ++ glusterd_svc_build_volfile_path (quotad_svc_name, conf->workdir, ++ filepath, sizeof (filepath)); + return glusterd_create_global_volfile (build_quotad_graph, + filepath, NULL); + } +@@ -162,17 +156,67 @@ out: + int + glusterd_quotadsvc_reconfigure () + { +- return glusterd_svc_reconfigure (glusterd_quotadsvc_create_volfile); +-} ++ int ret = -1; ++ xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; ++ gf_boolean_t identical = _gf_false; + +-void +-glusterd_quotadsvc_build_volfile_path (char *server, char *workdir, +- char *volfile, size_t len) +-{ +- char dir[PATH_MAX] = {0,}; ++ this = THIS; ++ GF_VALIDATE_OR_GOTO (this->name, this, out); ++ ++ priv = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, priv, out); ++ ++ if (glusterd_all_volumes_with_quota_stopped ()) ++ goto manager; ++ ++ /* ++ * Check both OLD and NEW volfiles, if they are SAME by size ++ * and cksum i.e. "character-by-character". If YES, then ++ * NOTHING has been changed, just return. ++ */ ++ ret = glusterd_svc_check_volfile_identical (priv->quotad_svc.name, ++ build_quotad_graph, ++ &identical); ++ if (ret) ++ goto out; ++ ++ if (identical) { ++ ret = 0; ++ goto out; ++ } ++ ++ /* ++ * They are not identical. Find out if the topology is changed ++ * OR just the volume options. If just the options which got ++ * changed, then inform the xlator to reconfigure the options. ++ */ ++ identical = _gf_false; /* RESET the FLAG */ ++ ret = glusterd_svc_check_topology_identical (priv->quotad_svc.name, ++ build_quotad_graph, ++ &identical); ++ if (ret) ++ goto out; + +- GF_ASSERT (len == PATH_MAX); ++ /* Topology is not changed, but just the options. But write the ++ * options to quotad volfile, so that quotad will be reconfigured. ++ */ ++ if (identical) { ++ ret = glusterd_quotadsvc_create_volfile (); ++ if (ret == 0) {/* Only if above PASSES */ ++ ret = glusterd_fetchspec_notify (THIS); ++ } ++ goto out; ++ } ++manager: ++ /* ++ * quotad volfile's topology has been changed. quotad server needs ++ * to be RESTARTED to ACT on the changed volfile. ++ */ ++ ret = priv->quotad_svc.manager (&(priv->quotad_svc), NULL, ++ PROC_START_NO_WAIT); + +- glusterd_svc_build_svcdir (server, workdir, dir, sizeof (dir)); +- snprintf (volfile, len, "%s/%s.vol", dir, server); ++out: ++ gf_msg_debug (this->name, 0, "Returning %d", ret); ++ return ret; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h +index c275aa4..5d35a00 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h +@@ -33,7 +33,4 @@ glusterd_quotadsvc_manager (glusterd_svc_t *svc, void *data, int flags); + int + glusterd_quotadsvc_reconfigure (); + +-void +-glusterd_quotadsvc_build_volfile_path (char *server, char *workdir, +- char *volfile, size_t len); + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +index b5c9785..3761dba 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +@@ -14,6 +14,7 @@ + #include "glusterd-utils.h" + #include "glusterd-volgen.h" + #include "glusterd-scrub-svc.h" ++#include "glusterd-svc-helper.h" + + char *scrub_svc_name = "scrub"; + +@@ -136,5 +137,71 @@ glusterd_scrubsvc_stop (glusterd_svc_t *svc, int sig) + int + glusterd_scrubsvc_reconfigure () + { +- return glusterd_svc_reconfigure (glusterd_scrubsvc_create_volfile); ++ int ret = -1; ++ xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; ++ gf_boolean_t identical = _gf_false; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO (this->name, this, out); ++ ++ priv = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, priv, out); ++ ++ if (glusterd_should_i_stop_bitd ()) ++ goto manager; ++ ++ ++ /* ++ * Check both OLD and NEW volfiles, if they are SAME by size ++ * and cksum i.e. "character-by-character". If YES, then ++ * NOTHING has been changed, just return. ++ */ ++ ret = glusterd_svc_check_volfile_identical (priv->scrub_svc.name, ++ build_scrub_graph, ++ &identical); ++ if (ret) ++ goto out; ++ ++ if (identical) { ++ ret = 0; ++ goto out; ++ } ++ ++ /* ++ * They are not identical. Find out if the topology is changed ++ * OR just the volume options. If just the options which got ++ * changed, then inform the xlator to reconfigure the options. ++ */ ++ identical = _gf_false; /* RESET the FLAG */ ++ ret = glusterd_svc_check_topology_identical (priv->scrub_svc.name, ++ build_scrub_graph, ++ &identical); ++ if (ret) ++ goto out; ++ ++ /* Topology is not changed, but just the options. But write the ++ * options to scrub volfile, so that scrub will be reconfigured. ++ */ ++ if (identical) { ++ ret = glusterd_scrubsvc_create_volfile (); ++ if (ret == 0) {/* Only if above PASSES */ ++ ret = glusterd_fetchspec_notify (THIS); ++ } ++ goto out; ++ } ++ ++manager: ++ /* ++ * scrub volfile's topology has been changed. scrub server needs ++ * to be RESTARTED to ACT on the changed volfile. ++ */ ++ ret = priv->scrub_svc.manager (&(priv->scrub_svc), ++ NULL, ++ PROC_START_NO_WAIT); ++ ++out: ++ gf_msg_debug (this->name, 0, "Returning %d", ret); ++ return ret; ++ + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index f9f4189..0e664b5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -15,6 +15,7 @@ + #include "glusterd-volgen.h" + #include "glusterd-svc-mgmt.h" + #include "glusterd-shd-svc.h" ++#include "glusterd-svc-helper.h" + + char *shd_svc_name = "glustershd"; + +@@ -182,5 +183,68 @@ out: + int + glusterd_shdsvc_reconfigure () + { +- return glusterd_svc_reconfigure (glusterd_shdsvc_create_volfile); ++ int ret = -1; ++ xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; ++ gf_boolean_t identical = _gf_false; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO (this->name, this, out); ++ ++ priv = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, priv, out); ++ ++ if (glusterd_all_shd_compatible_volumes_stopped ()) ++ goto manager; ++ ++ /* ++ * Check both OLD and NEW volfiles, if they are SAME by size ++ * and cksum i.e. "character-by-character". If YES, then ++ * NOTHING has been changed, just return. ++ */ ++ ret = glusterd_svc_check_volfile_identical (priv->shd_svc.name, ++ build_shd_graph, ++ &identical); ++ if (ret) ++ goto out; ++ ++ if (identical) { ++ ret = 0; ++ goto out; ++ } ++ ++ /* ++ * They are not identical. Find out if the topology is changed ++ * OR just the volume options. If just the options which got ++ * changed, then inform the xlator to reconfigure the options. ++ */ ++ identical = _gf_false; /* RESET the FLAG */ ++ ret = glusterd_svc_check_topology_identical (priv->shd_svc.name, ++ build_shd_graph, ++ &identical); ++ if (ret) ++ goto out; ++ ++ /* Topology is not changed, but just the options. But write the ++ * options to shd volfile, so that shd will be reconfigured. ++ */ ++ if (identical) { ++ ret = glusterd_shdsvc_create_volfile (); ++ if (ret == 0) {/* Only if above PASSES */ ++ ret = glusterd_fetchspec_notify (THIS); ++ } ++ goto out; ++ } ++manager: ++ /* ++ * shd volfile's topology has been changed. shd server needs ++ * to be RESTARTED to ACT on the changed volfile. ++ */ ++ ret = priv->shd_svc.manager (&(priv->shd_svc), NULL, ++ PROC_START_NO_WAIT); ++ ++out: ++ gf_msg_debug (this->name, 0, "Returning %d", ret); ++ return ret; ++ + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index c88b613..18136fb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -19,9 +19,10 @@ + #include "glusterd-nfs-svc.h" + #include "glusterd-bitd-svc.h" + #include "glusterd-scrub-svc.h" ++#include "glusterd-svc-helper.h" + + int +-glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo) ++glusterd_svcs_reconfigure () + { + int ret = 0; + xlator_t *this = THIS; +@@ -36,23 +37,17 @@ glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo) + if (ret) + goto out; + +- if (volinfo && !glusterd_is_shd_compatible_volume (volinfo)) { +- ; /* Do nothing */ +- } else { +- ret = glusterd_shdsvc_reconfigure (); +- if (ret) +- goto out; +- } ++ ret = glusterd_shdsvc_reconfigure (); ++ if (ret) ++ goto out; ++ + if (conf->op_version == GD_OP_VERSION_MIN) + goto out; + +- if (volinfo && !glusterd_is_volume_quota_enabled (volinfo)) { +- /*Do nothing */ +- } else { +- ret = glusterd_quotadsvc_reconfigure (); +- if (ret) +- goto out; +- } ++ ret = glusterd_quotadsvc_reconfigure (); ++ if (ret) ++ goto out; ++ + ret = glusterd_bitdsvc_reconfigure (); + if (ret) + goto out; +@@ -153,3 +148,107 @@ out: + } + + ++int ++glusterd_svc_check_volfile_identical (char *svc_name, ++ glusterd_graph_builder_t builder, ++ gf_boolean_t *identical) ++{ ++ char orgvol[PATH_MAX] = {0,}; ++ char tmpvol[PATH_MAX] = {0,}; ++ glusterd_conf_t *conf = NULL; ++ xlator_t *this = NULL; ++ int ret = -1; ++ int need_unlink = 0; ++ int tmp_fd = -1; ++ ++ this = THIS; ++ ++ GF_ASSERT (this); ++ GF_ASSERT (identical); ++ conf = this->private; ++ ++ glusterd_svc_build_volfile_path (svc_name, conf->workdir, ++ orgvol, sizeof (orgvol)); ++ ++ snprintf (tmpvol, sizeof (tmpvol), "/tmp/g%s-XXXXXX", svc_name); ++ ++ tmp_fd = mkstemp (tmpvol); ++ if (tmp_fd < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to create temp file" ++ " %s:(%s)", tmpvol, strerror (errno)); ++ goto out; ++ } ++ ++ need_unlink = 1; ++ ++ ret = glusterd_create_global_volfile (builder, ++ tmpvol, NULL); ++ if (ret) ++ goto out; ++ ++ ret = glusterd_check_files_identical (orgvol, tmpvol, ++ identical); ++ if (ret) ++ goto out; ++ ++out: ++ if (need_unlink) ++ unlink (tmpvol); ++ ++ if (tmp_fd >= 0) ++ close (tmp_fd); ++ ++ return ret; ++} ++ ++int ++glusterd_svc_check_topology_identical (char *svc_name, ++ glusterd_graph_builder_t builder, ++ gf_boolean_t *identical) ++{ ++ char orgvol[PATH_MAX] = {0,}; ++ char tmpvol[PATH_MAX] = {0,}; ++ glusterd_conf_t *conf = NULL; ++ xlator_t *this = THIS; ++ int ret = -1; ++ int tmpclean = 0; ++ int tmpfd = -1; ++ ++ if ((!identical) || (!this) || (!this->private)) ++ goto out; ++ ++ conf = this->private; ++ GF_VALIDATE_OR_GOTO (this->name, conf, out); ++ ++ /* Fetch the original volfile */ ++ glusterd_svc_build_volfile_path (svc_name, conf->workdir, ++ orgvol, sizeof (orgvol)); ++ ++ /* Create the temporary volfile */ ++ snprintf (tmpvol, sizeof (tmpvol), "/tmp/g%s-XXXXXX", svc_name); ++ tmpfd = mkstemp (tmpvol); ++ if (tmpfd < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, errno, ++ GD_MSG_FILE_OP_FAILED, "Unable to create temp file" ++ " %s:(%s)", tmpvol, strerror (errno)); ++ goto out; ++ } ++ ++ tmpclean = 1; /* SET the flag to unlink() tmpfile */ ++ ++ ret = glusterd_create_global_volfile (builder, ++ tmpvol, NULL); ++ if (ret) ++ goto out; ++ ++ /* Compare the topology of volfiles */ ++ ret = glusterd_check_topology_identical (orgvol, tmpvol, ++ identical); ++out: ++ if (tmpfd >= 0) ++ close (tmpfd); ++ if (tmpclean) ++ unlink (tmpvol); ++ return ret; ++} +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h +index 2af75bc..053f69a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h +@@ -18,13 +18,24 @@ + + #include "glusterd.h" + #include "glusterd-svc-mgmt.h" ++#include "glusterd-volgen.h" + + int +-glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo); ++glusterd_svcs_reconfigure (); + + int + glusterd_svcs_stop (); + + int + glusterd_svcs_manager (glusterd_volinfo_t *volinfo); ++ ++int ++glusterd_svc_check_volfile_identical (char *svc_name, ++ glusterd_graph_builder_t builder, ++ gf_boolean_t *identical); ++int ++glusterd_svc_check_topology_identical (char *svc_name, ++ glusterd_graph_builder_t builder, ++ gf_boolean_t *identical); ++ + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +index 130bc56..25314a1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +@@ -250,7 +250,11 @@ glusterd_svc_build_volfile_path (char *server, char *workdir, char *volfile, + GF_ASSERT (len == PATH_MAX); + + glusterd_svc_build_svcdir (server, workdir, dir, sizeof (dir)); +- snprintf (volfile, len, "%s/%s-server.vol", dir, server); ++ ++ if (!strcmp(server, "quotad")) /*quotad has different volfile name*/ ++ snprintf (volfile, len, "%s/%s.vol", dir, server); ++ else ++ snprintf (volfile, len, "%s/%s-server.vol", dir, server); + } + + void +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index ee5cf68..836ec3e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -5416,8 +5416,7 @@ out: + } + + int +-glusterd_create_global_volfile (int (*builder) (volgen_graph_t *graph, +- dict_t *set_dict), ++glusterd_create_global_volfile (glusterd_graph_builder_t builder, + char *filepath, dict_t *mod_dict) + { + volgen_graph_t graph = {0,}; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h +index cdeaea4..7453c0d 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h +@@ -60,6 +60,9 @@ struct volgen_graph { + }; + typedef struct volgen_graph volgen_graph_t; + ++typedef int (*glusterd_graph_builder_t) (volgen_graph_t *graph, ++ dict_t *mod_dict); ++ + #define COMPLETE_OPTION(key, completion, ret) \ + do { \ + if (!strchr (key, '.')) { \ +@@ -158,8 +161,7 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, + glusterd_volinfo_t *volinfo); + + int +-glusterd_create_global_volfile (int (*builder) (volgen_graph_t *graph, +- dict_t *set_dict), ++glusterd_create_global_volfile (glusterd_graph_builder_t builder, + char *filepath, dict_t *mod_dict); + + int +@@ -262,12 +264,6 @@ end_sethelp_xml_doc (xmlTextWriterPtr writer); + char* + glusterd_get_trans_type_rb (gf_transport_type ttype); + +-int +-glusterd_check_nfs_volfile_identical (gf_boolean_t *identical); +- +-int +-glusterd_check_nfs_topology_identical (gf_boolean_t *identical); +- + uint32_t + glusterd_get_op_version_for_key (char *key); + +-- +1.7.1 + diff --git a/SOURCES/0269-snapview-client-Allocate-memory-using-GF_CALLOC.patch b/SOURCES/0269-snapview-client-Allocate-memory-using-GF_CALLOC.patch new file mode 100644 index 0000000..6bac01c --- /dev/null +++ b/SOURCES/0269-snapview-client-Allocate-memory-using-GF_CALLOC.patch @@ -0,0 +1,50 @@ +From b7ba294c987f0f8b9a2a39067f59e0ffc0463f38 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Mon, 6 Jul 2015 12:15:45 +0530 +Subject: [PATCH 269/279] snapview-client: Allocate memory using GF_CALLOC + +loc->path memory should allocate through +GF_CALLOC/GF_MALLOC, since it uses GF_FREE +from loc_wipe. + +Back port of : +>Change-Id: If3030175dfb07b0e0b6c0a30234857f8a0780035 +>BUG: 1240184 +>Signed-off-by: Mohammed Rafi KC +>Reviewed-on: http://review.gluster.org/11543 +>Tested-by: NetBSD Build System +>Reviewed-by: Avra Sengupta +>Reviewed-by: Vijay Bellur + +(cherry picked from commit 32207db25eea821dfb1abd033df1013d4b8fc622) + +Change-Id: I69f9338dc5ae9950b5344000259558423c3f8618 +BUG: 1245915 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: http://review.gluster.org/11743 +Reviewed-by: Niels de Vos +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-on: https://code.engineering.redhat.com/gerrit/55152 +Reviewed-by: Rajesh Joseph +Tested-by: Rajesh Joseph +--- + .../features/snapview-client/src/snapview-client.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c +index 81e3b20..f1b3899 100644 +--- a/xlators/features/snapview-client/src/snapview-client.c ++++ b/xlators/features/snapview-client/src/snapview-client.c +@@ -536,7 +536,7 @@ svc_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, + * virtual directory from path + */ + subvolume = FIRST_CHILD (this); +- root_loc.path = "/"; ++ root_loc.path = gf_strdup("/"); + gf_uuid_clear(root_loc.gfid); + root_loc.gfid[15] = 1; + root_loc.inode = inode_ref (loc->inode->table->root); +-- +1.7.1 + diff --git a/SOURCES/0270-rpc-add-owner-xlator-argument-to-rpc_clnt_new.patch b/SOURCES/0270-rpc-add-owner-xlator-argument-to-rpc_clnt_new.patch new file mode 100644 index 0000000..ed774f5 --- /dev/null +++ b/SOURCES/0270-rpc-add-owner-xlator-argument-to-rpc_clnt_new.patch @@ -0,0 +1,310 @@ +From e472b92b2306c37350ca66678d2b642ff510d8b4 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Fri, 14 Aug 2015 16:01:05 +0530 +Subject: [PATCH 270/279] rpc: add owner xlator argument to rpc_clnt_new + + Backport of http://review.gluster.com/11908 + +The @owner argument tells RPC layer the xlator that owns the connection +and to which xlator THIS needs be set during network notifications like +CONNECT and DISCONNECT. + +Code paths that originate from the head of a (volume) graph and use +STACK_WIND ensure that the RPC local endpoint has the right xlator saved +in the frame of the call (callback pair). This guarantees that the +callback is executed in the right xlator context. + +The client handshake process which includes fetching of brick ports from +glusterd, setting lk-version on the brick for the session, don't have +the correct xlator set in their frames. The problem lies with RPC +notifications. It doesn't have the provision to set THIS with the xlator +that is registered with the corresponding RPC programs. e.g, +RPC_CLNT_CONNECT event received by protocol/client doesn't have THIS set +to its xlator. This implies, call(-callbacks) originating from this +thread don't have the right xlator set too. + +The fix would be to save the xlator registered with the RPC connection +during rpc_clnt_new. e.g, protocol/client's xlator would be saved with +the RPC connection that it 'owns'. RPC notifications such as CONNECT, +DISCONNECT, etc inherit THIS from the RPC connection's xlator. + +BUG: 1235571 +Change-Id: I6138c7f2ffa9a99a15eec020e1f829400b186ce4 +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/55164 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + api/src/glfs-internal.h | 1 - + api/src/glfs-mgmt.c | 2 +- + cli/src/cli-quotad-client.c | 2 +- + cli/src/cli.c | 2 +- + glusterfsd/src/glusterfsd-mgmt.c | 2 +- + libglusterfs/src/globals.h | 1 + + rpc/rpc-lib/src/rpc-clnt.c | 19 ++++++++++++++++++- + rpc/rpc-lib/src/rpc-clnt.h | 4 +++- + .../features/changelog/src/changelog-rpc-common.c | 2 +- + xlators/features/quota/src/quota-enforcer-client.c | 2 +- + .../snapview-server/src/snapview-server-mgmt.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-handler.c | 2 +- + xlators/nfs/server/src/nlm4.c | 2 +- + xlators/protocol/client/src/client.c | 2 +- + 15 files changed, 33 insertions(+), 14 deletions(-) + +diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h +index 83b4ade..8ff78de 100644 +--- a/api/src/glfs-internal.h ++++ b/api/src/glfs-internal.h +@@ -199,7 +199,6 @@ int glfs_first_lookup (xlator_t *subvol); + void glfs_process_upcall_event (struct glfs *fs, void *data); + GFAPI_PRIVATE(glfs_process_upcall_event, 3.7.0); + +-#define DECLARE_OLD_THIS xlator_t *old_THIS = NULL + + #define __GLFS_ENTRY_VALIDATE_FS(fs, label) \ + do { \ +diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c +index 2159d67..903b102 100644 +--- a/api/src/glfs-mgmt.c ++++ b/api/src/glfs-mgmt.c +@@ -868,7 +868,7 @@ glfs_mgmt_init (struct glfs *fs) + if (ret) + goto out; + +- rpc = rpc_clnt_new (options, ctx, THIS->name, 8); ++ rpc = rpc_clnt_new (options, THIS, THIS->name, 8); + if (!rpc) { + ret = -1; + gf_msg (THIS->name, GF_LOG_WARNING, 0, +diff --git a/cli/src/cli-quotad-client.c b/cli/src/cli-quotad-client.c +index 7c16519..d3a2312 100644 +--- a/cli/src/cli-quotad-client.c ++++ b/cli/src/cli-quotad-client.c +@@ -131,7 +131,7 @@ cli_quotad_clnt_init (xlator_t *this, dict_t *options) + if (ret) + goto out; + +- rpc = rpc_clnt_new (options, this->ctx, this->name, 16); ++ rpc = rpc_clnt_new (options, this, this->name, 16); + if (!rpc) + goto out; + +diff --git a/cli/src/cli.c b/cli/src/cli.c +index 525ec4b..851178b 100644 +--- a/cli/src/cli.c ++++ b/cli/src/cli.c +@@ -627,7 +627,7 @@ cli_rpc_init (struct cli_state *state) + goto out; + } + +- rpc = rpc_clnt_new (options, this->ctx, this->name, 16); ++ rpc = rpc_clnt_new (options, this, this->name, 16); + if (!rpc) + goto out; + +diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c +index 1cff44b..aa7ee4f 100644 +--- a/glusterfsd/src/glusterfsd-mgmt.c ++++ b/glusterfsd/src/glusterfsd-mgmt.c +@@ -2038,7 +2038,7 @@ glusterfs_mgmt_init (glusterfs_ctx_t *ctx) + if (ret) + goto out; + +- rpc = rpc_clnt_new (options, THIS->ctx, THIS->name, 8); ++ rpc = rpc_clnt_new (options, THIS, THIS->name, 8); + if (!rpc) { + ret = -1; + gf_log (THIS->name, GF_LOG_WARNING, "failed to create rpc clnt"); +diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h +index 9aca3c3..9579c45 100644 +--- a/libglusterfs/src/globals.h ++++ b/libglusterfs/src/globals.h +@@ -68,6 +68,7 @@ + + /* THIS */ + #define THIS (*__glusterfs_this_location()) ++#define DECLARE_OLD_THIS xlator_t *old_THIS = THIS + + xlator_t **__glusterfs_this_location (); + xlator_t *glusterfs_this_get (); +diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c +index 5fbe072..1d87866 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.c ++++ b/rpc/rpc-lib/src/rpc-clnt.c +@@ -817,6 +817,16 @@ out: + static void + rpc_clnt_destroy (struct rpc_clnt *rpc); + ++#define RPC_THIS_SAVE(xl) do { \ ++ old_THIS = THIS ; \ ++ if (!old_THIS) \ ++ gf_log_callingfn ("rpc", GF_LOG_CRITICAL, \ ++ "THIS is not initialised."); \ ++ THIS = xl; \ ++} while (0) ++ ++#define RPC_THIS_RESTORE (THIS = old_THIS) ++ + int + rpc_clnt_notify (rpc_transport_t *trans, void *mydata, + rpc_transport_event_t event, void *data, ...) +@@ -828,6 +838,7 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata, + rpc_transport_pollin_t *pollin = NULL; + struct timespec ts = {0, }; + void *clnt_mydata = NULL; ++ DECLARE_OLD_THIS; + + conn = mydata; + if (conn == NULL) { +@@ -837,6 +848,8 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata, + if (!clnt) + goto out; + ++ RPC_THIS_SAVE (clnt->owner); ++ + switch (event) { + case RPC_TRANSPORT_DISCONNECT: + { +@@ -937,6 +950,7 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata, + } + + out: ++ RPC_THIS_RESTORE; + return ret; + } + +@@ -1041,11 +1055,13 @@ out: + } + + struct rpc_clnt * +-rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, char *name, ++rpc_clnt_new (dict_t *options, xlator_t *owner, char *name, + uint32_t reqpool_size) + { + int ret = -1; + struct rpc_clnt *rpc = NULL; ++ glusterfs_ctx_t *ctx = owner->ctx; ++ + + rpc = GF_CALLOC (1, sizeof (*rpc), gf_common_mt_rpcclnt_t); + if (!rpc) { +@@ -1054,6 +1070,7 @@ rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, char *name, + + pthread_mutex_init (&rpc->lock, NULL); + rpc->ctx = ctx; ++ rpc->owner = owner; + + if (!reqpool_size) + reqpool_size = RPC_CLNT_DEFAULT_REQUEST_COUNT; +diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h +index ee46a9a..6a4bb40 100644 +--- a/rpc/rpc-lib/src/rpc-clnt.h ++++ b/rpc/rpc-lib/src/rpc-clnt.h +@@ -188,9 +188,11 @@ typedef struct rpc_clnt { + int refcount; + int auth_null; + char disabled; ++ xlator_t *owner; + } rpc_clnt_t; + +-struct rpc_clnt *rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, ++ ++struct rpc_clnt *rpc_clnt_new (dict_t *options, xlator_t *owner, + char *name, uint32_t reqpool_size); + + int rpc_clnt_start (struct rpc_clnt *rpc); +diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c +index de3a730..b3b14fa 100644 +--- a/xlators/features/changelog/src/changelog-rpc-common.c ++++ b/xlators/features/changelog/src/changelog-rpc-common.c +@@ -52,7 +52,7 @@ changelog_rpc_client_init (xlator_t *this, void *cbkdata, + goto dealloc_dict; + } + +- rpc = rpc_clnt_new (options, this->ctx, this->name, 16); ++ rpc = rpc_clnt_new (options, this, this->name, 16); + if (!rpc) + goto dealloc_dict; + +diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c +index 067db6d..10bd24f 100644 +--- a/xlators/features/quota/src/quota-enforcer-client.c ++++ b/xlators/features/quota/src/quota-enforcer-client.c +@@ -453,7 +453,7 @@ quota_enforcer_init (xlator_t *this, dict_t *options) + if (ret) + goto out; + +- rpc = rpc_clnt_new (options, this->ctx, this->name, 16); ++ rpc = rpc_clnt_new (options, this, this->name, 16); + if (!rpc) { + ret = -1; + goto out; +diff --git a/xlators/features/snapview-server/src/snapview-server-mgmt.c b/xlators/features/snapview-server/src/snapview-server-mgmt.c +index 0fe3687..4b61326 100644 +--- a/xlators/features/snapview-server/src/snapview-server-mgmt.c ++++ b/xlators/features/snapview-server/src/snapview-server-mgmt.c +@@ -85,7 +85,7 @@ svs_mgmt_init (xlator_t *this) + goto out; + } + +- priv->rpc = rpc_clnt_new (options, this->ctx, this->name, 8); ++ priv->rpc = rpc_clnt_new (options, this, this->name, 8); + if (!priv->rpc) { + gf_log (this->name, GF_LOG_ERROR, "failed to initialize RPC"); + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +index fca9323..607a065 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +@@ -46,7 +46,7 @@ glusterd_conn_init (glusterd_conn_t *conn, char *sockpath, + goto out; + + /* @options is free'd by rpc_transport when destroyed */ +- rpc = rpc_clnt_new (options, this->ctx, (char *)svc->name, 16); ++ rpc = rpc_clnt_new (options, this, (char *)svc->name, 16); + if (!rpc) { + ret = -1; + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 82bd7b1..ed5d6ff 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -3295,7 +3295,7 @@ glusterd_rpc_create (struct rpc_clnt **rpc, + GF_ASSERT (options); + + /* TODO: is 32 enough? or more ? */ +- new_rpc = rpc_clnt_new (options, this->ctx, this->name, 16); ++ new_rpc = rpc_clnt_new (options, this, this->name, 16); + if (!new_rpc) + goto out; + +diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c +index a1127a3..ac45b4f 100644 +--- a/xlators/nfs/server/src/nlm4.c ++++ b/xlators/nfs/server/src/nlm4.c +@@ -1055,7 +1055,7 @@ nlm4_establish_callback (void *csarg) + } + + /* TODO: is 32 frames in transit enough ? */ +- rpc_clnt = rpc_clnt_new (options, cs->nfsx->ctx, "NLM-client", 32); ++ rpc_clnt = rpc_clnt_new (options, cs->nfsx, "NLM-client", 32); + if (rpc_clnt == NULL) { + gf_msg (GF_NLM, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "rpc_clnt NULL"); +diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c +index db7a07a..ccb26dd 100644 +--- a/xlators/protocol/client/src/client.c ++++ b/xlators/protocol/client/src/client.c +@@ -2286,7 +2286,7 @@ client_init_rpc (xlator_t *this) + goto out; + } + +- conf->rpc = rpc_clnt_new (this->options, this->ctx, this->name, 0); ++ conf->rpc = rpc_clnt_new (this->options, this, this->name, 0); + if (!conf->rpc) { + gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_INIT_FAILED, + "failed to initialize RPC"); +-- +1.7.1 + diff --git a/SOURCES/0271-rebalance-glusterd-Refactor-rebalance-volfile.patch b/SOURCES/0271-rebalance-glusterd-Refactor-rebalance-volfile.patch new file mode 100644 index 0000000..a35409c --- /dev/null +++ b/SOURCES/0271-rebalance-glusterd-Refactor-rebalance-volfile.patch @@ -0,0 +1,197 @@ +From 374e94cd9670ee9f0ef997edfde6f9198d5494b5 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Tue, 7 Jul 2015 16:27:45 +0530 +Subject: [PATCH 271/279] rebalance/glusterd: Refactor rebalance volfile + + Back port of http://review.gluster.org/11889 + +performance xlator loaded in rebalance xlators are dummy +translators, since all fops are starting with dht level. + +Removing the performance xlators from rebalance volfile +will help to minimize the chance for a graph switch. + +The new rebalance xlators will look like->>> + + (io-stats) + || + || + || + (----DHT----) + // \\ + // \\ + // \\ + (replica-1) ... (replica-n) + // \\ // \\ + // \\ // \\ + // \\ // \\ + client client client client + +Back port of : +>Change-Id: I3808e3b48fd0cb3e60ef386b8ac9fd994e2831e3 +>BUG: 1240621 +>Signed-off-by: Mohammed Rafi KC +>Reviewed-on: http://review.gluster.org/11565 +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: Dan Lambright +>Reviewed-by: Atin Mukherjee + +>(cherry picked from commit 16bd894480b34e20950af795dc1ebb66d942541a) + +>Change-Id: I967754fd69629e983ff355e1f60eb91bbaa96b9a +>BUG: 1252727 +>Signed-off-by: Mohammed Rafi KC +>Reviewed-on: http://review.gluster.org/11889 +>Tested-by: NetBSD Build System +>Tested-by: Gluster Build System +>Reviewed-by: N Balachandran +>Reviewed-by: Atin Mukherjee + +Change-Id: I7a05bcb734273ab6fcac6296c0e15cdb9d31e7b3 +BUG: 1253549 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/55292 +Reviewed-by: Nithya Balachandran +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 98 ++++++++++++++++++++------- + 1 files changed, 74 insertions(+), 24 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index 836ec3e..3d04e9f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -3534,7 +3534,6 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + gf_boolean_t var = _gf_false; + gf_boolean_t ob = _gf_false; + gf_boolean_t uss_enabled = _gf_false; +- gf_boolean_t rebal_volfile = _gf_false; + xlator_t *this = THIS; + + GF_ASSERT (this); +@@ -3752,19 +3751,12 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + if (uss_enabled == -1) + goto out; + if (uss_enabled && !volinfo->is_snap_volume) { +- rebal_volfile = dict_get_str_boolean (set_dict, +- "rebalance-volfile-creation", +- _gf_false); +- if (rebal_volfile == -1) +- goto out; + +- if (!rebal_volfile) { +- ret = volgen_graph_build_snapview_client +- (graph, volinfo, +- volname, set_dict); +- if (ret == -1) +- goto out; +- } ++ ret = volgen_graph_build_snapview_client ++ (graph, volinfo, ++ volname, set_dict); ++ if (ret == -1) ++ goto out; + } + + ret = dict_get_str_boolean (set_dict, "ganesha.enable", _gf_false); +@@ -4212,6 +4204,73 @@ out: + } + + static int ++build_rebalance_volfile (glusterd_volinfo_t *volinfo, char *filepath, ++ dict_t *mod_dict) ++{ ++ volgen_graph_t graph = {0,}; ++ xlator_t *xl = NULL; ++ int ret = -1; ++ xlator_t *this = NULL; ++ dict_t *set_dict = NULL; ++ ++ this = THIS; ++ ++ if (volinfo->brick_count <= volinfo->dist_leaf_count) { ++ /* ++ * Volume is not a distribute volume or ++ * contains only 1 brick, no need to create ++ * the volfiles. ++ */ ++ return 0; ++ } ++ ++ if (mod_dict) { ++ set_dict = dict_copy (volinfo->dict, NULL); ++ if (!set_dict) ++ return -1; ++ dict_copy (mod_dict, set_dict); ++ /* XXX dict_copy swallows errors */ ++ } else { ++ set_dict = volinfo->dict; ++ } ++ ++ ++ ret = volgen_graph_build_clients (&graph, volinfo, set_dict, NULL); ++ if (volinfo->type == GF_CLUSTER_TYPE_TIER) ++ ret = volume_volgen_graph_build_clusters_tier ++ (&graph, volinfo, _gf_false); ++ else ++ ret = volume_volgen_graph_build_clusters ++ (&graph, volinfo, _gf_false); ++ ++ xl = volgen_graph_add_as (&graph, "debug/io-stats", volinfo->volname); ++ if (!xl) { ++ ret = -1; ++ goto out; ++ } ++ ++ ret = graph_set_generic_options (this, &graph, set_dict, ++ "rebalance-daemon"); ++ if (ret) ++ goto out; ++ ++ ret = volgen_graph_set_options_generic (&graph, set_dict, volinfo, ++ basic_option_handler); ++ ++ if (!ret) ++ ret = volgen_write_volfile (&graph, filepath); ++ ++out: ++ volgen_graph_free (&graph); ++ ++ if (mod_dict) ++ dict_destroy (set_dict); ++ ++ ++ return ret; ++ ++} ++static int + build_shd_volume_graph (xlator_t *this, volgen_graph_t *graph, + glusterd_volinfo_t *volinfo, + dict_t *mod_dict, dict_t *set_dict, +@@ -4871,19 +4930,10 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, + } + + /* Generate volfile for rebalance process */ +- ret = dict_set_int32 (dict, "rebalance-volfile-creation", _gf_true); +- if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, errno, +- GD_MSG_DICT_SET_FAILED, +- "Failed to set rebalance-volfile-creation"); +- goto out; +- } +- + glusterd_get_rebalance_volfile (volinfo, filepath, PATH_MAX); ++ ret = build_rebalance_volfile (volinfo, filepath, dict); ++ + +- ret = generate_single_transport_client_volfile (volinfo, +- filepath, +- dict); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, +-- +1.7.1 + diff --git a/SOURCES/0272-glusterd-log-improvement-in-glusterd_peer_rpc_notify.patch b/SOURCES/0272-glusterd-log-improvement-in-glusterd_peer_rpc_notify.patch new file mode 100644 index 0000000..6427885 --- /dev/null +++ b/SOURCES/0272-glusterd-log-improvement-in-glusterd_peer_rpc_notify.patch @@ -0,0 +1,54 @@ +From 32b0df844e96cfff95ef2c1c7366b6b521070f24 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Thu, 16 Apr 2015 17:54:24 +0530 +Subject: [PATCH 272/279] glusterd: log improvement in glusterd_peer_rpc_notify + +Backport of http://review.gluster.org/#/c/11886/ + +If ping time out is enabled glusterd can receive a disconnect event from a peer +which has been already deleted resulting into a critical log printed. This patch +ensures that critical message is logged only when its a connect event. + +Change-Id: I67d9aa3f60195e08af7dfc8a42683422aaf90a00 +BUG: 1246946 +Signed-off-by: Atin Mukherjee +Reviewed-on: http://review.gluster.org/10272 +Tested-by: Gluster Build System +Reviewed-by: Gaurav Kumar Garg +Tested-by: NetBSD Build System +Reviewed-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/55047 +Tested-by: Krishnan Parthasarathi +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 13 +++++++++---- + 1 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index ed5d6ff..c2bfcf5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -5011,12 +5011,17 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, + + peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen); + if (!peerinfo) { +- /* Peerinfo should be available at this point. Not finding it +- * means that something terrible has happened ++ /* Peerinfo should be available at this point if its a connect ++ * event. Not finding it means that something terrible has ++ * happened. For non-connect event we might end up having a null ++ * peerinfo, so log at debug level. + */ +- gf_msg (THIS->name, GF_LOG_CRITICAL, ENOENT, ++ gf_msg (THIS->name, (RPC_CLNT_CONNECT == event) ? ++ GF_LOG_CRITICAL : GF_LOG_DEBUG, ENOENT, + GD_MSG_PEER_NOT_FOUND, "Could not find peer " +- "%s(%s)", peerctx->peername, uuid_utoa (peerctx->peerid)); ++ "%s(%s)", peerctx->peername, ++ uuid_utoa (peerctx->peerid)); ++ + ret = -1; + goto out; + } +-- +1.7.1 + diff --git a/SOURCES/0273-glusterd-rebalance-trusted-rebalance-volfile.patch b/SOURCES/0273-glusterd-rebalance-trusted-rebalance-volfile.patch new file mode 100644 index 0000000..10badd9 --- /dev/null +++ b/SOURCES/0273-glusterd-rebalance-trusted-rebalance-volfile.patch @@ -0,0 +1,65 @@ +From 6c2db235183b1d1840dc94e9b47e98ebde422e0e Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Mon, 17 Aug 2015 14:18:43 +0530 +Subject: [PATCH 273/279] glusterd/rebalance: trusted rebalance volfile + +Creating the client volfiles with GF_CLIENT_OTHER +overwrites the trusted rebalance volfile and causes rebalance +to fail if auth.allow is set. +Now, we always set the value of trusted-client to GF_CLIENT_TRUSTED +for rebalance volfiles. + +backport: http://review.gluster.org/11819 + +Change-Id: I0c68937213f6d2bfe7221e0fb1210555226009b0 +BUG: 1213893 +Signed-off-by: Nithya Balachandran +Reviewed-on: https://code.engineering.redhat.com/gerrit/55319 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-volgen.c | 16 +++++++++------- + 1 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index 3d04e9f..d784d17 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -4224,16 +4224,19 @@ build_rebalance_volfile (glusterd_volinfo_t *volinfo, char *filepath, + return 0; + } + ++ set_dict = dict_copy (volinfo->dict, NULL); ++ if (!set_dict) ++ return -1; ++ + if (mod_dict) { +- set_dict = dict_copy (volinfo->dict, NULL); +- if (!set_dict) +- return -1; + dict_copy (mod_dict, set_dict); + /* XXX dict_copy swallows errors */ +- } else { +- set_dict = volinfo->dict; + } + ++ /* Rebalance is always a trusted client*/ ++ ret = dict_set_uint32 (set_dict, "trusted-client", GF_CLIENT_TRUSTED); ++ if (ret) ++ return -1; + + ret = volgen_graph_build_clients (&graph, volinfo, set_dict, NULL); + if (volinfo->type == GF_CLUSTER_TYPE_TIER) +@@ -4263,8 +4266,7 @@ build_rebalance_volfile (glusterd_volinfo_t *volinfo, char *filepath, + out: + volgen_graph_free (&graph); + +- if (mod_dict) +- dict_destroy (set_dict); ++ dict_destroy (set_dict); + + + return ret; +-- +1.7.1 + diff --git a/SOURCES/0274-quota-checking-for-absolute-path-in-quota-command.patch b/SOURCES/0274-quota-checking-for-absolute-path-in-quota-command.patch new file mode 100644 index 0000000..b983ba6 --- /dev/null +++ b/SOURCES/0274-quota-checking-for-absolute-path-in-quota-command.patch @@ -0,0 +1,51 @@ +From 1232b4c764a9b0f6d8789359048325ff38bf2e07 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Wed, 22 Jul 2015 15:12:36 +0530 +Subject: [PATCH 274/279] quota : checking for absolute path in quota command + +Currently, if absolute path is not entered in +"gluster volume quota list ", +it just shows the header (Path Hard-limit Soft-limit...) +instead of showing an error message. + +With this patch, it shows an error to enter the absolute path. + +> Change-Id: I2c3d34bfdc7b924d00b11f8649b73a5069cbc2dc +> BUG: 1245558 +> Signed-off-by: Manikandan Selvaganesh +> Reviewed-on: http://review.gluster.org/11738 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Vijaikumar Mallikarjuna +> Reviewed-by: Raghavendra G + +Change-Id: I2c3d34bfdc7b924d00b11f8649b73a5069cbc2dc +BUG: 1065651 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: https://code.engineering.redhat.com/gerrit/55300 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + cli/src/cli-cmd-parser.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 8f3396f..0f7b5be 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -1176,6 +1176,12 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) + + type = GF_QUOTA_OPTION_TYPE_LIST; + ++ if (words[4] && words[4][0] != '/') { ++ cli_err ("Please enter absolute path"); ++ ret = -1; ++ goto out; ++ } ++ + i = 4; + while (i < wordcount) { + snprintf (key, 20, "path%d", i-4); +-- +1.7.1 + diff --git a/SOURCES/0275-quota-volume-reset-shouldn-t-remove-quota-deem-statf.patch b/SOURCES/0275-quota-volume-reset-shouldn-t-remove-quota-deem-statf.patch new file mode 100644 index 0000000..953e942 --- /dev/null +++ b/SOURCES/0275-quota-volume-reset-shouldn-t-remove-quota-deem-statf.patch @@ -0,0 +1,225 @@ +From 6674020a7a1503f2ca1da30a622f950bfcbb34e3 Mon Sep 17 00:00:00 2001 +From: Manikandan Selvaganesh +Date: Wed, 5 Aug 2015 19:23:01 +0530 +Subject: [PATCH 275/279] quota : volume-reset shouldn't remove quota-deem-statfs + +Volume-reset shouldn't remove quota-deem-statfs, unless +explicitly specified, when quota is enabled. + +1) glusterd_op_stage_reset_volume () + 'gluster volume set/reset ' features.quota/ + features.inode-quota' should not be allowed as it is deprecated. + Setting and resetting quota/inode-quota features should be allowed + only through 'gluster volume quota enable/disable'. + +2) glusterd_enable_default_options () + Option 'features.quota-deem-statfs' should not be turned off + with 'gluster volume reset ', since quota features + can be set/reset only with 'gluster volume quota + enable/disable'. + +But, 'gluster volume set features.quota-deem-statfs' +can be turned on/off when quota is enabled. + +> Change-Id: Ib5aa00a4d8c82819c08dfc23e2a86f43ebc436c4 +> BUG: 1250582 +> Signed-off-by: Manikandan Selvaganesh +> Reviewed-on: http://review.gluster.org/11839 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Vijaikumar Mallikarjuna +> Reviewed-by: Atin Mukherjee + +Change-Id: Ib5aa00a4d8c82819c08dfc23e2a86f43ebc436c4 +BUG: 1027723 +Signed-off-by: Manikandan Selvaganesh +Reviewed-on: https://code.engineering.redhat.com/gerrit/55299 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + ...set-should-not-remove-quota-quota-deem-statfs.t | 53 ++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 31 +++++++++++ + xlators/mgmt/glusterd/src/glusterd-utils.c | 22 ++++++++ + xlators/mgmt/glusterd/src/glusterd-volgen.h | 1 + + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 4 +- + 5 files changed, 109 insertions(+), 2 deletions(-) + create mode 100644 tests/bugs/quota/bug-1250582-volume-reset-should-not-remove-quota-quota-deem-statfs.t + +diff --git a/tests/bugs/quota/bug-1250582-volume-reset-should-not-remove-quota-quota-deem-statfs.t b/tests/bugs/quota/bug-1250582-volume-reset-should-not-remove-quota-quota-deem-statfs.t +new file mode 100644 +index 0000000..3b55e73 +--- /dev/null ++++ b/tests/bugs/quota/bug-1250582-volume-reset-should-not-remove-quota-quota-deem-statfs.t +@@ -0,0 +1,53 @@ ++#!/bin/bash ++ ++# This test ensures that 'gluster volume reset' command do not remove ++# features.quota-deem-statfs, features.quota. ++# Also, tests that 'gluster volume set features.quota-deem-statfs' can be ++# turned on/off when quota is enabled. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++TEST glusterd; ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${v0}{1,2}; ++EXPECT 'Created' volinfo_field $V0 'Status'; ++ ++TEST $CLI volume start $V0; ++EXPECT 'Started' volinfo_field $V0 'Status'; ++ ++TEST $CLI volume quota $V0 enable ++EXPECT 'on' volinfo_field $V0 'features.quota' ++EXPECT 'on' volinfo_field $V0 'features.inode-quota' ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume reset $V0 ++EXPECT 'on' volinfo_field $V0 'features.quota' ++EXPECT 'on' volinfo_field $V0 'features.inode-quota' ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume reset $V0 force ++EXPECT 'on' volinfo_field $V0 'features.quota' ++EXPECT 'on' volinfo_field $V0 'features.inode-quota' ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume reset $V0 features.quota-deem-statfs ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume set $V0 features.quota-deem-statfs off ++EXPECT 'off' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume set $V0 features.quota-deem-statfs on ++EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs' ++ ++TEST $CLI volume quota $V0 disable ++EXPECT 'off' volinfo_field $V0 'features.quota' ++EXPECT 'off' volinfo_field $V0 'features.inode-quota' ++EXPECT '' volinfo_field $V0 'features.quota-deem-statfs' ++ ++cleanup; ++ +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index e7ad7f4..4b06482 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -1376,6 +1376,26 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) + } else if (exists > 0) { + if (key_fixed) + key = key_fixed; ++ ++ /* 'gluster volume set/reset ++ * features.quota/features.inode-quota' should ++ * not be allowed as it is deprecated. ++ * Setting and resetting quota/inode-quota features ++ * should be allowed only through 'gluster volume quota ++ * enable/disable'. ++ * But, 'gluster volume set features.quota-deem-statfs' ++ * can be turned on/off when quota is enabled. ++ */ ++ ++ if (strcmp (VKEY_FEATURES_INODE_QUOTA, key) == 0 || ++ strcmp (VKEY_FEATURES_QUOTA, key) == 0) { ++ snprintf (msg, sizeof (msg), "'gluster volume " ++ "reset %s' is deprecated. " ++ "Use 'gluster volume quota " ++ "disable' instead.", key); ++ ret = -1; ++ goto out; ++ } + ALL_VOLUME_OPTION_CHECK (volname, key, ret, + op_errstr, out); + } +@@ -1734,6 +1754,17 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data) + GF_ASSERT (data); + is_force = (int32_t*)data; + ++ /* Keys which has the flag OPT_FLAG_NEVER_RESET ++ * should not be deleted ++ */ ++ ++ if (_gf_true == glusterd_check_voloption_flags (key, ++ OPT_FLAG_NEVER_RESET)) { ++ if (*is_force != 1) ++ *is_force = *is_force | GD_OP_PROTECTED; ++ goto out; ++ } ++ + if (*is_force != 1) { + if (_gf_true == glusterd_check_voloption_flags (key, + OPT_FLAG_FORCE)) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 0101ec5..4982828 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -9527,6 +9527,28 @@ glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option) + } + } + ++ /* Option 'features.quota-deem-statfs' should not be turned off ++ * with 'gluster volume reset ', since quota features ++ * can be reset only with 'gluster volume quota ++ * disable'. ++ */ ++ ++ if (!option || !strcmp ("features.quota-deem-statfs", option)) { ++ if (glusterd_is_volume_quota_enabled(volinfo)) { ++ ret = dict_set_dynstr_with_alloc (volinfo->dict, ++ "features.quota-deem-statfs", "on"); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, errno, ++ GD_MSG_DICT_SET_FAILED, ++ "Failed to set option " ++ "'features.quota-deem-statfs' " ++ "on volume %s", ++ volinfo->volname); ++ goto out; ++ } ++ } ++ } ++ + } + out: + return ret; +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h +index 7453c0d..3128b6b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h +@@ -91,6 +91,7 @@ typedef enum gd_volopt_flags_ { + OPT_FLAG_FORCE = 0x01, // option needs force to be reset + OPT_FLAG_XLATOR_OPT = 0x02, // option enables/disables xlators + OPT_FLAG_CLIENT_OPT = 0x04, // option affects clients ++ OPT_FLAG_NEVER_RESET = 0x08, /* option which should not be reset */ + } gd_volopt_flags_t; + + typedef enum { +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +index b536d18..709ac31 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c +@@ -1383,7 +1383,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .option = "quota", + .value = "off", + .type = NO_DOC, +- .flags = OPT_FLAG_FORCE, ++ .flags = OPT_FLAG_NEVER_RESET, + .op_version = 1 + }, + { .key = VKEY_FEATURES_INODE_QUOTA, +@@ -1391,7 +1391,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { + .option = "inode-quota", + .value = "off", + .type = NO_DOC, +- .flags = OPT_FLAG_FORCE, ++ .flags = OPT_FLAG_NEVER_RESET, + .op_version = 1 + }, + +-- +1.7.1 + diff --git a/SOURCES/0276-libglusterfs-write-error-handling-when-filesystem-ha.patch b/SOURCES/0276-libglusterfs-write-error-handling-when-filesystem-ha.patch new file mode 100644 index 0000000..786e281 --- /dev/null +++ b/SOURCES/0276-libglusterfs-write-error-handling-when-filesystem-ha.patch @@ -0,0 +1,74 @@ +From 7a578ddf23794d8a95000ce950807c88de74dfce Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Wed, 12 Aug 2015 15:00:29 +0530 +Subject: [PATCH 276/279] libglusterfs: write error handling when filesystem have no space left + +This is a backport of: http://review.gluster.org/#/c/11029/ + +When no space left on filesystem and user want to perform any operation +which result to change in /var/lib/glusterd/* files then glusterd is +failing to write on temporary file. + +Fix is to handle error when write failed on temporary files due to no +space left on file system. + +>Change-Id: I79d595776b42580da35e1282b4a3cd7fe3d14afe +>BUG: 1226829 +>Signed-off-by: Gaurav Kumar Garg + +Change-Id: Ifae5d27698025bb3b5cf7235449565575e762451 +BUG: 1226665 +Signed-off-by: Gaurav Kumar Garg +Reviewed-on: https://code.engineering.redhat.com/gerrit/54977 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + libglusterfs/src/store.c | 12 ++++++------ + 1 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c +index 7c8b29d..8442b31 100644 +--- a/libglusterfs/src/store.c ++++ b/libglusterfs/src/store.c +@@ -345,15 +345,15 @@ gf_store_save_value (int fd, char *key, char *value) + + fp = fdopen (dup_fd, "a+"); + if (fp == NULL) { +- gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, +- "fdopen failed."); ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, ++ LG_MSG_FILE_OP_FAILED, "fdopen failed."); + ret = -1; + goto out; + } + + ret = fprintf (fp, "%s=%s\n", key, value); + if (ret < 0) { +- gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, + "Unable to store key: %s, value: %s.", + key, value); + ret = -1; +@@ -361,8 +361,8 @@ gf_store_save_value (int fd, char *key, char *value) + } + + ret = fflush (fp); +- if (feof (fp)) { +- gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, + "fflush failed."); + ret = -1; + goto out; +@@ -373,7 +373,7 @@ out: + if (fp) + fclose (fp); + +- gf_msg_debug ("", 0, "returning: %d", ret); ++ gf_msg_debug (THIS->name, 0, "returning: %d", ret); + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0277-xml-output-Fix-non-uniform-opErrstr-xml-output.patch b/SOURCES/0277-xml-output-Fix-non-uniform-opErrstr-xml-output.patch new file mode 100644 index 0000000..23e8370 --- /dev/null +++ b/SOURCES/0277-xml-output-Fix-non-uniform-opErrstr-xml-output.patch @@ -0,0 +1,47 @@ +From f7cd20ace4dc09f02de5720157684ed85cd94ee2 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 5 Aug 2015 16:36:06 +0530 +Subject: [PATCH 277/279] xml output: Fix non-uniform opErrstr xml output + + Backport of http://review.gluster.org/#/c/11835/ + +Display in case of no operrstr for +all xml output of gluster commands. + +Change-Id: Ie16f749f90b4642357c562012408c434cd38661f +BUG: 1245897 +Signed-off-by: Avra Sengupta +Reviewed-on: http://review.gluster.org/11920 +Tested-by: NetBSD Build System +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/55411 +Tested-by: Rajesh Joseph +--- + cli/src/cli-xml-output.c | 11 +++++++++-- + 1 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c +index d41aebc..b558a9a 100644 +--- a/cli/src/cli-xml-output.c ++++ b/cli/src/cli-xml-output.c +@@ -123,8 +123,15 @@ cli_xml_output_common (xmlTextWriterPtr writer, int op_ret, int op_errno, + "%d", op_errno); + XML_RET_CHECK_AND_GOTO (ret, out); + +- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"opErrstr", +- "%s", op_errstr); ++ if (op_errstr) ++ ret = xmlTextWriterWriteFormatElement (writer, ++ (xmlChar *)"opErrstr", ++ "%s", op_errstr); ++ else ++ ret = xmlTextWriterWriteFormatElement (writer, ++ (xmlChar *)"opErrstr", ++ "%s", ""); ++ + XML_RET_CHECK_AND_GOTO (ret, out); + + out: +-- +1.7.1 + diff --git a/SOURCES/0278-Set-nfs.disable-to-on-when-global-NFS-Ganesha-key-is.patch b/SOURCES/0278-Set-nfs.disable-to-on-when-global-NFS-Ganesha-key-is.patch new file mode 100644 index 0000000..9e77fc6 --- /dev/null +++ b/SOURCES/0278-Set-nfs.disable-to-on-when-global-NFS-Ganesha-key-is.patch @@ -0,0 +1,71 @@ +From efd88ab25c2a9ebb16da2200c5335e7b7c24f83e Mon Sep 17 00:00:00 2001 +From: Meghana M +Date: Mon, 3 Aug 2015 03:03:07 +0530 +Subject: [PATCH 278/279] Set nfs.disable to "on" when global NFS-Ganesha key is enabled + +"nfs.disable" gets set to "on" for all the existing volumes, +when the command "gluster nfs-ganesha enable" is executed. +When a new volume is created,it gets exported via Gluster-NFS on +the nodes outside the NFS-Ganesha. To fix this, +the "nfs.disable" key is set to "on" before starting the volume, +whenever the global option is set to "enable". + +This patch is a backport of the fix upstream, +http://review.gluster.org/#/c/11871/ + +Change-Id: I5581d64d785ad3eb526c575dbafcf9044c76e593 +BUG: 1226817 +Signed-off-by: Meghana Madhusudhan +Reviewed-on: https://code.engineering.redhat.com/gerrit/55401 +Reviewed-by: Jiffin Thottan +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 24 +++++++++++++++++++++++ + 1 files changed, 24 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index b52f832..d2716f8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -2377,6 +2377,8 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + char *brick_mount_dir = NULL; + char key[PATH_MAX] = ""; + char *volname = NULL; ++ char *str = NULL; ++ gf_boolean_t option = _gf_false; + int flags = 0; + glusterd_volinfo_t *volinfo = NULL; + glusterd_brickinfo_t *brickinfo = NULL; +@@ -2430,6 +2432,28 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) + } + } + ++ ret = dict_get_str (conf->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, &str); ++ if (ret == -1) { ++ gf_msg (this->name, GF_LOG_INFO, 0, ++ GD_MSG_DICT_GET_FAILED, "Global dict not present."); ++ ret = 0; ++ ++ } else { ++ ret = gf_string2boolean (str, &option); ++ /* Check if the feature is enabled and set nfs-disable to true */ ++ if (option) { ++ gf_msg_debug (this->name, 0, "NFS-Ganesha is enabled"); ++ /* Gluster-nfs should not start when NFS-Ganesha is enabled*/ ++ ret = dict_set_str (volinfo->dict, "nfs.disable", "on"); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SET_FAILED, "Failed to set nfs.disable for" ++ "volume %s", volname); ++ goto out; ++ } ++ } ++ } ++ + ret = glusterd_start_volume (volinfo, flags, _gf_true); + if (ret) + goto out; +-- +1.7.1 + diff --git a/SOURCES/0279-logging-Stop-using-global-xlator-for-log_buf-allocat.patch b/SOURCES/0279-logging-Stop-using-global-xlator-for-log_buf-allocat.patch new file mode 100644 index 0000000..2ae21ad --- /dev/null +++ b/SOURCES/0279-logging-Stop-using-global-xlator-for-log_buf-allocat.patch @@ -0,0 +1,63 @@ +From fdda3f97ae45df1dbad87f11cd2b96b050c5fe2b Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Thu, 30 Jul 2015 17:03:50 +0530 +Subject: [PATCH 279/279] logging: Stop using global xlator for log_buf allocations + +This reverts commit 765849ee00f6661c9059122ff2346b03b224745f. + +With http://review.gluster.org/#/c/10417/, struct mem_accnt +is no longer embedded in a xlator_t object, but instead is +allocated separately. Hence this workaround provided to avoid +crashes in logging infrastructure is no longer needed + +This is a backport of the below fix - + http://review.gluster.org/11811 + +BUG: 1241761 +Change-Id: Ibecf693b912c9d37029f9e1f9da684bf8b292c5e +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/11811 +Reviewed-by: N Balachandran +Reviewed-by: Kaleb KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/55415 +Reviewed-by: Nithya Balachandran +Reviewed-by: Kaleb Keithley +Tested-by: Kaleb Keithley +--- + libglusterfs/src/logging.c | 13 ------------- + 1 files changed, 0 insertions(+), 13 deletions(-) + +diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c +index c81c5b1..8bbaa3e 100644 +--- a/libglusterfs/src/logging.c ++++ b/libglusterfs/src/logging.c +@@ -297,18 +297,6 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file, + int errnum, uint64_t msgid, char **appmsgstr, int graph_id) + { + int ret = -1; +- xlator_t *old_THIS; +- extern xlator_t global_xlator; +- +- /* +- * The current translator will be put in the block header for any +- * memory block we allocate here. Unfortunately, these objects might +- * outlive the current translator, and if we then try to dereference +- * that pointer we go BOOM. Since this is really a global structure, +- * use the global translator. +- */ +- old_THIS = THIS; +- THIS = &global_xlator; + + if (!buf || !domain || !file || !function || !appmsgstr || !*appmsgstr) + goto out; +@@ -339,7 +327,6 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file, + + ret = 0; + out: +- THIS = old_THIS; + return ret; + } + +-- +1.7.1 + diff --git a/SOURCES/0280-quota-marker-fix-inode-quota-with-rename.patch b/SOURCES/0280-quota-marker-fix-inode-quota-with-rename.patch new file mode 100644 index 0000000..0f714a7 --- /dev/null +++ b/SOURCES/0280-quota-marker-fix-inode-quota-with-rename.patch @@ -0,0 +1,1601 @@ +From 411aa49510fa41ba982e03544d367430cbfc7513 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Sun, 12 Jul 2015 08:49:49 +0530 +Subject: [PATCH 280/304] quota/marker: fix inode quota with rename + +This is a backport of http://review.gluster.org/11578 + +There are three problems with marker-rename which +is fixed in this patch + +Problem 1) +1) mq_reduce_parent_size is not handling inode-quota contribution +2) When dest files exists and IO is happening + Now renaming will overwrite existing file + mq_reduce_parent_size called on dest file + with saved contribution, this can be + a problem is IO is still happening + contribution might have changed + +Problem 2) +There is a small race between rename and in-progress write +Consider below scenario +1) rename FOP invoked on file 'x' +2) write is still in progress for file 'x' +3) rename takes a lock on old-parent +4) write-update txn blocked on old-parent to acquire lock +5) in rename_cbk, contri xattrs are removed and contribution is deleted and + lock is released +6) now write-update txn gets the lock and updates the wrong parent + as it was holding lock on old parent + so validate parent once the lock is acquired + +Problem 3) +when a rename operation is performed, a lock is +held on old parent. This lock is release before +unwinding the rename operation. +This can be a problem if there are in-progress +writes happening during rename, where update txn +can take a lock and update the old parent +as inode table is not updated with new parent + +> Change-Id: Ic3316097c001c33533f98592e8fcf234b1ee2aa2 +> BUG: 1240991 +> Signed-off-by: vmallika +> Reviewed-on: http://review.gluster.org/11578 +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G + +Change-Id: I4753f2380fc9ef03a1ba612ec4644921478eae0c +BUG: 1240918 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/55711 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + tests/bugs/quota/bug-1235182.t | 17 +- + tests/bugs/quota/bug-1240991.t | 43 ++ + xlators/features/marker/src/marker-quota-helper.c | 5 + + xlators/features/marker/src/marker-quota.c | 549 ++++++++++----------- + xlators/features/marker/src/marker-quota.h | 5 +- + xlators/features/marker/src/marker.c | 445 ++++++++--------- + xlators/features/marker/src/marker.h | 4 +- + 7 files changed, 536 insertions(+), 532 deletions(-) + create mode 100644 tests/bugs/quota/bug-1240991.t + +diff --git a/tests/bugs/quota/bug-1235182.t b/tests/bugs/quota/bug-1235182.t +index e28b557..2f963e6 100644 +--- a/tests/bugs/quota/bug-1235182.t ++++ b/tests/bugs/quota/bug-1235182.t +@@ -28,13 +28,22 @@ TEST $CLI volume quota $V0 limit-usage / 1GB + TEST $CLI volume quota $V0 hard-timeout 0 + TEST $CLI volume quota $V0 soft-timeout 0 + +-$QDD $M0/f1 256 400& ++TEST mkdir $M0/1 ++$QDD $M0/1/f1 256 400& + PID=$! +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $M0/f1 +-TESTS_EXPECTED_IN_LOOP=50 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $M0/1/f1 ++TESTS_EXPECTED_IN_LOOP=150 + for i in {1..50}; do + ii=`expr $i + 1`; +- TEST_IN_LOOP mv $M0/f$i $M0/f$ii; ++ touch $M0/$i/f$ii ++ echo Hello > $M0/$i/f$ii ++ ++ #rename within same dir ++ TEST_IN_LOOP mv -f $M0/$i/f$i $M0/$i/f$ii; ++ ++ #rename to different dir ++ TEST_IN_LOOP mkdir $M0/$ii ++ TEST_IN_LOOP mv -f $M0/$i/f$ii $M0/$ii/f$ii; + done + + echo "Wait for process with pid $PID to complete" +diff --git a/tests/bugs/quota/bug-1240991.t b/tests/bugs/quota/bug-1240991.t +new file mode 100644 +index 0000000..2a1a6d1 +--- /dev/null ++++ b/tests/bugs/quota/bug-1240991.t +@@ -0,0 +1,43 @@ ++#!/bin/bash ++ ++# This regression test tries to ensure renaming a directory with content, and ++# no limit set, is accounted properly, when moved into a directory with quota ++# limit set. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 $H0:$B0/${V0} ++TEST $CLI volume start $V0; ++ ++TEST $CLI volume quota $V0 enable; ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST $CLI volume quota $V0 hard-timeout 0 ++TEST $CLI volume quota $V0 soft-timeout 0 ++ ++TEST mkdir -p $M0/dir/dir1 ++TEST $CLI volume quota $V0 limit-objects /dir 20 ++ ++TEST mkdir $M0/dir/dir1/d{1..5} ++TEST touch $M0/dir/dir1/f{1..5} ++TEST mv $M0/dir/dir1 $M0/dir/dir2 ++ ++#Number of files under /dir is 5 ++EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "5" quota_object_list_field "/dir" 4 ++ ++#Number of directories under /dir is 7 ++EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "7" quota_object_list_field "/dir" 5 ++ ++TEST $CLI volume stop $V0 ++TEST $CLI volume delete $V0 ++EXPECT "1" get_aux ++ ++cleanup; +diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c +index a103bb9..df76f12 100644 +--- a/xlators/features/marker/src/marker-quota-helper.c ++++ b/xlators/features/marker/src/marker-quota-helper.c +@@ -174,6 +174,9 @@ mq_get_contribution_node (inode_t *inode, quota_inode_ctx_t *ctx) + + LOCK (&ctx->lock); + { ++ if (list_empty (&ctx->contribution_head)) ++ goto unlock; ++ + list_for_each_entry (temp, &ctx->contribution_head, + contri_list) { + if (gf_uuid_compare (temp->gfid, inode->gfid) == 0) { +@@ -183,7 +186,9 @@ mq_get_contribution_node (inode_t *inode, quota_inode_ctx_t *ctx) + } + } + } ++unlock: + UNLOCK (&ctx->lock); ++ + out: + return contri; + } +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index 6ccd974..bb9dfa8 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2592,15 +2592,11 @@ out: + + int32_t + mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, +- inode_contribution_t *contri, quota_meta_t *delta, +- gf_boolean_t remove_xattr) ++ inode_contribution_t *contri, quota_meta_t *delta) + { + int32_t ret = -1; + char contri_key[CONTRI_KEY_MAX] = {0, }; + +- if (remove_xattr == _gf_false) +- goto done; +- + GET_CONTRI_KEY (contri_key, contri->gfid, ret); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "get contri_key " +@@ -2627,7 +2623,6 @@ mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + } + } + +-done: + LOCK (&contri->lock); + { + contri->contribution += delta->size; +@@ -2781,8 +2776,8 @@ mq_synctask_cleanup (int ret, call_frame_t *frame, void *opaque) + } + + int +-mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc, +- int64_t contri) ++mq_synctask1 (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, ++ loc_t *loc, quota_meta_t *contri) + { + int32_t ret = -1; + quota_synctask_t *args = NULL; +@@ -2798,7 +2793,14 @@ mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc, + + args->this = this; + loc_copy (&args->loc, loc); +- args->contri = contri; ++ ++ if (contri) { ++ args->contri = *contri; ++ } else { ++ args->contri.size = -1; ++ args->contri.file_count = -1; ++ args->contri.dir_count = -1; ++ } + + if (spawn) { + ret = synctask_new1 (this->ctx->env, 1024 * 16, task, +@@ -2817,6 +2819,12 @@ out: + return ret; + } + ++int ++mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc) ++{ ++ return mq_synctask1 (this, task, spawn, loc, NULL); ++} ++ + int32_t + mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc, + quota_inode_ctx_t **ctx) +@@ -2861,136 +2869,6 @@ out: + } + + int +-mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, +- inode_contribution_t *contri) +-{ +- int32_t ret = -1; +- loc_t child_loc = {0,}; +- loc_t parent_loc = {0,}; +- gf_boolean_t locked = _gf_false; +- gf_boolean_t dirty = _gf_false; +- gf_boolean_t status = _gf_false; +- quota_meta_t delta = {0, }; +- +- GF_VALIDATE_OR_GOTO ("marker", contri, out); +- GF_REF_GET (contri); +- +- GF_VALIDATE_OR_GOTO ("marker", loc, out); +- GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); +- GF_VALIDATE_OR_GOTO ("marker", ctx, out); +- +- ret = mq_loc_copy (&child_loc, loc); +- if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "loc copy failed"); +- goto out; +- } +- +- while (!__is_root_gfid (child_loc.gfid)) { +- /* To improve performance, abort current transaction +- * if one is already in progress for same inode +- */ +- if (status == _gf_true) { +- /* status will alreday set before txn start, +- * so it should not be set in first +- * loop iteration +- */ +- ret = mq_test_and_set_ctx_updation_status (ctx, +- &status); +- if (ret < 0 || status == _gf_true) +- goto out; +- } +- +- ret = mq_inode_loc_fill (NULL, child_loc.parent, &parent_loc); +- if (ret < 0) { +- gf_log (this->name, GF_LOG_ERROR, "loc fill failed"); +- goto out; +- } +- +- ret = mq_lock (this, &parent_loc, F_WRLCK); +- if (ret < 0) +- goto out; +- locked = _gf_true; +- +- mq_set_ctx_updation_status (ctx, _gf_false); +- status = _gf_true; +- +- ret = mq_get_delta (this, &child_loc, &delta, ctx, contri); +- if (ret < 0) +- goto out; +- +- if (quota_meta_is_null (&delta)) +- goto out; +- +- ret = mq_mark_dirty (this, &parent_loc, 1); +- if (ret < 0) +- goto out; +- dirty = _gf_true; +- +- ret = mq_update_contri (this, &child_loc, contri, &delta); +- if (ret < 0) +- goto out; +- +- ret = mq_update_size (this, &parent_loc, &delta); +- if (ret < 0) { +- gf_log (this->name, GF_LOG_DEBUG, "rollback " +- "contri updation"); +- mq_sub_meta (&delta, NULL); +- mq_update_contri (this, &child_loc, contri, &delta); +- goto out; +- } +- +- ret = mq_mark_dirty (this, &parent_loc, 0); +- dirty = _gf_false; +- +- ret = mq_lock (this, &parent_loc, F_UNLCK); +- locked = _gf_false; +- +- if (__is_root_gfid (parent_loc.gfid)) +- break; +- +- /* Repeate above steps upwards till the root */ +- loc_wipe (&child_loc); +- ret = mq_loc_copy (&child_loc, &parent_loc); +- if (ret < 0) +- goto out; +- loc_wipe (&parent_loc); +- +- ret = mq_inode_ctx_get (child_loc.inode, this, &ctx); +- if (ret < 0) +- goto out; +- +- if (list_empty (&ctx->contribution_head)) { +- gf_log (this->name, GF_LOG_ERROR, +- "contribution node list is empty (%s)", +- uuid_utoa(child_loc.inode->gfid)); +- ret = -1; +- goto out; +- } +- +- GF_REF_PUT (contri); +- contri = mq_get_contribution_node (child_loc.parent, ctx); +- GF_ASSERT (contri != NULL); +- } +- +-out: +- if (ret >= 0 && dirty) +- ret = mq_mark_dirty (this, &parent_loc, 0); +- +- if (locked) +- ret = mq_lock (this, &parent_loc, F_UNLCK); +- +- if (ctx && status == _gf_false) +- mq_set_ctx_updation_status (ctx, _gf_false); +- +- loc_wipe (&child_loc); +- loc_wipe (&parent_loc); +- if (contri) +- GF_REF_PUT (contri); +- +- return 0; +-} +- +-int + mq_create_xattrs_task (void *opaque) + { + int32_t ret = -1; +@@ -3067,7 +2945,7 @@ _mq_create_xattrs_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn) + if (ret < 0 || status == _gf_true) + goto out; + +- ret = mq_synctask (this, mq_create_xattrs_task, spawn, &loc, 0); ++ ret = mq_synctask (this, mq_create_xattrs_task, spawn, &loc); + out: + if (ret < 0 && status == _gf_false) + mq_set_ctx_create_status (ctx, _gf_false); +@@ -3109,13 +2987,13 @@ mq_reduce_parent_size_task (void *opaque) + quota_inode_ctx_t *ctx = NULL; + inode_contribution_t *contribution = NULL; + quota_meta_t delta = {0, }; ++ quota_meta_t contri = {0, }; + loc_t parent_loc = {0,}; + gf_boolean_t locked = _gf_false; + gf_boolean_t dirty = _gf_false; + quota_synctask_t *args = NULL; + xlator_t *this = NULL; + loc_t *loc = NULL; +- int64_t contri = 0; + gf_boolean_t remove_xattr = _gf_true; + + GF_ASSERT (opaque); +@@ -3133,26 +3011,6 @@ mq_reduce_parent_size_task (void *opaque) + goto out; + } + +- contribution = mq_get_contribution_node (loc->parent, ctx); +- if (contribution == NULL) { +- ret = -1; +- gf_log_callingfn (this->name, GF_LOG_WARNING, +- "contribution for the node %s is NULL", +- loc->path); +- goto out; +- } +- +- if (contri >= 0) { +- /* contri paramater is supplied only for rename operation. +- * remove xattr is alreday performed, we need to skip +- * removexattr for rename operation +- */ +- remove_xattr = _gf_false; +- delta.size = contri; +- delta.file_count = 1; +- delta.dir_count = 0; +- } +- + ret = mq_inode_loc_fill (NULL, loc->parent, &parent_loc); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "loc fill failed"); +@@ -3164,7 +3022,26 @@ mq_reduce_parent_size_task (void *opaque) + goto out; + locked = _gf_true; + +- if (contri < 0) { ++ if (contri.size >= 0) { ++ /* contri paramater is supplied only for rename operation. ++ * remove xattr is alreday performed, we need to skip ++ * removexattr for rename operation ++ */ ++ remove_xattr = _gf_false; ++ delta.size = contri.size; ++ delta.file_count = contri.file_count; ++ delta.dir_count = contri.dir_count; ++ } else { ++ remove_xattr = _gf_true; ++ contribution = mq_get_contribution_node (loc->parent, ctx); ++ if (contribution == NULL) { ++ ret = -1; ++ gf_log (this->name, GF_LOG_DEBUG, ++ "contribution for the node %s is NULL", ++ loc->path); ++ goto out; ++ } ++ + LOCK (&contribution->lock); + { + delta.size = contribution->contribution; +@@ -3174,26 +3051,6 @@ mq_reduce_parent_size_task (void *opaque) + UNLOCK (&contribution->lock); + } + +- /* TODO: Handle handlinks with better approach +- Iterating dentry_list without a lock is not a good idea +- if (loc->inode->ia_type != IA_IFDIR) { +- list_for_each_entry (dentry, &inode->dentry_list, inode_list) { +- if (loc->parent == dentry->parent) { +- * If the file has another link within the same +- * directory, we should not be reducing the size +- * of parent +- * +- delta = 0; +- idelta = 0; +- break; +- } +- } +- } +- */ +- +- if (quota_meta_is_null (&delta)) +- goto out; +- + ret = mq_mark_dirty (this, &parent_loc, 1); + if (ret < 0) + goto out; +@@ -3201,9 +3058,13 @@ mq_reduce_parent_size_task (void *opaque) + + mq_sub_meta (&delta, NULL); + +- ret = mq_remove_contri (this, loc, ctx, contribution, &delta, +- remove_xattr); +- if (ret < 0) ++ if (remove_xattr) { ++ ret = mq_remove_contri (this, loc, ctx, contribution, &delta); ++ if (ret < 0) ++ goto out; ++ } ++ ++ if (quota_meta_is_null (&delta)) + goto out; + + ret = mq_update_size (this, &parent_loc, &delta); +@@ -3229,7 +3090,8 @@ out: + } + + int32_t +-mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, int64_t contri) ++mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, ++ quota_meta_t *contri) + { + int32_t ret = -1; + loc_t loc = {0, }; +@@ -3252,8 +3114,8 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, int64_t contri) + goto out; + } + +- ret = mq_synctask (this, mq_reduce_parent_size_task, _gf_true, &loc, +- contri); ++ ret = mq_synctask1 (this, mq_reduce_parent_size_task, _gf_true, &loc, ++ contri); + out: + loc_wipe (&loc); + return ret; +@@ -3262,74 +3124,204 @@ out: + int + mq_initiate_quota_task (void *opaque) + { +- int32_t ret = -1; +- quota_inode_ctx_t *ctx = NULL; +- inode_contribution_t *contribution = NULL; +- quota_synctask_t *args = NULL; +- xlator_t *this = NULL; +- loc_t *loc = NULL; +- +- GF_ASSERT (opaque); ++ int32_t ret = -1; ++ loc_t child_loc = {0,}; ++ loc_t parent_loc = {0,}; ++ gf_boolean_t locked = _gf_false; ++ gf_boolean_t dirty = _gf_false; ++ gf_boolean_t status = _gf_false; ++ quota_meta_t delta = {0, }; ++ quota_synctask_t *args = NULL; ++ xlator_t *this = NULL; ++ loc_t *loc = NULL; ++ inode_contribution_t *contri = NULL; ++ quota_inode_ctx_t *ctx = NULL; ++ inode_t *tmp_parent = NULL; ++ ++ GF_VALIDATE_OR_GOTO ("marker", opaque, out); + + args = (quota_synctask_t *) opaque; + loc = &args->loc; + this = args->this; ++ ++ GF_VALIDATE_OR_GOTO ("marker", this, out); + THIS = this; + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret == -1) { +- gf_log (this->name, GF_LOG_WARNING, +- "inode ctx get failed, aborting quota txn"); ++ GF_VALIDATE_OR_GOTO (this->name, loc, out); ++ GF_VALIDATE_OR_GOTO (this->name, loc->inode, out); ++ ++ ret = mq_loc_copy (&child_loc, loc); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_ERROR, "loc copy failed"); + goto out; + } + +- /* Create the contribution node if its absent. Is it right to +- assume that if the contribution node is not there, then +- create one and proceed instead of returning? +- Reason for this assumption is for hard links. Suppose +- hard link for a file f1 present in a directory d1 is +- created in the directory d2 (as f2). Now, since d2's +- contribution is not there in f1's inode ctx, d2's +- contribution xattr wont be created and will create problems +- for quota operations. +- */ +- contribution = mq_get_contribution_node (loc->parent, ctx); +- if (!contribution) { +- if (!loc_is_root(loc)) +- gf_log_callingfn (this->name, GF_LOG_TRACE, +- "contribution node for the " +- "path (%s) with parent (%s) " +- "not found", loc->path, +- loc->parent ? +- uuid_utoa (loc->parent->gfid) : +- NULL); ++ while (!__is_root_gfid (child_loc.gfid)) { + +- contribution = mq_add_new_contribution_node (this, ctx, loc); +- if (!contribution) { +- if (!loc_is_root(loc)) +- gf_log_callingfn (this->name, GF_LOG_WARNING, +- "could not allocate " +- " contribution node for (%s) " +- "parent: (%s)", loc->path, +- loc->parent ? +- uuid_utoa (loc->parent->gfid) : +- NULL); +- ret = -1; ++ ret = mq_inode_ctx_get (child_loc.inode, this, &ctx); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_WARNING, ++ "inode ctx get failed for %s, " ++ "aborting update txn", child_loc.path); + goto out; + } +- } + +- mq_start_quota_txn_v2 (this, loc, ctx, contribution); ++ /* To improve performance, abort current transaction ++ * if one is already in progress for same inode ++ */ ++ if (status == _gf_true) { ++ /* status will alreday set before txn start, ++ * so it should not be set in first ++ * loop iteration ++ */ ++ ret = mq_test_and_set_ctx_updation_status (ctx, ++ &status); ++ if (ret < 0 || status == _gf_true) ++ goto out; ++ } ++ ++ ret = mq_inode_loc_fill (NULL, child_loc.parent, &parent_loc); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_ERROR, "loc fill failed"); ++ goto out; ++ } ++ ++ ret = mq_lock (this, &parent_loc, F_WRLCK); ++ if (ret < 0) ++ goto out; ++ locked = _gf_true; ++ ++ mq_set_ctx_updation_status (ctx, _gf_false); ++ status = _gf_true; ++ ++ /* Contribution node can be NULL in below scenarios and ++ create if needed: ++ ++ Scenario 1) ++ In this case create a new contribution node ++ Suppose hard link for a file f1 present in a directory d1 is ++ created in the directory d2 (as f2). Now, since d2's ++ contribution is not there in f1's inode ctx, d2's ++ contribution xattr wont be created and will create problems ++ for quota operations. ++ ++ Don't create contribution if parent has been changed after ++ taking a lock, this can happen when rename is performed ++ and writes is still in-progress for the same file ++ ++ Scenario 2) ++ When a rename operation is performed, contribution node ++ for olp path will be removed. ++ ++ Create contribution node only if oldparent is same as ++ newparent. ++ Consider below example ++ 1) rename FOP invoked on file 'x' ++ 2) write is still in progress for file 'x' ++ 3) rename takes a lock on old-parent ++ 4) write-update txn blocked on old-parent to acquire lock ++ 5) in rename_cbk, contri xattrs are removed and contribution ++ is deleted and lock is released ++ 6) now write-update txn gets the lock and updates the ++ wrong parent as it was holding lock on old parent ++ so validate parent once the lock is acquired ++ ++ For more information on thsi problem, please see ++ doc for marker_rename in file marker.c ++ */ ++ contri = mq_get_contribution_node (child_loc.parent, ctx); ++ if (contri == NULL) { ++ tmp_parent = inode_parent (child_loc.inode, 0, NULL); ++ if (tmp_parent == NULL) { ++ ret = -1; ++ goto out; ++ } ++ if (gf_uuid_compare(tmp_parent->gfid, ++ parent_loc.gfid)) { ++ /* abort txn if parent has changed */ ++ ret = 0; ++ goto out; ++ } ++ ++ inode_unref (tmp_parent); ++ tmp_parent = NULL; ++ ++ contri = mq_add_new_contribution_node (this, ctx, ++ &child_loc); ++ if (contri == NULL) { ++ gf_log (this->name, GF_LOG_ERROR, "Failed to " ++ "create contribution node for %s, " ++ "abort update txn", child_loc.path); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ ret = mq_get_delta (this, &child_loc, &delta, ctx, contri); ++ if (ret < 0) ++ goto out; ++ ++ if (quota_meta_is_null (&delta)) ++ goto out; ++ ++ ret = mq_mark_dirty (this, &parent_loc, 1); ++ if (ret < 0) ++ goto out; ++ dirty = _gf_true; ++ ++ ret = mq_update_contri (this, &child_loc, contri, &delta); ++ if (ret < 0) ++ goto out; ++ ++ ret = mq_update_size (this, &parent_loc, &delta); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_DEBUG, "rollback " ++ "contri updation"); ++ mq_sub_meta (&delta, NULL); ++ mq_update_contri (this, &child_loc, contri, &delta); ++ goto out; ++ } ++ ++ ret = mq_mark_dirty (this, &parent_loc, 0); ++ dirty = _gf_false; ++ ++ ret = mq_lock (this, &parent_loc, F_UNLCK); ++ locked = _gf_false; ++ ++ if (__is_root_gfid (parent_loc.gfid)) ++ break; ++ ++ /* Repeate above steps upwards till the root */ ++ loc_wipe (&child_loc); ++ ret = mq_loc_copy (&child_loc, &parent_loc); ++ if (ret < 0) ++ goto out; ++ ++ loc_wipe (&parent_loc); ++ GF_REF_PUT (contri); ++ contri = NULL; ++ } + +- ret = 0; + out: +- if (contribution) +- GF_REF_PUT (contribution); ++ if (ret >= 0 && dirty) ++ ret = mq_mark_dirty (this, &parent_loc, 0); + +- if (ctx && ret < 0) ++ if (locked) ++ ret = mq_lock (this, &parent_loc, F_UNLCK); ++ ++ if (ctx && status == _gf_false) + mq_set_ctx_updation_status (ctx, _gf_false); + +- return ret; ++ loc_wipe (&child_loc); ++ loc_wipe (&parent_loc); ++ ++ if (tmp_parent) ++ inode_unref (tmp_parent); ++ ++ if (contri) ++ GF_REF_PUT (contri); ++ ++ return 0; + } + + int +@@ -3359,7 +3351,7 @@ _mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn) + if (ret < 0 || status == _gf_true) + goto out; + +- ret = mq_synctask (this, mq_initiate_quota_task, spawn, &loc, 0); ++ ret = mq_synctask (this, mq_initiate_quota_task, spawn, &loc); + + out: + if (ret < 0 && status == _gf_false) +@@ -3556,14 +3548,14 @@ mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc) + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + +- ret = mq_synctask (this, mq_update_dirty_inode_task, _gf_true, +- loc, 0); ++ ret = mq_synctask (this, mq_update_dirty_inode_task, _gf_true, loc); + out: + return ret; + } + + int32_t +-mq_inspect_directory_xattr (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, ++mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx, ++ inode_contribution_t *contribution, loc_t *loc, + dict_t *dict, struct iatt buf) + { + int32_t ret = 0; +@@ -3572,19 +3564,6 @@ mq_inspect_directory_xattr (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; +- inode_contribution_t *contribution = NULL; +- +- if (!loc_is_root(loc)) { +- contribution = mq_add_new_contribution_node (this, ctx, loc); +- if (contribution == NULL) { +- if (!gf_uuid_is_null (loc->inode->gfid)) +- gf_log (this->name, GF_LOG_DEBUG, +- "cannot add a new contribution node " +- "(%s)", uuid_utoa (loc->inode->gfid)); +- ret = -1; +- goto out; +- } +- } + + ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY, &dirty); + if (ret < 0) { +@@ -3647,14 +3626,12 @@ create_xattr: + ret = mq_create_xattrs_txn (this, loc); + + out: +- if (contribution) +- GF_REF_PUT (contribution); +- + return ret; + } + + int32_t +-mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, ++mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, ++ inode_contribution_t *contribution, loc_t *loc, + dict_t *dict, struct iatt buf) + { + int32_t ret = -1; +@@ -3662,15 +3639,6 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; +- inode_contribution_t *contribution = NULL; +- +- contribution = mq_add_new_contribution_node (this, ctx, loc); +- if (contribution == NULL) { +- gf_log_callingfn (this->name, GF_LOG_DEBUG, "cannot allocate " +- "contribution node (path:%s)", loc->path); +- ret = -1; +- goto out; +- } + + LOCK (&ctx->lock); + { +@@ -3708,9 +3676,6 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc, + /* TODO: revist this code when fixing hardlinks */ + + out: +- if (contribution) +- GF_REF_PUT (contribution); +- + return ret; + } + +@@ -3718,22 +3683,48 @@ int32_t + mq_xattr_state (xlator_t *this, loc_t *origin_loc, dict_t *dict, + struct iatt buf) + { +- int32_t ret = -1; +- quota_inode_ctx_t *ctx = NULL; +- loc_t loc = {0, }; ++ int32_t ret = -1; ++ quota_inode_ctx_t *ctx = NULL; ++ loc_t loc = {0, }; ++ inode_contribution_t *contribution = NULL; ++ ++ if (((buf.ia_type == IA_IFREG) && !dht_is_linkfile (&buf, dict)) ++ || (buf.ia_type == IA_IFLNK) || (buf.ia_type == IA_IFDIR)) { ++ /* do healing only for these type of files */ ++ } else { ++ ret = 0; ++ goto out; ++ } + + ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx); + if (ret < 0) + goto out; + +- if (((buf.ia_type == IA_IFREG) && !dht_is_linkfile (&buf, dict)) +- || (buf.ia_type == IA_IFLNK)) { +- mq_inspect_file_xattr (this, ctx, &loc, dict, buf); +- } else if (buf.ia_type == IA_IFDIR) +- mq_inspect_directory_xattr (this, &loc, ctx, dict, buf); ++ if (!loc_is_root(&loc)) { ++ contribution = mq_add_new_contribution_node (this, ctx, &loc); ++ if (contribution == NULL) { ++ if (!gf_uuid_is_null (loc.inode->gfid)) ++ gf_log (this->name, GF_LOG_WARNING, ++ "cannot add a new contribution node " ++ "(%s)", uuid_utoa (loc.gfid)); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ if (buf.ia_type == IA_IFDIR) ++ mq_inspect_directory_xattr (this, ctx, contribution, &loc, dict, ++ buf); ++ else ++ mq_inspect_file_xattr (this, ctx, contribution, &loc, dict, ++ buf); + + out: + loc_wipe (&loc); ++ ++ if (contribution) ++ GF_REF_PUT (contribution); ++ + return ret; + } + +diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h +index 89ac559..65cb0b2 100644 +--- a/xlators/features/marker/src/marker-quota.h ++++ b/xlators/features/marker/src/marker-quota.h +@@ -18,6 +18,7 @@ + #include "xlator.h" + #include "marker-mem-types.h" + #include "refcount.h" ++#include "quota-common-utils.h" + + #define QUOTA_XATTR_PREFIX "trusted.glusterfs" + #define QUOTA_DIRTY_KEY "trusted.glusterfs.quota.dirty" +@@ -98,7 +99,7 @@ typedef struct quota_inode_ctx quota_inode_ctx_t; + struct quota_synctask { + xlator_t *this; + loc_t loc; +- int64_t contri; ++ quota_meta_t contri; + gf_boolean_t is_static; + }; + typedef struct quota_synctask quota_synctask_t; +@@ -146,7 +147,7 @@ int32_t + mq_reduce_parent_size (xlator_t *, loc_t *, int64_t); + + int32_t +-mq_reduce_parent_size_txn (xlator_t *, loc_t *, int64_t); ++mq_reduce_parent_size_txn (xlator_t *, loc_t *, quota_meta_t *); + + int32_t + mq_rename_update_newpath (xlator_t *, loc_t *); +diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c +index ba599da..6265028 100644 +--- a/xlators/features/marker/src/marker.c ++++ b/xlators/features/marker/src/marker.c +@@ -210,6 +210,11 @@ marker_local_unref (marker_local_t *local) + if (local->xdata) + dict_unref (local->xdata); + ++ if (local->lk_frame) { ++ STACK_DESTROY (local->lk_frame->root); ++ local->lk_frame = NULL; ++ } ++ + if (local->oplocal) { + marker_local_unref (local->oplocal); + local->oplocal = NULL; +@@ -836,7 +841,7 @@ marker_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + priv = this->private; + + if (priv->feature_enabled & GF_QUOTA) +- mq_reduce_parent_size_txn (this, &local->loc, -1); ++ mq_reduce_parent_size_txn (this, &local->loc, NULL); + + if (priv->feature_enabled & GF_XTIME) + marker_xtime_update_marks (this, local); +@@ -905,7 +910,7 @@ marker_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (priv->feature_enabled & GF_QUOTA) { + if (!local->skip_txn) +- mq_reduce_parent_size_txn (this, &local->loc, -1); ++ mq_reduce_parent_size_txn (this, &local->loc, NULL); + } + + if (priv->feature_enabled & GF_XTIME) +@@ -1048,35 +1053,23 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this, + frame->local = NULL; + + if (op_ret < 0) { +- if (local->err == 0) { +- local->err = op_errno ? op_errno : EINVAL; +- } +- + gf_log (this->name, GF_LOG_WARNING, + "inodelk (UNLOCK) failed on path:%s (gfid:%s) (%s)", +- local->parent_loc.path, +- uuid_utoa (local->parent_loc.inode->gfid), ++ oplocal->parent_loc.path, ++ uuid_utoa (oplocal->parent_loc.inode->gfid), + strerror (op_errno)); + } + +- if (local->stub != NULL) { +- call_resume (local->stub); +- local->stub = NULL; +- } else if (local->err != 0) { +- STACK_UNWIND_STRICT (rename, frame, -1, local->err, NULL, NULL, +- NULL, NULL, NULL, NULL); +- } else { +- gf_log (this->name, GF_LOG_CRITICAL, +- "continuation stub to unwind the call is absent, hence " +- "call will be hung (call-stack id = %"PRIu64")", +- frame->root->unique); +- } ++ if (local->err != 0) ++ goto err; + +- mq_reduce_parent_size_txn (this, &oplocal->loc, oplocal->contribution); ++ mq_reduce_parent_size_txn (this, &oplocal->loc, &oplocal->contribution); + + if (local->loc.inode != NULL) { +- mq_reduce_parent_size_txn (this, &local->loc, +- local->contribution); ++ /* If destination file exits before rename, it would have ++ * been unlinked while renaming a file ++ */ ++ mq_reduce_parent_size_txn (this, &local->loc, NULL); + } + + newloc.inode = inode_ref (oplocal->loc.inode); +@@ -1097,39 +1090,26 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this, + marker_xtime_update_marks (this, local); + } + ++err: + marker_local_unref (local); + marker_local_unref (oplocal); ++ + return 0; + } + + +-int32_t +-marker_rename_release_newp_lock (call_frame_t *frame, void *cookie, +- xlator_t *this, int32_t op_ret, +- int32_t op_errno, dict_t *xdata) ++void ++marker_rename_release_oldp_lock (marker_local_t *local, xlator_t *this) + { +- marker_local_t *local = NULL, *oplocal = NULL; +- struct gf_flock lock = {0, }; ++ marker_local_t *oplocal = NULL; ++ call_frame_t *lk_frame = NULL; ++ struct gf_flock lock = {0, }; + +- local = frame->local; + oplocal = local->oplocal; ++ lk_frame = local->lk_frame; + +- if (op_ret < 0) { +- if (local->err == 0) { +- local->err = op_errno ? op_errno : EINVAL; +- } +- +- gf_log (this->name, GF_LOG_WARNING, +- "inodelk (UNLOCK) failed on %s (gfid:%s) (%s)", +- oplocal->parent_loc.path, +- uuid_utoa (oplocal->parent_loc.inode->gfid), +- strerror (op_errno)); +- } +- +- if (local->next_lock_on == NULL) { +- marker_rename_done (frame, NULL, this, 0, 0, NULL); +- goto out; +- } ++ if (lk_frame == NULL) ++ goto err; + + lock.l_type = F_UNLCK; + lock.l_whence = SEEK_SET; +@@ -1137,47 +1117,75 @@ marker_rename_release_newp_lock (call_frame_t *frame, void *cookie, + lock.l_len = 0; + lock.l_pid = 0; + +- STACK_WIND (frame, ++ STACK_WIND (lk_frame, + marker_rename_done, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->inodelk, +- this->name, &local->parent_loc, F_SETLKW, &lock, NULL); ++ this->name, &oplocal->parent_loc, F_SETLKW, &lock, NULL); + +-out: +- return 0; ++ return; ++ ++err: ++ marker_local_unref (local); ++ marker_local_unref (oplocal); + } + + + int32_t +-marker_rename_release_oldp_lock (call_frame_t *frame, void *cookie, +- xlator_t *this, int32_t op_ret, +- int32_t op_errno, dict_t *xdata) ++marker_rename_unwind (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) + { +- marker_local_t *local = NULL, *oplocal = NULL; +- struct gf_flock lock = {0, }; ++ marker_local_t *local = NULL; ++ marker_local_t *oplocal = NULL; ++ quota_inode_ctx_t *ctx = NULL; ++ inode_contribution_t *contri = NULL; + + local = frame->local; + oplocal = local->oplocal; +- +- if ((op_ret < 0) && (op_errno != ENOATTR) && (op_errno != ENODATA)) { +- local->err = op_errno; +- } ++ frame->local = NULL; + + //Reset frame uid and gid if set. + if (cookie == (void *) _GF_UID_GID_CHANGED) + MARKER_RESET_UID_GID (frame, frame->root, local); + +- lock.l_type = F_UNLCK; +- lock.l_whence = SEEK_SET; +- lock.l_start = 0; +- lock.l_len = 0; +- lock.l_pid = 0; ++ if (op_ret < 0) ++ local->err = op_errno ? op_errno : EINVAL; ++ ++ if (local->stub != NULL) { ++ /* Remove contribution node from in-memory even if ++ * remove-xattr has failed as the rename is already performed ++ * if local->stub is set, which means rename was sucessful ++ */ ++ mq_inode_ctx_get (oplocal->loc.inode, this, &ctx); ++ if (ctx) { ++ contri = mq_get_contribution_node (oplocal->loc.parent, ++ ctx); ++ if (contri) { ++ QUOTA_FREE_CONTRIBUTION_NODE (ctx, contri); ++ GF_REF_PUT (contri); ++ } ++ } ++ ++ call_resume (local->stub); ++ local->stub = NULL; ++ local->err = 0; ++ } else if (local->err != 0) { ++ STACK_UNWIND_STRICT (rename, frame, -1, local->err, NULL, NULL, ++ NULL, NULL, NULL, NULL); ++ } else { ++ gf_log (this->name, GF_LOG_CRITICAL, ++ "continuation stub to unwind the call is absent, hence " ++ "call will be hung (call-stack id = %"PRIu64")", ++ frame->root->unique); ++ } ++ ++ /* If there are in-progress writes on old-path when during rename ++ * operation, update txn will update the wrong path if lock ++ * is released before rename unwind. ++ * So release lock only after rename unwind ++ */ ++ marker_rename_release_oldp_lock (local, this); + +- STACK_WIND (frame, +- marker_rename_release_newp_lock, +- FIRST_CHILD(this), +- FIRST_CHILD(this)->fops->inodelk, +- this->name, &oplocal->parent_loc, F_SETLKW, &lock, NULL); + return 0; + } + +@@ -1249,7 +1257,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + newloc.parent = inode_ref (local->loc.parent); + gf_uuid_copy (newloc.gfid, oplocal->loc.inode->gfid); + +- STACK_WIND_COOKIE (frame, marker_rename_release_oldp_lock, ++ STACK_WIND_COOKIE (frame, marker_rename_unwind, + frame->cookie, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->removexattr, + &newloc, contri_key, NULL); +@@ -1283,7 +1291,7 @@ out: + return 0; + + quota_err: +- marker_rename_release_oldp_lock (frame, NULL, this, 0, 0, NULL); ++ marker_rename_unwind (frame, NULL, this, 0, 0, NULL); + return 0; + } + +@@ -1296,60 +1304,7 @@ marker_do_rename (call_frame_t *frame, void *cookie, xlator_t *this, + marker_local_t *oplocal = NULL; + char contri_key[CONTRI_KEY_MAX] = {0, }; + int32_t ret = 0; +- int64_t *contribution = 0; +- +- local = frame->local; +- oplocal = local->oplocal; +- +- //Reset frame uid and gid if set. +- if (cookie == (void *) _GF_UID_GID_CHANGED) +- MARKER_RESET_UID_GID (frame, frame->root, local); +- +- if ((op_ret < 0) && (op_errno != ENOATTR) && (op_errno != ENODATA)) { +- local->err = op_errno ? op_errno : EINVAL; +- gf_log (this->name, GF_LOG_WARNING, +- "fetching contribution values from %s (gfid:%s) " +- "failed (%s)", local->loc.path, +- uuid_utoa (local->loc.inode->gfid), +- strerror (op_errno)); +- goto err; +- } +- +- if (local->loc.inode != NULL) { +- GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret); +- if (ret < 0) { +- local->err = errno ? errno : ENOMEM; +- goto err; +- } +- +- if (dict_get_bin (dict, contri_key, +- (void **) &contribution) == 0) { +- local->contribution = ntoh64 (*contribution); +- } +- } +- +- STACK_WIND (frame, marker_rename_cbk, FIRST_CHILD(this), +- FIRST_CHILD(this)->fops->rename, &oplocal->loc, +- &local->loc, local->xdata); +- +- return 0; +- +-err: +- marker_rename_release_oldp_lock (frame, NULL, this, 0, 0, NULL); +- return 0; +-} +- +- +-int32_t +-marker_get_newpath_contribution (call_frame_t *frame, void *cookie, +- xlator_t *this, int32_t op_ret, +- int32_t op_errno, dict_t *dict, dict_t *xdata) +-{ +- marker_local_t *local = NULL; +- marker_local_t *oplocal = NULL; +- char contri_key[CONTRI_KEY_MAX] = {0, }; +- int32_t ret = 0; +- int64_t *contribution = 0; ++ quota_meta_t contribution = {0, }; + + local = frame->local; + oplocal = local->oplocal; +@@ -1373,68 +1328,51 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie, + local->err = errno ? errno : ENOMEM; + goto err; + } ++ quota_dict_get_meta (dict, contri_key, &contribution); ++ oplocal->contribution = contribution; + +- if (dict_get_bin (dict, contri_key, (void **) &contribution) == 0) +- oplocal->contribution = ntoh64 (*contribution); +- +- if (local->loc.inode != NULL) { +- GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret); +- if (ret < 0) { +- local->err = errno ? errno : ENOMEM; +- goto err; +- } +- +- /* getxattr requires uid and gid to be 0, +- * reset them in the callback. +- */ +- MARKER_SET_UID_GID (frame, local, frame->root); +- if (gf_uuid_is_null (local->loc.gfid)) +- gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); +- +- GF_UUID_ASSERT (local->loc.gfid); +- +- STACK_WIND_COOKIE (frame, marker_do_rename, +- frame->cookie, FIRST_CHILD(this), +- FIRST_CHILD(this)->fops->getxattr, +- &local->loc, contri_key, NULL); +- } else { +- marker_do_rename (frame, NULL, this, 0, 0, NULL, NULL); +- } ++ STACK_WIND (frame, marker_rename_cbk, FIRST_CHILD(this), ++ FIRST_CHILD(this)->fops->rename, &oplocal->loc, ++ &local->loc, local->xdata); + + return 0; ++ + err: +- marker_rename_release_oldp_lock (frame, NULL, this, 0, 0, NULL); ++ marker_rename_unwind (frame, NULL, this, 0, 0, NULL); + return 0; + } + +- + int32_t +-marker_get_oldpath_contribution (call_frame_t *frame, void *cookie, ++marker_get_oldpath_contribution (call_frame_t *lk_frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xdata) + { +- marker_local_t *local = NULL; +- marker_local_t *oplocal = NULL; +- char contri_key[CONTRI_KEY_MAX] = {0, }; +- int32_t ret = 0; ++ call_frame_t *frame = NULL; ++ marker_local_t *local = NULL; ++ marker_local_t *oplocal = NULL; ++ char contri_key[CONTRI_KEY_MAX] = {0, }; ++ int32_t ret = 0; + +- local = frame->local; ++ local = lk_frame->local; + oplocal = local->oplocal; ++ frame = local->frame; + + if (op_ret < 0) { + local->err = op_errno ? op_errno : EINVAL; + gf_log (this->name, GF_LOG_WARNING, + "cannot hold inodelk on %s (gfid:%s) (%s)", +- local->next_lock_on->path, +- uuid_utoa (local->next_lock_on->inode->gfid), ++ oplocal->loc.path, uuid_utoa (oplocal->loc.inode->gfid), + strerror (op_errno)); +- goto lock_err; ++ goto err; ++ ++ STACK_DESTROY (local->lk_frame->root); ++ local->lk_frame = NULL; + } + + GET_CONTRI_KEY (contri_key, oplocal->loc.parent->gfid, ret); + if (ret < 0) { + local->err = errno ? errno : ENOMEM; +- goto quota_err; ++ goto err; + } + + /* getxattr requires uid and gid to be 0, +@@ -1448,79 +1386,102 @@ marker_get_oldpath_contribution (call_frame_t *frame, void *cookie, + + GF_UUID_ASSERT (oplocal->loc.gfid); + +- STACK_WIND_COOKIE (frame, marker_get_newpath_contribution, ++ STACK_WIND_COOKIE (frame, marker_do_rename, + frame->cookie, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->getxattr, + &oplocal->loc, contri_key, NULL); +- return 0; +- +-quota_err: +- marker_rename_release_oldp_lock (frame, NULL, this, 0, 0, NULL); +- return 0; +- +-lock_err: +- if ((local->next_lock_on == NULL) +- || (local->next_lock_on == &local->parent_loc)) { +- local->next_lock_on = NULL; +- marker_rename_release_oldp_lock (frame, NULL, this, 0, 0, NULL); +- } else { +- marker_rename_release_newp_lock (frame, NULL, this, 0, 0, NULL); +- } + + return 0; +-} +- +- +-int32_t +-marker_rename_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +- int32_t op_ret, int32_t op_errno, dict_t *xdata) +-{ +- marker_local_t *local = NULL, *oplocal = NULL; +- loc_t *loc = NULL; +- struct gf_flock lock = {0, }; +- +- local = frame->local; +- oplocal = local->oplocal; +- +- if (op_ret < 0) { +- if (local->next_lock_on != &oplocal->parent_loc) { +- loc = &oplocal->parent_loc; +- } else { +- loc = &local->parent_loc; +- } +- +- local->err = op_errno ? op_errno : EINVAL; +- gf_log (this->name, GF_LOG_WARNING, +- "cannot hold inodelk on %s (gfid:%s) (%s)", +- loc->path, uuid_utoa (loc->inode->gfid), +- strerror (op_errno)); +- goto err; +- } +- +- if (local->next_lock_on != NULL) { +- lock.l_len = 0; +- lock.l_start = 0; +- lock.l_type = F_WRLCK; +- lock.l_whence = SEEK_SET; +- +- STACK_WIND (frame, +- marker_get_oldpath_contribution, +- FIRST_CHILD(this), +- FIRST_CHILD(this)->fops->inodelk, +- this->name, local->next_lock_on, +- F_SETLKW, &lock, NULL); +- } else { +- marker_get_oldpath_contribution (frame, 0, this, 0, 0, NULL); +- } +- +- return 0; +- + err: +- marker_rename_done (frame, NULL, this, 0, 0, NULL); +- return 0; +-} +- +- ++ marker_rename_unwind (frame, NULL, this, 0, 0, NULL); ++ return 0; ++} ++ ++ ++/* For a marker_rename FOP, following is the algorithm used for Quota ++ * accounting. The use-case considered is: ++ * 1. rename (src, dst) ++ * 2. both src and dst exist ++ * 3. there are parallel operations on src and dst (lets say through fds ++ * opened on them before rename was initiated). ++ * ++ * PS: We've not thought through whether this algo works in the presence of ++ * hardlinks to src and/or dst. ++ * ++ * Algorithm: ++ * ========== ++ * ++ * 1) set inodelk on src-parent ++ * As part of rename operation, parent can change for the file. ++ * We need to remove contribution (both on disk xattr and in-memory one) ++ * to src-parent (and its ancestors) and add the contribution to dst-parent ++ * (and its ancestors). While we are doing these operations, contribution of ++ * the file/directory shouldn't be changing as we want to be sure that ++ * a) what we subtract from src-parent is exactly what we add to dst-parent ++ * b) we should subtract from src-parent exactly what we contributed to ++ * src-parent ++ * So, We hold a lock on src-parent to block any parallel transcations on ++ * src-inode (since thats the one which survives rename). ++ * ++ * If there are any parallel transactions on dst-inode they keep succeeding ++ * till the association of dst-inode with dst-parent is broken because of an ++ * inode_rename after unwind of rename fop from marker. Only after unwind ++ * (and hence inode_rename), we delete and subtract the contribution of ++ * dst-inode to dst-parent. That way we are making sure we subtract exactly ++ * what dst-inode contributed to dst-parent. ++ * ++ * 2) lookup contribution to src-parent on src-inode. ++ * We need to save the contribution info for use at step-8. ++ * ++ * 3) wind rename ++ * Perform rename on disk ++ * ++ * 4) remove xattr on src-loc ++ * After rename, parent can change, so ++ * need to remove xattrs storing contribution to src-parent. ++ * ++ * 5) remove contribution node corresponding to src-parent from the in-memory ++ * list. ++ * After rename, contri gfid can change and we have ++ * also removed xattr from file. ++ * We need to remove in-memory contribution node to prevent updations to ++ * src-parent even after a successful rename ++ * ++ * 6) unwind rename ++ * This will ensure that rename is done in the server ++ * inode table. An inode_rename disassociates src-inode from src-parent and ++ * associates it with dst-parent. It also disassociates dst-inode from ++ * dst-parent. After inode_rename, inode_parent on src-inode will give ++ * dst-parent and inode_parent on dst-inode will return NULL (assuming ++ * dst-inode doesn't have any hardlinks). ++ * ++ * 7) release inodelk on src-parent ++ * Lock on src-parent should be released only after ++ * rename on disk, remove xattr and rename_unwind (and hence inode_rename) ++ * operations. If lock is released before inode_rename, a parallel ++ * transaction on src-inode can still update src-parent (as inode_parent on ++ * src-inode can still return src-parent). This would make the ++ * contribution from src-inode to src-parent stored in step-2 stale. ++ * ++ * 8) Initiate mq_reduce_parent_size_txn on src-parent to remove contribution ++ * of src-inode to src-parent. We use the contribution stored in step-2. ++ * Since, we had acquired the lock on src-parent all along step-2 through ++ * inode_rename, we can be sure that a parallel transaction wouldn't have ++ * added a delta to src-parent. ++ * ++ * 9) Initiate mq_reduce_parent_size_txn on dst-parent if dst-inode exists. ++ * The size reduced from dst-parent and its ancestors is the ++ * size stored as contribution to dst-parent in dst-inode. ++ * If the destination file had existed, rename will unlink the ++ * destination file as part of its operation. ++ * We need to reduce the size on the dest parent similarly to ++ * unlink. Since, we are initiating reduce-parent-size transaction after ++ * inode_rename, we can be sure that a parallel transaction wouldn't add ++ * delta to dst-parent while we are reducing the contribution of dst-inode ++ * from its ancestors before rename. ++ * ++ * 10) create contribution xattr to dst-parent on src-inode. ++ */ + int32_t + marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + loc_t *newloc, dict_t *xdata) +@@ -1530,7 +1491,6 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + marker_local_t *oplocal = NULL; + marker_conf_t *priv = NULL; + struct gf_flock lock = {0, }; +- loc_t *lock_on = NULL; + + priv = this->private; + +@@ -1569,19 +1529,6 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + if (ret < 0) + goto err; + +- if ((newloc->inode != NULL) && (newloc->parent != oldloc->parent) +- && (gf_uuid_compare (newloc->parent->gfid, +- oldloc->parent->gfid) < 0)) { +- lock_on = &local->parent_loc; +- local->next_lock_on = &oplocal->parent_loc; +- } else { +- lock_on = &oplocal->parent_loc; +- if ((newloc->inode != NULL) && (newloc->parent +- != oldloc->parent)) { +- local->next_lock_on = &local->parent_loc; +- } +- } +- + lock.l_len = 0; + lock.l_start = 0; + lock.l_type = F_WRLCK; +@@ -1589,14 +1536,22 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + + local->xdata = dict_ref (xdata); + +- if (is_lk_owner_null (&frame->root->lk_owner)) +- set_lk_owner_from_ptr (&frame->root->lk_owner, frame->root); ++ local->frame = frame; ++ local->lk_frame = create_frame (this, this->ctx->pool); ++ if (local->lk_frame == NULL) ++ goto err; ++ ++ local->lk_frame->root->uid = 0; ++ local->lk_frame->root->gid = 0; ++ local->lk_frame->local = local; ++ set_lk_owner_from_ptr (&local->lk_frame->root->lk_owner, ++ local->lk_frame->root); + +- STACK_WIND (frame, +- marker_rename_inodelk_cbk, ++ STACK_WIND (local->lk_frame, ++ marker_get_oldpath_contribution, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->inodelk, +- this->name, lock_on, ++ this->name, &oplocal->parent_loc, + F_SETLKW, &lock, NULL); + + return 0; +diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h +index f198859..12a51bc 100644 +--- a/xlators/features/marker/src/marker.h ++++ b/xlators/features/marker/src/marker.h +@@ -97,7 +97,6 @@ struct marker_local{ + pid_t pid; + loc_t loc; + loc_t parent_loc; +- loc_t *next_lock_on; + uid_t uid; + gid_t gid; + int32_t ref; +@@ -106,7 +105,8 @@ struct marker_local{ + mode_t mode; + int32_t err; + call_stub_t *stub; +- int64_t contribution; ++ call_frame_t *lk_frame; ++ quota_meta_t contribution; + struct marker_local *oplocal; + + /* marker quota specific */ +-- +1.7.1 + diff --git a/SOURCES/0281-bitrot-glusterd-gluster-volume-set-command-for-bitro.patch b/SOURCES/0281-bitrot-glusterd-gluster-volume-set-command-for-bitro.patch new file mode 100644 index 0000000..e34c194 --- /dev/null +++ b/SOURCES/0281-bitrot-glusterd-gluster-volume-set-command-for-bitro.patch @@ -0,0 +1,146 @@ +From a415d682160dbb9cb86fcfd5c0371dc575de22ab Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Mon, 8 Jun 2015 13:01:44 +0530 +Subject: [PATCH 281/304] bitrot/glusterd: gluster volume set command for bitrot should not supported + +This patch is backport of: http://review.gluster.org/11118 + +Currently gluster volume set bitrot succeeds. gluster volume +set command for bitrot is not supported. +Gluster should only accept gluster volume bitrot * commands. + + >>Change-Id: I5ff4b79f202ad018c76188f19d6311aad0d7c166 + >>BUG: 1229134 + >>Signed-off-by: Gaurav Kumar Garg + +BUG: 1228135 +Change-Id: I6a9e3d07023021e5f910c8e7f436f9b64d48a277 +Signed-off-by: Gaurav Kumar Garg +Reviewed-on: https://code.engineering.redhat.com/gerrit/55756 +Reviewed-by: Raghavendra Bhat +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + .../bitrot/bug-1229134-bitd-not-support-vol-set.t | 38 ++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 53 ++++++++++++++++++++ + 2 files changed, 91 insertions(+), 0 deletions(-) + create mode 100644 tests/bugs/bitrot/bug-1229134-bitd-not-support-vol-set.t + +diff --git a/tests/bugs/bitrot/bug-1229134-bitd-not-support-vol-set.t b/tests/bugs/bitrot/bug-1229134-bitd-not-support-vol-set.t +new file mode 100644 +index 0000000..471471f +--- /dev/null ++++ b/tests/bugs/bitrot/bug-1229134-bitd-not-support-vol-set.t +@@ -0,0 +1,38 @@ ++#!/bin/bash ++ ++## Test case for bitrot BZ:1229134 ++## gluster volume set bitrot * command succeeds, ++## which is not supported to enable bitrot. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup; ++ ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create and start the volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2} ++TEST $CLI volume start $V0 ++ ++## 'gluster volume set ' command for bitrot should failed. ++TEST ! $CLI volume set $V0 bitrot enable ++TEST ! $CLI volume set $V0 bitrot disable ++TEST ! $CLI volume set $V0 scrub-frequency daily ++TEST ! $CLI volume set $V0 scrub pause ++TEST ! $CLI volume set $V0 scrub-throttle lazy ++ ++ ++## 'gluster volume bitrot *' command for bitrot should succeeds. ++TEST $CLI volume bitrot $V0 enable ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++ ++TEST $CLI volume bitrot $V0 scrub pause ++TEST $CLI volume bitrot $V0 scrub-frequency daily ++TEST $CLI volume bitrot $V0 scrub-throttle lazy ++ ++cleanup; ++ +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 4b06482..1c8925c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -447,6 +447,54 @@ glusterd_op_sm_inject_all_acc (uuid_t *txn_id) + } + + static int ++glusterd_check_bitrot_cmd (char *key, char *value, char *errstr, size_t size) ++{ ++ int ret = -1; ++ ++ if ((!strncmp (key, "bitrot", strlen ("bitrot"))) || ++ (!strncmp (key, "features.bitrot", strlen ("features.bitrot")))) { ++ snprintf (errstr, size, " 'gluster volume set %s' " ++ "is invalid command. Use 'gluster volume bitrot " ++ " {enable|disable}' instead.", key); ++ ret = -1; ++ goto out; ++ } else if ((!strncmp (key, "scrub-freq", strlen ("scrub-freq"))) || ++ (!strncmp (key, "features.scrub-freq", ++ strlen ("features.scrub-freq")))) { ++ snprintf (errstr, size, " 'gluster volume " ++ "set %s' is invalid command. Use 'gluster " ++ "volume bitrot scrub-frequency" ++ " {hourly|daily|weekly|biweekly|monthly}' instead.", ++ key); ++ ret = -1; ++ goto out; ++ } else if ((!strncmp (key, "scrub", strlen ("scrub"))) || ++ (!strncmp (key, "features.scrub", ++ strlen ("features.scrub")))) { ++ snprintf (errstr, size, " 'gluster volume set %s' is " ++ "invalid command. Use 'gluster volume bitrot " ++ " scrub {pause|resume}' instead.", key); ++ ret = -1; ++ goto out; ++ } else if ((!strncmp (key, "scrub-throttle", ++ strlen ("scrub-throttle"))) || ++ (!strncmp (key, "features.scrub-throttle", ++ strlen ("features.scrub-throttle")))) { ++ snprintf (errstr, size, " 'gluster volume set %s' is " ++ "invalid command. Use 'gluster volume bitrot " ++ " scrub-throttle {lazy|normal|aggressive}' " ++ "instead.", ++ key); ++ ret = -1; ++ goto out; ++ } ++ ++ ret = 0; ++out: ++ return ret; ++} ++ ++static int + glusterd_check_quota_cmd (char *key, char *value, char *errstr, size_t size) + { + int ret = -1; +@@ -975,6 +1023,11 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) + } + } + ++ ret = glusterd_check_bitrot_cmd (key, value, errstr, ++ sizeof (errstr)); ++ if (ret) ++ goto out; ++ + ret = glusterd_check_quota_cmd (key, value, errstr, sizeof (errstr)); + if (ret) + goto out; +-- +1.7.1 + diff --git a/SOURCES/0282-features-bit-rot-stub-handle-REOPEN_WAIT-on-forgotte.patch b/SOURCES/0282-features-bit-rot-stub-handle-REOPEN_WAIT-on-forgotte.patch new file mode 100644 index 0000000..91d90f6 --- /dev/null +++ b/SOURCES/0282-features-bit-rot-stub-handle-REOPEN_WAIT-on-forgotte.patch @@ -0,0 +1,163 @@ +From d4e4e3326d03a8c051ec3bea865dd669f3ea3566 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Tue, 21 Jul 2015 15:13:28 +0530 +Subject: [PATCH 282/304] features/bit-rot-stub: handle REOPEN_WAIT on forgotten inodes + + Upstream review: http://review.gluster.org/11729 + +> Change-Id: Ia8706ec9b66d78c4e33e7b7faf69f0d113ba68a4 +> BUG: 1245981 +> Signed-off-by: Raghavendra Bhat +> Reviewed-on: http://review.gluster.org/11729 +> Tested-by: Gluster Build System +> Tested-by: NetBSD Build System +> Reviewed-by: Venky Shankar +> Signed-off-by: Raghavendra Bhat + +Change-Id: I9de4b597e8ecd36afb98a553fb1101f8b9baff0b +BUG: 1245165 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/55759 +--- + tests/bugs/bitrot/bug-1245981.t | 55 ++++++++++++++++++++++ + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 44 +++++++++++++++++- + 2 files changed, 98 insertions(+), 1 deletions(-) + create mode 100644 tests/bugs/bitrot/bug-1245981.t + +diff --git a/tests/bugs/bitrot/bug-1245981.t b/tests/bugs/bitrot/bug-1245981.t +new file mode 100644 +index 0000000..2bed4d9 +--- /dev/null ++++ b/tests/bugs/bitrot/bug-1245981.t +@@ -0,0 +1,55 @@ ++#!/bin/bash ++ ++## Test case for bitrot ++## Tunable object signing waiting time value for bitrot. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++SLEEP_TIME=5 ++ ++cleanup; ++## Start glusterd ++TEST glusterd; ++TEST pidof glusterd; ++ ++## Lets create and start the volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 ++TEST $CLI volume start $V0 ++TEST $CLI volume set $V0 network.inode-lru-limit 1 ++## Enable bitrot on volume $V0 ++TEST $CLI volume bitrot $V0 enable ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count ++ ++# wait a bit for oneshot crawler to finish ++sleep 2; ++ ++## Set object expiry time value ++TEST $CLI volume bitrot $V0 signing-time $SLEEP_TIME ++ ++## Mount the volume ++TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; ++ ++# create and check object signature ++fname="$M0/filezero" ++echo "ZZZ" > $fname ++echo "123" > $M0/new_file; ++ ++touch $M0/1 ++touch $M0/2 ++touch $M0/3 ++touch $M0/4 ++touch $M0/5 ++ ++# wait till the object is signed ++sleep `expr $SLEEP_TIME \* 2` ++ ++backpath=$(get_backend_paths $fname) ++TEST getfattr -m . -n trusted.bit-rot.signature $backpath ++ ++backpath=$(get_backend_paths $M0/new_file) ++TEST getfattr -m . -n trusted.bit-rot.signature $backpath ++ ++cleanup; +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 41c8359..3b3d4d1 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -851,6 +851,40 @@ br_stub_fsetxattr_resume (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + } + ++/** ++ * Handles object reopens. Object reopens can be of 3 types. 2 are from ++ * oneshot crawler and 1 from the regular signer. ++ * ONESHOT CRAWLER: ++ * For those objects which were created before bitrot was enabled. oneshow ++ * crawler crawls the namespace and signs all the objects. It has to do ++ * the versioning before making bit-rot-stub send a sign notification. ++ * So it sends fsetxattr with BR_OBJECT_REOPEN as the value. And bit-rot-stub ++ * upon getting BR_OBJECT_REOPEN value checks if the version has to be ++ * increased or not. By default the version will be increased. But if the ++ * object is modified before BR_OBJECT_REOPEN from oneshot crawler, then ++ * versioning need not be done. In that case simply a success is returned. ++ * SIGNER: ++ * Signer wait for 2 minutes upon getting the notification from bit-rot-stub ++ * and then it sends a dummy write (in reality a fsetxattr) call, to change ++ * the state of the inode from REOPEN_WAIT to SIGN_QUICK. The funny part here ++ * is though the inode's state is REOPEN_WAIT, the call sent by signer is ++ * BR_OBJECT_RESIGN. Once the state is changed to SIGN_QUICK, then yet another ++ * notification is sent upon release (RESIGN would have happened via fsetxattr, ++ * so a fd is needed) and the object is signed truly this time. ++ * There is a challenge in the above RESIGN method by signer. After sending ++ * the 1st notification, the inode could be forgotten before RESIGN request ++ * is received. In that case, the inode's context (the newly looked up inode) ++ * would not indicate the inode as being modified (it would be in the default ++ * state) and because of this, a SIGN_QUICK notification to truly sign the ++ * object would not be sent. So, this is how its handled. ++ * if (request == RESIGN) { ++ * if (inode->sign_info == NORMAL) { ++ * mark_inode_non_dirty; ++ * mark_inode_modified; ++ * } ++ * GOBACK (means unwind without doing versioning) ++ * } ++ */ + static void + br_stub_handle_object_reopen (call_frame_t *frame, + xlator_t *this, fd_t *fd, uint32_t val) +@@ -863,6 +897,7 @@ br_stub_handle_object_reopen (call_frame_t *frame, + gf_boolean_t modified = _gf_false; + br_stub_inode_ctx_t *ctx = NULL; + br_stub_local_t *local = NULL; ++ gf_boolean_t goback = _gf_true; + + ret = br_stub_need_versioning (this, fd, &inc_version, &modified, &ctx); + if (ret) +@@ -870,11 +905,18 @@ br_stub_handle_object_reopen (call_frame_t *frame, + + LOCK (&fd->inode->lock); + { ++ if ((val == BR_OBJECT_REOPEN) && inc_version) ++ goback = _gf_false; ++ if (val == BR_OBJECT_RESIGN && ++ ctx->info_sign == BR_SIGN_NORMAL) { ++ __br_stub_mark_inode_synced (ctx); ++ __br_stub_set_inode_modified (ctx); ++ } + (void) __br_stub_inode_sign_state (ctx, GF_FOP_FSETXATTR, fd); + } + UNLOCK (&fd->inode->lock); + +- if ((val == BR_OBJECT_RESIGN) || !inc_version) { ++ if (goback) { + op_ret = op_errno = 0; + goto unwind; + } +-- +1.7.1 + diff --git a/SOURCES/0283-features-bit-rot-stub-fail-the-fop-if-inode-context-.patch b/SOURCES/0283-features-bit-rot-stub-fail-the-fop-if-inode-context-.patch new file mode 100644 index 0000000..84a37be --- /dev/null +++ b/SOURCES/0283-features-bit-rot-stub-fail-the-fop-if-inode-context-.patch @@ -0,0 +1,322 @@ +From 4a5e97e0e726229f8295ad01c1dd2b97f88828b1 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Sat, 27 Jun 2015 13:17:32 +0530 +Subject: [PATCH 283/304] features/bit-rot-stub: fail the fop if inode context get fails + + Upstream reivew: Reviewed-on: http://review.gluster.org/11449 + +In stub, for fops like readv, writev etc, if the the object is bad, then the fop +is denied. But for checking if the object is bad inode context should be +checked. Now, if the inode context is not there, then the fop is allowed to +continue. This patch fixes it and the fop is unwound with an error, if the inode +context is not found. + +> Change-Id: I5ea4d4fc1a91387f7f9d13ca8cb43c88429f02b0 +> BUG: 1243391 +> Signed-off-by: Raghavendra Bhat +> Reviewed-on: http://review.gluster.org/11449 +> Tested-by: NetBSD Build System +> Reviewed-by: Venky Shankar +> Signed-off-by: Raghavendra Bhat + +Change-Id: Icb07ac086b69ced60828e15bac421ef7ed31fb88 +BUG: 1245165 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/55760 +--- + tests/bitrot/bug-internal-xattrs-check-1243391.t | 42 ++++++++++++ + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 77 ++++++++++++++++++++-- + xlators/features/bit-rot/src/stub/bit-rot-stub.h | 42 +++++++----- + 3 files changed, 138 insertions(+), 23 deletions(-) + create mode 100644 tests/bitrot/bug-internal-xattrs-check-1243391.t + +diff --git a/tests/bitrot/bug-internal-xattrs-check-1243391.t b/tests/bitrot/bug-internal-xattrs-check-1243391.t +new file mode 100644 +index 0000000..bc9c125 +--- /dev/null ++++ b/tests/bitrot/bug-internal-xattrs-check-1243391.t +@@ -0,0 +1,42 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../include.rc ++. $(dirname $0)/../volume.rc ++ ++cleanup; ++ ++TEST glusterd ++TEST pidof glusterd ++ ++## Create a distribute volume (B=2) ++TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2; ++EXPECT "$V0" volinfo_field $V0 'Volume Name'; ++EXPECT 'Created' volinfo_field $V0 'Status'; ++EXPECT '2' brick_count $V0 ++ ++ ++## Start the volume ++TEST $CLI volume start $V0; ++EXPECT 'Started' volinfo_field $V0 'Status'; ++ ++## Mount the volume ++TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; ++ ++echo "123" >> $M0/file; ++ ++TEST ! setfattr -n "trusted.glusterfs.set-signature" -v "123" $M0/file; ++TEST ! setfattr -n "trusted.glusterfs.get-signature" -v "123" $M0/file; ++ ++# sign xattr ++TEST ! setfattr -n "trusted.bit-rot.signature" -v "123" $M0/file; ++TEST ! setfattr -x "trusted.bit-rot.signature" $M0/file; ++ ++# versioning xattr ++TEST ! setfattr -n "trusted.bit-rot.version" -v "123" $M0/file; ++TEST ! setfattr -x "trusted.bit-rot.version" $M0/file; ++ ++# bad file xattr ++TEST ! setfattr -n "trusted.bit-rot.bad-file" -v "123" $M0/file; ++TEST ! setfattr -x "trusted.bit-rot.bad-file" $M0/file; ++ ++cleanup; +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 3b3d4d1..52f0d5c 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -457,6 +457,40 @@ br_stub_mark_inode_modified (xlator_t *this, br_stub_local_t *local) + } + + /** ++ * The possible return values from br_stub_is_bad_object () are: ++ * 1) 0 => as per the inode context object is not bad ++ * 2) -1 => Failed to get the inode context itself ++ * 3) -2 => As per the inode context object is bad ++ * Both -ve values means the fop which called this function is failed ++ * and error is returned upwards. ++ */ ++static int ++br_stub_check_bad_object (xlator_t *this, inode_t *inode, int32_t *op_ret, ++ int32_t *op_errno) ++{ ++ int ret = -1; ++ ++ ret = br_stub_is_bad_object (this, inode); ++ if (ret == -2) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_BAD_OBJECT_ACCESS, ++ "%s is a bad object. Returning", ++ uuid_utoa (inode->gfid)); ++ *op_ret = -1; ++ *op_errno = EIO; ++ } ++ ++ if (ret == -1) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, "could not get inode" ++ " context for %s", uuid_utoa (inode->gfid)); ++ *op_ret = -1; ++ *op_errno = EINVAL; ++ } ++ ++ return ret; ++} ++ ++/** + * callback for inode/fd versioning + */ + int +@@ -1100,6 +1134,12 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, + goto done; + } + ++ if (dict_get (dict, GLUSTERFS_GET_OBJECT_SIGNATURE)) { ++ br_stub_handle_internal_xattr (frame, this, fd, ++ GLUSTERFS_GET_OBJECT_SIGNATURE); ++ goto done; ++ } ++ + /* object reopen request */ + ret = dict_get_uint32 (dict, BR_REOPEN_SIGN_HINT_KEY, &val); + if (!ret) { +@@ -1140,6 +1180,7 @@ br_stub_setxattr (call_frame_t *frame, xlator_t *this, + char *format = "(%s:%s)"; + + if (dict_get (dict, GLUSTERFS_SET_OBJECT_SIGNATURE) || ++ dict_get (dict, GLUSTERFS_GET_OBJECT_SIGNATURE) || + dict_get (dict, BR_REOPEN_SIGN_HINT_KEY) || + dict_get (dict, BITROT_OBJECT_BAD_KEY) || + dict_get (dict, BITROT_SIGNING_VERSION_KEY) || +@@ -1582,13 +1623,16 @@ br_stub_readv (call_frame_t *frame, xlator_t *this, + { + int32_t op_ret = -1; + int32_t op_errno = EINVAL; ++ int32_t ret = -1; + + GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind); + GF_VALIDATE_OR_GOTO (this->name, frame, unwind); + GF_VALIDATE_OR_GOTO (this->name, fd, unwind); + GF_VALIDATE_OR_GOTO (this->name, fd->inode, unwind); + +- BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); ++ if (ret) ++ goto unwind; + + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readv, fd, size, offset, +@@ -1682,7 +1726,9 @@ br_stub_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (ret) + goto unwind; + +- BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); ++ if (ret) ++ goto unwind; + + /** + * The inode is not dirty and also witnessed atleast one successful +@@ -1803,7 +1849,9 @@ br_stub_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + if (ret) + goto unwind; + +- BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); ++ if (ret) ++ goto unwind; + + if (!inc_version && modified) + goto wind; +@@ -1935,7 +1983,9 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + if (ret) + goto cleanup_fd; + +- BR_STUB_HANDLE_BAD_OBJECT (this, fd->inode, op_ret, op_errno, unwind); ++ ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); ++ if (ret) ++ goto unwind; + + if (!inc_version && modified) + goto wind; +@@ -2029,7 +2079,9 @@ br_stub_open (call_frame_t *frame, xlator_t *this, + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + +- BR_STUB_HANDLE_BAD_OBJECT (this, loc->inode, op_ret, op_errno, unwind); ++ ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); ++ if (ret) ++ goto unwind; + + if (frame->root->pid == GF_CLIENT_PID_SCRUB) + goto wind; +@@ -2211,6 +2263,13 @@ unwind: + * calls can be avoided and bad objects can be caught instantly. Fetching the + * xattr is needed only in lookups when there is a brick restart or inode + * forget. ++ * ++ * If the dict (@xattr) is NULL, then how should that be handled? Fail the ++ * lookup operation? Or let it continue with version being initialized to ++ * BITROT_DEFAULT_CURRENT_VERSION. But what if the version was different ++ * on disk (and also a right signature was there), but posix failed to ++ * successfully allocate the dict? Posix does not treat call back xdata ++ * creattion failure as the lookup failure. + */ + static inline int32_t + br_stub_lookup_version (xlator_t *this, +@@ -2235,6 +2294,14 @@ br_stub_lookup_version (xlator_t *this, + || (status == BR_VXATTR_STATUS_UNSIGNED)) + ? obuf->ongoingversion : BITROT_DEFAULT_CURRENT_VERSION; + ++ /** ++ * If signature is there, but version is not therem then that status is ++ * is treated as INVALID. So in that case, we should not initialize the ++ * inode context with wrong version names etc. ++ */ ++ if (status == BR_VXATTR_STATUS_INVALID) ++ return -1; ++ + return br_stub_init_inode_versions (this, NULL, inode, version, + _gf_true, bad_object); + } +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +index e5649fc..260fe18 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h +@@ -390,32 +390,32 @@ br_stub_remove_vxattrs (dict_t *xattr) + } + } + +-#define BR_STUB_HANDLE_BAD_OBJECT(this, inode, op_ret, op_errno, label) \ +- do { \ +- if (br_stub_is_bad_object (this, inode)) { \ +- gf_msg (this->name, GF_LOG_ERROR, 0, \ +- BRS_MSG_BAD_OBJECT_ACCESS, \ +- "%s is a bad object. Returning", \ +- uuid_utoa (inode->gfid)); \ +- op_ret = -1; \ +- op_errno = EIO; \ +- goto label; \ +- } \ +- } while (0) +- +-static inline gf_boolean_t ++/** ++ * This function returns the below values for different situations ++ * 0 => as per the inode context object is not bad ++ * -1 => Failed to get the inode context itself ++ * -2 => As per the inode context object is bad ++ * Both -ve values means the fop which called this function is failed ++ * and error is returned upwards. ++ * In future if needed or more errors have to be handled, then those ++ * errors can be made into enums. ++ */ ++static inline int + br_stub_is_bad_object (xlator_t *this, inode_t *inode) + { +- gf_boolean_t bad_object = _gf_false; ++ int bad_object = 0; ++ gf_boolean_t tmp = _gf_false; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + int32_t ret = -1; + + ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); + if (ret) { +- gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_SET_CONTEXT_FAILED, ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ BRS_MSG_GET_INODE_CONTEXT_FAILED, + "failed to get the inode context for the inode %s", + uuid_utoa (inode->gfid)); ++ bad_object = -1; + goto out; + } + +@@ -423,7 +423,9 @@ br_stub_is_bad_object (xlator_t *this, inode_t *inode) + + LOCK (&inode->lock); + { +- bad_object = __br_stub_is_bad_object (ctx); ++ tmp = __br_stub_is_bad_object (ctx); ++ if (tmp) ++ bad_object = -2; + } + UNLOCK (&inode->lock); + +@@ -459,12 +461,16 @@ out: + return ret; + } + ++/** ++ * There is a possibility that dict_set might fail. The o/p of dict_set is ++ * given to the caller and the caller has to decide what to do. ++ */ + static inline int32_t + br_stub_mark_xdata_bad_object (xlator_t *this, inode_t *inode, dict_t *xdata) + { + int32_t ret = 0; + +- if (br_stub_is_bad_object (this, inode)) ++ if (br_stub_is_bad_object (this, inode) == -2) + ret = dict_set_int32 (xdata, GLUSTERFS_BAD_INODE, 1); + + return ret; +-- +1.7.1 + diff --git a/SOURCES/0284-bitrot-Scrubber-log-should-mark-bad-file-as-a-ALERT-.patch b/SOURCES/0284-bitrot-Scrubber-log-should-mark-bad-file-as-a-ALERT-.patch new file mode 100644 index 0000000..c9c8706 --- /dev/null +++ b/SOURCES/0284-bitrot-Scrubber-log-should-mark-bad-file-as-a-ALERT-.patch @@ -0,0 +1,42 @@ +From ba6855fbb31112c54edbaa2d4624024691266d3f Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Thu, 20 Aug 2015 16:12:53 +0530 +Subject: [PATCH 284/304] bitrot: Scrubber log should mark bad file as a ALERT in the scrubber log + +This patch is backport of: http://review.gluster.org/11965 + +If bad file detected by scrubber then scrubber should log that bad +file as a ALERT message in scrubber log. + + >>Change-Id: I410429e78fd3768655230ac028fa66f7fc24b938 + >>BUG: 1240218 + >>Signed-off-by: Gaurav Kumar Garg + +Change-Id: I6f1f9ca1a1d20d99b98060ffd574b6d5a877431e +BUG: 1238977 +Signed-off-by: Gaurav Kumar Garg +Reviewed-on: https://code.engineering.redhat.com/gerrit/55866 +Reviewed-by: Raghavendra Bhat +Tested-by: Raghavendra Bhat +--- + xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +index 3a038ce..2fb5caa 100644 +--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c ++++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +@@ -243,8 +243,8 @@ bitd_compare_ckum (xlator_t *this, + goto dictfree; + } + +- gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_MARK_CORRUPTED, "Marking %s" +- " [GFID: %s | Brick: %s] as corrupted..", loc->path, ++ gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_MARK_CORRUPTED, "Marking" ++ " %s [GFID: %s | Brick: %s] as corrupted..", loc->path, + uuid_utoa (linked_inode->gfid), child->brick_path); + ret = syncop_fsetxattr (child->xl, fd, xattr, 0, NULL, NULL); + if (ret) +-- +1.7.1 + diff --git a/SOURCES/0285-protocol-server-use-different-dict-for-resolving.patch b/SOURCES/0285-protocol-server-use-different-dict-for-resolving.patch new file mode 100644 index 0000000..fad9275 --- /dev/null +++ b/SOURCES/0285-protocol-server-use-different-dict-for-resolving.patch @@ -0,0 +1,107 @@ +From b7ee0d94438ad82ac50a7f856ac41be4fd4e28c7 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Tue, 14 Jul 2015 16:16:00 +0530 +Subject: [PATCH 285/304] protocol/server: use different dict for resolving + + Backport of: http://review.gluster.org/11661 + +protocol/server has to resolve the inode before continuing with any fop coming +from the clients. For resolving it, server xlator was using the same dict +associated with the fop. It causes problems in some situations. + +If a directory's inode was forgotten because of lru limit being exceeded, then +when a create fop comes for an entry within that directory, server tries to +resolve it. But since the parent directory's inode is not found in the inode +table, it tries to do a hard resolve by doing a lookup on the parent gfid. + +If any xlator below server wants to get some extended attributes whenever +lookup comes, then they set the new keys in the same dict that came along with +the create fop. Now, the lookup of the parent succeeds and the create fop +proceeds with the same dict (with extra keys present). posix xlaror creates +those xattrs that are present in the dict. Thus the xattrs which were not to +be present by default are also set as part of create. (Ex: bit-rot related +xattrs such as bad-file, version and sign xattrs) + +> Change-Id: I4bdad175a1d7a04a3aa36073667c556d6c260263 +> Signed-off-by: Raghavendra Bhat +> Reviewed-on: http://review.gluster.org/11661 +> Reviewed-by: Vijaikumar Mallikarjuna +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G +> Signed-off-by: Raghavendra Bhat + +Change-Id: I55c788858bc15549f67cc80151a95d3c2a695376 +BUG: 1251409 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/55883 +--- + xlators/protocol/server/src/server-resolve.c | 26 ++++++++++++++++++++++++-- + 1 files changed, 24 insertions(+), 2 deletions(-) + +diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c +index a7da519..906dc00 100644 +--- a/xlators/protocol/server/src/server-resolve.c ++++ b/xlators/protocol/server/src/server-resolve.c +@@ -106,6 +106,7 @@ resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + server_resolve_t *resolve = NULL; + inode_t *link_inode = NULL; + loc_t *resolve_loc = NULL; ++ dict_t *dict = NULL; + + state = CALL_STATE (frame); + resolve = state->resolve_now; +@@ -166,10 +167,19 @@ resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode_path (resolve_loc->parent, resolve_loc->name, + (char **) &resolve_loc->path); + ++ dict = dict_copy_with_ref (state->xdata, NULL); ++ if (!dict && state->xdata) ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, ++ "BUG: dict allocation failed (pargfid: %s, name: %s), " ++ "still continuing", uuid_utoa (resolve_loc->gfid), ++ resolve_loc->name); ++ + STACK_WIND (frame, resolve_gfid_entry_cbk, + frame->root->client->bound_xl, + frame->root->client->bound_xl->fops->lookup, +- &resolve->resolve_loc, state->xdata); ++ &resolve->resolve_loc, dict); ++ if (dict) ++ dict_unref (dict); + return 0; + out: + resolve_continue (frame); +@@ -185,6 +195,7 @@ resolve_gfid (call_frame_t *frame) + server_resolve_t *resolve = NULL; + loc_t *resolve_loc = NULL; + int ret = 0; ++ dict_t *xdata = NULL; + + state = CALL_STATE (frame); + this = frame->this; +@@ -199,10 +210,21 @@ resolve_gfid (call_frame_t *frame) + resolve_loc->inode = inode_new (state->itable); + ret = loc_path (resolve_loc, NULL); + ++ xdata = dict_copy_with_ref (state->xdata, NULL); ++ if (!xdata && state->xdata) ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, ++ "BUG: dict allocation failed (gfid: %s), " ++ "still continuing", ++ uuid_utoa (resolve_loc->gfid)); ++ + STACK_WIND (frame, resolve_gfid_cbk, + frame->root->client->bound_xl, + frame->root->client->bound_xl->fops->lookup, +- &resolve->resolve_loc, state->xdata); ++ &resolve->resolve_loc, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); ++ + return 0; + } + +-- +1.7.1 + diff --git a/SOURCES/0286-tests-set-inode-lru-limit-to-1-and-check-if-bit-rot-.patch b/SOURCES/0286-tests-set-inode-lru-limit-to-1-and-check-if-bit-rot-.patch new file mode 100644 index 0000000..584850d --- /dev/null +++ b/SOURCES/0286-tests-set-inode-lru-limit-to-1-and-check-if-bit-rot-.patch @@ -0,0 +1,171 @@ +From 4054c96ec56c90ccd5955af555a7e953417206fa Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Mon, 20 Jul 2015 16:03:40 +0530 +Subject: [PATCH 286/304] tests: set inode-lru-limit to 1 and check if bit-rot xattrs are wrongy created + + Backport of http://review.gluster.org/11718 + +This test sets the lru limit of the inode table to 1 and checks if inode forgets +and resolve cause any problem with bit-rot xattrs (especially bad-file xattr). + +> Change-Id: I1fa25fa2d31dda8d26e8192562e896e5bddd0381 +> BUG: 1244613 +> Signed-off-by: Raghavendra Bhat +> Reviewed-on: http://review.gluster.org/11718 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Venky Shankar +> Signed-off-by: Raghavendra Bhat + +Change-Id: I0daddac9b47211e2e6b9f1299396eadf0ec1e207 +BUG: 1251409 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/55884 +--- + tests/bitrot/bug-1244613.t | 87 ++++++++++++++++++++++++++ + xlators/protocol/server/src/server-resolve.c | 28 +++++---- + 2 files changed, 103 insertions(+), 12 deletions(-) + create mode 100644 tests/bitrot/bug-1244613.t + +diff --git a/tests/bitrot/bug-1244613.t b/tests/bitrot/bug-1244613.t +new file mode 100644 +index 0000000..000a1d3 +--- /dev/null ++++ b/tests/bitrot/bug-1244613.t +@@ -0,0 +1,87 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../include.rc ++. $(dirname $0)/../volume.rc ++. $(dirname $0)/../nfs.rc ++. $(dirname $0)/../fileio.rc ++ ++cleanup; ++ ++TESTS_EXPECTED_IN_LOOP=16 ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 $H0:$B0/brick1; ++EXPECT 'Created' volinfo_field $V0 'Status'; ++ ++ ++# The test makes use of inode-lru-limit to hit a scenario, where we ++# find an inode whose ancestry is not there. Following is the ++# hypothesis (which is confirmed by seeing logs indicating that ++# codepath has been executed, but not through a good understanding of ++# NFS internals). ++ ++# At the end of an fop, the reference count of an inode would be ++# zero. The inode (and its ancestry) persists in memory only ++# because of non-zero lookup count. These looked up inodes are put ++# in an lru queue of size 1 (here). So, there can be at most one ++# such inode in memory. ++ ++# NFS Server makes use of anonymous fds. So, if it cannot find ++# valid fd, it does a nameless lookup. This gives us an inode ++# whose ancestry is NULL. When a write happens on this inode, ++# quota-enforcer/marker finds a NULL ancestry and asks ++# storage/posix to build it. ++ ++TEST $CLI volume set $V0 network.inode-lru-limit 1 ++TEST $CLI volume set $V0 performance.nfs.write-behind off ++ ++TEST $CLI volume start $V0; ++EXPECT 'Started' volinfo_field $V0 'Status'; ++ ++TEST mount_nfs $H0:/$V0 $N0; ++deep=/0/1/2/3/4/5/6/7/8/9 ++TEST mkdir -p $N0/$deep ++ ++TEST touch $N0/$deep/file1 $N0/$deep/file2 $N0/$deep/file3 $N0/$deep/file4 ++ ++TEST fd_open 3 'w' "$N0/$deep/file1" ++TEST fd_open 4 'w' "$N0/$deep/file2" ++TEST fd_open 5 'w' "$N0/$deep/file3" ++TEST fd_open 6 'w' "$N0/$deep/file4" ++ ++# consume all quota ++echo "Hello" > $N0/$deep/new_file_1 ++echo "World" >> $N0/$deep/new_file_1 ++echo 1 >> $N0/$deep/new_file_1 ++echo 2 >> $N0/$deep/new_file_1 ++ ++ ++# At the end of each fop in server, reference count of the ++# inode associated with each of the file above drops to zero and hence ++# put into lru queue. Since lru-limit is set to 1, an fop next file ++# will displace the current inode from itable. This will ensure that ++# when writes happens on same fd, fd resolution results in ++# nameless lookup from server and encounters an fd ++# associated with an inode whose parent is not present in itable. ++ ++for j in $(seq 1 2); do ++ for i in $(seq 3 6); do ++ TEST_IN_LOOP fd_write $i "content" ++ TEST_IN_LOOP sync ++ done ++done ++ ++exec 3>&- ++exec 4>&- ++exec 5>&- ++exec 6>&- ++ ++$CLI volume statedump $V0 all ++ ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0 ++ ++TEST $CLI volume stop $V0 ++ ++cleanup; +diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c +index 906dc00..5f3d475 100644 +--- a/xlators/protocol/server/src/server-resolve.c ++++ b/xlators/protocol/server/src/server-resolve.c +@@ -167,12 +167,14 @@ resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode_path (resolve_loc->parent, resolve_loc->name, + (char **) &resolve_loc->path); + +- dict = dict_copy_with_ref (state->xdata, NULL); +- if (!dict && state->xdata) +- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, +- "BUG: dict allocation failed (pargfid: %s, name: %s), " +- "still continuing", uuid_utoa (resolve_loc->gfid), +- resolve_loc->name); ++ if (state->xdata) { ++ dict = dict_copy_with_ref (state->xdata, NULL); ++ if (!dict) ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, ++ "BUG: dict allocation failed (pargfid: %s, name: %s), " ++ "still continuing", uuid_utoa (resolve_loc->gfid), ++ resolve_loc->name); ++ } + + STACK_WIND (frame, resolve_gfid_entry_cbk, + frame->root->client->bound_xl, +@@ -210,12 +212,14 @@ resolve_gfid (call_frame_t *frame) + resolve_loc->inode = inode_new (state->itable); + ret = loc_path (resolve_loc, NULL); + +- xdata = dict_copy_with_ref (state->xdata, NULL); +- if (!xdata && state->xdata) +- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, +- "BUG: dict allocation failed (gfid: %s), " +- "still continuing", +- uuid_utoa (resolve_loc->gfid)); ++ if (state->xdata) { ++ xdata = dict_copy_with_ref (state->xdata, NULL); ++ if (!xdata) ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, ++ "BUG: dict allocation failed (gfid: %s), " ++ "still continuing", ++ uuid_utoa (resolve_loc->gfid)); ++ } + + STACK_WIND (frame, resolve_gfid_cbk, + frame->root->client->bound_xl, +-- +1.7.1 + diff --git a/SOURCES/0287-protocol-server-forget-the-inodes-which-got-ENOENT-i.patch b/SOURCES/0287-protocol-server-forget-the-inodes-which-got-ENOENT-i.patch new file mode 100644 index 0000000..eabcf1e --- /dev/null +++ b/SOURCES/0287-protocol-server-forget-the-inodes-which-got-ENOENT-i.patch @@ -0,0 +1,217 @@ +From 8509249e4a211013ff923bd5f2c6891da7275143 Mon Sep 17 00:00:00 2001 +From: Raghavendra Bhat +Date: Wed, 1 Jul 2015 15:56:58 +0530 +Subject: [PATCH 287/304] protocol/server: forget the inodes which got ENOENT in lookup + + Upstream Review: http://review.gluster.org/11489 + +If a looked up object is removed from the backend, then upon getting a +revalidated lookup on that object ENOENT error is received. protocol/server +xlator handles it by removing dentry upon which ENOENT is received. But the +inode associated with it still remains in the inode table, and whoever does +nameless lookup on the gfid of that object will be able to do it successfully +despite the object being not present. + +For handling this issue, upon getting ENOENT on a looked up entry in revalidate +lookups, protocol/server should forget the inode as well. + +Though removing files directly from the backend is not allowed, in case of +objects corrupted due to bitrot and marked as bad by scrubber, objects are +removed directly from the backend in case of replicate volumes, so that the +object is healed from the good copy. For handling this, the inode of the bad +object removed from the backend should be forgotten. Otherwise, the inode which +knows the object it represents is bad, does not allow read/write operations +happening as part of self-heal. + +> Change-Id: I23b7a5bef919c98eea684aa1e977e317066cfc71 +> BUG: 1238188 +> Signed-off-by: Raghavendra Bhat +> Reviewed-on: http://review.gluster.org/11489 +> Tested-by: NetBSD Build System +> Reviewed-by: Raghavendra G +> Signed-off-by: Raghavendra Bhat + +Change-Id: I9823e8562f05b2a5af0b70c17a5471014e0a179e +BUG: 1238171 +Signed-off-by: Raghavendra Bhat +Reviewed-on: https://code.engineering.redhat.com/gerrit/55868 +--- + libglusterfs/src/inode.c | 26 +++++++++++ + libglusterfs/src/inode.h | 3 + + xlators/protocol/server/src/server-rpc-fops.c | 56 +++++++++++++++---------- + xlators/protocol/server/src/server.h | 3 + + 4 files changed, 66 insertions(+), 22 deletions(-) + +diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c +index 7b49fbe..af50865 100644 +--- a/libglusterfs/src/inode.c ++++ b/libglusterfs/src/inode.c +@@ -1319,6 +1319,32 @@ inode_parent (inode_t *inode, uuid_t pargfid, const char *name) + return parent; + } + ++static int ++__inode_has_dentry (inode_t *inode) ++{ ++ if (!inode) { ++ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, ++ LG_MSG_INODE_NOT_FOUND, "inode not found"); ++ return 0; ++ } ++ ++ return !list_empty (&inode->dentry_list); ++} ++ ++int ++inode_has_dentry (inode_t *inode) ++{ ++ ++ int dentry_present = 0; ++ ++ LOCK (&inode->lock); ++ { ++ dentry_present = __inode_has_dentry (inode); ++ } ++ UNLOCK (&inode->lock); ++ ++ return dentry_present; ++} + + int + __inode_path (inode_t *inode, const char *name, char **bufp) +diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h +index 474dc39..fcc150b 100644 +--- a/libglusterfs/src/inode.h ++++ b/libglusterfs/src/inode.h +@@ -272,4 +272,7 @@ inode_ctx_merge (fd_t *fd, inode_t *inode, inode_t *linked_inode); + int + inode_is_linked (inode_t *inode); + ++int ++inode_has_dentry (inode_t *inode); ++ + #endif /* _INODE_H */ +diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c +index 99b8011..bd1ced4 100644 +--- a/xlators/protocol/server/src/server-rpc-fops.c ++++ b/xlators/protocol/server/src/server-rpc-fops.c +@@ -32,6 +32,16 @@ + ret = RPCSVC_ACTOR_ERROR; \ + } while (0) + ++void ++forget_inode_if_no_dentry (inode_t *inode) ++{ ++ if (!inode_has_dentry (inode)) ++ inode_forget (inode, 0); ++ ++ return; ++} ++ ++ + /* Callback function section */ + int + server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +@@ -108,6 +118,23 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode_unlink (state->loc.inode, + state->loc.parent, + state->loc.name); ++ /** ++ * If the entry is not present, then just ++ * unlinking the associated dentry is not ++ * suffecient. This condition should be ++ * treated as unlink of the entry. So along ++ * with deleting the entry, its also important ++ * to forget the inode for it (if the dentry ++ * being considered was the last dentry). ++ * Otherwise it might lead to inode leak. ++ * It also might lead to wrong decisions being ++ * taken if the future lookups on this inode are ++ * successful since they are able to find the ++ * inode in the inode table (atleast gfid based ++ * lookups will be successful, if the lookup ++ * is a soft lookup) ++ */ ++ forget_inode_if_no_dentry (state->loc.inode); + } + } + goto out; +@@ -416,7 +443,6 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + { + gfs3_rmdir_rsp rsp = {0,}; + server_state_t *state = NULL; +- inode_t *parent = NULL; + rpcsvc_request_t *req = NULL; + + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, +@@ -436,15 +462,11 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + inode_unlink (state->loc.inode, state->loc.parent, + state->loc.name); +- parent = inode_parent (state->loc.inode, 0, NULL); +- if (parent) +- /* parent should not be found for directories after +- * inode_unlink, since directories cannot have +- * hardlinks. +- */ +- inode_unref (parent); +- else +- inode_forget (state->loc.inode, 0); ++ /* parent should not be found for directories after ++ * inode_unlink, since directories cannot have ++ * hardlinks. ++ */ ++ forget_inode_if_no_dentry (state->loc.inode); + + gf_stat_from_iatt (&rsp.preparent, preparent); + gf_stat_from_iatt (&rsp.postparent, postparent); +@@ -1023,12 +1045,7 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + if (tmp_inode) { + inode_unlink (tmp_inode, state->loc2.parent, + state->loc2.name); +- tmp_parent = inode_parent (tmp_inode, 0, NULL); +- if (tmp_parent) +- inode_unref (tmp_parent); +- else +- inode_forget (tmp_inode, 0); +- ++ forget_inode_if_no_dentry (tmp_inode); + inode_unref (tmp_inode); + } + +@@ -1064,7 +1081,6 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + { + gfs3_unlink_rsp rsp = {0,}; + server_state_t *state = NULL; +- inode_t *parent = NULL; + rpcsvc_request_t *req = NULL; + + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, +@@ -1089,11 +1105,7 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + inode_unlink (state->loc.inode, state->loc.parent, + state->loc.name); + +- parent = inode_parent (state->loc.inode, 0, NULL); +- if (parent) +- inode_unref (parent); +- else +- inode_forget (state->loc.inode, 0); ++ forget_inode_if_no_dentry (state->loc.inode); + + gf_stat_from_iatt (&rsp.preparent, preparent); + gf_stat_from_iatt (&rsp.postparent, postparent); +diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h +index 6caf449..1055b72 100644 +--- a/xlators/protocol/server/src/server.h ++++ b/xlators/protocol/server/src/server.h +@@ -172,4 +172,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, + int gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict); + int gf_server_check_getxattr_cmd (call_frame_t *frame, const char *name); + ++void ++forget_inode_if_no_dentry (inode_t *inode); ++ + #endif /* !_SERVER_H */ +-- +1.7.1 + diff --git a/SOURCES/0288-afr-launch-index-heal-on-local-subvols-up-on-a-child.patch b/SOURCES/0288-afr-launch-index-heal-on-local-subvols-up-on-a-child.patch new file mode 100644 index 0000000..f8cd88b --- /dev/null +++ b/SOURCES/0288-afr-launch-index-heal-on-local-subvols-up-on-a-child.patch @@ -0,0 +1,86 @@ +From 3abed9139e839cb1393d27bce5b2459b96b5a19e Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Thu, 13 Aug 2015 18:33:08 +0530 +Subject: [PATCH 288/304] afr: launch index heal on local subvols up on a child-up event + +Patch in master: http://review.gluster.org/11912 +Patch in release-3.7: http://review.gluster.org/#/c/11982/ + +Problem: +When a replica's child goes down and comes up, the index heal is +triggered only on the child that just came up. This does not serve the +intended purpose as the list of files that need to be healed +to this child is actually captured on the other child of the replica. + +Fix: +Launch index-heal on all local children of the replica xlator which just +received a child up. Note that afr_selfheal_childup() eventually calls +afr_shd_index_healer() which will not run the heal on non-local +children. + +Change-Id: Ic0d47728c45f1c2bfb443c3bcc551818e5f8680c +BUG: 1239021 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/56024 +Reviewed-by: Krutika Dhananjay +--- + xlators/cluster/afr/src/afr-common.c | 28 +++++++++++----------------- + 1 files changed, 11 insertions(+), 17 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 31c6eff..2401cfd 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -3888,7 +3888,6 @@ afr_notify (xlator_t *this, int32_t event, + int idx = -1; + int ret = -1; + int call_psh = 0; +- int up_child = -1; + dict_t *input = NULL; + dict_t *output = NULL; + gf_boolean_t had_quorum = _gf_false; +@@ -3949,7 +3948,6 @@ afr_notify (xlator_t *this, int32_t event, + priv->child_up[idx] = 1; + + call_psh = 1; +- up_child = idx; + for (i = 0; i < priv->child_count; i++) + if (priv->child_up[i] == 1) + up_children++; +@@ -4085,22 +4083,18 @@ afr_notify (xlator_t *this, int32_t event, + if (propagate) + ret = default_notify (this, event, data); + +- if (!had_heard_from_all && have_heard_from_all && priv->shd.iamshd) { +- /* +- * Since self-heal is supposed to be launched only after +- * the responses from all the bricks are collected, +- * launch self-heals now on all up subvols. +- */ +- for (i = 0; i < priv->child_count; i++) +- if (priv->child_up[i]) +- afr_selfheal_childup (this, i); +- } else if (have_heard_from_all && call_psh && priv->shd.iamshd) { +- /* +- * Already heard from everyone. Just launch heal on now up +- * subvolume. ++ if ((!had_heard_from_all) || call_psh) { ++ /* Launch self-heal on all local subvolumes if: ++ * a) We have_heard_from_all for the first time ++ * b) Already heard from everyone, but we now got a child-up ++ * event. + */ +- afr_selfheal_childup (this, up_child); +- } ++ if (have_heard_from_all && priv->shd.iamshd) { ++ for (i = 0; i < priv->child_count; i++) ++ if (priv->child_up[i]) ++ afr_selfheal_childup (this, i); ++ } ++ } + out: + return ret; + } +-- +1.7.1 + diff --git a/SOURCES/0289-snapshot-scheduler-Output-correction-of-initialisati.patch b/SOURCES/0289-snapshot-scheduler-Output-correction-of-initialisati.patch new file mode 100644 index 0000000..c92dbe4 --- /dev/null +++ b/SOURCES/0289-snapshot-scheduler-Output-correction-of-initialisati.patch @@ -0,0 +1,37 @@ +From 21462d03db0f164f526d9a962ba322300129a8f3 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Fri, 14 Aug 2015 18:28:08 +0530 +Subject: [PATCH 289/304] snapshot/scheduler: Output correction of initialisation + +Change-Id: I4a6e00805da7b254b8b08e7bb142960fb6c64923 +BUG: 1224184 +Signed-off-by: Avra Sengupta +Reviewed-on: http://review.gluster.org/11924 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: mohammed rafi kc +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/56041 +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/snap_scheduler.py | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index ce808cf..f9cfc9e 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -451,8 +451,8 @@ def initialise_scheduler(): + + os.symlink(GCRON_TASKS, GCRON_CROND_TASK) + +- log.info("Successfully inited snapshot scheduler for this node") +- output("Successfully inited snapshot scheduler for this node") ++ log.info("Successfully initialised snapshot scheduler for this node") ++ output("Successfully initialised snapshot scheduler for this node") + + ret = 0 + return ret +-- +1.7.1 + diff --git a/SOURCES/0290-snapshot-Log-deletion-of-snapshot-during-auto-delete.patch b/SOURCES/0290-snapshot-Log-deletion-of-snapshot-during-auto-delete.patch new file mode 100644 index 0000000..663cc70 --- /dev/null +++ b/SOURCES/0290-snapshot-Log-deletion-of-snapshot-during-auto-delete.patch @@ -0,0 +1,68 @@ +From bafdf2a720fe14bf699793754d77168baa7cdc87 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Thu, 20 Aug 2015 14:40:29 +0530 +Subject: [PATCH 290/304] snapshot: Log deletion of snapshot, during auto-delete + +When auto-delete is enabled, and soft-limit is reached, +on creation of a snapshot, the oldest snapshot for that +volume is deleted. + +Displaying a warning log before deleting the oldest +snapshot. + +Change-Id: I75f0366935966a223b63a4ec5ac13f9fe36c0e82 +BUG: 1231080 +Signed-off-by: Avra Sengupta +Reviewed-on: http://review.gluster.org/11963 +Tested-by: NetBSD Build System +Reviewed-by: mohammed rafi kc +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/56045 +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-messages.h | 2 +- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 8 +++++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index 8f80e99..addd3e2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -776,7 +776,7 @@ + * @recommendedaction + * + */ +-#define GD_MSG_SNAPSHOT_OP_SUCCESS (GLUSTERD_COMP_BASE + 91) ++#define GD_MSG_OP_SUCCESS (GLUSTERD_COMP_BASE + 91) + + /*! + * @messageid +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 34cafd8..080aa88 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -5974,7 +5974,7 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr, + goto out; + } else + gf_msg (this->name, GF_LOG_INFO, 0, +- GD_MSG_SNAPSHOT_OP_SUCCESS, "Successfully marked " ++ GD_MSG_OP_SUCCESS, "Successfully marked " + "snap %s for decommission.", snap->snapname); + + if (is_origin_glusterd (dict) == _gf_true) { +@@ -7727,6 +7727,12 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict) + snap = tmp_volinfo->snapshot; + GF_ASSERT (snap); + ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_SOFT_LIMIT_REACHED, "Soft-limit " ++ "(value = %"PRIu64") of volume %s is reached. " ++ "Deleting snapshot %s.", limit, volinfo->volname, ++ snap->snapname); ++ + LOCK (&snap->lock); + { + snap->snap_status = GD_SNAP_STATUS_DECOMMISSION; +-- +1.7.1 + diff --git a/SOURCES/0291-snapshot-scheduler-Check-if-volume-exists-before-add.patch b/SOURCES/0291-snapshot-scheduler-Check-if-volume-exists-before-add.patch new file mode 100644 index 0000000..a991974 --- /dev/null +++ b/SOURCES/0291-snapshot-scheduler-Check-if-volume-exists-before-add.patch @@ -0,0 +1,146 @@ +From 64cfd2d7b3be3e79420c455273aa27b847e6fd83 Mon Sep 17 00:00:00 2001 +From: Avra Sengupta +Date: Wed, 5 Aug 2015 13:49:41 +0530 +Subject: [PATCH 291/304] snapshot/scheduler: Check if volume exists before adding/editing schedules + +Before adding or editing a scheduler, check if the volume name provided +in the schedule, exists in the cluster or not. + +Added return code VOLUME_DOES_NOT_EXIST(17) for the same. + +Change-Id: Ia3fe3cc1e1568ddd10f9193bbf40a098f0fe990a +BUG: 1245924 +Signed-off-by: Avra Sengupta +Reviewed-on: http://review.gluster.org/11830 +Tested-by: NetBSD Build System +Reviewed-by: mohammed rafi kc +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/56047 +Tested-by: Rajesh Joseph +--- + extras/snap_scheduler/snap_scheduler.py | 88 +++++++++++++++++++++++------- + 1 files changed, 67 insertions(+), 21 deletions(-) + +diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py +index f9cfc9e..af092e2 100755 +--- a/extras/snap_scheduler/snap_scheduler.py ++++ b/extras/snap_scheduler/snap_scheduler.py +@@ -53,6 +53,7 @@ INVALID_JOBNAME = 13 + INVALID_VOLNAME = 14 + INVALID_SCHEDULE = 15 + INVALID_ARG = 16 ++VOLUME_DOES_NOT_EXIST = 17 + + def output(msg): + print("%s: %s" % (SCRIPT_NAME, msg)) +@@ -324,6 +325,34 @@ def update_current_scheduler(data): + return ret + + ++def isVolumePresent(volname): ++ success = False ++ if volname == "": ++ log.debug("No volname given") ++ return success ++ ++ cli = ["gluster", ++ "volume", ++ "info", ++ volname] ++ log.debug("Running command '%s'", " ".join(cli)) ++ ++ p = subprocess.Popen(cli, stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ out, err = p.communicate() ++ rv = p.returncode ++ ++ log.debug("Command '%s' returned '%d'", " ".join(cli), rv) ++ ++ if rv: ++ log.error("Command output:") ++ log.error(err) ++ else: ++ success = True; ++ ++ return success ++ ++ + def add_schedules(jobname, schedule, volname): + log.info("Adding snapshot schedules.") + ret = load_tasks_from_file() +@@ -335,22 +364,31 @@ def add_schedules(jobname, schedule, volname): + output(print_str) + ret = JOB_ALREADY_EXISTS + else: +- tasks[jobname] = schedule + ":" + volname +- ret = write_tasks_to_file() +- if ret == 0: +- # Create a LOCK_FILE for the job +- job_lockfile = LOCK_FILE_DIR + jobname +- try: +- f = os.open(job_lockfile, os.O_CREAT | os.O_NONBLOCK, 0644) +- os.close(f) +- except OSError as (errno, strerror): +- log.error("Failed to open %s. Error: %s.", +- job_lockfile, strerror) +- ret = INTERNAL_ERROR +- return ret +- log.info("Successfully added snapshot schedule %s" % jobname) +- output("Successfully added snapshot schedule") +- ret = 0 ++ if not isVolumePresent(volname): ++ print_str = ("Volume %s does not exist. Create %s and retry." % ++ (volname, volname)) ++ log.error(print_str) ++ output(print_str) ++ ret = VOLUME_DOES_NOT_EXIST ++ else: ++ tasks[jobname] = schedule + ":" + volname ++ ret = write_tasks_to_file() ++ if ret == 0: ++ # Create a LOCK_FILE for the job ++ job_lockfile = LOCK_FILE_DIR + jobname ++ try: ++ f = os.open(job_lockfile, os.O_CREAT | os.O_NONBLOCK, ++ 0644) ++ os.close(f) ++ except OSError as (errno, strerror): ++ log.error("Failed to open %s. Error: %s.", ++ job_lockfile, strerror) ++ ret = INTERNAL_ERROR ++ return ret ++ log.info("Successfully added snapshot schedule %s" % ++ jobname) ++ output("Successfully added snapshot schedule") ++ ret = 0 + else: + print_str = "Failed to add snapshot schedule. " \ + "Error: Failed to load tasks from "+GCRON_ENABLED +@@ -401,11 +439,19 @@ def edit_schedules(jobname, schedule, volname): + ret = load_tasks_from_file() + if ret == 0: + if jobname in tasks: +- tasks[jobname] = schedule+":"+volname +- ret = write_tasks_to_file() +- if ret == 0: +- log.info("Successfully edited snapshot schedule %s" % jobname) +- output("Successfully edited snapshot schedule") ++ if not isVolumePresent(volname): ++ print_str = ("Volume %s does not exist. Create %s and retry." % ++ (volname, volname)) ++ log.error(print_str) ++ output(print_str) ++ ret = VOLUME_DOES_NOT_EXIST ++ else: ++ tasks[jobname] = schedule+":"+volname ++ ret = write_tasks_to_file() ++ if ret == 0: ++ log.info("Successfully edited snapshot schedule %s" % ++ jobname) ++ output("Successfully edited snapshot schedule") + else: + print_str = ("Failed to edit %s. Error: No such " + "job scheduled" % jobname) +-- +1.7.1 + diff --git a/SOURCES/0292-dht-block-handle-create-op-falling-to-decommissioned.patch b/SOURCES/0292-dht-block-handle-create-op-falling-to-decommissioned.patch new file mode 100644 index 0000000..82b7a30 --- /dev/null +++ b/SOURCES/0292-dht-block-handle-create-op-falling-to-decommissioned.patch @@ -0,0 +1,753 @@ +From 4c91b33219078226a3cccabc409b366f3bccfbc0 Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Tue, 16 Jun 2015 20:35:46 +0530 +Subject: [PATCH 292/304] dht: block/handle create op falling to decommissioned brick + +Problem: +Post remove-brick start till commit phase, the client layout +may not be in sync with disk layout because of lack of lookup. +Hence,a create call may fall on the decommissioned brick. + +Solution: +Will acquire a lock on hashed subvol. So that a fix-layout or +selfheal can not step on layout while reading the layout. + +Even if we read a layout before remove-brick fix-layout and the +file falls on the decommissioned brick, the file should be +migrated to a new brick as per the fix-layout. + +BUG: 1225452 +Change-Id: Ice13674d61522a64c92ba26fe402333335da0462 +Signed-off-by: Susant Palai +Reviewed-on: http://review.gluster.org/11260 +Tested-by: Gluster Build System +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/56166 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 456 +++++++++++++++++++++++++++---- + xlators/cluster/dht/src/dht-common.h | 11 + + xlators/cluster/dht/src/dht-diskusage.c | 25 ++- + xlators/cluster/dht/src/dht-linkfile.c | 2 +- + xlators/cluster/dht/src/dht-selfheal.c | 18 +- + 5 files changed, 455 insertions(+), 57 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 8b2715f..ebc183d 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -39,7 +39,6 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + + int run_defrag = 0; + +- + int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) + { +@@ -3505,7 +3504,6 @@ err: + return 0; + } + +- + static int + dht_common_setxattr_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno, +@@ -5462,9 +5460,6 @@ dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int ret = -1; + dht_local_t *local = NULL; + +- if (op_ret == -1) +- goto out; +- + local = frame->local; + if (!local) { + op_ret = -1; +@@ -5472,6 +5467,9 @@ dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + goto out; + } + ++ if (op_ret == -1) ++ goto out; ++ + prev = cookie; + + if (local->loc.parent) { +@@ -5491,18 +5489,34 @@ dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + op_errno = EINVAL; + goto out; + } ++ ++ local->op_errno = op_errno; ++ + if (local->linked == _gf_true) { + local->stbuf = *stbuf; + dht_linkfile_attr_heal (frame, this); + } + out: ++ + DHT_STRIP_PHASE1_FLAGS (stbuf); +- DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, stbuf, preparent, +- postparent, xdata); ++ ++ if (local && local->lock.locks) { ++ /* store op_errno for failure case*/ ++ local->op_errno = op_errno; ++ local->refresh_layout_unlock (frame, this, op_ret); ++ ++ if (op_ret == 0) { ++ DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, ++ inode, stbuf, preparent, postparent, ++ xdata); ++ } ++ } else { ++ DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, ++ stbuf, preparent, postparent, xdata); ++ } + return 0; + } + +- + int + dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, +@@ -5514,8 +5528,10 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + dht_local_t *local = NULL; + xlator_t *cached_subvol = NULL; + +- if (op_ret == -1) ++ if (op_ret == -1) { ++ local->op_errno = op_errno; + goto err; ++ } + + local = frame->local; + cached_subvol = local->cached_subvol; +@@ -5527,25 +5543,327 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + + return 0; + err: +- DHT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL, +- NULL, NULL, NULL); ++ if (local->lock.locks) ++ local->refresh_layout_unlock (frame, this, -1); ++ ++ return 0; ++} ++ ++int ++dht_create_wind_to_avail_subvol (call_frame_t *frame, xlator_t *this, ++ xlator_t *subvol, loc_t *loc, int32_t flags, ++ mode_t mode, mode_t umask, fd_t *fd, ++ dict_t *params) ++{ ++ dht_local_t *local = NULL; ++ xlator_t *avail_subvol = NULL; ++ ++ local = frame->local; ++ ++ if (!dht_is_subvol_filled (this, subvol)) { ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s", loc->path, ++ subvol->name); ++ ++ STACK_WIND (frame, dht_create_cbk, ++ subvol, subvol->fops->create, ++ loc, flags, mode, umask, fd, params); ++ ++ } else { ++ avail_subvol = dht_free_disk_available_subvol (this, subvol, local); ++ ++ if (avail_subvol != subvol) { ++ local->params = dict_ref (params); ++ local->flags = flags; ++ local->mode = mode; ++ local->umask = umask; ++ local->cached_subvol = avail_subvol; ++ local->hashed_subvol = subvol; ++ ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s (link at %s)", loc->path, ++ avail_subvol->name, subvol->name); ++ ++ dht_linkfile_create (frame, dht_create_linkfile_create_cbk, ++ this, avail_subvol, subvol, loc); ++ ++ goto out; ++ } ++ ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s", loc->path, subvol->name); ++ ++ STACK_WIND (frame, dht_create_cbk, ++ subvol, subvol->fops->create, ++ loc, flags, mode, umask, fd, params); ++ } ++out: + return 0; + } + + int ++dht_build_parent_loc (xlator_t *this, loc_t *parent, loc_t *child, ++ int32_t *op_errno) ++{ ++ inode_table_t *table = NULL; ++ int ret = -1; ++ ++ if (!parent || !child) { ++ if (op_errno) ++ *op_errno = EINVAL; ++ goto out; ++ } ++ ++ if (child->parent) { ++ parent->inode = inode_ref (child->parent); ++ if (!parent->inode) { ++ if (op_errno) ++ *op_errno = EINVAL; ++ goto out; ++ } ++ ++ gf_uuid_copy (parent->gfid, child->pargfid); ++ ++ ret = 0; ++ ++ goto out; ++ } else { ++ if (gf_uuid_is_null (child->pargfid)) { ++ if (op_errno) ++ *op_errno = EINVAL; ++ goto out; ++ } ++ ++ table = this->itable; ++ ++ if (!table) { ++ if (op_errno) { ++ *op_errno = EINVAL; ++ goto out; ++ } ++ } ++ ++ parent->inode = inode_find (table, child->pargfid); ++ ++ if (!parent->inode) { ++ if (op_errno) { ++ *op_errno = EINVAL; ++ goto out; ++ } ++ } ++ ++ gf_uuid_copy (parent->gfid, child->pargfid); ++ ++ ret = 0; ++ } ++ ++out: ++ return ret; ++} ++ ++ ++int32_t ++dht_create_do (call_frame_t *frame) ++{ ++ dht_local_t *local = NULL; ++ dht_layout_t *refreshed = NULL; ++ xlator_t *subvol = NULL; ++ xlator_t *this = NULL; ++ dht_conf_t *conf = NULL; ++ dht_methods_t *methods = NULL; ++ ++ local = frame->local; ++ ++ this = THIS; ++ ++ conf = this->private; ++ ++ GF_VALIDATE_OR_GOTO (this->name, conf, err); ++ ++ methods = conf->methods; ++ ++ GF_VALIDATE_OR_GOTO (this->name, conf->methods, err); ++ ++ /* We don't need parent_loc anymore */ ++ loc_wipe (&local->loc); ++ ++ loc_copy (&local->loc, &local->loc2); ++ ++ loc_wipe (&local->loc2); ++ ++ refreshed = local->selfheal.refreshed_layout; ++ ++ subvol = methods->layout_search (this, refreshed, local->loc.name); ++ ++ if (!subvol) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_HASHED_SUBVOL_GET_FAILED, "no subvolume in " ++ "layout for path=%s", local->loc.path); ++ local->op_errno = ENOENT; ++ goto err; ++ } ++ ++ dht_create_wind_to_avail_subvol (frame, this, subvol, &local->loc, ++ local->flags, local->mode, ++ local->umask, local->fd, local->params); ++ return 0; ++err: ++ local->refresh_layout_unlock (frame, this, -1); ++ ++ return 0; ++} ++ ++int32_t ++dht_create_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ DHT_STACK_DESTROY (frame); ++ return 0; ++} ++ ++int32_t ++dht_create_finish (call_frame_t *frame, xlator_t *this, int op_ret) ++{ ++ dht_local_t *local = NULL, *lock_local = NULL; ++ call_frame_t *lock_frame = NULL; ++ int lock_count = 0; ++ ++ local = frame->local; ++ lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); ++ if (lock_count == 0) ++ goto done; ++ ++ lock_frame = copy_frame (frame); ++ if (lock_frame == NULL) { ++ goto done; ++ } ++ ++ lock_local = dht_local_init (lock_frame, &local->loc, NULL, ++ lock_frame->root->op); ++ if (lock_local == NULL) { ++ goto done; ++ } ++ ++ lock_local->lock.locks = local->lock.locks; ++ lock_local->lock.lk_count = local->lock.lk_count; ++ ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ ++ dht_unlock_inodelk (lock_frame, lock_local->lock.locks, ++ lock_local->lock.lk_count, ++ dht_create_unlock_cbk); ++ lock_frame = NULL; ++ ++done: ++ if (lock_frame != NULL) { ++ DHT_STACK_DESTROY (lock_frame); ++ } ++ ++ if (op_ret == 0) ++ return 0; ++ ++ DHT_STACK_UNWIND (create, frame, op_ret, local->op_errno, NULL, NULL, ++ NULL, NULL, NULL, NULL); ++ return 0; ++} ++ ++int32_t ++dht_create_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ dht_local_t *local = NULL; ++ ++ local = frame->local; ++ ++ if (!local) { ++ goto err; ++ } ++ ++ if (op_ret < 0) { ++ gf_msg ("DHT", GF_LOG_ERROR, 0, DHT_MSG_INODE_LK_ERROR, ++ "Create lock failed for file: %s", local->loc2.name); ++ ++ local->op_errno = op_errno; ++ ++ goto err; ++ } ++ ++ local->refresh_layout_unlock = dht_create_finish; ++ ++ local->refresh_layout_done = dht_create_do; ++ ++ dht_refresh_layout (frame); ++ ++ return 0; ++err: ++ dht_create_finish (frame, this, -1); ++ return 0; ++} ++ ++int32_t ++dht_create_lock (call_frame_t *frame, xlator_t *subvol) ++{ ++ dht_local_t *local = NULL; ++ int count = 1, ret = -1; ++ dht_lock_t **lk_array = NULL; ++ ++ GF_VALIDATE_OR_GOTO ("dht", frame, err); ++ GF_VALIDATE_OR_GOTO (frame->this->name, frame->local, err); ++ ++ local = frame->local; ++ ++ lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); ++ ++ if (lk_array == NULL) ++ goto err; ++ ++ lk_array[0] = dht_lock_new (frame->this, subvol, &local->loc, F_RDLCK, ++ DHT_LAYOUT_HEAL_DOMAIN); ++ ++ if (lk_array[0] == NULL) ++ goto err; ++ ++ local->lock.locks = lk_array; ++ local->lock.lk_count = count; ++ ++ ret = dht_blocking_inodelk (frame, lk_array, count, ++ dht_create_lock_cbk); ++ ++ if (ret < 0) { ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ goto err; ++ } ++ ++ return 0; ++err: ++ if (lk_array != NULL) { ++ dht_lock_array_free (lk_array, count); ++ GF_FREE (lk_array); ++ } ++ ++ return -1; ++} ++ ++int + dht_create (call_frame_t *frame, xlator_t *this, + loc_t *loc, int32_t flags, mode_t mode, + mode_t umask, fd_t *fd, dict_t *params) + { +- int op_errno = -1; +- xlator_t *subvol = NULL; +- dht_local_t *local = NULL; +- xlator_t *avail_subvol = NULL; ++ int op_errno = -1; ++ xlator_t *subvol = NULL; ++ dht_local_t *local = NULL; ++ int i = 0; ++ dht_conf_t *conf = NULL; ++ int ret = 0; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (loc, err); + ++ conf = this->private; ++ + dht_get_du_info (frame, this, loc); + + local = dht_local_init (frame, loc, fd, GF_FOP_CREATE); +@@ -5568,48 +5886,90 @@ dht_create (call_frame_t *frame, xlator_t *this, + + subvol = dht_subvol_get_hashed (this, loc); + if (!subvol) { +- gf_msg_debug (this->name, 0, +- "no subvolume in layout for path=%s", +- loc->path); ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_HASHED_SUBVOL_GET_FAILED, ++ "no subvolume in layout for path=%s", ++ loc->path); ++ + op_errno = ENOENT; + goto err; + } + +- if (!dht_is_subvol_filled (this, subvol)) { +- gf_msg_trace (this->name, 0, +- "creating %s on %s", loc->path, +- subvol->name); +- STACK_WIND (frame, dht_create_cbk, +- subvol, subvol->fops->create, +- loc, flags, mode, umask, fd, params); +- goto done; +- } +- /* Choose the minimum filled volume, and create the +- files there */ +- avail_subvol = dht_free_disk_available_subvol (this, subvol, local); +- if (avail_subvol != subvol) { +- local->params = dict_ref (params); +- local->flags = flags; +- local->mode = mode; +- local->umask = umask; +- local->cached_subvol = avail_subvol; +- local->hashed_subvol = subvol; +- gf_msg_trace (this->name, 0, +- "creating %s on %s (link at %s)", loc->path, +- avail_subvol->name, subvol->name); +- dht_linkfile_create (frame, dht_create_linkfile_create_cbk, +- this, avail_subvol, subvol, loc); +- goto done; ++ /* Post remove-brick, the client layout may not be in sync with ++ * disk layout because of lack of lookup. Hence,a create call ++ * may fall on the decommissioned brick. Hence, if the ++ * hashed_subvol is part of decommissioned bricks list, do a ++ * lookup on parent dir. If a fix-layout is already done by the ++ * remove-brick process, the parent directory layout will be in ++ * sync with that of the disk. If fix-layout is still ending ++ * on the parent directory, we can let the file get created on ++ * the decommissioned brick which will be eventually migrated to ++ * non-decommissioned brick based on the new layout. ++ */ ++ ++ if (conf->decommission_subvols_cnt) { ++ for (i = 0; i < conf->subvolume_cnt; i++) { ++ if (conf->decommissioned_bricks[i] && ++ conf->decommissioned_bricks[i] == subvol) { ++ ++ gf_msg_debug (this->name, 0, "hashed subvol:%s is " ++ "part of decommission brick list for " ++ "file: %s", subvol->name, loc->path); ++ ++ /* dht_refresh_layout needs directory info in ++ * local->loc. Hence, storing the parent_loc in ++ * local->loc and storing the create context in ++ * local->loc2. We will restore this information ++ * in dht_creation do */ ++ ++ ret = loc_copy (&local->loc2, &local->loc); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, ++ "loc_copy failed %s", loc->path); ++ ++ goto err; ++ } ++ ++ local->params = dict_ref (params); ++ local->flags = flags; ++ local->mode = mode; ++ local->umask = umask; ++ ++ loc_wipe (&local->loc); ++ ++ ret = dht_build_parent_loc (this, &local->loc, loc, ++ &op_errno); ++ ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, ++ "parent loc build failed"); ++ goto err; ++ } ++ ++ ret = dht_create_lock (frame, subvol); ++ ++ if (ret < 0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_INODE_LK_ERROR, ++ "locking parent failed"); ++ goto err; ++ } ++ ++ goto done; ++ } ++ } + } +- gf_msg_trace (this->name, 0, +- "creating %s on %s", loc->path, subvol->name); +- STACK_WIND (frame, dht_create_cbk, +- subvol, subvol->fops->create, +- loc, flags, mode, umask, fd, params); ++ ++ ++ dht_create_wind_to_avail_subvol (frame, this, subvol, loc, flags, mode, ++ umask, fd, params); + done: + return 0; + + err: ++ + op_errno = (op_errno == -1) ? errno : op_errno; + DHT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL, + NULL, NULL, NULL); +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 5e86b32..f583d30 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -44,6 +44,10 @@ typedef int (*dht_selfheal_dir_cbk_t) (call_frame_t *frame, void *cookie, + typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, xlator_t *dst_node, + call_frame_t *frame); + ++typedef int (*dht_refresh_layout_unlock) (call_frame_t *frame, xlator_t *this, ++ int op_ret); ++ ++typedef int (*dht_refresh_layout_done_handle) (call_frame_t *frame); + + struct dht_layout { + int spread_cnt; /* layout spread count per directory, +@@ -212,6 +216,10 @@ struct dht_local { + gf_boolean_t force_mkdir; + dht_layout_t *layout, *refreshed_layout; + } selfheal; ++ ++ dht_refresh_layout_unlock refresh_layout_unlock; ++ dht_refresh_layout_done_handle refresh_layout_done; ++ + uint32_t uid; + uint32_t gid; + +@@ -510,6 +518,7 @@ typedef struct dht_migrate_info { + GF_REF_DECL; + } dht_migrate_info_t; + ++ + #define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT) + + #define is_revalidate(loc) (dht_inode_ctx_layout_get (loc->inode, this, NULL) == 0) +@@ -1067,4 +1076,6 @@ dht_layout_sort (dht_layout_t *layout); + int + dht_layout_missing_dirs (dht_layout_t *layout); + ++int ++dht_refresh_layout (call_frame_t *frame); + #endif/* _DHT_H */ +diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c +index 000494c..2a9ad37 100644 +--- a/xlators/cluster/dht/src/dht-diskusage.c ++++ b/xlators/cluster/dht/src/dht-diskusage.c +@@ -339,7 +339,8 @@ out: + } + + static inline +-int32_t dht_subvol_has_err (xlator_t *this, dht_layout_t *layout) ++int32_t dht_subvol_has_err (dht_conf_t *conf, xlator_t *this, ++ dht_layout_t *layout) + { + int ret = -1; + int i = 0; +@@ -355,6 +356,17 @@ int32_t dht_subvol_has_err (xlator_t *this, dht_layout_t *layout) + goto out; + } + } ++ ++ /* discard decommissioned subvol */ ++ if (conf->decommission_subvols_cnt) { ++ for (i = 0; i < conf->subvolume_cnt; i++) { ++ if (conf->decommissioned_bricks[i] && ++ conf->decommissioned_bricks[i] == this) ++ ret = -1; ++ goto out; ++ } ++ } ++ + ret = 0; + out: + return ret; +@@ -376,8 +388,9 @@ dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol, + conf = this->private; + + for(i=0; i < conf->subvolume_cnt; i++) { +- /* check if subvol has layout errors, before selecting it */ +- ignore_subvol = dht_subvol_has_err (conf->subvolumes[i], ++ /* check if subvol has layout errors and also it is not a ++ * decommissioned brick, before selecting it */ ++ ignore_subvol = dht_subvol_has_err (conf, conf->subvolumes[i], + layout); + if (ignore_subvol) + continue; +@@ -424,8 +437,10 @@ dht_subvol_maxspace_nonzeroinode (xlator_t *this, xlator_t *subvol, + conf = this->private; + + for (i = 0; i < conf->subvolume_cnt; i++) { +- /* check if subvol has layout errors, before selecting it */ +- ignore_subvol = dht_subvol_has_err (conf->subvolumes[i], ++ /* check if subvol has layout errors and also it is not a ++ * decommissioned brick, before selecting it*/ ++ ++ ignore_subvol = dht_subvol_has_err (conf, conf->subvolumes[i], + layout); + if (ignore_subvol) + continue; +diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c +index a247170..a3e6d99 100644 +--- a/xlators/cluster/dht/src/dht-linkfile.c ++++ b/xlators/cluster/dht/src/dht-linkfile.c +@@ -120,7 +120,7 @@ dht_linkfile_create (call_frame_t *frame, fop_mknod_cbk_t linkfile_cbk, + int need_unref = 0; + int ret = 0; + dht_conf_t *conf = this->private; +- char gfid[GF_UUID_BUF_SIZE] = {0}; ++ char gfid[GF_UUID_BUF_SIZE] = {0}; + + local = frame->local; + local->linkfile.linkfile_cbk = linkfile_cbk; +diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c +index cfe7e5a..cd1d97f 100644 +--- a/xlators/cluster/dht/src/dht-selfheal.c ++++ b/xlators/cluster/dht/src/dht-selfheal.c +@@ -214,7 +214,7 @@ unlock: + + if (is_last_call (this_call_cnt)) { + if (local->op_ret == 0) { +- dht_refresh_layout_done (frame); ++ local->refresh_layout_done (frame); + } else { + goto err; + } +@@ -224,7 +224,8 @@ unlock: + return 0; + + err: +- dht_selfheal_dir_finish (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1); ++ + return 0; + } + +@@ -290,7 +291,7 @@ dht_refresh_layout (call_frame_t *frame) + return 0; + + out: +- dht_selfheal_dir_finish (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1); + return 0; + } + +@@ -299,10 +300,21 @@ int32_t + dht_selfheal_layout_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) + { ++ dht_local_t *local = NULL; ++ ++ local = frame->local; ++ ++ if (!local) { ++ goto err; ++ } ++ + if (op_ret < 0) { + goto err; + } + ++ local->refresh_layout_unlock = dht_selfheal_dir_finish; ++ local->refresh_layout_done = dht_refresh_layout_done; ++ + dht_refresh_layout (frame); + return 0; + +-- +1.7.1 + diff --git a/SOURCES/0293-cluster-dht-avoid-mknod-on-decommissioned-brick.patch b/SOURCES/0293-cluster-dht-avoid-mknod-on-decommissioned-brick.patch new file mode 100644 index 0000000..4ab83c0 --- /dev/null +++ b/SOURCES/0293-cluster-dht-avoid-mknod-on-decommissioned-brick.patch @@ -0,0 +1,448 @@ +From 3095da8cb7b78a755700b6edfaa9fab20d98df2b Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Mon, 24 Aug 2015 03:04:41 -0400 +Subject: [PATCH 293/304] cluster/dht: avoid mknod on decommissioned brick + +BUG: 1225452 +Change-Id: I838bce1a28d53d437def149d85d6e1770a292f19 +Signed-off-by: Susant Palai +Reviewed-on: http://review.gluster.org/11998 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Raghavendra G +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/56186 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 366 ++++++++++++++++++++++++++++++---- + xlators/cluster/dht/src/dht-common.h | 5 + + 2 files changed, 335 insertions(+), 36 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index ebc183d..5c1a693 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -4995,8 +4995,22 @@ out: + * See dht_iatt_merge for reference. + */ + DHT_STRIP_PHASE1_FLAGS (stbuf); +- DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, stbuf, +- preparent, postparent, xdata); ++ ++ if (local && local->lock.locks) { ++ /* store op_errno for failure case*/ ++ local->op_errno = op_errno; ++ local->refresh_layout_unlock (frame, this, op_ret); ++ ++ if (op_ret == 0) { ++ DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, ++ inode, stbuf, preparent, postparent, ++ xdata); ++ } ++ } else { ++ DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, ++ stbuf, preparent, postparent, xdata); ++ } ++ + return 0; + } + +@@ -5029,24 +5043,269 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + + return 0; + err: +- DHT_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL, +- NULL); ++ if (local->lock.locks) ++ local->refresh_layout_unlock (frame, this, -1); ++ + return 0; + } + + int ++dht_mknod_wind_to_avail_subvol (call_frame_t *frame, xlator_t *this, ++ xlator_t *subvol, loc_t *loc, dev_t rdev, ++ mode_t mode, mode_t umask, dict_t *params) ++{ ++ dht_local_t *local = NULL; ++ xlator_t *avail_subvol = NULL; ++ ++ local = frame->local; ++ ++ if (!dht_is_subvol_filled (this, subvol)) { ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s", loc->path, ++ subvol->name); ++ ++ STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)subvol, ++ subvol, subvol->fops->mknod, loc, mode, ++ rdev, umask, params); ++ } else { ++ avail_subvol = dht_free_disk_available_subvol (this, subvol, local); ++ ++ if (avail_subvol != subvol) { ++ local->params = dict_ref (params); ++ local->rdev = rdev; ++ local->mode = mode; ++ local->umask = umask; ++ local->cached_subvol = avail_subvol; ++ local->hashed_subvol = subvol; ++ ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s (link at %s)", loc->path, ++ avail_subvol->name, subvol->name); ++ ++ dht_linkfile_create (frame, ++ dht_mknod_linkfile_create_cbk, ++ this, avail_subvol, subvol, loc); ++ ++ goto out; ++ } ++ ++ gf_msg_debug (this->name, 0, ++ "creating %s on %s", loc->path, subvol->name); ++ ++ STACK_WIND_COOKIE (frame, dht_newfile_cbk, ++ (void *)subvol, subvol, ++ subvol->fops->mknod, loc, mode, ++ rdev, umask, params); ++ ++ } ++out: ++ return 0; ++} ++ ++ ++int32_t ++dht_mknod_do (call_frame_t *frame) ++{ ++ dht_local_t *local = NULL; ++ dht_layout_t *refreshed = NULL; ++ xlator_t *subvol = NULL; ++ xlator_t *this = NULL; ++ dht_conf_t *conf = NULL; ++ dht_methods_t *methods = NULL; ++ ++ local = frame->local; ++ ++ this = THIS; ++ ++ conf = this->private; ++ ++ GF_VALIDATE_OR_GOTO (this->name, conf, err); ++ ++ methods = conf->methods; ++ ++ GF_VALIDATE_OR_GOTO (this->name, conf->methods, err); ++ ++ /* We don't need parent_loc anymore */ ++ loc_wipe (&local->loc); ++ ++ loc_copy (&local->loc, &local->loc2); ++ ++ loc_wipe (&local->loc2); ++ ++ refreshed = local->selfheal.refreshed_layout; ++ ++ subvol = methods->layout_search (this, refreshed, local->loc.name); ++ ++ if (!subvol) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_HASHED_SUBVOL_GET_FAILED, "no subvolume in " ++ "layout for path=%s", local->loc.path); ++ local->op_errno = ENOENT; ++ goto err; ++ } ++ ++ dht_mknod_wind_to_avail_subvol (frame, this, subvol, &local->loc, ++ local->rdev, local->mode, ++ local->umask, local->params); ++ return 0; ++err: ++ local->refresh_layout_unlock (frame, this, -1); ++ ++ return 0; ++} ++ ++ ++int32_t ++dht_mknod_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ DHT_STACK_DESTROY (frame); ++ return 0; ++} ++ ++int32_t ++dht_mknod_finish (call_frame_t *frame, xlator_t *this, int op_ret) ++{ ++ dht_local_t *local = NULL, *lock_local = NULL; ++ call_frame_t *lock_frame = NULL; ++ int lock_count = 0; ++ ++ local = frame->local; ++ lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); ++ if (lock_count == 0) ++ goto done; ++ ++ lock_frame = copy_frame (frame); ++ if (lock_frame == NULL) { ++ goto done; ++ } ++ ++ lock_local = dht_local_init (lock_frame, &local->loc, NULL, ++ lock_frame->root->op); ++ if (lock_local == NULL) { ++ goto done; ++ } ++ ++ lock_local->lock.locks = local->lock.locks; ++ lock_local->lock.lk_count = local->lock.lk_count; ++ ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ ++ dht_unlock_inodelk (lock_frame, lock_local->lock.locks, ++ lock_local->lock.lk_count, ++ dht_mknod_unlock_cbk); ++ lock_frame = NULL; ++ ++done: ++ if (lock_frame != NULL) { ++ DHT_STACK_DESTROY (lock_frame); ++ } ++ ++ if (op_ret == 0) ++ return 0; ++ ++ DHT_STACK_UNWIND (mknod, frame, op_ret, local->op_errno, NULL, NULL, ++ NULL, NULL, NULL); ++ return 0; ++} ++ ++int32_t ++dht_mknod_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ dht_local_t *local = NULL; ++ ++ local = frame->local; ++ ++ if (!local) { ++ goto err; ++ } ++ ++ if (op_ret < 0) { ++ gf_msg ("DHT", GF_LOG_ERROR, 0, DHT_MSG_INODE_LK_ERROR, ++ "mknod lock failed for file: %s", local->loc2.name); ++ ++ local->op_errno = op_errno; ++ ++ goto err; ++ } ++ ++ local->refresh_layout_unlock = dht_mknod_finish; ++ ++ local->refresh_layout_done = dht_mknod_do; ++ ++ dht_refresh_layout (frame); ++ ++ return 0; ++err: ++ dht_mknod_finish (frame, this, -1); ++ return 0; ++} ++ ++int32_t ++dht_mknod_lock (call_frame_t *frame, xlator_t *subvol) ++{ ++ dht_local_t *local = NULL; ++ int count = 1, ret = -1; ++ dht_lock_t **lk_array = NULL; ++ ++ GF_VALIDATE_OR_GOTO ("dht", frame, err); ++ GF_VALIDATE_OR_GOTO (frame->this->name, frame->local, err); ++ ++ local = frame->local; ++ ++ lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); ++ ++ if (lk_array == NULL) ++ goto err; ++ ++ lk_array[0] = dht_lock_new (frame->this, subvol, &local->loc, F_RDLCK, ++ DHT_LAYOUT_HEAL_DOMAIN); ++ ++ if (lk_array[0] == NULL) ++ goto err; ++ ++ local->lock.locks = lk_array; ++ local->lock.lk_count = count; ++ ++ ret = dht_blocking_inodelk (frame, lk_array, count, ++ dht_mknod_lock_cbk); ++ ++ if (ret < 0) { ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ goto err; ++ } ++ ++ return 0; ++err: ++ if (lk_array != NULL) { ++ dht_lock_array_free (lk_array, count); ++ GF_FREE (lk_array); ++ } ++ ++ return -1; ++} ++ ++ ++int + dht_mknod (call_frame_t *frame, xlator_t *this, + loc_t *loc, mode_t mode, dev_t rdev, mode_t umask, dict_t *params) + { +- xlator_t *subvol = NULL; +- int op_errno = -1; +- xlator_t *avail_subvol = NULL; +- dht_local_t *local = NULL; ++ xlator_t *subvol = NULL; ++ int op_errno = -1; ++ int i = 0; ++ int ret = 0; ++ dht_local_t *local = NULL; ++ dht_conf_t *conf = NULL; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (loc, err); + ++ conf = this->private; ++ + dht_get_du_info (frame, this, loc); + + local = dht_local_init (frame, loc, NULL, GF_FOP_MKNOD); +@@ -5064,42 +5323,77 @@ dht_mknod (call_frame_t *frame, xlator_t *this, + goto err; + } + +- if (!dht_is_subvol_filled (this, subvol)) { +- gf_msg_trace (this->name, 0, +- "creating %s on %s", loc->path, +- subvol->name); ++ /* Post remove-brick, the client layout may not be in sync with ++ * disk layout because of lack of lookup. Hence,a mknod call ++ * may fall on the decommissioned brick. Hence, if the ++ * hashed_subvol is part of decommissioned bricks list, do a ++ * lookup on parent dir. If a fix-layout is already done by the ++ * remove-brick process, the parent directory layout will be in ++ * sync with that of the disk. If fix-layout is still ending ++ * on the parent directory, we can let the file get created on ++ * the decommissioned brick which will be eventually migrated to ++ * non-decommissioned brick based on the new layout. ++ */ + +- STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)subvol, +- subvol, subvol->fops->mknod, loc, mode, +- rdev, umask, params); +- } else { ++ if (conf->decommission_subvols_cnt) { ++ for (i = 0; i < conf->subvolume_cnt; i++) { ++ if (conf->decommissioned_bricks[i] && ++ conf->decommissioned_bricks[i] == subvol) { + +- avail_subvol = dht_free_disk_available_subvol (this, subvol, +- local); +- if (avail_subvol != subvol) { +- /* Choose the minimum filled volume, and create the +- files there */ ++ gf_msg_debug (this->name, 0, "hashed subvol:%s is " ++ "part of decommission brick list for " ++ "file: %s", subvol->name, loc->path); ++ ++ /* dht_refresh_layout needs directory info in ++ * local->loc. Hence, storing the parent_loc in ++ * local->loc and storing the create context in ++ * local->loc2. We will restore this information ++ * in dht_creation do */ ++ ++ ret = loc_copy (&local->loc2, &local->loc); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, ++ "loc_copy failed %s", loc->path); ++ ++ goto err; ++ } + + local->params = dict_ref (params); +- local->cached_subvol = avail_subvol; +- local->mode = mode; + local->rdev = rdev; ++ local->mode = mode; + local->umask = umask; +- dht_linkfile_create (frame, +- dht_mknod_linkfile_create_cbk, +- this, avail_subvol, subvol, loc); +- } else { +- gf_msg_trace (this->name, 0, +- "creating %s on %s", loc->path, +- subvol->name); + +- STACK_WIND_COOKIE (frame, dht_newfile_cbk, +- (void *)subvol, subvol, +- subvol->fops->mknod, loc, mode, +- rdev, umask, params); +- } ++ loc_wipe (&local->loc); ++ ++ ret = dht_build_parent_loc (this, &local->loc, loc, ++ &op_errno); ++ ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, ++ DHT_MSG_NO_MEMORY, ++ "parent loc build failed"); ++ goto err; ++ } ++ ++ ret = dht_mknod_lock (frame, subvol); ++ ++ if (ret < 0) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ DHT_MSG_INODE_LK_ERROR, ++ "locking parent failed"); ++ goto err; ++ } ++ ++ goto done; ++ } ++ } + } + ++ dht_mknod_wind_to_avail_subvol (frame, this, subvol, loc, rdev, mode, ++ umask, params); ++ ++done: + return 0; + + err: +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index f583d30..1b5a084 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -1078,4 +1078,9 @@ dht_layout_missing_dirs (dht_layout_t *layout); + + int + dht_refresh_layout (call_frame_t *frame); ++ ++int ++dht_build_parent_loc (xlator_t *this, loc_t *parent, loc_t *child, ++ int32_t *op_errno); ++ + #endif/* _DHT_H */ +-- +1.7.1 + diff --git a/SOURCES/0294-afr-modify-afr_txn_nothing_failed.patch b/SOURCES/0294-afr-modify-afr_txn_nothing_failed.patch new file mode 100644 index 0000000..f68d78b --- /dev/null +++ b/SOURCES/0294-afr-modify-afr_txn_nothing_failed.patch @@ -0,0 +1,176 @@ +From d2c8c165deb86082a13c15cc33d558336ff22d14 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Tue, 4 Aug 2015 18:37:47 +0530 +Subject: [PATCH 294/304] afr: modify afr_txn_nothing_failed() + +Patch in master: http://review.gluster.org/#/c/11827/ +Patch in release-3.7: http://review.gluster.org/#/c/11985/ +In an AFR transaction, we need to consider something as failed only if the +failure (either in the pre-op or the FOP phase) occurs on the bricks on which a +transaction lock was obtained. + +Without this, we would end up considering the transaction as failure even on the +bricks on which the lock was not obtained, resulting in unnecessary fsyncs +during the post-op phase of every write transaction for non-appending writes. + +Change-Id: I02efa64f6cf80fcc3cb8dd6a9543dbf480b866b9 +BUG: 1227759 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/56256 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/bugs/replicate/bug-1250170-fsync.c | 56 +++++++++++++++++++++++++++++ + tests/bugs/replicate/bug-1250170-fsync.t | 35 ++++++++++++++++++ + xlators/cluster/afr/src/afr-transaction.c | 15 ++------ + 3 files changed, 94 insertions(+), 12 deletions(-) + create mode 100644 tests/bugs/replicate/bug-1250170-fsync.c + create mode 100644 tests/bugs/replicate/bug-1250170-fsync.t + +diff --git a/tests/bugs/replicate/bug-1250170-fsync.c b/tests/bugs/replicate/bug-1250170-fsync.c +new file mode 100644 +index 0000000..1d3025b +--- /dev/null ++++ b/tests/bugs/replicate/bug-1250170-fsync.c +@@ -0,0 +1,56 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++int main (int argc, char **argv) ++{ ++ char *file = NULL; ++ int fd = -1; ++ char *buffer = NULL; ++ size_t buf_size = 0; ++ size_t written = 0; ++ int ret = 0; ++ off_t offset = 0; ++ int i = 0; ++ int loop_count = 5; ++ ++ if (argc < 2) { ++ printf ("Usage:%s \n", argv[0]); ++ return -1; ++ } ++ ++ file = argv[1]; ++ buf_size = 1024; ++ buffer = calloc(1, buf_size); ++ if (!buffer) { ++ perror("calloc"); ++ return -1; ++ } ++ memset (buffer, 'R', buf_size); ++ ++ fd = open(file, O_WRONLY); ++ if (fd == -1) { ++ perror("open"); ++ return -1; ++ } ++ ++ for (i = 0; i < loop_count; i++) { ++ ret = write (fd, buffer, buf_size); ++ if (ret == -1) { ++ perror("write"); ++ return ret; ++ } else { ++ written += ret; ++ } ++ offset = lseek (fd, 0 , SEEK_SET); ++ } ++ ++ free(buffer); ++ return 0; ++ ++} +diff --git a/tests/bugs/replicate/bug-1250170-fsync.t b/tests/bugs/replicate/bug-1250170-fsync.t +new file mode 100644 +index 0000000..7a3fdbf +--- /dev/null ++++ b/tests/bugs/replicate/bug-1250170-fsync.t +@@ -0,0 +1,35 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++TEST gcc $(dirname $0)/bug-1250170-fsync.c -o $(dirname $0)/bug-1250170-fsync ++TEST glusterd ++TEST pidof glusterd ++ ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume set $V0 performance.write-behind off ++TEST $CLI volume start $V0 ++TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0; ++ ++TEST touch $M0/file ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++TEST gluster volume profile $V0 start ++#Perform 5 non-sequential writes. ++TEST $(dirname $0)/bug-1250170-fsync $M0/file ++ ++#Run profile info initially to filter out the interval statistics in the ++#subsequent runs. ++TEST $CLI volume profile $V0 info ++#We get only cumulative statistics. ++write_count=$($CLI volume profile $V0 info | grep WRITE |awk '{count += $8} END {print count}') ++fsync_count=$($CLI volume profile $V0 info | grep FSYNC |awk '{count += $8} END {print count}') ++ ++EXPECT "5" echo $write_count ++TEST [ -z $fsync_count ] ++ ++TEST $CLI volume profile $V0 stop ++TEST umount $M0 ++rm -f $(dirname $0)/bug-1250170-fsync ++cleanup +diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c +index ba50abd..d773b5a 100644 +--- a/xlators/cluster/afr/src/afr-transaction.c ++++ b/xlators/cluster/afr/src/afr-transaction.c +@@ -493,18 +493,14 @@ afr_txn_nothing_failed (call_frame_t *frame, xlator_t *this) + { + afr_private_t *priv = NULL; + afr_local_t *local = NULL; +- int pre_op_count = 0; + int i = 0; + + local = frame->local; + priv = this->private; + +- pre_op_count = AFR_COUNT (local->transaction.pre_op, priv->child_count); +- if (pre_op_count < priv->child_count) +- return _gf_false; +- + for (i = 0; i < priv->child_count; i++) { +- if (local->transaction.failed_subvols[i]) ++ if (local->transaction.pre_op[i] && ++ local->transaction.failed_subvols[i]) + return _gf_false; + } + +@@ -1156,14 +1152,9 @@ afr_changelog_pre_op (call_frame_t *frame, xlator_t *this) + goto err; + } + +- if (call_count > 1 && +- (local->transaction.type == AFR_DATA_TRANSACTION || ++ if ((local->transaction.type == AFR_DATA_TRANSACTION || + !local->optimistic_change_log)) { + +- /* If we are performing change on only one subvol, no +- need to mark dirty, because we are setting the pending +- counts already anyways +- */ + local->dirty[idx] = hton32(1); + + ret = dict_set_static_bin (xdata_req, AFR_DIRTY, local->dirty, +-- +1.7.1 + diff --git a/SOURCES/0295-heal-Add-check-for-healing-directories-in-split-brai.patch b/SOURCES/0295-heal-Add-check-for-healing-directories-in-split-brai.patch new file mode 100644 index 0000000..220a5e7 --- /dev/null +++ b/SOURCES/0295-heal-Add-check-for-healing-directories-in-split-brai.patch @@ -0,0 +1,79 @@ +From 4abf18c10a0949ce30e3413071778f5f33449b1f Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Mon, 17 Aug 2015 10:29:19 +0000 +Subject: [PATCH 295/304] heal: Add check for healing directories in split-brain + +Patch in master: http://review.gluster.org/#/c/11937/ +Patch in release-3.7: http://review.gluster.org/#/c/12007/ + +1. Healing using `bigger-file' option does not make much sense for directories, +hence disallow it and notify the user. +2. Healing using 'source-brick' option for directories performs a conservative +merge. Notify the user about it. + +Change-Id: Iafaa7a7ed2ab2c97472cd29efefb318bcfee3dbb +BUG: 1234399 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/56153 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + heal/src/glfs-heal.c | 28 +++++++++++++++++++++++++++- + 1 files changed, 27 insertions(+), 1 deletions(-) + +diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c +index bc76518..3b3003e 100644 +--- a/heal/src/glfs-heal.c ++++ b/heal/src/glfs-heal.c +@@ -535,6 +535,27 @@ glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, + } + + int ++_validate_directory (dict_t *xattr_req, char *file) ++{ ++ int heal_op = -1; ++ int ret = 0; ++ ++ ret = dict_get_int32 (xattr_req, "heal-op", &heal_op); ++ if (ret) ++ return ret; ++ ++ if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE) { ++ printf ("'bigger-file' not a valid option for directories.\n"); ++ ret = -1; ++ } else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) { ++ printf ("'source-brick' option used on a directory (%s). " ++ "Performing conservative merge.\n", file); ++ } ++ ++ return ret; ++} ++ ++int + glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, + char *file, dict_t *xattr_req) + { +@@ -556,7 +577,7 @@ glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, + gf_uuid_parse (path, loc.gfid); + loc.path = gf_strdup (uuid_utoa (loc.gfid)); + loc.inode = inode_new (rootloc->inode->table); +- ret = syncop_lookup (xl, &loc, 0, 0, xattr_req, &xattr_rsp); ++ ret = syncop_lookup (xl, &loc, &iatt, 0, xattr_req, &xattr_rsp); + if (ret) { + op_errno = -ret; + printf ("Lookup failed on %s:%s.\n", file, +@@ -580,6 +601,11 @@ retry: + } + } + ++ if (iatt.ia_type == IA_IFDIR) { ++ ret = _validate_directory (xattr_req, file); ++ if (ret) ++ goto out; ++ } + ret = syncop_getxattr (xl, &loc, &xattr_rsp, GF_AFR_HEAL_SBRAIN, + xattr_req, NULL); + if (ret) { +-- +1.7.1 + diff --git a/SOURCES/0296-cluster-afr-Examine-data-metadata-readable-for-read-.patch b/SOURCES/0296-cluster-afr-Examine-data-metadata-readable-for-read-.patch new file mode 100644 index 0000000..37b3540 --- /dev/null +++ b/SOURCES/0296-cluster-afr-Examine-data-metadata-readable-for-read-.patch @@ -0,0 +1,274 @@ +From 2d168099b85ef5f5d8b6f6a1ae55902b1360b441 Mon Sep 17 00:00:00 2001 +From: Anuradha Talur +Date: Mon, 3 Aug 2015 17:09:13 +0530 +Subject: [PATCH 296/304] cluster/afr : Examine data/metadata readable for read-subvol During lookup and discover, currently read_subvol is based only on data_readable. read_subvol should be decided based on both data_readable and metadata_readable. + +Credits to Ravishankar N for the logic of afr_first_up_child +from http://review.gluster.org/10905/ . + +> Change-Id: I98580b23c278172ee2902be08eeaafb6722e830c +> BUG: 1240244 +> Signed-off-by: Anuradha Talur +> Reviewed-on: http://review.gluster.org/11551 +> Reviewed-by: Ravishankar N +> Tested-by: Gluster Build System +> Reviewed-by: Krutika Dhananjay +> Reviewed-by: Pranith Kumar Karampuri + +BUG: 1238398 +Signed-off-by: Anuradha Talur +Change-Id: Ib4f1ee57dc6103dd608fc983d7cf7efab9dadf59 +Reviewed-on: https://code.engineering.redhat.com/gerrit/56259 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + .../replicate/bug-1238398-split-brain-resolution.t | 48 ++++++++++++ + xlators/cluster/afr/src/afr-common.c | 77 +++++++++++++++----- + xlators/cluster/afr/src/afr-read-txn.c | 16 ++++- + 3 files changed, 118 insertions(+), 23 deletions(-) + create mode 100644 tests/bugs/replicate/bug-1238398-split-brain-resolution.t + +diff --git a/tests/bugs/replicate/bug-1238398-split-brain-resolution.t b/tests/bugs/replicate/bug-1238398-split-brain-resolution.t +new file mode 100644 +index 0000000..7ba09f0 +--- /dev/null ++++ b/tests/bugs/replicate/bug-1238398-split-brain-resolution.t +@@ -0,0 +1,48 @@ ++#!/bin/bash ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++cleanup; ++ ++function get_split_brain_status { ++ local path=$1 ++ echo `getfattr -n replica.split-brain-status $path` | cut -f2 -d"=" | sed -e 's/^"//' -e 's/"$//' ++} ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} ++TEST $CLI volume start $V0 ++ ++#Disable self-heal-daemon ++TEST $CLI volume set $V0 cluster.self-heal-daemon off ++ ++TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; ++ ++TEST `echo "some-data" > $M0/metadata-split-brain.txt` ++ ++#Create metadata split-brain ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++TEST chmod 666 $M0/metadata-split-brain.txt ++ ++TEST $CLI volume start $V0 force ++TEST kill_brick $V0 $H0 $B0/${V0}1 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++ ++TEST chmod 757 $M0/metadata-split-brain.txt ++ ++TEST $CLI volume start $V0 force ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 ++ ++EXPECT 2 get_pending_heal_count $V0 ++ ++#Inspect the file in metadata-split-brain ++EXPECT "data-split-brain:no metadata-split-brain:yes Choices:patchy-client-0,patchy-client-1" get_split_brain_status $M0/metadata-split-brain.txt ++TEST setfattr -n replica.split-brain-choice -v $V0-client-0 $M0/metadata-split-brain.txt ++ ++EXPECT "757" stat -c %a $M0/metadata-split-brain.txt ++ ++TEST setfattr -n replica.split-brain-choice -v $V0-client-1 $M0/metadata-split-brain.txt ++EXPECT "666" stat -c %a $M0/metadata-split-brain.txt ++ ++cleanup; +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 2401cfd..7255179 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -368,7 +368,8 @@ afr_inode_get_readable (call_frame_t *frame, inode_t *inode, xlator_t *this, + + if (inode->ia_type == IA_IFDIR) { + /* For directories, allow even if it is in data split-brain. */ +- if (type == AFR_METADATA_TRANSACTION) { ++ if (type == AFR_METADATA_TRANSACTION || ++ local->op == GF_FOP_STAT || local->op == GF_FOP_FSTAT) { + if (!metadata_count) + return -EIO; + } +@@ -1508,6 +1509,40 @@ afr_get_parent_read_subvol (xlator_t *this, inode_t *parent, + + } + ++int ++afr_read_subvol_decide (inode_t *inode, xlator_t *this, ++ afr_read_subvol_args_t *args) ++{ ++ int data_subvol = -1; ++ int mdata_subvol = -1; ++ ++ data_subvol = afr_data_subvol_get (inode, this, ++ 0, 0, args); ++ mdata_subvol = afr_metadata_subvol_get (inode, this, ++ 0, 0, args); ++ if (data_subvol == -1 || mdata_subvol == -1) ++ return -1; ++ ++ return data_subvol; ++} ++ ++static inline int ++afr_first_up_child (call_frame_t *frame, xlator_t *this) ++{ ++ afr_private_t *priv = NULL; ++ afr_local_t *local = NULL; ++ int i = 0; ++ ++ local = frame->local; ++ priv = this->private; ++ ++ for (i = 0; i < priv->child_count; i++) ++ if (local->replies[i].valid && ++ local->replies[i].op_ret == 0) ++ return i; ++ return 0; ++} ++ + static void + afr_lookup_done (call_frame_t *frame, xlator_t *this) + { +@@ -1623,13 +1658,13 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) + gf_uuid_copy (args.gfid, read_gfid); + args.ia_type = ia_type; + if (afr_replies_interpret (frame, this, local->inode)) { +- read_subvol = afr_data_subvol_get (local->inode, this, +- 0, 0, &args); ++ read_subvol = afr_read_subvol_decide (local->inode, ++ this, &args); + afr_inode_read_subvol_reset (local->inode, this); + goto cant_interpret; + } else { +- read_subvol = afr_data_subvol_get (local->inode, this, +- 0, 0, &args); ++ read_subvol = afr_data_subvol_get (local->inode, this, ++ 0, 0, &args); + } + } else { + cant_interpret: +@@ -1637,7 +1672,7 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) + if (spb_choice >= 0) + read_subvol = spb_choice; + else +- read_subvol = 0; ++ read_subvol = afr_first_up_child (frame, this); + } + dict_del (replies[read_subvol].xdata, GF_CONTENT_KEY); + } +@@ -1649,7 +1684,7 @@ unwind: + if (spb_choice >= 0) + read_subvol = spb_choice; + else +- read_subvol = 0; ++ read_subvol = afr_first_up_child (frame, this); + } + par_read_subvol = afr_get_parent_read_subvol (this, parent, replies, + readable); +@@ -2030,11 +2065,15 @@ afr_discover_done (call_frame_t *frame, xlator_t *this) + afr_local_t *local = NULL; + int i = -1; + int op_errno = 0; +- int read_subvol = 0; ++ int spb_choice = -1; ++ int read_subvol = -1; + + priv = this->private; + local = frame->local; + ++ afr_inode_split_brain_choice_get (local->inode, this, ++ &spb_choice); ++ + for (i = 0; i < priv->child_count; i++) { + if (!local->replies[i].valid) + continue; +@@ -2052,27 +2091,25 @@ afr_discover_done (call_frame_t *frame, xlator_t *this) + + afr_replies_interpret (frame, this, local->inode); + +- read_subvol = afr_data_subvol_get (local->inode, this, 0, 0, NULL); ++ read_subvol = afr_read_subvol_decide (local->inode, this, NULL); + if (read_subvol == -1) { + gf_msg (this->name, GF_LOG_WARNING, 0, + AFR_MSG_READ_SUBVOL_ERROR, "no read subvols for %s", + local->loc.path); + +- for (i = 0; i < priv->child_count; i++) { +- if (!local->replies[i].valid || +- local->replies[i].op_ret == -1) +- continue; +- read_subvol = i; +- break; +- } ++ if (spb_choice >= 0) { ++ read_subvol = spb_choice; ++ } else { ++ read_subvol = afr_first_up_child (frame, this); ++ } + } + + unwind: + if (read_subvol == -1) { +- afr_inode_split_brain_choice_get (local->inode, this, +- &read_subvol); +- if (read_subvol == -1) +- read_subvol = 0; ++ if (spb_choice >= 0) ++ read_subvol = spb_choice; ++ else ++ read_subvol = afr_first_up_child (frame, this); + } + + AFR_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno, +diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c +index 1b2faf3..a70565c 100644 +--- a/xlators/cluster/afr/src/afr-read-txn.c ++++ b/xlators/cluster/afr/src/afr-read-txn.c +@@ -193,12 +193,16 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + { + afr_local_t *local = NULL; + afr_private_t *priv = NULL; ++ unsigned char *data = NULL; ++ unsigned char *metadata = NULL; + int read_subvol = -1; + int event_generation = 0; + int ret = -1; + + priv = this->private; + local = frame->local; ++ data = alloca0 (priv->child_count); ++ metadata = alloca0 (priv->child_count); + + afr_read_txn_wipe (frame, this); + +@@ -213,10 +217,16 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, + goto read; + } + +- + local->transaction.type = type; +- ret = afr_inode_read_subvol_type_get (inode, this, local->readable, +- &event_generation, type); ++ if (local->op == GF_FOP_FSTAT || local->op == GF_FOP_STAT) { ++ ret = afr_inode_read_subvol_get (inode, this, data, metadata, ++ &event_generation); ++ AFR_INTERSECT (local->readable, data, metadata, ++ priv->child_count); ++ } else { ++ ret = afr_inode_read_subvol_type_get (inode, this, local->readable, ++ &event_generation, type); ++ } + if (ret == -1) + /* very first transaction on this inode */ + goto refresh; +-- +1.7.1 + diff --git a/SOURCES/0297-common-ha-concise-output-for-HA-status.patch b/SOURCES/0297-common-ha-concise-output-for-HA-status.patch new file mode 100644 index 0000000..81aa55f --- /dev/null +++ b/SOURCES/0297-common-ha-concise-output-for-HA-status.patch @@ -0,0 +1,67 @@ +From f1c6270c820903dccf48b2583ee6f9453b4e3537 Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Mon, 24 Aug 2015 02:02:25 -0400 +Subject: [PATCH 297/304] common-ha: concise output for HA status + +filter out unnecessary detail from HA status + +backport of http://review.gluster.org/#/c/11942/ +upstream https://bugzilla.redhat.com/show_bug.cgi?id=1250628 + +Change-Id: Ie3b8fc8fe902272c21cd1d4d342d297245ec15e7 +BUG: 1235971 +Signed-off-by: Kaleb S. KEITHLEY +Reviewed-on: https://code.engineering.redhat.com/gerrit/56014 +Reviewed-by: Soumya Koduri +--- + extras/ganesha/scripts/ganesha-ha.sh | 27 ++++++++++++++++++++++++++- + 1 files changed, 26 insertions(+), 1 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 9c82c09..01bd651 100644 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -843,6 +843,29 @@ setup_state_volume() + } + + ++status() ++{ ++ local regex_str="^ ${1}"; shift ++ local status_file=$(mktemp) ++ ++ while [[ ${1} ]]; do ++ ++ regex_str="${regex_str}|^ ${1}" ++ ++ shift ++ done ++ ++ pcs status | egrep "^Online:" > ${status_file} ++ ++ echo >> ${status_file} ++ ++ pcs status | egrep "${regex_str}" | sed -e "s/\t/ /" | cut -d ' ' -f 2,4 >> ${status_file} ++ ++ cat ${status_file} ++ ++ rm -f ${status_file} ++} ++ + + main() + { +@@ -976,7 +999,9 @@ $HA_CONFDIR/ganesha-ha.conf + ;; + + status | --status) +- exec pcs status ++ determine_servers "status" ++ ++ status ${HA_SERVERS} + ;; + + refresh-config | --refresh-config) +-- +1.7.1 + diff --git a/SOURCES/0298-snapshot-Make-fops-static-for-correct-resolution-of-.patch b/SOURCES/0298-snapshot-Make-fops-static-for-correct-resolution-of-.patch new file mode 100644 index 0000000..4a4810d --- /dev/null +++ b/SOURCES/0298-snapshot-Make-fops-static-for-correct-resolution-of-.patch @@ -0,0 +1,371 @@ +From a1aad4e5f096e3ec2ad832f3d91f1000e17cdb37 Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Thu, 30 Jul 2015 16:37:45 +0530 +Subject: [PATCH 298/304] snapshot: Make fops static for correct resolution of symbols + +Few of the snapshot fops (like 'svc_lookup') may not get resolved +while using dynamic loading as there could be other libraries(like libntirpc) +with same routine names. Making them static to resolve the same. + +This is backport of the below fix - +http://review.gluster.org/#/c/11805/ + +Change-Id: I6577bf3705864f5583425c94427b4e1025a59bcd +BUG: 1245636 +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/11805 +Reviewed-by: Niels de Vos +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/56154 +Tested-by: Kaleb Keithley +--- + .../features/snapview-client/src/snapview-client.c | 74 ++++++++++---------- + 1 files changed, 38 insertions(+), 36 deletions(-) + +diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c +index f1b3899..b3f1a92 100644 +--- a/xlators/features/snapview-client/src/snapview-client.c ++++ b/xlators/features/snapview-client/src/snapview-client.c +@@ -263,7 +263,7 @@ out: + } + + +-int32_t ++static int32_t + svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, dict_t *xdata, struct iatt *postparent) +@@ -378,7 +378,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xdata) + { +@@ -498,7 +498,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xdata) + { +@@ -561,7 +561,7 @@ out: + handled? i.e just based on inode type decide where the call should + be sent and in the call back update the contexts. + */ +-int32_t ++static int32_t + svc_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xdata) + { +@@ -591,7 +591,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) + { + int32_t ret = -1; +@@ -620,7 +620,7 @@ out: + return ret; + } + +-int32_t ++static int32_t + svc_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) + { +@@ -687,7 +687,7 @@ out: + will not be any corresponding fd opened on svs and + svc has to do things that open-behind is doing. + */ +-int32_t ++static int32_t + svc_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata) + { +@@ -733,7 +733,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + struct iatt *stbuf, int32_t valid, dict_t *xdata) + { +@@ -777,6 +777,7 @@ out: + return 0; + } + ++/* XXX: This function is currently not used. Mark it 'static' when required */ + int32_t + svc_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, + int32_t valid, dict_t *xdata) +@@ -820,7 +821,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, + dict_t *xdata) + { +@@ -900,6 +901,7 @@ out: + return 0; + } + ++/* XXX: This function is currently not used. Mark it 'static' when required */ + int32_t + svc_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, + dict_t *xdata) +@@ -931,7 +933,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata) + { +@@ -976,7 +978,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata) + { +@@ -1020,7 +1022,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata) + { +@@ -1064,7 +1066,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, +@@ -1089,7 +1091,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata) + { +@@ -1136,7 +1138,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, +@@ -1160,7 +1162,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata) + { +@@ -1211,7 +1213,7 @@ out: + a virtual inode, then unwind the call back with EROFS. Otherwise simply + STACK_WIND the call to the first child of svc xlator. + */ +-int32_t ++static int32_t + svc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata) + { +@@ -1256,7 +1258,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, + struct iatt *stbuf, struct iatt *preparent, +@@ -1281,7 +1283,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_create (call_frame_t *frame, xlator_t *this, + loc_t *loc, int32_t flags, mode_t mode, + mode_t umask, fd_t *fd, dict_t *xdata) +@@ -1330,7 +1332,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, +@@ -1355,7 +1357,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata) + { +@@ -1402,7 +1404,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata) + { +@@ -1445,7 +1447,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata) + { +@@ -1476,7 +1478,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_readlink (call_frame_t *frame, xlator_t *this, + loc_t *loc, size_t size, dict_t *xdata) + { +@@ -1507,7 +1509,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, + dict_t *xdata) + { +@@ -1538,7 +1540,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, + dict_t *xdata) +@@ -1614,7 +1616,7 @@ out: + * windows. + */ + +-int32_t ++static int32_t + svc_readdirp_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, dict_t *xdata, +@@ -1787,7 +1789,7 @@ out: + return unwind; + } + +-int32_t ++static int32_t + svc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + gf_dirent_t *entries, dict_t *xdata) +@@ -1847,7 +1849,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, + dict_t *xdata) +@@ -1923,7 +1925,7 @@ out: + /* Renaming the entries from or to snapshots is not allowed as the snapshots + are read-only. + */ +-int32_t ++static int32_t + svc_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + loc_t *newloc, dict_t *xdata) + { +@@ -2001,7 +2003,7 @@ out: + will be equivalent of creating hardlinks across different filesystems. + And so is vise versa. + */ +-int32_t ++static int32_t + svc_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata) + { +@@ -2049,7 +2051,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) + { +@@ -2094,7 +2096,7 @@ out: + return 0; + } + +-int ++static int + svc_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync, + dict_t *xdata) + { +@@ -2138,7 +2140,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_flush (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *xdata) + { +@@ -2168,7 +2170,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_releasedir (xlator_t *this, fd_t *fd) + { + svc_fd_t *sfd = NULL; +@@ -2191,7 +2193,7 @@ out: + return 0; + } + +-int32_t ++static int32_t + svc_forget (xlator_t *this, inode_t *inode) + { + int ret = -1; +-- +1.7.1 + diff --git a/SOURCES/0299-glusterd-stop-all-the-daemons-services-on-peer-detac.patch b/SOURCES/0299-glusterd-stop-all-the-daemons-services-on-peer-detac.patch new file mode 100644 index 0000000..660fe01 --- /dev/null +++ b/SOURCES/0299-glusterd-stop-all-the-daemons-services-on-peer-detac.patch @@ -0,0 +1,221 @@ +From 0568fbdb19131f571e3ee61d7e275281cbc40dfd Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Tue, 25 Aug 2015 11:15:56 +0530 +Subject: [PATCH 299/304] glusterd: stop all the daemons services on peer detach + +This patch is backport of: http://review.gluster.org/#/c/11509/ + +Currently glusterd is not stopping all the deamon service on peer detach + +With this fix it will do peer detach cleanup properlly and will stop all +the daemon which was running before peer detach on the node. + + >>Change-Id: Ifed403ed09187e84f2a60bf63135156ad1f15775 + >>BUG: 1255386 + >>Signed-off-by: Gaurav Kumar Garg + +Change-Id: I632e61e4cb6b7cbfcb626ab2217b55071ed690ca +BUG: 1238070 +Signed-off-by: Gaurav Kumar Garg +Reviewed-on: https://code.engineering.redhat.com/gerrit/56148 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + .../bug-1238706-daemons-stop-on-peer-cleanup.t | 41 ++++++++++++++++++++ + tests/volume.rc | 16 ++++---- + xlators/mgmt/glusterd/src/glusterd-messages.h | 16 ++++++++ + xlators/mgmt/glusterd/src/glusterd-sm.c | 40 ++++++++++++------- + 4 files changed, 90 insertions(+), 23 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t + +diff --git a/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t b/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t +new file mode 100644 +index 0000000..9ff1758 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t +@@ -0,0 +1,41 @@ ++#!/bin/bash ++ ++## Test case for stopping all running daemons service on peer detach. ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup; ++ ++ ++## Start a 2 node virtual cluster ++TEST launch_cluster 2; ++ ++## Peer probe server 2 from server 1 cli ++TEST $CLI_1 peer probe $H2; ++ ++EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count ++ ++ ++## Creating and starting volume ++TEST $CLI_1 volume create $V0 $H1:$B1/${V0}0 $H1:$B1/${V0}1 ++TEST $CLI_1 volume start $V0 ++ ++## To Do: Add test case for quota and snapshot daemon. Currently quota ++## Daemon is not working in cluster framework. And sanpd daemon ++## Start only in one node in cluster framework. Add test case ++## once patch http://review.gluster.org/#/c/11666/ merged, ++ ++## We are having 2 node "nfs" daemon should run on both node. ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" get_nfs_count ++ ++## Detach 2nd node from the cluster. ++TEST $CLI_1 peer detach $H2; ++ ++ ++## After detaching 2nd node we will have only 1 nfs and quota daemon running. ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_nfs_count ++ ++cleanup; ++ +diff --git a/tests/volume.rc b/tests/volume.rc +index aeffa4a..d90dda7 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -547,6 +547,14 @@ function get_quotad_count { + ps auxww | grep glusterfs | grep quotad.pid | grep -v grep | wc -l + } + ++function get_nfs_count { ++ ps auxww | grep glusterfs | grep nfs.pid | grep -v grep | wc -l ++} ++ ++function get_snapd_count { ++ ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l ++} ++ + function quota_list_field () { + local QUOTA_PATH=$1 + local FIELD=$2 +@@ -565,11 +573,3 @@ function quota_usage() + { + quota_list_field $1 4 + } +- +-function get_nfs_count { +- ps auxww | grep glusterfs | grep nfs.pid | grep -v grep | wc -l +-} +- +-function get_snapd_count { +- ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index addd3e2..d678372 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -4594,6 +4594,22 @@ + */ + #define GD_MSG_SVC_STOP_SUCCESS (GLUSTERD_COMP_BASE + 568) + ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_PARAM_NULL (GLUSTERD_COMP_BASE + 569) ++ ++/*! ++ * @messageid ++ * @diagnosis ++ * @recommendedaction ++ * ++ */ ++#define GD_MSG_SVC_STOP_FAIL (GLUSTERD_COMP_BASE + 570) ++ + /*------------*/ + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_GLUSTERD_MESSAGES_H_ */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index e8e9b3a..8e91cef 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -35,6 +35,7 @@ + #include "glusterd-op-sm.h" + #include "glusterd-utils.h" + #include "glusterd-store.h" ++#include "glusterd-svc-helper.h" + #include "glusterd-snapshot-utils.h" + #include "glusterd-server-quorum.h" + +@@ -600,17 +601,29 @@ out: + /* Clean up stale volumes on the peer being detached. The volumes which have + * bricks on other peers are stale with respect to the detached peer. + */ +-static int ++static void + glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + { +- int ret = -1; +- glusterd_volinfo_t *volinfo = NULL; ++ int ret = -1; ++ glusterd_volinfo_t *volinfo = NULL; + glusterd_volinfo_t *tmp_volinfo = NULL; ++ glusterd_svc_t *svc = NULL; + + GF_ASSERT (priv); + + cds_list_for_each_entry_safe (volinfo, tmp_volinfo, &priv->volumes, + vol_list) { ++ /* Stop snapd daemon service if snapd daemon is running*/ ++ if (!volinfo->is_snap_volume) { ++ svc = &(volinfo->snapd.svc); ++ ret = svc->stop (svc, SIGTERM); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SVC_STOP_FAIL, "Failed to " ++ "stop snapd daemon service."); ++ } ++ } ++ + /* The peer detach checks make sure that, at this point in the + * detach process, there are only volumes contained completely + * within or completely outside the detached peer. +@@ -627,14 +640,17 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_STALE_VOL_REMOVE_FAIL, + "Error deleting stale volume"); +- goto out; + } + } + } +- ret = 0; +-out: +- gf_msg_debug (THIS->name, 0, "Returning %d", ret); +- return ret; ++ ++ /* Stop all daemon services of Detaching node once peer detached */ ++ ret = glusterd_svcs_stop (); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_SVC_STOP_FAIL, ++ "Failed to stop all daemon services."); ++ } + } + + static int +@@ -679,13 +695,7 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event, + } + rcu_read_unlock (); + +- ret = glusterd_peer_detach_cleanup (priv); +- if (ret) { +- gf_msg (THIS->name, GF_LOG_WARNING, 0, +- GD_MSG_PEER_DETACH_CLEANUP_FAIL, +- "Peer detach cleanup was not successful"); +- ret = 0; +- } ++ glusterd_peer_detach_cleanup (priv); + out: + if (new_event) + GF_FREE (new_event->peername); +-- +1.7.1 + diff --git a/SOURCES/0300-glusterd-Don-t-allow-remove-brick-start-commit-if-gl.patch b/SOURCES/0300-glusterd-Don-t-allow-remove-brick-start-commit-if-gl.patch new file mode 100644 index 0000000..737a0d6 --- /dev/null +++ b/SOURCES/0300-glusterd-Don-t-allow-remove-brick-start-commit-if-gl.patch @@ -0,0 +1,265 @@ +From 84007736637b8278858401d1988c1ea39df530d0 Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Tue, 21 Jul 2015 09:57:43 +0530 +Subject: [PATCH 300/304] glusterd: Don't allow remove brick start/commit if glusterd is down of the host of the brick + +Backport of http://review.gluster.org/#/c/11726/ + +remove brick stage blindly starts the remove brick operation even if the +glusterd instance of the node hosting the brick is down. Operationally its +incorrect and this could result into a inconsistent rebalance status across all +the nodes as the originator of this command will always have the rebalance +status to 'DEFRAG_NOT_STARTED', however when the glusterd instance on the other +nodes comes up, will trigger rebalance and make the status to completed once the +rebalance is finished. + +This patch fixes two things: +1. Add a validation in remove brick to check whether all the peers hosting the +bricks to be removed are up. + +2. Don't copy volinfo->rebal.dict from stale volinfo during restore as this +might end up in a incosistent node_state.info file resulting into volume status +command failure. + +Change-Id: Ia4a76865c05037d49eec5e3bbfaf68c1567f1f81 +BUG: 1236038 +Signed-off-by: Atin Mukherjee +Reviewed-on: http://review.gluster.org/11726 +Tested-by: NetBSD Build System +Reviewed-by: N Balachandran +Reviewed-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/56353 +Tested-by: Krishnan Parthasarathi +--- + .../glusterd/bug-1245045-remove-brick-validation.t | 54 +++++++++ + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 119 +++++++++++++++----- + xlators/mgmt/glusterd/src/glusterd-utils.c | 1 - + 3 files changed, 143 insertions(+), 31 deletions(-) + create mode 100644 tests/bugs/glusterd/bug-1245045-remove-brick-validation.t + +diff --git a/tests/bugs/glusterd/bug-1245045-remove-brick-validation.t b/tests/bugs/glusterd/bug-1245045-remove-brick-validation.t +new file mode 100644 +index 0000000..22a8d55 +--- /dev/null ++++ b/tests/bugs/glusterd/bug-1245045-remove-brick-validation.t +@@ -0,0 +1,54 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../cluster.rc ++ ++cleanup ++ ++TEST launch_cluster 3; ++TEST $CLI_1 peer probe $H2; ++TEST $CLI_1 peer probe $H3; ++EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count ++ ++TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 ++TEST $CLI_1 volume start $V0 ++ ++kill_glusterd 2 ++ ++#remove-brick should fail as the peer hosting the brick is down ++TEST ! $CLI_1 volume remove-brick $V0 $H2:$B2/${V0} start ++ ++TEST start_glusterd 2 ++ ++EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count ++ ++#volume status should work ++TEST $CLI_2 volume status ++ ++ ++TEST $CLI_1 volume remove-brick $V0 $H2:$B2/${V0} start ++kill_glusterd 2 ++ ++#remove-brick commit should fail as the peer hosting the brick is down ++TEST ! $CLI_1 volume remove-brick $V0 $H2:$B2/${V0} commit ++ ++TEST start_glusterd 2 ++ ++EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count ++ ++#volume status should work ++TEST $CLI_2 volume status ++ ++TEST $CLI_1 volume remove-brick $V0 $H2:$B2/${V0} stop ++ ++kill_glusterd 3 ++EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count ++ ++TEST $CLI_1 volume remove-brick $V0 $H2:$B2/${V0} start ++ ++TEST start_glusterd 3 ++EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count ++ ++TEST $CLI_3 volume status ++ ++cleanup +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index caf51a4..e1a0397 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -1661,6 +1661,83 @@ out: + return ret; + } + ++static int ++glusterd_remove_brick_validate_bricks (gf1_op_commands cmd, int32_t brick_count, ++ dict_t *dict, ++ glusterd_volinfo_t *volinfo, ++ char **errstr) ++{ ++ char *brick = NULL; ++ char msg[2048] = {0,}; ++ char key[256] = {0,}; ++ glusterd_brickinfo_t *brickinfo = NULL; ++ glusterd_peerinfo_t *peerinfo = NULL; ++ int i = 0; ++ int ret = -1; ++ ++ /* Check whether all the nodes of the bricks to be removed are ++ * up, if not fail the operation */ ++ for (i = 1; i <= brick_count; i++) { ++ snprintf (key, sizeof (key), "brick%d", i); ++ ret = dict_get_str (dict, key, &brick); ++ if (ret) { ++ snprintf (msg, sizeof (msg), ++ "Unable to get %s", key); ++ *errstr = gf_strdup (msg); ++ goto out; ++ } ++ ++ ret = ++ glusterd_volume_brickinfo_get_by_brick(brick, volinfo, ++ &brickinfo); ++ if (ret) { ++ snprintf (msg, sizeof (msg), "Incorrect brick " ++ "%s for volume %s", brick, volinfo->volname); ++ *errstr = gf_strdup (msg); ++ goto out; ++ } ++ /* Do not allow commit if the bricks are not decommissioned ++ * if its a remove brick commit ++ */ ++ if (cmd == GF_OP_CMD_COMMIT && !brickinfo->decommissioned) { ++ snprintf (msg, sizeof (msg), "Brick %s " ++ "is not decommissioned. " ++ "Use start or force option", ++ brick); ++ *errstr = gf_strdup (msg); ++ ret = -1; ++ goto out; ++ } ++ ++ if (glusterd_is_local_brick (THIS, volinfo, brickinfo)) ++ continue; ++ ++ rcu_read_lock (); ++ peerinfo = glusterd_peerinfo_find_by_uuid ++ (brickinfo->uuid); ++ if (!peerinfo) { ++ snprintf (msg, sizeof(msg), "Host node of the " ++ "brick %s is not in cluster", brick); ++ *errstr = gf_strdup (msg); ++ ret = -1; ++ rcu_read_unlock (); ++ goto out; ++ } ++ if (!peerinfo->connected) { ++ snprintf (msg, sizeof(msg), "Host node of the " ++ "brick %s is down", brick); ++ *errstr = gf_strdup (msg); ++ ret = -1; ++ rcu_read_unlock (); ++ goto out; ++ } ++ rcu_read_unlock (); ++ } ++ ++out: ++ return ret; ++} ++ + int + glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + { +@@ -1679,6 +1756,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + char *brick = NULL; + glusterd_brickinfo_t *brickinfo = NULL; + gsync_status_param_t param = {0,}; ++ glusterd_peerinfo_t *peerinfo = NULL; + + this = THIS; + GF_ASSERT (this); +@@ -1817,6 +1895,12 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + goto out; + } + ++ ret = glusterd_remove_brick_validate_bricks (cmd, brick_count, ++ dict, volinfo, ++ &errstr); ++ if (ret) ++ goto out; ++ + if (is_origin_glusterd (dict)) { + ret = glusterd_generate_and_set_task_id + (dict, GF_REMOVE_BRICK_TID_KEY); +@@ -1861,36 +1945,11 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) + goto out; + } + +- /* Do not allow commit if the bricks are not decommissioned */ +- for ( i = 1; i <= brick_count; i++ ) { +- snprintf (key, sizeof (key), "brick%d", i); +- ret = dict_get_str (dict, key, &brick); +- if (ret) { +- snprintf (msg, sizeof (msg), +- "Unable to get %s", key); +- errstr = gf_strdup (msg); +- goto out; +- } +- +- ret = +- glusterd_volume_brickinfo_get_by_brick(brick, volinfo, +- &brickinfo); +- if (ret) { +- snprintf (msg, sizeof (msg), "Incorrect brick " +- "%s for volume %s", brick, volname); +- errstr = gf_strdup (msg); +- goto out; +- } +- if ( !brickinfo->decommissioned ) { +- snprintf (msg, sizeof (msg), "Brick %s " +- "is not decommissioned. " +- "Use start or force option", +- brick); +- errstr = gf_strdup (msg); +- ret = -1; +- goto out; +- } +- } ++ ret = glusterd_remove_brick_validate_bricks (cmd, brick_count, ++ dict, volinfo, ++ &errstr); ++ if (ret) ++ goto out; + + /* If geo-rep is configured, for this volume, it should be + * stopped. +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 4982828..0f0ca27 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -3739,7 +3739,6 @@ gd_check_and_update_rebalance_info (glusterd_volinfo_t *old_volinfo, + new->skipped_files = old->skipped_files; + new->rebalance_failures = old->rebalance_failures; + new->rebalance_time = old->rebalance_time; +- new->dict = (old->dict ? dict_ref (old->dict) : NULL); + + /* glusterd_rebalance_t.{op, id, defrag_cmd} are copied during volume + * import +-- +1.7.1 + diff --git a/SOURCES/0301-libgfapi-Gracefully-exit-when-glfd-is-invalid.patch b/SOURCES/0301-libgfapi-Gracefully-exit-when-glfd-is-invalid.patch new file mode 100644 index 0000000..0a96f48 --- /dev/null +++ b/SOURCES/0301-libgfapi-Gracefully-exit-when-glfd-is-invalid.patch @@ -0,0 +1,78 @@ +From 7685ba36b1ee34009c4954038373920d269cb2ce Mon Sep 17 00:00:00 2001 +From: Bipin Kunal +Date: Tue, 12 May 2015 16:36:55 +0530 +Subject: [PATCH 301/304] libgfapi: Gracefully exit when glfd is invalid + +Backport of http://review.gluster.org/#/c/10759/ + +When glfs_* methods operating on glfd are invoked after calling +glfs_close(), the program segfaults inside __GLFS_ENTRY_VALIDATE_FD +trying to deference glfd->fd->inode which is invalid. + +Also, returning EBADF seemed more specific than EINVAL. + +BUG: 1255471 + +Change-Id: I13a92dca52da9a300252b69e026581b3a9e931fd +Signed-off-by: Prashanth Pai +Reviewed-on: http://review.gluster.org/10759 +Tested-by: Gluster Build System +Reviewed-by: Shyamsundar Ranganathan +Signed-off-by: Bipin Kunal +Reviewed-on: https://code.engineering.redhat.com/gerrit/56191 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + api/src/glfs-internal.h | 4 ++-- + api/src/glfs.c | 6 ++++-- + libglusterfs/src/fd.c | 2 +- + 3 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h +index 8ff78de..2d8a7dc 100644 +--- a/api/src/glfs-internal.h ++++ b/api/src/glfs-internal.h +@@ -217,8 +217,8 @@ do { \ + + #define __GLFS_ENTRY_VALIDATE_FD(glfd, label) \ + do { \ +- if (!glfd) { \ +- errno = EINVAL; \ ++ if (!glfd || !glfd->fd || !glfd->fd->inode) { \ ++ errno = EBADF; \ + goto label; \ + } \ + old_THIS = THIS; \ +diff --git a/api/src/glfs.c b/api/src/glfs.c +index 897d3ea..1c7b55a 100644 +--- a/api/src/glfs.c ++++ b/api/src/glfs.c +@@ -560,8 +560,10 @@ glfs_fd_destroy (struct glfs_fd *glfd) + } + glfs_unlock (glfd->fs); + +- if (glfd->fd) +- fd_unref (glfd->fd); ++ if (glfd->fd) { ++ fd_unref (glfd->fd); ++ glfd->fd = NULL; ++ } + + GF_FREE (glfd->readdirbuf); + +diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c +index 85334bb..9beb79c 100644 +--- a/libglusterfs/src/fd.c ++++ b/libglusterfs/src/fd.c +@@ -538,7 +538,7 @@ fd_destroy (fd_t *fd) + } + UNLOCK (&fd->inode->lock); + inode_unref (fd->inode); +- fd->inode = (inode_t *)0xaaaaaaaa; ++ fd->inode = NULL; + fd_lk_ctx_unref (fd->lk_ctx); + mem_put (fd); + out: +-- +1.7.1 + diff --git a/SOURCES/0302-snapshot-cleanup-snaps-during-unprobe.patch b/SOURCES/0302-snapshot-cleanup-snaps-during-unprobe.patch new file mode 100644 index 0000000..e2b1a40 --- /dev/null +++ b/SOURCES/0302-snapshot-cleanup-snaps-during-unprobe.patch @@ -0,0 +1,208 @@ +From d2f48b625c0d7d361b62f7a4f1a698bef3d67dc9 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Tue, 17 Mar 2015 19:57:47 +0530 +Subject: [PATCH 302/304] snapshot:cleanup snaps during unprobe + + Backport of http://review.gluster.org/#/c/9930/ + +When doing an unprobe, the volume that doesnot +contain any brick of the particular node will be +deleted. So the snaps associated with that volume +should also delete + +Change-Id: I9f3d23bd11b254ebf7d7722cc1e12455d6b024ff +BUG: 1238111 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: http://review.gluster.org/9930 +Tested-by: NetBSD Build System +Reviewed-by: Avra Sengupta +Reviewed-by: Rajesh Joseph +Reviewed-on: https://code.engineering.redhat.com/gerrit/56396 +Tested-by: Rajesh Joseph +--- + xlators/mgmt/glusterd/src/glusterd-sm.c | 9 ++ + .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 89 ++++++++++++++++++++ + .../mgmt/glusterd/src/glusterd-snapshot-utils.h | 5 + + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 23 +----- + 4 files changed, 104 insertions(+), 22 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 8e91cef..f0159b2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -635,6 +635,15 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv) + gf_msg (THIS->name, GF_LOG_INFO, 0, + GD_MSG_STALE_VOL_DELETE_INFO, + "Deleting stale volume %s", volinfo->volname); ++ ++ ret = glusterd_cleanup_snaps_for_volume (volinfo); ++ if (ret) { ++ gf_msg (THIS->name, GF_LOG_ERROR, 0, ++ GD_MSG_VOL_DELETE_FAIL, ++ "Error deleting snapshots for volume %s", ++ volinfo->volname); ++ } ++ + ret = glusterd_delete_volume (volinfo); + if (ret) { + gf_msg (THIS->name, GF_LOG_ERROR, 0, +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +index acc4e42..ccea9ff 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +@@ -40,6 +40,95 @@ + * This function restores the atime and mtime of marker.tstamp + * if present from snapped marker.tstamp file. + */ ++ ++int32_t ++glusterd_snapobject_delete (glusterd_snap_t *snap) ++{ ++ if (snap == NULL) { ++ gf_msg(THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_PARAM_NULL, "snap is NULL"); ++ return -1; ++ } ++ ++ cds_list_del_init (&snap->snap_list); ++ cds_list_del_init (&snap->volumes); ++ if (LOCK_DESTROY(&snap->lock)) ++ gf_msg (THIS->name, GF_LOG_WARNING, 0, ++ GD_MSG_LOCK_DESTROY_FAILED, ++ "Failed destroying lock" ++ "of snap %s", snap->snapname); ++ ++ GF_FREE (snap->description); ++ GF_FREE (snap); ++ ++ return 0; ++} ++ ++ ++/* ++ * This function is to be called only from glusterd_peer_detach_cleanup() ++ * as this continues to delete snaps inspite of faiure while deleting ++ * one, as we don't want to fail peer_detach in such a case. ++ */ ++int ++glusterd_cleanup_snaps_for_volume (glusterd_volinfo_t *volinfo) ++{ ++ int32_t op_ret = 0; ++ int32_t ret = 0; ++ xlator_t *this = NULL; ++ glusterd_volinfo_t *snap_vol = NULL; ++ glusterd_volinfo_t *dummy_snap_vol = NULL; ++ glusterd_snap_t *snap = NULL; ++ ++ this = THIS; ++ GF_ASSERT (this); ++ ++ cds_list_for_each_entry_safe (snap_vol, dummy_snap_vol, ++ &volinfo->snap_volumes, ++ snapvol_list) { ++ ret = glusterd_store_delete_volume (snap_vol); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_DELETE_FAIL, "Failed to remove " ++ "volume %s from store", snap_vol->volname); ++ op_ret = ret; ++ continue; ++ } ++ ++ ret = glusterd_volinfo_delete (snap_vol); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_DELETE_FAIL, "Failed to remove " ++ "volinfo %s ", snap_vol->volname); ++ op_ret = ret; ++ continue; ++ } ++ ++ snap = snap_vol->snapshot; ++ ret = glusterd_store_delete_snap (snap); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_DELETE_FAIL, "Failed to remove " ++ "snap %s from store", snap->snapname); ++ op_ret = ret; ++ continue; ++ } ++ ++ ret = glusterd_snapobject_delete (snap); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ GD_MSG_VOL_DELETE_FAIL, "Failed to delete " ++ "snap object %s", snap->snapname); ++ op_ret = ret; ++ continue; ++ } ++ } ++ ++ return op_ret; ++} ++ ++ ++ + int + glusterd_snap_geo_rep_restore (glusterd_volinfo_t *snap_volinfo, + glusterd_volinfo_t *new_volinfo) +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h +index ce8d7d4..63d39e8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h +@@ -38,6 +38,11 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict, + glusterd_volinfo_t *new_volinfo, + glusterd_volinfo_t *snap_volinfo, + int32_t volcount); ++int32_t ++glusterd_snapobject_delete (glusterd_snap_t *snap); ++ ++int32_t ++glusterd_cleanup_snaps_for_volume (glusterd_volinfo_t *volinfo); + + int32_t + glusterd_missed_snapinfo_new (glusterd_missed_snap_info **missed_snapinfo); +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 080aa88..6f10ebc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -86,6 +86,7 @@ typedef struct snap_create_args_ snap_create_args_t; + then the snap device will be /dev//. + This function takes care of building the path for the snap device. + */ ++ + char * + glusterd_build_snap_device_path (char *device, char *snapname, + int32_t brickcount) +@@ -2961,28 +2962,6 @@ out: + } + + int32_t +-glusterd_snapobject_delete (glusterd_snap_t *snap) +-{ +- if (snap == NULL) { +- gf_msg(THIS->name, GF_LOG_WARNING, EINVAL, +- GD_MSG_INVALID_ENTRY, "snap is NULL"); +- return -1; +- } +- +- cds_list_del_init (&snap->snap_list); +- cds_list_del_init (&snap->volumes); +- if (LOCK_DESTROY(&snap->lock)) +- gf_msg (THIS->name, GF_LOG_WARNING, 0, +- GD_MSG_LOCK_DESTROY_FAILED, "Failed destroying lock" +- "of snap %s", snap->snapname); +- +- GF_FREE (snap->description); +- GF_FREE (snap); +- +- return 0; +-} +- +-int32_t + glusterd_snap_remove (dict_t *rsp_dict, + glusterd_snap_t *snap, + gf_boolean_t remove_lvm, +-- +1.7.1 + diff --git a/SOURCES/0303-libgfapi-adding-follow-flag-to-glfs_h_lookupat.patch b/SOURCES/0303-libgfapi-adding-follow-flag-to-glfs_h_lookupat.patch new file mode 100644 index 0000000..fb2ad82 --- /dev/null +++ b/SOURCES/0303-libgfapi-adding-follow-flag-to-glfs_h_lookupat.patch @@ -0,0 +1,362 @@ +From f7ac1de714b976a3718248595bd839f67aec84fc Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Tue, 11 Aug 2015 16:00:47 +0530 +Subject: [PATCH 303/303] libgfapi: adding 'follow' flag to glfs_h_lookupat() + +This patch is backport of http://review.gluster.org/#/c/11883/ + +Previously glfs_h_lookupat won't follow the symlink, this patch +introduces new flag `follow` which will resolve the same. Applications +linking against the new library will need to use the new glfs_h_lookupat +API call. + +In order to stay compatible with existing binaries that use the previous +glfs_h_lookupat() function, the old symbol needs to stay available. + +Verification that there are two versions of glfs_h_lookupat: + + $ objdump -T /usr/lib64/libgfapi.so.0 | grep -w glfs_h_lookupat + 0000000000015070 g DF .text 000000000000021e GFAPI_3.7.4 glfs_h_lookupat + 0000000000015290 g DF .text 0000000000000008 (GFAPI_3.4.2) glfs_h_lookupat + +Testing with a binary (based on anonymous_fd_read_write.c from ./tests/) +that was linked against the old library: + + $ objdump -T ./lookupat | grep -w glfs_h_lookupat + 0000000000000000 DF *UND* 0000000000000000 GFAPI_3.4.2 glfs_h_lookupat + +Enable debugging for 'ld.so' so that we can check that the GFAPI_3.4.2 +version of the symbol gets loaded: + + $ export LD_DEBUG_OUTPUT=lookupat.ld.log LD_DEBUG=all + $ ./lookupat + $ grep -w glfs_h_lookupat lookupat.ld.log.2543 + 2543: symbol=glfs_h_lookupat; lookup in file=./lookupat [0] + 2543: symbol=glfs_h_lookupat; lookup in file=/lib64/libgfapi.so.0 [0] + 2543: binding file ./lookupat [0] to /lib64/libgfapi.so.0 [0]: normal symbol `glfs_h_lookupat' [GFAPI_3.4.2] + +This change has been successfully cherry-picked as 1ead86a8bcbfe4045729466e4b98f765f3c13c8d +in master + +Upstream reference +>Change-Id: I8bf9b1c19a0585f681bc1a7f84aad1ccd0f75f6a +>BUG: 1252410 +>Signed-off-by: Jiffin Tony Thottan +>Signed-off-by: Niels de Vos +>Reviewed-on: http://review.gluster.org/11883 +>Reviewed-by: soumya k +>Reviewed-by: Kaleb KEITHLEY +>Tested-by: NetBSD Build System + +Change-Id: Idcce1fb3e8cbf1377807f18f7361e435c07097e9 +BUG: 1257007 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/56325 +Reviewed-by: Kaleb Keithley +Reviewed-by: Soumya Koduri +Tested-by: Kaleb Keithley +--- + api/examples/glfsxmp.c | 36 ++++++++++---------- + api/src/gfapi.aliases | 4 ++- + api/src/gfapi.map | 6 +++- + api/src/glfs-handleops.c | 15 ++++++-- + api/src/glfs-handles.h | 8 ++-- + .../gfapi-symbol-versions/gfapi-symbol-versions.md | 2 +- + tests/basic/gfapi/anonymous_fd_read_write.c | 2 +- + .../features/snapview-server/src/snapview-server.c | 2 +- + 8 files changed, 45 insertions(+), 30 deletions(-) + +diff --git a/api/examples/glfsxmp.c b/api/examples/glfsxmp.c +index 7180a99..7ff3f0e 100644 +--- a/api/examples/glfsxmp.c ++++ b/api/examples/glfsxmp.c +@@ -216,7 +216,7 @@ test_h_unlink (void) + printf ("glfs_h_unlink tests: In Progress\n"); + + /* Prepare tests */ +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -350,7 +350,7 @@ test_h_getsetattrs (void) + printf("glfs_h_getattrs and setattrs tests: In Progress\n"); + + /* Prepare tests */ +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -447,7 +447,7 @@ test_h_truncate (void) + printf("glfs_h_truncate tests: In Progress\n"); + + /* Prepare tests */ +- root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -585,7 +585,7 @@ test_h_links (void) + printf("glfs_h_link(s) tests: In Progress\n"); + + /* Prepare tests */ +- root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -729,7 +729,7 @@ test_h_rename (void) + printf("glfs_h_rename tests: In Progress\n"); + + /* Prepare tests */ +- root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ root = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -904,7 +904,7 @@ test_h_performance (void) + printf("glfs_h_performance tests: In Progress\n"); + + /* Prepare tests */ +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, NULL, strerror (errno)); +@@ -940,7 +940,7 @@ test_h_performance (void) + goto out; + } + +- leaf = glfs_h_lookupat (fs, dir, my_file_name, &sb); ++ leaf = glfs_h_lookupat (fs, dir, my_file_name, &sb, 0); + if (leaf != NULL) { + fprintf (stderr, "glfs_h_lookup: exists %s\n", + my_file_name); +@@ -1114,7 +1114,7 @@ test_handleops (int argc, char *argv[]) + /* glfs_lookupat test */ + printf ("glfs_h_lookupat tests: In Progress\n"); + /* start at root of the volume */ +- root = glfs_h_lookupat (fs, NULL, "/", &sb); ++ root = glfs_h_lookupat (fs, NULL, "/", &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + "/", NULL, strerror (errno)); +@@ -1124,7 +1124,7 @@ test_handleops (int argc, char *argv[]) + peek_stat (&sb); + + /* lookup a parent within root */ +- parent = glfs_h_lookupat (fs, root, parent_name, &sb); ++ parent = glfs_h_lookupat (fs, root, parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + parent_name, root, strerror (errno)); +@@ -1134,7 +1134,7 @@ test_handleops (int argc, char *argv[]) + peek_stat (&sb); + + /* lookup a leaf/child within the parent */ +- leaf = glfs_h_lookupat (fs, parent, leaf_name, &sb); ++ leaf = glfs_h_lookupat (fs, parent, leaf_name, &sb, 0); + if (leaf == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + leaf_name, parent, strerror (errno)); +@@ -1149,7 +1149,7 @@ test_handleops (int argc, char *argv[]) + glfs_h_close (parent); parent = NULL; + + /* check absolute paths */ +- root = glfs_h_lookupat (fs, NULL, "/", &sb); ++ root = glfs_h_lookupat (fs, NULL, "/", &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + "/", NULL, strerror (errno)); +@@ -1158,7 +1158,7 @@ test_handleops (int argc, char *argv[]) + } + peek_stat (&sb); + +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, root, strerror (errno)); +@@ -1167,7 +1167,7 @@ test_handleops (int argc, char *argv[]) + } + peek_stat (&sb); + +- leaf = glfs_h_lookupat (fs, NULL, full_leaf_name, &sb); ++ leaf = glfs_h_lookupat (fs, NULL, full_leaf_name, &sb, 0); + if (leaf == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_leaf_name, parent, strerror (errno)); +@@ -1180,7 +1180,7 @@ test_handleops (int argc, char *argv[]) + glfs_h_close (leaf); leaf = NULL; + + /* check multiple component paths */ +- leaf = glfs_h_lookupat (fs, root, relative_leaf_name, &sb); ++ leaf = glfs_h_lookupat (fs, root, relative_leaf_name, &sb, 0); + if (leaf == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + relative_leaf_name, parent, strerror (errno)); +@@ -1236,7 +1236,7 @@ test_handleops (int argc, char *argv[]) + + /* Create tests */ + printf ("glfs_h_creat tests: In Progress\n"); +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, root, strerror (errno)); +@@ -1284,7 +1284,7 @@ test_handleops (int argc, char *argv[]) + printf ("glfs_h_extract_handle and glfs_h_create_from_handle tests: In Progress\n"); + /* TODO: Change the lookup to creat below for a GIFD recovery falure, + * that needs to be fixed */ +- leaf = glfs_h_lookupat (fs, parent, leaf_name1, &sb); ++ leaf = glfs_h_lookupat (fs, parent, leaf_name1, &sb, 0); + if (leaf == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + leaf_name1, parent, strerror (errno)); +@@ -1355,7 +1355,7 @@ test_handleops (int argc, char *argv[]) + goto out; + } + +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, root, strerror (errno)); +@@ -1399,7 +1399,7 @@ test_handleops (int argc, char *argv[]) + goto out; + } + +- parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb); ++ parent = glfs_h_lookupat (fs, NULL, full_parent_name, &sb, 0); + if (parent == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of %s: from (%p),%s\n", + full_parent_name, root, strerror (errno)); +diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases +index 9776c87..40b6ed2 100644 +--- a/api/src/gfapi.aliases ++++ b/api/src/gfapi.aliases +@@ -89,7 +89,7 @@ _pub_glfs_dup _glfs_dup$GFAPI_3.4.0 + _pub_glfs_setfsuid _glfs_setfsuid$GFAPI_3.4.2 + _pub_glfs_setfsgid _glfs_setfsgid$GFAPI_3.4.2 + _pub_glfs_setfsgroups _glfs_setfsgroups$GFAPI_3.4.2 +-_pub_glfs_h_lookupat _glfs_h_lookupat$GFAPI_3.4.2 ++_pub_glfs_h_lookupat34 _glfs_h_lookupat$GFAPI_3.4.2 + _pub_glfs_h_creat _glfs_h_creat$GFAPI_3.4.2 + _pub_glfs_h_mkdir _glfs_h_mkdir$GFAPI_3.4.2 + _pub_glfs_h_mknod _glfs_h_mknod$GFAPI_3.4.2 +@@ -138,3 +138,5 @@ _priv_glfs_free_from_ctx _glfs_free_from_ctx$GFAPI_PRIVATE_3.7.0 + _priv_glfs_new_from_ctx _glfs_new_from_ctx$GFAPI_PRIVATE_3.7.0 + _priv_glfs_resolve _glfs_resolve$GFAPI_PRIVATE_3.7.0 + _priv_glfs_process_upcall_event _glfs_process_upcall_event$GFAPI_PRIVATE_3.7.0 ++ ++_pub_glfs_h_lookupat _glfs_h_lookupat$GFAPI_3.7.4 +diff --git a/api/src/gfapi.map b/api/src/gfapi.map +index 4886398..d42ae2b 100644 +--- a/api/src/gfapi.map ++++ b/api/src/gfapi.map +@@ -98,7 +98,6 @@ GFAPI_3.4.2 { + glfs_setfsuid; + glfs_setfsgid; + glfs_setfsgroups; +- glfs_h_lookupat; + glfs_h_creat; + glfs_h_mkdir; + glfs_h_mknod; +@@ -163,3 +162,8 @@ GFAPI_PRIVATE_3.7.0 { + glfs_resolve; + glfs_process_upcall_event; + } GFAPI_3.7.0; ++ ++GFAPI_3.7.4 { ++ global: ++ glfs_h_lookupat; ++} GFAPI_PRIVATE_3.7.0; +diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c +index 9a85f19..3fd4ead 100644 +--- a/api/src/glfs-handleops.c ++++ b/api/src/glfs-handleops.c +@@ -63,7 +63,7 @@ glfs_iatt_from_stat (struct stat *stat, int valid, struct iatt *iatt, + + struct glfs_object * + pub_glfs_h_lookupat (struct glfs *fs, struct glfs_object *parent, +- const char *path, struct stat *stat) ++ const char *path, struct stat *stat, int follow) + { + int ret = 0; + xlator_t *subvol = NULL; +@@ -100,7 +100,7 @@ pub_glfs_h_lookupat (struct glfs *fs, struct glfs_object *parent, + + /* fop/op */ + ret = glfs_resolve_at (fs, subvol, inode, path, &loc, &iatt, +- 0 /*TODO: links? */, 0); ++ follow, 0); + + /* populate out args */ + if (!ret) { +@@ -124,7 +124,16 @@ invalid_fs: + return object; + } + +-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_lookupat, 3.4.2); ++GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_lookupat, 3.7.4); ++ ++struct glfs_object * ++pub_glfs_h_lookupat34 (struct glfs *fs, struct glfs_object *parent, ++ const char *path, struct stat *stat) ++{ ++ return pub_glfs_h_lookupat (fs, parent, path, stat, 0); ++} ++ ++GFAPI_SYMVER_PUBLIC(glfs_h_lookupat34, glfs_h_lookupat, 3.4.2); + + int + pub_glfs_h_statfs (struct glfs *fs, struct glfs_object *object, +diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h +index 19c4e8f..71bd21f 100644 +--- a/api/src/glfs-handles.h ++++ b/api/src/glfs-handles.h +@@ -153,10 +153,10 @@ enum gfapi_callback_type { + /* Handle based operations */ + /* Operations that generate handles */ + struct glfs_object *glfs_h_lookupat (struct glfs *fs, +- struct glfs_object *parent, +- const char *path, +- struct stat *stat) __THROW +- GFAPI_PUBLIC(glfs_h_lookupat, 3.4.0); ++ struct glfs_object *parent, ++ const char *path, ++ struct stat *stat, int follow) __THROW ++ GFAPI_PUBLIC(glfs_h_lookupat, 3.7.4); + + struct glfs_object *glfs_h_creat (struct glfs *fs, struct glfs_object *parent, + const char *path, int flags, mode_t mode, +diff --git a/tests/basic/gfapi/anonymous_fd_read_write.c b/tests/basic/gfapi/anonymous_fd_read_write.c +index 281184e..885f0a2 100644 +--- a/tests/basic/gfapi/anonymous_fd_read_write.c ++++ b/tests/basic/gfapi/anonymous_fd_read_write.c +@@ -54,7 +54,7 @@ main (int argc, char *argv[]) + ret = glfs_init (fs); + LOG_ERR("glfs_init", ret); + +- root = glfs_h_lookupat (fs, NULL, "/", &sb); ++ root = glfs_h_lookupat (fs, NULL, "/", &sb, 0); + if (root == NULL) { + fprintf (stderr, "glfs_h_lookupat: error on lookup of / ,%s\n", + strerror (errno)); +diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c +index 3415ce0..5ae9625 100644 +--- a/xlators/features/snapview-server/src/snapview-server.c ++++ b/xlators/features/snapview-server/src/snapview-server.c +@@ -293,7 +293,7 @@ svs_lookup_entry (xlator_t *this, loc_t *loc, struct iatt *buf, + fs = parent_ctx->fs; + + object = glfs_h_lookupat (fs, parent_object, loc->name, +- &statbuf); ++ &statbuf, 0); + if (!object) { + gf_log (this->name, GF_LOG_DEBUG, "failed to do lookup and " + "get the handle for entry %s (path: %s)", loc->name, +-- +1.7.1 + diff --git a/SOURCES/0304-libgfapi-non-default-symbol-version-macros-are-incor.patch b/SOURCES/0304-libgfapi-non-default-symbol-version-macros-are-incor.patch new file mode 100644 index 0000000..3b4737f --- /dev/null +++ b/SOURCES/0304-libgfapi-non-default-symbol-version-macros-are-incor.patch @@ -0,0 +1,47 @@ +From 6b9d0145a7a43bf7f7c756ccc19157fc7b2e36e0 Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Wed, 19 Aug 2015 02:43:00 -0400 +Subject: [PATCH 304/304] libgfapi: non-default symbol version macros are incorrect + +default symbol versions are in form glfs_h_lookupat@@GFAPI_2.7.4, +versus old, non-default versions are in the form glfs_h_lookup@GFAPI_2.4.2 + +I.e. "@@" versus "@" + +Backport of: +* Change-Id: I88a6b129558c0b3a6064de7620b3b20425e80bc9 +* BUG: 1254863 +* http://review.gluster.org/#/c/11955/ + +BUG: 1257007 +Change-Id: I394fb92b9d47790e57e1586b1631f3a31f4aa2d8 +Author: Kaleb S. KEITHLEY +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/11955 +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/56460 +Reviewed-by: Jiffin Thottan +--- + api/src/glfs-internal.h | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h +index 2d8a7dc..93e72a3 100644 +--- a/api/src/glfs-internal.h ++++ b/api/src/glfs-internal.h +@@ -35,10 +35,10 @@ + asm(".symver priv_"STR(fn)", "STR(fn)"@@GFAPI_PRIVATE_"STR(ver)) + + #define GFAPI_SYMVER_PUBLIC(fn1, fn2, ver) \ +- asm(".symver pub_"STR(fn1)", "STR(fn2)"@@GFAPI_"STR(ver)) ++ asm(".symver pub_"STR(fn1)", "STR(fn2)"@GFAPI_"STR(ver)) + + #define GFAPI_SYMVER_PRIVATE(fn1, fn2, ver) \ +- asm(".symver priv_"STR(fn1)", "STR(fn2)"@@GFAPI_PRIVATE_"STR(ver)) ++ asm(".symver priv_"STR(fn1)", "STR(fn2)"@GFAPI_PRIVATE_"STR(ver)) + #define STR(str) #str + #else + #ifndef GFAPI_PUBLIC +-- +1.7.1 + diff --git a/SOURCES/0305-tools-glusterfind-Do-not-show-session-corrupted-if-n.patch b/SOURCES/0305-tools-glusterfind-Do-not-show-session-corrupted-if-n.patch new file mode 100644 index 0000000..0d043d8 --- /dev/null +++ b/SOURCES/0305-tools-glusterfind-Do-not-show-session-corrupted-if-n.patch @@ -0,0 +1,40 @@ +From 1bffa4faeb00787b26f1316f3d60e2898ededdb7 Mon Sep 17 00:00:00 2001 +From: Aravinda VK +Date: Thu, 16 Jul 2015 18:23:36 +0530 +Subject: [PATCH 305/320] tools/glusterfind: Do not show session corrupted if no status file + +When a glusterfind session is created it creates session directories +in all the nodes which are part of the Volume. But session status +file only present in initiated node. + +Show Session corrupted only if status file exists and invalid content. + +Change-Id: I8443c0335b872645b54c0aa77d9893dbe2589c92 +Signed-off-by: Aravinda VK +BUG: 1232569 +Reviewed-on: http://review.gluster.org/11699 +Reviewed-on: http://review.gluster.org/12028 +Reviewed-on: https://code.engineering.redhat.com/gerrit/56497 +Reviewed-by: Milind Changire +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Kotresh Hiremath Ravishankar +--- + tools/glusterfind/src/main.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index 9a6a2ac..b4d2c7e 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -519,7 +519,7 @@ def mode_list(session_dir, args): + last_processed = f.read().strip() + except (OSError, IOError) as e: + if e.errno == ENOENT: +- pass ++ continue + else: + raise + output.append((session, volname, last_processed)) +-- +1.7.1 + diff --git a/SOURCES/0306-tools-glusterfind-Prepend-prefix-in-case-of-delete.patch b/SOURCES/0306-tools-glusterfind-Prepend-prefix-in-case-of-delete.patch new file mode 100644 index 0000000..ed72e52 --- /dev/null +++ b/SOURCES/0306-tools-glusterfind-Prepend-prefix-in-case-of-delete.patch @@ -0,0 +1,137 @@ +From ae85bbe6d89744e31be374dfba7287250d93a729 Mon Sep 17 00:00:00 2001 +From: Saravanakumar Arumugam +Date: Fri, 17 Jul 2015 15:51:22 +0530 +Subject: [PATCH 306/320] tools/glusterfind: Prepend prefix in case of delete + +In case of delete operation alone, output prefix adding +was not handled earlier. +Output prefix is added now. + +Change-Id: Ia91444dddbff501b26a864f6185ca4c0aaf4c802 +Reviewed-on: http://review.gluster.org/11712/ +Reviewed-on: http://review.gluster.org/12016/ +BUG: 1241385 +Signed-off-by: Saravanakumar Arumugam +Reviewed-on: https://code.engineering.redhat.com/gerrit/56398 +Reviewed-by: Milind Changire +Reviewed-by: Kotresh Hiremath Ravishankar +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/changelog.py | 18 ++++-------------- + tools/glusterfind/src/changelogdata.py | 8 ++++++-- + tools/glusterfind/src/utils.py | 13 +++++++++++++ + 3 files changed, 23 insertions(+), 16 deletions(-) + +diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py +index 5939d48..4d0a190 100644 +--- a/tools/glusterfind/src/changelog.py ++++ b/tools/glusterfind/src/changelog.py +@@ -21,6 +21,7 @@ import libgfchangelog + from utils import mkdirp, symlink_gfid_to_path + from utils import fail, setup_logger, find + from utils import get_changelog_rollover_time ++from utils import output_path_prepare + from changelogdata import ChangelogData + import conf + +@@ -37,17 +38,6 @@ history_turn_time = 0 + logger = logging.getLogger() + + +-def output_path_prepare(path, output_prefix): +- """ +- If Prefix is set, joins to Path, removes ending slash +- and encodes it. +- """ +- if output_prefix != ".": +- path = os.path.join(output_prefix, path) +- if path.endswith("/"): +- path = path[0:len(path)-1] +- +- return urllib.quote_plus(path) + + + def pgfid_to_path(brick, changelog_data): +@@ -217,7 +207,7 @@ def gfid_to_path_using_batchfind(brick, changelog_data): + ignore_dirs=ignore_dirs) + + +-def parse_changelog_to_db(changelog_data, filename): ++def parse_changelog_to_db(changelog_data, filename, args): + """ + Parses a Changelog file and populates data in gfidpath table + """ +@@ -240,7 +230,7 @@ def parse_changelog_to_db(changelog_data, filename): + changelog_data.when_rename(changelogfile, data) + elif data[0] == "E" and data[2] in ["UNLINK", "RMDIR"]: + # UNLINK/RMDIR +- changelog_data.when_unlink_rmdir(changelogfile, data) ++ changelog_data.when_unlink_rmdir(changelogfile, data, args) + + + def get_changes(brick, hash_dir, log_file, start, end, args): +@@ -300,7 +290,7 @@ def get_changes(brick, hash_dir, log_file, start, end, args): + if change.endswith(".%s" % start): + continue + try: +- parse_changelog_to_db(changelog_data, change) ++ parse_changelog_to_db(changelog_data, change, args) + libgfchangelog.cl_history_done(change) + except IOError as e: + logger.warn("Error parsing changelog file %s: %s" % +diff --git a/tools/glusterfind/src/changelogdata.py b/tools/glusterfind/src/changelogdata.py +index 08d711b..39a16d5 100644 +--- a/tools/glusterfind/src/changelogdata.py ++++ b/tools/glusterfind/src/changelogdata.py +@@ -13,7 +13,7 @@ import urllib + import os + + from utils import RecordType +- ++from utils import output_path_prepare + + class OutputMerger(object): + """ +@@ -386,12 +386,16 @@ class ChangelogData(object): + not self.gfidpath_exists({"gfid": data[1], "type": "MODIFY"}): + self.gfidpath_add(changelogfile, RecordType.MODIFY, data[1]) + +- def when_unlink_rmdir(self, changelogfile, data): ++ def when_unlink_rmdir(self, changelogfile, data, args): + # E / + pgfid1, bn1 = urllib.unquote_plus(data[3]).split("/", 1) + # Quote again the basename + bn1 = urllib.quote_plus(bn1.strip()) ++ + deleted_path = data[4] if len(data) == 5 else "" ++ if deleted_path != "": ++ deleted_path = output_path_prepare(deleted_path, ++ args.output_prefix) + + if self.gfidpath_exists({"gfid": data[1], "type": "NEW", + "pgfid1": pgfid1, "bn1": bn1}): +diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py +index cda5ea6..fdf61fe 100644 +--- a/tools/glusterfind/src/utils.py ++++ b/tools/glusterfind/src/utils.py +@@ -226,3 +226,16 @@ def get_changelog_rollover_time(volumename): + return int(tree.find('volGetopts/Value').text) + except ParseError: + return DEFAULT_CHANGELOG_INTERVAL ++ ++ ++def output_path_prepare(path, output_prefix): ++ """ ++ If Prefix is set, joins to Path, removes ending slash ++ and encodes it. ++ """ ++ if output_prefix != ".": ++ path = os.path.join(output_prefix, path) ++ if path.endswith("/"): ++ path = path[0:len(path)-1] ++ ++ return urllib.quote_plus(path) +-- +1.7.1 + diff --git a/SOURCES/0307-tools-glusterfind-password-prompts-for-peer-nodes-on.patch b/SOURCES/0307-tools-glusterfind-password-prompts-for-peer-nodes-on.patch new file mode 100644 index 0000000..e00e59e --- /dev/null +++ b/SOURCES/0307-tools-glusterfind-password-prompts-for-peer-nodes-on.patch @@ -0,0 +1,46 @@ +From 38a5a035ccba395dde991ab849a26b6f65257a16 Mon Sep 17 00:00:00 2001 +From: Milind Changire +Date: Wed, 5 Aug 2015 16:21:51 +0530 +Subject: [PATCH 307/320] tools/glusterfind: password prompts for peer nodes on delete + +SSH keys getting deleted on local node caused password prompts for peer +nodes on a delete operation. + +This race for session directory cleanup on local node is now addressed +by avoiding the delete path for local node in node_cmd() +The session directory tree is deleted anyway in mode_delete() + +Change-Id: I8d000b01f523fffc0336bbec51b55099c0d4430f +BUG: 1234213 +Reviewed-on: http://review.gluster.org/#/c/11832/ +Reviewed-on: http://review.gluster.org/#/c/11693/ +Signed-off-by: Milind Changire +Reviewed-on: https://code.engineering.redhat.com/gerrit/54471 +Reviewed-by: Saravanakumar Arumugam +Reviewed-by: Kotresh Hiremath Ravishankar +Reviewed-by: Aravinda Vishwanathapura Krishna Murthy +Tested-by: Aravinda Vishwanathapura Krishna Murthy +--- + tools/glusterfind/src/main.py | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index b4d2c7e..6c2568e 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -55,6 +55,12 @@ def node_cmd(host, host_uuid, task, cmd, args, opts): + """ + localdir = is_host_local(host_uuid) + ++ # this is so to avoid deleting the ssh keys on local node which otherwise ++ # cause ssh password prompts on the console (race conditions) ++ # mode_delete() should be cleaning up the session tree ++ if localdir and task == "delete": ++ return ++ + pem_key_path = get_pem_key_path(args.session, args.volume) + + if not localdir: +-- +1.7.1 + diff --git a/SOURCES/0308-marker-fix-log-when-loc.parent-and-inode-gfid-is-NUL.patch b/SOURCES/0308-marker-fix-log-when-loc.parent-and-inode-gfid-is-NUL.patch new file mode 100644 index 0000000..77628d0 --- /dev/null +++ b/SOURCES/0308-marker-fix-log-when-loc.parent-and-inode-gfid-is-NUL.patch @@ -0,0 +1,512 @@ +From fa6b4f05369b3ce0172cf05cd5770ac10d76ed0f Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 20 Aug 2015 12:01:57 +0530 +Subject: [PATCH 308/320] marker: fix log when loc.parent and inode gfid is NULL + +This is a backport of http://review.gluster.org/#/c/11863/ + +This patch does the following + +1) Set loc.parent if it is NULL + Don't log warning in txn if parent is NULL +2) Don't initiate txn when inode gfid is NULL +3) optimize invoking dirty txn with status flag + +> Change-Id: I67dd9e6268014b0b257c136e951e6ded0a2e911f +> BUG: 1251454 +> Signed-off-by: vmallika + +Change-Id: I3851f1f0bf43168fb369ad17fdf5c0bf27c6a631 +BUG: 1251457 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/56468 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 256 ++++++++++++++++++---------- + xlators/features/marker/src/marker-quota.h | 1 + + 2 files changed, 168 insertions(+), 89 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index bb9dfa8..b582158 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -64,111 +64,129 @@ out: + return ret; + } + +-int32_t +-mq_get_ctx_updation_status (quota_inode_ctx_t *ctx, ++static void ++mq_set_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag, ++ gf_boolean_t status) ++{ ++ LOCK (&ctx->lock); ++ { ++ *flag = status; ++ } ++ UNLOCK (&ctx->lock); ++} ++ ++static void ++mq_test_and_set_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag, + gf_boolean_t *status) + { +- int32_t ret = -1; ++ gf_boolean_t temp = _gf_false; + +- GF_VALIDATE_OR_GOTO ("marker", ctx, out); +- GF_VALIDATE_OR_GOTO ("marker", status, out); ++ LOCK (&ctx->lock); ++ { ++ temp = *status; ++ *status = *flag; ++ *flag = temp; ++ } ++ UNLOCK (&ctx->lock); ++} + ++static void ++mq_get_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag, ++ gf_boolean_t *status) ++{ + LOCK (&ctx->lock); + { +- *status = ctx->updation_status; ++ *status = *flag; + } + UNLOCK (&ctx->lock); ++} + +- ret = 0; ++int32_t ++mq_get_ctx_updation_status (quota_inode_ctx_t *ctx, ++ gf_boolean_t *status) ++{ ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); ++ GF_VALIDATE_OR_GOTO ("marker", status, out); ++ ++ mq_get_ctx_status (ctx, &ctx->updation_status, status); ++ return 0; + out: +- return ret; ++ return -1; + } + +- + int32_t + mq_set_ctx_updation_status (quota_inode_ctx_t *ctx, + gf_boolean_t status) + { +- int32_t ret = -1; +- +- if (ctx == NULL) +- goto out; +- +- LOCK (&ctx->lock); +- { +- ctx->updation_status = status; +- } +- UNLOCK (&ctx->lock); ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); + +- ret = 0; ++ mq_set_ctx_status (ctx, &ctx->updation_status, status); ++ return 0; + out: +- return ret; ++ return -1; + } + + int32_t + mq_test_and_set_ctx_updation_status (quota_inode_ctx_t *ctx, + gf_boolean_t *status) + { +- int32_t ret = -1; +- gf_boolean_t temp = _gf_false; +- + GF_VALIDATE_OR_GOTO ("marker", ctx, out); + GF_VALIDATE_OR_GOTO ("marker", status, out); + +- LOCK (&ctx->lock); +- { +- temp = *status; +- *status = ctx->updation_status; +- ctx->updation_status = temp; +- } +- UNLOCK (&ctx->lock); +- +- ret = 0; ++ mq_test_and_set_ctx_status (ctx, &ctx->updation_status, status); ++ return 0; + out: +- return ret; ++ return -1; + } + + int32_t + mq_set_ctx_create_status (quota_inode_ctx_t *ctx, + gf_boolean_t status) + { +- int32_t ret = -1; +- +- if (ctx == NULL) +- goto out; +- +- LOCK (&ctx->lock); +- { +- ctx->create_status = status; +- } +- UNLOCK (&ctx->lock); ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); + +- ret = 0; ++ mq_set_ctx_status (ctx, &ctx->create_status, status); ++ return 0; + out: +- return ret; ++ return -1; + } + + int32_t + mq_test_and_set_ctx_create_status (quota_inode_ctx_t *ctx, + gf_boolean_t *status) + { +- int32_t ret = -1; +- gf_boolean_t temp = _gf_false; +- + GF_VALIDATE_OR_GOTO ("marker", ctx, out); + GF_VALIDATE_OR_GOTO ("marker", status, out); + +- LOCK (&ctx->lock); +- { +- temp = *status; +- *status = ctx->create_status; +- ctx->create_status = temp; +- } +- UNLOCK (&ctx->lock); ++ mq_test_and_set_ctx_status (ctx, &ctx->create_status, status); ++ return 0; ++out: ++ return -1; ++} + +- ret = 0; ++int32_t ++mq_set_ctx_dirty_status (quota_inode_ctx_t *ctx, ++ gf_boolean_t status) ++{ ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); ++ ++ mq_set_ctx_status (ctx, &ctx->dirty_status, status); ++ return 0; + out: +- return ret; ++ return -1; ++} ++ ++int32_t ++mq_test_and_set_ctx_dirty_status (quota_inode_ctx_t *ctx, ++ gf_boolean_t *status) ++{ ++ GF_VALIDATE_OR_GOTO ("marker", ctx, out); ++ GF_VALIDATE_OR_GOTO ("marker", status, out); ++ ++ mq_test_and_set_ctx_status (ctx, &ctx->dirty_status, status); ++ return 0; ++out: ++ return -1; + } + + void +@@ -2401,6 +2419,7 @@ mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "failed to get inode ctx for " + "%s", loc->path); ++ ret = 0; + goto out; + } + +@@ -2833,8 +2852,7 @@ mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc, + quota_inode_ctx_t *ctxtmp = NULL; + + if (origin_loc == NULL || origin_loc->inode == NULL || +- (gf_uuid_is_null(origin_loc->gfid) && +- gf_uuid_is_null(origin_loc->inode->gfid))) ++ gf_uuid_is_null(origin_loc->inode->gfid)) + goto out; + + loc_copy (loc, origin_loc); +@@ -2842,6 +2860,14 @@ mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc, + if (gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (loc->gfid, loc->inode->gfid); + ++ if (!loc_is_root(loc) && loc->parent == NULL) { ++ loc->parent = inode_parent (loc->inode, 0, NULL); ++ if (loc->parent == NULL) { ++ ret = -1; ++ goto out; ++ } ++ } ++ + if (ctx) + ret = mq_inode_ctx_get (loc->inode, this, ctx); + else +@@ -2985,6 +3011,7 @@ mq_reduce_parent_size_task (void *opaque) + { + int32_t ret = -1; + quota_inode_ctx_t *ctx = NULL; ++ quota_inode_ctx_t *parent_ctx = NULL; + inode_contribution_t *contribution = NULL; + quota_meta_t delta = {0, }; + quota_meta_t contri = {0, }; +@@ -3004,13 +3031,6 @@ mq_reduce_parent_size_task (void *opaque) + this = args->this; + THIS = this; + +- ret = mq_inode_ctx_get (loc->inode, this, &ctx); +- if (ret < 0) { +- gf_log_callingfn (this->name, GF_LOG_WARNING, "ctx for" +- " the node %s is NULL", loc->path); +- goto out; +- } +- + ret = mq_inode_loc_fill (NULL, loc->parent, &parent_loc); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "loc fill failed"); +@@ -3033,6 +3053,14 @@ mq_reduce_parent_size_task (void *opaque) + delta.dir_count = contri.dir_count; + } else { + remove_xattr = _gf_true; ++ ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) { ++ gf_log_callingfn (this->name, GF_LOG_WARNING, "ctx for" ++ " the node %s is NULL", loc->path); ++ goto out; ++ } ++ + contribution = mq_get_contribution_node (loc->parent, ctx); + if (contribution == NULL) { + ret = -1; +@@ -3072,8 +3100,20 @@ mq_reduce_parent_size_task (void *opaque) + goto out; + + out: +- if (dirty && ret >= 0) +- ret = mq_mark_dirty (this, &parent_loc, 0); ++ if (dirty) { ++ if (ret < 0) { ++ /* On failure clear dirty status flag. ++ * In the next lookup inspect_directory_xattr ++ * can set the status flag and fix the ++ * dirty directory ++ */ ++ ret = mq_inode_ctx_get (parent_loc.inode, this, ++ &parent_ctx); ++ mq_set_ctx_dirty_status (parent_ctx, _gf_false); ++ } else { ++ ret = mq_mark_dirty (this, &parent_loc, 0); ++ } ++ } + + if (locked) + ret = mq_lock (this, &parent_loc, F_UNLCK); +@@ -3108,12 +3148,6 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, + goto out; + } + +- if (loc.parent == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, " +- "aborting reduce parent size txn", loc.path); +- goto out; +- } +- + ret = mq_synctask1 (this, mq_reduce_parent_size_task, _gf_true, &loc, + contri); + out: +@@ -3136,6 +3170,7 @@ mq_initiate_quota_task (void *opaque) + loc_t *loc = NULL; + inode_contribution_t *contri = NULL; + quota_inode_ctx_t *ctx = NULL; ++ quota_inode_ctx_t *parent_ctx = NULL; + inode_t *tmp_parent = NULL; + + GF_VALIDATE_OR_GOTO ("marker", opaque, out); +@@ -3303,8 +3338,20 @@ mq_initiate_quota_task (void *opaque) + } + + out: +- if (ret >= 0 && dirty) +- ret = mq_mark_dirty (this, &parent_loc, 0); ++ if (dirty) { ++ if (ret < 0) { ++ /* On failure clear dirty status flag. ++ * In the next lookup inspect_directory_xattr ++ * can set the status flag and fix the ++ * dirty directory ++ */ ++ ret = mq_inode_ctx_get (parent_loc.inode, this, ++ &parent_ctx); ++ mq_set_ctx_dirty_status (parent_ctx, _gf_false); ++ } else { ++ ret = mq_mark_dirty (this, &parent_loc, 0); ++ } ++ } + + if (locked) + ret = mq_lock (this, &parent_loc, F_UNLCK); +@@ -3341,12 +3388,6 @@ _mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn) + goto out; + } + +- if (loc.parent == NULL) { +- gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, " +- "aborting updation txn", loc.path); +- goto out; +- } +- + ret = mq_test_and_set_ctx_updation_status (ctx, &status); + if (ret < 0 || status == _gf_true) + goto out; +@@ -3409,6 +3450,7 @@ mq_update_dirty_inode_task (void *opaque) + quota_synctask_t *args = NULL; + xlator_t *this = NULL; + loc_t *loc = NULL; ++ quota_inode_ctx_t *ctx = NULL; + + GF_ASSERT (opaque); + +@@ -3417,6 +3459,10 @@ mq_update_dirty_inode_task (void *opaque) + this = args->this; + THIS = this; + ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) ++ goto out; ++ + ret = mq_lock (this, loc, F_WRLCK); + if (ret < 0) + goto out; +@@ -3526,8 +3572,16 @@ out: + if (fd) + fd_unref (fd); + +- if (ret >= 0 && dirty) ++ if (ret < 0) { ++ /* On failure clear dirty status flag. ++ * In the next lookup inspect_directory_xattr ++ * can set the status flag and fix the ++ * dirty directory ++ */ ++ mq_set_ctx_dirty_status (ctx, _gf_false); ++ } else if (dirty) { + mq_mark_dirty (this, loc, 0); ++ } + + if (locked) + mq_lock (this, loc, F_UNLCK); +@@ -3541,15 +3595,23 @@ out: + } + + int32_t +-mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc) ++mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx) + { +- int32_t ret = -1; ++ int32_t ret = -1; ++ gf_boolean_t status = _gf_true; + + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); + ++ ret = mq_test_and_set_ctx_dirty_status (ctx, &status); ++ if (ret < 0 || status == _gf_true) ++ goto out; ++ + ret = mq_synctask (this, mq_update_dirty_inode_task, _gf_true, loc); + out: ++ if (ret < 0 && status == _gf_false) ++ mq_set_ctx_dirty_status (ctx, _gf_false); ++ + return ret; + } + +@@ -3564,6 +3626,7 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx, + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; ++ gf_boolean_t status = _gf_false; + + ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY, &dirty); + if (ret < 0) { +@@ -3603,15 +3666,21 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx, + ctx->size = size.size; + ctx->file_count = size.file_count; + ctx->dir_count = size.dir_count; ++ ctx->dirty = dirty; + } + UNLOCK (&ctx->lock); + ++ ret = mq_get_ctx_updation_status (ctx, &status); ++ if (ret < 0 || status == _gf_true) { ++ /* If the update txn is in progress abort inspection */ ++ ret = 0; ++ goto out; ++ } ++ + mq_compute_delta (&delta, &size, &contri); + + if (dirty) { +- if (ctx->dirty == 0) +- ret = mq_update_dirty_inode_txn (this, loc); +- ++ ret = mq_update_dirty_inode_txn (this, loc, ctx); + goto out; + } + +@@ -3620,6 +3689,7 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx, + mq_initiate_quota_txn (this, loc); + + ret = 0; ++ goto out; + + create_xattr: + if (ret < 0) +@@ -3639,6 +3709,7 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, + quota_meta_t contri = {0, }; + quota_meta_t delta = {0, }; + char contri_key[CONTRI_KEY_MAX] = {0, }; ++ gf_boolean_t status = _gf_false; + + LOCK (&ctx->lock); + { +@@ -3669,6 +3740,13 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx, + } + UNLOCK (&contribution->lock); + ++ ret = mq_get_ctx_updation_status (ctx, &status); ++ if (ret < 0 || status == _gf_true) { ++ /* If the update txn is in progress abort inspection */ ++ ret = 0; ++ goto out; ++ } ++ + mq_compute_delta (&delta, &size, &contri); + if (!quota_meta_is_null (&delta)) + mq_initiate_quota_txn (this, loc); +diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h +index 65cb0b2..1f50c26 100644 +--- a/xlators/features/marker/src/marker-quota.h ++++ b/xlators/features/marker/src/marker-quota.h +@@ -91,6 +91,7 @@ struct quota_inode_ctx { + int8_t dirty; + gf_boolean_t create_status; + gf_boolean_t updation_status; ++ gf_boolean_t dirty_status; + gf_lock_t lock; + struct list_head contribution_head; + }; +-- +1.7.1 + diff --git a/SOURCES/0309-posix-xattrop-GF_XATTROP_GET_AND_SET-implementation.patch b/SOURCES/0309-posix-xattrop-GF_XATTROP_GET_AND_SET-implementation.patch new file mode 100644 index 0000000..5e5e821 --- /dev/null +++ b/SOURCES/0309-posix-xattrop-GF_XATTROP_GET_AND_SET-implementation.patch @@ -0,0 +1,165 @@ +From 86318073e0c3c9747badf26733b66d070b67064e Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 27 Aug 2015 11:31:01 +0530 +Subject: [PATCH 309/320] posix: xattrop 'GF_XATTROP_GET_AND_SET' implementation + +This is a backport of http://review.gluster.org/#/c/11995 + +GF_XATTROP_GET_AND_SET stores the existing xattr +value in xdata and sets the new value + +xattrop was reusing input xattr dict to set the results +instead of creating new dict. +This can be problem for server side xlators as the inout dict +will have the value changed. + +> Change-Id: I43369082e1d0090d211381181e9f3b9075b8e771 +> BUG: 1251454 +> Signed-off-by: vmallika + +Change-Id: I2033c5bde803f9fd0c1cd39192d51003d22776d3 +BUG: 1251457 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/56467 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + libglusterfs/src/glusterfs.h | 3 +- + xlators/storage/posix/src/posix.c | 38 +++++++++++++++++++++++++++++++----- + 2 files changed, 34 insertions(+), 7 deletions(-) + +diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h +index 97965ab..87a63db 100644 +--- a/libglusterfs/src/glusterfs.h ++++ b/libglusterfs/src/glusterfs.h +@@ -376,7 +376,8 @@ typedef enum { + GF_XATTROP_ADD_ARRAY, + GF_XATTROP_ADD_ARRAY64, + GF_XATTROP_OR_ARRAY, +- GF_XATTROP_AND_ARRAY ++ GF_XATTROP_AND_ARRAY, ++ GF_XATTROP_GET_AND_SET + } gf_xattrop_flags_t; + + #define GF_SET_IF_NOT_PRESENT 0x1 /* default behaviour */ +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 535e5ff..f1ebcc6 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -4820,6 +4820,7 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + int op_errno = 0; + gf_xattrop_flags_t optype = 0; + char *array = NULL; ++ char *dst_data = NULL; + inode_t *inode = NULL; + xlator_t *this = NULL; + posix_xattr_filler_t *filler = NULL; +@@ -4883,6 +4884,11 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + goto unlock; + } + ++ if (size == -1 && optype == GF_XATTROP_GET_AND_SET) { ++ GF_FREE (array); ++ array = NULL; ++ } ++ + /* We only write back the xattr if it has been really modified + * (i.e. v->data is not all 0's). Otherwise we return its value + * but we don't update anything. +@@ -4890,7 +4896,8 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + * If the xattr does not exist, a value of all 0's is returned + * without creating it. */ + size = v->len; +- if (mem_0filled(v->data, v->len) == 0) ++ if (optype != GF_XATTROP_GET_AND_SET && ++ mem_0filled(v->data, v->len) == 0) + goto unlock; + + switch (optype) { +@@ -4898,12 +4905,18 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + case GF_XATTROP_ADD_ARRAY: + __add_array ((int32_t *) array, + (int32_t *) v->data, v->len / 4); ++ dst_data = array; + break; + + case GF_XATTROP_ADD_ARRAY64: + __add_long_array ((int64_t *) array, + (int64_t *) v->data, + v->len / 8); ++ dst_data = array; ++ break; ++ ++ case GF_XATTROP_GET_AND_SET: ++ dst_data = v->data; + break; + + default: +@@ -4919,10 +4932,10 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + + if (filler->real_path) { + size = sys_lsetxattr (filler->real_path, k, +- array, v->len, 0); ++ dst_data, v->len, 0); + } else { + size = sys_fsetxattr (filler->fdnum, k, +- (char *)array, ++ (char *)dst_data, + v->len, 0); + } + op_errno = errno; +@@ -4948,8 +4961,8 @@ unlock: + k, strerror (op_errno)); + op_ret = -1; + goto out; +- } else { +- size = dict_set_bin (d, k, array, v->len); ++ } else if (array) { ++ size = dict_set_bin (filler->xattr, k, array, v->len); + + if (size != 0) { + if (filler->real_path) +@@ -4999,6 +5012,7 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + struct posix_fd *pfd = NULL; + inode_t *inode = NULL; + posix_xattr_filler_t filler = {0,}; ++ dict_t *xdata = NULL; + + VALIDATE_OR_GOTO (frame, out); + VALIDATE_OR_GOTO (xattr, out); +@@ -5031,11 +5045,19 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + inode = fd->inode; + } + ++ xdata = dict_new (); ++ if (xdata == NULL) { ++ op_ret = -1; ++ op_errno = ENOMEM; ++ goto out; ++ } ++ + filler.this = this; + filler.fdnum = _fd; + filler.real_path = real_path; + filler.flags = (int)optype; + filler.inode = inode; ++ filler.xattr = xdata; + + op_ret = dict_foreach (xattr, _posix_handle_xattr_keyvalue_pair, + &filler); +@@ -5043,7 +5065,11 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + + out: + +- STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr, NULL); ++ STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xdata, xdata); ++ ++ if (xdata) ++ dict_unref (xdata); ++ + return 0; + } + +-- +1.7.1 + diff --git a/SOURCES/0310-cli-on-error-invoke-cli_cmd_broadcast_response-funct.patch b/SOURCES/0310-cli-on-error-invoke-cli_cmd_broadcast_response-funct.patch new file mode 100644 index 0000000..f528f98 --- /dev/null +++ b/SOURCES/0310-cli-on-error-invoke-cli_cmd_broadcast_response-funct.patch @@ -0,0 +1,237 @@ +From bc759c626e16af3be07f82bb8203a3c455973757 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Mon, 24 Aug 2015 08:07:14 +0530 +Subject: [PATCH 310/320] cli: on error invoke cli_cmd_broadcast_response function in separate thread + +This is a backport of http://review.gluster.org/#/c/11990/ + +There is a problem in current CLI framework +CLI holds the lock when processing command. +When processing quota list command, below sequence of steps executed in the +same thread and causing deadlock + +1) CLI holds the lock +2) Send rpc_clnt_submit request to quotad for quota usage +3) If quotad is down, rpc_clnt_submit invokes cbk function with error +4) cbk function cli_quotad_getlimit_cbk tries to hold lock to broadcast + the results and hangs, because same thread has already holding the lock + +This patch fixes the problem by creating seperate thread for +broadcasting the result + +> Change-Id: I53be006eadf6aaf348083d9168535530d70a8ab3 +> BUG: 1242819 +> Signed-off-by: vmallika + +Change-Id: Id010b95be689a947dd7ef75500d6c00d0f78cd3c +BUG: 1242803 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/56573 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + cli/src/cli-cmd-volume.c | 12 ------ + cli/src/cli-rpc-ops.c | 94 ++++++++++++++++++++++++++++++++++++++++++--- + cli/src/cli.c | 1 + + cli/src/cli.h | 1 + + 4 files changed, 89 insertions(+), 19 deletions(-) + +diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c +index 6dd3058..ca18108 100644 +--- a/cli/src/cli-cmd-volume.c ++++ b/cli/src/cli-cmd-volume.c +@@ -1381,18 +1381,6 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options) + CLI_LOCAL_INIT (local, words, frame, xdata); + proc = &cli_quotad_clnt.proctable[GF_AGGREGATOR_GETLIMIT]; + +- if (!(global_state->mode & GLUSTER_MODE_XML)) { +- print_quota_list_header (type); +- } else { +- ret = cli_xml_output_vol_quota_limit_list_begin +- (local, 0, 0, NULL); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Error in printing " +- "xml output"); +- goto out; +- } +- } +- + gfid_str = GF_CALLOC (1, gf_common_mt_char, 64); + if (!gfid_str) { + ret = -1; +diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c +index dfc5c6b..fd76df7 100644 +--- a/cli/src/cli-rpc-ops.c ++++ b/cli/src/cli-rpc-ops.c +@@ -3232,7 +3232,8 @@ out: + } + + int +-print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict) ++print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict, ++ int32_t list_count) + { + char *path = NULL; + char *default_sl = NULL; +@@ -3244,11 +3245,11 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict) + quota_limits_t *size_limits = NULL; + int32_t type = 0; + ++ GF_ASSERT (frame); ++ + local = frame->local; + gd_rsp_dict = local->dict; + +- GF_ASSERT (frame); +- + ret = dict_get_int32 (rsp_dict, "type", &type); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to get type"); +@@ -3306,12 +3307,37 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict) + goto out; + } + ++ if (list_count == 0) { ++ if (!(global_state->mode & GLUSTER_MODE_XML)) { ++ print_quota_list_header (type); ++ } else { ++ ret = cli_xml_output_vol_quota_limit_list_begin ++ (local, 0, 0, NULL); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Error in " ++ "printing xml output"); ++ goto out; ++ } ++ } ++ } ++ + ret = print_quota_list_output (local, path, default_sl, &limits, + &used_space, type); + out: + return ret; + } + ++void* ++cli_cmd_broadcast_response_detached (void *opaque) ++{ ++ int32_t ret = 0; ++ ++ ret = (intptr_t) opaque; ++ cli_cmd_broadcast_response (ret); ++ ++ return NULL; ++} ++ + int + cli_quotad_getlimit_cbk (struct rpc_req *req, struct iovec *iov, + int count, void *myframe) +@@ -3321,12 +3347,41 @@ cli_quotad_getlimit_cbk (struct rpc_req *req, struct iovec *iov, + int ret = -1; + dict_t *dict = NULL; + call_frame_t *frame = NULL; ++ cli_local_t *local = NULL; ++ dict_t *gd_rsp_dict = NULL; ++ int32_t list_count = 0; ++ pthread_t th_id = {0, }; + +- if (-1 == req->rpc_status) { ++ frame = myframe; ++ GF_ASSERT (frame); ++ ++ local = frame->local; ++ gd_rsp_dict = local->dict; ++ ++ LOCK (&local->lock); ++ { ++ ret = dict_get_int32 (gd_rsp_dict, "quota-list-count", ++ &list_count); ++ if (ret) ++ list_count = 0; ++ ret = dict_set_int32 (gd_rsp_dict, "quota-list-count", ++ list_count + 1); ++ } ++ UNLOCK (&local->lock); ++ ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to set " ++ "quota-list-count in dict"); + goto out; + } + +- frame = myframe; ++ if (-1 == req->rpc_status) { ++ if (list_count == 0) ++ cli_err ("Connection failed. Please check if quota " ++ "daemon is operational."); ++ ret = -1; ++ goto out; ++ } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); + if (ret < 0) { +@@ -3357,11 +3412,36 @@ cli_quotad_getlimit_cbk (struct rpc_req *req, struct iovec *iov, + "unserialize req-buffer to dictionary"); + goto out; + } +- print_quota_list_from_quotad (frame, dict); ++ print_quota_list_from_quotad (frame, dict, list_count); + } + + out: +- cli_cmd_broadcast_response (ret); ++ /* Bad Fix: CLI holds the lock to process a command. ++ * When processing quota list command, below sequence of steps executed ++ * in the same thread and causing deadlock ++ * ++ * 1) CLI holds the lock ++ * 2) Send rpc_clnt_submit request to quotad for quota usage ++ * 3) If quotad is down, rpc_clnt_submit invokes cbk function with error ++ * 4) cbk function cli_quotad_getlimit_cbk invokes ++ * cli_cmd_broadcast_response which tries to hold lock to broadcast ++ * the results and hangs, because same thread has already holding ++ * the lock ++ * ++ * Broadcasting response in a seperate thread which is not a ++ * good fix. This needs to be re-visted with better solution ++ */ ++ if (ret == -1) { ++ ret = pthread_create (&th_id, NULL, ++ cli_cmd_broadcast_response_detached, ++ (void *)-1); ++ if (ret) ++ gf_log ("cli", GF_LOG_ERROR, "pthread_create failed: " ++ "%s", strerror (errno)); ++ } else { ++ cli_cmd_broadcast_response (ret); ++ } ++ + if (dict) + dict_unref (dict); + +diff --git a/cli/src/cli.c b/cli/src/cli.c +index 851178b..fa5b682 100644 +--- a/cli/src/cli.c ++++ b/cli/src/cli.c +@@ -653,6 +653,7 @@ cli_local_get () + cli_local_t *local = NULL; + + local = GF_CALLOC (1, sizeof (*local), cli_mt_cli_local_t); ++ LOCK_INIT (&local->lock); + + return local; + } +diff --git a/cli/src/cli.h b/cli/src/cli.h +index 6c0fbce..d831af0 100644 +--- a/cli/src/cli.h ++++ b/cli/src/cli.h +@@ -151,6 +151,7 @@ struct cli_local { + xmlDocPtr doc; + int vol_count; + #endif ++ gf_lock_t lock; + }; + + struct cli_volume_status { +-- +1.7.1 + diff --git a/SOURCES/0311-dht-lock-on-subvols-to-prevent-lookup-vs-rmdir-race.patch b/SOURCES/0311-dht-lock-on-subvols-to-prevent-lookup-vs-rmdir-race.patch new file mode 100644 index 0000000..0147e78 --- /dev/null +++ b/SOURCES/0311-dht-lock-on-subvols-to-prevent-lookup-vs-rmdir-race.patch @@ -0,0 +1,917 @@ +From a288ff3ea3b792dcafaa4ffa247d3c6032d68f10 Mon Sep 17 00:00:00 2001 +From: Sakshi +Date: Thu, 16 Jul 2015 14:31:03 +0530 +Subject: [PATCH 311/320] dht : lock on subvols to prevent lookup vs rmdir race + +There is a possibility that while an rmdir is completed on +some non-hashed subvol and proceeding to others. A lookup +selfheal can recreate the same directory on those subvols +for which the rmdir had succeeded. The fix is to take a +blocking inodelk on the subvols before starting rmdir. +Since selfheal requires lock on all subvols, if an rmdir +is in progess acquiring locks will fail and vice versa. + +Change-Id: I841a44758c3b88f5e04d1cb73ad36e0cac9fdabb +BUG: 1115367 +Signed-off-by: Sakshi +Reviewed-on: http://review.gluster.org/11725 +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Reviewed-on: https://code.engineering.redhat.com/gerrit/56595 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 180 +++++++++++++++++++++++++++---- + xlators/cluster/dht/src/dht-common.h | 14 ++- + xlators/cluster/dht/src/dht-helper.c | 38 ++++++- + xlators/cluster/dht/src/dht-rename.c | 2 +- + xlators/cluster/dht/src/dht-selfheal.c | 181 +++++++++++++++++++++++--------- + 5 files changed, 331 insertions(+), 84 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 5c1a693..f819aa6 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -40,6 +40,10 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + int run_defrag = 0; + + int ++dht_rmdir_unlock (call_frame_t *frame, xlator_t *this); ++ ++ ++int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) + { + int ret = -1; +@@ -4514,7 +4518,6 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + * corresponding hashed subvolume will take care of the + * directory entry. + */ +- + if (readdir_optimize) { + if (prev->this == local->first_up_subvol) + goto list; +@@ -4999,7 +5002,7 @@ out: + if (local && local->lock.locks) { + /* store op_errno for failure case*/ + local->op_errno = op_errno; +- local->refresh_layout_unlock (frame, this, op_ret); ++ local->refresh_layout_unlock (frame, this, op_ret, 0); + + if (op_ret == 0) { + DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, +@@ -5044,7 +5047,7 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + return 0; + err: + if (local->lock.locks) +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); + + return 0; + } +@@ -5149,7 +5152,7 @@ dht_mknod_do (call_frame_t *frame) + local->umask, local->params); + return 0; + err: +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); + + return 0; + } +@@ -5164,7 +5167,7 @@ dht_mknod_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int32_t +-dht_mknod_finish (call_frame_t *frame, xlator_t *this, int op_ret) ++dht_mknod_finish (call_frame_t *frame, xlator_t *this, int op_ret, int invoke_cbk) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -5239,7 +5242,7 @@ dht_mknod_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + return 0; + err: +- dht_mknod_finish (frame, this, -1); ++ dht_mknod_finish (frame, this, -1, 0); + return 0; + } + +@@ -5270,7 +5273,7 @@ dht_mknod_lock (call_frame_t *frame, xlator_t *subvol) + local->lock.lk_count = count; + + ret = dht_blocking_inodelk (frame, lk_array, count, +- dht_mknod_lock_cbk); ++ IGNORE_ENOENT_ESTALE, dht_mknod_lock_cbk); + + if (ret < 0) { + local->lock.locks = NULL; +@@ -5797,7 +5800,7 @@ out: + if (local && local->lock.locks) { + /* store op_errno for failure case*/ + local->op_errno = op_errno; +- local->refresh_layout_unlock (frame, this, op_ret); ++ local->refresh_layout_unlock (frame, this, op_ret, 0); + + if (op_ret == 0) { + DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, +@@ -5838,7 +5841,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + return 0; + err: + if (local->lock.locks) +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); + + return 0; + } +@@ -6002,7 +6005,7 @@ dht_create_do (call_frame_t *frame) + local->umask, local->fd, local->params); + return 0; + err: +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); + + return 0; + } +@@ -6016,7 +6019,7 @@ dht_create_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int32_t +-dht_create_finish (call_frame_t *frame, xlator_t *this, int op_ret) ++dht_create_finish (call_frame_t *frame, xlator_t *this, int op_ret, int invoke_cbk) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -6091,7 +6094,7 @@ dht_create_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + return 0; + err: +- dht_create_finish (frame, this, -1); ++ dht_create_finish (frame, this, -1, 0); + return 0; + } + +@@ -6122,7 +6125,7 @@ dht_create_lock (call_frame_t *frame, xlator_t *subvol) + local->lock.lk_count = count; + + ret = dht_blocking_inodelk (frame, lk_array, count, +- dht_create_lock_cbk); ++ IGNORE_ENOENT_ESTALE, dht_create_lock_cbk); + + if (ret < 0) { + local->lock.locks = NULL; +@@ -6582,6 +6585,7 @@ unlock: + this_call_cnt = dht_frame_return (frame); + if (is_last_call (this_call_cnt)) { + if (local->need_selfheal) { ++ dht_rmdir_unlock (frame, this); + local->layout = + dht_layout_get (this, local->loc.inode); + +@@ -6605,6 +6609,7 @@ unlock: + 1); + } + ++ dht_rmdir_unlock (frame, this); + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, + local->op_errno, &local->preparent, + &local->postparent, NULL); +@@ -6673,6 +6678,7 @@ unlock: + + if (done) { + if (local->need_selfheal && local->fop_succeeded) { ++ dht_rmdir_unlock (frame, this); + local->layout = + dht_layout_get (this, local->loc.inode); + +@@ -6707,6 +6713,7 @@ unlock: + + } + ++ dht_rmdir_unlock (frame, this); + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, + local->op_errno, &local->preparent, + &local->postparent, NULL); +@@ -6718,11 +6725,110 @@ unlock: + + + int ++dht_rmdir_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ DHT_STACK_DESTROY (frame); ++ return 0; ++} ++ ++ ++int ++dht_rmdir_unlock (call_frame_t *frame, xlator_t *this) ++{ ++ dht_local_t *local = NULL, *lock_local = NULL; ++ call_frame_t *lock_frame = NULL; ++ int lock_count = 0; ++ ++ local = frame->local; ++ lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); ++ ++ if (lock_count == 0) ++ goto done; ++ ++ lock_frame = copy_frame (frame); ++ if (lock_frame == NULL) ++ goto done; ++ ++ lock_local = dht_local_init (lock_frame, &local->loc, NULL, ++ lock_frame->root->op); ++ if (lock_local == NULL) ++ goto done; ++ ++ lock_local->lock.locks = local->lock.locks; ++ lock_local->lock.lk_count = local->lock.lk_count; ++ ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ dht_unlock_inodelk (lock_frame, lock_local->lock.locks, ++ lock_local->lock.lk_count, ++ dht_rmdir_unlock_cbk); ++ lock_frame = NULL; ++ ++done: ++ if (lock_frame != NULL) { ++ DHT_STACK_DESTROY (lock_frame); ++ } ++ ++ return 0; ++} ++ ++ ++int ++dht_rmdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) ++{ ++ dht_local_t *local = NULL; ++ dht_conf_t *conf = NULL; ++ int i = 0; ++ ++ VALIDATE_OR_GOTO (this->private, err); ++ ++ conf = this->private; ++ local = frame->local; ++ ++ if (op_ret < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_INODE_LK_ERROR, ++ "acquiring inodelk failed rmdir for %s)", ++ local->loc.path); ++ ++ local->op_ret = -1; ++ local->op_errno = (op_errno == EAGAIN) ? EBUSY : op_errno; ++ goto err; ++ } ++ ++ for (i = 0; i < conf->subvolume_cnt; i++) { ++ if (local->hashed_subvol && ++ (local->hashed_subvol == conf->subvolumes[i])) ++ continue; ++ ++ STACK_WIND (frame, dht_rmdir_cbk, ++ conf->subvolumes[i], ++ conf->subvolumes[i]->fops->rmdir, ++ &local->loc, local->flags, NULL); ++ } ++ ++ return 0; ++ ++err: ++ /* No harm in calling an extra rmdir unlock */ ++ dht_rmdir_unlock (frame, this); ++ DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno, ++ &local->preparent, &local->postparent, NULL); ++ ++ return 0; ++} ++ ++ ++int + dht_rmdir_do (call_frame_t *frame, xlator_t *this) + { + dht_local_t *local = NULL; + dht_conf_t *conf = NULL; +- int i = 0; ++ dht_lock_t **lk_array = NULL; ++ int i = 0, ret = -1; ++ int count = 1; + xlator_t *hashed_subvol = NULL; + char gfid[GF_UUID_BUF_SIZE] ={0}; + +@@ -6736,7 +6842,6 @@ dht_rmdir_do (call_frame_t *frame, xlator_t *this) + + local->call_cnt = conf->subvolume_cnt; + +- + /* first remove from non-hashed_subvol */ + hashed_subvol = dht_subvol_get_hashed (this, &local->loc); + +@@ -6760,20 +6865,49 @@ dht_rmdir_do (call_frame_t *frame, xlator_t *this) + return 0; + } + +- for (i = 0; i < conf->subvolume_cnt; i++) { +- if (hashed_subvol && +- (hashed_subvol == conf->subvolumes[i])) +- continue; ++ count = conf->subvolume_cnt; + +- STACK_WIND (frame, dht_rmdir_cbk, +- conf->subvolumes[i], +- conf->subvolumes[i]->fops->rmdir, +- &local->loc, local->flags, NULL); ++ lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); ++ if (lk_array == NULL) { ++ local->op_ret = -1; ++ local->op_errno = ENOMEM; ++ goto err; ++ } ++ ++ for (i = 0; i < count; i++) { ++ lk_array[i] = dht_lock_new (frame->this, ++ conf->subvolumes[i], ++ &local->loc, F_WRLCK, ++ DHT_LAYOUT_HEAL_DOMAIN); ++ if (lk_array[i] == NULL) { ++ local->op_ret = -1; ++ local->op_errno = EINVAL; ++ goto err; ++ } ++ } ++ ++ local->lock.locks = lk_array; ++ local->lock.lk_count = count; ++ ++ ret = dht_blocking_inodelk (frame, lk_array, count, ++ IGNORE_ENOENT_ESTALE, ++ dht_rmdir_lock_cbk); ++ if (ret < 0) { ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ local->op_ret = -1; ++ local->op_errno = errno ? errno : EINVAL; ++ goto err; + } + + return 0; + + err: ++ if (lk_array != NULL) { ++ dht_lock_array_free (lk_array, count); ++ GF_FREE (lk_array); ++ } ++ + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno, + &local->preparent, &local->postparent, NULL); + return 0; +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 1b5a084..7f99a06 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -45,7 +45,7 @@ typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, xlator_t *dst_node, + call_frame_t *frame); + + typedef int (*dht_refresh_layout_unlock) (call_frame_t *frame, xlator_t *this, +- int op_ret); ++ int op_ret, int invoke_cbk); + + typedef int (*dht_refresh_layout_done_handle) (call_frame_t *frame); + +@@ -136,6 +136,11 @@ typedef enum { + qdstatfs_action_COMPARE, + } qdstatfs_action_t; + ++typedef enum { ++ FAIL_ON_ANY_ERROR, ++ IGNORE_ENOENT_ESTALE ++} dht_reaction_type_t; ++ + struct dht_skip_linkto_unlink { + + gf_boolean_t handle_valid_link; +@@ -266,6 +271,7 @@ struct dht_local { + fop_inodelk_cbk_t inodelk_cbk; + dht_lock_t **locks; + int lk_count; ++ dht_reaction_type_t reaction; + + /* whether locking failed on _any_ of the "locks" above */ + int op_ret; +@@ -1047,7 +1053,8 @@ dht_fill_dict_to_avoid_unlink_of_migrating_file (dict_t *dict); + + int + dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, fop_inodelk_cbk_t inodelk_cbk); ++ int lk_count, dht_reaction_type_t reaction, ++ fop_inodelk_cbk_t inodelk_cbk); + + /* same as dht_nonblocking_inodelk, but issues sequential blocking locks on + * @lk_array directly. locks are issued on some order which remains same +@@ -1055,7 +1062,8 @@ dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + */ + int + dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, fop_inodelk_cbk_t inodelk_cbk); ++ int lk_count, dht_reaction_type_t reaction, ++ fop_inodelk_cbk_t inodelk_cbk); + + int32_t + dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index 2e4a53c..1b3fbb0 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -347,6 +347,7 @@ dht_lock_new (xlator_t *this, xlator_t *xl, loc_t *loc, short type, + + lock->xl = xl; + lock->type = type; ++ + lock->domain = gf_strdup (domain); + if (lock->domain == NULL) { + dht_lock_free (lock); +@@ -1692,7 +1693,8 @@ out: + + int + dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, fop_inodelk_cbk_t inodelk_cbk) ++ int lk_count, dht_reaction_type_t reaction, ++ fop_inodelk_cbk_t inodelk_cbk) + { + struct gf_flock flock = {0,}; + int i = 0, ret = 0; +@@ -1715,6 +1717,7 @@ dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + dht_set_lkowner (lk_array, lk_count, &lock_frame->root->lk_owner); + + local = lock_frame->local; ++ local->lock.reaction = reaction; + local->main_frame = frame; + + local->call_cnt = lk_count; +@@ -1745,21 +1748,42 @@ dht_blocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) + { + int lk_index = 0; ++ int i = 0; + dht_local_t *local = NULL; + + lk_index = (long) cookie; + + local = frame->local; +- + if (op_ret == 0) { + local->lock.locks[lk_index]->locked = _gf_true; + } else { +- local->lock.op_ret = -1; +- local->lock.op_errno = op_errno; +- goto cleanup; ++ switch (op_errno) { ++ case ESTALE: ++ case ENOENT: ++ if (local->lock.reaction != IGNORE_ENOENT_ESTALE) { ++ local->lock.op_ret = -1; ++ local->lock.op_errno = op_errno; ++ goto cleanup; ++ } ++ break; ++ default: ++ local->lock.op_ret = -1; ++ local->lock.op_errno = op_errno; ++ goto cleanup; ++ } + } + + if (lk_index == (local->lock.lk_count - 1)) { ++ for (i = 0; (i < local->lock.lk_count) && ++ (!local->lock.locks[i]->locked); i++) { ++ ; ++ } ++ ++ if (i == local->lock.lk_count) { ++ local->lock.op_ret = -1; ++ local->lock.op_errno = op_errno; ++ } ++ + dht_inodelk_done (frame); + } else { + dht_blocking_inodelk_rec (frame, ++lk_index); +@@ -1833,7 +1857,8 @@ out: + + int + dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, fop_inodelk_cbk_t inodelk_cbk) ++ int lk_count, dht_reaction_type_t reaction, ++ fop_inodelk_cbk_t inodelk_cbk) + { + int ret = -1; + call_frame_t *lock_frame = NULL; +@@ -1855,6 +1880,7 @@ dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + dht_set_lkowner (lk_array, lk_count, &lock_frame->root->lk_owner); + + local = lock_frame->local; ++ local->lock.reaction = reaction; + local->main_frame = frame; + + dht_blocking_inodelk_rec (lock_frame, 0); +diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c +index 320f875..06d7ac8 100644 +--- a/xlators/cluster/dht/src/dht-rename.c ++++ b/xlators/cluster/dht/src/dht-rename.c +@@ -1307,7 +1307,7 @@ dht_rename_lock (call_frame_t *frame) + local->lock.lk_count = count; + + ret = dht_nonblocking_inodelk (frame, lk_array, count, +- dht_rename_lock_cbk); ++ FAIL_ON_ANY_ERROR, dht_rename_lock_cbk); + if (ret < 0) { + local->lock.locks = NULL; + local->lock.lk_count = 0; +diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c +index cd1d97f..46491cf 100644 +--- a/xlators/cluster/dht/src/dht-selfheal.c ++++ b/xlators/cluster/dht/src/dht-selfheal.c +@@ -82,7 +82,7 @@ dht_selfheal_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int +-dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret) ++dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret, int invoke_cbk) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -90,7 +90,6 @@ dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret) + + local = frame->local; + lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); +- + if (lock_count == 0) + goto done; + +@@ -117,8 +116,9 @@ dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret) + lock_frame = NULL; + + done: +- local->selfheal.dir_cbk (frame, NULL, frame->this, ret, +- local->op_errno, NULL); ++ if (!invoke_cbk) ++ local->selfheal.dir_cbk (frame, NULL, frame->this, ret, ++ local->op_errno, NULL); + if (lock_frame != NULL) { + DHT_STACK_DESTROY (lock_frame); + } +@@ -160,13 +160,13 @@ dht_refresh_layout_done (call_frame_t *frame) + + dht_layout_unref (frame->this, heal); + +- dht_selfheal_dir_finish (frame, frame->this, 0); ++ dht_selfheal_dir_finish (frame, frame->this, 0, 0); + } + + return 0; + + err: +- dht_selfheal_dir_finish (frame, frame->this, -1); ++ dht_selfheal_dir_finish (frame, frame->this, -1, 0); + return 0; + } + +@@ -224,8 +224,9 @@ unlock: + return 0; + + err: +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); + ++ dht_selfheal_dir_finish (frame, this, -1, 0); + return 0; + } + +@@ -291,7 +292,8 @@ dht_refresh_layout (call_frame_t *frame) + return 0; + + out: +- local->refresh_layout_unlock (frame, this, -1); ++ local->refresh_layout_unlock (frame, this, -1, 0); ++ dht_selfheal_dir_finish (frame, this, -1, 0); + return 0; + } + +@@ -319,7 +321,7 @@ dht_selfheal_layout_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + + err: +- dht_selfheal_dir_finish (frame, this, -1); ++ dht_selfheal_dir_finish (frame, this, -1, 0); + return 0; + } + +@@ -580,7 +582,7 @@ dht_selfheal_layout_lock (call_frame_t *frame, dht_layout_t *layout, + local->lock.locks = lk_array; + local->lock.lk_count = count; + +- ret = dht_blocking_inodelk (frame, lk_array, count, ++ ret = dht_blocking_inodelk (frame, lk_array, count, FAIL_ON_ANY_ERROR, + dht_selfheal_layout_lock_cbk); + if (ret < 0) { + local->lock.locks = NULL; +@@ -591,13 +593,7 @@ dht_selfheal_layout_lock (call_frame_t *frame, dht_layout_t *layout, + return 0; + err: + if (lk_array != NULL) { +- int tmp_count = 0, i = 0; +- +- for (i = 0; (i < count) && (lk_array[i]); i++, tmp_count++) { +- ; +- } +- +- dht_lock_array_free (lk_array, tmp_count); ++ dht_lock_array_free (lk_array, count); + GF_FREE (lk_array); + } + +@@ -636,7 +632,7 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + this_call_cnt = dht_frame_return (frame); + + if (is_last_call (this_call_cnt)) { +- dht_selfheal_dir_finish (frame, this, 0); ++ dht_selfheal_dir_finish (frame, this, 0, 0); + } + + return 0; +@@ -831,7 +827,7 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout) + missing_xattr, loc->path); + + if (missing_xattr == 0) { +- dht_selfheal_dir_finish (frame, this, 0); ++ dht_selfheal_dir_finish (frame, this, 0, 0); + return 0; + } + +@@ -958,7 +954,7 @@ dht_selfheal_dir_xattr_for_nameless_lookup (call_frame_t *frame, loc_t *loc, + missing_xattr, loc->path); + + if (missing_xattr == 0) { +- dht_selfheal_dir_finish (frame, this, 0); ++ dht_selfheal_dir_finish (frame, this, 0, 0); + return 0; + } + +@@ -1026,7 +1022,7 @@ dht_selfheal_dir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_should_heal_layout); + + if (ret < 0) { +- dht_selfheal_dir_finish (frame, this, -1); ++ dht_selfheal_dir_finish (frame, this, -1, 0); + } + } + +@@ -1057,7 +1053,7 @@ dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf, + dht_should_heal_layout); + + if (ret < 0) { +- dht_selfheal_dir_finish (frame, this, -1); ++ dht_selfheal_dir_finish (frame, this, -1, 0); + } + + return 0; +@@ -1095,7 +1091,7 @@ dht_selfheal_dir_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_layout_t *layout = NULL; + call_frame_t *prev = NULL; + xlator_t *subvol = NULL; +- int i = 0; ++ int i = 0, ret = -1; + int this_call_cnt = 0; + char gfid[GF_UUID_BUF_SIZE] = {0}; + +@@ -1114,7 +1110,6 @@ dht_selfheal_dir_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + if (op_ret) { +- + gf_uuid_unparse(local->loc.gfid, gfid); + gf_msg (this->name, ((op_errno == EEXIST) ? GF_LOG_DEBUG : + GF_LOG_WARNING), +@@ -1127,11 +1122,13 @@ dht_selfheal_dir_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); + dht_iatt_merge (this, &local->preparent, preparent, prev->this); + dht_iatt_merge (this, &local->postparent, postparent, prev->this); ++ ret = 0; + + out: + this_call_cnt = dht_frame_return (frame); + + if (is_last_call (this_call_cnt)) { ++ dht_selfheal_dir_finish (frame, this, ret, -1); + dht_selfheal_dir_setattr (frame, &local->loc, &local->stbuf, 0xffffff, layout); + } + +@@ -1184,32 +1181,33 @@ out: + } + + int +-dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, +- dht_layout_t *layout, int force) ++dht_selfheal_dir_mkdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ++ int32_t op_ret, int32_t op_errno, dict_t *xdata) + { +- int missing_dirs = 0; ++ dht_local_t *local = NULL; + int i = 0; + int ret = -1; +- dht_local_t *local = NULL; +- xlator_t *this = NULL; + dict_t *dict = NULL; ++ dht_layout_t *layout = NULL; ++ loc_t *loc = NULL; + +- local = frame->local; +- this = frame->this; ++ VALIDATE_OR_GOTO (this->private, err); + +- local->selfheal.force_mkdir = force ? _gf_true : _gf_false; ++ local = frame->local; ++ layout = local->layout; ++ loc = &local->loc; + +- for (i = 0; i < layout->cnt; i++) { +- if (layout->list[i].err == ENOENT || force) +- missing_dirs++; +- } ++ if (op_ret < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, op_errno, ++ DHT_MSG_INODE_LK_ERROR, ++ "acquiring inodelk failed for %s", ++ loc->path); + +- if (missing_dirs == 0) { +- dht_selfheal_dir_setattr (frame, loc, &local->stbuf, 0xffffffff, layout); +- return 0; ++ local->op_ret = -1; ++ local->op_errno = (op_errno == EAGAIN) ? EBUSY : op_errno; ++ goto err; + } + +- local->call_cnt = missing_dirs; + if (!gf_uuid_is_null (local->gfid)) { + dict = dict_new (); + if (!dict) +@@ -1223,6 +1221,7 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, + " key = gfid-req", loc->path); + } else if (local->params) { + /* Send the dictionary from higher layers directly */ ++ + dict = dict_ref (local->params); + } + /* Set acls */ +@@ -1234,8 +1233,18 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, + DHT_MSG_DICT_SET_FAILED, + "dict is NULL, need to make sure gfids are same"); + ++ ++ /* We don't have to do a lookup here again: ++ 1) Parallel rmdir would had removed the directory and locking would ++ have anyway failed with an ESTALE on all subvols. Hence selfheal ++ will never create the directory. ++ 2) Parallel lookup creating directory does not have to be mutually ++ exclusive for the mkdir phase of lookup selfheal. ++ */ ++ + for (i = 0; i < layout->cnt; i++) { +- if (layout->list[i].err == ENOENT || force) { ++ if (layout->list[i].err == ENOENT || ++ local->selfheal.force_mkdir) { + gf_msg_debug (this->name, 0, + "Creating directory %s on subvol %s", + loc->path, layout->list[i].xlator->name); +@@ -1254,6 +1263,82 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, + dict_unref (dict); + + return 0; ++ ++err: ++ dht_selfheal_dir_finish (frame, this, -1, 0); ++ return 0; ++} ++ ++int ++dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, ++ dht_layout_t *layout, int force) ++{ ++ int missing_dirs = 0; ++ int i = 0; ++ int ret = -1; ++ int count = 1; ++ dht_local_t *local = NULL; ++ dht_conf_t *conf = NULL; ++ xlator_t *this = NULL; ++ dht_lock_t **lk_array = NULL; ++ ++ local = frame->local; ++ this = frame->this; ++ conf = this->private; ++ ++ local->selfheal.force_mkdir = force ? _gf_true : _gf_false; ++ ++ for (i = 0; i < layout->cnt; i++) { ++ if (layout->list[i].err == ENOENT || force) ++ missing_dirs++; ++ } ++ ++ if (missing_dirs == 0) { ++ dht_selfheal_dir_setattr (frame, loc, &local->stbuf, ++ 0xffffffff, layout); ++ return 0; ++ } ++ ++ local->call_cnt = missing_dirs; ++ count = conf->subvolume_cnt; ++ ++ /* Locking on all subvols in the mkdir phase of lookup selfheal is ++ is done to synchronize with rmdir/rename. ++ */ ++ lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); ++ if (lk_array == NULL) ++ goto err; ++ ++ for (i = 0; i < count; i++) { ++ lk_array[i] = dht_lock_new (frame->this, ++ conf->subvolumes[i], ++ &local->loc, F_WRLCK, ++ DHT_LAYOUT_HEAL_DOMAIN); ++ if (lk_array[i] == NULL) ++ goto err; ++ } ++ ++ local->lock.locks = lk_array; ++ local->lock.lk_count = count; ++ ++ ret = dht_blocking_inodelk (frame, lk_array, count, ++ IGNORE_ENOENT_ESTALE, ++ dht_selfheal_dir_mkdir_lock_cbk); ++ ++ if (ret < 0) { ++ local->lock.locks = NULL; ++ local->lock.lk_count = 0; ++ goto err; ++ } ++ ++ return 0; ++err: ++ if (lk_array != NULL) { ++ dht_lock_array_free (lk_array, count); ++ GF_FREE (lk_array); ++ } ++ ++ return -1; + } + + int +@@ -1825,7 +1910,7 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk, + + sorry_no_fix: + /* TODO: need to put appropriate local->op_errno */ +- dht_selfheal_dir_finish (frame, this, ret); ++ dht_selfheal_dir_finish (frame, this, ret, 0); + + return 0; + } +@@ -1893,7 +1978,7 @@ dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame, + + sorry_no_fix: + /* TODO: need to put appropriate local->op_errno */ +- dht_selfheal_dir_finish (frame, this, ret); ++ dht_selfheal_dir_finish (frame, this, ret, 0); + + return 0; + +@@ -2244,7 +2329,7 @@ dht_update_commit_hash_for_layout (call_frame_t *frame) + local->lock.locks = lk_array; + local->lock.lk_count = count; + +- ret = dht_blocking_inodelk (frame, lk_array, count, ++ ret = dht_blocking_inodelk (frame, lk_array, count, FAIL_ON_ANY_ERROR, + dht_update_commit_hash_for_layout_resume); + if (ret < 0) { + local->lock.locks = NULL; +@@ -2255,13 +2340,7 @@ dht_update_commit_hash_for_layout (call_frame_t *frame) + return 0; + err: + if (lk_array != NULL) { +- int tmp_count = 0, i = 0; +- +- for (i = 0; (i < count) && (lk_array[i]); i++, tmp_count++) { +- ; +- } +- +- dht_lock_array_free (lk_array, tmp_count); ++ dht_lock_array_free (lk_array, count); + GF_FREE (lk_array); + } + +-- +1.7.1 + diff --git a/SOURCES/0312-glusterd-use-2-epoll-worker-threads-by-default.patch b/SOURCES/0312-glusterd-use-2-epoll-worker-threads-by-default.patch new file mode 100644 index 0000000..61c08f6 --- /dev/null +++ b/SOURCES/0312-glusterd-use-2-epoll-worker-threads-by-default.patch @@ -0,0 +1,95 @@ +From b02af7c959377cb95521f1f8d17e8ac38d2999e5 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Sat, 11 Jul 2015 09:21:27 +0530 +Subject: [PATCH 312/320] glusterd: use 2 epoll worker threads by default + + Backport of http://review.gluster.org/11847 + +The no. of epoll worker threads can be configured +by adding the following option into glusterd.vol. + + option event-threads + +BUG: 1241336 +Change-Id: I2a9e2d81c64beaf54872081f9ce45355cf4dfca7 +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: http://review.gluster.org/11630 +Tested-by: NetBSD Build System +Reviewed-by: Atin Mukherjee +Tested-by: Gluster Build System +(cherry picked from commit 6b7bdcb02cf39199d3720c2471121d14df64c8ab) +Reviewed-on: http://review.gluster.org/11847 +Reviewed-on: https://code.engineering.redhat.com/gerrit/56625 +Tested-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd.c | 21 +++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd.h | 1 + + 2 files changed, 22 insertions(+), 0 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 2c75545..b83b249 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -28,6 +28,7 @@ + #include "defaults.h" + #include "list.h" + #include "dict.h" ++#include "options.h" + #include "compat.h" + #include "compat-errno.h" + #include "syscall.h" +@@ -1327,6 +1328,7 @@ init (xlator_t *this) + char *valgrind_str = NULL; + char *transport_type = NULL; + char var_run_dir[PATH_MAX] = {0,}; ++ int32_t workers = 0; + + #ifndef GF_DARWIN_HOST_OS + { +@@ -1775,6 +1777,15 @@ init (xlator_t *this) + if (ret) + goto out; + ++ GF_OPTION_INIT ("event-threads", workers, int32, out); ++ if (workers > 0 && workers != conf->workers) { ++ conf->workers = workers; ++ ret = event_reconfigure_threads (this->ctx->event_pool, ++ workers); ++ if (ret) ++ goto out; ++ } ++ + ret = 0; + out: + if (ret < 0) { +@@ -1953,5 +1964,15 @@ struct volume_options options[] = { + .max = 300, + .default_value = TOSTRING(RPC_DEFAULT_PING_TIMEOUT), + }, ++ { .key = {"event-threads"}, ++ .type = GF_OPTION_TYPE_INT, ++ .min = 1, ++ .max = 32, ++ .default_value = "2", ++ .description = "Specifies the number of event threads to execute " ++ "in parallel. Larger values would help process" ++ " responses faster, depending on available processing" ++ " power. Range 1-32 threads." ++ }, + { .key = {NULL} }, + }; +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index c72c569..b6876f8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -175,6 +175,7 @@ typedef struct { + struct cds_list_head missed_snaps_list; + int ping_timeout; + uint32_t generation; ++ int32_t workers; + } glusterd_conf_t; + + +-- +1.7.1 + diff --git a/SOURCES/0313-glusterd-Re-enable-ping-timer-between-glusterds.patch b/SOURCES/0313-glusterd-Re-enable-ping-timer-between-glusterds.patch new file mode 100644 index 0000000..1ce57b6 --- /dev/null +++ b/SOURCES/0313-glusterd-Re-enable-ping-timer-between-glusterds.patch @@ -0,0 +1,30 @@ +From 69230a453246672916a292c90a457110cb9234ff Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Mon, 24 Aug 2015 11:50:50 +0530 +Subject: [PATCH 313/320] glusterd: (Re)enable ping-timer between glusterds + +BUG: 1241336 +Change-Id: I78d790d3e1e73efcc2196797c6ef82fbc7ea1d3c +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/56627 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + extras/glusterd.vol.in | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/extras/glusterd.vol.in b/extras/glusterd.vol.in +index 6de5e3b..690dbe7 100644 +--- a/extras/glusterd.vol.in ++++ b/extras/glusterd.vol.in +@@ -5,6 +5,6 @@ volume management + option transport.socket.keepalive-time 10 + option transport.socket.keepalive-interval 2 + option transport.socket.read-fail-log off +- option ping-timeout 0 ++ option ping-timeout 30 + # option base-port 49152 + end-volume +-- +1.7.1 + diff --git a/SOURCES/0314-event-epoll-Use-pollers-to-check-if-event_pool_dispa.patch b/SOURCES/0314-event-epoll-Use-pollers-to-check-if-event_pool_dispa.patch new file mode 100644 index 0000000..3bc87dd --- /dev/null +++ b/SOURCES/0314-event-epoll-Use-pollers-to-check-if-event_pool_dispa.patch @@ -0,0 +1,78 @@ +From f338f8513ec9ffbe26ba9fe4de000331dc2c2789 Mon Sep 17 00:00:00 2001 +From: Krishnan Parthasarathi +Date: Thu, 13 Aug 2015 14:39:58 +0530 +Subject: [PATCH 314/320] event-epoll: Use pollers[] to check if event_pool_dispatch was called + + Backport of http://review.gluster.org/12004 + +This patch allows event_pool to change the no. of worker threads handling +events independent of event_dispatch() being called. + +NB This patch is not a straight backport of the above patch. It +telescopes the following patches upstream, + + [1] http://review.gluster.com/11911 + [2] http://review.gluster.com/12004 + +[1] - uses an extra flag to change behaviour of reconfiguring the no. of +worker threads. This wasn't complete. + +[2] - makes event_reconfigure_threads() implementation of epoll-based +eventing independent of when event_dispatch() is called , without the +extra flag introduced in [1]. + +BUG: 1241336 +Change-Id: Ia8df3c958545324472262c555ed84b71797f002e +Signed-off-by: Krishnan Parthasarathi +Reviewed-on: https://code.engineering.redhat.com/gerrit/56626 +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + libglusterfs/src/event-epoll.c | 24 +++++++++++++++++++++++- + 1 files changed, 23 insertions(+), 1 deletions(-) + +diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c +index 9403217..fc3099d 100644 +--- a/libglusterfs/src/event-epoll.c ++++ b/libglusterfs/src/event-epoll.c +@@ -770,6 +770,23 @@ event_dispatch_epoll (struct event_pool *event_pool) + return ret; + } + ++/** ++ * @param event_pool event_pool on which fds of interest are registered for ++ * events. ++ * ++ * @return 1 if at least one epoll worker thread is spawned, 0 otherwise ++ * ++ * NB This function SHOULD be called under event_pool->mutex. ++ */ ++ ++static int ++event_pool_dispatched_unlocked (struct event_pool *event_pool) ++{ ++ return (event_pool->pollers[0] != 0); ++ ++} ++ ++ + int + event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) + { +@@ -796,7 +813,12 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) + + oldthreadcount = event_pool->eventthreadcount; + +- if (oldthreadcount < value) { ++ /* Start 'worker' threads as necessary only if event_dispatch() ++ * was called before. If event_dispatch() was not called, there ++ * will be no epoll 'worker' threads running yet. */ ++ ++ if (event_pool_dispatched_unlocked(event_pool) ++ && (oldthreadcount < value)) { + /* create more poll threads */ + for (i = oldthreadcount; i < value; i++) { + /* Start a thread if the index at this location +-- +1.7.1 + diff --git a/SOURCES/0315-ec-trusted.ec.version-xattr-of-all-root-directories-.patch b/SOURCES/0315-ec-trusted.ec.version-xattr-of-all-root-directories-.patch new file mode 100644 index 0000000..2a2728a --- /dev/null +++ b/SOURCES/0315-ec-trusted.ec.version-xattr-of-all-root-directories-.patch @@ -0,0 +1,147 @@ +From 91b3455664555ac4d5fbc244ab8c19b3bb5dc63b Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Wed, 15 Jul 2015 16:37:37 +0530 +Subject: [PATCH 315/320] ec : trusted.ec.version xattr of all root directories of all bricks should be same. + +Problem: +After replacing the brick using "replace-brick" command and running "heal +full", the version of the root directory of the newly added brick is not +getting healed. heal starts running on the dentries of the root but does not +run on root directory. + +Solution: +Run heal on root directory. + +> Change-Id: Ifd42a3fb341b049c895817e892e5b484a5aa6f80 +> BUG: 1243382 +> Signed-off-by: Ashish Pandey +> Reviewed-on: http://review.gluster.org/11676 +> Reviewed-by: Pranith Kumar Karampuri +> Tested-by: NetBSD Build System + +Change-Id: Ifd42a3fb341b049c895817e892e5b484a5aa6f80 +BUG: 1241862 +Signed-off-by: Ashish Pandey +Reviewed-on: https://code.engineering.redhat.com/gerrit/55523 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/basic/ec/ec-root-heal.t | 33 +++++++++++++++++++++++++++++++++ + tests/volume.rc | 20 +++++++++++++++++--- + xlators/cluster/ec/src/ec-heald.c | 3 +++ + 3 files changed, 53 insertions(+), 3 deletions(-) + create mode 100644 tests/basic/ec/ec-root-heal.t + +diff --git a/tests/basic/ec/ec-root-heal.t b/tests/basic/ec/ec-root-heal.t +new file mode 100644 +index 0000000..91e668c +--- /dev/null ++++ b/tests/basic/ec/ec-root-heal.t +@@ -0,0 +1,33 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup ++function num_entries { ++ ls -l $1 | wc -l ++} ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} ++TEST $CLI volume start $V0 ++TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 ++touch $M0/{1..10} ++TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}5 $H0:$B0/${V0}6 commit force ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count_shd $V0 0 ++ ++# active heal ++TEST $CLI volume heal $V0 full ++#ls -l gives "Total" line so number of lines will be 1 more ++EXPECT_WITHIN $HEAL_TIMEOUT "^11$" num_entries $B0/${V0}6 ++ec_version=$(get_hex_xattr trusted.ec.version $B0/${V0}0) ++EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}1 ++EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}2 ++EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}3 ++EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}4 ++EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}6 ++ ++cleanup; +diff --git a/tests/volume.rc b/tests/volume.rc +index d90dda7..e053b5f 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -121,7 +121,7 @@ function ec_get_info { + local vol=$1 + local dist_id=$2 + local key=$3 +- local fpath=$(generate_mount_statedump $vol) ++ local fpath=$4 + local value=$(sed -n "/^\[cluster\/disperse\.$vol-disperse-$dist_id\]/,/^\[/{s/^$key=\(.*\)/\1/p;}" $fpath | head -1) + rm -f $fpath + echo "$value" +@@ -131,14 +131,28 @@ function ec_child_up_status { + local vol=$1 + local dist_id=$2 + local brick_id=$(($3 + 1)) +- local mask=$(ec_get_info $vol $dist_id "childs_up_mask") ++ local mask=$(ec_get_info $vol $dist_id "childs_up_mask" $(generate_mount_statedump $vol)) + echo "${mask: -$brick_id:1}" + } + + function ec_child_up_count { + local vol=$1 + local dist_id=$2 +- ec_get_info $vol $dist_id "childs_up" ++ ec_get_info $vol $dist_id "childs_up" $(generate_mount_statedump $vol) ++} ++ ++function ec_child_up_status_shd { ++ local vol=$1 ++ local dist_id=$2 ++ local brick_id=$(($3 + 1)) ++ local mask=$(ec_get_info $vol $dist_id "childs_up_mask" $(generate_shd_statedump $vol)) ++ echo "${mask: -$brick_id:1}" ++} ++ ++function ec_child_up_count_shd { ++ local vol=$1 ++ local dist_id=$2 ++ ec_get_info $vol $dist_id "childs_up" $(generate_shd_statedump $vol) + } + + function get_shd_process_pid { +diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c +index 75f5848..4498d2e 100644 +--- a/xlators/cluster/ec/src/ec-heald.c ++++ b/xlators/cluster/ec/src/ec-heald.c +@@ -379,12 +379,14 @@ ec_shd_full_healer (void *data) + { + struct subvol_healer *healer = NULL; + xlator_t *this = NULL; ++ loc_t rootloc = {0}; + + int run = 0; + + healer = data; + THIS = this = healer->this; + ++ rootloc.inode = this->itable->root; + for (;;) { + pthread_mutex_lock (&healer->mutex); + { +@@ -404,6 +406,7 @@ ec_shd_full_healer (void *data) + "starting full sweep on subvol %s", + ec_subvol_name (this, healer->subvol)); + ++ ec_shd_selfheal (healer, healer->subvol, &rootloc); + ec_shd_full_sweep (healer, this->itable->root); + + gf_msg (this->name, GF_LOG_INFO, 0, +-- +1.7.1 + diff --git a/SOURCES/0316-gluster-cli-snapshot-delete-all-does-not-work-with-x.patch b/SOURCES/0316-gluster-cli-snapshot-delete-all-does-not-work-with-x.patch new file mode 100644 index 0000000..edbdfad --- /dev/null +++ b/SOURCES/0316-gluster-cli-snapshot-delete-all-does-not-work-with-x.patch @@ -0,0 +1,763 @@ +From ca1a22bec82e5cb2f7ed2ec88d55bdc9e5a0dca1 Mon Sep 17 00:00:00 2001 +From: Rajesh Joseph +Date: Wed, 26 Aug 2015 08:28:59 +0530 +Subject: [PATCH 316/320] gluster/cli: snapshot delete all does not work with xml + +Problem: snapshot delete all command fails with --xml option +Fix: Provided xml support for delete all command + +Change-Id: I77cad131473a9160e188c783f442b6a38a37f758 +BUG: 1245077 +Signed-off-by: Rajesh Joseph +Reviewed-on: http://review.gluster.org/12027 +Tested-by: NetBSD Build System +Tested-by: Gluster Build System +Reviewed-by: Avra Sengupta +Reviewed-on: https://code.engineering.redhat.com/gerrit/56628 +--- + cli/src/cli-cmd-parser.c | 4 +- + cli/src/cli-rpc-ops.c | 141 ++++++++---- + cli/src/cli-xml-output.c | 298 +++++++++++++++++++------ + cli/src/cli.h | 18 ++ + rpc/xdr/src/cli1-xdr.x | 6 +- + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 11 +- + 6 files changed, 357 insertions(+), 121 deletions(-) + +diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c +index 0f7b5be..0d3ca29 100644 +--- a/cli/src/cli-cmd-parser.c ++++ b/cli/src/cli-cmd-parser.c +@@ -4311,7 +4311,7 @@ cli_snap_delete_parse (dict_t *dict, const char **words, int wordcount, + } + } + +- ret = dict_set_int32 (dict, "delete-cmd", cmd); ++ ret = dict_set_int32 (dict, "sub-cmd", cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save " + "type of snapshot delete"); +@@ -4391,7 +4391,7 @@ cli_snap_status_parse (dict_t *dict, const char **words, int wordcount) + + out: + if (ret == 0) { +- ret = dict_set_int32 (dict, "status-cmd", cmd); ++ ret = dict_set_int32 (dict, "sub-cmd", cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save cmd " + "of snapshot status"); +diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c +index fd76df7..413a326 100644 +--- a/cli/src/cli-rpc-ops.c ++++ b/cli/src/cli-rpc-ops.c +@@ -8694,17 +8694,32 @@ cli_snapshot_remove_reply (gf_cli_rsp *rsp, dict_t *dict, call_frame_t *frame) + GF_ASSERT (rsp); + GF_ASSERT (dict); + +- if (rsp->op_ret) { +- cli_err ("snapshot delete: failed: %s", +- rsp->op_errstr ? rsp->op_errstr : +- "Please check log file for details"); +- ret = rsp->op_ret; +- goto out; +- } ++ local = frame->local; + +- ret = dict_get_int32 (dict, "delete-cmd", &delete_cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &delete_cmd); + if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Could not get delete-cmd"); ++ gf_log ("cli", GF_LOG_ERROR, "Could not get sub-cmd"); ++ goto end; ++ } ++ ++ if ((global_state->mode & GLUSTER_MODE_XML) && ++ (delete_cmd == GF_SNAP_DELETE_TYPE_SNAP)) { ++ ret = cli_xml_output_snap_delete_begin (local, rsp->op_ret, ++ rsp->op_errno, ++ rsp->op_errstr); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to create " ++ "xml output for delete"); ++ goto end; ++ } ++ } ++ ++ ++ if (rsp->op_ret && !(global_state->mode & GLUSTER_MODE_XML)) { ++ cli_err ("snapshot delete: failed: %s", ++ rsp->op_errstr ? rsp->op_errstr : ++ "Please check log file for details"); ++ ret = rsp->op_ret; + goto out; + } + +@@ -8727,17 +8742,37 @@ cli_snapshot_remove_reply (gf_cli_rsp *rsp, dict_t *dict, call_frame_t *frame) + goto out; + } + +- ret = dict_get_str (dict, "snapname", &snap_name); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Failed to get snapname"); +- goto out; +- } ++ if (global_state->mode & GLUSTER_MODE_XML) { ++ ret = cli_xml_snapshot_delete (local->writer, local->doc, ++ dict, rsp); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to create " ++ "xml output for snapshot delete command"); ++ goto out; ++ } ++ /* Error out in case of the op already failed */ ++ if (rsp->op_ret) { ++ ret = rsp->op_ret; ++ goto out; ++ } ++ } else { ++ ret = dict_get_str (dict, "snapname", &snap_name); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get snapname"); ++ goto out; ++ } + +- cli_out ("snapshot delete: %s: snap removed successfully", +- snap_name); ++ cli_out ("snapshot delete: %s: snap removed successfully", ++ snap_name); ++ } + ret = 0; + + out: ++ if ((global_state->mode & GLUSTER_MODE_XML) && ++ (delete_cmd == GF_SNAP_DELETE_TYPE_SNAP)) { ++ ret = cli_xml_output_snap_delete_end (local); ++ } ++end: + return ret; + } + +@@ -9465,8 +9500,8 @@ cli_populate_req_dict_for_delete (dict_t *snap_dict, dict_t *dict, size_t index) + GF_ASSERT (snap_dict); + GF_ASSERT (dict); + +- ret = dict_set_int32 (snap_dict, "delete-cmd", +- GF_SNAP_DELETE_TYPE_SNAP); ++ ret = dict_set_int32 (snap_dict, "sub-cmd", ++ GF_SNAP_DELETE_TYPE_ITER); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save command " + "type in snap dictionary"); +@@ -9518,7 +9553,7 @@ cli_populate_req_dict_for_status (dict_t *snap_dict, dict_t *dict, int index) { + GF_ASSERT (snap_dict); + GF_ASSERT (dict); + +- ret = dict_set_uint32 (snap_dict, "status-cmd", ++ ret = dict_set_uint32 (snap_dict, "sub-cmd", + GF_SNAP_STATUS_TYPE_SNAP); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save command " +@@ -9605,7 +9640,7 @@ cli_snapshot_status (dict_t *dict, gf_cli_rsp *rsp, + goto out; + } + +- ret = dict_get_int32 (dict, "status-cmd", &status_cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &status_cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not fetch status type"); + goto out; +@@ -9690,9 +9725,10 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, + goto out; + } + +- /* Snapshot status command is handled separately */ ++ /* Snapshot status and delete command is handled separately */ + if (global_state->mode & GLUSTER_MODE_XML && +- GF_SNAP_OPTION_TYPE_STATUS != type) { ++ GF_SNAP_OPTION_TYPE_STATUS != type && ++ GF_SNAP_OPTION_TYPE_DELETE != type) { + ret = cli_xml_output_snapshot (type, dict, rsp.op_ret, + rsp.op_errno, rsp.op_errstr); + if (ret) { +@@ -9958,10 +9994,10 @@ gf_cli_snapshot_for_delete (call_frame_t *frame, xlator_t *this, + + options = data; + +- ret = dict_get_int32 (local->dict, "delete-cmd", &cmd); ++ ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to get " +- "delete-cmd"); ++ "sub-cmd"); + goto out; + } + +@@ -9979,7 +10015,18 @@ gf_cli_snapshot_for_delete (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (snapcount == 0) { ++ if (global_state->mode & GLUSTER_MODE_XML) { ++#ifdef HAVE_LIB_XML ++ ret = xmlTextWriterWriteFormatElement (local->writer, ++ (xmlChar *)"snapCount", ++ "%d", snapcount); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to write " ++ "xml element \"snapCount\""); ++ goto out; ++ } ++#endif /* HAVE_LIB_XML */ ++ } else if (snapcount == 0) { + cli_out ("No snapshots present"); + goto out; + } +@@ -10072,9 +10119,9 @@ gf_cli_snapshot_for_status (call_frame_t *frame, xlator_t *this, + local = frame->local; + options = data; + +- ret = dict_get_int32 (local->dict, "status-cmd", &cmd); ++ ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); + if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Failed to get status-cmd"); ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get sub-cmd"); + goto out; + } + +@@ -10093,7 +10140,7 @@ gf_cli_snapshot_for_status (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (snapcount == 0) { ++ if (snapcount == 0 && !(global_state->mode & GLUSTER_MODE_XML)) { + cli_out ("No snapshots present"); + } + +@@ -10164,12 +10211,11 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, + + ret = dict_get_int32 (local->dict, "type", &type); + +- if (GF_SNAP_OPTION_TYPE_STATUS == type && +- global_state->mode & GLUSTER_MODE_XML) { +- ret = cli_xml_output_snap_status_begin (local, 0, 0, NULL); ++ if (global_state->mode & GLUSTER_MODE_XML) { ++ ret = cli_xml_snapshot_begin_composite_op (local); + if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Error creating xml " +- "output"); ++ gf_log ("cli", GF_LOG_ERROR, "Failed to begin " ++ "snapshot xml composite op"); + goto out; + } + } +@@ -10182,7 +10228,7 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "cli_to_glusterd for " + "snapshot failed"); +- goto out; ++ goto xmlend; + } + + if (GF_SNAP_OPTION_TYPE_STATUS == type) { +@@ -10190,17 +10236,9 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "cli to glusterd " + "for snapshot status command failed"); +- goto out; + } + +- if (global_state->mode & GLUSTER_MODE_XML) { +- ret = cli_xml_output_snap_status_end (local); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Error creating " +- "xml output"); +- goto out; +- } +- } ++ goto xmlend; + } + + if (GF_SNAP_OPTION_TYPE_DELETE == type) { +@@ -10208,12 +10246,22 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "cli to glusterd " + "for snapshot delete command failed"); +- goto out; + } ++ ++ goto xmlend; + } + + ret = 0; + ++xmlend: ++ if (global_state->mode & GLUSTER_MODE_XML) { ++ ret = cli_xml_snapshot_end_composite_op (local); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to end " ++ "snapshot xml composite op"); ++ goto out; ++ } ++ } + out: + if (ret && local && GF_SNAP_OPTION_TYPE_STATUS == type) { + tmp_ret = dict_get_str (local->dict, "op_err_str", &err_str); +@@ -10229,6 +10277,11 @@ out: + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + + GF_FREE (req.dict.dict_val); ++ ++ if (global_state->mode & GLUSTER_MODE_XML) { ++ /* XML mode handles its own error */ ++ ret = 0; ++ } + return ret; + } + +diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c +index b558a9a..9960635 100644 +--- a/cli/src/cli-xml-output.c ++++ b/cli/src/cli-xml-output.c +@@ -4101,65 +4101,6 @@ out: + return ret; + } + +-/* This function will generate snapshot delete output in xml format. +- * +- * @param writer xmlTextWriterPtr +- * @param doc xmlDocPtr +- * @param dict dict containing delete output +- * +- * @return 0 on success and -1 on failure +- */ +-static int +-cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) +-{ +- int ret = -1; +- char *str_value = NULL; +- +- GF_ASSERT (writer); +- GF_ASSERT (doc); +- GF_ASSERT (dict); +- +- /* */ +- ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapDelete"); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- /* */ +- ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- ret = dict_get_str (dict, "snapname", &str_value); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); +- goto out; +- } +- +- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", +- "%s", str_value); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- ret = dict_get_str (dict, "snapuuid", &str_value); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); +- goto out; +- } +- +- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", +- "%s", str_value); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- /* */ +- ret = xmlTextWriterEndElement (writer); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- /* */ +- ret = xmlTextWriterEndElement (writer); +- XML_RET_CHECK_AND_GOTO (ret, out); +- +- ret = 0; +-out: +- +- return ret; +-} + + /* This function will generate snapshot restore output in xml format. + * +@@ -4908,7 +4849,7 @@ cli_xml_snapshot_status (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) + ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapStatus"); + XML_RET_CHECK_AND_GOTO (ret, out); + +- ret = dict_get_int32 (dict, "status-cmd", &status_cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &status_cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not fetch status type"); + goto out; +@@ -5338,6 +5279,81 @@ out: + } + #endif /* HAVE_LIB_XML */ + ++/* This function will generate snapshot delete output in xml format. ++ * ++ * @param writer xmlTextWriterPtr ++ * @param doc xmlDocPtr ++ * @param dict dict containing delete output ++ * @param rsp cli response ++ * ++ * @return 0 on success and -1 on failure ++ */ ++int ++cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, ++ gf_cli_rsp *rsp) ++{ ++ int ret = -1; ++#ifdef HAVE_LIB_XML ++ char *str_value = NULL; ++ ++ GF_ASSERT (writer); ++ GF_ASSERT (doc); ++ GF_ASSERT (dict); ++ ++ /* */ ++ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++ ret = dict_get_str (dict, "snapname", &str_value); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); ++ goto xmlend; ++ } ++ ++ if (!rsp->op_ret) { ++ ret = xmlTextWriterWriteFormatElement (writer, ++ (xmlChar *) "status", ++ "Success"); ++ XML_RET_CHECK_AND_GOTO (ret, xmlend); ++ } else { ++ ret = xmlTextWriterWriteFormatElement (writer, ++ (xmlChar *) "status", ++ "Failure"); ++ XML_RET_CHECK_AND_GOTO (ret, xmlend); ++ ++ ret = cli_xml_output_common (writer, rsp->op_ret, ++ rsp->op_errno, ++ rsp->op_errstr); ++ XML_RET_CHECK_AND_GOTO (ret, xmlend); ++ } ++ ++ ++ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", ++ "%s", str_value); ++ XML_RET_CHECK_AND_GOTO (ret, xmlend); ++ ++ ret = dict_get_str (dict, "snapuuid", &str_value); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); ++ goto xmlend; ++ } ++ ++ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", ++ "%s", str_value); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++xmlend: ++ /* */ ++ ret = xmlTextWriterEndElement (writer); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++#endif /* HAVE_LIB_XML */ ++ ret = 0; ++out: ++ ++ return ret; ++} ++ + int + cli_xml_output_snap_status_begin (cli_local_t *local, int op_ret, int op_errno, + char *op_errstr) +@@ -5396,6 +5412,70 @@ out: + #endif + } + ++int ++cli_xml_output_snap_delete_begin (cli_local_t *local, int op_ret, int op_errno, ++ char *op_errstr) ++{ ++#if (HAVE_LIB_XML) ++ int ret = -1; ++ int delete_cmd = -1; ++ ++ GF_ASSERT (local); ++ ++ ret = cli_begin_xml_output (&(local->writer), &(local->doc)); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++ ret = dict_get_int32 (local->dict, "sub-cmd", &delete_cmd); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get sub-cmd"); ++ goto out; ++ } ++ ++ ret = cli_xml_output_common (local->writer, op_ret, op_errno, ++ op_errstr); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++ /* */ ++ ret = xmlTextWriterStartElement (local->writer, ++ (xmlChar *) "snapDelete"); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++ /* */ ++ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"snapshots"); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++out: ++ gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); ++ return ret; ++#else ++ return 0; ++#endif ++} ++ ++int ++cli_xml_output_snap_delete_end (cli_local_t *local) ++{ ++#if (HAVE_LIB_XML) ++ int ret = -1; ++ ++ GF_ASSERT (local); ++ ++ /* */ ++ ret = xmlTextWriterEndElement (local->writer); ++ XML_RET_CHECK_AND_GOTO (ret, out); ++ ++ /* */ ++ ret = xmlTextWriterEndElement (local->writer); ++ XML_RET_CHECK_AND_GOTO(ret, out); ++ ++ ret = cli_end_xml_output (local->writer, local->doc); ++out: ++ gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); ++ return ret; ++#else ++ return 0; ++#endif ++} + /* This function will generate xml output for all the snapshot commands + * + * @param cmd_type command type +@@ -5446,14 +5526,6 @@ cli_xml_output_snapshot (int cmd_type, dict_t *dict, int op_ret, + goto out; + } + break; +- case GF_SNAP_OPTION_TYPE_DELETE: +- ret = cli_xml_snapshot_delete (writer, doc, dict); +- if (ret) { +- gf_log ("cli", GF_LOG_ERROR, "Failed to create " +- "xml output for snapshot delete command"); +- goto out; +- } +- break; + case GF_SNAP_OPTION_TYPE_RESTORE: + ret = cli_xml_snapshot_restore (writer, doc, dict); + if (ret) { +@@ -5525,6 +5597,96 @@ out: + } + + int ++cli_xml_snapshot_begin_composite_op (cli_local_t *local) ++{ ++ int ret = -1; ++#ifdef HAVE_LIB_XML ++ int cmd = -1; ++ int type = -1; ++ ++ ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get " ++ "sub-cmd"); ++ ret = 0; ++ goto out; ++ } ++ ++ if (cmd == GF_SNAP_STATUS_TYPE_SNAP || ++ cmd == GF_SNAP_DELETE_TYPE_SNAP){ ++ ret = 0; ++ goto out; ++ } ++ ++ ret = dict_get_int32 (local->dict, "type", &type); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get snapshot " ++ "command type from dictionary"); ++ goto out; ++ } ++ ++ if (GF_SNAP_OPTION_TYPE_STATUS == type) ++ ret = cli_xml_output_snap_status_begin (local, 0, 0, NULL); ++ else if (GF_SNAP_OPTION_TYPE_DELETE == type) ++ ret = cli_xml_output_snap_delete_begin (local, 0, 0, NULL); ++ ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Error creating xml output"); ++ goto out; ++ } ++ ++#endif /* HAVE_LIB_XML */ ++ ret = 0; ++out: ++ return ret; ++} ++ ++int ++cli_xml_snapshot_end_composite_op (cli_local_t *local) ++{ ++ int ret = -1; ++#ifdef HAVE_LIB_XML ++ int cmd = -1; ++ int type = -1; ++ ++ ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get " ++ "sub-cmd"); ++ ret = 0; ++ goto out; ++ } ++ ++ if (cmd == GF_SNAP_STATUS_TYPE_SNAP || ++ cmd == GF_SNAP_DELETE_TYPE_SNAP){ ++ ret = 0; ++ goto out; ++ } ++ ++ ret = dict_get_int32 (local->dict, "type", &type); ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Failed to get snapshot " ++ "command type from dictionary"); ++ goto out; ++ } ++ ++ if (GF_SNAP_OPTION_TYPE_STATUS == type) ++ ret = cli_xml_output_snap_status_end (local); ++ else if (GF_SNAP_OPTION_TYPE_DELETE == type) ++ ret = cli_xml_output_snap_delete_end (local); ++ ++ if (ret) { ++ gf_log ("cli", GF_LOG_ERROR, "Error creating xml " ++ "output"); ++ goto out; ++ } ++#endif /* HAVE_LIB_XML */ ++ ret = 0; ++out: ++ return ret; ++} ++ ++int + cli_xml_snapshot_status_single_snap (cli_local_t *local, dict_t *dict, + char *key) + { +diff --git a/cli/src/cli.h b/cli/src/cli.h +index d831af0..a971d02 100644 +--- a/cli/src/cli.h ++++ b/cli/src/cli.h +@@ -428,6 +428,24 @@ int + cli_xml_output_vol_status_tasks_detail (cli_local_t *local, dict_t *dict); + + int ++cli_xml_output_common (xmlTextWriterPtr writer, int op_ret, int op_errno, ++ char *op_errstr); ++int ++cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, ++ gf_cli_rsp *rsp); ++int ++cli_xml_snapshot_begin_composite_op (cli_local_t *local); ++ ++int ++cli_xml_snapshot_end_composite_op (cli_local_t *local); ++ ++int ++cli_xml_output_snap_delete_begin (cli_local_t *local, int op_ret, int op_errno, ++ char *op_errstr); ++int ++cli_xml_output_snap_delete_end (cli_local_t *local); ++ ++int + cli_xml_output_snap_status_begin (cli_local_t *local, int op_ret, int op_errno, + char *op_errstr); + int +diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x +index 34f324f..73863ae 100644 +--- a/rpc/xdr/src/cli1-xdr.x ++++ b/rpc/xdr/src/cli1-xdr.x +@@ -189,13 +189,15 @@ enum gf1_cli_snapshot_config { + enum gf1_cli_snapshot_status { + GF_SNAP_STATUS_TYPE_ALL = 0, + GF_SNAP_STATUS_TYPE_SNAP, +- GF_SNAP_STATUS_TYPE_VOL ++ GF_SNAP_STATUS_TYPE_VOL, ++ GF_SNAP_STATUS_TYPE_ITER + }; + + enum gf1_cli_snapshot_delete { + GF_SNAP_DELETE_TYPE_ALL = 0, + GF_SNAP_DELETE_TYPE_SNAP = 1, +- GF_SNAP_DELETE_TYPE_VOL = 2 ++ GF_SNAP_DELETE_TYPE_VOL = 2, ++ GF_SNAP_DELETE_TYPE_ITER = 3 + }; + + struct gf_cli_req { +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +index 6f10ebc..089eb61 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c +@@ -5506,15 +5506,16 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op, + GF_ASSERT (err_str); + GF_VALIDATE_OR_GOTO (this->name, op_errno, out); + +- ret = dict_get_int32 (dict, "delete-cmd", &delete_cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &delete_cmd); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, +- GD_MSG_COMMAND_NOT_FOUND, "Failed to get delete-cmd"); ++ GD_MSG_COMMAND_NOT_FOUND, "Failed to get sub-cmd"); + goto out; + } + + switch (delete_cmd) { + case GF_SNAP_DELETE_TYPE_SNAP: ++ case GF_SNAP_DELETE_TYPE_ITER: + ret = glusterd_handle_snapshot_delete_type_snap (req, op, dict, + err_str, + op_errno, len); +@@ -5647,7 +5648,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr, + goto out; + } + +- ret = dict_get_int32 (dict, "status-cmd", &cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &cmd); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, +@@ -7531,7 +7532,7 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr, + conf = this->private; + + GF_ASSERT (conf); +- ret = dict_get_int32 (dict, "status-cmd", &cmd); ++ ret = dict_get_int32 (dict, "sub-cmd", &cmd); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, +@@ -7539,7 +7540,7 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr, + goto out; + } + +- ret = dict_set_int32 (rsp_dict, "status-cmd", cmd); ++ ret = dict_set_int32 (rsp_dict, "sub-cmd", cmd); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, +-- +1.7.1 + diff --git a/SOURCES/0317-marker-preserve-previous-dirty-flag-during-update-tx.patch b/SOURCES/0317-marker-preserve-previous-dirty-flag-during-update-tx.patch new file mode 100644 index 0000000..39dc0f4 --- /dev/null +++ b/SOURCES/0317-marker-preserve-previous-dirty-flag-during-update-tx.patch @@ -0,0 +1,232 @@ +From b0061ce310b487858b74dbaa8266a61df87dafb6 Mon Sep 17 00:00:00 2001 +From: vmallika +Date: Thu, 27 Aug 2015 21:11:53 +0530 +Subject: [PATCH 317/320] marker: preserve previous dirty flag during update txn + +This is a backport of http://review.gluster.org/#/c/12032/ + +In case if dir has become dirty because of crash, +this dirty flag on disk was getting reset in the +next update txn. + +This patch now gets the dirty flag before setting +in the update txn and it the value is dirty, it keeps +the flag dirty, so that inspect_directory can fix the +dirty dir + +> Change-Id: Iab2c343dbe19bd3b291adbfeebe6d9785b6bb9e3 +> BUG: 1251454 +> Signed-off-by: vmallika + +Change-Id: I4a34c8a0e13aa1c21cd9ddbb272c7e22a4137004 +BUG: 1251457 +Signed-off-by: vmallika +Reviewed-on: https://code.engineering.redhat.com/gerrit/56569 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/features/marker/src/marker-quota.c | 106 ++++++++++++++++++++++++---- + 1 files changed, 91 insertions(+), 15 deletions(-) + +diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c +index b582158..d9063a8 100644 +--- a/xlators/features/marker/src/marker-quota.c ++++ b/xlators/features/marker/src/marker-quota.c +@@ -2386,18 +2386,30 @@ out: + } + + int32_t +-mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) ++mq_get_set_dirty (xlator_t *this, loc_t *loc, int32_t dirty, ++ int32_t *prev_dirty) + { +- int32_t ret = -1; +- dict_t *dict = NULL; +- quota_inode_ctx_t *ctx = NULL; ++ int32_t ret = -1; ++ int8_t value = 0; ++ quota_inode_ctx_t *ctx = NULL; ++ dict_t *dict = NULL; ++ dict_t *rsp_dict = NULL; + + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); ++ GF_VALIDATE_OR_GOTO ("marker", prev_dirty, out); ++ ++ ret = mq_inode_ctx_get (loc->inode, this, &ctx); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_ERROR, "failed to get inode ctx for " ++ "%s", loc->path); ++ goto out; ++ } + + dict = dict_new (); + if (!dict) { + gf_log (this->name, GF_LOG_ERROR, "dict_new failed"); ++ ret = -1; + goto out; + } + +@@ -2407,14 +2419,48 @@ mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) + goto out; + } + +- ret = syncop_setxattr (FIRST_CHILD(this), loc, dict, 0, NULL, NULL); ++ ret = syncop_xattrop (FIRST_CHILD(this), loc, GF_XATTROP_GET_AND_SET, ++ dict, NULL, &rsp_dict); + if (ret < 0) { + gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) +- ? GF_LOG_DEBUG:GF_LOG_ERROR, "setxattr dirty = %d " +- "failed for %s: %s", dirty, loc->path, strerror (-ret)); ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "xattrop failed " ++ "for %s: %s", loc->path, strerror (-ret)); + goto out; + } + ++ *prev_dirty = 0; ++ if (rsp_dict) { ++ ret = dict_get_int8 (rsp_dict, QUOTA_DIRTY_KEY, &value); ++ if (ret == 0) ++ *prev_dirty = value; ++ } ++ ++ LOCK (&ctx->lock); ++ { ++ ctx->dirty = dirty; ++ } ++ UNLOCK (&ctx->lock); ++ ret = 0; ++out: ++ if (dict) ++ dict_unref (dict); ++ ++ if (rsp_dict) ++ dict_unref (rsp_dict); ++ ++ return ret; ++} ++ ++int32_t ++mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) ++{ ++ int32_t ret = -1; ++ dict_t *dict = NULL; ++ quota_inode_ctx_t *ctx = NULL; ++ ++ GF_VALIDATE_OR_GOTO ("marker", loc, out); ++ GF_VALIDATE_OR_GOTO ("marker", loc->inode, out); ++ + ret = mq_inode_ctx_get (loc->inode, this, &ctx); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "failed to get inode ctx for " +@@ -2423,6 +2469,27 @@ mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty) + goto out; + } + ++ dict = dict_new (); ++ if (!dict) { ++ ret = -1; ++ gf_log (this->name, GF_LOG_ERROR, "dict_new failed"); ++ goto out; ++ } ++ ++ ret = dict_set_int8 (dict, QUOTA_DIRTY_KEY, dirty); ++ if (ret < 0) { ++ gf_log (this->name, GF_LOG_ERROR, "dict_set failed"); ++ goto out; ++ } ++ ++ ret = syncop_setxattr (FIRST_CHILD(this), loc, dict, 0, NULL, NULL); ++ if (ret < 0) { ++ gf_log_callingfn (this->name, (-ret == ENOENT || -ret == ESTALE) ++ ? GF_LOG_DEBUG:GF_LOG_ERROR, "setxattr dirty = %d " ++ "failed for %s: %s", dirty, loc->path, strerror (-ret)); ++ goto out; ++ } ++ + LOCK (&ctx->lock); + { + ctx->dirty = dirty; +@@ -3010,6 +3077,7 @@ int32_t + mq_reduce_parent_size_task (void *opaque) + { + int32_t ret = -1; ++ int32_t prev_dirty = 0; + quota_inode_ctx_t *ctx = NULL; + quota_inode_ctx_t *parent_ctx = NULL; + inode_contribution_t *contribution = NULL; +@@ -3079,7 +3147,7 @@ mq_reduce_parent_size_task (void *opaque) + UNLOCK (&contribution->lock); + } + +- ret = mq_mark_dirty (this, &parent_loc, 1); ++ ret = mq_get_set_dirty (this, &parent_loc, 1, &prev_dirty); + if (ret < 0) + goto out; + dirty = _gf_true; +@@ -3101,11 +3169,13 @@ mq_reduce_parent_size_task (void *opaque) + + out: + if (dirty) { +- if (ret < 0) { ++ if (ret < 0 || prev_dirty) { + /* On failure clear dirty status flag. + * In the next lookup inspect_directory_xattr + * can set the status flag and fix the +- * dirty directory ++ * dirty directory. ++ * Do the same if dir was dirty before ++ * the txn + */ + ret = mq_inode_ctx_get (parent_loc.inode, this, + &parent_ctx); +@@ -3159,6 +3229,7 @@ int + mq_initiate_quota_task (void *opaque) + { + int32_t ret = -1; ++ int32_t prev_dirty = 0; + loc_t child_loc = {0,}; + loc_t parent_loc = {0,}; + gf_boolean_t locked = _gf_false; +@@ -3299,7 +3370,8 @@ mq_initiate_quota_task (void *opaque) + if (quota_meta_is_null (&delta)) + goto out; + +- ret = mq_mark_dirty (this, &parent_loc, 1); ++ prev_dirty = 0; ++ ret = mq_get_set_dirty (this, &parent_loc, 1, &prev_dirty); + if (ret < 0) + goto out; + dirty = _gf_true; +@@ -3317,8 +3389,10 @@ mq_initiate_quota_task (void *opaque) + goto out; + } + +- ret = mq_mark_dirty (this, &parent_loc, 0); +- dirty = _gf_false; ++ if (prev_dirty == 0) { ++ ret = mq_mark_dirty (this, &parent_loc, 0); ++ dirty = _gf_false; ++ } + + ret = mq_lock (this, &parent_loc, F_UNLCK); + locked = _gf_false; +@@ -3339,11 +3413,13 @@ mq_initiate_quota_task (void *opaque) + + out: + if (dirty) { +- if (ret < 0) { ++ if (ret < 0 || prev_dirty) { + /* On failure clear dirty status flag. + * In the next lookup inspect_directory_xattr + * can set the status flag and fix the +- * dirty directory ++ * dirty directory. ++ * Do the same if the dir was dirty before ++ * txn + */ + ret = mq_inode_ctx_get (parent_loc.inode, this, + &parent_ctx); +-- +1.7.1 + diff --git a/SOURCES/0318-cluster-ec-Fix-write-size-in-self-heal.patch b/SOURCES/0318-cluster-ec-Fix-write-size-in-self-heal.patch new file mode 100644 index 0000000..26c9c2e --- /dev/null +++ b/SOURCES/0318-cluster-ec-Fix-write-size-in-self-heal.patch @@ -0,0 +1,141 @@ +From 0d2dd0b1395397fced99b62dd826d4ab18fb94f1 Mon Sep 17 00:00:00 2001 +From: Xavier Hernandez +Date: Fri, 7 Aug 2015 12:37:52 +0200 +Subject: [PATCH 318/320] cluster/ec: Fix write size in self-heal + +Self-heal was always using a fixed block size to heal a file. This +was incorrect for dispersed volumes with a number of data bricks not +being a power of 2. + +This patch adjusts the block size to a multiple of the stripe size +of the volume. It also propagates errors detected during the data +heal to stop healing the file and not mark it as healed. + +> Change-Id: I9ee3fde98a9e5d6116fd096ceef88686fd1d28e2 +> BUG: 1251446 +> Signed-off-by: Xavier Hernandez +> Reviewed-on: http://review.gluster.org/11862 +> Tested-by: NetBSD Build System +> Tested-by: Gluster Build System +> Reviewed-by: Pranith Kumar Karampuri + +3.7: http://review.gluster.org/11869 + +BUG: 1241862 +Change-Id: I3bbe6ed6ff60b3efcc08d7425678bb9aeb5ddb11 +Signed-off-by: Xavier Hernandez +Reviewed-on: https://code.engineering.redhat.com/gerrit/56691 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/bugs/disperse/bug-1251446.t | 50 +++++++++++++++++++++++++++++++++++++ + xlators/cluster/ec/src/ec-data.h | 1 + + xlators/cluster/ec/src/ec-heal.c | 9 ++++++ + 3 files changed, 60 insertions(+), 0 deletions(-) + create mode 100644 tests/bugs/disperse/bug-1251446.t + +diff --git a/tests/bugs/disperse/bug-1251446.t b/tests/bugs/disperse/bug-1251446.t +new file mode 100644 +index 0000000..f805539 +--- /dev/null ++++ b/tests/bugs/disperse/bug-1251446.t +@@ -0,0 +1,50 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup ++ ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume create $V0 disperse 4 redundancy 1 $H0:$B0/${V0}{0..3} ++TEST $CLI volume start $V0 ++TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "4" ec_child_up_count $V0 0 ++ ++TEST dd if=/dev/urandom of=$M0/test1 bs=1024k count=2 ++cs=$(sha1sum $M0/test1 | awk '{ print $1 }') ++ ++TEST kill_brick $V0 $H0 $B0/${V0}0 ++EXPECT '3' online_brick_count ++ ++TEST cp $M0/test1 $M0/test2 ++EXPECT "$cs" echo $(sha1sum $M0/test2 | awk '{ print $1 }') ++ ++TEST $CLI volume start $V0 force ++EXPECT '4' online_brick_count ++ ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid ++TEST $CLI volume heal $V0 full ++EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 ++ ++EXPECT "699392" stat -c "%s" $B0/${V0}0/test2 ++ ++# force cache clear ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST $CLI volume stop $V0 ++TEST $CLI volume start $V0 ++TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "4" ec_child_up_count $V0 0 ++ ++TEST kill_brick $V0 $H0 $B0/${V0}3 ++EXPECT '3' online_brick_count ++ ++EXPECT "$cs" echo $(sha1sum $M0/test2 | awk '{ print $1 }') ++ ++## cleanup ++EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 ++TEST $CLI volume stop $V0 ++TEST $CLI volume delete $V0 ++ ++cleanup; +diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h +index ec470e9..1008706 100644 +--- a/xlators/cluster/ec/src/ec-data.h ++++ b/xlators/cluster/ec/src/ec-data.h +@@ -285,6 +285,7 @@ struct _ec_heal + fd_t *fd; + int32_t partial; + int32_t done; ++ int32_t error; + gf_boolean_t nameheal; + uintptr_t available; + uintptr_t good; +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index a7c97a5..fde7e31 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -1779,6 +1779,7 @@ ec_heal_block_done (call_frame_t *frame, void *cookie, xlator_t *this, + + fop->heal = NULL; + heal->fop = NULL; ++ heal->error = op_ret < 0 ? op_errno : 0; + syncbarrier_wake (heal->data); + return 0; + } +@@ -1789,6 +1790,9 @@ ec_sync_heal_block (call_frame_t *frame, xlator_t *this, ec_heal_t *heal) + ec_heal_block (frame, this, heal->bad|heal->good, EC_MINIMUM_ONE, + ec_heal_block_done, heal); + syncbarrier_wait (heal->data, 1); ++ if (heal->error != 0) { ++ return -heal->error; ++ } + if (heal->bad == 0) + return -ENOTCONN; + return 0; +@@ -1814,6 +1818,11 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, + pool = ec->xl->ctx->iobuf_pool; + heal->total_size = size; + heal->size = iobpool_default_pagesize (pool); ++ /* We need to adjust the size to a multiple of the stripe size of the ++ * volume. Otherwise writes would need to fill gaps (head and/or tail) ++ * with existent data from the bad bricks. This could be garbage on a ++ * damaged file or it could fail if there aren't enough bricks. */ ++ heal->size -= heal->size % ec->stripe_size; + heal->bad = ec_char_array_to_mask (healed_sinks, ec->nodes); + heal->good = ec_char_array_to_mask (sources, ec->nodes); + heal->iatt.ia_type = IA_IFREG; +-- +1.7.1 + diff --git a/SOURCES/0319-cluster-dht-Don-t-set-posix-acls-on-linkto-files.patch b/SOURCES/0319-cluster-dht-Don-t-set-posix-acls-on-linkto-files.patch new file mode 100644 index 0000000..1b543d1 --- /dev/null +++ b/SOURCES/0319-cluster-dht-Don-t-set-posix-acls-on-linkto-files.patch @@ -0,0 +1,279 @@ +From 94253b21f832ff12d1c545c5d87e6bc79465d090 Mon Sep 17 00:00:00 2001 +From: Nithya Balachandran +Date: Mon, 31 Aug 2015 15:52:04 +0530 +Subject: [PATCH 319/320] cluster/dht: Don't set posix acls on linkto files + +Posix acls on a linkto file change the file's permission +bits and cause DHT to treat it as a non-linkto file.This +happens on the migration failure of a file on which posix + acls were set. +The fix prevents posix acls from being set on a linkto +file and copies them across only after a file has +been successfully migrated. + +backport of: +http://review.gluster.org/#/c/12025/ + +Some tier.t upstream changes have not been merged downstream +so this backport does not include the changes the upstream + patch made to tier.t. + +Change-Id: I7380cae9e847785534535c5d306574a231e21a10 +BUG: 1234610 +Signed-off-by: Nithya Balachandran +Reviewed-on: https://code.engineering.redhat.com/gerrit/56696 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/bugs/distribute/bug-1247563.t | 57 +++++++++++++++++++++++++++++ + xlators/cluster/dht/src/dht-rebalance.c | 34 +++++++++++++++++ + xlators/storage/posix/src/posix-helpers.c | 15 ++++++-- + xlators/storage/posix/src/posix.c | 11 +++++- + xlators/storage/posix/src/posix.h | 4 +- + 5 files changed, 114 insertions(+), 7 deletions(-) + create mode 100644 tests/bugs/distribute/bug-1247563.t + +diff --git a/tests/bugs/distribute/bug-1247563.t b/tests/bugs/distribute/bug-1247563.t +new file mode 100644 +index 0000000..f7f9258 +--- /dev/null ++++ b/tests/bugs/distribute/bug-1247563.t +@@ -0,0 +1,57 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++ ++is_sticky_set () { ++ echo $1 ++ if [ -k $1 ]; ++ then ++ echo "yes" ++ else ++ echo "no" ++ fi ++} ++ ++cleanup; ++ ++#Basic checks ++TEST glusterd ++TEST pidof glusterd ++TEST $CLI volume info ++ ++#Create a distributed volume ++TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; ++TEST $CLI volume start $V0 ++ ++# Mount FUSE ++TEST glusterfs --acl -s $H0 --volfile-id $V0 $M0 ++ ++TEST mkdir $M0/dir1 ++ ++echo "Testing pacls on rebalance" > $M0/dir1/FILE1 ++FPATH1=`find $B0/ -name FILE1` ++ ++# Rename the file to create a linkto, for rebalance to ++# act on the file ++ ++TEST mv $M0/dir1/FILE1 $M0/dir1/FILE2 ++FPATH2=`find $B0/ -perm 1000 -name FILE2` ++ ++setfacl -m user:root:rwx $M0/dir1/FILE2 ++ ++# Run rebalance without the force option to skip ++# the file migration ++TEST $CLI volume rebalance $V0 start ++ ++EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 ++ ++#Check that the file has been skipped,i.e., the linkto still exists ++EXPECT "yes" is_sticky_set $FPATH2 ++ ++ ++#The linkto file should not have any posix acls set ++COUNT=`getfacl $FPATH2 |grep -c "user:root:rwx"` ++EXPECT "0" echo $COUNT ++ ++cleanup; +diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c +index 012d86b..442b46a 100644 +--- a/xlators/cluster/dht/src/dht-rebalance.c ++++ b/xlators/cluster/dht/src/dht-rebalance.c +@@ -1196,6 +1196,40 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, + ret = -1; + } + ++ /* Posix acls are not set on DHT linkto files as part of the initial ++ * initial xattrs set on the dst file, so these need ++ * to be set on the dst file after the linkto attrs are removed. ++ * TODO: Optimize this. ++ */ ++ if (xattr) { ++ dict_unref (xattr); ++ xattr = NULL; ++ } ++ ++ ret = syncop_listxattr (from, loc, &xattr, NULL, NULL); ++ if (ret < 0) { ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_MIGRATE_FILE_FAILED, ++ "Migrate file failed:" ++ "%s: failed to get xattr from %s (%s)", ++ loc->path, from->name, strerror (-ret)); ++ ret = -1; ++ } else { ++ ret = syncop_setxattr (to, loc, xattr, 0, NULL, NULL); ++ if (ret < 0) { ++ /* Potential problem here where Posix ACLs will ++ * not be set on the target file */ ++ ++ gf_msg (this->name, GF_LOG_WARNING, 0, ++ DHT_MSG_MIGRATE_FILE_FAILED, ++ "Migrate file failed:" ++ "%s: failed to set xattr on %s (%s)", ++ loc->path, to->name, strerror (-ret)); ++ ret = -1; ++ } ++ } ++ ++ + /* Make the source as a linkfile first before deleting it */ + empty_iatt.ia_prot.sticky = 1; + ret = syncop_fsetattr (from, src_fd, &empty_iatt, +diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c +index cae56e7..082e74e 100644 +--- a/xlators/storage/posix/src/posix-helpers.c ++++ b/xlators/storage/posix/src/posix-helpers.c +@@ -1072,7 +1072,7 @@ void posix_dump_buffer (xlator_t *this, const char *real_path, const char *key, + + int + posix_handle_pair (xlator_t *this, const char *real_path, +- char *key, data_t *value, int flags) ++ char *key, data_t *value, int flags, struct iatt *stbuf) + { + int sys_ret = -1; + int ret = 0; +@@ -1084,7 +1084,12 @@ posix_handle_pair (xlator_t *this, const char *real_path, + ret = posix_set_file_contents (this, real_path, key, value, + flags); + } else if (GF_POSIX_ACL_REQUEST (key)) { ++ if (stbuf && IS_DHT_LINKFILE_MODE (stbuf)) ++ goto out; + ret = posix_pacl_set (real_path, key, value->data); ++ } else if (!strncmp(key, POSIX_ACL_ACCESS_XATTR, strlen(key)) ++ && stbuf && IS_DHT_LINKFILE_MODE (stbuf)) { ++ goto out; + } else { + sys_ret = sys_lsetxattr (real_path, key, value->data, + value->len, flags); +@@ -1135,7 +1140,7 @@ out: + + int + posix_fhandle_pair (xlator_t *this, int fd, +- char *key, data_t *value, int flags) ++ char *key, data_t *value, int flags, struct iatt *stbuf) + { + int sys_ret = -1; + int ret = 0; +@@ -1143,6 +1148,9 @@ posix_fhandle_pair (xlator_t *this, int fd, + if (XATTR_IS_PATHINFO (key)) { + ret = -EACCES; + goto out; ++ } else if (!strncmp(key, POSIX_ACL_ACCESS_XATTR, strlen(key)) ++ && stbuf && IS_DHT_LINKFILE_MODE (stbuf)) { ++ goto out; + } + + sys_ret = sys_fsetxattr (fd, key, value->data, +@@ -1525,7 +1533,7 @@ _handle_entry_create_keyvalue_pair (dict_t *d, char *k, data_t *v, + } + + ret = posix_handle_pair (filler->this, filler->real_path, k, v, +- XATTR_CREATE); ++ XATTR_CREATE, filler->stbuf); + if (ret < 0) { + errno = -ret; + return -1; +@@ -1546,6 +1554,7 @@ posix_entry_create_xattr_set (xlator_t *this, const char *path, + + filler.this = this; + filler.real_path = path; ++ filler.stbuf = NULL; + + ret = dict_foreach (dict, _handle_entry_create_keyvalue_pair, &filler); + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index f1ebcc6..f7826fe 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3198,7 +3198,7 @@ _handle_setxattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + filler = tmp; + + return posix_handle_pair (filler->this, filler->real_path, k, v, +- filler->flags); ++ filler->flags, filler->stbuf); + } + + #ifdef GF_DARWIN_HOST_OS +@@ -3272,6 +3272,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + goto out; + } + ++ posix_pstat(this, loc->gfid, real_path, &stbuf); ++ + op_ret = -1; + + dict_del (dict, GFID_XATTR_KEY); +@@ -3279,6 +3281,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this, + + filler.real_path = real_path; + filler.this = this; ++ filler.stbuf = &stbuf; ++ + #ifdef GF_DARWIN_HOST_OS + filler.flags = map_xattr_flags(flags); + #else +@@ -4443,7 +4447,7 @@ _handle_fsetxattr_keyvalue_pair (dict_t *d, char *k, data_t *v, + filler = tmp; + + return posix_fhandle_pair (filler->this, filler->fdnum, k, v, +- filler->flags); ++ filler->flags, filler->stbuf); + } + + int32_t +@@ -4476,11 +4480,14 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, + } + _fd = pfd->fd; + ++ posix_fdstat (this, pfd->fd, &stbuf); ++ + dict_del (dict, GFID_XATTR_KEY); + dict_del (dict, GF_XATTR_VOL_ID_KEY); + + filler.fdnum = _fd; + filler.this = this; ++ filler.stbuf = &stbuf; + #ifdef GF_DARWIN_HOST_OS + filler.flags = map_xattr_flags(flags); + #else +diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h +index cf1465a..f8230be 100644 +--- a/xlators/storage/posix/src/posix.h ++++ b/xlators/storage/posix/src/posix.h +@@ -207,9 +207,9 @@ int posix_pstat (xlator_t *this, uuid_t gfid, const char *real_path, + dict_t *posix_xattr_fill (xlator_t *this, const char *path, loc_t *loc, + fd_t *fd, int fdnum, dict_t *xattr, struct iatt *buf); + int posix_handle_pair (xlator_t *this, const char *real_path, char *key, +- data_t *value, int flags); ++ data_t *value, int flags, struct iatt *stbuf); + int posix_fhandle_pair (xlator_t *this, int fd, char *key, data_t *value, +- int flags); ++ int flags, struct iatt *stbuf); + void posix_spawn_janitor_thread (xlator_t *this); + int posix_get_file_contents (xlator_t *this, uuid_t pargfid, + const char *name, char **contents); +-- +1.7.1 + diff --git a/SOURCES/0320-dht-lock-on-all-subvols-to-prevent-rmdir-vs-lookup-s.patch b/SOURCES/0320-dht-lock-on-all-subvols-to-prevent-rmdir-vs-lookup-s.patch new file mode 100644 index 0000000..681fc9c --- /dev/null +++ b/SOURCES/0320-dht-lock-on-all-subvols-to-prevent-rmdir-vs-lookup-s.patch @@ -0,0 +1,903 @@ +From fa25e79a00ef314a7a972534d4cd9e3b6f7fa6c4 Mon Sep 17 00:00:00 2001 +From: Sakshi +Date: Mon, 31 Aug 2015 16:06:35 +0530 +Subject: [PATCH 320/320] dht : lock on all subvols to prevent rmdir vs lookup selfheal race + +Reverting the changes made for fixing the above problem + +Change-Id: I31baf2b2fa2f62c57429cd44f3f229c35eff1939 +BUG: 1115367 +Signed-off-by: Sakshi +Reviewed-on: https://code.engineering.redhat.com/gerrit/56702 +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 180 ++++--------------------------- + xlators/cluster/dht/src/dht-common.h | 14 +-- + xlators/cluster/dht/src/dht-helper.c | 38 +------ + xlators/cluster/dht/src/dht-rename.c | 2 +- + xlators/cluster/dht/src/dht-selfheal.c | 183 +++++++++---------------------- + 5 files changed, 86 insertions(+), 331 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index f819aa6..5c1a693 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -40,10 +40,6 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); + int run_defrag = 0; + + int +-dht_rmdir_unlock (call_frame_t *frame, xlator_t *this); +- +- +-int + dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) + { + int ret = -1; +@@ -4518,6 +4514,7 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + * corresponding hashed subvolume will take care of the + * directory entry. + */ ++ + if (readdir_optimize) { + if (prev->this == local->first_up_subvol) + goto list; +@@ -5002,7 +4999,7 @@ out: + if (local && local->lock.locks) { + /* store op_errno for failure case*/ + local->op_errno = op_errno; +- local->refresh_layout_unlock (frame, this, op_ret, 0); ++ local->refresh_layout_unlock (frame, this, op_ret); + + if (op_ret == 0) { + DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, +@@ -5047,7 +5044,7 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + return 0; + err: + if (local->lock.locks) +- local->refresh_layout_unlock (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); + + return 0; + } +@@ -5152,7 +5149,7 @@ dht_mknod_do (call_frame_t *frame) + local->umask, local->params); + return 0; + err: +- local->refresh_layout_unlock (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); + + return 0; + } +@@ -5167,7 +5164,7 @@ dht_mknod_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int32_t +-dht_mknod_finish (call_frame_t *frame, xlator_t *this, int op_ret, int invoke_cbk) ++dht_mknod_finish (call_frame_t *frame, xlator_t *this, int op_ret) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -5242,7 +5239,7 @@ dht_mknod_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + return 0; + err: +- dht_mknod_finish (frame, this, -1, 0); ++ dht_mknod_finish (frame, this, -1); + return 0; + } + +@@ -5273,7 +5270,7 @@ dht_mknod_lock (call_frame_t *frame, xlator_t *subvol) + local->lock.lk_count = count; + + ret = dht_blocking_inodelk (frame, lk_array, count, +- IGNORE_ENOENT_ESTALE, dht_mknod_lock_cbk); ++ dht_mknod_lock_cbk); + + if (ret < 0) { + local->lock.locks = NULL; +@@ -5800,7 +5797,7 @@ out: + if (local && local->lock.locks) { + /* store op_errno for failure case*/ + local->op_errno = op_errno; +- local->refresh_layout_unlock (frame, this, op_ret, 0); ++ local->refresh_layout_unlock (frame, this, op_ret); + + if (op_ret == 0) { + DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, +@@ -5841,7 +5838,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + return 0; + err: + if (local->lock.locks) +- local->refresh_layout_unlock (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); + + return 0; + } +@@ -6005,7 +6002,7 @@ dht_create_do (call_frame_t *frame) + local->umask, local->fd, local->params); + return 0; + err: +- local->refresh_layout_unlock (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); + + return 0; + } +@@ -6019,7 +6016,7 @@ dht_create_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int32_t +-dht_create_finish (call_frame_t *frame, xlator_t *this, int op_ret, int invoke_cbk) ++dht_create_finish (call_frame_t *frame, xlator_t *this, int op_ret) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -6094,7 +6091,7 @@ dht_create_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + return 0; + err: +- dht_create_finish (frame, this, -1, 0); ++ dht_create_finish (frame, this, -1); + return 0; + } + +@@ -6125,7 +6122,7 @@ dht_create_lock (call_frame_t *frame, xlator_t *subvol) + local->lock.lk_count = count; + + ret = dht_blocking_inodelk (frame, lk_array, count, +- IGNORE_ENOENT_ESTALE, dht_create_lock_cbk); ++ dht_create_lock_cbk); + + if (ret < 0) { + local->lock.locks = NULL; +@@ -6585,7 +6582,6 @@ unlock: + this_call_cnt = dht_frame_return (frame); + if (is_last_call (this_call_cnt)) { + if (local->need_selfheal) { +- dht_rmdir_unlock (frame, this); + local->layout = + dht_layout_get (this, local->loc.inode); + +@@ -6609,7 +6605,6 @@ unlock: + 1); + } + +- dht_rmdir_unlock (frame, this); + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, + local->op_errno, &local->preparent, + &local->postparent, NULL); +@@ -6678,7 +6673,6 @@ unlock: + + if (done) { + if (local->need_selfheal && local->fop_succeeded) { +- dht_rmdir_unlock (frame, this); + local->layout = + dht_layout_get (this, local->loc.inode); + +@@ -6713,7 +6707,6 @@ unlock: + + } + +- dht_rmdir_unlock (frame, this); + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, + local->op_errno, &local->preparent, + &local->postparent, NULL); +@@ -6725,110 +6718,11 @@ unlock: + + + int +-dht_rmdir_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +- int32_t op_ret, int32_t op_errno, dict_t *xdata) +-{ +- DHT_STACK_DESTROY (frame); +- return 0; +-} +- +- +-int +-dht_rmdir_unlock (call_frame_t *frame, xlator_t *this) +-{ +- dht_local_t *local = NULL, *lock_local = NULL; +- call_frame_t *lock_frame = NULL; +- int lock_count = 0; +- +- local = frame->local; +- lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); +- +- if (lock_count == 0) +- goto done; +- +- lock_frame = copy_frame (frame); +- if (lock_frame == NULL) +- goto done; +- +- lock_local = dht_local_init (lock_frame, &local->loc, NULL, +- lock_frame->root->op); +- if (lock_local == NULL) +- goto done; +- +- lock_local->lock.locks = local->lock.locks; +- lock_local->lock.lk_count = local->lock.lk_count; +- +- local->lock.locks = NULL; +- local->lock.lk_count = 0; +- dht_unlock_inodelk (lock_frame, lock_local->lock.locks, +- lock_local->lock.lk_count, +- dht_rmdir_unlock_cbk); +- lock_frame = NULL; +- +-done: +- if (lock_frame != NULL) { +- DHT_STACK_DESTROY (lock_frame); +- } +- +- return 0; +-} +- +- +-int +-dht_rmdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +- int32_t op_ret, int32_t op_errno, dict_t *xdata) +-{ +- dht_local_t *local = NULL; +- dht_conf_t *conf = NULL; +- int i = 0; +- +- VALIDATE_OR_GOTO (this->private, err); +- +- conf = this->private; +- local = frame->local; +- +- if (op_ret < 0) { +- gf_msg (this->name, GF_LOG_WARNING, op_errno, +- DHT_MSG_INODE_LK_ERROR, +- "acquiring inodelk failed rmdir for %s)", +- local->loc.path); +- +- local->op_ret = -1; +- local->op_errno = (op_errno == EAGAIN) ? EBUSY : op_errno; +- goto err; +- } +- +- for (i = 0; i < conf->subvolume_cnt; i++) { +- if (local->hashed_subvol && +- (local->hashed_subvol == conf->subvolumes[i])) +- continue; +- +- STACK_WIND (frame, dht_rmdir_cbk, +- conf->subvolumes[i], +- conf->subvolumes[i]->fops->rmdir, +- &local->loc, local->flags, NULL); +- } +- +- return 0; +- +-err: +- /* No harm in calling an extra rmdir unlock */ +- dht_rmdir_unlock (frame, this); +- DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno, +- &local->preparent, &local->postparent, NULL); +- +- return 0; +-} +- +- +-int + dht_rmdir_do (call_frame_t *frame, xlator_t *this) + { + dht_local_t *local = NULL; + dht_conf_t *conf = NULL; +- dht_lock_t **lk_array = NULL; +- int i = 0, ret = -1; +- int count = 1; ++ int i = 0; + xlator_t *hashed_subvol = NULL; + char gfid[GF_UUID_BUF_SIZE] ={0}; + +@@ -6842,6 +6736,7 @@ dht_rmdir_do (call_frame_t *frame, xlator_t *this) + + local->call_cnt = conf->subvolume_cnt; + ++ + /* first remove from non-hashed_subvol */ + hashed_subvol = dht_subvol_get_hashed (this, &local->loc); + +@@ -6865,49 +6760,20 @@ dht_rmdir_do (call_frame_t *frame, xlator_t *this) + return 0; + } + +- count = conf->subvolume_cnt; +- +- lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); +- if (lk_array == NULL) { +- local->op_ret = -1; +- local->op_errno = ENOMEM; +- goto err; +- } +- +- for (i = 0; i < count; i++) { +- lk_array[i] = dht_lock_new (frame->this, +- conf->subvolumes[i], +- &local->loc, F_WRLCK, +- DHT_LAYOUT_HEAL_DOMAIN); +- if (lk_array[i] == NULL) { +- local->op_ret = -1; +- local->op_errno = EINVAL; +- goto err; +- } +- } +- +- local->lock.locks = lk_array; +- local->lock.lk_count = count; ++ for (i = 0; i < conf->subvolume_cnt; i++) { ++ if (hashed_subvol && ++ (hashed_subvol == conf->subvolumes[i])) ++ continue; + +- ret = dht_blocking_inodelk (frame, lk_array, count, +- IGNORE_ENOENT_ESTALE, +- dht_rmdir_lock_cbk); +- if (ret < 0) { +- local->lock.locks = NULL; +- local->lock.lk_count = 0; +- local->op_ret = -1; +- local->op_errno = errno ? errno : EINVAL; +- goto err; ++ STACK_WIND (frame, dht_rmdir_cbk, ++ conf->subvolumes[i], ++ conf->subvolumes[i]->fops->rmdir, ++ &local->loc, local->flags, NULL); + } + + return 0; + + err: +- if (lk_array != NULL) { +- dht_lock_array_free (lk_array, count); +- GF_FREE (lk_array); +- } +- + DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno, + &local->preparent, &local->postparent, NULL); + return 0; +diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h +index 7f99a06..1b5a084 100644 +--- a/xlators/cluster/dht/src/dht-common.h ++++ b/xlators/cluster/dht/src/dht-common.h +@@ -45,7 +45,7 @@ typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, xlator_t *dst_node, + call_frame_t *frame); + + typedef int (*dht_refresh_layout_unlock) (call_frame_t *frame, xlator_t *this, +- int op_ret, int invoke_cbk); ++ int op_ret); + + typedef int (*dht_refresh_layout_done_handle) (call_frame_t *frame); + +@@ -136,11 +136,6 @@ typedef enum { + qdstatfs_action_COMPARE, + } qdstatfs_action_t; + +-typedef enum { +- FAIL_ON_ANY_ERROR, +- IGNORE_ENOENT_ESTALE +-} dht_reaction_type_t; +- + struct dht_skip_linkto_unlink { + + gf_boolean_t handle_valid_link; +@@ -271,7 +266,6 @@ struct dht_local { + fop_inodelk_cbk_t inodelk_cbk; + dht_lock_t **locks; + int lk_count; +- dht_reaction_type_t reaction; + + /* whether locking failed on _any_ of the "locks" above */ + int op_ret; +@@ -1053,8 +1047,7 @@ dht_fill_dict_to_avoid_unlink_of_migrating_file (dict_t *dict); + + int + dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, dht_reaction_type_t reaction, +- fop_inodelk_cbk_t inodelk_cbk); ++ int lk_count, fop_inodelk_cbk_t inodelk_cbk); + + /* same as dht_nonblocking_inodelk, but issues sequential blocking locks on + * @lk_array directly. locks are issued on some order which remains same +@@ -1062,8 +1055,7 @@ dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + */ + int + dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, dht_reaction_type_t reaction, +- fop_inodelk_cbk_t inodelk_cbk); ++ int lk_count, fop_inodelk_cbk_t inodelk_cbk); + + int32_t + dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, +diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c +index 1b3fbb0..2e4a53c 100644 +--- a/xlators/cluster/dht/src/dht-helper.c ++++ b/xlators/cluster/dht/src/dht-helper.c +@@ -347,7 +347,6 @@ dht_lock_new (xlator_t *this, xlator_t *xl, loc_t *loc, short type, + + lock->xl = xl; + lock->type = type; +- + lock->domain = gf_strdup (domain); + if (lock->domain == NULL) { + dht_lock_free (lock); +@@ -1693,8 +1692,7 @@ out: + + int + dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, dht_reaction_type_t reaction, +- fop_inodelk_cbk_t inodelk_cbk) ++ int lk_count, fop_inodelk_cbk_t inodelk_cbk) + { + struct gf_flock flock = {0,}; + int i = 0, ret = 0; +@@ -1717,7 +1715,6 @@ dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + dht_set_lkowner (lk_array, lk_count, &lock_frame->root->lk_owner); + + local = lock_frame->local; +- local->lock.reaction = reaction; + local->main_frame = frame; + + local->call_cnt = lk_count; +@@ -1748,42 +1745,21 @@ dht_blocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) + { + int lk_index = 0; +- int i = 0; + dht_local_t *local = NULL; + + lk_index = (long) cookie; + + local = frame->local; ++ + if (op_ret == 0) { + local->lock.locks[lk_index]->locked = _gf_true; + } else { +- switch (op_errno) { +- case ESTALE: +- case ENOENT: +- if (local->lock.reaction != IGNORE_ENOENT_ESTALE) { +- local->lock.op_ret = -1; +- local->lock.op_errno = op_errno; +- goto cleanup; +- } +- break; +- default: +- local->lock.op_ret = -1; +- local->lock.op_errno = op_errno; +- goto cleanup; +- } ++ local->lock.op_ret = -1; ++ local->lock.op_errno = op_errno; ++ goto cleanup; + } + + if (lk_index == (local->lock.lk_count - 1)) { +- for (i = 0; (i < local->lock.lk_count) && +- (!local->lock.locks[i]->locked); i++) { +- ; +- } +- +- if (i == local->lock.lk_count) { +- local->lock.op_ret = -1; +- local->lock.op_errno = op_errno; +- } +- + dht_inodelk_done (frame); + } else { + dht_blocking_inodelk_rec (frame, ++lk_index); +@@ -1857,8 +1833,7 @@ out: + + int + dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, +- int lk_count, dht_reaction_type_t reaction, +- fop_inodelk_cbk_t inodelk_cbk) ++ int lk_count, fop_inodelk_cbk_t inodelk_cbk) + { + int ret = -1; + call_frame_t *lock_frame = NULL; +@@ -1880,7 +1855,6 @@ dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, + dht_set_lkowner (lk_array, lk_count, &lock_frame->root->lk_owner); + + local = lock_frame->local; +- local->lock.reaction = reaction; + local->main_frame = frame; + + dht_blocking_inodelk_rec (lock_frame, 0); +diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c +index 06d7ac8..320f875 100644 +--- a/xlators/cluster/dht/src/dht-rename.c ++++ b/xlators/cluster/dht/src/dht-rename.c +@@ -1307,7 +1307,7 @@ dht_rename_lock (call_frame_t *frame) + local->lock.lk_count = count; + + ret = dht_nonblocking_inodelk (frame, lk_array, count, +- FAIL_ON_ANY_ERROR, dht_rename_lock_cbk); ++ dht_rename_lock_cbk); + if (ret < 0) { + local->lock.locks = NULL; + local->lock.lk_count = 0; +diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c +index 46491cf..b9b58ea 100644 +--- a/xlators/cluster/dht/src/dht-selfheal.c ++++ b/xlators/cluster/dht/src/dht-selfheal.c +@@ -82,7 +82,7 @@ dht_selfheal_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + } + + int +-dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret, int invoke_cbk) ++dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret) + { + dht_local_t *local = NULL, *lock_local = NULL; + call_frame_t *lock_frame = NULL; +@@ -90,6 +90,7 @@ dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret, int invok + + local = frame->local; + lock_count = dht_lock_count (local->lock.locks, local->lock.lk_count); ++ + if (lock_count == 0) + goto done; + +@@ -116,9 +117,8 @@ dht_selfheal_dir_finish (call_frame_t *frame, xlator_t *this, int ret, int invok + lock_frame = NULL; + + done: +- if (!invoke_cbk) +- local->selfheal.dir_cbk (frame, NULL, frame->this, ret, +- local->op_errno, NULL); ++ local->selfheal.dir_cbk (frame, NULL, frame->this, ret, ++ local->op_errno, NULL); + if (lock_frame != NULL) { + DHT_STACK_DESTROY (lock_frame); + } +@@ -160,13 +160,13 @@ dht_refresh_layout_done (call_frame_t *frame) + + dht_layout_unref (frame->this, heal); + +- dht_selfheal_dir_finish (frame, frame->this, 0, 0); ++ dht_selfheal_dir_finish (frame, frame->this, 0); + } + + return 0; + + err: +- dht_selfheal_dir_finish (frame, frame->this, -1, 0); ++ dht_selfheal_dir_finish (frame, frame->this, -1); + return 0; + } + +@@ -224,9 +224,9 @@ unlock: + return 0; + + err: +- local->refresh_layout_unlock (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); + +- dht_selfheal_dir_finish (frame, this, -1, 0); ++ dht_selfheal_dir_finish (frame, this, -1); + return 0; + } + +@@ -292,8 +292,8 @@ dht_refresh_layout (call_frame_t *frame) + return 0; + + out: +- local->refresh_layout_unlock (frame, this, -1, 0); +- dht_selfheal_dir_finish (frame, this, -1, 0); ++ local->refresh_layout_unlock (frame, this, -1); ++ dht_selfheal_dir_finish (frame, this, -1); + return 0; + } + +@@ -321,7 +321,7 @@ dht_selfheal_layout_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + return 0; + + err: +- dht_selfheal_dir_finish (frame, this, -1, 0); ++ dht_selfheal_dir_finish (frame, this, -1); + return 0; + } + +@@ -582,7 +582,7 @@ dht_selfheal_layout_lock (call_frame_t *frame, dht_layout_t *layout, + local->lock.locks = lk_array; + local->lock.lk_count = count; + +- ret = dht_blocking_inodelk (frame, lk_array, count, FAIL_ON_ANY_ERROR, ++ ret = dht_blocking_inodelk (frame, lk_array, count, + dht_selfheal_layout_lock_cbk); + if (ret < 0) { + local->lock.locks = NULL; +@@ -593,7 +593,13 @@ dht_selfheal_layout_lock (call_frame_t *frame, dht_layout_t *layout, + return 0; + err: + if (lk_array != NULL) { +- dht_lock_array_free (lk_array, count); ++ int tmp_count = 0, i = 0; ++ ++ for (i = 0; (i < count) && (lk_array[i]); i++, tmp_count++) { ++ ; ++ } ++ ++ dht_lock_array_free (lk_array, tmp_count); + GF_FREE (lk_array); + } + +@@ -632,7 +638,7 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + this_call_cnt = dht_frame_return (frame); + + if (is_last_call (this_call_cnt)) { +- dht_selfheal_dir_finish (frame, this, 0, 0); ++ dht_selfheal_dir_finish (frame, this, 0); + } + + return 0; +@@ -827,7 +833,7 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout) + missing_xattr, loc->path); + + if (missing_xattr == 0) { +- dht_selfheal_dir_finish (frame, this, 0, 0); ++ dht_selfheal_dir_finish (frame, this, 0); + return 0; + } + +@@ -954,7 +960,7 @@ dht_selfheal_dir_xattr_for_nameless_lookup (call_frame_t *frame, loc_t *loc, + missing_xattr, loc->path); + + if (missing_xattr == 0) { +- dht_selfheal_dir_finish (frame, this, 0, 0); ++ dht_selfheal_dir_finish (frame, this, 0); + return 0; + } + +@@ -1022,7 +1028,7 @@ dht_selfheal_dir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_should_heal_layout); + + if (ret < 0) { +- dht_selfheal_dir_finish (frame, this, -1, 0); ++ dht_selfheal_dir_finish (frame, this, -1); + } + } + +@@ -1053,7 +1059,7 @@ dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf, + dht_should_heal_layout); + + if (ret < 0) { +- dht_selfheal_dir_finish (frame, this, -1, 0); ++ dht_selfheal_dir_finish (frame, this, -1); + } + + return 0; +@@ -1091,7 +1097,7 @@ dht_selfheal_dir_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_layout_t *layout = NULL; + call_frame_t *prev = NULL; + xlator_t *subvol = NULL; +- int i = 0, ret = -1; ++ int i = 0; + int this_call_cnt = 0; + char gfid[GF_UUID_BUF_SIZE] = {0}; + +@@ -1122,13 +1128,11 @@ dht_selfheal_dir_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); + dht_iatt_merge (this, &local->preparent, preparent, prev->this); + dht_iatt_merge (this, &local->postparent, postparent, prev->this); +- ret = 0; + + out: + this_call_cnt = dht_frame_return (frame); + + if (is_last_call (this_call_cnt)) { +- dht_selfheal_dir_finish (frame, this, ret, -1); + dht_selfheal_dir_setattr (frame, &local->loc, &local->stbuf, 0xffffff, layout); + } + +@@ -1181,33 +1185,33 @@ out: + } + + int +-dht_selfheal_dir_mkdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +- int32_t op_ret, int32_t op_errno, dict_t *xdata) ++dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, ++ dht_layout_t *layout, int force) + { +- dht_local_t *local = NULL; ++ int missing_dirs = 0; + int i = 0; + int ret = -1; ++ dht_local_t *local = NULL; ++ xlator_t *this = NULL; + dict_t *dict = NULL; +- dht_layout_t *layout = NULL; +- loc_t *loc = NULL; +- +- VALIDATE_OR_GOTO (this->private, err); + + local = frame->local; +- layout = local->layout; +- loc = &local->loc; ++ this = frame->this; + +- if (op_ret < 0) { +- gf_msg (this->name, GF_LOG_WARNING, op_errno, +- DHT_MSG_INODE_LK_ERROR, +- "acquiring inodelk failed for %s", +- loc->path); ++ local->selfheal.force_mkdir = force ? _gf_true : _gf_false; + +- local->op_ret = -1; +- local->op_errno = (op_errno == EAGAIN) ? EBUSY : op_errno; +- goto err; ++ for (i = 0; i < layout->cnt; i++) { ++ if (layout->list[i].err == ENOENT || force) ++ missing_dirs++; + } + ++ if (missing_dirs == 0) { ++ dht_selfheal_dir_setattr (frame, loc, &local->stbuf, ++ 0xffffffff, layout); ++ return 0; ++ } ++ ++ local->call_cnt = missing_dirs; + if (!gf_uuid_is_null (local->gfid)) { + dict = dict_new (); + if (!dict) +@@ -1221,7 +1225,6 @@ dht_selfheal_dir_mkdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *th + " key = gfid-req", loc->path); + } else if (local->params) { + /* Send the dictionary from higher layers directly */ +- + dict = dict_ref (local->params); + } + /* Set acls */ +@@ -1233,18 +1236,8 @@ dht_selfheal_dir_mkdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *th + DHT_MSG_DICT_SET_FAILED, + "dict is NULL, need to make sure gfids are same"); + +- +- /* We don't have to do a lookup here again: +- 1) Parallel rmdir would had removed the directory and locking would +- have anyway failed with an ESTALE on all subvols. Hence selfheal +- will never create the directory. +- 2) Parallel lookup creating directory does not have to be mutually +- exclusive for the mkdir phase of lookup selfheal. +- */ +- + for (i = 0; i < layout->cnt; i++) { +- if (layout->list[i].err == ENOENT || +- local->selfheal.force_mkdir) { ++ if (layout->list[i].err == ENOENT || force) { + gf_msg_debug (this->name, 0, + "Creating directory %s on subvol %s", + loc->path, layout->list[i].xlator->name); +@@ -1263,82 +1256,6 @@ dht_selfheal_dir_mkdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *th + dict_unref (dict); + + return 0; +- +-err: +- dht_selfheal_dir_finish (frame, this, -1, 0); +- return 0; +-} +- +-int +-dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, +- dht_layout_t *layout, int force) +-{ +- int missing_dirs = 0; +- int i = 0; +- int ret = -1; +- int count = 1; +- dht_local_t *local = NULL; +- dht_conf_t *conf = NULL; +- xlator_t *this = NULL; +- dht_lock_t **lk_array = NULL; +- +- local = frame->local; +- this = frame->this; +- conf = this->private; +- +- local->selfheal.force_mkdir = force ? _gf_true : _gf_false; +- +- for (i = 0; i < layout->cnt; i++) { +- if (layout->list[i].err == ENOENT || force) +- missing_dirs++; +- } +- +- if (missing_dirs == 0) { +- dht_selfheal_dir_setattr (frame, loc, &local->stbuf, +- 0xffffffff, layout); +- return 0; +- } +- +- local->call_cnt = missing_dirs; +- count = conf->subvolume_cnt; +- +- /* Locking on all subvols in the mkdir phase of lookup selfheal is +- is done to synchronize with rmdir/rename. +- */ +- lk_array = GF_CALLOC (count, sizeof (*lk_array), gf_common_mt_char); +- if (lk_array == NULL) +- goto err; +- +- for (i = 0; i < count; i++) { +- lk_array[i] = dht_lock_new (frame->this, +- conf->subvolumes[i], +- &local->loc, F_WRLCK, +- DHT_LAYOUT_HEAL_DOMAIN); +- if (lk_array[i] == NULL) +- goto err; +- } +- +- local->lock.locks = lk_array; +- local->lock.lk_count = count; +- +- ret = dht_blocking_inodelk (frame, lk_array, count, +- IGNORE_ENOENT_ESTALE, +- dht_selfheal_dir_mkdir_lock_cbk); +- +- if (ret < 0) { +- local->lock.locks = NULL; +- local->lock.lk_count = 0; +- goto err; +- } +- +- return 0; +-err: +- if (lk_array != NULL) { +- dht_lock_array_free (lk_array, count); +- GF_FREE (lk_array); +- } +- +- return -1; + } + + int +@@ -1910,7 +1827,7 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk, + + sorry_no_fix: + /* TODO: need to put appropriate local->op_errno */ +- dht_selfheal_dir_finish (frame, this, ret, 0); ++ dht_selfheal_dir_finish (frame, this, ret); + + return 0; + } +@@ -1978,7 +1895,7 @@ dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame, + + sorry_no_fix: + /* TODO: need to put appropriate local->op_errno */ +- dht_selfheal_dir_finish (frame, this, ret, 0); ++ dht_selfheal_dir_finish (frame, this, ret); + + return 0; + +@@ -2329,7 +2246,7 @@ dht_update_commit_hash_for_layout (call_frame_t *frame) + local->lock.locks = lk_array; + local->lock.lk_count = count; + +- ret = dht_blocking_inodelk (frame, lk_array, count, FAIL_ON_ANY_ERROR, ++ ret = dht_blocking_inodelk (frame, lk_array, count, + dht_update_commit_hash_for_layout_resume); + if (ret < 0) { + local->lock.locks = NULL; +@@ -2340,7 +2257,13 @@ dht_update_commit_hash_for_layout (call_frame_t *frame) + return 0; + err: + if (lk_array != NULL) { +- dht_lock_array_free (lk_array, count); ++ int tmp_count = 0, i = 0; ++ ++ for (i = 0; (i < count) && (lk_array[i]); i++, tmp_count++) { ++ ; ++ } ++ ++ dht_lock_array_free (lk_array, tmp_count); + GF_FREE (lk_array); + } + +-- +1.7.1 + diff --git a/SOURCES/0321-CommonHA-Fix-the-path-of-systemctl-cmd.patch b/SOURCES/0321-CommonHA-Fix-the-path-of-systemctl-cmd.patch new file mode 100644 index 0000000..73607f6 --- /dev/null +++ b/SOURCES/0321-CommonHA-Fix-the-path-of-systemctl-cmd.patch @@ -0,0 +1,39 @@ +From cc45a6c5a0f6d68529b790b1a03daf4d84af6cd9 Mon Sep 17 00:00:00 2001 +From: Soumya Koduri +Date: Wed, 2 Sep 2015 14:17:55 +0530 +Subject: [PATCH 321/330] CommonHA: Fix the path of 'systemctl' cmd + +'systemctl' command path should be '/usr/bin/sytemctl'. +Fixed the typo in the HA-script. + +This is backport of the below fix - +http://review.gluster.org/12089 + +BUG: 1259221 +Change-Id: Id40852191255d5107ddd17f5ec9f97073a2bc32c +Signed-off-by: Soumya Koduri +Reviewed-on: http://review.gluster.org/12089 +Reviewed-by: Kaleb KEITHLEY +Reviewed-by: Niels de Vos +Reviewed-on: https://code.engineering.redhat.com/gerrit/57119 +Tested-by: Niels de Vos +--- + extras/ganesha/scripts/ganesha-ha.sh | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh +index 01bd651..4bd3354 100644 +--- a/extras/ganesha/scripts/ganesha-ha.sh ++++ b/extras/ganesha/scripts/ganesha-ha.sh +@@ -97,7 +97,7 @@ manage_service () + { + local action=${1} + local new_node=${2} +- if [ "$SERVICE_MAN" == "/usr/sbin/systemctl" ] ++ if [ "$SERVICE_MAN" == "/usr/bin/systemctl" ] + then + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ + ${SECRET_PEM} root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha" +-- +1.7.1 + diff --git a/SOURCES/0322-uss-handle-buf-variable-properly-in-svs_glfs_readdir.patch b/SOURCES/0322-uss-handle-buf-variable-properly-in-svs_glfs_readdir.patch new file mode 100644 index 0000000..abc8122 --- /dev/null +++ b/SOURCES/0322-uss-handle-buf-variable-properly-in-svs_glfs_readdir.patch @@ -0,0 +1,56 @@ +From 05926a815a7df19c732d1ab7ea2ef3b36632038f Mon Sep 17 00:00:00 2001 +From: Jiffin Tony Thottan +Date: Mon, 7 Sep 2015 16:46:48 +0530 +Subject: [PATCH 322/330] uss : handle `buf` variable properly in svs_glfs_readdir() + +The svs_glfs_readdir() is a generic function which is called from +svs_readdir() and svs_readdirp(). But in svs_readdir 'buf' variable +is passed as NULL, then glfs_read_readdir() will fail. This patch +will fix the same. + +It is backport of http://review.gluster.org/12117 + +Upstream Reference: +> Change-Id: Id02e4e17e30c85de117db5ddd9f97b578622dff9 +> BUG: 1260611 +> Signed-off-by: Jiffin Tony Thottan +> cherry-picked as 7b6183c36ebfe020b724c95b018a8cd535e1ecdd + +Change-Id: I22628fdf3267e9366a5aa0df2b7984c0e6318819 +BUG: 1260086 +Signed-off-by: Jiffin Tony Thottan +Reviewed-on: https://code.engineering.redhat.com/gerrit/57343 +Reviewed-by: Niels de Vos +Tested-by: Niels de Vos +--- + .../features/snapview-server/src/snapview-server.c | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c +index 5ae9625..ed30cb8 100644 +--- a/xlators/features/snapview-server/src/snapview-server.c ++++ b/xlators/features/snapview-server/src/snapview-server.c +@@ -1246,7 +1246,6 @@ svs_glfs_readdir (xlator_t *this, glfs_fd_t *glfd, gf_dirent_t *entries, + GF_VALIDATE_OR_GOTO ("svs", this, out); + GF_VALIDATE_OR_GOTO (this->name, glfd, out); + GF_VALIDATE_OR_GOTO (this->name, entries, out); +- GF_VALIDATE_OR_GOTO (this->name, buf, out); + + while (filled_size < size) { + in_case = glfs_telldir (glfd); +@@ -1287,9 +1286,10 @@ svs_glfs_readdir (xlator_t *this, glfs_fd_t *glfd, gf_dirent_t *entries, + entry->d_off = glfs_telldir (glfd); + entry->d_ino = de.d_ino; + entry->d_type = de.d_type; +- iatt_from_stat (buf, &statbuf); +- if (readdirplus) ++ if (readdirplus) { ++ iatt_from_stat (buf, &statbuf); + entry->d_stat = *buf; ++ } + list_add_tail (&entry->list, &entries->list); + + filled_size += this_size; +-- +1.7.1 + diff --git a/SOURCES/0323-features-snap-cleanup-the-root-loc-in-statfs.patch b/SOURCES/0323-features-snap-cleanup-the-root-loc-in-statfs.patch new file mode 100644 index 0000000..5eb5050 --- /dev/null +++ b/SOURCES/0323-features-snap-cleanup-the-root-loc-in-statfs.patch @@ -0,0 +1,76 @@ +From 42c12a784d3acdb135eaf69d0589f9b6ddc277f3 Mon Sep 17 00:00:00 2001 +From: Ashish Pandey +Date: Tue, 8 Sep 2015 12:27:50 +0530 +Subject: [PATCH 323/330] features/snap : cleanup the root loc in statfs + +Problem : In svc_statfs function, wipe_loc is getting called on loc + passed by nfs. This loc is being used by svc_stat which + throws erro if loc->inode is NULL. + +Solution : wipe_loc should be called on local root_loc. + +Patch for upstream - +http://review.gluster.org/#/c/12123/ + +Patch for downstream - +http://review.gluster.org/#/c/12147/ + +Change-Id: I9cc5ee3b1bd9f352f2362a6d997b7b09051c0f68 +BUG: 1257509 +Signed-off-by: Ashish Pandey +Reviewed-on: https://code.engineering.redhat.com/gerrit/57439 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + tests/bugs/snapshot/bug-1260848.t | 25 ++++++++++++++++++++ + .../features/snapview-client/src/snapview-client.c | 2 +- + 2 files changed, 26 insertions(+), 1 deletions(-) + create mode 100644 tests/bugs/snapshot/bug-1260848.t + +diff --git a/tests/bugs/snapshot/bug-1260848.t b/tests/bugs/snapshot/bug-1260848.t +new file mode 100644 +index 0000000..9963b29 +--- /dev/null ++++ b/tests/bugs/snapshot/bug-1260848.t +@@ -0,0 +1,25 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../nfs.rc ++. $(dirname $0)/../../volume.rc ++ ++cleanup; ++ ++## Start and create a volume ++TEST glusterd ++TEST pidof glusterd ++ ++TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} ++TEST $CLI volume set $V0 uss on ++TEST $CLI volume start $V0 ++ ++## Wait for volume to register with rpc.mountd ++EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available; ++ ++## Mount NFS ++TEST mount_nfs $H0:/$V0 $N0 nolock; ++ ++TEST df -h $N0 ++ ++cleanup; +diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c +index b3f1a92..e784ff6 100644 +--- a/xlators/features/snapview-client/src/snapview-client.c ++++ b/xlators/features/snapview-client/src/snapview-client.c +@@ -546,7 +546,7 @@ svc_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, + + STACK_WIND_TAIL (frame, subvolume, subvolume->fops->statfs, + temp_loc, xdata); +- if (temp_loc) ++ if (temp_loc == &root_loc) + loc_wipe (temp_loc); + + wind = _gf_true; +-- +1.7.1 + diff --git a/SOURCES/0324-dht-NULL-dereferencing-causes-crash.patch b/SOURCES/0324-dht-NULL-dereferencing-causes-crash.patch new file mode 100644 index 0000000..29db038 --- /dev/null +++ b/SOURCES/0324-dht-NULL-dereferencing-causes-crash.patch @@ -0,0 +1,64 @@ +From 1c1cb9523eeda869c1589ef27005f4a99bda2a02 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Fri, 4 Sep 2015 19:46:48 +0530 +Subject: [PATCH 324/330] dht: NULL dereferencing causes crash + + back port of : http://review.gluster.org/12106 + +If linkfile_create is failed for some reason, then +we are trying to dereference a null variable + +>Change-Id: I3c6ff3715821b9b993d1bab7b90167de2861e190 +>BUG: 1260147 +>Signed-off-by: Mohammed Rafi KC +>Reviewed-on: http://review.gluster.org/12106 +>Reviewed-by: Susant Palai +>Reviewed-by: N Balachandran +>Tested-by: Gluster Build System +>Reviewed-by: Raghavendra G + +Change-Id: I95d5b58ecf46a6f6dded127267061f671e0055e6 +BUG: 1260512 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/57364 +Reviewed-by: Nithya Balachandran +Reviewed-by: Susant Palai +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 5c1a693..e3fe7dd 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -5025,10 +5025,10 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + dht_local_t *local = NULL; + xlator_t *cached_subvol = NULL; + ++ local = frame->local; + if (op_ret == -1) + goto err; + +- local = frame->local; + if (!local || !local->cached_subvol) { + op_errno = EINVAL; + goto err; +@@ -5822,12 +5822,12 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + dht_local_t *local = NULL; + xlator_t *cached_subvol = NULL; + ++ local = frame->local; + if (op_ret == -1) { + local->op_errno = op_errno; + goto err; + } + +- local = frame->local; + cached_subvol = local->cached_subvol; + + STACK_WIND (frame, dht_create_cbk, +-- +1.7.1 + diff --git a/SOURCES/0325-dht-remove-brick-Avoid-data-loss-for-hard-link-migra.patch b/SOURCES/0325-dht-remove-brick-Avoid-data-loss-for-hard-link-migra.patch new file mode 100644 index 0000000..1fedcc1 --- /dev/null +++ b/SOURCES/0325-dht-remove-brick-Avoid-data-loss-for-hard-link-migra.patch @@ -0,0 +1,127 @@ +From effeeb6b530a49370d3f4882238b1a9eb94e84b9 Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Fri, 4 Sep 2015 05:14:05 -0400 +Subject: [PATCH 325/330] dht/remove-brick: Avoid data loss for hard link migration + +Problem: If the hashed subvol of a file has reached cluster.min-free-disk, +for a create opertaion a linkto file will be created on the hashed and +the data file will be created on some other brick. + +For creation of the linkfile we populate the dictionary with linkto key +and value as the cached subvol. After successful linkto file creation, +the linkto-key-value pair is not deleted form the dictionary and hence, +the data file will also have linkto xattr which points to itself.This looks +something like this. + + client-0 client-1 +-------T file rwx------file +linkto.xattr=client-1 linkto.xattr=client-1 + +Now coming to the data loss part. Hardlink migration highly depend on this +linkto xattr on the data file. This value should be the new hashed subvol +of the first hardlink encountered post fix-layout. But when it tries to +read the linkto xattr it gets the same target as where it is sitting. + +Now the source and destination are same for migration. At the end of +migration the source file is truncated and deleted, which in this case +is the destination and also the only data file it self resulting in +data loss. + +BUG: 1259750 +Change-Id: Ie65204bfc63638164f10e17ed0552f86016bdf44 +Signed-off-by: Susant Palai +Reviewed-on: http://review.gluster.org/12105 +Reviewed-by: N Balachandran +Tested-by: NetBSD Build System +Reviewed-by: Raghavendra G +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/57566 +Reviewed-by: Nithya Balachandran +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 42 +++++++++++++++++++++++++++++----- + 1 files changed, 36 insertions(+), 6 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index e3fe7dd..1d27fba 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -5022,20 +5022,33 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) + { +- dht_local_t *local = NULL; +- xlator_t *cached_subvol = NULL; ++ dht_local_t *local = NULL; ++ xlator_t *cached_subvol = NULL; ++ dht_conf_t *conf = NULL; + + local = frame->local; +- if (op_ret == -1) +- goto err; + + if (!local || !local->cached_subvol) { + op_errno = EINVAL; + goto err; + } + ++ if (op_ret == -1) ++ goto err; ++ ++ conf = this->private; ++ if (!conf) { ++ local->op_errno = EINVAL; ++ goto err; ++ } ++ + cached_subvol = local->cached_subvol; + ++ if (local->params) { ++ dict_del (local->params, conf->link_xattr_name); ++ dict_del (local->params, GLUSTERFS_INTERNAL_FOP_KEY); ++ } ++ + STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)cached_subvol, + cached_subvol, cached_subvol->fops->mknod, + &local->loc, local->mode, local->rdev, local->umask, +@@ -5819,17 +5832,34 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) + { +- dht_local_t *local = NULL; +- xlator_t *cached_subvol = NULL; ++ dht_local_t *local = NULL; ++ xlator_t *cached_subvol = NULL; ++ dht_conf_t *conf = NULL; + + local = frame->local; ++ if (!local) { ++ op_errno = EINVAL; ++ goto err; ++ } ++ + if (op_ret == -1) { + local->op_errno = op_errno; + goto err; + } + ++ conf = this->private; ++ if (!conf) { ++ local->op_errno = EINVAL; ++ goto err; ++ } ++ + cached_subvol = local->cached_subvol; + ++ if (local->params) { ++ dict_del (local->params, conf->link_xattr_name); ++ dict_del (local->params, GLUSTERFS_INTERNAL_FOP_KEY); ++ } ++ + STACK_WIND (frame, dht_create_cbk, + cached_subvol, cached_subvol->fops->create, + &local->loc, local->flags, local->mode, +-- +1.7.1 + diff --git a/SOURCES/0326-firewall-spec-Create-glusterfs-firewall-service-if-f.patch b/SOURCES/0326-firewall-spec-Create-glusterfs-firewall-service-if-f.patch new file mode 100644 index 0000000..91a5f2b --- /dev/null +++ b/SOURCES/0326-firewall-spec-Create-glusterfs-firewall-service-if-f.patch @@ -0,0 +1,226 @@ +From d51815d7d0b065e447e5f51f26f1f724d2a3406f Mon Sep 17 00:00:00 2001 +From: anand +Date: Sat, 22 Aug 2015 01:09:53 +0530 +Subject: [PATCH 326/330] firewall/spec: Create glusterfs firewall service if firewalld installed. + +It creates glusterfs firewall service during installation. + +glusterfs service : It contains all default ports which needs to be opened. +During installation glusterfs.xml is copied into firewall service directory(/usr/lib/firewalld/services/). + +Note: +1.For bricks: It opens the 512 ports, if brick is running out side this range(>49664) then admin need to open the port +for that brick. +2.By default this service is not enabled in any of zone. + +To enable this service(glusterfs) in firewall: + +1. Get active zone(s) in node + firewall-cmd --get-active-zones + +2. Enable this service(glusterfs) to zone(s) + firewall-cmd --zone= --add-service=glusterfs --To apply runtime + firewall-cmd --permanent --zone= --add-service=glusterfs --To apply permanent + +Note: + we can also use firewall-config which gives GUI to configure firewall. + +Backportof: +>>http://review.gluster.org/#/c/11989/19 +>>Change-Id: Id97fe620c560fd10599511d751aed11a99ba4da5 +>>BUG: 1253967 + +Change-Id: I8fde5d908098d490aa4ab39877aab8dc44ebeacc +BUG: 1253774 +Signed-off-by: anand +Reviewed-on: https://code.engineering.redhat.com/gerrit/57564 +Reviewed-by: Kaushal Madappa +Reviewed-by: Atin Mukherjee +Tested-by: Atin Mukherjee +--- + configure.ac | 18 ++++++++++++++++++ + extras/Makefile.am | 2 +- + extras/firewalld/Makefile.am | 6 ++++++ + extras/firewalld/glusterfs.xml | 13 +++++++++++++ + glusterfs.spec.in | 36 ++++++++++++++++++++++++++++++++++++ + 5 files changed, 74 insertions(+), 1 deletions(-) + create mode 100644 extras/firewalld/Makefile.am + create mode 100644 extras/firewalld/glusterfs.xml + +diff --git a/configure.ac b/configure.ac +index a93c1cd..dfe105f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -211,6 +211,7 @@ AC_CONFIG_FILES([Makefile + extras/ocf/volume + extras/LinuxRPM/Makefile + extras/geo-rep/Makefile ++ extras/firewalld/Makefile + extras/hook-scripts/add-brick/Makefile + extras/hook-scripts/add-brick/pre/Makefile + extras/hook-scripts/add-brick/post/Makefile +@@ -731,6 +732,22 @@ AC_SUBST(ZLIB_CFLAGS) + AC_SUBST(ZLIB_LIBS) + # end CDC xlator secion + ++#start firewalld section ++BUILD_FIREWALLD="no" ++AC_ARG_ENABLE([firewalld], ++ AC_HELP_STRING([--enable-firewalld], ++ [enable installation configuration for firewalld]), ++ [BUILD_FIREWALLD="${enableval}"], [BUILD_FIREWALLD="no"]) ++ ++if test "x${BUILD_FIREWALLD}" = "xyes"; then ++ if !(which firewalld 1>/dev/null 2>&1) ; then ++ BUILD_FIREWALLD="no (firewalld not installed)" ++ fi ++fi ++AM_CONDITIONAL([USE_FIREWALLD],test ["x${BUILD_FIREWALLD}" = "xyes"]) ++ ++#endof firewald section ++ + # Data tiering requires sqlite + AC_ARG_ENABLE([tiering], + AC_HELP_STRING([--disable-tiering], +@@ -1343,4 +1360,5 @@ echo "Encryption xlator : $BUILD_CRYPT_XLATOR" + echo "Unit Tests : $BUILD_UNITTEST" + echo "POSIX ACLs : $BUILD_POSIX_ACLS" + echo "Data Classification : $BUILD_GFDB" ++echo "firewalld-config : $BUILD_FIREWALLD" + echo +diff --git a/extras/Makefile.am b/extras/Makefile.am +index ba2bef3..da99ecc 100644 +--- a/extras/Makefile.am ++++ b/extras/Makefile.am +@@ -5,7 +5,7 @@ EditorModedir = $(docdir) + EditorMode_DATA = glusterfs-mode.el glusterfs.vim + + SUBDIRS = init.d systemd benchmarking hook-scripts $(OCF_SUBDIR) LinuxRPM \ +- $(GEOREP_EXTRAS_SUBDIR) ganesha snap_scheduler ++ $(GEOREP_EXTRAS_SUBDIR) ganesha snap_scheduler firewalld + + confdir = $(sysconfdir)/glusterfs + conf_DATA = glusterfs-logrotate gluster-rsyslog-7.2.conf gluster-rsyslog-5.8.conf \ +diff --git a/extras/firewalld/Makefile.am b/extras/firewalld/Makefile.am +new file mode 100644 +index 0000000..a5c11b0 +--- /dev/null ++++ b/extras/firewalld/Makefile.am +@@ -0,0 +1,6 @@ ++EXTRA_DIST = glusterfs.xml ++ ++if USE_FIREWALLD ++staticdir = /usr/lib/firewalld/services/ ++static_DATA = glusterfs.xml ++endif +diff --git a/extras/firewalld/glusterfs.xml b/extras/firewalld/glusterfs.xml +new file mode 100644 +index 0000000..f8efd90 +--- /dev/null ++++ b/extras/firewalld/glusterfs.xml +@@ -0,0 +1,13 @@ ++ ++ ++glusterfs-static ++Default ports for gluster-distributed storage ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/glusterfs.spec.in b/glusterfs.spec.in +index 78bd311..f9e0447 100644 +--- a/glusterfs.spec.in ++++ b/glusterfs.spec.in +@@ -103,6 +103,10 @@ + %global _with_systemd true + %endif + ++%if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 7 ) ++%global _with_firewalld --enable-firewalld ++%endif ++ + %if 0%{?_tmpfilesdir:1} + %define _with_tmpfilesdir --with-tmpfilesdir=%{_tmpfilesdir} + %else +@@ -243,6 +247,10 @@ BuildRequires: glib2-devel + BuildRequires: libattr-devel + %endif + ++%if (0%{?_with_firewalld:1}) ++BuildRequires: firewalld ++%endif ++ + Obsoletes: hekafs + Obsoletes: %{name}-common < %{version}-%{release} + Obsoletes: %{name}-core < %{version}-%{release} +@@ -639,6 +647,7 @@ export LDFLAGS + %{?_without_epoll} \ + %{?_without_fusermount} \ + %{?_without_georeplication} \ ++ %{?_with_firewalld} \ + %{?_without_ocf} \ + %{?_without_qemu_block} \ + %{?_without_rdma} \ +@@ -896,6 +905,15 @@ if [ -e /etc/ld.so.conf.d/glusterfs.conf ]; then + rm -f /etc/ld.so.conf.d/glusterfs.conf + /sbin/ldconfig + fi ++ ++%if (0%{?_with_firewalld:1}) ++#reload service files if firewalld running ++if $(systemctl is-active firewalld 1>/dev/null 2>&1); then ++ #firewalld-filesystem is not available for rhel7, so command used for reload. ++ firewall-cmd --reload ++fi ++%endif ++ + pidof -c -o %PPID -x glusterd &> /dev/null + if [ $? -eq 0 ]; then + kill -9 `pgrep -f gsyncd.py` &> /dev/null +@@ -956,6 +974,17 @@ fi + %postun api + /sbin/ldconfig + ++%if ( 0%{?_build_server} ) ++%postun server ++%if (0%{?_with_firewalld:1}) ++#reload service files if firewalld running ++if $(systemctl is-active firewalld 1>/dev/null 2>&1); then ++ firewall-cmd --reload ++fi ++%endif ++%endif ++ ++ + %postun libs + /sbin/ldconfig + +@@ -1339,6 +1368,10 @@ fi + %{_libexecdir}/glusterfs/peer_add_secret_pub + %endif + ++%if ( 0%{?_with_firewalld:1} ) ++/usr/lib/firewalld/services/glusterfs.xml ++%endif ++ + + ##----------------------------------------------------------------------------- + ## All %pretrans should be placed here and keep them sorted +@@ -1931,6 +1964,9 @@ end + + %changelog + ++* Tue Aug 25 2015 Anand Nekkunti ++- adding glusterfs-firewalld service (#1253774) ++ + * Fri Jun 19 2015 Bala.FA + - exclude libgfdb.pc conditionally for rhel-5 (#1233486) + +-- +1.7.1 + diff --git a/SOURCES/0327-glusterd-disable-ping-timer-b-w-glusterd-and-make-ep.patch b/SOURCES/0327-glusterd-disable-ping-timer-b-w-glusterd-and-make-ep.patch new file mode 100644 index 0000000..9faebd2 --- /dev/null +++ b/SOURCES/0327-glusterd-disable-ping-timer-b-w-glusterd-and-make-ep.patch @@ -0,0 +1,41 @@ +From 8dce156a30800bc404679d380b2ab75bd680dd10 Mon Sep 17 00:00:00 2001 +From: Gaurav Kumar Garg +Date: Fri, 11 Sep 2015 17:55:42 +0530 +Subject: [PATCH 327/330] glusterd: disable ping timer b/w glusterd and make epoll thread count to 1 + +Currently glusterd is crashing when enable/disable heal and i/o is in +progress on the fuse mount. + +for more details refer following bug: +https://bugzilla.redhat.com/show_bug.cgi?id=1259992 +https://bugzilla.redhat.com/show_bug.cgi?id=1260930 + +This is because of by default multi thread epoll in glusterd is 2. +Workaround is to make epoll thread to 1 and set ping-timeout to 0 + +Change-Id: I34158b7f41c814f9bde85c7a32f4f0bc5dbaf86c +BUG: 1262236 +Signed-off-by: Gaurav Kumar Garg +Reviewed-on: https://code.engineering.redhat.com/gerrit/57629 +Reviewed-by: Krishnan Parthasarathi +Tested-by: Krishnan Parthasarathi +--- + extras/glusterd.vol.in | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/extras/glusterd.vol.in b/extras/glusterd.vol.in +index 690dbe7..316104c 100644 +--- a/extras/glusterd.vol.in ++++ b/extras/glusterd.vol.in +@@ -5,6 +5,7 @@ volume management + option transport.socket.keepalive-time 10 + option transport.socket.keepalive-interval 2 + option transport.socket.read-fail-log off +- option ping-timeout 30 ++ option ping-timeout 0 ++ option event-threads 1 + # option base-port 49152 + end-volume +-- +1.7.1 + diff --git a/SOURCES/0328-dht-cluster-Avoid-crash-if-local-is-NULL.patch b/SOURCES/0328-dht-cluster-Avoid-crash-if-local-is-NULL.patch new file mode 100644 index 0000000..857a006 --- /dev/null +++ b/SOURCES/0328-dht-cluster-Avoid-crash-if-local-is-NULL.patch @@ -0,0 +1,82 @@ +From c3338a100dd9948d7c30c7b50f6cebf95fd6801e Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Fri, 11 Sep 2015 08:52:44 -0400 +Subject: [PATCH 328/330] dht/cluster: Avoid crash if local is NULL + +This patch addresses crash handling if local is NULL. In addition to that, +we were not unwinding if no lock is taken in dht_linkfile_create_cbk(create/mknod). +This patch handles that also. + +BUG: 1259750 +Change-Id: I3f3dca5e88fba255e4c499f64c390da144a56590 +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/57617 +Reviewed-by: Nithya Balachandran +Reviewed-by: Raghavendra Gowdappa +Tested-by: Raghavendra Gowdappa +--- + xlators/cluster/dht/src/dht-common.c | 20 +++++++++++++++++--- + 1 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 1d27fba..7f4ae48 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -5033,12 +5033,15 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + goto err; + } + +- if (op_ret == -1) ++ if (op_ret == -1) { ++ local->op_errno = op_errno; + goto err; ++ } + + conf = this->private; + if (!conf) { + local->op_errno = EINVAL; ++ op_errno = EINVAL; + goto err; + } + +@@ -5056,8 +5059,13 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, + + return 0; + err: +- if (local->lock.locks) ++ if (local && local->lock.locks) { + local->refresh_layout_unlock (frame, this, -1); ++ } else { ++ DHT_STACK_UNWIND (mknod, frame, -1, ++ op_errno, NULL, NULL, NULL, ++ NULL, NULL); ++ } + + return 0; + } +@@ -5850,6 +5858,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + conf = this->private; + if (!conf) { + local->op_errno = EINVAL; ++ op_errno = EINVAL; + goto err; + } + +@@ -5867,8 +5876,13 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, + + return 0; + err: +- if (local->lock.locks) ++ if (local && local->lock.locks) { + local->refresh_layout_unlock (frame, this, -1); ++ } else { ++ DHT_STACK_UNWIND (create, frame, -1, ++ op_errno, NULL, NULL, NULL, ++ NULL, NULL, NULL); ++ } + + return 0; + } +-- +1.7.1 + diff --git a/SOURCES/0329-afr-get-split-brain-status-in-a-synctask.patch b/SOURCES/0329-afr-get-split-brain-status-in-a-synctask.patch new file mode 100644 index 0000000..adc92b9 --- /dev/null +++ b/SOURCES/0329-afr-get-split-brain-status-in-a-synctask.patch @@ -0,0 +1,283 @@ +From ec6028d919a974dcbe9d8428a09fc9de85a5fafd Mon Sep 17 00:00:00 2001 +From: Anuradha Talur +Date: Fri, 11 Sep 2015 18:43:36 +0530 +Subject: [PATCH 329/330] afr : get split-brain-status in a synctask + +On executing `getfattr -n replica.split-brain-status ` on mount, +there is a possibility that the mount hangs. To avoid this hang, +fetch the split-brain-status of a file in synctask. + +Upstream master patch : review.gluster.org/12163 +Upstream 3.7 patch : review.gluster.org/12166 + +Change-Id: I87b781419ffc63248f915325b845e3233143d385 +BUG: 1262291 +Signed-off-by: Anuradha Talur +Reviewed-on: https://code.engineering.redhat.com/gerrit/57674 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/afr/src/afr-common.c | 32 +++++++++++--- + xlators/cluster/afr/src/afr-inode-read.c | 67 +++++++++++++++++++++++----- + xlators/cluster/afr/src/afr-inode-write.c | 3 + + xlators/cluster/afr/src/afr-mem-types.h | 1 + + xlators/cluster/afr/src/afr-messages.h | 9 +++- + xlators/cluster/afr/src/afr.h | 13 ++++- + 6 files changed, 103 insertions(+), 22 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 7255179..9abb96d 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -4741,8 +4741,7 @@ out: + } + + int +-afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc, +- dict_t *xdata) ++afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc) + { + gf_boolean_t data_selfheal = _gf_false; + gf_boolean_t metadata_selfheal = _gf_false; +@@ -4867,7 +4866,14 @@ out: + } + + int +-afr_get_split_brain_status (call_frame_t *frame, xlator_t *this, loc_t *loc) ++afr_get_split_brain_status_cbk (int ret, call_frame_t *frame, void *opaque) ++{ ++ GF_FREE (opaque); ++ return 0; ++} ++ ++int ++afr_get_split_brain_status (void *opaque) + { + gf_boolean_t d_spb = _gf_false; + gf_boolean_t m_spb = _gf_false; +@@ -4880,7 +4886,15 @@ afr_get_split_brain_status (call_frame_t *frame, xlator_t *this, loc_t *loc) + inode_t *inode = NULL; + afr_private_t *priv = NULL; + xlator_t **children = NULL; +- ++ call_frame_t *frame = NULL; ++ xlator_t *this = NULL; ++ loc_t *loc = NULL; ++ afr_spb_status_t *data = NULL; ++ ++ data = opaque; ++ frame = data->frame; ++ this = frame->this; ++ loc = data->loc; + priv = this->private; + children = priv->children; + +@@ -4930,14 +4944,20 @@ afr_get_split_brain_status (call_frame_t *frame, xlator_t *this, loc_t *loc) + goto out; + } + ret = dict_set_dynstr (dict, GF_AFR_SBRAIN_STATUS, status); +- if (ret) ++ if (ret) { ++ op_errno = -ret; ++ ret = -1; + goto out; ++ } + } else { + ret = dict_set_str (dict, GF_AFR_SBRAIN_STATUS, + "The file is not under data or" + " metadata split-brain"); +- if (ret) ++ if (ret) { ++ op_errno = -ret; ++ ret = -1; + goto out; ++ } + } + + ret = 0; +diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c +index 1ebe5e5..6afd51d 100644 +--- a/xlators/cluster/afr/src/afr-inode-read.c ++++ b/xlators/cluster/afr/src/afr-inode-read.c +@@ -1429,6 +1429,59 @@ afr_marker_populate_args (call_frame_t *frame, int type, int *gauge, + return priv->child_count; + } + ++static int ++afr_handle_heal_xattrs (call_frame_t *frame, xlator_t *this, loc_t *loc, ++ const char *heal_op) ++{ ++ int ret = -1; ++ afr_spb_status_t *data = NULL; ++ ++ if (!strcmp (heal_op, GF_HEAL_INFO)) { ++ afr_get_heal_info (frame, this, loc); ++ ret = 0; ++ goto out; ++ } ++ ++ if (!strcmp (heal_op, GF_AFR_HEAL_SBRAIN)) { ++ afr_heal_splitbrain_file (frame, this, loc); ++ ret = 0; ++ goto out; ++ } ++ ++ if (!strcmp (heal_op, GF_AFR_SBRAIN_STATUS)) { ++ data = GF_CALLOC (1, sizeof (*data), gf_afr_mt_spb_status_t); ++ if (!data) { ++ ret = 1; ++ goto out; ++ } ++ data->frame = frame; ++ data->loc = loc; ++ ret = synctask_new (this->ctx->env, ++ afr_get_split_brain_status, ++ afr_get_split_brain_status_cbk, ++ NULL, data); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_SPLIT_BRAIN_STATUS, ++ "Failed to create" ++ " synctask. Unable to fetch split-brain status" ++ " for %s.", loc->name); ++ ret = 1; ++ goto out; ++ } ++ goto out; ++ } ++ ++out: ++ if (ret == 1) { ++ AFR_STACK_UNWIND (getxattr, frame, -1, ENOMEM, NULL, NULL); ++ if (data) ++ GF_FREE (data); ++ ret = 0; ++ } ++ return ret; ++} ++ + int32_t + afr_getxattr (call_frame_t *frame, xlator_t *this, + loc_t *loc, const char *name, dict_t *xdata) +@@ -1478,20 +1531,10 @@ afr_getxattr (call_frame_t *frame, xlator_t *this, + afr_marker_populate_args) == 0) + return 0; + +- if (!strcmp (name, GF_HEAL_INFO)) { +- afr_get_heal_info (frame, this, loc, xdata); ++ ret = afr_handle_heal_xattrs (frame, this, &local->loc, name); ++ if (ret == 0) + return 0; +- } + +- if (!strcmp (name, GF_AFR_HEAL_SBRAIN)) { +- afr_heal_splitbrain_file (frame, this, loc); +- return 0; +- } +- +- if (!strcmp (name, GF_AFR_SBRAIN_STATUS)) { +- afr_get_split_brain_status (frame, this, loc); +- return 0; +- } + /* + * Special xattrs which need responses from all subvols + */ +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index be83781..01390f0 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -1302,6 +1302,7 @@ afr_handle_split_brain_commands (xlator_t *this, call_frame_t *frame, + " synctask. Aborting split-brain choice set" + " for %s", loc->name); + ret = 1; ++ op_errno = ENOMEM; + goto out; + } + ret = 0; +@@ -1325,6 +1326,8 @@ out: + /* key was correct but value was invalid when ret == 1 */ + if (ret == 1) { + AFR_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); ++ if (data) ++ GF_FREE (data); + ret = 0; + } + return ret; +diff --git a/xlators/cluster/afr/src/afr-mem-types.h b/xlators/cluster/afr/src/afr-mem-types.h +index a11063c..fd484e4 100644 +--- a/xlators/cluster/afr/src/afr-mem-types.h ++++ b/xlators/cluster/afr/src/afr-mem-types.h +@@ -44,6 +44,7 @@ enum gf_afr_mem_types_ { + gf_afr_mt_reply_t, + gf_afr_mt_subvol_healer_t, + gf_afr_mt_spbc_timeout_t, ++ gf_afr_mt_spb_status_t, + gf_afr_mt_end + }; + #endif +diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h +index e4bf85b..4793413 100644 +--- a/xlators/cluster/afr/src/afr-messages.h ++++ b/xlators/cluster/afr/src/afr-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLFS_COMP_BASE_AFR GLFS_MSGID_COMP_AFR +-#define GLFS_NUM_MESSAGES 37 ++#define GLFS_NUM_MESSAGES 38 + #define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1) + + #define glfs_msg_start_x GLFS_COMP_BASE_AFR, "Invalid: Start of messages" +@@ -333,6 +333,13 @@ + #define AFR_MSG_SELF_HEAL_FAILED (GLFS_COMP_BASE_AFR + 37) + + ++/*! ++ * @messageid 108038 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_SPLIT_BRAIN_STATUS (GLFS_COMP_BASE_AFR + 38) ++ + + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_AFR_MESSAGES_H_ */ +diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h +index 729ae82..316eeea 100644 +--- a/xlators/cluster/afr/src/afr.h ++++ b/xlators/cluster/afr/src/afr.h +@@ -755,6 +755,11 @@ typedef struct afr_spbc_timeout { + int spb_child_index; + } afr_spbc_timeout_t; + ++typedef struct afr_spb_status { ++ call_frame_t *frame; ++ loc_t *loc; ++} afr_spb_status_t; ++ + typedef struct afr_read_subvol_args { + ia_type_t ia_type; + uuid_t gfid; +@@ -1050,14 +1055,16 @@ gf_boolean_t + afr_is_xattr_ignorable (char *key); + + int +-afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc, +- dict_t *xdata); ++afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc); + + int + afr_heal_splitbrain_file(call_frame_t *frame, xlator_t *this, loc_t *loc); + + int +-afr_get_split_brain_status (call_frame_t *frame, xlator_t *this, loc_t *loc); ++afr_get_split_brain_status (void *opaque); ++ ++int ++afr_get_split_brain_status_cbk (int ret, call_frame_t *frame, void *opaque); + + int + afr_inode_split_brain_choice_set (inode_t *inode, xlator_t *this, +-- +1.7.1 + diff --git a/SOURCES/0330-afr-perform-replace-brick-in-a-synctask.patch b/SOURCES/0330-afr-perform-replace-brick-in-a-synctask.patch new file mode 100644 index 0000000..87fb589 --- /dev/null +++ b/SOURCES/0330-afr-perform-replace-brick-in-a-synctask.patch @@ -0,0 +1,231 @@ +From 2cb67dea078a2d3f3f650e02eb91cedb3663f5d6 Mon Sep 17 00:00:00 2001 +From: Ravishankar N +Date: Mon, 14 Sep 2015 15:43:31 +0530 +Subject: [PATCH 330/330] afr: perform replace-brick in a synctask + +Patch in master: http://review.gluster.org/#/c/12169/ +Patch in release-3.7: http://review.gluster.org/#/c/12172/ + +Problem: +replace-brick setxattr is not performed inside a synctask. This can lead +to hangs if the setxattr is executed by epoll thread, as the epoll +thread will be waiting for replies to come where as epoll thread is the +thread that needs to epoll_ctl for reading from socket and listen. + +Fix: +Move replace-brick to synctask to prevent epoll thread hang. + +This patch is in line with the fix performed in +http://review.gluster.org/#/c/12163/ + +Change-Id: I0e04fe549428a91b8ca5cfe359ce0526c6c0336d +BUG: 1262291 +Signed-off-by: Ravishankar N +Reviewed-on: https://code.engineering.redhat.com/gerrit/57735 +Reviewed-by: Pranith Kumar Karampuri +Tested-by: Pranith Kumar Karampuri +--- + xlators/cluster/afr/src/afr-inode-write.c | 70 ++++++++++++++++++++++++----- + xlators/cluster/afr/src/afr-mem-types.h | 1 + + xlators/cluster/afr/src/afr-messages.h | 10 +++- + xlators/cluster/afr/src/afr.h | 6 +++ + 4 files changed, 73 insertions(+), 14 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c +index 01390f0..3968b24 100644 +--- a/xlators/cluster/afr/src/afr-inode-write.c ++++ b/xlators/cluster/afr/src/afr-inode-write.c +@@ -1099,27 +1099,45 @@ out: + } + + int +-_afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, +- int rb_index) ++_afr_handle_replace_brick_cbk (int ret, call_frame_t *frame, void *opaque) ++{ ++ afr_replace_brick_args_t *data = NULL; ++ ++ data = opaque; ++ loc_wipe (&data->loc); ++ GF_FREE (data); ++ return 0; ++} ++ ++int ++_afr_handle_replace_brick (void *opaque) + { + + afr_local_t *local = NULL; + afr_private_t *priv = NULL; ++ int rb_index = -1; + int ret = -1; + int op_errno = ENOMEM; ++ call_frame_t *frame = NULL; ++ xlator_t *this = NULL; ++ afr_replace_brick_args_t *data = NULL; + ++ data = opaque; ++ frame = data->frame; ++ rb_index = data->rb_index; ++ this = frame->this; + priv = this->private; + + local = AFR_FRAME_INIT (frame, op_errno); + if (!local) + goto out; + +- loc_copy (&local->loc, loc); ++ loc_copy (&local->loc, &data->loc); + + gf_log (this->name, GF_LOG_DEBUG, "Child being replaced is : %s", + priv->children[rb_index]->name); + +- ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index, ++ ret = _afr_handle_replace_brick_type (this, frame, &local->loc, rb_index, + AFR_METADATA_TRANSACTION); + if (ret) { + op_errno = -ret; +@@ -1132,7 +1150,7 @@ _afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, + local->pending = NULL; + local->xdata_req = NULL; + +- ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index, ++ ret = _afr_handle_replace_brick_type (this, frame, &local->loc, rb_index, + AFR_ENTRY_TRANSACTION); + if (ret) { + op_errno = -ret; +@@ -1359,32 +1377,60 @@ afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc, + { + int ret = -1; + int rb_index = -1; ++ int op_errno = EPERM; + char *replace_brick = NULL; ++ afr_replace_brick_args_t *data = NULL; + + ret = dict_get_str (dict, GF_AFR_REPLACE_BRICK, &replace_brick); + + if (!ret) { + if (frame->root->pid != GF_CLIENT_PID_AFR_SELF_HEALD) { ++ gf_log (this->name, GF_LOG_ERROR, "'%s' is an internal" ++ " extended attribute : %s.", ++ GF_AFR_REPLACE_BRICK, strerror (EPERM)); + ret = 1; + goto out; + } + rb_index = afr_get_child_index_from_name (this, replace_brick); + +- if (rb_index < 0) ++ if (rb_index < 0) { + /* Didn't belong to this replica pair + * Just do a no-op + */ + AFR_STACK_UNWIND (setxattr, frame, 0, 0, NULL); +- else +- _afr_handle_replace_brick (this, frame, loc, rb_index); ++ return 0; ++ } else { ++ data = GF_CALLOC (1, sizeof (*data), ++ gf_afr_mt_replace_brick_t); ++ if (!data) { ++ ret = 1; ++ op_errno = ENOMEM; ++ goto out; ++ } ++ data->frame = frame; ++ loc_copy (&data->loc, loc); ++ data->rb_index = rb_index; ++ ret = synctask_new (this->ctx->env, ++ _afr_handle_replace_brick, ++ _afr_handle_replace_brick_cbk, ++ NULL, data); ++ if (ret) { ++ gf_msg (this->name, GF_LOG_ERROR, 0, ++ AFR_MSG_REPLACE_BRICK_FAILED, ++ "Failed to create synctask. Unable to " ++ "perform replace-brick."); ++ ret = 1; ++ op_errno = ENOMEM; ++ loc_wipe (&data->loc); ++ GF_FREE (data); ++ goto out; ++ } ++ } + ret = 0; + } + out: + if (ret == 1) { +- gf_log (this->name, GF_LOG_ERROR, "'%s' is an internal" +- " extended attribute : %s.", +- GF_AFR_REPLACE_BRICK, strerror (EPERM)); +- AFR_STACK_UNWIND (setxattr, frame, -1, EPERM, NULL); ++ AFR_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + ret = 0; + } + return ret; +diff --git a/xlators/cluster/afr/src/afr-mem-types.h b/xlators/cluster/afr/src/afr-mem-types.h +index fd484e4..6f1eee9 100644 +--- a/xlators/cluster/afr/src/afr-mem-types.h ++++ b/xlators/cluster/afr/src/afr-mem-types.h +@@ -45,6 +45,7 @@ enum gf_afr_mem_types_ { + gf_afr_mt_subvol_healer_t, + gf_afr_mt_spbc_timeout_t, + gf_afr_mt_spb_status_t, ++ gf_afr_mt_replace_brick_t, + gf_afr_mt_end + }; + #endif +diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h +index 4793413..d07c7bc 100644 +--- a/xlators/cluster/afr/src/afr-messages.h ++++ b/xlators/cluster/afr/src/afr-messages.h +@@ -45,7 +45,7 @@ + */ + + #define GLFS_COMP_BASE_AFR GLFS_MSGID_COMP_AFR +-#define GLFS_NUM_MESSAGES 38 ++#define GLFS_NUM_MESSAGES 39 + #define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1) + + #define glfs_msg_start_x GLFS_COMP_BASE_AFR, "Invalid: Start of messages" +@@ -332,7 +332,6 @@ + */ + #define AFR_MSG_SELF_HEAL_FAILED (GLFS_COMP_BASE_AFR + 37) + +- + /*! + * @messageid 108038 + * @diagnosis +@@ -340,6 +339,13 @@ + */ + #define AFR_MSG_SPLIT_BRAIN_STATUS (GLFS_COMP_BASE_AFR + 38) + ++/*! ++ * @messageid 108039 ++ * @diagnosis ++ * @recommendedaction ++*/ ++#define AFR_MSG_REPLACE_BRICK_FAILED (GLFS_COMP_BASE_AFR + 39) ++ + + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + #endif /* !_AFR_MESSAGES_H_ */ +diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h +index 316eeea..19e764a 100644 +--- a/xlators/cluster/afr/src/afr.h ++++ b/xlators/cluster/afr/src/afr.h +@@ -760,6 +760,12 @@ typedef struct afr_spb_status { + loc_t *loc; + } afr_spb_status_t; + ++typedef struct afr_replace_brick_args { ++ call_frame_t *frame; ++ loc_t loc; ++ int rb_index; ++} afr_replace_brick_args_t; ++ + typedef struct afr_read_subvol_args { + ia_type_t ia_type; + uuid_t gfid; +-- +1.7.1 + diff --git a/SOURCES/0331-dht-cluster-Avoid-double-unlock-in-dht_refresh_layou.patch b/SOURCES/0331-dht-cluster-Avoid-double-unlock-in-dht_refresh_layou.patch new file mode 100644 index 0000000..64cc400 --- /dev/null +++ b/SOURCES/0331-dht-cluster-Avoid-double-unlock-in-dht_refresh_layou.patch @@ -0,0 +1,39 @@ +From dad0770acb2b1ccbefd317c03e2b202dfbdd0178 Mon Sep 17 00:00:00 2001 +From: Susant Palai +Date: Wed, 16 Sep 2015 07:04:24 -0400 +Subject: [PATCH 331/331] dht/cluster: Avoid double unlock in dht_refresh_layout_cbk + +Change-Id: Id230ec744e277cd6a24a09890496a0c3023e565f +BUG: 1263653 +Signed-off-by: Susant Palai +Reviewed-on: https://code.engineering.redhat.com/gerrit/57882 +Reviewed-by: Nithya Balachandran +Tested-by: Nithya Balachandran +--- + xlators/cluster/dht/src/dht-selfheal.c | 3 +-- + 1 files changed, 1 insertions(+), 2 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c +index b9b58ea..b3f1c4d 100644 +--- a/xlators/cluster/dht/src/dht-selfheal.c ++++ b/xlators/cluster/dht/src/dht-selfheal.c +@@ -226,7 +226,6 @@ unlock: + err: + local->refresh_layout_unlock (frame, this, -1); + +- dht_selfheal_dir_finish (frame, this, -1); + return 0; + } + +@@ -293,7 +292,7 @@ dht_refresh_layout (call_frame_t *frame) + + out: + local->refresh_layout_unlock (frame, this, -1); +- dht_selfheal_dir_finish (frame, this, -1); ++ + return 0; + } + +-- +1.7.1 + diff --git a/SPECS/glusterfs.spec b/SPECS/glusterfs.spec index 0721976..87e220f 100644 --- a/SPECS/glusterfs.spec +++ b/SPECS/glusterfs.spec @@ -9,8 +9,12 @@ ## All argument definitions should be placed here and keep them sorted ## +# if you wish to compile an rpm with cmocka unit testing... +# rpmbuild -ta glusterfs-3.7.1.tar.gz --with cmocka +%{?_with_cmocka:%global _with_cmocka --enable-cmocka} + # if you wish to compile an rpm without rdma support, compile like this... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without rdma +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without rdma %{?_without_rdma:%global _without_rdma --disable-ibverbs} # No RDMA Support on s390(x) @@ -19,15 +23,15 @@ %endif # if you wish to compile an rpm without epoll... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without epoll +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without epoll %{?_without_epoll:%global _without_epoll --disable-epoll} # if you wish to compile an rpm without fusermount... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without fusermount +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without fusermount %{?_without_fusermount:%global _without_fusermount --disable-fusermount} # if you wish to compile an rpm without geo-replication support, compile like this... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without georeplication +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without georeplication %{?_without_georeplication:%global _without_georeplication --disable-georeplication} # Disable geo-replication on EL5, as its default Python is too old @@ -36,20 +40,23 @@ %endif # if you wish to compile an rpm without the OCF resource agents... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without ocf +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without ocf %{?_without_ocf:%global _without_ocf --without-ocf} # if you wish to build rpms without syslog logging, compile like this -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without syslog +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without syslog %{?_without_syslog:%global _without_syslog --disable-syslog} # disable syslog forcefully as rhel <= 6 doesn't have rsyslog or rsyslog-mmcount -%if ( 0%{?rhel} && 0%{?rhel} <= 6 ) +# Fedora deprecated syslog, see +# https://fedoraproject.org/wiki/Changes/NoDefaultSyslog +# (And what about RHEL7?) +%if ( 0%{?fedora} && 0%{?fedora} >= 20 ) || ( 0%{?rhel} && 0%{?rhel} <= 6 ) %global _without_syslog --disable-syslog %endif # if you wish to compile an rpm without the BD map support... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without bd +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without bd %{?_without_bd:%global _without_bd --disable-bd-xlator} %if ( 0%{?rhel} && 0%{?rhel} < 6 || 0%{?sles_version} ) @@ -57,7 +64,7 @@ %endif # if you wish to compile an rpm without the qemu-block support... -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without qemu-block +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without qemu-block %{?_without_qemu_block:%global _without_qemu_block --disable-qemu-block} %if ( 0%{?rhel} && 0%{?rhel} < 6 ) @@ -66,22 +73,28 @@ %endif # if you wish not to build server rpms, compile like this. -# rpmbuild -ta glusterfs-3.6.0.29.tar.gz --without server +# rpmbuild -ta glusterfs-3.7.1.tar.gz --without server %global _build_server 1 %if "%{?_without_server}" %global _build_server 0 %endif -%if ( "%{?dist}" == ".el6rhs" ) || ( "%{?dist}" == ".el7rhs" ) +%if ( "%{?dist}" == ".el6rhs" ) || ( "%{?dist}" == ".el7rhs" ) || ( "%{?dist}" == ".el7rhgs" ) %global _build_server 1 %else %global _build_server 0 +%global _without_georeplication --disable-georeplication %endif %global _without_extra_xlators 1 %global _without_regression_tests 1 +# Disable data-tiering on EL5, sqlite is too old +%if ( 0%{?rhel} && 0%{?rhel} < 6 ) +%global _without_tiering --disable-tiering +%endif + ##----------------------------------------------------------------------------- ## All %global definitions should be placed here and keep them sorted ## @@ -90,6 +103,16 @@ %global _with_systemd true %endif +%if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 7 ) +%global _with_firewalld --enable-firewalld +%endif + +%if 0%{?_tmpfilesdir:1} +%define _with_tmpfilesdir --with-tmpfilesdir=%{_tmpfilesdir} +%else +%define _with_tmpfilesdir --without-tmpfilesdir +%endif + # there is no systemtap support! Perhaps some day there will be %global _without_systemtap --enable-systemtap=no @@ -103,6 +126,7 @@ %define _init_enable() /bin/systemctl enable %1.service ; %define _init_disable() /bin/systemctl disable %1.service ; %define _init_restart() /bin/systemctl try-restart %1.service ; +%define _init_start() /bin/systemctl start %1.service ; %define _init_stop() /bin/systemctl stop %1.service ; %define _init_install() install -D -p -m 0644 %1 %{buildroot}%{_unitdir}/%2.service ; # can't seem to make a generic macro that works @@ -112,6 +136,7 @@ %define _init_enable() /sbin/chkconfig --add %1 ; %define _init_disable() /sbin/chkconfig --del %1 ; %define _init_restart() /sbin/service %1 condrestart &>/dev/null ; +%define _init_start() /sbin/service %1 start &>/dev/null ; %define _init_stop() /sbin/service %1 stop &>/dev/null ; %define _init_install() install -D -p -m 0755 %1 %{buildroot}%{_sysconfdir}/init.d/%2 ; # can't seem to make a generic macro that works @@ -154,7 +179,7 @@ ##----------------------------------------------------------------------------- ## All package definitions should be placed here and keep them sorted ## -Summary: Cluster File System +Summary: Distributed File System %if ( 0%{_for_fedora_koji_builds} ) Name: glusterfs Version: 3.5.0 @@ -162,8 +187,8 @@ Release: 0.1%{?prereltag:.%{prereltag}}%{?dist} Vendor: Fedora Project %else Name: glusterfs -Version: 3.6.0.29 -Release: 2%{?dist} +Version: 3.7.1 +Release: 16%{?dist} ExclusiveArch: x86_64 aarch64 %endif License: GPLv2 or LGPLv3+ @@ -173,14 +198,11 @@ URL: http://www.gluster.org/docs/index.php/GlusterFS Source0: http://bits.gluster.org/pub/gluster/glusterfs/src/glusterfs-%{version}%{?prereltag}.tar.gz Source1: glusterd.sysconfig Source2: glusterfsd.sysconfig -Source3: glusterfs-fuse.logrotate -Source4: glusterd.logrotate -Source5: glusterfsd.logrotate Source6: rhel5-load-fuse-modules Source7: glusterfsd.service Source8: glusterfsd.init %else -Source0: glusterfs-3.6.0.29.tar.gz +Source0: glusterfs-3.7.1.tar.gz %endif BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -190,14 +212,6 @@ BuildRequires: python-simplejson %endif %if ( 0%{?_with_systemd:1} ) BuildRequires: systemd-units -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -%else -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/service -Requires(preun): /sbin/chkconfig -Requires(postun): /sbin/service %endif Requires: %{name}-libs = %{version}-%{release} @@ -205,9 +219,21 @@ BuildRequires: bison flex BuildRequires: gcc make automake libtool BuildRequires: ncurses-devel readline-devel BuildRequires: libxml2-devel openssl-devel -BuildRequires: libaio-devel +BuildRequires: libaio-devel libacl-devel BuildRequires: python-devel BuildRequires: python-ctypes +BuildRequires: userspace-rcu-devel >= 0.7 +%if ( 0%{?rhel} && 0%{?rhel} <= 5 ) +BuildRequires: e2fsprogs-devel +%else +BuildRequires: libuuid-devel +%endif +%if ( 0%{?_with_cmocka:1} ) +BuildRequires: libcmocka-devel >= 1.0.1 +%endif +%if ( 0%{!?_without_tiering:1} ) +BuildRequires: sqlite-devel +%endif %if ( 0%{!?_without_systemtap:1} ) BuildRequires: systemtap-sdt-devel %endif @@ -221,6 +247,10 @@ BuildRequires: glib2-devel BuildRequires: libattr-devel %endif +%if (0%{?_with_firewalld:1}) +BuildRequires: firewalld +%endif + Obsoletes: hekafs Obsoletes: %{name}-common < %{version}-%{release} Obsoletes: %{name}-core < %{version}-%{release} @@ -228,8 +258,340 @@ Obsoletes: %{name}-ufo Provides: %{name}-common = %{version}-%{release} Provides: %{name}-core = %{version}-%{release} +# Patch0001: 0001-Update-rfc.sh-to-rhgs-3.1.patch +Patch0002: 0002-features-quota-Do-unwind-if-postbuf-is-NULL.patch +Patch0003: 0003-features-quota-Make-quota-deem-statfs-option-on-by-d.patch +Patch0004: 0004-features-quota-prevent-statfs-frame-loss-when-an-err.patch +Patch0005: 0005-quota-retry-connecting-to-quotad-on-ENOTCONN-error.patch +Patch0006: 0006-snapshot-scheduler-Return-proper-error-code-in-case-.patch +Patch0007: 0007-glusterd-do-not-show-pid-of-brick-in-volume-status-i.patch +Patch0008: 0008-glusterd-Buffer-overflow-causing-crash-for-glusterd.patch +Patch0009: 0009-glusterd-shared_storage-Provide-a-volume-set-option-.patch +Patch0010: 0010-dht-rebalance-Fixed-rebalance-failure.patch +Patch0011: 0011-cluster-dht-Fix-dht_setxattr-to-follow-files-under-m.patch +Patch0012: 0012-cluster-dht-Don-t-rely-on-linkto-xattr-to-find-desti.patch +Patch0013: 0013-afr-honour-selfheal-enable-disable-volume-set-option.patch +Patch0014: 0014-cluster-ec-EC_XATTR_DIRTY-doesn-t-come-in-response.patch +Patch0015: 0015-glusterd-Bump-op-version-and-max-op-version-for-3.7..patch +Patch0016: 0016-build-remove-ghost-directory-entries.patch +Patch0017: 0017-build-add-RHGS-specific-changes.patch +Patch0018: 0018-secalert-remove-setuid-bit-for-fusermount-glusterfs.patch +Patch0019: 0019-dht-Add-lookup-optimize-configuration-option-for-DHT.patch +Patch0020: 0020-features-quota-Fix-ref-leak.patch +Patch0021: 0021-worm-Let-lock-zero-xattrop-calls-succeed.patch +Patch0022: 0022-glusterd-snapshot-Return-correct-errno-in-events-of-.patch +Patch0023: 0023-snapshot-Fix-finding-brick-mount-path-logic.patch +Patch0024: 0024-bitrot-glusterd-scrub-option-should-be-disabled-once.patch +Patch0025: 0025-glusterd-fix-repeated-connection-to-nfssvc-failed-ms.patch +Patch0026: 0026-rpc-call-transport_unref-only-on-non-NULL-transport.patch +Patch0027: 0027-socket-throttle-only-connected-transport.patch +Patch0028: 0028-cluster-dht-pass-a-destination-subvol-to-fop2-varian.patch +Patch0029: 0029-cluster-ec-Prevent-double-unwind.patch +Patch0030: 0030-Upcall-cache-invalidation-Ignore-fops-with-frame-roo.patch +Patch0031: 0031-cli-Fix-incorrect-parse-logic-for-volume-heal-comman.patch +Patch0032: 0032-nfs-allocate-and-return-the-hashkey-for-the-auth_cac.patch +Patch0033: 0033-features-marker-Cleanup-loc-in-case-of-errors.patch +Patch0034: 0034-ec-Changing-log-level-to-DEBUG-in-case-of-ENOENT.patch +Patch0035: 0035-protocol-server-Changing-log-level-from-Warning-to-D.patch +Patch0036: 0036-glusterd-Stop-tcp-ip-listeners-during-glusterd-exit.patch +Patch0037: 0037-libglusterfs-Enabling-the-fini-in-cleanup_and_exit.patch +Patch0038: 0038-glusterd-disable-ping-timer.patch +Patch0039: 0039-cluster-ec-Wind-unlock-fops-at-all-cost.patch +Patch0040: 0040-build-fix-compiling-on-older-distributions.patch +Patch0041: 0041-rpm-correct-date-and-order-of-entries-in-the-changel.patch +Patch0042: 0042-nfs-ganesha-HA-fix-race-between-setting-grace-and-vi.patch +Patch0043: 0043-logging-log-Stale-filehandle-on-the-client-as-Debug.patch +Patch0044: 0044-snapshot-scheduler-Handle-OSError-in-os.-callbacks.patch +Patch0045: 0045-snapshot-scheduler-Check-if-GCRON_TASKS-exists-befor.patch +Patch0046: 0046-storage-posix-Handle-MAKE_INODE_HANDLE-failures.patch +Patch0047: 0047-snapshot-scheduler-Reload-etc-cron.d-glusterfs_snap_.patch +Patch0048: 0048-build-packaging-corrections-for-RHEL-5.patch +Patch0049: 0049-features-marker-Pass-along-xdata-to-lower-translator.patch +Patch0050: 0050-cluster-dht-fix-incorrect-dst-subvol-info-in-inode_c.patch +Patch0051: 0051-build-introduce-security-hardening-flags-in-gluster.patch +Patch0052: 0052-glusterd-Display-status-of-Self-Heal-Daemon-for-disp.patch +Patch0053: 0053-cluster-dht-maintain-start-state-of-rebalance-daemon.patch +Patch0054: 0054-cluster-tier-account-for-reordered-layouts.patch +Patch0055: 0055-cluster-tier-make-attach-detach-work-with-new-rebala.patch +Patch0056: 0056-tier-dht-Fixing-non-atomic-promotion-demotion-w.r.t-.patch +Patch0057: 0057-cluster-ec-Prevent-Null-dereference-in-dht-rename.patch +Patch0058: 0058-features-changelog-Avoid-setattr-fop-logging-during-.patch +Patch0059: 0059-tools-glusterfind-verifying-volume-presence.patch +Patch0060: 0060-geo-rep-ignore-symlink-and-harlink-errors-in-geo-rep.patch +Patch0061: 0061-spec-fix-add-pre-transaction-scripts-for-geo-rep-and.patch +Patch0062: 0062-tools-glusterfind-Fix-GFID-to-Path-conversion-for-di.patch +Patch0063: 0063-tools-glusterfind-Cleanup-glusterfind-dir-after-a-vo.patch +Patch0064: 0064-geo-rep-Validate-use_meta_volume-option.patch +Patch0065: 0065-tools-glusterfind-Cleanup-session-dir-after-delete.patch +Patch0066: 0066-tools-glusterfind-verifying-volume-is-online.patch +Patch0067: 0067-features-changelog-Do-htime-setxattr-without-XATTR_R.patch +Patch0068: 0068-snapshot-scheduler-Modified-main-function-to-take-ar.patch +Patch0069: 0069-glusterd-fix-op-versions-for-RHS-backwards-compatabi.patch +Patch0070: 0070-tools-glusterfind-ignoring-deleted-files.patch +Patch0071: 0071-spec-geo-rep-Add-rsync-as-dependency-for-georeplicat.patch +Patch0072: 0072-tools-glusterfind-print-message-for-good-cases.patch +Patch0073: 0073-common-ha-handle-long-node-names-and-node-names-with.patch +Patch0074: 0074-common-ha-Clean-up-persistent-cib-state.patch +Patch0075: 0075-glusterd-subvol_count-value-for-replicate-volume-sho.patch +Patch0076: 0076-upcall-prevent-busy-loop-in-reaper-thread.patch +Patch0077: 0077-common-ha-Clean-up-cib-state-completely.patch +Patch0078: 0078-NFS-Ganesha-Return-corect-return-value.patch +Patch0079: 0079-contrib-timer-wheel-fix-deadlock-in-del_timer.patch +Patch0080: 0080-libglusterfs-update-glfs-messages-header-for-reserve.patch +Patch0081: 0081-protocol-client-porting-log-messages-to-new-framewor.patch +Patch0082: 0082-protocol-server-port-log-messages-to-new-framework.patch +Patch0083: 0083-common-ha-cluster-HA-setup-sometimes-fails.patch +Patch0084: 0084-ec-Display-correct-message-after-successful-heal-sta.patch +Patch0085: 0085-cluster-ec-Prevent-races-in-ec_unlock-for-rename.patch +Patch0086: 0086-glusterd-Porting-messages-to-new-logging-framework.patch +Patch0087: 0087-sm-glusterd-Porting-messages-to-new-logging-framewor.patch +Patch0088: 0088-rebalance-store-glusterd-glusterd-porting-to-new-log.patch +Patch0089: 0089-handler-messages-glusterd-Porting-to-new-logging-fra.patch +Patch0090: 0090-handshake-locks-mountbroker-syncop-glusterd-New-logg.patch +Patch0091: 0091-utils-glusterd-Porting-to-new-logging-framwork.patch +Patch0092: 0092-quota-glusterd-porting-to-new-logging-framework.patch +Patch0093: 0093-snapshot-Fix-terminating-slash-in-brick-mount-path.patch +Patch0094: 0094-rpm-glusterfs-devel-for-client-builds-should-not-dep.patch +Patch0095: 0095-snapshot-man-page-modifications.patch +Patch0096: 0096-ops-glusterd-Porting-messages-to-new-logging-framewo.patch +Patch0097: 0097-glusterd-uss-snapshot-Intialise-snapdsvc-after-volfi.patch +Patch0098: 0098-build-add-pretrans-check.patch +Patch0099: 0099-glusterd-geo-rep-porting-log-messages-to-a-new-frame.patch +Patch0100: 0100-glusterd-Fixing-the-compilation-failures.patch +Patch0101: 0101-cluster-afr-Do-not-attempt-entry-self-heal-if-the-la.patch +Patch0102: 0102-common-ha-cluster-HA-setup-sometimes-fails.patch +Patch0103: 0103-glusterd-Fix-snapshot-of-a-volume-with-geo-rep.patch +Patch0104: 0104-quota-fix-double-accounting-with-rename-operation.patch +Patch0105: 0105-gluster-shared_storage-Add-Remove-shared-storage-fro.patch +Patch0106: 0106-glusterd-mgmt_v3-Print-the-node-info-with-failure-me.patch +Patch0107: 0107-build-exclude-libgfdb.pc-conditionally.patch +Patch0108: 0108-libgfchangelog-Fix-crash-in-gf_changelog_process.patch +Patch0109: 0109-Porting-new-log-messages-for-posix.patch +Patch0110: 0110-rdma-porting-rdma-to-a-new-message-id-logging-format.patch +Patch0111: 0111-glusterd-afr-set-afr-pending-xattrs-on-replace-brick.patch +Patch0112: 0112-libglusterfs-allocate-a-segment-for-quota-logging.patch +Patch0113: 0113-libgfapi-port-gfapi-to-new-logging-framework.patch +Patch0114: 0114-cluster-afr-set-pending-xattrs-for-replaced-brick.patch +Patch0115: 0115-common-ha-cluster-setup-issues-on-RHEL7.patch +Patch0116: 0116-NFS-Ganesha-Automatically-export-vol-that-was-export.patch +Patch0117: 0117-features-bitrot-tuanble-object-signing-waiting-time-.patch +Patch0118: 0118-features-bitrot-fix-fd-leak-in-truncate-stub.patch +Patch0119: 0119-tier-volume-set-Validate-volume-set-option-for-tier.patch +Patch0120: 0120-glusterd-tier-glusterd-crashed-with-detach-tier-comm.patch +Patch0121: 0121-glusterd-shared_storage-Added-help-description-for-e.patch +Patch0122: 0122-cluster-dht-Prevent-use-after-free-bug.patch +Patch0123: 0123-afr-complete-conservative-merge-even-in-case-of-gfid.patch +Patch0124: 0124-dht-Error-value-check-before-performing-rebalance-co.patch +Patch0125: 0125-common-ha-Fixing-add-node-operation.patch +Patch0126: 0126-quota-allow-writes-when-with-ENOENT-ESTALE-on-active.patch +Patch0127: 0127-tier-glusterd-Add-description-for-volume-set-options.patch +Patch0128: 0128-cluster-ec-Avoid-parallel-executions-of-the-same-sta.patch +Patch0129: 0129-nfs.c-nfs3.c-port-log-messages-to-a-new-framework.patch +Patch0130: 0130-features-quota-port-QUOTA-messages-to-new-logging-fr.patch +Patch0131: 0131-NFS-Ganesha-Implement-refresh-config.patch +Patch0132: 0132-glusterd-use-mkdir_p-for-creating-rundir.patch +Patch0133: 0133-glusterd-Store-peerinfo-after-updating-hostnames.patch +Patch0134: 0134-tools-glusterfind-Fail-glusterfind-creation-if-volum.patch +Patch0135: 0135-geo-rep-Fix-geo-rep-fanout-setup-with-meta-volume.patch +Patch0136: 0136-geo-rep-Fix-toggling-of-use_meta_volume-config.patch +Patch0137: 0137-geo-rep-Fix-glusterd-working-directory.patch +Patch0138: 0138-geo-rep-Fix-ssh-issue-in-geo-rep.patch +Patch0139: 0139-cluster-ec-wind-fops-on-good-subvols-for-access-read.patch +Patch0140: 0140-cluster-afr-Pick-gfid-from-poststat-during-fresh-loo.patch +Patch0141: 0141-protocol-client-removing-duplicate-printing-in-gf_ms.patch +Patch0142: 0142-EC-While-Healing-a-file-set-the-config-xattr.patch +Patch0143: 0143-libglusterfs-Introducing-new-logging-message.patch +Patch0144: 0144-core-add-gf_ref_t-for-common-refcounting-structures.patch +Patch0145: 0145-quota-marker-fix-mem-leak-in-marker.patch +Patch0146: 0146-cluster-afr-set-pending-xattrs-for-replaced-brick.patch +Patch0147: 0147-common-utils-libglusterfs-Porting-to-a-new-logging-f.patch +Patch0148: 0148-afr-Block-fops-when-file-is-in-split-brain.patch +Patch0149: 0149-quota-marker-accounting-goes-bad-with-rename-while-w.patch +Patch0150: 0150-dht-Adding-log-messages-to-the-new-logging-framework.patch +Patch0151: 0151-gfdb-libglusterfs-Porting-to-a-new-logging-framework.patch +Patch0152: 0152-changetimerecorder-Porting-to-new-logging-framework.patch +Patch0153: 0153-features-bitrot-log-scrub-frequency-throttle-values.patch +Patch0154: 0154-tests-bitrot-Scrub-state-change-tests.patch +Patch0155: 0155-common-ha-fix-delete-node.patch +Patch0156: 0156-features-bit-rot-check-for-both-inmemory-and-ondisk-.patch +Patch0157: 0157-bit-rot-New-logging-framework-for-bit-rot-log-messag.patch +Patch0158: 0158-features-bitrot-cleanup-v1.patch +Patch0159: 0159-features-bitrot-cleanup-v2.patch +Patch0160: 0160-features-bitrot-handle-scrub-states-via-state-machin.patch +Patch0161: 0161-geo-rep-Fix-add-user-in-mountbroker-user-management.patch +Patch0162: 0162-features-bitrot-convert-pending-gf_log-to-gf_msg.patch +Patch0163: 0163-geo-rep-ignore-ESTALE-as-ENOENT.patch +Patch0164: 0164-fd-inode-libglusterfs-porting-to-a-new-logging-frame.patch +Patch0165: 0165-call-stub-circ-buff-client_t-compat-dict-libglusterf.patch +Patch0166: 0166-graph-libglusterfs-porting-to-a-new-logging-framewor.patch +Patch0167: 0167-defaults-globals-iobuf-latency-logging-options-xlato.patch +Patch0168: 0168-event-parse-utils-quota-common-utils-rbthash-libglus.patch +Patch0169: 0169-cluster-afr-truncate-all-sinks-files.patch +Patch0170: 0170-features-changelog-Always-log-directory-rename-opera.patch +Patch0171: 0171-cluster-ec-Fix-incorrect-check-for-iatt-differences.patch +Patch0172: 0172-ec-Porting-messages-to-new-logging-framework.patch +Patch0173: 0173-glusterd-Porting-left-out-log-messages-to-new-framew.patch +Patch0174: 0174-ganesha-volinfo-is-not-persisted-after-modifying-opt.patch +Patch0175: 0175-common-utils-libglusterfs-removing-strerror-to-avoid.patch +Patch0176: 0176-NFS-Ganesha-Automatically-export-volume-after-volume.patch +Patch0177: 0177-storage-posix-Check-xdata-for-NULL-before-dict_get.patch +Patch0178: 0178-protocol-server-Include-a-check-to-validate-xprt-cli.patch +Patch0179: 0179-Upcall-Fix-an-issue-with-invalidating-parent-entries.patch +Patch0180: 0180-mem-pool-stack-store-syncop-timer-libglusterfs-Porti.patch +Patch0181: 0181-quota-Fix-statfs-values-in-EC-when-quota_deem_statfs.patch +Patch0182: 0182-Logging-Porting-the-performance-translator.patch +Patch0183: 0183-afr-Porting-messages-to-new-logging-framework.patch +Patch0184: 0184-features-performace-Updating-the-glfs-components.patch +Patch0185: 0185-features-bit-rot-stub-deny-access-to-bad-objects.patch +Patch0186: 0186-features-bit-rot-stub-do-not-allow-setxattr-and-remo.patch +Patch0187: 0187-tier-ctr-Ignore-creation-of-T-file-and-Ctr-Lookup-he.patch +Patch0188: 0188-glusterd-Correction-in-Error-message-for-disperse-vo.patch +Patch0189: 0189-gfapi-symlink-resolution-for-glfs_object.patch +Patch0190: 0190-feature-performace-Fix-broken-build.patch +Patch0191: 0191-rdma-removing-duplicate-printing-of-error-string-in-.patch +Patch0192: 0192-NFS-Ganesha-Exporting-volume-fails.patch +Patch0193: 0193-common-ha-Fix-var-lib-nfs-statd-state-path-creation.patch +Patch0194: 0194-cluster-ec-Add-throttling-in-background-healing.patch +Patch0195: 0195-cluster-ec-Remove-dead-code.patch +Patch0196: 0196-protocol-server-Correctly-reconfigure-auth.ssl-allow.patch +Patch0197: 0197-cluster-dht-use-refcount-to-manage-memory-used-to-st.patch +Patch0198: 0198-protocol-server-fail-setvolume-if-any-of-xlators-is-.patch +Patch0199: 0199-NFS-Ganesha-Unexport-fails-after-S31ganesha-start-sc.patch +Patch0200: 0200-cluster-ec-Make-background-healing-optional-behavior.patch +Patch0201: 0201-access-control-validating-context-of-access-control-.patch +Patch0202: 0202-tools-glusterfind-RENAME-and-MODIFY-issues.patch +Patch0203: 0203-cluster-afr-expunge-first-impunge-next-in-entry-self.patch +Patch0204: 0204-glusterd-shared_storage-Use-var-lib-glusterd-ss_bric.patch +Patch0205: 0205-cluster-ec-Don-t-read-from-bad-subvols.patch +Patch0206: 0206-cluster-ec-Remove-failed-subvols-from-source-sink-co.patch +Patch0207: 0207-protocol-server-Add-null-check-to-gf_client_put.patch +Patch0208: 0208-quota-fix-mem-leak-in-quota-enforcer.patch +Patch0209: 0209-posix-fix-mem-leak-in-posix_get_ancestry-error-path.patch +Patch0210: 0210-quota-marker-fix-mem-leak-in-marker.patch +Patch0211: 0211-glusterd-Removing-sync-lock-and-unlock-inside-rcu-re.patch +Patch0212: 0212-cluster-ec-Fix-use-after-free-bug.patch +Patch0213: 0213-glusterd-geo-rep-Fix-failure-of-geo-rep-pause.patch +Patch0214: 0214-glusterd-Get-the-local-txn_info-based-on-trans_id-in.patch +Patch0215: 0215-snapshot-scheduler-Use-var-run-gluster-shared_storag.patch +Patch0216: 0216-glusterd-correct-replace-brick-flow.patch +Patch0217: 0217-glusterd-snapd-Stop-snapd-daemon-when-glusterd-is-re.patch +Patch0218: 0218-quotad-create-sock-listener-only-after-graph-init-is.patch +Patch0219: 0219-common-ha-ganesha-ha.sh-status-tries-to-read-ganesha.patch +Patch0220: 0220-quota-marker-fix-mem-leak-in-marker.patch +Patch0221: 0221-quota-marker-use-smaller-stacksize-in-synctask-for-m.patch +Patch0222: 0222-quota-marker-set-lk_owner-when-taking-lock-on-parent.patch +Patch0223: 0223-quota-marker-fix-spurious-failure-afr-quota-xattr-md.patch +Patch0224: 0224-gfapi-Update-loc-inode-accordingly-in-glfs_loc_link.patch +Patch0225: 0225-glusterd-Fix-management-encryption-issues-with-Glust.patch +Patch0226: 0226-NFS-Ganesha-Export-fails-on-RHEL-7.1.patch +Patch0227: 0227-libgfdb-sql-Fixing-broken-query-of-find_unchanged.patch +Patch0228: 0228-glusterd-use-a-real-host-name-instead-of-numeric-whe.patch +Patch0229: 0229-glusterd-Send-friend-update-even-for-EVENT_RCVD_ACC.patch +Patch0230: 0230-logging-Fixed-incorrect-buffer-size.patch +Patch0231: 0231-quota-marker-inspect-file-dir-invoked-without-having.patch +Patch0232: 0232-NFS-Ganesha-Add-node-does-not-copy-exports-directory.patch +Patch0233: 0233-access_control-avoid-double-unrefing-of-acl-variable.patch +Patch0234: 0234-features-posix-Avoid-double-free-of-a-variable-in-po.patch +Patch0235: 0235-cluster-ec-Propogate-correct-errno-in-case-of-failur.patch +Patch0236: 0236-cluster-ec-Prevent-data-corruptions.patch +Patch0237: 0237-rpc-transport-socket_poller-fixes-for-proper-working.patch +Patch0238: 0238-glusterd-Fix-failure-in-replace-brick-when-src-brick.patch +Patch0239: 0239-quota-marker-fix-mem-leak-in-marker.patch +Patch0240: 0240-features-bitrot-move-inode-state-just-at-the-last-mo.patch +Patch0241: 0241-features-bitrot-throttle-signer.patch +Patch0242: 0242-extras-hooks-Fix-parsing-of-args-in-S30samba-set.sh.patch +Patch0243: 0243-timer-fix-race-between-gf_timer_call_cancel-and-gf_t.patch +Patch0244: 0244-cluster-ec-Handle-race-between-unlock-timer-new-lock.patch +Patch0245: 0245-Revert-timer-fix-race-between-gf_timer_call_cancel-a.patch +Patch0246: 0246-glusterd-Porting-the-left-out-gf_log_callingfns-to-n.patch +Patch0247: 0247-glusterd-Pass-NULL-in-glusterd_svc_manager-in-gluste.patch +Patch0248: 0248-glusterd-Do-not-log-failure-if-glusterd_get_txn_opin.patch +Patch0249: 0249-cluster-afr-Fix-incorrect-logging-in-read-transactio.patch +Patch0250: 0250-heal-Do-not-invoke-glfs_fini-for-glfs-heal-commands.patch +Patch0251: 0251-dht-send-lookup-even-for-fd-based-operations-during-.patch +Patch0252: 0252-geo-rep-Fix-fd-referenced-before-assignment.patch +Patch0253: 0253-geo-rep-Fix-history-failure.patch +Patch0254: 0254-geo-rep-Do-not-crash-worker-on-ESTALE.patch +Patch0255: 0255-glusterd-getting-txn_id-from-frame-cookie-in-op_sm-c.patch +Patch0256: 0256-client-rpc-make-ping-timeout-configurable-for-gluste.patch +Patch0257: 0257-quota-marker-contribution-with-list_del-can-cause-me.patch +Patch0258: 0258-quota-Fix-crash-in-quota-enforcer.patch +Patch0259: 0259-quota-don-t-log-error-when-disk-quota-exceeded.patch +Patch0260: 0260-posix-posix_make_ancestryfromgfid-shouldn-t-log-ENOE.patch +Patch0261: 0261-quota-validating-soft-limit-percentage.patch +Patch0262: 0262-quota-marker-set-log-level-to-debug-for-ESTALE-ENOEN.patch +Patch0263: 0263-quota-fix-parents-caching-during-build-ancestry.patch +Patch0264: 0264-posix-fix-mem-leak-in-posix-xattrop.patch +Patch0265: 0265-rpc-server-glusterd-Init-transport-list-for-accepted.patch +Patch0266: 0266-uss-Take-ref-on-root-inode.patch +Patch0267: 0267-glusterd-initialize-the-daemon-services-on-demand.patch +Patch0268: 0268-glusterd-Stop-restart-notify-to-daemons-svcs-during-.patch +Patch0269: 0269-snapview-client-Allocate-memory-using-GF_CALLOC.patch +Patch0270: 0270-rpc-add-owner-xlator-argument-to-rpc_clnt_new.patch +Patch0271: 0271-rebalance-glusterd-Refactor-rebalance-volfile.patch +Patch0272: 0272-glusterd-log-improvement-in-glusterd_peer_rpc_notify.patch +Patch0273: 0273-glusterd-rebalance-trusted-rebalance-volfile.patch +Patch0274: 0274-quota-checking-for-absolute-path-in-quota-command.patch +Patch0275: 0275-quota-volume-reset-shouldn-t-remove-quota-deem-statf.patch +Patch0276: 0276-libglusterfs-write-error-handling-when-filesystem-ha.patch +Patch0277: 0277-xml-output-Fix-non-uniform-opErrstr-xml-output.patch +Patch0278: 0278-Set-nfs.disable-to-on-when-global-NFS-Ganesha-key-is.patch +Patch0279: 0279-logging-Stop-using-global-xlator-for-log_buf-allocat.patch +Patch0280: 0280-quota-marker-fix-inode-quota-with-rename.patch +Patch0281: 0281-bitrot-glusterd-gluster-volume-set-command-for-bitro.patch +Patch0282: 0282-features-bit-rot-stub-handle-REOPEN_WAIT-on-forgotte.patch +Patch0283: 0283-features-bit-rot-stub-fail-the-fop-if-inode-context-.patch +Patch0284: 0284-bitrot-Scrubber-log-should-mark-bad-file-as-a-ALERT-.patch +Patch0285: 0285-protocol-server-use-different-dict-for-resolving.patch +Patch0286: 0286-tests-set-inode-lru-limit-to-1-and-check-if-bit-rot-.patch +Patch0287: 0287-protocol-server-forget-the-inodes-which-got-ENOENT-i.patch +Patch0288: 0288-afr-launch-index-heal-on-local-subvols-up-on-a-child.patch +Patch0289: 0289-snapshot-scheduler-Output-correction-of-initialisati.patch +Patch0290: 0290-snapshot-Log-deletion-of-snapshot-during-auto-delete.patch +Patch0291: 0291-snapshot-scheduler-Check-if-volume-exists-before-add.patch +Patch0292: 0292-dht-block-handle-create-op-falling-to-decommissioned.patch +Patch0293: 0293-cluster-dht-avoid-mknod-on-decommissioned-brick.patch +Patch0294: 0294-afr-modify-afr_txn_nothing_failed.patch +Patch0295: 0295-heal-Add-check-for-healing-directories-in-split-brai.patch +Patch0296: 0296-cluster-afr-Examine-data-metadata-readable-for-read-.patch +Patch0297: 0297-common-ha-concise-output-for-HA-status.patch +Patch0298: 0298-snapshot-Make-fops-static-for-correct-resolution-of-.patch +Patch0299: 0299-glusterd-stop-all-the-daemons-services-on-peer-detac.patch +Patch0300: 0300-glusterd-Don-t-allow-remove-brick-start-commit-if-gl.patch +Patch0301: 0301-libgfapi-Gracefully-exit-when-glfd-is-invalid.patch +Patch0302: 0302-snapshot-cleanup-snaps-during-unprobe.patch +Patch0303: 0303-libgfapi-adding-follow-flag-to-glfs_h_lookupat.patch +Patch0304: 0304-libgfapi-non-default-symbol-version-macros-are-incor.patch +Patch0305: 0305-tools-glusterfind-Do-not-show-session-corrupted-if-n.patch +Patch0306: 0306-tools-glusterfind-Prepend-prefix-in-case-of-delete.patch +Patch0307: 0307-tools-glusterfind-password-prompts-for-peer-nodes-on.patch +Patch0308: 0308-marker-fix-log-when-loc.parent-and-inode-gfid-is-NUL.patch +Patch0309: 0309-posix-xattrop-GF_XATTROP_GET_AND_SET-implementation.patch +Patch0310: 0310-cli-on-error-invoke-cli_cmd_broadcast_response-funct.patch +Patch0311: 0311-dht-lock-on-subvols-to-prevent-lookup-vs-rmdir-race.patch +Patch0312: 0312-glusterd-use-2-epoll-worker-threads-by-default.patch +Patch0313: 0313-glusterd-Re-enable-ping-timer-between-glusterds.patch +Patch0314: 0314-event-epoll-Use-pollers-to-check-if-event_pool_dispa.patch +Patch0315: 0315-ec-trusted.ec.version-xattr-of-all-root-directories-.patch +Patch0316: 0316-gluster-cli-snapshot-delete-all-does-not-work-with-x.patch +Patch0317: 0317-marker-preserve-previous-dirty-flag-during-update-tx.patch +Patch0318: 0318-cluster-ec-Fix-write-size-in-self-heal.patch +Patch0319: 0319-cluster-dht-Don-t-set-posix-acls-on-linkto-files.patch +Patch0320: 0320-dht-lock-on-all-subvols-to-prevent-rmdir-vs-lookup-s.patch +Patch0321: 0321-CommonHA-Fix-the-path-of-systemctl-cmd.patch +Patch0322: 0322-uss-handle-buf-variable-properly-in-svs_glfs_readdir.patch +Patch0323: 0323-features-snap-cleanup-the-root-loc-in-statfs.patch +Patch0324: 0324-dht-NULL-dereferencing-causes-crash.patch +Patch0325: 0325-dht-remove-brick-Avoid-data-loss-for-hard-link-migra.patch +Patch0326: 0326-firewall-spec-Create-glusterfs-firewall-service-if-f.patch +Patch0327: 0327-glusterd-disable-ping-timer-b-w-glusterd-and-make-ep.patch +Patch0328: 0328-dht-cluster-Avoid-crash-if-local-is-NULL.patch +Patch0329: 0329-afr-get-split-brain-status-in-a-synctask.patch +Patch0330: 0330-afr-perform-replace-brick-in-a-synctask.patch +Patch0331: 0331-dht-cluster-Avoid-double-unlock-in-dht_refresh_layou.patch + %description -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -238,18 +600,19 @@ called Translators from GNU Hurd kernel. Much of the code in GlusterFS is in user space and easily manageable. This package includes the glusterfs binary, the glusterfsd daemon and the -gluster command line, libglusterfs and glusterfs translator modules common to -both GlusterFS server and client framework. +libglusterfs and glusterfs translator modules common to both GlusterFS server +and client framework. %package api -Summary: Clustered file-system api library +Summary: GlusterFS api library Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} +Requires: %{name}-client-xlators = %{version}-%{release} # we provide the Python package/namespace 'gluster' -Provides: python-gluster = %{version}-%{release} +#Provides: python-gluster = %{version}-%{release} %description api -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -264,9 +627,10 @@ Summary: Development Libraries Group: Development/Libraries Requires: %{name} = %{version}-%{release} Requires: %{name}-devel = %{version}-%{release} +Requires: libacl-devel %description api-devel -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -282,7 +646,7 @@ Group: Applications/File Requires: %{name}-libs = %{version}-%{release} %description cli -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -302,7 +666,7 @@ Requires: %{name}-extra-xlators = %{version}-%{release} %endif %description devel -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -316,12 +680,13 @@ This package provides the development libraries and include files. %package extra-xlators Summary: Extra Gluster filesystem Translators Group: Applications/File -# We need -api rpm for its __init__.py in Python site-packages area -Requires: %{name}-api = %{version}-%{release} +# We need python-gluster rpm for gluster module's __init__.py in Python +# site-packages area +Requires: python-gluster = %{version}-%{release} Requires: python python-ctypes %description extra-xlators -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -337,14 +702,16 @@ for GlusterFS. Summary: Fuse client Group: Applications/File BuildRequires: fuse-devel +Requires: attr Requires: %{name} = %{version}-%{release} +Requires: %{name}-client-xlators = %{version}-%{release} Obsoletes: %{name}-client < %{version}-%{release} Provides: %{name}-client = %{version}-%{release} %description fuse -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -352,7 +719,30 @@ terms of features and extensibility. It borrows a powerful concept called Translators from GNU Hurd kernel. Much of the code in GlusterFS is in user space and easily manageable. -This package provides support to FUSE based clients. +This package provides support to FUSE based clients and inlcudes the +glusterfs(d) binary. + +%if ( 0%{?_build_server} ) +%package ganesha +Summary: NFS-Ganesha configuration +Group: Applications/File + +Requires: %{name}-server = %{version}-%{release} +Requires: nfs-ganesha-gluster +Requires: pcs + +%description ganesha +GlusterFS is a distributed file-system capable of scaling to several +petabytes. It aggregates various storage bricks over Infiniband RDMA +or TCP/IP interconnect into one large parallel network file +system. GlusterFS is one of the most sophisticated file systems in +terms of features and extensibility. It borrows a powerful concept +called Translators from GNU Hurd kernel. Much of the code in GlusterFS +is in user space and easily manageable. + +This package provides the configuration and related files for using +NFS-Ganesha as the NFS server using GlusterFS +%endif %if ( 0%{?_build_server} ) %if ( 0%{!?_without_georeplication:1} ) @@ -362,9 +752,10 @@ Group: Applications/File Requires: %{name} = %{version}-%{release} Requires: %{name}-server = %{version}-%{release} Requires: python python-ctypes +Requires: rsync %description geo-replication -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several peta-bytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file system in @@ -389,7 +780,7 @@ Requires: rsyslog-mmcount %endif %description libs -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -399,16 +790,34 @@ is in user space and easily manageable. This package provides the base GlusterFS libraries +%package -n python-gluster +Summary: GlusterFS python library +Group: Development/Tools +Requires: python + +%description -n python-gluster +GlusterFS is a distributed file-system capable of scaling to several +petabytes. It aggregates various storage bricks over Infiniband RDMA +or TCP/IP interconnect into one large parallel network file +system. GlusterFS is one of the most sophisticated file systems in +terms of features and extensibility. It borrows a powerful concept +called Translators from GNU Hurd kernel. Much of the code in GlusterFS +is in user space and easily manageable. + +This package contains the python modules of GlusterFS and own gluster +namespace. + + %if ( 0%{!?_without_rdma:1} ) %package rdma Summary: GlusterFS rdma support for ib-verbs Group: Applications/File BuildRequires: libibverbs-devel -BuildRequires: librdmacm-devel +BuildRequires: librdmacm-devel >= 1.0.15 Requires: %{name} = %{version}-%{release} %description rdma -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -427,14 +836,19 @@ Group: Development/Tools Requires: %{name} = %{version}-%{release} Requires: %{name}-fuse = %{version}-%{release} Requires: %{name}-server = %{version}-%{release} -Requires: perl(App::Prove) perl(Test::Harness) gcc util-linux-ng lvm2 -Requires: python attr dbench git nfs-utils xfsprogs +## thin provisioning support +Requires: lvm2 >= 2.02.89 +Requires: perl(App::Prove) perl(Test::Harness) gcc util-linux-ng +Requires: python attr dbench file git libacl-devel net-tools +Requires: nfs-utils xfsprogs yajl %description regression-tests The Gluster Test Framework, is a suite of scripts used for regression testing of Gluster. %endif +%endif +%if ( 0%{?_build_server} ) %if ( 0%{!?_without_ocf:1} ) %package resource-agents Summary: OCF Resource Agents for GlusterFS @@ -450,12 +864,12 @@ Group: System Environment/Base Group: Productivity/Clustering/HA %endif # for glusterd -Requires: glusterfs-server +Requires: %{name}-server # depending on the distribution, we need pacemaker or resource-agents Requires: %{_prefix}/lib/ocf/resource.d %description resource-agents -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -467,14 +881,34 @@ This package provides the resource agents which plug glusterd into Open Cluster Framework (OCF) compliant cluster resource managers, like Pacemaker. %endif +%endif +%if ( 0%{?_build_server} ) %package server Summary: Clustered file-system server Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} -Requires: %{name}-cli = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} +Requires: %{name}-cli = %{version}-%{release} +# some daemons (like quota) use a fuse-mount, glusterfsd is part of -fuse Requires: %{name}-fuse = %{version}-%{release} +# self-heal daemon, rebalance, nfs-server etc. are actually clients +Requires: %{name}-client-xlators = %{version}-%{release} +# psmisc for killall, lvm2 for snapshot, and nfs-utils and +# rpcbind/portmap for gnfs server +Requires: psmisc +Requires: lvm2 +Requires: nfs-utils +%if ( 0%{?_with_systemd:1} ) +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units +%else +Requires(post): /sbin/chkconfig +Requires(preun): /sbin/service +Requires(preun): /sbin/chkconfig +Requires(postun): /sbin/service +%endif %if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 6 ) Requires: rpcbind %else @@ -483,9 +917,13 @@ Requires: portmap %if ( 0%{?rhel} && 0%{?rhel} < 6 ) Obsoletes: %{name}-geo-replication = %{version}-%{release} %endif +%if ( 0%{?rhel} && 0%{?rhel} <= 6 ) +Requires: python-argparse +%endif +Requires: pyxattr %description server -GlusterFS is a clustered file-system capable of scaling to several +GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. GlusterFS is one of the most sophisticated file systems in @@ -496,21 +934,389 @@ is in user space and easily manageable. This package provides the glusterfs server daemon. %endif +%package client-xlators +Summary: GlusterFS client-side translators +Group: Applications/File + +%description client-xlators +GlusterFS is a distributed file-system capable of scaling to several +petabytes. It aggregates various storage bricks over Infiniband RDMA +or TCP/IP interconnect into one large parallel network file +system. GlusterFS is one of the most sophisticated file systems in +terms of features and extensibility. It borrows a powerful concept +called Translators from GNU Hurd kernel. Much of the code in GlusterFS +is in user space and easily manageable. + +This package provides the translators needed on any GlusterFS client. + %prep %setup -q -n %{name}-%{version}%{?prereltag} +# %patch0001 -p1 +%patch0002 -p1 +%patch0003 -p1 +%patch0004 -p1 +%patch0005 -p1 +%patch0006 -p1 +%patch0007 -p1 +%patch0008 -p1 +%patch0009 -p1 +%patch0010 -p1 +%patch0011 -p1 +%patch0012 -p1 +%patch0013 -p1 +%patch0014 -p1 +%patch0015 -p1 +%patch0016 -p1 +%patch0017 -p1 +%patch0018 -p1 +%patch0019 -p1 +%patch0020 -p1 +%patch0021 -p1 +%patch0022 -p1 +%patch0023 -p1 +%patch0024 -p1 +%patch0025 -p1 +%patch0026 -p1 +%patch0027 -p1 +%patch0028 -p1 +%patch0029 -p1 +%patch0030 -p1 +%patch0031 -p1 +%patch0032 -p1 +%patch0033 -p1 +%patch0034 -p1 +%patch0035 -p1 +%patch0036 -p1 +%patch0037 -p1 +%patch0038 -p1 +%patch0039 -p1 +%patch0040 -p1 +%patch0041 -p1 +%patch0042 -p1 +%patch0043 -p1 +%patch0044 -p1 +%patch0045 -p1 +%patch0046 -p1 +%patch0047 -p1 +%patch0048 -p1 +%patch0049 -p1 +%patch0050 -p1 +%patch0051 -p1 +%patch0052 -p1 +%patch0053 -p1 +%patch0054 -p1 +%patch0055 -p1 +%patch0056 -p1 +%patch0057 -p1 +%patch0058 -p1 +%patch0059 -p1 +%patch0060 -p1 +%patch0061 -p1 +%patch0062 -p1 +%patch0063 -p1 +%patch0064 -p1 +%patch0065 -p1 +%patch0066 -p1 +%patch0067 -p1 +%patch0068 -p1 +%patch0069 -p1 +%patch0070 -p1 +%patch0071 -p1 +%patch0072 -p1 +%patch0073 -p1 +%patch0074 -p1 +%patch0075 -p1 +%patch0076 -p1 +%patch0077 -p1 +%patch0078 -p1 +%patch0079 -p1 +%patch0080 -p1 +%patch0081 -p1 +%patch0082 -p1 +%patch0083 -p1 +%patch0084 -p1 +%patch0085 -p1 +%patch0086 -p1 +%patch0087 -p1 +%patch0088 -p1 +%patch0089 -p1 +%patch0090 -p1 +%patch0091 -p1 +%patch0092 -p1 +%patch0093 -p1 +%patch0094 -p1 +%patch0095 -p1 +%patch0096 -p1 +%patch0097 -p1 +%patch0098 -p1 +%patch0099 -p1 +%patch0100 -p1 +%patch0101 -p1 +%patch0102 -p1 +%patch0103 -p1 +%patch0104 -p1 +%patch0105 -p1 +%patch0106 -p1 +%patch0107 -p1 +%patch0108 -p1 +%patch0109 -p1 +%patch0110 -p1 +%patch0111 -p1 +%patch0112 -p1 +%patch0113 -p1 +%patch0114 -p1 +%patch0115 -p1 +%patch0116 -p1 +%patch0117 -p1 +%patch0118 -p1 +%patch0119 -p1 +%patch0120 -p1 +%patch0121 -p1 +%patch0122 -p1 +%patch0123 -p1 +%patch0124 -p1 +%patch0125 -p1 +%patch0126 -p1 +%patch0127 -p1 +%patch0128 -p1 +%patch0129 -p1 +%patch0130 -p1 +%patch0131 -p1 +%patch0132 -p1 +%patch0133 -p1 +%patch0134 -p1 +%patch0135 -p1 +%patch0136 -p1 +%patch0137 -p1 +%patch0138 -p1 +%patch0139 -p1 +%patch0140 -p1 +%patch0141 -p1 +%patch0142 -p1 +%patch0143 -p1 +%patch0144 -p1 +%patch0145 -p1 +%patch0146 -p1 +%patch0147 -p1 +%patch0148 -p1 +%patch0149 -p1 +%patch0150 -p1 +%patch0151 -p1 +%patch0152 -p1 +%patch0153 -p1 +%patch0154 -p1 +%patch0155 -p1 +%patch0156 -p1 +%patch0157 -p1 +%patch0158 -p1 +%patch0159 -p1 +%patch0160 -p1 +%patch0161 -p1 +%patch0162 -p1 +%patch0163 -p1 +%patch0164 -p1 +%patch0165 -p1 +%patch0166 -p1 +%patch0167 -p1 +%patch0168 -p1 +%patch0169 -p1 +%patch0170 -p1 +%patch0171 -p1 +%patch0172 -p1 +%patch0173 -p1 +%patch0174 -p1 +%patch0175 -p1 +%patch0176 -p1 +%patch0177 -p1 +%patch0178 -p1 +%patch0179 -p1 +%patch0180 -p1 +%patch0181 -p1 +%patch0182 -p1 +%patch0183 -p1 +%patch0184 -p1 +%patch0185 -p1 +%patch0186 -p1 +%patch0187 -p1 +%patch0188 -p1 +%patch0189 -p1 +%patch0190 -p1 +%patch0191 -p1 +%patch0192 -p1 +%patch0193 -p1 +%patch0194 -p1 +%patch0195 -p1 +%patch0196 -p1 +%patch0197 -p1 +%patch0198 -p1 +%patch0199 -p1 +%patch0200 -p1 +%patch0201 -p1 +%patch0202 -p1 +%patch0203 -p1 +%patch0204 -p1 +%patch0205 -p1 +%patch0206 -p1 +%patch0207 -p1 +%patch0208 -p1 +%patch0209 -p1 +%patch0210 -p1 +%patch0211 -p1 +%patch0212 -p1 +%patch0213 -p1 +%patch0214 -p1 +%patch0215 -p1 +%patch0216 -p1 +%patch0217 -p1 +%patch0218 -p1 +%patch0219 -p1 +%patch0220 -p1 +%patch0221 -p1 +%patch0222 -p1 +%patch0223 -p1 +%patch0224 -p1 +%patch0225 -p1 +%patch0226 -p1 +%patch0227 -p1 +%patch0228 -p1 +%patch0229 -p1 +%patch0230 -p1 +%patch0231 -p1 +%patch0232 -p1 +%patch0233 -p1 +%patch0234 -p1 +%patch0235 -p1 +%patch0236 -p1 +%patch0237 -p1 +%patch0238 -p1 +%patch0239 -p1 +%patch0240 -p1 +%patch0241 -p1 +%patch0242 -p1 +%patch0243 -p1 +%patch0244 -p1 +%patch0245 -p1 +%patch0246 -p1 +%patch0247 -p1 +%patch0248 -p1 +%patch0249 -p1 +%patch0250 -p1 +%patch0251 -p1 +%patch0252 -p1 +%patch0253 -p1 +%patch0254 -p1 +%patch0255 -p1 +%patch0256 -p1 +%patch0257 -p1 +%patch0258 -p1 +%patch0259 -p1 +%patch0260 -p1 +%patch0261 -p1 +%patch0262 -p1 +%patch0263 -p1 +%patch0264 -p1 +%patch0265 -p1 +%patch0266 -p1 +%patch0267 -p1 +%patch0268 -p1 +%patch0269 -p1 +%patch0270 -p1 +%patch0271 -p1 +%patch0272 -p1 +%patch0273 -p1 +%patch0274 -p1 +%patch0275 -p1 +%patch0276 -p1 +%patch0277 -p1 +%patch0278 -p1 +%patch0279 -p1 +%patch0280 -p1 +%patch0281 -p1 +%patch0282 -p1 +%patch0283 -p1 +%patch0284 -p1 +%patch0285 -p1 +%patch0286 -p1 +%patch0287 -p1 +%patch0288 -p1 +%patch0289 -p1 +%patch0290 -p1 +%patch0291 -p1 +%patch0292 -p1 +%patch0293 -p1 +%patch0294 -p1 +%patch0295 -p1 +%patch0296 -p1 +%patch0297 -p1 +%patch0298 -p1 +%patch0299 -p1 +%patch0300 -p1 +%patch0301 -p1 +%patch0302 -p1 +%patch0303 -p1 +%patch0304 -p1 +%patch0305 -p1 +%patch0306 -p1 +%patch0307 -p1 +%patch0308 -p1 +%patch0309 -p1 +%patch0310 -p1 +%patch0311 -p1 +%patch0312 -p1 +%patch0313 -p1 +%patch0314 -p1 +%patch0315 -p1 +%patch0316 -p1 +%patch0317 -p1 +%patch0318 -p1 +%patch0319 -p1 +%patch0320 -p1 +%patch0321 -p1 +%patch0322 -p1 +%patch0323 -p1 +%patch0324 -p1 +%patch0325 -p1 +%patch0326 -p1 +%patch0327 -p1 +%patch0328 -p1 +%patch0329 -p1 +%patch0330 -p1 +%patch0331 -p1 %build -./autogen.sh -%configure \ - %{?_without_rdma} \ +# In RHEL7 few hardening flags are available by default, however the RELRO +# default behaviour is partial, convert to full +%if ( 0%{?rhel} && 0%{?rhel} >= 7 ) +LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now" +export LDFLAGS +%else +%if ( 0%{?rhel} && 0%{?rhel} == 6 ) +CFLAGS="$RPM_OPT_FLAGS -fPIE -DPIE" +LDFLAGS="$RPM_LD_FLAGS -pie -Wl,-z,relro,-z,now" +%else +#It appears that with gcc-4.1.2 in RHEL5 there is an issue using both -fPIC and + # -fPIE that makes -z relro not work; -fPIE seems to undo what -fPIC does +CFLAGS="$RPM_OPT_FLAGS" +LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now" +%endif +export CFLAGS +export LDFLAGS +%endif + +./autogen.sh && %configure \ + %{?_with_cmocka} \ + %{?_with_tmpfilesdir} \ + %{?_without_bd} \ %{?_without_epoll} \ %{?_without_fusermount} \ %{?_without_georeplication} \ + %{?_with_firewalld} \ %{?_without_ocf} \ - %{?_without_syslog} \ - %{?_without_bd} \ %{?_without_qemu_block} \ - %{?_without_systemtap} + %{?_without_rdma} \ + %{?_without_syslog} \ + %{?_without_systemtap} \ + %{?_without_tiering} # fix hardening and remove rpath in shlibs %if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) @@ -526,10 +1332,8 @@ pushd xlators/features/glupy/src FLAGS="$RPM_OPT_FLAGS" python setup.py build popd -# Build the Python libgfapi examples -pushd api/examples -FLAGS="$RPM_OPT_FLAGS" python setup.py build -popd +%check +make check %install rm -rf %{buildroot} @@ -538,10 +1342,6 @@ make install DESTDIR=%{buildroot} pushd xlators/features/glupy/src python setup.py install --skip-build --verbose --root %{buildroot} popd -# install the gfapi Python library in /usr/lib/python*/site-packages -pushd api/examples -python setup.py install --skip-build --verbose --root %{buildroot} -popd # Install include directory mkdir -p %{buildroot}%{_includedir}/glusterfs install -p -m 0644 libglusterfs/src/*.h \ @@ -557,7 +1357,6 @@ install -p -m 0644 rpc/xdr/src/*.h \ mkdir -p %{buildroot}%{_includedir}/glusterfs/server install -p -m 0644 xlators/protocol/server/src/*.h \ %{buildroot}%{_includedir}/glusterfs/server/ -%if ( 0%{?_build_server} ) %if ( 0%{_for_fedora_koji_builds} ) install -D -p -m 0644 %{SOURCE1} \ %{buildroot}%{_sysconfdir}/sysconfig/glusterd @@ -567,7 +1366,6 @@ install -D -p -m 0644 %{SOURCE2} \ install -D -p -m 0644 extras/glusterd-sysconfig \ %{buildroot}%{_sysconfdir}/sysconfig/glusterd %endif -%endif %if ( 0%{_for_fedora_koji_builds} ) %if ( 0%{?rhel} && 0%{?rhel} <= 5 ) @@ -580,6 +1378,8 @@ mkdir -p %{buildroot}%{_localstatedir}/log/glusterd mkdir -p %{buildroot}%{_localstatedir}/log/glusterfs mkdir -p %{buildroot}%{_localstatedir}/log/glusterfsd mkdir -p %{buildroot}%{_localstatedir}/run/gluster +touch %{buildroot}%{python_sitelib}/gluster/__init__.py + # Remove unwanted files from all the shared libraries find %{buildroot}%{_libdir} -name '*.a' -delete @@ -614,7 +1414,6 @@ rm -f %{buildroot}%{_defaultdocdir}/%{name}/glusterfs-mode.el rm -f %{buildroot}%{_defaultdocdir}/%{name}/glusterfs.vim %endif -%if ( 0%{?_build_server} ) # Create working directory mkdir -p %{buildroot}%{_sharedstatedir}/glusterd @@ -626,34 +1425,16 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha %if ( 0%{_for_fedora_koji_builds} ) %_init_install %{glusterfsd_service} glusterfsd %endif -%endif - -%if ( 0%{_for_fedora_koji_builds} ) -# Client logrotate entry -install -D -p -m 0644 %{SOURCE3} \ - %{buildroot}%{_sysconfdir}/logrotate.d/glusterfs-fuse -# Server logrotate entry -%if ( 0%{?_build_server} ) -install -D -p -m 0644 %{SOURCE4} \ - %{buildroot}%{_sysconfdir}/logrotate.d/glusterd -# Legacy server logrotate entry -install -D -p -m 0644 %{SOURCE5} \ - %{buildroot}%{_sysconfdir}/logrotate.d/glusterfsd -%endif -%else install -D -p -m 0644 extras/glusterfs-logrotate \ %{buildroot}%{_sysconfdir}/logrotate.d/glusterfs -%endif -%if ( 0%{?_build_server} ) %if ( 0%{!?_without_georeplication:1} ) mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/geo-replication touch %{buildroot}%{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf install -D -p -m 0644 extras/glusterfs-georep-logrotate \ %{buildroot}%{_sysconfdir}/logrotate.d/glusterfs-georep %endif -%endif %if ( 0%{!?_without_syslog:1} ) %if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) @@ -672,7 +1453,8 @@ install -D -p -m 0644 extras/logger.conf.example \ %endif %endif -%if ( 0%{?_build_server} ) +touch %{buildroot}%{_sharedstatedir}/glusterd/glusterd.info +touch %{buildroot}%{_sharedstatedir}/glusterd/options subdirs=("add-brick" "create" "copy-file" "delete" "gsync-create" "remove-brick" "reset" "set" "start" "stop") for dir in ${subdirs[@]} do @@ -682,15 +1464,9 @@ mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/glustershd mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/peers mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/vols mkdir -p %{buildroot}%{_sharedstatedir}/glusterd/nfs/run -touch %{buildroot}%{_sharedstatedir}/glusterd/glusterd.info -touch %{buildroot}%{_sharedstatedir}/glusterd/options touch %{buildroot}%{_sharedstatedir}/glusterd/nfs/nfs-server.vol touch %{buildroot}%{_sharedstatedir}/glusterd/nfs/run/nfs.pid -%if ( 0%{!?_without_georeplication:1} ) -install -p -m 0744 extras/hook-scripts/S56glusterd-geo-rep-create-post.sh \ - %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create/post -%endif %{__install} -p -m 0744 extras/hook-scripts/start/post/*.sh \ %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/start/post %{__install} -p -m 0744 extras/hook-scripts/stop/pre/*.sh \ @@ -706,7 +1482,11 @@ install -p -m 0744 extras/hook-scripts/S56glusterd-geo-rep-create-post.sh \ find ./tests ./run-tests.sh -type f | cpio -pd %{buildroot}%{_prefix}/share/glusterfs -%endif + +## Install bash completion for cli +install -p -m 0744 -D extras/command-completion/gluster.bash \ + %{buildroot}%{_sysconfdir}/bash_completion.d/gluster + %clean rm -rf %{buildroot} @@ -724,6 +1504,11 @@ rm -rf %{buildroot} %post api /sbin/ldconfig +%post fuse +%if ( 0%{?rhel} == 5 ) +modprobe fuse +%endif + %if ( 0%{?_build_server} ) %if ( 0%{!?_without_georeplication:1} ) %post geo-replication @@ -741,7 +1526,18 @@ fi %post server # Legacy server %_init_enable glusterd +# fix bz#1110715 +if [ -f %_init_glusterfsd ]; then %_init_enable glusterfsd +fi +# ".cmd_log_history" is renamed to "cmd_history.log" in GlusterFS-3.7 . +# While upgrading glusterfs-server package form GlusterFS version <= 3.6 to +# GlusterFS version 3.7, ".cmd_log_history" should be renamed to +# "cmd_history.log" to retain cli command history contents. +if [ -f %{_localstatedir}/log/glusterfs/.cmd_log_history ]; then + mv %{_localstatedir}/log/glusterfs/.cmd_log_history \ + %{_localstatedir}/log/glusterfs/cmd_history.log +fi # Genuine Fedora (and EPEL) builds never put gluster files in /etc; if # there are any files in /etc from a prior gluster.org install, move them @@ -765,7 +1561,6 @@ if [ -d %{_sharedstatedir}/glusterd/vols ]; then done fi -cp %{_sysconfdir}/glusterfs/group-small-file-perf.example /var/lib/glusterd/groups/small-file-perf # add marker translator # but first make certain that there are no old libs around to bite us # BZ 834847 @@ -773,14 +1568,35 @@ if [ -e /etc/ld.so.conf.d/glusterfs.conf ]; then rm -f /etc/ld.so.conf.d/glusterfs.conf /sbin/ldconfig fi + +%if (0%{?_with_firewalld:1}) +#reload service files if firewalld running +if $(systemctl is-active firewalld 1>/dev/null 2>&1); then + #firewalld-filesystem is not available for rhel7, so command used for reload. + firewall-cmd --reload +fi +%endif + pidof -c -o %PPID -x glusterd &> /dev/null if [ $? -eq 0 ]; then kill -9 `pgrep -f gsyncd.py` &> /dev/null - killall glusterd &> /dev/null + killall --wait glusterd &> /dev/null glusterd --xlator-option *.upgrade=on -N + + #Cleaning leftover glusterd socket file which is created by glusterd in + #rpm_script_t context. + rm -rf /var/run/glusterd.socket + + # glusterd _was_ running, we killed it, it exited after *.upgrade=on, + # so start it again + %_init_start glusterd else glusterd --xlator-option *.upgrade=on -N + + #Cleaning leftover glusterd socket file which is created by glusterd in + #rpm_script_t context. + rm -rf /var/run/glusterd.socket fi %endif @@ -821,105 +1637,220 @@ fi %postun api /sbin/ldconfig +%if ( 0%{?_build_server} ) +%postun server +%if (0%{?_with_firewalld:1}) +#reload service files if firewalld running +if $(systemctl is-active firewalld 1>/dev/null 2>&1); then + firewall-cmd --reload +fi +%endif +%endif + + %postun libs /sbin/ldconfig ##----------------------------------------------------------------------------- -## All %files should be placed here and keep them sorted +## All files should be placed here and keep them grouped ## %files -%doc ChangeLog COPYING-GPLV2 COPYING-LGPLV3 INSTALL README THANKS -%config(noreplace) %{_sysconfdir}/logrotate.d/* +# exclude extra-xlators files +%if ( ! 0%{!?_without_extra_xlators:1} ) +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/mac-compat.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_client.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_dht.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_server.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quiesce.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/features/template.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache.so +%exclude %{python_sitelib}/* +%endif +# exclude regression-tests files +%if ( ! 0%{!?_without_regression_tests:1} ) +%exclude %{_prefix}/share/glusterfs/run-tests.sh +%exclude %{_prefix}/share/glusterfs/tests/* +%endif +%if ( ! 0%{?_build_server} ) +# exclude ganesha files +%exclude %{_sysconfdir}/ganesha/* +%exclude %{_libexecdir}/ganesha/* +%exclude %{_prefix}/lib/ocf/* +# exclude incrementalapi +%exclude %{_libexecdir}/glusterfs/* +%exclude %{_sbindir}/gfind_missing_files +%exclude %{_libexecdir}/glusterfs/glusterfind +%exclude %{_bindir}/glusterfind +%exclude %{_libexecdir}/glusterfs/peer_add_secret_pub +%{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.py +%exclude %{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.pyc +%exclude %{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.pyo +# exclude server files +%exclude %{_sharedstatedir}/glusterd/* +%exclude %{_sysconfdir}/glusterfs +%exclude %{_sysconfdir}/glusterfs/glusterd.vol +%exclude %{_sysconfdir}/glusterfs/glusterfs-georep-logrotate +%exclude %{_sysconfdir}/glusterfs/glusterfs-logrotate +%exclude %{_sysconfdir}/glusterfs/gluster-rsyslog-5.8.conf +%exclude %{_sysconfdir}/glusterfs/gluster-rsyslog-7.2.conf +%exclude %{_sysconfdir}/glusterfs/group-virt.example +%exclude %{_sysconfdir}/glusterfs/logger.conf.example +%exclude %_init_glusterd +%exclude %{_sysconfdir}/sysconfig/glusterd +%exclude %{_bindir}/glusterfind +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so +%if ( 0%{!?_without_tiering:1} ) +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so +%endif +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/snapview-server.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/marker.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quota* +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/trash.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/upcall.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mgmt* +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* +%if ( 0%{!?_without_tiering:1} ) +%exclude %{_libdir}/libgfdb.so.* +%endif +%exclude %{_sbindir}/gcron.py +%exclude %{_sbindir}/glfsheal +%exclude %{_sbindir}/glusterd +%exclude %{_sbindir}/snap_scheduler.py +%exclude %{_datadir}/glusterfs/scripts/stop-all-gluster-processes.sh +#/usr/share/doc/glusterfs-server-3.7.0beta2/clear_xattrs.sh +%exclude %{_localstatedir}/run/gluster +%if 0%{?_tmpfilesdir:1} +%exclude %{_tmpfilesdir}/gluster.conf +%endif +%endif +%doc ChangeLog COPYING-GPLV2 COPYING-LGPLV3 INSTALL README.md THANKS %if ( 0%{!?_without_syslog:1} ) %if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 6 ) %{_sysconfdir}/rsyslog.d/gluster.conf.example %endif %endif -%{_libdir}/glusterfs -%{_sbindir}/glusterfs* %{_mandir}/man8/*gluster*.8* %exclude %{_mandir}/man8/gluster.8* %dir %{_localstatedir}/log/glusterfs -%dir %{_localstatedir}/run/gluster -%dir %{_sharedstatedir}/glusterd %if ( 0%{!?_without_rdma:1} ) %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/rpc-transport/rdma* %endif -# server-side, etc., xlators in other RPMs -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/api* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/fuse* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mgmt* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* -# Glupy files are in the -extra-xlators package -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy* -# sample xlators not generally used or usable -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/mac-compat* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache* +%dir %{_datadir}/glusterfs/scripts %{_datadir}/glusterfs/scripts/post-upgrade-script-for-quota.sh %{_datadir}/glusterfs/scripts/pre-upgrade-script-for-quota.sh -%if ( ! 0%{?_build_server} ) -%if ( 0%{?rhel} && 0%{?rhel} > 5 ) -%exclude %{_libexecdir}/glusterfs/* -%endif -%exclude %{_datadir}/glusterfs/* -%exclude %{_prefix}/lib/ocf/* -%exclude %{_sharedstatedir}/glusterd/* -%exclude %{_sysconfdir}/glusterfs/* -%exclude %_init_glusterd -%exclude %{_sbindir}/glusterd -%endif -%exclude %{_prefix}/share/glusterfs/* -%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy.so -%exclude %{python_sitelib}/gluster/glupy.* -%if ( 0%{?rhel} && 0%{?rhel} > 5 ) -%exclude %{python_sitelib}/glusterfs_glupy*.egg-info -%endif -%exclude %{_sbindir}/glfsheal +# xlators that are needed on the client- and on the server-side +%dir %{_libdir}/glusterfs/%{version}%{?prereltag}/auth +%{_libdir}/glusterfs/%{version}%{?prereltag}/auth/addr.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/auth/login.so +%dir %{_libdir}/glusterfs/%{version}%{?prereltag}/rpc-transport +%{_libdir}/glusterfs/%{version}%{?prereltag}/rpc-transport/socket.so +%dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/error-gen.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/io-stats.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/trace.so +%if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) ) +# RHEL-5 based distributions have a too old openssl +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/crypt.so +%endif +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/access-control.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/barrier.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/cdc.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changelog.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/gfid-access.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/read-only.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/shard.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/snapview-client.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/worm.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/meta.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/io-cache.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/io-threads.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/md-cache.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/open-behind.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/quick-read.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/read-ahead.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/readdir-ahead.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/stat-prefetch.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/write-behind.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/system/posix-acl.so + %files api %exclude %{_libdir}/*.so -# Shared Python-GlusterFS files -%{python_sitelib}/gluster/__init__.* # libgfapi files %{_libdir}/libgfapi.* -%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/api* -%{python_sitelib}/gluster/gfapi.* -# Don't expect a .egg-info file on EL5 -%if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) ) -%{python_sitelib}/glusterfs_api*.egg-info -%endif +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/api.so %files api-devel %{_libdir}/pkgconfig/glusterfs-api.pc -%{_libdir}/pkgconfig/libgfchangelog.pc %{_libdir}/libgfapi.so %{_includedir}/glusterfs/api/* %files cli %{_sbindir}/gluster %{_mandir}/man8/gluster.8* +%{_sysconfdir}/bash_completion.d/gluster %files devel %{_includedir}/glusterfs %exclude %{_includedir}/glusterfs/y.tab.h %exclude %{_includedir}/glusterfs/api %exclude %{_libdir}/libgfapi.so +%if ( ! 0%{?_build_server} ) +%exclude %{_libdir}/libgfchangelog.so +%endif +%if ( 0%{!?_without_tiering:1} && ! 0%{?_build_server}) +%exclude %{_libdir}/libgfdb.so +%endif %{_libdir}/*.so # Glupy Translator examples %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/debug-trace.* %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/helloworld.* %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/negative.* +%if ( 0%{?_build_server} ) +%{_libdir}/pkgconfig/libgfchangelog.pc +%else +%exclude %{_libdir}/pkgconfig/libgfchangelog.pc +%endif +%if ( 0%{!?_without_tiering:1} && 0%{?_build_server}) +%{_libdir}/pkgconfig/libgfdb.pc +%else +%if ( 0%{?rhel} && 0%{?rhel} >= 6 ) +%exclude %{_libdir}/pkgconfig/libgfdb.pc +%endif +%endif + +%files client-xlators +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/*.so +%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/ganesha.so +%if ( 0%{!?_without_qemu_block:1} ) +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/qemu-block.so +%endif +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/client.so %if ( 0%{!?_without_extra_xlators:1} ) %files extra-xlators -# Glupy C shared library +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13.so %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/mac-compat.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_client.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_dht.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/prot_server.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quiesce.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/features/template.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache.so # Glupy Python files -%{python_sitelib}/gluster/glupy.* +%{python_sitelib}/gluster/glupy/* # Don't expect a .egg-info file on EL5 %if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) ) %{python_sitelib}/glusterfs_glupy*.egg-info @@ -927,10 +1858,11 @@ fi %endif %files fuse -%if ( 0%{_for_fedora_koji_builds} ) -%config(noreplace) %{_sysconfdir}/logrotate.d/glusterfs-fuse -%endif -%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/fuse* +# glusterfs is a symlink to glusterfsd, -server depends on -fuse. +%{_sbindir}/glusterfs +%{_sbindir}/glusterfsd +%config(noreplace) %{_sysconfdir}/logrotate.d/glusterfs +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/fuse.so /sbin/mount.glusterfs %if ( 0%{!?_without_fusermount:1} ) %{_bindir}/fusermount-glusterfs @@ -942,15 +1874,22 @@ fi %endif %if ( 0%{?_build_server} ) +%files ganesha +%{_sysconfdir}/ganesha/* +%attr(0755,-,-) %{_libexecdir}/ganesha/* +%attr(0755,-,-) %{_prefix}/lib/ocf/resource.d/heartbeat/* +%endif + +%if ( 0%{?_build_server} ) %if ( 0%{!?_without_georeplication:1} ) %files geo-replication -%{_sysconfdir}/logrotate.d/glusterfs-georep +%config(noreplace) %{_sysconfdir}/logrotate.d/glusterfs-georep %{_libexecdir}/glusterfs/gsyncd %{_libexecdir}/glusterfs/python/syncdaemon/* %{_libexecdir}/glusterfs/gverify.sh %{_libexecdir}/glusterfs/set_geo_rep_pem_keys.sh -%{_libexecdir}/glusterfs/peer_add_secret_pub %{_libexecdir}/glusterfs/peer_gsec_create +%{_libexecdir}/glusterfs/peer_mountbroker %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/geo-replication %{_sharedstatedir}/glusterd/hooks/1/gsync-create/post/S56glusterd-geo-rep-create-post.sh %{_datadir}/glusterfs/scripts/get-gfid.sh @@ -960,11 +1899,22 @@ fi %{_datadir}/glusterfs/scripts/gsync-sync-gfid %ghost %attr(0644,-,-) %{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf %endif +%{_libexecdir}/glusterfs/gfind_missing_files +%{_sbindir}/gfind_missing_files %endif %files libs %{_libdir}/*.so.* %exclude %{_libdir}/libgfapi.* +%if ( 0%{!?_without_tiering:1} ) +# libgfdb is only needed server-side +%exclude %{_libdir}/libgfdb.* +%endif + +%files -n python-gluster +# introducing glusterfs module in site packages. +# so that all other gluster submodules can reside in the same namespace. +%{python_sitelib}/gluster/__init__.* %if ( 0%{!?_without_rdma:1} ) %files rdma @@ -974,36 +1924,45 @@ fi %if ( 0%{?_build_server} ) %if ( 0%{!?_without_regression_tests:1} ) %files regression-tests -%{_prefix}/share/glusterfs/* +%{_prefix}/share/glusterfs/run-tests.sh +%{_prefix}/share/glusterfs/tests %exclude %{_prefix}/share/glusterfs/tests/basic/rpm.t %endif +%endif +%if ( 0%{?_build_server} ) %if ( 0%{!?_without_ocf:1} ) %files resource-agents # /usr/lib is the standard for OCF, also on x86_64 %{_prefix}/lib/ocf/resource.d/glusterfs %endif +%endif +%if ( 0%{?_build_server} ) %files server +%exclude %{_sharedstatedir}/glusterd/hooks/1/gsync-create/post/S56glusterd-geo-rep-create-post.sh %doc extras/clear_xattrs.sh -%if ( 0%{_for_fedora_koji_builds} ) -%config(noreplace) %{_sysconfdir}/logrotate.d/glusterd -%endif %config(noreplace) %{_sysconfdir}/sysconfig/glusterd %config(noreplace) %{_sysconfdir}/glusterfs +%dir %{_localstatedir}/run/gluster +%if 0%{?_tmpfilesdir:1} +%{_tmpfilesdir}/gluster.conf +%endif +%dir %{_sharedstatedir}/glusterd +%{_sharedstatedir}/glusterd/* %dir %{_sharedstatedir}/glusterd/groups %config(noreplace) %{_sharedstatedir}/glusterd/groups/virt # Legacy configs %if ( 0%{_for_fedora_koji_builds} ) -%config(noreplace) %{_sysconfdir}/logrotate.d/glusterfsd %config(noreplace) %{_sysconfdir}/sysconfig/glusterfsd %endif %config %{_sharedstatedir}/glusterd/hooks/1/add-brick/post/disabled-quota-root-xattr-heal.sh %config %{_sharedstatedir}/glusterd/hooks/1/add-brick/pre/S28Quota-enable-root-xattr-heal.sh %config %{_sharedstatedir}/glusterd/hooks/1/set/post/S30samba-set.sh -%config %{_sharedstatedir}/glusterd/hooks/1/set/post/S31ganesha-set.sh +%config %{_sharedstatedir}/glusterd/hooks/1/set/post/S32gluster_enable_shared_storage.sh %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S29CTDBsetup.sh %config %{_sharedstatedir}/glusterd/hooks/1/start/post/S30samba-start.sh +%config %{_sharedstatedir}/glusterd/hooks/1/start/post/S31ganesha-start.sh %config %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S30samba-stop.sh %config %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh %config %{_sharedstatedir}/glusterd/hooks/1/reset/post/S31ganesha-reset.sh @@ -1015,12 +1974,36 @@ fi # binaries %{_sbindir}/glusterd %{_sbindir}/glfsheal -%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* +# {_sbindir}/glusterfsd is the actual binary, but glusterfs (client) is a +# symlink. The binary itself (and symlink) are part of the glusterfs-fuse +# package, because glusterfs-server depends on that anyway. +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so +%if ( 0%{!?_without_tiering:1} ) +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so +%endif +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix* -%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/snapview-server.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/marker.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quota* +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/trash.so +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/upcall.so %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mgmt* %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs* -%{_sharedstatedir}/glusterd/* +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server* +%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage* +%if ( 0%{!?_without_tiering:1} ) +%{_libdir}/libgfdb.so.* +%endif + +#snap_scheduler +%{_sbindir}/snap_scheduler.py +%{_sbindir}/gcron.py + #hookscripts %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1 @@ -1038,8 +2021,21 @@ fi %ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/options %ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/nfs-server.vol %ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/run/nfs.pid + +# Extra utility script +%{_datadir}/glusterfs/scripts/stop-all-gluster-processes.sh + +# Incrementalapi +%{_libexecdir}/glusterfs/glusterfind +%{_bindir}/glusterfind +%{_libexecdir}/glusterfs/peer_add_secret_pub %endif +%if ( 0%{?_with_firewalld:1} ) +/usr/lib/firewalld/services/glusterfs.xml +%endif + + ##----------------------------------------------------------------------------- ## All %pretrans should be placed here and keep them sorted ## @@ -1173,7 +2169,7 @@ end -%pretrans devel -p +%pretrans cli -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1202,7 +2198,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1214,7 +2210,7 @@ end -%pretrans fuse -p +%pretrans client-xlators -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1243,7 +2239,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1255,9 +2251,7 @@ end -%if 0%{?_can_georeplicate} -%if ( 0%{!?_without_georeplication:1} ) -%pretrans geo-replication -p +%pretrans devel -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1286,7 +2280,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1295,12 +2289,10 @@ os.remove(tmpname) if not (ok == 0) then error("Detected running glusterfs processes", ok) end -%endif -%endif -%pretrans libs -p +%pretrans fuse -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1329,7 +2321,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1341,8 +2333,7 @@ end -%if ( 0%{!?_without_rdma:1} ) -%pretrans rdma -p +%pretrans ganesha -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1371,7 +2362,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-ganesha_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1380,12 +2371,11 @@ os.remove(tmpname) if not (ok == 0) then error("Detected running glusterfs processes", ok) end -%endif -%if ( 0%{!?_without_ocf:1} ) -%pretrans resource-agents -p +%if ( 0%{!?_without_georeplication:1} ) +%pretrans geo-replication -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1414,7 +2404,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1427,7 +2417,7 @@ end -%pretrans server -p +%pretrans libs -p if not posix.access("/bin/bash", "x") then -- initial installation, no shell, no running glusterfsd return 0 @@ -1456,7 +2446,7 @@ fi -- rpm in RHEL5 does not have os.tmpname() -- io.tmpfile() can not be resolved to a filename to pass to bash :-/ -tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s") +tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s") tmpfile = io.open(tmpname, "w") tmpfile:write(script) tmpfile:close() @@ -1465,114 +2455,270 @@ os.remove(tmpname) if not (ok == 0) then error("Detected running glusterfs processes", ok) end -%endif -%changelog -* Thu Oct 09 2014 Bala FA - v3.6.0.29-2 -- build to make higher release with rh-common-rhel-7 to avoid build - collision -* Fri Sep 19 2014 Bala FA - v3.6.0.29-1 -- fixes bugs bz#1136711 bz#1138288 bz#1139213 bz#1139273 bz#1139473 - bz#1140643 bz#1143960 -* Wed Sep 03 2014 Bala FA - v3.6.0.28-1 -- fixes bugs bz#1110694 bz#1116150 bz#1121099 bz#1124692 bz#1127234 - bz#1136711 bz#921528 bz#969298 +%pretrans -n python-gluster -p +if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd + return 0 +end -* Mon Aug 04 2014 Bala FA - v3.6.0.27-1 -- fixes bugs bz#1048930 bz#1108588 bz#1123305 bz#1124583 bz#1125818 +-- TODO: move this completely to a lua script +-- For now, we write a temporary bash script and execute that. -* Thu Jul 31 2014 Bala FA - v3.6.0.26-1 -- fixes bugs bz#1111029 bz#1111577 bz#1113852 bz#1116761 bz#1117135 - bz#1117283 bz#1119223 bz#1120830 bz#1121059 bz#1121603 +script = [[#!/bin/sh +pidof -c -o %PPID -x glusterfsd &>/dev/null -* Tue Jul 22 2014 Bala FA - v3.6.0.25-1 -- fixes bugs bz#1007033 bz#1101910 bz#1104121 bz#1104921 bz#1109150 - bz#1116376 bz#1116703 bz#1116992 bz#1117135 bz#1120198 bz#1120245 bz#BUG: +if [ $? -eq 0 ]; then + pushd . > /dev/null 2>&1 + for volume in /var/lib/glusterd/vols/*; do cd $volume; + vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` + volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` + if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then + exit 1; + fi + done + + popd > /dev/null 2>&1 + exit 1; +fi +]] + +-- rpm in RHEL5 does not have os.tmpname() +-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ +tmpname = "/tmp/python-gluster_pretrans_" .. os.date("%s") +tmpfile = io.open(tmpname, "w") +tmpfile:write(script) +tmpfile:close() +ok, how, val = os.execute("/bin/bash " .. tmpname) +os.remove(tmpname) +if not (ok == 0) then + error("Detected running glusterfs processes", ok) +end -* Thu Jul 03 2014 Bala FA - v3.6.0.24-1 -- fixes bugs bz#1104153 bz#1109149 bz#1112582 bz#1113961 bz#1114008 - bz#1114592 bz#1115266 bz#1115267 -* Wed Jun 25 2014 Bala FA - v3.6.0.23-1 -- fixes bugs bz#1111148 bz#1111612 -* Mon Jun 23 2014 Bala FA - v3.6.0.22-1 -- fixes bugs bz#1006809 bz#1111122 +%if ( 0%{!?_without_rdma:1} ) +%pretrans rdma -p +if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd + return 0 +end -* Fri Jun 20 2014 Bala FA - v3.6.0.21-1 -- fixes bugs bz#1101407 bz#1103155 bz#1110211 bz#1110224 bz#1110252 bz#1111468 +-- TODO: move this completely to a lua script +-- For now, we write a temporary bash script and execute that. -* Thu Jun 19 2014 Bala FA - v3.6.0.20-1 -- fixes bugs bz#1030309 bz#1082951 bz#1103644 +script = [[#!/bin/sh +pidof -c -o %PPID -x glusterfsd &>/dev/null -* Wed Jun 18 2014 Bala FA - v3.6.0.19-1 -- fixes bugs bz#1030309 bz#1088231 bz#1090986 bz#1094681 bz#1095314 - bz#1098971 bz#1108018 bz#1108505 bz#1108570 bz#1109149 +if [ $? -eq 0 ]; then + pushd . > /dev/null 2>&1 + for volume in /var/lib/glusterd/vols/*; do cd $volume; + vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` + volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` + if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then + exit 1; + fi + done -* Mon Jun 16 2014 Bala FA - v3.6.0.18-1 -- fixes bugs bz#1006729 bz#1064597 bz#1066389 bz#1082951 bz#1098971 - bz#1102550 bz#1103688 bz#1105323 bz#1107665 bz#1107961 bz#1108018 bz#1109141 + popd > /dev/null 2>&1 + exit 1; +fi +]] -* Fri Jun 13 2014 Bala FA - v3.6.0.17-1 -- fixes bugs bz#1082951 bz#1086145 bz#1097102 bz#1100211 bz#1103680 - bz#1104159 bz#1104574 bz#1104635 bz#1105102 bz#1107523 bz#1108652 +-- rpm in RHEL5 does not have os.tmpname() +-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ +tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s") +tmpfile = io.open(tmpname, "w") +tmpfile:write(script) +tmpfile:close() +ok, how, val = os.execute("/bin/bash " .. tmpname) +os.remove(tmpname) +if not (ok == 0) then + error("Detected running glusterfs processes", ok) +end +%endif -* Wed Jun 11 2014 Bala FA - v3.6.0.16-1 -- fixes bugs bz#1096565 bz#1096614 bz#1097512 bz#1098087 bz#1099385 - bz#1101407 bz#1101514 bz#1101961 bz#1104602 bz#1105444 -* Mon Jun 09 2014 Bala FA - v3.6.0.15-1 -- fixes bugs bz#1096729 bz#1102747 -* Sat Jun 07 2014 Bala FA - v3.6.0.14-1 -- fixes bugs bz#1094716 bz#1101525 +%if ( 0%{!?_without_ocf:1} ) +%pretrans resource-agents -p +if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd + return 0 +end -* Thu Jun 05 2014 Bala FA - v3.6.0.13-1 -- fixes bugs bz#1046908 bz#1082043 bz#1094832 bz#1095267 bz#1096139 - bz#1098196 bz#1100282 bz#1104016 bz#1104486 +-- TODO: move this completely to a lua script +-- For now, we write a temporary bash script and execute that. -* Tue Jun 03 2014 Bala FA - v3.6.0.12-1 -- fixes bugs bz#1099079 bz#1101588 bz#1103576 bz#921528 bz#970813 +script = [[#!/bin/sh +pidof -c -o %PPID -x glusterfsd &>/dev/null -* Fri May 30 2014 Bala FA - v3.6.0.11-1 -- fixes bugs bz#1043566 bz#1080245 +if [ $? -eq 0 ]; then + pushd . > /dev/null 2>&1 + for volume in /var/lib/glusterd/vols/*; do cd $volume; + vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` + volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` + if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then + exit 1; + fi + done -* Thu May 29 2014 Bala FA - v3.6.0.10-1 -- fixes bugs bz#1102053 + popd > /dev/null 2>&1 + exit 1; +fi +]] -* Tue May 27 2014 Bala FA - v3.6.0.9-1 -- fixes bugs bz#1098862 bz#1099833 +-- rpm in RHEL5 does not have os.tmpname() +-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ +tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s") +tmpfile = io.open(tmpname, "w") +tmpfile:write(script) +tmpfile:close() +ok, how, val = os.execute("/bin/bash " .. tmpname) +os.remove(tmpname) +if not (ok == 0) then + error("Detected running glusterfs processes", ok) +end +%endif -* Mon May 26 2014 Bala FA - v3.6.0.8-1 -- fixes bugs bz#1098053 -* Fri May 23 2014 Bala FA - v3.6.0.7-1 -- fixes bugs bz#1098691 -* Thu May 22 2014 Bala FA - v3.6.0.6-1 -- fixes bugs bz#1097782 bz#1099010 bz#989480 +%pretrans server -p +if not posix.access("/bin/bash", "x") then + -- initial installation, no shell, no running glusterfsd + return 0 +end -* Tue May 20 2014 Bala FA - v3.6.0.5-1 -- fixes bugs bz#1096729 +-- TODO: move this completely to a lua script +-- For now, we write a temporary bash script and execute that. -* Mon May 19 2014 Bala FA - v3.6.0.4-1 -- fixes bugs bz#1095190 bz#1096565 bz#1097679 bz#1098069 bz#1098070 +script = [[#!/bin/sh +pidof -c -o %PPID -x glusterfsd &>/dev/null -* Sat May 17 2014 Bala FA - v3.6.0.3-1 -- fixes bugs bz#1094681 +if [ $? -eq 0 ]; then + pushd . > /dev/null 2>&1 + for volume in /var/lib/glusterd/vols/*; do cd $volume; + vol_type=`grep '^type=' info | awk -F'=' '{print $2}'` + volume_started=`grep '^status=' info | awk -F'=' '{print $2}'` + if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then + exit 1; + fi + done -* Thu May 15 2014 Bala FA - v3.6.0.2-1 -- fixes bugs bz#1061580 bz#1077452 bz#1091961 bz#1093602 bz#1096616 - bz#1096700 bz#1097224 bz#1098020 bz#1098053 + popd > /dev/null 2>&1 + exit 1; +fi +]] -* Wed May 14 2014 Sreenath G - v3.6.0.1-1 -- fixes bugs bz#1062158 bz#1097565 bz#1097581 bz#1097603 +-- rpm in RHEL5 does not have os.tmpname() +-- io.tmpfile() can not be resolved to a filename to pass to bash :-/ +tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s") +tmpfile = io.open(tmpname, "w") +tmpfile:write(script) +tmpfile:close() +ok, how, val = os.execute("/bin/bash " .. tmpname) +os.remove(tmpname) +if not (ok == 0) then + error("Detected running glusterfs processes", ok) +end +%endif -* Tue May 13 2014 Bala.FA - v3.6.0.0-1 -- Initial build fixes bugs bz#1032894, bz#1039544, bz#1040351, - bz#1046853, bz#1047782, bz#1053579, bz#1061685, bz#1074947, - bz#1078061, bz#1080970, bz#1089172, bz#1091926, bz#1091934, - bz#1092841, bz#1093602, bz#1094708, bz#1095097, bz#1095585, - bz#1096026, bz#874554, bz#959986 +%changelog +* Mon Sep 21 2015 Bala.FA - 3.7.1-16 +- fixes bugs bz#1263653 + +* Tue Sep 15 2015 Bala.FA - 3.7.1-15 +- fixes bugs bz#1253774 bz#1257509 bz#1259221 bz#1259750 bz#1260086 + bz#1260512 bz#1262236 bz#1262291 + +* Tue Sep 01 2015 Bala.FA - 3.7.1-14 +- fixes bugs bz#1115367 bz#1232569 bz#1234213 bz#1234610 bz#1241336 + bz#1241385 bz#1241862 bz#1242803 bz#1245077 bz#1251457 + +* Thu Aug 27 2015 Bala.FA - 3.7.1-13 +- fixes bugs bz#1224184 bz#1225452 bz#1227759 bz#1228135 bz#1231080 + bz#1234399 bz#1235971 bz#1236038 bz#1238070 bz#1238111 bz#1238171 bz#1238398 + bz#1238977 bz#1239021 bz#1240918 bz#1245165 bz#1245636 bz#1245924 bz#1251409 + bz#1255471 bz#1257007 bz#1247349 + +* Wed Aug 19 2015 Bala.FA - 3.7.1-12 +- fixes bugs bz#1027723 bz#1064265 bz#1065651 bz#1134288 bz#1213893 + bz#1226665 bz#1226817 bz#1229606 bz#1229621 bz#1230532 bz#1232216 bz#1235571 + bz#1236546 bz#1236672 bz#1236990 bz#1238049 bz#1238071 bz#1239075 bz#1240657 + bz#1241649 bz#1241761 bz#1243542 bz#1243722 bz#1243886 bz#1244527 bz#1245448 + bz#1245536 bz#1245542 bz#1245897 bz#1245915 bz#1245919 bz#1246946 bz#1252359 + bz#1253549 + +* Sun Jul 19 2015 Bala.FA - 3.7.1-11 +- fixes bugs bz#1244187 + +* Wed Jul 15 2015 Bala.FA - 3.7.1-10 +- fixes bugs bz#1224177 bz#1230513 bz#1240617 bz#1242367 bz#1242423 + bz#1242543 bz#1242585 bz#1242767 + +* Mon Jul 13 2015 Bala.FA - 3.7.1-9 +- fixes bugs bz#1224177 bz#1224610 bz#1230525 bz#1231647 bz#1234725 + bz#1235121 bz#1239057 bz#1239108 bz#1239317 bz#1240196 bz#1240338 bz#1240925 + bz#1241048 bz#1241150 bz#1241366 bz#1241830 bz#1241839 bz#1241904 bz#1242046 + +* Wed Jul 08 2015 Bala.FA - 3.7.1-8 +- fixes bugs bz#1223205 bz#1224177 bz#1228247 bz#1229567 bz#1230513 + bz#1231635 bz#1231732 bz#1239280 bz#1240168 bz#1240245 + +* Fri Jul 03 2015 Bala.FA - 3.7.1-7 +- fixes bugs bz#1227197 bz#1228127 bz#1230612 bz#1231782 bz#1235735 + bz#1236556 bz#1237053 bz#1237165 bz#1238167 + +* Sun Jun 28 2015 Bala.FA - 3.7.1-6 +- fixes bugs bz#1140649 bz#1222856 bz#1223225 bz#1223677 bz#1223738 + bz#1223757 bz#1224177 bz#1224199 bz#1224227 bz#1224619 bz#1225747 bz#1226149 + bz#1226863 bz#1227869 bz#1228525 bz#1228598 bz#1231771 bz#1231773 bz#1231775 + bz#1231779 bz#1231784 bz#1231792 bz#1231796 bz#1231797 bz#1232307 bz#1232309 + bz#1232625 bz#1233033 bz#1233575 bz#1233694 bz#1234419 bz#1234720 bz#1234725 + bz#1234869 bz#1235147 bz#1235182 bz#1235225 bz#1235236 bz#1235244 bz#1235540 + bz#1235544 bz#1235628 bz#1235940 + +* Wed Jun 24 2015 Bala.FA - 3.7.1-5 +- fixes bugs bz#1121560 bz#1140649 bz#1178130 bz#1224115 bz#1226863 + bz#1227311 bz#1227900 bz#1228626 bz#1229260 bz#1229601 bz#1230513 bz#1230517 + bz#1230646 bz#1231223 bz#1231778 bz#1231780 bz#1231782 bz#1231788 bz#1231792 + bz#1232609 bz#1232624 bz#1233046 bz#1233486 + +* Thu Jun 18 2015 Bala.FA - 3.7.1-4 +- fixes bugs bz#1130998 bz#1224137 bz#1225010 bz#1227029 bz#1227311 + bz#1227709 bz#1230101 bz#1230635 bz#1231026 bz#1231166 bz#1231651 bz#1231771 + bz#1231775 bz#1231776 bz#1231792 bz#1232428 bz#1232641 bz#1233144 + +* Mon Jun 15 2015 Bala.FA - 3.7.1-3 +- fixes bugs bz#1211839 bz#1224046 bz#1224236 bz#1224662 bz#1224880 + bz#1225507 bz#1226889 bz#1227618 bz#1228017 bz#1228495 bz#1228597 bz#1229623 + bz#1229674 bz#1230607 bz#1230764 bz#1231078 + +* Fri Jun 12 2015 Bala.FA - 3.7.1-2 +- fixes bugs bz#1140506 bz#1186216 bz#1200815 bz#1203901 bz#1222053 + bz#1222785 bz#1223205 bz#1223746 bz#1224123 bz#1224136 bz#1224160 bz#1224161 + bz#1224175 bz#1224177 bz#1224183 bz#1224195 bz#1224215 bz#1224249 bz#1224618 + bz#1227172 bz#1227179 bz#1227469 bz#1227918 bz#1228164 bz#1228173 bz#1228496 + bz#1228529 bz#1228643 bz#1229268 bz#1229612 bz#1230114 bz#1230186 bz#1230195 + bz#1230522 + +* Tue Jun 09 2015 Bala FA - 3.7.1-1 +- rebase to 3.7.1 +- fixes bugs bz#1027710 bz#1039674 bz#1047481 bz#1140506 bz#1223201 + bz#1223206 bz#1223715 bz#1224225 bz#1226162 bz#1227262 bz#1227317 + bz#1227649 bz#1228266 bz#1228518 bz#1228541 + +* Tue Jun 02 2015 Bala FA - 3.7.0-3.1 +- fix glusterfs server build in rhel-7 due to change in dist tag + +* Mon Jun 01 2015 Bala FA - 3.7.0-3 +- Resolves bz#1134690 bz#1110715 + +* Fri May 15 2015 Bala FA - 3.7.0-2 +- Resolves bz#1221743: glusterd not starting after a fresh install of + 3.7.0-1.el6rhs build + +* Thu May 14 2015 Bala FA - 3.7.0-1 +- rebased to 3.7.0