From patchwork Tue Aug 16 17:52:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945135 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 1F9E1C2BB41 for ; Tue, 16 Aug 2022 17:53:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D24B8D0003; Tue, 16 Aug 2022 13:53:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5820D8D0001; Tue, 16 Aug 2022 13:53:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 449498D0003; Tue, 16 Aug 2022 13:53:24 -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 375F98D0001 for ; Tue, 16 Aug 2022 13:53:24 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 078DB4139F for ; Tue, 16 Aug 2022 17:53:24 +0000 (UTC) X-FDA: 79806202728.24.3F72884 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf16.hostedemail.com (Postfix) with ESMTP id 9310F180024 for ; Tue, 16 Aug 2022 17:53:23 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id 24so9887532pgr.7 for ; Tue, 16 Aug 2022 10:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=roEOVbMBkZrS+KI85Bv7B/f0yshSydvUYCZY5utraVI=; b=ActwK8Jt7K27jbZ1SDooaQBHFc3mnygMHje2PjXbo9ZNsrwCXn6G0xUASvSNkzD+0y AyrgUxkLsem6YNeJWCOpIkU9+FKbKit2PtMC1X7yLU2njQc5/9LmJY0jRsWpZys5v+64 QChiPuqoPa2KA/eNJN1WLHS9y/DWnByD1K5nUAMlLlh5aLH36skgBCbSvl8ULnW0DHRY JUVCK/1kL+F2ub7VBdWH+Eb9bmID7kmFepbMBG9fkMqxZ3UAokQBCSPCZ0FbI3GfgZq9 5BM0nLr4PP5Mm7iTE2zCy82fW9yhHLip/dCtTDvVrFIg0otieB7a8guaOQT3WQnSYtD9 abSA== 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=5xjYbfh6GRUcGzlNHmsoEKeTvZiKDPDl2dyqXYrEJRIywAqEa4OyYPlFTKdZvNRBmI TzaxvzuFxoj3+JAyKdkTcPCaxhTqbkrtQls/NbW4R5s0TgJS10lNjhNBNMfk8BWZC9r3 ajkhinwRdNtQIV+/5DtiXPEZb+PmprP3SAdCJwBwWYTvAXRuImIh9EHb7YmvWLp68CJ4 0hn2XMDi5U1NFY3ZUJQV7WibJaqn7W/ZHDoJZfsz6SXN2yS6uNvhkFOnwxRmHA2rc32W ko0fcjycLvj8Dr7ZpJ1kBTZXbDv0dt3+j6CDpXQhkukzfMi3d9WRSoy4UvwQ+vMwefzU MPEw== X-Gm-Message-State: ACgBeo2CzNKANdE32w+C23sjsZvBDIyNSSL8NWn0A7Uenovp/QFyfd5t gewyogdz3z/vPHVjyzmKraA50xIx6fD0FNqr X-Google-Smtp-Source: AA6agR6yFUT1jJHdNPbYH3EPp/bBZozQNeNVWrwD0KmtCBeHjs9sgp2lRPVNSFhHowmEeaH5rPDg7Q== X-Received: by 2002:a63:d55:0:b0:41c:86b0:59b5 with SMTP id 21-20020a630d55000000b0041c86b059b5mr18810471pgn.351.1660672402576; Tue, 16 Aug 2022 10:53:22 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:22 -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 v2 1/7] filemap: Add filemap_get_folios_contig() Date: Tue, 16 Aug 2022 10:52:40 -0700 Message-Id: <20220816175246.42401-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672403; a=rsa-sha256; cv=none; b=bikbMcdPbb+EQCfsPkBHaTlx6FsU0Hkt67jWcP29RFfENZZgb79/7fPL6lTKUo+y0ohPdI iFCzFNnDmCG1h4XXew3VqVz/ihUyHNVNm4AFod/S+buakWelxjlDQCxhczMGLLaeQQPUod nt6O/uY04y26qXHqUIo9rGuiXTup0Qc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ActwK8Jt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.169 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=1660672403; 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=sHJ/36ddORc8p48Gx2GhEyAvcJk/xV8Sd1bzXrKXxpUukQ1XOg/7Z5kji/E+dJcOXHXjf8 ME/LChxqNAET3MUhpsR7YHguKQdLPIbXAOAmNST6Ka2xPFOHEiiUeM9atakJ+TvtJf6/1p NulJ98owQQZisTbg1AXi6BWmDh3SuR4= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9310F180024 X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ActwK8Jt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: mz86qkygwbwsdek377fr18m5zg96owro X-HE-Tag: 1660672403-71504 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 Tue Aug 16 17:52:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945136 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 2FC53C32773 for ; Tue, 16 Aug 2022 17:53:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC478D0005; Tue, 16 Aug 2022 13:53:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9BD78D0001; Tue, 16 Aug 2022 13:53:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EEA68D0005; Tue, 16 Aug 2022 13:53:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 925908D0001 for ; Tue, 16 Aug 2022 13:53:26 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 56A95141311 for ; Tue, 16 Aug 2022 17:53:26 +0000 (UTC) X-FDA: 79806202812.22.03DC700 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf14.hostedemail.com (Postfix) with ESMTP id E74B51001BB for ; Tue, 16 Aug 2022 17:53:25 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id z187so9954677pfb.12 for ; Tue, 16 Aug 2022 10:53:25 -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=jx5etBacOfgeXw8OAxR7RH5xH7gasMcsy/7VBjftCKo=; b=H4w5e03AG8w22x3dkX4OcAQ/fXJPEqBuxomQqu935pHvx9qnv6UXB89C7TehiRczmJ +FQpqijjHerlPV7QgbLD9Svk01RL23Cq8zB1agtQdTKICezXQlLztKbYqQG1U9PrYB3F zyWqZ6RrPzRD3dLiMvI5ykjFnKfybBoCI8pBmmEXw98ZnWN2weK8bBLgA5U9I2Z+eIUM QKiR22gp7i+ANjq/+XdN02Ns7oj11Mwz8KxmhJOAHV0Heca0OEqx2IZI7t82b/W2MAFn 2iMRbdUPNsHr/ID8+Wt6iBOyBWHr7BuWOnifm62JTx2pKAaCJskWB35TDHj4rVoHTHoq ts3Q== 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=jx5etBacOfgeXw8OAxR7RH5xH7gasMcsy/7VBjftCKo=; b=ceuGpyl4D/pg8iRCEk6pHT4KGtEOdA78wSRh2Yudj2zpIzIeauqXvLpS2xlprNTjGL xIQczaVzn8Qt3vMYTKewLrgDMw0K1OawdzLGXQg4Nb1vDM8tMeioFAc2aHjgoc5wT4lP LT0ypbokrxuAR2pTsRklZp+dCAYjpvnS5tkVME/cPNRDgffbwohJNyRfvh0oXlyf9iV6 Ls5rSRAK5wCTVqrNjUZfxJ3O7BvmMeOMAt2i6Ai+Tt1eYco4FqXuwgjd6cpbvIbJWspI +2wFyn/jR8C3IrHgk6zQEoe1liZrPghSQRDKJcR6jSqKn0ukGTMmIf+Gu6+Ny10e7dRH yzVQ== X-Gm-Message-State: ACgBeo3VISyNEFzDkreL+Tfi/XcN+MvBVtBJSh6rRk34B+3gRZ6MEQax 7iCzRIBD0i7h3wdIcNQNIE8= X-Google-Smtp-Source: AA6agR6fqGrcGUuroXDXIutzhUk7sX/MVDFC98kOSRnE68zQD+oXaXUzXcwPc80r4Tb7267OZ3uaaw== X-Received: by 2002:a65:5382:0:b0:41c:7021:6fe9 with SMTP id x2-20020a655382000000b0041c70216fe9mr19185825pgq.191.1660672404947; Tue, 16 Aug 2022 10:53:24 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:24 -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 v2 2/7] btrfs: Convert __process_pages_contig() to use filemap_get_folios_contig() Date: Tue, 16 Aug 2022 10:52:41 -0700 Message-Id: <20220816175246.42401-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672406; a=rsa-sha256; cv=none; b=rQdofCEUtfFRThqa+BqG+SCAjA064+Slqs9unAsc25qe49acYvh86VkWrwu6x54hUM5ata Toy+3hEk3S2ljL/tHjfU7i2NCHM4KDCzzotMW+5tS8CkmuX9sQIClStTVqjMEzdpgPq1yQ lMkXZsiDHin4Y0H5L745RR8t+/WhDFg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H4w5e03A; spf=pass (imf14.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 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=1660672406; 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=jx5etBacOfgeXw8OAxR7RH5xH7gasMcsy/7VBjftCKo=; b=JxJeGRfk0J+bfqnuidInCwgqH/By2EP1sCOYLtY/ddu5BAotmIl3dPKB1XKmoDkFkmLZz9 3WEbfO8HPTJFfW/qdiYv0LEC9xN7HvQdLQNg01Ev5uydmy1FeNrCru9z1z50i36nMwfpiS sElGXRh5Q+9j5oHN1JDtP4zLxMb49aI= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H4w5e03A; spf=pass (imf14.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: n9thbqxum6hype61kyi6xtdzrongenfu X-Rspamd-Queue-Id: E74B51001BB X-Rspamd-Server: rspam06 X-HE-Tag: 1660672405-561774 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) Acked-by: David Sterba --- 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 Tue Aug 16 17:52:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945137 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 19732C2BB41 for ; Tue, 16 Aug 2022 17:53:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BB778D0006; Tue, 16 Aug 2022 13:53:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66BE98D0001; Tue, 16 Aug 2022 13:53:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 533AF8D0006; Tue, 16 Aug 2022 13:53:29 -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 4512E8D0001 for ; Tue, 16 Aug 2022 13:53:29 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0C5CB8139C for ; Tue, 16 Aug 2022 17:53:29 +0000 (UTC) X-FDA: 79806202938.01.02BBC1C Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf13.hostedemail.com (Postfix) with ESMTP id A420B201CF for ; Tue, 16 Aug 2022 17:53:28 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id d20so9962761pfq.5 for ; Tue, 16 Aug 2022 10:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=seovf7hiIocC7KrgUovFX1N/tGF31/3t5G8CMyD0zNk=; b=A0QG8rMJwgPAuWRxPlxnmh0emyQWQHjQkk9hr6ZxAF1b/UlBzE2vwG6yDS6Onat/T1 nRdTln1m+yYp5YakV3snbMptSKhwuNZzSDdp+NESr/ni9xiSwgMDPWEEifb5m0ZosUSV 9sHCH+S1LknyJ/6Tl+mQPkMXI351gqUZSkqiEPyrq0vLFwuzTIVb8cRw4rdotfCRibYp RnT8Uco4OInEnU/NOs8Bxepr+KJ5ngBTyRUVkb2BB3TNyBoiNHJ22I2XvB3SLeWnaXDA Tp3f6UUxkmtH/JSg8yZtpECHMchQJlJVuq9dRAuUXMqoOgIXk5bosl31og54wQVNkTFS l2UA== 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=seovf7hiIocC7KrgUovFX1N/tGF31/3t5G8CMyD0zNk=; b=ZlknJkys7pca859xh+YHmKlaRFJrgzT1VgWAbT7XQJPNlmwQjVEiEO+nIskMUPV3Fg 4F0eOOF2S7IhG8olHwyBBFORYTFimPOfX61L4YJ3csEQOJpYek0pTsqPIAtssFR94SDx tgvXVYc/Cuksk4kJVEIBwmstZCj8i9diBBis9iD3SR8e5zVBoO+tvo9qHDRIOHM2JB8/ yN1fVkl1pnCIBOl69m4OjvvRpNkveRgOmEhcnVZUBO9ySba1By3ucwi00QQTQYdLR5ug levRbWL0XSOnIWdHQEjre7MWfvCBQd5PPH8Ni0NzP8Na9mZiv1KPZLW8pNhoPbCfeUg7 HpwQ== X-Gm-Message-State: ACgBeo3dfCOImN5gYQp/z500E0WkJozaisvjC9mchlyLROcwQm40Ic6o lInHn3EUg1TfSRDm1S29tN8= X-Google-Smtp-Source: AA6agR5OMPr2DofSZD/3VZBz9h2pJym/U+Ew2vFlF94lnjZe3JsI+ZihdlS1+zjNBbNg0ylOVu34Fg== X-Received: by 2002:a63:88c7:0:b0:429:a566:e534 with SMTP id l190-20020a6388c7000000b00429a566e534mr3304481pgd.517.1660672407707; Tue, 16 Aug 2022 10:53:27 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:27 -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 v2 3/7] btrfs: Convert end_compressed_writeback() to use filemap_get_folios() Date: Tue, 16 Aug 2022 10:52:42 -0700 Message-Id: <20220816175246.42401-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672408; a=rsa-sha256; cv=none; b=6VPR70uzxHzhCnPGvB0VJgcBuFUvsUdwFzfW9DMk4JBsQviCdnRcvkmgEasmvaPLg2dqF6 Fjo1RgkIESsozmlaxIeU+9BCTg0aCOPHN7/Q+po11Ea7Wgdma1BcGmGCYHNMHIsJDJeuEn 8va87jNgW9+GRGSBDJFxXidD5qrU1oQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A0QG8rMJ; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.175 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=1660672408; 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=seovf7hiIocC7KrgUovFX1N/tGF31/3t5G8CMyD0zNk=; b=5fMY2P3ovzv2o4oXVNYMcV8uoy+PlG2/+BKPM0QkAfP23uV85KbG7UIvh9AMhjbIgynbtx wnZi0ti8Ys3TZ08Tc+mm+Zy1KEeAlcR0oPzA/fejajLQqnje1B/4VkP1JRypfA8z2I0bAM OOSX508zu6iC1nNlLtyCtaDp840a11c= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A0QG8rMJ; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: msib85ptuto3kn866bjkndnuknrk1aeu X-Rspamd-Queue-Id: A420B201CF X-Rspamd-Server: rspam06 X-HE-Tag: 1660672408-258889 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) Acked-by: David Sterba --- 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 f4564f32f6d9..3dcd5006cfb4 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,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 Tue Aug 16 17:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945138 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 6696FC2BB41 for ; Tue, 16 Aug 2022 17:53:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07BEE8D0001; Tue, 16 Aug 2022 13:53:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00503940007; Tue, 16 Aug 2022 13:53:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0D7B8D0007; Tue, 16 Aug 2022 13:53:31 -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 D43118D0001 for ; Tue, 16 Aug 2022 13:53:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AFD97A0FAE for ; Tue, 16 Aug 2022 17:53:31 +0000 (UTC) X-FDA: 79806203022.01.334F83D Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf17.hostedemail.com (Postfix) with ESMTP id 51BD4401C7 for ; Tue, 16 Aug 2022 17:53:31 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id w11-20020a17090a380b00b001f73f75a1feso18088461pjb.2 for ; Tue, 16 Aug 2022 10:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=zEWA5Mz5qgiKRAyUDs57laoSTQi4JTinbk89K1VeDTg=; b=Q0jTOXo0r8co2kNY7avhSUyp1min9bEFsIm1c2a5izPGeJQJyrPEAdD/n+GuHi8PWd WDStj6ozmxAN2tU8n0OKp1MPPxLW30a+rTvbx7Em+x0pgSFHhDJIWxTzr8OhJrSdE1iQ J/cZAICwfQm78pCbo4YRcdifiMgACJZJJeJfKQ90aQHcbOLTrcfKeLde4inZkvLukGdo fsrPaibUyeZTQcqDwhOMT3JDJ+Niv+a0cdWCMmdyIVFOUoqIraeDZhAU0Lz0n0wHdAni CbdZ22zpnt5sFgJAo2zIgwtwYFfiaDOqSKqpG+qLfvUloduCa5fc3Mk2m1FjVMPb80Bj gjBQ== 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=zEWA5Mz5qgiKRAyUDs57laoSTQi4JTinbk89K1VeDTg=; b=DkDWIzPcHCvO+ryv34z0pgJ0GLkjk8PCnfsVTVHC1xVSPnk1bhWqf2nzuvSk0oZPCt kUNsNG1gIRBIwpQJ/++BwGEahwZ7LsLSqXCgnoqELpawBe0IrBmBBjKaSMwqXBGGip1I 8HChnuXBh8uHTvLUBlr+bv75/VCo5WdEeWd5VNKKmQRFWmu/zJS1MyjHx/XymSRT1gP1 W4/6CWUELoaryFy97rvgSQmE/lMLbUEFu+FlUvMb4gvatJPCr0U7vXo1T6nM68wDpqcs uVhbgrtFtcoxKhkX5S+DGG7h0VLEmoTuAaroHSGQNRmWmlCY/Su27VB2s3IfDm3fqo7z qa+A== X-Gm-Message-State: ACgBeo3y7ttp3wxawATVwefngbrmO58IVN2+YnWDBWAX7J4PRGEM0BBg U7wjSzndKx1ZgRzK6SGyGngbLf6VlrtIfU5g X-Google-Smtp-Source: AA6agR61JnV3Crbh6hYVNBysj3mGvmoS9RGt6Gp3A5bI59WrLZeu7LtBj/cszoS3ATgEqLUhuvnKbQ== X-Received: by 2002:a17:903:494:b0:172:9823:e355 with SMTP id jj20-20020a170903049400b001729823e355mr28574plb.75.1660672410347; Tue, 16 Aug 2022 10:53:30 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:29 -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 v2 4/7] btrfs: Convert process_page_range() to use filemap_get_folios_contig() Date: Tue, 16 Aug 2022 10:52:43 -0700 Message-Id: <20220816175246.42401-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672411; a=rsa-sha256; cv=none; b=adR8COUv+7b9yN5fGnJjotcnX/2qqzmrHr9Y7H8U5txE9S1GvGDZS+veQCejNp8amH36e6 LlSWbsO4wcDsYMQ1q5wu3V293wKBR8qGveljK3u0PtuvIY7ZRgo2mopl5JYLl4WwXyMNHJ MqeP4OZILTIDVwWNsTyrlcgB7bTrDyY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q0jTOXo0; spf=pass (imf17.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=1660672411; 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=zEWA5Mz5qgiKRAyUDs57laoSTQi4JTinbk89K1VeDTg=; b=pEKHR49cDzw9C9m4jlcvW5mAolQw3CSFYJTmF1ULjyhb6ojwtsbLglG4tcgyiUvgw82kZ3 yzw2aMiXFSKDZ7rJj3tmRziihoigUkcpMj22wpbaN9/2gfG+WNjIAhyOMseijApryCFovH cjvZ7xruJX8yik8oE7jHulrreSsBOK0= Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q0jTOXo0; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: dqzzghu1mrnju9qix8rcppj1q1k94mpn X-Rspamd-Queue-Id: 51BD4401C7 X-Rspamd-Server: rspam06 X-HE-Tag: 1660672411-925874 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) Acked-by: David Sterba --- 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 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..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 Tue Aug 16 17:52:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945139 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 8F5F0C25B0E for ; Tue, 16 Aug 2022 17:53:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C49E940008; Tue, 16 Aug 2022 13:53:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27448940007; Tue, 16 Aug 2022 13:53:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11552940008; Tue, 16 Aug 2022 13:53:34 -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 02803940007 for ; Tue, 16 Aug 2022 13:53:34 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D6113AAE0E for ; Tue, 16 Aug 2022 17:53:33 +0000 (UTC) X-FDA: 79806203106.15.F4E72ED Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf05.hostedemail.com (Postfix) with ESMTP id 64C311001B8 for ; Tue, 16 Aug 2022 17:53:33 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id ch17-20020a17090af41100b001fa74771f61so1939525pjb.0 for ; Tue, 16 Aug 2022 10:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ktZvpNBWMB4uHfnE+rUfz2bXCBfYO0lBC7J3R+2mvIE=; b=Y8K6b0s6QKd7PDmeOTTWB0yaZC7vPIgwGzzFCr33S2koD2Hntvrnq7u4FuXXo/HcZq zOJXP7WABOm0/F8JoOxu3w5O28BiUfityQCQTOu48talUjvZ2uzLwzaLYlBZqfgCpuXb W48GTG76KuSrbXXSXAfZbviUi/yGPkLG2XT/lxnE4MpmaQzUgrUZiCPeXJwZntfFt/oL mkCmUofDKpauaS6XjX85u7K/o4bgJ0p8jxy1t4ohenGfwj881gRdEIXCjZYSV/zNX9J8 43ndegoWjsacmVhWmeqxVCmQ7sY6A0TCms37AMmiyzer/lp6Tv/Shc9FvTA28/UL5C9w dm6Q== 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=ktZvpNBWMB4uHfnE+rUfz2bXCBfYO0lBC7J3R+2mvIE=; b=FzkscCNEb/LANXn0DRzwqqMXX5vWoMpXwmlfpkF7LKYZWC5kw4KcfxhyYNy5N43IZB q0ASqNTSIeXF/dfS7jvc9uLxkCv+qfVbo+cIRMaD9quhaKW5H5IsYdJpukRM1MLeDEFD lOEUzJ/X5YY8MbLue6pkUmVtA/8EJ6I2eNCXZNRcUIYHB8Z8QT9rdGjwCZFLRb7rGev7 vR9O5JyRt1Nc+w9yiHtudqclcKcVL8Kmvnm7CYOALdALszJvPi+2aZbQLy9dAyzF/awk smXFGRfVHbfVjZ4mGRApjossRsnQsCmkzFOwxxRaOBG3gBiNDT2bOhWQyBXpCoiNolEE xRsQ== X-Gm-Message-State: ACgBeo1fKKywMljDMhwkK4rLnDtZpCNwyCnyNCt/90u0qeR1gOPxTYET ZH7SD41pQJN8iK3a+v5aRCbFbs8OUSVpThyg X-Google-Smtp-Source: AA6agR7JEo87hJmoTxC0nH2KSt1ALXhRO8ILO4fFMpA1/D1/pB03kDOtTk9YUU7NeUcbDA1g4yVvyQ== X-Received: by 2002:a17:903:1209:b0:16b:81f6:e952 with SMTP id l9-20020a170903120900b0016b81f6e952mr23805936plh.48.1660672412339; Tue, 16 Aug 2022 10:53:32 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:31 -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 v2 5/7] nilfs2: Convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig() Date: Tue, 16 Aug 2022 10:52:44 -0700 Message-Id: <20220816175246.42401-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672413; a=rsa-sha256; cv=none; b=ACh/Vp18i9xySgqFvpk1JPwucFHdYXDVmNTCJG6bOIHHwETxsw8h+rhNYh01ivF58i4oCH poUT1YE8A3POgQ7eFY+9nL97EkvDucaWR8qUW+IaeJYW0fNYY3c3KWeV6cHjUMz2uIVEqS Mik1VcI+ktjbDJPlMxCqt2j8mscrPRU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y8K6b0s6; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 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=1660672413; 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=ktZvpNBWMB4uHfnE+rUfz2bXCBfYO0lBC7J3R+2mvIE=; b=FwHClwmgItiJVr/DgSx7miiANTAkSEgox2BCeViF5a4mENVIAGXYCAbnDJpNLm4y6ML46G waWXSlJ7adx8BS/u1qZFwu2GwGgV5bqH7FrwdiRqAW/6SSOJdnJZeTaHj2lSoFOLQApO1+ pPUp1Shk6lInQV58YOAAV2iAZD0L6OU= Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y8K6b0s6; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.41 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: s6u4ic8p5984whzh3k88zkpo7pd358io X-Rspamd-Queue-Id: 64C311001B8 X-HE-Tag: 1660672413-56800 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) --- v2: - Fixed a warning regarding a now unused label "out" - Reported-by: kernel test robot --- fs/nilfs2/page.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 3267e96c256c..14629e03d0da 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,16 @@ 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); -out: - pagevec_release(&pvec); + folio_unlock(folio); + folio_batch_release(&fbatch); return length; } From patchwork Tue Aug 16 17:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12945140 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 EA4B7C32772 for ; Tue, 16 Aug 2022 17:53:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CED9940009; Tue, 16 Aug 2022 13:53:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77D55940007; Tue, 16 Aug 2022 13:53:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F751940009; Tue, 16 Aug 2022 13:53:36 -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 52AF9940007 for ; Tue, 16 Aug 2022 13:53:36 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1BA51161433 for ; Tue, 16 Aug 2022 17:53:36 +0000 (UTC) X-FDA: 79806203232.07.CBE4DE0 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf12.hostedemail.com (Postfix) with ESMTP id AFD0F401C4 for ; Tue, 16 Aug 2022 17:53:35 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id x23so9877582pll.7 for ; Tue, 16 Aug 2022 10:53:35 -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=Nq+9QouXGb9OtKzDYs9F8DUKfb+2kMYjnY9YqSGh58CPfgXesRfH7AB/vwHuUCUeTZ tR5fd1Z2FcQIXpTnaS7MCNHzac6DLnCEZwhEMGe6RP3BtPbE1bgUNGTES/uo1EkkwKA4 bBPp/B8YXeI20uy2wEPAWp1LrQxh8Pj1Wjzcw3yEXBHfZmbT9IimlafYhclU6FVRnA27 SrfhSvtNeFiu2pcXT6TLj+fhB1ru65S1RG3ATIcgDiaboBDt96lWqU/L1zom/ilGXrHG BBVjwFombZRkSMnrrilxsNTVOFiXeVHFScQYjkPHdUmeuEUHxcBxW2aJm87IVi5lU+Cu fGFg== 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=ZB+VSeC+EoaiVR+kbHMKlepXkZbc2Mon2Fz9PRHZFbt4RdWpNMiGExiWYodAkIYvO/ oB1rO4vrcYyZ5tjGcLKsdR/mBu4yMtaIFOBd1rnTH+RV7X6dHXbjS1KPtt2voG4szGeW ZpV12SO/ScqGzRQpEbbyH/eFjZtX36PFeotyHaEbUK/SjUMltrBizZQoC2HhUyE4eX9F RIJCfADQJiw8vV4wy8l4TGCCTMgKfvRvV9rms1zzG/qIimoZFYnio4DQUho8Aa/NO04n TeDUaSIvwUAlMPjOqNjlnrIEwM52XoTL+atBendY+aFtPA9jjcAPFIri3MH8w8vxTNil ZxVg== X-Gm-Message-State: ACgBeo0q2c+P5miqXKTzCNVYf3MDADoi4efYWAVsglgg5Q5LiySE1Nlh dDjcvTcfwPd/k/VYos4mhjI= X-Google-Smtp-Source: AA6agR7GQgPWWrx6Fw7vZ0I/Rl7XXKYgeoRPMw6xhsIRQQbrp+ICKcFNCw0+Sn81oTgAiJYNXMIVQA== X-Received: by 2002:a17:902:904b:b0:170:a3e6:9d98 with SMTP id w11-20020a170902904b00b00170a3e69d98mr22779756plz.50.1660672414764; Tue, 16 Aug 2022 10:53:34 -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 mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:33 -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 v2 6/7] ramfs: Convert ramfs_nommu_get_unmapped_area() to use filemap_get_folios_contig() Date: Tue, 16 Aug 2022 10:52:45 -0700 Message-Id: <20220816175246.42401-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660672415; a=rsa-sha256; cv=none; b=yItyezYkm4GjGN0P0UKmJAYqYkWrw6CforBUwPlJwiUWAO9kv1qZuTEcxm3+u/FIKzgmD+ zVKad5wiX7K6KhziBvidZwUA93JK9/B3coi7f3m7szHrA6ueCoq6tB7pzRYNiZYBnWjpcG NZutUk+kRtOhz18d0ExoDevmHaQ3rYI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Nq+9QouX; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660672415; 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=ZGUVVkxgxVVZGhgWROGJoQPeFn3grxd/wfEXR2LlALlJzK+YFZR9F2S7UolH8Ye2q2fx/L oMdzAp18+hIjl6LEU5UPpEEx0jkHh5lFLKl0MVa7GZNhN7aNH6CM5yTJODajnQb65TiT7C ue7O6RUxTRKQiegJmtd/YU1I2sVjYgM= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Nq+9QouX; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: ezspmc6gwemz3n1yj184yz13omh1w3rd X-Rspamd-Queue-Id: AFD0F401C4 X-HE-Tag: 1660672415-50313 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 Tue Aug 16 17:52: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: 12945141 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 9FB5BC25B0E for ; Tue, 16 Aug 2022 17:53:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4239794000A; Tue, 16 Aug 2022 13:53:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D4E5940007; Tue, 16 Aug 2022 13:53:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2749694000A; Tue, 16 Aug 2022 13:53:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 199F4940007 for ; Tue, 16 Aug 2022 13:53:40 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 03A04A1058 for ; Tue, 16 Aug 2022 17:53:39 +0000 (UTC) X-FDA: 79806203400.18.84335CF Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 9512D2004A for ; Tue, 16 Aug 2022 17:53:39 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id p18so9877092plr.8 for ; Tue, 16 Aug 2022 10:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/CfNnOMJk6G65551bZckVmJ3kjJ/k4Yc+qvoAg65GHU=; b=kqIejtorBX4FPW47cUeP/ByJWQrYcj2ywHGo1YwUpKu3wlfgwOtH92PDuSGWsSr0nC SyaGY3GrNkDx25FDJPPQWuoQGGYTz+T/RQ/YGQokcrzuV/lGrTyIu2XsSjU0eLIkyu8R wA915ZmTNXVqBC13s6yt6NusLaeqy3Ri6jn5WxqH9mt0LbtYnY/4Auiks7IDIfTzjAw6 jMkAarr30hWP/fHq03/hXSuZBHRSKOkjOkBqXz12EehkRA4uZ4TqOdDFQ8KUeg7LMgi1 ZeH8HR8m4hK7VBBRkXiakq+KH0S1fV8B96ZdcNh9yDU/3Nn3++VacUTVJveG+6hPMoL5 rVJQ== 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=lP4RZfRyE5a/F3qErBusY/61FkV46G8Q/1BY7QcODJyABd2Cs0KNTRxBFvHdmgh4xt Hjij2swyDFeh/7qvVBlR6HiGl+RDW4yXin6lcjTV1HZzE8FJcZ/U3z5ekGfTeeIoPPsM pejmj3HvBQptvPH79295wY5sRt6axmgpEae4xwjT7Wf7r+qV6hCIX57QK5TlgzF+V0T2 IwG+4o2PXhdrK4wtPg70HYvG8I1N5x9UC9Npb9cKI9HCmbUhhsBQ5wVRRCJ0/DZmdSjV lw+V/agczwN9xM7RxPqyaMytTrx4ZcN4hkVlc3JeadHUAcFEm/Zwfijz+NngeAAdpfSF oiOA== X-Gm-Message-State: ACgBeo0DnC74cestbXC5b1nib4YMDUls0fyJxkC52rOcmY8Ze62CR2SC OXF1wKyasp8W/TLKwKzYOec= X-Google-Smtp-Source: AA6agR6KWskv5w3DSEJDue1RncLYUny5eN3qY42Nd7sluyseRT6JQY3OH6l7hMcINwYDTG2mrRERaw== X-Received: by 2002:a17:903:481:b0:172:715f:69d9 with SMTP id jj1-20020a170903048100b00172715f69d9mr9791577plb.5.1660672418478; Tue, 16 Aug 2022 10:53:38 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id mi4-20020a17090b4b4400b001f52fa1704csm3379963pjb.3.2022.08.16.10.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 10:53:37 -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 v2 7/7] filemap: Remove find_get_pages_contig() Date: Tue, 16 Aug 2022 10:52:46 -0700 Message-Id: <20220816175246.42401-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220816175246.42401-1-vishal.moola@gmail.com> References: <20220816175246.42401-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kqIejtor; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.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=1660672419; a=rsa-sha256; cv=none; b=TT+oXPx7I7e0J5cV647RxPbIckB10dqO66bvkDA6fRZXfV2lY1CjQB1ydqR6wbnvmARIkg roaVGd3kPjz8t2Vwx3knnSgJJepoUqL/Rs+Z/I5JxUgkyFPXyqJSm/O+MwnlHJAvn/6W1B mr4Q7UMqOWl4e61HXdPMs3FFvleVYGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660672419; 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=IOWnBDY25R+fUwfih4h6DNuF3lFfXRbX/3SplguKvwfGleaJuHuc6twPH8Bjzi2qo8xkm8 AJtCj3Fkx4RDFrVKDU0eQWCOqxIA3pGWy+jxJTpwsdQyHG4xnF+Doe6PUjWYjmhROuUb1G MxKrNtxrGIYcga84jOWu5jQ2rCnDIAc= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kqIejtor; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ajranryp3i6x679c4pixahpc9gqkemf9 X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 9512D2004A X-HE-Tag: 1660672419-980316 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