Skip to contentSkip to conversation

f2fs: fix blkofs_end correctly in f2fs_migrate_blocks()

PATCH Applied Chao Yu 4 participants 12 messages Feb 26, 2024 – Mar 4, 2024 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/4 f2fs: fix blkofs_end correctly in f2fs_migrate_blocks()

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
 fs/f2fs/data.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/data.c +3 -2
index c21b92f18463..0c728e82d936 100644
@@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	unsigned int blkofs;
 	unsigned int blk_per_sec = BLKS_PER_SEC(sbi);
+	unsigned int end_blk = start_blk + blkcnt - 1;
 	unsigned int secidx = start_blk / blk_per_sec;
 	unsigned int end_sec;
 	int ret = 0;
 
 	if (!blkcnt)
 		return 0;
-	end_sec = secidx + (blkcnt - 1) / blk_per_sec;
+	end_sec = end_blk / blk_per_sec;
 
 	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 	filemap_invalidate_lock(inode->i_mapping);
@@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 
 	for (; secidx <= end_sec; secidx++) {
 		unsigned int blkofs_end = secidx == end_sec ?
-			(blkcnt - 1) % blk_per_sec : blk_per_sec - 1;
+				end_blk % blk_per_sec : blk_per_sec - 1;
 
 		f2fs_down_write(&sbi->pin_sem);
 
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH 2/4 f2fs: relocate f2fs_precache_extents() in f2fs_swap_activate()

This patch exchangs position of f2fs_precache_extents() and filemap_fdatawrite(), so that f2fs_precache_extents() can load extent info after physical addresses of all data are fixed.

---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -2
index 0c728e82d936..bd8674bf1d84 100644
@@ -4045,12 +4045,12 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file,
 	if (!f2fs_disable_compressed_file(inode))
 		return -EINVAL;
 
-	f2fs_precache_extents(inode);
-
 	ret = filemap_fdatawrite(inode->i_mapping);
 	if (ret < 0)
 		return ret;
 
+	f2fs_precache_extents(inode);
+
 	ret = check_swap_activate(sis, file, span);
 	if (ret < 0)
 		return ret;
Signature · 1 line
2.40.1
author maintainer
#3 lore raw

PATCH 3/4 f2fs: clean up new_curseg()

In reply to Chao Yu

Move f2fs_valid_pinned_area() check logic from new_curseg() to get_new_segment(), it can avoid calling __set_free() if it fails to find free segment in conventional zone for pinned file.

---
 fs/f2fs/segment.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
fs/f2fs/segment.c +14 -9
index 847fe0b7f29f..c159b0985596 100644
@@ -2715,12 +2715,19 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
 got_it:
 	/* set it as dirty segment in free segmap */
 	f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap));
+
+	/* no free section in conventional zone */
+	if (new_sec && pinning &&
+		!f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) {
+		ret = -EAGAIN;
+		goto out_unlock;
+	}
 	__set_inuse(sbi, segno);
 	*newseg = segno;
 out_unlock:
 	spin_unlock(&free_i->segmap_lock);
 
-	if (ret) {
+	if (ret == -ENOSPC) {
 		f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT);
 		f2fs_bug_on(sbi, 1);
 	}
@@ -2796,19 +2803,17 @@ static int new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec)
 	struct curseg_info *curseg = CURSEG_I(sbi, type);
 	unsigned int segno = curseg->segno;
 	bool pinning = type == CURSEG_COLD_DATA_PINNED;
+	int ret;
 
 	if (curseg->inited)
 		write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, segno));
 
 	segno = __get_next_segno(sbi, type);
