summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/stat-prefetch-design.txt13
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c55
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
@@ -1389,6 +1389,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)
{
struct stat *buf = NULL;
@@ -1452,6 +1506,7 @@ struct xlator_fops fops = {
.readv = sp_readv,
.writev = sp_writev,
.fsync = sp_fsync,
+ .rename = sp_rename,
};
struct xlator_mops mops = {