Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp816743pxb; Thu, 17 Feb 2022 15:40:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNcfZ2B61SgB5MHk2vgBckRsw+m5NJEBN9F4ldUijAFJJD+MpdaavXPevrt74zyOkO8o53 X-Received: by 2002:a63:e24e:0:b0:33e:9849:526e with SMTP id y14-20020a63e24e000000b0033e9849526emr4265958pgj.468.1645141223089; Thu, 17 Feb 2022 15:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645141223; cv=none; d=google.com; s=arc-20160816; b=KR2ftm44X0yUUHGH3rtA11utp0Jqjz2KjQwye+oCsjSA+UAHesnIgVm2429CLSaJbH kDukUzuNctaJd4fg5/SWdT63qkRIRKz4C8Vul7hqRufwNNmNty4nI0SdcSqSBcNj0i2H NWG934CeCnC7juxpPsq0hHb0zLbL4AugpPXq6XnnK42cIAXNuH/6iqlVv6o7UnVkREm5 w4IxfIaFpl2O8z0ExJ/pCNXrcQ068U+kKDEpxRPylsB6PoGQueGFvQLd43X1Us4S8fjN bvRVULJk1btNDkXXVH6MngZrGMtbhKMrpoP4LknufTMKEZDn7o3tHa6/wPn+QSsNYwEA GrWw== 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=rJbknmMMQc7P/Rh46YEuD8kUrCfShuy/PfuRnvuL8Ic=; b=gGbaIBhjScdT+cy7BhCAjzViWDQBGOxtQLdaN74TnfZe8x2Fh2hMLmCQWXMVgpBD1h Ypg6VzaQ8g05hob3NsjhSoFyCPGdsl+Q6Htbn2OguY6wPe8rywA15RY91zQiViVyshfk lfNaV0Xh12EhRSagFnx3DaZy2ebdoZA9cRUqIzTeROjgVShNtLoLsBOCfkPU0piLhQ6k 09e6Vg357zJ2qjsJjciokw532FG2X0FPGkudub4RNswanerVDSwt5AIS5yZtl9j+QzCb /Vd24LVihUuztuXXi1CYkq18gd4OC0OtFdoqVa9ERt+uuk/gBvIGT8lc/9FY2g1//pME oPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OveIbU+l; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 18si3028845pge.847.2022.02.17.15.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OveIbU+l; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B3913A194; Thu, 17 Feb 2022 15:17:45 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343925AbiBQWjt (ORCPT + 99 others); Thu, 17 Feb 2022 17:39:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343922AbiBQWjs (ORCPT ); Thu, 17 Feb 2022 17:39:48 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9077E811B9 for ; Thu, 17 Feb 2022 14:39:33 -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 sin.source.kernel.org (Postfix) with ESMTPS id 05C24CE303F for ; Thu, 17 Feb 2022 22:39:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C861C340EB for ; Thu, 17 Feb 2022 22:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645137570; bh=OEaWlQura1Zo3jLczETAEUmVQFXQqWShYTiOvBTsLUA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OveIbU+lqrqwC3Yg7RbJlwNTAJkvNrIxH+nQGzS4ycxnUFQ90kC1qnCb9E75Aj5An t/rjQNxHXBc0Dwcdc103arijzoK23J286Dd5K/OoB2JzBM9D4BaGuE5QWVgaGI6IpG rvcyLJmw2Z6+OnU+GdohdV2LciYrQhkpy5UpH8zxTMIJZaMlo2z1NsfVaS8m8xKTJy cnW3t/Uf+UWhSvdHEENpI/sjjdtCb/XCuhwiLN08JFdCojG0O28FTX32K3WayIvVHy BpE6byUNo2qZSOWDRuynJ+kDyiHCpCikzFsrYOLO8yeeFl3kmubN9vOdACqE3KPsd+ IFBrZOgp9PTeQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v4 2/5] NFS: Simplify nfs_readdir_xdr_to_array() Date: Thu, 17 Feb 2022 17:33:20 -0500 Message-Id: <20220217223323.696173-3-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217223323.696173-2-trondmy@kernel.org> References: <20220217223323.696173-1-trondmy@kernel.org> <20220217223323.696173-2-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 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 b0ee3a0e0f81..10421b5331ca 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.35.1