From 4e5c297d7c3480d0d3ab1c0c2a184c6a4fb801ef Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 24 Mar 2009 03:46:08 -0700 Subject: fix to rm of large file blocking other operations on the same directory containing file (ref: rt #779) 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 --- xlators/storage/posix/src/posix.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } -- cgit