From b8416320b381ae8a6fdd058b0a09ea42ce56d573 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. Signed-off-by: Alex Zhuravlev Change-Id: I005c96b349e55646996fd0d265ab4dd1e2b9a1fa Reviewed-on: https://review.whamcloud.com/41681 Reviewed-by: Andreas Dilger Reviewed-by: Neil Brown Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- 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 506f06f..af5649d 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -101,6 +101,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; @@ -108,11 +109,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); @@ -135,6 +135,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; @@ -142,11 +143,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