From 4c630a77e1325349adb369f9a7c83557007eda56 Mon Sep 17 00:00:00 2001 From: vmallika Date: Fri, 22 May 2015 14:04:31 +0530 Subject: quota: quota.conf backward compatibility fix This is a backport of http://review.gluster.org/#/c/10889/ > In release-3.7 the format of quota.conf is changed. > There is a backward compatibility issues during upgrade > 1) There can be an issue when peer sync between node-3.6 and node-3.7 > 2) If the user sets/removes limit, there is will different format of > file in node-3.6 and node-3.7 > > This patch fixes the issue: > 1) restrict the user to execute command quota enable, limit-usage, remove > 2) write quota.conf in older format if op-version is less than 3.6 > > Change-Id: Ib76f5a0a85394642159607a105cacda743e7d26b > BUG: 1223739 > Signed-off-by: vmallika > Reviewed-on: http://review.gluster.org/10889 > Tested-by: NetBSD Build System > Reviewed-by: Krishnan Parthasarathi Change-Id: I3d5075b96de1e125d30b0f6045389573aaaaecdb BUG: 1226153 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/10985 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- libglusterfs/src/quota-common-utils.c | 51 ----------------------------------- libglusterfs/src/quota-common-utils.h | 8 ++---- 2 files changed, 2 insertions(+), 57 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c index 97965b09947..012f80fab48 100644 --- a/libglusterfs/src/quota-common-utils.c +++ b/libglusterfs/src/quota-common-utils.c @@ -176,57 +176,6 @@ out: return ret; } -int32_t -quota_conf_write_header (int fd) -{ - int header_len = 0; - int ret = 0; - - header_len = strlen (QUOTA_CONF_HEADER); - - ret = gf_nwrite (fd, QUOTA_CONF_HEADER, header_len); - if (ret != header_len) { - ret = -1; - goto out; - } - - ret = 0; - -out: - if (ret < 0) - gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to write " - "header to a quota conf"); - - return ret; -} - -int32_t -quota_conf_write_gfid (int fd, void *buf, char type) -{ - int ret = 0; - - ret = gf_nwrite (fd, buf, 16); - if (ret != 16) { - ret = -1; - goto out; - } - - ret = gf_nwrite (fd, &type, 1); - if (ret != 1) { - ret = -1; - goto out; - } - - ret = 0; - -out: - if (ret < 0) - gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to write " - "gfid %s to a quota conf", uuid_utoa (buf)); - - return ret; -} - int32_t quota_conf_read_gfid (int fd, void *buf, char *type, float version) { diff --git a/libglusterfs/src/quota-common-utils.h b/libglusterfs/src/quota-common-utils.h index e80c74cba72..2c3632b903c 100644 --- a/libglusterfs/src/quota-common-utils.h +++ b/libglusterfs/src/quota-common-utils.h @@ -16,6 +16,8 @@ #define GF_QUOTA_CONF_VERSION 1.2 #define QUOTA_CONF_HEADER \ "GlusterFS Quota conf | version: v1.2\n" +#define QUOTA_CONF_HEADER_1_1 \ + "GlusterFS Quota conf | version: v1.1\n" typedef enum { GF_QUOTA_CONF_TYPE_USAGE = 1, @@ -51,12 +53,6 @@ quota_conf_read_header (int fd, char *buf); int32_t quota_conf_read_version (int fd, float *version); -int32_t -quota_conf_write_header (int fd); - -int32_t -quota_conf_write_gfid (int fd, void *buf, char type); - int32_t quota_conf_read_gfid (int fd, void *buf, char *type, float version); -- cgit