From 32b5667f017e3206bd9d3b65074eecb7ddb84244 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Thu, 17 Mar 2016 18:53:13 +0530 Subject: glusterd : skip non directories inside /var/lib/glusterd/vols Right now glusterd won't come up if vols directory contains an invalid entry. Instead of doing that with this change a message will be logged and then skip that entry Backport details: >Change-Id: I665b5c35291b059cf054622da0eec4db44ec5f68 >BUG: 1318591 >Signed-off-by: Jiffin Tony Thottan >Reviewed-on: http://review.gluster.org/13764 >Reviewed-by: Prashanth Pai >Reviewed-by: Atin Mukherjee >Smoke: Gluster Build System >CentOS-regression: Gluster Build System >NetBSD-regression: NetBSD Build System (cherry picked from commit 720b63c24b07ee64e1338db28de602b9abbef0a1) Change-Id: I665b5c35291b059cf054622da0eec4db44ec5f68 BUG: 1365265 Signed-off-by: Jiffin Tony Thottan Reviewed-on: http://review.gluster.org/15113 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Prashanth Pai CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- xlators/mgmt/glusterd/src/glusterd-store.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 8b903ba1e48..8cf3b5d38eb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -3112,6 +3112,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) DIR *dir = NULL; struct dirent *entry = NULL; glusterd_volinfo_t *volinfo = NULL; + struct stat st = {0,}; + char entry_path[PATH_MAX] = {0,}; GF_ASSERT (this); priv = this->private; @@ -3140,6 +3142,22 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) (!strcmp (entry->d_name, "info")))) goto next; + snprintf (entry_path, PATH_MAX, "%s/%s", path, entry->d_name); + ret = sys_lstat (entry_path, &st); + if (ret == -1) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, + "Failed to stat entry %s : %s", path, + strerror (errno)); + goto next; + } + + if (!S_ISDIR (st.st_mode)) { + gf_msg_debug (this->name, 0, "%s is not a vaild volume" + , entry->d_name); + goto next; + } + volinfo = glusterd_store_retrieve_volume (entry->d_name, snap); if (!volinfo) { gf_msg (this->name, GF_LOG_ERROR, 0, -- cgit