From 9dbae0c80569689533c92a29871e3fa6dbbae1b9 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 22 Feb 2010 08:59:10 +0000 Subject: dht: unlink stale linkfiles in rmdir to prevent ENOTEMPTY Thanks to He Xaobing , this patch is inspired by http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=188#c2 Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati 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 --- xlators/cluster/dht/src/dht-helper.c | 46 +++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/dht/src/dht-helper.c') 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; +} -- cgit