Blob Blame History Raw
From c64009585671a2191d5144252af921c1d6bfec7b Mon Sep 17 00:00:00 2001
From: Raghavendra G <raghavendra@gluster.com>
Date: Fri, 17 May 2013 12:52:32 +0530
Subject: [PATCH 575/576] 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: 1473229
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>
Reviewed-on: https://code.engineering.redhat.com/gerrit/113631
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/performance/io-cache/src/io-cache.c  | 96 +++++++++++++++++-----------
 xlators/performance/io-cache/src/io-cache.h  |  6 +-
 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 9de6ee1..120a033 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -173,38 +173,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);
@@ -213,7 +195,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,
@@ -225,16 +207,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);
@@ -248,6 +229,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);
@@ -511,7 +522,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;
@@ -648,7 +659,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);
                 {
@@ -735,7 +746,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);
                 {
@@ -1405,12 +1416,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:
@@ -1418,10 +1439,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 d7c823f..50008ef 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 6eb3412..f8653fa 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;
 
-- 
1.8.3.1