From patchwork Mon Aug 15 18:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943966 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 6E4FAC25B0E for ; Mon, 15 Aug 2022 18:56:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3FAC8D0003; Mon, 15 Aug 2022 14:55:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC7578D0001; Mon, 15 Aug 2022 14:55:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D19468D0003; Mon, 15 Aug 2022 14:55:59 -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 C3A9D8D0001 for ; Mon, 15 Aug 2022 14:55:59 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9FBE28026F for ; Mon, 15 Aug 2022 18:55:59 +0000 (UTC) X-FDA: 79802731638.16.7573CE0 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf15.hostedemail.com (Postfix) with ESMTP id 3966BA01C8 for ; Mon, 15 Aug 2022 18:55:59 +0000 (UTC) Received: by mail-pl1-f169.google.com with SMTP id 13so7097688plo.12 for ; Mon, 15 Aug 2022 11:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DC0lDtuVz6yFca92GBSK6djBgAZXj0wHc7OOD2pjghE=; b=QWwJlBuMd3BZgQulNy3FF7Q8pHPEfKIeqgRJRGAHI5ml30UD5XY5UUb29NmNZ8GBjD GxKLYh8ECcsSkfb8EV5IztKhRaUL+Onv2MfPhcIiNquRk71zD8RiLLFXvt/rviGRyCIk 8Y4upNBC2pPja+wNdchcY0q5S40PIsZtaqTiOA9sRc5a2o5UyIANJhCZaX0QOfz/9BVr GEtb3lgFajKMMwzsCGpuGJ5UlCPBFGxy93H79eQF8kL1tcdvqUpqF3vDpp8wcQvlX07b aXwTAzF6n1dZNb0C6hPPmmlC4TUj3CmYGpvXa+ZGc7hQxiNrXl1vl+Y7ZpGVOO5I7umb rtCg== 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=DC0lDtuVz6yFca92GBSK6djBgAZXj0wHc7OOD2pjghE=; b=Wxywj8CnT4270GLCBirXM8UU8C067+npzBT4mvvlbEWwASwPeSdNl4xExqkFqQ+hV6 tpIN35iZLRcvwbhFZzh6+Sp9EMtRGToRJ0ck8Xe7KZ53ew526h5XNQsI4aTmlqyUJyth HHLZh2sO/3BRhfFmuINrgwe31awbYwTtNDhwQY2QQERqz+BEE+qkAeGyrkYJDlCJzI+m xRhNQxQ+1ujbajNdCKUcwgtWkSoQMEA752+6xEnzfwY8sMILC7Vv5j8+tKeXetvVgwRd Mf/cNN6+VsJ+amT2nEmx1sobcar2auIh1c6590AJ8JKBgkJ/ME52OAdR0a+1HwIFFYLf BHJA== X-Gm-Message-State: ACgBeo2I/tCStA/iO9T8lpxNKNzyuzvsh2XCnphNTReEZ+nflLDPfKpg q33D48xC90OP8Iwh7qlMoco= X-Google-Smtp-Source: AA6agR6oRWqK8fWSNacTEJBV1JAilD8l4rIaZKnYmiUqRPSQ33T+fZtCDVjT3SqOVrTd4JO1xkIN3Q== X-Received: by 2002:a17:903:41c6:b0:16f:3d1:f63 with SMTP id u6-20020a17090341c600b0016f03d10f63mr18064404ple.50.1660589758240; Mon, 15 Aug 2022 11:55:58 -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 x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:55:57 -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 1/7] filemap: Add filemap_get_folios_contig() Date: Mon, 15 Aug 2022 11:54:46 -0700 Message-Id: <20220815185452.37447-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-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=QWwJlBuM; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 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=1660589759; a=rsa-sha256; cv=none; b=ItjgK5BM/WNroFOb7P8pFZiHFkTCR4pIXIwdJPm3Ls+CXG6JpIJj635OnltJPcw05xRQai YXOJ/od6U83tJFPTnfE92blDoDYqtVlV60svfGTGsK1InfPN8b0Jw4BhPQmJ+nhFvMGbRG 9CphlpH0BJy4o+RGHeP83xrOczetRuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660589759; 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=DC0lDtuVz6yFca92GBSK6djBgAZXj0wHc7OOD2pjghE=; b=09IRZI2J84/xhMvNCER5YYtyX21LTsx8U0vKFh9We0rzCzXxHsKD7YauED7KgtxHphr1QH D4x+jEZTOn3hIvJtMbDn3FWeDCgcdvTdCIWzO1xgXgDcxCI4z7fbQtHeoLprXDbX8EYVc2 0J5xeEpvsLwQ8XHoJ3MyywW6cs7T9xQ= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QWwJlBuM; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: akj3csd3obcrdkhx7zrswew6oqxtiwzo X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 3966BA01C8 X-HE-Tag: 1660589759-755441 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, 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 0178b2040ea3..8689c32d628b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -718,6 +718,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 15800334147b..3a497e178fde 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2194,6 +2194,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 Mon Aug 15 18:54:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943967 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 F0A72C00140 for ; Mon, 15 Aug 2022 18:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 358A28D0005; Mon, 15 Aug 2022 14:56:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30D6B8D0001; Mon, 15 Aug 2022 14:56:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1352C8D0005; Mon, 15 Aug 2022 14:56:01 -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 00A148D0001 for ; Mon, 15 Aug 2022 14:56:00 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CC8801A0ECD for ; Mon, 15 Aug 2022 18:56:00 +0000 (UTC) X-FDA: 79802731680.08.32C42FA Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf09.hostedemail.com (Postfix) with ESMTP id 743F71401BA for ; Mon, 15 Aug 2022 18:56:00 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id z19so7137613plb.1 for ; Mon, 15 Aug 2022 11:56:00 -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=YNgoWYCY1lPrjzW0L6uvTUDhqO8Va4cbu+Lukza45Kk=; b=LLqk6nZx0CZaFFAKrYtayFNSQtFEufiNWAnBpPZzb6NuyTnfFHJ50yjihvOX09BnKM S47QhKHOD34cTFOPR6PhaMP7mmdaLrRYSmY3S08Yq78sPmyEiJxae5DQvOOdYruhjV2K VainybYqq60xbvb9Mjvhb2WTFrPUhyaHxn2OUAWwknzK883JGnUdbEkTFKzA/VFk6DlK U8j6FtQ9cjPFpqQ5YnVDfhVJc2COUwxSydLt+v/jUsytUL1hfqyDMVpnBKcHVytFmRqk lLrXpBUiei5hCA+Dw8+0AgZvhFxuDhaZTjwgI8a7Iu6XaMONbkJrwlTwh1AJurWNAhXM TeLQ== 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=YNgoWYCY1lPrjzW0L6uvTUDhqO8Va4cbu+Lukza45Kk=; b=t++5sFDj3v9p3cmcfv/XFBc51l4HXJTb9zHDhL2eN8ilrCR76yKOCL+wrv/u3p0+VF eulZjyBT0KcxBkO4+GbI7CDpxyR2TIdphEObpScjqRNAvPWWuffqQH/390YZPYwnd7qb Uy2wCTnnTNP+VT/+YUdB99ByCJp7lu8q50mx0PA2BzOMvW6GgZ5hNeE9vUA5i17SnIUv WhCIx/bRB4axS0NKlIB86eyITv2E4YMmUltdtpTQN7/G7RAc8Vw/3X+EvQq14ZrXBQz7 AxY2sszrzg4WhX0z+ax/RgcrcOGHi7FfQ3dZ7Iq05aqaZwFn2w8EYsW2bR0+nwehGV/4 6Z1w== X-Gm-Message-State: ACgBeo3Ge7zdETrYU2XNFHdhPv5+Q+poAa4PwjxtipPcwQMzJ3LM1ubE ar7yVPP+pgcQ2vbscJLTkT8= X-Google-Smtp-Source: AA6agR7Ao983jsJzFfh+XdeTEh3h2BJEmqP3wgZdEa6QB7GpFTZxxIDE7k3xHAwvuKwa7uOA/N5Omg== X-Received: by 2002:a17:902:ef81:b0:16d:cd36:7955 with SMTP id iz1-20020a170902ef8100b0016dcd367955mr17848496plb.24.1660589759453; Mon, 15 Aug 2022 11:55:59 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:55:59 -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 2/7] btrfs: Convert __process_pages_contig() to use filemap_get_folios_contig() Date: Mon, 15 Aug 2022 11:54:47 -0700 Message-Id: <20220815185452.37447-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660589760; a=rsa-sha256; cv=none; b=t9VmDd3CZiE3yXExrqS2IPItDr0GJmWYUm9toCfoocn4xRKzeC7g0vxTlQXFRmH5+L4l7a RpZN9f5CXJu/J/jDNheJN355bPA+Ta4GsgERmFRL/AgYgyy5ira+MOvVCtGi4b1Ji/dOus 8errclZl7pdnyb4xOBg3uT98OFioStU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LLqk6nZx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 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=1660589760; 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=YNgoWYCY1lPrjzW0L6uvTUDhqO8Va4cbu+Lukza45Kk=; b=ovXYM2N7lvUNQjSP4mk+apC+kKCtBBQ1mCjf0Mjg7hVjOhGrPWARGzGpmqvKg2qSAdvw0k t4B3ZM0BJl7RGBkU6A5V/6+tai/yhzGLDDksIeaJVuHvXl1Z0gHPxMm7HrFtSSlkxXJ2/u LcezL2umUsPV+5ONgMhmhLdWuggJFI4= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 743F71401BA X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LLqk6nZx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: 31puf8k3q99imbpnaak1jc9h5g735taq X-HE-Tag: 1660589760-702612 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. 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 bfae67c593c5..2c2f0e281014 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1900,9 +1900,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; @@ -1911,16 +1910,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. @@ -1930,23 +1930,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 Mon Aug 15 18:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943968 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 75E01C25B08 for ; Mon, 15 Aug 2022 18:56:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 382DA8D0006; Mon, 15 Aug 2022 14:56:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 332738D0001; Mon, 15 Aug 2022 14:56:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A9B98D0006; Mon, 15 Aug 2022 14:56:02 -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 0D42C8D0001 for ; Mon, 15 Aug 2022 14:56:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E0ACD1A0EFF for ; Mon, 15 Aug 2022 18:56:01 +0000 (UTC) X-FDA: 79802731722.17.085DF0C Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf15.hostedemail.com (Postfix) with ESMTP id 75BA0A01C8 for ; Mon, 15 Aug 2022 18:56:01 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id q7-20020a17090a7a8700b001f300db8677so7529756pjf.5 for ; Mon, 15 Aug 2022 11:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/3WdeuCJ7GOu9Di/kxGE5ZGCTP43O1pORgSps3IpIM0=; b=pzhH71/RORsENTBh74vzN5tqqZUKFr4QVYLeRWr9RocyL7OZKiodwsp21TGAG95MnP dsuAJ49JcqdqnfiQ/krxHAJW/NtnLndMog8nxsvyC2oA20RPu4/6P6mDM4v7uuHosvVH pT5ae4HmStn9CqdvdQtc2KGE6WbjIPCG3FCvuooEIPPs6GLaeOdlD3rRWGmVbQl6FVff Nzqo8PGtzrW7EDcHQrvUe2tpoWaUa6xYETFR7d9fAzFnv7Bbq3TYbrJwUFNVcLqbYKyj NC6RjlEpmZ5pJ/nLcPtKXXEhsDM9I9HkAYhAFnuJgZuL9w1mjMSt+T8E7NreD5qk8oS0 AZrQ== 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=/3WdeuCJ7GOu9Di/kxGE5ZGCTP43O1pORgSps3IpIM0=; b=PkVPWGl/+7GlFq6vVif7ISzzlbkdIeFBS9MfnrL4WWJTGUu1k2OHkYTZA3r/teL/VH 0IR0EPUKWTjvcI9FHiGIR0mbOSVseUTW1XWDEzTEO2FlgZ0yUR8lFxZh5aKwC9M2/sQb DaB4wXnBLjV+V+OC0KBeAexn9djHL16SX0KQld7oOz4kggXfF/VJleefv1nOwq2gfvAE NthODbxaIWxvJoRNMtfpFp39W/UOV4smZ9Zr20U5XBAYsDF/dwv0e88xqx2lESiGM9qx c+qTHLoA4k/wOm6gKISuCEkJShqOF3VhqMUnx2D2XtIGvp6DuznPbnrhIXc4w9Ao98Ds Qc1A== X-Gm-Message-State: ACgBeo0EOWby6mvFfnqUkUSkTHcjsQjD1OiKYJ4CTApmxPUehbVg7QfR HiU48oKLl4XLc3dXXZSr0ms= X-Google-Smtp-Source: AA6agR4ivgKsW1nGK+NgnkoWRxp99CaZs3EHTMf/igrghYYz2Hbi4Z0NHcfQ+u7S31hvnU6vrpxPBQ== X-Received: by 2002:a17:90b:1bcf:b0:1f5:53cf:c01d with SMTP id oa15-20020a17090b1bcf00b001f553cfc01dmr30056226pjb.37.1660589760532; Mon, 15 Aug 2022 11:56:00 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:56:00 -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 3/7] btrfs: Convert end_compressed_writeback() to use filemap_get_folios() Date: Mon, 15 Aug 2022 11:54:48 -0700 Message-Id: <20220815185452.37447-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-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="pzhH71/R"; spf=pass (imf15.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=1660589761; a=rsa-sha256; cv=none; b=6/hdHoxIra0BbdqBvQTs4YtG88GJdCO9B96LsYXU0oOLT5GlNMSePmhM4x4n2KzPgG/D9j sKl0Y5bJysGQMMRgxyXf0VBUScoMkaYdHjieJbskJvJq5JPQBie9ZxSeQ9QA5RPhXJL1s2 HSLEvHUhTqqvqzkYMtoEdXWy6DzDRos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660589761; 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=/3WdeuCJ7GOu9Di/kxGE5ZGCTP43O1pORgSps3IpIM0=; b=oLrxHLKtR3AOElDL/J0/ksPyGooS9c0UEBdquiPI1/0yWnyk3w8xis3+f3ANk09aWvK4v2 CgQfyQusrQcWhbN2BLTScKiKYfu/l2sAbajC8Yu2lQBneqIoAHr1QV2iTVUKR+Ed5o78UO Tev60JTTh1HKZy7zSKYitFfVIi8fzmw= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="pzhH71/R"; spf=pass (imf15.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-Stat-Signature: 3nwdi5fxbrex1q4xkfipzwg9rmotyfh9 X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 75BA0A01C8 X-HE-Tag: 1660589761-888036 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. Signed-off-by: Vishal Moola (Oracle) --- fs/btrfs/compression.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index e84d22c5c6a8..d4ebef60b3ce 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -222,8 +223,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; @@ -231,24 +231,22 @@ 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); + folio_batch_init(&fbatch); + while (index <= end_index) { + ret = filemap_get_folios(inode->i_mapping, &index, end_index, + &fbatch); + if (ret == 0) { - nr_pages -= 1; - index += 1; - continue; + 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 Mon Aug 15 18:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943969 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 14F94C00140 for ; Mon, 15 Aug 2022 18:56:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B1288D0001; Mon, 15 Aug 2022 14:56:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8603B8E0001; Mon, 15 Aug 2022 14:56:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 728AB8D0007; Mon, 15 Aug 2022 14:56:03 -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 5BE888D0001 for ; Mon, 15 Aug 2022 14:56:03 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 39AA6AB6F2 for ; Mon, 15 Aug 2022 18:56:03 +0000 (UTC) X-FDA: 79802731806.07.3E096F4 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf29.hostedemail.com (Postfix) with ESMTP id C0A1E120024 for ; Mon, 15 Aug 2022 18:56:02 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id p18so7112927plr.8 for ; Mon, 15 Aug 2022 11:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=+TETRuQREbWQMsK22eWvupq1sOQwbs1H5QXxZ2DEAgU=; b=f3E/ojiaz0NM63zgkJ6u7+tDQzLKIRRocWMkYaGqPGppzv5A2CRcZ4klgHcqLpTBNO UngXV4EWEHYrgvCn+TOgh3V4yIN6sgOaH9C/2fJz3k8+uUYVbNPlrkVIIFQfMIJMKIOg Zx+3dLSWUqr0a7/Y+/TzyPM78llRWrbfD1OHttkjC8QErSmtqZAWVFzrxI6dRuUcxfZ9 McsQaV5CDmB3AXS4JCgfoDnPbukLWfrjty6MFRUZTI0z/GMVNZHiomZxIDdgiAh3o0lm dAaIbaqHz2liQhdZWWPXXok0hv8bdHGpgBBAGWHIz5lNBWv1Eioqe3n7Vu92977ImC7r 0b5A== 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=+TETRuQREbWQMsK22eWvupq1sOQwbs1H5QXxZ2DEAgU=; b=6vro6z513k6NeRPQijS6LTKFZ+CzVSDdb40pkZ2QEp3OLfsAd0BbBFhN11TF/pSeJt QmFFRlr/wOCc94OE2Jvgyg+chGWCHNM0yl2ibbBqLAesujZ7V9MOtl2APjthZG1CppCP 7wl3aSl9ODiDWRw1l2itZ9png3ORsgUPm7c38SWU/XqsCSMz4+Vurqt/4s62NTm1+EbA /ylUfp6Q9WIvBcP/xZGTuB6E/Ngzwrww/gXX54I1fXk9H9hyAjH67ueb4+H7i19v+2Pd nI4eu861wDUR5FNxKMoJ+7v2jHD1T9xwQhPOOaAk8KJGRl3TSxQ9QSjpfcjVctnZT4JV hfCw== X-Gm-Message-State: ACgBeo2/IcTcS2A7sPAaVJJjz6WO6Zqw5wXyiL5cr9Uk7x30rS2w1ClS sGphR/iOYH2WFE0m1lC2N1oruF2ZkbcEbvwW X-Google-Smtp-Source: AA6agR7CudSG0LqZx+wKC4C1PIGfjK9cuqlus0vYtBkYoxZbg+jdJMDMCTln1TB5lc5Wk4KfUxJMvQ== X-Received: by 2002:a17:90a:317:b0:1f3:8ad:52aa with SMTP id 23-20020a17090a031700b001f308ad52aamr20072887pje.106.1660589761635; Mon, 15 Aug 2022 11:56:01 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:56:01 -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 4/7] btrfs: Convert process_page_range() to use filemap_get_folios_contig() Date: Mon, 15 Aug 2022 11:54:49 -0700 Message-Id: <20220815185452.37447-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660589762; a=rsa-sha256; cv=none; b=zU8OAaaEuq1/MZ85tQtd4tMvgPPueX3pnlm2DDzyJaZIezAGKju6vozm7v2wBkpm2ITvxO sNHlCGtwVreG+lRVUwkTIY+rSaA+aw34fseJkfx/RivdApGHwPvXibj3W7zgdWam16V38b d4yVSjHX65V9dhCuPOAUp43UK4sBwZQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="f3E/ojia"; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 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=1660589762; 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=+TETRuQREbWQMsK22eWvupq1sOQwbs1H5QXxZ2DEAgU=; b=EfAzcpVRlViA7wFp2jCf4mhC1CZoXCyhk0nXSqBRIrxJN++V6vDC0gFA8YI5lb/3V4FBp3 X6VinsZ/CrWP3D0o338qyo4z2NGnUJagvLYe0dHwgGyEYP0Bz/IAw0bbvac8dYL531DtWg zjc0JGrJ6WXQ4liKTDIW63bcpSwdVtM= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="f3E/ojia"; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: 5zr7mggdwo1gshzqzk8644gd9gs7a395 X-Rspamd-Queue-Id: C0A1E120024 X-HE-Tag: 1660589762-156898 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. Signed-off-by: Vishal Moola (Oracle) --- fs/btrfs/subpage.c | 2 +- fs/btrfs/tests/extent-io-tests.c | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c index 6fc2b77ae5c3..9a176af847d7 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..530073868916 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,39 @@ 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 Mon Aug 15 18:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943970 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 6829AC25B08 for ; Mon, 15 Aug 2022 18:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3F8B8E0002; Mon, 15 Aug 2022 14:56:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC82B8E0001; Mon, 15 Aug 2022 14:56:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D42558E0002; Mon, 15 Aug 2022 14:56:04 -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 C3CB48E0001 for ; Mon, 15 Aug 2022 14:56:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9761C40EFB for ; Mon, 15 Aug 2022 18:56:04 +0000 (UTC) X-FDA: 79802731848.06.C594AA4 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf11.hostedemail.com (Postfix) with ESMTP id D150540015 for ; Mon, 15 Aug 2022 18:56:03 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id f28so7353061pfk.1 for ; Mon, 15 Aug 2022 11:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=EVNfKk5ZAzp2gPep1Yofo/UzU1m6EYLq8voCf56STj8=; b=M8IZIk7Jp8250xvZqGSMpvSUeZ3dvuFn3bLOlwIQycHml+YrzlnYk0wuRdVtsm8HzU bvV65mni8k2mo/XT9hYMsHRILCfrChluFWNGS/L4GOgJ3HhjZGjaAydrW7Z+ztq40Egv 3wDl0SMEYJ2Fy/s4RzU0l1aGaYxJMmiBfcHn4FhsVr4s7NJVUw6ov8jHJZrpyd8vArg0 c7Ko09i20UU7E/MjJRaWpiaq4u0vVa0I+rSEomiRhlwa/sFcyD/BE093QgNiriTA2ki7 vz5yVxU4u1BU6qGKeJnATjpNPSjpB+ezcTUrbIiPkqD4tjBgq9e+1Ui3xXrJ+vmpSBN6 LlKg== 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=EVNfKk5ZAzp2gPep1Yofo/UzU1m6EYLq8voCf56STj8=; b=f1gk5B8+iTQ1YHXWjBKZA4iEaJb7vdF+K1GdQAflMf0DVEhODITXLGb3QxqZC4tIRw UHXeAdmwNugNOypqcNgK5hrijIRnLUHczlcc/oExFIaC4oCXQlOTZ91tLO3C8GkQQAff nK3opdi/K753Z2rVAvHo8fMYtxFlY60MhPRR2fYNFvDOPU6EIF6Y2T5hJxfjSfoXMKVJ 0awNb6cnVyELNOWWCqo3z49S8h3Vf/stRa2NE+Ydrc54e6SayMR6FofZK8c5/2v77gx4 79GcDXoAnV0OuL46DVvQIF9ZlM5Ou0HTMK/bJcWgfTk5qOkVXxwIMaT8Jz9h9PQh6Fs8 vDCA== X-Gm-Message-State: ACgBeo29IDVulQw5fmAa51TeTRAVKeoFakFs1Gs4ALCLZeR5ZHAig2Eu trhFvT3Alqu5qM96hJ2b0Jg= X-Google-Smtp-Source: AA6agR5AZjMZG0XiC1/OQks2+/viJeEXuejuN52kw77RNDFEYI4CLvS7tEmJitupYm81daGL/6HH6A== X-Received: by 2002:a63:1342:0:b0:422:5e7a:2a8f with SMTP id 2-20020a631342000000b004225e7a2a8fmr13035811pgt.425.1660589762829; Mon, 15 Aug 2022 11:56:02 -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 x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:56:02 -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 5/7] nilfs2: Convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig() Date: Mon, 15 Aug 2022 11:54:50 -0700 Message-Id: <20220815185452.37447-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-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=1660589764; 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=EVNfKk5ZAzp2gPep1Yofo/UzU1m6EYLq8voCf56STj8=; b=gZ6O30wTc02nIYMrS12vfCYzWNs7rbFaxis/EJ3TatfUfyhOm0quwG+seNBc4eb/dcnq0J kbo45GEcBmguaTWSG0rCpNruRUrDZCX6NP9iIn/4ow983vLCPmy0ToqaC9qHWlPztEi5r+ nxdOAXDB9ZXiuSXkJix0dWsUkYKr7dk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=M8IZIk7J; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660589764; a=rsa-sha256; cv=none; b=mNtrsXj6DKkZo21v5pRgIPd/CBjoWs7Kt1BUaotVPPoSrCJ6f/yLaHpM6Urna1TP10t8uu u7Q+mN6yMJqi4pBK1/LlvUHT32ff157TU+lcRWRnhFyXPgfuffyPVVr+oYvE1KqvC0D8i3 cY5BGDLtA+VxiM3HWI7rEKSjeN9ZWGA= Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=M8IZIk7J; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Stat-Signature: xx81dfukfr45nioybdustwy98u9ii9oz X-Rspamd-Queue-Id: D150540015 X-Rspamd-Server: rspam11 X-HE-Tag: 1660589763-801042 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) Reported-by: kernel test robot Reported-by: kernel test robot --- fs/nilfs2/page.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 3267e96c256c..40cc8eb0bc8e 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -480,13 +480,13 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, sector_t start_blk, sector_t *blkoff) { - unsigned int i; + unsigned int i, nr; 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; @@ -494,27 +494,24 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, 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 = filemap_get_folios_contig(inode->i_mapping, &index, ULONG_MAX, + &fbatch); + if (nr == 0) return length; - if (length > 0 && pvec.pages[0]->index > index) - goto out; - - b = pvec.pages[0]->index << (PAGE_SHIFT - inode->i_blkbits); + b = fbatch.folios[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; - bh = head = page_buffers(page); + bh = head = folio_buffers(folio); do { if (b < start_blk) continue; @@ -532,18 +529,17 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, b += nblocks_in_page; } - unlock_page(page); + folio_unlock(folio); - } while (++i < pagevec_count(&pvec)); + } while (++i < nr); - index = page->index + 1; - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); goto repeat; out_locked: - unlock_page(page); + folio_unlock(folio); out: - pagevec_release(&pvec); + folio_batch_release(&fbatch); return length; } From patchwork Mon Aug 15 18:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943971 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 DCC5BC00140 for ; Mon, 15 Aug 2022 18:56:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2D818E0003; Mon, 15 Aug 2022 14:56:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE3118E0001; Mon, 15 Aug 2022 14:56:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94298E0003; Mon, 15 Aug 2022 14:56:05 -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 ABB588E0001 for ; Mon, 15 Aug 2022 14:56:05 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8DF431A0792 for ; Mon, 15 Aug 2022 18:56:05 +0000 (UTC) X-FDA: 79802731890.05.7840A5E Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 0391D4002A for ; Mon, 15 Aug 2022 18:56:04 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id 130so7312557pfv.13 for ; Mon, 15 Aug 2022 11:56:04 -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=JxYlL9B7PcenLE4u6mpHNMIpwNwBfeAtvgsgZnBC2EQ=; b=Ia1O+/fmqiUDytIZqSmA1V3vSbkX1zepYr8UWJ1xOY+Au2TuQsU1CjaK+zT0PLsmd/ E+O3yzfMaR5NdY5ImhVrdZFqgG8IY6GLyAkAuZAxXNJ7g1frwjv+xObysOMw9ZQj9N38 V4kBxNRZzYBXVht6J1C8aUFPM4q7f2/Mr6FKOhM86huxwwIsCgF7Ec+Fkmx2Imxe112s 8rZyF/n/+Pg4xSWae5jHMVbRnTduCkxC52xGgOOsHGt0tWEXwod/MCwauyzBrtSeu3v4 sUXY2yNRl9HIjovNajfVtO2mLmyLZtZShw82f7ZwxsdOEL4uwXFqQMMX21AafPCChnds jq0w== 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=JxYlL9B7PcenLE4u6mpHNMIpwNwBfeAtvgsgZnBC2EQ=; b=mrgClSluDgH0LWK2E/Qa7T5ttSEIv3fSbo/5i01bdLuSy3qg/LQC1QJXtrBq5MJVpo mt7Cn5Fr9rhAP/e85bVnsQiKDPTJfMdmCRSHEajQsJHV8x6Fq2vmAymjkv4RGdQUseKn FKBbRxqtwz6DTLaiC17z5kFDWoJHjh0367AxXe546+dN2p3M6cCvYsEduX4Co9A8Mh0K 5pBpmYLEqwEOgTiciVNuzOWmzvjArkALvB8EHuZV0qdWLevzjSTxvD7mZaaFFIQr08uf HWslSQYsFbIW/Tbq0g8Dbwwxq3ZVMeR8Xu3HlrpGQ5d/2qr9cG2Hqsy3MYNYeeuMZMVi R10w== X-Gm-Message-State: ACgBeo2Hh3hVHgG3BmeA1TumWXB1EcX8YPYs7Pg94W20caVyluh4BFXJ eTYFAJYhN2NiJtRFaANz+IA= X-Google-Smtp-Source: AA6agR4vgieevqYQjgOv8/gNfqzyTLP+yvvViGRQmf5ckGQ1mKZhtPq+2QJlr6dvquuI43mj/Y/Dug== X-Received: by 2002:a63:d5:0:b0:41a:58f:929e with SMTP id 204-20020a6300d5000000b0041a058f929emr14627963pga.260.1660589764035; Mon, 15 Aug 2022 11:56:04 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:56:03 -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 6/7] ramfs: Convert ramfs_nommu_get_unmapped_area() to use filemap_get_folios_contig() Date: Mon, 15 Aug 2022 11:54:51 -0700 Message-Id: <20220815185452.37447-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660589765; a=rsa-sha256; cv=none; b=v5G6ugSySwnSQm5lnGd4dfpG9Yb4ZNOJwEaWlrnjbD8GwiCOF1HgVFeaNyVaURKjmaXGle CPD5IVM5PwQJZiHduRwh+FeCJ36GUSsmkN7StIAGgniROV4Du/gb1L3UeaDizrsZ1V3twP PaSgjPGlx9BIGNwId8493ScTkpH4hYs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Ia1O+/fm"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.176 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=1660589765; 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=JxYlL9B7PcenLE4u6mpHNMIpwNwBfeAtvgsgZnBC2EQ=; b=h5UCSkB8BOt2L+dR28UvBNfBJH0hRjlEuwGHAmU/U7OYU3a3JxHfiScWN1n78t5DgA4AjM GhCH+wt18F9BEuM/oKIrjVfBkkBDLWy2ShdqySsSunHyu7CUpsAna7EdZV6RyyON5vo436 q61wTZ9lsOB0//TKWt5+Q8BHaT1tcIY= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0391D4002A X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Ia1O+/fm"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: 6exrdq81pp9s3r5dz1qb4n4wr4ptzw83 X-HE-Tag: 1660589764-831672 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..81817f301e17 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, 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 = filemap_get_folios_contig(inode->i_mapping, &pgoff, + ULONG_MAX, &fbatch); + if (!nr) { + 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; 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 Mon Aug 15 18:54:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12943972 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 83D07C25B08 for ; Mon, 15 Aug 2022 18:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AB3D8E0005; Mon, 15 Aug 2022 14:56:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E7C08E0001; Mon, 15 Aug 2022 14:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D447D8E0005; Mon, 15 Aug 2022 14:56:06 -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 B55288E0001 for ; Mon, 15 Aug 2022 14:56:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8BED6C0586 for ; Mon, 15 Aug 2022 18:56:06 +0000 (UTC) X-FDA: 79802731932.30.FCE09D4 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf11.hostedemail.com (Postfix) with ESMTP id 214A340015 for ; Mon, 15 Aug 2022 18:56:05 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id ha11so7689152pjb.2 for ; Mon, 15 Aug 2022 11:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1TWw7ByCFm6NhkDCyy6ya2eZRdPaW0G32WpVpASX5vg=; b=iFemGX/6S2CEM0vc5Q7ZhA97VMtcnCohjPo5wTK/HWHqxK8N8QD+bkVVv0eRbEzJzH HqNnewi3fYbCRLFexc2OOX6LZPISwiwwClyISPUI5KMeUWOZeNZVhgrVNoTh/Ef21AvD inPVaZs72ziOBxRoTzzTlm+NfVEF+4Feqy2/CddIRYZtl8QSJ13XwO818UEDaiCRUVwz nb4QhvVObgxonTmLBTxLoJJ/T2W7q5OkqOs2FzS77LEHAbNCL5hJhBuhcB2oBU5Jz7is ge8YPVEk2wRZ+hVtTUqI862Ct1zgWNCA3b3a8uO8nl7FIulVV3gjzC6wH7UdYYgrFJGP GdQA== 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=1TWw7ByCFm6NhkDCyy6ya2eZRdPaW0G32WpVpASX5vg=; b=KtcjHDcvrO7HLqBSEyvqjL9nbZImI4xas9DhSSqHfbW7HlVj3AWTDJLDGnmDizPBeh 40XcODer8UtdtS+fFuGr1CNYIwuVH3O+DqN/pSsuaEuvGbDB1Nvw/cPAImkz0CmjoVvr BCuDo5q541uzTDabhBl/D5wV5bRb6V0g/3S8CZFN73iUrdjEvTf/bk8pvzA34Coywfi5 sMqv5zwIKfvj/ysO1NpXPsc/Rg1jTA4gwny5+N66CHEFvD4/4EQwrFjUy068jbg2FGLA gW8oAuaNQB7X2neuN0AIUDJCV3xyImxPz22k5MBk0DUi+vEterX+YfqhKFHEhpT6uBPV trIA== X-Gm-Message-State: ACgBeo11NyfuLXtxQp9b+beKvXPRBLR0oHQ7ZMbtNS82L2+S+eNwoO0H pSc0Kto6airvlZGEp/D7MCU= X-Google-Smtp-Source: AA6agR42uHmDMa0ZEOjeCzxe7g2crutPG+O6C4nHn1CNeAL6quQVHCY4QkzHACRNyGQNfrTk58qaWw== X-Received: by 2002:a17:902:cec6:b0:16e:ec03:ff1 with SMTP id d6-20020a170902cec600b0016eec030ff1mr18488768plg.96.1660589765161; Mon, 15 Aug 2022 11:56:05 -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 x190-20020a6231c7000000b0052def2e20dasm6858174pfx.167.2022.08.15.11.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:56:04 -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 7/7] filemap: Remove find_get_pages_contig() Date: Mon, 15 Aug 2022 11:54:52 -0700 Message-Id: <20220815185452.37447-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com> References: <20220815185452.37447-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660589766; a=rsa-sha256; cv=none; b=DMH1/+3j6NlWZzv4UpD34/8mPNSOJ1yTwjkU9cI92/rey9lYTWD46kYOylkMQddfJ6ro/R 7UuEo87qFv8adGy2uoLAKRyDT0VsfE4cz0XbM6d5QOJdEqCeYRzLasAHD0ARr716LbuKLi SI1C58vVJH6mZJ9YasTfbfeDspekLCQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="iFemGX/6"; spf=pass (imf11.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=1660589766; 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=1TWw7ByCFm6NhkDCyy6ya2eZRdPaW0G32WpVpASX5vg=; b=IuixfiqBOlJEzrpW5/YUYW5X7F0cgzJk5UeD3bXg6pPkNk/TZBbxK6qGHeprEp5NNob7hO OHGSYBtSGivewatNUzmQ1zFt5T9mfg31yRuRJ2jW/lvvF2+GowAw0V6ZhkEbHz/zHvSEBT +bnRNQDzBunWy+NeS9+Ca+IwppFF7As= Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="iFemGX/6"; spf=pass (imf11.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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 214A340015 X-Stat-Signature: a7h4p5tgwzihs8ynwdg6sq69wtpwwkop X-Rspam-User: X-HE-Tag: 1660589765-974274 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 8689c32d628b..09de43e36a64 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -720,8 +720,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 3a497e178fde..100f36c9247c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2267,66 +2267,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