21ab4e
From c64009585671a2191d5144252af921c1d6bfec7b Mon Sep 17 00:00:00 2001
21ab4e
From: Raghavendra G <raghavendra@gluster.com>
21ab4e
Date: Fri, 17 May 2013 12:52:32 +0530
21ab4e
Subject: [PATCH 575/576] performance/io-cache: update inode contexts of each
21ab4e
 entry in readdirplus
21ab4e
21ab4e
io-cache stores read-cache in inode which is currently created only in
21ab4e
lookup. But, with readdirplus and md-cache absorbing lookups, io-cache
21ab4e
need not receive a lookup before a fop like readv.
21ab4e
21ab4e
Change-Id: I6eba995b0a90d4d5055a4aef0489707b852da1b8
21ab4e
BUG: 1473229
21ab4e
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
21ab4e
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
21ab4e
Reviewed-on: https://review.gluster.org/5029
21ab4e
Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/113631
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/performance/io-cache/src/io-cache.c  | 96 +++++++++++++++++-----------
21ab4e
 xlators/performance/io-cache/src/io-cache.h  |  6 +-
21ab4e
 xlators/performance/io-cache/src/ioc-inode.c |  4 +-
21ab4e
 3 files changed, 67 insertions(+), 39 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
21ab4e
index 9de6ee1..120a033 100644
21ab4e
--- a/xlators/performance/io-cache/src/io-cache.c
21ab4e
+++ b/xlators/performance/io-cache/src/io-cache.c
21ab4e
@@ -173,38 +173,20 @@ ioc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
21ab4e
 }
21ab4e
 
21ab4e
 int32_t
