linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks()
@ 2024-05-15  8:24 Liao Yuanhong via Linux-f2fs-devel
  2024-05-16  8:06 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Liao Yuanhong via Linux-f2fs-devel @ 2024-05-15  8:24 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: Liao Yuanhong, linux-kernel, bo.wu, linux-f2fs-devel

Currently, when we allocating a swap file on zone UFS, this file will
created on conventional UFS. If the swap file size is not aligned with the
zone size, the last extent will enter f2fs_migrate_blocks(), resulting in
significant additional I/O overhead and prolonged lock occupancy. In most
cases, this is unnecessary, because on Conventional UFS, as long as the
start block of the swap file is aligned with zone, it is sequentially
aligned.To circumvent this issue, we have altered the conditions for
entering f2fs_migrate_blocks(). Now, if the start block of the last extent
is aligned with the start of zone, we avoids entering
f2fs_migrate_blocks().

Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
 fs/f2fs/data.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 50ceb25b3..4d58fb6c2 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3925,10 +3925,12 @@ static int check_swap_activate(struct swap_info_struct *sis,
 	block_t pblock;
 	block_t lowest_pblock = -1;
 	block_t highest_pblock = 0;
+	block_t blk_start;
 	int nr_extents = 0;
 	unsigned int nr_pblocks;
 	unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
 	unsigned int not_aligned = 0;
+	unsigned int cur_sec;
 	int ret = 0;
 
 	/*
@@ -3965,23 +3967,39 @@ 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) % blks_per_sec ||
+		blk_start = pblock - SM_I(sbi)->main_blkaddr;
+
+		if (blk_start % blks_per_sec ||
 				nr_pblocks % blks_per_sec ||
 				!f2fs_valid_pinned_area(sbi, pblock)) {
 			bool last_extent = false;
 
 			not_aligned++;
 
+			cur_sec = (blk_start + nr_pblocks) / BLKS_PER_SEC(sbi);
 			nr_pblocks = roundup(nr_pblocks, blks_per_sec);
-			if (cur_lblock + nr_pblocks > sis->max)
+			if (cur_lblock + nr_pblocks > sis->max) {
 				nr_pblocks -= blks_per_sec;
 
+				/* the start address is aligned to section */
+				if (!(blk_start % blks_per_sec))
+					last_extent = true;
+			}
+
 			/* this extent is last one */
 			if (!nr_pblocks) {
 				nr_pblocks = last_lblock - cur_lblock;
 				last_extent = true;
 			}
 
+			/*
+			 * the last extent which located on conventional UFS doesn't
+			 * need migrate
+			 */
+			if (last_extent && f2fs_sb_has_blkzoned(sbi) &&
+				cur_sec < GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi)))
+				goto next;
+
 			ret = f2fs_migrate_blocks(inode, cur_lblock,
 							nr_pblocks);
 			if (ret) {
@@ -3994,6 +4012,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
 				goto retry;
 		}
 
+next:
 		if (cur_lblock + nr_pblocks >= sis->max)
 			nr_pblocks = sis->max - cur_lblock;
 
-- 
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] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks()
  2024-05-15  8:24 [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks() Liao Yuanhong via Linux-f2fs-devel
@ 2024-05-16  8:06 ` Chao Yu
  2024-05-16  8:53   ` Wu Bo via Linux-f2fs-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2024-05-16  8:06 UTC (permalink / raw)
  To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel

On 2024/5/15 16:24, Liao Yuanhong wrote:
> Currently, when we allocating a swap file on zone UFS, this file will
> created on conventional UFS. If the swap file size is not aligned with the
> zone size, the last extent will enter f2fs_migrate_blocks(), resulting in
> significant additional I/O overhead and prolonged lock occupancy. In most
> cases, this is unnecessary, because on Conventional UFS, as long as the
> start block of the swap file is aligned with zone, it is sequentially
> aligned.To circumvent this issue, we have altered the conditions for
> entering f2fs_migrate_blocks(). Now, if the start block of the last extent
> is aligned with the start of zone, we avoids entering
> f2fs_migrate_blocks().

Hi,

Is it possible that we can pin swapfile, and fallocate on it aligned to
zone size, then mkswap and swapon?

Thanks,

> 
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
>   fs/f2fs/data.c | 23 +++++++++++++++++++++--
>   1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 50ceb25b3..4d58fb6c2 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3925,10 +3925,12 @@ static int check_swap_activate(struct swap_info_struct *sis,
>          block_t pblock;
>          block_t lowest_pblock = -1;
>          block_t highest_pblock = 0;
> +       block_t blk_start;
>          int nr_extents = 0;
>          unsigned int nr_pblocks;
>          unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
>          unsigned int not_aligned = 0;
> +       unsigned int cur_sec;
>          int ret = 0;
> 
>          /*
> @@ -3965,23 +3967,39 @@ 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) % blks_per_sec ||
> +               blk_start = pblock - SM_I(sbi)->main_blkaddr;
> +
> +               if (blk_start % blks_per_sec ||
>                                  nr_pblocks % blks_per_sec ||
>                                  !f2fs_valid_pinned_area(sbi, pblock)) {
>                          bool last_extent = false;
> 
>                          not_aligned++;
> 
> +                       cur_sec = (blk_start + nr_pblocks) / BLKS_PER_SEC(sbi);
>                          nr_pblocks = roundup(nr_pblocks, blks_per_sec);
> -                       if (cur_lblock + nr_pblocks > sis->max)
> +                       if (cur_lblock + nr_pblocks > sis->max) {
>                                  nr_pblocks -= blks_per_sec;
> 
> +                               /* the start address is aligned to section */
> +                               if (!(blk_start % blks_per_sec))
> +                                       last_extent = true;
> +                       }
> +
>                          /* this extent is last one */
>                          if (!nr_pblocks) {
>                                  nr_pblocks = last_lblock - cur_lblock;
>                                  last_extent = true;
>                          }
> 
> +                       /*
> +                        * the last extent which located on conventional UFS doesn't
> +                        * need migrate
> +                        */
> +                       if (last_extent && f2fs_sb_has_blkzoned(sbi) &&
> +                               cur_sec < GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi)))
> +                               goto next;
> +
>                          ret = f2fs_migrate_blocks(inode, cur_lblock,
>                                                          nr_pblocks);
>                          if (ret) {
> @@ -3994,6 +4012,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
>                                  goto retry;
>                  }
> 
> +next:
>                  if (cur_lblock + nr_pblocks >= sis->max)
>                          nr_pblocks = sis->max - cur_lblock;
> 
> --
> 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] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks()
  2024-05-16  8:06 ` Chao Yu
@ 2024-05-16  8:53   ` Wu Bo via Linux-f2fs-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Wu Bo via Linux-f2fs-devel @ 2024-05-16  8:53 UTC (permalink / raw)
  To: chao; +Cc: jaegeuk, linux-kernel, liaoyuanhong, bo.wu, linux-f2fs-devel

