From 4bc0fa312f8a64c7ee0f52e5635d7f082454aaa2 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 16 Apr 2012 14:42:56 +0530 Subject: storage/posix: Prevent gfid handle leaks The case which can lead to gfid handle leaks: Self-heal removes directory '/d' with 10 files in it, in brick b1. This dir is renamed to //d'> by posix. Before the janitor thread could remove the directory, self-heal could remove another directory with same path '/d'. Then again the rename to same path is done by posix as before. The gfid-handles of the old '/d', 10 files in it are not unlinked. To prevent such problems, rename the directory to be removed to /. Change-Id: Iad13708e1ebcc5222b64c058aa9a2d372e1bfa5b BUG: 811970 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/3159 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/storage/posix/src/posix.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'xlators/storage') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 5bfaa4214..e18654cc7 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1120,6 +1120,7 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, int32_t op_errno = 0; char * real_path = NULL; char * par_path = NULL; + char * gfid_str = NULL; struct iatt preparent = {0,}; struct iatt postparent = {0,}; struct iatt stbuf; @@ -1159,12 +1160,13 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, } if (flags) { - uint32_t hashval = 0; - char *tmp_path = alloca (strlen (priv->trash_path) + 16); + gfid_str = uuid_utoa (stbuf.ia_gfid); + char *tmp_path = alloca (strlen (priv->trash_path) + + strlen ("/") + + strlen (gfid_str) + 1); mkdir (priv->trash_path, 0755); - hashval = gf_dm_hashfn (real_path, strlen (real_path)); - sprintf (tmp_path, "%s/%u", priv->trash_path, hashval); + sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str); op_ret = rename (real_path, tmp_path); } else { op_ret = rmdir (real_path); -- cgit