From 8b6719f1b32e134babe9f47e2dc79c66a3735b49 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Thu, 30 May 2024 18:39:37 +0200 Subject: [PATCH] LU-17887 obd: do not update obd_memory from RCU OBD_FREE_PRE() should not be run from an RCU callback as the obdclass module may have been unloaded during the RCU grace period. Signed-off-by: Bruno Faccini Change-Id: I6f663b2aed2e60c15f2a1b9755b2c4050bd91ce2 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55263 Reviewed-by: Alex Zhuravlev Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/obdclass/lu_object.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index cd98acb..9f96896 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1956,14 +1956,6 @@ int lu_env_add(struct lu_env *env) } EXPORT_SYMBOL(lu_env_add); -static void lu_env_item_free(struct rcu_head *head) -{ - struct lu_env_item *lei; - - lei = container_of(head, struct lu_env_item, lei_rcu_head); - OBD_FREE_PTR(lei); -} - void lu_env_remove(struct lu_env *env) { struct lu_env_item *lei; @@ -1986,8 +1978,10 @@ void lu_env_remove(struct lu_env *env) lei = rhashtable_lookup_fast(&lu_env_rhash, &task, lu_env_rhash_params); if (lei && rhashtable_remove_fast(&lu_env_rhash, &lei->lei_linkage, - lu_env_rhash_params) == 0) - call_rcu(&lei->lei_rcu_head, lu_env_item_free); + lu_env_rhash_params) == 0) { + OBD_FREE_PRE(lei, sizeof(*lei), "kfreed"); + kfree_rcu(lei, lei_rcu_head); + } } EXPORT_SYMBOL(lu_env_remove); -- 1.8.3.1