From patchwork Wed Aug 24 00:40: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: 12952754 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 8E074C32796 for ; Wed, 24 Aug 2022 00:42:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0218C94000A; Tue, 23 Aug 2022 20:42:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEC5F940007; Tue, 23 Aug 2022 20:42:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C544794000A; Tue, 23 Aug 2022 20:42:46 -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 B56E1940007 for ; Tue, 23 Aug 2022 20:42:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 91A4340454 for ; Wed, 24 Aug 2022 00:42:46 +0000 (UTC) X-FDA: 79832635932.25.908C754 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf13.hostedemail.com (Postfix) with ESMTP id 54BF82000E for ; Wed, 24 Aug 2022 00:42:46 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id o14-20020a17090a0a0e00b001fabfd3369cso16325921pjo.5 for ; Tue, 23 Aug 2022 17:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=roEOVbMBkZrS+KI85Bv7B/f0yshSydvUYCZY5utraVI=; b=axPR5zKGK6FMyTGxARPaldWKtH7yyljRt5bxFzpIGOUfrlF7+RCqumQ03cEhG8/mnR J4GdPGyiCvAQhoAR+VLKPErEwrHdTZsicE16ytnlwYQC02ac3i+UQjMzYcmQIFuv/BMe VgRpVk3yOG3Oy3AZRKq/NOkyFrGYzVAkxud7JOndBVhOysDfedJ46ou8jKoLkOzWVSgf pDQocPOwVQwzE8SHXCGvsWfYeASm9P85dA+4okdbCpu5deeBfX1oQrUBBZ9l1pzTJVYb pkqTdg7JukSeYz9o6engmowTMsgXeGTtX4InuI3CCb2A33IllR6xneDSV1xMPMPp4lfn iWgg== 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=roEOVbMBkZrS+KI85Bv7B/f0yshSydvUYCZY5utraVI=; b=BmZmRsspT9+fSMAvz6ZPJ8I0eCMe43v+g6jrTpQUEe2IWBH7IBU8rdOOlDundxjRDZ xPowR0cLYkSE13Jak1ANM1Lvi3hFGxcQRen8ZI7GsIPQ4PXqLX0hXvLAjz8kLCZLsy9h ODip8dyvkrkqpse50OU7lFCaeAH7ZupW7KQhlcNW/2aa+jL1i2CtQAVN2P94RuIqNgDg wNUAjVnTKvALVfoJr6yeiZSFvGfwzy4suLImozzrLsfA7hmuZLYCrq7n1HpvQGlxHTv2 yg3Ty3waM4NDcGrWx9CkVnmvIkIbN8wVwQlh596apTYzh7x4m8Va7P7XCB3MhboDXvp2 bLyg== X-Gm-Message-State: ACgBeo0VBe/+g7Sew5lV53ykZXwS/Y7OqzOVNhXSu2OAaorz6B29ZjmS BFDcOJ12YeTWxMlDHMA9huk= X-Google-Smtp-Source: AA6agR53GLH+fjC3PReEZrs7TBuuMUHLeMC2vLgvCj3RocZFLBaunRfuKN28TqxGevtAj9YnYzCjZw== X-Received: by 2002:a17:90b:3a92:b0:1fb:23f3:f218 with SMTP id om18-20020a17090b3a9200b001fb23f3f218mr5576811pjb.102.1661301765225; Tue, 23 Aug 2022 17:42:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:44 -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)" Subject: [PATCH v3 1/7] filemap: Add filemap_get_folios_contig() Date: Tue, 23 Aug 2022 17:40:17 -0700 Message-Id: <20220824004023.77310-2-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; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=axPR5zKG; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661301766; a=rsa-sha256; cv=none; b=SMgh7Q3oF7VkyfuJ6HPTfGRxFg6mMvOoCJCdyFRNvAUR6o5QypDJkudI0+VQs/gAvGd6Ss LTo4N1P5IlrxNLA3Uc+HG2FQizcJgNWth0UWvkdHpfqxV+HQX7+33HnWeZp5RT3isAWhfx ecacj4vRoZJltxSacnS6aWE2/dfxTz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301766; 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=roEOVbMBkZrS+KI85Bv7B/f0yshSydvUYCZY5utraVI=; b=FoDXP6MO/yzUUZOb8T5QEIM/duhP3bxTQQQ1QqP9BSrwn144kpa36OXO/dCggIkKkAmAZJ zZQyWM8wNigH/EGPuw0C6YlsNSB/4IG+qJUhcey6bNDrzvUprLSiUjFKuoYNrJNOEefgqb xhR10mIiQqJiKV0nMYXnwrwce7SicIA= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=axPR5zKG; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 54BF82000E X-Stat-Signature: 7wmhfh11gu17xxd6n3z4rsw1436fge7x X-HE-Tag: 1661301766-166812 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 function is meant to replace find_get_pages_contig(). Unlike find_get_pages_contig(), filemap_get_folios_contig() no longer takes in a target number of pages to find - It returns up to 15 contiguous folios. To be more consistent with filemap_get_folios(), filemap_get_folios_contig() now also updates the start index passed in, and takes an end index. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 73 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index cc9adbaddb59..951936a2be1d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -720,6 +720,8 @@ static inline struct page *find_subpage(struct page *head, pgoff_t index) 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 find_get_pages_contig(struct address_space *mapping, pgoff_t start, unsigned int nr_pages, struct page **pages); unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, diff --git a/mm/filemap.c b/mm/filemap.c index 8ccb868c3d95..8167bcc96e37 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2196,6 +2196,79 @@ bool folio_more_pages(struct folio *folio, pgoff_t index, pgoff_t max) return index < folio->index + folio_nr_pages(folio) - 1; } +/** + * filemap_get_folios_contig - Get a batch of contiguous folios + * @mapping: The address_space to search + * @start: The starting page index + * @end: The final page index (inclusive) + * @fbatch: The batch to fill + * + * filemap_get_folios_contig() works exactly like filemap_get_folios(), + * except the returned folios are guaranteed to be contiguous. This may + * not return all contiguous folios if the batch gets filled up. + * + * Return: The number of folios found. + * Also update @start to be positioned for traversal of the next folio. + */ + +unsigned filemap_get_folios_contig(struct address_space *mapping, + pgoff_t *start, pgoff_t end, struct folio_batch *fbatch) +{ + XA_STATE(xas, &mapping->i_pages, *start); + unsigned long nr; + struct folio *folio; + + rcu_read_lock(); + + for (folio = xas_load(&xas); folio && xas.xa_index <= end; + folio = xas_next(&xas)) { + if (xas_retry(&xas, folio)) + continue; + /* + * If the entry has been swapped out, we can stop looking. + * No current caller is looking for DAX entries. + */ + if (xa_is_value(folio)) + goto update_start; + + if (!folio_try_get_rcu(folio)) + goto retry; + + if (unlikely(folio != xas_reload(&xas))) + goto put_folio; + + if (!folio_batch_add(fbatch, folio)) { + nr = folio_nr_pages(folio); + + if (folio_test_hugetlb(folio)) + nr = 1; + *start = folio->index + nr; + goto out; + } + continue; +put_folio: + folio_put(folio); + +retry: + xas_reset(&xas); + } + +update_start: + nr = folio_batch_count(fbatch); + + if (nr) { + folio = fbatch->folios[nr - 1]; + if (folio_test_hugetlb(folio)) + *start = folio->index + 1; + else + *start = folio->index + folio_nr_pages(folio); + } +out: + rcu_read_unlock(); + return folio_batch_count(fbatch); +} +EXPORT_SYMBOL(filemap_get_folios_contig); + /** * find_get_pages_contig - gang contiguous pagecache lookup * @mapping: The address_space to search From patchwork Wed Aug 24 00:40: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: 12952755 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 34656C32793 for ; Wed, 24 Aug 2022 00:42:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0CF794000B; Tue, 23 Aug 2022 20:42:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B20B7940007; Tue, 23 Aug 2022 20:42:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9979694000B; Tue, 23 Aug 2022 20:42:48 -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 87B55940007 for ; Tue, 23 Aug 2022 20:42:48 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5B551C0235 for ; Wed, 24 Aug 2022 00:42:48 +0000 (UTC) X-FDA: 79832636016.15.1335D0D Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 1D8B118004F for ; Wed, 24 Aug 2022 00:42:47 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id z187so14981825pfb.12 for ; Tue, 23 Aug 2022 17:42:47 -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=7skDaFS+wO3x7T1TXAuYW/BptQcipesiqb0XDCtUEEw=; b=eHdJm85W11mqHe7iSlXRQz2ygLqKExb3lA40z8uFuGfbXq3WXeGy9DXultohRdLawo 7Qd4RYcqXdiOD1jVazkFWrVfbcEpZLkLKiYEbbVNpAP6i1Nd7Enztpw0rco/HtfAgelS yXfeHGXyD3xjvUoNPjR0C5NtRVGRp7UlscxmNBTFPWt1x2OwLuMcANfed4zmLsZjT/45 2+zuuS+rYfMhq3rXHITdzud7s/woaEpElOxkAQsM6OVktlhuI4CydOja6ok5+Q7WCPNx 7UYV6GrwTNA8j6aGb/1ATFVVL0qJDsULOKYgFWsLu62kFPJLVN89ECVXY93Qo3YIHNjG RWfw== 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=7skDaFS+wO3x7T1TXAuYW/BptQcipesiqb0XDCtUEEw=; b=mKAza1Mu69jSzkl8q1W23TBdoWzLFPDLq4CksJhBXL5n9S6bwboNd9XDvTB7/ZIbWL 3e3EcqDv9eO5hWD2CoLSur11AE9UIgGRRQoK82zIp5fqfW+WbkRaqRN0YPM+8wBqxXV/ 9vYh4K4yG+c/9JmFQMI2TD63MxDsboo0FaBhp/mVp3VIfNNlWbQ08syRg/UmCmMyOUkp AmhnPa7+e670VhOWMtQbESs7ggS2NgJvubwO/YkkCh7gdnpJznITrfMlvbw3vh9Cop1W eyAoeGlokGQ8ObMkQXVkijRD/cAAQvY9IHQRt6q0BDfylF5nHl9t2YbpxrV6CTQwxX9W dNqg== X-Gm-Message-State: ACgBeo0woUnSuGRXtpfH345dmbtGWpJRYUHmaJlbiHMnMWaq5LG6D4bF PiqzM3Y3tewxQj1D3B9xmLQ= X-Google-Smtp-Source: AA6agR5Q1Wli3z1uHbV2YZ/D6eEz/caJjcTDDqR90x6WtSvY1gRmMDL8bMOFSbjugWK/cuKV+GsHyw== X-Received: by 2002:aa7:9084:0:b0:535:ed0c:f401 with SMTP id i4-20020aa79084000000b00535ed0cf401mr25266450pfa.48.1661301767013; Tue, 23 Aug 2022 17:42:47 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id ij5-20020a170902ab4500b0016dd667d511sm11063319plb.252.2022.08.23.17.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:46 -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 2/7] btrfs: Convert __process_pages_contig() to use filemap_get_folios_contig() Date: Tue, 23 Aug 2022 17:40:18 -0700 Message-Id: <20220824004023.77310-3-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; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eHdJm85W; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.172 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=1661301768; a=rsa-sha256; cv=none; b=0PCgAj8KoA1Wh93Pfrj1fRxXgIW447wPCMR07YPjajfgVp9abUDl349K7Xz66nXlUds333 5Tp9KxvX+R/TFUo5mYvjgeTzw+Ry4amXoiQR2z8EvDYGH8t6scDVQhweYjxLpOFXDb0ch5 YGYQcjY5t59wet5WMRaP/iJSMPCoIS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301768; 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=7skDaFS+wO3x7T1TXAuYW/BptQcipesiqb0XDCtUEEw=; b=tLIXpt3sSB7akJ6aYLD8f8If8BHrvoYfDL1e7nnudcms2iR4yXUZfv8NbmcsSqRiXC2nvx ux4MyQIekFQnQL4u7SqS3k8d2/Iiz/XkGMXOHmbUUgKxOIcuhXqqwnWDkQ7EK1sEMBIa9+ s3vXVbbZOHB1fvze4ZxaPMDCecL54Q4= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eHdJm85W; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Queue-Id: 1D8B118004F X-Rspamd-Server: rspam05 X-Stat-Signature: nrqd39my6fsyofspd96gbe11ec9o54t9 X-HE-Tag: 1661301767-862800 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 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. Acked-by: David Sterba Signed-off-by: Vishal Moola (Oracle) --- fs/btrfs/extent_io.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8f6b544ae616..f16929bc531b 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1882,9 +1882,8 @@ static int __process_pages_contig(struct address_space *mapping, pgoff_t start_index = start >> PAGE_SHIFT; pgoff_t end_index = end >> PAGE_SHIFT; pgoff_t index = start_index; - unsigned long nr_pages = end_index - start_index + 1; unsigned long pages_processed = 0; - struct page *pages[16]; + struct folio_batch fbatch; int err = 0; int i; @@ -1893,16 +1892,17 @@ static int __process_pages_contig(struct address_space *mapping, ASSERT(processed_end && *processed_end == start); } - if ((page_ops & PAGE_SET_ERROR) && nr_pages > 0) + if ((page_ops & PAGE_SET_ERROR) && start_index <= end_index) mapping_set_error(mapping, -EIO); - while (nr_pages > 0) { - int found_pages; + folio_batch_init(&fbatch); + while (index <= end_index) { + int found_folios; + + found_folios = filemap_get_folios_contig(mapping, &index, + end_index, &fbatch); - found_pages = find_get_pages_contig(mapping, index, - min_t(unsigned long, - nr_pages, ARRAY_SIZE(pages)), pages); - if (found_pages == 0) { + if (found_folios == 0) { /* * Only if we're going to lock these pages, we can find * nothing at @index. @@ -1912,23 +1912,20 @@ static int __process_pages_contig(struct address_space *mapping, goto out; } - for (i = 0; i < found_pages; i++) { + for (i = 0; i < found_folios; i++) { int process_ret; - + struct folio *folio = fbatch.folios[i]; process_ret = process_one_page(fs_info, mapping, - pages[i], locked_page, page_ops, + &folio->page, locked_page, page_ops, start, end); if (process_ret < 0) { - for (; i < found_pages; i++) - put_page(pages[i]); err = -EAGAIN; + folio_batch_release(&fbatch); goto out; } - put_page(pages[i]); - pages_processed++; + pages_processed += folio_nr_pages(folio); } - nr_pages -= found_pages; - index += found_pages; + folio_batch_release(&fbatch); cond_resched(); } out: From patchwork Wed Aug 24 00:40: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: 12952756 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 A0EDBC32796 for ; Wed, 24 Aug 2022 00:42:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A71294000C; Tue, 23 Aug 2022 20:42:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26966940007; Tue, 23 Aug 2022 20:42:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10A9994000C; Tue, 23 Aug 2022 20:42:50 -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 00376940007 for ; Tue, 23 Aug 2022 20:42:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D981F1C60A8 for ; Wed, 24 Aug 2022 00:42:49 +0000 (UTC) X-FDA: 79832636058.10.71E2E57 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf18.hostedemail.com (Postfix) with ESMTP id 9727B1C0005 for ; Wed, 24 Aug 2022 00:42:49 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id s36-20020a17090a69a700b001faad0a7a34so18833049pjj.4 for ; Tue, 23 Aug 2022 17:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qAIZUZ0pgScRmQa0duFh/+V4CGm9o36zgCrAtR/Z4DI=; b=oI3O32y9Nc1raAftWQD45HU0GA4593iugYPxYzJPeePQFlHLBee2vueXj2ulohnlGD 0apI5Vd2fXUvaSfIfbhGlpXWV8qX5pAShMjdTMdoMsZPlf0qnMkxYf0Mt7om59P/zn0D nkf6+QPwhFNNcbPSMmPiebGNWB5Fyut9TU52gVuzsPb0lqdPHa06BWertBwZr/3AkyLF 6G3GMlyy5cWyGBlHl/U/aIJUlygwCrZndzi8pl6TFqpKdhcY0snfUl3PeC/zdS/Z90cK XGmdiXzwyIPV20FBVatPpV4QZVBMlp43v26aUh+bcTSoSOOt++Szi9rUHP6iiXXqbfVr Ntuw== 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=qAIZUZ0pgScRmQa0duFh/+V4CGm9o36zgCrAtR/Z4DI=; b=J4d24P5mi3n16XjIUTKGXALCFmH6Bao3YrfNHlpyS32mqC0wdjARqthwG1VoqHaLM3 4hQA+R0rDCJx49TSLsJ9Dn/WuUcJ4ym2RqnkWTMhQ1HBoL5Z6VX94ubOGp08hxEua1uv 2mOMyvUOIyN+7QnQonD/nu7kjJ8h3TTNpWTPFwu1nrrbwl8rsmY8yll9rterdopvo5no Oq7PipgD5lmdxDwYZIbt603jo9R+W+b9d4ZFcm4V4YLm7CfsLNPliYrqTuO4qkUobm5s wwB/rcyuuWq09yjq83ijTcBrK3a5KhbSNXA90nB6czisee4Pqhh9wZK0xy7BVtK65Ww8 lU7Q== X-Gm-Message-State: ACgBeo2X8JjvGEzVbQX3cY4HgOOkc4yv6/qhCsE2z1Fj3CvYHUGpqcJ5 +m4DteTDYJ0uBVikvrg8xp0= X-Google-Smtp-Source: AA6agR5llaHTn279DIwEZUeEMnW3NXj8vtX5ysX6JUk/8qA8xgTynGzMRCc6FPq/y4eEsBnNCo1oEQ== X-Received: by 2002:a17:903:22c6:b0:172:cad9:403 with SMTP id y6-20020a17090322c600b00172cad90403mr19905404plg.123.1661301768634; Tue, 23 Aug 2022 17:42:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:48 -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 3/7] btrfs: Convert end_compressed_writeback() to use filemap_get_folios() Date: Tue, 23 Aug 2022 17:40:19 -0700 Message-Id: <20220824004023.77310-4-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301769; 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=qAIZUZ0pgScRmQa0duFh/+V4CGm9o36zgCrAtR/Z4DI=; b=qBnBFCxHiLpxWDdsXlJ9wRT0yDglI19BxuQEmtD/mAAIAWUky7XdmuaSbjKQwa+1vfUXxA b2Xwg6DYrWgkARFXDc2EliJ2sSEMBbOLBNKiLN1lNlxwH1YRP3YNTOebqyLBHGLuKSaBCj DNA3Y9FNpdid0OgVKu4Gcwm1LHroV9Y= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=oI3O32y9; spf=pass (imf18.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=1661301769; a=rsa-sha256; cv=none; b=xgnT/cjvspdbEgoobd7gR2IYXzDWAsUQZ1zlwAnKph/wDhEh5aJx9+WdPhMjSQdwGVsKv0 mlcPYH3Z250tAeshaqsWFiL2fbz5HALp+++ER05vOVPfl4QFiih10upngjgI5DYcQNBMc/ LCRwCIQYL+6Z2qkqkhomhJPzwQ61nW0= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9727B1C0005 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=oI3O32y9; spf=pass (imf18.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-Stat-Signature: rnas75f4ui7d9qpjmgpto5k8bz1s8iyg X-HE-Tag: 1661301769-209861 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 this function does not care about the pages being contiguous so we can just use filemap_get_folios() to be more efficient. Acked-by: David Sterba Signed-off-by: Vishal Moola (Oracle) --- fs/btrfs/compression.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index f4564f32f6d9..e0f8839cdd94 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -339,8 +340,7 @@ static noinline void end_compressed_writeback(struct inode *inode, struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); unsigned long index = cb->start >> PAGE_SHIFT; unsigned long end_index = (cb->start + cb->len - 1) >> PAGE_SHIFT; - struct page *pages[16]; - unsigned long nr_pages = end_index - index + 1; + struct folio_batch fbatch; const int errno = blk_status_to_errno(cb->status); int i; int ret; @@ -348,24 +348,23 @@ static noinline void end_compressed_writeback(struct inode *inode, if (errno) mapping_set_error(inode->i_mapping, errno); - while (nr_pages > 0) { - ret = find_get_pages_contig(inode->i_mapping, index, - min_t(unsigned long, - nr_pages, ARRAY_SIZE(pages)), pages); - if (ret == 0) { - nr_pages -= 1; - index += 1; - continue; - } + folio_batch_init(&fbatch); + while (index <= end_index) { + ret = filemap_get_folios(inode->i_mapping, &index, end_index, + &fbatch); + + if (ret == 0) + return; + for (i = 0; i < ret; i++) { + struct folio *folio = fbatch.folios[i]; + if (errno) - SetPageError(pages[i]); - btrfs_page_clamp_clear_writeback(fs_info, pages[i], + folio_set_error(folio); + btrfs_page_clamp_clear_writeback(fs_info, &folio->page, cb->start, cb->len); - put_page(pages[i]); } - nr_pages -= ret; - index += ret; + folio_batch_release(&fbatch); } /* the inode may be gone now */ } 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; } From patchwork Wed Aug 24 00:40: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: 12952758 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 4C912C32796 for ; Wed, 24 Aug 2022 00:42:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E06CC80008; Tue, 23 Aug 2022 20:42:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3F1880007; Tue, 23 Aug 2022 20:42:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB8A180008; Tue, 23 Aug 2022 20:42:52 -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 A91CA80007 for ; Tue, 23 Aug 2022 20:42:52 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7F810A0127 for ; Wed, 24 Aug 2022 00:42:52 +0000 (UTC) X-FDA: 79832636184.30.E44C916 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf18.hostedemail.com (Postfix) with ESMTP id 2F4E41C0008 for ; Wed, 24 Aug 2022 00:42:52 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id 12so13664373pga.1 for ; Tue, 23 Aug 2022 17:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=KyMLiEXuqe6oMgJlOPUNT684cH6jPO08N05OJyEa5MI=; b=JXzLL8UAMMTyqxQPGNwR9rod7kTLexta+9ZdxunA7mrxp0SsVejkQaJC5Bmil85eaD jH1a6u8Qw8HCxqsOCfUc6dXwabaWbL1o3EKqezvzeM4nqchYD0Zj+Nmw3zXtu6Ivc5f1 EmVyKyYwbbK3AEFq5jQHeUtGYTArf4JfFOUDCmZx6nsXZ5aoClbLow/COO51EDjyteN0 Z5h2uy3b6bEdUihA/HT+I9Z7cRXmvPNXWmft999iQHIXvE2GFKctDA5u/QCN3Gs/WtGS mygT/DoUY6gHw3/Bu1+ryrseK5gWZjTBlO4ZKmPq4oIHx6urSYB5Io7e8qe2QSPRV7El NI5Q== 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=KyMLiEXuqe6oMgJlOPUNT684cH6jPO08N05OJyEa5MI=; b=Xs3VWTg4RKwq2xgbDYxY3fepnMjDxXujTSSLQn+sXc3ZpzSOXbpw3eqtycQkAAXb/2 P9qxBd2iCM3OwhwVt0p1TnsiE3glMelmITe3IOO4j6sAG0zZa4WHRdzxK+oY8nWvdIXO q7C1iD8s59E3jlF6ehOn1Q6mi3q//CYUWy/1G+SU8tKySMT/zyHaY89rfYMV5g8NGNVX nPpNYo2CLUhcHd2vb/SXbz2bA0vgzOdGtu3FDrLT9FSE/VdHRIksq8cVS1pUkXOSoyt6 ys9F+IJ7xbQI2MtsMFBXZmBQ4scF8YLz4SFpZ78pq6XoKr3lyEIlMCjubMSFFgrDJPkR suxA== X-Gm-Message-State: ACgBeo0+1stp2Q8pdKE+iSzRSazrjGF6oi6ik9dMcxUq2SxhejcSXjI2 VPSIr0+jOb6De2vAkporB5NzM7M6TCH2D9A+ X-Google-Smtp-Source: AA6agR7ZhhuWt7Z3orz6dRd2bYxDUpCPJIMRmnwoYYc0vK/g3DtqDkZxoGhhEptFnPNqDJqxc/NxIg== X-Received: by 2002:aa7:8887:0:b0:536:a411:40d0 with SMTP id z7-20020aa78887000000b00536a41140d0mr11726341pfe.46.1661301771045; Tue, 23 Aug 2022 17:42:51 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id ij5-20020a170902ab4500b0016dd667d511sm11063319plb.252.2022.08.23.17.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:50 -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)" Subject: [PATCH v3 5/7] nilfs2: Convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig() Date: Tue, 23 Aug 2022 17:40:21 -0700 Message-Id: <20220824004023.77310-6-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661301772; a=rsa-sha256; cv=none; b=0NnQ4GzZuYUwQrNIcntPIG8p+vtjJffz1C7cAqaPA7wg3eOaCPXTDCc/8mj697XMeNCkZv Kx+IlF0f2TVFgPkp3q5/tm6fyRaAEkl5C9r5d+5sFQ+ZKoPY6uVSChtbt0xSC5uxxk+Bld LSGVoeudSs63umYA0ANVPO55tIXALxg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JXzLL8UA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.171 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=1661301772; 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=KyMLiEXuqe6oMgJlOPUNT684cH6jPO08N05OJyEa5MI=; b=yuTtmYRichRrI3bc9ZSce7LuBsSpZwBp0jtefgiT4zbpuHnhHWB+bqdEO6qIsSwVNVuz2M gb/oukjJgbdELiEULhI7Jg6Oil+emf2edvYcco/w3Dog0t7+FsnTcdRxv4t0CajARibk6G nxWGj7egP36pWtj7b6Uo0fY/2sCoW9I= X-Stat-Signature: wdam4z8fgfxeb53jnpy15p4y1yo7545z X-Rspamd-Queue-Id: 2F4E41C0008 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JXzLL8UA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1661301772-109041 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. Also cleaned up an unnecessary if statement - pvec.pages[0]->index > index will always evaluate to false, and filemap_get_folios_contig() returns 0 if there is no folio found at index. Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 3267e96c256c..39b7eea2642a 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -480,41 +480,36 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, sector_t start_blk, sector_t *blkoff) { - unsigned int i; + unsigned int i, nr_folios; pgoff_t index; - unsigned int nblocks_in_page; unsigned long length = 0; - sector_t b; - struct pagevec pvec; - struct page *page; + struct folio_batch fbatch; + struct folio *folio; if (inode->i_mapping->nrpages == 0) return 0; index = start_blk >> (PAGE_SHIFT - inode->i_blkbits); - nblocks_in_page = 1U << (PAGE_SHIFT - inode->i_blkbits); - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: - pvec.nr = find_get_pages_contig(inode->i_mapping, index, PAGEVEC_SIZE, - pvec.pages); - if (pvec.nr == 0) + nr_folios = filemap_get_folios_contig(inode->i_mapping, &index, ULONG_MAX, + &fbatch); + if (nr_folios == 0) return length; - if (length > 0 && pvec.pages[0]->index > index) - goto out; - - b = pvec.pages[0]->index << (PAGE_SHIFT - inode->i_blkbits); i = 0; do { - page = pvec.pages[i]; + folio = fbatch.folios[i]; - lock_page(page); - if (page_has_buffers(page)) { + folio_lock(folio); + if (folio_buffers(folio)) { struct buffer_head *bh, *head; + sector_t b; - bh = head = page_buffers(page); + b = folio->index << (PAGE_SHIFT - inode->i_blkbits); + bh = head = folio_buffers(folio); do { if (b < start_blk) continue; @@ -529,21 +524,17 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, } else { if (length > 0) goto out_locked; - - b += nblocks_in_page; } - unlock_page(page); + folio_unlock(folio); - } while (++i < pagevec_count(&pvec)); + } while (++i < nr_folios); - index = page->index + 1; - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); goto repeat; out_locked: - unlock_page(page); -out: - pagevec_release(&pvec); + folio_unlock(folio); + folio_batch_release(&fbatch); return length; } From patchwork Wed Aug 24 00:40: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: 12952759 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 9B89FC32793 for ; Wed, 24 Aug 2022 00:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0702980009; Tue, 23 Aug 2022 20:42:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0222180007; Tue, 23 Aug 2022 20:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D678780009; Tue, 23 Aug 2022 20:42:53 -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 B2B7380007 for ; Tue, 23 Aug 2022 20:42:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 91DE21401B6 for ; Wed, 24 Aug 2022 00:42:53 +0000 (UTC) X-FDA: 79832636226.07.0134C4D Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf09.hostedemail.com (Postfix) with ESMTP id 44A2514002E for ; Wed, 24 Aug 2022 00:42:53 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id g18so15560160pju.0 for ; Tue, 23 Aug 2022 17:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=uj5rrWVo2hhIgeuvVD0w6VogaYUvVvctXUbaYlCVCAo=; b=ojG9SQPgHrXaANCUaSiNdwQENvFe0haF1bqg2TNsX0PZ4L89+S9oEqG3x9mSHNOmCX fEkkxL5MmF2Z+NoSCrF7uNfE6LOSdRvjC+VTS7SYmQu5M4NnGKBD9B5TiVgrFjDzCruf ANQMTXrR9WRRE/NMOxIWTzrUPOQwD6wcQDRW7d/A3HQruAY8Q/LFHBCLjO+NulfdW0ej OG6BFSK5Hgghaq2RPMGKBYCZxcxHmlqEO0Kwmibm4qoLBH+INxAubDUtJqb670NJ+JN/ WmfukncGRHe3XrC+vSmdtg51xSWy2Eoaktuu073lH25G+RTwB0r8uRdzZPr4xNjjFfn5 aEjw== 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=uj5rrWVo2hhIgeuvVD0w6VogaYUvVvctXUbaYlCVCAo=; b=YYjQj0yA6u2AZTbLllQaGB1sZ7iSjCe/S+eE2trhJG/vq3xwQcF3U3heLhBShUkQRP zH33cMjSvgPp+NwFD7iEPMAoAd1sFAQxvVbl1fgWhqAALe1cNeLv7MCtnIkCM7i/Q0hQ jZrStM0+lIhlHmCWvQtiizVdYVkts4IV3TE2AF1Q6D0pnG6zjhAGmOMGbpqne/zqRpoi M3tkO/V7JksbAmMvQJirwBFIpFuRFWciEycOUJoXLszVyCBEu2DiZj1JMGB7VX8XzFb9 HNYPSbTTK9U6wy83FEXHxYPo027UMqDv9qC3/HV3rosNzz09+xe9Cp/1vsOI2IcpjX1p 2JmA== X-Gm-Message-State: ACgBeo2CZ6Ve/6c9+RUhbz2kTcEbT8NhX0g9nSIsY4NtCcTGGBnC2emQ dNZXG7k+nSGdQg6Jj2RiUE8B05wrifwbTPZm X-Google-Smtp-Source: AA6agR4QKpwL6R2zyk4XY3/XZMQUNveYTQy+QnagYV81kICTpxGmHkiP0SGAa0ajiEmDjO3dLDXJ2Q== X-Received: by 2002:a17:902:7b87:b0:172:8ae9:2015 with SMTP id w7-20020a1709027b8700b001728ae92015mr26859761pll.112.1661301772273; Tue, 23 Aug 2022 17:42:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:51 -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)" Subject: [PATCH v3 6/7] ramfs: Convert ramfs_nommu_get_unmapped_area() to use filemap_get_folios_contig() Date: Tue, 23 Aug 2022 17:40:22 -0700 Message-Id: <20220824004023.77310-7-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661301773; a=rsa-sha256; cv=none; b=6gqSvzmxfFPD3J9xNXRQnPhJLN+7VqeJEFgo5cgr3PFYdRtPosug8QOcEmAVnn+70y1aos KzirzVVgqfmaXf55aTINxLZdRNqFHHVe3gCTpy0C1jwagy9+qqMQvlHYDdySfp1gvITYrt ZnTiBRW5pSdJ28eyBoqNl93YxQIuqQk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ojG9SQPg; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301773; 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=uj5rrWVo2hhIgeuvVD0w6VogaYUvVvctXUbaYlCVCAo=; b=dUO7e2EI1YeVlNPWUD1crPoYEGItH79CUTjgfOCjV/qvNRLvRLAb8ntRqT48VNdSUNWq1T bFVukeHIpmtH5JT5ez9tZ++a5vU9OE7VHtuZKeFCtPFVj0uDXa5bmLvysufb09K+/wbAe6 XfGigDydRsAn2V2EMHwjEdiBxbIRka0= X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 44A2514002E Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ojG9SQPg; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: kwcj4h9ctbjj797xranuxctsfw55wgtc X-HE-Tag: 1661301773-152576 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 to use folios throughout. This is in preparation for the removal for find_get_pages_contig(). Now also supports large folios. The initial version of this function set the page_address to be returned after finishing all the checks. Since folio_batches have a maximum of 15 folios, the function had to be modified to support getting and checking up to lpages, 15 pages at a time while still returning the initial page address. Now the function sets ret as soon as the first batch arrives, and updates it only if a check fails. The physical adjacency check utilizes the page frame numbers. The page frame number of each folio must be nr_pages away from the first folio. Signed-off-by: Vishal Moola (Oracle) --- --- fs/ramfs/file-nommu.c | 50 +++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index ba3525ccc27e..cb240eac5036 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -203,9 +203,9 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { - unsigned long maxpages, lpages, nr, loop, ret; + unsigned long maxpages, lpages, nr_folios, loop, ret, nr_pages, pfn; struct inode *inode = file_inode(file); - struct page **pages = NULL, **ptr, *page; + struct folio_batch fbatch; loff_t isize; /* the mapping mustn't extend beyond the EOF */ @@ -221,31 +221,39 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file, goto out; /* gang-find the pages */ - pages = kcalloc(lpages, sizeof(struct page *), GFP_KERNEL); - if (!pages) - goto out_free; - - nr = find_get_pages_contig(inode->i_mapping, pgoff, lpages, pages); - if (nr != lpages) - goto out_free_pages; /* leave if some pages were missing */ + folio_batch_init(&fbatch); + nr_pages = 0; +repeat: + nr_folios = filemap_get_folios_contig(inode->i_mapping, &pgoff, + ULONG_MAX, &fbatch); + if (!nr_folios) { + ret = -ENOSYS; + return ret; + } + if (ret == -ENOSYS) { + ret = (unsigned long) folio_address(fbatch.folios[0]); + pfn = folio_pfn(fbatch.folios[0]); + } /* check the pages for physical adjacency */ - ptr = pages; - page = *ptr++; - page++; - for (loop = lpages; loop > 1; loop--) - if (*ptr++ != page++) - goto out_free_pages; + for (loop = 0; loop < nr_folios; loop++) { + if (pfn + nr_pages != folio_pfn(fbatch.folios[loop])) { + ret = -ENOSYS; + goto out_free; /* leave if not physical adjacent */ + } + nr_pages += folio_nr_pages(fbatch.folios[loop]); + if (nr_pages >= lpages) + goto out_free; /* successfully found desired pages*/ + } + if (nr_pages < lpages) { + folio_batch_release(&fbatch); + goto repeat; /* loop if pages are missing */ + } /* okay - all conditions fulfilled */ - ret = (unsigned long) page_address(pages[0]); -out_free_pages: - ptr = pages; - for (loop = nr; loop > 0; loop--) - put_page(*ptr++); out_free: - kfree(pages); + folio_batch_release(&fbatch); out: return ret; } From patchwork Wed Aug 24 00:40: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: 12952760 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 D43D1C32796 for ; Wed, 24 Aug 2022 00:42:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CF158000A; Tue, 23 Aug 2022 20:42:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DE9280007; Tue, 23 Aug 2022 20:42:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1588A8000A; Tue, 23 Aug 2022 20:42:55 -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 0502C80007 for ; Tue, 23 Aug 2022 20:42:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CC7F3ABE87 for ; Wed, 24 Aug 2022 00:42:54 +0000 (UTC) X-FDA: 79832636268.29.5DF159A Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf17.hostedemail.com (Postfix) with ESMTP id 7D1A040003 for ; Wed, 24 Aug 2022 00:42:54 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id x23so14282810pll.7 for ; Tue, 23 Aug 2022 17:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/CfNnOMJk6G65551bZckVmJ3kjJ/k4Yc+qvoAg65GHU=; b=G8TXZ41ypzXH2ZGDemwUIRnrhlgVru1aOFOrt11RUGeOxYD2OEbjqjcKoGK6qHOJi9 MbtYizKOZFfhZwL8kE8b9i9Vda56q1LheWpsm8zBqVGawexnK256o4cNnjDR2yR0RNj1 jWmHonngeuWnuopR3tvKa2pkmlrs5Pvf+FehXXpbrFYiVp5TramRl4P9BVFicecGfqZH 7P5r07WqQCaO+01g7WRirRh4lfh0/bgOArCv3maqdBcWCfoaSptp5Y2zL01c+FWlMUrG VMAMO5V/XsqnEjfd4gfoDT7FqrQQU9iEiOVlcQ7iQkIuLOAklkrQAyE4dm4arHMjJXHc ptNA== 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=/CfNnOMJk6G65551bZckVmJ3kjJ/k4Yc+qvoAg65GHU=; b=Mjys0adpttbS3AeEsICHdUKbsIMKcMGtP/tZNatkSolH23k1DDfxYXQVOAYRox2VtL Cm5YI41/8HwJaeYqrh4LHJzLIAC0N+e5WZkumVQUATpOooQJWLtAEy5GK2qp5qhAk5eu Ec/DPpw04+awIzdh6JqD+bDA/9yGvSKwCbZ6yO7BCvuEgvtu+Mob/3lvsSNf+aKhkGK2 LMD+WwqeETDTC3lU+ZLEHchYp14aAuvTgKSBcOD2JTEV/K/nOzZ/9xkYZUGlbK3t35a/ oS6n13V4esSZ/JjWRs8vZKiSxVnanh5LFXjKqBTNzk1eG4KDng636ZFrsyHSw4dP+2nM PhRw== X-Gm-Message-State: ACgBeo2MmfYHmDS5tdtTdDIWPJ9ylCRMi8J5+RDl56FjeJTM1cVO/ngt GlS9E2RRaFONXpdG1WRl6LU= X-Google-Smtp-Source: AA6agR5WT/40tN+ZgWF8O3r0YRQFSvwdr0HcxJVpLFddbFnLr3FgL+4iWeI2l6ZXe1RaOMtfOyIiEw== X-Received: by 2002:a17:902:bd41:b0:172:74c9:2a08 with SMTP id b1-20020a170902bd4100b0017274c92a08mr26498900plx.9.1661301773430; Tue, 23 Aug 2022 17:42:53 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id ij5-20020a170902ab4500b0016dd667d511sm11063319plb.252.2022.08.23.17.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:42:52 -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)" Subject: [PATCH v3 7/7] filemap: Remove find_get_pages_contig() Date: Tue, 23 Aug 2022 17:40:23 -0700 Message-Id: <20220824004023.77310-8-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661301774; a=rsa-sha256; cv=none; b=QJQlfCFmtyLIj8fRtHdDGRu2/4kPqnWBy1BCZqQ1O8KxiqG6u3fdcPOBMvAq74yAJkVVXy b913+CgOTx4hB3QlvUEwPIZ7G+fUWfKtgxg6Ufb+AqeRa0coQG3kIxq1BxG8/i0jCOyLUV pdaiu9buwpUDfc46lrPcxb9Lf8/93EY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G8TXZ41y; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661301774; 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=/CfNnOMJk6G65551bZckVmJ3kjJ/k4Yc+qvoAg65GHU=; b=urjcwFB1pS3QcHuplJCWvn6KP+y+Tjj7KOZRaUHOiHIiL4EMEwQUHPVvmaoz+Y4t7tcSvK 7zWItvjieDqLFm3DJDkRWjwPrg1lGhEssmgstgbDx2sSqC/SqpzSDPmA7v1ymMVVrzlGtL +kPY29y+Q62Mye6dKtl/Hh/V6CbNXfU= X-Rspam-User: X-Stat-Signature: 99zzbx6busmsdxro75tmiixztmwdkc8r X-Rspamd-Queue-Id: 7D1A040003 X-Rspamd-Server: rspam12 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G8TXZ41y; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1661301774-20402 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 of find_get_pages_contig() have been removed, so it is no longer needed. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 2 -- mm/filemap.c | 60 ----------------------------------------- 2 files changed, 62 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 951936a2be1d..a04a645b64e9 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -722,8 +722,6 @@ 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 find_get_pages_contig(struct address_space *mapping, pgoff_t start, - unsigned int nr_pages, struct page **pages); 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 8167bcc96e37..af5a4b5f866d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2269,66 +2269,6 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, } EXPORT_SYMBOL(filemap_get_folios_contig); -/** - * find_get_pages_contig - gang contiguous pagecache lookup - * @mapping: The address_space to search - * @index: The starting page index - * @nr_pages: The maximum number of pages - * @pages: Where the resulting pages are placed - * - * find_get_pages_contig() works exactly like find_get_pages_range(), - * except that the returned number of pages are guaranteed to be - * contiguous. - * - * Return: the number of pages which were found. - */ -unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, - unsigned int nr_pages, struct page **pages) -{ - XA_STATE(xas, &mapping->i_pages, index); - struct folio *folio; - unsigned int ret = 0; - - if (unlikely(!nr_pages)) - return 0; - - rcu_read_lock(); - for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) { - if (xas_retry(&xas, folio)) - continue; - /* - * If the entry has been swapped out, we can stop looking. - * No current caller is looking for DAX entries. - */ - if (xa_is_value(folio)) - break; - - if (!folio_try_get_rcu(folio)) - goto retry; - - if (unlikely(folio != xas_reload(&xas))) - goto put_page; - -again: - pages[ret] = folio_file_page(folio, xas.xa_index); - if (++ret == nr_pages) - break; - if (folio_more_pages(folio, xas.xa_index, ULONG_MAX)) { - xas.xa_index++; - folio_ref_inc(folio); - goto again; - } - continue; -put_page: - folio_put(folio); -retry: - xas_reset(&xas); - } - rcu_read_unlock(); - return ret; -} -EXPORT_SYMBOL(find_get_pages_contig); - /** * find_get_pages_range_tag - Find and return head pages matching @tag. * @mapping: the address_space to search