From patchwork Mon Aug 20 02:40:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10569843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B3075A4 for ; Mon, 20 Aug 2018 02:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29B40291B7 for ; Mon, 20 Aug 2018 02:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2894E291B5; Mon, 20 Aug 2018 02:40:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CFC41291B7 for ; Mon, 20 Aug 2018 02:40:28 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2F0347A1693; Sun, 19 Aug 2018 19:40:28 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C6C2E7A109E for ; Sun, 19 Aug 2018 19:40:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id C893910050EF; Sun, 19 Aug 2018 22:40:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C69C0369; Sun, 19 Aug 2018 22:40:24 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 19 Aug 2018 22:40:23 -0400 Message-Id: <1534732823-23115-1-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 Subject: [lustre-devel] [PATCH v2 32/38] lustre: osc: restore cl_loi_list_lock X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 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" X-Virus-Scanned: ClamAV using ClamSMTP Access to struct client_obd should be protected with the spinlock cl_loi_list_lock. This was dropped during the port to sysfs so restore the proper locking. Signed-off-by: James Simmons --- Changelog) v1) Initial patch v2) remove unneeded spin lock for max_rpcs_in_flight_show drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3c31e98..5fb7a16 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -136,7 +141,10 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, long val; int mult; + spin_lock(&cli->cl_loi_list_lock); val = cli->cl_dirty_max_pages; + spin_unlock(&cli->cl_loi_list_lock); + mult = 1 << (20 - PAGE_SHIFT); return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } @@ -247,9 +255,13 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_unlock(&cli->cl_loi_list_lock); + return len; } LUSTRE_RO_ATTR(cur_dirty_bytes); @@ -260,8 +272,13 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t cur_grant_bytes_store(struct kobject *kobj, @@ -280,8 +297,12 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, return rc; /* this is only for shrinking grant */ - if (val >= cli->cl_avail_grant) + spin_lock(&cli->cl_loi_list_lock); + if (val >= cli->cl_avail_grant) { + spin_unlock(&cli->cl_loi_list_lock); return -EINVAL; + } + spin_unlock(&cli->cl_loi_list_lock); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); @@ -298,8 +319,13 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } LUSTRE_RO_ATTR(cur_lost_grant_bytes);