Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1231978ybl; Fri, 10 Jan 2020 14:35:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxTi4WvTj2pXvY/rP3GMGTr4Uz+RRoxvughmLTr3qJ8tEaK7ov5AFvyNBZSJa56d7L12uoA X-Received: by 2002:aca:1204:: with SMTP id 4mr4158440ois.143.1578695756372; Fri, 10 Jan 2020 14:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578695756; cv=none; d=google.com; s=arc-20160816; b=alvXFiRIp5H3tWDDvmlDdj9oqK3kilounden2gjkjDtAWVxMx60Vhm4xQSCAoI607T rTExLBAPzPJWEfMZwYx4Fm+Rk/X0wgqkY3O3t7aZiyDs92ZCARZw830CDt/IQW/Ljehg trcHUags7dSka2wPy11P+AKqIm5Gmr/u+AO5LbtOM854W1trPQkyTdv05o7sifXDAVYS v3V9fkssYM8cadJLvljLaOPiv6N9+YJB1CR7ksaS8tULGti8Pkv1ZTtHlQKOSN3gQcFH be4tMb8Z/mNSV7QK57uEof2E6TcBAbDYLhYRfL7XR0//wKU9Q6Jl9QYkB8/Ir7cIyVin oJOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xsfb9xbGJqHF0vJh/iXTq267VS4JgDlr9nlfdAvU1UQ=; b=rTJBZsEyQYtceLv24n8NCSUV/4EWZu8wbhMbUM6PaRxMtt1MzavqF1fedRogfjNiTS cEP0FGjKO3xrissc6AbZ6Nv9mx5dVZQZnfCRGE54xaJpa+cDNMmyZn5Cr7ylTecv6N/Q mg/GDMpuwhzNlm3MYCw8DqENKm81ufK4jENYbRGwKl8X+C6zZKENrEvM+P49Y8rjjn95 4Ps8dyNMv/7LZ0RYYeOThxy/NxY/ANHDuorOPFg+wWcFYyT4eI1lHDMhKtjZIm6XRSJQ 4ONzmJ0nPaEnTHI7i7BHVUQhN3Z7eaQCgHOAjGQkNxhJM8bf8OyqKi52gj3o6ouiAsQa mniw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=n8UaaSa7; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f187si1866957oia.218.2020.01.10.14.35.45; Fri, 10 Jan 2020 14:35:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=n8UaaSa7; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbgAJWfp (ORCPT + 99 others); Fri, 10 Jan 2020 17:35:45 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:33375 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbgAJWfp (ORCPT ); Fri, 10 Jan 2020 17:35:45 -0500 Received: by mail-yw1-f68.google.com with SMTP id 192so1332250ywy.0 for ; Fri, 10 Jan 2020 14:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xsfb9xbGJqHF0vJh/iXTq267VS4JgDlr9nlfdAvU1UQ=; b=n8UaaSa7QkR69IfxxXsb4sy8HgKiL9Qon5KYnph3QfUgrN2dMNlEqkANaB/IbeqILd sXBWGtAGcLGXc0bDMo7e7SUv57aWLyP7TRm5sIlSBeLLyTMHwwfQCsviGfqo5KeveFjc gWrTky/xttbI8YeO+bP2Y4XcKk6Yw5/0tLuae+sEVfLKYHwQ9xY7PmIecHp0FwGzmBMh gj/bIWhCahuE/hM9Dz1ZckJPrZJ3/P6x2i90NoRidrE3IyiDecE6pyLIu8Z69gpO5GtH rr0Z2Kb3WLJtgk4gjD+TLtvbsy2Z5m1euDZUZlX61GffBbcFRAnkDcu+W1ILLzZmQqLM ljcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Xsfb9xbGJqHF0vJh/iXTq267VS4JgDlr9nlfdAvU1UQ=; b=b4oW7stLKDf5hG1V4qozJjAPAI1fsDzWgF8MuDS7LZdqG7B4hJULdSK9kEa+EF1DSk bCEMQdlYsT+jdDvd/+PNCtId1E04LCiAhuJ26K8pCLmq+gEIm9+ep98mPHIm12Bjm/lQ bLJcF4/fog0K1AJNqb1GMmkVwxPN+ODEGqySr4IyoYwuq1Ix0nMkiBwB2t702v0kscxz ZTySS8PGt+jun7aeZJ909sDAwK6JU5sdFBymVRJnrGo+LFAZC1MYwOBV293wtcIbB+y3 wd0/wujvXFrG3y2yl06yMOS+Ch9hUU3ytLjASVu4r+JGAZlmlLdCpkgPIx+iZ9mFYI0w LPTw== X-Gm-Message-State: APjAAAV1Lfg6X4rqpL14d+7FFFxA21XJhYvNrUbjwzri6qMjCfa3Lw8f n1sYUlVRh+PN2BcZg76D9/s= X-Received: by 2002:a0d:ffc2:: with SMTP id p185mr4714977ywf.256.1578695744090; Fri, 10 Jan 2020 14:35:44 -0800 (PST) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id h23sm1607735ywc.105.2020.01.10.14.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2020 14:35:43 -0800 (PST) From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: bfields@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH 3/4] NFSD: Add READ_PLUS hole segment encoding Date: Fri, 10 Jan 2020 17:35:37 -0500 Message-Id: <20200110223538.528560-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200110223538.528560-1-Anna.Schumaker@Netapp.com> References: <20200110223538.528560-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker However, we only encode the hole if it is at the beginning of the range and treat everything else as data to keep things simple. Signed-off-by: Anna Schumaker --- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfs4xdr.c | 47 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 3c11ca9bd5d7..fc8c821eda8b 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2184,7 +2184,7 @@ static inline u32 nfsd4_read_plus_rsize(struct svc_rqst *rqstp, struct nfsd4_op u32 maxcount = svc_max_payload(rqstp); u32 rlen = min(op->u.read.rd_length, maxcount); /* enough extra xdr space for encoding either a hole or data segment. */ - u32 segments = 1 + 2 + 2; + u32 segments = 2 * (1 + 2 + 2); return (op_encode_hdr_size + 2 + segments + XDR_QUADLEN(rlen)) * sizeof(__be32); } diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 014e05365c17..552972b35547 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4302,6 +4302,31 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, return nfserr; } +static __be32 +nfsd4_encode_read_plus_hole(struct nfsd4_compoundres *resp, struct nfsd4_read *read, + unsigned long maxcount, u32 *eof) +{ + struct file *file = read->rd_nf->nf_file; + __be32 *p; + + /* Content type, offset, byte count */ + p = xdr_reserve_space(&resp->xdr, 4 + 8 + 8); + if (!p) + return nfserr_resource; + + maxcount = min_t(unsigned long, maxcount, read->rd_length); + + *p++ = cpu_to_be32(NFS4_CONTENT_HOLE); + p = xdr_encode_hyper(p, read->rd_offset); + p = xdr_encode_hyper(p, maxcount); + + *eof = (read->rd_offset + maxcount) >= i_size_read(file_inode(file)); + + read->rd_offset += maxcount; + read->rd_length = (maxcount > 0) ? read->rd_length - maxcount : 0; + return nfs_ok; +} + static __be32 nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_read *read) @@ -4311,6 +4336,8 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr, struct xdr_stream *xdr = &resp->xdr; struct file *file; int starting_len = xdr->buf->len; + unsigned int segments = 0; + loff_t data_pos; __be32 *p; if (nfserr) @@ -4335,12 +4362,28 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr, (xdr->buf->buflen - xdr->buf->len)); maxcount = min_t(unsigned long, maxcount, read->rd_length); - nfserr = nfsd4_encode_read_plus_data(resp, read, maxcount, &eof); + data_pos = vfs_llseek(file, read->rd_offset, SEEK_DATA); + if (data_pos == -ENXIO) + data_pos = i_size_read(file_inode(file)); + else if (data_pos < 0) + data_pos = read->rd_offset; + + if (data_pos > read->rd_offset) { + nfserr = nfsd4_encode_read_plus_hole(resp, read, + data_pos - read->rd_offset, &eof); + segments++; + } + + if (!nfserr && !eof && read->rd_length > 0) { + nfserr = nfsd4_encode_read_plus_data(resp, read, maxcount, &eof); + segments++; + } + if (nfserr) xdr_truncate_encode(xdr, starting_len); else { *p++ = htonl(eof); - *p++ = htonl(1); + *p++ = htonl(segments); } return nfserr; -- 2.24.1