-	if (get_new_segment(sbi, &segno, new_sec, pinning)) {
-		curseg->segno = NULL_SEGNO;
-		return -ENOSPC;
-	}
-	if (new_sec && pinning &&
-	    !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) {
-		__set_free(sbi, segno);
-		return -EAGAIN;
+	ret = get_new_segment(sbi, &segno, new_sec, pinning);
+	if (ret) {
+		if (ret == -ENOSPC)
+			curseg->segno = NULL_SEGNO;
+		return ret;
 	}
 
 	curseg->next_segno = segno;
Signature · 1 line
2.40.1
author maintainer
#5 lore raw

PATCH 4/4 f2fs: fix to reset fields for unloaded curseg

In reply to Chao Yu

In f2fs_allocate_data_block(), before skip allocating new segment for DATA_PINNED log header, it needs to tag log header as unloaded one to avoid skipping logic in locate_dirty_segment() and __f2fs_save_inmem_curseg().

---
 fs/f2fs/segment.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
fs/f2fs/segment.c +15 -4
index c159b0985596..5e45afd69f3f 100644
@@ -3101,12 +3101,16 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
 	struct curseg_info *curseg = CURSEG_I(sbi, type);
 	unsigned int old_segno;
 
+	if (type == CURSEG_COLD_DATA_PINNED && !curseg->inited)
+		goto allocate;
+
 	if (!force && curseg->inited &&
 	    !curseg->next_blkoff &&
 	    !get_valid_blocks(sbi, curseg->segno, new_sec) &&
 	    !get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
 		return 0;
 
+allocate:
 	old_segno = curseg->segno;
 	if (new_curseg(sbi, type, true))
 		return -EAGAIN;
@@ -3451,6 +3455,13 @@ static void f2fs_randomize_chunk(struct f2fs_sb_info *sbi,
 		get_random_u32_inclusive(1, sbi->max_fragment_hole);
 }
 
+static void reset_curseg_fields(struct curseg_info *curseg)
+{
+	curseg->inited = false;
+	curseg->segno = NULL_SEGNO;
+	curseg->next_segno = 0;
+}
+
 int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 		block_t old_blkaddr, block_t *new_blkaddr,
 		struct f2fs_summary *sum, int type,
@@ -3516,8 +3527,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 	 */
 	if (segment_full) {
 		if (type == CURSEG_COLD_DATA_PINNED &&
-		    !((curseg->segno + 1) % sbi->segs_per_sec))
+		    !((curseg->segno + 1) % sbi->segs_per_sec)) {
+			reset_curseg_fields(curseg);
 			goto skip_new_segment;
+		}
 
 		if (from_gc) {
 			get_atssr_segment(sbi, type, se->type,
@@ -4595,9 +4608,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
 			array[i].seg_type = CURSEG_COLD_DATA;
 		else if (i == CURSEG_ALL_DATA_ATGC)
 			array[i].seg_type = CURSEG_COLD_DATA;
-		array[i].segno = NULL_SEGNO;
-		array[i].next_blkoff = 0;
-		array[i].inited = false;
+		reset_curseg_fields(&array[i]);
 	}
 	return restore_curseg_summaries(sbi);
 }
Signature · 1 line
2.40.1
author maintainer
#7 lore raw
In reply to Chao Yu

Jaegeuk, Daeho,

Any comments on this serials?

Thanks,

Quoted 37 lines · Chao Yu

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
  fs/f2fs/data.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/data.c +3 -2
index c21b92f18463..0c728e82d936 100644
@@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
  	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
  	unsigned int blkofs;
  	unsigned int blk_per_sec = BLKS_PER_SEC(sbi);
+	unsigned int end_blk = start_blk + blkcnt - 1;
  	unsigned int secidx = start_blk / blk_per_sec;
  	unsigned int end_sec;
  	int ret = 0;
 
  	if (!blkcnt)
  		return 0;
-	end_sec = secidx + (blkcnt - 1) / blk_per_sec;
+	end_sec = end_blk / blk_per_sec;
 
  	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
  	filemap_invalidate_lock(inode->i_mapping);
@@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 
  	for (; secidx <= end_sec; secidx++) {
  		unsigned int blkofs_end = secidx == end_sec ?
-			(blkcnt - 1) % blk_per_sec : blk_per_sec - 1;
+				end_blk % blk_per_sec : blk_per_sec - 1;
 
  		f2fs_down_write(&sbi->pin_sem);
 
Reviewed-by
#8 lore raw
Quoted 6 lines · Chao Yu

Jaegeuk, Daeho,

Any comments on this serials?

Thanks,

No functional difference here, since start_blk is always aligned with the section address.
However, this is more clear in itself.

Thanks,

Quoted 45 lines · Chao Yu
Quoted 29 lines

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
  fs/f2fs/data.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -1
index c21b92f18463..0c728e82d936 100644
@@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
      struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
      unsigned int blkofs;
      unsigned int blk_per_sec = BLKS_PER_SEC(sbi);
+     unsigned int end_blk = start_blk + blkcnt - 1;
      unsigned int secidx = start_blk / blk_per_sec;
      unsigned int end_sec;
      int ret = 0;
 
      if (!blkcnt)
              return 0;
-     end_sec = secidx + (blkcnt - 1) / blk_per_sec;
+     end_sec = end_blk / blk_per_sec;
 
      f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
      filemap_invalidate_lock(inode->i_mapping);

fs/f2fs/data.c static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, · line 3864

Quoted 8 lines
fs/f2fs/data.c +1 -1
@@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 
      for (; secidx <= end_sec; secidx++) {
              unsigned int blkofs_end = secidx == end_sec ?
-                     (blkcnt - 1) % blk_per_sec : blk_per_sec - 1;
+                             end_blk % blk_per_sec : blk_per_sec - 1;
 
              f2fs_down_write(&sbi->pin_sem);
 

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v1 2/4
#2 lore raw

Re: [f2fs-dev] [PATCH 2/4] f2fs: relocate f2fs_precache_extents() in f2fs_swap_activate()

In reply to Chao Yu

Thanks,

Quoted 38 lines · Chao Yu

This patch exchangs position of f2fs_precache_extents() and filemap_fdatawrite(), so that f2fs_precache_extents() can load extent info after physical addresses of all data are fixed.

---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -3
index 0c728e82d936..bd8674bf1d84 100644
@@ -4045,12 +4045,12 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file,
        if (!f2fs_disable_compressed_file(inode))
                return -EINVAL;
 
-       f2fs_precache_extents(inode);
-
        ret = filemap_fdatawrite(inode->i_mapping);
        if (ret < 0)
                return ret;
 
+       f2fs_precache_extents(inode);
+
        ret = check_swap_activate(sis, file, span);
        if (ret < 0)
                return ret;
--

2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v1 3/4
#4 lore raw

Re: [f2fs-dev] [PATCH 3/4] f2fs: clean up new_curseg()

In reply to Chao Yu

Thanks,

Quoted 70 lines · Chao Yu

Move f2fs_valid_pinned_area() check logic from new_curseg() to get_new_segment(), it can avoid calling __set_free() if it fails to find free segment in conventional zone for pinned file.

---
 fs/f2fs/segment.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
fs/f2fs/segment.c +14 -10
index 847fe0b7f29f..c159b0985596 100644
@@ -2715,12 +2715,19 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
 got_it:
        /* set it as dirty segment in free segmap */
        f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap));
+
+       /* no free section in conventional zone */
+       if (new_sec && pinning &&
+               !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) {
+               ret = -EAGAIN;
+               goto out_unlock;
+       }
        __set_inuse(sbi, segno);
        *newseg = segno;
 out_unlock:
        spin_unlock(&free_i->segmap_lock);
 
-       if (ret) {
+       if (ret == -ENOSPC) {
                f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT);
                f2fs_bug_on(sbi, 1);
        }
@@ -2796,19 +2803,17 @@ static int new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec)
        struct curseg_info *curseg = CURSEG_I(sbi, type);
        unsigned int segno = curseg->segno;
        bool pinning = type == CURSEG_COLD_DATA_PINNED;
+       int ret;
 
        if (curseg->inited)
                write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, segno));
 
        segno = __get_next_segno(sbi, type);
