summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-02-07 04:30:20 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-07 03:43:27 -0800
commit090a96d0a5963bc62efc3354480e277610cab7e6 (patch)
treecbf1424fe4f065efb78d40978cda924d9226ad7e /xlators/cluster/dht
parentfd4523e667f19cf5c4f3849679aacf41f860a766 (diff)
dht: Remove pointer casting in layout handling
Small changes by Anand Avati <avati@gluster.com> over original submission: Remove pointer casting (copy data to proper memory before using it). Fixes bug #493. Hello, See bug #493 for more information on this patch. http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=493#c2 This patch assumes that the scope of disk_layout is local wherever it is used. Seems correct, not really checked, though. Greetings, Hraban Luyat Signed-off-by: Hraban Luyat <hraban@0brg.net> Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 493 (tcp + dht + armv5tel: ???brick: disk layout has invalid count 29696???) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=493
Diffstat (limited to 'xlators/cluster/dht')
-rw-r--r--xlators/cluster/dht/src/dht-common.h2
-rw-r--r--xlators/cluster/dht/src/dht-layout.c22
2 files changed, 15 insertions, 9 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index ca4a1d33e..53aeaa0f7 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -217,7 +217,7 @@ int dht_layout_merge (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
int dht_disk_layout_extract (xlator_t *this, dht_layout_t *layout,
int pos, int32_t **disk_layout_p);
int dht_disk_layout_merge (xlator_t *this, dht_layout_t *layout,
- int pos, int32_t *disk_layout);
+ int pos, void *disk_layout_raw);
int dht_frame_return (call_frame_t *frame);
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index e43be876a..86d3c4410 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -276,15 +276,18 @@ out:
int
dht_disk_layout_merge (xlator_t *this, dht_layout_t *layout,
- int pos, int32_t *disk_layout)
+ int pos, void *disk_layout_raw)
{
int cnt = 0;
int type = 0;
int start_off = 0;
int stop_off = 0;
+ int disk_layout[4];
/* TODO: assert disk_layout_ptr is of required length */
+ memcpy (disk_layout, disk_layout_raw, sizeof (disk_layout));
+
cnt = ntoh32 (disk_layout[0]);
if (cnt != 1) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -316,7 +319,7 @@ dht_layout_merge (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
int i = 0;
int ret = -1;
int err = -1;
- int32_t *disk_layout = NULL;
+ void *disk_layout_raw = NULL;
if (op_ret != 0) {
@@ -339,7 +342,7 @@ dht_layout_merge (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
if (xattr) {
/* during lookup and not mkdir */
ret = dict_get_ptr (xattr, "trusted.glusterfs.dht",
- VOID(&disk_layout));
+ &disk_layout_raw);
}
if (ret != 0) {
@@ -351,7 +354,7 @@ dht_layout_merge (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
goto out;
}
- ret = dht_disk_layout_merge (this, layout, i, disk_layout);
+ ret = dht_disk_layout_merge (this, layout, i, disk_layout_raw);
if (ret != 0) {
gf_log (this->name, GF_LOG_DEBUG,
"layout merge from subvolume %s failed",
@@ -607,7 +610,8 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
int ret = 0;
int err = 0;
int dict_ret = 0;
- int32_t *disk_layout = NULL;
+ int32_t disk_layout[4];
+ void *disk_layout_raw = NULL;
int32_t count = -1;
uint32_t start_off = -1;
uint32_t stop_off = -1;
@@ -641,8 +645,8 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
}
dict_ret = dict_get_ptr (xattr, "trusted.glusterfs.dht",
- VOID(&disk_layout));
-
+ &disk_layout_raw);
+
if (dict_ret < 0) {
if (err == 0) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -650,7 +654,9 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol,
ret = -1;
}
goto out;
- }
+ }
+
+ memcpy (disk_layout, disk_layout_raw, sizeof (disk_layout));
count = ntoh32 (disk_layout[0]);
if (count != 1) {