From: schumaker.anna@gmail.com
To: Trond.Myklebust@hammerspace.com, linux-nfs@vger.kernel.org
Cc: Anna.Schumaker@Netapp.com
Subject: [PATCH 5/7] NFS: Add READ_PLUS hole segment decoding
Date: Fri, 10 Jan 2020 17:34:53 -0500 [thread overview]
Message-ID: <20200110223455.528471-6-Anna.Schumaker@Netapp.com> (raw)
In-Reply-To: <20200110223455.528471-1-Anna.Schumaker@Netapp.com>
From: Anna Schumaker <Anna.Schumaker@Netapp.com>
We keep things simple for now by only decoding a single hole or data
segment returned by the server, even if they returned more to us.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
fs/nfs/nfs42xdr.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index bf118ecabe2c..3407a3cf2e13 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -47,7 +47,7 @@
#define decode_deallocate_maxsz (op_decode_hdr_maxsz)
#define encode_read_plus_maxsz (op_encode_hdr_maxsz + \
encode_stateid_maxsz + 3)
-#define NFS42_READ_PLUS_SEGMENT_SIZE (1 /* data_content4 */ + \
+#define NFS42_READ_PLUS_SEGMENT_SIZE (2 /* data_content4 */ + \
2 /* data_info4.di_offset */ + \
2 /* data_info4.di_length */)
#define decode_read_plus_maxsz (op_decode_hdr_maxsz + \
@@ -771,6 +771,31 @@ static uint32_t decode_read_plus_data(struct xdr_stream *xdr, struct nfs_pgio_re
return count;
}
+static uint32_t decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *res,
+ uint32_t *eof)
+{
+ __be32 *p;
+ uint64_t offset, length;
+ size_t recvd;
+
+ p = xdr_inline_decode(xdr, 8 + 8);
+ if (unlikely(!p))
+ return -EIO;
+
+ p = xdr_decode_hyper(p, &offset);
+ p = xdr_decode_hyper(p, &length);
+ if (length == 0)
+ return 0;
+
+ recvd = xdr_expand_hole(xdr, 0, length);
+ if (recvd < length) {
+ *eof = 0;
+ length = recvd;
+ }
+
+ return length;
+}
+
static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)
{
__be32 *p;
@@ -798,7 +823,10 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)
if (type == NFS4_CONTENT_DATA)
count = decode_read_plus_data(xdr, res, &eof);
else
- return -EINVAL;
+ count = decode_read_plus_hole(xdr, res, &eof);
+
+ if (segments > 1)
+ eof = 0;
res->eof = eof;
res->count = count;
--
2.24.1
next prev parent reply other threads:[~2020-01-10 22:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 22:34 [PATCH 0/7] NFS: Add support for the v4.2 READ_PLUS operation schumaker.anna
2020-01-10 22:34 ` [PATCH 1/7] SUNRPC: Split out a function for setting current page schumaker.anna
2020-01-10 22:34 ` [PATCH 2/7] SUNRPC: Add the ability to expand holes in data pages schumaker.anna
2020-01-10 22:34 ` [PATCH 3/7] SUNRPC: Add the ability to shift data to a specific offset schumaker.anna
2020-01-10 22:34 ` [PATCH 4/7] NFS: Add READ_PLUS data segment support schumaker.anna
2020-01-10 22:34 ` schumaker.anna [this message]
2020-01-10 22:34 ` [PATCH 6/7] NFS: Decode multiple READ_PLUS segments schumaker.anna
2020-01-10 22:34 ` [PATCH 7/7] NFS: Add a mount option for READ_PLUS schumaker.anna
2020-01-10 22:41 ` Chuck Lever
2020-01-10 22:43 ` Schumaker, Anna
2020-01-10 22:45 ` 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=20200110223455.528471-6-Anna.Schumaker@Netapp.com \
--to=schumaker.anna@gmail.com \
--cc=Anna.Schumaker@Netapp.com \
--cc=Trond.Myklebust@hammerspace.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).