Return-Path: Received: from mail-dm3nam03on0136.outbound.protection.outlook.com ([104.47.41.136]:30240 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728089AbeH3WUa (ORCPT ); Thu, 30 Aug 2018 18:20:30 -0400 From: Sasha Levin To: "stable@vger.kernel.org" CC: Steven French , Sasha Levin Subject: [PATCH AUTOSEL 4.4 25/30] smb3: fix reset of bytes read and written stats Date: Thu, 30 Aug 2018 18:16:33 +0000 Message-ID: <20180830181533.36683-25-alexander.levin@microsoft.com> References: <20180830181533.36683-1-alexander.levin@microsoft.com> In-Reply-To: <20180830181533.36683-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Steve French [ Upstream commit c281bc0c7412308c7ec0888904f7c99353da4796 ] echo 0 > /proc/fs/cifs/Stats is supposed to reset the stats but there were four (see example below) that were not reset (bytes read and witten, total vfs ops and max ops at one time). ... 0 session 0 share reconnects Total vfs operations: 100 maximum at one time: 2 1) \\localhost\test SMBs: 0 Bytes read: 502092 Bytes written: 31457286 TreeConnects: 0 total 0 failed TreeDisconnects: 0 total 0 failed ... This patch fixes cifs_stats_proc_write to properly reset those four. Signed-off-by: Steve French Reviewed-by: Aurelien Aptel Signed-off-by: Sasha Levin --- fs/cifs/cifs_debug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 0a3544fb50f9..738c81853466 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -269,6 +269,10 @@ static ssize_t cifs_stats_proc_write(struct file *file= , atomic_set(&totBufAllocCount, 0); atomic_set(&totSmBufAllocCount, 0); #endif /* CONFIG_CIFS_STATS2 */ + spin_lock(&GlobalMid_Lock); + GlobalMaxActiveXid =3D 0; + GlobalCurrentXid =3D 0; + spin_unlock(&GlobalMid_Lock); spin_lock(&cifs_tcp_ses_lock); list_for_each(tmp1, &cifs_tcp_ses_list) { server =3D list_entry(tmp1, struct TCP_Server_Info, @@ -281,6 +285,10 @@ static ssize_t cifs_stats_proc_write(struct file *file= , struct cifs_tcon, tcon_list); atomic_set(&tcon->num_smbs_sent, 0); + spin_lock(&tcon->stat_lock); + tcon->bytes_read =3D 0; + tcon->bytes_written =3D 0; + spin_unlock(&tcon->stat_lock); if (server->ops->clear_stats) server->ops->clear_stats(tcon); } --=20 2.17.1