diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-03-24 03:46:08 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-03-24 21:53:31 +0530 |
commit | 4e5c297d7c3480d0d3ab1c0c2a184c6a4fb801ef (patch) | |
tree | 65d75f1cbe324bf8f56c7cd376389520f2631ef4 /xlators/storage | |
parent | 6e8017479fd9997ae47e7c8cbb74247d7e2b4fd0 (diff) |
fix to rm of large file blocking other operations on the same directory containing file (ref: rt #779)2.0.0rc7
posix_unlink follows the below procedure to avoid client noticing delay during
unlink of large file
1. open file
2. unlink file
3. stack_unwind
4. close file
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 534db05fdbe..c20c7fec454 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -853,6 +853,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this, int32_t op_ret = -1; int32_t op_errno = 0; char * real_path = NULL; + int32_t fd = -1; DECLARE_OLD_FS_ID_VAR; @@ -863,6 +864,15 @@ posix_unlink (call_frame_t *frame, xlator_t *this, SET_FS_ID (frame->root->uid, frame->root->gid); MAKE_REAL_PATH (real_path, this, loc->path); + fd = open (real_path, O_RDONLY); + if (fd == -1) { + op_ret = -1; + op_errno = errno; + gf_log (this->name, GF_LOG_WARNING, + "open of %s failed: %s", loc->path, strerror (op_errno)); + goto out; + } + op_ret = unlink (real_path); if (op_ret == -1) { op_errno = errno; @@ -876,8 +886,13 @@ posix_unlink (call_frame_t *frame, xlator_t *this, out: SET_TO_OLD_FS_ID (); frame->root->rsp_refs = NULL; + STACK_UNWIND (frame, op_ret, op_errno); + if (fd != -1) { + close (fd); + } + return 0; } |