Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3058453pxj; Mon, 17 May 2021 16:41:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+VD9cMi/z6muuEWFtBI3uff0gwQkhZw7TjYXaHhivhQVC82gy5Rjc8EEn9BQRbG66Pqua X-Received: by 2002:a05:6402:50d2:: with SMTP id h18mr3301150edb.10.1621294908325; Mon, 17 May 2021 16:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621294908; cv=none; d=google.com; s=arc-20160816; b=ofeCdILMcgJo8lFHPwSOywEcHaaw36qS7Rns85NNnjngPUtGkw2R6W6x1YbX7++qyx dkU/lytpCWbMQcrAhFujBMvXB/OLgUPiJU1rPPUjnnP1pFoGYqXxvgywBMOFmHL9J8Kr l4vuT1QU0iFyBa3o2TDOYZZ9wUdIGo+tkbbBJhO8dFOC+LCJcRo4oUhU/hBg/1m60QXK 3UrO54GfLvd2i3J0A3XqnxPlDFmQ5CEtpWKFTErAYWA+SR+KoWApMyvgugaj0oJ93OJU PmEkIZ5/qOaqmQ0ofiZtf2uwaHMLf8d3q8Jplj2lFnv6LzkSne9HnY5kBe20c8pXmfdn K91w== 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=WmuRe7SFR4hvrBZ7x+DSnCIH74fcQ9Pl9Fmm0QgVuaI=; b=L3gbklx4MRmeTDB3sVKk0t39k+7/GMpTJg4ir4LdOtyBr90H0hmykhJbwPaJJJPUzP bMwjHXGW5qV7ytpbnirW3N/c1InX8XgP51ogUhMUI3T7sidIXxgf0GKrHRQf8T69IdHk ep7NGEpTGRfstHUrNxN+NlGBhgZnibjzzJwY1F/o0tf0TztkJVs7Q7c1Km2Oka7Z4SfO PAszOBUEKoimMiagU9iWKFF1Od8jffgkvoeWO+GmHv3qlDEdT6C3EXRhb4erNDydS1fD lXl4XpcHTKZKPpjJ3n3H/CZl5pQJD7D6KZXj8ZNxgP1Qi38OrC/MjKABDdEDvxfQ85rT TDDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DV06ZnBm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn20si17023759ejc.545.2021.05.17.16.41.23; Mon, 17 May 2021 16:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=DV06ZnBm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238920AbhEQOXH (ORCPT + 99 others); Mon, 17 May 2021 10:23:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:33294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239299AbhEQOT1 (ORCPT ); Mon, 17 May 2021 10:19:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F541613B5; Mon, 17 May 2021 14:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260657; bh=p4+9Y6gsQVpVcJTV/sSTUtPM58rj3sS9gNE/aZntvXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DV06ZnBmWlSktupXaZhiTRSf/BW+WfD6DfAFg6j6ySub2HCbdLqrm2IxOGEVqMs4V +BBZxe8KKSrg8mIbdR4uyjeXHZAVXmNht9mEP2wcRgOOehtfDTSArI0lwT+XLTAFL4 js0g5PPcI2kKztCGMPlm92VAQLiKkRgx1TamBPdo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.12 146/363] NFS: Fix handling of cookie verifier in uncached_readdir() Date: Mon, 17 May 2021 16:00:12 +0200 Message-Id: <20210517140307.554430717@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 13884ff2bef01df37c450c6dd09122f92333dccc ] 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 Signed-off-by: Sasha Levin --- 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