diff options
author | Mohammed Rafi KC <rkavunga@redhat.com> | 2015-11-30 19:02:54 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-12-16 12:45:03 -0800 |
commit | b5de382afa8c5777e455c7a376fc4f1f01d782d1 (patch) | |
tree | cecd66049c205a204b0d5faa77e8bb9eef858ece /xlators/cluster/dht/src/dht-common.c | |
parent | 27c16d6da82876a689dfba53b8d45c3a3a657954 (diff) |
tier:unlink during migration
files deleted during promotion were not deleting as the
files are moving from hashed to non-hashed.
On deleting a file that is undergoing promotion,
the unlink call is not sent to the dst file as the
hashed subvol == cached subvol. This causes
the file to reappear once the migration is complete.
This patch also fixes a problem with stale linkfile
deleting.
Change-Id: I4b02a498218c9d8eeaa4556fa4219e91e7fa71e5
BUG: 1282390
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: http://review.gluster.org/12829
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 151 |
1 files changed, 77 insertions, 74 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index ee07a7f4f71..9d661441122 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1163,9 +1163,19 @@ dht_lookup_unlink_stale_linkto_cbk (call_frame_t *frame, void *cookie, int dht_fill_dict_to_avoid_unlink_of_migrating_file (dict_t *dict) { - int ret = 0; + int ret = 0; + xlator_t *this = NULL; + char *linktoskip_key = NULL; + + this = THIS; + GF_VALIDATE_OR_GOTO ("dht", this, err); - ret = dict_set_int32 (dict, DHT_SKIP_NON_LINKTO_UNLINK, 1); + if (dht_is_tier_xlator (this)) + linktoskip_key = TIER_SKIP_NON_LINKTO_UNLINK; + else + linktoskip_key = DHT_SKIP_NON_LINKTO_UNLINK; + + ret = dict_set_int32 (dict, linktoskip_key, 1); if (ret) goto err; @@ -2427,103 +2437,104 @@ err: return 0; } - int -dht_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +dht_unlink_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) { - dht_local_t *local = NULL; - call_frame_t *prev = NULL; + dht_local_t *local = NULL; + call_frame_t *prev = NULL; local = frame->local; prev = cookie; LOCK (&frame->lock); { - if (op_ret == -1) { - local->op_ret = -1; + if ((op_ret == -1) && !((op_errno == ENOENT) || + (op_errno == ENOTCONN))) { local->op_errno = op_errno; gf_msg_debug (this->name, op_errno, - "Unlink: subvolume %s returned -1", - prev->this->name); + "Unlink link: subvolume %s" + " returned -1", + prev->this->name); goto unlock; } local->op_ret = 0; - - local->postparent = *postparent; - local->preparent = *preparent; - - if (local->loc.parent) { - dht_inode_ctx_time_update (local->loc.parent, this, - &local->preparent, 0); - dht_inode_ctx_time_update (local->loc.parent, this, - &local->postparent, 1); - } } unlock: UNLOCK (&frame->lock); + DHT_STACK_UNWIND (unlink, frame, local->op_ret, local->op_errno, - &local->preparent, &local->postparent, NULL); + &local->preparent, &local->postparent, xdata); return 0; } - int -dht_unlink_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +dht_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) { - dht_local_t *local = NULL; - call_frame_t *prev = NULL; - - xlator_t *cached_subvol = NULL; + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + xlator_t *hashed_subvol = NULL; local = frame->local; prev = cookie; LOCK (&frame->lock); { - if ((op_ret == -1) && !((op_errno == ENOENT) || - (op_errno == ENOTCONN))) { - local->op_errno = op_errno; + if (op_ret == -1) { + if (op_errno != ENOENT) { + local->op_ret = -1; + local->op_errno = op_errno; + } else { + local->op_ret = 0; + } gf_msg_debug (this->name, op_errno, - "Unlink link: subvolume %s" - " returned -1", - prev->this->name); + "Unlink: subvolume %s returned -1", + prev->this->name); goto unlock; } local->op_ret = 0; + + local->postparent = *postparent; + local->preparent = *preparent; + + if (local->loc.parent) { + dht_inode_ctx_time_update (local->loc.parent, this, + &local->preparent, 0); + dht_inode_ctx_time_update (local->loc.parent, this, + &local->postparent, 1); + } } unlock: UNLOCK (&frame->lock); - if (local->op_ret == -1) - goto err; - - cached_subvol = dht_subvol_get_cached (this, local->loc.inode); - if (!cached_subvol) { - gf_msg_debug (this->name, 0, - "no cached subvolume for path=%s", - local->loc.path); - local->op_errno = EINVAL; - goto err; + if (!local->op_ret) { + hashed_subvol = dht_subvol_get_hashed (this, &local->loc); + if (hashed_subvol && + hashed_subvol != local->cached_subvol) { + /* + * If hashed and cached are different, then we need + * to unlink linkfile from hashed subvol if data + * file is deleted successfully + */ + STACK_WIND (frame, dht_unlink_linkfile_cbk, + hashed_subvol, + hashed_subvol->fops->unlink, &local->loc, + local->flags, xdata); + return 0; + } } - STACK_WIND (frame, dht_unlink_cbk, - cached_subvol, cached_subvol->fops->unlink, - &local->loc, local->flags, NULL); + DHT_STACK_UNWIND (unlink, frame, local->op_ret, local->op_errno, + &local->preparent, &local->postparent, xdata); return 0; - -err: - DHT_STACK_UNWIND (unlink, frame, -1, local->op_errno, - NULL, NULL, NULL); - return 0; } int @@ -5608,7 +5619,6 @@ dht_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, dict_t *xdata) { xlator_t *cached_subvol = NULL; - xlator_t *hashed_subvol = NULL; int op_errno = -1; dht_local_t *local = NULL; @@ -5623,15 +5633,6 @@ dht_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, goto err; } - hashed_subvol = dht_subvol_get_hashed (this, loc); - /* Dont fail unlink if hashed_subvol is NULL which can be the result - * of layout anomaly */ - if (!hashed_subvol) { - gf_msg_debug (this->name, 0, - "no subvolume in layout for path=%s", - loc->path); - } - cached_subvol = local->cached_subvol; if (!cached_subvol) { gf_msg_debug (this->name, 0, @@ -5641,15 +5642,9 @@ dht_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, } local->flags = xflag; - if (hashed_subvol && hashed_subvol != cached_subvol) { - STACK_WIND (frame, dht_unlink_linkfile_cbk, - hashed_subvol, hashed_subvol->fops->unlink, loc, - xflag, xdata); - } else { - STACK_WIND (frame, dht_unlink_cbk, - cached_subvol, cached_subvol->fops->unlink, loc, - xflag, xdata); - } + STACK_WIND (frame, dht_unlink_cbk, + cached_subvol, cached_subvol->fops->unlink, loc, + xflag, xdata); return 0; err: @@ -8121,3 +8116,11 @@ int32_t dht_set_local_rebalance (xlator_t *this, dht_local_t *local, return 0; } +gf_boolean_t +dht_is_tier_xlator (xlator_t *this) +{ + + if (strcmp (this->type, "cluster/tier") == 0) + return _gf_true; + return _gf_false; +} |