summaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
Commit message (Collapse)AuthorAgeFilesLines
* NFSD: fix bug for readdir of pseudofsKinglong Mee2014-06-171-0/+1
| | | | | | | | | | Commit 561f0ed498ca (nfsd4: allow large readdirs) introduces a bug about readdir the root of pseudofs. Call xdr_truncate_encode() revert encoded name when skipping. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill READ64J. Bruce Fields2014-06-061-17/+16
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill READ32J. Bruce Fields2014-06-061-128/+127
| | | | | | | | While we're here, let's kill off a couple of the read-side macros. Leaving the more complicated ones alone for now. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd: make nfsd4_encode_fattr staticJeff Layton2014-05-301-1/+1
| | | | | | | | | | sparse says: CHECK fs/nfsd/nfs4xdr.c fs/nfsd/nfs4xdr.c:2043:1: warning: symbol 'nfsd4_encode_fattr' was not declared. Should it be static? Signed-off-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs bufferChristoph Hellwig2014-05-301-2/+2
| | | | | | | | | Note nobody's ever noticed because the typical client probably never requests FILES_AVAIL without also requesting something else on the list. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* NFSD: Adds macro EX_UUID_LEN for exports uuid's lengthKinglong Mee2014-05-301-1/+2
| | | | | Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: better reservation of head space for krb5J. Bruce Fields2014-05-301-2/+3
| | | | | | | | | RPC_MAX_AUTH_SIZE is scattered around several places. Better to set it once in the auth code, where this kind of estimate should be made. And while we're at it we can leave it zero when we're not using krb5i or krb5p. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill write32, write64J. Bruce Fields2014-05-301-30/+21
| | | | | | | And switch a couple other functions from the encode(&p,...) convention to the p = encode(p,...) convention mostly used elsewhere. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill WRITEMEMJ. Bruce Fields2014-05-301-34/+28
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill WRITE64J. Bruce Fields2014-05-301-28/+24
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: kill WRITE32J. Bruce Fields2014-05-301-152/+154
| | | | | | | These macros just obscure what's going on. Adopt the convention of the client-side code. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: really fix nfs4err_resource in 4.1 caseJ. Bruce Fields2014-05-301-0/+8
| | | | | | | | | | | | | | | | | encode_getattr, for example, can return nfserr_resource to indicate it ran out of buffer space. That's not a legal error in the 4.1 case. And in the 4.1 case, if we ran out of buffer space, we should have exceeded a session limit too. (Note in 1bc49d83c37cfaf46be357757e592711e67f9809 "nfsd4: fix nfs4err_resource in 4.1 case" we originally tried fixing this error return before fixing the problem that we could error out while we still had lots of available space. The result was to trade one illegal error for another in those cases. We decided that was helpful, so reverted the change in fc208d026be0c7d60db9118583fc62f6ca97743d, and are only reinstating it now that we've elimited almost all of those cases.) Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: allow exotic read compoundsJ. Bruce Fields2014-05-301-36/+25
| | | | | | | | I'm not sure why a client would want to stuff multiple reads in a single compound rpc, but it's legal for them to do it, and we should really support it. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: more read encoding cleanupJ. Bruce Fields2014-05-301-12/+10
| | | | | | More cleanup, no change in functionality. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: read encoding cleanupJ. Bruce Fields2014-05-301-13/+14
| | | | | | Trivial cleanup, no change in functionality. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: separate splice and readv casesJ. Bruce Fields2014-05-301-42/+131
| | | | | | | | | | | | The splice and readv cases are actually quite different--for example the former case ignores the array of vectors we build up for the latter. It is probably clearer to separate the two cases entirely. There's some code duplication between the split out encoders, but this is only temporary and will be fixed by a later patch. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: turn off zero-copy-read in exotic casesJ. Bruce Fields2014-05-301-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently allow only one read per compound, with operations before and after whose responses will require no more than about a page to encode. While we don't expect clients to violate those limits any time soon, this limitation isn't really condoned by the spec, so to future proof the server we should lift the limitation. At the same time we'd like to continue to support zero-copy reads. Supporting multiple zero-copy-reads per compound would require a new data structure to replace struct xdr_buf, which can represent only one set of included pages. So for now we plan to modify encode_read() to support either zero-copy or non-zero-copy reads, and use some heuristics at the start of the compound processing to decide whether a zero-copy read will work. This will allow us to support more exotic compounds without introducing a performance regression in the normal case. Later patches handle those "exotic compounds", this one just makes sure zero-copy is turned off in those cases. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: don't treat readlink like a zero-copy operationJ. Bruce Fields2014-05-301-30/+12
| | | | | | | | | There's no advantage to this zero-copy-style readlink encoding, and it unnecessarily limits the kinds of compounds we can handle. (In practice I can't see why a client would want e.g. multiple readlink calls in a comound, but it's probably a spec violation for us not to handle it.) Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: enforce rd_dircountJ. Bruce Fields2014-05-301-1/+4
| | | | | | | | | | As long as we're here, let's enforce the protocol's limit on the number of directory entries to return in a readdir. I don't think anyone's ever noticed our lack of enforcement, but maybe there's more of a chance they will now that we allow larger readdirs. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: allow large readdirsJ. Bruce Fields2014-05-301-62/+75
| | | | | | | | Currently we limit readdir results to a single page. This can result in a performance regression compared to NFSv3 when reading large directories. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: adjust buflen to session channel limitJ. Bruce Fields2014-05-301-16/+8
| | | | | | | | | | | | We can simplify session limit enforcement by restricting the xdr buflen to the session size. Also fix a preexisting bug: we should really have been taking into account the auth-required space when comparing against session limits, which are limits on the size of the entire rpc reply, including any krb5 overhead. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: fix buflen calculation after read encodingJ. Bruce Fields2014-05-301-1/+7
| | | | | | | | | | | | We don't necessarily want to assume that the buflen is the same as the number of bytes available in the pages. We may have some reason to set it to something less (for example, later patches will use a smaller buflen to enforce session limits). So, calculate the buflen relative to the previous buflen instead of recalculating it from scratch. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: nfsd4_check_resp_size should check against whole bufferJ. Bruce Fields2014-05-301-2/+1
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: minor encode_read cleanupJ. Bruce Fields2014-05-301-4/+6
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: more precise nfsd4_max_replyJ. Bruce Fields2014-05-301-31/+4
| | | | | | | | | | | It will turn out to be useful to have a more accurate estimate of reply size; so, piggyback on the existing op reply-size estimators. Also move nfsd4_max_reply to nfs4proc.c to get easier access to struct nfsd4_operation and friends. (Thanks to Christoph Hellwig for pointing out that simplification.) Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: don't try to encode conflicting owner if low on spaceJ. Bruce Fields2014-05-301-3/+13
| | | | | | | | | | | | | I ran into this corner case in testing: in theory clients can provide state owners up to 1024 bytes long. In the sessions case there might be a risk of this pushing us over the DRC slot size. The conflicting owner isn't really that important, so let's humor a client that provides a small maxresponsize_cached by allowing ourselves to return without the conflicting owner instead of outright failing the operation. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: convert 4.1 replay encodingJ. Bruce Fields2014-05-301-1/+1
| | | | | | | | | | | | Limits on maxresp_sz mean that we only ever need to replay rpc's that are contained entirely in the head. The one exception is very small zero-copy reads. That's an odd corner case as clients wouldn't normally ask those to be cached. in any case, this seems a little more robust. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: allow encoding across page boundariesJ. Bruce Fields2014-05-301-17/+43
| | | | | | | | | | | After this we can handle for example getattr of very large ACLs. Read, readdir, readlink are still special cases with their own limits. Also we can't handle a new operation starting close to the end of a page. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: size-checking cleanupJ. Bruce Fields2014-05-301-14/+15
| | | | | | Better variable name, some comments, etc. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: remove redundant encode buffer size checkingJ. Bruce Fields2014-05-301-9/+13
| | | | | | | | | Now that all op encoders can handle running out of space, we no longer need to check the remaining size for every operation; only nonidempotent operations need that check, and that can be done by nfsd4_check_resp_size. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: nfsd4_check_resp_size needn't recalculate lengthJ. Bruce Fields2014-05-301-15/+3
| | | | | | | We're keeping the length updated as we go now, so there's no need for the extra calculation here. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: reserve space before inlining 0-copy pagesJ. Bruce Fields2014-05-301-4/+7
| | | | | | | | | | | | Once we've included page-cache pages in the encoding it's difficult to remove them and restart encoding. (xdr_truncate_encode doesn't handle that case.) So, make sure we'll have adequate space to finish the operation first. For now COMPOUND_SLACK_SPACE checks should prevent this case happening, but we want to remove those checks. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: teach encoders to handle reserve_space failuresJ. Bruce Fields2014-05-301-64/+183
| | | | | | | | | | | | | | | | | | | We've tried to prevent running out of space with COMPOUND_SLACK_SPACE and special checking in those operations (getattr) whose result can vary enormously. However: - COMPOUND_SLACK_SPACE may be difficult to maintain as we add more protocol. - BUG_ON or page faulting on failure seems overly fragile. - Especially in the 4.1 case, we prefer not to fail compounds just because the returned result came *close* to session limits. (Though perfect enforcement here may be difficult.) - I'd prefer encoding to be uniform for all encoders instead of having special exceptions for encoders containing, for example, attributes. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: "backfill" using write_bytes_to_xdr_bufJ. Bruce Fields2014-05-301-19/+26
| | | | | | | | | | | | | | | | Normally xdr encoding proceeds in a single pass from start of a buffer to end, but sometimes we have to write a few bytes to an earlier position. Use write_bytes_to_xdr_buf for these cases rather than saving a pointer to write to. We plan to rewrite xdr_reserve_space to handle encoding across page boundaries using a scratch buffer, and don't want to risk writing to a pointer that was contained in a scratch buffer. Also it will no longer be safe to calculate lengths by subtracting two pointers, so use xdr_buf offsets instead. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: use xdr_truncate_encodeJ. Bruce Fields2014-05-301-20/+16
| | | | | | | Now that lengths are reliable, we can use xdr_truncate instead of open-coding it everywhere. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: keep xdr buf length updatedJ. Bruce Fields2014-05-281-2/+13
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: no need for encode_compoundres to adjust lengthsJ. Bruce Fields2014-05-281-7/+1
| | | | | | | xdr_reserve_space should now be calculating the length correctly as we go, so there's no longer any need to fix it up here. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: remove ADJUST_ARGSJ. Bruce Fields2014-05-281-40/+0
| | | | | | It's just uninteresting debugging code at this point. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: use xdr_stream throughout compound encodingJ. Bruce Fields2014-05-281-8/+15
| | | | | | | Note this makes ADJUST_ARGS useless; we'll remove it in the following patch. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: use xdr_reserve_space in attribute encodingJ. Bruce Fields2014-05-281-116/+172
| | | | | | | | | | | | | | | | | | | This is a cosmetic change for now; no change in behavior. Note we're just depending on xdr_reserve_space to do the bounds checking for us, we're not really depending on its adjustment of iovec or xdr_buf lengths yet, as those are fixed up by as necessary after the fact by read-link operations and by nfs4svc_encode_compoundres. However we do have to update xdr->iov on read-like operations to prevent xdr_reserve_space from messing with the already-fixed-up length of the the head. When the attribute encoding fails partway through we have to undo the length adjustments made so far. We do it manually for now, but later patches will add an xdr_truncate_encode() helper to handle cases like this. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: allow space for final error returnJ. Bruce Fields2014-05-271-2/+7
| | | | | | | | This post-encoding check should be taking into account the need to encode at least an out-of-space error to the following op (if any). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: fix encoding of out-of-space repliesJ. Bruce Fields2014-05-271-1/+16
| | | | | | | | | | | If nfsd4_check_resp_size() returns an error then we should really be truncating the reply here, otherwise we may leave extra garbage at the end of the rpc reply. Also add a warning to catch any cases where our reply-size estimates may be wrong in the case of a non-idempotent operation. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: tweak nfsd4_encode_getattr to take xdr_streamJ. Bruce Fields2014-05-231-12/+35
| | | | | | | | Just change the nfsd4_encode_getattr api. Not changing any code or adding any new functionality yet. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: embed xdr_stream in nfsd4_compoundresJ. Bruce Fields2014-05-231-32/+35
| | | | | | | This is a mechanical transformation with no change in behavior. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: decoding errors can still be cached and require spaceJ. Bruce Fields2014-05-231-5/+5
| | | | | | | | | | | | | | Currently a non-idempotent op reply may be cached if it fails in the proc code but not if it fails at xdr decoding. I doubt there are any xdr-decoding-time errors that would make this a problem in practice, so this probably isn't a serious bug. The space estimates should also take into account space required for encoding of error returns. Again, not a practical problem, though it would become one after future patches which will tighten the space estimates. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* Revert "nfsd4: fix nfs4err_resource in 4.1 case"J. Bruce Fields2014-04-181-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | Since we're still limiting attributes to a page, the result here is that a large getattr result will return NFS4ERR_REP_TOO_BIG/TOO_BIG_TO_CACHE instead of NFS4ERR_RESOURCE. Both error returns are wrong, and the real bug here is the arbitrary limit on getattr results, fixed by as-yet out-of-tree patches. But at a minimum we can make life easier for clients by sticking to one broken behavior in released kernels instead of two.... Trond says: one immediate consequence of this patch will be that NFSv4.1 clients will now report EIO instead of EREMOTEIO if they hit the problem. That may make debugging a little less obvious. Another consequence will be that if we ever do try to add client side handling of NFS4ERR_REP_TOO_BIG, then we now have to deal with the “handle existing buggy server” syndrome. Reported-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: fix memory leak in nfsd4_encode_fattr()Yan, Zheng2014-03-311-1/+3
| | | | | | | | fh_put() does not free the temporary file handle. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: fix nfs4err_resource in 4.1 caseJ. Bruce Fields2014-03-281-0/+8
| | | | | | | | | encode_getattr, for example, can return nfserr_resource to indicate it ran out of buffer space. That's not a legal error in the 4.1 case. And in the 4.1 case, if we ran out of buffer space, we should have exceeded a session limit too. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: remove redundant check from nfsd4_check_resp_sizeJ. Bruce Fields2014-03-281-2/+0
| | | | | | | cstate->slot and ->session are each set together in nfsd4_sequence. If one is non-NULL, so is the other. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
* nfsd4: update comments with obsolete function nameJ. Bruce Fields2014-03-281-1/+1
| | | | Signed-off-by: J. Bruce Fields <bfields@redhat.com>
OpenPOWER on IntegriCloud