From patchwork Mon Sep 12 18:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12973912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A87C6FA83 for ; Mon, 12 Sep 2022 18:25:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 855CA6B0080; Mon, 12 Sep 2022 14:25:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8058B6B0081; Mon, 12 Sep 2022 14:25:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60ADF8D0001; Mon, 12 Sep 2022 14:25:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 50EFC6B0080 for ; Mon, 12 Sep 2022 14:25:34 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 327CFAAF27 for ; Mon, 12 Sep 2022 18:25:34 +0000 (UTC) X-FDA: 79904261388.05.E8B3D40 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf31.hostedemail.com (Postfix) with ESMTP id DDE51200AE for ; Mon, 12 Sep 2022 18:25:33 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id y127so9438901pfy.5 for ; Mon, 12 Sep 2022 11:25:33 -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=KoXD1n4O8ij6+vaDqAsDjDA1z1eTfTDWEfPJ9QSCW/M=; b=BZPYTfKKJ2IeGMWsAm7r5I0nQB4gclz+jy6EiITDppW6LssmKcSmGL+zkMGzIjf98J Q3BASOV6PEAfmE68/qZUmNU+ToR1Rwqc0faNQ8jDOn7kQ+r7lr+aPhsgOnMbpqRcDM2q 5NYfTIsAyd9Th1n/L/TbbN3vetw/ZO4rITCeD3wkLYNjZFz3gI1ars7ee7f7W3JdkKBy aPnrjXNnzFtLErLace4ESBOS/R7qEYB2MaD2vqFA0/AlV9HezcEeR5NRqn30wevEveTR bGDRTu8iaWmVvnqe/dXNAI6iA31yI+10bgpY9gd7za2p7wzO3beyLUxFMZoM2A6weUU1 dwKA== 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=KoXD1n4O8ij6+vaDqAsDjDA1z1eTfTDWEfPJ9QSCW/M=; b=aDKmqbAqMvQCIbr9ZJkidEq0+lYgEWiFZOiMygJt6znlLPWgfqbKorQjVInkxY+pW9 T0/1erS/AuZfzgezaRZ3jSbuAiMbN5/S6L8GvAcvZ6pn7uNCzArUtPEjl3sDoQnrMcNs cfISLpCm4ZTsJ4dNL4SpPrYDyx7Q7dIzoRyUasRlvhYTaFZHw578OVaBKhFaXYYQRSJ8 biAtSbBvLIgHfq7lMcmE7tEfKcrSoC2VpiOXXMXIXLq1ciSSP1Jv4lHDwK15pwZPuWPN 9Buj5B8SsEAsvebEJQLfzLetcbDb2LmX/xYY1qz2plvYXRURvGQHCwVgpIya3Xv/C6Nl 6BTQ== X-Gm-Message-State: ACgBeo10+IIEklDpC9uInlqzJ4YLwPkqG4+2qSxLBASeRWQWiZR7kBzH 5dnOlsJsVCcLh9jrNYTDzzw= X-Google-Smtp-Source: AA6agR4kc218OTkByNvMFvG40KB25np+dV2H9QdbTpPY0UgJwFep6+zCtMG38JLWYBwE1M9+1Fbrug== X-Received: by 2002:a63:1a53:0:b0:41f:5298:9b5f with SMTP id a19-20020a631a53000000b0041f52989b5fmr24051599pgm.244.1663007132921; Mon, 12 Sep 2022 11:25:32 -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 x127-20020a626385000000b0053b2681b0e0sm5916894pfb.39.2022.09.12.11.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 11:25:32 -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)" , David Sterba Subject: [PATCH v2 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Mon, 12 Sep 2022 11:22:08 -0700 Message-Id: <20220912182224.514561-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220912182224.514561-1-vishal.moola@gmail.com> References: <20220912182224.514561-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BZPYTfKK; spf=pass (imf31.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663007133; a=rsa-sha256; cv=none; b=AmeFdvmJy3Zgpxk0ggdx97JuLh4MoMg9Ijrpwbdx5IR2QE2Kl/Z7/98cAqIWaYY3g+DeW9 4W6CZDYEweZS512lFPyhyX574yM8WEZJBtgHiUBsByjbLVJFVqwyhvQNkyiBZi9f2xa3wz oXP7AcP4tS2zLl2uN+4M+sJAtPXlf6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663007133; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KoXD1n4O8ij6+vaDqAsDjDA1z1eTfTDWEfPJ9QSCW/M=; b=Vmtm8nOoCZBjaxcTQ+CuuY1uEnpYFFRXpko+otBrlXEKvwmsVJRKo7uLV9fU5bHkXRAPp5 FPLqo69ZCsImyJynFriKke0e20irU/7G8G5dzhxytmTqpLAQ6FjkDr6TqhU/HReKJ6B/gR xn8IwILhLsQ5Of6Adh568V/tcS14cqo= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DDE51200AE X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BZPYTfKK; spf=pass (imf31.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: wna3dboqgn3ygqqufin49zfg7wqfsjdg X-HE-Tag: 1663007133-326844 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Now also supports large folios. Signed-off-by: Vishal Moola (Oracle) Acked-by: David Sterba --- fs/btrfs/extent_io.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d1fa072bfdd0..80fe313f8461 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4972,8 +4972,8 @@ static int extent_write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int nr_to_write_done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -4993,7 +4993,7 @@ static int extent_write_cache_pages(struct address_space *mapping, if (!igrab(inode)) return 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -5031,14 +5031,14 @@ static int extent_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !nr_to_write_done && (index <= end) && - (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, - &index, end, tag))) { + (nr_folios = filemap_get_folios_tag(mapping, &index, + end, tag, &fbatch))) { unsigned i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index + 1; + done_index = folio->index + folio_nr_pages(folio); /* * At this point we hold neither the i_pages lock nor * the page lock: the page may be truncated or @@ -5046,29 +5046,29 @@ static int extent_write_cache_pages(struct address_space *mapping, * or even swizzled back from swapper_space to * tmpfs file mapping */ - if (!trylock_page(page)) { + if (!folio_trylock(folio)) { submit_write_bio(epd, 0); - lock_page(page); + folio_lock(folio); } - if (unlikely(page->mapping != mapping)) { - unlock_page(page); + if (unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } if (wbc->sync_mode != WB_SYNC_NONE) { - if (PageWriteback(page)) + if (folio_test_writeback(folio)) submit_write_bio(epd, 0); - wait_on_page_writeback(page); + folio_wait_writeback(folio); } - if (PageWriteback(page) || - !clear_page_dirty_for_io(page)) { - unlock_page(page); + if (folio_test_writeback(folio) || + !folio_clear_dirty_for_io(folio)) { + folio_unlock(folio); continue; } - ret = __extent_writepage(page, wbc, epd); + ret = __extent_writepage(&folio->page, wbc, epd); if (ret < 0) { done = 1; break; @@ -5081,7 +5081,7 @@ static int extent_write_cache_pages(struct address_space *mapping, */ nr_to_write_done = wbc->nr_to_write <= 0; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } if (!scanned && !done) {