summaryrefslogtreecommitdiff
path: root/fs/nfsd
AgeCommit message (Collapse)AuthorFilesLines
2021-01-11Merge tag 'nfsd-5.11-1' of git://git.linux-nfs.org/projects/cel/cel-2.6Linus Torvalds4-27/+41
Pull nfsd fixes from Chuck Lever: - Fix major TCP performance regression - Get NFSv4.2 READ_PLUS regression tests to pass - Improve NFSv4 COMPOUND memory allocation - Fix sparse warning * tag 'nfsd-5.11-1' of git://git.linux-nfs.org/projects/cel/cel-2.6: NFSD: Restore NFSv4 decoding's SAVEMEM functionality SUNRPC: Handle TCP socket sends with kernel_sendpage() again NFSD: Fix sparse warning in nfssvc.c nfsd: Don't set eof on a truncated READ_PLUS nfsd: Fixes for nfsd4_encode_read_plus_data()
2020-12-18NFSD: Restore NFSv4 decoding's SAVEMEM functionalityChuck Lever1-16/+26
While converting the NFSv4 decoder to use xdr_stream-based XDR processing, I removed the old SAVEMEM() macro. This macro wrapped a bit of logic that avoided a memory allocation by recognizing when the decoded item resides in a linear section of the Receive buffer. In that case, it returned a pointer into that buffer instead of allocating a bounce buffer. The bounce buffer is necessary only when xdr_inline_decode() has placed the decoded item in the xdr_stream's scratch buffer, which disappears the next time xdr_inline_decode() is called with that xdr_stream. That happens only if the data item crosses a page boundary in the receive buffer, an exceedingly rare occurrence. Allocating a bounce buffer every time results in a minor performance regression that was introduced by the recent NFSv4 decoder overhaul. Let's restore the previous behavior. On average, it saves about 1.5 kmalloc() calls per COMPOUND. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-18NFSD: Fix sparse warning in nfssvc.cChuck Lever3-7/+5
fs/nfsd/nfssvc.c:36:6: warning: symbol 'inter_copy_offload_enable' was not declared. Should it be static? The parameter was added by commit ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy"). Relocate it into the source file that uses it, and make it static. This approach is similar to the nfs4_disable_idmapping, cltrack_prog, and cltrack_legacy_disable module parameters. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-18nfsd: Don't set eof on a truncated READ_PLUSTrond Myklebust1-4/+5
If the READ_PLUS operation was truncated due to an error, then ensure we clear the 'eof' flag. Fixes: 9f0b5792f07d ("NFSD: Encode a full READ_PLUS reply") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-18nfsd: Fixes for nfsd4_encode_read_plus_data()Trond Myklebust1-0/+5
Ensure that we encode the data payload + padding, and that we truncate the preallocated buffer to the actual read size. Fixes: 528b84934eb9 ("NFSD: Add READ_PLUS data support") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-17Merge tag 'fsnotify_for_v5.11-rc1' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs Pull fsnotify updates from Jan Kara: "A few fsnotify fixes from Amir fixing fallout from big fsnotify overhaul a few months back and an improvement of defaults limiting maximum number of inotify watches from Waiman" * tag 'fsnotify_for_v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fsnotify: fix events reported to watching parent and child inotify: convert to handle_inode_event() interface fsnotify: generalize handle_inode_event() inotify: Increase default inotify.max_user_watches limit to 1048576
2020-12-09nfsd: Record NFSv4 pre/post-op attributes as non-atomicTrond Myklebust3-1/+10
For the case of NFSv4, specify to the client that the pre/post-op attributes were not recorded atomically with the main operation. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: Set PF_LOCAL_THROTTLE on local filesystems onlyTrond Myklebust1-2/+11
Don't set PF_LOCAL_THROTTLE on remote filesystems like NFS, since they aren't expected to ever be subject to double buffering. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: Fix up nfsd to ensure that timeout errors don't result in ESTALETrond Myklebust1-4/+12
If the underlying filesystem times out, then we want knfsd to return NFSERR_JUKEBOX/DELAY rather than NFSERR_STALE. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: close cached files prior to a REMOVE or RENAME that would replace targetJeff Layton1-7/+9
It's not uncommon for some workloads to do a bunch of I/O to a file and delete it just afterward. If knfsd has a cached open file however, then the file may still be open when the dentry is unlinked. If the underlying filesystem is nfs, then that could trigger it to do a sillyrename. On a REMOVE or RENAME scan the nfsd_file cache for open files that correspond to the inode, and proactively unhash and put their references. This should prevent any delete-on-last-close activity from occurring, solely due to knfsd's open file cache. This must be done synchronously though so we use the variants that call flush_delayed_fput. There are deadlock possibilities if you call flush_delayed_fput while holding locks, however. In the case of nfsd_rename, we don't even do the lookups of the dentries to be renamed until we've locked for rename. Once we've figured out what the target dentry is for a rename, check to see whether there are cached open files associated with it. If there are, then unwind all of the locking, close them all, and then reattempt the rename. None of this is really necessary for "typical" filesystems though. It's mostly of use for NFS, so declare a new export op flag and use that to determine whether to close the files beforehand. Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: allow filesystems to opt out of subtree checkingJeff Layton1-0/+6
When we start allowing NFS to be reexported, then we have some problems when it comes to subtree checking. In principle, we could allow it, but it would mean encoding parent info in the filehandles and there may not be enough space for that in a NFSv3 filehandle. To enforce this at export upcall time, we add a new export_ops flag that declares the filesystem ineligible for subtree checking. Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operationsJeff Layton3-3/+20
With NFSv3 nfsd will always attempt to send along WCC data to the client. This generally involves saving off the in-core inode information prior to doing the operation on the given filehandle, and then issuing a vfs_getattr to it after the op. Some filesystems (particularly clustered or networked ones) have an expensive ->getattr inode operation. Atomicity is also often difficult or impossible to guarantee on such filesystems. For those, we're best off not trying to provide WCC information to the client at all, and to simply allow it to poll for that information as needed with a GETATTR RPC. This patch adds a new flags field to struct export_operations, and defines a new EXPORT_OP_NOWCC flag that filesystems can use to indicate that nfsd should not attempt to provide WCC info in NFSv3 replies. It also adds a blurb about the new flags field and flag to the exporting documentation. The server will also now skip collecting this information for NFSv2 as well, since that info is never used there anyway. Note that this patch does not add this flag to any filesystem export_operations structures. This was originally developed to allow reexporting nfs via nfsd. Other filesystems may want to consider enabling this flag too. It's hard to tell however which ones have export operations to enable export via knfsd and which ones mostly rely on them for open-by-filehandle support, so I'm leaving that up to the individual maintainers to decide. I am cc'ing the relevant lists for those filesystems that I think may want to consider adding this though. Cc: HPDD-discuss@lists.01.org Cc: ceph-devel@vger.kernel.org Cc: cluster-devel@redhat.com Cc: fuse-devel@lists.sourceforge.net Cc: ocfs2-devel@oss.oracle.com Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09Revert "nfsd4: support change_attr_type attribute"J. Bruce Fields2-11/+0
This reverts commit a85857633b04d57f4524cca0a2bfaf87b2543f9f. We're still factoring ctime into our change attribute even in the IS_I_VERSION case. If someone sets the system time backwards, a client could see the change attribute go backwards. Maybe we can just say "well, don't do that", but there's some question whether that's good enough, or whether we need a better guarantee. Also, the client still isn't actually using the attribute. While we're still figuring this out, let's just stop returning this attribute. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd4: don't query change attribute in v2/v3 caseJ. Bruce Fields1-5/+9
inode_query_iversion() has side effects, and there's no point calling it when we're not even going to use it. We check whether we're currently processing a v4 request by checking fh_maxsize, which is arguably a little hacky; we could add a flag to svc_fh instead. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: minor nfsd4_change_attribute cleanupJ. Bruce Fields1-8/+5
Minor cleanup, no change in behavior. Also pull out a common helper that'll be useful elsewhere. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: simplify nfsd4_change_infoJ. Bruce Fields2-20/+2
It doesn't make sense to carry all these extra fields around. Just make everything into change attribute from the start. This is just cleanup, there should be no change in behavior. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: only call inode_query_iversion in the I_VERSION caseJ. Bruce Fields3-12/+13
inode_query_iversion() can modify i_version. Depending on the exported filesystem, that may not be safe. For example, if you're re-exporting NFS, NFS stores the server's change attribute in i_version and does not expect it to be modified locally. This has been observed causing unnecessary cache invalidations. The way a filesystem indicates that it's OK to call inode_query_iverson() is by setting SB_I_VERSION. So, move the I_VERSION check out of encode_change(), where it's used only in GETATTR responses, to nfsd4_change_attribute(), which is also called for pre- and post- operation attributes. (Note we could also pull the NFSEXP_V4ROOT case into nfsd4_change_attribute() as well. That would actually be a no-op, since pre/post attrs are only used for metadata-modifying operations, and V4ROOT exports are read-only. But we might make the change in the future just for simplicity.) Reported-by: Daire Byrne <daire@dneg.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09NFSD: Fix 5 seconds delay when doing inter server copyDai Ngo1-0/+1
Since commit b4868b44c5628 ("NFSv4: Wait for stateid updates after CLOSE/OPEN_DOWNGRADE"), every inter server copy operation suffers 5 seconds delay regardless of the size of the copy. The delay is from nfs_set_open_stateid_locked when the check by nfs_stateid_is_sequential fails because the seqid in both nfs4_state and nfs4_stateid are 0. Fix by modifying nfs4_init_cp_state to return the stateid with seqid 1 instead of 0. This is also to conform with section 4.8 of RFC 7862. Here is the relevant paragraph from section 4.8 of RFC 7862: A copy offload stateid's seqid MUST NOT be zero. In the context of a copy offload operation, it is inappropriate to indicate "the most recent copy offload operation" using a stateid with a seqid of zero (see Section 8.2.2 of [RFC5661]). It is inappropriate because the stateid refers to internal state in the server and there may be several asynchronous COPY operations being performed in parallel on the same file by the server. Therefore, a copy offload stateid with a seqid of zero MUST be considered invalid. Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy") Signed-off-by: Dai Ngo <dai.ngo@oracle.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09NFSD: Fix sparse warning in nfs4proc.cChuck Lever1-6/+2
linux/fs/nfsd/nfs4proc.c:1542:24: warning: incorrect type in assignment (different base types) linux/fs/nfsd/nfs4proc.c:1542:24: expected restricted __be32 [assigned] [usertype] status linux/fs/nfsd/nfs4proc.c:1542:24: got int Clean-up: The dup_copy_fields() function returns only zero, so make it return void for now, and get rid of the return code check. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09nfsd: Fix message level for normal terminationkazuo ito1-2/+1
The warning message from nfsd terminating normally can confuse system adminstrators or monitoring software. Though it's not exactly fair to pin-point a commit where it originated, the current form in the current place started to appear in: Fixes: e096bbc6488d ("knfsd: remove special handling for SIGHUP") Signed-off-by: kazuo ito <kzpn200@gmail.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-03fsnotify: generalize handle_inode_event()Amir Goldstein1-1/+1
The handle_inode_event() interface was added as (quoting comment): "a simple variant of handle_event() for groups that only have inode marks and don't have ignore mask". In other words, all backends except fanotify. The inotify backend also falls under this category, but because it required extra arguments it was left out of the initial pass of backends conversion to the simple interface. This results in code duplication between the generic helper fsnotify_handle_event() and the inotify_handle_event() callback which also happen to be buggy code. Generalize the handle_inode_event() arguments and add the check for FS_EXCL_UNLINK flag to the generic helper, so inotify backend could be converted to use the simple interface. Link: https://lore.kernel.org/r/20201202120713.702387-2-amir73il@gmail.com CC: stable@vger.kernel.org Fixes: b9a1b9772509 ("fsnotify: create method handle_inode_event() in fsnotify_operations") Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-30NFSD: Remove macros that are no longer usedChuck Lever2-49/+0
Now that all the NFSv4 decoder functions have been converted to make direct calls to the xdr helpers, remove the unused C macros. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_compound()Chuck Lever1-40/+29
And clean-up: Now that we have removed the DECODE_TAIL macro from nfsd4_decode_compound(), we observe that there's no benefit for nfsd4_decode_compound() to return nfs_ok or nfserr_bad_xdr only to have its sole caller convert those values to one or zero, respectively. Have nfsd4_decode_compound() return 1/0 instead. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Make nfsd4_ops::opnum a u32Chuck Lever3-6/+5
Avoid passing a "pointer to int" argument to xdr_stream_decode_u32. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_listxattrs()Chuck Lever1-5/+5
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_setxattr()Chuck Lever1-7/+7
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_xattr_name()Chuck Lever1-12/+9
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_clone()Chuck Lever1-31/+21
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_seek()Chuck Lever1-7/+7
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_offload_status()Chuck Lever1-1/+1
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_copy_notify()Chuck Lever1-8/+8
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_copy()Chuck Lever2-20/+23
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_nl4_server()Chuck Lever1-14/+20
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_fallocate()Chuck Lever1-7/+7
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete()Chuck Lever1-10/+8
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid()Chuck Lever1-10/+6
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_test_stateid()Chuck Lever1-36/+25
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_sequence()Chuck Lever1-16/+20
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name()Chuck Lever1-11/+8
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_layoutreturn()Chuck Lever1-28/+44
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_layoutget()Chuck Lever1-14/+17
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_layoutcommit()Chuck Lever1-62/+58
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo()Chuck Lever1-21/+29
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_free_stateid()Chuck Lever1-7/+1
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_destroy_session()Chuck Lever1-5/+1
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Replace READ* macros in nfsd4_decode_create_session()Chuck Lever1-10/+14
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Add a helper to decode channel_attrs4Chuck Lever1-33/+38
De-duplicate some code. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Add a helper to decode nfs_impl_id4Chuck Lever1-25/+38
Refactor for clarity. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Add a helper to decode state_protect4_aChuck Lever3-19/+29
Refactor for clarity. Also, remove a stale comment. Commit ed94164398c9 ("nfsd: implement machine credential support for some operations") added support for SP4_MACH_CRED, so state_protect_a is no longer completely ignored. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-11-30NFSD: Add a separate decoder for ssv_sp_parmsChuck Lever1-26/+44
Refactor for clarity. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>