summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-08-23 22:31:53 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-08 01:42:11 -0700
commit1a2db6ed799d9ce05232422f5d5094da4fd5c35c (patch)
treebbedd58968c97d84d3b553bd195d6bd018dd7020
parent29c282b1605afe6d6016660e21018e1954ce0a79 (diff)
performance/stat-prefetch: implement sp_rmdir.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 221 (stat prefetch implementation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221
-rw-r--r--doc/stat-prefetch-design.txt2
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c55
2 files changed, 57 insertions, 0 deletions
diff --git a/doc/stat-prefetch-design.txt b/doc/stat-prefetch-design.txt
index 65f1b9227..13abc5297 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 c89d1fd47..b61769650 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 = {