From 7b8e82f80942b862f30d3fb72c7eecb23fcae226 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 17 Mar 2016 22:44:12 +0530 Subject: features/trash: Handle unexpected errors during mkdir When expected directory hierarchy in not present in trash directory, trash translator tries to create it inside the same. Any errors from posix other than the expected ones should be handled properly during an internal mkdir call and logged accordingly explaining the reason for not moving the file to trash directory. Change-Id: I4e19637138ea4fb92f9301be372ac19542a6aed8 BUG: 1318757 Signed-off-by: Anoop C S Reviewed-on: http://review.gluster.org/13771 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: jiffin tony Thottan --- xlators/features/trash/src/trash.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'xlators/features/trash/src') diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 1381e8b049d..4b0e6741d9a 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -669,6 +669,17 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } } + if ((op_ret == -1) && (op_errno != EEXIST)) { + gf_log (this->name, GF_LOG_ERROR, "Directory creation failed [%s]. " + "Therefore unlinking %s without moving to trash " + "directory", strerror(op_errno), local->loc.name); + STACK_WIND (frame, trash_common_unwind_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, &local->loc, 0, + xdata); + goto out; + } + LOCK (&frame->lock); { loop_count = ++local->loop_count; @@ -1456,6 +1467,18 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } } + if ((op_ret == -1) && (op_errno != EEXIST)) { + gf_log (this->name, GF_LOG_ERROR, "Directory creation failed [%s]. " + "Therefore truncating %s without moving the " + "original copy to trash directory", + strerror(op_errno), local->loc.name); + STACK_WIND (frame, trash_common_unwind_buf_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->truncate, &local->loc, + local->fop_offset, xdata); + goto out; + } + LOCK (&frame->lock); { loop_count = ++local->loop_count; -- cgit