diff options
| author | Raghavendra G <raghavendra@gluster.com> | 2009-08-23 22:36:17 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2009-09-08 01:42:39 -0700 | 
| commit | 26be5dc52d771b37d4e9da8814111448e4e68148 (patch) | |
| tree | 09805a809045e55fa62eb02098f758159ef7227e | |
| parent | 155e6342d4f72d3be500510277b0808859ae2d2c (diff) | |
performance/stat-prefetch: flush stat corresponding to directory being read in readdir
- delete the entry corresponding to basename of path on which fd is opened
   from cache stored in parent. This is necessary because readdir changes
   st_atime.
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.txt | 8 | ||||
| -rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 17 | 
2 files changed, 22 insertions, 3 deletions
diff --git a/doc/stat-prefetch-design.txt b/doc/stat-prefetch-design.txt index 46bb3699d21..d10f841e69d 100644 --- a/doc/stat-prefetch-design.txt +++ b/doc/stat-prefetch-design.txt @@ -29,9 +29,11 @@ fops to be implemented:    the directory contents.  * readdir -  Cache the direntries returned in readdir_cbk in the context of fd. If the  -  readdir is happening on non-expected offsets (means a seekdir/rewinddir  -  has happened), cache has to be flushed. +  1. Cache the direntries returned in readdir_cbk in the context of fd. +  2. If the readdir is happening on non-expected offsets (means a seekdir/rewinddir  +     has happened), cache has to be flushed. +  3. Delete the entry corresponding to basename of path on which fd is opened  +     from cache stored in parent.  * chmod/fchmod    Delete the entry corresponding to basename from cache stored in context of diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 78de50159f0..961b74f330d 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -630,6 +630,8 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,  {          sp_cache_t *cache    = NULL;          sp_local_t *local    = NULL; +        char       *path     = NULL; +        int32_t     ret      = -1;          cache = sp_get_cache_fd (this, fd);          if (cache) { @@ -641,6 +643,17 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,                  }          } +        ret = inode_path (fd->inode, NULL, &path); +        if (ret == -1) { +                goto unwind; +        } +   +        ret = sp_cache_remove_parent_entry (frame, this, path); +        if (ret < 0) { +                errno = -ret; +                goto unwind; +        } +          local = CALLOC (1, sizeof (*local));          if (local) {                  local->fd = fd; @@ -651,6 +664,10 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,                      FIRST_CHILD(this)->fops->readdir, fd, size, off);          return 0; + +unwind: +        SP_STACK_UNWIND (frame, -1, errno, NULL); +        return 0;  }  | 
