If curseg is not the first segment in its zone, the zone is not empty.
A new section should be allocated and avoid resetting the old zone.

Reviewed-by: Chao Yu <c...@kernel.org>
Signed-off-by: Sheng Yong <shengy...@oppo.com>
---
v2: remove and update inaccurate commit msg
---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4c8836ded90fc..50b38cbe33401 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -5004,7 +5004,8 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info 
*sbi, int type)
        }
 
        /* Allocate a new section if it's not new. */
-       if (cs->next_blkoff) {
+       if (cs->next_blkoff ||
+           cs->segno != GET_SEG_FROM_SEC(sbi, GET_ZONE_FROM_SEC(sbi, 
cs_section))) {
                unsigned int old_segno = cs->segno, old_blkoff = 
cs->next_blkoff;
 
                f2fs_allocate_new_section(sbi, type, true);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to