From patchwork Thu Sep 1 22:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D9F3ECAAD3 for ; Thu, 1 Sep 2022 22:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 725288005C; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D3318000D; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 574268005C; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4348A8000D for ; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2D5A01C6107 for ; Thu, 1 Sep 2022 22:02:37 +0000 (UTC) X-FDA: 79864891554.16.6524401 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf13.hostedemail.com (Postfix) with ESMTP id E255620044 for ; Thu, 1 Sep 2022 22:02:36 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso3779273pjk.0 for ; Thu, 01 Sep 2022 15:02: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; bh=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=ghwmH7OBtODEG3q6T97VdwhOtKpgroD8O6/eJME6RxcE0RCt6y1f0k8Z+Nf438szjC f1Tz2jCtqotWMYX7jAfk8pOks8r2uw1MbNfVxQq0DoggwzPzqUI1rjL/zYCVH96CDWOv 6N+BySbmSBpBiAynr3+ZISEA0FDbCfqFR2qcMY0YXtQvpxu9mYXWpYrIjN0m8121kRUK taJIkqf7L0HTr7GIXny4HPFg0cC9mjsMx0m7GnMMBPB1n6WD1zCiOVAj8NMqjbSN/CwY UiWg2L5Utibhg+ppDHvNeQZKqE6Q7TMiSRDWsRr05n+F5Hbq6n90JrOCXpSrF4pvJHUr 61YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=A7kpC8NmQZe9GrOen4yFyLZP8BJg5by8WFnRnJeWcUpra5vIO7pqmtV898ytRd2D2k HlVGbufaTmtFiB1NV0rYeIFrttm7tOwm+TvTC8VKKV/lOrynuFCKmKV8jOhEVpTOm6Nd G1gT17Hc7EV15yHBEaRp17Zh6SHkbveMkLl9DVHBZHR9F1JMvIVHRZiy+wHgBAtM6bz9 HK60hvrokhqY6gURH7cFaJ0tTf6EjD91yxb8bpfeSQlox9vc0/gC+tr8dAFbUJdGFLf0 rSjGKVUbv/NGmwN7+fVRCV5v2CcI5GwSedJyFpkSf5Hnjtmmvx7Oz6eASxngmq9f+VYR BHuA== X-Gm-Message-State: ACgBeo1F+9mBIkV8Cl5BWL+yysyeYB2FcBWAemLx1A6HKDbOEtlGguam HKMfnRGSj9sNIFDtycNkcLw= X-Google-Smtp-Source: AA6agR66279h5kRGOp1743YusbEZncu2V+e3ESCBIyAmjv+FQyjI4ExArRN8AnvHyGVWNl+1uieWjw== X-Received: by 2002:a17:902:e88c:b0:175:2471:8d8a with SMTP id w12-20020a170902e88c00b0017524718d8amr13575643plg.0.1662069755764; Thu, 01 Sep 2022 15:02:35 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:35 -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 01/23] pagemap: Add filemap_grab_folio() Date: Thu, 1 Sep 2022 15:01:16 -0700 Message-Id: <20220901220138.182896-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069756; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=sTUk5bPGxNIZTDWNu2MdF2QSZZVykMU739dpg5AFkZJfLAzRn1L2o1l7Iqz6D8rv+Acz8N gWpjkustIHuxuGjZGaqxpwUdkdnTEdGPXaZVgYqRheM+qKYIPNrLQD7RWf6fugN615NtRb x5aFXblamjekt7wNRdyGc1Q3z8pR74E= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghwmH7OB; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069756; a=rsa-sha256; cv=none; b=FObzZTSOrwKWrZrgfSHq1y+JXblpKVkpdDWcXrlwGFaoKoiede1FDbJUjZJFlpNocxmys4 IBN/D9rxtnPXyTXUSuAz2u+3zazJ7wCwnuv6wwN8+6Yo3DQ+MBuUDzJZpocCbkJa/PcUVN iL6zOnOCI06/nDrVtgTyJ5vMq8jTDqQ= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghwmH7OB; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: 1ouowwoankck53dd3ewu64hajniw1cgf X-Rspamd-Queue-Id: E255620044 X-Rspamd-Server: rspam05 X-HE-Tag: 1662069756-911867 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0178b2040ea3..4d3092d6b2c0 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 Thu Sep 1 22:01:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 678EDECAAD2 for ; Thu, 1 Sep 2022 22:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2B458005D; Thu, 1 Sep 2022 18:02:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD9EF8000D; Thu, 1 Sep 2022 18:02:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B5E8005D; Thu, 1 Sep 2022 18:02:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B235D8000D for ; Thu, 1 Sep 2022 18:02:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87AE21605E9 for ; Thu, 1 Sep 2022 22:02:38 +0000 (UTC) X-FDA: 79864891596.22.C34D26A Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf10.hostedemail.com (Postfix) with ESMTP id 37E4FC004C for ; Thu, 1 Sep 2022 22:02:38 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id s206so346828pgs.3 for ; Thu, 01 Sep 2022 15:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=CVjZRQRXjU7sjBLr6rHvAQKfUIl2rAWam+cMUVwdi8E=; b=bv0LlXMBz1E57HLrV0PxYhOttdXPLA9G/hmytg6Pe0rd+F6zlztjWzFwbENyiMaQWR F0y9cniRQ6tVYw7gWA96HxH7uvhLa7fAV6j9jf6hJKnH+nqTOa6IuccLgG2jeB4wnKbN dXNbKHhDCRc0KcSaeocdSfxm7jfTTYEBJlJdkL7KuMup4EyoA3sh9A1lYrEFkmC6fktZ zYtzraSEWM+6VBSfJSxJZMDmzsg1bohGoHF4buE8zyNN/Y+ges7udin1m1Ip09ANb1qi yx9Dumn8NExq4UnKeww1kfiOzJo2ul+62vzxa7uoxr+6j09KzXtjhQLvasVG7qC/0CUb sXvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=CVjZRQRXjU7sjBLr6rHvAQKfUIl2rAWam+cMUVwdi8E=; b=pID5yM1VgG5s/G+rrW7wym0NKLhigBgOJyjWcVgXtyyYpHiLDwb1uEG44Q/EKi69/7 7kFddxk5B6LSRqbCUdiNl5S7G4ozEOktVv6FIj4vsU7fpU+HipH4LNGylxvLV6CqS6Mi Vg4yIzW7OKYuAvrfKYU6Ll5maQge2hNspTaOTN+IP0qJcuGGeO7+bSxPk1BObyYTJ7tX um8yTlkbCot62P35gpY7+CjtprvqingXzJ5KhcwdGUqXZkyjP0PkuY2O6ys1niib+z5q y8tRKYzI+nHG61Ve5H5x2UdxhVbQUioiOjPDRsTGJULrXr+4kGBpKBMiG1pIEOHKKID2 LPgw== X-Gm-Message-State: ACgBeo19pfl2NZE0CmYLJLYrgzBp845yK+BVbRVNw1ezn5L6pMx0F2xe c03KCqLofJcyKcgub2K5atfgLmmsodEGRg== X-Google-Smtp-Source: AA6agR5teCrNzMyLQkKmpfunK2hBqhwsyte/cVkAvHsCIIzpnsrjuH2ApmtR8GoGrfaDovrF9RfZdg== X-Received: by 2002:a63:6cc4:0:b0:41a:ff04:661f with SMTP id h187-20020a636cc4000000b0041aff04661fmr27931509pgc.600.1662069757234; Thu, 01 Sep 2022 15:02:37 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:36 -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 02/23] filemap: Added filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:17 -0700 Message-Id: <20220901220138.182896-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069758; a=rsa-sha256; cv=none; b=cuLEYstyCeLDkZDHGyAJvNoLxS8GzHx3Wq5e5ERQXlwNLi2iVeiP0aZI2zcQdIvzqLjaeb oI0oKT+ljUrvdpTj7C+F07RtYxNNQWxIHn6ZjXCHnftFwNdBD0y1oWVNOjPnHYx9XHZ65g er46Jc66MnWQXs/mfEFErd0Oexu/9Tg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bv0LlXMB; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069758; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CVjZRQRXjU7sjBLr6rHvAQKfUIl2rAWam+cMUVwdi8E=; b=v1PKGK4FEicUU47tpkXFcryFUxbXYWMmZdUBidetgaLFytT5Vn+uSDwHslTQ7nbsfevIli tvjwStCIdzrY2Ok6+APtWQYmbzrrXh/LeqfBlPtWT93M2AgGKenuwpB5E87O0AcHi5m2UD GGT0c0Gvc4Xiv2/dGaNRAP52576rd8k= X-Stat-Signature: ky3u4m4imtksk33wy48k34darxuqx37z X-Rspam-User: X-Rspamd-Queue-Id: 37E4FC004C X-Rspamd-Server: rspam07 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bv0LlXMB; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1662069758-694489 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) --- 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 4d3092d6b2c0..85cc96c82c2c 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 find_get_pages_contig(struct address_space *mapping, pgoff_t start, unsigned int nr_pages, struct page **pages); +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 15800334147b..3ded72a65668 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2254,6 +2254,59 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, } EXPORT_SYMBOL(find_get_pages_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 Thu Sep 1 22:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09C82ECAAD3 for ; Thu, 1 Sep 2022 22:02:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FD1C8005E; Thu, 1 Sep 2022 18:02:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 687038000D; Thu, 1 Sep 2022 18:02:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D8F58005E; Thu, 1 Sep 2022 18:02:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3BE218000D for ; Thu, 1 Sep 2022 18:02:40 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 18C8A405B0 for ; Thu, 1 Sep 2022 22:02:40 +0000 (UTC) X-FDA: 79864891680.29.1002D7C Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf04.hostedemail.com (Postfix) with ESMTP id AED7F40056 for ; Thu, 1 Sep 2022 22:02:39 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id h11-20020a17090a470b00b001fbc5ba5224so383728pjg.2 for ; Thu, 01 Sep 2022 15:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=e1eM0qi5kNEXaBuV4o8U+3ZrhdfXdzoi+l/ai4waThY=; b=gNJXwxFuFke6eYj0nz2/PiDYXJ6uuw/+y6pvA6QnWq7eouNcHBf6+EJm5Gq193Grgh QKheBVVmh8HekBMRDB/fVleY8+effRW479vEXXGHLR3S87K//Jhw2e5O+6agt21yf265 3kAUpqXavBcWDTvapyzBiis+xac8n0OHDWu3AZnWr0Wr+BK3whUep7JGlwqONOkwM7N0 +1XX1ffonfhplIVIfU/utkDEIIZZiHHrp7IYcKrC4ceg3Zt1nHegjtwcFABUPSqNEdnl 4EwYzeXkwp7J8eKW59Rb1lKWQlyJ5HTmd9bz7AQHe6l+E5Qrn3Xr5kUs3+qXtBgSUL9M Ozqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=e1eM0qi5kNEXaBuV4o8U+3ZrhdfXdzoi+l/ai4waThY=; b=AX1Bl0UeAouQ8B1B0mOePagTOnbfvR6J8gRKRSNZVEGh7uoEG1SlNf+6ruL8ExaKuZ XOdFk7XQMG26w17bBzmbHKhGfWl+4+bAbCHtuDLvSX75hDXMf90tJnyhk8y6Bv1uxO9m CMs84JXzXSRHmPwWfKiBFlrHd0KsLBq/1IaPit924XTQ6v++nI0xgQdahcNh9TulP2fj w92WI+44UaaYCfkkJo/EwXtzltxf00CJ+8n8odDZhZ3/ChRypCC2rqaWKIOmq8JRFJAS 88Y8VQTQyuvZ3BCcUDtMD3qPcHqDxMFHOUlnzb1qKlIhXVEkmxGvxxX+6q9hwLdnQveM vVgQ== X-Gm-Message-State: ACgBeo2WomWIJGSboQ1btLxxWrXsI+5x3WlxiKQkbAJhH9SXpLkpmIGY IXbhxZHTQA01sXsrC4BWO1E= X-Google-Smtp-Source: AA6agR79ut39yeQZLj/LWKnnlXRQp19F2hOxIhYbazSQ5kgq5xXWtmAM1WGiML8jodYQoBXi0CNqGg== X-Received: by 2002:a17:90b:2bca:b0:1fd:a06b:ef4f with SMTP id ru10-20020a17090b2bca00b001fda06bef4fmr1267475pjb.201.1662069758626; Thu, 01 Sep 2022 15:02:38 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:38 -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 03/23] filemap: Convert __filemap_fdatawait_range() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:18 -0700 Message-Id: <20220901220138.182896-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069759; a=rsa-sha256; cv=none; b=Ur3Hr7rzxSVxukveC9TZTWMDBludGSSKBZLIN7L6gvoKjJUMRgUywaw8I+SjPqKKmB+w8t kHKzk4AfSWHZr2tjn60wmDMoRA12j9m93LmjGNbZKfN9t3FLQr5y0wQcaIqchxMUtU3irK Bl3CcfS+9JByy24MaO8lodbeKm72wxI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gNJXwxFu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069759; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e1eM0qi5kNEXaBuV4o8U+3ZrhdfXdzoi+l/ai4waThY=; b=7Ck+YVXbcbnnRcn/CLl4GYx5vZX76omMjcpklG/LT+FBvfZNbKycovV/ueb3rh2x+PIXek De+JK63zgPYoBYRVCxnWpBxEBOEC4zloaWhcipRJZ7uKR1H3C0WkRiV9Q8ctUEg31EtRs1 YCeYhXk4834SqyNL8XftgpiiCK9oUCE= X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: AED7F40056 X-Stat-Signature: 5er4u1zsxnuq67ciytgrj1nc57iwbzzy Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gNJXwxFu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1662069759-243726 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Converted function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) --- mm/filemap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 3ded72a65668..435fc53b3f2f 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 Thu Sep 1 22:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0541FECAAD2 for ; Thu, 1 Sep 2022 22:02:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63F9E8005F; Thu, 1 Sep 2022 18:02:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E9078000D; Thu, 1 Sep 2022 18:02:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C6988005F; Thu, 1 Sep 2022 18:02:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2EE4B8000D for ; Thu, 1 Sep 2022 18:02:42 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 00916120AA7 for ; Thu, 1 Sep 2022 22:02:41 +0000 (UTC) X-FDA: 79864891764.09.3FDF8A5 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf25.hostedemail.com (Postfix) with ESMTP id 6316BA005C for ; Thu, 1 Sep 2022 22:02:41 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id u9-20020a17090a1f0900b001fde6477464so3726040pja.4 for ; Thu, 01 Sep 2022 15:02: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; bh=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=Gaj0mMM9H3egxmzvqoNe1iEZ8hM4gGCuOLd4DrOQSPxMqktv1CzrXzVDyO8P2nyIk/ yUBeUFPxBV3eXEeh6ja6r3jkoQsS04RG50Hnxubt2HmCGrtg5eKsV3UPlvUzZnUKawGI My9DzO3Xj8pL30ByGUnOEZVfKGDkHTQ2C4HIc/qJJANb+ptbCXEplLhDGKA3WFdXs9M8 mS8cT1eLA3HlUfNc2XYawFkS2Pm3KnFAocu/vOFGqQPu2plQzBgCe9NVA8+UzmqDvFrB 1wkufgXt46pAfuPf7/lCvGbjs1HcMTtdBZcKTuJGYsiDo4Y26ACLq07Wk/qpB89Wt8ju 1+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=79271AJ7r7hnw/SIZcgacgReD+WuRLN/u/od+YdsJ/Sd17pSWy/tvbiAnuxm4kQLzb PCpnOg7mRxuv8alGW72vZKiVpPBcHi4NKkwMQ3oKiGgpltso2BcgTIYVcyomcFRL+NeL jSMowYP+l06O5y4uGhr5ZvpXNu2tm3Y1FkXX60QPlnwY8XzcCbV3IHr7TRe5jJ8QCeKh JpRZnyg+M+tQQDfNmdDwKteUwuHQJker+tTvblD/UT3uBLIzRdJtNWNNVPqL5HmORLqb zGTW2FbvDdDtc5PyZZSZ3XGkIIKXzz3zMO7O+efq5GIQTUWnVlhYV9jFXC3drmLxLqT9 Fl2Q== X-Gm-Message-State: ACgBeo1A9OVNe3oP713DoG8iQyInzZrctQrQ0dadmHH097rMt41CFxw+ 59U4m2Zj8FI33SMpqzoRG3U= X-Google-Smtp-Source: AA6agR6dxA12uK+I+w8xC2CjqrYGTglG0dwrWM/V/jCpC1FZtdsk4I0wsfRIaHclHD4NelAUtre+yQ== X-Received: by 2002:a17:90a:640c:b0:1fe:1763:e169 with SMTP id g12-20020a17090a640c00b001fe1763e169mr1291542pjj.35.1662069760287; Thu, 01 Sep 2022 15:02:40 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:39 -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 04/23] page-writeback: Convert write_cache_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:19 -0700 Message-Id: <20220901220138.182896-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069761; a=rsa-sha256; cv=none; b=2AXIqNbAsKW/5p1ozHOeeItS0omkIhS9EpxjdIwZ8MgGEXvpX5SL8CJp/jj86myJXqEjbx w+ekQA8amxBzA25TzUXGjIIUkS668c/aZKukGjAzTZrdv3mKK3CSCMakjMsNyseC/dS9NS IDkiPAMJFyFfy8Vpjkdq0FDCCvIQ0jQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Gaj0mMM9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069761; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=67A/dC+jR6XpLGLC4ODkJ9hSQCj7SGuspJu+k6nnCZE=; b=5j1NlOxuONBVTbQCuvtM4ScjWLLxjIKSG3ELZ4wGNIdtCtjjfJLDfQJucTvzW98m3P48vL lUrHGvswL7gn7dShuGj7Q4VyoClkez6i772YYesx1hfugaF8O5cCpnEPpYynUDmZ2VolWA D/FpFeusooMXix/kg9KRhabIAY4adcg= X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6316BA005C X-Stat-Signature: oeja169rytpmsguygw595mcohdr6y9ee Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Gaj0mMM9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1662069761-316275 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) --- mm/page-writeback.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 032a7bf8d259..087165357a5a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2285,15 +2285,15 @@ int write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int error; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* prev offset */ end = -1; @@ -2313,17 +2313,18 @@ int write_cache_pages(struct address_space *mapping, while (!done && (index <= end)) { int i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index; + done_index = folio->index; - lock_page(page); + folio_lock(folio); /* * Page truncated or invalidated. We can freely skip it @@ -2333,30 +2334,30 @@ int write_cache_pages(struct address_space *mapping, * even if there is now a new, dirty page at the same * pagecache address. */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - wait_on_page_writeback(page); + folio_wait_writeback(folio); else goto continue_unlock; } - BUG_ON(PageWriteback(page)); - if (!clear_page_dirty_for_io(page)) + BUG_ON(folio_test_writeback(folio)); + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = (*writepage)(page, wbc, data); + error = writepage(&folio->page, wbc, data); if (unlikely(error)) { /* * Handle errors according to the type of @@ -2371,11 +2372,12 @@ int write_cache_pages(struct address_space *mapping, * the first error. */ if (error == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); error = 0; } else if (wbc->sync_mode != WB_SYNC_ALL) { ret = error; - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -2395,7 +2397,7 @@ int write_cache_pages(struct address_space *mapping, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Thu Sep 1 22:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40066ECAAD2 for ; Thu, 1 Sep 2022 22:02:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85BC680060; Thu, 1 Sep 2022 18:02:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 80E038000D; Thu, 1 Sep 2022 18:02:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5ED4380060; Thu, 1 Sep 2022 18:02:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 351AF8000D for ; Thu, 1 Sep 2022 18:02:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 16F39A08B7 for ; Thu, 1 Sep 2022 22:02:43 +0000 (UTC) X-FDA: 79864891806.08.DCF82B9 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf07.hostedemail.com (Postfix) with ESMTP id C08314000D for ; Thu, 1 Sep 2022 22:02:42 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id 76so127391pfy.3 for ; Thu, 01 Sep 2022 15:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=BofO2z6y9ENTQWp0Yvv0xZOA4E0ZmpnPsRHNqq6A2jC1fFkLvkeI9auiLxIXCMWaFI Ny/wnTRd4bsfeSW1PW0hlP2y1AW0H/gKGeJyyyuXIzCBClJwAJdgV0XPBr23RLqie4M/ ewOkzhyY5JUKKRcuoL+BKdtDBY649mPhRz+RjFkATheqTrkrL23h4FPz7QrlORmIjWgR HOb4a9Tepxb/llZqXj0DwkH1KVQYgyA1Reni49ob6gMd5Ubkso+9GqQHb704TQ/xa7VI DNqNBw4bPc6iBtu1mEpGSjGiajYdCK5/I1MxHEc0MmiyV/DXBSSxCupIrv8urS1sT+Pz 3wwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=r1k9WY62Hvld15NEIP1gnL60TPPTN9Zwg/h8ge9lZUrgHKPNjZoJJQ0iJhpSjQFOw1 w37yge9vT45SezC6XyQIDdlujZynbkQtPdZkFEajEXbmmIFEpWI0hXNtT3WzoEyNt9sw vqREcDbavLMYVA6EQB9yiwtq0BrcU7Df+kDIcH2la4vDiTL1Xhdouyfmb+qRg44q06de yR4+2Ezt+5kzCZ5PV7niT/VkMtUIH0qdLeqVb6mnt0SXtyRdnSVxMpKB0hkwuyMVVO7b beSlQRzWi2NWQMpPeivxkut7UBhWUgKrQ1UzfvA0YFpaTpCMetes7WDy0LkPz2rNR7RZ 8MQg== X-Gm-Message-State: ACgBeo32Ec54AfBSU8w3PU6YmZuqqRtbqaTHJ4+qrxRMxp+bwk6WKAne 74sSd/h0yITY39pAyam+Gg0= X-Google-Smtp-Source: AA6agR4QgchkxCnj/34OOoCX8oBg5svfID3CvXXYOvQ+6OAqnA4ElIZZzg75g2LnJSAMa171PFwf5w== X-Received: by 2002:a63:256:0:b0:42f:b14b:2085 with SMTP id 83-20020a630256000000b0042fb14b2085mr11358313pgc.189.1662069761849; Thu, 01 Sep 2022 15:02:41 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:41 -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 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:20 -0700 Message-Id: <20220901220138.182896-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069762; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=e1pFyfS6jJO5Lti4Ll8OLCsjGa/0pHjh3YVH5Q1CnO5K65dqW1PJgMXKNUghIt8DvQ0L0a +KLqWqoUAKqrNzMR4XDQY2ZWE1WBToITfgtf6CbhJ8NHI4Nc6DNCHIWYxkj8JbG++dmGoz 2eaJoJgVWGcOn1XCScCRMp4EMJKrDyU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BofO2z6y; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069762; a=rsa-sha256; cv=none; b=6SrofgByvZZ6or2eFBuotnY2h8bvYUEzlIxV4JwlhfAS8t6Nm8LvJLfQ9gej1cLSSG+0+F XW2j7Wcs0SL7gGKujlYE+SKOK0MIYzm7Z6KYneFy5/8sOtQ2g7ufxLAcFN2a8WVsDFEeSf 6NS9vADtJNdxTPpnbNtSpUotvqYi9Ww= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BofO2z6y; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: daibmuwtcs61i4d95jfnqrc565kd48ok X-Rspamd-Queue-Id: C08314000D X-Rspamd-Server: rspam05 X-HE-Tag: 1662069762-773071 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Thu Sep 1 22:01:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E794EC54EE9 for ; Thu, 1 Sep 2022 22:02:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 304D080061; Thu, 1 Sep 2022 18:02:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B73B8000D; Thu, 1 Sep 2022 18:02:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E04580061; Thu, 1 Sep 2022 18:02:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EA0788000D for ; Thu, 1 Sep 2022 18:02:44 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7FE14A08E7 for ; Thu, 1 Sep 2022 22:02:44 +0000 (UTC) X-FDA: 79864891848.31.775AE0D Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf04.hostedemail.com (Postfix) with ESMTP id 3D1C440051 for ; Thu, 1 Sep 2022 22:02:44 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso3713680pjh.5 for ; Thu, 01 Sep 2022 15:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3W8eVECYUWOXPq8AmB0uwIDBTXoxHTg96669VXu7Qys=; b=T7nuCbAZMiTAbV5HIjQpWH+eZ9bQTc6PCgtrgl1hET8edirsolRjeqzxxDLlpylo6O o4mNGjl/sRdPAL9cyBLo7pPSX2/e8rdulZr4fxc4F/cQ5AhRiqY99FCf8SxmFrrEWzLG GwmBlyr64nECHNcSvLGGDgU9jwM9uICGm9ENuaBnbkPPhW9pSHYWvTqQUY01jHfEu8iA 8qTU4vBK0tC6E/aFkaadbV0SSS1NROThuuOvdZR7ns9gnx2zbMOLC86SVrchIF9MO4NL JVoqN7FZ2hPAYogb7KAItYOxx1SfAaxkg+Ce70dXU0IvySIkg7JupZsJgatOwfXFf7eS c2hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=3W8eVECYUWOXPq8AmB0uwIDBTXoxHTg96669VXu7Qys=; b=F7AA1TE461KocWElm6y6iOjgMkSrXxcfApfuR2Rf9RZ5NkMKqLxWujamCRCS1Y9jvO bqL8/bN/jdN/ROkOiAml6TWQBmRhXkxsPSTmK4Be2Lsfi32NvAvFKrxfXSEe6n6dZedK bhBCOdUmFia4yIOnIm0fPCnBeSU4orrNWCW37oECXQVkOQhs1UDHUiX0326qW5BK3s8z JYywmZ/e8mWdLDIKpy2Sq/K6qdo8E8+L9Fnrkgs0QsJyHHKv/C5SteU/Un9Ut97ux7xm X/Kgt6BUKDTfQN2n0cx/Z3FW13g3EnNIoQ/k9PnuUp5TW/XDhMyvbXwbGseduFNNnHlv dqCw== X-Gm-Message-State: ACgBeo20hgmMAvoimnJxIdfVgsKSyf89as/aB+70PeoHi21fVJIAarsj zNCaCb9nQW9QQtOlyziZrHI= X-Google-Smtp-Source: AA6agR4+8BUAX2YkjXUvTou/rR9ObQ1uX2z42w4hYTYm88BqrnOHPc03kR7a6JZ8cWUAEetKKB6rvA== X-Received: by 2002:a17:902:ecd2:b0:16e:d87f:d19e with SMTP id a18-20020a170902ecd200b0016ed87fd19emr32807669plh.75.1662069763246; Thu, 01 Sep 2022 15:02:43 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:42 -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 06/23] btrfs: Convert btree_write_cache_pages() to use filemap_get_folio_tag() Date: Thu, 1 Sep 2022 15:01:21 -0700 Message-Id: <20220901220138.182896-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069764; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3W8eVECYUWOXPq8AmB0uwIDBTXoxHTg96669VXu7Qys=; b=ETH7vZcFZ/YuMNuBMLzkBQsws/vGz7BKwUmoQ4jsQZyoIEkTmZg9rHIZeSRWLvkUnCl9CZ nHdmjXA1SYpjwl+SaeomX+V5aibUNujdaX3XLo1eFCDtNqR2fLUfyp/Lric3hFKfJgrtlz NPYQ+DNmBu1rfRtFB0AGW6hVGqRWSdI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=T7nuCbAZ; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069764; a=rsa-sha256; cv=none; b=0iDuUIuEdjZD8tlllalH54RA4LNfhoWkJWI4RM+5mUCSmesuMMXXNYCxlz1dTKoZ1RoHhS Z3HJKWAYV8RG6+xRLl40mWzXugyqguMwQ87UEzVP0twF0o/ui5ZpyvJIORO9/nU6buPiNv soTuN3vDxxACwqLQD50Wf91NchoeHiw= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=T7nuCbAZ; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: n11c45jmt8xa7m3m9fehyqyjdnnqsfnb X-Rspamd-Queue-Id: 3D1C440051 X-Rspamd-Server: rspam05 X-HE-Tag: 1662069764-213619 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 cf4f19e80e2f..d1fa072bfdd0 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4844,14 +4844,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; @@ -4874,14 +4874,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) { @@ -4896,7 +4897,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 Thu Sep 1 22:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D1F7C6FA85 for ; Thu, 1 Sep 2022 22:02:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43D6280062; Thu, 1 Sep 2022 18:02:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 414958000D; Thu, 1 Sep 2022 18:02:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DC7880062; Thu, 1 Sep 2022 18:02:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1F5848000D for ; Thu, 1 Sep 2022 18:02:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E2E2514084B for ; Thu, 1 Sep 2022 22:02:45 +0000 (UTC) X-FDA: 79864891890.21.49612D2 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf06.hostedemail.com (Postfix) with ESMTP id 915AA180043 for ; Thu, 1 Sep 2022 22:02:45 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id y141so108001pfb.7 for ; Thu, 01 Sep 2022 15:02: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; bh=H1ZMVMBgfrZYGu2QZ+223evW3CSAsjQgLD9a3FFT7h8=; b=igWgWaj0aHyNZf5XNZM5uDc0n5BV1AEK0E8cDeZNmauvOVLadH3WVQNodqCzZr8D8R hzujhG+S4PCrAuPukcXuRC5mwOFIxxwc0GiMx0cdVcwx5Wb6+iBFORlAPVoNjlIQX23W bEswqyuy8EmNrId6zlGtKLGA8gtyv55Rw1AH2+FmpfoXovpJpdtYKd501mfmlL+x16b6 RnroUj9UCaRa413Bl0N2xC2vydY5iSJtBjMDD5AAH5twN0K4mRxdAqlQAPIoPZ5lM8/Y gtqAG5Yqwp/Rp7ZQwJrAj53rl2ta1L0rfXCTZ6LkGMVa7YXGDBshaZeshZvIj3BPWRPL PsFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H1ZMVMBgfrZYGu2QZ+223evW3CSAsjQgLD9a3FFT7h8=; b=Tf7rRoIeWRaRRJfqOU7bhZoNd7z/r/ROV2PoVrpGwW/YIZVkCdxdnSH63pN3CupE6+ Cd2/oaOwH+nhEUiO+5e4SuoTIWP7pESPpTGNEP09KuH1P/m195A3FAxF9o5aCJHumaQl 1V6SzL/blB+1NjwwnmkECqxeQ4ulawnYlv6CfVV3xDxFff0Bn/6gMVYNM6iqEaVdoPlZ goba1HAVQfrACH+eKTwkf9ZADUxj2UgrNirgkUfE+M3Tx/KSKfbWonnWlIi0eInivXkf AgBqk4Lsq1b96sHohM1sBeH3TgkRJUth7d6VaoMUuOgRD7wPtTQzU67YX9YmnE2rcp3N UerQ== X-Gm-Message-State: ACgBeo28QGmZHcJEu9sJppqJG/NUp4bdjyGPEVG8CoadAlUpAyetHchg elPT6HmieTRVDmyzbVP0aZk= X-Google-Smtp-Source: AA6agR5L6zGCc4qqeGX4LmKGAR0dl5NNlHckFzIH8Y7h0BJOTByYfkAodyvTQyqMLGO5MJ0QXJsLYg== X-Received: by 2002:a05:6a00:3406:b0:535:f76f:c971 with SMTP id cn6-20020a056a00340600b00535f76fc971mr33419595pfb.5.1662069764597; Thu, 01 Sep 2022 15:02:44 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:44 -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 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:22 -0700 Message-Id: <20220901220138.182896-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069765; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H1ZMVMBgfrZYGu2QZ+223evW3CSAsjQgLD9a3FFT7h8=; b=cC5JthD12+amn/vj82oKy029nU1yu4v2+9UpgYSgTRDO0dkPQamMBwMykwYylYCreXqVkK RuECt36NTvXLX/nzarCSf6aDVv9wrLJff028/8k/uH959iJdGuNnhChv3Usi8i23efXUNB CxcueofNpj2q/08IOkzBbN3BLIkbqf8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=igWgWaj0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069765; a=rsa-sha256; cv=none; b=vLy+TE0XDgSHb9rwNQQH8yo9BL4GE4j/UbUzyO7lSbOLppQ5lBclTyuv0o5egyyD+B4fKB 7LjsW2BB7xjvYtbqkRiR4iWsE+H321ilAG4EYpLKra7kOOQ3YPNGURbVmnLSpXx/416xC3 B8yOTEpfcLGyI++L0W/IQE9RvxmEpQc= Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=igWgWaj0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspamd-Queue-Id: 915AA180043 X-Stat-Signature: 111j71r5p4inuawzzaz7fp7m1otp8e69 X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1662069765-393216 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 d1fa072bfdd0..80fe313f8461 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4972,8 +4972,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; @@ -4993,7 +4993,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; @@ -5031,14 +5031,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 @@ -5046,29 +5046,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; @@ -5081,7 +5081,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 Thu Sep 1 22:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 028DFC6FA87 for ; Thu, 1 Sep 2022 22:02:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8106A80063; Thu, 1 Sep 2022 18:02:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 770EE8000D; Thu, 1 Sep 2022 18:02:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C30080063; Thu, 1 Sep 2022 18:02:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4A98C8000D for ; Thu, 1 Sep 2022 18:02:47 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 23374403A5 for ; Thu, 1 Sep 2022 22:02:47 +0000 (UTC) X-FDA: 79864891974.09.A8451CA Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf04.hostedemail.com (Postfix) with ESMTP id 9896640055 for ; Thu, 1 Sep 2022 22:02:46 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso3713776pjh.5 for ; Thu, 01 Sep 2022 15:02: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; bh=vD6EjjDMoxaFUA+mx+1Z6aV95S5MJYOdc07mIzZAFKw=; b=J+3Lh1gRgdgO2v9UxZL/wonAzQShpgtXZcvKoRf3BV0vsDl9B8j4onqZK5iJ4Te1ra kS6FHDrHYE2wl4ZWgCwVCI2QjRvy2h4BYtKX7RHvGTeYno9QJen+kWR1dIVH98zT840w TDHFXzAjfDCr5mF2lvdFOQ5vWqNBOVn0cLsS9DG2NrcdaCSWCCfrPdjRoxFzeS2WHP4m KF5F4ATBbr5y4byaqJFlpEDkxpMsFTPkO6HJ+H5gZ8BFW4rn7puy7FH9nr4II6bT78hX pCbYdfg+kdPJtiZmlGtKmdFWvWRuO6eZInjkl5giGJsTD8H9jVnzJgFX+gKJUsbg/qJe DKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vD6EjjDMoxaFUA+mx+1Z6aV95S5MJYOdc07mIzZAFKw=; b=dV3g4CBqJhOEwpEwRla76u/L4bZbKCcnM88pFTO6WNdSz2vDi7ITVso78gRk9meivD 5XL0dpKHuaMJw1JzgG1fq9uqZymh6uO+9hU2gKm7jr9/ywHuezZxkFPj1kJx0R4tihNv KIYjVaR21wGMiCG2oWKohP9opOdBJBPZm+yplN9kEmvYmF5Le7D0nhOhfSC0hPOdSGgi d/m7oXIGlrRPJae6snpC8P8ZUTMfQ++vJ4jgxDNZgGRNVWk4vxFlFI3lSDTKR2i1jA8m Bf50jwpXKRTCUkpiRlRPTXUAlTzExI3+n2v6FDdNy6SBWwTLNnqpdyHUMS8hE08WGw4P jNeA== X-Gm-Message-State: ACgBeo0oCaSB/TxlvK6xG/SIcTX/KMZj3LgFLZbZdEYnnuyKKYmwJMq0 bNu2TKbDyJKWT/bnPf6NuDU= X-Google-Smtp-Source: AA6agR43V0FgJNvjnTQz8ryTt3Pm0CxyoieXDTsl9xByKrJjMY6W+iFV2R2mKq/7XbtSFGiHeP8Wnw== X-Received: by 2002:a17:902:8e88:b0:172:d1f8:efcb with SMTP id bg8-20020a1709028e8800b00172d1f8efcbmr31678715plb.27.1662069766028; Thu, 01 Sep 2022 15:02:46 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:45 -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 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:23 -0700 Message-Id: <20220901220138.182896-9-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069766; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vD6EjjDMoxaFUA+mx+1Z6aV95S5MJYOdc07mIzZAFKw=; b=3OY53xH092UIodIeDJXmjuUbOElgnig8QcgHxJWYt8U8CJQvWOTXfrEPHCHHjOaV4T+XqG SeEnCYQ9hX98XHE2M67auEee44vnpIZxveGAdOD5Aq5fYkfL1NaOctpBpIqtSgnZVxGm8r KurLX0OUBMu4kqCOLR/k2ei3Lrn8bq0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=J+3Lh1gR; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069766; a=rsa-sha256; cv=none; b=KAstr+UhVVxuZ3iGNKXzesjbZ/fFapS+FUvvaaQW2jiZN6byYtJmzpDT3WORPcDP1YZ7uy 3RvSICwMgWiTA9YsZo6FZtspHua2DSHt8z/h0+BhI4LytJyTR1pqdr0kK2ADephUXn3V6X f1cWDlv+bNi/Yf6lVvOwO9j08eT4BXM= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=J+3Lh1gR; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: m3ztmcaonef6jsy9dm9dr9538jrkqz4i X-Rspamd-Queue-Id: 9896640055 X-Rspamd-Server: rspam05 X-HE-Tag: 1662069766-59315 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change does NOT support large folios. This shouldn't be an issue as of now since ceph only utilizes folios of size 1 anyways, and there is a lot of work to be done on ceph conversions to folios for later patches at some point. Also some minor renaming for consistency. Signed-off-by: Vishal Moola (Oracle) --- fs/ceph/addr.c | 138 +++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 68 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index dcf701b05cc1..33dbe55b08be 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,9 +869,9 @@ 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; + struct folio *folio; pgoff_t strip_unit_end = 0; u64 offset = 0, len = 0; bool from_pool = false; @@ -879,28 +879,28 @@ 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("filemap_get_folios_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]; - dout("? %p idx %lu\n", page, page->index); + for (i = 0; i < nr_folios && locked_pages < max_pages; i++) { + folio = fbatch.folios[i]; + dout("? %p idx %lu\n", folio, folio->index); if (locked_pages == 0) - lock_page(page); /* first page */ - else if (!trylock_page(page)) + folio_lock(folio); /* first folio */ + else if (!folio_trylock(folio)) break; /* only dirty pages, or our accounting breaks */ - if (unlikely(!PageDirty(page)) || - unlikely(page->mapping != mapping)) { - dout("!dirty or !mapping %p\n", page); - unlock_page(page); + if (unlikely(!folio_test_dirty(folio)) || + unlikely(folio->mapping != mapping)) { + dout("!dirty or !mapping %p\n", folio); + folio_unlock(folio); continue; } /* only if matching snap context */ - pgsnapc = page_snap_context(page); + pgsnapc = page_snap_context(&folio->page); if (pgsnapc != snapc) { dout("page snapc %p %lld != oldest %p %lld\n", pgsnapc, pgsnapc->seq, snapc, snapc->seq); @@ -908,11 +908,10 @@ static int ceph_writepages_start(struct address_space *mapping, !ceph_wbc.head_snapc && wbc->sync_mode != WB_SYNC_NONE) should_loop = true; - unlock_page(page); + folio_unlock(folio); continue; } - if (page_offset(page) >= ceph_wbc.i_size) { - struct folio *folio = page_folio(page); + if (folio_pos(folio) >= ceph_wbc.i_size) { dout("folio at %lu beyond eof %llu\n", folio->index, ceph_wbc.i_size); @@ -924,25 +923,26 @@ static int ceph_writepages_start(struct address_space *mapping, folio_unlock(folio); continue; } - if (strip_unit_end && (page->index > strip_unit_end)) { - dout("end of strip unit %p\n", page); - unlock_page(page); + if (strip_unit_end && (folio->index > strip_unit_end)) { + dout("end of strip unit %p\n", folio); + folio_unlock(folio); break; } - if (PageWriteback(page) || PageFsCache(page)) { + if (folio_test_writeback(folio) || + folio_test_fscache(folio)) { if (wbc->sync_mode == WB_SYNC_NONE) { - dout("%p under writeback\n", page); - unlock_page(page); + dout("%p under writeback\n", folio); + folio_unlock(folio); continue; } - dout("waiting on writeback %p\n", page); - wait_on_page_writeback(page); - wait_on_page_fscache(page); + dout("waiting on writeback %p\n", folio); + folio_wait_writeback(folio); + folio_wait_fscache(folio); } - if (!clear_page_dirty_for_io(page)) { - dout("%p !clear_page_dirty_for_io\n", page); - unlock_page(page); + if (!folio_clear_dirty_for_io(folio)) { + dout("%p !clear_page_dirty_for_io\n", folio); + folio_unlock(folio); continue; } @@ -958,7 +958,7 @@ static int ceph_writepages_start(struct address_space *mapping, u32 xlen; /* prepare async write request */ - offset = (u64)page_offset(page); + offset = (u64)folio_pos(folio); ceph_calc_file_object_mapping(&ci->i_layout, offset, wsize, &objnum, &objoff, @@ -966,7 +966,7 @@ static int ceph_writepages_start(struct address_space *mapping, len = xlen; num_ops = 1; - strip_unit_end = page->index + + strip_unit_end = folio->index + ((len - 1) >> PAGE_SHIFT); BUG_ON(pages); @@ -981,54 +981,53 @@ static int ceph_writepages_start(struct address_space *mapping, } len = 0; - } else if (page->index != + } else if (folio->index != (offset + len) >> PAGE_SHIFT) { if (num_ops >= (from_pool ? CEPH_OSD_SLAB_OPS : CEPH_OSD_MAX_OPS)) { - redirty_page_for_writepage(wbc, page); - unlock_page(page); + folio_redirty_for_writepage(wbc, folio); + folio_unlock(folio); break; } num_ops++; - offset = (u64)page_offset(page); + offset = (u64)folio_pos(folio); 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); + inode, folio, folio->index); if (atomic_long_inc_return(&fsc->writeback_count) > CONGESTION_ON_THRESH( fsc->mount_options->congestion_kb)) fsc->write_congested = true; - pages[locked_pages++] = page; - pvec.pages[i] = NULL; + pages[locked_pages++] = &folio->page; + fbatch.folios[i] = NULL; - len += thp_size(page); + len += folio_size(folio); } /* did we get anything? */ if (!locked_pages) - goto release_pvec_pages; + goto release_folio_batches; 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 folio to the 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; - - if (pvec_pages && i == pvec_pages && + fbatch.nr = n; + if (nr_folios && i == nr_folios && locked_pages < max_pages) { - dout("reached end pvec, trying for more\n"); - pagevec_release(&pvec); + dout("reached end of fbatch, trying for more\n"); + folio_batch_release(&fbatch); goto get_more_pages; } } @@ -1056,7 +1055,7 @@ static int ceph_writepages_start(struct address_space *mapping, BUG_ON(IS_ERR(req)); } BUG_ON(len < page_offset(pages[locked_pages - 1]) + - thp_size(page) - offset); + folio_size(folio) - offset); req->r_callback = writepages_finish; req->r_inode = inode; @@ -1098,7 +1097,7 @@ static int ceph_writepages_start(struct address_space *mapping, set_page_writeback(pages[i]); if (caching) ceph_set_page_fscache(pages[i]); - len += thp_size(page); + len += folio_size(folio); } ceph_fscache_write_to_cache(inode, offset, len, caching); @@ -1108,7 +1107,7 @@ static int ceph_writepages_start(struct address_space *mapping, /* writepages_finish() clears writeback pages * according to the data length, so make sure * data length covers all locked pages */ - u64 min_len = len + 1 - thp_size(page); + u64 min_len = len + 1 - folio_size(folio); len = get_writepages_data_length(inode, pages[i - 1], offset); len = max(len, min_len); @@ -1164,10 +1163,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_folio_batches: + dout("folio_batch_release on %d batches (%p)", (int) fbatch.nr, + fbatch.nr ? fbatch.folios[0] : NULL); + folio_batch_release(&fbatch); } if (should_loop && !done) { @@ -1180,19 +1179,22 @@ static int ceph_writepages_start(struct address_space *mapping, if (wbc->sync_mode != WB_SYNC_NONE && start_index == 0 && /* all dirty pages were checked */ !ceph_wbc.head_snapc) { - struct page *page; + struct folio *folio; 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]; - if (page_snap_context(page) != snapc) + folio = fbatch.folios[i]; + if (page_snap_context(&folio->page) != + snapc) continue; - wait_on_page_writeback(page); + folio_wait_writeback(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Thu Sep 1 22:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C68A8ECAAD2 for ; Thu, 1 Sep 2022 22:02:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 501B280064; Thu, 1 Sep 2022 18:02:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 488F78000D; Thu, 1 Sep 2022 18:02:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3087A80064; Thu, 1 Sep 2022 18:02:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0F0D28000D for ; Thu, 1 Sep 2022 18:02:49 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DADB6405B0 for ; Thu, 1 Sep 2022 22:02:48 +0000 (UTC) X-FDA: 79864892016.03.0DA5C15 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf18.hostedemail.com (Postfix) with ESMTP id 6C1DF1C004C for ; Thu, 1 Sep 2022 22:02:48 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id u22so50340plq.12 for ; Thu, 01 Sep 2022 15:02: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; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=GtrGYdGLszgBq1fvi5V2PSfoLOXh1TNyiK0ofvUFGiVvwdQ6PkaGy3Ns4qJwLgF4b3 aIYdrsYMX+clX1Y+yOXcuDls8w+WiavI/64KPDiJmDgxyBZ4dAulShvhPc4ENInwd3Br cmukOGKll48ywyFlU3xTzvvA/EhYiy85fvbJiJhltWdFBrenWV2xIc1tgrmQTV6xVFrr kPWQoFcSoXWz75f58hl6lYhesgfwr3gasm4nlqUw3/vIqwimOmHoTKvTQsLxit2YTq1H EGgbgkZ8lcymg9dX7HeYXgo7ygr9E+FPEd+ZGk8VSDrPOWMvOyx7zdOCyAyIqsvEGW5B 7Vuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=V8n5ENucgFDq+8B4snYv06X84UmFG1OUTqlVeGvLafVLovsGV+f3vCr1qScLcbDuiP gLSAwumiDAmC4VIHpqVoA+vIuwd1815qStcJqL4rz+J41HH7AIAN+31YbbYlVusdqhrM xmOAgt6rJV7dotkc8CBalkzZF7y7ol2DwRNRke7UHcUGgV1Lj5NgMWJ7UM5PwHUKngR1 a0cM1nAvXOhoaigYMSA8aExiEp2hHGjEi+buwwmTnc3cKF51uSu447WO98dF3/OPd14Z 6BEbQziiJy2c8FyFtVY6I09YxsBynBPX1mWgVHRK8uoHQIqnitSyL7S3IHvw/YzaoYA3 Z31A== X-Gm-Message-State: ACgBeo25PGNOeDJxt/TU8+6Pwp5zNaVqhRQQw9OveWOJ3FC8h0zhMVak Lry5Pfu6zGSjwqQQXu6xeG8= X-Google-Smtp-Source: AA6agR7dfnvwb+YDcWYBRWPejd1+fbHl6FDcd6aRRcb1reei6qT56P411IPlU9pH3GjxRMm/z5BQBg== X-Received: by 2002:a17:902:c613:b0:174:7a32:f76 with SMTP id r19-20020a170902c61300b001747a320f76mr24825305plr.165.1662069767428; Thu, 01 Sep 2022 15:02:47 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:47 -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 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:24 -0700 Message-Id: <20220901220138.182896-10-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069768; a=rsa-sha256; cv=none; b=rGGwQNnHtoTDoP5Z7Y0wNJmMzyb5y24yT9o2KnERvySAhGexoAzAOilsBobbygykdxu7hT Gp4SCuyFHBKK4oqEGKe/IqmT9fuIHbzqnyj0m9TO11ZoT9wulMuVrwX/1wn6BK3vnZRyLM VzHbe7Ey0zsM+st2tEOtfNx6M18yGeA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GtrGYdGL; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069768; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YET10ng1nR0ea8GMjh+/irz/Zcx26qfqc4LRuHlkdsg=; b=RrPmTymK0NkyzRxOYf2/GmI2SVF9aCTiNqlxWJFEltz/IsIORHz3SmVUytMQB+V/z0hsIu n9bOu+r2khLPkOqe3FPgXgcldFjaYcI3iQ+6sQpWrYYOGfGtCd8wDez8waL9W4N4nuKRzp 7PVvbHEBvpFsGWkurgeehgSQSx3jkeQ= X-Stat-Signature: 53dmd71ipy8myy9mo6ti7cegxopxsmxp X-Rspam-User: X-Rspamd-Queue-Id: 6C1DF1C004C X-Rspamd-Server: rspam07 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GtrGYdGL; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1662069768-195210 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios. 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 fa738adc031f..c4da53b57369 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2517,14 +2517,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 Thu Sep 1 22:01:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A194EC54EE9 for ; Thu, 1 Sep 2022 22:02:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8D7080065; Thu, 1 Sep 2022 18:02:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3DCC8000D; Thu, 1 Sep 2022 18:02:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B66F880065; Thu, 1 Sep 2022 18:02:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A89608000D for ; Thu, 1 Sep 2022 18:02:50 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8AA99A051F for ; Thu, 1 Sep 2022 22:02:50 +0000 (UTC) X-FDA: 79864892100.02.4DEF86F Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf20.hostedemail.com (Postfix) with ESMTP id 103BF1C0060 for ; Thu, 1 Sep 2022 22:02:49 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id u1-20020a17090a410100b001fff314d14fso354016pjf.5 for ; Thu, 01 Sep 2022 15:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6NcBwR4ABkPySjWunvka2slqDQWJiFAlVbuCNfsPT4M=; b=EMgPqv/dW9ejZPEHc8h0Is509X4km9zwyRiEeD2t+4Yx6XUuh0YXvkpHP71hc59gcH WHXYVRkSAnQTt2Q5KImgRXXH0n5e1nRRcwFpn1jn9Z0qBu3Za0+kSR5U3Y+oisvno0xB qHbF4h+rY+S22MLF5ap3CosoN1i6JX9EICc4nBvjMUeE9f6QqYdAhhzuln06qzJfz57w oLHRFjF+s5/WSklK4JMa6+VrW4gduwUK1e6UTZXB5QCl9rMvRAKM4RtoT15Wjcl4IJNW /hiN/u5HgTeRKgbPyvHTCdJvfSuKWwkMOiDMOAsJ6ZTq4D1ND7jjeTpG1Ks55/3UbdBy cXcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6NcBwR4ABkPySjWunvka2slqDQWJiFAlVbuCNfsPT4M=; b=IMQf+CXPhsxZ/ylhUq5fINHpJbBNIoHNxQhb7lnr2q3U1t5ssVoM16nRUoK+hncouR 68D2c3hjltv327k4flLK9E50WQjYfCRV7QD8BedwOkd5HGAGxUeEAQH4YPYkBbLG0XgA qmo8uwSv0twMnC8RQEk7Qx3eHonU5GB5JQRtXAejntqVdo2iHzIcFjOl5pypJFQGCNhL x80ldV7/wX1o/A1AThy8pQ4DCB13aEML7GOMkFm0Oa4J/2udkf5iRTg8Y+IVsC+Fr68Y bGTxDdz2c5C8y53Qa4gSrbNQlBVaNwf7C072lqAblytzlwqyzOYE0XRnALMsXVkFmJ9B oj7Q== X-Gm-Message-State: ACgBeo1QYnOe8nfv5JRC1A9VsBcjjfgJr4nRwswVoahJt5U1HjQr6Aim gLzfXDJ1JBwepuMFagOhMv9teXnxPYVMxA== X-Google-Smtp-Source: AA6agR5snoq69yQww0YGWXPMUaiRC6H7FjKFO/+Gerw4iv9NQmzTMmyBjpDkB62vFRGsgB5JpchToQ== X-Received: by 2002:a17:90a:55:b0:1f7:4513:8cac with SMTP id 21-20020a17090a005500b001f745138cacmr1263139pjb.93.1662069769102; Thu, 01 Sep 2022 15:02:49 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:48 -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 10/23] ext4: Convert mpage_prepare_extent_to_map() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:25 -0700 Message-Id: <20220901220138.182896-11-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069770; a=rsa-sha256; cv=none; b=BDIOD3qnpehR9GV126Iu+dimOmiQiz/yO9ta0CE0WekCasIVD30IcEuoWvjgO3rnuoHSVx AfzpXOrTVEtxQhEi5xTMGCjSpZvj4rNqBsFGAAALkLcLJlnt4nOxR/blF8K+6a8MiKTTSB aTPPG7341jS4Wgx/k7lUbdyTFzdwzG0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="EMgPqv/d"; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069770; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6NcBwR4ABkPySjWunvka2slqDQWJiFAlVbuCNfsPT4M=; b=ZDZ3fzGicTJtcHJPHDEMl67F0+UqzZiosOovPvVc1dsMMAH2t35RXs+/R5lozLc+Qbx6H1 W1rETnwuzKdzoQUvgrsUycxgHcUEQWd94YnXYvjNQqPzV9XE9cnPyVouHlWuOmTxKEVNcc JSJkm46HYDUtuWhbuCQ8hysmzZ7dT9M= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="EMgPqv/d"; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 103BF1C0060 X-Stat-Signature: puztz89i3yp87po3wr1u31xznmyekiui X-HE-Tag: 1662069769-384647 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 601214453c3a..fbd876e10a85 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2565,8 +2565,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; @@ -2580,18 +2580,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 @@ -2605,10 +2604,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 @@ -2616,16 +2615,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 @@ -2636,33 +2635,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 Thu Sep 1 22:01:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87B7FC6FA83 for ; Thu, 1 Sep 2022 22:02:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2428C80066; Thu, 1 Sep 2022 18:02:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F3AA8000D; Thu, 1 Sep 2022 18:02:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01C9580066; Thu, 1 Sep 2022 18:02:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DD88F8000D for ; Thu, 1 Sep 2022 18:02:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C2EFE1C328E for ; Thu, 1 Sep 2022 22:02:51 +0000 (UTC) X-FDA: 79864892142.22.2D734F5 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf19.hostedemail.com (Postfix) with ESMTP id 724E41A0048 for ; Thu, 1 Sep 2022 22:02:51 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id v4so314895pgi.10 for ; Thu, 01 Sep 2022 15:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=I3QciEP4mJX7JM2ray9Wq2x1rxYKyHsz8NamV9Ya2AE=; b=eq9I17+la1WvNV+5BSt65HZdmlI3kpaQwmc9FNX7sdwBtXf+g2lNUB5WUhRS8OFoVD rINVeqVAcVVisK1Opo9R2pevuXpfEbwA99OJ208ZKIIyjpD5HHd0N60mi8ebF98L49+q asukoj9VbepYW7IflAdN9BGVca3CKrE/EQ8+71vSNeXgMnFRtGy7jjgwK8jCYtV0IYZU 7BgD3GLe64vx+dyHCUQr+ilgXPRhjWK6drtfIHh2aksw6CcQGrC7yYbxPrBBJadHfHjd i7zp6HQd4BYuJ26dV9hFhE0t7Np6mtipz0Z2VydoTQb00rq1gRPs86DGfBHqJ9Mr6HuN cWyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=I3QciEP4mJX7JM2ray9Wq2x1rxYKyHsz8NamV9Ya2AE=; b=dvDWNmGFg4u7cG/szpsZtaaQz32Zi9Tpg7bS1fX+ofb6qi0GhS1Rsr4JKtn7cbVZd8 xZMCqy65V4oINyZL2/gJbk7k5vFk+civsw7k1j/8s+hionuWBdW70Two5Usqm3IBcY8h wgs9PVRuSsnV2z9njTv4Bx2xIHPWZqsexfPK/6HR4UfO6BugEvd9tAXqVhWLX5Sp7yEs aVXGk9LuZXWqviVZtfnF9bjmQWsYF4x6gKum2MfqNSRD3Fh/DgYQRSPkS6jczZLDzhYO uf3Py359q6WDJlQ7lTPyxhzAk2v6ou3svdQOPJbFISOOTICnYcsiHMjLkvB0odhSYXho VJqw== X-Gm-Message-State: ACgBeo0Uv2g+JHAxfGAu7sM013SVBFa1y1/i0jmPv9yRaebGEvWRXFkV gqoXmrIr6kRwi2Kb3Yc91JA= X-Google-Smtp-Source: AA6agR4XIzdhDKaN05qx0CB/1tuiJtwdxphLxV23uBbz5RLMiJ77OqGFVttntoVGEyN7FTxjH2CDFg== X-Received: by 2002:a05:6a00:816:b0:52f:43f9:b644 with SMTP id m22-20020a056a00081600b0052f43f9b644mr33511592pfk.57.1662069770469; Thu, 01 Sep 2022 15:02:50 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:50 -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 11/23] f2fs: Convert f2fs_fsync_node_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:26 -0700 Message-Id: <20220901220138.182896-12-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069771; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I3QciEP4mJX7JM2ray9Wq2x1rxYKyHsz8NamV9Ya2AE=; b=Q2uBeIXwFZe1OfgIpBnz2eUDRnxxUjdS5yEQXHSlPxBa8A5X+FQbkvYLaO+eHKKY4QJswI j7dn24NVFQCA+lnA5Vb+QWebBOR6Gh6oQqK9MFM3MrA7JfrPQRYFr0+MoVvUeqH3MhieUu usfhKBzwgdQgZHh8V8m70v2y3nKoAGU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eq9I17+l; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069771; a=rsa-sha256; cv=none; b=Da7s8zqhYM3V49+JtiKATRc9DQaYQRuKXcVB1NaaEgUly0pcbgRR0/12gPxCMlWwJ4r9Sd 66/HDm86Tg4aWKA7TTEbCFe7J6FKGuZwavfIIuMXWFVSmvywZ62RC1TVsG4IRepiCsEG6B RISy0RxrosIseF0YiKzgKjnOW5xHBao= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eq9I17+l; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam11 X-Stat-Signature: 8gea7my1z651ramcnzyfwhk6iusq8d6s X-Rspamd-Queue-Id: 724E41A0048 X-Rspam-User: X-HE-Tag: 1662069771-172468 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). Does NOT support large folios. 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 e06a0c478b39..a3c5eedfcf64 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1726,12 +1726,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) { @@ -1740,20 +1740,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; } @@ -1819,7 +1820,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 Thu Sep 1 22:01:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52906C6FA8B for ; Thu, 1 Sep 2022 22:02:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 306CA80067; Thu, 1 Sep 2022 18:02:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B52B8000D; Thu, 1 Sep 2022 18:02:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E40880067; Thu, 1 Sep 2022 18:02:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F01A88000D for ; Thu, 1 Sep 2022 18:02:52 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D4EE9405B0 for ; Thu, 1 Sep 2022 22:02:52 +0000 (UTC) X-FDA: 79864892184.16.E7ECA91 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf20.hostedemail.com (Postfix) with ESMTP id 714871C005E for ; Thu, 1 Sep 2022 22:02:52 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id u1-20020a17090a410100b001fff314d14fso354094pjf.5 for ; Thu, 01 Sep 2022 15:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VVDEDDCx2d1u9kTxOO3+HYn0Qu0jVDr1kjF69+koZKM=; b=b1/QSkbA0KE2xUlFrUXQEVG0tKpol73bVxgD0JU9l+NoBY6qShuSjNB+kmeBlOMRM5 JTyIWvr9pHHuB5iH3YW16+gbFOwJPd0guEmk3lwDKP1rofaLlcFIYJW7KLMyPaqSsnUL 3ANonRcxOaEgEr3fjaSMK6EhvpBNrqrC9y5jO3YalIG74gceZr+XlLuEMojU3DQOF2YT ZNnm8VG78RQtVu2G6CZxxzpbZ3oGLbUw/rcEMpsLZCHgtIqvQM56vT9Mo84bDHjBrKPR idwfoeW+VWrVke2zu158oVXXH2A5l7M+GBuTmwchmOVovptMyXXZZra4FRtAg/MbnMB0 QMFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VVDEDDCx2d1u9kTxOO3+HYn0Qu0jVDr1kjF69+koZKM=; b=v+3zbqn3blJXpcqOami+kLtUIoug1ofhPb37NwT5QrB+5/h/kYxqaWzdGO3MCTLisc MtjryW7FgNe/se+tmFOYIovJSph9Rd8Sc9q5QxR8x5eLuDoW0WzQkNI9J0kjU0qFEKKS apeHNBkszw7daJQvW3AJSpp2qtljUApDrViHhQ/XT562XcLAg7cA0Cz300woYndB2ZQb c8RKL/R3ukqNhdVV+X/PsRzn5/LJ+lUqS0gd08BjhuXk1g1fHBuW0YCLS0O3+hLjMPKH 5L01yx9Wj/n4KX9qcg8bMv4b4q5/SCnhOCWIdMdq54RsZJICOCS+3wajGDh0hu9YjM8Z nYeA== X-Gm-Message-State: ACgBeo3RVkJu3cspUhB3Qdzb0h+DqBDhswft6Mz74lTcKRothAt7Rq3t tVUgtgyGFqGI1FkDzjtFHffYbD0KI/42AQ== X-Google-Smtp-Source: AA6agR66Ea/tFozfkhDfcVtnv3hw9p6c/dgn9A3H0n8S4fBp6aMTRwJJz8RoIdyCPNF25qzur+Vgow== X-Received: by 2002:a17:90a:9309:b0:1fa:d28b:3751 with SMTP id p9-20020a17090a930900b001fad28b3751mr1262365pjo.189.1662069771948; Thu, 01 Sep 2022 15:02:51 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:51 -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 12/23] f2fs: Convert f2fs_flush_inline_data() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:27 -0700 Message-Id: <20220901220138.182896-13-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069772; a=rsa-sha256; cv=none; b=E+1QbpvB/5vKfGeug97tHU1HoeDALF4hhEfCGxC2rY2uu7Pa8YqGWGLXxzdXpviC3GqdRP sug2dctOMZZo62yafZxyWp7cXRliNYw+/yZXTWRKgc/X/IhNsfQ4WaZoUC6gv10WzQxECS 2jzok/YzT5mGedYaAjzk+0v+K5tgn/g= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="b1/QSkbA"; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069772; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VVDEDDCx2d1u9kTxOO3+HYn0Qu0jVDr1kjF69+koZKM=; b=qTUt8ykwJWUVbkhvXflNsdIJwlwUyg0Pwxt71ri6BBqGslLpK3lisEFJes6rJ/whiyOEFE 7IXDbilR5H6Vb7NvbW25eWog3AHcbqX9iko1tVh1kGtRrkGOPHM+1/9ksDIywqu2Ri318n CG8DFsjY5/NbX568qrkGKzxwbekGBfY= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="b1/QSkbA"; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 714871C005E X-Stat-Signature: pidzino6gtjoq4ii3a8rhg85jzhxkpa1 X-HE-Tag: 1662069772-245218 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios. This is in preparation for the removal of find_get_pages_tag(). Does NOT support large folios. Signed-off-by: Vishal Moola (Oracle) --- 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 a3c5eedfcf64..c2b54c58392a 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1885,17 +1885,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; @@ -1922,7 +1923,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 Thu Sep 1 22:01:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EF00C6FA83 for ; Thu, 1 Sep 2022 22:02:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEC8C80068; Thu, 1 Sep 2022 18:02:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9B6C8000D; Thu, 1 Sep 2022 18:02:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC7F280068; Thu, 1 Sep 2022 18:02:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B45558000D for ; Thu, 1 Sep 2022 18:02:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8AFD5A08AE for ; Thu, 1 Sep 2022 22:02:54 +0000 (UTC) X-FDA: 79864892268.06.AA9D86F Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf01.hostedemail.com (Postfix) with ESMTP id 5AD3840059 for ; Thu, 1 Sep 2022 22:02:54 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id n65-20020a17090a5ac700b001fbb4fad865so389942pji.1 for ; Thu, 01 Sep 2022 15:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=pWqS4ooFUTFHzhqRBDvFvbwutPU6GCzkgDePLKh0xDE=; b=ltbTUVZlF/Z87l55Zx7YIMdiSlF79NxCKA3kDzN/UdHnBbOhUkxYokZciUF5yB23IQ 3aZV0dCORuNfmkqtB4Um8rih0THqW1I8+Kg6eCX7JtCSq0qK5FxY5JJ3W+WjbZVvFS/N SHzuRTNRkOZU91jiFJ75s3/HaNBfpPrOuW0Q5xjsFySVCqjGc+FQww/RxS0JKeXHhL7h kAOi4h68L/U7Zh4Cxk29fMBM+9NAxnpOY6BN4/Gy4hT5bv4ACVWiuAvUMQEQVyDUFGrl 0WnCZ51DYlpojmaB5f2e+eBCMWO+Ah52Ft8Wrewyr1JSMgQJJeMlPU47Bp2sXDcRwEoX fJpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=pWqS4ooFUTFHzhqRBDvFvbwutPU6GCzkgDePLKh0xDE=; b=aE8jhayunXQpE115grQ3ROgKDExzKyCJE7e1boRH4rYqedQwAjb1RjgfBeYmx95A4j NpjCK9xqfimyLksTtc2g6gOQEQQmbXiakoAeDIwMSwcro0+2vX9UJ1q15QEnFrN1p2m2 DTPjO8nWsOK0duzZXUn6wyNlHTgT7gw/jmVPAljybvksbG1nnlgGl/gUbLDbONcg3QYS 8ny9OCU/zC8Z/+G+FsKN/LOuGSGfO6+YNnJ+dKcR95wtnHjNKp6md9ImtPRERjmXsctT yC1BUajPSOsU1TTk6vLUdqXZHrM72Foh3RUbPgPp3NYUiLWJrlx2lrTa2aG6LMwNpLY5 cEUw== X-Gm-Message-State: ACgBeo0vidJ3TI1H5Xkrz4GOPfoem2eXSuU9B/l7NNaRvpGK/SYAQ1ch aBMwLtuJCZVVNuBc4sCIQHo0GhuC1c/aJg== X-Google-Smtp-Source: AA6agR51CwUjM/zXT+7/k4/OH1O/ysrX1I+7Yp9oSarGXCh3bpO5jidmIwe1Ndwhec8sTGheHCwaGg== X-Received: by 2002:a17:90b:4b52:b0:1fd:ed88:967e with SMTP id mi18-20020a17090b4b5200b001fded88967emr1312967pjb.108.1662069773326; Thu, 01 Sep 2022 15:02:53 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:52 -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 13/23] f2fs: Convert f2fs_sync_node_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:28 -0700 Message-Id: <20220901220138.182896-14-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069774; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pWqS4ooFUTFHzhqRBDvFvbwutPU6GCzkgDePLKh0xDE=; b=EEit9JmaM67QdXKNg/7cRdxNADYbIc/cuPqj4uG5aIOmtssGBrpdmu02CL9vwY+n7ql0RJ iPOh8w1FXCIg1x0x/st743H0xfdfdcCurBi0NGRUSYXapqP26vsLCz19rg9EMI3npteTvz LVpskNj1TcngsnRLStPxJ9Y2LQV0fjE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ltbTUVZl; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069774; a=rsa-sha256; cv=none; b=ETeWI/9hIQEwkaw5LY3snZmujiKWtXTBgS5GAajH1TpfZrJLsk6lwWHlmuX3Hcn0syhIVn i5k2t6ggPbkRvQwE3eAh1K/xpSf87DWJOLnYN/RHWkw1WvZrjzQCKWQ08vUXz+owypEuWP evOFfnB4gglNhful/o7SkM9ibFi/Ql0= X-Stat-Signature: jimaa4ob6y7krtchs5by5ntgbcy1ejns X-Rspamd-Queue-Id: 5AD3840059 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ltbTUVZl; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1662069774-361245 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). Does NOT support large folios. Signed-off-by: Vishal Moola (Oracle) --- 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 c2b54c58392a..cf8665f04c0d 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1933,23 +1933,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 */ @@ -2024,7 +2025,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 Thu Sep 1 22:01: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: 12963277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE832C54EE9 for ; Thu, 1 Sep 2022 22:03:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB5AB80069; Thu, 1 Sep 2022 18:02:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D64578000D; Thu, 1 Sep 2022 18:02:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE21980069; Thu, 1 Sep 2022 18:02:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A9E2F8000D for ; Thu, 1 Sep 2022 18:02:56 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 82B024091D for ; Thu, 1 Sep 2022 22:02:56 +0000 (UTC) X-FDA: 79864892352.07.44B2248 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf09.hostedemail.com (Postfix) with ESMTP id D771614005A for ; Thu, 1 Sep 2022 22:02:55 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id m2so110194pls.4 for ; Thu, 01 Sep 2022 15:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=u20IhbDv0xijuh3aR+8LlcuRg0PXYMjLK8O6VaTOmnk=; b=JES6PMtT7eS15KIIYQC9NTsfQi1Voc6UK45Ak2ItRiResJCg05CGANCngr1ipMLdHQ U1T40zGYdMEMN1Xz2AR4JPIcfEX2KX0V3NmUhJlpaOhzxucRRwk9lPhFKQzfPzfwk9+D 5Ie3mgjXWsZ1Dg7GfXEHbeckmAOuJldqoB9JOIPccuXk9bOaYxjTnWMFNdfw656FYRtK ie9Gz5GIv7IEBruI4Pl75gj0kXVRucDld2WuaUXHzSQdGqdGTWEjjx5ssN5vo5Iy10UL 1P1Eaq55E9rlQImKIgKoFuUgaDBMFqpntmq+YByhLRUjeFHc+NOxPcre+GuojxGZmo23 bXng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=u20IhbDv0xijuh3aR+8LlcuRg0PXYMjLK8O6VaTOmnk=; b=AVlRsyiIspQ7g67QQNtQoebGgwlj3D+Xn85oDPIPN8dKx6DJhOcmxY3gyz4yB/3Kd9 couad+Hf6Cyfbd1DhKHjYk0qa5IkbpMWyUpY8qX8z5aDDkizKyfBGL9+pmyBH74Y7jlB 8WReixHARxcXsn0BKf5xCs1WXI7Nt8Py7eT9xSqtsDVTvKuC9gmfSkMRoE1g9icl8o+R OzC/BB79MSxZhVLCv53/lwzcE4AXVEvwxtNLbZbsPC83ygC8bakdyle00KpvsevfV4Bl k+tv+W1H2NOcg5qkBb8i8eAGlHra3jAocLHnj3wDf7LgPuYpAENO8foZ/5QHppmaNZt0 VPDw== X-Gm-Message-State: ACgBeo1MhTwr4yWGr5C2RQKqLYWrOxawObwwfzP7O/LRnTe+vhV50l4u 8NOfl1ou0PLyzYfVaVZudGs= X-Google-Smtp-Source: AA6agR6waYxvrYNGIdcgKs1/5thmnL5sLZmkmkWnOmiGx8YnNG4rEDeB7g25We+tjW8/c4dzFDCXuQ== X-Received: by 2002:a17:90a:5996:b0:1fb:fb6:2adc with SMTP id l22-20020a17090a599600b001fb0fb62adcmr1264771pji.177.1662069774825; Thu, 01 Sep 2022 15:02:54 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:54 -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 14/23] f2fs: Convert f2fs_write_cache_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:29 -0700 Message-Id: <20220901220138.182896-15-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069775; a=rsa-sha256; cv=none; b=pRUsBevv+SLFpgdbutg/awh2jTvKUmNwVLRKthJvdTf07efAVB4Qtp2U7/H1V6Vynp0xob dK/dmw5XvdYb6S/FbTLL3R/ZLrBnp420INXq9vaiq4Ti092BuMX8JrKqCOdCwP01vQXwEg wstVTB2Qk5k7Vj6x34SXXox3Y1ONQZA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JES6PMtT; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069775; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u20IhbDv0xijuh3aR+8LlcuRg0PXYMjLK8O6VaTOmnk=; b=uKMvm6YP0UddVzWmhm0V9CspLg0UcWQq0mv365tGua9DWs/IFgozghfjL3FkfTcoXUcQAM 3ZPR0kY8Br+T8a1jC+BPgX0kp49+o7YCN5p5VNSWTzNZdhB2EO+AfpOm6Y7HsqwXtwEY6z 49deeGVkVI8c9fgotXvWRAf2HpLu4+k= X-Rspam-User: X-Stat-Signature: fjtf4hhaegha8ztgzpb47krtreymcgpu X-Rspamd-Queue-Id: D771614005A X-Rspamd-Server: rspam06 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JES6PMtT; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1662069775-733840 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Converted the function to use folios. 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) Reported-by: kernel test robot Reported-by: kernel test robot --- fs/f2fs/compress.c | 13 ++++----- fs/f2fs/data.c | 67 +++++++++++++++++++++++++--------------------- fs/f2fs/f2fs.h | 5 ++-- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 70e97075e535..e1bd2e859f64 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -841,10 +841,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; /* @@ -854,13 +855,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 aa3ccddfa037..f87b9644b10b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2917,7 +2917,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; @@ -2938,7 +2938,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; @@ -2948,6 +2948,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); @@ -2973,13 +2975,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; @@ -2996,7 +2998,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) @@ -3005,27 +3007,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)) + &fbatch, i, nr_pages, true)) goto lock_page; 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; } @@ -3038,46 +3041,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 @@ -3101,7 +3105,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; } @@ -3115,7 +3120,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 3c7cdb70fe2e..dcb28240f724 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4196,8 +4196,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 Thu Sep 1 22:01: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: 12963278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D16AC6FA9B for ; Thu, 1 Sep 2022 22:03:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85C388006A; Thu, 1 Sep 2022 18:02:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 835758000D; Thu, 1 Sep 2022 18:02:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D4518006A; Thu, 1 Sep 2022 18:02:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5540E8000D for ; Thu, 1 Sep 2022 18:02:57 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2161980B3E for ; Thu, 1 Sep 2022 22:02:57 +0000 (UTC) X-FDA: 79864892394.19.89FFF24 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf19.hostedemail.com (Postfix) with ESMTP id BB89A1A003F for ; Thu, 1 Sep 2022 22:02:56 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id v4so315102pgi.10 for ; Thu, 01 Sep 2022 15:02: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; bh=cO8ljolH2h2y0oWNA4Z7VoneqopIkQJQEMsP9EWX9UE=; b=kKpyoHXEn14IP8WZWJwoknMWz/3cEOj2DtppI4cG+XUgdh8Tj1+NKWa1adqBtYfRyk VHPG5rdhWAQ4al3AZaUyV4gt0By/gJ2McMkw6RSp3WXMbGoQm4Z42P2OF7rEI5+v8UFy T83xOcnBL+8y53/G5LsCfiBNZVkJ59jiyGCBVGzvkjfyRBt3dlDX+e3T3Jb65ECCpxvk de50C1kCfFbev8CHBRr9SMR2MV04+yZrNWPkJ78ejHguj8T8ZvuRGaGrPi165Wp2Alcd WVUEC3AobWtJj3jqC/3Bd7A785/43KHGySAeLICCAztfaQ+xJ9RiweF5yex+rajvvdOC /ydw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cO8ljolH2h2y0oWNA4Z7VoneqopIkQJQEMsP9EWX9UE=; b=ITh7wZSnu97aoM/udaDOfVupT3PS/adQ0adOiHwP9Z4Y6gNHOv18wXtwMRIbG0K+dT BdKBkQphNxRW5EsYP+69T+6IZbs9DmHyOsVp5wZLqR5w0ofXMb0Cc/i+aKqwYgI5yJH6 EcjMMk2wi0yM8itzhaKqUZpkyvva/19X3YXwFQA0aL7GWuIubAPPEHJTVUuHhWNmFQiX GJAdSVM2TPctMm2sPnOvVzaIbhtPGPCB/+Vc6bziQsCnUeBzSnbT1ZIWPxFgSXDSfFhw G8EWSi3MofNuh/mf2eayv2+OkGQRhWWDE98LUMoyD2MAOrMwfsjXFbQYKkiDBz7GIyMT PIkw== X-Gm-Message-State: ACgBeo29XCFyOYoOIm+uU9MvKDf2WhHiXHrMwprF++3B+ny6EhVGoHLx KFH9nWnJtBl60d2nH1pWSjM= X-Google-Smtp-Source: AA6agR5hXhjZN5uBNUEvEE06143lBtKSeWoPuJQC/ApxWtxLERe0a7EzkbibHXQL+mnSnNH8xT9rzg== X-Received: by 2002:a62:1c81:0:b0:52f:ccb5:9de1 with SMTP id c123-20020a621c81000000b0052fccb59de1mr33199922pfc.45.1662069776277; Thu, 01 Sep 2022 15:02:56 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02: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 15/23] f2fs: Convert last_fsync_dnode() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:30 -0700 Message-Id: <20220901220138.182896-16-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069776; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cO8ljolH2h2y0oWNA4Z7VoneqopIkQJQEMsP9EWX9UE=; b=LEEuUHU1/xvJqPf/O50iiAvZJ00ivubA3luKQEyyfXgvIXBQtqB0JCAPIuXTSNPr99wXGL xFfcVYD39n3j2RyqszjnKS8MLVbz5Ww7RWXVQAbNGJFr94FJpO+hm51sxJHMGZwKdV2so3 GMh75CBeJoB55eN/q3f38BBNAb6O4iE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kKpyoHXE; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069776; a=rsa-sha256; cv=none; b=5J8SUIm66l2aQTuf840bZ+Gbtzzq9TEFGMNVlwDLn6CRjCG49UF3EnDxmZbS/slaxHn4+v bmiZdwFBBY+tyT4HCnntxZCx/hAJvIaxc82x1XSpJrXntbhHn/s/YpTSxbvC2aUl+BPzvc zLLWtYtw2zh4gsBr8TxBnn6nHpwkpUk= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kKpyoHXE; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam11 X-Stat-Signature: ayyo7j6ker3fj5345dd58xa7ipsde5u8 X-Rspamd-Queue-Id: BB89A1A003F X-Rspam-User: X-HE-Tag: 1662069776-34134 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert to use folios. 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 cf8665f04c0d..b993be76013e 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1513,23 +1513,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); } @@ -1560,7 +1561,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 Thu Sep 1 22:01: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: 12963279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EC03C6FA87 for ; Thu, 1 Sep 2022 22:03:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 949FE8006B; Thu, 1 Sep 2022 18:02:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 883618000D; Thu, 1 Sep 2022 18:02:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AD958006B; Thu, 1 Sep 2022 18:02:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4FA528000D for ; Thu, 1 Sep 2022 18:02:59 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 25C44140ACB for ; Thu, 1 Sep 2022 22:02:59 +0000 (UTC) X-FDA: 79864892478.19.AE2C7CF Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf04.hostedemail.com (Postfix) with ESMTP id BEFCC40055 for ; Thu, 1 Sep 2022 22:02:58 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id j9-20020a17090a3e0900b001fd9568b117so363019pjc.3 for ; Thu, 01 Sep 2022 15:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vLd5VxDvs/Hufc5GkPRPWmylC7gs4hvMBc2dqzKoD6A=; b=p+JLiL+0TTGlTunPHVFUf8hhPxVUM5krHr3xZ/nRtJsCNup/c9/1/FoZkcqQlbTuqR 7yIQkEI22HWTHAw3e/uBkXqiAtCxV72rvCMVQDK2rhTKLvByKuPPHpK3PCQQNtMmUlsZ x6ryoAy3iv+hjbY7odiJzZWYPcNHrRagmhRM0AsEu+7Rf7kbkLslvL/Ovm8ovRJNa83a fCdcJzV6GQj/13aqFF2TaCcDLkESTf7VN0HdaG6gurPXivZxibbBjD2PdNa+QzjUnHs8 ZSaXOBn0t7311FPL7y8pLBASVORDuHdIUh5dZBe944rGxmavfQqKXZbN9HU3xa8g1J3R pIuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vLd5VxDvs/Hufc5GkPRPWmylC7gs4hvMBc2dqzKoD6A=; b=vp5+PG/QmYmrc7yUZ1S1J8GGARZ6YqMD6Zf50uvSaLdmi/f5LxtgZ4eNDGOvcrKI3x vmHHIbcVLmst7FQPP7y0TnKQxb8505z5rWiqUZqMw/i2lm5P3QNSvNY0pzW7D30GgiqD tv63nwfj8su2KfLNjIebqMIG/DYYpw5Ui/K/T2j3LvaKxSufdGQGek9XTbv1lhDA/jdB VBKg90jtosl1NGaWy0ck9Yu0C1NR0QLTB5WjP07klUH1oMgQnA/FemSXLBWGqGWqUq82 huemAxI3kgXmI5zBaFWcGNA+RN419DQ3+pqP9ev4y2i+R0Wv3FTKqz4miXc/kbqNziqR /XUg== X-Gm-Message-State: ACgBeo3L93plGxGtDQhF1B8N36riah/X6mk34m/O78Izy99yzYVHVD7v QgIH/kX3ZkFkVonpe+WqNYQ= X-Google-Smtp-Source: AA6agR5YVj27mT4ke4I4ySLvDuaW18kp2BR/JRNlH5JJgk92B7crMzwZ8wnQi+NB/g4q0HYWFNk6+Q== X-Received: by 2002:a17:90a:428a:b0:1fb:87bf:89c with SMTP id p10-20020a17090a428a00b001fb87bf089cmr1323177pjg.20.1662069777704; Thu, 01 Sep 2022 15:02:57 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02: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 16/23] f2fs: Convert f2fs_sync_meta_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:31 -0700 Message-Id: <20220901220138.182896-17-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069778; a=rsa-sha256; cv=none; b=vnpYelQytaL4ugbOeDdyjj+ajvubL4z1jAfKQTJ7H9sWC0nXXvQOPsOhy/7vWtP3LogulY Eb18MO67kGZEilG8k/yslb211U14JsD9fDXI4OAt9ON6rU3XY8b7wQYgRDNZD+9sx7DsgT RoVw8IaniP724j26iump51sjFUGVXbI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=p+JLiL+0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069778; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vLd5VxDvs/Hufc5GkPRPWmylC7gs4hvMBc2dqzKoD6A=; b=77+yreozFFNmgtJqE0DcOJFMD1PWehgz8eYPl203yBShRSSfhu9JNq6SuMaM6zTXqUboPH iAxbUQVQOhZvJBfdtBkSvbYuRZWZvv+BTOY7pO8g1IvGSzJq/k9vxcffmmuntwEGOZ2jMk 61q4XQ7bJLOj+SOVkeK1/FBPviFbdVM= X-Stat-Signature: j794jqmetupsfpppigp17yau1to6c9nz X-Rspamd-Queue-Id: BEFCC40055 X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=p+JLiL+0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspamd-Server: rspam08 X-HE-Tag: 1662069778-962486 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use folios. 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 8259e0fa97e1..9f6694f7d723 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -377,59 +377,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: @@ -1381,7 +1384,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 Thu Sep 1 22:01: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: 12963280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9028FC6FA8B for ; Thu, 1 Sep 2022 22:03:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBB8F8006C; Thu, 1 Sep 2022 18:03:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B41A18000D; Thu, 1 Sep 2022 18:03:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85A248006C; Thu, 1 Sep 2022 18:03:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 77F468000D for ; Thu, 1 Sep 2022 18:03:00 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 52DA4120843 for ; Thu, 1 Sep 2022 22:03:00 +0000 (UTC) X-FDA: 79864892520.20.980E8D0 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 2208B40046 for ; Thu, 1 Sep 2022 22:02:59 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id s206so347592pgs.3 for ; Thu, 01 Sep 2022 15:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=IubIAba7YZRE2EVUfgGLgsJyTwN7IqgVJbA/A+wmkewugdYRTLP0jpRXRb8ZXglipi 39kXxM6Mh+Z6QuuZfYEPUR2RkGCYdDRf/OhD1qFK/2cwzDopXDY+PFuzMkRe7T3jVEmw VuNwUZRG5MOKCM66KiX4o0t5NxQvk169FVhCbpsfrc3CSfCG9utWCQ9XhahKE870IgN8 83K87/w+dCyfg9bQGfEtPOHFnX8P0pRUMrbNclAsnO6OSlpzksg2wX++lfmW0gfHXTZO /aB7miehFJRUltlCq0BmpQxj+Upu3Ta0KRuHwnHQCvdNIz8ng++xSsLIXcDoYAtZEIHC +BUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=WWXrgEytzReGuSIEv7W//QNnR2rG7Fj5TN2UGfiWnlhT6e1eQgVZT4M1dY2ok3MZzY 2D24eGrqRsuG2k8vjgVz8WX3kuOFmRUTs+r2wM2lX/0n6v50hLhgQmyyiSTGBLlbM05Y nJYSM2jiEcNr5On+BDbZHDFloWnBIVZjDBmxtJCV+imBS+c8wdAiRpakFCog8hsAtk1x P7ZPRW1Vb7wdSDfykZcCs+vxqZgL3tfRBrvhg1Y9uCbHQlkCyiGBtK4l+DX0OFhPtAuW uFT3GNB25hq/rE/D7+EPVuMfJhpV0sAceNy+13ls7Ek7LaBfE06T1RX15OULhQiz4HdF QDiA== X-Gm-Message-State: ACgBeo2yWuz3THqcT84Iw75MYB3vDH+3W5wPjtq2YnIf+CE4VwFlvALS 5FmPca2ocGuRwjX1zCnPJWY= X-Google-Smtp-Source: AA6agR7kK8mv3eGDvFSsjWIqFGNnwejzgA7uFnO8hxtjKghd7bP/AMPU5Gj1n3q8LbQ5/7h0Aw9Zuw== X-Received: by 2002:a63:914c:0:b0:42b:a8fa:eb47 with SMTP id l73-20020a63914c000000b0042ba8faeb47mr21681836pge.267.1662069779121; Thu, 01 Sep 2022 15:02:59 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02: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 17/23] gfs2: Convert gfs2_write_cache_jdata() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:32 -0700 Message-Id: <20220901220138.182896-18-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069780; a=rsa-sha256; cv=none; b=b/WA7XX0oKZwMafgoDMe7GGsTP3jsob3j9D2QIG71R9WPEE9yUCCMmZZJXomyrfZ7xfd8N 3qU+RR6RliNcWfnOCwAQYvgY+OTKz8DD9bX+twE/fHGgsaHxKakfLfSoRN4fieRicHphFj RjnhTQm+bgDCDs8em2+ULJqkWgZhKIQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IubIAba7; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069780; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YZ9m9PEte2VFIEg+ZjqrJWhRYr046qHZsEH0p4wP4bQ=; b=MLEYWEjnx+GZ0gnVTjeyCyUasCDpq+78euj3NWf/bIIXZkNu2oxeqYZq5MMsMW1ejAX3rs aiThcMlfAmGmoCGXqPcqBk4oAz8G9C0W/hqEQk/+DqhlfSCgcG9JiLg8ugI6M03ba4YC+z PzPUD8P1VkXIAfKYiXkkdTW0S9znEFg= X-Rspamd-Queue-Id: 2208B40046 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IubIAba7; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: ctrufnnhqkksd198m44sg1mdt4dc6d86 X-HE-Tag: 1662069779-331213 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Thu Sep 1 22:01: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: 12963281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7464CC6FA92 for ; Thu, 1 Sep 2022 22:03:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 464C18006D; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 416078000D; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 218CF8006D; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 10D068000D for ; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CF1A4C0885 for ; Thu, 1 Sep 2022 22:03:01 +0000 (UTC) X-FDA: 79864892562.22.5FD0229 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf04.hostedemail.com (Postfix) with ESMTP id 7709E40055 for ; Thu, 1 Sep 2022 22:03:01 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id h13-20020a17090a648d00b001fdb9003787so358386pjj.4 for ; Thu, 01 Sep 2022 15:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=STxbhiL9IoQUx8Fgwja3LTFavGfQLVFycqxgyDfQIlo=; b=mGc2AoTR/eShDxn1bEGmqvAylW19QjNRk+3TcxKgV4984n2y3D5OuujULmMIC93l/e 994+ww4T76o6BwzB7Dyfg1FF5LjMDxODXBmaL6NBji3traBoNonz2I7oQAmlcfxNHVOA JLdLJqIa03W2Qrsk2PIvMnMysU/ngcbLVN/BRQBiNvcP54q0fdpfZuno15/BTBEyV9zg LqeO6y2P9pncUMeumeGyzoYeeCTEq6ojO8ZrLkKxcxzK4cx52ZP/vQb7lv19FhPcRb0w pXJidnaUHcjIUUhd88lBjjlm5xn6XbNJLDk41pSKS73ei7RFGp2h8pKrtvCI0OhjWSf8 m3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=STxbhiL9IoQUx8Fgwja3LTFavGfQLVFycqxgyDfQIlo=; b=35wWg5Tr3O9qM7DNCS14vQPHv9Q2HSkLUngN5ICyUa8AEmvjtozSU+JK2i0pHpxEHe InGNgs9LvonXizDVtuMIP+m1TKtoW7le/f5LjyIeNsKIWYRcWzL35NEa5U1Y4ZM/h8v1 DT9ovxA8hWr9lSK0AcwQf7lzjaX0T1vQzMOMI+7SXsFAfD3jJ9neiSFDlTKg9303xhZ1 1EKExfhVVFWYwis/gur3ecW23lKpLlyZJOX15VLswflqbgBhCU1ibqvm4ovBgB71tdMP GCwza1k2gEHk5IqNxi7MrgJ7RSCaGgIupXrumeV4QoYhXUpo5Y/eHLkEOI/N6/hR+wMv 4M3A== X-Gm-Message-State: ACgBeo0Hkj+9ZU40XQqigiAkS9eZh7sskeP5da9WN0t7D6cqLEvOzCkM P+4ZHz7uCwRcWUjWDu828dE= X-Google-Smtp-Source: AA6agR5hhXeukBftcpo4uj8qt2S1ZJNE07BNY5BMKr4j8Hs713UO7OgYoXkgvfwPLmscDaOkJk3Q/A== X-Received: by 2002:a17:90b:212:b0:1fd:e61b:866a with SMTP id fy18-20020a17090b021200b001fde61b866amr1263582pjb.141.1662069780541; Thu, 01 Sep 2022 15:03:00 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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)" Subject: [PATCH 18/23] nilfs2: Convert nilfs_lookup_dirty_data_buffers() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:33 -0700 Message-Id: <20220901220138.182896-19-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069781; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=STxbhiL9IoQUx8Fgwja3LTFavGfQLVFycqxgyDfQIlo=; b=lsDLE3RryPjIQavd4bKf7E5jgBDRikwYp2TufHfJo7eHLZ76PHaAkUMmauIezPhj/xDpTe fo46Ps9EiS1wu40+wIQhJG4Fa7Klif9jL7/bXMmyI6sR6iGn6FtWBeZYkHvZL0XcvvI+ei GeagWo4zEnjz4C9NUC3lhU67PE38eE8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mGc2AoTR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069781; a=rsa-sha256; cv=none; b=gvGniXuKhY1UeLENOthZxZh4tq+YWtk+nPM3UFK4MeIcuXMVojHcRnO56Joyy34XCixX62 sSXW3G0WWTdcaeYj2eX87ukAJ7KoEsaRgannkese6MFVKtNqPLG7OcPGwNSu9YHCEWxv1G 29bmxdEgGIkARFcFC4XpwTPeCWh0Xhk= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mGc2AoTR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspamd-Queue-Id: 7709E40055 X-Stat-Signature: yutk5sjwyg14yhbfy39qnnj3y5fckn7z X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1662069781-640417 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) --- 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 0afe0832c754..e95c667bdc8f 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); + head = folio_buffers(folio); + folio_lock(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 Thu Sep 1 22:01: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: 12963282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6D6DC54EE9 for ; Thu, 1 Sep 2022 22:03:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B8018006E; Thu, 1 Sep 2022 18:03:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2401D8000D; Thu, 1 Sep 2022 18:03:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F378A8006E; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E47508000D for ; Thu, 1 Sep 2022 18:03:02 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C859E140ACB for ; Thu, 1 Sep 2022 22:03:02 +0000 (UTC) X-FDA: 79864892604.05.5834D8B Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf01.hostedemail.com (Postfix) with ESMTP id 68E834004C for ; Thu, 1 Sep 2022 22:03:02 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id n65-20020a17090a5ac700b001fbb4fad865so390199pji.1 for ; Thu, 01 Sep 2022 15:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=R1s+Q+mQAi/BIrt6gOgtRlGYE9v+cGNlC5URnwM67nk=; b=g6fAyp3iJgf3LzmTu5bD5zWTZ7od9i2yk9cu47djS4LzM5/vaCauETEa79FJPDbfwN cLdqlUh9d8nI0Nm+LbuAhIItiLNmHGfoqlGAYhSfTiRw4ljsDmSdVadB+3m2xO1TNUJa 0nuVGnoNqQQoLmodKszRhMXSnkLvvjZ4R3brnkvtlDRm/qXRnT+DMRacWFesHhTBBNKc 0V+89RIxZ0WLehbpnGAbTdJ5uOSPOqVqMofTzLN0E95dgYKuDPhCGssRW2KFzlTQQNsi D66yCF12E7iDcZecg+ujt+pmVYyoJIOMaXlKUD3A3/5c5nIgJRrzLjZgJB8I6DmUxegn s9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=R1s+Q+mQAi/BIrt6gOgtRlGYE9v+cGNlC5URnwM67nk=; b=Q5hUgEd41qz3CyhDlcGxNAHsQyldbjnzGWLCRSkdtACD48rGK6e2jlJK+Bpnqezdd7 wBHhV0JhCWcypSABWD92mC14b/7h6T8X6LhMPL+vuqyY5st/DWOh35YBMlPEMoOs5mVr m/N3HwYT/NLc8SgMeiKxof2GmEsaJUpbMa0GigYKk2c1ZIaRiAI7cbfgkdbIN52//uy4 pa+e1ixuq+6SuQKGyRCYrSRftCa6OxD/FwcF11wbvILxcluQ+ZgXDCeJ0sDf1sIBenGo IIaytAFhiM8QsX8U/uekM2IDOwS3yV1QEavTV5k/hTMno6VZJ1wA5quRi/y+OdPAj1IE aqNQ== X-Gm-Message-State: ACgBeo0aqR7cXdal1wEu6gsFL/6XdhWak8eevb3/6/d/ZWu+wf24/pcG XpFq4unJ23tPRiDXNnRpwrg= X-Google-Smtp-Source: AA6agR6TsbdMkmC0TPigfGG4lOziD2qdPKDR4aZqEoxc5g1boqEfjdmsGUoCDRdXOVT8V8NL8wfwag== X-Received: by 2002:a17:90b:1bc4:b0:1fd:b913:ef58 with SMTP id oa4-20020a17090b1bc400b001fdb913ef58mr1275606pjb.220.1662069781924; Thu, 01 Sep 2022 15:03:01 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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 19/23] nilfs2: Convert nilfs_lookup_dirty_node_buffers() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:34 -0700 Message-Id: <20220901220138.182896-20-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069782; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=R1s+Q+mQAi/BIrt6gOgtRlGYE9v+cGNlC5URnwM67nk=; b=38WkxWKmKpV6rrtPp/N2ZC29T9uDVQ9Qdw2BTuuoyJyX077vwdkzlPqh2VRiQdoviL1eew aMe65+uRW8yI/3QnxAPV46ao5Fq6H8Njw4ms8EB2bFNls12ovVuq0PoBaYZdPiP/1tkas7 kPt6n7zQHn0xG8Cf76bPRsR+i0hoAzY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=g6fAyp3i; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069782; a=rsa-sha256; cv=none; b=WAAvi5oFJgwJnvOMcf9zkyQfrTWGDIKBViJXi6i/McWpYIemHPx4mXl3EstL31z+3DWoyb Wyz0Gzb9GvmCk+z8041Bx6oEZ0MZomm6KbdLVxFi1GfNw9RcL90YysJvn24nQCQpl+XZrx dBkuCSgukkj5sN6GUypQ6Xm7v1tMaZE= X-Stat-Signature: 6wsw3xz4s5reecj3ety6n41onjz6bbmu X-Rspamd-Queue-Id: 68E834004C Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=g6fAyp3i; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1662069782-243180 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 e95c667bdc8f..d386d913e349 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 Thu Sep 1 22:01: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: 12963283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E1BEC6FA98 for ; Thu, 1 Sep 2022 22:03:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9E5F8006F; Thu, 1 Sep 2022 18:03:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4EBE8000D; Thu, 1 Sep 2022 18:03:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB90F8006F; Thu, 1 Sep 2022 18:03:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A01518000D for ; Thu, 1 Sep 2022 18:03:04 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7AF88AB39F for ; Thu, 1 Sep 2022 22:03:04 +0000 (UTC) X-FDA: 79864892688.27.0F945A8 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf27.hostedemail.com (Postfix) with ESMTP id 338C940086 for ; Thu, 1 Sep 2022 22:03:04 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id u22so50967plq.12 for ; Thu, 01 Sep 2022 15:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hDptbc18eb98tE8iQjyPGn696c4/GhyznW32HiLxniE=; b=gUm8S346I3K4ORq4miRaGKQWrBRZuwaXck/yvUpzoYTdcWhN98CW9jDruatqJgoZRb Qr7AVjxZmulo+5f9KMRw7o9SzO4VVVP0E6R5Fgix1Tba0Tyc9gA4/EjPT0MKD3o3ubc2 vB47B4Wkmo9W5esV3vAFQYuGkm6R+OQ7uA08pjBivhfS8LGFryls97UPR15F7iPOmvl2 dHyicbyty/5LQkxTuojwAF90zrZpQJynSNJ5hxss6FcgzCzxI5JO1ptQdUHVZCAWmElB t+fwz3It0ogWy5Uf628XzRjlYTQ/0YWnLDjVYm3aDd4wv+omRXtHPDbeL0giXBfgWA+5 lhlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hDptbc18eb98tE8iQjyPGn696c4/GhyznW32HiLxniE=; b=FmNdHnPUramM1nPHmcWTVMUT783aQ0EE8lV4KxQhLLX/Gsy7zFGg0TC9xN+ZUAcNCC uxoWakccS6hvcmBc0zVZI4vi7ypBGkqHHWzujhzton4xkY+zGIjgHcifl8e2f2VGZuVX kZgzIJtMopungcKvmRf9UebG329Mbm1Mxk3SmJIjAtUa6/5xaGNKtgXrUICCtMMklOAt g6viXClzOBHa86AWThNdciqgPpqbR8o6bxW7JKZjoNpIh4a7yxcETNht7gZoOV9xaSFi 7ek1tDIQXYiWo2kLxzumXGWMHqSYbKw+L2X6Sdym4Ff4FlU8rMhFrsDqVIlV86Yk8oKq 9a3w== X-Gm-Message-State: ACgBeo0As1Qu+IwS9CsKltCgM4+0NpkkO181LszfMcM99cQk4uKzGziM oTt8DBdvbdIGQcz8RDEkGho= X-Google-Smtp-Source: AA6agR5IeTCiSE25gUAjMIUlyuAb/ATe40085kNlIdR9XrP9KH+/bi+PEVrsNM55mfWzwEZYZhZwXQ== X-Received: by 2002:a17:90a:8581:b0:1fd:62e0:67cc with SMTP id m1-20020a17090a858100b001fd62e067ccmr1336794pjn.144.1662069783338; Thu, 01 Sep 2022 15:03:03 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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 20/23] nilfs2: Convert nilfs_btree_lookup_dirty_buffers() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:35 -0700 Message-Id: <20220901220138.182896-21-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069784; a=rsa-sha256; cv=none; b=t/OEGMRiefkQiNGY7DMCOZOFLPBNbBZT3Kjr2Pp+Ip+DXFloUrqHpaB4OK6AMb6GJrQXS1 eVaCago2MxJkrA8pIQV+EWhVlVxKu9yQP1sgEPmdTv1CGf36Gk8fAgsUwSnDoFKBvuVkXD RX3SqhAOGZ2gQEx15Dsbp2SBNve3PIs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gUm8S346; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hDptbc18eb98tE8iQjyPGn696c4/GhyznW32HiLxniE=; b=5u7VW/ENU7ohQ8Nmj/6H/skOBsPQgH7z3K+z4pUOo9rRr+liGaADDc6sticgQhHctkvWuM 4GJtFYl4in98dSWU+P0IqGjAIRx+3V1hrTgvSFeURX1eRcbjunuAP8l/fheeI74y+FpaJC PYxpaeX4gd29Rm+a/aD3twEs6GiHv1Q= X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 338C940086 X-Stat-Signature: mgobirsuxea36x31geuor85fnqaqh1zs Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gUm8S346; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1662069784-875919 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 9f4d9432d38a..1e26f32a4e36 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -2143,7 +2143,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; @@ -2153,19 +2153,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 Thu Sep 1 22:01: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: 12963284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFDBBC6FA8C for ; Thu, 1 Sep 2022 22:03:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D24480070; Thu, 1 Sep 2022 18:03:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85FDA8000D; Thu, 1 Sep 2022 18:03:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C3F880070; Thu, 1 Sep 2022 18:03:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 451538000D for ; Thu, 1 Sep 2022 18:03:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 20D55120754 for ; Thu, 1 Sep 2022 22:03:06 +0000 (UTC) X-FDA: 79864892772.01.7CA10AA Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf24.hostedemail.com (Postfix) with ESMTP id BA20E18006D for ; Thu, 1 Sep 2022 22:03:05 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id c2so114951plo.3 for ; Thu, 01 Sep 2022 15:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wOJt0d5525/vdydCfZOLqeQx20ust1GIMaCJJ+sLeoU=; b=diBwxyvKEf6JI6u957lZlRjBGUqMPUv/DOTu7USfBuUCPzlXtneLcNkT0wHfsvIjgR RtFF5KdI3PUaclSG4E8jhu3HF/vGooJNXm0wgBU68eptXErnpIrgJIK7grK3lg2BeI6L gnzmKoFOzWTOhjK7j7BejIXQ7JSWJrnbFx0Oc6zaDOnzxuaDir2i3tvuwfF1UzG2jYEP Cytu/wxg4A0FNem7xkUQzwOJicEG0m8Lou+wbr97B040g23ggq7N5kdhn0ywWQ13/Za/ fq1WOxoWKPbol+s7gwJKowNnVI90ccXLoGBZIPqrz2b0PYJIIzBsCuxtrhYjXdSRoOEL ZZig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wOJt0d5525/vdydCfZOLqeQx20ust1GIMaCJJ+sLeoU=; b=ZhK//BXLscGEdvvdd7jtv6KRIUrPDKt3fj7JGD0F0w/UrVJrv1guxAUoP8xH5O+20Y su4c/49vf2LGBGtnk+3NI8ceo6Hz3bVuglNclJZ8GPUAvKE4AtQOejcSV9DjOk0cjqxN lCFdFCq24vPDUH1R/T7DTjp9JsnZ/Z0hSVNMNKJsPW0KRe1VisjXKkBt4Z1ieINzAsUU wiwudyuizLEE/GDIiSuQCATnek9CK29QARTrmHoTj+Du/GrZPo12Do848OXj6g/Q/X80 iycCwz7XsNznu/o4bJYqCQO7aiQVQG/gqlQ0ut7RfFf0CGbjPvymSK9HJ4O6gxTPwQvO RbuA== X-Gm-Message-State: ACgBeo3g8GsYh8vMJb1yfDrEufEbEg/RsBiiBHFD5qvrkDipe6/mJ5PN 5azZXkARSXxdMeccg/MxO/8= X-Google-Smtp-Source: AA6agR6RjeZe7Y8QnW0cYYPMobD16I7AFu/QpKwQwdSJSAXd1pKggv0iXArcdd34IaNHJIW6grL9/Q== X-Received: by 2002:a17:902:ea02:b0:16f:11bf:f018 with SMTP id s2-20020a170902ea0200b0016f11bff018mr32101491plg.150.1662069784735; Thu, 01 Sep 2022 15:03:04 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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 21/23] nilfs2: Convert nilfs_copy_dirty_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:36 -0700 Message-Id: <20220901220138.182896-22-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069785; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wOJt0d5525/vdydCfZOLqeQx20ust1GIMaCJJ+sLeoU=; b=0rzZXC1qADf4El+I0fzH3LY0aPduwCaNTsquIToAFNW7z37vdKPvBz2lgpKiPui6QnoVaI hzFSkhQfA4GOsBxXzAUw1jdMTSTFEgSBBNbLqI6FbK2U8aPG4Pv3uuo/EtEdb1os9rJs3P yCctfAy7S7ygkWW8rkjMGBFW7i7QU2E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=diBwxyvK; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069785; a=rsa-sha256; cv=none; b=vLNR3FoU5i6zxVAbC+TGcX6LOeSPDNq5sp9brQwlp2HCgDeGCSJ8xY8oxOQL+iWJ/s9InA +3g41shboStLH/YHgLLErxfhyXJpu+9HmNplgPLwpLzTdN9rU55Y5pBo3qMB99vlfOu8be gjmN+5LmZk2oPzWWEkDvvwqjAS+zA0Y= X-Stat-Signature: 1eb7xmbbshtegmr146tjik4u36bnemad X-Rspamd-Queue-Id: BA20E18006D Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=diBwxyvK; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1662069785-988890 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 3267e96c256c..5c96084e829f 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 Thu Sep 1 22:01: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: 12963285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 536B6C6FA82 for ; Thu, 1 Sep 2022 22:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2D4880071; Thu, 1 Sep 2022 18:03:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D16AA8000D; Thu, 1 Sep 2022 18:03:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB56A80071; Thu, 1 Sep 2022 18:03:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A9C738000D for ; Thu, 1 Sep 2022 18:03:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 86BEA1A0602 for ; Thu, 1 Sep 2022 22:03:07 +0000 (UTC) X-FDA: 79864892814.30.02F5F6E Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf17.hostedemail.com (Postfix) with ESMTP id 263D640049 for ; Thu, 1 Sep 2022 22:03:07 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id u9-20020a17090a1f0900b001fde6477464so3726858pja.4 for ; Thu, 01 Sep 2022 15:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6jEJW/hdf8NlYILH28nH262i/WrC/eObbm9U3wHW7N0=; b=N9gi0ek73D6+Ob4gJQTCenTIizkASUjD+NGWnY0SxFC164jHY2z+KDjngS5u8a5ea1 pTnBRJWlclL9jxrutcaq59svND4AAi3Mu6zjZ5R0ZdTzg7WkwILrexZuQIgRHx4yncJe OCQ0GP35CE39948Jkx+DdsWr/hVemLW0aPd8pHpB8mjZW2hr0avHI7FZaniFXz2bEU5c 8rj/3cGG0sHkP+Xg1vHbPyhxWGLC3ZGSwUXEq4Bo3qDVM63ON1NgwYw3KkUKbds8fRoP Z5oZrMmJFM7HBd6JNC8OlP+eYzpgfFP4AsKvNF+23CtWe3kx/Wqjrlwut0YprghhKCzN 8ZkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6jEJW/hdf8NlYILH28nH262i/WrC/eObbm9U3wHW7N0=; b=XeUm844iMrqwUXRsFar0SzT6Dyw6lRHbZZss4ehsW4hTM8qdW6EALIUvtE/xS2KRDZ cMulYpxeX0cd4mIG606rg4jI/7/2cMgA3dOL8QIf2H0dAivbxzWxTVz5A2kqDo9SOV9n HWT2510jiX1MWhQMy8YS9taXxlOv6uGfXPIUgOL1NfVVExI3bx2pxv5tewIDsblKCEPR e/w8NCo0C8jS+GeBplu52p7QYU7iv5yH1ANxteFCT0JLlAj8g1n4VOhiSaoDVP71x+mZ VrB/RTIEGTIdHOL/8u9qfX+Jk7/HtLj4gN6GqyOYUAnKcWhjSkC/WBu6DEBJdPXTwHgq IaAQ== X-Gm-Message-State: ACgBeo15zOInWYT5gO3azgeGgaBJSUUeTtqx/5tgHBPWmuTUZoTlUe+6 /C0LnMpHZ7jSgE8QqZUilrI= X-Google-Smtp-Source: AA6agR6ueb+SpLMpe0ENf809+aslBhtpdEEwbT3aRvZt/q/0zk6S/BuXNiziVl4cLeo0K8hj5HTpaw== X-Received: by 2002:a17:903:40d2:b0:174:e086:c748 with SMTP id t18-20020a17090340d200b00174e086c748mr19496625pld.108.1662069786179; Thu, 01 Sep 2022 15:03:06 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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 22/23] nilfs2: Convert nilfs_clear_dirty_pages() to use filemap_get_folios_tag() Date: Thu, 1 Sep 2022 15:01:37 -0700 Message-Id: <20220901220138.182896-23-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069787; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6jEJW/hdf8NlYILH28nH262i/WrC/eObbm9U3wHW7N0=; b=axXZLn7YTpDY9P/mt1x6NB0dvOEx28SsfhjZNMMgpAfN4AT5JQOlIDFuhrQ/7Te1aKPzuJ poQVukWcTrmrI+G3UyqLXbZ9QpeFsXjiB66qzgmGWBQw+M241WRZoXn5sq9yyTY26nGMC/ Gf2CQlxCzNI5fXY9UaBCcbF6z2yEhsg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=N9gi0ek7; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069787; a=rsa-sha256; cv=none; b=uZbfAHUgqQ2zT/9TA+u6uaRaQ3AXj5yfOmP1Y/Qq9ny0u1C11zSsYNuhCsYZowqv81fHpA xXUTykdsOh31WLT/krxt1QIlyz15qncjw9n5t5rwjPAcfyIXZbvR4Dc9rk0+D7EhtLDBp2 71KZ0kJpNYU/VBhrVxaw6nFft54z9+s= X-Stat-Signature: 44dyxd9kkgxffw5m4ha93csnbqazmonn X-Rspamd-Queue-Id: 263D640049 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=N9gi0ek7; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1662069787-958171 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 5c96084e829f..b66f4e988016 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 Thu Sep 1 22:01: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: 12963286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0B4BC6FA83 for ; Thu, 1 Sep 2022 22:03:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A1F180072; Thu, 1 Sep 2022 18:03:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3512C8000D; Thu, 1 Sep 2022 18:03:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23FC880072; Thu, 1 Sep 2022 18:03:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 16C5A8000D for ; Thu, 1 Sep 2022 18:03:09 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EF3541C5EB9 for ; Thu, 1 Sep 2022 22:03:08 +0000 (UTC) X-FDA: 79864892856.17.8C50A00 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf02.hostedemail.com (Postfix) with ESMTP id A12E48005C for ; Thu, 1 Sep 2022 22:03:08 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id t5so308955pjs.0 for ; Thu, 01 Sep 2022 15:03: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; bh=HQUrfRdnfiMPUlTfezXhcqX7GV4m5M0rlOnnNapCheA=; b=AZ1Gh+wOtBhSiXkUQoUoHrl/CllEH0S/F6SZN+G8cU8utWIxzXrnoFihXwwy0eoaqG ZtZ6nYtih0NHVOG/x9bUxgLJC0EeQZankUp2pEA7g6KYwaTJf9CocEAG7w7ibYh1DFhx 2HQQyt2JiKisIfFxLEcRmhLgtYoadDjglGDJ/UnVuA3tBxC76X4AHHv5Kq+Ie9VJwofJ AspbI9B41dZhIaTKwUcp4Vr/pjxO1RO2X+wSsB0xbuIWNYtsF5wtGAA1UbZGQNpu9lWz 7b8hoU1c9a8OqeUDqCd00/2NCsmjk5Y7NtnPYtn8ybzFuBSqIhxSE2lBKoRWqNV7Eixi EGTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HQUrfRdnfiMPUlTfezXhcqX7GV4m5M0rlOnnNapCheA=; b=6kb+Ssi2CM0qsEjxrOTQP3oS1oCFVudPoqibHNcMglSZS+DDPFmDgvIxC0KVFMqA1U IAYDPLmDIyIfR9q5JRIrnGCj7sSPuNhWeWuWd6oi+ykJkPeMrb9JheRSkGnl7nusrHNb xeSJYc5xnGgSi42HgumoQfh3hw39bHMOk+Vt5FTO7eKd8xqxhZnJKHxmW3Ru13G8NN8a yVjOMr2mjw6iUwmt8o8Z2GGB99Lb2YYvMXtjRogAY4+2JifEstHnqvT5FMMVE0BlDZyQ bbez1M144ff5XgnSbfn9n4Hc9V2pSo657LrHhzHKxyCGyzgWl6WYs9GhuWhshThOOQPD Arzg== X-Gm-Message-State: ACgBeo2qW83lEAuMjaoPlfJysGMeylbge/PLo/uLqk2+S77VCABXGTJm iSy2zievkJldXPZMTqSFGBs= X-Google-Smtp-Source: AA6agR6M4KV1/uy50J3RjGncA9GjGMYBIQY9N46Ltdjsdv79/QyPq5LWrP53sFKtBy9pAOIegAIevw== X-Received: by 2002:a17:903:41d0:b0:174:d8e0:b0f1 with SMTP id u16-20020a17090341d000b00174d8e0b0f1mr19365682ple.74.1662069787634; Thu, 01 Sep 2022 15:03:07 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:03: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 23/23] filemap: Remove find_get_pages_range_tag() Date: Thu, 1 Sep 2022 15:01:38 -0700 Message-Id: <20220901220138.182896-24-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069788; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HQUrfRdnfiMPUlTfezXhcqX7GV4m5M0rlOnnNapCheA=; b=1B+nTOixHxNCivqvUi4D+z/3YiH+yVY4pzi5jjOooqfcAcdy6uEbse5UZEmM1rGwyCbCW+ ZQEqzvKI807EstjlEuZAdw0I3Le/87q7JlrD2F15eN6afz5UtY3wv8epBlPkShKvQTjyLI tjHAENSnyyvuEdwNaeFPrIRRl7Ae2f0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AZ1Gh+wO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662069788; a=rsa-sha256; cv=none; b=XqozpWdwAYlrWTWnNhNvidAJe3HJpvhqIf8AA4Ye6RaHW7c1YS4YbrB6g6PFl2cevtcCHs fvOR7mu4ilMCmJMXdl2xdBYeaFS6jZ7CBiwWEm54Z1d/TYW0h/2vYygg7F8RqL+u6V+4H5 aHQCfsySiaVo8G35w/bEh83THh3op+E= Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AZ1Gh+wO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspamd-Queue-Id: A12E48005C X-Stat-Signature: 11pgybp83d3x3t484hetpk6f8t6z45xb X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1662069788-985341 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 85cc96c82c2c..b8ea33751a66 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -742,16 +742,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, unsigned int nr_pages, struct page **pages); 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 435fc53b3f2f..b986f246a6ae 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2309,66 +2309,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 9cee7f6a3809..7b8c1c8024a1 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1055,16 +1055,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 */