Skip to content

Commit 46f84a9

Browse files
Matthew Wilcox (Oracle)jankara
authored andcommitted
ext2: Convert ext2_check_page to ext2_check_folio
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) <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent 3de6047 commit 46f84a9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

fs/ext2/dir.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ static void ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
9696
unlock_page(page);
9797
}
9898

99-
static bool ext2_check_page(struct page *page, int quiet, char *kaddr)
99+
static bool ext2_check_folio(struct folio *folio, int quiet, char *kaddr)
100100
{
101-
struct inode *dir = page->mapping->host;
101+
struct inode *dir = folio->mapping->host;
102102
struct super_block *sb = dir->i_sb;
103103
unsigned chunk_size = ext2_chunk_size(dir);
104104
u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count);
105105
unsigned offs, rec_len;
106-
unsigned limit = PAGE_SIZE;
106+
unsigned limit = folio_size(folio);
107107
ext2_dirent *p;
108108
char *error;
109109

110-
if ((dir->i_size >> PAGE_SHIFT) == page->index) {
111-
limit = dir->i_size & ~PAGE_MASK;
110+
if (dir->i_size < folio_pos(folio) + limit) {
111+
limit = offset_in_folio(folio, dir->i_size);
112112
if (limit & (chunk_size - 1))
113113
goto Ebadsize;
114114
if (!limit)
@@ -132,7 +132,7 @@ static bool ext2_check_page(struct page *page, int quiet, char *kaddr)
132132
if (offs != limit)
133133
goto Eend;
134134
out:
135-
SetPageChecked(page);
135+
folio_set_checked(folio);
136136
return true;
137137

138138
/* Too bad, we had an error */
@@ -160,22 +160,22 @@ static bool ext2_check_page(struct page *page, int quiet, char *kaddr)
160160
bad_entry:
161161
if (!quiet)
162162
ext2_error(sb, __func__, "bad entry in directory #%lu: : %s - "
163-
"offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
164-
dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
163+
"offset=%llu, inode=%lu, rec_len=%d, name_len=%d",
164+
dir->i_ino, error, folio_pos(folio) + offs,
165165
(unsigned long) le32_to_cpu(p->inode),
166166
rec_len, p->name_len);
167167
goto fail;
168168
Eend:
169169
if (!quiet) {
170170
p = (ext2_dirent *)(kaddr + offs);
171-
ext2_error(sb, "ext2_check_page",
171+
ext2_error(sb, "ext2_check_folio",
172172
"entry in directory #%lu spans the page boundary"
173-
"offset=%lu, inode=%lu",
174-
dir->i_ino, (page->index<<PAGE_SHIFT)+offs,
173+
"offset=%llu, inode=%lu",
174+
dir->i_ino, folio_pos(folio) + offs,
175175
(unsigned long) le32_to_cpu(p->inode));
176176
}
177177
fail:
178-
SetPageError(page);
178+
folio_set_error(folio);
179179
return false;
180180
}
181181

@@ -195,9 +195,9 @@ static void *ext2_get_page(struct inode *dir, unsigned long n,
195195

196196
if (IS_ERR(folio))
197197
return ERR_CAST(folio);
198-
page_addr = kmap_local_folio(folio, n & (folio_nr_pages(folio) - 1));
198+
page_addr = kmap_local_folio(folio, 0);
199199
if (unlikely(!folio_test_checked(folio))) {
200-
if (!ext2_check_page(&folio->page, quiet, page_addr))
200+
if (!ext2_check_folio(folio, quiet, page_addr))
201201
goto fail;
202202
}
203203
*page = &folio->page;

0 commit comments

Comments
 (0)