From patchwork Mon Oct 17 20:24:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629221wrs; Mon, 17 Oct 2022 13:28:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gZp791PefM2iE5YzgTmBe9JvYfPrqCPItEnFhmXFnQddEC7il9Qb/ILINEEjbeG9FKhxZ X-Received: by 2002:a17:907:75c4:b0:78e:176e:f62e with SMTP id jl4-20020a17090775c400b0078e176ef62emr10055288ejc.736.1666038499885; Mon, 17 Oct 2022 13:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038499; cv=none; d=google.com; s=arc-20160816; b=krMNUBLjizzRD3upM2Kjqjta/7STAP02lr2L9B870EAljgN5oJMsQoZ2mgcoAii7jf WkBffljPgMq9zkMA8dgQy1kaKX5q8rfIxYuGkfqjpgvcyWcIDCiU1krnX0Y3CX//zTmb 5H98Ojzc56PG2F5p53uM0xdQXPeov0vE5EFZ9gw9YZrJxw8E2nhWrAoyBsQfi+xbesUT Z4wOmVmZ+3AFCPZeDKlWMlwULOPj5Xz9ClfSpHlZhu7JVArX1ZaayTLej67Askbgu/Ca DALaKt4jprQ4h+uFrxFARfPhzedNAEbZkkljUEUqoTiv9TK48Z1EC7uRFSAH2oU2VrPP pIBg== 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=GbkaK1BhnmuuyeEPYHO1j/C42qAqDKaBYuSZ7EsnhRU=; b=usAUkRAyBKR1Pcck/A/R1xM5e2s4dA7sjhXMYYA0W0VFf4E1P31I5oqy9LPYnMxmO8 oFREdwrIYMYDElhYYhqxs1nGB5YsoBp7Au0zslcqxNSBFbZYMpPaZsiRaUJ9ZzVZFJqn mxdYPBJ7K1VnETs2gHcpI0H6B8jnNyyNyl3gritIj0nI35nkrNiSQzDcRFeHqpCfxB9L 8ZA5bBupzkg0K9ssjauNxrY8MvmyYyIRGk9n1AjGjDOMalNmMAeknMJxvGRhsv4Q7/1H 3ntwvk2Y68xpKY5iEeytRURku1uuQ/Q6bQL27Y67uI+6lrbY7U7Xc7Plp/J3MqW2Qqgy AHIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NQ3KvRSS; 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 hv12-20020a17090760cc00b00780e89ce0b0si10664426ejc.600.2022.10.17.13.27.50; Mon, 17 Oct 2022 13:28:19 -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=NQ3KvRSS; 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 S231167AbiJQU1E (ORCPT + 99 others); Mon, 17 Oct 2022 16:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbiJQU0m (ORCPT ); Mon, 17 Oct 2022 16:26:42 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3472434994; Mon, 17 Oct 2022 13:24:57 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id i3so12108454pfc.11; Mon, 17 Oct 2022 13:24:56 -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=GbkaK1BhnmuuyeEPYHO1j/C42qAqDKaBYuSZ7EsnhRU=; b=NQ3KvRSSCU8wPaTgediDqeAMel/vIah0+7k422IToZaKZI3bGfU37b14iH42kEU0X7 Qzi6EP9hjDaf1fqg1ZQFK32c9ILuCZG+zRyKOIFQp5ZQMoB2jLD4q1Gyr0WQ8mtE2qRq m8TScIwF6nHJLl980ya+Sr2hxZTVlJg4LpKy1hFXQBj8kaEyxSareN0Oky9YZM7BiaNw 2vWb6xBDZgHXAKHRWn3JDalz3e7jNZ/tPokjvwD0EzjqbULHQtABSVFlz/pa4stgqdUZ akBnIoIm5M5fDRlS5Fp6GmmllvS/DMn6w9C+Jv33XGjD/jl12SrDdjixrx8PhoYvdeEc +A9g== 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=GbkaK1BhnmuuyeEPYHO1j/C42qAqDKaBYuSZ7EsnhRU=; b=TQmPzW2b2x4kba0D8LlBoeDh2kaq3YUFE8YnKYHLHP8GpkyqxFBIdac+Q/J6hlrxKg M/A+ErL824+z7Lw4b25iykWlqbVOwOUSPu5S0m+UB1NKXQ1Uu6BuwRt8b6PUgLU2mB8G QKYvjOw28TQMRVdmJZfLg1rhKgj/5X2DhYokJmFeHyDVgYsun/Ch1oyMIWZJsrXUEQcB POiUQfI5asJxYX0NN4BIYPU5RLmcCJpzCYhytS/rLF6vdGgSzIshDxJvNkswYboCBrwW YpISmMr341fJUKkwbp+xP/6Nh2HtE53z9IZqdvkf0FbgIqKFdKdi0ZtXGLacRT13Mj22 qiXA== X-Gm-Message-State: ACrzQf1vtbJ2zxwUEdsv9GNqsumjhSpzHiOGL6WrKJTBfO07LGrN9YZG BikGluhLrJW2ozvE2lLRoLiwh1ClrLy+pQ== X-Received: by 2002:a05:6a00:230d:b0:53d:c198:6ad7 with SMTP id h13-20020a056a00230d00b0053dc1986ad7mr14548828pfh.67.1666038295539; Mon, 17 Oct 2022 13:24:55 -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.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:24:55 -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 01/23] pagemap: Add filemap_grab_folio() Date: Mon, 17 Oct 2022 13:24:29 -0700 Message-Id: <20221017202451.4951-2-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?1746967986388806007?= X-GMAIL-MSGID: =?utf-8?q?1746967986388806007?= Add function filemap_grab_folio() to grab a folio from the page cache. This function is meant to serve as a folio replacement for grab_cache_page, and is used to facilitate the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..74d87e37a142 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -547,6 +547,26 @@ static inline struct folio *filemap_lock_folio(struct address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } +/** + * filemap_grab_folio - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * + * Looks up the page cache entry at @mapping & @index. If no folio is found, + * a new folio is created. The folio is locked, marked as accessed, and + * returned. + * + * Return: A found or created folio. NULL if no folio is found and failed to + * create a folio. + */ +static inline struct folio *filemap_grab_folio(struct address_space *mapping, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); +} + /** * find_get_page - find and get a page reference * @mapping: the address_space to search From patchwork Mon Oct 17 20:24:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630239wrs; Mon, 17 Oct 2022 13:31:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dKkn4fg+L3ORokbhIqLkiy02fPxO92YkNqcjJeNJrDLdvsVkYxt7ftnAyCA6cKYA8uk+v X-Received: by 2002:a17:907:3f13:b0:782:1266:8c10 with SMTP id hq19-20020a1709073f1300b0078212668c10mr10011337ejc.197.1666038686490; Mon, 17 Oct 2022 13:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038686; cv=none; d=google.com; s=arc-20160816; b=oKa5wmfqDj2QNgH1SGNuz+aVrTJqxkuwFS5xd3OhK8G/+RRA+ChD9WrcWpcMlvm4Nu 7r2pBsEqesgu/APKWSwnIk8CTMjRNWPPpOmswpOtmv+utgTlw2PJC83cf8jvS4WDOy77 E8ZT2L1UvQHFw8CUXXvQjMBfgMgANByKTvpr0nZvo+Gl5PVN2AjZ5O3gAqnpiVrvo1hP h4l9yM+eu/ZkUVry17H/r1gaA6gHUIRmdi+/hnJNmGzu7UgOnIs8C0EcEro0kzVvaqpw tVGTLVR+V5KffK2xncdJNB+r6OZcbIKqR2TQYnA3/PadeXiTrNmRQtQJ3HVr1lCZP5Lm QFsQ== 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=iL1dJ1+HlDDjTxTgJeEvA/bk0AVphIHMY13JSDpQpPE=; b=miLnT84YMyOHYCIPNXqVQ/Rx3G8y/Rc7YMCOkiaVcnw0UW+CAZziuNGLVsLDzI0eB7 ZU1nZv0RUwh150YkCcjcMG8nnRIGJ/qzl3tlf9PxsqkhdUf6QhrtwzESf5i7/PLK/y1B Yohd1B0R6AHNHjX5dAjiBm0yy4sy5INRjZOb8sBhulRL4P6UeY6roXNr8gz0uYw96U0o bdpWxZ68JF2FTnlzC5mns6QlPYmv26ZlEdMWa9021Q83jkB3FW9k2r+SU3EGds6IeSdy ctD/i/a6yweLaPc75wIVU1QCo211IAAV+IioO53xCVJVQHP51+4HwK8lhdgNFNM29TBD aREQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=T2PyyDlk; 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 q2-20020a056402040200b004571a669230si8172307edv.469.2022.10.17.13.30.59; Mon, 17 Oct 2022 13:31:26 -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=T2PyyDlk; 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 S231553AbiJQU1w (ORCPT + 99 others); Mon, 17 Oct 2022 16:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbiJQU0p (ORCPT ); Mon, 17 Oct 2022 16:26:45 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96464399E7; Mon, 17 Oct 2022 13:24:57 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id a6-20020a17090abe0600b0020d7c0c6650so15372093pjs.0; Mon, 17 Oct 2022 13:24:57 -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=iL1dJ1+HlDDjTxTgJeEvA/bk0AVphIHMY13JSDpQpPE=; b=T2PyyDlkptXX08P0R0ss2FTcgqydLRmWv8uDLrgGaq5mTKgJ/us02bEe/BBTCH9sEn VgHiNn+EdlC3zxgxF+sscSbNXURHqrEPZaIe1RPlrW5+u0qSWgRqKr40/xbANBXmFg1h N1mSVri9e42lN3JGVr+UAHmLNz7otGMbXVDtSFCb4EodUJlvYpoJj8cf2WiW3564ILfR 9aKPvyyQuTy5ihLisAvNhV6PjDWXr4XNKAQFc4eHwCknIz7qHUllV5jMj5VWlUG6h7nG +lg6ZM5Kjl6gaQ08gd163fTmGuQCxiVYgmc+SyhQ5A+9+zFkk3LJGoUSdKcQw1lKYAQ+ lMoQ== 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=iL1dJ1+HlDDjTxTgJeEvA/bk0AVphIHMY13JSDpQpPE=; b=hJzbekrXTrIbeQL/XV0mis95B5C/3mZm2mxzuv5HW9Ql015JLcLv+Q4vVu6VYIoxYU o56eA+sKd2xHSqQSFfkwTrfSkm4TtNEgu/aSb9vZqGUKknCW2ZSQuiRCie3QDxRtnQVQ nATB6LtpvpIhg9vXYH46zBsPW4xcyOSnjbx8PI4tf/ubtjaKHdR8L/zqOBsSLtXllIAr V9m4OGojBbtCHe/j0xG9luXenLJfXAmqFR9/UBluQbD+xtSsxiGMvOQd+/ASr6X+cxLs +huAaTkAbjKG06DYmTGMSdhvq1BV60c9y0zip5cQWcBiML2NfPT/JPZBnpXExJMChWGs Zxrg== X-Gm-Message-State: ACrzQf2JGBWjrurugkjgumiAC56U5i+pBKc7oIiVmorbT+LER3D0q47U u2l8p3mBYbF4HXhtygXNj2l1TidZyTl/vA== X-Received: by 2002:a17:90a:8c97:b0:20d:a1a2:bfda with SMTP id b23-20020a17090a8c9700b0020da1a2bfdamr15543342pjo.234.1666038296428; Mon, 17 Oct 2022 13:24:56 -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.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:24:56 -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 02/23] filemap: Added filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:30 -0700 Message-Id: <20221017202451.4951-3-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?1746968181594075395?= X-GMAIL-MSGID: =?utf-8?q?1746968181594075395?= This is the equivalent of find_get_pages_range_tag(), except for folios instead of pages. One noteable difference is filemap_get_folios_tag() does not take in a maximum pages argument. It instead tries to fill a folio batch and stops either once full (15 folios) or reaching the end of the search range. The new function supports large folios, the initial function did not since all callers don't use large folios. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 74d87e37a142..28275eecb949 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -740,6 +740,8 @@ unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, pgoff_t end, xa_mark_t tag, unsigned int nr_pages, struct page **pages); diff --git a/mm/filemap.c b/mm/filemap.c index 08341616ae7a..aa6e90ab0551 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2262,6 +2262,59 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, } EXPORT_SYMBOL(filemap_get_folios_contig); +/** + * filemap_get_folios_tag - Get a batch of folios matching @tag. + * @mapping: The address_space to search + * @start: The starting page index + * @end: The final page index (inclusive) + * @tag: The tag index + * @fbatch: The batch to fill + * + * Same as filemap_get_folios, but only returning folios tagged with @tag + * + * Return: The number of folios found + * Also update @start to index the next folio for traversal + */ +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch) +{ + XA_STATE(xas, &mapping->i_pages, *start); + struct folio *folio; + + rcu_read_lock(); + while ((folio = find_get_entry(&xas, end, tag)) != NULL) { + /* Shadow entries should never be tagged, but this iteration + * is lockless so there is a window for page reclaim to evict + * a page we saw tagged. Skip over it. + */ + if (xa_is_value(folio)) + continue; + if (!folio_batch_add(fbatch, folio)) { + unsigned long nr = folio_nr_pages(folio); + + if (folio_test_hugetlb(folio)) + nr = 1; + *start = folio->index + nr; + goto out; + } + } + /* + * We come here when there is no page beyond @end. We take care to not + * overflow the index @start as it confuses some of the callers. This + * breaks the iteration when there is a page at index -1 but that is + * already broke anyway. + */ + if (end == (pgoff_t)-1) + *start = (pgoff_t)-1; + else + *start = end + 1; +out: + rcu_read_unlock(); + + return folio_batch_count(fbatch); +} +EXPORT_SYMBOL(filemap_get_folios_tag); + /** * find_get_pages_range_tag - Find and return head pages matching @tag. * @mapping: the address_space to search From patchwork Mon Oct 17 20:24:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629956wrs; Mon, 17 Oct 2022 13:30:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6aAiEnZ5o/FW3DrFirMRVaeiZpL0pRq1JB9bwX3tMtHp0K0OX8oNQz6Y7JZ97fELKoBOuP X-Received: by 2002:a17:906:fd85:b0:77b:b538:6472 with SMTP id xa5-20020a170906fd8500b0077bb5386472mr10033261ejb.48.1666038644062; Mon, 17 Oct 2022 13:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038644; cv=none; d=google.com; s=arc-20160816; b=A7HvvsK5h77RqO0aJXbcOJeIu4RnVh+Cmg4YHNNVpO5OWs7S2fq2Du4X4N6vmUykk5 HPrvJula74YHwt1xZFQeuSpf06XhXFWv+g8o3jqprgfipy+aV16N3QAgtKBAS4NWZdYH wcf/igRF7zNpIJsqzJzAUm/7PVxLQuoCHvutMrVNsDfxcFm7q47HSgi55/J3YpyKHVnk K86NHjas3O7fZY261vvngrAU8O9kNLJOazyqDWIs8/tkprA7ikCi9p3+SYL+1hSdEyjw JbCFFyx7AHHXa5hchSUUvg8lX/q+Ax/Z//gztZ+iqX20qy43LN9QewmtljycnWhJwRhJ NxGQ== 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=QZRdB+dZmNtA32T+cQHDMYonPyYz7jjivtFD0eVIJJw=; b=JeGN2otpOmHWA1wjPhd8xc9Szuq0rl840sohGIxCzqHErJoVyXXHE/9SzLsXwaR9b2 NX5KPOn4E/1/B9N0AFTYpITtzy6IRj4IeI0aKVvLoupbmFDf6tE31xs32ILroO2x6Qbg pg1ikNTUdTAe+SkJZvIMEJaiSjkvgqF6YBntbwbc1au7fMVlQXr5Q2KarwYrsa501gds HeMST7XX/zxUayF38LEqdOBBIXKVKdamtNCWxiyQ3Za4jHuWHDxGswn1n+6u4E4X/K/B 1xapRCuLiCZsNaoJwW6ZjZCH//kKxVihgUOFoZPUimBpiOwURAVoTRFYwn2+1e49bse4 5dlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EMG8zUe6; 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 h21-20020a056402281500b0045b293121f1si8391799ede.12.2022.10.17.13.30.13; Mon, 17 Oct 2022 13:30:44 -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=EMG8zUe6; 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 S231812AbiJQU3A (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiJQU0x (ORCPT ); Mon, 17 Oct 2022 16:26:53 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F041C7E011; Mon, 17 Oct 2022 13:25:27 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id f140so12143506pfa.1; Mon, 17 Oct 2022 13:25:27 -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=QZRdB+dZmNtA32T+cQHDMYonPyYz7jjivtFD0eVIJJw=; b=EMG8zUe6nj+OzUpxpcc6vz9egeLlNxWJFwjbuAX7cIf8UVozlJc16RJgVW6MmHr8wj lAYPDYX2mCzW8yaHilBBcng/MkEd3zQadtzIm4aJed/L2hmaKukav+bbHe5lJaIq8Cmg 0jCDF+tjRM5z3mhRWX4Pz9YQeJePTcm5XXkFfwT7bZ3hhjUxBBExa8JfvRa7z2z1eEE8 aa1Z+xdo2jBQyaNl3srNu1X1eXAZfvMUHpUQQgygrIgkLcMnTlgBOGGoIPFtqd0FKlwi hsEHCzW24ByTmgfjer1ioe0J81eAgCS681a1EYbjZkADJzINZruwqE0d8CSsY1eGT4Gg 1ZFQ== 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=QZRdB+dZmNtA32T+cQHDMYonPyYz7jjivtFD0eVIJJw=; b=Whr4RL1dJApmuUnA2alXFEqKwHjQdyLfvvXwAWNMjD684qJOLnY/l9WtCEb9xT0FIv IiavW/wCkPATtR4cX7GhTuLzP6HTFeyX82LZhiKlvrlGvMQ45/vuKWFK9+yVbvV+hYnK iGgTisAVo6KEEIAYUwrLjXpr8TPJh7jYzka1tYuOg9EUp20EVxS3NrfwnEWhUpMiddQ1 f+GTcwx52S32ib5cd+u+VIKNZdOUqWjMqv7ylcCf6wMlhodVYWh14wKqkG9MGnIASvhp a4nnqHdvxuqheWs7SH2QECraWaFY/3XMiP6fJFmgEGznFKD2IErwwT/Sl/GrUQK0NzUl NKvw== X-Gm-Message-State: ACrzQf09RdUktVHNm6HV9jQuo873sh758LOZwzaSdihDPPsHkPLABtii 70h1GWjx9KWtpEbEMu0c4P52mln8QPNP9w== X-Received: by 2002:a05:6a00:c86:b0:563:b89c:3d0b with SMTP id a6-20020a056a000c8600b00563b89c3d0bmr14629107pfv.50.1666038297319; Mon, 17 Oct 2022 13:24:57 -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.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:24:57 -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 03/23] filemap: Convert __filemap_fdatawait_range() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:31 -0700 Message-Id: <20221017202451.4951-4-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?1746968137318263828?= X-GMAIL-MSGID: =?utf-8?q?1746968137318263828?= Converted function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index aa6e90ab0551..d78d62a7e44a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -503,28 +503,30 @@ static void __filemap_fdatawait_range(struct address_space *mapping, { pgoff_t index = start_byte >> PAGE_SHIFT; pgoff_t end = end_byte >> PAGE_SHIFT; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned nr_folios; if (end_byte < start_byte) return; - pagevec_init(&pvec); + folio_batch_init(&fbatch); + while (index <= end) { unsigned i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, - end, PAGECACHE_TAG_WRITEBACK); - if (!nr_pages) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + PAGECACHE_TAG_WRITEBACK, &fbatch); + + if (!nr_folios) 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]; - wait_on_page_writeback(page); - ClearPageError(page); + folio_wait_writeback(folio); + folio_clear_error(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Mon Oct 17 20:24:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629531wrs; Mon, 17 Oct 2022 13:29:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7r0IoAbKAjAGfLK3kOQZmBLdZ+rvf3Hu6PLrgzF2lD7a83EU355UEPpneQUcl4GIpvHmvn X-Received: by 2002:a17:906:65c6:b0:73c:8897:65b0 with SMTP id z6-20020a17090665c600b0073c889765b0mr10179659ejn.322.1666038573223; Mon, 17 Oct 2022 13:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038573; cv=none; d=google.com; s=arc-20160816; b=KKZORMaAqfTHPZK7fFa/Gxwq9o1yREEiXyG4NjtVSmp9zxrPZTxIjIDo6CfirpPYYH 2dySGQT2VDWfXfzgNhRYsJBlCnSLkkH5u3RYXcGqHcmdLMq8By93FadwWkDDKA9NomkH JWPALi68l2CjDSYygNxfB7A8Xpq5XV9JWj0Zz8b1QyW73TqG+qk2srZt8MZ2kZubI3u7 EizXTyAFzYpcct9EIovYxWx2HDdo2vWgGnHgnMCCHEU0T53aJ9CtDRJwzeKE9Kn9lvcc YOJW5y7xQH3tqLh4I19BZEyTHUFkuYEnxBoTS7YDQ9FuWDraBlh0Zqhn3icGJk8fU6uS Gfng== 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=Djg16035gM5p4sGWRwaRPAJ04PvNuws/dBsvoNLi870=; b=jSt7Zk6226FsokPra9mnX95kvqyxoh38BwIlLKzSziPRzLIM1gwAbgFx1MGWhE1qBs T0sbcdnVkjq8OhKsFVT4pEZcwomAM9kTXBBvJYM7jZsfW4mncmV3fZ9W8+4i5v1FslJC evqgPIMv1O5OLrAoq7y8mzXp94o+8zrmqmMTg5ySYfuUKSj9d02iCQ4YgDKqK7aMaoR+ R3OzOOW4EPqdYogl2We3fhJWQfaOMxPCyV0syKAfuI08GSa/OapRyOXmNsc9dXlO/BLE lhPk69nIYmz1k29iAgY7KBCKDRZZbWN6/YjNLhQIeEY6yTzbO9Azerv9aPyi36HF3+f+ Y3vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m2ykFBut; 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 12-20020a508e0c000000b0045d02c98c3bsi8486982edw.301.2022.10.17.13.29.05; Mon, 17 Oct 2022 13:29: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=m2ykFBut; 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 S231600AbiJQU2L (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiJQU0x (ORCPT ); Mon, 17 Oct 2022 16:26:53 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0257D7E012; Mon, 17 Oct 2022 13:25:28 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 129so11456375pgc.5; Mon, 17 Oct 2022 13:25:27 -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=Djg16035gM5p4sGWRwaRPAJ04PvNuws/dBsvoNLi870=; b=m2ykFButH5DCs9UiZXZhGomBEJhgTu17N1oM4zXEGXbTg9IQtUH0NbbzFAkFW2esz3 nnpPJi6pUNONDjhNI4Y4RiuyXTibQAQYFV5KeKrbC/Yog7oxEWPcIRzdbVro5Up8DX/e ySYprp3hrV1L88vio3YXgr/bcbV1oA3JtekwIoQzcdh+E47v6inH8Z8COzdK40BsEaIi HvyhzLLAKJBZzywyL4Wpy/b8JdeM/8cDKOj1owvmG8RYMWR1zMonMAQ5MWJNLnUQi8NO wWXReAMRqCOUU+8mtr4dyMFEA0VkSoB2Usk5SYSWUXONQr45zm4gz/IggsL4MBJ6RHKX CtVg== 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=Djg16035gM5p4sGWRwaRPAJ04PvNuws/dBsvoNLi870=; b=eOL93MrBcO0UFRa8hPgasyDtFsuZIFGRUd/5n0hcG89f8WF2H7F9Ryu3KCI0Ww+ExI 11fT7MI1p5hqvgkzjR3bpQ85KfacnWWRPKlkWVw6tnPW7sqS4JhVnsUiAB4fi4mpz1jS P7FvbQ+jEol/DDQLn/uy8JxUhN13uLXLkzPi3j1ZXnCj+LVk/pQ+HLNIM0YHpGjl3iLQ aNHMu0fvtNxtigtL4pjd+6o8UyZzT0WiJASgTiKesEzhm6bHUUmXx8cFpBFd40iJ1RlK uBgJBeYaClyjWhal1roNJTvhSpjJFkTefFpcDSxRiIT+BpmwNmg/3Nz5DeNTo12VPf67 ZSnw== X-Gm-Message-State: ACrzQf2WkNVvyLnu0u04hEqv+cgVj+WflMauEqrXzEKGsIZY/AV6O3L3 v9v3Xh2AtZEW08OYLu63IHmWef76bjf28A== X-Received: by 2002:a05:6a00:3202:b0:565:c863:78a1 with SMTP id bm2-20020a056a00320200b00565c86378a1mr14441253pfb.7.1666038298287; Mon, 17 Oct 2022 13:24:58 -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.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:24:58 -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 04/23] page-writeback: Convert write_cache_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:32 -0700 Message-Id: <20221017202451.4951-5-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?1746968062969295686?= X-GMAIL-MSGID: =?utf-8?q?1746968062969295686?= 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) Reviewed-by: Matthew Wilcox (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 7e9d8d857ecc..aeec8b196232 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2286,15 +2286,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; @@ -2314,17 +2314,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 @@ -2334,30 +2335,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 @@ -2372,11 +2373,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; } @@ -2396,7 +2398,7 @@ int write_cache_pages(struct address_space *mapping, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Mon Oct 17 20:24:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629520wrs; Mon, 17 Oct 2022 13:29:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7M7b3SDP8zhnITyv/EjVb7gDwNLZjwRcZRdmsWzXF5a+qNCAtG8yXsywyFuVx87ALUw18B X-Received: by 2002:a17:906:99c3:b0:78d:9cc9:deda with SMTP id s3-20020a17090699c300b0078d9cc9dedamr10195200ejn.712.1666038572434; Mon, 17 Oct 2022 13:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038572; cv=none; d=google.com; s=arc-20160816; b=IqI/ih5fG15L0hCqBknsKF2GurVazxG+pv1LBCGKOr6qXS3uYDHXBowqjnyCmjYY75 vgJbGq0Ey/eBkdUPemsAD/cqoImUOYIMlTW31K2/cKMk8YgfSpgdjBbV4g4/xWWXLYpm toCzRVxz0Hanut5N+4l7642q/QGJewz3Gq3P5c6BLMV01MDMVJG0b297yJ3U935C7iX3 Rx9ltkzQFjCG44MSeTovvyeH2SwIRv8goHRDYoisOI6XFV3P4ONBnynfaiTIAFWP8VSl 7NWOelrs6dJbzqOCkl0t6qDIuqCbTYxi33kQ1dzYKwG2JEoxmankjT2X2QIUDjF+1Z+C H3rQ== 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=wBY1NrBIv9xetMKdetRJVFMD/fis2/cKbUx1OxFOf8Q=; b=0M0uNYX0zWdzh0O0h6ccPaq7BaKIi1MA8g4LVbhOPEZO4AzS7nl+wk6t70MQnJXQ+o Q1fHRUHcAwsAwaP2VGx+8RbWD3FgDyfGgwG0cjB91A8O7ITh/LmuqvoGgWsL3dwIlsuB c0re/wOEWt3CEB9+TTIzoWgZ1H0G2dZB5On+1dv+TFCfQSokY2FlrhfiwNh8U8Z+wGTy G3NS8TI6+cWVesdVL4Pr0I+Mqeb/NvaMYddNxhMNDOsX/paIV+uMctbzWkuyk6XzYkFT 13mxGwCdlFP8o2bsK9yHnQE1/XCqVvWzrcgZ6s7XgobFWm0761cpWHOyPNH1kP8DZ3/w Nt8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MWt3X87H; 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 12-20020a508e0c000000b0045d02c98c3bsi8486974edw.301.2022.10.17.13.29.05; Mon, 17 Oct 2022 13:29:32 -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=MWt3X87H; 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 S231527AbiJQU1u (ORCPT + 99 others); Mon, 17 Oct 2022 16:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJQU0z (ORCPT ); Mon, 17 Oct 2022 16:26:55 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6BA47B291; Mon, 17 Oct 2022 13:25:30 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id 10so11871859pli.0; Mon, 17 Oct 2022 13:25:30 -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=wBY1NrBIv9xetMKdetRJVFMD/fis2/cKbUx1OxFOf8Q=; b=MWt3X87HmwhMmLHuEolcoErHJ8+cnb0qejVEhB4UK228aRdmlAOEshJVcQq6SimLXJ JY9/QH0hMx5/25hlt9MTwbDJumVPAHhKg/cCm8WuVuUFy+I+u48SO+9tpN2iCm5KZKEF xo/ONL+jgXeXf3TipVML2Zzj4cnJpuRilibE7T+1XNYePTjGRz+T9vKG3vw+o3+bvU6/ a+c9PKP+odj8q59fBj8tZTCKw/d/gNag3lEKGBmlFbH3mLui2bpCo2Buwa4jcmTPRkLP 0HnXfKu3eDv3UIMGGEuUq29e3raok2bt+fHu5v9GbA4cVQqJd98ycuMa1CZWo4Ustdcx TgdA== 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=wBY1NrBIv9xetMKdetRJVFMD/fis2/cKbUx1OxFOf8Q=; b=IOwWXkZ4mpNhvNVQIQ5C7oSIV3zUDnGBYakWQ0IHmwHh2HAvQFuQxzeUo/KZTjLFcO I+EFmte0jREk7b2jghjsWyn0O6JCjDrb6e54dd0Uypk10HVmrA24F/mCgw2RTX7MRERY ZsoC/yOHl8noogHzHu6hb2cMgU5S/z8Rm7FDoR3WHkumvkgCoV9veAUEWvBPD0jfFTRG rHOMdPCcjcK4WAzMrTFLR7DBoJIWNeW5TOzHhuiFi81obheM6XDV93pr5FU6DSQhjr6W AevJc3SsWkebrqUrkaGV0BV8INaZW+NgUL2iK6vi0ZGFCD5p60LhiKK2fTrrX7UZ3R2M QR2w== X-Gm-Message-State: ACrzQf33bHqG6XQlH0ak5MSkP6pdY8adG7RfqJbs0YpSrGNucFi7i024 a5eNIQDlYKiEEPfHT50Uy5WwlHI/DpRWOA== X-Received: by 2002:a17:902:c943:b0:182:f5af:40c5 with SMTP id i3-20020a170902c94300b00182f5af40c5mr13511810pla.72.1666038299406; Mon, 17 Oct 2022 13:24:59 -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.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:24:59 -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 Howells Subject: [PATCH v3 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:33 -0700 Message-Id: <20221017202451.4951-6-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?1746968061773911211?= X-GMAIL-MSGID: =?utf-8?q?1746968061773911211?= Convert to use folios throughout. This function is in preparation to remove find_get_pages_range_tag(). Also modified this function to write the whole batch one at a time, rather than calling for a new set every single write. Signed-off-by: Vishal Moola (Oracle) Tested-by: David Howells --- fs/afs/write.c | 114 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 9ebdd36eaf2f..c17dbd82a38c 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -699,82 +699,86 @@ static int afs_writepages_region(struct address_space *mapping, loff_t start, loff_t end, loff_t *_next) { struct folio *folio; - struct page *head_page; + struct folio_batch fbatch; ssize_t ret; + unsigned int i; int n, skips = 0; _enter("%llx,%llx,", start, end); + folio_batch_init(&fbatch); do { pgoff_t index = start / PAGE_SIZE; - n = find_get_pages_range_tag(mapping, &index, end / PAGE_SIZE, - PAGECACHE_TAG_DIRTY, 1, &head_page); + n = filemap_get_folios_tag(mapping, &index, end / PAGE_SIZE, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!n) break; + for (i = 0; i < n; i++) { + folio = fbatch.folios[i]; + start = folio_pos(folio); /* May regress with THPs */ - folio = page_folio(head_page); - start = folio_pos(folio); /* May regress with THPs */ - - _debug("wback %lx", folio_index(folio)); + _debug("wback %lx", folio_index(folio)); - /* At this point we hold neither the i_pages lock nor the - * page lock: the page may be truncated or invalidated - * (changing page->mapping to NULL), or even swizzled - * back from swapper_space to tmpfs file mapping - */ - if (wbc->sync_mode != WB_SYNC_NONE) { - ret = folio_lock_killable(folio); - if (ret < 0) { - folio_put(folio); - return ret; - } - } else { - if (!folio_trylock(folio)) { - folio_put(folio); - return 0; + /* At this point we hold neither the i_pages lock nor the + * page lock: the page may be truncated or invalidated + * (changing page->mapping to NULL), or even swizzled + * back from swapper_space to tmpfs file mapping + */ + if (wbc->sync_mode != WB_SYNC_NONE) { + ret = folio_lock_killable(folio); + if (ret < 0) { + folio_batch_release(&fbatch); + return ret; + } + } else { + if (!folio_trylock(folio)) + continue; } - } - if (folio_mapping(folio) != mapping || - !folio_test_dirty(folio)) { - start += folio_size(folio); - folio_unlock(folio); - folio_put(folio); - continue; - } + if (folio->mapping != mapping || + !folio_test_dirty(folio)) { + start += folio_size(folio); + folio_unlock(folio); + continue; + } - if (folio_test_writeback(folio) || - folio_test_fscache(folio)) { - folio_unlock(folio); - if (wbc->sync_mode != WB_SYNC_NONE) { - folio_wait_writeback(folio); + if (folio_test_writeback(folio) || + folio_test_fscache(folio)) { + folio_unlock(folio); + if (wbc->sync_mode != WB_SYNC_NONE) { + folio_wait_writeback(folio); #ifdef CONFIG_AFS_FSCACHE - folio_wait_fscache(folio); + folio_wait_fscache(folio); #endif - } else { - start += folio_size(folio); + } else { + start += folio_size(folio); + } + if (wbc->sync_mode == WB_SYNC_NONE) { + if (skips >= 5 || need_resched()) { + *_next = start; + _leave(" = 0 [%llx]", *_next); + return 0; + } + skips++; + } + continue; } - folio_put(folio); - if (wbc->sync_mode == WB_SYNC_NONE) { - if (skips >= 5 || need_resched()) - break; - skips++; + + if (!folio_clear_dirty_for_io(folio)) + BUG(); + ret = afs_write_back_from_locked_folio(mapping, wbc, + folio, start, end); + if (ret < 0) { + _leave(" = %zd", ret); + folio_batch_release(&fbatch); + return ret; } - continue; - } - if (!folio_clear_dirty_for_io(folio)) - BUG(); - ret = afs_write_back_from_locked_folio(mapping, wbc, folio, start, end); - folio_put(folio); - if (ret < 0) { - _leave(" = %zd", ret); - return ret; + start += ret; } - - start += ret; - + folio_batch_release(&fbatch); cond_resched(); } while (wbc->nr_to_write > 0); From patchwork Mon Oct 17 20:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629821wrs; Mon, 17 Oct 2022 13:30:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5JWgtdyNscUdnMKjhTVyR9AdRdK0vKFV/A92QkzsupfOVnTurQpe5o3VSlbb4ikODY+dPO X-Received: by 2002:a17:907:970b:b0:78d:8d70:e4e8 with SMTP id jg11-20020a170907970b00b0078d8d70e4e8mr9778325ejc.614.1666038622862; Mon, 17 Oct 2022 13:30:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038622; cv=none; d=google.com; s=arc-20160816; b=T2Q3xgp5yW/j7jLYk2IbkPtF7Du+We6ALKwGsGFrI7W5E/XfBWWc2fs0h+eXZuWrDt 4cW5KIOXUQOq1JcPWZe7vbr1lIFQAG5dTj2hVESq1Cw2Xw2weFKKwlZMuoMuXlMk1/Y3 kRbGKJz+P3oHrcapngiBZIgrt1LJXzbFkRQXUj4FILeWJcAMzPGsZp/9stbK+zPgO0fA bs5MbMihVSWSBd5n95KnHiNwJwNgKlLyWU9Y4TQC182zr68K1mkpvN8nBOqKjiAxwUDF Znqj9jd8MVD9dAPV1vMwEJNoC4D/XT3v+Sx3Wdl7AiULNuspGPAsp/4nevglWMY4JBfV ZThQ== 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=OszXCtyBAOhtTfNS2VcED/PJCoIEbwhBnrXkCjtJV6A=; b=whKNGm/8LmwcBPhoUVSOIO09T2U7bzkv+31rhstQdd6J+i3+GuBEMKiULM4Uv0kIuU UjXBU62kwICqWpuio+H0hSHF+boJl9Av6U+DS2Bxatl+TRKWKPd37HJCYN5YPuUUCmpU PoME+Zc0o+6sASIZv+znPHn6cmIP4yI09hoACQg02guflux6aPhLqzIKkKwW7+G6nMVa w7cgP45cuSaZSWB5ivC8SkSPhsjBmWz1Z1J+UXbarDAC+25c4CRThLYdq2h4c87+dxvQ BJFUQ5BhOmc7NqX1HyiJrmHki0XgG5FfuVfUyJPmNiIlMTYzHJvKcr8HxGRTSp10/HLm 8pSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DlogKpHG; 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 cr12-20020a170906d54c00b0078e2bbd67b0si2674985ejc.36.2022.10.17.13.29.58; Mon, 17 Oct 2022 13:30:22 -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=DlogKpHG; 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 S231751AbiJQU2r (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiJQU0y (ORCPT ); Mon, 17 Oct 2022 16:26:54 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED4137E30C; Mon, 17 Oct 2022 13:25:30 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id f23so11819492plr.6; Mon, 17 Oct 2022 13:25:30 -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=OszXCtyBAOhtTfNS2VcED/PJCoIEbwhBnrXkCjtJV6A=; b=DlogKpHGuzxO+jQRFtRTRFNBhcjjfosVdGfz4vShoT5jbOvLmiulTdcKtHEFGwz5vi lfN8CyIsdDsnzLwlPsrwSNu7A69s5Fy0qqRQj2nA9AGm0yWGFBOpq6+hyWMx+nCdiEOf HOWv03XJMaxBzb3v/k5D8Tkgw8Rsjf1L9diV61pFglGBB5j0nFSq0gT1h245hSzueZGw Np3EM/UvXHrfuYbzgwORQStqJotyQYc3vhFcPkD+Oz9PUmc3lvU5n0m6WUynYqD8tTw7 UZB5z88hHxb4eP2oFj6wehPTurmZRyd9zSlH8SoJqpqYDPStY4oaZoe1q3QYLoKSuu0H QHYg== 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=OszXCtyBAOhtTfNS2VcED/PJCoIEbwhBnrXkCjtJV6A=; b=VQYDcRtPoQlwc06AWMRvrJlhxwAErbozmEZalHh/B5hlgN4A1QKvLZBslvmc4e2I6V asZLH2ywkGCXzXHIAqF6Ofbc/hVKlgNt5NWK1Ch0ZzbAyD0mKM8r5qrL82NtOawVMOu1 EhwlYLSHG+dj3kqSDFm1S3SERz4QL+XhlJXpwpCrgiwqnaijFJPc3ZxqiwMsCrJ2Q/ub nNXc/lbmNkPnF57d0CZeWrDkqcWPauYYiBGwKEQKUjn9jVDICawTjb1oaglUEzMILBjg +IiMDv3vJ4XWekNldQc+0r5FW727Fq2J/OJ8bkEakyMQMcj8bMgmj0dZN1Pv+XU9KMQZ JXIw== X-Gm-Message-State: ACrzQf1+YjuStaAR144kOolSf5Ub3rgSSsHGUq/x8nRM/yN7Firtsi/J /SNG/TWwIJFmsm9BREKsGu8Spx7eHFGmLw== X-Received: by 2002:a17:90b:3847:b0:20d:c41f:de7a with SMTP id nl7-20020a17090b384700b0020dc41fde7amr18478400pjb.85.1666038300344; Mon, 17 Oct 2022 13:25:00 -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.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:00 -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 06/23] btrfs: Convert btree_write_cache_pages() to use filemap_get_folio_tag() Date: Mon, 17 Oct 2022 13:24:34 -0700 Message-Id: <20221017202451.4951-7-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?1746968115313992107?= X-GMAIL-MSGID: =?utf-8?q?1746968115313992107?= 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) Acked-by: David Sterba --- fs/btrfs/extent_io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4dcf22e051ff..9ae75db4d55e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2960,14 +2960,14 @@ int btree_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 */ int scanned = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -2990,14 +2990,15 @@ int btree_write_cache_pages(struct address_space *mapping, if (wbc->sync_mode == WB_SYNC_ALL) tag_pages_for_writeback(mapping, index, end); 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]; - ret = submit_eb_page(page, wbc, &epd, &eb_context); + ret = submit_eb_page(&folio->page, wbc, &epd, + &eb_context); if (ret == 0) continue; if (ret < 0) { @@ -3012,7 +3013,7 @@ int btree_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) { From patchwork Mon Oct 17 20:24:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629953wrs; Mon, 17 Oct 2022 13:30:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QiZejIBGica0Wd9VxNByF0/rWblYOqzM+uhQGZxLl/36byqU7FnHMyAHyTq89WWLB6QCP X-Received: by 2002:a17:907:2cf1:b0:78d:cafc:caba with SMTP id hz17-20020a1709072cf100b0078dcafccabamr10256440ejc.154.1666038643199; Mon, 17 Oct 2022 13:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038643; cv=none; d=google.com; s=arc-20160816; b=0UoVpNze4NLzt2fi/wOWV/mB5BGduMYAYVcmngI/U4sFyhlynw2XWMf9FCgG0LiHI4 VyXd1ikotTv4CA61m1ie5FN33X0ouIFFkdmdusEJRD/x/U95ODNaywwjekfkWLZOE+pJ IMkX7TESubsbWpLaqj4j4u7el4OmzzbX+K0Jgs6tWWvlLJS35vyPDOA3wIkJl71Azxvi 3cj2G8i1RUEArsKN906yAbIbjcLvSv5/Xan0MJYh+PecHC8qsWIz9jzR+DMwJEbHO6ij y5GB6V1IDbwtWvZZtkhUikFHEugg5XBIQ1i71G5zFQgzkbw0Wjzm4NBROrREyGiT6LaN 3XVg== 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=zeUurN6z83YfDm42e0hrtviCwMIWVJkZ8FVY/6tmNDUXlz3jIaBgNxfnQzU5biFylL l4ymIVN3WCNhgzAwTIVzWSxITaYBAXA9eW324iRgAB81g5WfFPYMtMKq7DMXOgQCRF8W Ra3lHcBpv/A7YI9SDnguprUWjEzzdhq7vD3+TFXvx8Ahu1QjUvvAfEQpKlO2uVmWaMJj AV3uq+bw7XNg4xIIki19tyTxJb3b55K3BlldjC4ZCARRomOxfDV5QZT++DelVOioiFaN mE/dJdau4Rp1KLcupiO5vqG+ExIYECFsocZn70rZz6XjhM2nP1aqhTAXZFXAPt8dupCt CY4w== 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-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 n12-20020a05640205cc00b0045c29d74fcesi12244404edx.568.2022.10.17.13.30.13; Mon, 17 Oct 2022 13:30:43 -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=aG3SJg4q; 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 S231682AbiJQU2g (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:36 -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 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?1746968136137199432?= X-GMAIL-MSGID: =?utf-8?q?1746968136137199432?= 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) { From patchwork Mon Oct 17 20:24:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629839wrs; Mon, 17 Oct 2022 13:30:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KdIg3RRp6jOKxMFHu/Y2bjatHw+7A4kb+MgOn/8cSzeqy5EjAMp/HRINcsCGQn0aOxZ/7 X-Received: by 2002:a17:907:1b1e:b0:783:8e33:2d1c with SMTP id mp30-20020a1709071b1e00b007838e332d1cmr10154325ejc.304.1666038625740; Mon, 17 Oct 2022 13:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038625; cv=none; d=google.com; s=arc-20160816; b=c4fLr3X1L00qA+sX3YtubyUlAbz6m9xyh3nLnHP5cvK2JZakV7ZMCgg/2TKXH5dDKY LXYqdjgtdrMe6Z0kRF2Scoy6+ClLjCR37oRTL7UZ0Y5eZTgx+Mh+rF0qK3co3B7u3c2a 3+F40IbwgoRxhK2Y6ngK+ZMQJ0E+36UluSyOKWrHhG92HguzL2EjinLzVsQqRKNraKXA wXMda1UHKi7m4Pc/dP+nYqkfj7VgCLgaZ3nSHRXytcKQaU4fbEflQmDzIMyvCf3US9qH idu9lvCek/E+MJbIbv1tNslEVM2oZLbYUzpd7xWnIbhbugpnd0exIz1a+F0d/NoGD3kB d0lQ== 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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=qyfNfaAE9f2igpMT4TqFHBnOvUzTOoO0qQqYRv/Nme61ag12L2W+wUjquwq7sDFPU1 GBt50fEsmasOLiI/UuTMHlowc6WMJWv1lC2BfD+nF78ZLd/TOD3eXwwwA5gsT0eIaqy+ GZ0Zn/ZLbCh5IuwmeJAu8CbDXvGo8wgKNAnSvZQhOayP3PTkRRvt7kjl21rzSPJKROEv gkW/fRCKzbtx0cXoGcb6NiEiR9aYwAtGGQzyUev3LOPzrEFM1wdGkvAzXQaPgUDkpxpK 24lcu4ay+4Y90tTh0lnMtwYlgMrtDCRl+sbHU3rkXsXfuCQAnDq5wl1TydeCQcrCSFE2 KEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bA5Qe50y; 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 nc23-20020a1709071c1700b00779f8e7ec5bsi10454505ejc.42.2022.10.17.13.30.00; Mon, 17 Oct 2022 13:30:25 -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=bA5Qe50y; 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 S231779AbiJQU24 (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbiJQU05 (ORCPT ); Mon, 17 Oct 2022 16:26:57 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 147AB4F393; Mon, 17 Oct 2022 13:25:35 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id h2so4465571plb.2; Mon, 17 Oct 2022 13:25:35 -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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=bA5Qe50yNj5Q74nC8AoJWbqxD30sNHXDZRSZjLBU2ggQFOqnFMYZOUdCpT+mhZ+lq2 faSlXwHIGonCA6fUpkF9TlvUtgw/q6Heb3/ZnncPeVsTRrFgCXZeF4p/xm3lRedvgw3W KKSZEuRHBFegZU8TkJCDKngUK1I8Usc/cY0HM7AG/2SXrG2rKfhT3xuYgfj86S9gbCSX IrGZrOKnzQR/yeV1HdzoBMkIs+Ea1Mg1RHmC0magT0MuqnjtiN78JLLz1516GfpIZ1AG tKmy+RCLo5bw3oF7LzYGH6a8yDVV4MfZAq+1BAkjHVnMGsbgv9qe4Ucppkoa20qwLXUS BCSQ== 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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=FtNCzYwSqPab/TYKK0it2xSw0vN+gcqV70buT+jjF64FCRSeypL0C/25kyw52dFvX8 gxXfwwfSk9i6OBOcqFwCemgkyXXQjAWVP6Pa4aroOiOiQeXTBJxLQW9jA2IdBNz0DPav yUzfWcx3IyAeRFAZWZkKDaumNj//ClG4koNyF1Ez8nmbWMjlPQ+zwvGwAtlt0CjTNg1E Ryb7Cck8AHx9LChZIBmcH3B6wsNaQktVMN1Qytct31OZS+jARXc2yIL/MqIz5K6SkFfY lD6Uwu9TSWrOWhSEAHdpCimDUpJyfKHjo63l+sFH+RPQBv0drwcDTOZbdS/Qft1d9BJm WkoA== X-Gm-Message-State: ACrzQf0NxmCsg2ZnLKWMc6Jogwyg9I15jB6xFxhw9qxYU3YCKX0wTBEv pcgqDNWfGf2x7wQnVaqAKYA7hXwYOmJcyw== X-Received: by 2002:a17:902:f08c:b0:183:9296:8b65 with SMTP id p12-20020a170902f08c00b0018392968b65mr14029611pla.59.1666038302223; Mon, 17 Oct 2022 13:25:02 -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.01 (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)" Subject: [PATCH v3 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:36 -0700 Message-Id: <20221017202451.4951-9-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?1746968117591704590?= X-GMAIL-MSGID: =?utf-8?q?1746968117591704590?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Also some minor renaming for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Jeff Layton --- fs/ceph/addr.c | 58 ++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index dcf701b05cc1..d2361d51db39 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -792,7 +792,7 @@ static int ceph_writepages_start(struct address_space *mapping, struct ceph_vino vino = ceph_vino(inode); pgoff_t index, start_index, end = -1; struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc; - struct pagevec pvec; + struct folio_batch fbatch; int rc = 0; unsigned int wsize = i_blocksize(inode); struct ceph_osd_request *req = NULL; @@ -821,7 +821,7 @@ static int ceph_writepages_start(struct address_space *mapping, if (fsc->mount_options->wsize < wsize) wsize = fsc->mount_options->wsize; - pagevec_init(&pvec); + folio_batch_init(&fbatch); start_index = wbc->range_cyclic ? mapping->writeback_index : 0; index = start_index; @@ -869,7 +869,7 @@ static int ceph_writepages_start(struct address_space *mapping, while (!done && index <= end) { int num_ops = 0, op_idx; - unsigned i, pvec_pages, max_pages, locked_pages = 0; + unsigned i, nr_folios, max_pages, locked_pages = 0; struct page **pages = NULL, **data_pages; struct page *page; pgoff_t strip_unit_end = 0; @@ -879,13 +879,13 @@ static int ceph_writepages_start(struct address_space *mapping, max_pages = wsize >> PAGE_SHIFT; get_more_pages: - pvec_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, - end, PAGECACHE_TAG_DIRTY); - dout("pagevec_lookup_range_tag got %d\n", pvec_pages); - if (!pvec_pages && !locked_pages) + nr_folios = filemap_get_folios_tag(mapping, &index, + end, PAGECACHE_TAG_DIRTY, &fbatch); + dout("pagevec_lookup_range_tag got %d\n", nr_folios); + if (!nr_folios && !locked_pages) break; - for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) { - page = pvec.pages[i]; + for (i = 0; i < nr_folios && locked_pages < max_pages; i++) { + page = &fbatch.folios[i]->page; dout("? %p idx %lu\n", page, page->index); if (locked_pages == 0) lock_page(page); /* first page */ @@ -995,7 +995,7 @@ static int ceph_writepages_start(struct address_space *mapping, len = 0; } - /* note position of first page in pvec */ + /* note position of first page in fbatch */ dout("%p will write page %p idx %lu\n", inode, page, page->index); @@ -1005,30 +1005,30 @@ static int ceph_writepages_start(struct address_space *mapping, fsc->write_congested = true; pages[locked_pages++] = page; - pvec.pages[i] = NULL; + fbatch.folios[i] = NULL; len += thp_size(page); } /* did we get anything? */ if (!locked_pages) - goto release_pvec_pages; + goto release_folios; if (i) { unsigned j, n = 0; - /* shift unused page to beginning of pvec */ - for (j = 0; j < pvec_pages; j++) { - if (!pvec.pages[j]) + /* shift unused page to beginning of fbatch */ + for (j = 0; j < nr_folios; j++) { + if (!fbatch.folios[j]) continue; if (n < j) - pvec.pages[n] = pvec.pages[j]; + fbatch.folios[n] = fbatch.folios[j]; n++; } - pvec.nr = n; + fbatch.nr = n; - if (pvec_pages && i == pvec_pages && + if (nr_folios && i == nr_folios && locked_pages < max_pages) { - dout("reached end pvec, trying for more\n"); - pagevec_release(&pvec); + dout("reached end fbatch, trying for more\n"); + folio_batch_release(&fbatch); goto get_more_pages; } } @@ -1164,10 +1164,10 @@ static int ceph_writepages_start(struct address_space *mapping, if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) done = true; -release_pvec_pages: - dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr, - pvec.nr ? pvec.pages[0] : NULL); - pagevec_release(&pvec); +release_folios: + dout("folio_batch release on %d folios (%p)\n", (int)fbatch.nr, + fbatch.nr ? fbatch.folios[0] : NULL); + folio_batch_release(&fbatch); } if (should_loop && !done) { @@ -1184,15 +1184,17 @@ static int ceph_writepages_start(struct address_space *mapping, unsigned i, nr; index = 0; while ((index <= end) && - (nr = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_WRITEBACK))) { + (nr = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_WRITEBACK, + &fbatch))) { for (i = 0; i < nr; i++) { - page = pvec.pages[i]; + page = &fbatch.folios[i]->page; if (page_snap_context(page) != snapc) continue; wait_on_page_writeback(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Mon Oct 17 20:24:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629521wrs; Mon, 17 Oct 2022 13:29:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jAwy4OnmNBJgDKs8yfVKlGsTcyCIeXWGG+e0kTgdwtw15XXjEwqcJuiRUheSZWz7hJQJ/ X-Received: by 2002:a05:6402:d5f:b0:458:dc7e:f728 with SMTP id ec31-20020a0564020d5f00b00458dc7ef728mr12211227edb.220.1666038572426; Mon, 17 Oct 2022 13:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038572; cv=none; d=google.com; s=arc-20160816; b=GL3CR0A67mBDHkF7o3pphgE0FnkGB4Lg8ejpuQ4/Eq5dfWW1vJMVwTBTp2pxubeMaw gzHUiSdtqq/Q/09EcGnuetcMLgf9hHEPQ/sojXgUFa9Qvy5ZheOa7sUCTqk5ea50pm0k g9kaupS6B3thDy4Jm1SzCjlTE5BlywIxF7nZZuHPNquJqILPqRte6hzMux3y0RR86D4b O5pGyZr61SBZ/cfmVXTG1QukEtgAk7WnjQ8giEBnYDVFxE9lMkPiVX+vO38b1eVnVk50 haeZTJhEepu/67F7ptubR94m21TeimdOkp5Qj9ZqsyaFVtF7y9Jwst6LgVbvdocOjEIm 7akA== 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=xF+S3kLPZzaI8oQb5OfM6HGraMAqxwArE1NOeePgjJI=; b=GzLH/Zcs4FzwhKOCzGIRkMHxKccam5XHpIwSgPOvXc2PshFesMy1E9mOXtRuTe0KS/ Dan7s9PwmSNdqObCSVutRiCbJtKL5awi+/cSmN3QeX4U5H7NmRmxNg7U/HWToP8alrWd bFG9yfWZ63EGtBli86YnozziEc9h47UmtlMI2axYnkgIyA4SyyanotwPal8/2BXtUWfe xqdIPGTX4JdqkMtb7h6nCpPr8/jUlOUyKv0TvvrRhd6+7F3O0UbVW8lRSQdYltjFlpgl RwC0wPlEoFxL+Qe5U8+dImvhYmb8aOMwMuM9SK2JgcyL82T6RJ6iFSxx58HK8k2iaL3u X9aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XUUSSIaI; 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 y11-20020a50eb0b000000b0045b50cee511si9069823edp.122.2022.10.17.13.29.05; Mon, 17 Oct 2022 13:29:32 -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=XUUSSIaI; 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 S231574AbiJQU16 (ORCPT + 99 others); Mon, 17 Oct 2022 16:27:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbiJQU05 (ORCPT ); Mon, 17 Oct 2022 16:26:57 -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 D05A57E32B; Mon, 17 Oct 2022 13:25:35 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id pq16so12020722pjb.2; Mon, 17 Oct 2022 13:25:35 -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=xF+S3kLPZzaI8oQb5OfM6HGraMAqxwArE1NOeePgjJI=; b=XUUSSIaIijy9nz3gVf5iV3Ax7/gZZZ7Kjy+jjIIePV53CqFWJIxxsOvnffQtyfkxjP Yj1nwTiH0AguMsbOTQeu+8Z9mi7qRPLyE0S6M0xCFwiO28OMVRcOXq6yKjJFASnj7zDP hHzCZ7l/wbiBSCCq8oyptJveE7nl6roT2dTX39Tmm+YHanI6ZLWRKL+GxVNnWAVi/aqd Utqx7yMucx2sjXgfOeQmOc8qMiwP1URFKwVETpEX4YOe1sQaY88gGBHBUZvpmMyb0f0m PLVAeL/JerSDZqt4gfmESRBxYd+ZqACu4QMuoto8SFxAd6Gjw4atWFM001xVBLWGQnUL y/uQ== 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=xF+S3kLPZzaI8oQb5OfM6HGraMAqxwArE1NOeePgjJI=; b=yqfdb1jfAX2IDjTWou36pkRJpWocYqsDmogwN8EQtZuACefbQFeFALZnqgs/I5pOHI 7dUJIf1WNVvytmv+ml0zTTf89hej5fR3ftkjRY7v19Cpsy2gaZ+o7AIoIyIvpViUO/Ir mBMA2PmMRqspzZb1nmMpU9MUMKhC/hTY5qp0ddrFVOxfUJ9k7hcNuWFlyM784+7O1nJN m/m9E7W4NR4Mp+oH7soo85S7FnC9ZjPlNVgiYggJdr/MtIxb8xwpmCCKrDVN2s2fVd3X 5bMSahps23yeYDBYekDzEO0tWNC561yNUQbJDaePfUOjo2ssfWfAAtnEWZG7Wyyh6nm5 Kl7A== X-Gm-Message-State: ACrzQf1vDUVESKQI9I6GMaxzRuBR/5cNzqrwCnNBh3MR4pB7No7BHIIO f19471mc+9Q/4T/i26QwIoh6ZD1bfU1rGA== X-Received: by 2002:a17:90b:400f:b0:20a:9965:ef08 with SMTP id ie15-20020a17090b400f00b0020a9965ef08mr15928728pjb.155.1666038303106; Mon, 17 Oct 2022 13:25:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:02 -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 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:37 -0700 Message-Id: <20221017202451.4951-10-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?1746968061792670193?= X-GMAIL-MSGID: =?utf-8?q?1746968061792670193?= This is in preparation for the removal of find_get_pages_range_tag(). Now also supports the use of large folios. Since tofind might be larger than the max number of folios in a folio_batch (15), we loop through filling in wdata->pages pulling more batches until we either reach tofind pages or run out of folios. This function may not return all pages in the last found folio before tofind pages are reached. Signed-off-by: Vishal Moola (Oracle) --- fs/cifs/file.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f6ffee514c34..9a0675dd2d3c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2520,14 +2520,41 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping, unsigned int *found_pages) { struct cifs_writedata *wdata; - + struct folio_batch fbatch; + unsigned int i, idx, p, nr; wdata = cifs_writedata_alloc((unsigned int)tofind, cifs_writev_complete); if (!wdata) return NULL; - *found_pages = find_get_pages_range_tag(mapping, index, end, - PAGECACHE_TAG_DIRTY, tofind, wdata->pages); + folio_batch_init(&fbatch); + *found_pages = 0; + +again: + nr = filemap_get_folios_tag(mapping, index, end, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!nr) + goto out; /* No dirty pages left in the range */ + + for (i = 0; i < nr; i++) { + struct folio *folio = fbatch.folios[i]; + + idx = 0; + p = folio_nr_pages(folio); +add_more: + wdata->pages[*found_pages] = folio_page(folio, idx); + if (++*found_pages == tofind) { + folio_batch_release(&fbatch); + goto out; + } + if (++idx < p) { + folio_ref_inc(folio); + goto add_more; + } + } + folio_batch_release(&fbatch); + goto again; +out: return wdata; } From patchwork Mon Oct 17 20:24:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629754wrs; Mon, 17 Oct 2022 13:30:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CqnTP+QXZm2dFt/h/+T+A2oDilYSXEGVhLVYSQYEMSkdKs2TeGk+APbkm1s1ohZM0HBYG X-Received: by 2002:a05:6402:26d2:b0:45d:280b:5878 with SMTP id x18-20020a05640226d200b0045d280b5878mr12039426edd.385.1666038613032; Mon, 17 Oct 2022 13:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038613; cv=none; d=google.com; s=arc-20160816; b=XSmTvQ9+XAqhaWJhsrqKkaafBG2OeAKdauI2MCy/ecBV7ALHXV117KfBH7+nUbAXvT qUQusiPV8OThvBO1YsUvBLP6gdqDwHvdTDqf8+VMZhHg2hEtJ4sURr5UGRIFDozw44tQ XYZJ/CzuicHNxmdZ0WzGsT49rNK7vFy1yJ0oMp8tXymD+sXV12Puj1ObZcwv/jkLEzBS DXmKVSdqb7xaQXNbPKawohc5NWINJjC9QcYMvmTPx+51XZKgTVkGLIAykfCOb+BhMHk6 utSOdb5Vfm/YEHJod4yGm3m61QQdSE29GuipCtpTvoWOyPKsthP9rt6fhuxvf9GQWalr z5Cw== 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=e9q7pFln9lQ65y9KBRkf+bzGyuKY9CYfpaig6iF8DC4=; b=yGr/3RtAQKp99dazE4jVF5+0qKqLaTilINomobmJU0t7HtNRxD0FJoG0wkvpob1AdH 1lQ8o/yta634uPaUZcVCLakWEDXp+e49Ods0/ynPiUXGmHLgDPN2i11EQA7kSCfbT1aG Dbn3a3FNoF4AgFAhIJ6pLZ03ZuXCAfWV3vJ4oqqUJ6rEm5vF1wc4vbXflFltvimgDYOD GFjrd50xyzUd3IQQQWjK3+BsB5sviHPX/IBX/qPNh9/Bz4Js5ub+1b9uf+fAIKb6QxkI nlDtAxFiFsmLWE7lh8J56TGNcFVMKMUlcOMEZUVbbGjUYzYMhIwbdk4UrbbbtJhDMBK6 B6qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gQyyhn3G; 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 h6-20020a05640250c600b0045d47f522f5si8111888edb.367.2022.10.17.13.29.47; Mon, 17 Oct 2022 13:30:13 -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=gQyyhn3G; 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 S231626AbiJQU2R (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbiJQU05 (ORCPT ); Mon, 17 Oct 2022 16:26:57 -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 129E77E32D; Mon, 17 Oct 2022 13:25:36 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id gf8so11985789pjb.5; Mon, 17 Oct 2022 13:25:36 -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=e9q7pFln9lQ65y9KBRkf+bzGyuKY9CYfpaig6iF8DC4=; b=gQyyhn3G6gjigc3apYsvcarlMYxlACGwN/909gbool871x+BPyL5P2OO1tembKgKHq uZUKK8pXtr6zkTq8u+I0NemrFdP8KcE6PnjiDpmjz/r3eQsrr4QToHikqa49YOu5vVAV uK1FE3pqL3guqBOTypvgNW0SMkH6sqWo71NiM+1isiuOndJ6/UshMg1C0O2MQz2YCjrr gy9RqnyC6O8ZMXXND0iM4vfh96zazohqHCughdUhwVjRGdML22zcPHco0+WuWpvbkJoT iKruffKUnMmYNez8Xa08SlSEQMKyL7yL2l+F/0eihreonP72en/+JTtV0qkeO9wTaMXn QtTw== 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=e9q7pFln9lQ65y9KBRkf+bzGyuKY9CYfpaig6iF8DC4=; b=UZwv0pFsKewEKcz1yItn8llnwFfYoVsLkPhAzGYHvt6D0vE/1KWWGIRVUtIlAhLbNv Apx6Znb2HD1gl0jnMmjps4/fDh8FuY3i+vJP36QSsmuEA13+luUGw1PcXtL/Nmm9gSLO IdQOgtizbgGssj/+y+zwVVkQxWW9bTtjbL9AWCvWFymJj2K+9rSnnPB359ggp2j1uYOv mVAgFoEhN8StV9S6mQiLolhxhXEWpcwZCFB4xPeXZdF8Y12I4AE7UIWkGOsR90n3EAD+ kUBQqh0yLwRwmDwwws4nZB8bUEbDsLDrtOFhhosoHdWXZw0J+qEIShWvwkJbRJrBpB91 R6gA== X-Gm-Message-State: ACrzQf00Z+ZgOvL/zuxJPT64FNj/8OuUWzlXwQwLDkTAGmFUIiBJX6TR DNWk2FgF8M8l7RgM/23eWhYXEDtsy8LB1w== X-Received: by 2002:a17:90b:4f8f:b0:20d:be54:f34f with SMTP id qe15-20020a17090b4f8f00b0020dbe54f34fmr21307323pjb.245.1666038304014; Mon, 17 Oct 2022 13:25:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:03 -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 10/23] ext4: Convert mpage_prepare_extent_to_map() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:38 -0700 Message-Id: <20221017202451.4951-11-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?1746968105047397879?= X-GMAIL-MSGID: =?utf-8?q?1746968105047397879?= Converted the function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Now supports large folios. Signed-off-by: Vishal Moola (Oracle) --- fs/ext4/inode.c | 55 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2b5ef1b64249..69a0708c8e87 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2572,8 +2572,8 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode) static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) { struct address_space *mapping = mpd->inode->i_mapping; - struct pagevec pvec; - unsigned int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; long left = mpd->wbc->nr_to_write; pgoff_t index = mpd->first_page; pgoff_t end = mpd->last_page; @@ -2587,18 +2587,17 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY; - - pagevec_init(&pvec); + folio_batch_init(&fbatch); mpd->map.m_len = 0; mpd->next_page = index; while (index <= end) { - 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]; /* * Accumulated enough dirty pages? This doesn't apply @@ -2612,10 +2611,10 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) goto out; /* If we can't merge this page, we are done. */ - if (mpd->map.m_len > 0 && mpd->next_page != page->index) + if (mpd->map.m_len > 0 && mpd->next_page != folio->index) goto out; - lock_page(page); + folio_lock(folio); /* * If the page is no longer dirty, or its mapping no * longer corresponds to inode we are writing (which @@ -2623,16 +2622,16 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * page is already under writeback and we are not doing * a data integrity writeback, skip the page */ - if (!PageDirty(page) || - (PageWriteback(page) && + if (!folio_test_dirty(folio) || + (folio_test_writeback(folio) && (mpd->wbc->sync_mode == WB_SYNC_NONE)) || - unlikely(page->mapping != mapping)) { - unlock_page(page); + unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } - wait_on_page_writeback(page); - BUG_ON(PageWriteback(page)); + folio_wait_writeback(folio); + BUG_ON(folio_test_writeback(folio)); /* * Should never happen but for buggy code in @@ -2643,33 +2642,33 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz */ - if (!page_has_buffers(page)) { - ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index); - ClearPageDirty(page); - unlock_page(page); + if (!folio_buffers(folio)) { + ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", folio->index); + folio_clear_dirty(folio); + folio_unlock(folio); continue; } if (mpd->map.m_len == 0) - mpd->first_page = page->index; - mpd->next_page = page->index + 1; + mpd->first_page = folio->index; + mpd->next_page = folio->index + folio_nr_pages(folio); /* Add all dirty buffers to mpd */ - lblk = ((ext4_lblk_t)page->index) << + lblk = ((ext4_lblk_t)folio->index) << (PAGE_SHIFT - blkbits); - head = page_buffers(page); + head = folio_buffers(folio); err = mpage_process_page_bufs(mpd, head, head, lblk); if (err <= 0) goto out; err = 0; - left--; + left -= folio_nr_pages(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } mpd->scanned_until_end = 1; return 0; out: - pagevec_release(&pvec); + folio_batch_release(&fbatch); return err; } From patchwork Mon Oct 17 20:24:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630801wrs; Mon, 17 Oct 2022 13:32:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eM4tX2D30pxjhlAAkysUxjQuJYYLimOhCedF5xqT1jaNQ+TYTivarzjHHpCJZtZ/OtfOb X-Received: by 2002:a17:907:b05:b0:78d:9bc9:b96f with SMTP id h5-20020a1709070b0500b0078d9bc9b96fmr9887207ejl.468.1666038773361; Mon, 17 Oct 2022 13:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038773; cv=none; d=google.com; s=arc-20160816; b=uH6AtV2mveVK9TF1ySvRy5rCCf29z+Nr5F6kj8jB4+L3lvoIL984tY6JddnIDzUN1s bv8K92PQps40NLNy5L4L3MqURiatY3nPDG5KINAGVIodvhe89FitRFHYWH1AFWl/PKRj T1Zy4N75udNIEWmptwUUVjx42Xb0setxZfJWh3l9KjJXPc+vtmd9xGoN5wb0KxpOpmDa c1VYXwLPjlGoRlo5CCEp/lYA5mm/3PuSupVoFugrpcxSUWP3VW3puei1lQwRLKpcxJSe PIzbKZaONqGUP3lqzbgZT567pXuiXoJrhBUzufIgHr8bbXhk3Z/g5C9tGpE5qJkCGMWv Gzxw== 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=6Gcylt+Ee3nnIcC1CSrxmmqTpju5LE3+AXEIgm+aVs4=; b=QqkatrZtJWS5AON/VFrjYW8ubWmHTINa8jpn5ywv4EurTK+L+Sq65LKmagpv9NuewU EzKw8DrOCOF4C8gwZEqOmyoF5GaW3Qs1iYm2qNncmTBcq4IuposuXPP+f4ci8wFwdsEK nsG0ZJAbx+USsRSGg1LhL84ptc12+8+StecElgAiMiqTM1753G4PCb5nlf14mw0FHac7 jB6V0HkbxbJfhYNyLWPLaDBOuRVh1I01z3qapDt6TWwDBeQcmDntygS6ABEgKRM5WerU rmN76ftq2Hv/QpCzvLVUphYfTzZSpUVfxoVqPU0RAffTmZVEp0gpqns7Qk55vKO5gq6G BcmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ifFTeoUY; 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 hr30-20020a1709073f9e00b00787b9cd2fe3si10565349ejc.844.2022.10.17.13.32.26; Mon, 17 Oct 2022 13:32:53 -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=ifFTeoUY; 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 S231840AbiJQU3E (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbiJQU06 (ORCPT ); Mon, 17 Oct 2022 16:26:58 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC357E808; Mon, 17 Oct 2022 13:25:40 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id l4so11810743plb.8; Mon, 17 Oct 2022 13:25:40 -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=6Gcylt+Ee3nnIcC1CSrxmmqTpju5LE3+AXEIgm+aVs4=; b=ifFTeoUYIX/JHROqieyQ+/nPZoHo4/h5Ny8eP9EcCFh4S+Q1mIxlVXZQkSCwUAkgYA 9KrR3+3Jqghr6crVnV6qXc5INX2cac8uDEOB4CkIBlX0YCJi7H6Fc3sAhQA7ybel8BgX radNlmHPnhi7yvSSHyVufNNIAoVGamFUYc8iB4p+0wU5MtiC9yP8hS5HKsQycm9b8YNg n9WVwFdcyw3e06Lf+T1d5fsIQ+OcxptTreSC0TvliItMIby1Vv9slyllHJAtXAWTKffh /zK+Jo5uR/RaB3yHi8HAR+9ZGb6Gmx42SHZYRFWpxY5gPcUdKQ7weGZ54ycWpGG932Ob xFGA== 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=6Gcylt+Ee3nnIcC1CSrxmmqTpju5LE3+AXEIgm+aVs4=; b=v+catqrNJ3+tsmvGxAK/CBebo9+AjUQlcNpF6XfvzOn2jE9r6WYDYoHJVXwAZm5hQQ 57d7OASFTQIaf9jwUJ2BDFQO6fqOQ2GmmDloCjSjffdPV9I/2K7yuvaLUXAneZvVoKme Yg7rpNQMUuw/7amwGgMnAjBljPD3BNNUvxuwjaxJ8t2zuxPRZDvtg1NBmYGMAoypL5me WUqHdDgKtI+fnXTYd7jt0Mk/LvlqWcJtJNGX5YT2SmW5SeA6ri1SRmmJRWiRB1IyC/Xc IUbg1/U3XHS1vrLrX7I18TC2z04pL/uoC1hZmfF8eFEs2hJ+GwIr6iwkvRXhVhRERD+8 2t/g== X-Gm-Message-State: ACrzQf1EWNthdGmfUbv+u+K7q+FajXvW8c8wnpMSQkZGcX55uVonCUYm mDWP8zwobKPpBIOjE0gJJGiSRIeQ9oijpw== X-Received: by 2002:a17:903:2306:b0:185:43a2:3d1c with SMTP id d6-20020a170903230600b0018543a23d1cmr13740880plh.154.1666038304993; Mon, 17 Oct 2022 13:25:04 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:04 -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 11/23] f2fs: Convert f2fs_fsync_node_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:39 -0700 Message-Id: <20221017202451.4951-12-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?1746968272897985615?= X-GMAIL-MSGID: =?utf-8?q?1746968272897985615?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 983572f23896..e8b72336c096 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1728,12 +1728,12 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, unsigned int *seq_id) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int ret = 0; struct page *last_page = NULL; bool marked = false; nid_t ino = inode->i_ino; - int nr_pages; + int nr_folios; int nwritten = 0; if (atomic) { @@ -1742,20 +1742,21 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, return PTR_ERR_OR_ZERO(last_page); } retry: - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &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 page *page = &fbatch.folios[i]->page; bool submitted = false; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); ret = -EIO; goto out; } @@ -1821,7 +1822,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (ret || marked) From patchwork Mon Oct 17 20:24:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629708wrs; Mon, 17 Oct 2022 13:30:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SCYZAFZrRp+/yvNHvC9jBa6uTLwVkGE9DeZ0SsjqI6GPlzNBl2mFHrr6W87PyTR+N2zr5 X-Received: by 2002:a05:6402:e01:b0:442:dd7e:f49d with SMTP id h1-20020a0564020e0100b00442dd7ef49dmr11814930edh.355.1666038604717; Mon, 17 Oct 2022 13:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038604; cv=none; d=google.com; s=arc-20160816; b=VkpQ7tPzKRHZB8P8KC/2PmtBGovwvEckEUJqZGCIBtTqt3JeeVqtQTDoWSNbCqE/Nc wtK1d8DG2KLfMYHQS4QWQRZOqPsYqTdvN+X8K8Z8/p4+ZU/b+/nmR5dNZ1+b6iKVwAj0 WeZ3wS8uQLRfbFHGVuyEY3ud7IRoemKpKS+M1gNjkjsw76rPI8ZR4LKKLL6/mHgqd9tK 0uGNDMEi+6L7+sVB3ieSULNVynp+iz7DSCxpKGKTqA1lfJOgYlUwYpzKYWF3hn+NVZil HrLzEOFpLbS0jmiS4koOVoaEBjTBn+w4IrGj+I5QOIs/SPM55v7Bxkq4b4/CwUpYUD4z 6rUQ== 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=m6ErMtYFOLSC+XFSDnhR16+VnHSa+A9yG2wppqURV6g=; b=ARNVN0B18Duq9QIPN7uib+2T68Zl60l40x1rGuYAUpxJ0lCzXUBVuqBR2PV6FoL8au pna1YKIGqHhKHrmJKzXTI+fdBVKOcOJD3fYhljFcmIW5D8hvGY9YRImxkDeUXgqSfKTn mXIOaXAhfWlNRZwLR8YG1AB0Ci3GplZv8QNtKCbA4lcyn5ZzN2BJ5r4fjClR3pZ00TZE uuxh1Z4OUxGo/RsKVxGAOWcg8e8GaEMvXcx0ZJ22NQh43CQ53o9/+2wAIk/oJtlRAs9z KzPucpfEsGoaZd45OWgE49MScFxlWmWUMo0geduhq40TZM9Gp7iuNsm3X5BduIMSXBu5 Cxbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cCPZ3LZe; 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 sh43-20020a1709076eab00b0078d96d3278csi6063785ejc.510.2022.10.17.13.29.39; Mon, 17 Oct 2022 13:30:04 -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=cCPZ3LZe; 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 S231646AbiJQU22 (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbiJQU06 (ORCPT ); Mon, 17 Oct 2022 16:26:58 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011A07E80D; Mon, 17 Oct 2022 13:25:40 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id q1so11430414pgl.11; Mon, 17 Oct 2022 13:25:40 -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=m6ErMtYFOLSC+XFSDnhR16+VnHSa+A9yG2wppqURV6g=; b=cCPZ3LZeIepzgHQo38JmLKd16CRdo+2iAtbuM0GeXbYUQtLEwsFysyya7MYzHjocpg 9H9ib+VuWdRu2d7bK5i8paQZGdzHkJ1SWJG7Dh0Ca6BqZhTE4s9Bd6e7ntf4YGC91R/h UgFC41Q0Q/xhD+8z+10ge1J4agN3xgWHAKXVd63knIgAcRcmNhj/iSTo20LpGHMF/9aA NbK4DCkGcpGDuZtGOnbGMumQl6ROrfsEwEfIgs8chmDRZdYYwSRrxiDodPpn4T5dlrkt VNzn2lVkELDr1gtJA0x7iwQCGF5ya7VDbUQisTDDlMqMXif/Z3VL8W7KPwnE+fu1FxM7 QosQ== 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=m6ErMtYFOLSC+XFSDnhR16+VnHSa+A9yG2wppqURV6g=; b=BsUnnEUPApSrbyAN/IkmdqA6A9gtv4dXg4Vk7xvTvRBm5DckvAVVT/UY1UGUtF3bx5 cFlN/+XQL/rkXxheuLX/QR8rdDBRJEBcFZNSQ1tg+yOE6+8HcLYuQO+XgnyVx7QkH3Fh dpr+1XcxRGXbpC/Yk0fyQJv6W2yfmFyRRIjKa/O1gmFXOAzSa1ElGKaqwwz9SUFEzrPP xBF74vZW94TWHRqbVKbXqAVNNrrtBI7YEfPtHP2p2zSC1y07rGGGxQqrHNs0w/5N6Xqg qpPlx5carl0v+Tz7y/9zgQ9X3COegnBZo5pzqrjHWE1QPMX2Rrnf30jzo7Ayd4Gd+uf8 pc3w== X-Gm-Message-State: ACrzQf3W1oPZ7P8M0Zk2H6bA9t/s2H89oA1/PtgoLbDb+LZyNJIb3DER zdkVoCw4LEScoTxRliZsEz8TVftfNBf2Zg== X-Received: by 2002:a65:674e:0:b0:43c:3b91:236e with SMTP id c14-20020a65674e000000b0043c3b91236emr12225402pgu.510.1666038306213; Mon, 17 Oct 2022 13:25:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:05 -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 12/23] f2fs: Convert f2fs_flush_inline_data() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:40 -0700 Message-Id: <20221017202451.4951-13-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?1746968095675966768?= X-GMAIL-MSGID: =?utf-8?q?1746968095675966768?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index e8b72336c096..a2f477cc48c7 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1887,17 +1887,18 @@ static bool flush_dirty_inode(struct page *page) void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) { pgoff_t index = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while ((nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &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 page *page = &fbatch.folios[i]->page; if (!IS_DNODE(page)) continue; @@ -1924,7 +1925,7 @@ void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) } unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Mon Oct 17 20:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630526wrs; Mon, 17 Oct 2022 13:32:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70O0C+BwrpSLxB0YW1DWjCD8QgoksI7nj86fgYAFSaLIArWHRZ01yruogM7IS6r4gkakJk X-Received: by 2002:a17:907:608f:b0:78e:1b60:60e2 with SMTP id ht15-20020a170907608f00b0078e1b6060e2mr10274058ejc.382.1666038724254; Mon, 17 Oct 2022 13:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038724; cv=none; d=google.com; s=arc-20160816; b=T1idK2KDD8/h2ckd5aPZjUDC76BIrVu9JF6GjYYxucIraXq3vC2h+wXskNIfPdcan8 LDbF1CWFVf/sENWG+gYMhlN7Y8CRe9aFFmL2yCTKpzzMFYJ7SM2M/XMHpHT1FSilX5VQ tR1cIaC+gogmLhgKhLzTThopX7wskTl1s5uOvTxFOsKZr3EV6+T1a2MRRR9G2eKrUzq3 KqD4ZcAGK0uPyQ5343YX/yfKBV0v1ycUmxovEhIy1wkX9FXtnmSyU0jZGdd7sV/yIvYo fSoxa5Ci7Atj8ez3qimeSd1WVavwXUxUcyWw/tgSNdHkn8mKamSU+Mh9DUCkxBEkpVgm bssQ== 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=VPyaEfnfsN/s28KIqk5JK9av//7f4plsWX6QMWBWYvw=; b=lYcQE8caUOPWIFZq6U3xYXoew0wMJILE5j64DYWN+Ek/ODH8GA9QuFE9Ir2+544b13 BLFG8yPJTIdD3jeliMaqCI3HqXE/dO/+ZGoKT6C0rdK0eeKiNLQp1xZi7Pu026STPSlc ZxBmH6mniwCBGT93Zq4kRn4+FgGUQLOfEG6cWQuOA0AA+8DXPz4vY2UMI6v0HAhU+8Sg A9VpRZKFadf6ImZwJYPR/55kCoo7WZl5WOjMa67ni5CKJ+nWQ1n2PL+iRpDCPiKNIx1P uG6RuafXApYTh6Fxz22yLhlKzZxkYbO9ZA+HH5V3Y0fbsZ4+73TdXwSA9DK9T2+aSVm/ 2eig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AAaBUf6A; 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 cw10-20020a170906478a00b007897abccc6bsi12296188ejc.484.2022.10.17.13.31.38; Mon, 17 Oct 2022 13:32:04 -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=AAaBUf6A; 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 S231439AbiJQU3b (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbiJQU06 (ORCPT ); Mon, 17 Oct 2022 16:26:58 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011467E80C; Mon, 17 Oct 2022 13:25:40 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so15316905pjq.3; Mon, 17 Oct 2022 13:25:40 -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=VPyaEfnfsN/s28KIqk5JK9av//7f4plsWX6QMWBWYvw=; b=AAaBUf6AYZwl2VDHcCjIUHoo+BDNMPnV+R8K7xw03ITt3bJu/PXwBptMp+Cd78GqHp N1fPmeaEcgT0dNOi5heH8RkIvQzLgdDjFTLLFkJTMuZtMzDzhqm3A5e2TUW+009WVhvP LnQ+Qnxue4GNQ/W4GSqfITdI/xtl/FcZVOsSAxzDrhPsnLCBNI0Pam1Vx851IlCokycW 3ihi+TyICcYVO2geBMteJjeyBoyopJkqhfYcH/Zh5WCo+KIFfIyQ0WkYt52MgC2bUa65 R8/gksQ//p7O7voqbBaQcC5j/XMc08BKModktLu/0bF2tT6gRFEgGcvAeXRPf7IXx8T9 8+gw== 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=VPyaEfnfsN/s28KIqk5JK9av//7f4plsWX6QMWBWYvw=; b=K3y+vz/l6cbKQZH0UzfP5sO9SBtBV3lMKDyNWS7HqJ7LlyDd2aQ28wm2an+T+Gppcs pDN6ji5qucv9gQMRdrZRYPqAW/NECZt58Rdn75RsL1IqiGE5oBuEZW/Y/sYXahHqhxyo Fg0TkB67eJ4XvuZPqC97zjEezoRVAJkbjeB6uneGeY3OCYnCOb3diWBUkM7EZzv3JPfT p+jfuo8z0F8fau22VenNXGrQSCOpAMHAnyJH6yePaCXDGqvucDrR9FloZ2Fmh5zObwOz +cuTEswL+Ip488HgT7kpTFx4isssijH0vQPjYaRWtDUgJ6TlTffK3dKfqr+HR6wYwd6d SP7Q== X-Gm-Message-State: ACrzQf0aebnu0k+J/SH1P2HTE2qIB/UcID/XAIEX47mH3lyKmY0KReS6 81xKvEbRqcjF2XY7PEjLKBrY7kF0NF+qQA== X-Received: by 2002:a17:90a:4216:b0:20d:2891:157 with SMTP id o22-20020a17090a421600b0020d28910157mr35557408pjg.47.1666038307198; Mon, 17 Oct 2022 13:25:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:06 -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 13/23] f2fs: Convert f2fs_sync_node_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:41 -0700 Message-Id: <20221017202451.4951-14-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?1746968221467069274?= X-GMAIL-MSGID: =?utf-8?q?1746968221467069274?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index a2f477cc48c7..38f32b4d61dc 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1935,23 +1935,24 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, bool do_balance, enum iostat_type io_type) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int step = 0; int nwritten = 0; int ret = 0; - int nr_pages, done = 0; + int nr_folios, done = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); next_step: index = 0; - while (!done && (nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while (!done && (nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), + &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 page *page = &fbatch.folios[i]->page; bool submitted = false; /* give a priority to WB_SYNC threads */ @@ -2026,7 +2027,7 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, if (--wbc->nr_to_write == 0) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (wbc->nr_to_write == 0) { From patchwork Mon Oct 17 20:24:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630435wrs; Mon, 17 Oct 2022 13:31:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7inAQ3CkCSfIk5xhOoAxu6/64+PHAj51o0jhSI8vXw7x52oCwhi23sNLqgJL2qayVKiwWX X-Received: by 2002:a17:907:72d3:b0:790:65a:3a02 with SMTP id du19-20020a17090772d300b00790065a3a02mr8995607ejc.354.1666038713387; Mon, 17 Oct 2022 13:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038713; cv=none; d=google.com; s=arc-20160816; b=JXkKneS4e29UytIaJhsOjXnHPr3U4wbuIet85gT2To3yaLZvWEUHHmeLGM+hvKxUp0 Jlgi+OekBv4/QOR+QtryB7eMgUNGKFOrLgPrWmWmG9RCVMYSieCFw7FO78214QKPq448 LLzyIQ6XlCrBCsn5i2KZNkug5OPv7Y6adnsWTHKTg2TeSrhoPvoKc+EfJOuF5danDUOu Ie5OBHUKGXYqZUKAnIkPf8v5im6I74390EZ2Lgw9PfSeWXeI/0DFk1wHyFJ6S9za+EOq vpaM0e+NI5D1QAyI7GSS8NIzWTEuErTacx6Lh93L9+S/J5PjsVjXHqWSXCZxZwBYbTtN UALA== 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=f2k7WPXYHIuzqiFfSHfNTIZb4ikRcS6mn79essSLTNQ=; b=Spo089bMbguDFVd3E3YgB+E1b4RrQlGaC1uUgmFnrQrCy29DXQ//DU9Or2O+EvSy71 Pz6eJbz7xFk8DZrHvD1/ClneSXNBdOZ29i9JoaKcdGng9OV+wtmKWORaehwopXKSRCj/ QMaGtDcGLj5rOrBnhutBvE69Gez40q9JqIuaumlaBxRJAEQxLNm7UARemHoOdtUM4tnV H2lRzd00nxAtIokR4iU0aqiCONP7xMwuqKZaaXs/123d1VgGMt/+L6Ex0SCmTgI5iRPg 2L7K91GbOQKihIXcRAInjsbgu+2HPmDMeoVRBxp8OOcGur+dRgbAzYwJ033Jl/s+JBjw BYGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="DD/pVv9L"; 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 y66-20020a50bb48000000b00458ea8cbfb2si9607006ede.505.2022.10.17.13.31.22; Mon, 17 Oct 2022 13:31:53 -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="DD/pVv9L"; 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 S231384AbiJQU3Y (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbiJQU06 (ORCPT ); Mon, 17 Oct 2022 16:26:58 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06BC7DF5D; Mon, 17 Oct 2022 13:25:41 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id z20so11797328plb.10; Mon, 17 Oct 2022 13:25:41 -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=f2k7WPXYHIuzqiFfSHfNTIZb4ikRcS6mn79essSLTNQ=; b=DD/pVv9L0eiobiuAJrfVtLjvlnyIzbSaai2HBNDktq7QUS1Q46EZBJqKBOEM7Fklm+ BfuDoea7Yn72O19ioCZKhzncxmaFvy9jKDbizvSQfBolDhEpPBTACUv1Pk86fLLUOreW No6Vhn+HaXOyVqrjGTvFR5/DyIgPz3V/s9dWFLWtxj7aB4EjtUqhcE4rX5A+z+60lJF5 2VWCM/v63FJJFvR8LKqv5VCnQh+Wqa+Uh18ZbWbeZuMIi5ccTSaASHG2j4nhyUZuFEPB iw2dCW+qURzZo7PDE/IGJKPQZbOcc7oIA+gKaqqUnacA9PbS+O9X9j/DgT/FN9GgGYJF WgUA== 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=f2k7WPXYHIuzqiFfSHfNTIZb4ikRcS6mn79essSLTNQ=; b=zHrEZ4AItJf6T9wTQDBn+V03ZkgU7Ji05dueYjvZNVb2nz0UADHTHB20+RoyAtNEau HvTvrEIdx3cluiOe7Mqt64LnDPAdqQvuThB7lG2Mnr7jfv/gVfgdA74szuo7PY3YVV/E 5/5sLAl1D50f/fJun6+XGUd31z7NLv1awgkht20ZIeMjbFCGEhmA1OVMr2k5NjDwy54U CgEfZ6O9lvX5/WkRgrsQwULEtsV8jm+33UwPD//G53b//O+Krai/gGFH79fIr2Exqfys U3hKYfjVlam0Ma75DjaE/Ud4xAbgzw4S8i/qSocEaH4cx2EfKL2LUdhSK3mk0UBoQ2L7 TTOA== X-Gm-Message-State: ACrzQf1hBlVJahZ3jUsS6Ac90yBBwjd1E3YFoX6bBopA4tGIQScx50gn XrX+E9GacTWcG/+C/9zDBTnZ1MRATDr5sw== X-Received: by 2002:a17:902:ce84:b0:185:47af:a0f2 with SMTP id f4-20020a170902ce8400b0018547afa0f2mr14185977plg.123.1666038308088; Mon, 17 Oct 2022 13:25:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:07 -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 14/23] f2fs: Convert f2fs_write_cache_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:42 -0700 Message-Id: <20221017202451.4951-15-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?1746968210367984208?= X-GMAIL-MSGID: =?utf-8?q?1746968210367984208?= Converted the function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Also modified f2fs_all_cluster_page_ready to take in a folio_batch instead of pagevec. This does NOT support large folios. The function currently only utilizes folios of size 1 so this shouldn't cause any issues right now. Signed-off-by: Vishal Moola (Oracle) --- fs/f2fs/compress.c | 13 +++++---- fs/f2fs/data.c | 69 +++++++++++++++++++++++++--------------------- fs/f2fs/f2fs.h | 5 ++-- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d315c2de136f..7af6c923e0aa 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -842,10 +842,11 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index) return is_page_in_cluster(cc, index); } -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate) +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, + int index, int nr_folios, bool uptodate) { - unsigned long pgidx = pages[index]->index; + unsigned long pgidx = fbatch->folios[index]->index; int i = uptodate ? 0 : 1; /* @@ -855,13 +856,13 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, if (uptodate && (pgidx % cc->cluster_size)) return false; - if (nr_pages - index < cc->cluster_size) + if (nr_folios - index < cc->cluster_size) return false; for (; i < cc->cluster_size; i++) { - if (pages[index + i]->index != pgidx + i) + if (fbatch->folios[index + i]->index != pgidx + i) return false; - if (uptodate && !PageUptodate(pages[index + i])) + if (uptodate && !folio_test_uptodate(fbatch->folios[index + i])) return false; } diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a71e818cd67b..7511578b73c3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2938,7 +2938,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, { int ret = 0; int done = 0, retry = 0; - struct page *pages[F2FS_ONSTACK_PAGES]; + struct folio_batch fbatch; struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); struct bio *bio = NULL; sector_t last_block; @@ -2959,7 +2959,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, .private = NULL, }; #endif - int nr_pages; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -2969,6 +2969,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, int submitted = 0; int i; + folio_batch_init(&fbatch); + if (get_dirty_pages(mapping->host) <= SM_I(F2FS_M_SB(mapping))->min_hot_blocks) set_inode_flag(mapping->host, FI_HOT_DATA); @@ -2994,13 +2996,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !retry && (index <= end)) { - nr_pages = find_get_pages_range_tag(mapping, &index, end, - tag, F2FS_ONSTACK_PAGES, pages); - 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 = pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; bool need_readd; readd: need_readd = false; @@ -3017,7 +3019,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (!f2fs_cluster_can_merge_page(&cc, - page->index)) { + folio->index)) { ret = f2fs_write_multi_pages(&cc, &submitted, wbc, io_type); if (!ret) @@ -3026,27 +3028,28 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (unlikely(f2fs_cp_error(sbi))) - goto lock_page; + goto lock_folio; if (!f2fs_cluster_is_empty(&cc)) - goto lock_page; + goto lock_folio; if (f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, true)) - goto lock_page; + &fbatch, i, nr_folios, true)) + goto lock_folio; ret2 = f2fs_prepare_compress_overwrite( inode, &pagep, - page->index, &fsdata); + folio->index, &fsdata); if (ret2 < 0) { ret = ret2; done = 1; break; } else if (ret2 && (!f2fs_compress_write_end(inode, - fsdata, page->index, 1) || + fsdata, folio->index, 1) || !f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, false))) { + &fbatch, i, nr_folios, + false))) { retry = 1; break; } @@ -3059,46 +3062,47 @@ static int f2fs_write_cache_pages(struct address_space *mapping, break; } #ifdef CONFIG_F2FS_FS_COMPRESSION -lock_page: +lock_folio: #endif - done_index = page->index; + done_index = folio->index; retry_write: - 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; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - f2fs_wait_on_page_writeback(page, + f2fs_wait_on_page_writeback( + &folio->page, DATA, true, true); else goto continue_unlock; } - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_compressed_file(inode)) { - get_page(page); - f2fs_compress_ctx_add_page(&cc, page); + folio_get(folio); + f2fs_compress_ctx_add_page(&cc, &folio->page); continue; } #endif - ret = f2fs_write_single_data_page(page, &submitted, - &bio, &last_block, wbc, io_type, - 0, true); + ret = f2fs_write_single_data_page(&folio->page, + &submitted, &bio, &last_block, + wbc, io_type, 0, true); if (ret == AOP_WRITEPAGE_ACTIVATE) - unlock_page(page); + folio_unlock(folio); #ifdef CONFIG_F2FS_FS_COMPRESSION result: #endif @@ -3122,7 +3126,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } goto next; } - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -3136,7 +3141,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, if (need_readd) goto readd; } - release_pages(pages, nr_pages); + folio_batch_release(&fbatch); cond_resched(); } #ifdef CONFIG_F2FS_FS_COMPRESSION diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..d7bfb88fa341 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4226,8 +4226,9 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, block_t blkaddr, bool in_task); bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate); +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, int index, int nr_folios, + bool uptodate); bool f2fs_sanity_check_cluster(struct dnode_of_data *dn); void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page); int f2fs_write_multi_pages(struct compress_ctx *cc, From patchwork Mon Oct 17 20:24:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630830wrs; Mon, 17 Oct 2022 13:33:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5mKbD9YQ37jtw/j608ryhrI1L9IAc91cehMXhsE7UcqT8O0Y5I/vfZUb0QpKV+MbSNDcH5 X-Received: by 2002:a50:fe85:0:b0:458:5562:bf1e with SMTP id d5-20020a50fe85000000b004585562bf1emr11672737edt.167.1666038780903; Mon, 17 Oct 2022 13:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038780; cv=none; d=google.com; s=arc-20160816; b=JCop4slXwA4FBkx2S09mEzCTgOqHA5QBAck/wEkNqFREynzr2DB+VJXHaNgJ3nLVTw hP5p3/93Ox6xlRFKKv/ev/Dg+zPz77l9v5AETGbTTF+QNAUlgnipp/cC3v8tpX9bx6ha NC90xEolirEE/JqeMh/7Tx/LMkRVlWUovsSH6jLCEbCVaVGQ/P4gYNXb+7nN2unaV+lP jo6eGCZwR/b2TaUx0KrovP43Vwfkk4WUeHeGMCSZ6tQMe8MkjJ0lTP0XWxcdmVEqlMFT /qkxM632nZxMQ2J/pdvFkIFQLeu6gS9VNOlIUkjjtLFT5ppdZkO6QrcLUVR4exNGO8si G2NQ== 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=EOnFNLr6WPd7tItI5uxkca8Truk0f560xSuLirSKI30=; b=TZYUxT6KSZ5MYPjTLNfdTEEuPsK6Hp34/5N9nrlC4t2AYTpnr+5ONFl+MlBBKkMVBO Wood86gcqAMBPPm5Ge0otlxbspwafz5+y1OOwb/nultOhmb0rOtBsPdgIWjjEy43v6ok Ibj7z3L2J3HYe6XohyVrqIjLAG0ndNnA1nqlfUT949UBlPp4RZELgn8n6F4dPf5HRZzL BhE5A+GKKfGauMlpmNhhw4yuOgYJnsAgwULsqlduf1PfVFsOwFEFMC6I5q5uUWZXUzMS YynC88e+Gd59J95IL5M9wXF8X7p8zU3rA4mepN09kDWGlvRQUGetm5YWP4n2Aa6mJhHB vqng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ebrl+ffl; 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 dz13-20020a0564021d4d00b00458db439f07si11429128edb.14.2022.10.17.13.32.34; Mon, 17 Oct 2022 13:33:00 -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=Ebrl+ffl; 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 S231129AbiJQU3P (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbiJQU07 (ORCPT ); Mon, 17 Oct 2022 16:26:59 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D717E835; Mon, 17 Oct 2022 13:25:45 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d10so12137650pfh.6; Mon, 17 Oct 2022 13:25:45 -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=EOnFNLr6WPd7tItI5uxkca8Truk0f560xSuLirSKI30=; b=Ebrl+fflonMxXmYbjzZ0W5FnuUgF1ENZ6beNYeaCYzgPsSFFFY2nuwfTKiz2FudAe/ 7ZKdf6z/O/+HYjYCpK8ChxO2CQY7gBGoDhDIU1UeMcG99x96VPKcLvY7daaxIL6HByus /5yfixBKbG6rVzNv4/ZTcQkFvGUMjjvk2/T8YJVcM+iPU6/Q8umaLAUYJtaxOxiT1yX5 slob1M+6u8lOpnGyvViPT+9/xv790R5/qWr3BkN0/2P0geRVbBZeT1bsX1UOhX0vCD6O vBYMGTV1jDQT8d5fBXvzef0tlyd90rL/RgBQhVdelCPIZRq4EycvfekOVwfGoK8elKWC hXqg== 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=EOnFNLr6WPd7tItI5uxkca8Truk0f560xSuLirSKI30=; b=C95pPs0mChxlojNmZTrZniHF92JyqVVZbWeaemLqxqPOla+NcT/+nMTa1QbYJHR6/y 8Uyf8Zx22A6ffr4tIYk0kXQ5G2B+rURiZ/SGsLQj9+sGRa+3KS3mSrTxMFuATQPrA9R9 Uoh6KxDTubbGt5SWupNBTWHx9962a2TKpaE+n0lNe8SpxKxhRLzkf9/Va1Ixhe1dfBsD 3y7lmm0s9TqiYiGwDSlI/JODHqxRMJkCpFfStg+HMlWcN9EWYLzPh3YmqIw+4aLAL80H 7OQTkG2I+B/tw0SDufCUxUamqsHk/TjDaQb7abEz5JQPtJhIT8y1JAzHOtRyPjBTqkt4 thfg== X-Gm-Message-State: ACrzQf1z4Phb+0KEdgojl6tC1kfcfEhddTxXRDDZ7wsFWD8SxD+9uM3Z cf1O3XcYI3huNQDLAOWW/V/ry5tac29HXA== X-Received: by 2002:a63:5b5c:0:b0:440:8531:d3f6 with SMTP id l28-20020a635b5c000000b004408531d3f6mr12503042pgm.114.1666038308965; Mon, 17 Oct 2022 13:25:08 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:08 -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 15/23] f2fs: Convert last_fsync_dnode() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:43 -0700 Message-Id: <20221017202451.4951-16-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?1746968280477774579?= X-GMAIL-MSGID: =?utf-8?q?1746968280477774579?= Convert to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 38f32b4d61dc..3e1764960a96 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1515,23 +1515,24 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino) static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; struct page *last_page = NULL; - int nr_pages; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &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 page *page = &fbatch.folios[i]->page; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); return ERR_PTR(-EIO); } @@ -1562,7 +1563,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) last_page = page; unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } return last_page; 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. */ From patchwork Mon Oct 17 20:24:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630240wrs; Mon, 17 Oct 2022 13:31:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5IW+kz0wv4+JBNH9+1Kbco1gbaWw5mzk9H4C4ddjpKzLatxcx49/RgyxRJNVS4hGelEx/r X-Received: by 2002:aa7:c314:0:b0:458:dc90:467a with SMTP id l20-20020aa7c314000000b00458dc90467amr11313920edq.284.1666038686590; Mon, 17 Oct 2022 13:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038686; cv=none; d=google.com; s=arc-20160816; b=0AiEEsSF1Gp8tpkgGoN9xTKcji6pfsQ7BkmthyOdIshYtZSg6YEYSi1shn/8n6/0tX DJEUR1JiIYqeGbzRDPPyStLZD+ERM781QpAhz7hFkNKgmwejdc8jgML827tEg7nx2fB2 th3dmqHesUeOYc1z7YNDXB1uRt01QKYpHu38aF7J+6Ozc7UyLCh2pj4+4Jtr8ItVHvSB EGpWEudxLxSlSXBUCesgvzWQTNGfv6cgdDzi+qWD7abn43kK2rbC3KzUCaQvzM++0aa7 U0W1pbxnyCEl++UvVLNv1oi4MlHAcsFEiDq40HeB8hYJvJefooUyojFEqzPZmBlDb3dA iMMA== 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=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=HmV8fmiXMXv58YpJOFJjzKPT61S+jMC0keZfID2+iFg41QTVCD2FPpjLd7d06TALq7 UntnIu72HrA37aF+1GwF/aZbZo5JyYMg/Qlo+/NvO5xp3AQTY0uuTvBcaS0r20cGLPr8 Nn17WtbXi1kQbnGCKT2LVRPUmLbMuvHUVPbEo5wNS0OdDgKi8l5YSwg8MJVZXJ4LUWjj CNIKqlx46TqMixMYFtwKMjWVoc20wxOxFufncvPdhKBve4fCuWctIWmCoDdsqyAu52RJ ayR46mtkFJoBiVqoNOXGoTEsbkJlipFxp85AWcI1YwomX0IxKaeFbBa6u4ljun8nbiIs ss/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RbTnAa8O; 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 y11-20020a50eb0b000000b0045b50cee511si9069823edp.122.2022.10.17.13.30.58; Mon, 17 Oct 2022 13:31:26 -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=RbTnAa8O; 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 S231283AbiJQU3L (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbiJQU1B (ORCPT ); Mon, 17 Oct 2022 16:27:01 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B8F4F1A9; Mon, 17 Oct 2022 13:25:46 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 128so11470974pga.1; 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=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=RbTnAa8OOU4bDfi05kBTS9XDQ6dgydoyGwgm2rAdlFuvDFKeJuTkR8cnp53eKSf2oP GzH8nisCG30X3jC1jl/LDcARm0rVApWqQVklxfmYAUvmTBu1AiZMoHb/94egUBPM1Hli zgZrL1ZfgTfDSY5qgxRLDSXd8k2yUZEjzXFgS8YFRuA/xZy1my2JfSRju33hwVEfedHe IsvYWmsBPX/KMv7/MjK+ai9AzBODwj7EhLvkMf7Mu/SBglvbuU403QvVjoZ1FQXLB8UZ +/dlwHXGwvn8fgYVCx9ihTT4XjorgHA56f2n+r/pzV+hOGYKhyzHOkTnNTVI8GPoU7jE aXaA== 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=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=N5ZO0iRpowkIFCS3pBNMqprBGLzM4V7wBB+pGIQkfhudvUEJ4TWTCubNoi2H+bgJ9Q gC8S+Wi14GWb8QYIjswkGKZggA8osWlpwgob+fDxHwgK69iznRoiUtTOBj1b/5FurciH 8C6IVEdLvitTv1eLVXdccwf+rX6MzD2C4mnsLEY0LQlDtGR+swp7obTl8NDHrxbh8EfF dBv44xJqUt5z+NVq1sTiwANjyDwnQaQAYh1j0POG0fNBTYhhtw1AnUyQS3etUB3TiKKP yyHcNXh/mFpRcamv1rsu8p+ztzher3ZIILQpyvUiiXMkROzYte18KYlfE7pLymNVwdlC 3yHg== X-Gm-Message-State: ACrzQf3GAAuAe03r5Bkd9446cEI+d0DqddIpKuDkn9H4K1QkEybJfa1g CeMaHXdn4D3Rj8CPZpndDxZW3WSO3SjnAw== X-Received: by 2002:a65:45c1:0:b0:461:5855:8d86 with SMTP id m1-20020a6545c1000000b0046158558d86mr11945929pgr.436.1666038311051; Mon, 17 Oct 2022 13:25:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:10 -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 17/23] gfs2: Convert gfs2_write_cache_jdata() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:45 -0700 Message-Id: <20221017202451.4951-18-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?1746968181659506219?= X-GMAIL-MSGID: =?utf-8?q?1746968181659506219?= Converted function to use folios throughout. This is in preparation for the removal of find_get_pgaes_range_tag(). Also had to modify and rename gfs2_write_jdata_pagevec() to take in and utilize folio_batch rather than pagevec and use folios rather than pages. gfs2_write_jdata_batch() now supports large folios. Signed-off-by: Vishal Moola (Oracle) --- fs/gfs2/aops.c | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 05bee80ac7de..8f87c2551a3d 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -195,67 +195,71 @@ static int gfs2_writepages(struct address_space *mapping, } /** - * gfs2_write_jdata_pagevec - Write back a pagevec's worth of pages + * gfs2_write_jdata_batch - Write back a folio batch's worth of folios * @mapping: The mapping * @wbc: The writeback control - * @pvec: The vector of pages - * @nr_pages: The number of pages to write + * @fbatch: The batch of folios * @done_index: Page index * * Returns: non-zero if loop should terminate, zero otherwise */ -static int gfs2_write_jdata_pagevec(struct address_space *mapping, +static int gfs2_write_jdata_batch(struct address_space *mapping, struct writeback_control *wbc, - struct pagevec *pvec, - int nr_pages, + struct folio_batch *fbatch, pgoff_t *done_index) { struct inode *inode = mapping->host; struct gfs2_sbd *sdp = GFS2_SB(inode); - unsigned nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits); + unsigned nrblocks; int i; int ret; + int nr_pages = 0; + int nr_folios = folio_batch_count(fbatch); + + for (i = 0; i < nr_folios; i++) + nr_pages += folio_nr_pages(fbatch->folios[i]); + nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits); ret = gfs2_trans_begin(sdp, nrblocks, nrblocks); if (ret < 0) return ret; - 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); - 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(inode)); - ret = __gfs2_jdata_writepage(page, wbc); + ret = __gfs2_jdata_writepage(&folio->page, wbc); if (unlikely(ret)) { if (ret == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); ret = 0; } else { @@ -268,7 +272,8 @@ static int gfs2_write_jdata_pagevec(struct address_space *mapping, * not be suitable for data integrity * writeout). */ - *done_index = page->index + 1; + *done_index = folio->index + + folio_nr_pages(folio); ret = 1; break; } @@ -305,8 +310,8 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, { int ret = 0; int done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t writeback_index; pgoff_t index; pgoff_t end; @@ -315,7 +320,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; @@ -341,17 +346,18 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && (index <= end)) { - 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; - ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, &done_index); + ret = gfs2_write_jdata_batch(mapping, wbc, &fbatch, + &done_index); if (ret) done = 1; if (ret > 0) ret = 0; - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Mon Oct 17 20:24:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629990wrs; Mon, 17 Oct 2022 13:30:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ruQsNa1PcuenQzvkAMAIq57vAxYuWLu6PU/O58ccTHUl7B/fqXmSLveebcvLLJtrmlA9Z X-Received: by 2002:a17:907:60c8:b0:78d:bc8d:8457 with SMTP id hv8-20020a17090760c800b0078dbc8d8457mr9933049ejc.418.1666038649042; Mon, 17 Oct 2022 13:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038649; cv=none; d=google.com; s=arc-20160816; b=F6RGYvnSC0FlBl/7+5TYu4XpuyUGhEfayJY0ZaH2sR30vrTKEhJ8TzwMOYzyeUjlp4 8EPjHo4Umy1LMSEt2qwRW2mFG3O4N7y+m/86ACZxE/tnjzKFHvUakQbZJdocvTiqeBzh JtrchV/OIsONAeMWae5H+E2fJPucDCgpJGwjtOb1183i+rY2cITPqfgtLiY6Kz9iVN+e g6WqeGUA2FcgQFbwJLyk1DfRUnOzpAJ8ZsCJdL+hUD2isdCDv1+ADeSZbkJ0KpvyU4fy zXpn8VzNQe+foFnSoeAq+wVUI5rQqclJ6Hs1zNsCshJ0dSOWcBLd/9GlMOCRoS2UP+Nl CE5Q== 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=HDAaQjWw9mFQrxjxUUwcIUCSC2HAIvgNCPk+fwsNTgA=; b=h0fg3vr0elpHsax73CaYVsZsEg9ANtPdP8tO/2Gf5uaZHl/cZiC88y1wX7WlP2NdxL WorgxdLj0mg3Rm8RPu1soKTDKRSredT+ZTREnZj0Or5rr1zxOTn+Rquf/d87gv/4vgkn nIu76bxZscd9ktOg3FUFOit7bHJQBM+YWwPNLrhprXJasquuxAOOc9OqKdlF9HiPCwds Eubn7gEkLJjpk/HCjpcp93AEuxojK1wbLMrwaJNb6KbfAhiYa251jomTIY3LBiT5mRj2 ZGYjLIN54IITaxMIoXumbTP/pWTKsWEoAkc+YGIC3Dz5nawEzQYUDDspfp2bo6yc7y2A FrVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KyZrIS2c; 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 h17-20020aa7de11000000b0045992feabd9si8331389edv.132.2022.10.17.13.30.21; Mon, 17 Oct 2022 13:30:49 -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=KyZrIS2c; 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 S231705AbiJQU2i (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230362AbiJQU1A (ORCPT ); Mon, 17 Oct 2022 16:27:00 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50037E83C; Mon, 17 Oct 2022 13:25:46 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id l1so11789228pld.13; 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=HDAaQjWw9mFQrxjxUUwcIUCSC2HAIvgNCPk+fwsNTgA=; b=KyZrIS2cRBI9Wi/s6j+k5Un+7xp/wwbjLfcNmkVss+gpEVM+6g9eB8E+kDr4ib/o9h aHZiqvGPcTO1RO0jkEq+CHtdYaQKQfVuoWerdbvVDifz5h14hCHY1ghQf1SL3/CEdh11 opq+bBxZbhYQFO+7l9ipSWqSYpcVET1qxgS/dFbZ3YpA8WAY5aRBjLdlXQ+GF1IEYumz mhbeFFWVxeBoA+sLdrLdfFPXm81t+2pA2/aP8VFL3BoQvWah+LWY3LmumYhfXUeul7r/ qn4+/zr/qr23Eqfc68ILRUEWUJNu0aVAW3XQ2taH9/TvZGJMRKjkxGOL4AtxxdlkSFnb Lm5w== 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=HDAaQjWw9mFQrxjxUUwcIUCSC2HAIvgNCPk+fwsNTgA=; b=S/vJbqpl9QLK4LMYeF9sWeATRLx81rz9Lh5ODLtS9V+vujCyAn+GX69M36ZYdJnTZP e9/Ldh8AD3U8nYJWMF5IcwR/z9v1F0R/qQJE+LyC/U+C/Rz6AezwfjH5+FL5fcZtipyB 6SNgLflRpJFsDIyiZronayw13gu3TJF7xVnuGPt9Tiwr0K0oW7JFV6KuybZq4JrR/Vxa kwFZxcs0MoOCmxYHraPTFpoDShJEAKavlA+8n7O/yc3iVge0cVTFZk6xtDQmLShRzBB1 M7v/RdxXFNgqOutWRDIW+XZU/o3PhiA6Vhu/abtkfljO3aRF4GqkRoz+WnEBugeUz9oA 1Ucg== X-Gm-Message-State: ACrzQf1R5BSwAVxipBa35F1r0p08afXtY9nkfR3L/3+U50OqwKLQ8gwg SmlsgUEsrHBPhJfwx8yibdmZ6niqfqlUVQ== X-Received: by 2002:a17:902:d714:b0:17f:5813:1df4 with SMTP id w20-20020a170902d71400b0017f58131df4mr14158278ply.148.1666038312014; Mon, 17 Oct 2022 13:25:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:11 -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)" , Ryusuke Konishi Subject: [PATCH v3 18/23] nilfs2: Convert nilfs_lookup_dirty_data_buffers() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:46 -0700 Message-Id: <20221017202451.4951-19-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?1746968142277912925?= X-GMAIL-MSGID: =?utf-8?q?1746968142277912925?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index b4cebad21b48..2183e1698f8e 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -680,7 +680,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, loff_t start, loff_t end) { struct address_space *mapping = inode->i_mapping; - struct pagevec pvec; + struct folio_batch fbatch; pgoff_t index = 0, last = ULONG_MAX; size_t ndirties = 0; int i; @@ -694,23 +694,26 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, index = start >> PAGE_SHIFT; last = end >> PAGE_SHIFT; } - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: if (unlikely(index > last) || - !pagevec_lookup_range_tag(&pvec, mapping, &index, last, - PAGECACHE_TAG_DIRTY)) + !filemap_get_folios_tag(mapping, &index, last, + PAGECACHE_TAG_DIRTY, &fbatch)) return ndirties; - for (i = 0; i < pagevec_count(&pvec); i++) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { struct buffer_head *bh, *head; - struct page *page = pvec.pages[i]; + struct folio *folio = fbatch.folios[i]; - lock_page(page); - if (!page_has_buffers(page)) - create_empty_buffers(page, i_blocksize(inode), 0); - unlock_page(page); + folio_lock(folio); + head = folio_buffers(folio); + if (!head) { + create_empty_buffers(&folio->page, i_blocksize(inode), 0); + head = folio_buffers(folio); + } + folio_unlock(folio); - bh = head = page_buffers(page); + bh = head; do { if (!buffer_dirty(bh) || buffer_async_write(bh)) continue; @@ -718,13 +721,13 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, list_add_tail(&bh->b_assoc_buffers, listp); ndirties++; if (unlikely(ndirties >= nlimit)) { - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); return ndirties; } } while (bh = bh->b_this_page, bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); goto repeat; } From patchwork Mon Oct 17 20:24:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629985wrs; Mon, 17 Oct 2022 13:30:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4N9u/Kistf4NQd/DY0Daqm0jdaXWfj3oG0XcMtlWmVPEd//AqpahvWSeQ9pDYA2hdRq7qT X-Received: by 2002:a05:6402:40d0:b0:45c:ffa2:4b5a with SMTP id z16-20020a05640240d000b0045cffa24b5amr11972154edb.341.1666038648655; Mon, 17 Oct 2022 13:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038648; cv=none; d=google.com; s=arc-20160816; b=dxYtXFjF9WM+Kv+WGF9SdsUSkObBvffHXHO/FoISiEKUSs/BTAJpKucLjsAs3H8fAl WovazOOqtfXXhcFxiQc4hWhyB5DwYkh43c3hsoA+cjKsUCiHiE/e1YRlAUJfQI1dWp/i BW7OvVl2CXyFb4y2txHMEm4FAhMLy3l6mvh52qjOAs88uwFN3dgHVE8U+o01AaN8r7DO Xy0ijeXIuuYp8Q8Bf6lCUNqS3WKXYRvZNIc+MYxV5VMI+1kuf7KYU8sDgIU+k8QHDtAR r3mjPNG84zw8qYzznDF8G/svjHRl1PEbue8HgEmU5mnIJWWA6VbiPTEBaKOHXoXMO03e hlOg== 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=PjCPDi1AZDHrB7VlRdP/cqyMu6n+VbdajeULasyuImU=; b=mI6Lph7z8Yh1Ma9OV/vJI/7ppunKH9TkLD6a07qwrtXf8D8axZGvE4v/GLyMyb/soH pyU0Y40C8sJbjCn/ZFXNARyiojoS0hmnag9yoCuQblyctz/5GS4lkKjcXu6EOMxhkwdg EqcVacPpL/d9aq//2De4n020ab3Oagvnbg9xpbIaJod5jzC8Ak0H0IIuDBK0FPfJqE8/ wpZbF8CNOWLzRiaczEAq//oiquAS5zf+glVXJRMLOetCbrHdM9xuNdpZWGmqvm1xPbK9 518z9prWJ0PLJdxdsZFzIKJtvgRI1iaMbMwbPvewsZDMc5VnBG3J9p6x7K0wnbSVkT4v uUZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qk4yM75o; 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 f4-20020a056402004400b004588172def1si8531073edu.410.2022.10.17.13.30.19; Mon, 17 Oct 2022 13:30:48 -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=Qk4yM75o; 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 S231726AbiJQU2o (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiJQU1A (ORCPT ); Mon, 17 Oct 2022 16:27:00 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E37077DF6F; Mon, 17 Oct 2022 13:25:46 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id 67so12111231pfz.12; 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=PjCPDi1AZDHrB7VlRdP/cqyMu6n+VbdajeULasyuImU=; b=Qk4yM75otecrzeUngFuKVCGaeUXfETNaFI0p6N/nABjpdCTLoTvjKNLJZ9OllX2bwP +U+4YR9Pv2UlaBNn4Ln/tBqDVA5+5H9uo8/ty5z3YSkoXkt/t+1/eR8X1FXv4Ci+T49/ wSVeFfxPMGrcmtuVOElrygDRrVNHoyFvAO+52XX8XFX3fZxBUKvCeAeRlBBlvxD+jYUA hW/fboSfjF2JsTe1GHEut4uWvlw1NT8ZvKkfI2RSo40rbSyNsY3uBQc7Sbd/6dY7EIEd 1BRYOETZSIBmP7Zq93eqEum+LCrtx8kl0OnMaxT9yXrWMw3yXtWBRbeDNWR3Teap7EmM YJZw== 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=PjCPDi1AZDHrB7VlRdP/cqyMu6n+VbdajeULasyuImU=; b=GnQ/qLgZIcDrHc8ZAzeCAzEj1xM09bz3XXJI2WN3MOq19yZcuE1yiA7/T5uCof1588 wOwIOx4USWzeM8hHmaxDPXPleC8YAveRTELc+JQr7d9bAKoH7as3eVROhnF6BrhWX54g At61z+I01OIE2qZ/B5NzkeM45M+1HRRQvS9veqKj1+nrpyhtl0aaA7CWwYExlgIaGCgW lIOkitEn1qTbk72CJUUlf+CMF+NTCgExHJJeFdtecZD586tJ2wIIku+A8ZthFYZpZ3aw jCZu3eAoqczWDndyaZi7Iqoa+CIgXMiDbSD8uQUCCzW3ZvKWyK2MnP2kbqUe0lFwQa/z hQhg== X-Gm-Message-State: ACrzQf2PwoarJMefj74RyE2f1Z8AP9t7cIr0OLVaYEI/4T9rAVTXZLEc ts0tgsjjX3ac2QUqpj5+53mgEFmh2sKHfw== X-Received: by 2002:a05:6a00:194e:b0:566:5da:ea67 with SMTP id s14-20020a056a00194e00b0056605daea67mr14416761pfk.77.1666038312970; Mon, 17 Oct 2022 13:25:12 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:12 -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)" , Ryusuke Konishi Subject: [PATCH v3 19/23] nilfs2: Convert nilfs_lookup_dirty_node_buffers() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:47 -0700 Message-Id: <20221017202451.4951-20-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?1746968142041468374?= X-GMAIL-MSGID: =?utf-8?q?1746968142041468374?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2183e1698f8e..fe984def1b1c 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -737,20 +737,19 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, { struct nilfs_inode_info *ii = NILFS_I(inode); struct inode *btnc_inode = ii->i_assoc_inode; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; unsigned int i; pgoff_t index = 0; if (!btnc_inode) return; + folio_batch_init(&fbatch); - pagevec_init(&pvec); - - while (pagevec_lookup_tag(&pvec, btnc_inode->i_mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btnc_inode->i_mapping, &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh) && !buffer_async_write(bh)) { @@ -761,7 +760,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, bh = bh->b_this_page; } while (bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Mon Oct 17 20:24:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630652wrs; Mon, 17 Oct 2022 13:32:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AXPkl+LO0Zglt7ToRRe/+1YDP0A74PwlH15vqwdFF4LWGuTTqSewW1Hduc86Dyn4GzI/6 X-Received: by 2002:a05:6402:1205:b0:458:c1b2:e428 with SMTP id c5-20020a056402120500b00458c1b2e428mr11727520edw.94.1666038746486; Mon, 17 Oct 2022 13:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038746; cv=none; d=google.com; s=arc-20160816; b=PE/DQ7dhZwj608YQkdFBaz3N6lv/Xs/za8NVWZ/Bdap6usSOQtDYSa+hUm4TtZdjRz PAor1B20SyQ9K5ZC/RJlgkkkChAzFnnW6HTnKSjiycRe2FujIXWtny9B8F+DL8ZZz1/l lpM6D2GrS2K5ExTSMIAw8z54UGUcM0N9NJuAhmCoE+L139Od8EMaueTEddExWovWYVLf NtOd2ZbiYuxK7Tql47ykLr95JVcCw4EG6knTkFxzrLe8ddlsnKvdAaIBKXpNWPpHGPZw rcND/Xn5HO9FGU7EIR//mltx1uwJpYm5kTBwNBHcGSc4X+8cn6mNiP0w2WIubhkVvoww 9A/Q== 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=BQteUz3c9SmxpbrkCwFkAif0aIJ90TCQG7A+tAmDyzA=; b=BwxfdWotdSsp+zu+UTBAQnltcl4xi6briagObjlWm1V/enMLwNoHlLWgqsC9hqOvZz MPD5LTUa1Z9/DYSXY+pVb12oldBXHczDb8pW5Qlmu/GFUfyuO1Ml2lR3AmgxE6VyZpTs HUjW8uE1m92ri/Y/3cg/+ef0PXwKvccl4s+YiLcKB399wo05LeAkVrq+0wEnjNcjg92n OLE2KPOCFjfdslvJKdYkg0HChMgdwczhhU6+mvqnI4oY7A3f/1YV1sAMMTJDKQKwxr/S p3QZSU7QeReFPpbND41Con2BCFFdqhbZm+3+dE2hu1BjbC6Dv//rY9SMrLX8li54sx/v IT5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Fjdsm+Pk; 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 w12-20020a1709060a0c00b0078ddff4b3absi7826711ejf.423.2022.10.17.13.31.57; Mon, 17 Oct 2022 13:32:26 -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=Fjdsm+Pk; 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 S231666AbiJQU2c (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbiJQU1B (ORCPT ); Mon, 17 Oct 2022 16:27:01 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 609477EFC6; Mon, 17 Oct 2022 13:25:48 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id 67so12111271pfz.12; Mon, 17 Oct 2022 13:25:48 -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=BQteUz3c9SmxpbrkCwFkAif0aIJ90TCQG7A+tAmDyzA=; b=Fjdsm+Pk28Zc97Y3NfxZL728h8TE5RyApTDow3aidnlAK3LTkxWjYLDilgvIsLE/vY DG2gnD/1V7xSRF9OsJCuy+QagbO7ftNrkZXcC/buneGyVqq9VL7AeRJOtRVYGhe2g3EB a/blG4d7UpkK2Y2MOZagl8fy+aFT9x6oOzcS45P8bK45kIEfwM/C09l7FqmJaWnoZXwX gFZ3AcnGYu59H2kxWRp0XYa5xE9P9qVWQYQvuOmeTw7vv99Hq0namT7cuf+rd9Gkq85p 7ZTnLCbq+RCD+NDxRapqFx6sJOCTXTzxUuQk7bLK0jIgrjjyBfZ8t57LhzVtWkrgsAPJ 0NWQ== 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=BQteUz3c9SmxpbrkCwFkAif0aIJ90TCQG7A+tAmDyzA=; b=tYipH4VV39gNPycdmDeXtiw6xB+LC70XFcNGrm+ZqU+zeRrRsGQEivVbXF77iKBfzW V/9R/6upuTr0h1TVK2+6l83xwjUUBoOhIkSxAbKZmXQud+8iOOgC+DrVBP9SFL6RKpLf QoOfFLQ0INd8cXeoe2O7RK/liZ/YB+UyVJzCkW/IMFQ1J2p6Yy/JeWkZGEQEUsyJDM7w j1RqDlgelxEuwqgxHNxujrioXqksNaU/DAMEC1JK3YWFpM1x32TG/LDTLWMQoQ/9tgWi SaUrUP+Yw+tCc49zgvrLQVGjo1eaaCBlU3MTvENyLE43AJrA7jHE/2EZV3k90/TIbH0J HsWA== X-Gm-Message-State: ACrzQf0bzQk1Syu5PzlKPz7jFUwJ3Sny/ip1rBOIQK61Q7cMCWBvEdOd c0PBlFJJg14sdCcRxnwFpmUX379gjem+/Q== X-Received: by 2002:aa7:8a15:0:b0:566:1817:6fcf with SMTP id m21-20020aa78a15000000b0056618176fcfmr14383803pfa.85.1666038313899; Mon, 17 Oct 2022 13:25:13 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:13 -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)" , Ryusuke Konishi Subject: [PATCH v3 20/23] nilfs2: Convert nilfs_btree_lookup_dirty_buffers() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:48 -0700 Message-Id: <20221017202451.4951-21-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?1746968244359288922?= X-GMAIL-MSGID: =?utf-8?q?1746968244359288922?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/btree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index b9d15c3df3cc..da6a19eede9a 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -2141,7 +2141,7 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, struct inode *btnc_inode = NILFS_BMAP_I(btree)->i_assoc_inode; struct address_space *btcache = btnc_inode->i_mapping; struct list_head lists[NILFS_BTREE_LEVEL_MAX]; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; pgoff_t index = 0; int level, i; @@ -2151,19 +2151,19 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, level++) INIT_LIST_HEAD(&lists[level]); - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, btcache, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btcache, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh)) nilfs_btree_add_dirty_buffer(btree, lists, bh); } while ((bh = bh->b_this_page) != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Mon Oct 17 20:24:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629769wrs; Mon, 17 Oct 2022 13:30:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5g2G+Ottracz0F2CLlDwQadDeRbOJjLrylskwQuIt9P+oYsr9w03gc1gSdRD/pkWrWXYK4 X-Received: by 2002:a17:907:608f:b0:78e:1b60:60e2 with SMTP id ht15-20020a170907608f00b0078e1b6060e2mr10268290ejc.382.1666038614413; Mon, 17 Oct 2022 13:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038614; cv=none; d=google.com; s=arc-20160816; b=eZ+9RGnnvOPTnhkUsQ9RqFtX+POYyC6jnZ04s/jcJZfFRdr1SuEGUZFz5mdtX8mfFJ 4qOt6MXNelPhXGjcmaXvkwaSwRppn1PRyglGAb089lDE/hDHlzxXetIgSr2LwJIavXiC CdsRACG1B7Upl3HKLcuSiuzIsrjpim1jLuu11DedWVXkrENwxM7PedYs1x58pXQ6dvgO JZHPf0F1FtwPPH3+Ptqd4f8uFnckMW0WrT8LoNfbKfgYLsKn2xnWFMtc9Y/MhVDEgkJc ps9d53+2HGQfDRNmxJfI1LFP4e/lPMlSIlhdyGaCIkt587tPN1BJnIAnHEJFvfnd0kdF qhLg== 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=E33K4tt62trvRpPvq+30izBLUL0IuVPL5OXIZrHr8HE=; b=IQGgLhWm4F9y3F/+Yu5BFRyw63KqZ6qZce+Jev6FOCsY8IV1xTz4mGbm3sQvGxtOZ0 mlrisijx1fjQxnOSlylglzx9hO1/X3opKIlC9rhIrbF87tMcIaxmPZYcvc6LnXBG50Ho XgYTcNGIAzB9R9Ve4DPnfZIshD1jn43xgHkZh/YxSnp8kjgfEm9jlU+2CmYHF0da9GjC Vz5FmF633OxR57uWPmREQgKsHZeSAfAmj5a1sGj00n8QtbqZ/bQTstIcO1DmVSJYnuA7 /80Nj4YGQYpsNWH0shOyI54NKvGcI/7TTXBE0tgA8KYdhXPVYpnq6OIn2g+oVOB5ySYx yhmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="cl1Xi/1e"; 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 cw10-20020a170906478a00b007897abccc6bsi12296188ejc.484.2022.10.17.13.29.49; Mon, 17 Oct 2022 13:30:14 -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="cl1Xi/1e"; 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 S231218AbiJQU2W (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiJQU1B (ORCPT ); Mon, 17 Oct 2022 16:27:01 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AD67DF57; Mon, 17 Oct 2022 13:25:48 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id b5so11458934pgb.6; Mon, 17 Oct 2022 13:25:48 -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=E33K4tt62trvRpPvq+30izBLUL0IuVPL5OXIZrHr8HE=; b=cl1Xi/1e0WoTPVgLswyDuFR7lxs/43LEKKD7Bo9Uw9kac9ra7cvb01UWyMEi5xxewT hyL1BtZ+mvM34/0A7+CMLc6hilzxun99rEMpx9xjsykG1vTPGkIhB0QBQ69a8Au+JrCf AfOyDw8pkWku9S+gAdDsIMskLeX96aYNe6IMl5AUvy5q7T1Ssku0uduQ+1wzM3YP9ppY 7I0Y8VcM5OTQAhlJHbjcqxwUUfDUbj/f/tlW+sAL897w74AqpJQalJRfI1m2YFF1Lzb9 r7eQ9gDkU5KFgK435GKStDS+BPmOYqtl3hyxC8hNrnbgmF0V6L78/uFd3xZV3vd3SDtq /rgw== 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=E33K4tt62trvRpPvq+30izBLUL0IuVPL5OXIZrHr8HE=; b=fGY2IbiQomX4TGiC40evXJNlzun53YMIyv8OJkdEF9igCez7MgvA3iBxqT/8r4hYxS egKWDUXVIyxpKAOm/qiPSOpfYYikK56dmWAOH3MXuQI/ZdVKU27dFLiuM1aO/qSn6Y/K k4c73wPxOutd3OcWiXviBTeRFqoWhWD2M8XghnsZaPEp6/pVsf/PuQftESFk8vvw/kcn kuMiOYdbP8+3pgg0RqElYvy3TxOsoTT2m8P8ZsmFErirIqB0wwVwevQ4xRmFKBNeTA6I ZrqMm9BHCEw8xWczjhOtYPIWVCVbOOvSSptf3Jk7ng5nl4XbU2qOVP85MfIYrs8NttwE j2eA== X-Gm-Message-State: ACrzQf0QKaxsLeehCEADA30mS2DOhHdD8xCw9weW6EDIhyvJnsXrMQBr EEu3/LAqt7R3DDW6GaQHTTMCY9tllMC5jA== X-Received: by 2002:a62:584:0:b0:55a:a7a5:b597 with SMTP id 126-20020a620584000000b0055aa7a5b597mr14379661pff.71.1666038314860; Mon, 17 Oct 2022 13:25:14 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:14 -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)" , Ryusuke Konishi Subject: [PATCH v3 21/23] nilfs2: Convert nilfs_copy_dirty_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:49 -0700 Message-Id: <20221017202451.4951-22-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?1746968105898280922?= X-GMAIL-MSGID: =?utf-8?q?1746968105898280922?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 39b7eea2642a..d921542a9593 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -240,42 +240,43 @@ static void nilfs_copy_page(struct page *dst, struct page *src, int copy_dirty) int nilfs_copy_dirty_pages(struct address_space *dmap, struct address_space *smap) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; int err = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: - if (!pagevec_lookup_tag(&pvec, smap, &index, PAGECACHE_TAG_DIRTY)) + if (!filemap_get_folios_tag(smap, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) return 0; - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i], *dpage; + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i], *dfolio; - lock_page(page); - if (unlikely(!PageDirty(page))) - NILFS_PAGE_BUG(page, "inconsistent dirty state"); + folio_lock(folio); + if (unlikely(!folio_test_dirty(folio))) + NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); - dpage = grab_cache_page(dmap, page->index); - if (unlikely(!dpage)) { + dfolio = filemap_grab_folio(dmap, folio->index); + if (unlikely(!dfolio)) { /* No empty page is added to the page cache */ err = -ENOMEM; - unlock_page(page); + folio_unlock(folio); break; } - if (unlikely(!page_has_buffers(page))) - NILFS_PAGE_BUG(page, + if (unlikely(!folio_buffers(folio))) + NILFS_PAGE_BUG(&folio->page, "found empty page in dat page cache"); - nilfs_copy_page(dpage, page, 1); - __set_page_dirty_nobuffers(dpage); + nilfs_copy_page(&dfolio->page, &folio->page, 1); + filemap_dirty_folio(folio_mapping(dfolio), dfolio); - unlock_page(dpage); - put_page(dpage); - unlock_page(page); + folio_unlock(dfolio); + folio_put(dfolio); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (likely(!err)) From patchwork Mon Oct 17 20:24:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630849wrs; Mon, 17 Oct 2022 13:33:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jwkdKEBifFZGNlzL/SmLzlQH/OmTr4aD2tYNHT+PT8dr6VMzuy07AZeL4bZfp/8W0fBMI X-Received: by 2002:a17:907:272a:b0:791:994d:fb6a with SMTP id d10-20020a170907272a00b00791994dfb6amr1701595ejl.337.1666038785835; Mon, 17 Oct 2022 13:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038785; cv=none; d=google.com; s=arc-20160816; b=AskyhTWDuau0JkS/viCRy4QUtBtxlMLkV0iOQCeubVxAP2FJbSXYHT5oOAPhZkN4x6 J+uL0UvJIEwPApV6Kfp+Dwu9Z2xw79bdTHA48k6obkaTUCJoTttZ/hXn5kRVrrpaTMe5 24q/Va7OeZBlAMlI7PPH+FvMlX6H3WLKCQQlT7VYeqSqwzY1MH/8Eu2VzVJj/hvoicjj xldq+A+PyBMOLDIpKoXZpEBlSh/MrLsBiPFyGxSZ1esuGyZPV7DfwmmwFsDNhjoNR67/ twu6UA9j0YgpW1aGqE72NJMfbVPfET9fl8w0jgImm/JZtYXqwuISKRFFKeeZVb5r2eZH 0LNg== 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=vEJiD15A68fC6SKwYs5XNRqfHJAp+vmoTIHZ0Wq7X1E=; b=tZd1rWPAkjIEwJ4d/Jp0/bz4H3aRhx71SNbwDqiTrvt4iFP2Ytmlvi1BlMnHGW+6ia ZHIu+ijllPob2coyenQJlluGftaBpWHox87mNZaC0sSdgG87uZ13VvgffreAeuGrlYXD 4rj+xnBmh9F5Ye1gSOQmwJqXxmQhlqFW4bKSJd8Kh+pzB6OdwEfdptQGdIK5eNDgyjyY 74vmvoSl8LEsEqkEC2ms1XYlaCAauBx/E05jKvhoLZC9dD3c+WyqSc9B792vp8yhuLZ9 iat8f7YThOEbgkKtpdshu3aClk+7VvwwtR5fEsfalh0xbd/FQil5b0Z27rIfDIjS+faP mLOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HuFrfcPO; 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 cw12-20020a170906478c00b007309a570223si11284431ejc.609.2022.10.17.13.32.40; Mon, 17 Oct 2022 13:33:05 -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=HuFrfcPO; 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 S229742AbiJQU3H (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbiJQU1C (ORCPT ); Mon, 17 Oct 2022 16:27:02 -0400 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 1E4DD7EFD2; Mon, 17 Oct 2022 13:25:53 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id n7so11840873plp.1; Mon, 17 Oct 2022 13:25:53 -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=vEJiD15A68fC6SKwYs5XNRqfHJAp+vmoTIHZ0Wq7X1E=; b=HuFrfcPO7PV53ayIMggGbnfzpHoeRQFhEFVQOHPc6PzciA7uBE16kgNsOTzTc1N9dJ 2hSJwfj31GhqB57Dr9/JR3txjsKxYKd0DISzk5VV/d3E3Vvva9/OdBLRndwoGjHrDXuK 3qY8DRPEAXcVMt/sdZ/bgfMCfvzda7cDqa8pI+Md0v4rCay9b1P1aDFJ+wuv/xkwhjDh 0KtsJUtybAp1KLL3S4A3UmyZmXQ8CTdDX6Bkp+k+AXUIgWAtr3eIZaG4Vz97JDWv8G7t DfxB/Jkfg4jPAEaUIknmd3fhww6CnCHqRF/goZ5vhsIyCSXiY5Ug+9SlNiOQCIqmtJWg 3FVg== 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=vEJiD15A68fC6SKwYs5XNRqfHJAp+vmoTIHZ0Wq7X1E=; b=mg32RvCntaS7btkW+bSysH7KeHRfc54xrMDT5gBOsEdMyJHGq53x5zZ0nsA++LNI0J wfo9pWpT8sjWFdXyQWorIfAIh77nmim4KDJQqJB3lywMfZbEBWDxwsgdcM5Ma5jPu1Cv P7c1cZtLtzhXH1YGYpAYN57A+PKi/Fu6npS4PoITuyKB24mEwyozYCWhGUx5az4NPPyY rr7jkqfTnVIQwfgn6ou/S2iX6hs28dcCMTOxfWO78WQe91CsjzgwrxdT0UOc82vfFDBS lLiBpwIpCzG1b0pdDn56D8m+fzw4njZsP/CDMShVtDQ6JHeP6NbV60Hu2EUw7/eCzmfK 4BLg== X-Gm-Message-State: ACrzQf22MdDwDc0EOOsINsSbL5koz6HpRHShv+O1GgNusZ3BCvaah3T9 GQ1iDn4W8BDKzMDORhqQxVaF56mDUBz/sw== X-Received: by 2002:a17:90a:e7d0:b0:20c:169f:7503 with SMTP id kb16-20020a17090ae7d000b0020c169f7503mr34763255pjb.175.1666038316564; Mon, 17 Oct 2022 13:25:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:16 -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)" , Ryusuke Konishi Subject: [PATCH v3 22/23] nilfs2: Convert nilfs_clear_dirty_pages() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:50 -0700 Message-Id: <20221017202451.4951-23-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?1746968285821096197?= X-GMAIL-MSGID: =?utf-8?q?1746968285821096197?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index d921542a9593..41ccd43cd979 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -358,22 +358,22 @@ void nilfs_copy_back_pages(struct address_space *dmap, */ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + while (filemap_get_folios_tag(mapping, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i]; - lock_page(page); - nilfs_clear_dirty_page(page, silent); - unlock_page(page); + folio_lock(folio); + nilfs_clear_dirty_page(&folio->page, silent); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Mon Oct 17 20:24:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1630447wrs; Mon, 17 Oct 2022 13:31:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ALt2cbPOgWPBkh7zpzVVHGJMNHs1esfherF7YbFcx2Mkn6jIV6xt7t25RqEurNI5yfvCe X-Received: by 2002:a05:6402:27c7:b0:45d:45f0:e6c4 with SMTP id c7-20020a05640227c700b0045d45f0e6c4mr11769290ede.325.1666038714449; Mon, 17 Oct 2022 13:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038714; cv=none; d=google.com; s=arc-20160816; b=mfNxEme1bM4n/K8Ud46izboT6+aReQC4+qaUwYAwUhqQ5Q9pYMmMrPGFrznrYEgc7R 4c/wmbUYsTg2A82aLe6wW/I/cHXDNgQHCuCD7qYkYYKusVC/QsobOtbhqOYAKBYVKPVH ZO5gjWCTg3Bpa1L3Z5HJ2kTQPpWg9H0C1NRZkrRD2YxXEa6pQAft4S0rfqD/zUFfWGlv 9Ad7pmhic3UcokXv4PTn8URqH+PESR1w92TS2+U1GYq/vtL94c3xZxwz8t2mP8/4dRVl mfSJY43twVgqlosQLP4RoPJ83fq8Jga4pa0G66Z0q83feEJN6p6fNoiOHetViw20SeU7 2CSQ== 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=uFc4CQLspR/Ieyg1375xMFBigqFCNsd92Gu75fIF35o=; b=zMdAAC3kxtvTTXDcPV99kWzmzt8eQt/gw7+qjw+qgT8kusz1NO5+7tMk1uktsFdTQK 4rmpeexiEqFCfKy7sIFAfBSsKeSWEVrlUOLdmRAMHq3gq5XP0oyr2hGcwOUSl3WMoTHn vp8TU449BwttCGcm8SJWjtjnc882F78zBcz5Ni0zQKF5u/2wTFIgb15pznIJxDtGv0r/ 7rBZG9udY5n7ScLZLtCeEuhfqqeSdunCW8CUr2S0GJIDPnhdro2Um/mJs3p6gTJGYbqH R+IxpPd9Iza8ayR5juwjAw87Y03ofoLVzJFGnlhRGUxZXu0KKlp5b1RWzTokKE1L/Ywn eS4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E2HrY593; 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 gb22-20020a170907961600b00734b2821879si11062919ejc.898.2022.10.17.13.31.27; Mon, 17 Oct 2022 13:31:54 -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=E2HrY593; 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 S231405AbiJQU32 (ORCPT + 99 others); Mon, 17 Oct 2022 16:29:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbiJQU1I (ORCPT ); Mon, 17 Oct 2022 16:27:08 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F49E7F0A8; Mon, 17 Oct 2022 13:26:08 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id y8so12098851pfp.13; Mon, 17 Oct 2022 13:26:08 -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=uFc4CQLspR/Ieyg1375xMFBigqFCNsd92Gu75fIF35o=; b=E2HrY593yhwBzKPuOHKDhfi7y0nx9yb5fVLhengIBmZ32w3tOZyumhviSaH5sejg6d cXIbW2kBAlqCzMIuFNALX410/lKWAaVyF/nPC+box19yMoAf45T8bwJvOot6q/x2bZo9 BWkaNTXy4/u7sIhcqFgjXMyziDNGnBPaOAkMC+I0A3f5atFA1gL+cBgYrRLHgSu4FbXR rmn0/zR4OQ1idgzRTlVeLxmGLfK+2zxyPHFFtwszyNI0ipZywzpx/Iy1Xgs26j64wa+a oMjuQUet9ZqqLrnd5wLntdj6lh+4K4G85SYoxS+pr0LF7K0Xj8Jv+ifbo1jiVJEiEW1q TnCA== 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=uFc4CQLspR/Ieyg1375xMFBigqFCNsd92Gu75fIF35o=; b=ETRVubRFuP0H63c4A1GMY1Skx8MFHc6vVjhZ1BZRKsumHI18RZe11KL82DiGODZW4+ /rmglViiTh1Hkb+bvZgHDRi7hHVfHU9BIE4V8glfNl0S3J2N7WsM8k2tfekhIsthLMpS 4sTVYH6ho3eXjWAx52cT/rR0ggB2qsIDnztrRkRXluxBGHWDjsu9MHSfKW+d6w1KhMKq OST4CIpa45UPBnTNDE6VZFlyPxFdNjijFrDtJ7qtpygKFY6ciVwv7hTgXW8vgjOacOoI 7tzvQvjU87Ve1gKBJ816eOl7VuvlGurf1Was4wKAk4csS9+K2n05oOS3Y/SSEA/+i3kz FthQ== X-Gm-Message-State: ACrzQf0+g5FEJSjkqfEQ6KoxzeswP5ZEEenJFD0nlkDLPCNBgronQ3yO Zs/+s63bQtN6uM86w73ugIopfdATAqOcpA== X-Received: by 2002:a05:6a00:8cc:b0:52c:7ab5:2ce7 with SMTP id s12-20020a056a0008cc00b0052c7ab52ce7mr14226045pfu.28.1666038318537; Mon, 17 Oct 2022 13:25:18 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:18 -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 23/23] filemap: Remove find_get_pages_range_tag() Date: Mon, 17 Oct 2022 13:24:51 -0700 Message-Id: <20221017202451.4951-24-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?1746968211283829631?= X-GMAIL-MSGID: =?utf-8?q?1746968211283829631?= All callers to find_get_pages_range_tag(), find_get_pages_tag(), pagevec_lookup_range_tag(), and pagevec_lookup_tag() have been removed. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 10 ------- include/linux/pagevec.h | 8 ------ mm/filemap.c | 60 ----------------------------------------- mm/swap.c | 10 ------- 4 files changed, 88 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 28275eecb949..c83dfcbc19b3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -742,16 +742,6 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages); -static inline unsigned find_get_pages_tag(struct address_space *mapping, - pgoff_t *index, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - return find_get_pages_range_tag(mapping, index, (pgoff_t)-1, tag, - nr_pages, pages); -} struct page *grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index); diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 215eb6c3bdc9..a520632297ac 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -26,14 +26,6 @@ struct pagevec { }; void __pagevec_release(struct pagevec *pvec); -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag); -static inline unsigned pagevec_lookup_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, xa_mark_t tag) -{ - return pagevec_lookup_range_tag(pvec, mapping, index, (pgoff_t)-1, tag); -} static inline void pagevec_init(struct pagevec *pvec) { diff --git a/mm/filemap.c b/mm/filemap.c index d78d62a7e44a..f303b8bd7dfa 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2317,66 +2317,6 @@ unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, } EXPORT_SYMBOL(filemap_get_folios_tag); -/** - * find_get_pages_range_tag - Find and return head pages matching @tag. - * @mapping: the address_space to search - * @index: the starting page index - * @end: The final page index (inclusive) - * @tag: the tag index - * @nr_pages: the maximum number of pages - * @pages: where the resulting pages are placed - * - * Like find_get_pages_range(), except we only return head pages which are - * tagged with @tag. @index is updated to the index immediately after the - * last page we return, ready for the next iteration. - * - * Return: the number of pages which were found. - */ -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - XA_STATE(xas, &mapping->i_pages, *index); - struct folio *folio; - unsigned ret = 0; - - if (unlikely(!nr_pages)) - return 0; - - rcu_read_lock(); - while ((folio = find_get_entry(&xas, end, tag))) { - /* - * Shadow entries should never be tagged, but this iteration - * is lockless so there is a window for page reclaim to evict - * a page we saw tagged. Skip over it. - */ - if (xa_is_value(folio)) - continue; - - pages[ret] = &folio->page; - if (++ret == nr_pages) { - *index = folio->index + folio_nr_pages(folio); - goto out; - } - } - - /* - * We come here when we got to @end. We take care to not overflow the - * index @index as it confuses some of the callers. This breaks the - * iteration when there is a page at index -1 but that is already - * broken anyway. - */ - if (end == (pgoff_t)-1) - *index = (pgoff_t)-1; - else - *index = end + 1; -out: - rcu_read_unlock(); - - return ret; -} -EXPORT_SYMBOL(find_get_pages_range_tag); - /* * CD/DVDs are error prone. When a medium error occurs, the driver may fail * a _large_ part of the i/o request. Imagine the worst scenario: diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..89351b6dd149 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1098,16 +1098,6 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag) -{ - pvec->nr = find_get_pages_range_tag(mapping, index, end, tag, - PAGEVEC_SIZE, pvec->pages); - return pagevec_count(pvec); -} -EXPORT_SYMBOL(pagevec_lookup_range_tag); - /* * Perform any setup for the swap system */