Commit aa4074e8 authored by Wu Bo's avatar Wu Bo Committed by Jaegeuk Kim

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: 859fca6b ("f2fs: swap: support migrating swapfile in aligned write mode")
Signed-off-by: default avatarLiao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: default avatarWu Bo <bo.wu@vivo.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 48d180e2
...@@ -3917,15 +3917,14 @@ static int check_swap_activate(struct swap_info_struct *sis, ...@@ -3917,15 +3917,14 @@ static int check_swap_activate(struct swap_info_struct *sis,
struct address_space *mapping = swap_file->f_mapping; struct address_space *mapping = swap_file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
sector_t cur_lblock; block_t cur_lblock;
sector_t last_lblock; block_t last_lblock;
sector_t pblock; block_t pblock;
sector_t lowest_pblock = -1; block_t lowest_pblock = -1;
sector_t highest_pblock = 0; block_t highest_pblock = 0;
int nr_extents = 0; int nr_extents = 0;
unsigned long nr_pblocks; unsigned int nr_pblocks;
unsigned int blks_per_sec = BLKS_PER_SEC(sbi); unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
unsigned int not_aligned = 0; unsigned int not_aligned = 0;
int ret = 0; int ret = 0;
...@@ -3963,8 +3962,8 @@ static int check_swap_activate(struct swap_info_struct *sis, ...@@ -3963,8 +3962,8 @@ static int check_swap_activate(struct swap_info_struct *sis,
pblock = map.m_pblk; pblock = map.m_pblk;
nr_pblocks = map.m_len; nr_pblocks = map.m_len;
if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask || if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
nr_pblocks & sec_blks_mask || nr_pblocks % blks_per_sec ||
!f2fs_valid_pinned_area(sbi, pblock)) { !f2fs_valid_pinned_area(sbi, pblock)) {
bool last_extent = false; bool last_extent = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment