Whamcloud - gitweb
LU-14441 mdc: check/grab import before access
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 13 Dec 2021 08:27:42 +0000 (11:27 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 24 Feb 2024 03:47:00 +0000 (03:47 +0000)
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 <bzzz@whamcloud.com>
Change-Id: I005c96b349e55646996fd0d265ab4dd1e2b9a1fa
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54126
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/mdc/lproc_mdc.c

index f0b79e9..42c2742 100644 (file)
@@ -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);