Whamcloud - gitweb
LU-12644 llite: try fast io for stride io correctly 66/35466/13
authorWang Shilong <wshilong@ddn.com>
Thu, 8 Aug 2019 17:14:19 +0000 (13:14 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 14 Feb 2020 05:50:09 +0000 (05:50 +0000)
We could have a really large gap for stride, calculate
skip pages correctly, otherwise, we will see many small
RPC with large stride gap.

Change-Id: Id72405c11234a2075f3cce4733d23544fe15eb17
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/35466
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/rw.c

index 9b2ecdd..23093e1 100644 (file)
@@ -1485,6 +1485,34 @@ static int kickoff_async_readahead(struct file *file, unsigned long pages)
        return 2;
 }
 
+/*
+ * Check if we can issue a readahead RPC, if that is
+ * the case, we can't do fast IO because we will need
+ * a cl_io to issue the RPC.
+ */
+static bool ll_use_fast_io(struct file *file,
+                          struct ll_readahead_state *ras, pgoff_t index)
+{
+       unsigned long fast_read_pages =
+               max(RA_REMAIN_WINDOW_MIN, ras->ras_rpc_pages);
+       loff_t skip_pages;
+
+       if (stride_io_mode(ras)) {
+               skip_pages = (ras->ras_stride_length +
+                       ras->ras_stride_bytes - 1) / ras->ras_stride_bytes;
+               skip_pages *= fast_read_pages;
+       } else {
+               skip_pages = fast_read_pages;
+       }
+
+       if (ras->ras_window_start_idx + ras->ras_window_pages <
+           ras->ras_next_readahead_idx + skip_pages ||
+           kickoff_async_readahead(file, fast_read_pages) > 0)
+               return true;
+
+       return false;
+}
+
 int ll_readpage(struct file *file, struct page *vmpage)
 {
        struct inode *inode = file_inode(file);
@@ -1508,8 +1536,6 @@ int ll_readpage(struct file *file, struct page *vmpage)
                struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
                struct ll_readahead_state *ras = &fd->fd_ras;
                struct lu_env  *local_env = NULL;
-               unsigned long fast_read_pages =
-                       max(RA_REMAIN_WINDOW_MIN, ras->ras_rpc_pages);
                struct vvp_page *vpg;
 
                result = -ENODATA;
@@ -1537,12 +1563,7 @@ int ll_readpage(struct file *file, struct page *vmpage)
                        /* avoid duplicate ras_update() call */
                        vpg->vpg_ra_updated = 1;
 
-                       /* Check if we can issue a readahead RPC, if that is
-                        * the case, we can't do fast IO because we will need
-                        * a cl_io to issue the RPC. */
-                       if (ras->ras_window_start_idx + ras->ras_window_pages <
-                           ras->ras_next_readahead_idx + fast_read_pages ||
-                           kickoff_async_readahead(file, fast_read_pages) > 0)
+                       if (ll_use_fast_io(file, ras, vvp_index(vpg)))
                                result = 0;
                }