From da37643fbfe026fe4b6f5987f0ca3057e20740be Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 13 Dec 2021 11:27:42 +0300 Subject: [PATCH] LU-14441 mdc: check/grab import before access to ensure the import doesn't disappear while being accessed via procfs. Lustre-change: https://review.whamcloud.com/41681 Lustre-commit: b8416320b381ae8a6fdd058b0a09ea42ce56d573 Signed-off-by: Alex Zhuravlev Change-Id: I005c96b349e55646996fd0d265ab4dd1e2b9a1fa Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54126 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/mdc/lproc_mdc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index f0b79e9..42c2742 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -99,6 +99,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + struct obd_import *imp; unsigned int val; int rc; @@ -106,11 +107,10 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, if (rc) return rc; - rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val); - if (rc) - count = rc; + with_imp_locked(obd, imp, rc) + rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val); - return count; + return rc ? rc : count; } LUSTRE_RW_ATTR(max_rpcs_in_flight); @@ -133,6 +133,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + struct obd_import *imp; u16 val; int rc; @@ -140,11 +141,10 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, if (rc) return rc; - rc = obd_set_max_mod_rpcs_in_flight(&obd->u.cli, val); - if (rc) - count = rc; + with_imp_locked(obd, imp, rc) + rc = obd_set_max_mod_rpcs_in_flight(&obd->u.cli, val); - return count; + return rc ? rc : count; } LUSTRE_RW_ATTR(max_mod_rpcs_in_flight); -- 1.8.3.1