From patchwork Wed Nov 2 16:10:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028380 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 4A699C43217 for ; Wed, 2 Nov 2022 16:11:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9AFB8E0003; Wed, 2 Nov 2022 12:11:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D5698E0001; Wed, 2 Nov 2022 12:11:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DBBA8E0003; Wed, 2 Nov 2022 12:11:10 -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 6FCE08E0001 for ; Wed, 2 Nov 2022 12:11:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1AA3CABBAD for ; Wed, 2 Nov 2022 16:11:10 +0000 (UTC) X-FDA: 80088991500.29.BDFC7C9 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf02.hostedemail.com (Postfix) with ESMTP id A38BB80003 for ; Wed, 2 Nov 2022 16:11:09 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id 78so16618610pgb.13 for ; Wed, 02 Nov 2022 09:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=b22oyujJhcmEnIoOWyXlmdwFsWtvDDEbrYWi+tTl/IKQZadCXIum/ufaWsfiuhgQWs P0ejMWAXsFFxmUJWgjcqRWL6iDvmTJOBHMdvrWNuXSDSGhujg7k49tnS+xBECZ0DDC1D QEeKOjhkuj2U1fYHa3KM1TSvYvE4FrIPOrf/CN/DjK2k7Ii76jHakZpfzft8GgAI2TOi 3dtL4HfeEfRRNgP7Mp0GAgu1ZDeKvnGqK9CY4nsrmEB3lEEy5PFMtwvBwHVV7JaSQ4Oc JqTTGwFIB+4o1Aa2ylRSznqsjRcz5BF5gANEbFRauGWLvr7/47QbInfDSn9b5QQsOYI/ 8XPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=4PdIXBduOPwWcgrXrIvXK/8D3iB1FYFhz3zxB1noxsKGcu7hwSRhftg7gRcnlr1XAt YAQYo6+cF+bLf87n9VsBb6oSQ0Ruxk0twlAulF/QKLiM+EmaB8Ot4a1nvp/tTzJmx/Za 1Et9VsV/Z69YI/JSOINaljHHGIxc4f5yjB+bTH5KEVF1DC6guN04ZCkp59qPzWApZrld 9A3u8ocy1pSsdgorVjJMK8aKY0pGp7YYRaabeIKZ6kvFRC0eXhRFkX/SyyOdzDWybe8I iYeJef0NAeZnuBDU4AltTzcLa1Rc0xCkHpPk25vH8zprTEaC7LwtMHJHj+BX16TJTcxF +bcA== X-Gm-Message-State: ACrzQf2iLy8EARjNwjaYVytgs8M2MnyiQiditqmMa4YLA4X17Wze/nmP CKEIqUINUGjodQ5aF0J5aZU= X-Google-Smtp-Source: AMsMyM4joqcseRqaAlvGrQuZzcj3D8bSzB3ystEOG//zbMspTew1XCkFbHiKN+JLHdCdJZX/wxsOQg== X-Received: by 2002:a05:6a00:1253:b0:56d:8742:a9ff with SMTP id u19-20020a056a00125300b0056d8742a9ffmr15514058pfi.5.1667405468483; Wed, 02 Nov 2022 09:11:08 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:08 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcox Subject: [PATCH v4 01/23] pagemap: Add filemap_grab_folio() Date: Wed, 2 Nov 2022 09:10:09 -0700 Message-Id: <20221102161031.5820-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405469; 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=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=rwo9qPlRMZ+O9uF342WLhCPO/NWtw59ApJaPjcXie8VfL0GfHfZjN8QHeI7e+pa5NalUp1 Kxgnngz7tpZoYNGmSqwuIQGGgV6yY0Ou2EWMRopVCfgLd2KluZzHh4C9tVrm+aVA+lF8+6 2guvtw6fzzwLtGalsIyCqTsIUpZpaQI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b22oyujJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405469; a=rsa-sha256; cv=none; b=0emJRgOiRrTtwB+PFAI3aVNyZgSlyzum7XvgnopIzsmbEIGJyx6ufFKGeaeNIgac6oZYkA +NXuH8pQpj64BfqU3eE7r41kAQGCJu/+hpLhTuXFPYJnBu829BTBG3AWt6EBShbmKFjgyh NshVSdbB4tiYp7rUcIYbigliQf4cErA= Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b22oyujJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A38BB80003 X-Stat-Signature: ifhdywyeggqcp5ppg47gsrjgj5jrr6y5 X-HE-Tag: 1667405469-787225 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) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..74d87e37a142 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -547,6 +547,26 @@ static inline struct folio *filemap_lock_folio(struct address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } +/** + * filemap_grab_folio - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * + * Looks up the page cache entry at @mapping & @index. If no folio is found, + * a new folio is created. The folio is locked, marked as accessed, and + * returned. + * + * Return: A found or created folio. NULL if no folio is found and failed to + * create a folio. + */ +static inline struct folio *filemap_grab_folio(struct address_space *mapping, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); +} + /** * find_get_page - find and get a page reference * @mapping: the address_space to search From patchwork Wed Nov 2 16:10:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028381 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 9859FC4332F for ; Wed, 2 Nov 2022 16:11:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19B368E0005; Wed, 2 Nov 2022 12:11:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0ADC08E0001; Wed, 2 Nov 2022 12:11:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1DB88E0005; Wed, 2 Nov 2022 12:11:11 -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 D354B8E0001 for ; Wed, 2 Nov 2022 12:11:11 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9114E16125E for ; Wed, 2 Nov 2022 16:11:11 +0000 (UTC) X-FDA: 80088991542.09.E857D4C Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf15.hostedemail.com (Postfix) with ESMTP id 2C5B0A000A for ; Wed, 2 Nov 2022 16:11:10 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso2597700pjc.0 for ; Wed, 02 Nov 2022 09:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=n1wMZVPJgGAZfgmD3ZkM/SCD642n1Mc4Zn6+qTmFZdbiwhyj7wS8pZ8SFI+liwrQ2r jRtU/zEufgYnUSRmaPQbqmHP5jt+qqrNY2eB+O1n3FUDftvsWT7jdtVrRY3CCZiGe3K8 A4WNFuGywv6YgnSjp3gkRLGNT2bhdMiVnpZ6tPSRX71fvkRoyEtYetGSXc69oJ1O1mWz KZNpeejY8S04w/0+Biv+H5A7Zb8g5E/3r8QLYAtAdy+fJFIPdJKL3md+xbL3oUEKqTZx /4olLVxViCwqQAaoUx8z7sEV7+rlEHas4BS4I6u0JIigVObca1ahPMhG3dFM4vj2Miz6 v6jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=U34C/mPeW5UK2Mv4i4ByrlB+nNMXfpv1ezo8hJzGZxo93bI0rDXVLPjuGfW7Du9eMW RevhXLSazQa2q7HIzVyX8bMjJJ2e3MJh5RY/4PX2ZOpXgfDiYgq7S2qURK0xfQSeK1cA FVGfAN69X3QKNuTMC2QrAGIJu9xCpDq6Wh8324leN0lCThv4E7PwRI6rHexPt4d1KvgJ sDDr6diDPBLAxK15NSEluALPGpRp6SNan/vlikrtGVTtrorIwPbHeivRHAHag9oTpUB+ Q89tk8uemdTaHKa8k9ILpmsvJDooWL+SM/OX9alGVzsCgQR2UGmjrwNszjrBOkLisJfC ZF4A== X-Gm-Message-State: ACrzQf3SlWIs8lLzVY2MCqC/fcwguHWHwi48KrqPL06R0o0VoWxHJyFI mck3Jp1mtHgw0qMoNaBNJC0= X-Google-Smtp-Source: AMsMyM50Il1duVwG4WCRXyqqx6zo9JX2k0qIMVQGpTqxyyUEKMma/iNuAz7sS7Uhi64hLkOOMPexZA== X-Received: by 2002:a17:90b:2248:b0:210:10dc:a314 with SMTP id hk8-20020a17090b224800b0021010dca314mr42536562pjb.15.1667405470077; Wed, 02 Nov 2022 09:11:10 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:09 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 02/23] filemap: Added filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:10 -0700 Message-Id: <20221102161031.5820-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405471; a=rsa-sha256; cv=none; b=Pt6qk8KbPBflVltbJ05LQok2LGJf1pA9+BUIJq3mkvlPYT5AeH0FIgaJSTeLG0GqlxdLx0 QqcrLRKBmGBWmyLRoaVBREcqBTKrj3u0CF3GyvcyzYl1ptFN89ScLaLRG01Asx1y8t12Y/ lCZilrdkbI9K3PwgTz6UTbSYyh6M7Gs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n1wMZVPJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.54 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=1667405471; 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=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=tryOxA3tLOin9sPAeV1ZplVEtSM/GDoUUUNyy2BdABt7VXr/+IxT/ykEO5ueSu4C4kfYfr YLMOKpRs9kvxmzE2a5eyFRA9+9qSdCuRI2ZIwwCTNXbuhyWgKOOrAnxep6dQEc7wIT/MXZ Pa8zQZXK+viCOVyXlENydJq5FGE/LS4= X-Stat-Signature: 7up5zp1khgp1sec6ksedfrh7gsefwcmq X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2C5B0A000A X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n1wMZVPJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1667405470-737966 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) Reviewed-by: Matthew Wilcow (Oracle) --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 74d87e37a142..28275eecb949 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -740,6 +740,8 @@ unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, pgoff_t end, xa_mark_t tag, unsigned int nr_pages, struct page **pages); diff --git a/mm/filemap.c b/mm/filemap.c index 08341616ae7a..9be22672ce1a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2262,6 +2262,60 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, } EXPORT_SYMBOL(filemap_get_folios_contig); +/** + * filemap_get_folios_tag - Get a batch of folios matching @tag + * @mapping: The address_space to search + * @start: The starting page index + * @end: The final page index (inclusive) + * @tag: The tag index + * @fbatch: The batch to fill + * + * Same as filemap_get_folios(), but only returning folios tagged with @tag. + * + * Return: The number of folios found. + * Also update @start to index the next folio for traversal. + */ +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch) +{ + XA_STATE(xas, &mapping->i_pages, *start); + struct folio *folio; + + rcu_read_lock(); + while ((folio = find_get_entry(&xas, end, tag)) != NULL) { + /* + * Shadow entries should never be tagged, but this iteration + * is lockless so there is a window for page reclaim to evict + * a page we saw tagged. Skip over it. + */ + if (xa_is_value(folio)) + continue; + if (!folio_batch_add(fbatch, folio)) { + unsigned long nr = folio_nr_pages(folio); + + if (folio_test_hugetlb(folio)) + nr = 1; + *start = folio->index + nr; + goto out; + } + } + /* + * We come here when there is no page beyond @end. We take care to not + * overflow the index @start as it confuses some of the callers. This + * breaks the iteration when there is a page at index -1 but that is + * already broke anyway. + */ + if (end == (pgoff_t)-1) + *start = (pgoff_t)-1; + else + *start = end + 1; +out: + rcu_read_unlock(); + + return folio_batch_count(fbatch); +} +EXPORT_SYMBOL(filemap_get_folios_tag); + /** * find_get_pages_range_tag - Find and return head pages matching @tag. * @mapping: the address_space to search From patchwork Wed Nov 2 16:10:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028382 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 1BEEFC4167B for ; Wed, 2 Nov 2022 16:11:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FF4F8E0006; Wed, 2 Nov 2022 12:11:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EC418E0001; Wed, 2 Nov 2022 12:11:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62C0B8E0006; Wed, 2 Nov 2022 12:11:13 -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 526A98E0001 for ; Wed, 2 Nov 2022 12:11:13 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 29641161210 for ; Wed, 2 Nov 2022 16:11:13 +0000 (UTC) X-FDA: 80088991626.12.F322B11 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf02.hostedemail.com (Postfix) with ESMTP id B51038000B for ; Wed, 2 Nov 2022 16:11:12 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id m6so16862249pfb.0 for ; Wed, 02 Nov 2022 09:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=WlFYPEeV3wf0VfK6pqbhv5Egc4h8KVjel140fCaMDBK3FcDDdSMrAwC2RRkCV1yrTw g5UfIoUTA56HrpjtwUHlbxxIl2+2XVj36Necvjw2qtsGVhSk3MpYNUz5lqUeXoe9rcG+ rSIhTCQW2xVo9vVWdW8xlqvFvN174oq7e9hBFs8SL0eQTkE9h9BtGOiyq5hrX0X03ARZ +PjKQOimzK0w0ph8uxMDYryUYErs4i2YihTAv+8viAcID4R9rEgIXHWoL0tVB1NY/fCF Zz7LVoKY7ZVpgl83UNZSArBIZLGwCRqsreKwNZaIOWeZgiKqm4whhefGhGSMZzVBzGt+ R1hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=5okoWBC63asZlMATTdkyEbvp+IT54jvReSkan9BFdCMLVogpU2dYtnWM5tGCNuV7dJ wF4h5iESvCSgLoECGcIgl8ijYQOS6a3NNJJOx2PsYoTmgRYwBpR1Z57dQtjBEZLJfq5F 3iRTxpVFDhueqI+zuM7TCZK/5ry242/gPu3ZGrTX/sHQAqKHCBunoi7CKDj+8FOCNQ0/ Zv5kRj59E9Jg5QIaGmwiQApqYHkKmcCzRzf53dsvXkaYvVR13qRdz/epno5O9Ca9m+Kb gCcbxiuhnJEUeVKcdY9fPDxE3PPsyIMj4/5hAwyCrNoba+Ugn3RUb6zsav8cfIkB/gF4 0c5w== X-Gm-Message-State: ACrzQf0EcJRV3UsDeNG3RVeMQi93eJLPVr6U105N9Z7CaJhPirmE23g3 DIB/DgKb/5ayVYuTmIHbs2c= X-Google-Smtp-Source: AMsMyM5yBalx5fts0VaFDBkG5q5k8ESrx5LXqDS/i9qmdUWGQhi6efEZneqsEsoguUnslwFAGGHvTA== X-Received: by 2002:a05:6a00:1a10:b0:56d:5266:56aa with SMTP id g16-20020a056a001a1000b0056d526656aamr19077451pfv.61.1667405471611; Wed, 02 Nov 2022 09:11:11 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:11 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 03/23] filemap: Convert __filemap_fdatawait_range() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:11 -0700 Message-Id: <20221102161031.5820-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405472; a=rsa-sha256; cv=none; b=s+Fr0PZKTW8CFTUaE6epZOgBG3La/bT+FLZsLT4YyOD1phf43mNDaMLTbm/bwBfCLYprvX SXi1znLE8QwZpmYQRHpes9mOU3KlJbc6LrAPgfc3TCeTRsYANZB96mYAWdaYaAh7weS90V INX30oC3WYkWd75WMUWmL1Kmra+sePI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WlFYPEeV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.181 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=1667405472; 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=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=a8snqfGZwzWpkPzBhrLamKI3yAUf+dipDQ9VaUxWcZMus8P1SlGbe7zeAmMBmpb/mt64go Tx74Zf8tNW5wpv2ObjoyhPuly9c/LWwR6BB6Jcvl7pDo6MtWE0P3gyZF5nd/G7DwWCdLbP iIGnjK5yAXJBGrzOKFZJ27N1qk0gxRI= X-Stat-Signature: kz3ok8x8jeme8mh5batsr3p67xdtejbe X-Rspamd-Queue-Id: B51038000B Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WlFYPEeV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1667405472-327347 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(). This change removes 2 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- mm/filemap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 9be22672ce1a..cc4be51eae5b 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 Wed Nov 2 16:10:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028383 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 DE16FC43217 for ; Wed, 2 Nov 2022 16:11:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E5C48E0007; Wed, 2 Nov 2022 12:11:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3943B8E0001; Wed, 2 Nov 2022 12:11:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20E428E0007; Wed, 2 Nov 2022 12:11:15 -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 1292D8E0001 for ; Wed, 2 Nov 2022 12:11:15 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D65B3A11F1 for ; Wed, 2 Nov 2022 16:11:14 +0000 (UTC) X-FDA: 80088991668.21.FEB8614 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf22.hostedemail.com (Postfix) with ESMTP id 52A96C000F for ; Wed, 2 Nov 2022 16:11:14 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id c2so17007219plz.11 for ; Wed, 02 Nov 2022 09:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=Gia/2xQtP1i9ycPtinKOiQgjpYF1J9ACaFpAh075vwzsAAhLNjNjwXPx2+vTDRXHUZ bZE7LvXvcDHVHatbKpXZr47x9Hs9Q1h4xbF6TvxceMrMsSveweURXYIlV+R88gCZYv6h OGEJsEMDJZXdIqsZtg4BoAUnUIyyXd4KPqoF9+M3lG4fab9IdnhxaNtEY8oPI7ibVacD ytnjCKB0xNJmaRpuLXjDt8ASUH4+yIxaxOUP0/7p0CNQH+PRkBqmasgPL+jnoVzH3Fpb kUPkQn8no5XnSuKHBdcn1wPdHmAGeK2tyKCUjMCDEJu+yG2BBKFd+VDxMe7qKyNYVM+a EXOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=b07Bz5F0zVw1btNJvnx3v8Do9ZPW7R7T2L4JktQWLR0Xfb7WFWTdaaIMNjo05Wni2P 0BtSoJuUzTO/tymzX5wc0VSme6wy4nHr7pVbFMm31jsEqaVoye0i4bx5dYFdXh2zoPQd 2VOFlj4enQ1DtdbQxdQSoQccPyY9r6BNvSAEtlTFwvtNxmSWDGkh9jpdHErQv2K9goFV +SiXm6rcp+heBguoM+TDeZW+kC1FOY52FTwpwNL0dsby+viqARLp6clf0qNzkNSrBlk8 Rcp315SJ9qyUsUhaWm4IL8JAZUnEo7f4e8ivKkm4ehjw9CVQgh1HHZFxn49kxFSFArU3 cQ0A== X-Gm-Message-State: ACrzQf21qDAb5da9Duzleix48sUm0fvWNsYJI3Nc2SAJtfs3waTSYwU2 /gRP6ws0INgg/FeVy2rbd2k= X-Google-Smtp-Source: AMsMyM4X+/f3jD8XaEJ/tjjSk3Zq6RyoQeAhchq0GUaByf6a7jG0+un2QlQf44Fu6bHaytqq3rYlyA== X-Received: by 2002:a17:903:2cb:b0:171:4f0d:beb6 with SMTP id s11-20020a17090302cb00b001714f0dbeb6mr25037165plk.53.1667405473165; Wed, 02 Nov 2022 09:11:13 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:12 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 04/23] page-writeback: Convert write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:12 -0700 Message-Id: <20221102161031.5820-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405474; a=rsa-sha256; cv=none; b=PazUB1KtO5StZG3RLucyg9gBV5cBOFDjYkChiMKp3fIvyEw7EnuIAORoBaFrqWu6E8Cfzg XbCjN1VIWWTe0tDZFYTBVHUsM1W7+OPkpCffTYmk7lE31t4EdEsGrv6InKRMrsKb+1i5bD tMAKJ7UEUl22wo0NGpmAm8H2H2ScB1Q= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Gia/2xQt"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 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=1667405474; 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=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=EnK1sivYPmKxGm+gTTwXmPvMamfbeBrXe327HeIfZyIOdWgbJr+EB/mkOD95aQol8qGIah drDI6rFwH2UNW2SlM2GdfcH83ZlTFkLfi8l5QEiQNlY+/EnRhbT0vioWqK5fmYoMyY1D07 jykAJDlF+YtmtPhBqF4tNzeXO6Qw4uc= X-Stat-Signature: t9g4iiymbuq93oippk3gutampwj6gpab X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 52A96C000F X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Gia/2xQt"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1667405474-746056 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(). This change removes 8 calls to compound_head(), and the function now supports large folios. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- mm/page-writeback.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e9d8d857ecc..aeec8b196232 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2286,15 +2286,15 @@ int write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int error; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* prev offset */ end = -1; @@ -2314,17 +2314,18 @@ int write_cache_pages(struct address_space *mapping, while (!done && (index <= end)) { int i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index; + done_index = folio->index; - lock_page(page); + folio_lock(folio); /* * Page truncated or invalidated. We can freely skip it @@ -2334,30 +2335,30 @@ int write_cache_pages(struct address_space *mapping, * even if there is now a new, dirty page at the same * pagecache address. */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - wait_on_page_writeback(page); + folio_wait_writeback(folio); else goto continue_unlock; } - BUG_ON(PageWriteback(page)); - if (!clear_page_dirty_for_io(page)) + BUG_ON(folio_test_writeback(folio)); + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = (*writepage)(page, wbc, data); + error = writepage(&folio->page, wbc, data); if (unlikely(error)) { /* * Handle errors according to the type of @@ -2372,11 +2373,12 @@ int write_cache_pages(struct address_space *mapping, * the first error. */ if (error == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); error = 0; } else if (wbc->sync_mode != WB_SYNC_ALL) { ret = error; - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -2396,7 +2398,7 @@ int write_cache_pages(struct address_space *mapping, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Wed Nov 2 16:10:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028384 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 C7512C4332F for ; Wed, 2 Nov 2022 16:11:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D80318E0008; Wed, 2 Nov 2022 12:11:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D32F18E0001; Wed, 2 Nov 2022 12:11:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8F818E0008; Wed, 2 Nov 2022 12:11:16 -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 9FC0D8E0001 for ; Wed, 2 Nov 2022 12:11:16 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 77B871211C2 for ; Wed, 2 Nov 2022 16:11:16 +0000 (UTC) X-FDA: 80088991752.24.AAF270B Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf23.hostedemail.com (Postfix) with ESMTP id BE8B4140006 for ; Wed, 2 Nov 2022 16:11:15 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id l2so17005217pld.13 for ; Wed, 02 Nov 2022 09:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=gQ3c0LdSBzFsK6fT4uYZJxPUXMrdMM/2nflC2cV7sYS3HEKaVakZmlZZyIEpcZLCrr azMVA0h0qEnPsHGSm1uNBpGCmLBetfTgOoRBq7HJ7OpluFtNBV6TRmNaUymXPL4NO53x lV7bQH7FkCayUIB1xUHmwk2uJBSE9FRd8QFcDG1446fcGXg2qwAnFc+AlpWK5Cx2HX0S xCa3bp5qXy30W+m2Z/irS788yBZSG1RzSQVRi5h5sfXIGSOxdwStdFlzSx8gSm/dxXkf XwSTeb0E/a4dtZhGU0fFLS5W23VlDnYw64tpG9lcaa2Y8R4gzUGbc7YB4qrZvGdJ5FAN uKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=5Cm4qPqyMVdM8ZIc9gTa3dX1M4X5kUPp9eQQxdKkK0si079xLaknCBq1kc0D6wZtWt 4bgCukQtOXTjSc1iiT9f/tBpiFIxqyDBTW2iUZznWO4s/kUFQuS6MZo//eXfIxMQ5K44 LniLZRQNzBMHvHkTpBTYs2r1RZzPNmmpWwpA1v1kr9rZaPuv/x1jh3pZ6uWWuHcTiaOT zRp1aY+Zdc5s3qdoQ2tiBngHtogh5xJcifuVP0XcqHC4QvViC54BW1UA+v3HDqxU4EU2 2MsZJXK9qVssXEzLUcw/9I+rpP1sE1HpCihHtpk70sF6hMANQaivBCpHQ5NYP8BrYrB5 39IQ== X-Gm-Message-State: ACrzQf22JLNhCVbId5VdGV5+8SZqNJyosruTuQhEWEjAtvdW25Ux9yJv v1ieRaNgyPeHItDcMzjdLU8= X-Google-Smtp-Source: AMsMyM62c1dJQNqvaiM9Z7MzVYpUXu+EHw3vgmAHkN7xcwjpflKXn1VXNFCc0lHQDCMSG8tUJstqLA== X-Received: by 2002:a17:90b:1bd2:b0:213:2d7:3162 with SMTP id oa18-20020a17090b1bd200b0021302d73162mr25853750pjb.91.1667405474612; Wed, 02 Nov 2022 09:11:14 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:14 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Howells Subject: [PATCH v4 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:13 -0700 Message-Id: <20221102161031.5820-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405475; a=rsa-sha256; cv=none; b=nttuvD1Dr1cBOjVOgkeCFywSh1M42bktf0Zg8CTNjUcw2MT3FOIshpAA/VmHx2XZ02onHK dpQN5MMBcJSXW66B1UPj3fas45OKv+j4O6DjjzPke4GQ/mbgORtPb3xHJFsPCQQd7e+5dC FwqbhH//DAnPZwvOzr3Qbxn04OIylKk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gQ3c0LdS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 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=1667405475; 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=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=Lm9K8x6Xb3BqX/IXrbY2kuuhxcFwb7ZxwZX5IzxX588mF6HBzQogzjUv1uXkpLnPPvjI3V FBNGcg0izJqr8YAF+NO/iWNqj5EGUYqFj0wVMEv6qDDOPXuEB+7/QLs7waCGbPmVFMxKcq ePofDQF1nxaCtkvQjB4MKe7EHVn5dBM= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BE8B4140006 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gQ3c0LdS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: nyhjmarzrdxey5q7x5aj5kuyrsicbkg3 X-HE-Tag: 1667405475-799843 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 Wed Nov 2 16:10:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028385 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 B8601C43219 for ; Wed, 2 Nov 2022 16:11:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BF798E0009; Wed, 2 Nov 2022 12:11:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 348858E0001; Wed, 2 Nov 2022 12:11:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E77E8E0009; Wed, 2 Nov 2022 12:11:18 -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 11AD98E0001 for ; Wed, 2 Nov 2022 12:11:18 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D5B56412AC for ; Wed, 2 Nov 2022 16:11:17 +0000 (UTC) X-FDA: 80088991794.06.1E855EE Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 3C0B6C000E for ; Wed, 2 Nov 2022 16:11:16 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 128so16664149pga.1 for ; Wed, 02 Nov 2022 09:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=G1xj7WAmIltNBsbLKuO9CkKEQ79pa0K47wkha3puJeaezV2/imAkDdcfm/KV23FIHU +KArDubzSRmx7FiH0l8qSZQuiZfGIGZFESde9F7GDr7BI0vnEKAz4OoG+/TLSnEP6lVV hEk3uS7L0RHCBIur0yh9N3EX0D7wiz8f/Tz1DOmo9UyRB6et4qwOzt9Nng+ZOsOpt5/H 9uNCUJ20VcSVqHMicFHHEq7ELqXYQFE7Mrb+NRFmYH88zfkz/DMkzuyMw0IDbt4InR+d u77NqmroP0vZczS44dmUtLli+wdv7QD3/rglQpmtqCu4rEb336yGk934JQ6ASFGIEHNx 5dKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=6f3xDEP5Q4N5F/5M01aULtE1axeAwAeBWnj46NpRce9i1LwrO1yCJSPxbLFPYOjcaL XX6pRidaWTI3Cp3Zvtydw1D6XL5PyV9ykQ7rkPYEUSOwqtSwihiPJ/Mdh5KuKd0JRi98 Vxae1WJUMbsJly8jhReEOs/WCSLHqqyn7EBpGtdcy49n6dwMZ4s5uGaj/tSTHdpXWuxs Srko29iygzRbl4c0RN5Qcd/AE1MTwiN3My0XnegwEu2dDhRlm1wSwAvWXHfZ9fw8VTky FfISimlGHMC3oC2zrhnVydps1w8ikl2mtcdTUay3uxO2SwV6YqcgK+YmtBRw4OAQfWcH ay2Q== X-Gm-Message-State: ACrzQf2KU2NAvVZmoULuoKd5joLQDYPfHIDU7rWtiCoL1/IcR/hEMBsC MIMPGcmUpdiOxnbq8LRsT7U= X-Google-Smtp-Source: AMsMyM6GJxhB3WK1RR+mjEzfRIolTwRsa2T5GOunC8tyj4bGy4RuSHbsovs3MGUIO1XlX8Eq6nDAFQ== X-Received: by 2002:a63:4753:0:b0:462:b3f0:a984 with SMTP id w19-20020a634753000000b00462b3f0a984mr21859153pgk.501.1667405476022; Wed, 02 Nov 2022 09:11:16 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:15 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Sterba Subject: [PATCH v4 06/23] btrfs: Convert btree_write_cache_pages() to use filemap_get_folio_tag() Date: Wed, 2 Nov 2022 09:10:14 -0700 Message-Id: <20221102161031.5820-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405477; a=rsa-sha256; cv=none; b=EOitMK1k8ddvlRDmDV8/0MTJmigoQGCuUsNbPg6atbxfn3AIctVhBaEJYgj1PbpPAkYgEX 6m3OPliSlpplewgXlD1B1vwZ48Izxuoj+OecyPciw6V5mtv9hBDhCP8N+mFWqWEqtst/Vr VGwvOthxeKc3Nq5MqK16N9xKLgAp52w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G1xj7WAm; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 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=1667405477; 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=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=JFgmRTnOz6/6cxhFKFhuBSsynJzZ2ZHyfziLGWfd+UPFoKX1OaKO0XP6IjqIyQOS8mI8fz e/ycq22a/EVe+C3fh4bs3yu8BBmsZSugsXZElVSa58QHBqTXwV2Th2is3sb2VDgG96vlwK 7IkJssD0T31ELtV2nRqJQ8qWyJ874q8= X-Stat-Signature: p88xijfn7gbx8k5emug8rwbt78h8ntdm X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3C0B6C000E X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G1xj7WAm; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-HE-Tag: 1667405476-985052 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 4dcf22e051ff..9ae75db4d55e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2960,14 +2960,14 @@ int btree_write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int nr_to_write_done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ int scanned = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -2990,14 +2990,15 @@ int btree_write_cache_pages(struct address_space *mapping, if (wbc->sync_mode == WB_SYNC_ALL) tag_pages_for_writeback(mapping, index, end); while (!done && !nr_to_write_done && (index <= end) && - (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag))) { + (nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch))) { unsigned i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - ret = submit_eb_page(page, wbc, &epd, &eb_context); + ret = submit_eb_page(&folio->page, wbc, &epd, + &eb_context); if (ret == 0) continue; if (ret < 0) { @@ -3012,7 +3013,7 @@ int btree_write_cache_pages(struct address_space *mapping, */ nr_to_write_done = wbc->nr_to_write <= 0; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } if (!scanned && !done) { From patchwork Wed Nov 2 16:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028386 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 9FDFEC4332F for ; Wed, 2 Nov 2022 16:11:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C48598E000A; Wed, 2 Nov 2022 12:11:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD43B8E0001; Wed, 2 Nov 2022 12:11:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4B238E000A; Wed, 2 Nov 2022 12:11:19 -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 957798E0001 for ; Wed, 2 Nov 2022 12:11:19 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2355316125E for ; Wed, 2 Nov 2022 16:11:19 +0000 (UTC) X-FDA: 80088991878.16.F10DEC2 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf21.hostedemail.com (Postfix) with ESMTP id 89CA01C0006 for ; Wed, 2 Nov 2022 16:11:18 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id b62so6262035pgc.0 for ; Wed, 02 Nov 2022 09:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=SeLQ4Qu5//oXLNdBKVpytDwCWDO3I4G0YA52j5Knaxs6ot8nHTPxSvbYLibh2we7yp QOIy/yHsS5HNor/MIiz1/wjrknFzailQqLyUUDbncxkYbsgZJU/KhMzRQwgIl+QybVYC Rqmh80nwtQvOLrWqsNMA1En6NleAdRBSdgoag/eIey7KzBlGjcP3tZEj27YIEQECQyBF FiPgSN2IEHbjhKQ2oUVo+PWzz8cWJh20VFpEboEHH28rkzkyFMeuKzSfjD9ZDJNc3sQY DZllsnJTeZr1MOe9IOgxs+YIxX7s6esYPo/OjncN4dhR0FUlfGbp9Fqklf0gZ4+OOwoZ 8BhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=deuHazps5fn3IvRdg0HnBe3P+k23Tt9xjz1qr8A3TslYWmmYJ05jSQzwZFgktK6/ax 39Y3A6XoWwE6E4EaOkFHrJDVUrIoNrmbsNDZIrhFeTojn2KAi4pfMrmtfVWZ1B0aySrY r4aWZpAx37uN64Mi4luSMX0lKCDkRN12EmBF5xWWxMHpDbWOl6THKF98BVItgOeRbw9I OUyrywXKSvcZL07SKOd4Sld4q7pFZoTesQCkoNy+0CUalAr8tKz9kWrz7BrlC2XeP1QA XxJiRQU/viO+YaChtNfW8mgcw4AFveWvek5PL4dogdTrAEu+ZcnrkJz5Qls1HaXHlIzS +4kw== X-Gm-Message-State: ACrzQf0tNLgZCLp7y/RA+FB0O93+Sz6I6jNiIAjnlGV2UT7MR42fcIFh sQGXmrFZlFKYHgyBwAuNfGY= X-Google-Smtp-Source: AMsMyM633/rTqiXcBf1XgON7eedWlU4pI5wcG5xiQZ6whfd6GaRXCeCpBFfVcxVkD9k3/TH52+6eXg== X-Received: by 2002:a05:6a00:a22:b0:54e:6a90:fbef with SMTP id p34-20020a056a000a2200b0054e6a90fbefmr25892086pfh.53.1667405477494; Wed, 02 Nov 2022 09:11:17 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:17 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Sterba Subject: [PATCH v4 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:15 -0700 Message-Id: <20221102161031.5820-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405478; a=rsa-sha256; cv=none; b=04JpX17qN0F+OtzyxXqrtg5whxpmorn1pT7TNjRwy6DqwT4wf68KKmL9QvhY34qlaiUM/c zYHWB7kkVxGMOXqNu5yQvZRC36BaGzkmmMHibSnGcig+KRs4mHVuZTSTAMs76n5m1a8KnC qNLBPfK+ijCL73We7SKmxOVHxl9cnbc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SeLQ4Qu5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 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=1667405478; 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=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=N1HAztp5qs9qv879Tt9B2ze689V+359hWT++vBGGlW++FCBIAnDr/7xdG1mzZqophCqZDy vX9rHvwWP4W5bnhOAAWd3GtifFDRl5cFBobVGlJviQgNYXQ2MGLhUtM0Ye1ev7V3t+y38d w0dpv2zYtk92Mu9ZWn8wPQevcKndbgU= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 89CA01C0006 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SeLQ4Qu5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: earnycjojrh8cedy7ktdn3fhu364ic84 X-HE-Tag: 1667405478-185083 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 9ae75db4d55e..983dde83ba93 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3088,8 +3088,8 @@ static int extent_write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int nr_to_write_done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -3109,7 +3109,7 @@ static int extent_write_cache_pages(struct address_space *mapping, if (!igrab(inode)) return 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -3147,14 +3147,14 @@ static int extent_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !nr_to_write_done && (index <= end) && - (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, - &index, end, tag))) { + (nr_folios = filemap_get_folios_tag(mapping, &index, + end, tag, &fbatch))) { unsigned i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index + 1; + done_index = folio->index + folio_nr_pages(folio); /* * At this point we hold neither the i_pages lock nor * the page lock: the page may be truncated or @@ -3162,29 +3162,29 @@ static int extent_write_cache_pages(struct address_space *mapping, * or even swizzled back from swapper_space to * tmpfs file mapping */ - if (!trylock_page(page)) { + if (!folio_trylock(folio)) { submit_write_bio(epd, 0); - lock_page(page); + folio_lock(folio); } - if (unlikely(page->mapping != mapping)) { - unlock_page(page); + if (unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } if (wbc->sync_mode != WB_SYNC_NONE) { - if (PageWriteback(page)) + if (folio_test_writeback(folio)) submit_write_bio(epd, 0); - wait_on_page_writeback(page); + folio_wait_writeback(folio); } - if (PageWriteback(page) || - !clear_page_dirty_for_io(page)) { - unlock_page(page); + if (folio_test_writeback(folio) || + !folio_clear_dirty_for_io(folio)) { + folio_unlock(folio); continue; } - ret = __extent_writepage(page, wbc, epd); + ret = __extent_writepage(&folio->page, wbc, epd); if (ret < 0) { done = 1; break; @@ -3197,7 +3197,7 @@ static int extent_write_cache_pages(struct address_space *mapping, */ nr_to_write_done = wbc->nr_to_write <= 0; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } if (!scanned && !done) { From patchwork Wed Nov 2 16:10: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: 13028388 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 6EA22C43219 for ; Wed, 2 Nov 2022 16:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E92558E000C; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1C898E0001; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6EF38E000C; Wed, 2 Nov 2022 12:11:22 -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 B172D8E0001 for ; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4DFD9A11F8 for ; Wed, 2 Nov 2022 16:11:22 +0000 (UTC) X-FDA: 80088992004.23.E699073 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf07.hostedemail.com (Postfix) with ESMTP id 3FC5F40007 for ; Wed, 2 Nov 2022 16:11:20 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so2563869pji.1 for ; Wed, 02 Nov 2022 09:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=g2BV7RNa287uRGJXaTiIIVA+hVR5jk23WAb5oSch87TqPTKliqdG6nz+TvKfJjQkWG wKwFiGSt2Rb1fl8eeNDFlkMtQOun4E0Gp7//G4HKGfUb3nk+G/4tSHVsMwQUdMvGOAs3 bX8lTwXqFogoudKAWmoKnMGrfcZTmnBWpzDYodcndNZUb6/dm0TMV023Fe43jCEkr7r5 Rk7e9/C8q6siu6DGaWKU8usxej+5hirj+dtoTubk2wobt1F6NAL1rswIeOZUZ4FLUvDE mSi2soPe8rx7EyvL4EOR7R78eiVnxuM8T8794ga/+RvsWTmIe4cpaJUb9HYaHpF6hnnU VRtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=i5JFYFo2pS0h94p0jKYvSipd9gWOmkI9ekdfJKrz5rV4hBU+xyhIrZWHGjQzmg9urG 0ZpQiPnyabk8Dxzw3I2kOBQLXQlrANAo1BaNPl4WfKcGbiposQkJRhnKPwigtAEpTUIa 5beu/3nF9qt6HG4Nh8KzcpNruPGQ2wFVb6FlCYl6oS75Ub0SU7+z0MXdHn2Jw8HBVRTz cqDicna1bck6ojdIOR7v7vuku793bKa9NPA9EXxPnYGpfRAtpTVGnMEwGdUhub4q0Ydn 46YH+TrQyYHBuE1nnB+cLfs4MR2T+9xFXdQHyhlzrv20znDc/aLHXvOSGTqdSEYzpNrm vQow== X-Gm-Message-State: ACrzQf1qElYbTy8xkSI03wZPad1mdnOI0CoL28jcBUZt7W2GX8nKVKhG 1h/IJZEhy3rVu8pWj39SNGQ= X-Google-Smtp-Source: AMsMyM4/FpZP+BuUM/6mJSvW0G+HXzSaXP7Fz99SRRGIB42z0mqALV8Hl9OVg/Nr0ICzLbiULCDfPA== X-Received: by 2002:a17:902:e80a:b0:187:3a52:d24e with SMTP id u10-20020a170902e80a00b001873a52d24emr8612509plg.171.1667405479107; Wed, 02 Nov 2022 09:11:19 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:18 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Jeff Layton Subject: [PATCH v4 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:16 -0700 Message-Id: <20221102161031.5820-9-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405480; a=rsa-sha256; cv=none; b=WtaDsMQkJBRW4Jcn/6Ddl+/Z140N5M63XAvKklSCGgHwC9/2Z6gkuVDfLro+PnlXwL2WF/ Yqn+cFkjmSm9iwL5+x4JmypgX+D0LXnSZQL0+dcVCbZQ7ImPyw9oXw4m275RvX8lGUJfwJ bX7BuZ6BRvOSCS56HspfxghviWt/e78= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=g2BV7RNa; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 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=1667405480; 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=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=nXt88LuiexNrnxrnMJWJmduADwp/MlyLudSIG9TERg3QSyzsNGxASxLyvGA3No6SIp43p7 kbh691WiQkYE+CZvQEz7Xkk/iAlAH78llb6S27iAw28JiIBNls5nisKzyGuXmAKlFPCEyP /1vXuqSq0a1s7vkYQaJBoBz+kdO+1oU= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3FC5F40007 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=g2BV7RNa; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: 3i3afy5dymjxbiwi6o34z8eidk3qqt5j X-HE-Tag: 1667405480-237419 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Also some minor renaming for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Jeff Layton --- fs/ceph/addr.c | 58 ++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index dcf701b05cc1..d2361d51db39 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -792,7 +792,7 @@ static int ceph_writepages_start(struct address_space *mapping, struct ceph_vino vino = ceph_vino(inode); pgoff_t index, start_index, end = -1; struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc; - struct pagevec pvec; + struct folio_batch fbatch; int rc = 0; unsigned int wsize = i_blocksize(inode); struct ceph_osd_request *req = NULL; @@ -821,7 +821,7 @@ static int ceph_writepages_start(struct address_space *mapping, if (fsc->mount_options->wsize < wsize) wsize = fsc->mount_options->wsize; - pagevec_init(&pvec); + folio_batch_init(&fbatch); start_index = wbc->range_cyclic ? mapping->writeback_index : 0; index = start_index; @@ -869,7 +869,7 @@ static int ceph_writepages_start(struct address_space *mapping, while (!done && index <= end) { int num_ops = 0, op_idx; - unsigned i, pvec_pages, max_pages, locked_pages = 0; + unsigned i, nr_folios, max_pages, locked_pages = 0; struct page **pages = NULL, **data_pages; struct page *page; pgoff_t strip_unit_end = 0; @@ -879,13 +879,13 @@ static int ceph_writepages_start(struct address_space *mapping, max_pages = wsize >> PAGE_SHIFT; get_more_pages: - pvec_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, - end, PAGECACHE_TAG_DIRTY); - dout("pagevec_lookup_range_tag got %d\n", pvec_pages); - if (!pvec_pages && !locked_pages) + nr_folios = filemap_get_folios_tag(mapping, &index, + end, PAGECACHE_TAG_DIRTY, &fbatch); + dout("pagevec_lookup_range_tag got %d\n", nr_folios); + if (!nr_folios && !locked_pages) break; - for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) { - page = pvec.pages[i]; + for (i = 0; i < nr_folios && locked_pages < max_pages; i++) { + page = &fbatch.folios[i]->page; dout("? %p idx %lu\n", page, page->index); if (locked_pages == 0) lock_page(page); /* first page */ @@ -995,7 +995,7 @@ static int ceph_writepages_start(struct address_space *mapping, len = 0; } - /* note position of first page in pvec */ + /* note position of first page in fbatch */ dout("%p will write page %p idx %lu\n", inode, page, page->index); @@ -1005,30 +1005,30 @@ static int ceph_writepages_start(struct address_space *mapping, fsc->write_congested = true; pages[locked_pages++] = page; - pvec.pages[i] = NULL; + fbatch.folios[i] = NULL; len += thp_size(page); } /* did we get anything? */ if (!locked_pages) - goto release_pvec_pages; + goto release_folios; if (i) { unsigned j, n = 0; - /* shift unused page to beginning of pvec */ - for (j = 0; j < pvec_pages; j++) { - if (!pvec.pages[j]) + /* shift unused page to beginning of fbatch */ + for (j = 0; j < nr_folios; j++) { + if (!fbatch.folios[j]) continue; if (n < j) - pvec.pages[n] = pvec.pages[j]; + fbatch.folios[n] = fbatch.folios[j]; n++; } - pvec.nr = n; + fbatch.nr = n; - if (pvec_pages && i == pvec_pages && + if (nr_folios && i == nr_folios && locked_pages < max_pages) { - dout("reached end pvec, trying for more\n"); - pagevec_release(&pvec); + dout("reached end fbatch, trying for more\n"); + folio_batch_release(&fbatch); goto get_more_pages; } } @@ -1164,10 +1164,10 @@ static int ceph_writepages_start(struct address_space *mapping, if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) done = true; -release_pvec_pages: - dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr, - pvec.nr ? pvec.pages[0] : NULL); - pagevec_release(&pvec); +release_folios: + dout("folio_batch release on %d folios (%p)\n", (int)fbatch.nr, + fbatch.nr ? fbatch.folios[0] : NULL); + folio_batch_release(&fbatch); } if (should_loop && !done) { @@ -1184,15 +1184,17 @@ static int ceph_writepages_start(struct address_space *mapping, unsigned i, nr; index = 0; while ((index <= end) && - (nr = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_WRITEBACK))) { + (nr = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_WRITEBACK, + &fbatch))) { for (i = 0; i < nr; i++) { - page = pvec.pages[i]; + page = &fbatch.folios[i]->page; if (page_snap_context(page) != snapc) continue; wait_on_page_writeback(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10: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: 13028387 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 703F6C433FE for ; Wed, 2 Nov 2022 16:11:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F1238E000B; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A28F8E0001; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5421A8E000B; Wed, 2 Nov 2022 12:11:22 -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 426308E0001 for ; Wed, 2 Nov 2022 12:11:22 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 166E041281 for ; Wed, 2 Nov 2022 16:11:22 +0000 (UTC) X-FDA: 80088992004.28.F384423 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf19.hostedemail.com (Postfix) with ESMTP id A4DEB1A0002 for ; Wed, 2 Nov 2022 16:11:21 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id o7so13499255pjj.1 for ; Wed, 02 Nov 2022 09:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=lgRGvbBXfYuj04wlBtpVHwy2yZsFFIANJMcP3krdA79wzBh4OScTeSvjJg4lQ3GiI3 qzedQnIEursJo8Y8wrorW1k3nnG6uW/QS2vrVmIvXFZlg1i7O4HcsiQIkHBi6LqK3Hws /m7aEjRd4+lrOka8mBd7EHcq45xsSi/7s+3yt3h27vjVFT6859E+s3o4irrHvYyKTxlH 6KXijZ6dtNgWx/FcJ0jqINoyCdNdAJm6gC+OU2m4I7MMiT2P+IkB6xQggwX5UN9tdlUH oIy8W/ni9KIfG99ZHM5kVgqC7Om0fcn8SoY/XV7phYth7Ym2e9szQ6efXI8rxGZIQ5Qz 7ZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=ssCN8MNvxGTkWbSVuqTE4O/uZzWwScrdiJzzeM9xA8Hk5RWOJXlM/mnnNTumJpBBYs uJZurv4ltToNc9a4HSoQVv1xDjhNVjCrcH+wbegPdrHfqYpS62LU8ktRtIXGzvm/mHAQ tp+sGVkr6AG9L3p0urGBNGVOrkVT3K/73R2pdB5WRI41H5sfd+jhgPLaG2g75hLgxuuS 0exxIwBMural0N2C72/yFtgnw4mslkduG8fp4YxvaUQCVMkKLyvgCu8k80HKM3BHdfXq RJCK4olGG84OZazCYdsTIoB0nlGiCGSF2zifFBBt2b0FOvNNkfddQwqwnZq6AxLYAuJy 8CAA== X-Gm-Message-State: ACrzQf1cHbmUYMrp4A7s1Y+unJylzaT2PP7dnSjJ6yNf3RZ1DpDQ4mkm XmQxOYbC04rJD+VudslmMIY= X-Google-Smtp-Source: AMsMyM6/72+MYEmeobRp0nXOdIc9AWtvXPDkE1Loq96kr4fO9Vd06b8/zC8fQ3xgY4YxH0AYxNXhtQ== X-Received: by 2002:a17:90a:3c8a:b0:213:8043:4b7f with SMTP id g10-20020a17090a3c8a00b0021380434b7fmr34554910pjc.99.1667405480651; Wed, 02 Nov 2022 09:11:20 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:20 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:17 -0700 Message-Id: <20221102161031.5820-10-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lgRGvbBX; spf=pass (imf19.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=1667405481; a=rsa-sha256; cv=none; b=3R1jFz2gIFZ9mvj6xUgP8UwkSLh2nZeVmsJGO3lJolGf0EtMmwuid7ejQf8YE8bPNd2+Cd KvbqQkmTJJG/kzijXfG/LIACGsRFd9Qg3QZc2H3VSIA4wgbfRaCijB+XTb9I1klYQ8yOFj JzL0OGKEU2/hxC84COvNfdAKzL78G2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405481; 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=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=p9TD1E2sDH9t7SdJVzLTIScJw54vrM+d0hudgu+fIF3byH2Amy5wvYNvr+OEY28wCLQ3Ze yRZudvkVsdt/iK1aXAH1sJagW7SeGYcuEYdAMlpmuSUedR4YykCK/t4ynaaa3gD4yQypyk cWdHuw6Y+VC+ePzaCFU2T3j7nRtQ0UE= X-Stat-Signature: 8gzhcea4da8b6yg1a5b63rpbcdedm1ga X-Rspamd-Queue-Id: A4DEB1A0002 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lgRGvbBX; spf=pass (imf19.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-Rspamd-Server: rspam01 X-HE-Tag: 1667405481-481682 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 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 | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f6ffee514c34..789fd0397cb4 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2520,14 +2520,40 @@ 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); + folio_ref_inc(folio); + if (++*found_pages == tofind) { + folio_batch_release(&fbatch); + goto out; + } + if (++idx < p) + goto add_more; + } + folio_batch_release(&fbatch); + goto again; +out: return wdata; } From patchwork Wed Nov 2 16:10: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: 13028389 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 706ADC433FE for ; Wed, 2 Nov 2022 16:11:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F5EE8E000D; Wed, 2 Nov 2022 12:11:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A60E8E0001; Wed, 2 Nov 2022 12:11:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36D0F8E000D; Wed, 2 Nov 2022 12:11:24 -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 1E4998E0001 for ; Wed, 2 Nov 2022 12:11:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CD55DABBA6 for ; Wed, 2 Nov 2022 16:11:23 +0000 (UTC) X-FDA: 80088992046.29.4768F24 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf07.hostedemail.com (Postfix) with ESMTP id 593B940005 for ; Wed, 2 Nov 2022 16:11:23 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id b11so16696979pjp.2 for ; Wed, 02 Nov 2022 09:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=d+XW6yxgXUY/dmps54gO3wO2PqfF8X3sDq8smHylpJ6nIBM4zBsMHva2qm9I5LqFL2 QACM5WP55FNzn65wJVW4x0X2RQo6CyKMexU8FSBY8AG10ZNAulWmhqckyER1nkGiMspT ZqA37FmcbK1m4i2HkqGatmsrYga/1zR/iZHsdk5MofsLoef0pUwG1V2srcoch/HfEeq8 Y3DYJ4onfq8FUAsSEfM43oAaV9FZAb2zY7fgjbbPkp3CBRQ6fMxNaaP0LxQZ0KDfWacU QL/qfoVB6iYB21fApOEhxGO+DRiBPMI/3V1bJAvtZeXMX4jXPeFp8lCyOrD8PwuvfwWa euXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=zePYTcuj7ZiJbx0NO9bgQxihS7kyVreM350WFePm8wEdpq/i3KpvX/I9ypp4mrMMAP D72gHB0J6B7OVNM1z1nDBHK3eql3hz74St+QGeHs22lNI5NkzRcSV+24cetFT0G+aLHD j9ngsAKNF7AdjtIhZ8sZjfKpOjham85dGhpP+IcxDJ05UYWeCNo/c3W1ry9hZXvFst5p ZV2nrDCwBNyTzVISHR3HY+ue+uUJLuHRKwYs+/2YRzJvfgILNH6wVsCcprTEKV0HzdrR FMstfOKh4pboRPY3W0luTEuEMRnN/uultTxsm9VsdUEAnKsfjPleWOpWWqdCxejYUmxE YBLg== X-Gm-Message-State: ACrzQf3BnoLzZqQuPRIQm8l0pHu4NXfVWKQOAzicfQnLX6eDmRnQifxL u5zPqqTOwQvPn8c/BbcWv3c= X-Google-Smtp-Source: AMsMyM5LdBAn65fV58RDcya59S76voFKa7sKrxzTyfWnCaf8L6hHgNBfM7eEbdAJBhgLDTjmpfKq+w== X-Received: by 2002:a17:902:f786:b0:180:6f9e:23b with SMTP id q6-20020a170902f78600b001806f9e023bmr26013889pln.37.1667405482254; Wed, 02 Nov 2022 09:11:22 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:21 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 10/23] ext4: Convert mpage_prepare_extent_to_map() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:18 -0700 Message-Id: <20221102161031.5820-11-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=d+XW6yxg; spf=pass (imf07.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=1667405483; a=rsa-sha256; cv=none; b=bcy1k6c2giWnXB9l8SM1kJW1mxkiBaiMELWMUQ1+JTAR8+ROZu7SY12l8OY9jHlxlz/+tU sd4bqo8gDVAdOnmdBcswafY+viyWNeBBEEcuEad5VDT9M16pXUGjemCMLeXIM4Mdpym0dJ iV9qvH914x+1mQHsDh1l5+pKamwGDFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405483; 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=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=arjCyG/PgNGk8Z5JzSg37LMZx+VXpKgHUsTRwOMhdTdY08/FJ+ErOE9qe1KrLGYc3tDqDn F6xHEIpqb180lkU3JjzWpnMyrz7+G5GpPavNeB6alafTko1SAlXw6JgRD6adyt7wYt2uPb RiR2EBe4gh94+7QEo3aWeK+6GL3VXnc= X-Stat-Signature: dk6uac41pwuaxtbjimh7737n3a43dbhy X-Rspamd-Queue-Id: 593B940005 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=d+XW6yxg; spf=pass (imf07.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-Rspamd-Server: rspam01 X-HE-Tag: 1667405483-448388 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. This change removes 10 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) --- fs/ext4/inode.c | 55 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2b5ef1b64249..69a0708c8e87 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2572,8 +2572,8 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode) static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) { struct address_space *mapping = mpd->inode->i_mapping; - struct pagevec pvec; - unsigned int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; long left = mpd->wbc->nr_to_write; pgoff_t index = mpd->first_page; pgoff_t end = mpd->last_page; @@ -2587,18 +2587,17 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY; - - pagevec_init(&pvec); + folio_batch_init(&fbatch); mpd->map.m_len = 0; mpd->next_page = index; while (index <= end) { - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; /* * Accumulated enough dirty pages? This doesn't apply @@ -2612,10 +2611,10 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) goto out; /* If we can't merge this page, we are done. */ - if (mpd->map.m_len > 0 && mpd->next_page != page->index) + if (mpd->map.m_len > 0 && mpd->next_page != folio->index) goto out; - lock_page(page); + folio_lock(folio); /* * If the page is no longer dirty, or its mapping no * longer corresponds to inode we are writing (which @@ -2623,16 +2622,16 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * page is already under writeback and we are not doing * a data integrity writeback, skip the page */ - if (!PageDirty(page) || - (PageWriteback(page) && + if (!folio_test_dirty(folio) || + (folio_test_writeback(folio) && (mpd->wbc->sync_mode == WB_SYNC_NONE)) || - unlikely(page->mapping != mapping)) { - unlock_page(page); + unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } - wait_on_page_writeback(page); - BUG_ON(PageWriteback(page)); + folio_wait_writeback(folio); + BUG_ON(folio_test_writeback(folio)); /* * Should never happen but for buggy code in @@ -2643,33 +2642,33 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz */ - if (!page_has_buffers(page)) { - ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index); - ClearPageDirty(page); - unlock_page(page); + if (!folio_buffers(folio)) { + ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", folio->index); + folio_clear_dirty(folio); + folio_unlock(folio); continue; } if (mpd->map.m_len == 0) - mpd->first_page = page->index; - mpd->next_page = page->index + 1; + mpd->first_page = folio->index; + mpd->next_page = folio->index + folio_nr_pages(folio); /* Add all dirty buffers to mpd */ - lblk = ((ext4_lblk_t)page->index) << + lblk = ((ext4_lblk_t)folio->index) << (PAGE_SHIFT - blkbits); - head = page_buffers(page); + head = folio_buffers(folio); err = mpage_process_page_bufs(mpd, head, head, lblk); if (err <= 0) goto out; err = 0; - left--; + left -= folio_nr_pages(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } mpd->scanned_until_end = 1; return 0; out: - pagevec_release(&pvec); + folio_batch_release(&fbatch); return err; } From patchwork Wed Nov 2 16:10: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: 13028390 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 58BC8C4167B for ; Wed, 2 Nov 2022 16:11:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCF7D8E000E; Wed, 2 Nov 2022 12:11:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D58C88E0001; Wed, 2 Nov 2022 12:11:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD1A68E000E; Wed, 2 Nov 2022 12:11:25 -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 B01C68E0001 for ; Wed, 2 Nov 2022 12:11:25 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 638CE1411AD for ; Wed, 2 Nov 2022 16:11:25 +0000 (UTC) X-FDA: 80088992130.11.2ADA966 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf15.hostedemail.com (Postfix) with ESMTP id D571CA0010 for ; Wed, 2 Nov 2022 16:11:24 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id p21so13159490plr.7 for ; Wed, 02 Nov 2022 09:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=PjiE5RDJ/IhYcpSdkRRACJ+kB6nieGFRihYA8FJAb8afHr//PYuLhKMedJ3nWsns4m WHHZ7o+B5kW/fEmrnRCfh1hKfAzAMYSiot+Tf/JsHplhr3y+1cIneR2pnNTm0Xu0G5/m eXGrJg3NPWw15lzsyaW8TPQOvC7voLcYyraNuBkGyVFr9BgKbhi8dJn3bhWNj61g20i8 HxoYlQ9BOFdM1wk4SoRmch2ZbfqT7e1EAK8uxuBGxdgsBMcHv1a+OFX50FwbjOGyxYjS TKmeuA3P8SPD1RJ2IqePqBoSh63VQ7QpSMtxtOjPS+T3FcYMe+l8npdlhpiu0xfcFt+6 AsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=mCo6k3FRqqYp5mSaUzCQapRibRGqwQIQaddNOTAFaP2AhuW2ImJqzbecmrGMwU/IkQ 69vasdKBuLUoLzoc7sw52npKqaNrqHfItLCnBvmorM1eJouzgVMSbo3P8nABxZ6p3YgK PCrvy88SsJL+lOIb8kE/R8H2eSJAPpAdjmmZrKrY/sHcx43vXdBxoj1DcgegkW/D8ycm 98fletMxBckVGf17X5p2Htf8OhHiVKx7Mq8TIlLF54aoWVZrNVfhMCMs+pO9l+BQC640 vlk7/6kaa4Q05AFXjvMDGEYRqGLMLsK7bhEUoReCFzDiQvG5UwSWHbHefrIzoFy49roC quEg== X-Gm-Message-State: ACrzQf2KClyBQI1k4O8oH7AjYlr3BUelLUni2YC8FrEgKzzuHU2aHRQr h3Qw7YZ3v3t6acVl/1eaLdM= X-Google-Smtp-Source: AMsMyM4/rTjRmXiZvaL0/UA6LSo69655Cl1G+qIeDGgAuEAjZIffsRS5BQYkpUCsHm79cx4g/ZmawQ== X-Received: by 2002:a17:90a:c918:b0:213:f5ea:5a60 with SMTP id v24-20020a17090ac91800b00213f5ea5a60mr14026872pjt.167.1667405483870; Wed, 02 Nov 2022 09:11:23 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:23 -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)" , Chao Yu Subject: [PATCH v4 11/23] f2fs: Convert f2fs_fsync_node_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:19 -0700 Message-Id: <20221102161031.5820-12-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PjiE5RDJ; spf=pass (imf15.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=1667405484; a=rsa-sha256; cv=none; b=Oxjvye3O7wTddCpS3MrHaIoPnaSJq7IaYLnMGRzmeNvfEr1E/B1qWgujKlc+XZVLEYjY37 IHcTUxNfPmYwJ20HEU4yt7SQ4GFqGLTuMblB9zdlZM2cAs9HmDOtqggr81v2GRne2iOtiE GqvW2XavtuCsR2tyov3xNHz4rpnd5VM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405484; 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=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=hdBDTydnxX8nYE4ALgpBjWa6sDU4GmF0bLCUoYWfoy9mZTQ7Zt55yl6MmnuekL73mp634N iyv63ZX8FweEp6qSpxpbeuEacrAdrxczSUOplBKG5LvVvVzW4gp6UATE0orhvE3fzYBlb4 L3LudTqUBgX7Z7tor6S+xMwjOnEVfYc= X-Stat-Signature: ykahdpfz6musst1dn84o8c9c7u6db853 X-Rspamd-Queue-Id: D571CA0010 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PjiE5RDJ; spf=pass (imf15.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-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1667405484-344361 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 983572f23896..e8b72336c096 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1728,12 +1728,12 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, unsigned int *seq_id) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int ret = 0; struct page *last_page = NULL; bool marked = false; nid_t ino = inode->i_ino; - int nr_pages; + int nr_folios; int nwritten = 0; if (atomic) { @@ -1742,20 +1742,21 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, return PTR_ERR_OR_ZERO(last_page); } retry: - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; bool submitted = false; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); ret = -EIO; goto out; } @@ -1821,7 +1822,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (ret || marked) From patchwork Wed Nov 2 16:10: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: 13028391 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 630F1C4167D for ; Wed, 2 Nov 2022 16:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFBBE8E000F; Wed, 2 Nov 2022 12:11:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA9AC8E0001; Wed, 2 Nov 2022 12:11:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FC948E000F; Wed, 2 Nov 2022 12:11:27 -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 92DAD8E0001 for ; Wed, 2 Nov 2022 12:11:27 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0942E803D9 for ; Wed, 2 Nov 2022 16:11:26 +0000 (UTC) X-FDA: 80088992214.12.6FF8E17 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf10.hostedemail.com (Postfix) with ESMTP id 97DDDC000B for ; Wed, 2 Nov 2022 16:11:26 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id k5so9131626pjo.5 for ; Wed, 02 Nov 2022 09:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=k4sYgtCTlKF9O5eHoAATqGO6DkAOPOB+/zWzhHb+mqOGd3qF7SgoAaKFi4lLVBsht/ 0a+GahnwrfYgcXzfcqjQMfMejC34Q/m1r6UggkT5/y5BwoQUSM/Inh109I0qpOE7qiZG VHSWVTYivN2nm8doYDi4kZvX7E+qWkNiB9Lrdy/A6STUjeM0jj3okY+N0rjKA3OWtndC 3sSdr2MVpV/CijFouW4jnz6JBqF5pTNSy78wF6PfERj1jNxM0lNUypdxS+HdwVF2Q1pa vL090y+jlC31ftR9kmfoc3DT021w95uO172fFY0HeNWUC0D/N2SjsKb0ohMgGDNyRVN7 /kgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=uNkwU0jYwBFxYVZdA8wT8gCGtCr5AxWEQejFGVCwGT6Nzz4qpl1DPpMSf9DQHCnKxd uj/6JhUttcDieQHd41H63uMp2VCjwKjEqY1FK84Rq6sMTIbB9uUHFSujYdjC0EeB8RUC 60cDpfJNUIGr8xRkOVm/6FLx692vehSbcyoC4s3eijCn80944eCXOvQB5GXYQwXyVGxX USAGR3y3itYYgiQ8NsQ4BRbfc15i53rFgWxZ0Mn3GjbWbFb8hSmEjGv4RjW3OVzLFLEN H+ZUD7dv4GIf53RBfKVsZhDryijB1LTzwqJrLbER4Ub0p6biQGnCSpSPRSMbpKYwgLEd lkog== X-Gm-Message-State: ACrzQf3uMdU+1ExtJlEyc7EIOdH19ZzjgSnufRyy8UsCkFX382XAGljj I0gXoUmbMx5Ru1d5rnW/hvE= X-Google-Smtp-Source: AMsMyM6I93ORgky9kjhOIjyftY7R2MXJmfWgHu6+CPmBQIrkt50BHJL8QLvp13RkJJ928M5oxPKLmA== X-Received: by 2002:a17:902:aa02:b0:186:9395:4e82 with SMTP id be2-20020a170902aa0200b0018693954e82mr26138278plb.5.1667405485482; Wed, 02 Nov 2022 09:11:25 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:25 -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)" , Chao Yu Subject: [PATCH v4 12/23] f2fs: Convert f2fs_flush_inline_data() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:20 -0700 Message-Id: <20221102161031.5820-13-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405486; 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=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=Q5eG8t7WYq902Gs3Gf5sshlG4+hxpHgMca5tomDs787ZJ7u8DhRE9z19SsnlBqQWT+hFhS aX0az+QnootO6iB0EA/eiFi1SerkRAttptBKHWeOHZktprfKHM2mrm76q7ivz1WP5oc1yV j/dKnvZKEvHY6YOX6rO6FPRBn6aldZk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=k4sYgtCT; spf=pass (imf10.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=1667405486; a=rsa-sha256; cv=none; b=2IwkwO2CDRWhegKg0uEJqxQjCSflZcjPkNH783QhCo23Hsz2B/5TFZomiFse9F1h6J0+lZ 9iIAbnRKTG+4stvDSpAchoPIcvhRR6dZcskoQ0dR7Gw7qAb9CUjoHBgPVFq6nc0VZeNPH6 wx+dt2zAmQwGl7v3podgLR58+Tmgf2I= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 97DDDC000B Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=k4sYgtCT; spf=pass (imf10.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-Stat-Signature: jfxtp67fubqib13m51y6p3xysnezbszh X-HE-Tag: 1667405486-770496 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 a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index e8b72336c096..a2f477cc48c7 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1887,17 +1887,18 @@ static bool flush_dirty_inode(struct page *page) void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) { pgoff_t index = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while ((nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; if (!IS_DNODE(page)) continue; @@ -1924,7 +1925,7 @@ void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) } unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10: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: 13028392 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 DB018C43219 for ; Wed, 2 Nov 2022 16:11:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B36CE8E0010; Wed, 2 Nov 2022 12:11:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABF758E0001; Wed, 2 Nov 2022 12:11:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9604E8E0010; Wed, 2 Nov 2022 12:11:28 -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 88E838E0001 for ; Wed, 2 Nov 2022 12:11:28 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6C6CF1A12B2 for ; Wed, 2 Nov 2022 16:11:28 +0000 (UTC) X-FDA: 80088992256.23.04CB274 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf17.hostedemail.com (Postfix) with ESMTP id E55EB40003 for ; Wed, 2 Nov 2022 16:11:27 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id y13so16825007pfp.7 for ; Wed, 02 Nov 2022 09:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=Poe9rdZUsWmbLff7Q1y+73uQ67NvWbfBoZzK/+dTQlX7qeN0LjEz/N/rBuja3dj4uQ V58XNqhmnAdXT/u5YYVAqWdQcM7IpZGzdPiS7WJ/SuI2UpsvG2jJQJ+QAjUVQ7//El8f fQS1kK8H9mty21sekVYBC67x1RIEUTD3q3zpcHhzYIZ7P8X4Gbv+aZIdKeXKk4H9Em2r Lzi0RsgndfKDM+rr+KiKcBf1rF+xpOLsZp5o+CS+hW7qQC1gAlW/yAz9e7GEL5+HY1Ox 2g2BT9bK3F21AxzoWn7zFoPz5OORdwHo0wvIqeyqfrg05E/t6JECV9fE6vKrC2SiNIWT MocA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=d5gtDxZ1rYlo5G4o5lwBfc65x7DNIetvxW9WsyEsyfxpzHyk0isBNsc8M9rfVcEfco 5vpXHBuaSaKYdkMMkR8J4IqIOlP15liBgEXUewV4eJ/bpnY6qHXgr9HNI8BCrsBdcXyN USYJTIwDCOrIm5GiU+RmnD0y+HKqyuvmjb0P7yWbhOm8/WMJBM7v4tsr7pkw4XqBp1Lv pRGQjt/DovUVpnpPKM+l/sVy01OZEHB5VMbBiVIDv6oGRVuLd5G87RsZlWpnHmoo5xlL tbGJEnaPMy7Bpi+ircwItMoE2ll5PdKDbX6163nfaMq3aFrDKpQHYTgVOW37ziXsb0ku aNhQ== X-Gm-Message-State: ACrzQf3sEtvplaoU35sjZgodKwrnAi5QEfN3Qvw4cObyEzMu4k6RUTXh puGNqXLbuPBVB7lso28+rRA= X-Google-Smtp-Source: AMsMyM7qibMFP4MyzDtzWi/W3QQD3NnJO1ppwFeeVWeabtq6FG43QL7qxxbpoZrNHocmvogYaW3TuQ== X-Received: by 2002:a05:6a00:b47:b0:56d:5266:464c with SMTP id p7-20020a056a000b4700b0056d5266464cmr18973688pfo.2.1667405486894; Wed, 02 Nov 2022 09:11:26 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:26 -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)" , Chao Yu Subject: [PATCH v4 13/23] f2fs: Convert f2fs_sync_node_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:21 -0700 Message-Id: <20221102161031.5820-14-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Poe9rdZU; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 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=1667405488; a=rsa-sha256; cv=none; b=HvSl/ZsdPY4MFG1oE42B5jlezz/PFaY/VVSnRNUOSmx4HcE6YwVMld5ZqoH2gay05WNjLl sHyTdiXGHbIi8uj0adguoCwnRCK99hYAWqkQoDBy33GroYR87xnlLHfqsvaQwlvzYvnSOE HetRrHyIggNySe4F3E4M90SNk4NZDaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405488; 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=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=XBoD9KR/g37YPSykNqkEk3lvX+cSakzwunqmvcpDzHIUtrVyYh+ANTCxIC1KWGQFqLYz2F Qcx3Hh12N/D6vIrcWmCnrmNNJk8TlbecC5rYdib2n8VH7iNYYmPsDUZhT7l0JUWpxK8HJS N9HusVufvHPD9n8mpFpvW0Nv+9DG/+8= X-Stat-Signature: qpe71b6eazcy1dyawqh8knjtxods3chu X-Rspamd-Queue-Id: E55EB40003 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Poe9rdZU; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1667405487-109148 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 a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index a2f477cc48c7..38f32b4d61dc 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1935,23 +1935,24 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, bool do_balance, enum iostat_type io_type) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int step = 0; int nwritten = 0; int ret = 0; - int nr_pages, done = 0; + int nr_folios, done = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); next_step: index = 0; - while (!done && (nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while (!done && (nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), + &index, (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; bool submitted = false; /* give a priority to WB_SYNC threads */ @@ -2026,7 +2027,7 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, if (--wbc->nr_to_write == 0) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (wbc->nr_to_write == 0) { From patchwork Wed Nov 2 16:10: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: 13028393 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 20B24C4321E for ; Wed, 2 Nov 2022 16:11:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4C008E0011; Wed, 2 Nov 2022 12:11:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FF358E0001; Wed, 2 Nov 2022 12:11:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 876218E0011; Wed, 2 Nov 2022 12:11:30 -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 7645B8E0001 for ; Wed, 2 Nov 2022 12:11:30 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F20F3ABBA5 for ; Wed, 2 Nov 2022 16:11:29 +0000 (UTC) X-FDA: 80088992340.03.47FA357 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf06.hostedemail.com (Postfix) with ESMTP id 47D47180008 for ; Wed, 2 Nov 2022 16:11:29 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id d24so17032864pls.4 for ; Wed, 02 Nov 2022 09:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=CYG7zu+QxCPI4y/4OmUZ6lM2JjETOTsDWuWnK+gbIF/bo8LwhHwDiP6kyfIdUbpyX8 ab9PRWMdaUYGWhq7nY4kTV0jG0utHkrf1BbP7dErm+mKDb0+A4TEESQqpmkxzFQT+DtN JlhOn+4S24OwuKkrVD0sPxqkQVGmn/run6/9tIdNBUZ2ufh5mY9r9vOsWyRs6O01IxY5 jAHXvzsRSva4MguNXkmSvlrLJxwuOGefxKTQZM10Odu+C4tDWapwK5UUuivkGmwCYD8n SKYn5/mySUl+qAWnJeuU5HhpDCL1/6/iG5Yn4Ie4dHT4sJqWWgvPDGxn9z17ZG2JtxX9 QX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=sWb1J8dyZs2KMSzSGQzSoL85Ys1NM5ju0U55Q1QtsD+lMHhjjwqe8Y2AQs0icteAVr FdoOA0xzDavRP7zhumqXfAhcYcQYIkhB6b1gN0ft85kO3LvPgg5EHFs0ZmE/V7lLwSoJ vy71H5Fv31sxrfCrxzAKyUIhj8r49tD98NyviGIomiR9guiElyDCUnIDqiOAPmj4cvKr KxbojnmGqR7vJ9mpCb7Bg/JdxJaYoS+/DY3qudxc+6AjXgz1Uu3nVxu10WsVOv6k+ZV+ I79LDhsAwieO8i2RAA0FpdMsco9TG/qNUXEu3AndXBS/OlwvPG9cI4U0cV7U4kSfcDTI ntHQ== X-Gm-Message-State: ACrzQf150wHArLnmRCr6OrzymUb7n5hr83hsjHXglML7cWx7FwCtvU+q 7UZayQxHITwqrhaKFsvLEno= X-Google-Smtp-Source: AMsMyM6I1DPKwfoeXRZ0zpmiqcREQFJWEBekvCZledBpKCLwMg84o0uKiw8tB7975QpgvsZe2RH2ig== X-Received: by 2002:a17:90a:b10b:b0:212:fbc3:e623 with SMTP id z11-20020a17090ab10b00b00212fbc3e623mr26873993pjq.5.1667405488224; Wed, 02 Nov 2022 09:11:28 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:27 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 14/23] f2fs: Convert f2fs_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:22 -0700 Message-Id: <20221102161031.5820-15-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CYG7zu+Q; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 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=1667405489; a=rsa-sha256; cv=none; b=xgEyqhcHsT6FIEE5K71vb8eaHZJuKp4In1LwnsZauq4TwD7Mi6q0Ax+bCfCYUfxaWPEJ55 CMtVYTcynBPjPzU9ABOaujTnH5FSTT0jksS+daTlbvFbLqqjzOEoRENWmU317JS0NlRMRn RZyzgfQDqXQCN/nNkKclsrt+5QiCNL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405489; 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=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=E9zNitivaXZaYykTIL9hDuhXkRmKt8ITAICFLX0lpqV/vKZ118WOwcKe8uasyf6aV0EX81 y3z6MsQaEC5OUBuPbxvOuCV2L4aOJUrdb8MLlHNbqMicUYRsTlPa6IobVqEFtXpH0oV4UB 7JkrNgNyVNixlmpCGPZ7REnzjz9aLt0= X-Stat-Signature: 7eqpqmohqmn3ht964uikksoen1xqecs1 X-Rspamd-Queue-Id: 47D47180008 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CYG7zu+Q; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1667405489-877038 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 a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 7 calls to compound_head(). Also modified f2fs_all_cluster_page_ready to take in a folio_batch instead of pagevec. This does NOT support large folios. The function currently only utilizes folios of size 1 so this shouldn't cause any issues right now. Signed-off-by: Vishal Moola (Oracle) --- fs/f2fs/compress.c | 13 +++++---- fs/f2fs/data.c | 69 +++++++++++++++++++++++++--------------------- fs/f2fs/f2fs.h | 5 ++-- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d315c2de136f..7af6c923e0aa 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -842,10 +842,11 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index) return is_page_in_cluster(cc, index); } -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate) +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, + int index, int nr_folios, bool uptodate) { - unsigned long pgidx = pages[index]->index; + unsigned long pgidx = fbatch->folios[index]->index; int i = uptodate ? 0 : 1; /* @@ -855,13 +856,13 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, if (uptodate && (pgidx % cc->cluster_size)) return false; - if (nr_pages - index < cc->cluster_size) + if (nr_folios - index < cc->cluster_size) return false; for (; i < cc->cluster_size; i++) { - if (pages[index + i]->index != pgidx + i) + if (fbatch->folios[index + i]->index != pgidx + i) return false; - if (uptodate && !PageUptodate(pages[index + i])) + if (uptodate && !folio_test_uptodate(fbatch->folios[index + i])) return false; } diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a71e818cd67b..7511578b73c3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2938,7 +2938,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, { int ret = 0; int done = 0, retry = 0; - struct page *pages[F2FS_ONSTACK_PAGES]; + struct folio_batch fbatch; struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); struct bio *bio = NULL; sector_t last_block; @@ -2959,7 +2959,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, .private = NULL, }; #endif - int nr_pages; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -2969,6 +2969,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, int submitted = 0; int i; + folio_batch_init(&fbatch); + if (get_dirty_pages(mapping->host) <= SM_I(F2FS_M_SB(mapping))->min_hot_blocks) set_inode_flag(mapping->host, FI_HOT_DATA); @@ -2994,13 +2996,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !retry && (index <= end)) { - nr_pages = find_get_pages_range_tag(mapping, &index, end, - tag, F2FS_ONSTACK_PAGES, pages); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; bool need_readd; readd: need_readd = false; @@ -3017,7 +3019,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (!f2fs_cluster_can_merge_page(&cc, - page->index)) { + folio->index)) { ret = f2fs_write_multi_pages(&cc, &submitted, wbc, io_type); if (!ret) @@ -3026,27 +3028,28 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (unlikely(f2fs_cp_error(sbi))) - goto lock_page; + goto lock_folio; if (!f2fs_cluster_is_empty(&cc)) - goto lock_page; + goto lock_folio; if (f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, true)) - goto lock_page; + &fbatch, i, nr_folios, true)) + goto lock_folio; ret2 = f2fs_prepare_compress_overwrite( inode, &pagep, - page->index, &fsdata); + folio->index, &fsdata); if (ret2 < 0) { ret = ret2; done = 1; break; } else if (ret2 && (!f2fs_compress_write_end(inode, - fsdata, page->index, 1) || + fsdata, folio->index, 1) || !f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, false))) { + &fbatch, i, nr_folios, + false))) { retry = 1; break; } @@ -3059,46 +3062,47 @@ static int f2fs_write_cache_pages(struct address_space *mapping, break; } #ifdef CONFIG_F2FS_FS_COMPRESSION -lock_page: +lock_folio: #endif - done_index = page->index; + done_index = folio->index; retry_write: - lock_page(page); + folio_lock(folio); - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - f2fs_wait_on_page_writeback(page, + f2fs_wait_on_page_writeback( + &folio->page, DATA, true, true); else goto continue_unlock; } - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_compressed_file(inode)) { - get_page(page); - f2fs_compress_ctx_add_page(&cc, page); + folio_get(folio); + f2fs_compress_ctx_add_page(&cc, &folio->page); continue; } #endif - ret = f2fs_write_single_data_page(page, &submitted, - &bio, &last_block, wbc, io_type, - 0, true); + ret = f2fs_write_single_data_page(&folio->page, + &submitted, &bio, &last_block, + wbc, io_type, 0, true); if (ret == AOP_WRITEPAGE_ACTIVATE) - unlock_page(page); + folio_unlock(folio); #ifdef CONFIG_F2FS_FS_COMPRESSION result: #endif @@ -3122,7 +3126,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } goto next; } - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -3136,7 +3141,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, if (need_readd) goto readd; } - release_pages(pages, nr_pages); + folio_batch_release(&fbatch); cond_resched(); } #ifdef CONFIG_F2FS_FS_COMPRESSION diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..d7bfb88fa341 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4226,8 +4226,9 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, block_t blkaddr, bool in_task); bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate); +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, int index, int nr_folios, + bool uptodate); bool f2fs_sanity_check_cluster(struct dnode_of_data *dn); void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page); int f2fs_write_multi_pages(struct compress_ctx *cc, From patchwork Wed Nov 2 16:10: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: 13028394 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 C4A64C4332F for ; Wed, 2 Nov 2022 16:11:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62D4D8E0012; Wed, 2 Nov 2022 12:11:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DD888E0001; Wed, 2 Nov 2022 12:11:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F1A8E0012; Wed, 2 Nov 2022 12:11:31 -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 369F78E0001 for ; Wed, 2 Nov 2022 12:11:31 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 114EC80565 for ; Wed, 2 Nov 2022 16:11:31 +0000 (UTC) X-FDA: 80088992382.11.6BFE0BE Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf18.hostedemail.com (Postfix) with ESMTP id A42D21C000A for ; Wed, 2 Nov 2022 16:11:30 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id 78so16619433pgb.13 for ; Wed, 02 Nov 2022 09:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=O4nbwv9cmBtSK1CT58yVHNsSMZiY/FKUA/O6oX43Ac0n4IX7vDCV2QLGEuoLXlUkd6 eHvyReQOL/NVjRshopa6fHkLaexjtpSCxifCTQBr0YR9yB++gFXMjIc34iHceLJdJagf WrwXLuWuCgB23v0+FXg91vjEGb1kLv6sB3PxXdVEjMmof4a7ofgr/GbDbkATXjxgH/8d +4RfUgwVsqN79UT/+0gaRpPE8h5g92Y8O3mytfBiXv715U8K+NOc/77TCeiz+rmrrP3T lHzCxF89bepNGUmoT3nYJomOxqi6w38Xq/9CrZcXJ2HzWpJvvHbi3XeAXF5vgGVoLqbr TnEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=jXYx6KF6f3zI45478IjNHPU1O8iILaRvxfnfcRd+oRXVgLHyW2SqT3MJGlhRlXk5c9 y36MkIBPTGiEp2qJy8IpNwAwWP2D9W11wbx6DXjyXWPYc2jOujC1ye6vc7pAL+xnPTMs Kv3j3H+i3gb/U38C/Yeb4sQRI9B9/LOEJUNIgymoJjEyHz/BscDNxFxQHjPkfqsyLgqy eZ5+gxJQKVwaq8W4Ok5lyxDA459UkQdrscRM3ZWCHLua6trU3pboPX85NV4HoYn3aOFP sScPgQvbEN24EX18SeGEdmM695w8OmLLwA7eqoOVleBeJcxjs2yPM37ET1WK7NUySyOr R9BQ== X-Gm-Message-State: ACrzQf1gN/Lo4RMEhnx9zGiH60vO8+/HV9UNuUjh3MYs1f6TVUPTtbcH OnJl4biTPFXE0uDkju8a8qPu94TI2L1t7g== X-Google-Smtp-Source: AMsMyM4Mu8mWuuJ9LsgyTXKiaDYuEixqiDshaCcEnGHSJqDXPNt4rQCX6PHQQ4mtu+d6jEWOcHwjbw== X-Received: by 2002:a05:6a00:999:b0:56c:3d0d:96fe with SMTP id u25-20020a056a00099900b0056c3d0d96femr26077443pfg.12.1667405489645; Wed, 02 Nov 2022 09:11:29 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:29 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 15/23] f2fs: Convert last_fsync_dnode() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:23 -0700 Message-Id: <20221102161031.5820-16-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=O4nbwv9c; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.176 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=1667405490; a=rsa-sha256; cv=none; b=JtOYfvK31oRCd4t9BjzPHL8MCg9iTnHb9uInezEQf1qKYkIpoZriJrl/qJly9hnYu3zMly mfwQnu//u+GTDbbU2Gh2BXSvb/PM6m7aV7yQhh5uSEl+KOOWF/lnl2Gu0sdfc2+gExVIB1 nDfBIaHjO9xztQ1J/zV89/4SyyOeM2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405490; 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=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=AW/FGRAilb4kCSyPjzo0PdcRDC0Grgqer3Ie/AyLhSAtk9LeGk5QjN2ygThO02t5SGcUxf /m/wniwiCM5G9JaCx+NEqw6cgSW6YA5DAxeu13oEnla+nDMOONnUG8pZ4fKUHfblSeB8A6 8hk/v0AZMonIDFfeaZRbtxyhYe2lSLk= X-Stat-Signature: hreo96gqyy66j1ghdpu3ikyhz6qgn3qt X-Rspamd-Queue-Id: A42D21C000A Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=O4nbwv9c; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1667405490-261359 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 a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 38f32b4d61dc..3e1764960a96 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1515,23 +1515,24 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino) static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; struct page *last_page = NULL; - int nr_pages; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); return ERR_PTR(-EIO); } @@ -1562,7 +1563,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) last_page = page; unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } return last_page; From patchwork Wed Nov 2 16:10:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13028395 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 74D69C433FE for ; Wed, 2 Nov 2022 16:11:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24BF8E0013; Wed, 2 Nov 2022 12:11:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D55D8E0001; Wed, 2 Nov 2022 12:11:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84FA58E0013; Wed, 2 Nov 2022 12:11:32 -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 747158E0001 for ; Wed, 2 Nov 2022 12:11:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 202A5412AD for ; Wed, 2 Nov 2022 16:11:32 +0000 (UTC) X-FDA: 80088992424.26.EF8E260 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 9FF6D1A0004 for ; Wed, 2 Nov 2022 16:11:31 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id o7so13499736pjj.1 for ; Wed, 02 Nov 2022 09:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=PTvyn3BEaAs9RE30oauDngZDkx0CdMxC8DfQHIIIl4jF6IO3gFQO/Hyq/HeBqHT04f Z6twx314UNMcXHGrTZulZS0YtVydCDj24T8M8fgfqpffbv6vl6jpy6+GiLGtpaRUnwjt hC9HVmZD06nQprUNjNlM4T7UE9IHxY7Kko6W6wvGb0GZeNyCB67/gGzrNo2P9nhFi2Jx wgZ0J9jcHXMv4ieTAzz3i1oJACiGkx9zlPc4v370bEV7YTt8vmW2WrJHjufczTQd6zL/ 8uZHmRqae+I/FnHCriK61BXAV9r2auhv6iVffm9aBrKd0N0Nv8qSUlpZf9PtTZLD1gi1 UHFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=qtx7mEJkSMTSR6g1+zqWSTl72OCQNjVIxzYD6q+NrWEZiV9F6pleTQxBlmcQJMtp2P rpwMTpGKQUiXR7PdTE8oN0aw3yIOV7lTL0lzIcTR8xlO/kCC5L1EBfQ7ZGEb1UD5vOwk FSLhuUs1XtHFw1Ca0YI1zjO1y2Z9cmnmIOuBGWF11J/Cu4I4P259NLGeRPBral2q7QWU RGm/c7mYXUHhrFraOIra7DBXtrM/+IBP5PkIV3pNZXtz/hBgeYVIHlz0cp1DmxfE7ojr Sxw5InHkR0HmuY3uyI6429gUD7rpjqxzwdbMe58JozO16RV+YidIjbthQPlP3gF2mNbT UqzQ== X-Gm-Message-State: ACrzQf3Skq9i4YuB+zVZF7CNMuflE6LDh0xKoSzF50YifcOsi8WrGtqo E5Wv8YT0yw4CuRPHAKk6v0Q= X-Google-Smtp-Source: AMsMyM6E3M7H/LqnJ3bGbNTMErjnaAvxsHbatUXbeFFkBd9l8Rp2shudfLk7oahwg2ax0C1UN8mN2Q== X-Received: by 2002:a17:90b:2705:b0:20a:b4fa:f624 with SMTP id px5-20020a17090b270500b0020ab4faf624mr26339614pjb.124.1667405491123; Wed, 02 Nov 2022 09:11:31 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:30 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 16/23] f2fs: Convert f2fs_sync_meta_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:24 -0700 Message-Id: <20221102161031.5820-17-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PTvyn3BE; spf=pass (imf19.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=1667405491; a=rsa-sha256; cv=none; b=hpEV12kN+2sCeK7nx34pmaiX1cLdUqrohaFx+o09gMzg8z9Fz4CGIFqBr3QdZ9UDPEUr4s U0n2HC4/vRlBFG92N5mrCO6asZOP5QEQmDmJQ7+9dS4vDOVQ4evynJbjq3m+07jxSSGI11 YFzKZRo61iE70lt/p6cJwKy+rTvLNyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405491; 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=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=w8HeU+aJKnqdDZiGgQDAQWv/pWfq+QtsjQa/WBB1lWkXtMwlcEMPfnsTzdlGTAqRtZBS/U zfFFY6jP4Vz3wL5HyFx2dNEkQTZxtgQSN4Z5CNJIXo78zAeFkCwkORijb2fTJoRAtvLfIG PLXY7E7lyMrV1+Zn1br8sPrzf2PELs4= X-Stat-Signature: s76qqebf69yqkn5ji4y6th8ka5xqh37m X-Rspamd-Queue-Id: 9FF6D1A0004 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PTvyn3BE; spf=pass (imf19.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-Rspamd-Server: rspam01 X-HE-Tag: 1667405491-94227 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 removes 5 calls to compound_head(). Initially the function was checking if the previous page index is truly the previous page i.e. 1 index behind the current page. To convert to folios and maintain this check we need to make the check folio->index != prev + folio_nr_pages(previous folio) since we don't know how many pages are in a folio. At index i == 0 the check is guaranteed to succeed, so to workaround indexing bounds we can simply ignore the check for that specific index. This makes the initial assignment of prev trivial, so I removed that as well. Also modified a comment in commit_checkpoint for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/checkpoint.c | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 0c82dae082aa..82eb26f471c5 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -390,59 +390,62 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type, { struct address_space *mapping = META_MAPPING(sbi); pgoff_t index = 0, prev = ULONG_MAX; - struct pagevec pvec; + struct folio_batch fbatch; long nwritten = 0; - int nr_pages; + int nr_folios; struct writeback_control wbc = { .for_reclaim = 0, }; struct blk_plug plug; - pagevec_init(&pvec); + folio_batch_init(&fbatch); blk_start_plug(&plug); - while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - if (prev == ULONG_MAX) - prev = page->index - 1; - if (nr_to_write != LONG_MAX && page->index != prev + 1) { - pagevec_release(&pvec); + if (nr_to_write != LONG_MAX && i != 0 && + folio->index != prev + + folio_nr_pages(fbatch.folios[i-1])) { + folio_batch_release(&fbatch); goto stop; } - lock_page(page); + folio_lock(folio); - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - f2fs_wait_on_page_writeback(page, META, true, true); + f2fs_wait_on_page_writeback(&folio->page, META, + true, true); - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; - if (__f2fs_write_meta_page(page, &wbc, io_type)) { - unlock_page(page); + if (__f2fs_write_meta_page(&folio->page, &wbc, + io_type)) { + folio_unlock(folio); break; } - nwritten++; - prev = page->index; + nwritten += folio_nr_pages(folio); + prev = folio->index; if (unlikely(nwritten >= nr_to_write)) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } stop: @@ -1398,7 +1401,7 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi, }; /* - * pagevec_lookup_tag and lock_page again will take + * filemap_get_folios_tag and lock_page again will take * some extra time. Therefore, f2fs_update_meta_pages and * f2fs_sync_meta_pages are combined in this function. */ From patchwork Wed Nov 2 16:10: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: 13028396 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 CEBDBC43217 for ; Wed, 2 Nov 2022 16:11:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FF898E0014; Wed, 2 Nov 2022 12:11:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 987148E0001; Wed, 2 Nov 2022 12:11:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DA508E0014; Wed, 2 Nov 2022 12:11:34 -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 6DF718E0001 for ; Wed, 2 Nov 2022 12:11:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E471716096E for ; Wed, 2 Nov 2022 16:11:33 +0000 (UTC) X-FDA: 80088992466.06.2989EF0 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf17.hostedemail.com (Postfix) with ESMTP id 3157D40007 for ; Wed, 2 Nov 2022 16:11:33 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id y13so16825251pfp.7 for ; Wed, 02 Nov 2022 09:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=cTecwnbK8PfqHVHi0WLzmJq5zHb6BfWLvopq1hm1TOLxAWNlw5daE69Z/irCx8vo3O +j5BiGarvjiwsPmZP/06ta3WKfAa7bLlp5GSyrFN7qWmbz83Oc5hawPd1UTNg0s2PZAv O3vAIVJb5OmP+FFcYDPLT6ikM0eWsinoDywLeN4mz4rb82IRK0N2HYPUHSO0dnJmyy+s pVW+NRgOBM3n6NZLyoGBLNofHn6niNZ92OuAFdUincydrQODix9rTdWA8NhNp3XFimI6 wZb5v/V31zd8j5yUJ7OTOcZFH5KYs0zkoeZLLC19M5UH0KcOZhcY02srDFlin9WNSxWB UHFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=lhAGCGFlSdeACaxByHfCS6J3zpsJiDf0yH3N+QEBmcgb/7WRvSCJNOm6xaswRmowyU T8mSB5+aIkFm3Li6MWqn2iAMA9qk/d3TEmeTyYvzR15STUE/L00ND1YLy8H+TWKEKQpT bEWUj8979W7s5dphnYdE4dQK3vvxjGqEHbbE3c8KVTQXsKjbnUQBbfDrMxhob3vu53wK FbqQHJYAvIV0ajt63rdjpPqEN5xkCmoyfaZKwAhA4TiBEPzlArxGvBFXKmrQ9quQVlZ4 Bn4opo1gHfLnBWA0dgTGzlx+QN2TAFii8M85940YD4LmoNZ93xRsGmt3VDnYLgVmn6oj 4duA== X-Gm-Message-State: ACrzQf16WVe76NR+rg03LTmittPrfNSRftXl6Zj8SB+RgAHSZecBFsed LQNIuHazvcYhsHq1ym74RvQ= X-Google-Smtp-Source: AMsMyM7dmaeETcXRuUxALfqdb3vJ518zMMGhJ7Lmw+5x5c8fE8sr41MfCxYfsnf6k8YhoW5FsxqMnA== X-Received: by 2002:aa7:951d:0:b0:56b:9937:c749 with SMTP id b29-20020aa7951d000000b0056b9937c749mr26032693pfp.78.1667405492550; Wed, 02 Nov 2022 09:11:32 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:32 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 17/23] gfs2: Convert gfs2_write_cache_jdata() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:25 -0700 Message-Id: <20221102161031.5820-18-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=cTecwnbK; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 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=1667405493; a=rsa-sha256; cv=none; b=sv9UAJCgITyePQIa7pWO0/vcUJ5cHJq0583cv7LlbQi7456RsbcZlWWfC36ctxUWemW4bL 12a7Zs+M81/WyFMjY3R97J3dSXacHL0sndbd/nvbqHGBoL9KVm241mywbc+WgRbRvjrDgW jNgFpWpoYwe1L9yeDP8ztQbrd8OeMnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405493; 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=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=ZMcj00KY6W0dZ4LSSC6+JsMoih3MulNGkigqHsq0yyzSnLo0KD4MDt051o4OkO+H1NIxgu w4sNGZH/0upjAGTEdaY+NYLAm/EROe5AJcJwqEfT2L32ZROH7AFcAdCTmV7hCIQFADRiQg 4Fi2GzGILbvCcZieMbLTvBWxaBHzfUg= X-Stat-Signature: qf7eexp3sp595m6yzd79e9u5kyc4g44k X-Rspamd-Queue-Id: 3157D40007 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=cTecwnbK; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1667405493-443312 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(). This change removes 8 calls to compound_head(). 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 Wed Nov 2 16:10: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: 13028397 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 698EEC4332F for ; Wed, 2 Nov 2022 16:11:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E9DB8E0015; Wed, 2 Nov 2022 12:11:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19A508E0001; Wed, 2 Nov 2022 12:11:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 012718E0015; Wed, 2 Nov 2022 12:11:35 -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 E6CB58E0001 for ; Wed, 2 Nov 2022 12:11:35 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9D252809F6 for ; Wed, 2 Nov 2022 16:11:35 +0000 (UTC) X-FDA: 80088992550.08.41AF781 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf23.hostedemail.com (Postfix) with ESMTP id 3C95214000C for ; Wed, 2 Nov 2022 16:11:34 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so2314538pjl.3 for ; Wed, 02 Nov 2022 09:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=q3y86Mqj0DeZyISqm/NEreuCkcVJdcqf1I2PppLIxLtCQkHnGzMeBPNGgV0nSBjZzo fx/DTafrePXLwXBlWJcD2VH7Lg0Z1T54Sz66MqXxFSFX63QD/buYFZb6ZlrEHmgkrvOG 6wPPcdqdE3EZlG/p2W7Gyv6nIhwzWc745dpabg6QvsjYd3Xg4Tk5BqwdQJX7kCgd5AvR dfK69VeuJCj+LO3ABeT4hrA0BZJDXiABX+2axHpLqvGhX3vsUKYQ7PHDjkGX3xzT+y95 L/VuMNGLM9kCQA0VEnLWnHg1PrMv390+X0DAi/s+IP/duC+XZLqgE8qsknuv46zXcBvg WCSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=vO8CpqWtP+4gCguebR1b/aOcLxAg7zXMbaBYfMUL9RZdy0LDdes72my+mMbbsTUK+P Ti/eXkdARhKt6XI6Xt3+i7q3zWNRcecCxzQ0+cRRBq0Rd08XqokvTrBOhORuc2OZVB0U HogicjkcNnqPhaYQ475sLqX092f4Ul526yoWho8QUoIiav6YrnCmNN2gzauQ44qkc5I2 uU1gVdhgRI03gnlCJvd3chtV09qiWUoENJ0kKP/sO3yHlu0+YOGaMJS997xf/CPLYQEE ZeNk5wvc4v1QgfS/8Kf1bnAqqjd0Zl33z/hVDvp9NrYma9wf329eJAL8dAcX7u3wwkRO rAcQ== X-Gm-Message-State: ACrzQf0Y1Qe4I5zm+UMFBaNbeRsTbdFh9kGYTajTkopFvUV84gTuz3/E Q+r896AjynA4lLVoiSs+9C9nazIz8VQPjA== X-Google-Smtp-Source: AMsMyM5+yJKPsTCW+zHgZjbHbMaNzVKcqfalsqvaAr3+srXOWHJW6H/w5W+YIAenXiG0v4QRbNBUvg== X-Received: by 2002:a17:902:b18d:b0:186:9bb5:a92 with SMTP id s13-20020a170902b18d00b001869bb50a92mr25445634plr.11.1667405494098; Wed, 02 Nov 2022 09:11:34 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:33 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 18/23] nilfs2: Convert nilfs_lookup_dirty_data_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:26 -0700 Message-Id: <20221102161031.5820-19-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405495; 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=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=GTnNfznYT5uRqxUbaMKmTjMdavZxRdTwcgLGO5RoC7DKiJLUj4C3qKoyvAIpquKBVfdzAy xPoZ24WUTMObPEnYds1aO8t+FEYWbPVrT5zLhEBVblKg4u1q8kQGp1JfZXO0l4sJTaTddC Spx0mqfCEiBmj6LaYpQcF3P9qj65zko= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=q3y86Mqj; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.43 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=1667405495; a=rsa-sha256; cv=none; b=HIy2bz7ExhFEmqak+yJHU+v09TgAOr2VoD5FOQ0sgh8mR1QHg+g55PP2TdwFEic9Qwe6QO SfwZvpbKncs+X0KpcMkpaQ21ZF/zdJPzRUCE7MlMqhRsMnNb7WN4qgMdZ4gJPOInZzr1v4 XAASie1KMkRmEFlivchhOBPviKwwKmk= X-Stat-Signature: ugbiohkmyzni38f9b7j59rrk3er66z1s X-Rspamd-Queue-Id: 3C95214000C X-Rspamd-Server: rspam06 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=q3y86Mqj; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1667405494-898195 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 removes 4 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index b4cebad21b48..2183e1698f8e 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -680,7 +680,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, loff_t start, loff_t end) { struct address_space *mapping = inode->i_mapping; - struct pagevec pvec; + struct folio_batch fbatch; pgoff_t index = 0, last = ULONG_MAX; size_t ndirties = 0; int i; @@ -694,23 +694,26 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, index = start >> PAGE_SHIFT; last = end >> PAGE_SHIFT; } - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: if (unlikely(index > last) || - !pagevec_lookup_range_tag(&pvec, mapping, &index, last, - PAGECACHE_TAG_DIRTY)) + !filemap_get_folios_tag(mapping, &index, last, + PAGECACHE_TAG_DIRTY, &fbatch)) return ndirties; - for (i = 0; i < pagevec_count(&pvec); i++) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { struct buffer_head *bh, *head; - struct page *page = pvec.pages[i]; + struct folio *folio = fbatch.folios[i]; - lock_page(page); - if (!page_has_buffers(page)) - create_empty_buffers(page, i_blocksize(inode), 0); - unlock_page(page); + folio_lock(folio); + head = folio_buffers(folio); + if (!head) { + create_empty_buffers(&folio->page, i_blocksize(inode), 0); + head = folio_buffers(folio); + } + folio_unlock(folio); - bh = head = page_buffers(page); + bh = head; do { if (!buffer_dirty(bh) || buffer_async_write(bh)) continue; @@ -718,13 +721,13 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, list_add_tail(&bh->b_assoc_buffers, listp); ndirties++; if (unlikely(ndirties >= nlimit)) { - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); return ndirties; } } while (bh = bh->b_this_page, bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); goto repeat; } From patchwork Wed Nov 2 16:10: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: 13028398 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 F4093C4332F for ; Wed, 2 Nov 2022 16:11:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 654628E0016; Wed, 2 Nov 2022 12:11:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6044E8E0001; Wed, 2 Nov 2022 12:11:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CCCC8E0016; Wed, 2 Nov 2022 12:11:37 -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 3CB008E0001 for ; Wed, 2 Nov 2022 12:11:37 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 15541A112E for ; Wed, 2 Nov 2022 16:11:37 +0000 (UTC) X-FDA: 80088992634.18.27CF955 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf30.hostedemail.com (Postfix) with ESMTP id 9A86480006 for ; Wed, 2 Nov 2022 16:11:36 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id p21so13160046plr.7 for ; Wed, 02 Nov 2022 09:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=LzbfvJ+o7+PPEWAo4w8AKJBmrzmPbRkBu3ORC/K7IBEBc4H7+EY6jlr3kPMKdC+kLo AmeRyK5Dh8JnM5M6037m8XCwwaveHP3T1zWfXQL5PNN2l8Ar7mvAlRUfGrHxX9l4CAlx lo3QVGXXrSxrr9dWf3dkPnZsG+uP9YkyrIkUspxdhnyIO5H9xO3I2khrWtyjrsb3beRJ 4OTNnGP/tYO4gLRsXwP7dLPwn1T8Eyszj0QvmzUxq1RtDQ9iIk0vaxsCgNdXJmRDiqCT sM3lyaFW63RiGf2IUhiE4Hi5Q9YJbodgMXUOnMDzbZK/PBDDWhOYiUrWWg5ys/RBXgc/ FTLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=fGqwfhA/yiy27RJ/9HkU0M8Rgze2LNmYHC2RMyd7XPoF/+J7v4K65YA0WttjncueLy LmW8V2TCF3amhej66OqZcVP9EMSDawWeYRphgRh+sBl7+aJCgk99c/Ng8yMSdjOt+Pon yW1TQOboHNwSQqvc+58oH+TIXS6aPde1ZYziGpgY8dFOTvKSnRaCthudC+l01VJgzMCc Co81yTjYvrkJM44YO3niQQmjvfZE3epaKsEH0SRAqGQCl+ZoH+Sz6CoCX/tvwB+MQAAV BYTr7FGFd4dmgTHiJlYDmJBeWylTkaA+E6DWba8rqDD6BDhBwWub2j7C6InFd3rjrRwn 0pnQ== X-Gm-Message-State: ACrzQf3HP9MfcW3CWNfrpqW/YSnDUm25iXPNYBCocqUeD4beDPefcHrM jhY9mMLT1FtISuQWSEVepMY= X-Google-Smtp-Source: AMsMyM5Gg7NNdqkkD0qRog5my+HvLc2ALPLnjteIt7psDYOA2pBRYr6Rk+9oY34/AO+uIwffHowUkA== X-Received: by 2002:a17:902:e5cb:b0:187:2d8c:a4fa with SMTP id u11-20020a170902e5cb00b001872d8ca4famr12910612plf.151.1667405495543; Wed, 02 Nov 2022 09:11:35 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11: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)" , Ryusuke Konishi Subject: [PATCH v4 19/23] nilfs2: Convert nilfs_lookup_dirty_node_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:27 -0700 Message-Id: <20221102161031.5820-20-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405496; 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=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=6cqFrf5Wj1o0m1q1XmP7YDpydL63w04BipsOYKWLkzuYrHeB1/xBR4hh+gc8W88org3mRE 6A3zmoPAioDxUi8kBx7m4AnSne//kmgFUfnyGniarvCuagjzEkCoNY4yyvkiAEcCqiKQ5y 2f57zgm+WhlZElCmUYC9253TLbc2nQI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LzbfvJ+o; spf=pass (imf30.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405496; a=rsa-sha256; cv=none; b=DanyQhfhVTe7g/ygQhmVFLD8Dd5ajzeNiMMRzBs2zHlqCSfDE+kAeAmVvV3U9s1Eq8/fXp kuvgxVUv3Hs8nLSoc6PnAAYpr589NrmdhC473p0JS9v4viTs7l0p6yGOTQWInAcNAKAa5c 4CpW7WUtAISSrUwskjf7MsHGoO7U3ZE= Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LzbfvJ+o; spf=pass (imf30.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-Stat-Signature: bwdp7zs1mhjfiqztfpwtatctp9ixig8b X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9A86480006 X-HE-Tag: 1667405496-225639 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, 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 removes 1 call to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2183e1698f8e..fe984def1b1c 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -737,20 +737,19 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, { struct nilfs_inode_info *ii = NILFS_I(inode); struct inode *btnc_inode = ii->i_assoc_inode; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; unsigned int i; pgoff_t index = 0; if (!btnc_inode) return; + folio_batch_init(&fbatch); - pagevec_init(&pvec); - - while (pagevec_lookup_tag(&pvec, btnc_inode->i_mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btnc_inode->i_mapping, &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh) && !buffer_async_write(bh)) { @@ -761,7 +760,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, bh = bh->b_this_page; } while (bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10: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: 13028399 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 3CB9FC433FE for ; Wed, 2 Nov 2022 16:11:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71BB48E0017; Wed, 2 Nov 2022 12:11:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DDEA8E0001; Wed, 2 Nov 2022 12:11:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 409048E0017; Wed, 2 Nov 2022 12:11:39 -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 33C178E0001 for ; Wed, 2 Nov 2022 12:11:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F2E19A112E for ; Wed, 2 Nov 2022 16:11:38 +0000 (UTC) X-FDA: 80088992676.27.BFAC712 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf21.hostedemail.com (Postfix) with ESMTP id 63BB71C000F for ; Wed, 2 Nov 2022 16:11:38 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id 128so16665009pga.1 for ; Wed, 02 Nov 2022 09:11: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 :message-id:reply-to; bh=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=Nq5OC7/qho070kMTIR5kedhLSGx2YL5E36Blk/zAHlfy6q42bFls2+pa4RnB8ovU/3 23vNW1b/D7YHHKye0/4R/8zfNZQd1v8t3O7W30JyYK8TO3BPzuGAvu8+idJLehY48eH0 nTA2LRYP2Tci8THpRdHRqOdUYAvC3WYgum+zsQ45VXVUlAh+7LDKxfOfFDNSJdU1TCHI 654ZghJ33xktcPdPAHAEZ2WzWNJD2pfRdlYSjV2sZ+0y6oREU3jCVDH6UyjTHuPXqQAv 7tNhrDH+d3WfX8ldYnIx9oUWEl/bGnai6OMrkkhyLBvzLpImZOGi3fus7xAeqEFsIJc3 iWsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=6OA2gL8bWfluWAzthzCPolbCp4xLQ27FEVI9I34UTy9lcDeTNaS/hRZkBQcXu0kJVt aJc3LkRGN3SplohjL0YAEWRuNjXLvkQAi2okFBgilu/vt/BYVJmff4CXOcNGyP/9sSeU bboHZExXTnNZoKYKa0hcVwyJEKdE3F4pTSdHctlJMCretY3mp9GNnxDtISLi7kCExGSg P+AZ+8z2gmADxTPZBvy8vK2cxHN+tJFI1k75IFQdT3j9vAT578gQdGu8z1my5RSNxFPy 87E19egAN++Y2cWBevgBiqTTjIZb4LdJ4vU16JYZvKxJe9/rvwdeVVaynuEwQFgtr+0g eiWQ== X-Gm-Message-State: ACrzQf1pTfg88t8DCYtZSyhqq9tTUWEgaiGa6r5RkCAghgO5frVw3KS8 fRaIYhzE9IGYWxJNHK/2fMM= X-Google-Smtp-Source: AMsMyM4j3s90xT9i6LYsmPHnxhpVulb37Bk4oCPHgBg+ghAVYd6bcWusmh3MWIob26u2e/+gVRMdDw== X-Received: by 2002:a63:85c8:0:b0:46e:c387:c85f with SMTP id u191-20020a6385c8000000b0046ec387c85fmr22258571pgd.105.1667405497249; Wed, 02 Nov 2022 09:11:37 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11: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)" , Ryusuke Konishi Subject: [PATCH v4 20/23] nilfs2: Convert nilfs_btree_lookup_dirty_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:28 -0700 Message-Id: <20221102161031.5820-21-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667405498; a=rsa-sha256; cv=none; b=V9jBOUSVGCbMODzrNh4RG0sCMWfd755bs6kSu/HR3iaI5X3KgkPDa3/2AufD7YquIkFYOL WjBvVF0FxXOmj8QketB6FWwYQ/mKL5x0LyGcjduC9DqpIj3yR/2lYswbmEsex6OL2m0PLs GPejsvL5F3kRyucDr9YVdbfF4ADhmcU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Nq5OC7/q"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.182 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=1667405498; 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=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=b3X3GtoDsHAsBkZhKid6ePyIpwodoc87Joo9E3GF9cEaFfv5sIaAQyGk6UqjO1Fop02/w9 8BijGUjKSzpmZ6nGf7hOBto/LaVzwMNaAepsh/JotPLUy9R0QtMUWKjmISeEiV3J7yOQNs lv5CU65IQUi9NuZ7eEfNpXNHYzqc7C8= X-Stat-Signature: z3bhf3se8gi59xp7rs5e3x6xfkbmj78e X-Rspamd-Queue-Id: 63BB71C000F Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Nq5OC7/q"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1667405498-223839 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 removes 1 call to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/btree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index b9d15c3df3cc..da6a19eede9a 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -2141,7 +2141,7 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, struct inode *btnc_inode = NILFS_BMAP_I(btree)->i_assoc_inode; struct address_space *btcache = btnc_inode->i_mapping; struct list_head lists[NILFS_BTREE_LEVEL_MAX]; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; pgoff_t index = 0; int level, i; @@ -2151,19 +2151,19 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, level++) INIT_LIST_HEAD(&lists[level]); - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, btcache, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btcache, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh)) nilfs_btree_add_dirty_buffer(btree, lists, bh); } while ((bh = bh->b_this_page) != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Wed Nov 2 16:10: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: 13028400 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 524D9C47089 for ; Wed, 2 Nov 2022 16:11:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56A098E0018; Wed, 2 Nov 2022 12:11:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51BF28E0001; Wed, 2 Nov 2022 12:11:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 393E48E0018; Wed, 2 Nov 2022 12:11:40 -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 2436A8E0001 for ; Wed, 2 Nov 2022 12:11:40 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 02BA41412E5 for ; Wed, 2 Nov 2022 16:11:39 +0000 (UTC) X-FDA: 80088992760.10.075BA9A Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf19.hostedemail.com (Postfix) with ESMTP id A19791A0006 for ; Wed, 2 Nov 2022 16:11:39 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id b29so16790299pfp.13 for ; Wed, 02 Nov 2022 09:11: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 :message-id:reply-to; bh=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=dnw/Y7Sdt/2yswLfUwe7rf3FamG1uOa+Cme4BQysz6O5GJju2KxY/lGLFeRfg3fP7F gusz6QFWiXK3Emskoxdh85TotdaoyDyH+kDkBo55CuXGPS5jgjmyY15TzCw5SJdm/Und Pe28CM7DVUvGUwOIf1oO6mSePnJQCQlGwEwLCjujRil72gYP2VXxqrNEY2Y2A8eBJRNr 6SM+6en5d7DcLIdBgiDQSKo8zoKuWtwZRdiHWF+RAAgco3tzrrCbCJhmkzEEdqzxvKka gMha+qpnNfslZTnKojM1KOTJPxVbBbMJ8BYFTrGc9EfVhhAKpe6HIgIjjlnkj/wKgw8P /0BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=OIg6erPW31SxJ166g4csOJHU50RrTutU7engyqTkTo6crCcmjzuV+x5mQzgN34kbXC COiYnrPtG7qVDuOuKmk4nfpEQ3QIcot5K+tIWqv/2pnI2a9CHTW9FtsVv7vP0m26PbmQ nIRouLfdn8XvAkHoBWyYFBGDmFYOEiVKoDLNRj6HWVlAMtgGaEGU09d0vlYhReWGpx2d S3HHm/MF5TTDVCCJS3jfFiM0bbFFY1jlffiA4UV9d6PtB0p3KaPA6kSOyVv0ziJT1Vvw VedlbWzyMdyxy/TPSGwBiWl5y9T+x8mnbe/Ri0npFMyrJ+HPqmw5HgVTSVjow89cMmDF biVQ== X-Gm-Message-State: ACrzQf1XqB/w4qabgqZf1LRkz5B2U9H9e76AeveZuVbNOL7UY9PN9sku 5Ey2h9JfP9VzWzHWn2vu3Vs= X-Google-Smtp-Source: AMsMyM6UoiV9uoEH+iCRydb6hjhh6rPd9RFTtERjNNbqJAcKqXBBASl63Y5A88aqGJTBtO3widxxqQ== X-Received: by 2002:a63:4949:0:b0:442:b733:2fae with SMTP id y9-20020a634949000000b00442b7332faemr21682136pgk.424.1667405498578; Wed, 02 Nov 2022 09:11:38 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11: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)" , Ryusuke Konishi Subject: [PATCH v4 21/23] nilfs2: Convert nilfs_copy_dirty_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:29 -0700 Message-Id: <20221102161031.5820-22-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405499; 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=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=wvJVlUA+WRvdSB14ZPac1oe9TGQdFGBjwX9mooREa6g1dLUBc+3ExgV/+meuk9YIXkHESN y+Hl62g4hlV7J+3t6zZXcveV9vudyCd5nZjJjPss4/boazF7MkmTqaWSeR59qmrFRARG/s lVT9eNIftmhOqNL9dV7s+l0z2VwlUZs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="dnw/Y7Sd"; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 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=1667405499; a=rsa-sha256; cv=none; b=JlOBlHwpmKe1ARmp+M+VNrEJyD1E+tiaoUtuvTnbDr7TZ8ybPe4DlWhG9aGmphEyf6m0TA iFK4T5hVAqchna+ZCaI2QxOdcyGD0SlSsLc2gWnZSCW/wYdzjqHowHGWj5OHh3Djx77OWM LzYUhqsol9d/+hREtPDSQBxjLcbo7oA= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A19791A0006 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="dnw/Y7Sd"; spf=pass (imf19.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: tzztq3h93co9nukxmnkzuscarb1jf57a X-HE-Tag: 1667405499-736298 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 removes 8 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 39b7eea2642a..d921542a9593 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -240,42 +240,43 @@ static void nilfs_copy_page(struct page *dst, struct page *src, int copy_dirty) int nilfs_copy_dirty_pages(struct address_space *dmap, struct address_space *smap) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; int err = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: - if (!pagevec_lookup_tag(&pvec, smap, &index, PAGECACHE_TAG_DIRTY)) + if (!filemap_get_folios_tag(smap, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) return 0; - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i], *dpage; + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i], *dfolio; - lock_page(page); - if (unlikely(!PageDirty(page))) - NILFS_PAGE_BUG(page, "inconsistent dirty state"); + folio_lock(folio); + if (unlikely(!folio_test_dirty(folio))) + NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); - dpage = grab_cache_page(dmap, page->index); - if (unlikely(!dpage)) { + dfolio = filemap_grab_folio(dmap, folio->index); + if (unlikely(!dfolio)) { /* No empty page is added to the page cache */ err = -ENOMEM; - unlock_page(page); + folio_unlock(folio); break; } - if (unlikely(!page_has_buffers(page))) - NILFS_PAGE_BUG(page, + if (unlikely(!folio_buffers(folio))) + NILFS_PAGE_BUG(&folio->page, "found empty page in dat page cache"); - nilfs_copy_page(dpage, page, 1); - __set_page_dirty_nobuffers(dpage); + nilfs_copy_page(&dfolio->page, &folio->page, 1); + filemap_dirty_folio(folio_mapping(dfolio), dfolio); - unlock_page(dpage); - put_page(dpage); - unlock_page(page); + folio_unlock(dfolio); + folio_put(dfolio); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (likely(!err)) From patchwork Wed Nov 2 16:10: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: 13028401 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 4CD5AC4708A for ; Wed, 2 Nov 2022 16:11:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE55C8E0019; Wed, 2 Nov 2022 12:11:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C207C8E0001; Wed, 2 Nov 2022 12:11:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A71FB8E0019; Wed, 2 Nov 2022 12:11:41 -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 9443C8E0001 for ; Wed, 2 Nov 2022 12:11:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5F8A3C0BD9 for ; Wed, 2 Nov 2022 16:11:41 +0000 (UTC) X-FDA: 80088992802.25.BD0DF99 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf23.hostedemail.com (Postfix) with ESMTP id EF643140008 for ; Wed, 2 Nov 2022 16:11:40 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso2315200pjc.2 for ; Wed, 02 Nov 2022 09:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=pqx1PJqOgEaKfUss0nxJak4n84vFKOvzq3ESyrjGFD8v8ROxU3CQGdvwQuKFd1I/w3 dCJ41EX/Bok9xslgktz6xXZZB5vDFu5BXOoWGO34UzLTcVVzuhGdIGcQHvEi5gNg3GSQ gscxO1Gb4psr/vsFsU/1JpKGLnKfg3l6eDymWIA8qk7+XrNzqRLz/vgtPRF4DPnVnb4T PW63xls+m/+8H/fBE5siUOyqDVnX5GNrTviD0Y18uYcvd2toxW0MDmiLDFy+p7D7UQQ6 IBU8URj3sypjIFT2nA8r21p6YwsgewrtbGGcm7sfWsWRu0sZsqZoVeMOaVhnUYxkI+jf hvVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=v7jvQ2PlMGulc+zpDa70DCjuizBQAINqeOqpi7TTCpGhZ9nTLZoTKz64vh6Ad7V24p vLsIYak+g11FwX7dpyDLjcDn7v7+ZkSXMWre+VuNl8KCTiaSR7qVCn12Ytw+Mq9I57dP zmLTWpfMAC+heMnLdxHT+4zZE3V4qzuHfb7lMxZ0yNgr7RCxlL6dHwauSy1tGaHZyz8U /lkoKe89NWxdN8OXSiXmmIzeLYZWezXlqRGhqsuNJ0en0YDXe7Io35yqabo5c7OP1XCN UxCVGWxLLQgQmPxvVI45F1I2LV3zbx2559Xe5Ip+STXXQajlW+ZsuVrqr6WMqTMVdzhO k+BA== X-Gm-Message-State: ACrzQf0Ew4fdIB1fAfEIeC+/6DTVGqgK0D6akyrR6gY4O7+v1+mF66d4 QI0cyHgu35cQ3zw3cJaH0ig= X-Google-Smtp-Source: AMsMyM4+pj++Af4Edyb2QUG36sMaov5LKSRDOi2tknVjdB5MdIhE6lghLouhN9qeqBdhiOHeQb9nDw== X-Received: by 2002:a17:90a:9a8f:b0:212:ea8d:dc34 with SMTP id e15-20020a17090a9a8f00b00212ea8ddc34mr45089840pjp.30.1667405500003; Wed, 02 Nov 2022 09:11:40 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11: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)" , Ryusuke Konishi Subject: [PATCH v4 22/23] nilfs2: Convert nilfs_clear_dirty_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:30 -0700 Message-Id: <20221102161031.5820-23-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405501; 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=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=OYUF7gNfUtQox4ugusxm5dL+pb8EIMxObXwfRku2r0TWX/JZLTPDQp91L5ptPvXM7FeO8q maVtwjQ7Lf3rP3U1L7h2J288Tp3I0cpfTgfQth3LnqJjvcyE8ma1dg8dkoLcBvg74rC3wm zb9uCfqxymTW7VNkWCIaIVqgr+EUrpU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pqx1PJqO; spf=pass (imf23.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=1667405501; a=rsa-sha256; cv=none; b=IX8QfskPXReh3lnRVLRQWjEszCKEJjf2mzCYi6KGnOU0I+LTBDhPg/kz/JPbTDXANhdepg tTifzw/77qM3PA4DsmfJ/xZRzvYsXdR6nOBs8Q//Sk1BSO5hsAevVzokxr4ngM+vaLvneJ Zon4CzjLaHKVET1Ph0h/wr2SjVsz3ls= X-Stat-Signature: 44q1zgb15aqqp76dth144dt3ww8s4t4n X-Rspamd-Queue-Id: EF643140008 X-Rspamd-Server: rspam06 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pqx1PJqO; spf=pass (imf23.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-HE-Tag: 1667405500-460600 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 removes 2 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index d921542a9593..41ccd43cd979 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -358,22 +358,22 @@ void nilfs_copy_back_pages(struct address_space *dmap, */ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + while (filemap_get_folios_tag(mapping, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i]; - lock_page(page); - nilfs_clear_dirty_page(page, silent); - unlock_page(page); + folio_lock(folio); + nilfs_clear_dirty_page(&folio->page, silent); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10: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: 13028402 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 70104C4332F for ; Wed, 2 Nov 2022 16:11:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BF3C8E001A; Wed, 2 Nov 2022 12:11:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3211D8E0001; Wed, 2 Nov 2022 12:11:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 171B78E001A; Wed, 2 Nov 2022 12:11:43 -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 091458E0001 for ; Wed, 2 Nov 2022 12:11:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 870111C3BE5 for ; Wed, 2 Nov 2022 16:11:42 +0000 (UTC) X-FDA: 80088992844.04.F3C88C7 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf17.hostedemail.com (Postfix) with ESMTP id 1670B4000F for ; Wed, 2 Nov 2022 16:11:41 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id y13so16825649pfp.7 for ; Wed, 02 Nov 2022 09:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=dfQedKuymKKcgaBkhG/S6LPnJ2O+4EvsNOgODJ6HJIVIONp85PHUPikgR1OK0QEXN5 yllHZOH3ybASQiMP5BnKEWHTPiCoHka0zDja58Ru610nhX2hFD55wJ8Gd376sGcaf689 bZrfvpTt8G5QxybOH/Q6elDPBkfe6Fc3kWWsMNhs/R9vrbLsrZ8uD+rka72YKKWWWGgG dWU5w6rAAJp2LD2+bLNGgBA0LMOcxmf8XyqrkCvTB+U0KRHPVRqOWqltLY33KWJ08EtL x4VuHCxKqbKwgsffO/TRtj8XIVLeukEUR03vIqJL55yVembQK6w940oX9YlEtm9O5Cyv atIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=Guo7f9iGpTPbTbGjEWsdNS9pvoqZtobNt+Q2Bd//m+hZBxw+gQwIw0RBOblquEa56r vOhfiHwP/afpAEz8HlU6Nb6UfLpZ8ev8qIxfSKansIRjUbt67u/KvCWpw3Ca2f/kyjMq P9vMvcalzaDEzF8sdHggSuyNZQChy7lPPEfgeZfzR1RFy9ss6m+f28eVHHnw2UMkC9Jh TxaQoCM+K1u7ZPR4U/xWnca66ostUXVdU+EBNvZZse2kruuUKeJEDTmuR76kiKFqri2S SGZXmjfEjhGKrGHIWrufXq7gKVay34VaJWSWXGNuFNNRs7TJvpBe+dwiCAITzNHRu+51 LD2Q== X-Gm-Message-State: ACrzQf0ZmeAhQVO/i3XPDCOmN5rcOkrtCtqAdfCN5O0RoUNliryqOPRo 0i72y7RuXyS2NdcpEZmfD1g= X-Google-Smtp-Source: AMsMyM6M+HYXpiH0U+VfyXFrJ89SEz8gDigaYYVWPndroJTYZEBXjmxNBwyGQzQ73aNi+YK3GqHHhQ== X-Received: by 2002:a63:5a1b:0:b0:461:9934:6f62 with SMTP id o27-20020a635a1b000000b0046199346f62mr22432948pgb.266.1667405501408; Wed, 02 Nov 2022 09:11:41 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11: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 v4 23/23] filemap: Remove find_get_pages_range_tag() Date: Wed, 2 Nov 2022 09:10:31 -0700 Message-Id: <20221102161031.5820-24-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dfQedKuy; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 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=1667405502; a=rsa-sha256; cv=none; b=VKpw3DMDbrH2e3GNvdV7j9CArDL52ilvXg7gUJm6S/g46Y8zvSQ5fEtnXqcpoPma1UZ8tK /cd5vAWusFnTEqchx1ANfpUnrTmMG0+v3OGANclL/jNGQZ4vJdePv8LGPyRinFLAF5cOpq O2sqc86C4KiT1RTHZlBulnBZRuNFBNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667405502; 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=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=Ncv6Wj9lTCVy6xbsfWHHtWZaP7cfb/7JIOm30Z6rkTjMHMAmyJzRgwKkKark6gA1TuK6k5 fB97CEsRi86aEKtSXRHybtGyhFUCdalK2Qpf4slUFfVNJ+MuC6TMOB1Q/I72jyWbOkPGhe cc94wNtvSi/+VSf82GMDtAOheiCkAz4= X-Stat-Signature: jggd6rxozhndyn3bzoeaeijyc5zj1hac X-Rspamd-Queue-Id: 1670B4000F Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dfQedKuy; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1667405501-229254 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 28275eecb949..c83dfcbc19b3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -742,16 +742,6 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages); -static inline unsigned find_get_pages_tag(struct address_space *mapping, - pgoff_t *index, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - return find_get_pages_range_tag(mapping, index, (pgoff_t)-1, tag, - nr_pages, pages); -} struct page *grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index); diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 215eb6c3bdc9..a520632297ac 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -26,14 +26,6 @@ struct pagevec { }; void __pagevec_release(struct pagevec *pvec); -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag); -static inline unsigned pagevec_lookup_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, xa_mark_t tag) -{ - return pagevec_lookup_range_tag(pvec, mapping, index, (pgoff_t)-1, tag); -} static inline void pagevec_init(struct pagevec *pvec) { diff --git a/mm/filemap.c b/mm/filemap.c index cc4be51eae5b..8ad45c2e22cd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2318,66 +2318,6 @@ unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, } EXPORT_SYMBOL(filemap_get_folios_tag); -/** - * find_get_pages_range_tag - Find and return head pages matching @tag. - * @mapping: the address_space to search - * @index: the starting page index - * @end: The final page index (inclusive) - * @tag: the tag index - * @nr_pages: the maximum number of pages - * @pages: where the resulting pages are placed - * - * Like find_get_pages_range(), except we only return head pages which are - * tagged with @tag. @index is updated to the index immediately after the - * last page we return, ready for the next iteration. - * - * Return: the number of pages which were found. - */ -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - XA_STATE(xas, &mapping->i_pages, *index); - struct folio *folio; - unsigned ret = 0; - - if (unlikely(!nr_pages)) - return 0; - - rcu_read_lock(); - while ((folio = find_get_entry(&xas, end, tag))) { - /* - * Shadow entries should never be tagged, but this iteration - * is lockless so there is a window for page reclaim to evict - * a page we saw tagged. Skip over it. - */ - if (xa_is_value(folio)) - continue; - - pages[ret] = &folio->page; - if (++ret == nr_pages) { - *index = folio->index + folio_nr_pages(folio); - goto out; - } - } - - /* - * We come here when we got to @end. We take care to not overflow the - * index @index as it confuses some of the callers. This breaks the - * iteration when there is a page at index -1 but that is already - * broken anyway. - */ - if (end == (pgoff_t)-1) - *index = (pgoff_t)-1; - else - *index = end + 1; -out: - rcu_read_unlock(); - - return ret; -} -EXPORT_SYMBOL(find_get_pages_range_tag); - /* * CD/DVDs are error prone. When a medium error occurs, the driver may fail * a _large_ part of the i/o request. Imagine the worst scenario: diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..89351b6dd149 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1098,16 +1098,6 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag) -{ - pvec->nr = find_get_pages_range_tag(mapping, index, end, tag, - PAGEVEC_SIZE, pvec->pages); - return pagevec_count(pvec); -} -EXPORT_SYMBOL(pagevec_lookup_range_tag); - /* * Perform any setup for the swap system */