From 101243860bca1bbda8a03ab76f6753ecc10799ed Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Mon, 21 Dec 2015 10:09:53 +0000 Subject: afr: warn if pending xattrs missing during init() Backport of http://review.gluster.org/#/c/13038/ Since commit 6e635284a4411b816d4d860a28262c9e6dc4bd6a (glusterfs-3.7.7), the afr pending xattrs are stored in the volfile and used by afr when it initializes. If a cluster is upgraded, prevent afr from loading until the op-version has been bumped up to 3.7.7 and the volfiles have been regenerated using a volume set command. Without this fix, AFR will crash when initialzing. Change-Id: I14249dedb3f2f77cd754d78d8a9a70fdc5fc8c10 BUG: 1293536 Signed-off-by: Ravishankar N (cherry picked from commit 4bfbabfdd698e93a1dc1aad5590ed18f10936c55) Reviewed-on: http://review.gluster.org/13058 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-messages.h | 11 ++++++++++- xlators/cluster/afr/src/afr.c | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h index d07c7bc2170..8217767fc4f 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 39 +#define GLFS_NUM_MESSAGES 40 #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" @@ -347,5 +347,14 @@ #define AFR_MSG_REPLACE_BRICK_FAILED (GLFS_COMP_BASE_AFR + 39) +/*! + * @messageid 108039 + * @diagnosis AFR was unable to be loaded because the pending-changelog xattrs + * were not found in the volfile. + * @recommendedaction Please ensure cluster op-version is atleast 30707 and the + * volfiles are regenerated. +*/ +#define AFR_MSG_NO_CHANGELOG (GLFS_COMP_BASE_AFR + 40) + #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" #endif /* !_AFR_MESSAGES_H_ */ diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index 4c072b6c69f..34de74da977 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -411,6 +411,13 @@ init (xlator_t *this) ret = -ENOMEM; goto out; } + if (!xattrs_list) { + ret = -EINVAL; + gf_msg (this->name, GF_LOG_ERROR, -ret, AFR_MSG_NO_CHANGELOG, + "Unable to fetch afr pending changelogs. Is op-version" + " >= 30707?"); + goto out; + } ptr = gf_strdup (xattrs_list); if (!ptr) { ret = -ENOMEM; -- cgit