01 Feb, 2017
2 commits
-
commit a430607b2ef7c3be090f88c71cfcb1b3988aa7c0 upstream.
Some nfsv4.0 servers may return a mode for the verifier following an open
with EXCLUSIVE4 createmode, but this does not mean the client should skip
setting the mode in the following SETATTR. It should only do that for
EXCLUSIVE4_1 or UNGAURDED createmode.Fixes: 5334c5bdac92 ("NFS: Send attributes in OPEN request for NFS4_CREATE_EXCLUSIVE4_1")
Signed-off-by: Benjamin Coddington
Signed-off-by: Trond Myklebust
Signed-off-by: Greg Kroah-Hartman -
commit 8ac092519ad91931c96d306c4bfae2c6587c325f upstream.
We cannot call nfs4_handle_exception() without first ensuring that the
slot has been freed. If not, we end up deadlocking with the process
waiting for recovery to complete, and recovery waiting for the slot
table to drain.Fixes: 2e80dbe7ac51 ("NFSv4.1: Close callback races for OPEN, LAYOUTGET...")
Signed-off-by: Trond Myklebust
Signed-off-by: Greg Kroah-Hartman
24 Nov, 2016
1 commit
-
Pull NFS client bugfixes from Anna Schumaker:
"Most of these fix regressions or races, but there is one patch for
stable that Arnd sent meStable bugfix:
- Hide array-bounds warningBugfixes:
- Keep a reference on lock states while checking
- Handle NFS4ERR_OLD_STATEID in nfs4_reclaim_open_state
- Don't call close if the open stateid has already been cleared
- Fix CLOSE rases with OPEN
- Fix a regression in DELEGRETURN"* tag 'nfs-for-4.9-4' of git://git.linux-nfs.org/projects/anna/linux-nfs:
NFSv4.x: hide array-bounds warning
NFSv4.1: Keep a reference on lock states while checking
NFSv4.1: Handle NFS4ERR_OLD_STATEID in nfs4_reclaim_open_state
NFSv4: Don't call close if the open stateid has already been cleared
NFSv4: Fix CLOSE races with OPEN
NFSv4.1: Fix a regression in DELEGRETURN
22 Nov, 2016
1 commit
-
While walking the list of lock_states, keep a reference on each
nfs4_lock_state to be checked, otherwise the lock state could be removed
while the check performs TEST_STATEID and possible FREE_STATEID.Signed-off-by: Benjamin Coddington
Signed-off-by: Anna Schumaker
19 Nov, 2016
3 commits
-
Ensure we test to see if the open stateid is actually set, before we
send a CLOSE.Signed-off-by: Trond Myklebust
Signed-off-by: Anna Schumaker -
If the reply to a successful CLOSE call races with an OPEN to the same
file, we can end up scribbling over the stateid that represents the
new open state.
The race looks like:Client Server
====== ======CLOSE stateid A on file "foo"
CLOSE stateid A, return stateid C
OPEN file "foo"
OPEN "foo", return stateid B
Receive reply to OPEN
Reset open state for "foo"
Associate stateid B to "foo"Receive CLOSE for A
Reset open state for "foo"
Replace stateid B with CThe fix is to examine the argument of the CLOSE, and check for a match
with the current stateid "other" field. If the two do not match, then
the above race occurred, and we should just ignore the CLOSE.Reported-by: Benjamin Coddington
Signed-off-by: Trond Myklebust
Signed-off-by: Anna Schumaker -
We don't want to call nfs4_free_revoked_stateid() in the case where
the delegreturn was successful.Reported-by: Benjamin Coddington
Signed-off-by: Trond Myklebust
Signed-off-by: Anna Schumaker
22 Oct, 2016
1 commit
-
Pull NFS client bugfixes from Anna Schumaker:
"Just two bugfixes this time:Stable bugfix:
- Fix last_write_offset incorrectly set to page boundaryOther bugfix:
- Fix missing-braces warning"* tag 'nfs-for-4.9-2' of git://git.linux-nfs.org/projects/anna/linux-nfs:
nfs4: fix missing-braces warning
pnfs/blocklayout: fix last_write_offset incorrectly set to page boundary
20 Oct, 2016
1 commit
-
A bugfix introduced a harmless warning for update_open_stateid:
fs/nfs/nfs4proc.c:1548:2: error: missing braces around initializer [-Werror=missing-braces]
Removing the zero in the initializer will do the right thing here
and initialize the entire structure to zero.Fixes: 1393d9612ba0 ("NFSv4: Fix a race when updating an open_stateid")
Signed-off-by: Arnd Bergmann
Signed-off-by: Anna Schumaker
14 Oct, 2016
1 commit
-
Pull NFS client updates from Anna Schumaker:
"Highlights include:Stable bugfixes:
- sunrpc: fix writ espace race causing stalls
- NFS: Fix inode corruption in nfs_prime_dcache()
- NFSv4: Don't report revoked delegations as valid in nfs_have_delegation()
- NFSv4: nfs4_copy_delegation_stateid() must fail if the delegation is invalid
- NFSv4: Open state recovery must account for file permission changes
- NFSv4.2: Fix a reference leak in nfs42_proc_layoutstats_genericFeatures:
- Add support for tracking multiple layout types with an ordered list
- Add support for using multiple backchannel threads on the client
- Add support for pNFS file layout session trunking
- Delay xprtrdma use of DMA API (for device driver removal)
- Add support for xprtrdma remote invalidation
- Add support for larger xprtrdma inline thresholds
- Use a scatter/gather list for sending xprtrdma RPC calls
- Add support for the CB_NOTIFY_LOCK callback
- Improve hashing sunrpc auth_creds by using both uid and gidBugfixes:
- Fix xprtrdma use of DMA API
- Validate filenames before adding to the dcache
- Fix corruption of xdr->nwords in xdr_copy_to_scratch
- Fix setting buffer length in xdr_set_next_buffer()
- Don't deadlock the state manager on the SEQUENCE status flags
- Various delegation and stateid related fixes
- Retry operations if an interrupted slot receives EREMOTEIO
- Make nfs boot time y2038 safe"* tag 'nfs-for-4.9-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (100 commits)
NFSv4.2: Fix a reference leak in nfs42_proc_layoutstats_generic
fs: nfs: Make nfs boot time y2038 safe
sunrpc: replace generic auth_cred hash with auth-specific function
sunrpc: add RPCSEC_GSS hash_cred() function
sunrpc: add auth_unix hash_cred() function
sunrpc: add generic_auth hash_cred() function
sunrpc: add hash_cred() function to rpc_authops struct
Retry operation on EREMOTEIO on an interrupted slot
pNFS: Fix atime updates on pNFS clients
sunrpc: queue work on system_power_efficient_wq
NFSv4.1: Even if the stateid is OK, we may need to recover the open modes
NFSv4: If recovery failed for a specific open stateid, then don't retry
NFSv4: Fix retry issues with nfs41_test/free_stateid
NFSv4: Open state recovery must account for file permission changes
NFSv4: Mark the lock and open stateids as invalid after freeing them
NFSv4: Don't test open_stateid unless it is set
NFSv4: nfs4_do_handle_exception() handle revoke/expiry of a single stateid
NFS: Always call nfs_inode_find_state_and_recover() when revoking a delegation
NFSv4: Fix a race when updating an open_stateid
NFSv4: Fix a race in nfs_inode_reclaim_delegation()
...
08 Oct, 2016
1 commit
-
These inode operations are no longer used; remove them.
Signed-off-by: Andreas Gruenbacher
Signed-off-by: Al Viro
05 Oct, 2016
1 commit
-
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.boot_time is used to construct the nfs client boot verifier.
Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.Use higher and lower 32 bit parts of ktime_t for the boot
verifier.Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.Signed-off-by: Deepa Dinamani
Reviewed-by: Arnd Bergmann
Cc: Trond Myklebust
Cc: Anna Schumaker
Cc: linux-nfs@vger.kernel.org
Signed-off-by: Anna Schumaker
30 Sep, 2016
1 commit
-
If an operation got interrupted, then since we don't know if the
server processed it on not, we keep the seq#. Upon reuse of slot
and seq# if we get reply from the cache (ie EREMOTEIO) then we
need to retry the operation after bumping the seq#Signed-off-by: Olga Kornievskaia
Signed-off-by: Anna Schumaker
28 Sep, 2016
22 commits
-
Fix the code so that we always mark the atime as invalid in nfs4_read_done().
Currently, the expectation appears to be that the pNFS drivers should always
do this, with the result that most of them don't.Signed-off-by: Trond Myklebust
Signed-off-by: Anna Schumaker -
TEST_STATEID only tells you that you have a valid open stateid. It doesn't
tell the client anything about whether or not it holds the required share
locks.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
[Anna: Wrap nfs_open_stateid_recover_openmode in CONFIG_NFS_V4_1 checks]
Signed-off-by: Anna Schumaker -
_nfs41_free_stateid() needs to be cached by the session, but
nfs41_test_stateid() may return NFS4ERR_RETRY_UNCACHED_REP (in which
case we should just retry).Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
We need to test the NFS_OPEN_STATE flag for whether or not the
open_stateid is valid.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If we're not yet sure that all state has expired or been revoked, we
should try to do a minimal recovery on just the one stateid.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If we're replacing an old stateid which has a different 'other' field,
then we probably need to free the old stateid.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
The actual stateid used in the READ or WRITE can represent a delegation,
a lock or a stateid, so it is useful to pass it as an argument to the
exception handler when an expired/revoked response is received from the
server. It also ensures that we don't re-label the state as needing
recovery if that has already occurred.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Handle revoked open/lock/delegation stateids when LAYOUTGET tells us
the state was revoked.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If the server tells us our stateid has expired, then handle that as if
it was revoked.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If the server tells us our stateid has expired, then handle that as if
it was revoked.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If a server returns NFS4ERR_ADMIN_REVOKED, NFS4ERR_DELEG_REVOKED
or NFS4ERR_EXPIRED on a call to close, open_downgrade, delegreturn, or
locku, we should call FREE_STATEID before attempting to recover.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Nothing should need to be serialised with FREE_STATEID on the client,
so let's make the RPC call always asynchronous. Also constify the
stateid argument.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Right now, we're only running TEST/FREE_STATEID on the locks if
the open stateid recovery succeeds. The protocol requires us to
always do so.
The fix would be to move the call to TEST/FREE_STATEID and do it
before we attempt open recovery.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
In some cases (e.g. when the SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED sequence
flag is set) we may already know that the stateid was revoked and that the
only valid operation we can call is FREE_STATEID. In those cases, allow
the stateid to carry the information in the type field, so that we skip
the redundant call to TEST_STATEID.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Ensure we don't spam the server with test_stateid() calls for
delegations that have already been checked.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
According to RFC5661, if any of the SEQUENCE status bits
SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED,
SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, SEQ4_STATUS_ADMIN_STATE_REVOKED,
or SEQ4_STATUS_RECALLABLE_STATE_REVOKED are set, then we need to use
TEST_STATEID to figure out which stateids have been revoked, so we
can acknowledge the loss of state using FREE_STATEID.While we already do this for open and lock state, we have not been doing
so for all the delegations.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
Allow the callers of nfs_remove_bad_delegation() to specify the stateid
that needs to be marked as bad.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
In NFSv4.1 and newer, if the server decides to revoke some or all of
the protocol state, the client is required to iterate through all the
stateids that it holds and call TEST_STATEID to determine which stateids
still correspond to valid state, and then call FREE_STATEID on the
others.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If the server crashes while we're testing stateids for validity, then
we want to initiate session recovery. Usually, we will be calling from
a state manager thread, though, so we don't really want to wait.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker -
If the delegation has been marked as revoked, we don't have to test
it, because we should already have called FREE_STATEID on it.Signed-off-by: Trond Myklebust
Tested-by: Olek Drokin
Signed-off-by: Anna Schumaker -
As described in RFC5661, section 18.46, some of the status flags exist
in order to tell the client when it needs to acknowledge the existence of
revoked state on the server and/or to recover state.
Those flags will then remain set until the recovery procedure is done.In order to avoid looping, the client therefore needs to ignore
those particular flags while recovering.Signed-off-by: Trond Myklebust
Tested-by: Oleg Drokin
Signed-off-by: Anna Schumaker
23 Sep, 2016
5 commits
-
Add a waitqueue head to the client structure. Have clients set a wait
on that queue prior to requesting a lock from the server. If the lock
is blocked, then we can use that to wait for wakeups.Note that we do need to do this "manually" since we need to set the
wait on the waitqueue prior to requesting the lock, but requesting a
lock can involve activities that can block.However, only do that for NFSv4.1 locks, either by compiling out
all of the waitqueue handling when CONFIG_NFS_V4_1 is disabled, or
skipping all of it at runtime if we're dealing with v4.0, or v4.1
servers that don't send lock callbacks.Note too that even when we expect to get a lock callback, RFC5661
section 20.11.4 is pretty clear that we still need to poll for them,
so we do still sleep on a timeout. We do however always poll at the
longest interval in that case.Signed-off-by: Jeff Layton
[Anna: nfs4_retry_setlk() "status" should default to -ERESTARTSYS]
Signed-off-by: Anna Schumaker -
This also consolidates the waiting logic into a single function,
instead of having it spread across two like it is now.Signed-off-by: Jeff Layton
Signed-off-by: Anna Schumaker -
We need to have this info set up before adding the waiter to the
waitqueue, so move this out of the _nfs4_proc_setlk and into the
caller. That's more efficient anyway since we don't need to do
this more than once if we end up waiting on the lock.Signed-off-by: Jeff Layton
Signed-off-by: Anna Schumaker -
We want to handle the two cases differently, such that we poll more
aggressively when we don't expect a callback.Signed-off-by: Jeff Layton
Signed-off-by: Anna Schumaker -
We actually want to use TASK_INTERRUPTIBLE sleeps when we're in the
process of polling for a NFSv4 lock. If there is a signal pending when
the task wakes up, then we'll be returning an error anyway. So, we might
as well wake up immediately for non-fatal signals as well. That allows
us to return to userland more quickly in that case, but won't change the
error that userland sees.Also, there is no need to use the *_unsafe sleep variants here, as no
vfs-layer locks should be held at this point.Signed-off-by: Jeff Layton
Signed-off-by: Anna Schumaker