From 59def4a06265b5aac4e5df331caf7d913cbd7f72 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Fri, 9 Dec 2016 15:01:40 +0530 Subject: [PATCH 238/246] snapshot/ganesha: Copy export.conf, only if ganesha.enable is on. Status of the volume being exported via nfs ganesha, should be checked by checking if ganesha.enable is set or not, rather than deciding based on the errno of the stat > Reviewed-on: http://review.gluster.org/16094 > CentOS-regression: Gluster Build System > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: jiffin tony Thottan > Reviewed-by: Rajesh Joseph (cherry picked from commit 74322ce58b1c949e11cb0aa72bfded0e34422157) Change-Id: Iaff786d9f77a2de1322ce8ccb4b80954f84d3373 BUG: 1402774 Signed-off-by: Avra Sengupta Reviewed-on: https://code.engineering.redhat.com/gerrit/92781 Reviewed-by: Jiffin Thottan Reviewed-by: Atin Mukherjee --- .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 81b9aa0..4a3a2f7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3722,6 +3722,14 @@ glusterd_copy_nfs_ganesha_file (glusterd_volinfo_t *src_vol, GF_VALIDATE_OR_GOTO (this->name, src_vol, out); GF_VALIDATE_OR_GOTO (this->name, dest_vol, out); + if (glusterd_check_ganesha_export(src_vol) == _gf_false) { + gf_msg_debug (this->name, 0, "%s is not exported via " + "NFS-Ganesha. Skipping copy of export conf.", + src_vol->volname); + ret = 0; + goto out; + } + if (src_vol->is_snap_volume) { GLUSTERD_GET_SNAP_DIR (snap_dir, src_vol->snapshot, priv); ret = snprintf (src_path, PATH_MAX, "%s/export.%s.conf", @@ -3735,19 +3743,15 @@ glusterd_copy_nfs_ganesha_file (glusterd_volinfo_t *src_vol, ret = sys_lstat (src_path, &stbuf); if (ret) { - /* * - * If export file is not present, volume is not exported - * via ganesha. So it is not necessary to copy that during - * snapshot. - */ - if (errno == ENOENT) { - ret = 0; - gf_msg_debug (this->name, 0, "%s not found", src_path); - } else - gf_msg (this->name, GF_LOG_WARNING, errno, - GD_MSG_FILE_OP_FAILED, - "Stat on %s failed with %s", - src_path, strerror (errno)); + /* + * This code path is hit, only when the src_vol is being * + * exported via NFS-Ganesha. So if the conf file is not * + * available, we fail the snapshot operation. * + */ + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_FILE_OP_FAILED, + "Stat on %s failed with %s", + src_path, strerror (errno)); goto out; } @@ -3778,6 +3782,14 @@ glusterd_copy_nfs_ganesha_file (glusterd_volinfo_t *src_vol, src = fopen (src_path, "r"); dest = fopen (dest_path, "w"); + if (!src || !dest) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_FILE_OP_FAILED, + "Failed to open %s", + dest ? src_path : dest_path); + goto out; + } + /* * * if the source volume is snapshot, the export conf file * consists of orginal volname -- 2.9.3