Whamcloud - gitweb
LU-8066 llite: remove redundant lookup in dump_pgcache 10/33010/5
authorNeilBrown <neilb@suse.com>
Sun, 16 Sep 2018 21:28:41 +0000 (17:28 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 1 Oct 2018 14:00:46 +0000 (14:00 +0000)
Both the 'next' and the 'show' functions for the dump_page_cache
seqfile perform a lookup based on the current file index.  This is
needless duplication.

The reason appears to be that the state that needs to be communicated
from "next" to "show" is two pointers, but seq_file only provides for
a single pointer to be returned from next and passed to show.

So make use of the new 'seq_private' structure to store the extra
pointer.
So when 'next' (or 'start') find something, it returns the page and
stores the clob in the private area.
'show' accepts the page as an argument, and finds the clob where it
was stored.

Linux-commit: 85b6542bbade42935386661cb45d90c4e13766b7

Test-Parameters: trivial envdefinitions="ONLY=63b" testlist=sanity
Test-Parameters: trivial envdefinitions="ONLY=118" testlist=sanity
Test-Parameters: trivial envdefinitions="ONLY=20" testlist=sanityn

Change-Id: I6a45430f7ba3007dcd70bdf09c4c7ed5a213533d
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/33010
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/vvp_dev.c

index 56b921a..6ffd719 100644 (file)
@@ -388,6 +388,7 @@ struct vvp_seq_private {
        struct ll_sb_info       *vsp_sbi;
        struct lu_env           *vsp_env;
        u16                     vsp_refcheck;
+       struct cl_object        *vsp_clob;
 };
 
 static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id)
@@ -452,21 +453,22 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env,
        return NULL;
 }
 
-static loff_t vvp_pgcache_find(const struct lu_env *env,
-                              struct lu_device *dev, loff_t pos)
+static struct page *vvp_pgcache_find(const struct lu_env *env,
+                                    struct lu_device *dev,
+                                    struct cl_object **clobp, loff_t *pos)
 {
        struct cl_object     *clob;
        struct lu_site       *site;
        struct vvp_pgcache_id id;
 
        site = dev->ld_site;
-       vvp_pgcache_id_unpack(pos, &id);
+       vvp_pgcache_id_unpack(*pos, &id);
 
        while (1) {
                if (id.vpi_bucket >= CFS_HASH_NHLIST(site->ls_obj_hash))
-                       return ~0ULL;
+                       return NULL;
                clob = vvp_pgcache_obj(env, dev, &id);
-               if (clob != NULL) {
+               if (clob) {
                        struct inode *inode = vvp_object_inode(clob);
                        struct page *vmpage;
                        int nr;
@@ -476,20 +478,22 @@ static loff_t vvp_pgcache_find(const struct lu_env *env,
                        if (nr > 0) {
                                id.vpi_index = vmpage->index;
                                /* Cant support over 16T file */
-                               nr = !(vmpage->index > 0xffffffff);
+                               if (vmpage->index <= 0xffffffff) {
+                                       *clobp = clob;
+                                       *pos = vvp_pgcache_id_pack(&id);
+                                       return vmpage;
+                               }
                                put_page(vmpage);
                        }
 
                        lu_object_ref_del(&clob->co_lu, "dump", current);
                        cl_object_put(env, clob);
-                       if (nr > 0)
-                               return vvp_pgcache_id_pack(&id);
                }
                /* to the next object. */
                ++id.vpi_depth;
                id.vpi_depth &= 0xf;
                if (id.vpi_depth == 0 && ++id.vpi_bucket == 0)
-                       return ~0ULL;
+                       return NULL;
                id.vpi_index = 0;
        }
 }
@@ -533,75 +537,51 @@ static void vvp_pgcache_page_show(const struct lu_env *env,
 static int vvp_pgcache_show(struct seq_file *f, void *v)
 {
        struct vvp_seq_private *priv = f->private;
-       loff_t pos;
-       struct cl_object *clob;
-       struct vvp_pgcache_id id;
-
-       pos = *(loff_t *) v;
-       vvp_pgcache_id_unpack(pos, &id);
-       clob = vvp_pgcache_obj(priv->vsp_env, &priv->vsp_sbi->ll_cl->cd_lu_dev,
-                              &id);
-       if (clob) {
-               struct inode *inode = vvp_object_inode(clob);
-               struct cl_page *page = NULL;
-               struct page *vmpage;
-               int result;
-
-               result = find_get_pages_contig(inode->i_mapping,
-                                             id.vpi_index, 1, &vmpage);
-               if (result > 0) {
-                       lock_page(vmpage);
-                       page = cl_vmpage_page(vmpage, clob);
-                       unlock_page(vmpage);
-
-                       put_page(vmpage);
-               }
-
-               seq_printf(f, "%8x@" DFID ": ", id.vpi_index,
-                          PFID(lu_object_fid(&clob->co_lu)));
-               if (page) {
-                       vvp_pgcache_page_show(priv->vsp_env, f, page);
-                       cl_page_put(priv->vsp_env, page);
-               } else {
-                       seq_puts(f, "missing\n");
-               }
-               lu_object_ref_del(&clob->co_lu, "dump", current);
-               cl_object_put(priv->vsp_env, clob);
+       struct page *vmpage = v;
+       struct cl_page *page;
+
+       seq_printf(f, "%8lx@" DFID ": ", vmpage->index,
+                  PFID(lu_object_fid(&priv->vsp_clob->co_lu)));
+       lock_page(vmpage);
+       page = cl_vmpage_page(vmpage, priv->vsp_clob);
+       unlock_page(vmpage);
+       put_page(vmpage);
+
+       if (page) {
+               vvp_pgcache_page_show(priv->vsp_env, f, page);
+               cl_page_put(priv->vsp_env, page);
        } else {
-               seq_printf(f, "%llx missing\n", pos);
+               seq_puts(f, "missing\n");
        }
+       lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current);
+       cl_object_put(priv->vsp_env, priv->vsp_clob);
+
        return 0;
 }
 
 static void *vvp_pgcache_start(struct seq_file *f, loff_t *pos)
 {
        struct vvp_seq_private *priv = f->private;
+       struct page *ret;
 
        if (priv->vsp_sbi->ll_site->ls_obj_hash->hs_cur_bits >
-           64 - PGC_OBJ_SHIFT) {
-               pos = ERR_PTR(-EFBIG);
-       } else {
-               *pos = vvp_pgcache_find(priv->vsp_env,
-                                       &priv->vsp_sbi->ll_cl->cd_lu_dev,
-                                       *pos);
-               if (*pos == ~0ULL)
-                       pos = NULL;
-       }
-
-       return pos;
+           64 - PGC_OBJ_SHIFT)
+               ret = ERR_PTR(-EFBIG);
+       else
+               ret = vvp_pgcache_find(priv->vsp_env,
+                                      &priv->vsp_sbi->ll_cl->cd_lu_dev,
+                                      &priv->vsp_clob, pos);
+       return ret;
 }
 
 static void *vvp_pgcache_next(struct seq_file *f, void *v, loff_t *pos)
 {
        struct vvp_seq_private *priv = f->private;
 
-       *pos = vvp_pgcache_find(priv->vsp_env,
+       *pos += 1;
+       return vvp_pgcache_find(priv->vsp_env,
                                &priv->vsp_sbi->ll_cl->cd_lu_dev,
-                               *pos + 1);
-       if (*pos == ~0ULL)
-               pos = NULL;
-
-       return pos;
+                               &priv->vsp_clob, pos);
 }
 
 static void vvp_pgcache_stop(struct seq_file *f, void *v)