Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1237619rwe; Thu, 1 Sep 2022 15:05:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5jP5gL8YhL4iBPyuwKtyoZhXLSc7zD9bbNgtCEBC2k5mgAmuNoTn0pW29/qtXUnNN/NUGr X-Received: by 2002:a63:6bc5:0:b0:41c:26d2:81e2 with SMTP id g188-20020a636bc5000000b0041c26d281e2mr27513846pgc.522.1662069899700; Thu, 01 Sep 2022 15:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662069899; cv=none; d=google.com; s=arc-20160816; b=nkv+ngQEtdeEEYKBCzQO3d//e7yDeM28Yy+0lx9EmEd3z98hspWh8CwdjoDsHoRIXv 81s8tYYZNp1Kw8Zs65c2AEsUXuDglFb914iEQeQwIpbTy3C0JA9TckyuVo4Q+l1B3dBW 35ZqgiXswjRO6eg129K6EcimP/sEcOIInz2YX+c20bLJteJDeuLbz6Ls2dRiPI3dhWMk TFSIg8xCpV3TvrzRNzFa7O60i85o5+/eQH/ZICeHfQXSsfGSiMCI8mIQlMKRbrIrMqEF cveGl936YjtJHeSnqp5P0LYQ+7mBHWTvK75qXn5dkSLJvv6NYupXAlwniy4WETGl1gbr fUcA== 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:cc:to:from :dkim-signature; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=M3n6cA6D/y0tI/B+I26cv/RL4oHeWSg2u/7w9M75Q7O3Fr1pWlZQ0RgoaFi9/yqpZ0 0eqV2qfAd1ZHHOppOXZlgPbYrk3Jq2WkFrOtZGVKLXAWOqk57eVvh9M1wuOAs7Dg/YIl cmbgaDqwSYXt1/ZfQhondZbZJ/cEtRcvvMxUcmgih+luKALU3sZsMGRYgkv15OC/ZASs OIfZ538FR9UyJOTmk6rWRebjfWS71IAlfz6z55Qh8+ykNMm3WhYhuT4amCQH8nolWQAf vbFpH8TpxGtQLBcca4fInt59KEQRP6iSeFL8+k+tTvsNdUC7npPCUGvq9i2pHgowHJhi 1DxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GtrGYdGL; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a170903301200b0016d7c6223cdsi149087pla.261.2022.09.01.15.04.45; Thu, 01 Sep 2022 15:04:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GtrGYdGL; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234828AbiIAWEN (ORCPT + 99 others); Thu, 1 Sep 2022 18:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234676AbiIAWDP (ORCPT ); Thu, 1 Sep 2022 18:03:15 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3404B9412D; Thu, 1 Sep 2022 15:02:48 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id mj6so280589pjb.1; Thu, 01 Sep 2022 15:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=GtrGYdGLszgBq1fvi5V2PSfoLOXh1TNyiK0ofvUFGiVvwdQ6PkaGy3Ns4qJwLgF4b3 aIYdrsYMX+clX1Y+yOXcuDls8w+WiavI/64KPDiJmDgxyBZ4dAulShvhPc4ENInwd3Br cmukOGKll48ywyFlU3xTzvvA/EhYiy85fvbJiJhltWdFBrenWV2xIc1tgrmQTV6xVFrr kPWQoFcSoXWz75f58hl6lYhesgfwr3gasm4nlqUw3/vIqwimOmHoTKvTQsLxit2YTq1H EGgbgkZ8lcymg9dX7HeYXgo7ygr9E+FPEd+ZGk8VSDrPOWMvOyx7zdOCyAyIqsvEGW5B 7Vuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=K2UjfDsIFIH9CdDJvhMIxAXe4nuF0KXe5+5sI1x68ShfsMRrr3RSxO6GZ7viOdQusq doF4UcFsJpx6+OPPeM/GsBd0LTOKOp9vKfYVivCJHdu7ys6DVxDtDCsuts7e+YITOlii Akwr55gdEKnkiEdO8kgb5bGEvvRNjx5j74izm9MggD5k9nC3HEody9BuGSt603ZKlgo7 JLa/CXJePptTwjHsNICn9UYmMeQRfWDQA5ICy4u/gYSsk13gL/3uGu1/RAM/IJ/1o9yl PjCIzk8jMBGCevHolya8UXVVePuhOSxYxkjwzf6q5Zh5guX0Osyq8SuifWFz8nq0A/TU MMNw== X-Gm-Message-State: ACgBeo2HjNObG4UoDtGaMl7ALZ5pz1Xgcxr+NfzNvOrz/OfNpGpar7jS 7kIInXNDVoQy4XDyI1wp1QRoxQkcjFTsDg== X-Received: by 2002:a17:902:c613:b0:174:7a32:f76 with SMTP id r19-20020a170902c61300b001747a320f76mr24825305plr.165.1662069767428; Thu, 01 Sep 2022 15:02:47 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:47 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:24 -0700 Message-Id: <20220901220138.182896-10-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-ext4@vger.kernel.org Convert function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). Now also supports the use of large folios. Since tofind might be larger than the max number of folios in a folio_batch (15), we loop through filling in wdata->pages pulling more batches until we either reach tofind pages or run out of folios. This function may not return all pages in the last found folio before tofind pages are reached. Signed-off-by: Vishal Moola (Oracle) --- fs/cifs/file.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index fa738adc031f..c4da53b57369 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2517,14 +2517,41 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping, unsigned int *found_pages) { struct cifs_writedata *wdata; - + struct folio_batch fbatch; + unsigned int i, idx, p, nr; wdata = cifs_writedata_alloc((unsigned int)tofind, cifs_writev_complete); if (!wdata) return NULL; - *found_pages = find_get_pages_range_tag(mapping, index, end, - PAGECACHE_TAG_DIRTY, tofind, wdata->pages); + folio_batch_init(&fbatch); + *found_pages = 0; + +again: + nr = filemap_get_folios_tag(mapping, index, end, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!nr) + goto out; /* No dirty pages left in the range */ + + for (i = 0; i < nr; i++) { + struct folio *folio = fbatch.folios[i]; + + idx = 0; + p = folio_nr_pages(folio); +add_more: + wdata->pages[*found_pages] = folio_page(folio, idx); + if (++*found_pages == tofind) { + folio_batch_release(&fbatch); + goto out; + } + if (++idx < p) { + folio_ref_inc(folio); + goto add_more; + } + } + folio_batch_release(&fbatch); + goto again; +out: return wdata; } -- 2.36.1