diff options
author | Avra Sengupta <asengupt@redhat.com> | 2016-12-09 15:01:40 +0530 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2016-12-12 03:59:43 -0800 |
commit | 74322ce58b1c949e11cb0aa72bfded0e34422157 (patch) | |
tree | 8a7fdad8199d17cdd4f15e36d5590ef97afc36d7 /xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | |
parent | 6c6c9cd284f7aaf9c07c000abc60d71013862afd (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
Change-Id: Iaff786d9f77a2de1322ce8ccb4b80954f84d3373
BUG: 1402828
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
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>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 38 |
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 |