Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2594550pxp; Sun, 13 Mar 2022 23:56:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEUM9OE2qjATHNhWlfIO18AlniE38ZnAnz24yC1SuIIyiWbVQqy/78m0Yr3rifESdcOM8D X-Received: by 2002:a05:6402:27ce:b0:416:9d78:9f1f with SMTP id c14-20020a05640227ce00b004169d789f1fmr19036832ede.356.1647240975163; Sun, 13 Mar 2022 23:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647240975; cv=none; d=google.com; s=arc-20160816; b=dyF4fQqyfHZC1OaQAbfSE02h9/lOulzW6qm1Z4C7ZnJuMciozuIemBICreYfs5S1Y/ VF9IjzdTiOx23BpeYqvZiNhZvIBVya951vmkAbpoPZbr/3Q4wrtk7hIVed+M8ansyGwL 4oig9qQLyBuyydo6UKMZZReWwto0HxhdKAVlLL+0ohKUItX1x3wFpe2rgjFgfrJtS3a2 COo+5A11w1n3hItg6dw1aq8YQTZXZoOzzxCuLBp7gRHU7HC1/xgaBVIaf9o82OAif7Dh z1EMAoJ7dZcS/k5vMYNRJ6A/uvybk9LtuYl7BdnZHIK31Tc3lDU/MYsj6r1Fsr+GaG8o Wsbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wOHe5XrnLrLn+ucld+wambBPtTM9OCG8XN8H99HXpLo=; b=NO5TR9/io1SnmBd5kC4MfnjM/+O0d62eI2TGIqY3LpLF4sVN6MzG18DQ2UwhmrAIK/ z8irglJDOFLYMxSMtxfHbrK+0bAnff8/0XsffRdeU5LEFIlBNlsAzAb9Pj+KMm9unTey lNu4r/K3GANRU7gNpSHfReqwKfClMwZQvsw84qo2F0oBh+McE2SNB78ic/gqjQYh79hg yRuU0KdqsyJLZVg2mGSOMOg49PhsozMSpPtnXM9ScuXBROnaqY+UaWeF7fRUGEASNhXu QMS7QBmU0AoWTTDXNstnwtWI3AViaIBJA+rHB+p90W8pXQ7ufYImTasbnmovN/BXuz3m x0EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TIzFTOTI; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa15-20020a170907868f00b006d082584a9asi9046476ejc.48.2022.03.13.23.55.40; Sun, 13 Mar 2022 23:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TIzFTOTI; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235125AbiCMRN1 (ORCPT + 99 others); Sun, 13 Mar 2022 13:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235109AbiCMRNX (ORCPT ); Sun, 13 Mar 2022 13:13:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3408139CDC for ; Sun, 13 Mar 2022 10:12:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94D64B80CAD for ; Sun, 13 Mar 2022 17:12:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2406AC340F3 for ; Sun, 13 Mar 2022 17:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647191534; bh=QjZwwJ3HUUQO+XfH2y64vcVJH+KHF3AR7/ERcEVd28Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TIzFTOTIzF2KQCNC8+MJBux48u/BUKywVu47KPeC5QfGRpDDhJltpelVdvI/HAqof e2YVrsX540+9hVNvmX+DLy7r/Gh63yczDq9X/AcIk4loofj7VPlLwSzEx5pFZkNIPd H/E6vyjWRidT/v9T8dK8rgIP/6VZ7v/zL7bJsSvM+AP64hj3KN7BB0UN57/HJWL2zR eMheuXQkJSZp6nNFKH5cy5brgQiQOpkDExSud8A0Jw9x58Za5sJKx7V9xy6oGYZlUb 96yas/+vyGxTdR5ZHVKIewdiJuRUFTS9boYI0uUzFmHCWNorXrCsBbhhXE+T22x3iw pNg8ZpdjPimlA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v10 26/26] NFS: Cache all entries in the readdirplus reply Date: Sun, 13 Mar 2022 13:05:57 -0400 Message-Id: <20220313170557.5940-27-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313170557.5940-26-trondmy@kernel.org> References: <20220313170557.5940-1-trondmy@kernel.org> <20220313170557.5940-2-trondmy@kernel.org> <20220313170557.5940-3-trondmy@kernel.org> <20220313170557.5940-4-trondmy@kernel.org> <20220313170557.5940-5-trondmy@kernel.org> <20220313170557.5940-6-trondmy@kernel.org> <20220313170557.5940-7-trondmy@kernel.org> <20220313170557.5940-8-trondmy@kernel.org> <20220313170557.5940-9-trondmy@kernel.org> <20220313170557.5940-10-trondmy@kernel.org> <20220313170557.5940-11-trondmy@kernel.org> <20220313170557.5940-12-trondmy@kernel.org> <20220313170557.5940-13-trondmy@kernel.org> <20220313170557.5940-14-trondmy@kernel.org> <20220313170557.5940-15-trondmy@kernel.org> <20220313170557.5940-16-trondmy@kernel.org> <20220313170557.5940-17-trondmy@kernel.org> <20220313170557.5940-18-trondmy@kernel.org> <20220313170557.5940-19-trondmy@kernel.org> <20220313170557.5940-20-trondmy@kernel.org> <20220313170557.5940-21-trondmy@kernel.org> <20220313170557.5940-22-trondmy@kernel.org> <20220313170557.5940-23-trondmy@kernel.org> <20220313170557.5940-24-trondmy@kernel.org> <20220313170557.5940-25-trondmy@kernel.org> <20220313170557.5940-26-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Even if we're not able to cache all the entries in the readdir buffer, let's ensure that we do prime the dcache. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 033249a72e92..7e12102b29e7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -789,6 +789,21 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry, dput(dentry); } +static int nfs_readdir_entry_decode(struct nfs_readdir_descriptor *desc, + struct nfs_entry *entry, + struct xdr_stream *stream) +{ + int ret; + + if (entry->fattr->label) + entry->fattr->label->len = NFS4_MAXLABELLEN; + ret = xdr_decode(desc, entry, stream); + if (ret || !desc->plus) + return ret; + nfs_prime_dcache(file_dentry(desc->file), entry, desc->dir_verifier); + return 0; +} + /* Perform conversion from xdr to cache array */ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, struct nfs_entry *entry, @@ -811,17 +826,10 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, xdr_set_scratch_page(&stream, scratch); do { - if (entry->fattr->label) - entry->fattr->label->len = NFS4_MAXLABELLEN; - - status = xdr_decode(desc, entry, &stream); + status = nfs_readdir_entry_decode(desc, entry, &stream); if (status != 0) break; - if (desc->plus) - nfs_prime_dcache(file_dentry(desc->file), entry, - desc->dir_verifier); - status = nfs_readdir_page_array_append(page, entry, &cookie); if (status != -ENOSPC) continue; @@ -849,15 +857,19 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, switch (status) { case -EBADCOOKIE: - if (entry->eof) { - nfs_readdir_page_set_eof(page); - status = 0; - } - break; - case -ENOSPC: + if (!entry->eof) + break; + nfs_readdir_page_set_eof(page); + fallthrough; case -EAGAIN: status = 0; break; + case -ENOSPC: + status = 0; + if (!desc->plus) + break; + while (!nfs_readdir_entry_decode(desc, entry, &stream)) + ; } if (page != *arrays) -- 2.35.1