On Thu, May 16, 2024 at 04:06:34PM +0800, Chao Yu wrote:
> On 2024/5/15 16:24, Liao Yuanhong wrote:
> > Currently, when we allocating a swap file on zone UFS, this file will
> > created on conventional UFS. If the swap file size is not aligned with the
> > zone size, the last extent will enter f2fs_migrate_blocks(), resulting in
> > significant additional I/O overhead and prolonged lock occupancy. In most
> > cases, this is unnecessary, because on Conventional UFS, as long as the
> > start block of the swap file is aligned with zone, it is sequentially
> > aligned.To circumvent this issue, we have altered the conditions for
> > entering f2fs_migrate_blocks(). Now, if the start block of the last extent
> > is aligned with the start of zone, we avoids entering
> > f2fs_migrate_blocks().
> 
> Hi,
> 
> Is it possible that we can pin swapfile, and fallocate on it aligned to
> zone size, then mkswap and swapon?

User can't see if the device is zoned device. And if f2fs fallocate to align
size to zone size, too much space may be wasted? Some zoned devices has a very
large zone size(>1G)

> 
> Thanks,
> 
> > 
> > Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> > Signed-off-by: Wu Bo <bo.wu@vivo.com>
> > ---
> >   fs/f2fs/data.c | 23 +++++++++++++++++++++--
> >   1 file changed, 21 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 50ceb25b3..4d58fb6c2 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -3925,10 +3925,12 @@ static int check_swap_activate(struct swap_info_struct *sis,
> >          block_t pblock;
> >          block_t lowest_pblock = -1;
> >          block_t highest_pblock = 0;
> > +       block_t blk_start;
> >          int nr_extents = 0;
> >          unsigned int nr_pblocks;
> >          unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
> >          unsigned int not_aligned = 0;
> > +       unsigned int cur_sec;
> >          int ret = 0;
> > 
> >          /*
> > @@ -3965,23 +3967,39 @@ 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) % blks_per_sec ||
> > +               blk_start = pblock - SM_I(sbi)->main_blkaddr;
> > +
> > +               if (blk_start % blks_per_sec ||
> >                                  nr_pblocks % blks_per_sec ||
> >                                  !f2fs_valid_pinned_area(sbi, pblock)) {
> >                          bool last_extent = false;
> > 
> >                          not_aligned++;
> > 
> > +                       cur_sec = (blk_start + nr_pblocks) / BLKS_PER_SEC(sbi);
> >                          nr_pblocks = roundup(nr_pblocks, blks_per_sec);
> > -                       if (cur_lblock + nr_pblocks > sis->max)
> > +                       if (cur_lblock + nr_pblocks > sis->max) {
> >                                  nr_pblocks -= blks_per_sec;
> > 
> > +                               /* the start address is aligned to section */
> > +                               if (!(blk_start % blks_per_sec))
> > +                                       last_extent = true;
> > +                       }
> > +
> >                          /* this extent is last one */
> >                          if (!nr_pblocks) {
> >                                  nr_pblocks = last_lblock - cur_lblock;
> >                                  last_extent = true;
> >                          }
> > 
> > +                       /*
> > +                        * the last extent which located on conventional UFS doesn't
> > +                        * need migrate
> > +                        */
> > +                       if (last_extent && f2fs_sb_has_blkzoned(sbi) &&
> > +                               cur_sec < GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi)))
> > +                               goto next;
> > +
> >                          ret = f2fs_migrate_blocks(inode, cur_lblock,
> >                                                          nr_pblocks);
> >                          if (ret) {
> > @@ -3994,6 +4012,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
> >                                  goto retry;
> >                  }
> > 
> > +next:
> >                  if (cur_lblock + nr_pblocks >= sis->max)
> >                          nr_pblocks = sis->max - cur_lblock;
> > 
> > --
> > 2.25.1
> > 
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2024-05-16  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  8:24 [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks() Liao Yuanhong via Linux-f2fs-devel
2024-05-16  8:06 ` Chao Yu
2024-05-16  8:53   ` Wu Bo via Linux-f2fs-devel

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).