From 8bc612d803b53e49f00268c1ba7471de9b93e0aa Mon Sep 17 00:00:00 2001 From: Shyam Date: Thu, 5 Feb 2015 12:52:55 -0500 Subject: cluster/dht: set op_errno correctly during migration. Backport of, http://review.gluster.org/#/c/6219/6 Change-Id: Ic3419dd05b4dbe49b6adf5648bdbe137722a6d04 BUG: 1166278 Signed-off-by: Shyam Reviewed-on: http://review.gluster.org/9599 Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY Reviewed-by: Niels de Vos --- xlators/cluster/dht/src/dht-helper.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 88eedf10c1f..c072a1bd265 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -888,6 +888,7 @@ dht_migration_complete_check_task (void *data) call_frame_t *frame = NULL; loc_t tmp_loc = {0,}; char *path = NULL; + int32_t op_errno = EINVAL; this = THIS; frame = data; @@ -895,8 +896,10 @@ dht_migration_complete_check_task (void *data) src_node = local->cached_subvol; - if (!local->loc.inode && !local->fd) + if (!local->loc.inode && !local->fd) { + local->op_errno = EINVAL; goto out; + } /* getxattr on cached_subvol for 'linkto' value */ if (!local->loc.inode) @@ -911,6 +914,7 @@ dht_migration_complete_check_task (void *data) if (ret) { if ((errno != ENOENT) || (!local->loc.inode)) { + local->op_errno = errno; gf_log (this->name, GF_LOG_ERROR, "%s: failed to get the 'linkto' xattr %s", local->loc.path, strerror (errno)); @@ -919,8 +923,10 @@ dht_migration_complete_check_task (void *data) /* Need to do lookup on hashed subvol, then get the file */ ret = syncop_lookup (this, &local->loc, NULL, &stbuf, NULL, NULL); - if (ret) + if (ret) { + local->op_errno = errno; goto out; + } dst_node = dht_subvol_get_cached (this, local->loc.inode); } @@ -929,6 +935,7 @@ dht_migration_complete_check_task (void *data) "%s: failed to get the destination node", local->loc.path); ret = -1; + local->op_errno = EINVAL; goto out; } @@ -937,6 +944,7 @@ dht_migration_complete_check_task (void *data) ret = syncop_lookup (dst_node, &local->loc, NULL, &stbuf, NULL, NULL); if (ret) { + local->op_errno = errno; gf_log (this->name, GF_LOG_ERROR, "%s: failed to lookup the file on %s", local->loc.path, dst_node->name); @@ -948,6 +956,7 @@ dht_migration_complete_check_task (void *data) "%s: gfid different on the target file on %s", local->loc.path, dst_node->name); ret = -1; + local->op_errno = EIO; goto out; } } @@ -964,6 +973,7 @@ dht_migration_complete_check_task (void *data) "%s: could not set preset layout for subvol %s", local->loc.path, dst_node->name); ret = -1; + local->op_errno = EINVAL; goto out; } @@ -973,6 +983,7 @@ dht_migration_complete_check_task (void *data) "%s: no pre-set layout for subvolume %s", local->loc.path, dst_node ? dst_node->name : ""); ret = -1; + local->op_errno = EINVAL; goto out; } @@ -984,6 +995,7 @@ dht_migration_complete_check_task (void *data) gf_log (this->name, GF_LOG_ERROR, "%s: failed to set the new layout", local->loc.path); + local->op_errno = EINVAL; goto out; } @@ -995,8 +1007,10 @@ dht_migration_complete_check_task (void *data) /* once we detect the migration complete, the fd-ctx is no more required.. delete the ctx */ ret = fd_ctx_del (local->fd, this, NULL); - if (!ret) + if (!ret){ + local->op_errno = EINVAL; goto out; + } /* perform open as root:root. There is window between linkfile * creation(root:root) and setattr with the correct uid/gid @@ -1007,6 +1021,8 @@ dht_migration_complete_check_task (void *data) if (local->loc.inode) { ret = syncop_open (dst_node, &local->loc, local->fd->flags, local->fd); + /* save the errno before any other syscall */ + op_errno = errno; } else { tmp_loc.inode = local->fd->inode; inode_path (local->fd->inode, NULL, &path); @@ -1014,6 +1030,8 @@ dht_migration_complete_check_task (void *data) tmp_loc.path = path; ret = syncop_open (dst_node, &tmp_loc, local->fd->flags, local->fd); + /* save the errno before any other call (like the free below) */ + op_errno = errno; GF_FREE (path); } @@ -1022,6 +1040,7 @@ dht_migration_complete_check_task (void *data) gf_log (this->name, GF_LOG_ERROR, "%s: failed to send open() on target file at %s", local->loc.path, dst_node->name); + local->op_errno = op_errno; goto out; } -- cgit