From patchwork Sun Feb 2 22:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11361887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFE5714E3 for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E831205F4 for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LzkfmkYU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgBBW4K (ORCPT ); Sun, 2 Feb 2020 17:56:10 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:37122 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbgBBW4K (ORCPT ); Sun, 2 Feb 2020 17:56:10 -0500 Received: by mail-yw1-f68.google.com with SMTP id l5so11952325ywd.4 for ; Sun, 02 Feb 2020 14:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aKCdiCvf1CCHY7Wz5wj2AxA/hIzhbB4Gaz8M9nQKtTs=; b=LzkfmkYUhNa7kpQ+d9SqUE7PkBWbV5siaQELkviYXiq5/UufpvC3mEwVvDoacqU9En IYdmsmeTEiIn4gci/E3kQ9t8RQVBZa8e/2Dhyi1+eaBFlBDX9wcC1O1gDGjFosqPosC0 vlpc7Bf8r8iC0KXHO2npx/+omZrMli/IB4Bpz5UD9crO6bHA6WYf2RsLTxse4xQ6Vvp4 nBqiTpi1Wk59k59DG0AMsXm3D9NtsuaTyIamX056Fpzv/oJ2MbPhmGA09BnnUIni/Ym5 JUGqHq/BKxugMjwQz8W2P3SRaL2svxkDCUuspvcihD/VCmO5RS5KYnhD78CAvYXqybdF Altg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aKCdiCvf1CCHY7Wz5wj2AxA/hIzhbB4Gaz8M9nQKtTs=; b=q3HA6hzqDBzPwoBUU6C07KPM+4zupWyFqN8wzfB5Xh2JwmnwcxaCJyvb9xDqMfYwDF 3X4JZXzAK1r/w1bfgWDChBANZDM6hh657CL/8DP5rZbM9MGCwQ0UnsN5PSdts7XrLkXN 7xHtS5fSbcAlfUKcLmS+93DZupZfob9IwMjvGb+j24IjzpoHLYXgaqxtY1vc+iWUHubX I9AwfAJb0ijbRIBbbPqb7nki4703u2k0eFM5FWoJLkLO9YmqNWpYAhKVYAnMicCWN614 B8zit6sGLagDStk1QLZlquXdgGyoR23Pb92s0mnWtUVs+n1ch10VPMLuyuAU113o4sHv uNIw== X-Gm-Message-State: APjAAAWVEyfGibtHJhlalvid0O+V0lv/CvJ8vIPwfQnKaaH/cvaRF51B NmZMuwER4DOzOlaNLPPsJw== X-Google-Smtp-Source: APXvYqxnPjn/Lvrw5Rgrv8UxyUZUupb3zqeuPZKtDg03vbxdlDhaVoTp14zUV3+FSXwyv/pazUMfog== X-Received: by 2002:a25:b989:: with SMTP id r9mr15966116ybg.366.1580684167678; Sun, 02 Feb 2020 14:56:07 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u136sm7185529ywf.101.2020.02.02.14.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 14:56:07 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: Benjamin Coddington , Dai Ngo , linux-nfs@vger.kernel.org Subject: [PATCH 1/4] NFS: Fix memory leaks and corruption in readdir Date: Sun, 2 Feb 2020 17:53:53 -0500 Message-Id: <20200202225356.995080-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200202225356.995080-1-trond.myklebust@hammerspace.com> References: <20200202225356.995080-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org nfs_readdir_xdr_to_array() must not exit without having initialised the array, so that the page cache deletion routines can safely call nfs_readdir_clear_array(). Furthermore, we should ensure that if we exit nfs_readdir_filler() with an error, we free up any page contents to prevent a leak if we try to fill the page again. Fixes: 11de3b11e08c ("NFS: Fix a memory leak in nfs_readdir") Cc: stable@vger.kernel.org # v2.6.37+ Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington --- fs/nfs/dir.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 76404f53cf21..ba0d55930e8a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -163,6 +163,17 @@ typedef struct { bool eof; } nfs_readdir_descriptor_t; +static +void nfs_readdir_init_array(struct page *page) +{ + struct nfs_cache_array *array; + + array = kmap_atomic(page); + memset(array, 0, sizeof(struct nfs_cache_array)); + array->eof_index = -1; + kunmap_atomic(array); +} + /* * we are freeing strings created by nfs_add_to_readdir_array() */ @@ -175,6 +186,7 @@ void nfs_readdir_clear_array(struct page *page) array = kmap_atomic(page); for (i = 0; i < array->size; i++) kfree(array->array[i].string.name); + array->size = 0; kunmap_atomic(array); } @@ -613,6 +625,8 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, int status = -ENOMEM; unsigned int array_size = ARRAY_SIZE(pages); + nfs_readdir_init_array(page); + entry.prev_cookie = 0; entry.cookie = desc->last_cookie; entry.eof = 0; @@ -629,8 +643,6 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, } array = kmap(page); - memset(array, 0, sizeof(struct nfs_cache_array)); - array->eof_index = -1; status = nfs_readdir_alloc_pages(pages, array_size); if (status < 0) @@ -685,6 +697,7 @@ int nfs_readdir_filler(void *data, struct page* page) unlock_page(page); return 0; error: + nfs_readdir_clear_array(page); unlock_page(page); return ret; } From patchwork Sun Feb 2 22:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11361885 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9540A138D for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73423205F4 for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g1zaao/C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbgBBW4K (ORCPT ); Sun, 2 Feb 2020 17:56:10 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37121 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgBBW4J (ORCPT ); Sun, 2 Feb 2020 17:56:09 -0500 Received: by mail-yw1-f66.google.com with SMTP id l5so11952351ywd.4 for ; Sun, 02 Feb 2020 14:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1hQ1NtRCTr1DhJGTY9effkGJ/kVi7dUZ88IQ4Kn0kjk=; b=g1zaao/C//JNnDwfYCGtb0D0mKafnVOcqQJCv1FLym+U9UaRKkkq+M1Qyq9rLcKyY4 2qL/tk4y8lhvwn/PM3yRhLWLWNhhZRPUMSwz4K7kpyqcOZl4KUWEtYULVe2qFU6i5pP1 B7lowD8TxFslto3uw8MWOM6tY5nvvlb01PQYCjmxLwXldKBNTUNemfBY09SYHtDISB8S c+Susd+d7wKU6bF6grFD4Qp6hjUKlu8/HoO4QupkceMZCc6RJQXR8eDoc6DR2CdBUjdU lWDQscRLtGOFWlN79HLWKqTYyuJ6SX3e6Zr8mvkcrrXjRLq177siTakhh/rFUv6oHdXN oHkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1hQ1NtRCTr1DhJGTY9effkGJ/kVi7dUZ88IQ4Kn0kjk=; b=pgR33DQQ4NJUYVDD6v+xl2hX++RIlKfzqsUOnDFvJ5dGzVoe9238yaZMUl8iJY6Nhi 4tO3/WB1klGpMXJj3H1PZ4Wdi0M4Nsi6aG4Ew3YOYN78IhQ4loHgjNNfoXK0oioFTmwu /8X7y7AuNg8xrkIN9YeQzBEm1vZ9Uw/Jx3VsrOk7NKmxiGC+IeraQf1xeq7PFDTSW50h H1d5dvSw8ufza/gOrKFiAiLuxKBgJU16/ABKRDB9Nhsxa6XhRu0EX5kBpi1CyfeiISY+ RmASaAzRaFQfWjMl5HeZACUFQmUUU+uZgeCVLgLSTxl/CD4UMsykFTfrUClIVevCYnHE tRoQ== X-Gm-Message-State: APjAAAXKT6yoWv4I97aJiabbB/m6TssNdBzPDwRKXNiyde8evsh/zItb dl4uIHOdBbqE7HWfRau57g== X-Google-Smtp-Source: APXvYqwUpcdmTnrD2dku+D+Qk4tg3JlqTSQWfw0xDq7xZWMkVvXPPirIAHsqfKP6rJs/X6uVbXoqCQ== X-Received: by 2002:a25:c0cf:: with SMTP id c198mr16605284ybf.135.1580684168905; Sun, 02 Feb 2020 14:56:08 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u136sm7185529ywf.101.2020.02.02.14.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 14:56:08 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: Benjamin Coddington , Dai Ngo , linux-nfs@vger.kernel.org Subject: [PATCH 2/4] NFS: Directory page cache pages need to be locked when read Date: Sun, 2 Feb 2020 17:53:54 -0500 Message-Id: <20200202225356.995080-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200202225356.995080-2-trond.myklebust@hammerspace.com> References: <20200202225356.995080-1-trond.myklebust@hammerspace.com> <20200202225356.995080-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When a NFS directory page cache page is removed from the page cache, its contents are freed through a call to nfs_readdir_clear_array(). To prevent the removal of the page cache entry until after we've finished reading it, we must take the page lock. Fixes: 11de3b11e08c ("NFS: Fix a memory leak in nfs_readdir") Cc: stable@vger.kernel.org # v2.6.37+ Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington --- fs/nfs/dir.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index ba0d55930e8a..90467b44ec13 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -705,8 +705,6 @@ int nfs_readdir_filler(void *data, struct page* page) static void cache_page_release(nfs_readdir_descriptor_t *desc) { - if (!desc->page->mapping) - nfs_readdir_clear_array(desc->page); put_page(desc->page); desc->page = NULL; } @@ -720,19 +718,28 @@ struct page *get_cache_page(nfs_readdir_descriptor_t *desc) /* * Returns 0 if desc->dir_cookie was found on page desc->page_index + * and locks the page to prevent removal from the page cache. */ static -int find_cache_page(nfs_readdir_descriptor_t *desc) +int find_and_lock_cache_page(nfs_readdir_descriptor_t *desc) { int res; desc->page = get_cache_page(desc); if (IS_ERR(desc->page)) return PTR_ERR(desc->page); - - res = nfs_readdir_search_array(desc); + res = lock_page_killable(desc->page); if (res != 0) - cache_page_release(desc); + goto error; + res = -EAGAIN; + if (desc->page->mapping != NULL) { + res = nfs_readdir_search_array(desc); + if (res == 0) + return 0; + } + unlock_page(desc->page); +error: + cache_page_release(desc); return res; } @@ -747,7 +754,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) desc->last_cookie = 0; } do { - res = find_cache_page(desc); + res = find_and_lock_cache_page(desc); } while (res == -EAGAIN); return res; } @@ -786,7 +793,6 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) desc->eof = true; kunmap(desc->page); - cache_page_release(desc); dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", (unsigned long long)*desc->dir_cookie, res); return res; @@ -832,13 +838,13 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) status = nfs_do_filldir(desc); + out_release: + nfs_readdir_clear_array(desc->page); + cache_page_release(desc); out: dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __func__, status); return status; - out_release: - cache_page_release(desc); - goto out; } /* The file offset position represents the dirent entry number. A @@ -903,6 +909,8 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) break; res = nfs_do_filldir(desc); + unlock_page(desc->page); + cache_page_release(desc); if (res < 0) break; } while (!desc->eof); From patchwork Sun Feb 2 22:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11361889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE9C714B4 for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBA36205F4 for ; Sun, 2 Feb 2020 22:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="it+9cEg3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbgBBW4L (ORCPT ); Sun, 2 Feb 2020 17:56:11 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:38327 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbgBBW4L (ORCPT ); Sun, 2 Feb 2020 17:56:11 -0500 Received: by mail-yw1-f67.google.com with SMTP id 10so11960740ywv.5 for ; Sun, 02 Feb 2020 14:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O2NHDirab5p1dosagLCqK710CjMeLB79QssC2AK7PVg=; b=it+9cEg3wcme4zWNIdp63ohylVZlm4sNo/aR3U2wBOie/b4iaTPdCj+PJXjdRyLgtY zPcNava41ZgmQU6yCC0kQU9evMeQkk7BM2wl/OXiGPPxebPNTJLQkmBb5fEuSfU9MC0o dsq/U/QF/RfhOdOguo6Ep5BBvAWU43IN/+fVduKX6nLGH73oG+djz3ldKT2VzGDx0WJ4 z1ex6GOsiQhJJtbgmvrsR7Yo70OchngIrFQ1JqYtHwuwweLgrBJ8Fe1W8KsIQUdwiSe1 n3qdUX1EjMnzlB5j0kp/aW1imI9SvkNjwiKLRQSOF03Vh1hB7j6eVCNREnDJeayMYRtF f7sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O2NHDirab5p1dosagLCqK710CjMeLB79QssC2AK7PVg=; b=bZmewPxqOMnSRnUjJ5kDI/YaGCCXhH+r4Zkizj+1k4JJo9/Hsy+5itT1e1A9B/Hovn ZMxzGyc5bvMSvffZI220CKI3QgZRDsF/G//Bnzms+l6DHy7pYbz39UZQUyPNw1qlA73P FsxD53l9YgUPAuBDEDFzO82mz5LWGvUINYfSp4uaXzOa8xcoL8lrI22wfvI7Op6yEFIg Xr5AnHOc1vPTLOou+JUfBykkx6TMssUdmYRAPaM23Ia4OLyphuiQgEhrBRhMnNp73VsH qLKMxD6xaI1RME3GZbnZymR4G4+xr/vaGiAqA130JwoSfDcSOiP4GJpBBXZz0XYHbm+n jYeQ== X-Gm-Message-State: APjAAAWasfgNOE+9W6YHl52KYlu5bmTft9sAM/hm49NJXLUQrpD5PueX ywxWjTATGNbB79vfx9EbqA== X-Google-Smtp-Source: APXvYqxVPSI0l+19oiVvjA2wItYO675PS3CACY5RUp4cpi0tSg0b3VUlhaxhIcm0aMfEyBAiw1+QAw== X-Received: by 2002:a81:431d:: with SMTP id q29mr5354337ywa.411.1580684169938; Sun, 02 Feb 2020 14:56:09 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u136sm7185529ywf.101.2020.02.02.14.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 14:56:09 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: Benjamin Coddington , Dai Ngo , linux-nfs@vger.kernel.org Subject: [PATCH 3/4] NFS: Use kmemdup_nul() in nfs_readdir_make_qstr() Date: Sun, 2 Feb 2020 17:53:55 -0500 Message-Id: <20200202225356.995080-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200202225356.995080-3-trond.myklebust@hammerspace.com> References: <20200202225356.995080-1-trond.myklebust@hammerspace.com> <20200202225356.995080-2-trond.myklebust@hammerspace.com> <20200202225356.995080-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The directory strings stored in the readdir cache may be used with printk(), so it is better to ensure they are nul-terminated. Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 90467b44ec13..60387dec9032 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -199,7 +199,7 @@ static int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int len) { string->len = len; - string->name = kmemdup(name, len, GFP_KERNEL); + string->name = kmemdup_nul(name, len, GFP_KERNEL); if (string->name == NULL) return -ENOMEM; /* From patchwork Sun Feb 2 22:53:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11361891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 573C414B4 for ; Sun, 2 Feb 2020 22:56:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35E5020661 for ; Sun, 2 Feb 2020 22:56:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qri7e740" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726561AbgBBW4M (ORCPT ); Sun, 2 Feb 2020 17:56:12 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39193 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbgBBW4M (ORCPT ); Sun, 2 Feb 2020 17:56:12 -0500 Received: by mail-yw1-f67.google.com with SMTP id h126so11955263ywc.6 for ; Sun, 02 Feb 2020 14:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sbpll5m/D2jqhS1yNNOSxZ189BRV9Du6vR6MiDbVdEg=; b=qri7e740zzgZdFTplW+u/98OCbz+VhxrxPJEAloQXSOjPSurjFgo9A6/TL5i266n1J zKhAUsBxlbCqTNtvCCT0nfk6CX9/d7p89ImE//+q6Nf7ht+Y3vJgzSagh5SOwVBiz/ws QKLV9ktFf1mH4Z81cPnsGta2t7eAqivLWuT9pyxmDDzoZivR+Y2goZ4U4pasT0W1spzU hkFr7nOlUxS/qErcWgJQputOvZcnqcA+YCd6T5yYsdpn9pd4qS/QrWT6hnLGFRP3h5iJ UOdZallwz9mzcxpTxL6zljvHwV19YJeNipY/Z2j13hAKASiJMg2dZNnLtJYu4+aWf4Nc pmXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sbpll5m/D2jqhS1yNNOSxZ189BRV9Du6vR6MiDbVdEg=; b=CnuQ1ML9VCTpQIv7D5poEfBBpYIoDJhRqqNxG4GuNqOnV6XX2UFE7ZVY6+dYBhLKnp PZE3vECTPTVcuJv6YSRDqzjrv6Bf5yIJfvM/62+zdikMAt2oXhaZ/aPlCHd9TcDWXRk+ nYXImjPFM4ImuCiWNS9z2dq9ltfA2KTT+PLjC4wAWWPitOfQdoNdNNWKxXFDKLcGfa+f FWRB14w2+6jn5nNEpH6rEdzV+SzoXHQ/LPMRaoxHCji93+Szk3Wx88RQPNbT6sWSycku 6LJYBTdL8WWGJD8AgD47cSV0B7h+n8Ot9Qw5uAs1cRCQjF211mvPBkoHI0lpKnG066ub K9Bg== X-Gm-Message-State: APjAAAVbREu7x19A8mNa8A6+wCanNxttxJKGVUxnaYjlm1MrjruUJTe8 jPOUJxhQtByIJfRU83bhWw== X-Google-Smtp-Source: APXvYqx784TAzbPMYolCx+Uaikhj4pzD/QrIyB7z80ES0utc6PL2m7u8USl8q9jY9++jOZXUmC3DbQ== X-Received: by 2002:a25:664e:: with SMTP id z14mr16706236ybm.75.1580684171200; Sun, 02 Feb 2020 14:56:11 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u136sm7185529ywf.101.2020.02.02.14.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 14:56:10 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: Benjamin Coddington , Dai Ngo , linux-nfs@vger.kernel.org Subject: [PATCH 4/4] NFS: Switch readdir to using iterate_shared() Date: Sun, 2 Feb 2020 17:53:56 -0500 Message-Id: <20200202225356.995080-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200202225356.995080-4-trond.myklebust@hammerspace.com> References: <20200202225356.995080-1-trond.myklebust@hammerspace.com> <20200202225356.995080-2-trond.myklebust@hammerspace.com> <20200202225356.995080-3-trond.myklebust@hammerspace.com> <20200202225356.995080-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Now that the page cache locking is repaired, we should be able to switch to using iterate_shared() for improved concurrency when doing readdir(). Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 60387dec9032..803e6fec0266 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -58,7 +58,7 @@ static void nfs_readdir_clear_array(struct page*); const struct file_operations nfs_dir_operations = { .llseek = nfs_llseek_dir, .read = generic_read_dir, - .iterate = nfs_readdir, + .iterate_shared = nfs_readdir, .open = nfs_opendir, .release = nfs_closedir, .fsync = nfs_fsync_dir,