Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: convert nilfs_add_link() to use a folio

Remove six calls to compound_head() by using the folio API.

Link: https://lkml.kernel.org/r/20231127143036.2425-14-konishi.ryusuke@gmail.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
f59bb60f 6f133c97

+14 -17
+14 -17
fs/nilfs2/dir.c
··· 439 439 unsigned int chunk_size = nilfs_chunk_size(dir); 440 440 unsigned int reclen = NILFS_DIR_REC_LEN(namelen); 441 441 unsigned short rec_len, name_len; 442 - struct page *page = NULL; 442 + struct folio *folio = NULL; 443 443 struct nilfs_dir_entry *de; 444 444 unsigned long npages = dir_pages(dir); 445 445 unsigned long n; 446 - char *kaddr; 447 - unsigned int from, to; 446 + size_t from, to; 448 447 int err; 449 448 450 449 /* 451 450 * We take care of directory expansion in the same loop. 452 - * This code plays outside i_size, so it locks the page 451 + * This code plays outside i_size, so it locks the folio 453 452 * to protect that region. 454 453 */ 455 454 for (n = 0; n <= npages; n++) { 455 + char *kaddr = nilfs_get_folio(dir, n, &folio); 456 456 char *dir_end; 457 457 458 - kaddr = nilfs_get_page(dir, n, &page); 459 - err = PTR_ERR(kaddr); 460 458 if (IS_ERR(kaddr)) 461 - goto out; 462 - lock_page(page); 459 + return PTR_ERR(kaddr); 460 + folio_lock(folio); 463 461 dir_end = kaddr + nilfs_last_byte(dir, n); 464 462 de = (struct nilfs_dir_entry *)kaddr; 465 - kaddr += PAGE_SIZE - reclen; 463 + kaddr += folio_size(folio) - reclen; 466 464 while ((char *)de <= kaddr) { 467 465 if ((char *)de == dir_end) { 468 466 /* We hit i_size */ ··· 487 489 goto got_it; 488 490 de = (struct nilfs_dir_entry *)((char *)de + rec_len); 489 491 } 490 - unlock_page(page); 491 - unmap_and_put_page(page, kaddr); 492 + folio_unlock(folio); 493 + folio_release_kmap(folio, kaddr); 492 494 } 493 495 BUG(); 494 496 return -EINVAL; 495 497 496 498 got_it: 497 - from = offset_in_page(de); 499 + from = offset_in_folio(folio, de); 498 500 to = from + rec_len; 499 - err = nilfs_prepare_chunk(page, from, to); 501 + err = nilfs_prepare_chunk(&folio->page, from, to); 500 502 if (err) 501 503 goto out_unlock; 502 504 if (de->inode) { ··· 511 513 memcpy(de->name, name, namelen); 512 514 de->inode = cpu_to_le64(inode->i_ino); 513 515 nilfs_set_de_type(de, inode); 514 - nilfs_commit_chunk(page, page->mapping, from, to); 516 + nilfs_commit_chunk(&folio->page, folio->mapping, from, to); 515 517 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 516 518 nilfs_mark_inode_dirty(dir); 517 519 /* OFFSET_CACHE */ 518 520 out_put: 519 - unmap_and_put_page(page, de); 520 - out: 521 + folio_release_kmap(folio, de); 521 522 return err; 522 523 out_unlock: 523 - unlock_page(page); 524 + folio_unlock(folio); 524 525 goto out_put; 525 526 } 526 527