cifs: maintain a state machine for tcp/smb/tcon sessions
authorShyam Prasad N <sprasad@microsoft.com>
Mon, 19 Jul 2021 17:37:52 +0000 (17:37 +0000)
committerSteve French <stfrench@microsoft.com>
Sat, 8 Jan 2022 02:09:22 +0000 (20:09 -0600)
commit73f9bfbe3d818bb52266d5c9f3ba57d97842ffe7
treed2cd41b96bddfe592b5a6e9bfd1eb54223947657
parent1913e1116a3174648cf2e6faedf29204f31cc438
cifs: maintain a state machine for tcp/smb/tcon sessions

If functions like cifs_negotiate_protocol, cifs_setup_session,
cifs_tree_connect are called in parallel on different channels,
each of these will be execute the requests. This maybe unnecessary
in some cases, and only the first caller may need to do the work.

This is achieved by having more states for the tcp/smb/tcon session
status fields. And tracking the state of reconnection based on the
state machine.

For example:
for tcp connections:
CifsNew/CifsNeedReconnect ->
  CifsNeedNegotiate ->
    CifsInNegotiate ->
      CifsNeedSessSetup ->
        CifsInSessSetup ->
          CifsGood

for smb sessions:
CifsNew/CifsNeedReconnect ->
  CifsGood

for tcon:
CifsNew/CifsNeedReconnect ->
  CifsInFilesInvalidate ->
    CifsNeedTcon ->
      CifsInTcon ->
        CifsGood

If any channel reconnect sees that it's in the middle of
transition to CifsGood, then they can skip the function.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsglob.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/sess.c
fs/cifs/smb2pdu.c