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; }