21ab4e
-ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
-                int32_t op_ret,	int32_t op_errno, inode_t *inode,
21ab4e
-                struct iatt *stbuf, dict_t *xdata, struct iatt *postparent)
21ab4e
+ioc_inode_update (xlator_t *this, inode_t *inode, char *path,
21ab4e
+                  struct iatt *iabuf)
21ab4e
 {
21ab4e
-        ioc_inode_t *ioc_inode         = NULL;
21ab4e
-        ioc_table_t *table             = NULL;
21ab4e
-        uint8_t      cache_still_valid = 0;
21ab4e
-        uint64_t     tmp_ioc_inode     = 0;
21ab4e
-        uint32_t     weight            = 0xffffffff;
21ab4e
-        const char  *path              = NULL;
21ab4e
-        ioc_local_t *local             = NULL;
21ab4e
-
21ab4e
-        if (op_ret != 0)
21ab4e
-                goto out;
21ab4e
+        ioc_table_t  *table             = NULL;
21ab4e
+        uint64_t      tmp_ioc_inode     = 0;
21ab4e
+        ioc_inode_t  *ioc_inode         = NULL;
21ab4e
+        uint32_t      weight            = 0xffffffff;
21ab4e
+        gf_boolean_t  cache_still_valid = _gf_false;
21ab4e
 
21ab4e
-        local = frame->local;
21ab4e
-        if (local == NULL) {
21ab4e
-                op_ret = -1;
21ab4e
-                op_errno = EINVAL;
21ab4e
+        if (!this || !inode)
21ab4e
                 goto out;
21ab4e
-        }
21ab4e
-
21ab4e
-        if (!this || !this->private) {
21ab4e
-                op_ret = -1;
21ab4e
-                op_errno = EINVAL;
21ab4e
-                goto out;
21ab4e
-        }
21ab4e
 
21ab4e
         table = this->private;
21ab4e
 
21ab4e
-        path = local->file_loc.path;
21ab4e
-
21ab4e
         LOCK (&inode->lock);
21ab4e
         {
21ab4e
                 __inode_ctx_get (inode, this, &tmp_ioc_inode);
21ab4e
@@ -213,7 +195,7 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
                 if (!ioc_inode) {
21ab4e
                         weight = ioc_get_priority (table, path);
21ab4e
 
21ab4e
-                        ioc_inode = ioc_inode_update (table, inode,
21ab4e
+                        ioc_inode = ioc_inode_create (table, inode,
21ab4e
                                                       weight);
21ab4e
 
21ab4e
                         __inode_ctx_put (inode, this,
21ab4e
@@ -225,16 +207,15 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
         ioc_inode_lock (ioc_inode);
21ab4e
         {
21ab4e
                 if (ioc_inode->cache.mtime == 0) {
21ab4e
-                        ioc_inode->cache.mtime = stbuf->ia_mtime;
21ab4e
-                        ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec;
21ab4e
+                        ioc_inode->cache.mtime = iabuf->ia_mtime;
21ab4e
+                        ioc_inode->cache.mtime_nsec = iabuf->ia_mtime_nsec;
21ab4e
                 }
21ab4e
 
21ab4e
-                ioc_inode->ia_size = stbuf->ia_size;
21ab4e
+                ioc_inode->ia_size = iabuf->ia_size;
21ab4e
         }
21ab4e
         ioc_inode_unlock (ioc_inode);
21ab4e
 
21ab4e
-        cache_still_valid = ioc_cache_still_valid (ioc_inode,
21ab4e
-                                                   stbuf);
21ab4e
+        cache_still_valid = ioc_cache_still_valid (ioc_inode, iabuf);
21ab4e
 
21ab4e
         if (!cache_still_valid) {
21ab4e
                 ioc_inode_flush (ioc_inode);
21ab4e
@@ -248,6 +229,36 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
         ioc_table_unlock (ioc_inode->table);
21ab4e
 
21ab4e
 out:
21ab4e
+        return 0;
21ab4e
+}
21ab4e
+
21ab4e
+
21ab4e
+int32_t
21ab4e
+ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
+                int32_t op_ret,	int32_t op_errno, inode_t *inode,
21ab4e
+                struct iatt *stbuf, dict_t *xdata, struct iatt *postparent)
21ab4e
+{
21ab4e
+        ioc_local_t *local             = NULL;
21ab4e
+
21ab4e
+        if (op_ret != 0)
21ab4e
+                goto out;
21ab4e
+
21ab4e
+        local = frame->local;
21ab4e
+        if (local == NULL) {
21ab4e
+                op_ret = -1;
21ab4e
+                op_errno = EINVAL;
21ab4e
+                goto out;
21ab4e
+        }
21ab4e
+
21ab4e
+        if (!this || !this->private) {
21ab4e
+                op_ret = -1;
21ab4e
+                op_errno = EINVAL;
21ab4e
+                goto out;
21ab4e
+        }
21ab4e
+
21ab4e
+        ioc_inode_update (this, inode, (char *)local->file_loc.path, stbuf);
21ab4e
+
21ab4e
+out:
21ab4e
         if (frame->local != NULL) {
21ab4e
                 local = frame->local;
21ab4e
                 loc_wipe (&local->file_loc);
21ab4e
@@ -511,7 +522,7 @@ ioc_get_priority (ioc_table_t *table, const char *path)
21ab4e
         uint32_t             priority = 1;
21ab4e
         struct ioc_priority *curr     = NULL;
21ab4e
 
21ab4e
-        if (list_empty(&table->priority_list))
21ab4e
+        if (list_empty(&table->priority_list) || !path)
21ab4e
                 return priority;
21ab4e
 
21ab4e
         priority = 0;
21ab4e
@@ -648,7 +659,7 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
                 /* assign weight */
21ab4e
                 weight = ioc_get_priority (table, path);
21ab4e
 
21ab4e
-                ioc_inode = ioc_inode_update (table, inode, weight);
21ab4e
+                ioc_inode = ioc_inode_create (table, inode, weight);
21ab4e
 
21ab4e
                 ioc_inode_lock (ioc_inode);
21ab4e
                 {
21ab4e
@@ -735,7 +746,7 @@ ioc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
                 /* assign weight */
21ab4e
                 weight = ioc_get_priority (table, path);
21ab4e
 
21ab4e
-                ioc_inode = ioc_inode_update (table, inode, weight);
21ab4e
+                ioc_inode = ioc_inode_create (table, inode, weight);
21ab4e
 
21ab4e
                 ioc_inode_lock (ioc_inode);
21ab4e
                 {
21ab4e
@@ -1405,12 +1416,22 @@ ioc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
21ab4e
                   int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata)
21ab4e
 {
21ab4e
         gf_dirent_t *entry = NULL;
21ab4e
+        char        *path  = NULL;
21ab4e
+        fd_t        *fd    = NULL;
21ab4e
+
21ab4e
+        if (frame) {
21ab4e
+                fd = frame->local;
21ab4e
+                frame->local = NULL;
21ab4e
+        }
21ab4e
 
21ab4e
         if (op_ret <= 0)
21ab4e
                 goto unwind;
21ab4e
 
21ab4e
         list_for_each_entry (entry, &entries->list, list) {
21ab4e
-                /* TODO: fill things */
21ab4e
+                inode_path (fd->inode, entry->d_name, &path);
21ab4e
+                ioc_inode_update (this, entry->inode, path, &entry->d_stat);
21ab4e
+                GF_FREE (path);
21ab4e
+                path = NULL;
21ab4e
         }
21ab4e
 
21ab4e
 unwind:
21ab4e
@@ -1418,10 +1439,13 @@ unwind:
21ab4e
 
21ab4e
         return 0;
21ab4e
 }
21ab4e
+
21ab4e
 int
21ab4e
 ioc_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
21ab4e
               off_t offset, dict_t *dict)
21ab4e
 {
21ab4e
+        frame->local = fd;
21ab4e
+
21ab4e
         STACK_WIND (frame, ioc_readdirp_cbk,
21ab4e
                     FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp,
21ab4e
                     fd, size, offset, dict);
21ab4e
diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h
21ab4e
index d7c823f..50008ef 100644
21ab4e
--- a/xlators/performance/io-cache/src/io-cache.h
21ab4e
+++ b/xlators/performance/io-cache/src/io-cache.h
21ab4e
@@ -300,8 +300,12 @@ ioc_inode_search (ioc_table_t *table, inode_t *inode);
21ab4e
 void
21ab4e
 ioc_inode_destroy (ioc_inode_t *ioc_inode);
21ab4e
 
21ab4e
+int32_t
21ab4e
+ioc_inode_update (xlator_t *this, inode_t *inode, char *path,
21ab4e
+                  struct iatt *iabuf);
21ab4e
+
21ab4e
 ioc_inode_t *
21ab4e
-ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight);
21ab4e
+ioc_inode_create (ioc_table_t *table, inode_t *inode, uint32_t weight);
21ab4e
 
21ab4e
 int64_t
21ab4e
 __ioc_page_destroy (ioc_page_t *page);
21ab4e
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c
21ab4e
index 6eb3412..f8653fa 100644
21ab4e
--- a/xlators/performance/io-cache/src/ioc-inode.c
21ab4e
+++ b/xlators/performance/io-cache/src/ioc-inode.c
21ab4e
@@ -165,7 +165,7 @@ out:
21ab4e
 
21ab4e
 
21ab4e
 /*
21ab4e
- * ioc_inode_update - create a new ioc_inode_t structure and add it to
21ab4e
+ * ioc_inode_create - create a new ioc_inode_t structure and add it to
21ab4e
  *                    the table table. fill in the fields which are derived
21ab4e
  *                    from inode_t corresponding to the file
21ab4e
  *
21ab4e
@@ -175,7 +175,7 @@ out:
21ab4e
  * not for external reference
21ab4e
  */
21ab4e
 ioc_inode_t *
21ab4e
-ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight)
21ab4e
+ioc_inode_create (ioc_table_t *table, inode_t *inode, uint32_t weight)
21ab4e
 {
21ab4e
         ioc_inode_t     *ioc_inode   = NULL;
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e