summaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * nfsd4: fix setclientid_confirm same_cred checkJ. Bruce Fields2012-05-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New clients are created only by nfsd4_setclientid(), which always gives any new client a unique clientid. The only exception is in the "callback update" case, in which case it may create an unconfirmed client with the same clientid as a confirmed client. In that case it also checks that the confirmed client has the same credential. Therefore, it is pointless for setclientid_confirm to check whether a confirmed and unconfirmed client with the same clientid have matching credentials--they're guaranteed to. Instead, it should be checking whether the credential on the setclientid_confirm matches either of those. Otherwise, it could be anyone sending the setclientid_confirm. Granted, I can't see why anyone would, but still it's probalby safer to check. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: merge 3 setclientid cases to 2J. Bruce Fields2012-05-311-7/+2
| | | | | | | | | | | | Boy, is this simpler. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: pull out common code from setclientid casesJ. Bruce Fields2012-05-311-21/+5
| | | | | | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: merge last two setclientid casesJ. Bruce Fields2012-05-311-9/+4
| | | | | | | | | | | | The code here is mostly the same. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: setclientid/confirm comment cleanupJ. Bruce Fields2012-05-311-56/+11
| | | | | | | | | | | | Be a little more concise. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: setclientid remove unnecessary terms from a logical expressionJ. Bruce Fields2012-05-311-3/+2
| | | | | | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: move rq_flavor into svc_credJ. Bruce Fields2012-05-311-3/+3
| | | | | | | | | | | | | | Move the rq_flavor into struct svc_cred, and use it in setclientid and exchange_id comparisons as well. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: stricter cred comparison for setclientid/exchange_idJ. Bruce Fields2012-05-311-1/+21
| | | | | | | | | | | | | | | | | | The typical setclientid or exchange_id will probably be performed with a credential that maps to either root or nobody, so comparing just uid's is unlikely to be useful. So, use everything else we can get our hands on. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: move principal name into svc_credJ. Bruce Fields2012-05-311-17/+17
| | | | | | | | | | | | | | | | Instead of keeping the principal name associated with a request in a structure that's private to auth_gss and using an accessor function, move it to svc_cred. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: allow removing clients not holding stateJ. Bruce Fields2012-05-311-2/+19
| | | | | | | | | | | | | | | | RFC 5661 actually says we should allow an exchange_id to remove a matching client, even if the exchange_id comes from a different principal, *if* the victim client lacks any state. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: rearrange exchange_id logic to simplifyJ. Bruce Fields2012-05-311-20/+20
| | | | | | | | | | | | | | Minor cleanup: it's simpler to have separate code paths for the update and non-update cases. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: exchange_id cleanup: commentsJ. Bruce Fields2012-05-311-26/+10
| | | | | | | | | | | | Make these comments a bit more concise and uniform. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: exchange_id cleanup: local shorthands for repeated testsJ. Bruce Fields2012-05-311-6/+10
| | | | | | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: allow an EXCHANGE_ID to kill a 4.0 clientJ. Bruce Fields2012-05-311-2/+8
| | | | | | | | | | | | | | | | | | Following rfc 5661 section 2.4.1, we can permit a 4.1 client to remove an established 4.0 client's state. (But we don't allow updates.) Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: exchange_id: check creds before killing confirmed clientJ. Bruce Fields2012-05-311-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | We mustn't allow a client to destroy another client with established state unless it has the right credential. And some minor cleanup. (Note: our comparison of credentials is actually pretty bogus currently; that will need to be fixed in another patch.) Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: exchange_id error cleanupJ. Bruce Fields2012-05-311-5/+1
| | | | | | | | | | | | | | There's no point to the dprintk here as the main proc_compound loop already does this. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: exchange_id has a pointless copyJ. Bruce Fields2012-05-311-1/+0
| | | | | | | | | | | | We just verified above that these two verifiers are already the same. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: wrap all accesses to st_deny_bmapJeff Layton2012-05-311-8/+29
| | | | | | | | | | | | | | | | Handle the st_deny_bmap in a similar fashion to the st_access_bmap. Add accessor functions and use those instead of bare bitops. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: wrap accesses to st_access_bmapJeff Layton2012-05-311-28/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we do this for the most part with "bare" bitops, but eventually we'll need to expand the share mode code to handle access and deny modes on other nodes. In order to facilitate that code in the future, move to some generic accessor functions. For now, these are mostly static inlines, but eventually we'll want to move these to "real" functions that are able to handle multi-node configurations or have a way to "swap in" new operations to be done in lieu of or in conjunction with these atomic bitops. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: make test_share a bool returnJeff Layton2012-05-311-3/+3
| | | | | | | | | | | | | | All of the callers treat the return that way already. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: consolidate set_access and set_denyJeff Layton2012-05-311-17/+7
| | | | | | | | | | | | | | | | | | These functions are identical. Also, rename them to bmap_to_share_mode to better reflect what they do, and have them just return the result instead of passing in a pointer to the storage location. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * NFSD: SETCLIENTID_CONFIRM returns NFS4ERR_CLID_INUSE too oftenChuck Lever2012-05-311-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC 3530bis, the only items SETCLIENTID_CONFIRM processing should be concerned with is the clientid, clientid verifier, and principal. The client's IP address is not supposed to be interesting. And, NFS4ERR_CLID_INUSE is meant only for principal mismatches. I triggered this logic with a prototype UCS client -- one that uses the same nfs_client_id4 string for all servers. The client mounted our server via its IPv4, then via its IPv6 address. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: int/__be32 fixesJ. Bruce Fields2012-05-311-11/+11
| | | | | | | | | | | | | | In each of these cases there's a simple unambiguous correct choice, and no actual bug. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd4: fix missing "static"J. Bruce Fields2012-05-311-1/+1
| | | | | | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: state.c should include current_stateid.hJ. Bruce Fields2012-05-311-0/+1
| | | | | | | | | | | | OK, admittedly I'm mainly just trying to shut sparse up. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | Merge branch 'for-3.5-take-2' of git://linux-nfs.org/~bfields/linuxLinus Torvalds2012-05-311-4/+9
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull nfsd update from Bruce Fields. * 'for-3.5-take-2' of git://linux-nfs.org/~bfields/linux: (23 commits) nfsd: trivial: use SEEK_SET instead of 0 in vfs_llseek SUNRPC: split upcall function to extract reusable parts nfsd: allocate id-to-name and name-to-id caches in per-net operations. nfsd: make name-to-id cache allocated per network namespace context nfsd: make id-to-name cache allocated per network namespace context nfsd: pass network context to idmap init/exit functions nfsd: allocate export and expkey caches in per-net operations. nfsd: make expkey cache allocated per network namespace context nfsd: make export cache allocated per network namespace context nfsd: pass pointer to export cache down to stack wherever possible. nfsd: pass network context to export caches init/shutdown routines Lockd: pass network namespace to creation and destruction routines NFSd: remove hard-coded dereferences to name-to-id and id-to-name caches nfsd: pass pointer to expkey cache down to stack wherever possible. nfsd: use hash table from cache detail in nfsd export seq ops nfsd: pass svc_export_cache pointer as private data to "exports" seq file ops nfsd: use exp_put() for svc_export_cache put nfsd: use cache detail pointer from svc_export structure on cache put nfsd: add link to owner cache detail to svc_export structure nfsd: use passed cache_detail pointer expkey_parse() ...
| * nfsd: don't use locks_in_grace to determine whether to call nfs4_grace_endJeff Layton2012-04-111-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's possible that lockd or another lock manager might still be on the list after we call nfsd4_end_grace. If the laundromat thread runs again at that point, then we could end up calling nfsd4_end_grace more than once. That's not only inefficient, but calling nfsd4_recdir_purge_old more than once could be problematic. Fix this by adding a new global "grace_ended" flag and use that to determine whether we've already called nfsd4_grace_end. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| * nfsd: trivial: remove unused variable from nfsd4_lockJeff Layton2012-04-111-2/+0
| | | | | | | | | | | | | | ..."fp" is set but never used. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd: fix error values returned by nfsd4_lockt() when nfsd_open() failsAl Viro2012-04-131-14/+9
|/ | | | | | | | | nfsd_open() already returns an NFS error value; only vfs_test_lock() result needs to be fed through nfserrno(). Broken by commit 55ef12 (nfsd: Ensure nfsv4 calls the underlying filesystem on LOCKT) three years ago... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* nfsd: add nfsd4_client_tracking_ops struct and a way to set itJeff Layton2012-03-261-42/+21
| | | | | | | | | | | | | | | | | | | Abstract out the mechanism that we use to track clients into a set of client name tracking functions. This gives us a mechanism to plug in a new set of client tracking functions without disturbing the callers. It also gives us a way to decide on what tracking scheme to use at runtime. For now, this just looks like pointless abstraction, but later we'll add a new alternate scheme for tracking clients on stable storage. Note too that this patch anticipates the eventual containerization of this code by passing in struct net pointers in places. No attempt is made to containerize the legacy client tracker however. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd: convert nfs4_client->cl_cb_flags to a generic flags fieldJeff Layton2012-03-261-17/+28
| | | | | | | | | | | | | | | | | | | We'll need a way to flag the nfs4_client as already being recorded on stable storage so that we don't continually upcall. Currently, that's recorded in the cl_firststate field of the client struct. Using an entire u32 to store a flag is rather wasteful though. The cl_cb_flags field is only using 2 bits right now, so repurpose that to a generic flags field. Rename NFSD4_CLIENT_KILL to NFSD4_CLIENT_CB_KILL to make it evident that it's part of the callback flags. Add a mask that we can use for existing checks that look to see whether any flags are set, so that the new flags don't interfere. Convert all references to cl_firstate to the NFSD4_CLIENT_STABLE flag, and add a new NFSD4_CLIENT_RECLAIM_COMPLETE flag. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* Merge nfs containerization work from Trond's treeJ. Bruce Fields2012-03-261-1/+1
|\ | | | | | | | | The nfs containerization work is a prerequisite for Jeff Layton's reboot recovery rework.
| * SUNRPC: parametrize rpc_uaddr2sockaddr() by network contextStanislav Kinsbursky2012-01-311-1/+1
| | | | | | | | | | | | | | | | Parametrize rpc_uaddr2sockaddr() by network context and thus force it's callers to pass in network context instead of using hard-coded "init_net". Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
* | NFSD: Fix nfs4_verifier memory alignmentChuck Lever2012-03-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up due to code review. The nfs4_verifier's data field is not guaranteed to be u32-aligned. Casting an array of chars to a u32 * is considered generally hazardous. We can fix most of this by using a __be32 array to generate the verifier's contents and then byte-copying it into the verifier field. However, there is one spot where there is a backwards compatibility constraint: the do_nfsd_create() call expects a verifier which is 32-bit aligned. Fix this spot by forcing the alignment of the create verifier in the nfsd4_open args structure. Also, sizeof(nfs4_verifer) is the size of the in-core verifier data structure, but NFS4_VERIFIER_SIZE is the number of octets in an XDR'd verifier. The two are not interchangeable, even if they happen to have the same value. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | NFSD: Fix warnings when NFSD_DEBUG is not definedTrond Myklebust2012-03-201-0/+8
| | | | | | | | | | Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: free_session/free_client must be called under the client_lockBenny Halevy2012-03-061-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The session client is manipulated under the client_lock hence both free_session and nfsd4_del_conns must be called under this lock. This patch adds a BUG_ON that checks this condition in the respective functions and implements the missing locks. nfsd4_{get,put}_session helpers were moved to the C file that uses them so to prevent use from external files and an unlocked version of nfsd4_put_session is provided for external use from nfs4xdr.c Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: refactor nfsd4_deleg_xgrade_none_ext logic out of nfsd4_process_open2Benny Halevy2012-03-061-15/+20
| | | | | | | | | | | | | | | | | | | | | | Handle the case where the nfsv4.1 client asked to uprade or downgrade its delegations and server returns no delegation. In this case, op_delegate_type is set to NFS4_OPEN_DELEGATE_NONE_EXT and op_why_no_deleg is set respectively to WND4_NOT_SUPP_{UP,DOWN}GRADE Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: refactor nfs4_open_deleg_none_ext logic out of nfs4_open_delegationBenny Halevy2012-03-061-19/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a 4.1 client asks for a delegation and the server returns none op_delegate_type is set to NFS4_OPEN_DELEGATE_NONE_EXT and op_why_no_deleg is set to either WND4_CONTENTION or WND4_RESOURCE. Or, if the client sent a NFS4_SHARE_WANT_CANCEL (which it is not supposed to ever do until our server supports delegations signaling), op_why_no_deleg is set to WND4_CANCELLED. Note that for WND4_CONTENTION and WND4_RESOURCE, the xdr layer is hard coded at this time to encode boolean FALSE for ond_server_will_push_deleg / ond_server_will_signal_avail. Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd4: fix recovery-entry leak nfsd startup failureJ. Bruce Fields2012-03-061-0/+1
| | | | | | | | | | | | Another leak on error Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd4: fix recovery-dir leak on nfsd startup failureJeff Layton2012-03-061-13/+13
| | | | | | | | | | | | | | | | | | The current code never calls nfsd4_shutdown_recdir if nfs4_state_start returns an error. Also, it's better to go ahead and consolidate these functions since one is just a trivial wrapper around the other. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd4: purge stable client records with insufficient stateJ. Bruce Fields2012-03-061-1/+3
| | | | | | | | | | | | | | | | | | | | To escape having your stable storage record purged at the end of the grace period, it's not sufficient to simply have performed a setclientid_confirm; you also need to meet the same requirements as someone creating a new record: either you should have done an open or open reclaim (in the 4.0 case) or a reclaim_complete (in the 4.1 case). Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd4: don't set cl_firststate on first reclaim in 4.1 caseJ. Bruce Fields2012-03-061-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We set cl_firststate when we first decide that a client will be permitted to reclaim state on next boot. This happens: - for new 4.0 clients, when they confirm their first open - for returning 4.0 clients, when they reclaim their first open - for 4.1+ clients, when they perform reclaim_complete We also use cl_firststate to decide whether a reclaim_complete has already been performed, in the 4.1+ case. We were setting it on 4.1 open reclaims, which caused spurious COMPLETE_ALREADY errors on RECLAIM_COMPLETE from an nfs4.1 client with anything to reclaim. Reported-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: implement NFS4_SHARE_WANT_NO_DELEG, NFS4_OPEN_DELEGATE_NONE_EXT, ↵Benny Halevy2012-02-171-7/+53
| | | | | | | | | | | | | | | | | | | | | | | | why_no_deleg Respect client request for not getting a delegation in NFSv4.1 Appropriately return delegation "type" NFS4_OPEN_DELEGATE_NONE_EXT and WND4_NOT_WANTED reason. [nfsd41: add missing break when encoding op_why_no_deleg] Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | NFSD: Clean up the test_stateid functionBryan Schumaker2012-02-171-1/+8
| | | | | | | | | | | | | | | | | | | | | | When I initially wrote it, I didn't understand how lists worked so I wrote something that didn't use them. I think making a list of stateids to test is a more straightforward implementation, especially compared to especially compared to decoding stateids while simultaneously encoding a reply to the client. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: split out share_access want and signal flags while decodingBenny Halevy2012-02-171-3/+3
| | | | | | | | | | Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: share_access_to_flags should consider only nfs4.x share_access flagsBenny Halevy2012-02-171-1/+1
| | | | | | | | | | | | | | | | Currently, it will not correctly ignore any nfsv4.1 signal flags if the client sends them. Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: use current stateid by valueTigran Mkrtchyan2012-02-151-4/+12
| | | | | | | | | | Signed-off-by: Tigran Mkrtchyan <kofemann@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: consume current stateid on DELEGRETURN and OPENDOWNGRADETigran Mkrtchyan2012-02-151-0/+18
| | | | | | | | | | Signed-off-by: Tigran Mkrtchyan <kofemann@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: handle current stateid in SETATTR and FREE_STATEIDTigran Mkrtchyan2012-02-151-0/+13
| | | | | | | | | | Signed-off-by: Tigran Mkrtchyan <kofemann@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* | nfsd41: consume current stateid on read and writeTigran Mkrtchyan2012-02-151-0/+12
| | | | | | | | | | Signed-off-by: Tigran Mkrtchyan <kofemann@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
OpenPOWER on IntegriCloud