diff mbox series

[04/33] lustre: llite: add __GFP_NORETRY for read-ahead page

Message ID 20250202204633.1148872-5-jsimmons@infradead.org (mailing list archive)
State New
Headers show
Series lustre: sync to OpenSFS branch May 31, 2023 | expand

Commit Message

James Simmons Feb. 2, 2025, 8:46 p.m. UTC
From: Qian Yingjin <qian@ddn.com>

We need __GFP_NORETRY for read-ahead page, otherwise the read
process would be OOM killed when reached cgroup memory limits.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16713
Lustre-commit: 8db5d39f669f03aa6 ("LU-16713 llite: add __GFP_NORETRY for read-ahead page")
Signed-off-by: Qian Yingjin <qian@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50625
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/rw.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index 92a9c252247e..9b1cf71116df 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -210,7 +210,16 @@  static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
 
 	switch (hint) {
 	case MAYNEED:
-		vmpage = grab_cache_page_nowait(inode->i_mapping, index);
+		/*
+		 * We need __GFP_NORETRY here for read-ahead page, otherwise
+		 * the process will fail with OOM killed due to memcg limit.
+		 * See @readahead_gfp_mask for an example.
+		 */
+		vmpage = pagecache_get_page(inode->i_mapping, index,
+					    FGP_LOCK | FGP_CREAT |
+					    FGP_NOFS | FGP_NOWAIT,
+					    mapping_gfp_mask(inode->i_mapping) |
+					    __GFP_NORETRY | __GFP_NOWARN);
 		if (!vmpage) {
 			which = RA_STAT_FAILED_GRAB_PAGE;
 			msg = "g_c_p_n failed";