From patchwork Wed Aug 24 00:40: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: 12952757 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 07ED2C32793 for ; Wed, 24 Aug 2022 00:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9222294000D; Tue, 23 Aug 2022 20:42:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D49C940007; Tue, 23 Aug 2022 20:42:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D67594000D; Tue, 23 Aug 2022 20:42:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5E06E940007 for ; Tue, 23 Aug 2022 20:42:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 370F140234 for ; Wed, 24 Aug 2022 00:42:51 +0000 (UTC) X-FDA: 79832636142.27.BB7AA3B Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf21.hostedemail.com (Postfix) with ESMTP id E03271C0045 for ; Wed, 24 Aug 2022 00:42:50 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id r14-20020a17090a4dce00b001faa76931beso18856159pjl.1 for ; Tue, 23 Aug 2022 17:42:50 -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; bh=fsvLs3dxCPx9IBTgjKC5zI8Z7kYUASZBA4STFA8FapY=; b=kl5Ynp+b/qJi5XM2umHjmSQHEkTDDMvpacUO50PPBjgNqBHxyxqWoXIUMOfjvHAJG3 oTGpKYfRiQ2GATQsJK0r9x42oinbboBr24fMIoK5LkiCM+8rQCJpZ15JcqKG+SzzWWdV /ChBcvv2dcdg92KmuvoNdeZZDzs+3KpmPPVT3ALy0+KQgopUCBZSq4NP89tr0HGtT/0V RP+TGfuY37/5Cg37DKL/cYxkJQRHYkhYRtyap5srPgo9RhQ9HCuU/cMf42hMXoTI+xfi de7hAL1mVJQ5y0T8dbCMF93yPMTrknbk2/3R/gCW32MNC4js0B9AaAgywAg9xISbM646 tVJw== 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; bh=fsvLs3dxCPx9IBTgjKC5zI8Z7kYUASZBA4STFA8FapY=; b=UTD+jYE2pa4p1K5SyVp4SlWhV2QH5EFqDLd+L5/M4uKJY1z6X40ZHcJK0vYp2MVKOM AtBi452kcAiFbyNvbgp4hGndgwLJbolyKPsn+MCvn2p32cHwkVYr/HQe5Hq/SfTwljr0 Z/EQrJXiAL/SvZ7u0/4jbrhq3mWzjROC4ocvnTOpnc/EWhhj6zeiT2greITwRJFSbYCM U8n/QYEIYtcK55UFUGlIrqj/IDWgS3lyU5FHldr2OuSjWdbGfe+kqbHk4x0Yestrutr+ 125Ucuvj4Ylrl03IWEkdo9dYqRvK0a0hWIEZ7ZG6aUlokU7o33xS6pVrsTeslQ4Z/eht TvAw== X-Gm-Message-State: ACgBeo13WHeeyMUGND9EgZvbrjXh2TSJQshz1xmTdmZ7m0/xs68Z1aLV UYlwUiJJJIiPlefvY8udhk8= X-Google-Smtp-Source: AA6agR6J0l1eMiiv5vUNrdo/CN/+qTnn+dZoNKOj6OE1MQuDAUmCobIy9S2J7jrjIr9Qw3KkvqcoFw== X-Received: by 2002:a17:90b:1d02:b0:1fb:77df:2c6 with SMTP id on2-20020a17090b1d0200b001fb77df02c6mr2391864pjb.102.1661301769897; Tue, 23 Aug 2022 17:42:49 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id ij5-20020a170902ab4500b0016dd667d511sm11063319plb.252.2022.08.23.17.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:49 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" , David Sterba Subject: [PATCH v3 4/7] btrfs: Convert process_page_range() to use filemap_get_folios_contig() Date: Tue, 23 Aug 2022 17:40:20 -0700 Message-Id: <20220824004023.77310-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220824004023.77310-1-vishal.moola@gmail.com> References: <20220824004023.77310-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kl5Ynp+b; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 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=1661301770; a=rsa-sha256; cv=none; b=P2P0Ataf6VEwVNd6sChdp+UUbudbGPujZpPEXsoxuA8LNZKHjULfABokU62zIn2HV7uNjq ifRhmtMJzJVx+1ZKoo655zdj0Pqndok8xIfUepkCazL8HR4o5NlKLHp9O1zFyBdaPvz0++ OZ4TF5rn/jhCC3esk0t2qk9mCcfFcIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301770; 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=fsvLs3dxCPx9IBTgjKC5zI8Z7kYUASZBA4STFA8FapY=; b=J16aSrmBLhr49iuO16vWI/3GlXGVIpee2oYadUqvfRDfi4XoayJHb1k5SI9JY/P9EViR7g KM3tYDg+dLSX3eelr71p9nzoHMMV1uoRJvWec2nbD9Waj6AuILl0KO8JVXPVEC2eW6yLz6 01zUimgufAybcB0BHlQ8FoLCqbbDHIA= Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kl5Ynp+b; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Queue-Id: E03271C0045 X-Rspamd-Server: rspam05 X-Stat-Signature: kc4caxnjyttia4hng73fn6b1qwzautrq X-HE-Tag: 1661301770-673569 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_contig(). Now also supports large folios. Since we may receive more than nr_pages pages, nr_pages may underflow. Since nr_pages > 0 is equivalent to index <= end_index, we replaced it with this check instead. Also minor comment renaming for consistency in subpage. Acked-by: David Sterba Signed-off-by: Vishal Moola (Oracle) --- fs/btrfs/subpage.c | 2 +- fs/btrfs/tests/extent-io-tests.c | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c index a105b291444f..6418c38c4b30 100644 --- a/fs/btrfs/subpage.c +++ b/fs/btrfs/subpage.c @@ -337,7 +337,7 @@ bool btrfs_subpage_end_and_test_writer(const struct btrfs_fs_info *fs_info, * * Even with 0 returned, the page still need extra check to make sure * it's really the correct page, as the caller is using - * find_get_pages_contig(), which can race with page invalidating. + * filemap_get_folios_contig(), which can race with page invalidating. */ int btrfs_page_start_writer_lock(const struct btrfs_fs_info *fs_info, struct page *page, u64 start, u32 len) diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c index a232b15b8021..26b0c99f54b8 100644 --- a/fs/btrfs/tests/extent-io-tests.c +++ b/fs/btrfs/tests/extent-io-tests.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -20,39 +21,40 @@ static noinline int process_page_range(struct inode *inode, u64 start, u64 end, unsigned long flags) { int ret; - struct page *pages[16]; + struct folio_batch fbatch; unsigned long index = start >> PAGE_SHIFT; unsigned long end_index = end >> PAGE_SHIFT; - unsigned long nr_pages = end_index - index + 1; int i; int count = 0; int loops = 0; - while (nr_pages > 0) { - ret = find_get_pages_contig(inode->i_mapping, index, - min_t(unsigned long, nr_pages, - ARRAY_SIZE(pages)), pages); + folio_batch_init(&fbatch); + + while (index <= end_index) { + ret = filemap_get_folios_contig(inode->i_mapping, &index, + end_index, &fbatch); for (i = 0; i < ret; i++) { + struct folio *folio = fbatch.folios[i]; + if (flags & PROCESS_TEST_LOCKED && - !PageLocked(pages[i])) + !folio_test_locked(folio)) count++; - if (flags & PROCESS_UNLOCK && PageLocked(pages[i])) - unlock_page(pages[i]); - put_page(pages[i]); + if (flags & PROCESS_UNLOCK && folio_test_locked(folio)) + folio_unlock(folio); if (flags & PROCESS_RELEASE) - put_page(pages[i]); + folio_put(folio); } - nr_pages -= ret; - index += ret; + folio_batch_release(&fbatch); cond_resched(); loops++; if (loops > 100000) { printk(KERN_ERR - "stuck in a loop, start %llu, end %llu, nr_pages %lu, ret %d\n", - start, end, nr_pages, ret); + "stuck in a loop, start %llu, end %llu, ret %d\n", + start, end, ret); break; } } + return count; }