From patchwork Wed Jan 28 20:43:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 5731081 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 201CDBF440 for ; Wed, 28 Jan 2015 21:34:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C4C1200E3 for ; Wed, 28 Jan 2015 21:34:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0265A200DF for ; Wed, 28 Jan 2015 21:34:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761560AbbA1UoF (ORCPT ); Wed, 28 Jan 2015 15:44:05 -0500 Received: from mx143.netapp.com ([216.240.21.24]:49184 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761534AbbA1UoD (ORCPT ); Wed, 28 Jan 2015 15:44:03 -0500 X-IronPort-AV: E=Sophos;i="5.09,482,1418112000"; d="scan'208";a="18873649" Received: from vmwexchts03-prd.hq.netapp.com ([10.122.105.31]) by mx143-out.netapp.com with ESMTP; 28 Jan 2015 12:43:57 -0800 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS03-PRD.hq.netapp.com (10.122.105.31) with Microsoft SMTP Server id 15.0.995.29; Wed, 28 Jan 2015 12:43:57 -0800 Received: from davros.com ([10.63.237.113]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id t0SKhpiP026948; Wed, 28 Jan 2015 12:43:56 -0800 (PST) From: Anna Schumaker To: , Subject: [PATCH v2 6/6] NFS: Add support for decoding multiple segments Date: Wed, 28 Jan 2015 15:43:50 -0500 Message-ID: <1422477830-28090-7-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422477830-28090-1-git-send-email-Anna.Schumaker@Netapp.com> References: <1422477830-28090-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 We now have everything we need to read holes and then shift data to where it's supposed to be. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 17126e8..010af55 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -201,11 +201,11 @@ static int decode_read_plus_data(struct xdr_stream *xdr, struct nfs_pgio_res *re p = xdr_decode_hyper(p, &offset); count = be32_to_cpup(p); - recvd = xdr_read_pages(xdr, count); + recvd = xdr_align_data(xdr, res->count, count); if (recvd < count) res->eof = 0; - res->count = recvd; + res->count += recvd; return 0; out_overflow: print_overflow_msg(__func__, xdr); @@ -225,11 +225,11 @@ static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *re p = xdr_decode_hyper(p, &offset); p = xdr_decode_hyper(p, &length); - recvd = xdr_expand_hole(xdr, 0, length); + recvd = xdr_expand_hole(xdr, res->count, length); if (recvd < length) res->eof = 0; - res->count = recvd; + res->count += recvd; return 0; out_overflow: print_overflow_msg(__func__, xdr); @@ -240,7 +240,7 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) { __be32 *p; int status, type; - uint32_t segments; + uint32_t i, segments; status = decode_op_hdr(xdr, OP_READ_PLUS); if (status) @@ -253,20 +253,24 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) res->count = 0; res->eof = be32_to_cpup(p++); segments = be32_to_cpup(p++); - if (segments == 0) - return 0; - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - goto out_overflow; - - type = be32_to_cpup(p++); - if (type == NFS4_CONTENT_DATA) - status = decode_read_plus_data(xdr, res); - else - status = decode_read_plus_hole(xdr, res); - - if (segments > 1) + for (i = 0; i < segments; i++) { + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + goto out_overflow; + + type = be32_to_cpup(p); + if (type == NFS4_CONTENT_DATA) + status = decode_read_plus_data(xdr, res); + else + status = decode_read_plus_hole(xdr, res); + if (status) + break; + if (res->count == xdr->buf->page_len) + break; + } + + if (i < segments) res->eof = 0; return status; out_overflow: