Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6021907pxb; Mon, 14 Feb 2022 13:19:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0VPVziw6qs9FmsJv20YlSWbJjOJJjQlChjW/CoEAYaTXUg4JyY+RukNEpXuuYDbN1mkfJ X-Received: by 2002:aa7:82d9:: with SMTP id f25mr1011214pfn.76.1644873577800; Mon, 14 Feb 2022 13:19:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644873577; cv=none; d=google.com; s=arc-20160816; b=E9Px1v8AStsyMAQCV/L/BYkEKH8oyEdiJweMvgwkjC4/ZFAH8RdKhjFso6RfAx2LdZ teRkzwjAIw6BOSJ6cZ4tAgch/RxCeiSPUNtXJII5CHHS/lw5kHwwS6QSjioIrrpdsX1i 6B1equXWwvlJOzvxBQ+FlIWybA8RpJm9tDH6ghAjUjKI5Lz/SJUWNKzJLcvVw7ZZLqum hNKbNslWOli76U/f8zgBP9a++ePo8z1SvmtAoi7kngFXDc9R9LRkeirJRp+002EEY6vj TRj9i3EQCQWYyV93S2wfK/is+kzAJrWFLVVEEPZEpfKej8ZjSeymc0ydz5NmlwpJrGzV 4Ttg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yDijAPAJjs4uscl+9pUwNDkU2adNwW0ccSeJsttUMIY=; b=zNolhm2PcPgA0AS2u66XL/osvTS0f0XlZVYKcPmp7Uw04UxOs42hWdWHe2cqLcv32u hByddYqRosgfFa4FDGjK1GKwTCKE5QmvGpsIPhWmzUxJLOzr3gWi6yoouD+4iEPaCXkl ZJ5Hatb0RRE0chWQmpAb1vOQ8VZTlbIAVTPcBf2m0MNnuEilm+OQC48cIIs7fumKVDDi CWMFubE230owm1SsmKG3RX37KK2GfQPdBJv/Qjly8lrOcFFZg8VIUsLcb7lPaEB/vuqs yyQ74DUtGefg1DiH4eRv0jtVsHt0m+tkGV2lr9fnV8tAdTtepo4ZorE6twO71n/boswZ u2kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dZHIi65B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k9si33732042pfc.320.2022.02.14.13.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:19:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dZHIi65B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C1B91AD2A6; Mon, 14 Feb 2022 12:39:18 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348098AbiBNKen (ORCPT + 99 others); Mon, 14 Feb 2022 05:34:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348172AbiBNKeA (ORCPT ); Mon, 14 Feb 2022 05:34:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C9EA2F01; Mon, 14 Feb 2022 02:00:41 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id CFAFF60A53; Mon, 14 Feb 2022 10:00:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2E41C340E9; Mon, 14 Feb 2022 10:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644832840; bh=xXZmEyAX8sqclo30hcbh/KtpPKJbBa4Qr/6DXqtVy0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZHIi65BDR7ry8kLA27YeYcqEB2NVHb8T/HLEBQbDiL2kaML3Mcolpvgv4kgApe4Y V1ww/czNx7Szu4q2iF/38OsW/gjfCGHYjOEuuNMieHyNkeis1EeKRseXIRh90H4gNp wt3zxaq2vD4bwRjUVf07Nqsni8XpeIt6szy8y3HU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.16 110/203] NFS: Dont overfill uncached readdir pages Date: Mon, 14 Feb 2022 10:25:54 +0100 Message-Id: <20220214092513.986287740@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092510.221474733@linuxfoundation.org> References: <20220214092510.221474733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org From: trondmy@kernel.org [ Upstream commit d9c4e39c1f8f8a8ebaccf00b8f22c14364b2d27e ] If we're doing an uncached read of the directory, then we ideally want to read only the exact set of entries that will fit in the buffer supplied by the getdents() system call. So unlike the case where we're reading into the page cache, let's send only one READDIR call, before trying to fill up the buffer. Fixes: 35df59d3ef69 ("NFS: Reduce number of RPC calls when doing uncached readdir") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index faf5168880223..13740f1e3972e 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -866,7 +866,8 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc, status = nfs_readdir_page_filler(desc, entry, pages, pglen, arrays, narrays); - } while (!status && nfs_readdir_page_needs_filling(page)); + } while (!status && nfs_readdir_page_needs_filling(page) && + page_mapping(page)); nfs_readdir_free_pages(pages, array_size); out: -- 2.34.1