Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4066062pxk; Tue, 8 Sep 2020 09:48:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJgmhCoqLZr1kxKJ5K7GU0muhFMsORx3j6yfyhS/DctyJ9M0Tnrryas95iv6o9uEvNz8fR X-Received: by 2002:aa7:d747:: with SMTP id a7mr20341869eds.304.1599583706377; Tue, 08 Sep 2020 09:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599583706; cv=none; d=google.com; s=arc-20160816; b=gc6O5DYYAeN4+UjYEZExnQBXQoCp0OJH2AaqeInqG5bNu6aGnYboTKT364lCr12R9f ExC+7zSPb82/8QEw3zQ/+uirj1KmrWqQXQKc4Fv3FcIHydQCAaMuM4L5VUmW/iFLWaPM 39m0n1mWF6e/7luXhlxwlPE9dOqCdmUsVUjkqgahdXnpW2PapjVFmkyoh27C0lTAcClH PZuJXdofwMnUHRV0jtRFN5/YuSH9rU8IRxAaH+IfqMOY7/N0ZC8G6WATDlX2iKpilqIo xkVCVezsClFqvKNhHG35pNSErfH+0yJ9wt4XnZgjS6V1Tdj+QHF+0Md6REth2QROwRQ6 yYgw== 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=McNZrU0EDFV6A3TZqivdfUIZNz6mK+EHHnD6g+nLLJ8=; b=v3WSLk3PkxtoIgE0dh9iNqyMDky4aC2lCNd5JDqBdW/5kj+FsCLR5w4BPTWP8XQAX/ Cy5AJqfpQ4Wqg3EeKqtLncyCsTiizJYiTHjA0ELaRkE1av6Xvp+WauqpBrHkvXl6mS2e DQo8w3OSrRLWQDVTBjDA+lBIIXKbD9GKsYOfwk+TmUBPjOpy88H76CCZHmqv8J/H4VIz frOjwJnKqHaczxUIbUWhbC4PzdfPkCgAwxNDlRXm1PdN/1buIikNuAg2IpurRA/XxkHz Ftudpgc5MPIIXZONs0/l6ZVnevIi9h1bcAMQtJFTL6n9xxRb7660ATjFsycqUHqE6CsZ Id9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jHRVG4tP; 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 c25si4853338eds.548.2020.09.08.09.48.02; Tue, 08 Sep 2020 09:48:26 -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=jHRVG4tP; 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 S1731956AbgIHQrM (ORCPT + 99 others); Tue, 8 Sep 2020 12:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731952AbgIHQ0T (ORCPT ); Tue, 8 Sep 2020 12:26:19 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F0FC061799 for ; Tue, 8 Sep 2020 09:25:25 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id l4so15987823ilq.2 for ; Tue, 08 Sep 2020 09:25:25 -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=McNZrU0EDFV6A3TZqivdfUIZNz6mK+EHHnD6g+nLLJ8=; b=jHRVG4tPsvF1IqVMGyQfVzxW8qACaqbKAd12Yx4AX8QZE/wjKLYHEggEi3xZPzTKbN E6/S0d+xSmgnAsjmDCypPOi+R3IyFH0foW/TexU6incpe8aHwEBRiJNrEYe0hEWLVqZv xoXxvqWnMNtJ4pLiqkZPYWKXkBi2S3eC82qFaF+Yc2J0GzNwMM28LNWxhLGryVjVKfev XKdBACG46frQZIgTDx/RujNIpPqpRLxFsLkCatumSuAfSCROC6NZe8asVRJ8JNVp/4rB GDuIg4uu70eg94n/ziRkR0SYYcSHIGTSpIGFy/5DJXfKKXzFh4m3LpGbOv1+pX7au0qd Pd4A== 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=McNZrU0EDFV6A3TZqivdfUIZNz6mK+EHHnD6g+nLLJ8=; b=qp4H5Q0nXoLp8LzGNAZvvucAfkrjWOOvulJjyAAJUj7F91M+H2nh86NuSXyWdjoRrn Q/n6awcqW+ucdLcRarbd7wAl2d2SbI/KwNoLe6qZck00afyJDYQMMozYFT01MKUgFcoJ x4GCHUnrhNiBGKTSXkgwPvV/F5U3YXMRhU4E7++uGneZW/B8730/6ImrOKE1A3/uTFO0 h8UaAoq6ylAORGxjgens8bWktVEitSOQ92AoNwBtPc8pjkb5TzVXgtzLSAMgSaThVqAW /1WwGqDjt9X/K2yFLstYQ67/P+3Brxqd5ILQzZXZME6fopUk3ONd94cJzVG3O1lzK1gC eNMQ== X-Gm-Message-State: AOAM532+fCSL0suG2IntVoZ1HAUmRnTdtYgLkzhRHcfw+x0YcZLzIIfl V7eVHhh31q6/oeH7XMIDkk2Ik58A4Ys= X-Received: by 2002:a92:dd85:: with SMTP id g5mr23754878iln.210.1599582324596; Tue, 08 Sep 2020 09:25:24 -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 2sm10291375ilj.24.2020.09.08.09.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 09:25:23 -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 v5 10/10] NFS: Decode a full READ_PLUS reply Date: Tue, 8 Sep 2020 12:25:13 -0400 Message-Id: <20200908162513.508991-11-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908162513.508991-1-Anna.Schumaker@Netapp.com> References: <20200908162513.508991-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 9720fedd2e57..0dc31ad2362e 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -1032,7 +1032,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) { @@ -1057,7 +1057,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) { @@ -1070,7 +1070,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); @@ -1086,22 +1086,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