cf62f1947f
Resolves: bz#1264911 bz#1277924 bz#1286820 bz#1360331 bz#1401969 Resolves: bz#1410719 bz#1419438 bz#1426042 bz#1444820 bz#1459101 Resolves: bz#1464150 bz#1464350 bz#1466122 bz#1466129 bz#1467903 Resolves: bz#1468972 bz#1476876 bz#1484446 bz#1492591 bz#1498391 Resolves: bz#1498730 bz#1499865 bz#1500704 bz#1501345 bz#1505570 Resolves: bz#1507361 bz#1507394 bz#1509102 bz#1509191 bz#1509810 Resolves: bz#1509833 bz#1511766 bz#1512470 bz#1512496 bz#1512963 Resolves: bz#1515051 bz#1519076 bz#1519740 bz#1534253 bz#1534530 Signed-off-by: Milind Changire <mchangir@redhat.com>
156 lines
5.9 KiB
Diff
156 lines
5.9 KiB
Diff
From a9310d6e4c9990020ff76f5b815bc99b5703f17e Mon Sep 17 00:00:00 2001
|
|
From: Sanoj Unnikrishnan <sunnikri@redhat.com>
|
|
Date: Wed, 8 Nov 2017 16:18:56 +0530
|
|
Subject: [PATCH 123/128] quota: fixes issue in quota.conf when setting large
|
|
number of limits
|
|
|
|
Problem: It was not possible to configure more than 7712 quota limits.
|
|
This was because a stack buffer of size 131072 was used to read from
|
|
quota.conf file. In the new format of quota.conf file each gfid entry
|
|
takes 17bytes (16byte gfid + 1 byte type). So, the buf_size was not a
|
|
multiple of gfid entry size and as per code this was considered as
|
|
corruption.
|
|
|
|
Solution: make buf size a multiple of gfid entry size
|
|
|
|
> Change-Id: Id036225505a47a4f6fa515a572ee7b0c958f30ed
|
|
> BUG: 1510940
|
|
> Patch: https://review.gluster.org/#/c/18695/
|
|
|
|
BUG: 1511766
|
|
Change-Id: Id036225505a47a4f6fa515a572ee7b0c958f30ed
|
|
Signed-off-by: Sanoj Unnikrishnan <sunnikri@redhat.com>
|
|
Reviewed-on: https://code.engineering.redhat.com/gerrit/124647
|
|
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
---
|
|
xlators/mgmt/glusterd/src/glusterd-quota.c | 45 ++++++++++++++++++++++--------
|
|
1 file changed, 33 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
|
|
index fc34042..1c3a801 100644
|
|
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
|
|
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
|
|
@@ -907,24 +907,31 @@ out:
|
|
}
|
|
|
|
/* The function glusterd_copy_to_tmp_file() reads the "remaining" bytes from
|
|
- * the source fd and writes them to destination fd, at the rate of 128K bytes
|
|
- * of read+write at a time.
|
|
+ * the source fd and writes them to destination fd, at the rate of 1000 entries
|
|
+ * a time (qconf_line_sz is the size of an entry)
|
|
*/
|
|
|
|
static int
|
|
-glusterd_copy_to_tmp_file (int src_fd, int dst_fd)
|
|
+glusterd_copy_to_tmp_file (int src_fd, int dst_fd, int qconf_line_sz)
|
|
{
|
|
int ret = 0;
|
|
- size_t entry_sz = 131072;
|
|
ssize_t bytes_read = 0;
|
|
- unsigned char buf[131072] = {0,};
|
|
xlator_t *this = NULL;
|
|
+ unsigned char *buf = 0;
|
|
+ int buf_sz = qconf_line_sz * 1000;
|
|
|
|
this = THIS;
|
|
GF_ASSERT (this);
|
|
+ GF_ASSERT (buf_sz > 0);
|
|
|
|
- while ((bytes_read = sys_read (src_fd, (void *)&buf, entry_sz)) > 0) {
|
|
- if (bytes_read % 16 != 0) {
|
|
+ buf = GF_CALLOC(buf_sz, 1, gf_common_mt_char);
|
|
+ if (!buf) {
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ while ((bytes_read = sys_read (src_fd, buf, buf_sz)) > 0) {
|
|
+ if (bytes_read % qconf_line_sz != 0) {
|
|
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
GD_MSG_QUOTA_CONF_CORRUPT, "quota.conf "
|
|
"corrupted");
|
|
@@ -942,6 +949,8 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd)
|
|
ret = 0;
|
|
|
|
out:
|
|
+ if (buf)
|
|
+ GF_FREE(buf);
|
|
return ret;
|
|
}
|
|
|
|
@@ -1034,7 +1043,6 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
|
|
int conf_fd = -1;
|
|
ssize_t bytes_read = 0;
|
|
size_t bytes_to_write = 0;
|
|
- unsigned char buf[131072] = {0,};
|
|
uuid_t gfid = {0,};
|
|
xlator_t *this = NULL;
|
|
gf_boolean_t found = _gf_false;
|
|
@@ -1045,6 +1053,8 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
|
|
float version = 0.0f;
|
|
char type = 0;
|
|
int quota_conf_line_sz = 16;
|
|
+ unsigned char *buf = 0;
|
|
+ int buf_sz = 0;
|
|
|
|
this = THIS;
|
|
GF_ASSERT (this);
|
|
@@ -1098,6 +1108,14 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
|
|
if (conf->op_version >= GD_OP_VERSION_3_7_0)
|
|
quota_conf_line_sz++;
|
|
|
|
+ buf_sz = quota_conf_line_sz * 1000;
|
|
+
|
|
+ buf = GF_CALLOC(buf_sz, 1, gf_common_mt_char);
|
|
+ if (!buf) {
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
fd = gf_store_mkstemp (volinfo->quota_conf_shandle);
|
|
if (fd < 0) {
|
|
ret = -1;
|
|
@@ -1129,7 +1147,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
|
|
type = GF_QUOTA_CONF_TYPE_USAGE;
|
|
|
|
for (;;) {
|
|
- bytes_read = sys_read (conf_fd, (void *)&buf, sizeof (buf));
|
|
+ bytes_read = sys_read (conf_fd, buf, buf_sz);
|
|
if (bytes_read <= 0) {
|
|
/*The flag @is_first_read is TRUE when the loop is
|
|
* entered, and is set to false if the first read
|
|
@@ -1166,7 +1184,8 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
|
|
* Else continue with the search.
|
|
*/
|
|
if (found) {
|
|
- ret = glusterd_copy_to_tmp_file (conf_fd, fd);
|
|
+ ret = glusterd_copy_to_tmp_file (conf_fd, fd,
|
|
+ quota_conf_line_sz);
|
|
if (ret)
|
|
goto out;
|
|
break;
|
|
@@ -1238,6 +1257,9 @@ out:
|
|
sys_close (conf_fd);
|
|
}
|
|
|
|
+ if (buf)
|
|
+ GF_FREE(buf);
|
|
+
|
|
if (ret && (fd > 0)) {
|
|
gf_store_unlink_tmppath (volinfo->quota_conf_shandle);
|
|
} else if (!ret && GF_QUOTA_OPTION_TYPE_UPGRADE != opcode) {
|
|
@@ -1260,8 +1282,7 @@ out:
|
|
"store quota version and cksum");
|
|
}
|
|
}
|
|
-
|
|
- return ret;
|
|
+ return ret;
|
|
}
|
|
|
|
int32_t
|
|
--
|
|
1.8.3.1
|
|
|