1. 02 Oct, 2020 2 commits
    • Benjamin Coddington's avatar
      NFSv4: Wait for stateid updates after CLOSE/OPEN_DOWNGRADE · b4868b44
      Benjamin Coddington authored
      Since commit 0e0cb35b ("NFSv4: Handle NFS4ERR_OLD_STATEID in
      CLOSE/OPEN_DOWNGRADE") the following livelock may occur if a CLOSE races
      with the update of the nfs_state:
      
      Process 1           Process 2           Server
      =========           =========           ========
       OPEN file
                          OPEN file
                                              Reply OPEN (1)
                                              Reply OPEN (2)
       Update state (1)
       CLOSE file (1)
                                              Reply OLD_STATEID (1)
       CLOSE file (2)
                                              Reply CLOSE (-1)
                          Update state (2)
                          wait for state change
       OPEN file
                          wake
       CLOSE file
       OPEN file
                          wake
       CLOSE file
       ...
                          ...
      
      We can avoid this situation by not issuing an immediate retry with a bumped
      seqid when CLOSE/OPEN_DOWNGRADE receives NFS4ERR_OLD_STATEID.  Instead,
      take the same approach used by OPEN and wait at least 5 seconds for
      outstanding stateid updates to complete if we can detect that we're out of
      sequence.
      
      Note that after this change it is still possible (though unlikely) that
      CLOSE waits a full 5 seconds, bumps the seqid, and retries -- and that
      attempt races with another OPEN at the same time.  In order to avoid this
      race (which would result in the livelock), update
      nfs_need_update_open_stateid() to handle the case where:
       - the state is NFS_OPEN_STATE, and
       - the stateid doesn't match the current open stateid
      
      Finally, nfs_need_update_open_stateid() is modified to be idempotent and
      renamed to better suit the purpose of signaling that the stateid passed
      is the next stateid in sequence.
      
      Fixes: 0e0cb35b ("NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE")
      Cc: stable@vger.kernel.org # v5.4+
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      b4868b44
    • Nick Desaulniers's avatar
      nfs: remove incorrect fallthrough label · fb08334b
      Nick Desaulniers authored
      There is no case after the default from which to fallthrough to. Clang
      will error in this case (unhelpfully without context, see link below)
      and GCC will with -Wswitch-unreachable.
      
      The previous commit should have just replaced the comment with a break
      statement.
      
      If we consider implicit fallthrough to be a design mistake of C, then
      all case statements should be terminated with one of the following
      statements:
      * break
      * continue
      * return
      * fallthrough
      * goto
      * (call of function with __attribute__(__noreturn__))
      
      Fixes: 2a1390c95a69 ("nfs: Convert to use the preferred fallthrough macro")
      Link: https://bugs.llvm.org/show_bug.cgi?id=47539Acked-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Suggested-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      fb08334b
  2. 24 Sep, 2020 2 commits
  3. 21 Sep, 2020 33 commits
  4. 20 Sep, 2020 3 commits