From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 098/118] NFSD: Update the NFSv2 READ argument decoder to use struct xdr_stream
Date: Fri, 20 Nov 2020 15:42:27 -0500 [thread overview]
Message-ID: <160590494786.1340.6179902743258104536.stgit@klimt.1015granger.net> (raw)
In-Reply-To: <160590425404.1340.8850646771948736468.stgit@klimt.1015granger.net>
The code that sets up rq_vec is refactored so that it is now
adjacent to the nfsd_read() call site where it is used.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfsd/nfsproc.c | 32 ++++++++++++++++++--------------
fs/nfsd/nfsxdr.c | 34 ++++++++++------------------------
fs/nfsd/xdr.h | 1 -
3 files changed, 28 insertions(+), 39 deletions(-)
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 5b8436af43a9..998a1f94c6f8 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -171,32 +171,36 @@ nfsd_proc_read(struct svc_rqst *rqstp)
{
struct nfsd_readargs *argp = rqstp->rq_argp;
struct nfsd_readres *resp = rqstp->rq_resp;
+ unsigned int len;
u32 eof;
+ int v;
dprintk("nfsd: READ %s %d bytes at %d\n",
SVCFH_fmt(&argp->fh),
argp->count, argp->offset);
+ argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2);
+
+ v = 0;
+ len = argp->count;
+ while (len > 0) {
+ struct page *page = *(rqstp->rq_next_page++);
+
+ rqstp->rq_vec[v].iov_base = page_address(page);
+ rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
+ len -= rqstp->rq_vec[v].iov_len;
+ v++;
+ }
+
/* Obtain buffer pointer for payload. 19 is 1 word for
* status, 17 words for fattr, and 1 word for the byte count.
*/
-
- if (NFSSVC_MAXBLKSIZE_V2 < argp->count) {
- char buf[RPC_MAX_ADDRBUFLEN];
- printk(KERN_NOTICE
- "oversized read request from %s (%d bytes)\n",
- svc_print_addr(rqstp, buf, sizeof(buf)),
- argp->count);
- argp->count = NFSSVC_MAXBLKSIZE_V2;
- }
svc_reserve_auth(rqstp, (19<<2) + argp->count + 4);
resp->count = argp->count;
- resp->status = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh),
- argp->offset,
- rqstp->rq_vec, argp->vlen,
- &resp->count,
- &eof);
+ fh_copy(&resp->fh, &argp->fh);
+ resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
+ rqstp->rq_vec, v, &resp->count, &eof);
if (resp->status == nfs_ok)
resp->status = fh_getattr(&resp->fh, &resp->stat);
else if (resp->status == nfserr_jukebox)
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 36765a96abae..7488fb396627 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -246,33 +246,19 @@ nfssvc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p)
int
nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p)
{
+ struct xdr_stream *xdr = &rqstp->rq_xdr_stream;
struct nfsd_readargs *args = rqstp->rq_argp;
- unsigned int len;
- int v;
- p = decode_fh(p, &args->fh);
- if (!p)
- return 0;
-
- args->offset = ntohl(*p++);
- len = args->count = ntohl(*p++);
- p++; /* totalcount - unused */
- len = min_t(unsigned int, len, NFSSVC_MAXBLKSIZE_V2);
+ if (!svcxdr_decode_fhandle(xdr, &args->fh))
+ return XDR_DECODE_FAILED;
+ p = xdr_inline_decode(xdr, sizeof(__be32) * 3);
+ if (!p)
+ return XDR_DECODE_FAILED;
+ args->offset = be32_to_cpup(p++);
+ args->count = be32_to_cpup(p);
+ /* totalcount is ignored */
- /* set up somewhere to store response.
- * We take pages, put them on reslist and include in iovec
- */
- v=0;
- while (len > 0) {
- struct page *p = *(rqstp->rq_next_page++);
-
- rqstp->rq_vec[v].iov_base = page_address(p);
- rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
- len -= rqstp->rq_vec[v].iov_len;
- v++;
- }
- args->vlen = v;
- return xdr_argsize_check(rqstp, p);
+ return XDR_DECODE_DONE;
}
int
diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h
index 84256a6a1ba1..d2ffda96975d 100644
--- a/fs/nfsd/xdr.h
+++ b/fs/nfsd/xdr.h
@@ -27,7 +27,6 @@ struct nfsd_readargs {
struct svc_fh fh;
__u32 offset;
__u32 count;
- int vlen;
};
struct nfsd_writeargs {
next prev parent reply other threads:[~2020-11-20 20:42 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 20:33 [PATCH v2 000/118] Update NFSD XDR functions Chuck Lever
2020-11-20 20:33 ` [PATCH v2 001/118] NFSD: Fix returned READDIR offset cookie Chuck Lever
2020-11-21 0:59 ` J. Bruce Fields
2020-11-21 16:15 ` Chuck Lever
2020-11-21 16:32 ` Bruce Fields
2020-11-20 20:33 ` [PATCH v2 002/118] SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 003/118] SUNRPC: Prepare for xdr_stream-style decoding on the server-side Chuck Lever
2020-11-23 18:49 ` J. Bruce Fields
2020-11-23 18:52 ` Chuck Lever
2020-11-20 20:34 ` [PATCH v2 004/118] NFSD: Add common helpers to decode void args and encode void results Chuck Lever
2020-11-20 20:34 ` [PATCH v2 005/118] NFSD: Replace the internals of the READ_BUF() macro Chuck Lever
2020-11-23 19:18 ` J. Bruce Fields
2020-11-23 19:21 ` Chuck Lever
2020-11-20 20:34 ` [PATCH v2 006/118] NFSD: Replace READ* macros in nfsd4_decode_access() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 007/118] NFSD: Replace READ* macros in nfsd4_decode_stateid() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 008/118] NFSD: Replace READ* macros in nfsd4_decode_close() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 009/118] NFSD: Replace READ* macros in nfsd4_decode_commit() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 010/118] NFSD: Change the way the expected length of a fattr4 is checked Chuck Lever
2020-11-20 20:34 ` [PATCH v2 011/118] NFSD: Replace READ* macros that decode the fattr4 size attribute Chuck Lever
2020-11-20 20:34 ` [PATCH v2 012/118] NFSD: Replace READ* macros that decode the fattr4 acl attribute Chuck Lever
2020-11-20 20:34 ` [PATCH v2 013/118] NFSD: Replace READ* macros that decode the fattr4 mode attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 014/118] NFSD: Replace READ* macros that decode the fattr4 owner attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 015/118] NFSD: Replace READ* macros that decode the fattr4 owner_group attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 016/118] NFSD: Replace READ* macros that decode the fattr4 time_set attributes Chuck Lever
2020-11-20 20:35 ` [PATCH v2 017/118] NFSD: Replace READ* macros that decode the fattr4 security label attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 018/118] NFSD: Replace READ* macros that decode the fattr4 umask attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 019/118] NFSD: Replace READ* macros in nfsd4_decode_fattr() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 020/118] NFSD: Replace READ* macros in nfsd4_decode_create() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 021/118] NFSD: Replace READ* macros in nfsd4_decode_getattr() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 022/118] NFSD: Replace READ* macros in nfsd4_decode_link() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 023/118] NFSD: Relocate nfsd4_decode_opaque() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 024/118] NFSD: Add helpers to decode a clientid4 and an NFSv4 state owner Chuck Lever
2020-11-20 20:35 ` [PATCH v2 025/118] NFSD: Add helper for decoding locker4 Chuck Lever
2020-11-20 20:36 ` [PATCH v2 026/118] NFSD: Replace READ* macros in nfsd4_decode_lock() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 027/118] NFSD: Replace READ* macros in nfsd4_decode_lockt() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 028/118] NFSD: Replace READ* macros in nfsd4_decode_locku() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 029/118] NFSD: Replace READ* macros in nfsd4_decode_lookup() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 030/118] NFSD: Add helper to decode NFSv4 verifiers Chuck Lever
2020-11-20 20:36 ` [PATCH v2 031/118] NFSD: Add helper to decode OPEN's createhow4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 032/118] NFSD: Add helper to decode OPEN's openflag4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 033/118] NFSD: Replace READ* macros in nfsd4_decode_share_access() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 034/118] NFSD: Replace READ* macros in nfsd4_decode_share_deny() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 035/118] NFSD: Add helper to decode OPEN's open_claim4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 036/118] NFSD: Replace READ* macros in nfsd4_decode_open() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 037/118] NFSD: Replace READ* macros in nfsd4_decode_open_confirm() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 038/118] NFSD: Replace READ* macros in nfsd4_decode_open_downgrade() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 039/118] NFSD: Replace READ* macros in nfsd4_decode_putfh() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 040/118] NFSD: Replace READ* macros in nfsd4_decode_read() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 041/118] NFSD: Replace READ* macros in nfsd4_decode_readdir() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 042/118] NFSD: Replace READ* macros in nfsd4_decode_remove() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 043/118] NFSD: Replace READ* macros in nfsd4_decode_rename() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 044/118] NFSD: Replace READ* macros in nfsd4_decode_renew() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 045/118] NFSD: Replace READ* macros in nfsd4_decode_secinfo() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 046/118] NFSD: Replace READ* macros in nfsd4_decode_setclientid() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 047/118] NFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 048/118] NFSD: Replace READ* macros in nfsd4_decode_verify() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 049/118] NFSD: Replace READ* macros in nfsd4_decode_write() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 050/118] NFSD: Replace READ* macros in nfsd4_decode_release_lockowner() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 051/118] NFSD: Replace READ* macros in nfsd4_decode_cb_sec() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 052/118] NFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 053/118] NFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 054/118] NFSD: Add a separate decoder to handle state_protect_ops Chuck Lever
2020-11-20 20:38 ` [PATCH v2 055/118] NFSD: Add a separate decoder for ssv_sp_parms Chuck Lever
2020-11-20 20:38 ` [PATCH v2 056/118] NFSD: Add a helper to decode state_protect4_a Chuck Lever
2020-11-20 20:38 ` [PATCH v2 057/118] NFSD: Add a helper to decode nfs_impl_id4 Chuck Lever
2020-11-20 20:38 ` [PATCH v2 058/118] NFSD: Add a helper to decode channel_attrs4 Chuck Lever
2020-11-20 20:38 ` [PATCH v2 059/118] NFSD: Replace READ* macros in nfsd4_decode_create_session() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 060/118] NFSD: Replace READ* macros in nfsd4_decode_destroy_session() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 061/118] NFSD: Replace READ* macros in nfsd4_decode_free_stateid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 062/118] NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 063/118] NFSD: Replace READ* macros in nfsd4_decode_layoutcommit() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 064/118] NFSD: Replace READ* macros in nfsd4_decode_layoutget() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 065/118] NFSD: Replace READ* macros in nfsd4_decode_layoutreturn() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 066/118] NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 067/118] NFSD: Replace READ* macros in nfsd4_decode_sequence() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 068/118] NFSD: Replace READ* macros in nfsd4_decode_test_stateid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 069/118] NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 070/118] NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 071/118] NFSD: Replace READ* macros in nfsd4_decode_fallocate() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 072/118] NFSD: Replace READ* macros in nfsd4_decode_clone() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 073/118] NFSD: Replace READ* macros in nfsd4_decode_nl4_server() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 074/118] NFSD: Replace READ* macros in nfsd4_decode_copy() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 075/118] NFSD: Replace READ* macros in nfsd4_decode_seek() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 076/118] NFSD: Replace READ* macros in nfsd4_decode_xattr_name() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 077/118] NFSD: Replace READ* macros in nfsd4_decode_setxattr() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 078/118] NFSD: Replace READ* macros in nfsd4_decode_listxattrs() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 079/118] NFSD: Replace READ* macros in nfsd4_decode_compound() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 080/118] NFSD: Remove macros that are no longer used Chuck Lever
2020-11-20 20:40 ` [PATCH v2 081/118] NFSD: Update GETATTR3args decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:41 ` [PATCH v2 082/118] NFSD: Update ACCESS3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 083/118] NFSD: Update READ3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 084/118] NFSD: Update WRITE3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 085/118] NFSD: Update READLINK3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 086/118] NFSD: Add helper to set up the pages where the dirlist is encoded Chuck Lever
2020-11-20 20:41 ` [PATCH v2 087/118] NFSD: Update READDIR3args decoders to use struct xdr_stream Chuck Lever
2020-11-23 20:55 ` J. Bruce Fields
2020-11-20 20:41 ` [PATCH v2 088/118] NFSD: Update COMMIT3arg decoder " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 089/118] NFSD: Update the NFSv3 DIROPargs " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 090/118] NFSD: Update the RENAME3args " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 091/118] NFSD: Update the LINK3args " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 092/118] NFSD: Update the SETATTR3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 093/118] NFSD: Update the CREATE3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 094/118] NFSD: Update the MKDIR3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 095/118] NFSD: Update the SYMLINK3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 096/118] NFSD: Update the MKNOD3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 097/118] NFSD: Update the NFSv2 GETATTR argument " Chuck Lever
2020-11-20 20:42 ` Chuck Lever [this message]
2020-11-20 20:42 ` [PATCH v2 099/118] NFSD: Update the NFSv2 WRITE " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 100/118] NFSD: Update the NFSv2 READLINK " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 101/118] NFSD: Add helper to set up the pages where the dirlist is encoded Chuck Lever
2020-11-20 20:42 ` [PATCH v2 102/118] NFSD: Update the NFSv2 READDIR argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:42 ` [PATCH v2 103/118] NFSD: Update NFSv2 diropargs decoding " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 104/118] NFSD: Update the NFSv2 RENAME argument decoder " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 105/118] NFSD: Update the NFSv2 LINK " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 106/118] NFSD: Update the NFSv2 SETATTR " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 107/118] NFSD: Update the NFSv2 CREATE " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 108/118] NFSD: Update the NFSv2 SYMLINK " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 109/118] NFSD: Remove argument length checking in nfsd_dispatch() Chuck Lever
2020-11-20 20:43 ` [PATCH v2 110/118] NFSD: Update the NFSv2 GETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:43 ` [PATCH v2 111/118] NFSD: Add an xdr_stream-based decoder for NFSv2/3 ACLs Chuck Lever
2020-11-20 20:43 ` [PATCH v2 112/118] NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:43 ` [PATCH v2 113/118] NFSD: Update the NFSv2 ACL GETATTR " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 114/118] NFSD: Update the NFSv2 ACL ACCESS " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 115/118] NFSD: Clean up after updating NFSv2 ACL decoders Chuck Lever
2020-11-20 20:44 ` [PATCH v2 116/118] NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:44 ` [PATCH v2 117/118] NFSD: Update the NFSv2 SETACL " Chuck Lever
2020-11-20 20:44 ` [PATCH v2 118/118] NFSD: Clean up after updating NFSv3 ACL decoders Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160590494786.1340.6179902743258104536.stgit@klimt.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).