Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2478853pxa; Mon, 17 Aug 2020 10:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdPw4RxSEjNz+jozh1Fyhb8Dmy6aZod/fpSaQGvsQz/8zKW2W/OEdFxThJohBEi8a89GVf X-Received: by 2002:a17:906:3b18:: with SMTP id g24mr15858880ejf.420.1597685658453; Mon, 17 Aug 2020 10:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597685658; cv=none; d=google.com; s=arc-20160816; b=0wByxiQ4Fsd3Bw6kjly2gBgPA4knU7zbmOiu7EE6D56lUKksV7RdSaU4KISZzUz30a dsc+4z6h9MRWOxJCD1OPiVUjY8CK2LtaZxKuPZHd3P3D4fv0/l42dUcSgml61Z/gaSk4 CbVitWlZ1fg/0EfC1d1UMXS8pd7pcDuJAto7j/q+7NN9ySIaILCh3B/Fm7xzaIuXopGH XkW5Csn2Ip0SPKWB1W5sCTPEyeE2/i3/8oOvG/0DYe3FeqhduoQiG9ofsjbZEIx+YnVa 7AsUU3j6P2juj+m2MvJMj/PpNEWglLjeY3RBncvdEZS25oDndLrxk697Kh4VmE6yDYKf An5g== 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=3AsGc/1Xpo40vE8L6nCtW9cEOngIRVeMlkrIMYelAG0=; b=qGyhfukV3ovhOeH4P4a//CYAMN6HV+/5wWTGwqw+P8UIgrNYvV/T0m05RUeEbQ/zLs 1NMU+OFnko1LVRqG+fc/o3EQBPGTRXk+oLLUuv5Eg4jTr/+WZq8TaZ/fb64x5ulBqFo+ 0MtRF5AA4b8QX77Qq4Naj28DASbST+Y5gmk+rAm+DRGs9+39tVRwPummjxm2N0l9Tsov FJRTHRzSCuQSWV5chPVjlfTiQ7l6y3kKTDT7G5ASCKaOy/GAoZPyzBkMLD5iAaE5gL28 a/TDz/mXLQ63epjE/W4qegB4zhxOQyWruOMNvcadRJBEHm5gxASJkrldz1RKlJB1u574 i+Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tTyADODw; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y23si11859276ejd.544.2020.08.17.10.33.53; Mon, 17 Aug 2020 10:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tTyADODw; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 S2389262AbgHQRdS (ORCPT + 99 others); Mon, 17 Aug 2020 13:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389111AbgHQQyE (ORCPT ); Mon, 17 Aug 2020 12:54:04 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72ABDC061359 for ; Mon, 17 Aug 2020 09:53:40 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id b17so18284048ion.7 for ; Mon, 17 Aug 2020 09:53:40 -0700 (PDT) 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=3AsGc/1Xpo40vE8L6nCtW9cEOngIRVeMlkrIMYelAG0=; b=tTyADODwhitY6QSkseippOl+P33mGViQEjaKKMStcePMPz7jf5GaDHFm3Ws1GJhsAX HCmACL3w7VdqC2YOBVuXUriwPWLRnFkF6HFbqeJBKacIgl12TYSbNi3IprXCBS8TqeMm 8BlBVHu9AFn1bqeixAeETq9DHlbp1OigEAXS45nEXgHlwLSi6HddYiceansuVHj0G1BR TcneAeZr3i9aUWjpXsv973ZISXDPY8bBzvBoLhVmoZpG1wqMx+Mek+dF6mFtbQAdmnUQ TYg/QfALludTLOnrlVkbWQ6vrraaojSanknpwNNRLnUujMTEnFcepoa31fnNKCZHJ5S0 SNFQ== 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=3AsGc/1Xpo40vE8L6nCtW9cEOngIRVeMlkrIMYelAG0=; b=iEd0hgrxHhkMBUe0Gm3qBAZFzn0C0qJrX8ykSlbIozLVVp4+EetZLK00Rt3M0eKi/h K62Pz0tjJtmjFQVZRO1j1vCKENgOuxF3HVnO3vR4f2Rkk8LeQUabD1dq19XZ+YSQKQOm EzLR68E1vrJI93IzOUmsxi/+VeTYrRj9nIfVNk9irkvvzrUihu7cXLhbvVa2T1WKToyO l7htskD9UTTwlrwHAsDVsj0dI9KeHWgmGBPkulIi3xmCQeiXhL4wlDxv9ssM4SZeyyqp 6V2gsfTIDoQhutuBMec8wFCtZIqCzwfJBpcb5YUFZ1yrlqslwDkbGzYl1vt5rfR/I0ba gziQ== X-Gm-Message-State: AOAM531sFbIfgLuLm8LGVsG0NnxUiHeA1S0MzppN33RPPT5BQW6jJvj/ MU5PgZi9TM0wFbnZvR9rdLdIvY3Hciw= X-Received: by 2002:a5d:91d4:: with SMTP id k20mr13399540ior.9.1597683219549; Mon, 17 Aug 2020 09:53:39 -0700 (PDT) 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 a16sm7413106ilc.7.2020.08.17.09.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 09:53:38 -0700 (PDT) From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v4 10/10] NFS: Decode a full READ_PLUS reply Date: Mon, 17 Aug 2020 12:53:27 -0400 Message-Id: <20200817165327.354181-11-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817165327.354181-1-Anna.Schumaker@Netapp.com> References: <20200817165327.354181-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 Decode multiple hole and data segments sent by the server, placing everything directly where they need to go in the xdr pages. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 90f415944b90..ffaa7ae9304a 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -756,7 +756,7 @@ 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); res->count += recvd; if (count > recvd) { @@ -781,7 +781,7 @@ 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); res->count += recvd; if (recvd < length) { @@ -794,7 +794,7 @@ static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *re static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) { uint32_t eof, segments, type; - int status; + int status, i; __be32 *p; status = decode_op_hdr(xdr, OP_READ_PLUS); @@ -810,22 +810,24 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) if (segments == 0) goto out; - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; + for (i = 0; i < segments; i++) { + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; - type = be32_to_cpup(p++); - if (type == NFS4_CONTENT_DATA) - status = decode_read_plus_data(xdr, res, &eof); - else if (type == NFS4_CONTENT_HOLE) - status = decode_read_plus_hole(xdr, res, &eof); - else - return -EINVAL; + type = be32_to_cpup(p++); + if (type == NFS4_CONTENT_DATA) + status = decode_read_plus_data(xdr, res, &eof); + else if (type == NFS4_CONTENT_HOLE) + status = decode_read_plus_hole(xdr, res, &eof); + else + return -EINVAL; - if (status) - return status; - if (segments > 1) - eof = 0; + if (status < 0) + return status; + if (status > 0) + break; + } out: res->eof = eof; -- 2.28.0