f2fs: fix block migration when section is not aligned to pow2
PATCH 1/1 f2fs: fix block migration when section is not aligned to pow2
As for zoned-UFS, f2fs section size is forced to zone size. And zone size may not aligned to pow2.
--- fs/f2fs/data.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/f2fs/data.c +2 -3
@@ -3904,7 +3904,6 @@ static int check_swap_activate(struct swap_info_struct *sis,int nr_extents =0 ;unsigned long nr_pblocks;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;
@@ -3942,8 +3941,8 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; -if ((pblock -SM_I (sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || +if ((pblock -SM_I (sbi)->main_blkaddr) % blks_per_sec || + nr_pblocks % blks_per_sec || !f2fs_valid_pinned_area (sbi, pblock)) {bool last_extent = false;
Signature · 1 line
2.25.1
Quoted 6 lines · Wu Bo
As for zoned-UFS, f2fs section size is forced to zone size. And zone size may not aligned to pow2.
Fixes 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write mode")Signed-off-by Liao Yuanhong <[email protected]>Signed-off-by Wu Bo <[email protected]>
Thanks,
Jaegeuk Kim
maintainerQuoted 23 lines · Wu Bo
As for zoned-UFS, f2fs section size is forced to zone size. And zone size may not aligned to pow2.
Fixes 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write mode")Signed-off-by Liao Yuanhong <[email protected]>Signed-off-by Wu Bo <[email protected]>--- fs/f2fs/data.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)fs/f2fs/data.c +0
-1@@ -3904,7 +3904,6 @@ static int check_swap_activate(struct swap_info_struct *sis,int nr_extents =0 ;unsigned long nr_pblocks;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;
fs/f2fs/data.c static int check_swap_activate(struct swap_info_struct *sis, · line 3945
Quoted 7 lines
fs/f2fs/data.c +2
-2@@ -3942,8 +3941,8 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; - if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || + if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec || + nr_pblocks % blks_per_sec ||
Modified a bit to address udiv issue like below. Let's see.
fs/f2fs/data.c +4 -4
@@ -3923,8 +3923,8 @@ static int check_swap_activate(struct swap_info_struct *sis,sector_t highest_pblock =0 ;int nr_extents =0 ;unsigned long nr_pblocks; +u32 align;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;
@@ -3961,10 +3961,10 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; +div_u64_rem (nr_pblocks, blks_per_sec, &align); -if ((pblock -SM_I (sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || - !f2fs_valid_pinned_area (sbi, pblock)) { +if ((pblock -SM_I (sbi)->main_blkaddr) % blks_per_sec || + align || !f2fs_valid_pinned_area (sbi, pblock)) {bool last_extent = false; not_aligned++;
Quoted 5 lines
fs/f2fs/data.c +0
-0!f2fs_valid_pinned_area(sbi, pblock)) {bool last_extent = false;Signature · 1 line
2.25.1
Jaegeuk Kim
maintainerQuoted 27 lines · Jaegeuk Kim
Quoted 26 lines · Wu Bo
As for zoned-UFS, f2fs section size is forced to zone size. And zone size may not aligned to pow2.
Fixes 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write mode")Signed-off-by Liao Yuanhong <[email protected]>Signed-off-by Wu Bo <[email protected]>--- fs/f2fs/data.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)fs/f2fs/data.c +0
-1@@ -3904,7 +3904,6 @@ static int check_swap_activate(struct swap_info_struct *sis,int nr_extents =0 ;unsigned long nr_pblocks;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;@@ -3942,8 +3941,8 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len;
Quoted 6 lines
fs/f2fs/data.c static int check_swap_activate(struct swap_info_struct *sis,
Quoted 4 lines
fs/f2fs/data.c +2
-2- if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || + if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec || + nr_pblocks % blks_per_sec ||Modified a bit to address udiv issue like below. Let's see.
Ok, I took v2 instead of this.
Quoted 33 lines
fs/f2fs/data.c +4
-4@@ -3923,8 +3923,8 @@ static int check_swap_activate(struct swap_info_struct *sis,sector_t highest_pblock =0 ;int nr_extents =0 ;unsigned long nr_pblocks; +u32 align;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;@@ -3961,10 +3961,10 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; +div_u64_rem (nr_pblocks, blks_per_sec, &align); -if ((pblock -SM_I (sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || - !f2fs_valid_pinned_area (sbi, pblock)) { +if ((pblock -SM_I (sbi)->main_blkaddr) % blks_per_sec || + align || !f2fs_valid_pinned_area (sbi, pblock)) {bool last_extent = false; not_aligned++;Quoted 6 lines
fs/f2fs/data.c +0
-0!f2fs_valid_pinned_area(sbi, pblock)) {bool last_extent = false;Signature · 1 line
2.25.1