From 0e5a4d60bde6e0008b2c20ec639e0043cd29f0b3 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 22 Jun 2021 09:26:40 +0800 Subject: [PATCH] LU-14778 readahead: fix to reserve min pages @pages_min might be larger than @pages which indicate more pages should be read, and it will cause a warning later. Lustre-change: https://review.whamcloud.com/44050 Lustre-commit: 4fc127428f00d6a3b179a143a61ddc78e5d8ca7c Signed-off-by: Wang Shilong Change-Id: Ifd82f709c3877172f08b87ab0551da735a0613e0 Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Reviewed-on: https://review.whamcloud.com/44287 Tested-by: jenkins Tested-by: Maloo --- lustre/llite/rw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 530a59e..1e460f0 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -90,8 +90,9 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, ENTRY; + 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); @@ -100,7 +101,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; /* @@ -816,7 +817,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) -- 1.8.3.1