From patchwork Wed Nov 2 16:10:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5630wru; Wed, 2 Nov 2022 09:15:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VgBkkopCyDPiS6UhYZb0bpHSMnYpY79Nor7Ym8fJWpA5BkV4HC4TOIy+y1R2uNqZN86WJ X-Received: by 2002:a17:907:75ef:b0:7aa:3373:e7d8 with SMTP id jz15-20020a17090775ef00b007aa3373e7d8mr24952756ejc.231.1667405733741; Wed, 02 Nov 2022 09:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405733; cv=none; d=google.com; s=arc-20160816; b=BlgVoeeSR7D+dDqQlktz7wVtpMnkb1Q/Gjn5yaCQPb99Z6VO9btdL5Yn4bAW5DW+fM MwtD/eoT67XBiDZsdf9Zf39DX1ejtxcx8gOtut0NVzMfr8kDjCfbb8Oq1B1DYT1oJoDf FgJK/X6yGM/b3mW47hSwPugRpV3Gm2oiLbXeMtFkBrG7PbfOoCZHtA9UxePWPaFFxlXA 9e/iw9XyP46XSLQ+Hq/kHAiQ1qyW+HY05215NIHBfQ+L4QyEDku2R8sNiW9ptdEGPsXx xlQefTkkzQHVNOYg9G2kbKCqTVwzMk6vVdhMRF8D8E3PGxLnundBBJ/IuhTyD3StQwTs zhUw== 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=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=ZDigJluS/ntMnAeuS+wRgqw1/J1e7AUg6sKztSQhW2nmw/zenSj3bngBNUJcoNHLfE cL5k+rl4lQ8i95+sOqE6N7K4RIG32DOtH50BD78fuLYCBhgqQ+JA2j6BP86RGQ7BEufc JdGH2RiqvoBw7D4xxGkCcHdSbfvWtKJEzYuy5wx+aNzR2B6/9/UlbHc1CE+YkZoHJZxB 4rajzxW1PykRDU1f0nTjsJ414vchJgGyStRwZSpqE1tQCPcpHgT+hySFuc2ARRpVWSHe vur2MrgTBHmbDfF1zYmn16DRZAf5Vq8cQKoLFXNEolT3HKwETuTvgpjGfuri7ey0Ejg9 cX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PTvyn3BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a1709065f9a00b0078dd7383ed8si12291870eju.414.2022.11.02.09.15.09; Wed, 02 Nov 2022 09:15:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=PTvyn3BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231670AbiKBQNV (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbiKBQLq (ORCPT ); Wed, 2 Nov 2022 12:11:46 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70A02CCB8; Wed, 2 Nov 2022 09:11:31 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so2318479pjk.1; Wed, 02 Nov 2022 09:11:31 -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=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=PTvyn3BEaAs9RE30oauDngZDkx0CdMxC8DfQHIIIl4jF6IO3gFQO/Hyq/HeBqHT04f Z6twx314UNMcXHGrTZulZS0YtVydCDj24T8M8fgfqpffbv6vl6jpy6+GiLGtpaRUnwjt hC9HVmZD06nQprUNjNlM4T7UE9IHxY7Kko6W6wvGb0GZeNyCB67/gGzrNo2P9nhFi2Jx wgZ0J9jcHXMv4ieTAzz3i1oJACiGkx9zlPc4v370bEV7YTt8vmW2WrJHjufczTQd6zL/ 8uZHmRqae+I/FnHCriK61BXAV9r2auhv6iVffm9aBrKd0N0Nv8qSUlpZf9PtTZLD1gi1 UHFg== 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=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=Oa/Jx11e3NWld2JZNaZ3JHLiUqXFehOV2BekTsKk1crgSYcuu7CJm7bDk3bKpqypvl qzxKr0O/abRYsDv/w/+6OQLLJH0+hSDG98GmYvTN4zwZIQCQw1OstbEeERUD/sk6XgeQ chMekHG5/xviAW2oO/H1mPSTcb+ReXGQepRQOyNGz7YSIj4ykowOWMCZsG2AHNnNt74f Ayu8OpNbL7EfFIekebW/WcKpLdMZWs9AbVYfcbLjNFXuUNXNgDsfDArNKKWCzfo04nBB OydLlUPDaPy5JBSVvAktyzmK0JbU62NkeQtHK4eN0T669HDINFXdbWv8ahmfKmoZ/XIm QKrQ== X-Gm-Message-State: ACrzQf1GPibSsQfjYL/WWQa4YuTCdqCU+i7WBYeUyCeBOF9hyD0zgjt6 5Jam8FDfciSZvDK9lDTPZXnCJnyiCd8QUA== X-Received: by 2002:a17:90b:2705:b0:20a:b4fa:f624 with SMTP id px5-20020a17090b270500b0020ab4faf624mr26339614pjb.124.1667405491123; Wed, 02 Nov 2022 09:11:31 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:30 -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 v4 16/23] f2fs: Convert f2fs_sync_meta_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:24 -0700 Message-Id: <20221102161031.5820-17-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401634385304025?= X-GMAIL-MSGID: =?utf-8?q?1748401634385304025?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 5 calls to compound_head(). Initially the function was checking if the previous page index is truly the previous page i.e. 1 index behind the current page. To convert to folios and maintain this check we need to make the check folio->index != prev + folio_nr_pages(previous folio) since we don't know how many pages are in a folio. At index i == 0 the check is guaranteed to succeed, so to workaround indexing bounds we can simply ignore the check for that specific index. This makes the initial assignment of prev trivial, so I removed that as well. Also modified a comment in commit_checkpoint for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/checkpoint.c | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 0c82dae082aa..82eb26f471c5 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -390,59 +390,62 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type, { struct address_space *mapping = META_MAPPING(sbi); pgoff_t index = 0, prev = ULONG_MAX; - struct pagevec pvec; + struct folio_batch fbatch; long nwritten = 0; - int nr_pages; + int nr_folios; struct writeback_control wbc = { .for_reclaim = 0, }; struct blk_plug plug; - pagevec_init(&pvec); + folio_batch_init(&fbatch); blk_start_plug(&plug); - while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch))) { int 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]; - if (prev == ULONG_MAX) - prev = page->index - 1; - if (nr_to_write != LONG_MAX && page->index != prev + 1) { - pagevec_release(&pvec); + if (nr_to_write != LONG_MAX && i != 0 && + folio->index != prev + + folio_nr_pages(fbatch.folios[i-1])) { + folio_batch_release(&fbatch); goto stop; } - lock_page(page); + folio_lock(folio); - 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; } - f2fs_wait_on_page_writeback(page, META, true, true); + f2fs_wait_on_page_writeback(&folio->page, META, + true, true); - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; - if (__f2fs_write_meta_page(page, &wbc, io_type)) { - unlock_page(page); + if (__f2fs_write_meta_page(&folio->page, &wbc, + io_type)) { + folio_unlock(folio); break; } - nwritten++; - prev = page->index; + nwritten += folio_nr_pages(folio); + prev = folio->index; if (unlikely(nwritten >= nr_to_write)) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } stop: @@ -1398,7 +1401,7 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi, }; /* - * pagevec_lookup_tag and lock_page again will take + * filemap_get_folios_tag and lock_page again will take * some extra time. Therefore, f2fs_update_meta_pages and * f2fs_sync_meta_pages are combined in this function. */