diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2014-09-15 11:57:43 +0200 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-09-19 03:02:47 -0700 |
commit | f32378b660dab5f3f311da8252969a7da16898f4 (patch) | |
tree | 5314df4ba69ac7e0e600f867e9e95dbae0759e1a /xlators/cluster | |
parent | c788a7784d8526b72714d60bac6e1e09ae985a84 (diff) |
ec: Fix some size_t vars to 64 bits even on 32 bits machines
The 64 bits 'trusted.ec.size' extended attribute was incorrectly
computed on 32 bits machines due to an overflow on negative
numbers.
Also changed some potentially dangerous uses of size_t in other
places.
Change-Id: Id76cfe49a2f350e564b5c71d8c8644fb9ce86662
BUG: 1125312
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/8738
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r-- | xlators/cluster/ec/src/ec-combine.c | 7 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-common.c | 2 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-data.h | 18 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-generic.c | 4 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.c | 6 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.h | 4 |
6 files changed, 20 insertions, 21 deletions
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c index 02b7e6024fd..0fa5ac068de 100644 --- a/xlators/cluster/ec/src/ec-combine.c +++ b/xlators/cluster/ec/src/ec-combine.c @@ -108,7 +108,7 @@ int32_t ec_iatt_combine(struct iatt * dst, struct iatt * src, int32_t count) void ec_iatt_rebuild(ec_t * ec, struct iatt * iatt, int32_t count, int32_t answers) { - size_t blocks; + uint64_t blocks; while (count-- > 0) { @@ -285,11 +285,10 @@ int32_t ec_dict_data_concat(const char * fmt, ec_cbk_data_t * cbk, int32_t which, char * key, ...) { data_t * data[cbk->count]; - size_t len, tmp; char * str = NULL, * pre = NULL, * sep, * post; dict_t * dict; va_list args; - int32_t i, num, prelen, postlen, seplen; + int32_t i, num, len, prelen, postlen, seplen, tmp; int32_t ret = -1; num = cbk->count; @@ -589,7 +588,7 @@ int32_t ec_dict_combine(ec_cbk_data_t * cbk, int32_t which) int32_t ec_vector_compare(struct iovec * dst_vector, int32_t dst_count, struct iovec * src_vector, int32_t src_count) { - size_t dst_size = 0, src_size = 0; + int32_t dst_size = 0, src_size = 0; if (dst_count > 0) { diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index ad04e646d68..6d4855a9656 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -1141,7 +1141,7 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie, } void ec_update_size_version(ec_fop_data_t * fop, uint64_t version, - size_t size) + uint64_t size) { dict_t * dict; uid_t uid; diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h index cf9ce241adb..71f047a9aba 100644 --- a/xlators/cluster/ec/src/ec-data.h +++ b/xlators/cluster/ec/src/ec-data.h @@ -181,8 +181,8 @@ struct _ec_fop_data int32_t locked; ec_lock_link_t locks[2]; int32_t have_size; - size_t pre_size; - size_t post_size; + uint64_t pre_size; + uint64_t post_size; gf_lock_t lock; uint32_t flags; @@ -198,14 +198,14 @@ struct _ec_fop_data ec_cbk_t cbks; void * data; - size_t user_size; - size_t head; + uint64_t user_size; + uint32_t head; dict_t * xdata; dict_t * dict; int32_t int32; uint32_t uint32; - size_t size; + uint64_t size; off_t offset; mode_t mode[2]; entrylk_cmd entrylk_cmd; @@ -238,7 +238,7 @@ struct _ec_cbk_data dict_t * dict; int32_t int32; uintptr_t uintptr[3]; - size_t size; + uint64_t size; uint64_t version; inode_t * inode; fd_t * fd; @@ -264,10 +264,10 @@ struct _ec_heal uintptr_t good; uintptr_t bad; uintptr_t open; - off_t offset; - size_t size; + uint64_t offset; + uint64_t size; uint64_t version; - size_t raw_size; + uint64_t raw_size; }; ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c index 4aa02903969..162cb901814 100644 --- a/xlators/cluster/ec/src/ec-generic.c +++ b/xlators/cluster/ec/src/ec-generic.c @@ -705,7 +705,7 @@ void ec_lookup_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk) ec_lock_t * lock = NULL; data_t * data = NULL; uint8_t * buff = NULL; - size_t size = 0; + uint64_t size = 0; int32_t i = 0, have_size = 0; if (cbk->op_ret < 0) @@ -745,7 +745,7 @@ void ec_lookup_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk) cbk->iatt[0].ia_size = size; } - size = SIZE_MAX; + size = UINT64_MAX; for (i = 0, ans = cbk; (ans != NULL) && (i < ec->fragments); ans = ans->next) { diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 22889337cbc..181a6f7b41a 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -579,9 +579,9 @@ ec_fd_t * ec_fd_get(fd_t * fd, xlator_t * xl) return ctx; } -size_t ec_adjust_offset(ec_t * ec, off_t * offset, int32_t scale) +uint32_t ec_adjust_offset(ec_t * ec, off_t * offset, int32_t scale) { - size_t head, tmp; + off_t head, tmp; tmp = *offset; head = tmp % ec->stripe_size; @@ -596,7 +596,7 @@ size_t ec_adjust_offset(ec_t * ec, off_t * offset, int32_t scale) return head; } -size_t ec_adjust_size(ec_t * ec, size_t size, int32_t scale) +uint64_t ec_adjust_size(ec_t * ec, uint64_t size, int32_t scale) { size += ec->stripe_size - 1; size -= size % ec->stripe_size; diff --git a/xlators/cluster/ec/src/ec-helpers.h b/xlators/cluster/ec/src/ec-helpers.h index 6625ade4b08..3010ea856de 100644 --- a/xlators/cluster/ec/src/ec-helpers.h +++ b/xlators/cluster/ec/src/ec-helpers.h @@ -53,7 +53,7 @@ ec_inode_t * ec_inode_get(inode_t * inode, xlator_t * xl); ec_fd_t * __ec_fd_get(fd_t * fd, xlator_t * xl); ec_fd_t * ec_fd_get(fd_t * fd, xlator_t * xl); -size_t ec_adjust_offset(ec_t * ec, off_t * offset, int32_t scale); -size_t ec_adjust_size(ec_t * ec, size_t size, int32_t scale); +uint32_t ec_adjust_offset(ec_t * ec, off_t * offset, int32_t scale); +uint64_t ec_adjust_size(ec_t * ec, uint64_t size, int32_t scale); #endif /* __EC_HELPERS_H__ */ |