From d90b87eed2fa68df5afcebbc54747e96f6d76cfb Mon Sep 17 00:00:00 2001 From: vmallika Date: Thu, 15 Oct 2015 12:41:13 +0530 Subject: quota: add version to quota xattrs When a quota is disable and the clean-up process terminated without completely cleaning-up the quota xattrs. Now when quota is enabled again, this can mess-up the accounting A version number is suffixed for all quota xattrs and this version number is specific to marker xaltor, i.e when quota xattrs are requested by quotad/client marker will remove the version suffix in the key before sending the response Change-Id: I1ca2c11460645edba0f6b68db70d476d8d26e1eb BUG: 1272411 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/12386 Tested-by: NetBSD Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Manikandan Selvaganesh Reviewed-by: Raghavendra G --- xlators/mgmt/glusterd/src/glusterd-quota.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-quota.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index 863c87e40bf..b8efcf12eeb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -1207,8 +1207,7 @@ glusterd_remove_quota_limit (char *volname, char *path, char **op_errstr, } if (type == GF_QUOTA_OPTION_TYPE_REMOVE) { - ret = sys_lremovexattr (abspath, - "trusted.glusterfs.quota.limit-set"); + ret = sys_lremovexattr (abspath, QUOTA_LIMIT_KEY); if (ret) { gf_asprintf (op_errstr, "removexattr failed on %s. " "Reason : %s", abspath, strerror (errno)); @@ -1217,8 +1216,7 @@ glusterd_remove_quota_limit (char *volname, char *path, char **op_errstr, } if (type == GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS) { - ret = sys_lremovexattr (abspath, - "trusted.glusterfs.quota.limit-objects"); + ret = sys_lremovexattr (abspath, QUOTA_LIMIT_OBJECTS_KEY); if (ret) { gf_asprintf (op_errstr, "removexattr failed on %s. " "Reason : %s", abspath, strerror (errno)); @@ -1494,19 +1492,33 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict) goto out; } + + if (GF_QUOTA_OPTION_TYPE_ENABLE == type) + volinfo->quota_version++; + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + if (ret) { + if (GF_QUOTA_OPTION_TYPE_ENABLE == type) + volinfo->quota_version--; + goto out; + } + ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, "Unable to re-create " "volfiles"); + if (GF_QUOTA_OPTION_TYPE_ENABLE == type) { + /* rollback volinfo */ + volinfo->quota_version--; + ret = glusterd_store_volinfo (volinfo, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); + } + ret = -1; goto out; } - ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); - if (ret) - goto out; - if (GLUSTERD_STATUS_STARTED == volinfo->status) { if (priv->op_version == GD_OP_VERSION_MIN) ret = priv->nfs_svc.manager (&(priv->nfs_svc), NULL, 0); -- cgit