From patchwork Mon Oct 17 20:24:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630352wrs; Mon, 17 Oct 2022 13:31:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/r3sjIV0AgTLaJDXYqjob8t9Ls4voViVqBBz29Ba/6CaWucK7Yr6XtQSgw1MEPQmRry/B X-Received: by 2002:a17:906:fd84:b0:730:acee:d067 with SMTP id xa4-20020a170906fd8400b00730aceed067mr10227634ejb.206.1666038702849; Mon, 17 Oct 2022 13:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038702; cv=none; d=google.com; s=arc-20160816; b=gjso0327oZCu4cBkkCPK1AGPXxNWX916CJfZ+xITBlz9qwUAV5hCFhENHnGsDj5pcK c0gG28UO1qk4waBlwOojf2WwbcMYlYZVUBkuKeR5yVfE2f/Sbc8h/BkAm05knsKH3n+q LARBPpNjLjvJ42xULePA1KL2IaDXokPH7ibYKQctn7L82w6X9/ebf72xAOgtz8fUaRrN TDX+CgllfiLkQNrDi06Y494b1kwV7pQNk3fELMBSoQEUVIj3WdYJnKb09+pS7WrDnEsO +V6CRv2Kv0o+ms2E9Q3Mv1qJJREDDdmYzGlMTHZkaUWQyocYVpYAovfjJN9XQgFzCOzi s4JQ== 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=pCDfC9IuoCSNDVn7a45aZdbsaBOFv8BIjFg1qCCcT9Q=; b=bCxXb0zD5VDpNtyS/VUUxXrhZWqrzZlTNNeti5cffvU8cQnkEfVl1NHoh78vWlj8LD r++fbRF6g4m8mpkm23j6Crw77kOL0O5WNrkxNU4J51hiMyaICwIvjdn0jIYim2kEHQVJ IfCkDNydaIdz16TdGRQOc2eham0PnqrQxS5X5WouzcDlxOHQoN+mSyCVHXl9MQ2ti5Dy 4xFxaPUDC67rAKqw4s01J9+qRN1UPPTfu2CYvKXfUCQ7yxqJ2akte30I1r/a7rgxiYCb Cjrvxjx4Dt49vpESiD18COeOQcY+jXA5Fkzj5i9suszOWn5pKL8b1KCutR7RNpBtuR6c mN8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FR1LNYFn; 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 hd13-20020a170907968d00b00782a1b59663si9748132ejc.891.2022.10.17.13.31.15; Mon, 17 Oct 2022 13:31:42 -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=FR1LNYFn; 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 S231374AbiJQU3U (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiJQU1A (ORCPT ); Mon, 17 Oct 2022 16:27:00 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4B017E83B; Mon, 17 Oct 2022 13:25:46 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id p14so12150089pfq.5; Mon, 17 Oct 2022 13:25:46 -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=pCDfC9IuoCSNDVn7a45aZdbsaBOFv8BIjFg1qCCcT9Q=; b=FR1LNYFng+AQCvWuGo7pKycSGzlM+nOufT5OULgoUpv7TxwUKFLoFGQ1PBu1TUboxQ cKfMi+XZCuXEiUYJYRkC+CRHS8K5My5bnBXcRnb8ADcQTVvNtlgrocyyxBeiv/bbURiD gKbQaae0HWZ7285WScdLoBRWOoDW+sGW/gTcN6/SSYtkeZQC/H5+0x037jkvDQPxscrX MVFh6LXIiYO+p3FoJ026Ixc6pWx3h4mx0Mo3qQon0W01P/7wO34ZuTABZPCG9dBvRZZd iERh6fCFGKCImdQZheraz9vYGFwmFIvIf+Y3XvzAKGcqVF3uvHE0V2j8rOq5X+V8Ls7b Wylg== 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=pCDfC9IuoCSNDVn7a45aZdbsaBOFv8BIjFg1qCCcT9Q=; b=1879IVVW3cnEs9GYIx35KgI1vvGvrPW3sT91AZ9D+KZdwOI9eof7caW0W1aUjX646v qkAEanrD4u8C5gCC2QiUIUcVXC2rC/Gsy594aH4FcCbrYlRE37w05kRdEJGlomFBTstd 7nR4MAKIDFH4KW9goVFVTXIs5wYURrsM8/A945T2kAb0LdqLzc5IM7JcFpMtb2pj/DxA hLelxUlx7PKZGT8OjQKbZrbSHf6+/F4YhR+5Ebqp6nhdtTHdYLZYmm7nrvcJZI/78bMm w0cQFf7fqzLHDSxtsgWhs49/Us6ZDVFOW34HRCt9s4Gr7ukPVxwvpWxDQXYTmfBrddhX kS0Q== X-Gm-Message-State: ACrzQf2sHx4JBf+7emI3teavm9n5NtFekPwXwTAR/3qufAdFt3dvb5B+ bH/80n+U4z16ugCZ4VydP6A5fEin/VLVlA== X-Received: by 2002:a05:6a00:4214:b0:562:67d0:77e7 with SMTP id cd20-20020a056a00421400b0056267d077e7mr14789856pfb.62.1666038309877; Mon, 17 Oct 2022 13:25:09 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:09 -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 v3 16/23] f2fs: Convert f2fs_sync_meta_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:44 -0700 Message-Id: <20221017202451.4951-17-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 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?1746968199089587161?= X-GMAIL-MSGID: =?utf-8?q?1746968199089587161?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). 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) --- 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. */