Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13798475rwl; Wed, 4 Jan 2023 13:17:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXvpcgVXuMMrZPD2O+aKXAmd9eb9RPIyNrjDW9snI4n7bckVJYu8YQttnQz8frGIeowx9IjI X-Received: by 2002:aa7:90c3:0:b0:580:9e9e:c442 with SMTP id k3-20020aa790c3000000b005809e9ec442mr8084978pfk.24.1672867021143; Wed, 04 Jan 2023 13:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672867021; cv=none; d=google.com; s=arc-20160816; b=o0HeY8uUAnR7zFcE4pVR+ud6VDEIFfvu7q2Rb2kvnECGuDy2fjQrR0qs5oCxjTTZKA mnSAlurmN86uXD4tFHU+kecjN9qQdjJl1QgPwt8vIh0OZlrgpHYzEKz5GBCgLTTnzHti 0rfRvt7k9RBe/rrMjK67PqvP+YTZ3doAMZqiMJBmQHW3pFSgj2PYdttWBYWkir2MnF3m I2HXuV73oSnj8K0izt9TnPb2Lpzt6gx4cmiV+YDiBmxHl6YaDwUdyBYhxxpVE/3p2vxC A+RvVh++VZQPWRgxRjiAVXNJOhGQnLuFMKKCiXsZxbfGqrtiUQlcdbYt+sl66D2renu+ UVLA== 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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=bhibHsFDQrtIT/UxVnj49cQoUmGx7rqScuF8l7JyWmuIf08BLtZSFC8dOl062pVc+c IQmUkCJzV+ujNNY5Z6o2lcGndEhScv80o7k1zuwof47rXcJ5SVcTZ03GomPatgVzfy5M KTbIAEIioLuBLnNfoH+ABTnocQLI0XjbOONclJg2JB77zKxoQ2SRx7e1rLHKbldkXO5C yJfQ0v8d+mMQPyEoWX+pNXR7HQoaTU0mtXqT8vCopWyeGQ+5ZEpdaCPKgsuRSPf9HQo5 cJ9wn+fd8HDmXHZUWGEnKPZ7e8rBmR5MqxjnMmnbDt3faUq/kyBIUC6mcxKWOoclaYAj R5SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E+BBLApy; 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 cp8-20020a056a00348800b005827af240basi2329019pfb.289.2023.01.04.13.16.45; Wed, 04 Jan 2023 13:17:01 -0800 (PST) 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=E+BBLApy; 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 S240377AbjADVPl (ORCPT + 99 others); Wed, 4 Jan 2023 16:15:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240313AbjADVPI (ORCPT ); Wed, 4 Jan 2023 16:15:08 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BADB1CFEA; Wed, 4 Jan 2023 13:15:07 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id p24so14704376plw.11; Wed, 04 Jan 2023 13:15:07 -0800 (PST) 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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=E+BBLApy3NOf4wopcmgQT3kNLqU1Hr79oQuMl3hR4qfUlPWmBHbnGAZdWjmWQ2sPqR KD3vqU0o08iqRQDMZ+Dx71Uxb6FKKwlTAVnatYSqFEFo2ql7zVbgfTN0jI5SnejCghpW Yp2dxAkOFXpIR/EP01TN2Qi1KZfVkx0gCM6uZyj6KEkdh1uwBHmlMJb1jYaj5mpjWFdJ YKq6x1i+oKVpuPiMkiFj7F6T2fVMDzxqmVK0DBQsS4p2ok35IbL+fj4QgWC5A6B2GSq/ rquvFqryD//D0fhKfDeCa0GAp4a8mm3vC0NMLAwoabxYnh/OEdzg2OeVrhSmFb39plUP r7zw== 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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=t7nILX2p8l6bVXm78dUNOvxGfqv1wPWPTXBT/Exrk0PBWriQQUqlhnUzmKzaD7xlPm S2ybHIAnCKE+wNJkjtYTJji4k55bqMR/WKstT0L/y6S21ObgnBp1Xhe0QDDHXGXBYbT2 ee8BF2484E3IiLsORP0kuCP/zC/ra0bggwcHQJHq0wO7HxuzYuVIrFmiPyDlNmKbFObX qCBHqT4ObvB8SW/xvc0+Zx4H4O6is2rpYrbNE6V3IZShGmebrzCAq4vqeeyya7gvDBc0 /mNlEpcYY7+nfdbble5wFuNp/fqtT9EvMF/5F1Wn1ZkDvAGR5DypVrrYhkJIQOd+RIR8 ZTfw== X-Gm-Message-State: AFqh2kpgyikS2s0flLIMmjvtpwp5o8kzk6HFmIyMjBgat2kzm/zBLdC/ Trm+p7I31z5CuaTVb2TMe+M1MlWAlM+Zog== X-Received: by 2002:a17:90a:fb87:b0:225:d81f:d463 with SMTP id cp7-20020a17090afb8700b00225d81fd463mr43386479pjb.26.1672866906363; Wed, 04 Jan 2023 13:15:06 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id i8-20020a17090a138800b00226369149cesm6408pja.21.2023.01.04.13.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 13:15:06 -0800 (PST) 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 v5 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 4 Jan 2023 13:14:32 -0800 Message-Id: <20230104211448.4804-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230104211448.4804-1-vishal.moola@gmail.com> References: <20230104211448.4804-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 64fbafc70822..a214b98c52fe 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2973,8 +2973,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; @@ -2994,7 +2994,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; @@ -3032,14 +3032,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 @@ -3047,29 +3047,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(bio_ctrl, 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(bio_ctrl, 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, bio_ctrl); + ret = __extent_writepage(&folio->page, wbc, bio_ctrl); if (ret < 0) { done = 1; break; @@ -3082,7 +3082,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.38.1