]> asedeno.scripts.mit.edu Git - linux.git/commit
CIFS: Increment num_remote_opens stats counter even in case of smb2_query_dir_first
authorShyam Prasad N <nspmangalore@gmail.com>
Mon, 9 Mar 2020 08:35:09 +0000 (01:35 -0700)
committerSteve French <stfrench@microsoft.com>
Tue, 17 Mar 2020 18:27:03 +0000 (13:27 -0500)
commit1be1fa42ebb73ad8fd67d2c846931361b4e3dd0a
treeff4017c0ab99e59e010225d76d051d4d7e9fb8a5
parent39946886fc865a4c26f1b3ea0805936db2d8986d
CIFS: Increment num_remote_opens stats counter even in case of smb2_query_dir_first

The num_remote_opens counter keeps track of the number of open files which must be
maintained by the server at any point. This is a per-tree-connect counter, and the value
of this counter gets displayed in the /proc/fs/cifs/Stats output as a following...

Open files: 0 total (local), 1 open on server
                             ^^^^^^^^^^^^^^^^
As a thumb-rule, we want to increment this counter for each open/create that we
successfully execute on the server. Similarly, we should decrement the counter when
we successfully execute a close.

In this case, an increment was being missed in case of smb2_query_dir_first,
in case of successful open. As a result, we would underflow the counter and we
could even see the counter go to negative after sufficient smb2_query_dir_first calls.

I tested the stats counter for a bunch of filesystem operations with the fix.
And it looks like the counter looks correct to me.

I also check if we missed the increments and decrements elsewhere. It does not
seem so. Few other cases where an open is done and we don't increment the counter are
the compound calls where the corresponding close is also sent in the request.

Signed-off-by: Shyam Prasad N <nspmangalore@gmail.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
fs/cifs/smb2ops.c