Skip to content

Commit 59d0d4c

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: update blkaddr in __set_data_blkaddr() for cleanup
This patch allows caller to pass blkaddr to f2fs_set_data_blkaddr() and let __set_data_blkaddr() inside f2fs_set_data_blkaddr() to update dn->data_blkaddr w/ last value of blkaddr. Just cleanup, no logic changes. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 2020cd4 commit 59d0d4c

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

fs/f2fs/data.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,10 +1179,11 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,
11791179
return 0;
11801180
}
11811181

1182-
static void __set_data_blkaddr(struct dnode_of_data *dn)
1182+
static void __set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
11831183
{
11841184
__le32 *addr = get_dnode_addr(dn->inode, dn->node_page);
11851185

1186+
dn->data_blkaddr = blkaddr;
11861187
addr[dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr);
11871188
}
11881189

@@ -1192,18 +1193,17 @@ static void __set_data_blkaddr(struct dnode_of_data *dn)
11921193
* ->node_page
11931194
* update block addresses in the node page
11941195
*/
1195-
void f2fs_set_data_blkaddr(struct dnode_of_data *dn)
1196+
void f2fs_set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
11961197
{
11971198
f2fs_wait_on_page_writeback(dn->node_page, NODE, true, true);
1198-
__set_data_blkaddr(dn);
1199+
__set_data_blkaddr(dn, blkaddr);
11991200
if (set_page_dirty(dn->node_page))
12001201
dn->node_changed = true;
12011202
}
12021203

12031204
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
12041205
{
1205-
dn->data_blkaddr = blkaddr;
1206-
f2fs_set_data_blkaddr(dn);
1206+
f2fs_set_data_blkaddr(dn, blkaddr);
12071207
f2fs_update_read_extent_cache(dn);
12081208
}
12091209

@@ -1230,8 +1230,7 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
12301230
block_t blkaddr = f2fs_data_blkaddr(dn);
12311231

12321232
if (blkaddr == NULL_ADDR) {
1233-
dn->data_blkaddr = NEW_ADDR;
1234-
__set_data_blkaddr(dn);
1233+
__set_data_blkaddr(dn, NEW_ADDR);
12351234
count--;
12361235
}
12371236
}

fs/f2fs/f2fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3822,7 +3822,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio);
38223822
struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
38233823
block_t blk_addr, sector_t *sector);
38243824
int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
3825-
void f2fs_set_data_blkaddr(struct dnode_of_data *dn);
3825+
void f2fs_set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
38263826
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
38273827
int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
38283828
int f2fs_reserve_new_block(struct dnode_of_data *dn);

fs/f2fs/file.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)
582582
if (blkaddr == NULL_ADDR)
583583
continue;
584584

585-
dn->data_blkaddr = NULL_ADDR;
586-
f2fs_set_data_blkaddr(dn);
585+
f2fs_set_data_blkaddr(dn, NULL_ADDR);
587586

588587
if (__is_valid_data_blkaddr(blkaddr)) {
589588
if (!f2fs_is_valid_blkaddr(sbi, blkaddr,
@@ -1478,8 +1477,7 @@ static int f2fs_do_zero_range(struct dnode_of_data *dn, pgoff_t start,
14781477
}
14791478

14801479
f2fs_invalidate_blocks(sbi, dn->data_blkaddr);
1481-
dn->data_blkaddr = NEW_ADDR;
1482-
f2fs_set_data_blkaddr(dn);
1480+
f2fs_set_data_blkaddr(dn, NEW_ADDR);
14831481
}
14841482

14851483
f2fs_update_read_extent_cache_range(dn, start, 0, index - start);
@@ -3454,8 +3452,7 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
34543452
if (blkaddr != NEW_ADDR)
34553453
continue;
34563454

3457-
dn->data_blkaddr = NULL_ADDR;
3458-
f2fs_set_data_blkaddr(dn);
3455+
f2fs_set_data_blkaddr(dn, NULL_ADDR);
34593456
}
34603457

34613458
f2fs_i_compr_blocks_update(dn->inode, compr_blocks, false);
@@ -3621,8 +3618,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
36213618
continue;
36223619
}
36233620

3624-
dn->data_blkaddr = NEW_ADDR;
3625-
f2fs_set_data_blkaddr(dn);
3621+
f2fs_set_data_blkaddr(dn, NEW_ADDR);
36263622
}
36273623

36283624
reserved = cluster_size - compr_blocks;

0 commit comments

Comments
 (0)