From 3c6a1e94c652685fac7c69bf530e05d27b7f477c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 17 Sep 2021 10:30:22 -0400 Subject: [PATCH] LU-15013 osc: use original cli for osc_lru_reclaim for debug msg Before the list cleanup introduced in osc_lru_reclaim() the variable cli was both passed in and used to scan the cl_client_cache. After the scan was done then we use cli in a debug message. It appears to be the original intent was to use the original cli passed in for the debug message, not the last scanned item. After the list cleanup patch landed now cli can be NULL which can crash the node. The fix is to use a separate struct client_obd variable for the scan and use the original cli passed in for the debug message. Test-Parameters: trivial Fixes: 8c166f6bf42c ("LU-6142 lustre: use list_first_entry() in lustre subdirectory.") Change-Id: I5f0f1b986744fdd30af7f7856c1278b41447a373 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/44966 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- lustre/osc/osc_page.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index 3217a1e..eb60998 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -696,6 +696,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) { struct lu_env *env; struct cl_client_cache *cache = cli->cl_cache; + struct client_obd *scan; int max_scans; __u16 refcheck; long rc = 0; @@ -735,19 +736,19 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) max_scans = atomic_read(&cache->ccc_users) - 2; while (--max_scans > 0 && - (cli = list_first_entry_or_null(&cache->ccc_lru, - struct client_obd, - cl_lru_osc)) != NULL) { + (scan = list_first_entry_or_null(&cache->ccc_lru, + struct client_obd, + cl_lru_osc)) != NULL) { CDEBUG(D_CACHE, "%s: cli %p LRU pages: %ld, busy: %ld.\n", - cli_name(cli), cli, - atomic_long_read(&cli->cl_lru_in_list), - atomic_long_read(&cli->cl_lru_busy)); + cli_name(scan), scan, + atomic_long_read(&scan->cl_lru_in_list), + atomic_long_read(&scan->cl_lru_busy)); - list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); - if (osc_cache_too_much(cli) > 0) { + list_move_tail(&scan->cl_lru_osc, &cache->ccc_lru); + if (osc_cache_too_much(scan) > 0) { spin_unlock(&cache->ccc_lru_lock); - rc = osc_lru_shrink(env, cli, npages, true); + rc = osc_lru_shrink(env, scan, npages, true); spin_lock(&cache->ccc_lru_lock); if (rc >= npages) break; @@ -760,7 +761,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) out: cl_env_put(env, &refcheck); CDEBUG(D_CACHE, "%s: cli %p freed %ld pages.\n", - cli_name(cli), cli, rc); + cli_name(cli), cli, rc); return rc; } -- 1.8.3.1