summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenkatesh Somyajulu <vsomyaju@redhat.com>2014-08-07 16:28:48 +0530
committerVijay Bellur <vbellur@redhat.com>2014-08-14 10:59:08 -0700
commit718f10e0d68715be2d73e677974629452485c699 (patch)
treeebe3c59a761805777d15a781c53c42f992f1e3b4
parent8116328a6b4ead0207fc5f93fcac9a2606c6f6ab (diff)
cluster/dht: Added keys in dht_lookup_everywhere_done
Case where both cached (C1) and hashed file are found, but hash does not point to above cached node (C1), then dont unlink if either fd-is-open on hashed or linkto-xattr is not found. Change-Id: I7ef49b88d2c88bf9d25d3aa7893714e6c0766c67 BUG: 1116150 Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com> Change-Id: I86d0a21d4c0501c45d837101ced4f96d6fedc5b9 Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com> Reviewed-on: http://review.gluster.org/8429 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: susant palai <spalai@redhat.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-common.c76
1 files changed, 72 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 1ba07296e2f..ef9383ca6ad 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -876,6 +876,59 @@ dht_lookup_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
int
+dht_lookup_unlink_of_false_linkto_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)
+{
+ int this_call_cnt = 0;
+ dht_local_t *local = NULL;
+ const char *path = NULL;
+
+ local = (dht_local_t*)frame->local;
+ path = local->loc.path;
+
+ gf_log (this->name, GF_LOG_INFO, "lookup_unlink returned with "
+ "op_ret -> %d and op-errno -> %d for %s", op_ret, op_errno,
+ ((path == NULL)? "null" : path ));
+
+ this_call_cnt = dht_frame_return (frame);
+ if (is_last_call (this_call_cnt)) {
+
+ if (op_ret == 0) {
+ dht_lookup_everywhere_done (frame, this);
+ } else {
+ /*When dht_lookup_everywhere is performed, one cached
+ *and one hashed file was found and hashed file does
+ *not point to the above mentioned cached node. So it
+ *was considered as stale and an unlink was performed.
+ *But unlink fails. So may be rebalance is in progress.
+ *now ideally we have two data-files. One obtained during
+ *lookup_everywhere and one where unlink-failed. So
+ *at this point in time we cannot decide which one to
+ *choose because there are chances of first cached
+ *file is truncated after rebalance and if it is choosen
+ *as cached node, application will fail. So return EIO.*/
+
+ if (op_errno == EBUSY) {
+
+ gf_log (this->name, GF_LOG_ERROR,
+ "Could not unlink the linkto file as "
+ "either fd is open and/or linkto xattr "
+ "is set for %s",
+ ((path == NULL)? "null":path));
+
+ }
+ DHT_STACK_UNWIND (lookup, frame, -1, EIO, NULL, NULL,
+ NULL, NULL);
+
+ }
+ }
+
+ return 0;
+}
+
+int
dht_lookup_unlink_stale_linkto_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int op_ret, int op_errno,
struct iatt *preparent,
@@ -1112,12 +1165,27 @@ dht_lookup_everywhere_done (call_frame_t *frame, xlator_t *this)
} else {
local->skip_unlink.handle_valid_link = _gf_false;
- if (local->skip_unlink.opend_fd_count == 0) {
- local->call_cnt = 1;
- STACK_WIND (frame, dht_lookup_unlink_cbk,
+ if (local->skip_unlink.opend_fd_count == 0) {
+
+
+ ret = dht_fill_dict_to_avoid_unlink_of_migrating_file
+ (local->xattr_req);
+
+
+ if (ret) {
+ DHT_STACK_UNWIND (lookup, frame, -1,
+ EIO, NULL, NULL,
+ NULL, NULL);
+ } else {
+ local->call_cnt = 1;
+ STACK_WIND (frame,
+ dht_lookup_unlink_of_false_linkto_cbk,
hashed_subvol,
hashed_subvol->fops->unlink,
- &local->loc, 0, NULL);
+ &local->loc, 0,
+ local->xattr_req);
+ }
+
return 0;
}