diff options
author | Raghavendra G <raghavendra@gluster.com> | 2013-05-17 12:52:32 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-08-11 11:09:11 +0000 |
commit | cfa33b224f58053bbbcbc46865fca70621a59f05 (patch) | |
tree | 6e40f74ab1199d46f75322b9e07deccea943a0fc | |
parent | 27571cf3cdc83b609bcabf7d0459d61e29abf681 (diff) |
performance/io-cache: update inode contexts of each entry in readdirplus
io-cache stores read-cache in inode which is currently created only in
lookup. But, with readdirplus and md-cache absorbing lookups, io-cache
need not receive a lookup before a fop like readv.
>Change-Id: I6eba995b0a90d4d5055a4aef0489707b852da1b8
>BUG: 1474180
>Signed-off-by: Raghavendra G <raghavendra@gluster.com>
>Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
>Reviewed-on: https://review.gluster.org/5029
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
(cherry picked from commit b90e12134af85635199750967c326761d6c06e86)
Change-Id: I6eba995b0a90d4d5055a4aef0489707b852da1b8
BUG: 1475638
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: https://review.gluster.org/17891
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 96 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.h | 6 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/ioc-inode.c | 4 |
3 files changed, 67 insertions, 39 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index df247c2318a..10bb8936311 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -172,38 +172,20 @@ ioc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, } int32_t -ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *stbuf, dict_t *xdata, struct iatt *postparent) +ioc_inode_update (xlator_t *this, inode_t *inode, char *path, + struct iatt *iabuf) { - ioc_inode_t *ioc_inode = NULL; - ioc_table_t *table = NULL; - uint8_t cache_still_valid = 0; - uint64_t tmp_ioc_inode = 0; - uint32_t weight = 0xffffffff; - const char *path = NULL; - ioc_local_t *local = NULL; - - if (op_ret != 0) - goto out; + ioc_table_t *table = NULL; + uint64_t tmp_ioc_inode = 0; + ioc_inode_t *ioc_inode = NULL; + uint32_t weight = 0xffffffff; + gf_boolean_t cache_still_valid = _gf_false; - local = frame->local; - if (local == NULL) { - op_ret = -1; - op_errno = EINVAL; + if (!this || !inode) goto out; - } - - if (!this || !this->private) { - op_ret = -1; - op_errno = EINVAL; - goto out; - } table = this->private; - path = local->file_loc.path; - LOCK (&inode->lock); { __inode_ctx_get (inode, this, &tmp_ioc_inode); @@ -212,7 +194,7 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (!ioc_inode) { weight = ioc_get_priority (table, path); - ioc_inode = ioc_inode_update (table, inode, + ioc_inode = ioc_inode_create (table, inode, weight); __inode_ctx_put (inode, this, @@ -224,16 +206,15 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ioc_inode_lock (ioc_inode); { if (ioc_inode->cache.mtime == 0) { - ioc_inode->cache.mtime = stbuf->ia_mtime; - ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec; + ioc_inode->cache.mtime = iabuf->ia_mtime; + ioc_inode->cache.mtime_nsec = iabuf->ia_mtime_nsec; } - ioc_inode->ia_size = stbuf->ia_size; + ioc_inode->ia_size = iabuf->ia_size; } ioc_inode_unlock (ioc_inode); - cache_still_valid = ioc_cache_still_valid (ioc_inode, - stbuf); + cache_still_valid = ioc_cache_still_valid (ioc_inode, iabuf); if (!cache_still_valid) { ioc_inode_flush (ioc_inode); @@ -247,6 +228,36 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ioc_table_unlock (ioc_inode->table); out: + return 0; +} + + +int32_t +ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *stbuf, dict_t *xdata, struct iatt *postparent) +{ + ioc_local_t *local = NULL; + + if (op_ret != 0) + goto out; + + local = frame->local; + if (local == NULL) { + op_ret = -1; + op_errno = EINVAL; + goto out; + } + + if (!this || !this->private) { + op_ret = -1; + op_errno = EINVAL; + goto out; + } + + ioc_inode_update (this, inode, (char *)local->file_loc.path, stbuf); + +out: if (frame->local != NULL) { local = frame->local; loc_wipe (&local->file_loc); @@ -510,7 +521,7 @@ ioc_get_priority (ioc_table_t *table, const char *path) uint32_t priority = 1; struct ioc_priority *curr = NULL; - if (list_empty(&table->priority_list)) + if (list_empty(&table->priority_list) || !path) return priority; priority = 0; @@ -647,7 +658,7 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* assign weight */ weight = ioc_get_priority (table, path); - ioc_inode = ioc_inode_update (table, inode, weight); + ioc_inode = ioc_inode_create (table, inode, weight); ioc_inode_lock (ioc_inode); { @@ -734,7 +745,7 @@ ioc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* assign weight */ weight = ioc_get_priority (table, path); - ioc_inode = ioc_inode_update (table, inode, weight); + ioc_inode = ioc_inode_create (table, inode, weight); ioc_inode_lock (ioc_inode); { @@ -1404,12 +1415,22 @@ ioc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata) { gf_dirent_t *entry = NULL; + char *path = NULL; + fd_t *fd = NULL; + + if (frame) { + fd = frame->local; + frame->local = NULL; + } if (op_ret <= 0) goto unwind; list_for_each_entry (entry, &entries->list, list) { - /* TODO: fill things */ + inode_path (fd->inode, entry->d_name, &path); + ioc_inode_update (this, entry->inode, path, &entry->d_stat); + GF_FREE (path); + path = NULL; } unwind: @@ -1417,10 +1438,13 @@ unwind: return 0; } + int ioc_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset, dict_t *dict) { + frame->local = fd; + STACK_WIND (frame, ioc_readdirp_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, fd, size, offset, dict); diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h index d7c823fe962..50008ef7004 100644 --- a/xlators/performance/io-cache/src/io-cache.h +++ b/xlators/performance/io-cache/src/io-cache.h @@ -300,8 +300,12 @@ ioc_inode_search (ioc_table_t *table, inode_t *inode); void ioc_inode_destroy (ioc_inode_t *ioc_inode); +int32_t +ioc_inode_update (xlator_t *this, inode_t *inode, char *path, + struct iatt *iabuf); + ioc_inode_t * -ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight); +ioc_inode_create (ioc_table_t *table, inode_t *inode, uint32_t weight); int64_t __ioc_page_destroy (ioc_page_t *page); diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index 6eb34124d1f..f8653fae6aa 100644 --- a/xlators/performance/io-cache/src/ioc-inode.c +++ b/xlators/performance/io-cache/src/ioc-inode.c @@ -165,7 +165,7 @@ out: /* - * ioc_inode_update - create a new ioc_inode_t structure and add it to + * ioc_inode_create - create a new ioc_inode_t structure and add it to * the table table. fill in the fields which are derived * from inode_t corresponding to the file * @@ -175,7 +175,7 @@ out: * not for external reference */ ioc_inode_t * -ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight) +ioc_inode_create (ioc_table_t *table, inode_t *inode, uint32_t weight) { ioc_inode_t *ioc_inode = NULL; |