summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorXavier Hernandez <jahernan@redhat.com>2017-12-13 17:27:42 +0100
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-12-22 16:19:53 +0000
commit41120aa8bab4ca4496bb37b8986434be404ae255 (patch)
treebf9dc2dc2ad7b426664a78676a99ddcad16d91f7 /xlators
parent3fd961d08588bd1ec31f8cfc72201dfa1a4e85d6 (diff)
cluster/ec: Fix possible shift overflow
A coverity scan has revelaed a potential shift overflow while scanning the bitmap of available subvolumes. The actual overflow cannot happen, but I've changed to test used to control the limit to make it explicit. Change-Id: Ieb55f010bbca68a1d86a93e47822f7c709a26e83 BUG: 789278 Signed-off-by: Xavier Hernandez <jahernan@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/ec/src/ec-common.c6
-rw-r--r--xlators/cluster/ec/src/ec.c7
-rw-r--r--xlators/cluster/ec/src/ec.h9
3 files changed, 12 insertions, 10 deletions
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index eea1e7c7a36..b7088e54724 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -568,7 +568,7 @@ void ec_dispatch_next(ec_fop_data_t * fop, uint32_t idx)
LOCK(&fop->lock);
i = ec_child_next(ec, fop, idx);
- if (i < EC_METHOD_MAX_NODES) {
+ if (i < EC_MAX_NODES) {
idx = i;
fop->remaining ^= 1ULL << idx;
@@ -581,7 +581,7 @@ void ec_dispatch_next(ec_fop_data_t * fop, uint32_t idx)
UNLOCK(&fop->lock);
- if (i < EC_METHOD_MAX_NODES)
+ if (i < EC_MAX_NODES)
{
fop->wind(ec, fop, idx);
}
@@ -708,7 +708,7 @@ void ec_dispatch_min(ec_fop_data_t * fop)
while (count-- > 0)
{
idx = ec_child_next(ec, fop, idx + 1);
- if (idx < EC_METHOD_MAX_NODES)
+ if (idx < EC_MAX_NODES)
mask |= 1ULL << idx;
}
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index c8beb2b56fc..4c80f1283f1 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -31,13 +31,6 @@ static char *ec_read_policies[EC_READ_POLICY_MAX + 1] = {
[EC_READ_POLICY_MAX] = NULL
};
-#define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS
-/* The maximum number of nodes is derived from the maximum allowed fragments
- * using the rule that redundancy cannot be equal or greater than the number
- * of fragments.
- */
-#define EC_MAX_NODES min(EC_MAX_FRAGMENTS * 2 - 1, EC_METHOD_MAX_NODES)
-
#define EC_INTERNAL_XATTR_OR_GOTO(name, xattr, op_errno, label) \
do { \
if (ec_is_internal_xattr (NULL, (char *)name, NULL, NULL)) { \
diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h
index b729fffc274..e2ec9cf04f5 100644
--- a/xlators/cluster/ec/src/ec.h
+++ b/xlators/cluster/ec/src/ec.h
@@ -11,6 +11,8 @@
#ifndef __EC_H__
#define __EC_H__
+#include "ec-method.h"
+
#define EC_XATTR_PREFIX "trusted.ec."
#define EC_XATTR_CONFIG EC_XATTR_PREFIX"config"
#define EC_XATTR_SIZE EC_XATTR_PREFIX"size"
@@ -21,4 +23,11 @@
#define EC_VERSION_SIZE 2
#define EC_SHD_INODE_LRU_LIMIT 10
+#define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS
+/* The maximum number of nodes is derived from the maximum allowed fragments
+ * using the rule that redundancy cannot be equal or greater than the number
+ * of fragments.
+ */
+#define EC_MAX_NODES min(EC_MAX_FRAGMENTS * 2 - 1, EC_METHOD_MAX_NODES)
+
#endif /* __EC_H__ */