summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2016-12-09 15:01:40 +0530
committerRajesh Joseph <rjoseph@redhat.com>2016-12-18 23:21:31 -0800
commit6e243d0c8e1f408bb648e1e8bd2d171de408f4b3 (patch)
tree9b96d6b2d289f172b6ab798efdf4433fed21f471
parent45431070d742ac9398b41efd23c1ea500a639669 (diff)
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 <jenkins@build.gluster.org> > Smoke: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> > Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> (cherry picked from commit 74322ce58b1c949e11cb0aa72bfded0e34422157) Change-Id: Iaff786d9f77a2de1322ce8ccb4b80954f84d3373 BUG: 1404101 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/16112 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c38
1 files 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