* [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2
@ 2024-04-26 10:41 Wu Bo via Linux-f2fs-devel
2024-04-27 1:57 ` Chao Yu
2024-04-29 17:37 ` Jaegeuk Kim
0 siblings, 2 replies; 4+ messages in thread
From: Wu Bo via Linux-f2fs-devel @ 2024-04-26 10:41 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu
Cc: Wu Bo, Liao Yuanhong, linux-kernel, Wu Bo, linux-f2fs-devel
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 <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
fs/f2fs/data.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index d9494b5fc7c1..7ff5ad3fd5dc 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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;
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2
2024-04-26 10:41 [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2 Wu Bo via Linux-f2fs-devel
@ 2024-04-27 1:57 ` Chao Yu
2024-04-29 17:37 ` Jaegeuk Kim
1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2024-04-27 1:57 UTC (permalink / raw)
To: Wu Bo, Jaegeuk Kim; +Cc: Wu Bo, linux-kernel, Liao Yuanhong, linux-f2fs-devel
On 2024/4/26 18:41, Wu Bo wrote:
> 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 <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2
2024-04-26 10:41 [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2 Wu Bo via Linux-f2fs-devel
2024-04-27 1:57 ` Chao Yu
@ 2024-04-29 17:37 ` Jaegeuk Kim
2024-04-29 17:42 ` Jaegeuk Kim
1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2024-04-29 17:37 UTC (permalink / raw)
To: Wu Bo; +Cc: Wu Bo, linux-kernel, Liao Yuanhong, linux-f2fs-devel
On 04/26, Wu Bo wrote:
> 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 <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
> fs/f2fs/data.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index d9494b5fc7c1..7ff5ad3fd5dc 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -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 ||
Modified a bit to address udiv issue like below. Let's see.
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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++;
> !f2fs_valid_pinned_area(sbi, pblock)) {
> bool last_extent = false;
>
> --
> 2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2
2024-04-29 17:37 ` Jaegeuk Kim
@ 2024-04-29 17:42 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2024-04-29 17:42 UTC (permalink / raw)
To: Wu Bo; +Cc: Wu Bo, linux-kernel, Liao Yuanhong, linux-f2fs-devel
On 04/29, Jaegeuk Kim wrote:
> On 04/26, Wu Bo wrote:
> > 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 <liaoyuanhong@vivo.com>
> > Signed-off-by: Wu Bo <bo.wu@vivo.com>
> > ---
> > fs/f2fs/data.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index d9494b5fc7c1..7ff5ad3fd5dc 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -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 ||
>
> Modified a bit to address udiv issue like below. Let's see.
Ok, I took v2 instead of this.
>
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -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++;
>
> > !f2fs_valid_pinned_area(sbi, pblock)) {
> > bool last_extent = false;
> >
> > --
> > 2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-29 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26 10:41 [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2 Wu Bo via Linux-f2fs-devel
2024-04-27 1:57 ` Chao Yu
2024-04-29 17:37 ` Jaegeuk Kim
2024-04-29 17:42 ` Jaegeuk Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).