From 6123265556e54891369cc79a72b670a4b23a8a41 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 16 Feb 2012 14:47:27 +0530 Subject: cluster/dht: Handle get cached/hashed subvol failures gracefully Change-Id: I7a41c2876be04acd166b2004d9aa66af078d32ea BUG: 790328 Signed-off-by: shishir gowda Reviewed-on: http://review.gluster.com/2757 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- xlators/cluster/dht/src/dht-common.c | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/dht/src/dht-common.c') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index d55750dde8d..f76dba40fcf 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1333,8 +1333,16 @@ dht_lookup (call_frame_t *frame, xlator_t *this, return 0; } - if (!hashed_subvol) + if (!hashed_subvol) { hashed_subvol = dht_subvol_get_hashed (this, loc); + if (!hashed_subvol) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to get hashed subvol for %s", + loc->path); + op_errno = EINVAL; + goto err; + } + } local->hashed_subvol = hashed_subvol; if (is_revalidate (loc)) { @@ -1846,6 +1854,14 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, if (key && (strcmp (key, GF_XATTR_PATHINFO_KEY) == 0)) { hashed_subvol = dht_subvol_get_hashed (this, loc); + if (!hashed_subvol) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to get hashed_subvol for %s", + loc->path); + op_errno = EINVAL; + goto err; + } + cached_subvol = local->cached_subvol; local->call_cnt = 1; @@ -1861,7 +1877,21 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, } if (key && (strcmp (key, GF_XATTR_LINKINFO_KEY) == 0)) { hashed_subvol = dht_subvol_get_hashed (this, loc); + if (!hashed_subvol) { + gf_log (this->name, GF_LOG_ERROR, "Failed to get" + "hashed subvol for %s", loc->path); + op_errno = EINVAL; + goto err; + } + cached_subvol = dht_subvol_get_cached (this, loc->inode); + if (!cached_subvol) { + gf_log (this->name, GF_LOG_ERROR, "Failed to get" + "cached subvol for %s", loc->path); + op_errno = EINVAL; + goto err; + } + if (hashed_subvol == cached_subvol) { op_errno = ENODATA; goto err; @@ -2187,6 +2217,13 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, forced_rebalance = 1; local->rebalance.target_node = dht_subvol_get_hashed (this, loc); + if (!local->rebalance.target_node) { + gf_log (this->name, GF_LOG_ERROR, "Failed to get " + "hashed subvol for %s", loc->path); + op_errno = EINVAL; + goto err; + } + local->rebalance.from_subvol = local->cached_subvol; if (local->rebalance.target_node == local->rebalance.from_subvol) { -- cgit