diff options
| author | Susant Palai <spalai@redhat.com> | 2018-01-18 13:06:12 +0530 |
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-02-06 14:33:30 +0000 |
| commit | a6aaf29d57274c452de057cb8d7b4bf4da0466b1 (patch) | |
| tree | 40c8f167a5e7428f8fa8345d56a6d30dd4ce60e9 /xlators/cluster/dht/src/dht-inode-write.c | |
| parent | 0e6e25ae9e11a15771da796eff211ef1f1c43684 (diff) | |
cluster/dht: avoid overwriting client writes during migration
For more details on this issue see
https://github.com/gluster/glusterfs/issues/308
Solution:
This is a restrictive solution where a file will not be migrated
if a client writes to it during the migration. This does not
check if the writes from the rebalance and the client actually
do overlap.
If dht_writev_cbk finds that the file is being migrated (PHASE1)
it will set an xattr on the destination file indicating the file
was updated by a non-rebalance client.
Rebalance checks if any other client has written to the dst file
and aborts the file migration if it finds the xattr.
updates gluster/glusterfs#308
Change-Id: I73aec28bc9dbb8da57c7425ec88c6b6af0fbc9dd
Signed-off-by: Susant Palai <spalai@redhat.com>
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Signed-off-by: N Balachandran <nbalacha@redhat.com>
(cherry picked from commit 545a7ce6762a1b3a7b989b43a9d18b5b1b299df0)
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
| -rw-r--r-- | xlators/cluster/dht/src/dht-inode-write.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index 7c596b1c099..226ee95e8b3 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -95,6 +95,33 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* Check if the rebalance phase1 is true */ if (IS_DHT_MIGRATION_PHASE1 (postbuf)) { + if (!dht_is_tier_xlator (this)) { + if (!local->xattr_req) { + local->xattr_req = dict_new (); + if (!local->xattr_req) { + gf_msg (this->name, GF_LOG_ERROR, + DHT_MSG_NO_MEMORY, + ENOMEM, "insufficient memory"); + local->op_errno = ENOMEM; + local->op_ret = -1; + goto out; + } + } + + ret = dict_set_uint32 (local->xattr_req, + GF_PROTECT_FROM_EXTERNAL_WRITES, + 1); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, + DHT_MSG_DICT_SET_FAILED, 0, + "Failed to set key %s in dictionary", + GF_PROTECT_FROM_EXTERNAL_WRITES); + local->op_errno = ENOMEM; + local->op_ret = -1; + goto out; + } + } + dht_iatt_merge (this, &local->stbuf, postbuf, NULL); dht_iatt_merge (this, &local->prebuf, prebuf, NULL); @@ -146,7 +173,6 @@ dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) return 0; } - if (subvol == NULL) goto out; |
