From 6e243d0c8e1f408bb648e1e8bd2d171de408f4b3 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Fri, 9 Dec 2016 15:01:40 +0530 Subject: 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: 1404101 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/16112 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: jiffin tony Thottan NetBSD-regression: NetBSD Build System Reviewed-by: Rajesh Joseph --- .../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 3f9e51e50cf..d1fb849f0f0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3723,6 +3723,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", @@ -3736,19 +3744,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; } @@ -3779,6 +3783,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 -- cgit