diff mbox series

[10/18] lustre: readahead: fix to reserve min pages

Message ID 1626697933-6971-11-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS as of July 18, 2021 | expand

Commit Message

James Simmons July 19, 2021, 12:32 p.m. UTC
From: Wang Shilong <wshilong@ddn.com>

@pages_min might be larger than @pages which indicate
more pages should be read, and it will cause a warning
later.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14778
Lustre-commit: 4fc127428f00d6a3 ("LU-14778 readahead: fix to reserve min pages")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/44050
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/rw.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index 184e5e8..4de77f6 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -85,8 +85,9 @@  static unsigned long ll_ra_count_get(struct ll_sb_info *sbi,
 	struct ll_ra_info *ra = &sbi->ll_ra_info;
 	long ret;
 
+	WARN_ON_ONCE(pages_min > pages);
 	/**
-	 * Don't try readahead agreesively if we are limited
+	 * Don't try readahead aggresively if we are limited
 	 * LRU pages, otherwise, it could cause deadlock.
 	 */
 	pages = min(sbi->ll_cache->ccc_lru_max >> 2, pages);
@@ -95,7 +96,7 @@  static unsigned long ll_ra_count_get(struct ll_sb_info *sbi,
 	 * this will make us leak @ra_cur_pages, because
 	 * ll_ra_count_put() acutally freed @pages.
 	 */
-	if (WARN_ON_ONCE(pages_min > pages))
+	if (unlikely(pages_min > pages))
 		pages_min = pages;
 
 	/*
@@ -829,7 +830,8 @@  static int ll_readahead(const struct lu_env *env, struct cl_io *io,
 	/* don't over reserved for mmap range read */
 	if (skip_index)
 		pages_min = 0;
-
+	if (pages_min > pages)
+		pages = pages_min;
 	ria->ria_reserved = ll_ra_count_get(ll_i2sbi(inode), ria, pages,
 					    pages_min);
 	if (ria->ria_reserved < pages)