Skip to content

Commit aa4074e

Browse files
Wu BoJaegeuk Kim
authored andcommitted
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. Fixes: 859fca6 ("f2fs: swap: support migrating swapfile in aligned write mode") Signed-off-by: Liao Yuanhong <[email protected]> Signed-off-by: Wu Bo <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 48d180e commit aa4074e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/f2fs/data.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,15 +3917,14 @@ static int check_swap_activate(struct swap_info_struct *sis,
39173917
struct address_space *mapping = swap_file->f_mapping;
39183918
struct inode *inode = mapping->host;
39193919
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
3920-
sector_t cur_lblock;
3921-
sector_t last_lblock;
3922-
sector_t pblock;
3923-
sector_t lowest_pblock = -1;
3924-
sector_t highest_pblock = 0;
3920+
block_t cur_lblock;
3921+
block_t last_lblock;
3922+
block_t pblock;
3923+
block_t lowest_pblock = -1;
3924+
block_t highest_pblock = 0;
39253925
int nr_extents = 0;
3926-
unsigned long nr_pblocks;
3926+
unsigned int nr_pblocks;
39273927
unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
3928-
unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
39293928
unsigned int not_aligned = 0;
39303929
int ret = 0;
39313930

@@ -3963,8 +3962,8 @@ static int check_swap_activate(struct swap_info_struct *sis,
39633962
pblock = map.m_pblk;
39643963
nr_pblocks = map.m_len;
39653964

3966-
if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask ||
3967-
nr_pblocks & sec_blks_mask ||
3965+
if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
3966+
nr_pblocks % blks_per_sec ||
39683967
!f2fs_valid_pinned_area(sbi, pblock)) {
39693968
bool last_extent = false;
39703969

0 commit comments

Comments
 (0)