From 52c34af5f4814b0b85efdc3c4d23638b6ca5514c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Sun, 23 Aug 2009 22:35:36 +0000 Subject: performance/stat-prefetch: implement sp_rename. 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 | 13 +++-- .../performance/stat-prefetch/src/stat-prefetch.c | 55 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/doc/stat-prefetch-design.txt b/doc/stat-prefetch-design.txt index 13abc52976a..6328875ac87 100644 --- a/doc/stat-prefetch-design.txt +++ b/doc/stat-prefetch-design.txt @@ -89,9 +89,16 @@ fops to be implemented: * rename 1. remove entry corresponding to oldname from cache stored in fd contexts of - old parent directory. - 2. remove entry corresponding to new parent directory from cache stored in - fd contexts of its parent directory. + oldparent. + 2. remove entry corresponding to newname from cache stored in fd contexts of + newparent. + 3. remove entry corresponding to oldparent from cache stored in + old-grand-parent. + 4. remove entry corresponding to newparent from cache stored in + new-grand-parent. + 5. if oldname happens to be a directory, remove entire cache from all fds + opened on it. + * create/mknod/mkdir/symlink/link Delete entry corresponding to basename of directory in which these operations diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index a5f8dbff79f..c364fa77c56 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1388,6 +1388,60 @@ unwind: } +int32_t +sp_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,loc_t *newloc) +{ + sp_cache_t *cache = NULL; + int32_t ret = -1; + + GF_VALIDATE_OR_GOTO (this->name, oldloc, unwind); + GF_VALIDATE_OR_GOTO (this->name, oldloc->path, unwind); + GF_VALIDATE_OR_GOTO (this->name, oldloc->name, unwind); + GF_VALIDATE_OR_GOTO (this->name, oldloc->parent, unwind); + GF_VALIDATE_OR_GOTO (this->name, oldloc->inode, unwind); + + GF_VALIDATE_OR_GOTO (this->name, newloc, unwind); + GF_VALIDATE_OR_GOTO (this->name, newloc->path, unwind); + GF_VALIDATE_OR_GOTO (this->name, newloc->name, unwind); + GF_VALIDATE_OR_GOTO (this->name, newloc->parent, unwind); + GF_VALIDATE_OR_GOTO (this->name, newloc->inode, unwind); + + cache = sp_get_cache_inode (this, oldloc->parent, frame->root->pid); + if (cache) { + sp_cache_remove_entry (cache, (char *)oldloc->name, 0); + } + + cache = sp_get_cache_inode (this, newloc->parent, frame->root->pid); + if (cache) { + sp_cache_remove_entry (cache, (char *)newloc->name, 0); + } + + ret = sp_cache_remove_parent_entry (frame, this, (char *)oldloc->path); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto unwind; + } + + ret = sp_cache_remove_parent_entry (frame, this, (char *)newloc->path); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto unwind; + } + + if (S_ISDIR (oldloc->inode->st_mode)) { + sp_remove_caches_from_all_fds_opened (this, oldloc->inode); + } + + STACK_WIND (frame, sp_stbuf_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rename, oldloc, newloc); + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, errno, NULL); + return 0; +} + + int32_t sp_forget (xlator_t *this, inode_t *inode) { @@ -1452,6 +1506,7 @@ struct xlator_fops fops = { .readv = sp_readv, .writev = sp_writev, .fsync = sp_fsync, + .rename = sp_rename, }; struct xlator_mops mops = { -- cgit