• Chuck Lever's avatar
    NFS: Fix up TEST_STATEID and FREE_STATEID return code handling · 377e507d
    Chuck Lever authored
    The TEST_STATEID and FREE_STATEID operations can return
    -NFS4ERR_BAD_STATEID, -NFS4ERR_OLD_STATEID, or -NFS4ERR_DEADSESSION.
    
    nfs41_{test,free}_stateid() should not pass these errors to
    nfs4_handle_exception() during state recovery, since that will
    recursively kick off state recovery again, resulting in a deadlock.
    
    In particular, when the TEST_STATEID operation returns NFS4_OK,
    res.status can contain one of these errors.  _nfs41_test_stateid()
    replaces NFS4_OK with the value in res.status, which is then returned
    to callers.
    
    But res.status is not passed through nfs4_stat_to_errno(), and thus is
    a positive NFS4ERR value.  Currently callers are only interested in
    !NFS4_OK, and nfs4_handle_exception() ignores positive values.
    
    Thus the res.status values are currently ignored by
    nfs4_handle_exception() and won't cause the deadlock above.  Thanks to
    this missing negative, it is only when these operations fail (which
    is very rare) that a deadlock can occur.
    
    Bryan agrees the original intent was to return res.status as a
    negative NFS4ERR value to callers of nfs41_test_stateid().
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
    377e507d
nfs4proc.c 181 KB