mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yonggil Song <yonggil.song@samsung.com>
To: "jaegeuk@kernel.org" <jaegeuk@kernel.org>,
	"chao@kernel.org" <chao@kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Dongjin Kim <dongjin_.kim@samsung.com>,
	Yonggil Song <yonggil.song@samsung.com>,
	Siwoo Jung <siu.jung@samsung.com>,
	Daejun Park <daejun7.park@samsung.com>
Subject: [PATCH] libf2fs: Fix calculation of usable segments for single zoned
Date: Mon, 07 Oct 2024 14:21:22 +0900	[thread overview]
Message-ID: <20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8> (raw)
In-Reply-To: <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8>

There was a bug that did not subtract the super block area when calculating
the usable segments for a single zoned device with a conventional zone.
This bug resulted in incorrect the overprovision and reserved area.

	<256MiB legacy block + zoned block w/ 32MiB zone size>
	Info: Overprovision ratio = 3.570%
	Info: Overprovision segments = 656 (GC reserved = 560)

	<8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
	Info: Overprovision ratio = 3.700%
	Info: Overprovision segments = 676 (GC reserved = 578)

This patch fixes the bug by subtracting the super block area when there is
only one zoned device.

Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
---
 lib/libf2fs_zoned.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 89ba5ad73a76..cc5c064b7e3e 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
 	}
 	usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
 						get_sb(log_blocks_per_seg);
+
+	/* single zoned device needs to remove a super block area */
+	if (c.ndevs == 1)
+		usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
+
 	return usable_segs;
 #endif
 	return get_sb(segment_count_main);
-- 
2.43.0

       reply	other threads:[~2024-10-07  5:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8>
2024-10-07  5:21 ` Yonggil Song [this message]
2024-10-08  9:02   ` Chao Yu
2024-10-08 13:16   ` Markus Elfring
     [not found]   ` <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p2>
2024-10-10  2:15     ` Yonggil Song
2024-10-10  4:31     ` Yonggil Song
     [not found]   ` <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p7>
2024-10-10  4:59     ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Yonggil Song
2024-10-11 15:34       ` Jaegeuk Kim
     [not found]       ` <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p3>
2024-10-14  1:43         ` Yonggil Song
2024-10-10  5:08 ` [RESEND][PATCH v2] libf2fs: Fix calculation of usable segments for single zoned device Yonggil Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8 \
    --to=yonggil.song@samsung.com \
    --cc=chao@kernel.org \
    --cc=daejun7.park@samsung.com \
    --cc=dongjin_.kim@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=siu.jung@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®