summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-dir-read.c
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-10-29 05:08:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-29 10:17:19 -0700
commitd72c47cb04725c694921e7f3277f6230c26bc936 (patch)
tree2ecc6752d4caed385f629b96d2eb636fbe113401 /xlators/cluster/afr/src/afr-dir-read.c
parent14962ce3e69e452a2447c12cde3369759365fda9 (diff)
cluster/afr: Move deleted files to /.trash in entry self-heal.
If entry self-heal determines that a file/directory should be deleted from a subvolume, move that entry to a directory called "/.trash" on that subvolume. This is for two reasons: 1) It limits the damage that can be done by a "wrong" entry self-heal. 2) It solves the problem of a to-be-deleted directory not being empty. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 227 (replicate selfheal does not remove directory with contents in it) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=227
Diffstat (limited to 'xlators/cluster/afr/src/afr-dir-read.c')
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index 5261243d164..fe1f4dadf73 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -155,6 +155,7 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
xlator_t ** children = NULL;
gf_dirent_t * entry = NULL;
+ gf_dirent_t * tmp = NULL;
int child_index = -1;
@@ -166,10 +167,16 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
child_index = (long) cookie;
if (op_ret != -1) {
- list_for_each_entry (entry, &entries->list, list) {
+ list_for_each_entry_safe (entry, tmp, &entries->list, list) {
entry->d_ino = afr_itransform (entry->d_ino,
priv->child_count,
child_index);
+
+ if ((local->fd->inode == local->fd->inode->table->root)
+ && !strcmp (entry->d_name, AFR_TRASH_DIR)) {
+ list_del_init (&entry->list);
+ FREE (entry);
+ }
}
}
@@ -189,6 +196,7 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ino_t inum = 0;
gf_dirent_t * entry = NULL;
+ gf_dirent_t * tmp = NULL;
int child_index = -1;
@@ -200,13 +208,19 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
child_index = (long) cookie;
if (op_ret != -1) {
- list_for_each_entry (entry, &entries->list, list) {
+ list_for_each_entry_safe (entry, tmp, &entries->list, list) {
inum = afr_itransform (entry->d_ino, priv->child_count,
child_index);
entry->d_ino = inum;
inum = afr_itransform (entry->d_stat.st_ino,
priv->child_count, child_index);
entry->d_stat.st_ino = inum;
+
+ if ((local->fd->inode == local->fd->inode->table->root)
+ && !strcmp (entry->d_name, AFR_TRASH_DIR)) {
+ list_del_init (&entry->list);
+ FREE (entry);
+ }
}
}