summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c28
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h1
6 files changed, 45 insertions, 8 deletions
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);
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index b9991b36c68..6d4fce23463 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1008,6 +1008,12 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
goto out;
}
+ snprintf (buf, sizeof (buf), "%d", volinfo->quota_version);
+ ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_QUOTA_VERSION,
+ buf);
+ if (ret)
+ goto out;
+
ret = glusterd_volume_write_tier_details (fd, volinfo);
ret = glusterd_volume_write_snap_details (fd, volinfo);
@@ -2666,6 +2672,9 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_COLD_TYPE,
strlen (key))) {
volinfo->tier_info.cold_type = atoi (value);
+ } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_QUOTA_VERSION,
+ strlen (GLUSTERD_STORE_KEY_VOL_QUOTA_VERSION))) {
+ volinfo->quota_version = atoi (value);
} else {
if (is_key_glusterd_hooks_friendly (key)) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index fdde2196633..7335c0a8445 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -58,6 +58,7 @@ typedef enum glusterd_store_ver_ac_{
#define GLUSTERD_STORE_KEY_PARENT_VOLNAME "parent_volname"
#define GLUSTERD_STORE_KEY_VOL_OP_VERSION "op-version"
#define GLUSTERD_STORE_KEY_VOL_CLIENT_OP_VERSION "client-op-version"
+#define GLUSTERD_STORE_KEY_VOL_QUOTA_VERSION "quota-version"
#define GLUSTERD_STORE_KEY_COLD_TYPE "cold_type"
#define GLUSTERD_STORE_KEY_COLD_COUNT "cold_count"
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index ff56c9f3f39..06c60f37751 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2489,6 +2489,9 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
snprintf (key, sizeof (key), "%s%d.caps", prefix, count);
ret = dict_set_int32 (dict, key, volinfo->caps);
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "%s%d.quota-version", prefix, count);
+ ret = dict_set_int32 (dict, key, volinfo->quota_version);
out:
GF_FREE (volume_id_str);
GF_FREE (rebalance_id_str);
@@ -3569,6 +3572,11 @@ glusterd_import_volinfo (dict_t *peer_data, int count,
/*This is not present in older glusterfs versions, so ignore ret value*/
ret = dict_get_int32 (peer_data, key, &new_volinfo->caps);
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "%s%d.quota_version", prefix, count);
+ /*This is not present in older glusterfs versions, so ignore ret value*/
+ ret = dict_get_int32 (peer_data, key, &new_volinfo->quota_version);
+
ret = glusterd_import_bricks (peer_data, count, new_volinfo, prefix);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 6c32c9bd980..571b23f3519 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1864,6 +1864,7 @@ brick_graph_add_marker (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
xlator_t *xl = NULL;
char tstamp_file[PATH_MAX] = {0,};
char volume_id[64] = {0,};
+ char buf[32] = {0,};
if (!graph || !volinfo || !set_dict)
goto out;
@@ -1881,6 +1882,11 @@ brick_graph_add_marker (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (ret)
goto out;
+ snprintf (buf, sizeof (buf), "%d", volinfo->quota_version);
+ ret = xlator_set_option (xl, "quota-version", buf);
+ if (ret)
+ goto out;
+
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 2c0012c0399..5beff25c286 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -407,6 +407,7 @@ struct glusterd_volinfo_ {
gd_quorum_status_t quorum_status;
glusterd_snapdsvc_t snapd;
+ int32_t quota_version;
};
typedef enum gd_snap_status_ {