From b72bc58ecc108a2fddbdb6f606cd86a57ca5a68f Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 25 Mar 2015 15:04:19 +0530 Subject: features/trash : Notify CTR translator if an unlink happens to a file This implementation is same as the posix_unlink_cbk() where CTR sends a request during a unlink to send the number of links to the inode and posix obliges sending it using the unwind xdata dict. For Trash xlator a unlink is stat + mkdir(if parent is not present) + rename. And hence this is handled in trash_unlink_rename_cbk(). Change-Id: I402e83567b88e3c9fe171379693c82937af567f9 BUG: 1205545 Signed-off-by: Jiffin Tony Thottan Signed-off-by: Joseph Fernandes Signed-off-by: Anoop C S Reviewed-on: http://review.gluster.org/9989 Tested-by: NetBSD Build System Tested-by: Joseph Fernandes Reviewed-by: Joseph Fernandes Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Vijay Bellur --- xlators/storage/posix/src/posix-helpers.c | 3 +++ xlators/storage/posix/src/posix.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'xlators/storage/posix') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index f3d6d6c3da7..e1bd5b127fd 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -409,6 +409,9 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, } else if (fnmatch (marker_contri_key, key, 0) == 0) { ret = _posix_get_marker_quota_contributions (filler, key); + } else if (strcmp(key, CTR_REQUEST_LINK_COUNT_XDATA) == 0) { + ret = dict_set (filler->xattr, + CTR_REQUEST_LINK_COUNT_XDATA, data); } else { ret = _posix_xattr_get_set_from_backend (filler, key); } diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 337f9b95fa2..8cbe2c5a02e 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1652,11 +1652,12 @@ posix_unlink (call_frame_t *frame, xlator_t *this, if (!unwind_dict) { op_ret = 0; gf_log (this->name, GF_LOG_WARNING, - "Failed to creating unwind_dict"); + "Memory allocation failure while " + "creating unwind_dict"); goto out; } - /* Even if unwind_dict fails to set CTR_RESPONSE_LINK_COUNT_XDATA we will - * not mark the FOP unsuccessful + /* Even if unwind_dict fails to set CTR_RESPONSE_LINK_COUNT_XDATA we + * will not mark the FOP unsuccessful * because this dict is only used by CTR Xlator to clear * all records if link count == 0*/ op_ret = dict_set_uint32 (unwind_dict, CTR_RESPONSE_LINK_COUNT_XDATA, @@ -1678,6 +1679,11 @@ out: close (fd); } + /* unref unwind_dict*/ + if (unwind_dict) { + dict_unref (unwind_dict); + } + return 0; } -- cgit