diff options
author | Venkatesh Somyajulu <vsomyaju@redhat.com> | 2014-09-10 23:38:02 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2014-10-01 03:35:14 -0700 |
commit | 98e8883787dc6943c4a3fc8282f91a8c73fb0803 (patch) | |
tree | 57020f13b798924ea4893e717945090b78da54cc /xlators | |
parent | 4bff3e0f63b8e5c9dd286f31d52cb5de05eb71b7 (diff) |
storage/posix: Don't unlink .glusterfs-hardlink before linkto check
BUG: 1129541
Change-Id: I90a10ac54123fbd8c7383ddcbd04e8879ae51232
Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com>
Reviewed-on: http://review.gluster.org/8559
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: N Balachandran <nbalacha@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
(cherry picked from commit b23be2e7581c6aa295053dc8866cab841ae374b6)
Signed-off-by: Nithya Balachandran <nbalacha@redhat.com>
Reviewed-on: http://review.gluster.org/8725
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 549a2267d73..605d282d355 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1362,6 +1362,41 @@ out: return 0; } +int32_t +posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path, + struct iatt *stbuf, int32_t *op_errno) +{ + int32_t ret = 0; + + /* Unlink the gfid_handle_first */ + + if (stbuf && stbuf->ia_nlink == 1) { + ret = posix_handle_unset (this, stbuf->ia_gfid, NULL); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "unlink of gfid handle failed for path:%s with" + "gfid %s with errno:%s", real_path, + uuid_utoa (stbuf->ia_gfid), strerror (errno)); + } + } + + /* Unlink the actual file */ + ret = sys_unlink (real_path); + if (ret == -1) { + if (op_errno) + *op_errno = errno; + + gf_log (this->name, GF_LOG_ERROR, + "unlink of %s failed: %s", real_path, + strerror (errno)); + goto err; + } + + return 0; + +err: + return -1; +} int32_t posix_unlink (call_frame_t *frame, xlator_t *this, @@ -1402,9 +1437,6 @@ posix_unlink (call_frame_t *frame, xlator_t *this, goto out; } - if (stbuf.ia_nlink == 1) - posix_handle_unset (this, stbuf.ia_gfid, NULL); - priv = this->private; op_ret = dict_get_int32 (xdata, DHT_SKIP_OPEN_FD_UNLINK, @@ -1489,12 +1521,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, } } - op_ret = sys_unlink (real_path); + op_ret = posix_unlink_gfid_handle_and_entry (this, real_path, &stbuf, + &op_errno); if (op_ret == -1) { - op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "unlink of %s failed: %s", real_path, - strerror (op_errno)); goto out; } |