Skip to content

Commit 52df49e

Browse files
Matthew Wilcox (Oracle)jankara
authored andcommitted
ext2: Add ext2_get_folio()
Convert ext2_get_page() into ext2_get_folio() and keep the original function around as a temporary wrapper. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent 46f84a9 commit 52df49e

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

fs/ext2/dir.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,34 +180,46 @@ static bool ext2_check_folio(struct folio *folio, int quiet, char *kaddr)
180180
}
181181

182182
/*
183-
* Calls to ext2_get_page()/ext2_put_page() must be nested according to the
184-
* rules documented in kmap_local_page()/kunmap_local().
183+
* Calls to ext2_get_folio()/folio_release_kmap() must be nested according
184+
* to the rules documented in kmap_local_folio()/kunmap_local().
185185
*
186-
* NOTE: ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page()
187-
* and should be treated as a call to ext2_get_page() for nesting purposes.
186+
* NOTE: ext2_find_entry() and ext2_dotdot() act as a call
187+
* to folio_release_kmap() and should be treated as a call to
188+
* folio_release_kmap() for nesting purposes.
188189
*/
189-
static void *ext2_get_page(struct inode *dir, unsigned long n,
190-
int quiet, struct page **page)
190+
static void *ext2_get_folio(struct inode *dir, unsigned long n,
191+
int quiet, struct folio **foliop)
191192
{
192193
struct address_space *mapping = dir->i_mapping;
193194
struct folio *folio = read_mapping_folio(mapping, n, NULL);
194-
void *page_addr;
195+
void *kaddr;
195196

196197
if (IS_ERR(folio))
197198
return ERR_CAST(folio);
198-
page_addr = kmap_local_folio(folio, 0);
199+
kaddr = kmap_local_folio(folio, 0);
199200
if (unlikely(!folio_test_checked(folio))) {
200-
if (!ext2_check_folio(folio, quiet, page_addr))
201+
if (!ext2_check_folio(folio, quiet, kaddr))
201202
goto fail;
202203
}
203-
*page = &folio->page;
204-
return page_addr;
204+
*foliop = folio;
205+
return kaddr;
205206

206207
fail:
207-
ext2_put_page(&folio->page, page_addr);
208+
folio_release_kmap(folio, kaddr);
208209
return ERR_PTR(-EIO);
209210
}
210211

212+
static void *ext2_get_page(struct inode *dir, unsigned long n,
213+
int quiet, struct page **pagep)
214+
{
215+
struct folio *folio;
216+
void *kaddr = ext2_get_folio(dir, n, quiet, &folio);
217+
218+
if (!IS_ERR(kaddr))
219+
*pagep = &folio->page;
220+
return kaddr;
221+
}
222+
211223
/*
212224
* NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure.
213225
*

0 commit comments

Comments
 (0)