Skip to contentSkip to conversation

f2fs: fix to use correct segment type in f2fs_allocate_data_block()

PATCH Superseded Chao Yu 2 participants 3 messages Feb 23, 2024 – Feb 24, 2024 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix to use correct segment type in f2fs_allocate_data_block()

@type in f2fs_allocate_data_block() indicates log header's type, it can be CURSEG_COLD_DATA_PINNED or CURSEG_ALL_DATA_ATGC, rather than type of data/node, however IS_DATASEG()/IS_NODESEG() only accept later one, fix it.

Fixes 093749e296e2 ("f2fs: support age threshold based garbage collection")
---
 fs/f2fs/segment.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +2 -2
index d0209ea77dd2..76422f50e6cc 100644
@@ -3505,12 +3505,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 	locate_dirty_segment(sbi, GET_SEGNO(sbi, old_blkaddr));
 	locate_dirty_segment(sbi, GET_SEGNO(sbi, *new_blkaddr));
 
-	if (IS_DATASEG(type))
+	if (IS_DATASEG(se->type))
 		atomic64_inc(&sbi->allocated_data_blocks);
 
 	up_write(&sit_i->sentry_lock);
 
-	if (page && IS_NODESEG(type)) {
+	if (page && IS_NODESEG(se->type)) {
 		fill_node_footer_blkaddr(page, NEXT_FREE_BLKADDR(sbi, curseg));
 
 		f2fs_inode_chksum_set(sbi, page);
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 16 lines · Chao Yu

@type in f2fs_allocate_data_block() indicates log header's type, it can be CURSEG_COLD_DATA_PINNED or CURSEG_ALL_DATA_ATGC, rather than type of data/node, however IS_DATASEG()/IS_NODESEG() only accept later one, fix it.

Fixes 093749e296e2 ("f2fs: support age threshold based garbage collection")
---
 fs/f2fs/segment.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +0 -0
index d0209ea77dd2..76422f50e6cc 100644

fs/f2fs/segment.c void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, · line 3508

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -3505,12 +3505,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 	locate_dirty_segment(sbi, GET_SEGNO(sbi, old_blkaddr));
 	locate_dirty_segment(sbi, GET_SEGNO(sbi, *new_blkaddr));
 
-	if (IS_DATASEG(type))
+	if (IS_DATASEG(se->type))

We have se only when type is CURSEG_ALL_DATA_ATGC. We may need to change IS_DATASEG()?

Quoted 11 lines
fs/f2fs/segment.c +1 -1
 		atomic64_inc(&sbi->allocated_data_blocks);
 
 	up_write(&sit_i->sentry_lock);
 
-	if (page && IS_NODESEG(type)) {
+	if (page && IS_NODESEG(se->type)) {
 		fill_node_footer_blkaddr(page, NEXT_FREE_BLKADDR(sbi, curseg));
 
 		f2fs_inode_chksum_set(sbi, page);
Signature · 1 line
2.40.1
author maintainer
#2 lore raw
Quoted 20 lines · Jaegeuk Kim
Quoted 19 lines · Chao Yu

@type in f2fs_allocate_data_block() indicates log header's type, it can be CURSEG_COLD_DATA_PINNED or CURSEG_ALL_DATA_ATGC, rather than type of data/node, however IS_DATASEG()/IS_NODESEG() only accept later one, fix it.

Fixes 093749e296e2 ("f2fs: support age threshold based garbage collection")
---
  fs/f2fs/segment.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +0 -0
index d0209ea77dd2..76422f50e6cc 100644
@@ -3505,12 +3505,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
  	locate_dirty_segment(sbi, GET_SEGNO(sbi, old_blkaddr));
  	locate_dirty_segment(sbi, GET_SEGNO(sbi, *new_blkaddr));
 
Quoted 4 lines

fs/f2fs/segment.c void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, · line 3508

Quoted 2 lines
fs/f2fs/segment.c +1 -1
-	if (IS_DATASEG(type))
+	if (IS_DATASEG(se->type))

We have se only when type is CURSEG_ALL_DATA_ATGC. We may need to change

Oops, correct.

Quoted 1 line

IS_DATASEG()?

Sure, I guess one other way is to use curseg->seg_type, let me know if you prefer to change IS_DATASEG().

Thanks,

Quoted 12 lines
Quoted 12 lines
fs/f2fs/segment.c +1 -1
  		atomic64_inc(&sbi->allocated_data_blocks);
 
  	up_write(&sit_i->sentry_lock);
 
-	if (page && IS_NODESEG(type)) {
+	if (page && IS_NODESEG(se->type)) {
  		fill_node_footer_blkaddr(page, NEXT_FREE_BLKADDR(sbi, curseg));
 
  		f2fs_inode_chksum_set(sbi, page);
Signature · 1 line
2.40.1