Skip to content

Commit 4fd0a09

Browse files
konisakpm00
authored andcommitted
nilfs2: convert common metadata file code to be folio-based
In the common routines for metadata files, nilfs_mdt_insert_new_block(), which inserts a new block buffer into the cache, is still page-based, and there are two places where bh_offset() is used. Convert these to page-based. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ryusuke Konishi <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 25f12e4 commit 4fd0a09

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

fs/nilfs2/alloc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ nilfs_palloc_entry_blkoff(const struct inode *inode, __u64 nr)
177177
* nilfs_palloc_desc_block_init - initialize buffer of a group descriptor block
178178
* @inode: inode of metadata file
179179
* @bh: buffer head of the buffer to be initialized
180-
* @kaddr: kernel address mapped for the page including the buffer
180+
* @from: kernel address mapped for a chunk of the block
181+
*
182+
* This function does not yet support the case where block size > PAGE_SIZE.
181183
*/
182184
static void nilfs_palloc_desc_block_init(struct inode *inode,
183-
struct buffer_head *bh, void *kaddr)
185+
struct buffer_head *bh, void *from)
184186
{
185-
struct nilfs_palloc_group_desc *desc = kaddr + bh_offset(bh);
187+
struct nilfs_palloc_group_desc *desc = from;
186188
unsigned long n = nilfs_palloc_groups_per_desc_block(inode);
187189
__le32 nfrees;
188190

fs/nilfs2/cpfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ nilfs_cpfile_block_get_checkpoint(const struct inode *cpfile, __u64 cno,
113113

114114
static void nilfs_cpfile_block_init(struct inode *cpfile,
115115
struct buffer_head *bh,
116-
void *kaddr)
116+
void *from)
117117
{
118-
struct nilfs_checkpoint *cp = kaddr + bh_offset(bh);
118+
struct nilfs_checkpoint *cp = from;
119119
size_t cpsz = NILFS_MDT(cpfile)->mi_entry_size;
120120
int n = nilfs_cpfile_checkpoints_per_block(cpfile);
121121

fs/nilfs2/mdt.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ nilfs_mdt_insert_new_block(struct inode *inode, unsigned long block,
3333
struct buffer_head *, void *))
3434
{
3535
struct nilfs_inode_info *ii = NILFS_I(inode);
36-
void *kaddr;
36+
struct folio *folio = bh->b_folio;
37+
void *from;
3738
int ret;
3839

3940
/* Caller exclude read accesses using page lock */
@@ -47,12 +48,14 @@ nilfs_mdt_insert_new_block(struct inode *inode, unsigned long block,
4748

4849
set_buffer_mapped(bh);
4950

50-
kaddr = kmap_local_page(bh->b_page);
51-
memset(kaddr + bh_offset(bh), 0, i_blocksize(inode));
51+
/* Initialize block (block size > PAGE_SIZE not yet supported) */
52+
from = kmap_local_folio(folio, offset_in_folio(folio, bh->b_data));
53+
memset(from, 0, bh->b_size);
5254
if (init_block)
53-
init_block(inode, bh, kaddr);
54-
flush_dcache_page(bh->b_page);
55-
kunmap_local(kaddr);
55+
init_block(inode, bh, from);
56+
kunmap_local(from);
57+
58+
flush_dcache_folio(folio);
5659

5760
set_buffer_uptodate(bh);
5861
mark_buffer_dirty(bh);
@@ -571,7 +574,8 @@ int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh)
571574
if (!bh_frozen)
572575
bh_frozen = create_empty_buffers(folio, 1 << blkbits, 0);
573576

574-
bh_frozen = get_nth_bh(bh_frozen, bh_offset(bh) >> blkbits);
577+
bh_frozen = get_nth_bh(bh_frozen,
578+
offset_in_folio(folio, bh->b_data) >> blkbits);
575579

576580
if (!buffer_uptodate(bh_frozen))
577581
nilfs_copy_buffer(bh_frozen, bh);
@@ -601,7 +605,8 @@ nilfs_mdt_get_frozen_buffer(struct inode *inode, struct buffer_head *bh)
601605
if (!IS_ERR(folio)) {
602606
bh_frozen = folio_buffers(folio);
603607
if (bh_frozen) {
604-
n = bh_offset(bh) >> inode->i_blkbits;
608+
n = offset_in_folio(folio, bh->b_data) >>
609+
inode->i_blkbits;
605610
bh_frozen = get_nth_bh(bh_frozen, n);
606611
}
607612
folio_unlock(folio);

0 commit comments

Comments
 (0)