summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-helper.c
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-02-22 08:59:10 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-22 06:45:32 -0800
commit9dbae0c80569689533c92a29871e3fa6dbbae1b9 (patch)
treef9037310ab6005eec07965ba72fe8f1e954c115a /xlators/cluster/dht/src/dht-helper.c
parent96ed73c1556da79e0a58cf1c051471a9b322b05b (diff)
dht: unlink stale linkfiles in rmdir to prevent ENOTEMPTY
Thanks to He Xaobing <allreol@gmail.com>, this patch is inspired by http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=188#c2 Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 188 ([ glusterfs 2.0.6rc2 ] - "Directory not empty" on rm -rf) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=188
Diffstat (limited to 'xlators/cluster/dht/src/dht-helper.c')
-rw-r--r--xlators/cluster/dht/src/dht-helper.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 9816c1784cd..5a89ba58489 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -139,7 +139,7 @@ dht_local_wipe (xlator_t *this, dht_local_t *local)
fd_unref (local->fd);
local->fd = NULL;
}
-
+
if (local->xattr_req)
dict_unref (local->xattr_req);
@@ -184,6 +184,7 @@ basestr (const char *str)
return basestr;
}
+
xlator_t *
dht_first_up_subvol (xlator_t *this)
{
@@ -192,7 +193,7 @@ dht_first_up_subvol (xlator_t *this)
int i = 0;
conf = this->private;
-
+
LOCK (&conf->subvolume_lock);
{
for (i = 0; i < conf->subvolume_cnt; i++) {
@@ -203,10 +204,11 @@ dht_first_up_subvol (xlator_t *this)
}
}
UNLOCK (&conf->subvolume_lock);
-
+
return child;
}
+
xlator_t *
dht_subvol_get_hashed (xlator_t *this, loc_t *loc)
{
@@ -343,3 +345,41 @@ dht_stat_merge (xlator_t *this, struct stat *to,
return 0;
}
+
+
+int
+dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
+{
+ if (!child) {
+ goto err;
+ }
+
+ if (strcmp (parent->path, "/") == 0)
+ asprintf ((char **)&child->path, "/%s", name);
+ else
+ asprintf ((char **)&child->path, "%s/%s", parent->path, name);
+
+ if (!child->path) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory");
+ goto err;
+ }
+
+ child->name = strrchr (child->path, '/');
+ if (child->name)
+ child->name++;
+
+ child->parent = inode_ref (parent->inode);
+ child->inode = inode_new (parent->inode->table);
+
+ if (!child->inode) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory");
+ goto err;
+ }
+
+ return 0;
+err:
+ loc_wipe (child);
+ return -1;
+}