summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-layout.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-10-04 22:15:57 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-05 02:48:14 -0700
commit6658fdde8f6e328e232d9d40067df8ae4b16e8b2 (patch)
tree20159c078f04c9aa5886685883d81aa30cea43f1 /xlators/cluster/dht/src/dht-layout.c
parent372ed08f25da2eb7e09f27685cb1773b88c62173 (diff)
distribute: check for 'conf' before dereferencing it
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1806 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1806
Diffstat (limited to 'xlators/cluster/dht/src/dht-layout.c')
-rw-r--r--xlators/cluster/dht/src/dht-layout.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index a9ecc587483..a11b78f8d06 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -72,6 +72,9 @@ dht_layout_get (xlator_t *this, inode_t *inode)
int ret = -1;
conf = this->private;
+ if (!conf)
+ goto out;
+
LOCK (&conf->layout_lock);
{
ret = inode_ctx_get (inode, this, &layout_int);
@@ -82,6 +85,7 @@ dht_layout_get (xlator_t *this, inode_t *inode)
}
UNLOCK (&conf->layout_lock);
+out:
return layout;
}
@@ -96,6 +100,9 @@ dht_layout_set (xlator_t *this, inode_t *inode, dht_layout_t *layout)
uint64_t old_layout_int;
conf = this->private;
+ if (!conf)
+ goto out;
+
LOCK (&conf->layout_lock);
{
oldret = inode_ctx_get (inode, this, &old_layout_int);
@@ -111,6 +118,7 @@ dht_layout_set (xlator_t *this, inode_t *inode, dht_layout_t *layout)
dht_layout_unref (this, old_layout);
}
+out:
return ret;
}
@@ -121,10 +129,11 @@ dht_layout_unref (xlator_t *this, dht_layout_t *layout)
dht_conf_t *conf = NULL;
int ref = 0;
- if (layout->preset)
+ if (layout->preset || !this->private)
return;
conf = this->private;
+
LOCK (&conf->layout_lock);
{
ref = --layout->ref;
@@ -141,7 +150,7 @@ dht_layout_ref (xlator_t *this, dht_layout_t *layout)
{
dht_conf_t *conf = NULL;
- if (layout->preset)
+ if (layout->preset || !this->private)
return layout;
conf = this->private;
@@ -197,8 +206,9 @@ dht_layout_for_subvol (xlator_t *this, xlator_t *subvol)
dht_layout_t *layout = NULL;
int i = 0;
-
conf = this->private;
+ if (!conf)
+ goto out;
for (i = 0; i < conf->subvolume_cnt; i++) {
if (conf->subvolumes[i] == subvol) {
@@ -207,6 +217,7 @@ dht_layout_for_subvol (xlator_t *this, xlator_t *subvol)
}
}
+out:
return layout;
}
@@ -217,7 +228,9 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)
dht_layout_t *layout = NULL;
int i = 0;
int ret = -1;
-
+
+ if (!conf)
+ goto out;
conf->file_layouts = GF_CALLOC (conf->subvolume_cnt,
sizeof (dht_layout_t *),
@@ -691,6 +704,8 @@ dht_layout_preset (xlator_t *this, xlator_t *subvol, inode_t *inode)
dht_conf_t *conf = NULL;
conf = this->private;
+ if (!conf)
+ goto out;
layout = dht_layout_for_subvol (this, subvol);
if (!layout) {