Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4255709pxf; Tue, 16 Mar 2021 09:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya4R92aVbWyJwOJKcexIfAsvcH3OCUpr8bJ6aO1hdi019G/yBfpa6aYNJ2BsGUTTkajVci X-Received: by 2002:a17:906:260a:: with SMTP id h10mr30918835ejc.392.1615910716838; Tue, 16 Mar 2021 09:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615910716; cv=none; d=google.com; s=arc-20160816; b=X/BReDg1k9riID8EEUlD0oP9b3tSlXyw2OYsmtyAmVQsXGQHwJknCPYSIEb+rZXvLq VRFJyY93PWSNVISA/Uv4enVWQyQJVB4Ln07Jjt6tERULuIMn5KVD4kDdn+tNVwuuPukg kFldcIUF/mP+eIGvD19h9C4vRHFuZRkyKwZB0+GR/j+zjcvRxS4B7Cm3S+uUdbTEPm+P yct6EwdTKr9UWL3EYM8e4Y2Cwqkfz9KaMPDp/vFOqbMFoCYuPTe7CnyhO6ERI95sFdQs vpfxsqaXayCuVsmWV0fXDDMS5X/055QJ607H7f3NOvN2W2c7VJJ67ZHiTvpOrny4zChm 5vDw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=d6LLIy45BH58Mv+hSSy2ymxeyDWBF1QtkQdxQd0NFFQ=; b=eI6T6adwtGGLI4eW/kPc7iM8oPGqRa3ca6tGdRFX6peMRmL7oR5G7BLMmJNPj/lTKw hpproN/B0CeMQ7RmOcQEv2pQND3SwGxiVE77tOesJXCh/hztj1eGb96pzrNHXcDy1vDF cFdH/RwVImmO8ooJjN1jgsfLjVxVUUnu/yCuv6DQs4hN8PAQy5ZP0JMVQuQmp0yaBMpO cxse2n15q0d8iDWIe9W/TYZgUxnDkIOTkffWZFnnBWkJCqKSbN85ywfRj4dRdtgVNFYd Cw3cyywUO8OS+BRF607QboAhdX8TwBzaTa6czC94rzk9PEatA1EISJCnnDPhSru5NRTe Ursw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Oey/2xkD"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si14286242ede.30.2021.03.16.09.04.45; Tue, 16 Mar 2021 09:05:16 -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=pass header.i=@kernel.org header.s=k20201202 header.b="Oey/2xkD"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234638AbhCPNgg (ORCPT + 99 others); Tue, 16 Mar 2021 09:36:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:50940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234654AbhCPNgE (ORCPT ); Tue, 16 Mar 2021 09:36:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4033664DD8; Tue, 16 Mar 2021 13:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615901764; bh=ogyyCh0M8xPcsZQ8I9C8rpbT7OsRqpdL8QMy7aDnaoM=; h=From:To:Cc:Subject:Date:From; b=Oey/2xkD/h5nqeDC2pvfbXdSEKTtTB4FN2TW4f6DKX6zZY+bJyIoHk+rIT1SwHLuH NobN1wLMlNWoXzivQK9cebjg8q0fpHEcS3hrMBOfZ+u43Pp3mkfBt9I1bWXA1ORxr0 lH2CORtbFZY6/jNKo5FBwbZiFZK/RQW6AI1zZls/6kH/euewPATIXx1CcquCRsR3fQ OUKcbmBKhM34/CrFFAgdr/MmrQQurqdUZs2S7CBWGX1n8fJKCXIVBL2odUBZtdV6g7 nkFdZAb5UpnabBog8LAwf5jmnsBwzzimRGMmdEI/5m1HN0Ip3K/zHN56dNBVQ1+5c0 ysRAqEbT/hrNQ== From: trondmy@kernel.org To: Nagendra S Tomar Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Fix handling of cookie verifier in uncached_readdir() Date: Tue, 16 Mar 2021 09:36:03 -0400 Message-Id: <20210316133603.1228154-1-trondmy@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If we're doing uncached readdir(), then the readdir cookie could be different from the one cached in the nfs_inode. We should therefore ensure that we save that one in the struct nfs_open_dir_context. Fixes: 35df59d3ef69 ("NFS: Reduce number of RPC calls when doing uncached readdir") Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 08a1e2e31d0b..2cf2a7d92faf 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -976,10 +976,10 @@ static int readdir_search_pagecache(struct nfs_readdir_descriptor *desc) /* * Once we've found the start of the dirent within a page: fill 'er up... */ -static void nfs_do_filldir(struct nfs_readdir_descriptor *desc) +static void nfs_do_filldir(struct nfs_readdir_descriptor *desc, + const __be32 *verf) { struct file *file = desc->file; - struct nfs_inode *nfsi = NFS_I(file_inode(file)); struct nfs_cache_array *array; unsigned int i = 0; @@ -993,7 +993,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc) desc->eof = true; break; } - memcpy(desc->verf, nfsi->cookieverf, sizeof(desc->verf)); + memcpy(desc->verf, verf, sizeof(desc->verf)); if (i < (array->size-1)) desc->dir_cookie = array->array[i+1].cookie; else @@ -1050,7 +1050,7 @@ static int uncached_readdir(struct nfs_readdir_descriptor *desc) for (i = 0; !desc->eof && i < sz && arrays[i]; i++) { desc->page = arrays[i]; - nfs_do_filldir(desc); + nfs_do_filldir(desc, verf); } desc->page = NULL; @@ -1071,6 +1071,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) { struct dentry *dentry = file_dentry(file); struct inode *inode = d_inode(dentry); + struct nfs_inode *nfsi = NFS_I(inode); struct nfs_open_dir_context *dir_ctx = file->private_data; struct nfs_readdir_descriptor *desc; int res; @@ -1124,7 +1125,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) break; } if (res == -ETOOSMALL && desc->plus) { - clear_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags); + clear_bit(NFS_INO_ADVISE_RDPLUS, &nfsi->flags); nfs_zap_caches(inode); desc->page_index = 0; desc->plus = false; @@ -1134,7 +1135,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) if (res < 0) break; - nfs_do_filldir(desc); + nfs_do_filldir(desc, nfsi->cookieverf); nfs_readdir_page_unlock_and_put_cached(desc); } while (!desc->eof); -- 2.30.2