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_prepare_chunk() and nilfs_commit_chunk() to folios

All callers now have a folio, so convert these two functions.
Saves one call to compound_head() in unlock_page().

[konishi.ryusuke: resolved conflicts in nilfs_{set_link,delete_entry}]
Link: https://lkml.kernel.org/r/20231127143036.2425-17-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
9bff5f98 0743230f

+19 -20
+19 -20
fs/nilfs2/dir.c
··· 78 78 return last_byte; 79 79 } 80 80 81 - static int nilfs_prepare_chunk(struct page *page, unsigned int from, 81 + static int nilfs_prepare_chunk(struct folio *folio, unsigned int from, 82 82 unsigned int to) 83 83 { 84 - loff_t pos = page_offset(page) + from; 84 + loff_t pos = folio_pos(folio) + from; 85 85 86 - return __block_write_begin(page, pos, to - from, nilfs_get_block); 86 + return __block_write_begin(&folio->page, pos, to - from, nilfs_get_block); 87 87 } 88 88 89 - static void nilfs_commit_chunk(struct page *page, 90 - struct address_space *mapping, 91 - unsigned int from, unsigned int to) 89 + static void nilfs_commit_chunk(struct folio *folio, 90 + struct address_space *mapping, size_t from, size_t to) 92 91 { 93 92 struct inode *dir = mapping->host; 94 - loff_t pos = page_offset(page) + from; 95 - unsigned int len = to - from; 96 - unsigned int nr_dirty, copied; 93 + loff_t pos = folio_pos(folio) + from; 94 + size_t copied, len = to - from; 95 + unsigned int nr_dirty; 97 96 int err; 98 97 99 - nr_dirty = nilfs_page_count_clean_buffers(page, from, to); 100 - copied = block_write_end(NULL, mapping, pos, len, len, page, NULL); 98 + nr_dirty = nilfs_page_count_clean_buffers(&folio->page, from, to); 99 + copied = block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL); 101 100 if (pos + copied > dir->i_size) 102 101 i_size_write(dir, pos + copied); 103 102 if (IS_DIRSYNC(dir)) 104 103 nilfs_set_transaction_flag(NILFS_TI_SYNC); 105 104 err = nilfs_set_file_dirty(dir, nr_dirty); 106 105 WARN_ON(err); /* do not happen */ 107 - unlock_page(page); 106 + folio_unlock(folio); 108 107 } 109 108 110 109 static bool nilfs_check_folio(struct folio *folio, char *kaddr) ··· 408 409 int err; 409 410 410 411 folio_lock(folio); 411 - err = nilfs_prepare_chunk(&folio->page, from, to); 412 + err = nilfs_prepare_chunk(folio, from, to); 412 413 BUG_ON(err); 413 414 de->inode = cpu_to_le64(inode->i_ino); 414 415 nilfs_set_de_type(de, inode); 415 - nilfs_commit_chunk(&folio->page, mapping, from, to); 416 + nilfs_commit_chunk(folio, mapping, from, to); 416 417 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 417 418 } 418 419 ··· 484 485 got_it: 485 486 from = offset_in_folio(folio, de); 486 487 to = from + rec_len; 487 - err = nilfs_prepare_chunk(&folio->page, from, to); 488 + err = nilfs_prepare_chunk(folio, from, to); 488 489 if (err) 489 490 goto out_unlock; 490 491 if (de->inode) { ··· 499 500 memcpy(de->name, name, namelen); 500 501 de->inode = cpu_to_le64(inode->i_ino); 501 502 nilfs_set_de_type(de, inode); 502 - nilfs_commit_chunk(&folio->page, folio->mapping, from, to); 503 + nilfs_commit_chunk(folio, folio->mapping, from, to); 503 504 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 504 505 nilfs_mark_inode_dirty(dir); 505 506 /* OFFSET_CACHE */ ··· 541 542 if (pde) 542 543 from = (char *)pde - kaddr; 543 544 folio_lock(folio); 544 - err = nilfs_prepare_chunk(&folio->page, from, to); 545 + err = nilfs_prepare_chunk(folio, from, to); 545 546 BUG_ON(err); 546 547 if (pde) 547 548 pde->rec_len = nilfs_rec_len_to_disk(to - from); 548 549 dir->inode = 0; 549 - nilfs_commit_chunk(&folio->page, mapping, from, to); 550 + nilfs_commit_chunk(folio, mapping, from, to); 550 551 inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); 551 552 out: 552 553 return err; ··· 567 568 if (IS_ERR(folio)) 568 569 return PTR_ERR(folio); 569 570 570 - err = nilfs_prepare_chunk(&folio->page, 0, chunk_size); 571 + err = nilfs_prepare_chunk(folio, 0, chunk_size); 571 572 if (unlikely(err)) { 572 573 folio_unlock(folio); 573 574 goto fail; ··· 588 589 memcpy(de->name, "..\0", 4); 589 590 nilfs_set_de_type(de, inode); 590 591 kunmap_local(kaddr); 591 - nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size); 592 + nilfs_commit_chunk(folio, mapping, 0, chunk_size); 592 593 fail: 593 594 folio_put(folio); 594 595 return err;