@@ -209,17 +209,6 @@ static void *ext2_get_folio(struct inode *dir, unsigned long n,
209
209
return ERR_PTR (- EIO );
210
210
}
211
211
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
-
223
212
/*
224
213
* NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure.
225
214
*
@@ -342,38 +331,35 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
342
331
* and the entry itself. Page is returned mapped and unlocked.
343
332
* Entry is guaranteed to be valid.
344
333
*
345
- * On Success ext2_put_page () should be called on *res_page .
334
+ * On Success folio_release_kmap () should be called on *foliop .
346
335
*
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().
349
338
*
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.
352
342
*/
353
343
struct 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 )
355
345
{
356
346
const char * name = child -> name ;
357
347
int namelen = child -> len ;
358
348
unsigned reclen = EXT2_DIR_REC_LEN (namelen );
359
349
unsigned long start , n ;
360
350
unsigned long npages = dir_pages (dir );
361
- struct page * page = NULL ;
362
351
struct ext2_inode_info * ei = EXT2_I (dir );
363
352
ext2_dirent * de ;
364
353
365
354
if (npages == 0 )
366
355
goto out ;
367
356
368
- /* OFFSET_CACHE */
369
- * res_page = NULL ;
370
-
371
357
start = ei -> i_dir_start_lookup ;
372
358
if (start >= npages )
373
359
start = 0 ;
374
360
n = start ;
375
361
do {
376
- char * kaddr = ext2_get_page (dir , n , 0 , & page );
362
+ char * kaddr = ext2_get_folio (dir , n , 0 , foliop );
377
363
if (IS_ERR (kaddr ))
378
364
return ERR_CAST (kaddr );
379
365
@@ -383,18 +369,18 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
383
369
if (de -> rec_len == 0 ) {
384
370
ext2_error (dir -> i_sb , __func__ ,
385
371
"zero-length directory entry" );
386
- ext2_put_page ( page , de );
372
+ folio_release_kmap ( * foliop , de );
387
373
goto out ;
388
374
}
389
375
if (ext2_match (namelen , name , de ))
390
376
goto found ;
391
377
de = ext2_next_entry (de );
392
378
}
393
- ext2_put_page ( page , kaddr );
379
+ folio_release_kmap ( * foliop , kaddr );
394
380
395
381
if (++ n >= npages )
396
382
n = 0 ;
397
- /* next page is past the blocks we've got */
383
+ /* next folio is past the blocks we've got */
398
384
if (unlikely (n > (dir -> i_blocks >> (PAGE_SHIFT - 9 )))) {
399
385
ext2_error (dir -> i_sb , __func__ ,
400
386
"dir %lu size %lld exceeds block count %llu" ,
@@ -407,7 +393,6 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
407
393
return ERR_PTR (- ENOENT );
408
394
409
395
found :
410
- * res_page = page ;
411
396
ei -> i_dir_start_lookup = n ;
412
397
return de ;
413
398
}
@@ -416,17 +401,18 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
416
401
* Return the '..' directory entry and the page in which the entry was found
417
402
* (as a parameter - p).
418
403
*
419
- * On Success ext2_put_page () should be called on *p .
404
+ * On Success folio_release_kmap () should be called on *foliop .
420
405
*
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().
423
408
*
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.
426
412
*/
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 )
428
414
{
429
- ext2_dirent * de = ext2_get_page (dir , 0 , 0 , p );
415
+ ext2_dirent * de = ext2_get_folio (dir , 0 , 0 , foliop );
430
416
431
417
if (!IS_ERR (de ))
432
418
return ext2_next_entry (de );
@@ -436,14 +422,14 @@ struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p)
436
422
int ext2_inode_by_name (struct inode * dir , const struct qstr * child , ino_t * ino )
437
423
{
438
424
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 );
442
428
if (IS_ERR (de ))
443
429
return PTR_ERR (de );
444
430
445
431
* ino = le32_to_cpu (de -> inode );
446
- ext2_put_page ( page , de );
432
+ folio_release_kmap ( folio , de );
447
433
return 0 ;
448
434
}
449
435
@@ -464,21 +450,21 @@ static int ext2_handle_dirsync(struct inode *dir)
464
450
}
465
451
466
452
int 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 )
468
454
{
469
- loff_t pos = page_offset ( page ) + offset_in_page ( de );
455
+ loff_t pos = folio_pos ( folio ) + offset_in_folio ( folio , de );
470
456
unsigned len = ext2_rec_len_from_disk (de -> rec_len );
471
457
int err ;
472
458
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 );
475
461
if (err ) {
476
- unlock_page ( page );
462
+ folio_unlock ( folio );
477
463
return err ;
478
464
}
479
465
de -> inode = cpu_to_le32 (inode -> i_ino );
480
466
ext2_set_de_type (de , inode );
481
- ext2_commit_chunk (page , pos , len );
467
+ ext2_commit_chunk (& folio -> page , pos , len );
482
468
if (update_times )
483
469
dir -> i_mtime = inode_set_ctime_current (dir );
484
470
EXT2_I (dir )-> i_flags &= ~EXT2_BTREE_FL ;
@@ -584,9 +570,8 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
584
570
* ext2_delete_entry deletes a directory entry by merging it with the
585
571
* previous entry. Page is up-to-date.
586
572
*/
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 )
588
574
{
589
- struct folio * folio = page_folio (page );
590
575
struct inode * inode = folio -> mapping -> host ;
591
576
size_t from , to ;
592
577
char * kaddr ;
0 commit comments