Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2617691pxp; Mon, 14 Mar 2022 00:39:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQYHvG1r8mgo6tb7EXvCGSu2H28OivZRad7195pkTrBqO8QCHG5f0yyp1VIhnRlXAiQfgY X-Received: by 2002:a17:90b:1648:b0:1bd:28ac:859d with SMTP id il8-20020a17090b164800b001bd28ac859dmr34275505pjb.59.1647243568552; Mon, 14 Mar 2022 00:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647243568; cv=none; d=google.com; s=arc-20160816; b=tbztkTLhYO68kVjFH5P5wdUvkHQM0rKqjaA8UQR+Jcp/a50yx5xA4TKJmkgBREJz+t PLNnZ2w80TlLhBRrAPc6+scFj2YhFMuhdaYayd9Cv2QOEcYZWxAEZ3Bz0NFEk8iyjG5a XCQ7hvZDK6V79cRmwgm1/UyfO3fKh1RGYW9Dl0tl/zoD++jMEJXlocnt3fjt6EE6Q8hB tpUeCY2kR1tzBfNeYRAG77YiUBWd8myNASwGZ9iKEGzTx3xqTTDy8ylXgNnOubZaIsy5 xLKR/H85rsv4gILs7q0eGXnnGPDsKQl5zASckPX8PMmS+Xn1K/7ceTrWprAEv1UYHe3x 939Q== 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=RkbeaYH6nIejQfmTNtQesWFDS49LBQrcm4aR67zSoxc=; b=gAIf7he+x5UnroDtfyaSfOc+MQL1HswO7X92IWM0J/wudxGu2vg9kLHN1X0feJNjap PqhOlnPGqG/0WWtnmNQtg1pJZl9sFmDIp718tfimSi7IG1U+XeuZeNmz0Q2FyeQj+nsz DXTPHYlKE42fRK4ZbE50Xolu9rnJ0UosXuxIluhBzFjJFieHxpX+C445O5Z/6a/0VdkU 1ACLKRtTDUUoBgU8IZDhmSX8e5OBYiR7x5QAI9L48UTtqvzGpBRada2uwe0PUSyqZ7zy bhiAFbe9sDn2uPxiYXP6rJ8sAhLM/bbIM9d6XEsBnCt7rCKZITIIVGX3YWsZ248t/FUP GXKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WukW4CIe; 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 u8-20020a170903124800b0015183d121e6si16862547plh.392.2022.03.14.00.39.05; Mon, 14 Mar 2022 00:39:28 -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=WukW4CIe; 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 S235111AbiCMRNT (ORCPT + 99 others); Sun, 13 Mar 2022 13:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235096AbiCMRNQ (ORCPT ); Sun, 13 Mar 2022 13:13:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529D8139CDA for ; Sun, 13 Mar 2022 10:12:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E5F8F61228 for ; Sun, 13 Mar 2022 17:12:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D15EC340E8 for ; Sun, 13 Mar 2022 17:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647191527; bh=yLr8IkkHWvZRHwxq1yjZixPXjlXDD2Jltl9nkaxNcXo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WukW4CIeIu2r/LxJR7LYZPOK/+2j/hDE0D8HkPkfUoeHRutG7t1eGur3exuArKhfR VFwOnTHlUrzgk7NxI/Jf/I7Yhr16ZjnWekRvF9icrhtofTXZ6Qg4YWALTqg3Xahsfi vsdwMic7YMZYY5Nd9IcRSVoLnsR3NFWNzKCrEPWnkSqo0eC+eCLGmeVKpwbECKGo66 38xYae9JuZqyA9hJMLYJ51LFFCxPCqgNCBJ4rW4FwsTOMvkhOSzagw06kBNU72I0uP 14DC0yXvJy77cDCW7KmUMRwWMj5MLXhhurg/iil3cE0QrbpgpA5KaLugaZNXkxcxzX TP3q0ABuWOY3Q== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v10 09/26] NFS: Don't advance the page pointer unless the page is full Date: Sun, 13 Mar 2022 13:05:40 -0400 Message-Id: <20220313170557.5940-10-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313170557.5940-9-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> 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 When we hit the end of the data in the readdir page, we don't want to start filling a new page, unless this one is full. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 93f70698e401..60f7feee0a16 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -417,6 +417,18 @@ bool nfs_readdir_use_cookie(const struct file *filp) return true; } +static void nfs_readdir_seek_next_array(struct nfs_cache_array *array, + struct nfs_readdir_descriptor *desc) +{ + if (array->page_full) { + desc->last_cookie = array->last_cookie; + desc->current_index += array->size; + desc->cache_entry_index = 0; + desc->page_index++; + } else + desc->last_cookie = array->array[0].cookie; +} + static int nfs_readdir_search_for_pos(struct nfs_cache_array *array, struct nfs_readdir_descriptor *desc) { @@ -428,6 +440,7 @@ static int nfs_readdir_search_for_pos(struct nfs_cache_array *array, if (diff >= array->size) { if (array->page_is_eof) goto out_eof; + nfs_readdir_seek_next_array(array, desc); return -EAGAIN; } @@ -500,7 +513,8 @@ static int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, status = -EBADCOOKIE; if (desc->dir_cookie == array->last_cookie) desc->eof = true; - } + } else + nfs_readdir_seek_next_array(array, desc); out: return status; } @@ -517,11 +531,6 @@ static int nfs_readdir_search_array(struct nfs_readdir_descriptor *desc) else status = nfs_readdir_search_for_cookie(array, desc); - if (status == -EAGAIN) { - desc->last_cookie = array->last_cookie; - desc->current_index += array->size; - desc->page_index++; - } kunmap_atomic(array); return status; } @@ -998,7 +1007,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc, { struct file *file = desc->file; struct nfs_cache_array *array; - unsigned int i = 0; + unsigned int i; array = kmap(desc->page); for (i = desc->cache_entry_index; i < array->size; i++) { @@ -1011,10 +1020,13 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc, break; } memcpy(desc->verf, verf, sizeof(desc->verf)); - if (i < (array->size-1)) - desc->dir_cookie = array->array[i+1].cookie; - else + if (i == array->size - 1) { desc->dir_cookie = array->last_cookie; + nfs_readdir_seek_next_array(array, desc); + } else { + desc->dir_cookie = array->array[i + 1].cookie; + desc->last_cookie = array->array[0].cookie; + } if (nfs_readdir_use_cookie(file)) desc->ctx->pos = desc->dir_cookie; else -- 2.35.1