summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2016-10-18 15:16:17 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-11-18 01:56:39 -0800
commit5310be8838f8db748a698bd3a98f8d00a4114e65 (patch)
treedcfdf14c322d8731cec0eafc7aa24bf1abbf6629
parent2f70f47979d204d5ee29811f5f5fa61d0a52c3b1 (diff)
events: Add FMT_WARN for gf_event
Raghavendra G found that posix is trying to print %s but passing an int when HEALTH_CHECK fails in posix. These are the kind of bugs that should be caught at compilation itself. Also fixed the problematic gf_event() callers. BUG: 1386097 Change-Id: Id7bd6d9a9690237cec3ca1aefa2aac085e8a1270 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/15671 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r--cli/src/cli-cmd-volume.c4
-rw-r--r--libglusterfs/src/events.c2
-rw-r--r--libglusterfs/src/events.h10
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c5
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-svc-helper.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c13
-rw-r--r--xlators/storage/posix/src/posix-helpers.c2
8 files changed, 30 insertions, 21 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index c47c002c3f0..018814058a8 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1061,7 +1061,7 @@ out:
cli_out ("Volume add-brick failed");
} else {
#if (USE_EVENTS)
- gf_event (EVENT_VOLUME_ADD_BRICK, event_str);
+ gf_event (EVENT_VOLUME_ADD_BRICK, "%s", event_str);
GF_FREE (event_str);
#endif
}
@@ -2050,7 +2050,7 @@ out:
} else {
#if (USE_EVENTS)
if (!event_ret) {
- gf_event (event, event_str);
+ gf_event (event, "%s", event_str);
GF_FREE (event_str);
}
#endif
diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c
index b7b513eb39a..6b3a73d8ae4 100644
--- a/libglusterfs/src/events.c
+++ b/libglusterfs/src/events.c
@@ -32,7 +32,7 @@
int
-gf_event (eventtypes_t event, char *fmt, ...)
+_gf_event (eventtypes_t event, char *fmt, ...)
{
int ret = 0;
int sock = -1;
diff --git a/libglusterfs/src/events.h b/libglusterfs/src/events.h
index 6b280a0066f..e059bc9c4d1 100644
--- a/libglusterfs/src/events.h
+++ b/libglusterfs/src/events.h
@@ -15,13 +15,19 @@
#ifdef USE_EVENTS
int
-gf_event (eventtypes_t event, char *fmt, ...);
+_gf_event (eventtypes_t event, char *fmt, ...);
#else
static inline int
-gf_event (eventtypes_t event, char *fmt, ...)
+_gf_event (eventtypes_t event, char *fmt, ...)
{
return 0;
}
#endif /* USE_EVENTS */
+#define gf_event(event, fmt...) \
+ do { \
+ FMT_WARN(fmt); \
+ _gf_event (event, ##fmt); \
+ } while (0)
+
#endif /* __EVENTS_H__ */
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 556bc5d250e..b6720ccfa5c 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -1604,6 +1604,7 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
int i = 0;
int valid_cnt = 0;
struct iatt first = {0, };
+ int first_idx = 0;
struct afr_reply *replies = NULL;
int ret = -1;
@@ -1643,6 +1644,7 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
valid_cnt++;
if (valid_cnt == 1) {
first = replies[i].poststat;
+ first_idx = i;
continue;
}
@@ -1658,7 +1660,8 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
"type=file;gfid=%s;"
"ia_type-%d=%s;ia_type-%d=%s",
this->name,
- uuid_utoa (replies[i].poststat.ia_gfid), first,
+ uuid_utoa (replies[i].poststat.ia_gfid),
+ first_idx,
gf_inode_type_to_str (first.ia_type), i,
gf_inode_type_to_str (replies[i].poststat.ia_type));
ret = -EIO;
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index e41a59e7bfc..df1bce3d8db 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -149,7 +149,7 @@ dht_send_rebalance_event (xlator_t *this, int cmd, gf_defrag_status_t status)
}
if (event != EVENT_LAST) {
- ret = gf_event (event, "volume=%s", volname);
+ gf_event (event, "volume=%s", volname);
}
GF_FREE (tmpstr);
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
index 72f00922667..70a12dff499 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
@@ -28,16 +28,19 @@ glusterd_svcs_reconfigure ()
int ret = 0;
xlator_t *this = THIS;
glusterd_conf_t *conf = NULL;
+ char *svc_name = NULL;
GF_ASSERT (this);
conf = this->private;
GF_ASSERT (conf);
+ svc_name = "nfs";
ret = glusterd_nfssvc_reconfigure ();
if (ret)
goto out;
+ svc_name = "self-heald";
ret = glusterd_shdsvc_reconfigure ();
if (ret)
goto out;
@@ -45,20 +48,24 @@ glusterd_svcs_reconfigure ()
if (conf->op_version == GD_OP_VERSION_MIN)
goto out;
+ svc_name = "quotad";
ret = glusterd_quotadsvc_reconfigure ();
if (ret)
goto out;
+ svc_name = "bitd";
ret = glusterd_bitdsvc_reconfigure ();
if (ret)
goto out;
+
+ svc_name = "scrubber";
ret = glusterd_scrubsvc_reconfigure ();
if (ret)
goto out;
out:
- if (ret)
- gf_event (EVENT_SVC_RECONFIGURE_FAILED, "");
-
+ if (ret && svc_name)
+ gf_event (EVENT_SVC_RECONFIGURE_FAILED, "svc_name=%s",
+ svc_name);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index d916444a9b2..504ffdbe04c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -4383,10 +4383,7 @@ glusterd_compare_friend_data (dict_t *peer_data, int32_t *status,
ret = glusterd_import_friend_volumes (peer_data);
if (ret)
goto out;
-
- if (glusterd_svcs_manager (NULL)) {
- gf_event (EVENT_SVC_MANAGER_FAILED, "");
- }
+ glusterd_svcs_manager (NULL);
}
out:
@@ -4915,9 +4912,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
continue;
if (start_svcs == _gf_false) {
start_svcs = _gf_true;
- if (glusterd_svcs_manager (NULL)) {
- gf_event (EVENT_SVC_MANAGER_FAILED, "");
- }
+ glusterd_svcs_manager (NULL);
}
gf_msg_debug (this->name, 0, "starting the volume %s",
volinfo->volname);
@@ -4967,9 +4962,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
}
if (start_svcs == _gf_false) {
start_svcs = _gf_true;
- if (glusterd_svcs_manager (volinfo)) {
- gf_event (EVENT_SVC_MANAGER_FAILED, "");
- }
+ glusterd_svcs_manager (volinfo);
}
start_svcs = _gf_true;
gf_msg_debug (this->name, 0, "starting the snap "
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index caa79bf5815..0af586e7777 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1769,7 +1769,7 @@ out:
"%s() on %s returned", op, file_path);
gf_event (EVENT_POSIX_HEALTH_CHECK_FAILED,
"op=%s;path=%s;error=%s;brick=%s:%s", op, file_path,
- op_errno, priv->hostname, priv->base_path);
+ strerror (op_errno), priv->hostname, priv->base_path);
}
return ret;