From f91d19a9ce6ec6659c84c3f907ebc3ecaceba176 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 12 Jan 2015 12:50:50 +0530 Subject: storage/posix: Set gfid after all xattrs, uid/gid are set Problem: When a new entry is created gfid is set even before uid/gid, xattrs are set on the entry. This can lead to dht/afr healing that file/dir with the uid/gid it sees just after the gfid is set, i.e. root/root. Sometimes setattr/setxattr are failing on that file/dir. Fix: Set gfid of the file/directory only after uid/gid, xattrs are setup properly. Readdirp, lookup either wait for the gfid to be assigned to the entry or not update the in-memory inode ctx in posix-acl xlator which was producing lot EACCESS/EPERM to the application or dht/afr self-heals. Change-Id: I0a6ced579daabe3452f5a85010a00ca6e8579451 BUG: 1088649 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/9434 Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Shyamsundar Ranganathan Reviewed-by: Raghavendra Bhat --- xlators/storage/posix/src/posix.c | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'xlators') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 72c219784bd..b4be2e4317f 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1146,14 +1146,6 @@ real_op: entry_created = _gf_true; - op_ret = posix_gfid_set (this, real_path, loc, xdata); - if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting gfid on %s failed", real_path); - } else { - gfid_set = _gf_true; - } - #ifndef HAVE_SET_FSID op_ret = lchown (real_path, frame->root->uid, gid); if (op_ret == -1) { @@ -1190,6 +1182,14 @@ ignore: strerror (errno)); } + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { + gf_log (this->name, GF_LOG_ERROR, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; + } + op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; @@ -1326,14 +1326,6 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, entry_created = _gf_true; - op_ret = posix_gfid_set (this, real_path, loc, xdata); - if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting gfid on %s failed", real_path); - } else { - gfid_set = _gf_true; - } - #ifndef HAVE_SET_FSID op_ret = chown (real_path, frame->root->uid, gid); if (op_ret == -1) { @@ -1358,6 +1350,14 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, strerror (errno)); } + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { + gf_log (this->name, GF_LOG_ERROR, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; + } + op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; @@ -1753,14 +1753,6 @@ posix_symlink (call_frame_t *frame, xlator_t *this, entry_created = _gf_true; - op_ret = posix_gfid_set (this, real_path, loc, xdata); - if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting gfid on %s failed", real_path); - } else { - gfid_set = _gf_true; - } - #ifndef HAVE_SET_FSID op_ret = lchown (real_path, frame->root->uid, gid); if (op_ret == -1) { @@ -1793,6 +1785,14 @@ ignore: strerror (errno)); } + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { + gf_log (this->name, GF_LOG_ERROR, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; + } + op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; @@ -2289,14 +2289,6 @@ posix_create (call_frame_t *frame, xlator_t *this, if (was_present) goto fill_stat; - op_ret = posix_gfid_set (this, real_path, loc, xdata); - if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting gfid on %s failed", real_path); - } else { - gfid_set = _gf_true; - } - #ifndef HAVE_SET_FSID op_ret = chown (real_path, frame->root->uid, gid); if (op_ret == -1) { @@ -2329,6 +2321,14 @@ ignore: } fill_stat: + op_ret = posix_gfid_set (this, real_path, loc, xdata); + if (op_ret) { + gf_log (this->name, GF_LOG_ERROR, + "setting gfid on %s failed", real_path); + } else { + gfid_set = _gf_true; + } + op_ret = posix_fdstat (this, _fd, &stbuf); if (op_ret == -1) { op_errno = errno; -- cgit