-       if (get_new_segment(sbi, &segno, new_sec, pinning)) {
-               curseg->segno = NULL_SEGNO;
-               return -ENOSPC;
-       }
-       if (new_sec && pinning &&
-           !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) {
-               __set_free(sbi, segno);
-               return -EAGAIN;
+       ret = get_new_segment(sbi, &segno, new_sec, pinning);
+       if (ret) {
+               if (ret == -ENOSPC)
+                       curseg->segno = NULL_SEGNO;
+               return ret;
        }
 
        curseg->next_segno = segno;
--

2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v1 4/4
#6 lore raw

Re: [f2fs-dev] [PATCH 4/4] f2fs: fix to reset fields for unloaded curseg

In reply to Chao Yu

Thanks,

Quoted 78 lines · Chao Yu

In f2fs_allocate_data_block(), before skip allocating new segment for DATA_PINNED log header, it needs to tag log header as unloaded one to avoid skipping logic in locate_dirty_segment() and __f2fs_save_inmem_curseg().

---
 fs/f2fs/segment.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
fs/f2fs/segment.c +15 -5
index c159b0985596..5e45afd69f3f 100644
@@ -3101,12 +3101,16 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
        struct curseg_info *curseg = CURSEG_I(sbi, type);
        unsigned int old_segno;
 
+       if (type == CURSEG_COLD_DATA_PINNED && !curseg->inited)
+               goto allocate;
+
        if (!force && curseg->inited &&
            !curseg->next_blkoff &&
            !get_valid_blocks(sbi, curseg->segno, new_sec) &&
            !get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
                return 0;
 
+allocate:
        old_segno = curseg->segno;
        if (new_curseg(sbi, type, true))
                return -EAGAIN;
@@ -3451,6 +3455,13 @@ static void f2fs_randomize_chunk(struct f2fs_sb_info *sbi,
                get_random_u32_inclusive(1, sbi->max_fragment_hole);
 }
 
+static void reset_curseg_fields(struct curseg_info *curseg)
+{
+       curseg->inited = false;
+       curseg->segno = NULL_SEGNO;
+       curseg->next_segno = 0;
+}
+
 int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
                block_t old_blkaddr, block_t *new_blkaddr,
                struct f2fs_summary *sum, int type,
@@ -3516,8 +3527,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
         */
        if (segment_full) {
                if (type == CURSEG_COLD_DATA_PINNED &&
-                   !((curseg->segno + 1) % sbi->segs_per_sec))
+                   !((curseg->segno + 1) % sbi->segs_per_sec)) {
+                       reset_curseg_fields(curseg);
                        goto skip_new_segment;
+               }
 
                if (from_gc) {
                        get_atssr_segment(sbi, type, se->type,
@@ -4595,9 +4608,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
                        array[i].seg_type = CURSEG_COLD_DATA;
                else if (i == CURSEG_ALL_DATA_ATGC)
                        array[i].seg_type = CURSEG_COLD_DATA;
-               array[i].segno = NULL_SEGNO;
-               array[i].next_blkoff = 0;
-               array[i].inited = false;
+               reset_curseg_fields(&array[i]);
        }
        return restore_curseg_summaries(sbi);
 }
--

2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#9 lore raw
In reply to Daeho Jeong
Quoted 10 lines · Daeho Jeong
Quoted 6 lines · Chao Yu

Jaegeuk, Daeho,

Any comments on this serials?

Thanks,

No functional difference here, since start_blk is always aligned with the section address.

You're right.

Quoted 1 line

However, this is more clear in itself.

Thanks for the review!

One more thing is, I found that fallocate() on pinned file will preallocate aligned w/ section-size which is about several hundred megabyte for ZUFS case, since commit e1175f022911 ("f2fs: fix to align to section for fallocate() on pinned file").

It looks not make sense, especially for logcat case which actually want to preallocate 2MB space, so, what about reverting commit e1175f022911 and looking for other solution to avoid GCing on fragmented pinned file.

What do you think?

Thanks,

Quoted 50 lines

Thanks,

Quoted 45 lines · Chao Yu
Quoted 29 lines

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
   fs/f2fs/data.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -1
index c21b92f18463..0c728e82d936 100644
@@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
       struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
       unsigned int blkofs;
       unsigned int blk_per_sec = BLKS_PER_SEC(sbi);
+     unsigned int end_blk = start_blk + blkcnt - 1;
       unsigned int secidx = start_blk / blk_per_sec;
       unsigned int end_sec;
       int ret = 0;
 
       if (!blkcnt)
               return 0;
-     end_sec = secidx + (blkcnt - 1) / blk_per_sec;
+     end_sec = end_blk / blk_per_sec;
 
       f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
       filemap_invalidate_lock(inode->i_mapping);

fs/f2fs/data.c static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, · line 3864

Quoted 8 lines
fs/f2fs/data.c +1 -1
@@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 
       for (; secidx <= end_sec; secidx++) {
               unsigned int blkofs_end = secidx == end_sec ?
-                     (blkcnt - 1) % blk_per_sec : blk_per_sec - 1;
+                             end_blk % blk_per_sec : blk_per_sec - 1;
 
               f2fs_down_write(&sbi->pin_sem);
 

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#10 lore raw
Quoted 18 lines · Chao Yu
Quoted 10 lines · Daeho Jeong
Quoted 6 lines · Chao Yu

Jaegeuk, Daeho,

Any comments on this serials?

Thanks,

No functional difference here, since start_blk is always aligned with the section address.

You're right.

Quoted 1 line

However, this is more clear in itself.

Thanks for the review!

Quoted 8 lines

One more thing is, I found that fallocate() on pinned file will preallocate aligned w/ section-size which is about several hundred megabyte for ZUFS case, since commit e1175f022911 ("f2fs: fix to align to section for fallocate() on pinned file").

It looks not make sense, especially for logcat case which actually want to preallocate 2MB space, so, what about reverting commit e1175f022911 and looking for other solution to avoid GCing on fragmented pinned file.

I remember we removed the logcat case.

Quoted 55 lines

What do you think?

Thanks,

Quoted 50 lines

Thanks,

Quoted 45 lines · Chao Yu
Quoted 29 lines

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
   fs/f2fs/data.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -1
index c21b92f18463..0c728e82d936 100644
@@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
       struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
       unsigned int blkofs;
       unsigned int blk_per_sec = BLKS_PER_SEC(sbi);
+     unsigned int end_blk = start_blk + blkcnt - 1;
       unsigned int secidx = start_blk / blk_per_sec;
       unsigned int end_sec;
       int ret = 0;
 
       if (!blkcnt)
               return 0;
-     end_sec = secidx + (blkcnt - 1) / blk_per_sec;
+     end_sec = end_blk / blk_per_sec;
 
       f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
       filemap_invalidate_lock(inode->i_mapping);

fs/f2fs/data.c static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, · line 3864

Quoted 8 lines
fs/f2fs/data.c +1 -1
@@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,
 
       for (; secidx <= end_sec; secidx++) {
               unsigned int blkofs_end = secidx == end_sec ?
-                     (blkcnt - 1) % blk_per_sec : blk_per_sec - 1;
+                             end_blk % blk_per_sec : blk_per_sec - 1;
 
               f2fs_down_write(&sbi->pin_sem);
 

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#11 lore raw
In reply to Chao Yu
This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 7 lines · On Mon, 26 Feb 2024 09:32:05 +0800 you wrote:

In f2fs_migrate_blocks(), when traversing blocks in last section, blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.

---
 fs/f2fs/data.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Here is the summary with links:
- [f2fs-dev,1/4] f2fs: fix blkofs_end correctly in f2fs_migrate_blocks()

    https://git.kernel.org/jaegeuk/f2fs/c/8249aac1b05c
  - [f2fs-dev,2/4] f2fs: relocate f2fs_precache_extents() in f2fs_swap_activate()
    https://git.kernel.org/jaegeuk/f2fs/c/f1e7646a8cd4
  - [f2fs-dev,3/4] f2fs: clean up new_curseg()
    https://git.kernel.org/jaegeuk/f2fs/c/1081b5121b27
  - [f2fs-dev,4/4] f2fs: fix to reset fields for unloaded curseg
    https://git.kernel.org/jaegeuk/f2fs/c/42a80aacb76b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html