summaryrefslogtreecommitdiffstats
path: root/fs/nfs
Commit message (Collapse)AuthorAgeFilesLines
* NFS: Fix an ABBA spinlock issue in pnfs_update_layout()Trond Myklebust2020-04-131-1/+2
| | | | | | | | | | | We need to drop the inode spinlock while calling nfs4_select_rw_stateid(), since nfs4_copy_delegation_stateid() could take the delegation lock. Note that it is safe to do this, since all other calls to pnfs_update_layout() for that inode will find themselves blocked by the lock we hold on NFS_LAYOUT_FIRST_LAYOUTGET. Fixes: fc51b1cf391d ("NFS: Beware when dereferencing the delegation cred") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
* Merge tag 'nfs-for-5.7-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfsLinus Torvalds2020-04-121-0/+1
|\ | | | | | | | | | | | | | | Pull NFS client bugfix from Trond Myklebust: "Fix an RCU read lock leakage in pnfs_alloc_ds_commits_list()" * tag 'nfs-for-5.7-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: pNFS: Fix RCU lock leakage
| * pNFS: Fix RCU lock leakageTrond Myklebust2020-04-111-0/+1
| | | | | | | | | | | | | | | | Another brown paper bag moment. pnfs_alloc_ds_commits_list() is leaking the RCU lock. Fixes: a9901899b649 ("pNFS: Add infrastructure for cleaning up per-layout commit structures") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
* | Merge tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfsLinus Torvalds2020-04-0729-1134/+1717
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull NFS client updates from Trond Myklebust: "Highlights include: Stable fixes: - Fix a page leak in nfs_destroy_unlinked_subrequests() - Fix use-after-free issues in nfs_pageio_add_request() - Fix new mount code constant_table array definitions - finish_automount() requires us to hold 2 refs to the mount record Features: - Improve the accuracy of telldir/seekdir by using 64-bit cookies when possible. - Allow one RDMA active connection and several zombie connections to prevent blocking if the remote server is unresponsive. - Limit the size of the NFS access cache by default - Reduce the number of references to credentials that are taken by NFS - pNFS files and flexfiles drivers now support per-layout segment COMMIT lists. - Enable partial-file layout segments in the pNFS/flexfiles driver. - Add support for CB_RECALL_ANY to the pNFS flexfiles layout type - pNFS/flexfiles Report NFS4ERR_DELAY and NFS4ERR_GRACE errors from the DS using the layouterror mechanism. Bugfixes and cleanups: - SUNRPC: Fix krb5p regressions - Don't specify NFS version in "UDP not supported" error - nfsroot: set tcp as the default transport protocol - pnfs: Return valid stateids in nfs_layout_find_inode_by_stateid() - alloc_nfs_open_context() must use the file cred when available - Fix locking when dereferencing the delegation cred - Fix memory leaks in O_DIRECT when nfs_get_lock_context() fails - Various clean ups of the NFS O_DIRECT commit code - Clean up RDMA connect/disconnect - Replace zero-length arrays with C99-style flexible arrays" * tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (86 commits) NFS: Clean up process of marking inode stale. SUNRPC: Don't start a timer on an already queued rpc task NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn() NFS/pnfs: Fix dereference of layout cred in pnfs_layoutcommit_inode() NFS: Beware when dereferencing the delegation cred NFS: Add a module parameter to set nfs_mountpoint_expiry_timeout NFS: finish_automount() requires us to hold 2 refs to the mount record NFS: Fix a few constant_table array definitions NFS: Try to join page groups before an O_DIRECT retransmission NFS: Refactor nfs_lock_and_join_requests() NFS: Reverse the submission order of requests in __nfs_pageio_add_request() NFS: Clean up nfs_lock_and_join_requests() NFS: Remove the redundant function nfs_pgio_has_mirroring() NFS: Fix memory leaks in nfs_pageio_stop_mirroring() NFS: Fix a request reference leak in nfs_direct_write_clear_reqs() NFS: Fix use-after-free issues in nfs_pageio_add_request() NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests() NFS: Fix a page leak in nfs_destroy_unlinked_subrequests() NFS: Remove unused FLUSH_SYNC support in nfs_initiate_pgio() pNFS/flexfiles: Specify the layout segment range in LAYOUTGET ...
| * NFS: Clean up process of marking inode stale.Trond Myklebust2020-04-064-8/+18
| | | | | | | | | | | | | | | | Instead of the various open coded calls to set the NFS_INO_STALE bit and call nfs_zap_caches(), consolidate them into a single function nfs_set_inode_stale(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn()Trond Myklebust2020-04-032-19/+34
| | | | | | | | | | | | | | When we're sending a layoutreturn, ensure that we reference the layout cred atomically with the copy of the stateid. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pnfs: Fix dereference of layout cred in pnfs_layoutcommit_inode()Trond Myklebust2020-04-031-1/+1
| | | | | | | | | | | | | | Ensure that the dereference of the layout cred is atomic with the stateid. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Beware when dereferencing the delegation credTrond Myklebust2020-04-032-1/+11
| | | | | | | | | | | | | | | | | | | | When we look up the delegation cred, we are usually doing so in conjunction with a read of the stateid, and we want to ensure that the look up is atomic with that read. Fixes: 57f188e04773 ("NFSv4: nfs_update_inplace_delegation() should update delegation cred") [sfr@canb.auug.org.au: Fixed up borken Fixes: line from Trond :-)] Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Add a module parameter to set nfs_mountpoint_expiry_timeoutTrond Myklebust2020-04-021-0/+50
| | | | | | | | | | | | | | | | Setting nfs_mountpoint_expiry_timeout() to a negative value stops mountpoint expiration, while setting it to a positive value restarts the scheduler. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: finish_automount() requires us to hold 2 refs to the mount recordTrond Myklebust2020-04-021-5/+7
| | | | | | | | | | | | | | | | | | | | | | We must not return from nfs_d_automount() without holding 2 references to the mount record. Doing so, will trigger the BUG() in finish_automount(). Also ensure that we don't try to reschedule the automount timer with a negative or zero timeout value. Fixes: 22a1ae9a93fb ("NFS: If nfs_mountpoint_expiry_timeout < 0, do not expire submounts") Cc: stable@vger.kernel.org # v5.5+ Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix a few constant_table array definitionsScott Mayhew2020-04-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | nfs_vers_tokens, nfs_xprt_protocol_tokens, and nfs_secflavor_tokens were all missing an empty item at the end of the array, allowing lookup_constant() to potentially walk off the end and trigger and oops. Reported-by: Olga Kornievskaia <aglo@umich.edu> Signed-off-by: Scott Mayhew <smayhew@redhat.com> Fixes: e38bb238ed8c ("NFS: Convert mount option parsing to use functionality from fs_parser.h") Cc: stable@vger.kernel.org # v5.6 Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Try to join page groups before an O_DIRECT retransmissionTrond Myklebust2020-04-012-1/+21
| | | | | | | | | | | | | | If we have to retransmit requests, try to join their page groups first. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Refactor nfs_lock_and_join_requests()Trond Myklebust2020-04-012-68/+122
| | | | | | | | | | | | | | | | Refactor nfs_lock_and_join_requests() in order to separate out the subrequest merging into its own function nfs_lock_and_join_group() that can be used by O_DIRECT. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Reverse the submission order of requests in __nfs_pageio_add_request()Trond Myklebust2020-04-011-69/+64
| | | | | | | | | | | | | | | | | | | | If we have to split the request up into subrequests, we have to submit the request pointed to by the function call parameter last, in case there is an error or other issue that causes us to exit before the last request is submitted. The reason is that the caller is expected to perform cleanup in those cases. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Clean up nfs_lock_and_join_requests()Trond Myklebust2020-04-012-71/+94
| | | | | | | | | | | | | | | | Clean up nfs_lock_and_join_requests() to simplify the calculation of the range covered by the page group, taking into account the presence of mirrors. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Remove the redundant function nfs_pgio_has_mirroring()Trond Myklebust2020-04-012-11/+2
| | | | | | | | | | | | | | We need to trust that desc->pg_mirror_idx is set correctly, whether or not mirroring is enabled. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix memory leaks in nfs_pageio_stop_mirroring()Trond Myklebust2020-04-011-9/+8
| | | | | | | | | | | | | | If we just set the mirror count to 1 without first clearing out the mirrors, we can leak queued up requests. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix a request reference leak in nfs_direct_write_clear_reqs()Trond Myklebust2020-04-011-0/+1
| | | | | | | | | | | | | | | | | | nfs_direct_write_scan_commit_list() will lock the request and bump the reference count, but we also need to account for the reference that was taken when we initially added the request to the commit list. Fixes: fb5f7f20cdb9 ("NFS: commit errors should be fatal") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix use-after-free issues in nfs_pageio_add_request()Trond Myklebust2020-04-011-24/+24
| | | | | | | | | | | | | | | | | | | | | | We need to ensure that we create the mirror requests before calling nfs_pageio_add_request_mirror() on the request we are adding. Otherwise, we can end up with a use-after-free if the call to nfs_pageio_add_request_mirror() triggers I/O. Fixes: c917cfaf9bbe ("NFS: Fix up NFS I/O subrequest creation") Cc: stable@vger.kernel.org Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests()Trond Myklebust2020-04-012-24/+53
| | | | | | | | | | | | | | | | | | When a subrequest is being detached from the subgroup, we want to ensure that it is not holding the group lock, or in the process of waiting for the group lock. Fixes: 5b2b5187fa85 ("NFS: Fix nfs_page_group_destroy() and nfs_lock_and_join_requests() race cases") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix a page leak in nfs_destroy_unlinked_subrequests()Trond Myklebust2020-04-011-0/+1
| | | | | | | | | | | | | | | | | | When we detach a subrequest from the list, we must also release the reference it holds to the parent. Fixes: 5b2b5187fa85 ("NFS: Fix nfs_page_group_destroy() and nfs_lock_and_join_requests() race cases") Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Remove unused FLUSH_SYNC support in nfs_initiate_pgio()Trond Myklebust2020-03-281-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | If the FLUSH_SYNC flag is set, nfs_initiate_pgio() will currently wait for completion, and then return the status of the I/O operation. What we actually want to report in nfs_pageio_doio() is whether or not the RPC call was launched successfully, whereas actual I/O status is intended handled in the reply callbacks. Since FLUSH_SYNC is never set by any of the callers anyway, let's just remove that code altogether. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS/flexfiles: Specify the layout segment range in LAYOUTGETTrond Myklebust2020-03-271-4/+4
| | | | | | | | | | | | | | | | | | Move from requesting only full file layout segments, to requesting layout segments that match our I/O size. This means the server is still free to return a full file layout, but we will no longer error out if it does not. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS/flexfiles: remove requirement for whole file layoutsTrond Myklebust2020-03-271-21/+0
| | | | | | | | | | | | | | Remove the requirement that the server always sends whole file layouts. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS/flexfiles: Check the layout segment range before doing I/OTrond Myklebust2020-03-273-3/+13
| | | | | | | | | | | | | | When starting to read or write with a layout segment, check that the range matches our request. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS/flexfile: Don't merge layout segments if the mirrors don't matchTrond Myklebust2020-03-271-0/+19
| | | | | | | | | | | | | | Check that the number of mirrors, and the mirror information matches before deciding to merge layout segments in pNFS/flexfiles. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Fix pnfs_layout_mark_request_commit() invalid layout segment handlingTrond Myklebust2020-03-271-16/+12
| | | | | | | | | | | | | | Fix up pnfs_layout_mark_request_commit() to alway reschedule the write if the layout segment is invalid. Also minor cleanup. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Simplify bucket layout segment reference countingTrond Myklebust2020-03-271-19/+20
| | | | | | | | Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Clean up pNFS commit operationsTrond Myklebust2020-03-275-71/+97
| | | | | | | | | | | | | | Move the pNFS commit related operations into a separate structure that can be carried by the pnfs_ds_commit_info. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Remove bucket array from struct pnfs_ds_commit_infoTrond Myklebust2020-03-275-172/+1
| | | | | | | | | | | | Remove the unused bucket array in struct pnfs_ds_commit_info. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Add a helper pnfs_generic_search_commit_reqs()Trond Myklebust2020-03-273-31/+54
| | | | | | | | | | | | | | Lift filelayout_search_commit_reqs() into the generic pnfs/nfs code, and add support for commit arrays. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS: Enable per-layout segment commit structuresTrond Myklebust2020-03-274-6/+117
| | | | | | | | | | | | | | Enable adding and lookup of per-layout segment commits in filelayout and flexfilelayout. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS: Add infrastructure for cleaning up per-layout commit structuresTrond Myklebust2020-03-276-4/+120
| | | | | | | | | | | | | | Ensure that both the file and flexfiles layout types clean up when freeing the layout segments. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Support commit arrays in nfs_clear_pnfs_ds_commit_verifiers()Trond Myklebust2020-03-271-3/+16
| | | | | | | | | | | | | | Add support for scanning the full list of per-layout segment commit arrays to nfs_clear_pnfs_ds_commit_verifiers(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Fix O_DIRECT commit verifier handlingTrond Myklebust2020-03-273-124/+22
| | | | | | | | | | | | | | | | Instead of trying to save the commit verifiers and checking them against previous writes, adopt the same strategy as for buffered writes, of just checking the verifiers at commit time. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: commit errors should be fatalTrond Myklebust2020-03-271-2/+30
| | | | | | | | | | | | | | Fix the O_DIRECT code to avoid retries if the COMMIT fails with a fatal error. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Allow O_DIRECT to release the DS commitinfoTrond Myklebust2020-03-272-0/+17
| | | | | | | | | | | | | | Add a pNFS callback to allow the O_DIRECT code to release the DS commitinfo when freeing the dreq. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS: Support per-layout segment commits in pnfs_generic_commit_pagelist()Trond Myklebust2020-03-271-0/+16
| | | | | | | | | | | | | | Add support for scanning the full list of per-layout segment commit arrays to pnfs_generic_commit_pagelist(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS: Support per-layout segment commits in pnfs_generic_recover_commit_reqs()Trond Myklebust2020-03-271-8/+33
| | | | | | | | | | | | | | Add support for scanning the full list of per-layout segment commit arrays to pnfs_generic_recover_commit_reqs(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFSv4/pNFS: Scan the full list of commit arrays when committingTrond Myklebust2020-03-271-12/+40
| | | | | | | | | | | | | | Add support for scanning the full list of per-layout segment commit arrays to pnfs_generic_scan_commit_lists() Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFSv4/pnfs: Support a list of commit arrays in struct pnfs_ds_commit_infoTrond Myklebust2020-03-274-1/+17
| | | | | | | | | | | | | | | | | | When we have multiple layout segments with different lists of mirrored data, we need to track the commits on a per layout segment basis. This patch adds a list to support this tracking in struct pnfs_ds_commit_info. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS: Add a helper to allocate the array of bucketsTrond Myklebust2020-03-262-0/+34
| | | | | | | | Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS/pNFS: Refactor pnfs_generic_commit_pagelist()Trond Myklebust2020-03-262-101/+76
| | | | | | | | | | | | | | Refactor pnfs_generic_commit_pagelist() to simplify the conversion to layout segment based commit lists. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * pNFS/flexfiles: Simplify allocation of the mirror arrayTrond Myklebust2020-03-262-17/+6
| | | | | | | | | | | | | | Just allocate the array at the end of the layout segment structure, instead of allocating it as a separate array of pointers. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: Don't specify NFS version in "UDP not supported" errorPetr Vorel2020-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | UDP was originally disabled in 6da1a034362f for NFSv4. Later in b24ee6c64ca7 UDP is by default disabled by NFS_DISABLE_UDP_SUPPORT=y for all NFS versions. Therefore remove v4 from error message. Fixes: b24ee6c64ca7 ("NFS: allow deprecation of NFS UDP protocol") Signed-off-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * nfsroot: set tcp as the default transport protocolLiwei Song2020-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | UDP is disabled by default in commit b24ee6c64ca7 ("NFS: allow deprecation of NFS UDP protocol"), but the default mount options is still udp, change it to tcp to avoid the "Unsupported transport protocol udp" error if no protocol is specified when mount nfs. Fixes: b24ee6c64ca7 ("NFS: allow deprecation of NFS UDP protocol") Signed-off-by: Liwei Song <liwei.song@windriver.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFS: direct.c: Fix memory leak of dreq when nfs_get_lock_context failsMisono Tomohiro2020-03-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When dreq is allocated by nfs_direct_req_alloc(), dreq->kref is initialized to 2. Therefore we need to call nfs_direct_req_release() twice to release the allocated dreq. Usually it is called in nfs_file_direct_{read, write}() and nfs_direct_complete(). However, current code only calls nfs_direct_req_relese() once if nfs_get_lock_context() fails in nfs_file_direct_{read, write}(). So, that case would result in memory leak. Fix this by adding the missing call. Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * nfs: Fix up documentation in nfs_follow_referral() and nfs_do_submount()Trond Myklebust2020-03-172-5/+2
| | | | | | | | | | | | Fallout from the mount patches. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * nfs: Replace zero-length array with flexible-array memberGustavo A. R. Silva2020-03-162-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
| * NFSv4.2: error out when relink swapfileMurphy Zhou2020-03-161-0/+3
| | | | | | | | | | | | | | This fixes xfstests generic/356 failure on NFSv4.2. Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>