Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5600822rwn; Mon, 12 Sep 2022 11:27:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR45cy/OKmeob1MGVpKHP8JtOJXRQ/9homeyWU5VpLO7CyijzRuEDG20wCcOoJ725HCFzMYs X-Received: by 2002:a05:6402:645:b0:452:33d1:5308 with SMTP id u5-20020a056402064500b0045233d15308mr1453702edx.6.1663007267635; Mon, 12 Sep 2022 11:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663007267; cv=none; d=google.com; s=arc-20160816; b=Ykob9e4o8ykC+uPIamB8BHiL0fkdFNbh2zpgU//InD3UL+JXZO+UvKZruK/Q+C1Cb7 G0nZzH6OQv4bz+6xgMaFFZMz2y03fJqhG5Xi8hX++FdFaQ29/v2Jpld8U88/roqW/mL/ 5mi5sEyEc9hPs7clLg+xAmvtJtXpDVeIVOIrI0TE4RNEF7bphhPBElKpuDBz/NQew5Hu 7NuZC2YyDEvDIfRF+0InDJgKLfpXDletW0zo7Y3MsoXX8a5HAjKJXqANqv21AuMsdCr4 Q8NBsHk0w8ke+wv0nUg57ieUhsiDA8pgVCYvs6XT0SxSXEVXVdpu5vE2iWp3cIoAC9Eb EHVw== 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=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=IzyMrttg1EtgrIhvbVYNUCjVoDUlz2WQidrNTdHmJ0QElziTwjAoumFMAjLcg4HGR1 DZp/enzkvjZ7P2vdq3KevOBIuFuQi9Q9M2VX85lUxR8R6V3IYwz17/XqyppI9tKOMFPM Y4HhW0FWee4DemiAvjYj8EXWsN/OStZ5VfUi9iqPOYo+EZaIbf4bI4BDFC+iqWvzYCc3 pQzh2uqPpi8VCWW6zq4rNztJZDd6uNFUhhA2Iv6+424Ey+MmA/YDOj/YpJT76mHCX/o/ rAYaa01y2ZpGYUsqw8PcWiM1dgqHgyzpgSid9jH5LbOLwwIZmumRMJ7zyBIl9Ve5T76y wc6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i+CvfGJ1; 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 s14-20020a056402036e00b00451747ba5f4si4238191edw.505.2022.09.12.11.27.23; Mon, 12 Sep 2022 11:27:47 -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=i+CvfGJ1; 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 S230284AbiILSZl (ORCPT + 99 others); Mon, 12 Sep 2022 14:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiILSZ3 (ORCPT ); Mon, 12 Sep 2022 14:25:29 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6070613FAD; Mon, 12 Sep 2022 11:25:28 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id bh13so9053047pgb.4; Mon, 12 Sep 2022 11:25:28 -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=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=i+CvfGJ1xweyLR6NOS/OxnqiRLWZM3RFv/3f4/eaiC8yXGa2PYgA//hX4fw4SBcwuZ ZPbJCvu6Hpri/ShhhvMOySAzKqMQZBI6Pd783OTpi2V4tcjTZwi9igZBMFH8xFr+QBRA RC97/WVT4NsDit8DUFsiQ44xQEfERi5ftH04KgshLmP1fzE+gvCjTG39D7ZgrD6KgVZ4 YN3kYEdDJX5fEGrdVCzJkLfhLNOoCzZx6TMetOW9eir5OFUx9ZNEwWki2VaMIQl4MvcV D3zCw3kAGReJ4KjB0hlwVX+5OYBG/axI7+cePqTtUb4CrNmCKpzDlLa9eUrXL2maCi1n /OyA== 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=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=r8bi81XcvP8R5d+IUH1ZxD98YJjd/Bufdj0G8GxcsYnXPiq0uHOGeOcChpuaW3KCK7 yE08VJNVPaZC+cXpq2xXdYxeCYnLyMq6b8JoGWKGVL3qtaA0iV/sFVB+UL83+eteoJGR xDMmhnZJwBDLB9DU2+EaN6jpCMFYZoMpYnbnWS3Lth+16lKxQKW2/Yt1zcbYInzvqSx7 lCfISYKwUQA9ay6FjJjjq5TWTLgA77nQA7EicxA6A/5sJK7nEHCrFwN6tNrPG8HKPlaq Gajn8Pv6XpNPvzjw0eZrYrZsoo0S1UNzkVjA5V24NFAytpdQ0dPBhGQQk2w6+GHodK9U +sxA== X-Gm-Message-State: ACgBeo1l5qszrOXJs9BL8rcHR3/qxMZJWwWgDLrP2UV/75h40rHd8y2R JakW+CqrIMUsE1BuJ2SKHHBOh5i67y4h4w== X-Received: by 2002:a63:ed58:0:b0:439:b3a:4f01 with SMTP id m24-20020a63ed58000000b004390b3a4f01mr4992754pgk.327.1663007127489; Mon, 12 Sep 2022 11:25:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 11:25:27 -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 v2 04/23] page-writeback: Convert write_cache_pages() to use filemap_get_folios_tag() Date: Mon, 12 Sep 2022 11:22:05 -0700 Message-Id: <20220912182224.514561-5-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 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 Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) --- mm/page-writeback.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 032a7bf8d259..087165357a5a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2285,15 +2285,15 @@ int write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int error; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* prev offset */ end = -1; @@ -2313,17 +2313,18 @@ int write_cache_pages(struct address_space *mapping, while (!done && (index <= end)) { int i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + + if (nr_folios == 0) break; - 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; + done_index = folio->index; - lock_page(page); + folio_lock(folio); /* * Page truncated or invalidated. We can freely skip it @@ -2333,30 +2334,30 @@ int write_cache_pages(struct address_space *mapping, * even if there is now a new, dirty page at the same * pagecache address. */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - wait_on_page_writeback(page); + folio_wait_writeback(folio); else goto continue_unlock; } - BUG_ON(PageWriteback(page)); - if (!clear_page_dirty_for_io(page)) + BUG_ON(folio_test_writeback(folio)); + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = (*writepage)(page, wbc, data); + error = writepage(&folio->page, wbc, data); if (unlikely(error)) { /* * Handle errors according to the type of @@ -2371,11 +2372,12 @@ int write_cache_pages(struct address_space *mapping, * the first error. */ if (error == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); error = 0; } else if (wbc->sync_mode != WB_SYNC_ALL) { ret = error; - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -2395,7 +2397,7 @@ int write_cache_pages(struct address_space *mapping, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } -- 2.36.1