diff options
author | Susant Palai <spalai@redhat.com> | 2018-01-18 13:06:12 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2018-02-02 15:24:38 +0000 |
commit | 545a7ce6762a1b3a7b989b43a9d18b5b1b299df0 (patch) | |
tree | 0f2c3015697553914cb520dbda107f3843521f53 /xlators/storage/posix/src/posix-entry-ops.c | |
parent | d9f773ba719397c12860f494a8cd38109e4b2fe3 (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>
Diffstat (limited to 'xlators/storage/posix/src/posix-entry-ops.c')
-rw-r--r-- | xlators/storage/posix/src/posix-entry-ops.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 4d7ed5be7c8..41d8c873b4c 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -180,6 +180,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this, int32_t nlink_samepgfid = 0; struct posix_private *priv = NULL; posix_inode_ctx_t *ctx = NULL; + int ret = 0; VALIDATE_OR_GOTO (frame, out); VALIDATE_OR_GOTO (this, out); @@ -248,6 +249,17 @@ posix_lookup (call_frame_t *frame, xlator_t *this, if (xdata && (op_ret == 0)) { xattr = posix_xattr_fill (this, real_path, loc, NULL, -1, xdata, &buf); + + if (dict_get (xdata, GF_CLEAN_WRITE_PROTECTION)) { + ret = sys_lremovexattr (real_path, + GF_PROTECT_FROM_EXTERNAL_WRITES); + if (ret == -1 && (errno != ENODATA && errno != ENOATTR)) + gf_msg (this->name, GF_LOG_ERROR, + P_MSG_XATTR_NOT_REMOVED, errno, + "removexattr failed. key %s path %s", + GF_PROTECT_FROM_EXTERNAL_WRITES, + loc->path); + } } if (priv->update_pgfid_nlinks) { |