diff options
author | Sunny Kumar <sunkumar@redhat.com> | 2018-07-03 16:03:35 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-07-12 04:35:58 +0000 |
commit | b32ad78516a4edf59a4e9c3ef266e3d69f616b83 (patch) | |
tree | fca7ff780ba4b26a653d7924bfe86128420e6b90 /xlators/mgmt | |
parent | e893eb1b23f62477e98e409eaf96941beeb27177 (diff) |
snapshot : remove stale entry
During snap delete after removing brick-path we should remove
snap-path too i.e. /var/run/gluster/snaps/<snap-name>.
During snap deactivate also we should remove snap-path.
Change-Id: Ib80b5d8844d6479d31beafa732e5671b0322248b
fixes: bz#1597662
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 4be89779465..3d984fa3f57 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -2904,6 +2904,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol) glusterd_brickinfo_t *brickinfo = NULL; xlator_t *this = NULL; char brick_dir[PATH_MAX] = ""; + char snap_path[PATH_MAX] = ""; char *tmp = NULL; char *brick_mount_path = NULL; gf_boolean_t is_brick_dir_present = _gf_false; @@ -3075,6 +3076,28 @@ remove_brick_path: brick_dir, strerror (errno)); goto out; } + + /* After removing brick_dir, fetch and remove snap path + * i.e. /var/run/gluster/snaps/<snap-name>. + */ + if (!snap_vol->snapshot) { + gf_msg (this->name, GF_LOG_WARNING, EINVAL, + GD_MSG_INVALID_ENTRY, "snapshot not" + "present in snap_vol"); + ret = -1; + goto out; + } + + snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", + snap_mount_dir, snap_vol->snapshot->snapname); + ret = recursive_rmdir (snap_path); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "Failed to remove " + "%s directory : error : %s", snap_path, + strerror (errno)); + goto out; + } } ret = 0; @@ -6246,6 +6269,7 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr, glusterd_snap_t *snap = NULL; glusterd_volinfo_t *snap_volinfo = NULL; xlator_t *this = NULL; + char snap_path[PATH_MAX] = ""; this = THIS; GF_ASSERT (this); @@ -6304,6 +6328,20 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr, "Failed to unmounts for %s", snap->snapname); } + /*Remove /var/run/gluster/snaps/<snap-name> entry for deactivated snaps. + * This entry will be created again during snap activate. + */ + snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", + snap_mount_dir, snapname); + ret = recursive_rmdir (snap_path); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "Failed to remove " + "%s directory : error : %s", snap_path, + strerror (errno)); + goto out; + } + ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid", uuid_utoa (snap->snap_id)); if (ret) { |