From 9746ee75865162af1827337f22a553ea0c3ba2ed Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Tue, 29 Mar 2016 19:06:46 +0530 Subject: features/changelog: Don't modify 'pargfid' in 'resolve_pargfid_to_path' If 'changelog' is enabled and 'changelog.capture-del-path' option is on it calls 'resolve_pargfid_to_path' which modifies 'pargfid' sent by caller. 'changelog_unlink' calls this routine directly with 'loc->pargfid' resulting it being modified and point to root instead of actual pargfid. This is a nasty bug and could cause the deletion of entry on root directory instead on actual parent when 'loc->path' is not present. Hence this fix to make 'pargfid' a const pointer and 'resolve_pargfid' to work on copy of pargfid. Glusterfind session creation enables these options by default to capture deleted entry path in changelog. Thanks Pranith for root causing this. Change-Id: I1d275a86f91c981b6889bedef93401c039d01d71 BUG: 1321955 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/13845 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Venky Shankar Reviewed-by: Ravishankar N CentOS-regression: Gluster Build System --- xlators/features/changelog/src/changelog-helpers.c | 4 +++- xlators/features/changelog/src/changelog-helpers.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 5783aaf3e29..6d3b99c6cdc 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -1910,7 +1910,7 @@ err: */ int -resolve_pargfid_to_path (xlator_t *this, uuid_t pargfid, +resolve_pargfid_to_path (xlator_t *this, const uuid_t pgfid, char **path, char *bname) { char *linkname = NULL; @@ -1920,6 +1920,7 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t pargfid, ssize_t len = 0; int ret = 0; uuid_t tmp_gfid = {0, }; + uuid_t pargfid = {0, }; changelog_priv_t *priv = NULL; char gpath[PATH_MAX] = {0,}; char result[PATH_MAX] = {0,}; @@ -1930,6 +1931,7 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t pargfid, priv = this->private; GF_ASSERT (priv); + gf_uuid_copy (pargfid, pgfid); if (!path || gf_uuid_is_null (pargfid)) { ret = -1; goto out; diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index df307382d34..70e6f60f30c 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -504,7 +504,8 @@ changelog_inode_ctx_t * __changelog_inode_ctx_get (xlator_t *, inode_t *, unsigned long **, unsigned long *, changelog_log_type); int -resolve_pargfid_to_path (xlator_t *this, uuid_t gfid, char **path, char *bname); +resolve_pargfid_to_path (xlator_t *this, const uuid_t gfid, char **path, + char *bname); /* macros */ -- cgit