diff mbox series

[09/24] lustre: mdc: check/grab import before access

Message ID 1663478534-19917-10-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to 2.15.52 | expand

Commit Message

James Simmons Sept. 18, 2022, 5:21 a.m. UTC
From: Alex Zhuravlev <bzzz@whamcloud.com>

to ensure the import doesn't disappear while being accessed
via sysfs.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14441
Lustre-commit: b8416320b381ae8a6 ("LU-14441 mdc: check/grab import before access")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41681
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/mdc/lproc_mdc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/mdc/lproc_mdc.c b/fs/lustre/mdc/lproc_mdc.c
index 3de6533..cb3744a 100644
--- a/fs/lustre/mdc/lproc_mdc.c
+++ b/fs/lustre/mdc/lproc_mdc.c
@@ -340,6 +340,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;
 
@@ -347,11 +348,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);
 
@@ -372,6 +372,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;
 
@@ -379,11 +380,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);