From patchwork Mon Oct 7 05:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggil Song X-Patchwork-Id: 13824063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D0D2CFB440 for ; Mon, 7 Oct 2024 05:21:42 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sxgBg-0006bC-5v; Mon, 07 Oct 2024 05:21:40 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sxgBe-0006b5-2z for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Oct 2024 05:21:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:Content-Type:Content-Transfer-Encoding: Date:Message-ID:To:From:Sender:Reply-To:Subject:Mime-Version:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XkPIRM3U4jCdaiGC4n343ikwc4gQdie3fQQ4q/mvRqQ=; b=AlAtzQVClbO6nHx/DCS9T2RyBK LaxGdin/bR0GWPJLf5hl4hktQfxSv4BGICjsmgYRrgvwC+bEZmHrWrxIj6DVFhEEA3Waws2kCYePO N4U1Gm1DTrUjGFpjdNhmPehExa6OW4tOC+gGGhH84mKsAI06w3COdffrzzToU50Z9SAQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:Content-Type:Content-Transfer-Encoding:Date:Message-ID:To:From :Sender:Reply-To:Subject:Mime-Version:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=XkPIRM3U4jCdaiGC4n343ikwc4gQdie3fQQ4q/mvRqQ=; b=K YhV6HNwjrq0mHLNj0A1RmWgE7yqadsHhveGuPh8MvI7PtnHQAW4WPb0hVRZH4Z9ReoKHhGo/03tup +lOEX8AgN7Koh0jMK9zLQDfu2XlPHCSfDAwbfkFbGxIXdyLTX64PJiFSzBhd/tQ/XiiUViFZnkhtW Ckx8cBWMzVXRBsbY=; Received: from mailout1.samsung.com ([203.254.224.24]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sxgBb-0002oV-Fm for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Oct 2024 05:21:38 +0000 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241007052123epoutp0162001d0c9502fd171680f6f076a09bcb~8FB_z1VT72939029390epoutp01W for ; Mon, 7 Oct 2024 05:21:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241007052123epoutp0162001d0c9502fd171680f6f076a09bcb~8FB_z1VT72939029390epoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1728278483; bh=XkPIRM3U4jCdaiGC4n343ikwc4gQdie3fQQ4q/mvRqQ=; h=Subject:Reply-To:From:To:Date:References:From; b=cpMQn3yQZNbEOsIPwpxlHj6Aar/SeHAbVzrOO791fLvXwkojSVEGSs2Ynn75zem0K rpgY5MjmAiNT/tpzaHsq/EovNGzXUBsg2Ui77dLONghgCMjMyNBuVf08IWjz93FUzO 4RdOXUCmeh1wYKk6dv2CEr7oQSeCcE6hxG2szh+s= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20241007052123epcas2p447dbc2e44eb1561a43a0686ad3fe3151~8FB_exGLD3151631516epcas2p4g; Mon, 7 Oct 2024 05:21:23 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.70]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XMSDf32gpz4x9Q3; Mon, 7 Oct 2024 05:21:22 +0000 (GMT) X-AuditID: b6c32a4d-183ff70000004a06-ad-67036fd2976e Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id C7.AA.18950.2DF63076; Mon, 7 Oct 2024 14:21:22 +0900 (KST) Mime-Version: 1.0 From: Yonggil Song To: "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , Dongjin Kim , Yonggil Song , Siwoo Jung , Daejun Park X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8> Date: Mon, 07 Oct 2024 14:21:22 +0900 X-CMS-MailID: 20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmme6lfOZ0g9fXxSxOTz3LZLHqQbjF j5MmFk/Wz2K2uLTI3eLy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4QafKI1u88VpHYKvzkh0XR+qyNp9osFv3rurFls0NMRrPnCaHeWc/zhNzu3/BerMRS nJFoqMVcVJwIANoEqBEMBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303 References: X-Headers-End: 1sxgBb-0002oV-Fm Subject: [f2fs-dev] [PATCH] libf2fs: Fix calculation of usable segments for single zoned X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: yonggil.song@samsung.com Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 --- 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);