Skip to content

Commit b18d78d

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
nilfs2: convert nilfs_recovery_copy_block() to take a folio
Use memcpy_to_folio() instead of open-coding it, and use offset_in_folio() in case anybody wants to use nilfs2 on a device with large blocks. [[email protected]: added label name change] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Ryusuke Konishi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c1d73eb commit b18d78d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

fs/nilfs2/recovery.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,19 +481,16 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
481481

482482
static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
483483
struct nilfs_recovery_block *rb,
484-
loff_t pos, struct page *page)
484+
loff_t pos, struct folio *folio)
485485
{
486486
struct buffer_head *bh_org;
487-
size_t from = pos & ~PAGE_MASK;
488-
void *kaddr;
487+
size_t from = offset_in_folio(folio, pos);
489488

490489
bh_org = __bread(nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize);
491490
if (unlikely(!bh_org))
492491
return -EIO;
493492

494-
kaddr = kmap_local_page(page);
495-
memcpy(kaddr + from, bh_org->b_data, bh_org->b_size);
496-
kunmap_local(kaddr);
493+
memcpy_to_folio(folio, from, bh_org->b_data, bh_org->b_size);
497494
brelse(bh_org);
498495
return 0;
499496
}
@@ -531,13 +528,13 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
531528
goto failed_inode;
532529
}
533530

534-
err = nilfs_recovery_copy_block(nilfs, rb, pos, &folio->page);
531+
err = nilfs_recovery_copy_block(nilfs, rb, pos, folio);
535532
if (unlikely(err))
536-
goto failed_page;
533+
goto failed_folio;
537534

538535
err = nilfs_set_file_dirty(inode, 1);
539536
if (unlikely(err))
540-
goto failed_page;
537+
goto failed_folio;
541538

542539
block_write_end(NULL, inode->i_mapping, pos, blocksize,
543540
blocksize, folio, NULL);
@@ -548,7 +545,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
548545
(*nr_salvaged_blocks)++;
549546
goto next;
550547

551-
failed_page:
548+
failed_folio:
552549
folio_unlock(folio);
553550
folio_put(folio);
554551

0 commit comments

Comments
 (0)