All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] mkfs.f2fs: should give section-aligned reserved segments
@ 2024-02-24  1:14 Jaegeuk Kim
  2024-02-24  2:00 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2024-02-24  1:14 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

The reserved segments should be aligned to the section boundary.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 include/f2fs_fs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 9056e02acd29..2e93503cada9 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1771,7 +1771,8 @@ static inline double get_reserved(struct f2fs_super_block *sb, double ovp)
 	else
 		reserved = (100 / ovp + 1 + NR_CURSEG_TYPE) * segs_per_sec;
 
-	return reserved;
+	/* Let's keep the section alignment */
+	return round_up(reserved, segs_per_sec);
 }
 
 static inline double get_best_overprovision(struct f2fs_super_block *sb)
-- 
2.44.0.rc0.258.g7320e95886-goog



_______________________________________________
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 v2] mkfs.f2fs: should give section-aligned reserved segments
  2024-02-24  1:14 [f2fs-dev] [PATCH] mkfs.f2fs: should give section-aligned reserved segments Jaegeuk Kim
@ 2024-02-24  2:00 ` Jaegeuk Kim
  2024-03-08 16:44   ` Daeho Jeong
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2024-02-24  2:00 UTC (permalink / raw)
  To: linux-f2fs-devel

The reserved segments should be aligned to the section boundary.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---

  v2:
  - fix bug

 include/f2fs_fs.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 9056e02acd29..fc56396fa358 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1760,25 +1760,27 @@ extern uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb);
 #define ZONE_ALIGN(blks)	SIZE_ALIGN(blks, c.blks_per_seg * \
 					c.segs_per_zone)
 
-static inline double get_reserved(struct f2fs_super_block *sb, double ovp)
+static inline uint32_t get_reserved(struct f2fs_super_block *sb, double ovp)
 {
-	double reserved;
 	uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
 	uint32_t segs_per_sec = round_up(usable_main_segs, get_sb(section_count));
+	uint32_t reserved;
 
 	if (c.conf_reserved_sections)
 		reserved = c.conf_reserved_sections * segs_per_sec;
 	else
 		reserved = (100 / ovp + 1 + NR_CURSEG_TYPE) * segs_per_sec;
 
-	return reserved;
+	/* Let's keep the section alignment */
+	return round_up(reserved, segs_per_sec) * segs_per_sec;
 }
 
 static inline double get_best_overprovision(struct f2fs_super_block *sb)
 {
-	double reserved, ovp, candidate, end, diff, space;
+	double ovp, candidate, end, diff, space;
 	double max_ovp = 0, max_space = 0;
 	uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
+	uint32_t reserved;
 
 	if (get_sb(segment_count_main) < 256) {
 		candidate = 10;
@@ -1795,7 +1797,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
 		ovp = (usable_main_segs - reserved) * candidate / 100;
 		if (ovp < 0)
 			continue;
-		space = usable_main_segs - max(reserved, ovp) -
+		space = usable_main_segs - max((double)reserved, ovp) -
 					2 * get_sb(segs_per_sec);
 		if (max_space < space) {
 			max_space = space;
-- 
2.44.0.rc0.258.g7320e95886-goog



_______________________________________________
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 v2] mkfs.f2fs: should give section-aligned reserved segments
  2024-02-24  2:00 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
@ 2024-03-08 16:44   ` Daeho Jeong
  0 siblings, 0 replies; 3+ messages in thread
From: Daeho Jeong @ 2024-03-08 16:44 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

Reviewed-by: Daeho Jeong <daehojeong@google.com>

On Fri, Feb 23, 2024 at 6:02 PM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
>
> The reserved segments should be aligned to the section boundary.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>
>   v2:
>   - fix bug
>
>  include/f2fs_fs.h | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index 9056e02acd29..fc56396fa358 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -1760,25 +1760,27 @@ extern uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb);
>  #define ZONE_ALIGN(blks)       SIZE_ALIGN(blks, c.blks_per_seg * \
>                                         c.segs_per_zone)
>
> -static inline double get_reserved(struct f2fs_super_block *sb, double ovp)
> +static inline uint32_t get_reserved(struct f2fs_super_block *sb, double ovp)
>  {
> -       double reserved;
>         uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
>         uint32_t segs_per_sec = round_up(usable_main_segs, get_sb(section_count));
> +       uint32_t reserved;
>
>         if (c.conf_reserved_sections)
>                 reserved = c.conf_reserved_sections * segs_per_sec;
>         else
>                 reserved = (100 / ovp + 1 + NR_CURSEG_TYPE) * segs_per_sec;
>
> -       return reserved;
> +       /* Let's keep the section alignment */
> +       return round_up(reserved, segs_per_sec) * segs_per_sec;
>  }
>
>  static inline double get_best_overprovision(struct f2fs_super_block *sb)
>  {
> -       double reserved, ovp, candidate, end, diff, space;
> +       double ovp, candidate, end, diff, space;
>         double max_ovp = 0, max_space = 0;
>         uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
> +       uint32_t reserved;
>
>         if (get_sb(segment_count_main) < 256) {
>                 candidate = 10;
> @@ -1795,7 +1797,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
>                 ovp = (usable_main_segs - reserved) * candidate / 100;
>                 if (ovp < 0)
>                         continue;
> -               space = usable_main_segs - max(reserved, ovp) -
> +               space = usable_main_segs - max((double)reserved, ovp) -
>                                         2 * get_sb(segs_per_sec);
>                 if (max_space < space) {
>                         max_space = space;
> --
> 2.44.0.rc0.258.g7320e95886-goog
>
>
>
> _______________________________________________
> 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-03-08 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-24  1:14 [f2fs-dev] [PATCH] mkfs.f2fs: should give section-aligned reserved segments Jaegeuk Kim
2024-02-24  2:00 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
2024-03-08 16:44   ` Daeho Jeong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.