From patchwork Wed Dec 17 22:35:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 5509471 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3A8109F1D4 for ; Wed, 17 Dec 2014 22:35:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C134209D3 for ; Wed, 17 Dec 2014 22:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 714B3209E1 for ; Wed, 17 Dec 2014 22:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751117AbaLQWfL (ORCPT ); Wed, 17 Dec 2014 17:35:11 -0500 Received: from mx11.netapp.com ([216.240.18.76]:7211 "EHLO mx11.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbaLQWfL (ORCPT ); Wed, 17 Dec 2014 17:35:11 -0500 X-IronPort-AV: E=Sophos;i="5.07,596,1413270000"; d="scan'208";a="174666242" Received: from vmwexchts01-prd.hq.netapp.com ([10.122.105.12]) by mx11-out.netapp.com with ESMTP; 17 Dec 2014 14:35:10 -0800 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) with Microsoft SMTP Server id 15.0.995.29; Wed, 17 Dec 2014 14:35:10 -0800 Received: from davros.com ([10.63.236.12]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id sBHMZ5B0001871; Wed, 17 Dec 2014 14:35:09 -0800 (PST) From: To: CC: Subject: [PATCH 4/4] NFSD: Add support for encoding multiple segments Date: Wed, 17 Dec 2014 17:35:04 -0500 Message-ID: <1418855704-14127-5-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418855704-14127-1-git-send-email-Anna.Schumaker@Netapp.com> References: <1418855704-14127-1-git-send-email-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anna Schumaker This patch lets us send an array of segments back to the client. In theory this will make v4.2 reads more efficient, but only if the client is equipped to handle multiple segment reads. Signed-off-by: Anna Schumaker --- fs/nfsd/nfs4xdr.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2ec9860..b678016 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3823,6 +3823,7 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, struct nfsd4_read *r *p++ = cpu_to_be32(maxcount); read->rd_offset += maxcount; + read->rd_length -= maxcount; return err; } @@ -3839,6 +3840,10 @@ nfsd4_encode_read_plus_hole(struct nfsd4_compoundres *resp, struct nfsd4_read *r p = xdr_encode_hyper(p, maxcount); read->rd_offset += maxcount; + if (maxcount > read->rd_length) + read->rd_length = 0; + else + read->rd_length -= maxcount; return nfs_ok; } @@ -3871,23 +3876,26 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr, goto err_truncate; } - hole_pos = vfs_llseek(read->rd_filp, read->rd_offset, SEEK_HOLE); - if (hole_pos == -ENXIO) - goto out_encode; + do { + hole_pos = vfs_llseek(read->rd_filp, read->rd_offset, SEEK_HOLE); + if (hole_pos == -ENXIO) + break; - data_pos = vfs_llseek(read->rd_filp, read->rd_offset, SEEK_DATA); - if (data_pos == -ENXIO) - data_pos = i_size_read(file_inode(file)); + data_pos = vfs_llseek(read->rd_filp, read->rd_offset, SEEK_DATA); + if (data_pos == -ENXIO) + data_pos = i_size_read(file_inode(file)); - if ((data_pos == read->rd_offset) && (hole_pos > data_pos)) - err = nfsd4_encode_read_plus_data(resp, read, file, hole_pos); - else if ((hole_pos == read->rd_offset) && (data_pos > hole_pos)) - err = nfsd4_encode_read_plus_hole(resp, read, file, data_pos); - else /* The file probably changed on us between seeks. */ - err = nfsd4_encode_read_plus_data(resp, read, file, i_size_read(file_inode(file))); - segments++; + if ((data_pos == read->rd_offset) && (hole_pos > data_pos)) + err = nfsd4_encode_read_plus_data(resp, read, file, hole_pos); + else if ((hole_pos == read->rd_offset) && (data_pos > hole_pos)) + err = nfsd4_encode_read_plus_hole(resp, read, file, data_pos); + else /* The file probably changed on us between seeks. */ + err = nfsd4_encode_read_plus_data(resp, read, file, i_size_read(file_inode(file))); + if (err) + break; + segments++; + } while (read->rd_length > 0); -out_encode: eof = (read->rd_offset >= i_size_read(file_inode(file))); *p++ = cpu_to_be32(eof); *p++ = cpu_to_be32(segments);