From 9e4c5bdaaec5ef347260f0fd2f916143224f3cc4 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 8 Aug 2019 13:14:19 -0400 Subject: [PATCH] LU-12644 llite: try fast io for stride io correctly 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 Reviewed-on: https://review.whamcloud.com/35466 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/llite/rw.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 9b2ecdd..23093e12 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -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; } -- 1.8.3.1