Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4972674rwi; Mon, 17 Oct 2022 13:31:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60zlVCWV7iFi8XkL1nas1mtCFum7aA5S6QXqN9SjM7XSZeBH4hMCQIVMD9ROHGivQaDvHI X-Received: by 2002:a17:907:9602:b0:780:8c9f:f99a with SMTP id gb2-20020a170907960200b007808c9ff99amr10311241ejc.465.1666038675444; Mon, 17 Oct 2022 13:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038675; cv=none; d=google.com; s=arc-20160816; b=Hp5d3Wi30BuHVNxMG3HZQzpShH4+MdoNn+re1zwwmRP4YM471AlDSmL0UFvuftyTyg C0cVwnOlESVtvX7pNXxH38JHQt0h7I6tkMpWehFXNTUuyW2O+UmxbQhwHZOgMH2yTsNk 0RFRhZUPlAhLBgv7Oqm7JTSoMgsHJT2i2Enrj3eouxYsaEj4UviJte7J73wKgAPovXgF 5aDxGdWgmo77c3fDux7WwoCOZC4USUp8QuwSIHFGTXKM1ysyyTK7aK2RIn9wWQnnKHsh 0PYqmn/Ctf0ExQ1CCuSxAQMScmEE/iq6NWc8ueqMO2kFd6EdMu2RLoN/OVoF4Z9ZCR2Z eW4w== 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=8lGvZhCn6w3m/u/axqUyJr4YJieOtwPL381iDrfRPJs=; b=GNt3O1SumcQEhP1oWahYo3+u02QuXh/ci7G2pm+k3Qe+PSnaHbxnGLdADru/eB/MeP RGORC16G6VziXfpKh3wKrLfC0kivu7LdvTq9j2ht0gsdIUw5nt9ie5AU7U02Qziwnov7 LhGQ2ybiwAM7T+KgiW9WIaYJiSfQcks9Rm1Jlsqe1pzpTvbAJiierCmGezIGNn6e49Hl SIHBRCSB04PzOr0DSPipta01ygHqg8H1+FIEl7G8AJm8/bpXYacfgQj9TGcv+oAYJqvL Vh43Tp/P0oDGbD98ZhiEFG1Itd28u99z815nORzsYDe8azAi5o3etR9yS3TsWyDiLngQ zITQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aG3SJg4q; 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 nc4-20020a1709071c0400b0078d810e16a4si10689599ejc.486.2022.10.17.13.30.51; Mon, 17 Oct 2022 13:31:15 -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=aG3SJg4q; 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 S230090AbiJQU1W (ORCPT + 99 others); Mon, 17 Oct 2022 16:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbiJQU04 (ORCPT ); Mon, 17 Oct 2022 16:26:56 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36A97E325; Mon, 17 Oct 2022 13:25:32 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id c24so11844035plo.3; Mon, 17 Oct 2022 13:25:32 -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 :message-id:reply-to; bh=8lGvZhCn6w3m/u/axqUyJr4YJieOtwPL381iDrfRPJs=; b=aG3SJg4qEEuUDtQxkrwRHnXHEwtEOL8oRmp1xZGekVyz7AhXflcPIT93FxZtSN7uZY lM5k52jpW2xqn/iYqreIVsJXVTqBXttefGdjlBnm2ZiWSVft3KopI5uWZCYYgnYlxzy0 viM2Fwjf08wHoU6bQj5F92IKi7+a0IhEnJXK/52p8U2ZcybnkQqwj27LdYTfvezaVks8 N0z1LL10X2PYU2LyW2qpNOXjfG1KLK+AtL0Xi5sghE+Ct+9vBqzo4iFRd67IECUeMCll RNVAWFX1G/NemRO5eE8fzhREY4K9flg9KP2L8wXVlgZh++Ne4D1TvU1k18grQa7QQvgO JZqQ== 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:message-id:reply-to; bh=8lGvZhCn6w3m/u/axqUyJr4YJieOtwPL381iDrfRPJs=; b=Z0kAGsdvOfwBLb6ZBREvNTJVdZsSz0yAhlczF4ZvGdCgoB2S+bqK3DPgs13r7/uFeT FvdNE3YIlAuaA7jW+lHrP7km2khC/Aof87BFI63huaX+eiZe0+2VwgS49LCVWO+FiU7B laBQ37TTOAdydGtUp0akHNaw2WdMsKe4tB0ia6BIH3WVu2DpicogrNZla3NtTawgorFk ZIDKAaERZYIeicme7OFAZd7/lI6wuuglNJvCWS0XmyUgcOmXwqIdx1ZqZajackgAjtGe L3Vag0MFmG/aVGTG0dcRjySikjUbmUsbNjS9k81I0N2amSyhd9HPywQg6UifUsCWb12k DqmA== X-Gm-Message-State: ACrzQf24wKxtVhLprMjOYxFDfhNM9Z2DejpaJ9qGNc73/axK02WYAVWC jBRsKu/xBT6NKkhMqT2gtk/5AToBlIOpYw== X-Received: by 2002:a17:902:f707:b0:184:e44f:88cc with SMTP id h7-20020a170902f70700b00184e44f88ccmr13721703plo.42.1666038301326; Mon, 17 Oct 2022 13:25:01 -0700 (PDT) Received: from vmfolio.. (c-76-102-73-225.hsd1.ca.comcast.net. [76.102.73.225]) by smtp.googlemail.com with ESMTPSA id pj12-20020a17090b4f4c00b00200b12f2bf5sm145037pjb.1.2022.10.17.13.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:01 -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 v3 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:35 -0700 Message-Id: <20221017202451.4951-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221017202451.4951-1-vishal.moola@gmail.com> References: <20221017202451.4951-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 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 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 9ae75db4d55e..983dde83ba93 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3088,8 +3088,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; @@ -3109,7 +3109,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; @@ -3147,14 +3147,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 @@ -3162,29 +3162,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; @@ -3197,7 +3197,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) { -- 2.36.1