From a432e7bc80dee70a48ccc5f04f5574cdce18a3a5 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Wed, 27 Jul 2016 15:49:25 +0530 Subject: posix: Do not move and recreate .glusterfs/unlink directory Problem: At the time of start of a volume, it is checked if .glusterfs/unlink exist or not. If it does, move it to landfill and recreate unlink directory. If a volume is mounted and we write data on it till we face ENOSPC, restart of that volume fails as it will not be able to create unlink dir. mkdir will fail with ENOSPC. This will not allow volume to restart. Solution: If .glusterfs/unlink directory exist, don't move it to landfill. Delete all the entries inside it. Change-Id: Icde3fb36012f2f01aeb119a2da042f761203c11f BUG: 1360679 Signed-off-by: Ashish Pandey Reviewed-on: http://review.gluster.org/15030 Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/storage/posix/src/posix.c | 69 ++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'xlators/storage/posix/src') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 0598b9525df..65b28dc8d21 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifndef GF_BSD_HOST_OS #include @@ -6673,6 +6674,61 @@ out: return ret; } +int32_t +posix_delete_unlink_entry (const char *fpath, const struct stat *sb, + int typeflag, struct FTW *ftwbuf) { + + int ret = 0; + + if (!fpath) + goto out; + + switch (typeflag) { + case FTW_SL: + case FTW_NS: + case FTW_F: + case FTW_SLN: + ret = sys_unlink(fpath); + break; + case FTW_D: + case FTW_DP: + case FTW_DNR: + if (ftwbuf->level != 0) { + ret = sys_rmdir(fpath); + } + break; + default: + break; + } + if (ret) { + gf_msg ("posix_delete_unlink_entry", GF_LOG_WARNING, errno, + P_MSG_HANDLE_CREATE, + "Deletion of entries %s failed" + "Please delete it manually", + fpath); + } +out: + return 0; +} + +int32_t +posix_delete_unlink (const char *unlink_path) { + + int ret = -1; + int flags = 0; + + flags |= (FTW_DEPTH | FTW_PHYS); + + ret = nftw(unlink_path, posix_delete_unlink_entry, 2, flags); + if (ret) { + gf_msg ("posix_delete_unlink", GF_LOG_ERROR, 0, + P_MSG_HANDLE_CREATE, + "Deleting files from %s failed", + unlink_path); + } + return ret; +} + int32_t posix_create_unlink_dir (xlator_t *this) { @@ -6714,15 +6770,8 @@ posix_create_unlink_dir (xlator_t *this) { unlink_path); return -1; } - ret = sys_rename (unlink_path, landfill_path); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, errno, - P_MSG_HANDLE_CREATE, - "Can not delete directory %s ", - unlink_path); - return -1; - } - break; + ret = posix_delete_unlink (unlink_path); + return 0; default: break; } @@ -6738,8 +6787,6 @@ posix_create_unlink_dir (xlator_t *this) { return 0; } - - /** * init - */ -- cgit