From patchwork Sun Sep 18 05:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 12979315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51A81C6FA86 for ; Sun, 18 Sep 2022 05:22:40 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4MVbmF292Yz1yFs; Sat, 17 Sep 2022 22:22:37 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4MVbm04PFlz1y6n for ; Sat, 17 Sep 2022 22:22:24 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id E2B2C8F09; Sun, 18 Sep 2022 01:22:16 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E00BFE8B93; Sun, 18 Sep 2022 01:22:16 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 18 Sep 2022 01:21:59 -0400 Message-Id: <1663478534-19917-10-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663478534-19917-1-git-send-email-jsimmons@infradead.org> References: <1663478534-19917-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 09/24] lustre: mdc: check/grab import before access X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Alex Zhuravlev 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 Reviewed-on: https://review.whamcloud.com/41681 Reviewed-by: Andreas Dilger Reviewed-by: Neil Brown Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/mdc/lproc_mdc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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);