Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2404582rdb; Thu, 21 Sep 2023 18:59:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHs7Gs2UKbHYdRZ06WJ4GSGEetUSv7scCQ4bdEQy6uzOMs0JjYW14xBfKGD5jX7hUgL67t8 X-Received: by 2002:a05:6358:278c:b0:142:f1d5:ef89 with SMTP id l12-20020a056358278c00b00142f1d5ef89mr7257846rwb.5.1695347977558; Thu, 21 Sep 2023 18:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695347977; cv=none; d=google.com; s=arc-20160816; b=ikf9iK3EeyTDc7LGImoP7ymVYO1baJLq1Ol/NKTV+WkIpiXIyqSHoChyLIEit0YHpq YOGLLl9ewH+Z01TTclfcz+S2cYRXBKm6dzSo1U0QfXIMMx6XBZizJ/3mlUh2ybqGtrRM QodoReHETTxSghoI1TpWse6EEIKFVMwburImqTGQSAWc8P/DACpMuzziBrNw4LIvJ90j JfuFmOJQT1jUuu39Ovf7StKJjAzmgEHowlkOGgTP47Ei2/e3y8SqpcFKL1tPD6m4G7s2 +cTDTpF0kNp7HYE5p5+PxzZOC3sLrYz5I64aQUoY0LfGCJj71EjptdxGxOyhDlL1N9uj fxIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0GrfoVZf4pEwJGUQDfdqNVEVdhrqvsVectxd5IhmpwU=; fh=c8NKFRvP9+Ml9XvzqG2nGqhVxTjW39J/I/tkc5xa6gs=; b=PQhl/Ec0cxFxsvgLCxBKS7EflwK14nZ+fd9DQrvBCi+jKpVouQbHBuM5/XA17UYpJX L/M3bb4vkr7CirYoX0K1bke5BGe+x+bJd0iETgUWrFo7VZJhaVFtVDSSeAfyDSP/tDhO 8nQh4wid26Z82UkcVm6RpMZ4pXNjqvpfa/M7K2q56kQZpIUqFaH2hUZtANSYHv5Li30L 1tOI5WTHELbfnBcYEgILMGLSTmxMZZxdfoWHnT9jInmMr/7H3vtaZI4dHv/MUghfiMkM JnaeneDiFp43NYpfXAkeTqRfUh9AGHoJ0IK7I2P0a1VVepHRT0CUWWmbsyXREH1qi61Y slXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nI1NMFYA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00578d7a3a4fdsi2711138pgk.563.2023.09.21.18.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:59:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nI1NMFYA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4F8BF807E461; Thu, 21 Sep 2023 14:45:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbjIUVpZ (ORCPT + 99 others); Thu, 21 Sep 2023 17:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbjIUVpL (ORCPT ); Thu, 21 Sep 2023 17:45:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A8E53BE38; Thu, 21 Sep 2023 13:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=0GrfoVZf4pEwJGUQDfdqNVEVdhrqvsVectxd5IhmpwU=; b=nI1NMFYATechazb63KL+u20rRS YeznrFpxSZ67lWT686rITU8827ZrJ6jSIveeK10VFV3aEiq/OHvEHdiKOa90yYnVLYIMh0ors8Vj1 iaYH14MAjSv428F6Zk+R03+9jluelLzVeOFD0XZa0879hx/U1alxk/94E90qDime6qBa3pO0dap7u vMNk1TtnN0IUMdH6Ddg9Uob0tqfnoaxBPUSOMYy+1yTpZqw816jwHHcW7sIfe6DEQkgfx/SdebeGH qUCCzeY0zb52Bix+5Ikr4KyzbeLoG0Awx9MrdOURIbkehScFdbY9ahJN6vlCeHHwyXhYn3ts/RARb 1NBubFEA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qjPxj-00DrVi-NS; Thu, 21 Sep 2023 20:07:47 +0000 From: "Matthew Wilcox (Oracle)" To: Jan Kara Cc: "Matthew Wilcox (Oracle)" , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Fabio M . De Francesco" Subject: [PATCH 02/10] ext2: Convert ext2_check_page to ext2_check_folio Date: Thu, 21 Sep 2023 21:07:39 +0100 Message-Id: <20230921200746.3303942-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230921200746.3303942-1-willy@infradead.org> References: <20230921200746.3303942-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:45:28 -0700 (PDT) Support in this function for large folios is limited to supporting filesystems with block size > PAGE_SIZE. This new functionality will only be supported on machines without HIGHMEM, so the problem of kmap_local only being able to map a single page in the folio can be ignored. We will not use large folios for ext2 directories on HIGHMEM machines. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ext2/dir.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index b335f17f682f..03867381eec2 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -96,19 +96,19 @@ static void ext2_commit_chunk(struct page *page, loff_t pos, unsigned len) unlock_page(page); } -static bool ext2_check_page(struct page *page, int quiet, char *kaddr) +static bool ext2_check_folio(struct folio *folio, int quiet, char *kaddr) { - struct inode *dir = page->mapping->host; + struct inode *dir = folio->mapping->host; struct super_block *sb = dir->i_sb; unsigned chunk_size = ext2_chunk_size(dir); u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count); unsigned offs, rec_len; - unsigned limit = PAGE_SIZE; + unsigned limit = folio_size(folio); ext2_dirent *p; char *error; - if ((dir->i_size >> PAGE_SHIFT) == page->index) { - limit = dir->i_size & ~PAGE_MASK; + if (dir->i_size < folio_pos(folio) + limit) { + limit = offset_in_folio(folio, dir->i_size); if (limit & (chunk_size - 1)) goto Ebadsize; if (!limit) @@ -132,7 +132,7 @@ static bool ext2_check_page(struct page *page, int quiet, char *kaddr) if (offs != limit) goto Eend; out: - SetPageChecked(page); + folio_set_checked(folio); return true; /* Too bad, we had an error */ @@ -160,22 +160,22 @@ static bool ext2_check_page(struct page *page, int quiet, char *kaddr) bad_entry: if (!quiet) ext2_error(sb, __func__, "bad entry in directory #%lu: : %s - " - "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<i_ino, error, folio_pos(folio) + offs, (unsigned long) le32_to_cpu(p->inode), rec_len, p->name_len); goto fail; Eend: if (!quiet) { p = (ext2_dirent *)(kaddr + offs); - ext2_error(sb, "ext2_check_page", + ext2_error(sb, "ext2_check_folio", "entry in directory #%lu spans the page boundary" - "offset=%lu, inode=%lu", - dir->i_ino, (page->index<i_ino, folio_pos(folio) + offs, (unsigned long) le32_to_cpu(p->inode)); } fail: - SetPageError(page); + folio_set_error(folio); return false; } @@ -195,9 +195,9 @@ static void *ext2_get_page(struct inode *dir, unsigned long n, if (IS_ERR(folio)) return ERR_CAST(folio); - page_addr = kmap_local_folio(folio, n & (folio_nr_pages(folio) - 1)); + page_addr = kmap_local_folio(folio, 0); if (unlikely(!folio_test_checked(folio))) { - if (!ext2_check_page(&folio->page, quiet, page_addr)) + if (!ext2_check_folio(folio, quiet, page_addr)) goto fail; } *page = &folio->page; -- 2.40.1