diff options
| author | Avra Sengupta <asengupt@redhat.com> | 2016-03-11 15:27:30 +0530 | 
|---|---|---|
| committer | Rajesh Joseph <rjoseph@redhat.com> | 2016-04-26 08:58:20 -0700 | 
| commit | 3c5586b3e8772f0a9d25502c9b4474e987ecc656 (patch) | |
| tree | 7a9b81a2ddcbf1ced89b16a59e26d76e15ee63b4 | |
| parent | 8781620900bac22e721d6979b72503737c7ddbc7 (diff) | |
snapshot/quota: Copy quota.cksum during snapshot operations
    Backport of http://review.gluster.org/#/c/13760/
A volume having a quota.conf file, should always have
a quota.cksum file too. Based on this above assumption
modifying glusterd_copy_quota_files() to always copy
quota.cksum, if quota.conf is present.
This change will be reflected when a snapshot is created,
restored and cloned.
Change-Id: Ia49dc26eacef32eeb8f7d7d9553c80e304b08779
BUG: 1329492
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/13760
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
(cherry picked from commit 8f3ad1e3ede77fa5f8c8d606e18a7e83865a822c)
Reviewed-on: http://review.gluster.org/14047
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-messages.h | 8 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 28 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 24 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 1 | 
4 files changed, 40 insertions, 21 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index 8dcbcdb2cd2..cfcd114749b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -4638,6 +4638,14 @@   */  #define GD_MSG_SNAP_RESUME_TIER_FAIL                (GLUSTERD_COMP_BASE + 573) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_FILE_NOT_FOUND                       (GLUSTERD_COMP_BASE + 574) +  /*------------*/  #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"  #endif /* !_GLUSTERD_MESSAGES_H_ */ diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 70c796aff94..e57779caed7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3652,6 +3652,34 @@ glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,                  goto out;          } +        ret = snprintf (src_path, sizeof (src_path), "%s/quota.cksum", +                        src_dir); +        if (ret < 0) +                goto out; + +        /* if quota.conf is present, quota.cksum has to be present. * +         * Fail snapshot operation if file is absent                * +         */ +        ret = sys_lstat (src_path, &stbuf); +        if (ret) { +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        GD_MSG_FILE_NOT_FOUND, "%s not found", src_path); +                goto out; +        } + +        ret = snprintf (dest_path, sizeof (dest_path), "%s/quota.cksum", +                       dest_dir); +        if (ret < 0) +                goto out; + +        ret = glusterd_copy_file (src_path, dest_path); +        if (ret) { +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        GD_MSG_NO_MEMORY, "Failed to copy %s in %s", +                        src_path, dest_path); +                goto out; +        } +          *conf_present = _gf_true;  out:          return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index a1580b6f9b6..e5c5c4c0489 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -9728,6 +9728,9 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,                  goto out;          } +        /* Need not save cksum, as we will copy cksum file in * +         * this function                                           * +         */          ret = glusterd_copy_quota_files (snap_vol, orig_vol, &conf_present);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, 0, @@ -9737,27 +9740,6 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,                  goto out;          } -        if (conf_present) { -                /* TO calculate checksum of quota conf we need to send -                 * second argument as _gf_true -                 */ -                ret = glusterd_compute_cksum (new_volinfo, _gf_true); -                if (ret) { -                        gf_msg (this->name, GF_LOG_ERROR, 0, -                                GD_MSG_CKSUM_COMPUTE_FAIL, "Failed to compute " -                                "checksum for quota conf file"); -                        goto out; -                } - -                ret = glusterd_store_save_quota_version_and_cksum (new_volinfo); -                if (ret) { -                        gf_msg (this->name, GF_LOG_ERROR, 0, -                                GD_MSG_QUOTA_CKSUM_VER_STORE_FAIL, "Failed to " -                                "store quota version and cksum"); -                        goto out; -                } -        } -          /* New volinfo always shows the status as created. Therefore           * set the status to the original volume's status. */          glusterd_set_volume_status (new_volinfo, orig_vol->status); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index f3d2d8665b3..aebfb2c70c7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -634,6 +634,7 @@ glusterd_volinfo_dup (glusterd_volinfo_t *volinfo,          new_volinfo->quota_conf_version = volinfo->quota_conf_version;          new_volinfo->quota_xattr_version = volinfo->quota_xattr_version;          new_volinfo->snap_max_hard_limit = volinfo->snap_max_hard_limit; +        new_volinfo->quota_conf_cksum = volinfo->quota_conf_cksum;          dict_copy (volinfo->dict, new_volinfo->dict);          dict_copy (volinfo->gsync_slaves, new_volinfo->gsync_slaves);  | 
