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