diff mbox series

[15/20] lustre: osc: use original cli for osc_lru_reclaim for debug msg

Message ID 1633974049-26490-16-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS Oct 11, 2021 | expand

Commit Message

James Simmons Oct. 11, 2021, 5:40 p.m. UTC
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.

Fixes: ce96138f3692 ("lustre: use list_first_entry() in lustre subdirectory.")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15013
Lustre-commit: 3c6a1e94c652685fac7c ("LU-15013 osc: use original cli for osc_lru_reclaim for debug msg")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/44966
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 fs/lustre/osc/osc_page.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/osc/osc_page.c b/fs/lustre/osc/osc_page.c
index d471df2..cba5d02 100644
--- a/fs/lustre/osc/osc_page.c
+++ b/fs/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,20 +736,20 @@  static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages)
 
 	max_scans = refcount_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;