From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 03/10] ufs: Convert ufs_check_page() to ufs_check_folio()
Date: Tue, 9 Jul 2024 04:30:20 +0100 [thread overview]
Message-ID: <20240709033029.1769992-4-willy@infradead.org> (raw)
In-Reply-To: <20240709033029.1769992-1-willy@infradead.org>
Includes large folio support in case we decide to support block size >
PAGE_SIZE (as with ext2, this support will be limited to machines
without HIGHMEM).
---
fs/ufs/dir.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 6c3235f426ed..287cab597cc1 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -112,20 +112,18 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
ufs_handle_dirsync(dir);
}
-
-static bool ufs_check_page(struct page *page)
+static bool ufs_check_folio(struct folio *folio, char *kaddr)
{
- struct inode *dir = page->mapping->host;
+ struct inode *dir = folio->mapping->host;
struct super_block *sb = dir->i_sb;
- char *kaddr = page_address(page);
unsigned offs, rec_len;
- unsigned limit = PAGE_SIZE;
+ unsigned limit = folio_size(folio);
const unsigned chunk_mask = UFS_SB(sb)->s_uspi->s_dirblksize - 1;
struct ufs_dir_entry *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_mask)
goto Ebadsize;
if (!limit)
@@ -150,13 +148,13 @@ static bool ufs_check_page(struct page *page)
if (offs != limit)
goto Eend;
out:
- SetPageChecked(page);
+ folio_set_checked(folio);
return true;
/* Too bad, we had an error */
Ebadsize:
- ufs_error(sb, "ufs_check_page",
+ ufs_error(sb, __func__,
"size of directory #%lu is not a multiple of chunk size",
dir->i_ino
);
@@ -176,17 +174,17 @@ static bool ufs_check_page(struct page *page)
Einumber:
error = "inode out of bounds";
bad_entry:
- ufs_error (sb, "ufs_check_page", "bad entry in directory #%lu: %s - "
- "offset=%lu, rec_len=%d, name_len=%d",
- dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
+ ufs_error(sb, __func__, "bad entry in directory #%lu: %s - "
+ "offset=%llu, rec_len=%d, name_len=%d",
+ dir->i_ino, error, folio_pos(folio) + offs,
rec_len, ufs_get_de_namlen(sb, p));
goto fail;
Eend:
p = (struct ufs_dir_entry *)(kaddr + offs);
ufs_error(sb, __func__,
"entry in directory #%lu spans the page boundary"
- "offset=%lu",
- dir->i_ino, (page->index<<PAGE_SHIFT)+offs);
+ "offset=%llu",
+ dir->i_ino, folio_pos(folio) + offs);
fail:
return false;
}
@@ -202,7 +200,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n,
return ERR_CAST(folio);
kaddr = kmap(&folio->page);
if (unlikely(!folio_test_checked(folio))) {
- if (!ufs_check_page(&folio->page))
+ if (!ufs_check_folio(folio, kaddr))
goto fail;
}
*foliop = folio;
--
2.43.0
next prev parent reply other threads:[~2024-07-09 3:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 3:30 [PATCH 00/10] Convert UFS directory handling to folios Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 01/10] ufs: Convert ufs_get_page() to use a folio Matthew Wilcox (Oracle)
2024-07-16 22:31 ` Al Viro
2024-07-09 3:30 ` [PATCH 02/10] ufs: Convert ufs_get_page() to ufs_get_folio() Matthew Wilcox (Oracle)
2024-07-09 3:30 ` Matthew Wilcox (Oracle) [this message]
2024-07-09 3:30 ` [PATCH 04/10] ufs: Convert ufs_find_entry() to take a folio Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 05/10] ufs: Convert ufs_set_link() and ufss_dotdot() " Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 06/10] ufs: Convert ufs_delete_entry() to work on " Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 07/10] ufs: Convert ufs_make_empty() to use " Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 08/10] ufs: Convert ufs_prepare_chunk() to take " Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 09/10] ufs; Convert ufs_commit_chunk() " Matthew Wilcox (Oracle)
2024-07-09 3:30 ` [PATCH 10/10] ufs: Convert directory handling to kmap_local Matthew Wilcox (Oracle)
2024-07-16 22:46 ` [PATCH 00/10] Convert UFS directory handling to folios Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240709033029.1769992-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).