Whamcloud - gitweb
LU-14441 mdc: check/grab import before access 81/41681/19
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 13 Dec 2021 08:27:42 +0000 (11:27 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 12 Sep 2022 02:53:17 +0000 (02:53 +0000)
to ensure the import doesn't disappear while being accessed
via procfs.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I005c96b349e55646996fd0d265ab4dd1e2b9a1fa
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>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdc/lproc_mdc.c

index 506f06f..af5649d 100644 (file)
@@ -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);