From 080af56a02aeec20899ecbc7202a8d293378c1f9 Mon Sep 17 00:00:00 2001 From: Sakshi Bansal Date: Thu, 4 Feb 2016 16:02:59 +0530 Subject: dht: mkdir must unwind with latest ctime Currently fops like mkdir used the the ctime it gets after creating the directory entry. But setting layout also updates the ctime of a directory. Hence DHT must get the ctime after the setxattr call and unwind with the latest ctime to avoid mismatch in time seen by applications like tar. Backport of http://review.gluster.org/#/c/13352/ > Change-Id: Iecbbe3aac5244af5da9788b48ccf299ca56b4bae > BUG: 1302948 > Signed-off-by: Sakshi Bansal > Reviewed-on: http://review.gluster.org/13352 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Raghavendra G BUG: 1312721 Change-Id: Ie09342d3705b40ce98b2935f05ad4402f74ba069 Signed-off-by: Sakshi Bansal Reviewed-on: http://review.gluster.org/13536 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- xlators/cluster/dht/src/dht-common.c | 6 ++++++ xlators/cluster/dht/src/dht-selfheal.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'xlators') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index f8fba8e9d31..fc7b272d51c 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -203,6 +203,7 @@ dht_lookup_selfheal_cbk (call_frame_t *frame, void *cookie, ret = dht_layout_set (this, local->inode, layout); } + dht_inode_ctx_time_update (local->inode, this, &local->stbuf, 1); if (local->loc.parent) { dht_inode_ctx_time_update (local->loc.parent, this, &local->postparent, 1); @@ -710,6 +711,8 @@ unlock: dht_layout_set (this, local->inode, layout); } + dht_inode_ctx_time_update (local->inode, this, + &local->stbuf, 1); if (local->loc.parent) { dht_inode_ctx_time_update (local->loc.parent, this, &local->postparent, 1); @@ -6490,6 +6493,9 @@ dht_mkdir_selfheal_cbk (call_frame_t *frame, void *cookie, if (op_ret == 0) { dht_layout_set (this, local->inode, layout); + + dht_inode_ctx_time_update (local->inode, this, + &local->stbuf, 1); if (local->loc.parent) { dht_inode_ctx_time_update (local->loc.parent, this, &local->preparent, 0); diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 5d034b91720..73e3782dedc 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -612,7 +612,9 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, dht_local_t *local = NULL; call_frame_t *prev = NULL; xlator_t *subvol = NULL; + struct iatt *stbuf = NULL; int i = 0; + int ret = 0; dht_layout_t *layout = NULL; int err = 0; int this_call_cnt = 0; @@ -627,6 +629,12 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else err = op_errno; + ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **) &stbuf); + if (ret < 0) { + gf_msg_debug (this->name, 0, "key = %s not present in dict", + DHT_IATT_IN_XDATA_KEY); + } + for (i = 0; i < layout->cnt; i++) { if (layout->list[i].xlator == subvol) { layout->list[i].err = err; @@ -634,6 +642,7 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } } + dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); this_call_cnt = dht_frame_return (frame); if (is_last_call (this_call_cnt)) { @@ -693,6 +702,15 @@ dht_selfheal_dir_xattr_persubvol (call_frame_t *frame, loc_t *loc, goto err; } + ret = dict_set_dynstr_with_alloc (xdata, DHT_IATT_IN_XDATA_KEY, "yes"); + if (ret < 0) { + gf_msg (this->name, GF_LOG_WARNING, 0, DHT_MSG_DICT_SET_FAILED, + "%s: Failed to set dictionary value: key = %s," + " gfid = %s", loc->path, + DHT_IATT_IN_XDATA_KEY, gfid); + goto err; + } + gf_uuid_unparse(loc->inode->gfid, gfid); ret = dht_disk_layout_extract (this, layout, i, &disk_layout); -- cgit