Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2150775pxb; Wed, 9 Feb 2022 11:57:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjswFIVrEwjD3bRphrgE4iEZnZhHhfaCQXqPBb38PWMI1rxSpRm1bbE45GOpzR1DVgNbrO X-Received: by 2002:a17:90b:4ad1:: with SMTP id mh17mr3279226pjb.246.1644436648474; Wed, 09 Feb 2022 11:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644436648; cv=none; d=google.com; s=arc-20160816; b=QVjSVEbUjZh+4zaLrtQtly/Q7W2+pK/lySSJQ02YHp68nuW7iZcR2qqketAnRWMttr HxGd9qhMsyUXDvDetVBUEY/eEygQw84TjJQX9EWJjy9J2KdzdumxuWyN0QerDk1aXx7O LbithXYVjQu4vZOk69/wwepZQQ75LH618tY8Kx1zvD0FYad0Ok7nSBAJM6ymBRthFmhF r03wxMDied1n+e/1ie10aFRQab3yRNQ/MdbJpwINUhy1xD6NjhPsSTTGpfSqXz7Xy1zz w970kxJ7N+w99kFMrCXeq4u+hrkubcf7toICiRGh9BC/ZqQznn+1tvxJD/EVI6cTsvnu DcWw== 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=RaafPI57HdpzvzZ++7jycbHr7RV0HUjlpOxqSXcd46o=; b=GIQwzH+KdxonCUwPJCU4JVg9Gjl+wzKGekIuwkCiYsXbyjZKrHJrxaq/YV0+Wv6qow R8q989ySicKwnbH7dxSe8yyPnDHPMLSJn2E5vG3IgYEhovrUfRVhadIJ7lBq0WCbZ65D 379KtFa1vOeKpVRV5yBz54SgmuATbzu1TbLepJKHWN96WYT2I00g0jjIsfUcwLAr2aJC sZfGoAncjJHcTQBHBfGlu1QGjInf+daomCPT1f1a/4f6xsis6HRWlcTlQYtFnShhXkUY C/1ze3Ry7cruA0DO/xgfGU0XlMCKGamzG0tbIZQuUCVghKBYQokDPlCyPPKtZLijEF7M NzFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="QpD6+/va"; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s138si7304864pgs.42.2022.02.09.11.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:57:28 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="QpD6+/va"; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A541E048E60; Wed, 9 Feb 2022 11:49:19 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241258AbiBISyZ (ORCPT + 99 others); Wed, 9 Feb 2022 13:54:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241304AbiBISyI (ORCPT ); Wed, 9 Feb 2022 13:54:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0DD0C1038D5 for ; Wed, 9 Feb 2022 10:49: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 ams.source.kernel.org (Postfix) with ESMTPS id 88C7EB82386 for ; Wed, 9 Feb 2022 18:49:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02410C340F2 for ; Wed, 9 Feb 2022 18:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644432579; bh=9Dkqpz9icKHWvPFSnPQopHVqWpz+abyAU5GPmJFxVv0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QpD6+/vaIROpzZF2n3teoxuiRQB5hk0XLi1WLoW4pQfHhsSzeSOy1iUS0/NTHFmiL qPpsPGzyv7VMssTdFqBIJlcdoSVrTK0hdtrJ6h49XLcujZsdGpwZY6XTZGhLxDFu0o ZO283J/G8nAGywas8/Ykgt0a7KCSR7L60KbOdXACttK7WkD7I5mrhJiRzzn2q89ui1 ecDTebLYmnWhddT7LMcI/COQ5nATTWrW7FRJH3yvs/az3A5qJ2anBbOFusTJWLdz+R +vzWhmXLvRd5C7TFGXCSK85ZEtxvel+6zPzfTZel5+iU0QRU5hsyigZ3nD7SHQJw8V kyXZd+BC3Le5Q== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v3 2/2] NFS: Simplify nfs_readdir_xdr_to_array() Date: Wed, 9 Feb 2022 13:42:51 -0500 Message-Id: <20220209184251.23909-3-trondmy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209184251.23909-2-trondmy@kernel.org> References: <20220209184251.23909-1-trondmy@kernel.org> <20220209184251.23909-2-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Recent changes to readdir mean that we can cope with partially filled page cache entries, so we no longer need to rely on looping in nfs_readdir_xdr_to_array(). Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1323eef34f7e..b4f6c0cf8df9 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -864,6 +864,7 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc, size_t array_size; struct inode *inode = file_inode(desc->file); unsigned int dtsize = desc->dtsize; + unsigned int pglen; int status = -ENOMEM; entry = kzalloc(sizeof(*entry), GFP_KERNEL); @@ -881,28 +882,20 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc, if (!pages) goto out; - do { - unsigned int pglen; - status = nfs_readdir_xdr_filler(desc, verf_arg, entry->cookie, - pages, dtsize, - verf_res); - if (status < 0) - break; - - pglen = status; - if (pglen == 0) { - nfs_readdir_page_set_eof(page); - break; - } - - verf_arg = verf_res; + status = nfs_readdir_xdr_filler(desc, verf_arg, entry->cookie, + pages, dtsize, verf_res); + if (status < 0) + goto free_pages; + pglen = status; + if (pglen != 0) status = nfs_readdir_page_filler(desc, entry, pages, pglen, arrays, narrays); - desc->buffer_fills++; - } while (!status && nfs_readdir_page_needs_filling(page) && - page_mapping(page)); + else + nfs_readdir_page_set_eof(page); + desc->buffer_fills++; +free_pages: nfs_readdir_free_pages(pages, array_size); out: nfs_free_fattr(entry->fattr); -- 2.34.1