aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-07-13xprtrdma: Pre-mark remotely invalidated MRsChuck Lever4-5/+28
There are rare cases where an rpcrdma_req and its matched rpcrdma_rep can be re-used, via rpcrdma_buffer_put, while the RPC reply handler is still using that req. This is typically due to a signal firing at just the wrong instant. As part of closing this race window, avoid using the wrong rpcrdma_rep to detect remotely invalidated MRs. Mark MRs as invalidated while we are sure the rep is still OK to use. BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=305 Fixes: 68791649a725 ('xprtrdma: Invalidate in the RPC reply ... ') Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13xprtrdma: On invalidation failure, remove MWs from rl_registeredChuck Lever1-0/+1
Callers assume the ro_unmap_sync and ro_unmap_safe methods empty the list of registered MRs. Ensure that all paths through fmr_op_unmap_sync() remove MWs from that list. Fixes: 9d6b04097882 ("xprtrdma: Place registered MWs on a ... ") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: check for nfs_refresh_inode() errors in nfs_fhget()NeilBrown1-2/+8
If an NFS server returns a filehandle that we have previously seen, and reports a different type, then nfs_refresh_inode() will log a warning and return an error. nfs_fhget() does not check for this error and may return an inode with a different type than the one that the server reported. This is likely to cause confusion, and is one way that ->open_context() could return a directory inode as discussed in the previous patch. So if nfs_refresh_inode() returns and error, return that error from nfs_fhget() to avoid the confusion propagating. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: guard against confused server in nfs_atomic_open()NeilBrown1-2/+4
A confused server could return a filehandle for an NFSv4 OPEN request, which it previously returned for a directory. So the inode returned by ->open_context() in nfs_atomic_open() could conceivably be a directory inode. This has particular implications for the call to nfs_file_set_open_context() in nfs_finish_open(). If that is called on a directory inode, then the nfs_open_context that gets stored in the filp->private_data will be linked to nfs_inode->open_files. When the directory is closed, nfs_closedir() will (ultimately) free the ->private_data, but not unlink it from nfs_inode->open_files (because it doesn't expect an nfs_open_context there). Subsequently the memory could get used for something else and eventually if the ->open_files list is walked, the walker will fall off the end and crash. So: change nfs_finish_open() to only call nfs_file_set_open_context() for regular-file inodes. This failure mode has been seen in a production setting (unknown NFS server implementation). The kernel was v3.0 and the specific sequence seen would not affect more recent kernels, but I think a risk is still present, and caution is wise. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: only invalidate dentrys that are clearly invalid.NeilBrown2-6/+10
Since commit bafc9b754f75 ("vfs: More precise tests in d_invalidate") in v3.18, a return of '0' from ->d_revalidate() will cause the dentry to be invalidated even if it has filesystems mounted on or it or on a descendant. The mounted filesystem is unmounted. This means we need to be careful not to return 0 unless the directory referred to truly is invalid. So -ESTALE or -ENOENT should invalidate the directory. Other errors such a -EPERM or -ERESTARTSYS should be returned from ->d_revalidate() so they are propagated to the caller. A particular problem can be demonstrated by: 1/ mount an NFS filesystem using NFSv3 on /mnt 2/ mount any other filesystem on /mnt/foo 3/ ls /mnt/foo 4/ turn off network, or otherwise make the server unable to respond 5/ ls /mnt/foo & 6/ cat /proc/$!/stack # note that nfs_lookup_revalidate is in the call stack 7/ kill -9 $! # this results in -ERESTARTSYS being returned 8/ observe that /mnt/foo has been unmounted. This patch changes nfs_lookup_revalidate() to only treat -ESTALE from nfs_lookup_verify_inode() and -ESTALE or -ENOENT from ->lookup() as indicating an invalid inode. Other errors are returned. Also nfs_check_inode_attributes() is changed to return -ESTALE rather than -EIO. This is consistent with the error returned in similar circumstances from nfs_update_inode(). As this bug allows any user to unmount a filesystem mounted on an NFS filesystem, this fix is suitable for stable kernels. Fixes: bafc9b754f75 ("vfs: More precise tests in d_invalidate") Cc: [email protected] (v3.18+) Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13PNFS for stateid errors retry against MDS firstOlga Kornievskaia2-61/+0
Upon receiving a stateid error such as BAD_STATEID, the client should retry the operation against the MDS before deciding to do stateid recovery. Previously, the code would initiate state recovery and it could lead to a race in a state manager that could chose an incorrect recovery method which would lead to the EIO failure for the application. Signed-off-by: Olga Kornievskaia <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13PNFS fix EACCESS on commit to DS handlingOlga Kornievskaia1-1/+2
Commit fabbbee0eb0f "PNFS fix fallback to MDS if got error on commit to DS" moved the pnfs_set_lo_fail() to unhandled errors which was not correct and lead to a kernel oops on umount. Instead, fix the original EACCESS on commit to DS error by getting the new layout and re-doing the IO. Fixes: fabbbee0eb0f ("PNFS fix fallback to MDS if got error on commit to DS") Signed-off-by: Olga Kornievskaia <[email protected]> Cc: [email protected] # v4.12 Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: silence a uninitialized variable warningDan Carpenter1-1/+2
Static checkers have gotten clever enough to complain that "id_long" is uninitialized on the failure path. It's harmless, but simple to fix. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13nfs: Fix fscache stat printing in nfs_show_stats()Tuo Chen Peng1-1/+1
nfs_show_stats() was incorrectly reading statistics for bytes when printing that for fsc. It caused files like /proc/self/mountstats to report incorrect fsc statistics for NFS mounts. Signed-off-by: Tuo Chen Peng <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: Fix initialization of nfs_page_array->npagesBenjamin Coddington1-0/+1
Commit 8ef9b0b9e1c0 open-coded nfs_pgarray_set(), and left out the initialization of the nfs_page_array's npages. This mistake didn't show up until testing with block layouts, and there shows that all pNFS reads return -EIO. Fixes: 8ef9b0b9e1c0 ("NFS: move nfs_pgarray_set() to open code") Signed-off-by: Benjamin Coddington <[email protected]> Cc: [email protected] # 4.12 Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: Fix commit policy for non-blocking calls to nfs_write_inode()Trond Myklebust1-1/+1
Now that the writes will schedule a commit on their own, we don't need nfs_write_inode() to schedule one if there are outstanding writes, and we're being called in non-blocking mode. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: Ensure we commit after writeback is completeTrond Myklebust4-0/+63
If the page cache is being flushed, then we want to ensure that we do start a commit once the pages are done being flushed. If we just wait until all I/O is done to that file, we can end up livelocking until the balance_dirty_pages() mechanism puts its foot down and forces I/O to stop. So instead we do more or less the same thing that O_DIRECT does, and set up a counter to tell us when the flush is done, Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: Remove unused fields in the page I/O structuresTrond Myklebust3-4/+0
Remove the 'layout_private' fields that were only used by the pNFS OSD layout driver. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13SUNRPC: Make slot allocation more reliableTrond Myklebust1-3/+5
In xprt_alloc_slot(), the spin lock is only needed to provide atomicity between the atomic_add_unless() failure and the call to xprt_add_backlog(). We do not actually need to hold it across the memory allocation itself. By dropping the lock, we can use a more resilient GFP_NOFS allocation, just as we now do in the rest of the RPC client code. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: nfs_rename() - revalidate directories on -ERESTARTSYSBenjamin Coddington3-1/+19
An interrupted rename will leave the old dentry behind if the rename succeeds. Fix this by forcing a lookup the next time through ->d_revalidate. A previous attempt at solving this problem took the approach to complete the work of the rename asynchronously, however that approach was wrong since it would allow the d_move() to occur after the directory's i_mutex had been dropped by the original process. Signed-off-by: Benjamin Coddington <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: convert flags to boolBenjamin Coddington9-42/+42
NFS uses some int, and unsigned int :1, and bool as flags in structs and args. Assert the preference for uniformly replacing these with the bool type. Signed-off-by: Benjamin Coddington <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13NFS: Set FATTR4_WORD0_TYPE for . and .. entriesAnna Schumaker1-4/+7
The current code worked okay for getdents(), but getdents64() expects the d_type field to get filled out properly in the stat structure. Setting this field fixes xfstests generic/401. Signed-off-by: Anna Schumaker <[email protected]>
2017-07-13nfsd4: const-ify nfsd4_opsChristoph Hellwig1-7/+6
nfsd4_ops contains function pointers, and marking it as constant avoids it being able to be used as an attach vector for code injections. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: mark all struct svc_version instances as constChristoph Hellwig14-65/+65
Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc: mark all struct svc_procinfo instances as constChristoph Hellwig12-15/+15
struct svc_procinfo contains function pointers, and marking it as constant avoids it being able to be used as an attach vector for code injections. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: move pc_count out of struct svc_procinfoChristoph Hellwig10-7/+28
pc_count is the only writeable memeber of struct svc_procinfo, which is a good candidate to be const-ified as it contains function pointers. This patch moves it into out out struct svc_procinfo, and into a separate writable array that is pointed to by struct svc_version. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd4: properly type op_func callbacksChristoph Hellwig3-173/+209
Pass union nfsd4_op_u to the op_func callbacks instead of using unsafe function pointer casts. It also adds two missing structures to struct nfsd4_op.u to facilitate this. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd4: remove nfsd4op_rsizeChristoph Hellwig1-55/+54
Except for a lot of unnecessary casts this typedef only has one user, so remove the casts and expand it in struct nfsd4_operation. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd4: properly type op_get_currentstateid callbacksChristoph Hellwig3-35/+50
Pass union nfsd4_op_u to the op_set_currentstateid callbacks instead of using unsafe function pointer casts. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd4: properly type op_set_currentstateid callbacksChristoph Hellwig4-19/+27
Given the args union in struct nfsd4_op a name, and pass it to the op_set_currentstateid callbacks instead of using unsafe function pointer casts. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: remove kxdrproc_tChristoph Hellwig1-7/+0
Remove the now unused typedef. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: properly type pc_encode callbacksChristoph Hellwig21-170/+185
Drop the resp argument as it can trivially be derived from the rqstp argument. With that all functions now have the same prototype, and we can remove the unsafe casting to kxdrproc_t. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc: properly type pc_decode callbacksChristoph Hellwig21-209/+237
Drop the argp argument as it can trivially be derived from the rqstp argument. With that all functions now have the same prototype, and we can remove the unsafe casting to kxdrproc_t. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: properly type pc_release callbacksChristoph Hellwig12-66/+63
Drop the p and resp arguments as they are always NULL or can trivially be derived from the rqstp argument. With that all functions now have the same prototype, and we can remove the unsafe casting to kxdrproc_t. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: properly type pc_func callbacksChristoph Hellwig11-227/+328
Drop the argp and resp arguments as they can trivially be derived from the rqstp argument. With that all functions now have the same prototype, and we can remove the unsafe casting to svc_procfunc as well as the svc_procfunc typedef itself. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd: remove the unused PROC() macro in nfs3proc.cChristoph Hellwig1-12/+0
Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd: use named initializers in PROC()Christoph Hellwig3-27/+27
Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13nfsd4: const-ify nfs_cb_version4Christoph Hellwig1-1/+1
Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: mark all struct rpc_procinfo instances as constChristoph Hellwig16-30/+31
struct rpc_procinfo contains function pointers, and marking it as constant avoids it being able to be used as an attach vector for code injections. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13nfs: use ARRAY_SIZE() in the nfsacl_version3 declarationChristoph Hellwig1-2/+1
Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13sunrpc: move p_count out of struct rpc_procinfoChristoph Hellwig13-15/+44
p_count is the only writeable memeber of struct rpc_procinfo, which is a good candidate to be const-ified as it contains function pointers. This patch moves it into out out struct rpc_procinfo, and into a separate writable array that is pointed to by struct rpc_version and indexed by p_statidx. Signed-off-by: Christoph Hellwig <[email protected]>
2017-07-13lockd: fix some weird indentationChristoph Hellwig2-19/+19
Remove double indentation of a few struct rpc_version and struct rpc_program instance. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13nfs: don't cast callback decode/proc/encode routinesChristoph Hellwig3-69/+77
Instead declare all functions with the proper methods signature. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13nfs: fix decoder callback prototypesChristoph Hellwig5-84/+151
Declare the p_decode callbacks with the proper prototype instead of casting to kxdrdproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13lockd: fix decoder callback prototypesChristoph Hellwig3-10/+16
Declare the p_decode callbacks with the proper prototype instead of casting to kxdrdproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13nfsd: fix decoder callback prototypesChristoph Hellwig1-4/+7
Declare the p_decode callbacks with the proper prototype instead of casting to kxdrdproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
2017-07-13sunrpc/auth_gss: fix decoder callback prototypesChristoph Hellwig3-3/+4
Declare the p_decode callbacks with the proper prototype instead of casting to kxdrdproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc: fix decoder callback prototypesChristoph Hellwig1-12/+15
Declare the p_decode callbacks with the proper prototype instead of casting to kxdrdproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
2017-07-13sunrpc: properly type argument to kxdrdproc_tChristoph Hellwig2-2/+4
Pass struct rpc_request as the first argument instead of an untyped blob. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc/auth_gss: nfsd: fix encoder callback prototypesChristoph Hellwig3-7/+8
Declare the p_encode callbacks with the proper prototype instead of casting to kxdreproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13nfsd: fix encoder callback prototypesChristoph Hellwig1-5/+8
Declare the p_encode callbacks with the proper prototype instead of casting to kxdreproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
2017-07-13nfs: fix encoder callback prototypesChristoph Hellwig5-122/+242
Declare the p_encode callbacks with the proper prototype instead of casting to kxdreproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13lockd: fix encoder callback prototypesChristoph Hellwig3-18/+34
Declare the p_encode callbacks with the proper prototype instead of casting to kxdreproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc: fix encoder callback prototypesChristoph Hellwig1-11/+13
Declare the p_encode callbacks with the proper prototype instead of casting to kxdreproc_t and losing all type safety. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Trond Myklebust <[email protected]>
2017-07-13sunrpc: properly type argument to kxdreproc_tChristoph Hellwig2-2/+6
Pass struct rpc_request as the first argument instead of an untyped blob, and mark the data object as const. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]>