@@ -209,17 +209,6 @@ static void *ext2_get_folio(struct inode *dir, unsigned long n,
209209 return ERR_PTR (- EIO );
210210}
211211
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-
223212/*
224213 * NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure.
225214 *
@@ -342,38 +331,35 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
342331 * and the entry itself. Page is returned mapped and unlocked.
343332 * Entry is guaranteed to be valid.
344333 *
345- * On Success ext2_put_page () should be called on *res_page .
334+ * On Success folio_release_kmap () should be called on *foliop .
346335 *
347- * NOTE: Calls to ext2_get_page ()/ext2_put_page () must be nested according to
348- * the rules documented in kmap_local_page ()/kunmap_local().
336+ * NOTE: Calls to ext2_get_folio ()/folio_release_kmap () must be nested
337+ * according to the rules documented in kmap_local_folio ()/kunmap_local().
349338 *
350- * ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page() and
351- * should be treated as a call to ext2_get_page() for nesting purposes.
339+ * ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_folio()
340+ * and should be treated as a call to ext2_get_folio() for nesting
341+ * purposes.
352342 */
353343struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir ,
354- const struct qstr * child , struct page * * res_page )
344+ const struct qstr * child , struct folio * * foliop )
355345{
356346 const char * name = child -> name ;
357347 int namelen = child -> len ;
358348 unsigned reclen = EXT2_DIR_REC_LEN (namelen );
359349 unsigned long start , n ;
360350 unsigned long npages = dir_pages (dir );
361- struct page * page = NULL ;
362351 struct ext2_inode_info * ei = EXT2_I (dir );
363352 ext2_dirent * de ;
364353
365354 if (npages == 0 )
366355 goto out ;
367356
368- /* OFFSET_CACHE */
369- * res_page = NULL ;
370-
371357 start = ei -> i_dir_start_lookup ;
372358 if (start >= npages )
373359 start = 0 ;
374360 n = start ;
375361 do {
376- char * kaddr = ext2_get_page (dir , n , 0 , & page );
362+ char * kaddr = ext2_get_folio (dir , n , 0 , foliop );
377363 if (IS_ERR (kaddr ))
378364 return ERR_CAST (kaddr );
379365
@@ -383,18 +369,18 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
383369 if (de -> rec_len == 0 ) {
384370 ext2_error (dir -> i_sb , __func__ ,
385371 "zero-length directory entry" );
386- ext2_put_page ( page , de );
372+ folio_release_kmap ( * foliop , de );
387373 goto out ;
388374 }
389375 if (ext2_match (namelen , name , de ))
390376 goto found ;
391377 de = ext2_next_entry (de );
392378 }
393- ext2_put_page ( page , kaddr );
379+ folio_release_kmap ( * foliop , kaddr );
394380
395381 if (++ n >= npages )
396382 n = 0 ;
397- /* next page is past the blocks we've got */
383+ /* next folio is past the blocks we've got */
398384 if (unlikely (n > (dir -> i_blocks >> (PAGE_SHIFT - 9 )))) {
399385 ext2_error (dir -> i_sb , __func__ ,
400386 "dir %lu size %lld exceeds block count %llu" ,
@@ -407,7 +393,6 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
407393 return ERR_PTR (- ENOENT );
408394
409395found :
410- * res_page = page ;
411396 ei -> i_dir_start_lookup = n ;
412397 return de ;
413398}
@@ -416,17 +401,18 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
416401 * Return the '..' directory entry and the page in which the entry was found
417402 * (as a parameter - p).
418403 *
419- * On Success ext2_put_page () should be called on *p .
404+ * On Success folio_release_kmap () should be called on *foliop .
420405 *
421- * NOTE: Calls to ext2_get_page ()/ext2_put_page () must be nested according to
422- * the rules documented in kmap_local_page ()/kunmap_local().
406+ * NOTE: Calls to ext2_get_folio ()/folio_release_kmap () must be nested
407+ * according to the rules documented in kmap_local_folio ()/kunmap_local().
423408 *
424- * ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page() and
425- * should be treated as a call to ext2_get_page() for nesting purposes.
409+ * ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_folio()
410+ * and should be treated as a call to ext2_get_folio() for nesting
411+ * purposes.
426412 */
427- struct ext2_dir_entry_2 * ext2_dotdot (struct inode * dir , struct page * * p )
413+ struct ext2_dir_entry_2 * ext2_dotdot (struct inode * dir , struct folio * * foliop )
428414{
429- ext2_dirent * de = ext2_get_page (dir , 0 , 0 , p );
415+ ext2_dirent * de = ext2_get_folio (dir , 0 , 0 , foliop );
430416
431417 if (!IS_ERR (de ))
432418 return ext2_next_entry (de );
@@ -436,14 +422,14 @@ struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p)
436422int ext2_inode_by_name (struct inode * dir , const struct qstr * child , ino_t * ino )
437423{
438424 struct ext2_dir_entry_2 * de ;
439- struct page * page ;
440-
441- de = ext2_find_entry (dir , child , & page );
425+ struct folio * folio ;
426+
427+ de = ext2_find_entry (dir , child , & folio );
442428 if (IS_ERR (de ))
443429 return PTR_ERR (de );
444430
445431 * ino = le32_to_cpu (de -> inode );
446- ext2_put_page ( page , de );
432+ folio_release_kmap ( folio , de );
447433 return 0 ;
448434}
449435
@@ -464,21 +450,21 @@ static int ext2_handle_dirsync(struct inode *dir)
464450}
465451
466452int ext2_set_link (struct inode * dir , struct ext2_dir_entry_2 * de ,
467- struct page * page , struct inode * inode , bool update_times )
453+ struct folio * folio , struct inode * inode , bool update_times )
468454{
469- loff_t pos = page_offset ( page ) + offset_in_page ( de );
455+ loff_t pos = folio_pos ( folio ) + offset_in_folio ( folio , de );
470456 unsigned len = ext2_rec_len_from_disk (de -> rec_len );
471457 int err ;
472458
473- lock_page ( page );
474- err = ext2_prepare_chunk (page , pos , len );
459+ folio_lock ( folio );
460+ err = ext2_prepare_chunk (& folio -> page , pos , len );
475461 if (err ) {
476- unlock_page ( page );
462+ folio_unlock ( folio );
477463 return err ;
478464 }
479465 de -> inode = cpu_to_le32 (inode -> i_ino );
480466 ext2_set_de_type (de , inode );
481- ext2_commit_chunk (page , pos , len );
467+ ext2_commit_chunk (& folio -> page , pos , len );
482468 if (update_times )
483469 dir -> i_mtime = inode_set_ctime_current (dir );
484470 EXT2_I (dir )-> i_flags &= ~EXT2_BTREE_FL ;
@@ -584,9 +570,8 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
584570 * ext2_delete_entry deletes a directory entry by merging it with the
585571 * previous entry. Page is up-to-date.
586572 */
587- int ext2_delete_entry (struct ext2_dir_entry_2 * dir , struct page * page )
573+ int ext2_delete_entry (struct ext2_dir_entry_2 * dir , struct folio * folio )
588574{
589- struct folio * folio = page_folio (page );
590575 struct inode * inode = folio -> mapping -> host ;
591576 size_t from , to ;
592577 char * kaddr ;
0 commit comments