From 1a2db6ed799d9ce05232422f5d5094da4fd5c35c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Sun, 23 Aug 2009 22:31:53 +0000 Subject: performance/stat-prefetch: implement sp_rmdir. Signed-off-by: Anand V. Avati BUG: 221 (stat prefetch implementation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221 --- doc/stat-prefetch-design.txt | 2 + .../performance/stat-prefetch/src/stat-prefetch.c | 55 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/doc/stat-prefetch-design.txt b/doc/stat-prefetch-design.txt index 65f1b922705..13abc52976a 100644 --- a/doc/stat-prefetch-design.txt +++ b/doc/stat-prefetch-design.txt @@ -66,6 +66,8 @@ fops to be implemented: fds opened on parent inode. 2. Remove the entire cache from all fds opened on inode corresponding to directory being removed. + 3. Delete the entry correspondig to basename of parent from cache stored in + grand-parent. * readv Delete the entry corresponding to basename from cache stored in context of fds diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index c89d1fd4781..b61769650a1 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1216,6 +1216,60 @@ unwind: } +void +sp_remove_caches_from_all_fds_opened (xlator_t *this, inode_t *inode) +{ + fd_t *fd = NULL; + sp_cache_t *cache = NULL; + + LOCK (&inode->lock); + { + list_for_each_entry (fd, &inode->fd_list, inode_list) { + cache = sp_get_cache_fd (this, fd); + if (cache) { + sp_cache_remove_entry (cache, NULL, 1); + } + } + } + UNLOCK (&inode->lock); +} + + +int32_t +sp_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +{ + sp_cache_t *cache = NULL; + int32_t ret = -1; + + GF_VALIDATE_OR_GOTO (this->name, loc, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc->name, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc->path, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc->inode, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc->parent, unwind); + + sp_remove_caches_from_all_fds_opened (this, loc->inode); + + cache = sp_get_cache_inode (this, loc->parent, frame->root->pid); + if (cache) { + sp_cache_remove_entry (cache, (char *)loc->name, 0); + } + + ret = sp_cache_remove_parent_entry (frame, this, (char *)loc->path); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto unwind; + } + + STACK_WIND (frame, sp_err_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rmdir, loc); + return 0; + +unwind: + STACK_UNWIND (frame, -1, errno); + return 0; +} + + int32_t sp_forget (xlator_t *this, inode_t *inode) { @@ -1276,6 +1330,7 @@ struct xlator_fops fops = { .utimens = sp_utimens, .readlink = sp_readlink, .unlink = sp_unlink, + .rmdir = sp_rmdir, }; struct xlator_mops mops = { -- cgit