From patchwork Mon Dec 4 18:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13478860 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 E12C7C10DC3 for ; Mon, 4 Dec 2023 18:05:32 +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 1rADJy-0002sP-Uv; Mon, 04 Dec 2023 18:05:31 +0000 Received: from [172.30.20.202] (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 1rADJo-0002sH-54 for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=42FM9Lmlz3ljAIiJllHUD6LJzJkhOHhnO7eCP4sRhgQ=; b=DRrAu3lkC3gaEuboEUiaQF2gi6 m4ThnQEqOBHMmCJGus7eSv2/0/qPgZ+FVdnEB2qY4vnQzoKWY7RWq0vMX+Pbkmkm5TmGnVZX92bVE KzOpSbs2y8S1CcfoyxUBGJ2VlPA8PAyUcS7CQDwYjfEmoQrZu5O36STWDqEF9ErVo28Q=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=42FM9Lmlz3ljAIiJllHUD6LJzJkhOHhnO7eCP4sRhgQ=; b=J pkc5msFPIEhFNQCO8yDCTge+kunh/r/lCOCB08ntEWhZGxXm3PAu15INc/uVviQJW16MkAYa6TlDi csgj85cPb/taAb5Ns084Me9HEYdIcUZJ1aYRj9LMKspL3EkxuV2YF4OBNwPXEOcA8qzmhfj7Iqu5v 19IFSNq/TNJNHY1w=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rADJl-0003Tr-UJ for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B43BD61012 for ; Mon, 4 Dec 2023 18:04:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50B42C433C8; Mon, 4 Dec 2023 18:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701713070; bh=mUugqGoNQY22hq7LD3Ng4JWWKEvMHSmLjfx04YNhku8=; h=From:To:Cc:Subject:Date:From; b=Ur12VQb4BP2PBWEsFOMmdyNuhOyOq9zdSRy80z1wC0D7+LaHAetoEvrqRb8zl2OrA V6RUsswTmytl3T/Q13d4lM8GRErmj202ovcKxAKrbhk+YnskL2w2+5Nq8eHkrxWsSA U2ytjP22b1y1jF4ckQB7Hs47rrKovgL1lslvSRsTvx93ilLOhIqHfJ9x+cdD0LjX8u oFYTcniGkb2iMOVXhyuHeDgrQ+8HQHyu9uiYJdaFF5AXSmyXEkOk4LkSb4bdzbSi5B HOAihdb8gM/T0oxKmrfe0hdiPqSB7hNaTXN/qGqnsvchwh26BFRLDq6SMfwBz/qrNy 2IRyswgB7RFHg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Mon, 4 Dec 2023 10:04:25 -0800 Message-ID: <20231204180428.925779-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog MIME-Version: 1.0 X-Headers-End: 1rADJl-0003Tr-UJ Subject: [f2fs-dev] [PATCH 1/4] f2fs: allocate new section if it's not new 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net If fsck can allocate a new zone, it'd be better to use that instead of allocating a new one. And, it modifies kernel messages. Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 08e2f44a1264..9081c9af977a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4949,20 +4949,18 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi, return ret; } - if (is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { - /* - * If there are valid blocks and the write pointer doesn't match - * with them, we need to report the inconsistency and fill - * the zone till the end to close the zone. This inconsistency - * does not cause write error because the zone will not be - * selected for write operation until it get discarded. - */ - f2fs_notice(sbi, "Valid blocks are not aligned with write " + /* + * If there are valid blocks and the write pointer doesn't match + * with them, we need to report the inconsistency and fill + * the zone till the end to close the zone. This inconsistency + * does not cause write error because the zone will not be + * selected for write operation until it get discarded. + */ + f2fs_notice(sbi, "Valid blocks are not aligned with write " "pointer: valid block[0x%x,0x%x] wp[0x%x,0x%x]", GET_SEGNO(sbi, last_valid_block), GET_BLKOFF_FROM_SEG0(sbi, last_valid_block), wp_segno, wp_blkoff); - } ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH, zone->start, zone->len, GFP_NOFS); @@ -5053,15 +5051,18 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type) f2fs_notice(sbi, "Unaligned curseg[%d] with write pointer: " "curseg[0x%x,0x%x] wp[0x%x,0x%x]", type, cs->segno, cs->next_blkoff, wp_segno, wp_blkoff); - } else { - f2fs_notice(sbi, "Not successfully unmounted in the previous " - "mount"); } - f2fs_notice(sbi, "Assign new section to curseg[%d]: " - "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff); + /* Allocate a new section if it's not new. */ + if (cs->next_blkoff) { + unsigned int old_segno = cs->segno, old_blkoff = cs->next_blkoff; - f2fs_allocate_new_section(sbi, type, true); + f2fs_allocate_new_section(sbi, type, true); + f2fs_notice(sbi, "Assign new section to curseg[%d]: " + "[0x%x,0x%x] -> [0x%x,0x%x]", + type, old_segno, old_blkoff, + cs->segno, cs->next_blkoff); + } /* check consistency of the zone curseg pointed to */ if (check_zone_write_pointer(sbi, zbd, &zone)) From patchwork Mon Dec 4 18:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13478862 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 72712C4167B for ; Mon, 4 Dec 2023 18:05:39 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rADK5-0007cy-Rd; Mon, 04 Dec 2023 18:05:38 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rADK0-0007ce-QF for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HG1CNJnpPUlkDrsPt6amTonclUxN4+/BtlTyq8ecSeU=; b=PO6vMO8kjKgZP9yQCTKxz1rmP7 1fxSYNQpPyHZ/jsYOAn4wfFnh/CTkL4m66HYU/wC2yfQKaHdBUx447sKEz5/7EOeK0oEyl2gF76nS 26pAoViWt2q2cH31aVyPk/6fZDnV2UjKj3bSFU9zdwh8N4fv3kVyIGsEBA7SUUTBwm40=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HG1CNJnpPUlkDrsPt6amTonclUxN4+/BtlTyq8ecSeU=; b=Z1sEA5sNrgW571uzxEgjvcNZCc tnwWmxKtru2Kuatv6TmVD6fs1C4/496ef5hYXdp3Qu6AECGRkMHu7nJRvovnSf8Om7zr2ZZzzFvfb NumCjgpmy8aXkFXT/lbczRagpkg+wThyrsGZgIiKiFFVJfMGmMshdHTpJmcL5rx6Gw0E=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rADJl-0003Tx-Ng for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 93233CE1275 for ; Mon, 4 Dec 2023 18:04:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0FCCC433C7; Mon, 4 Dec 2023 18:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701713071; bh=5uILUttJEnB7yuvoHAjCIDDFlCw2Yu+1VyECoAyrkIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Px+gBEtB5gOIxbUSaHIJWKJfoWuoWSWnf7cNY1RJkYdRobSfs0sVl4iE/qxgEtBeC 5EkByepKhfdqd782afxg8sn7qQ9SgjZqXqgTD1CmLpXx5NyNMIINjUeXi16A6M1Qud S2t0nAjbzFCinfGqKkxBKhqXqWMKZfmG0lBUkIl+zn7TK5Y0kddtUEukKPNSgRDwu1 C1XqibzWN3PfcchsBmRftLKw51hSZMR8IwVhMNlSjq0l++nP9xOGm3IMwqrI8j9dj4 Y1htIwkHuZKcIZToWAm1OTPtzVntKrS5hS1ol1m/eIpqrBo8bnZUXlfmCty/tS+wVj E1rYcTfM4OFBQ== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Mon, 4 Dec 2023 10:04:26 -0800 Message-ID: <20231204180428.925779-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231204180428.925779-1-jaegeuk@kernel.org> References: <20231204180428.925779-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rADJl-0003Tx-Ng Subject: [f2fs-dev] [PATCH 2/4] f2fs: fix write pointers on zoned device after roll forward 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 1. do roll forward recovery 2. update current segments pointers 3. fix the entire zones' write pointers 4. do checkpoint Signed-off-by: Jaegeuk Kim --- fs/f2fs/recovery.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 16415c770b45..d0f24ccbd1ac 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -917,6 +917,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) && f2fs_sb_has_blkzoned(sbi)) { err = f2fs_fix_curseg_write_pointer(sbi); + if (!err) + err = f2fs_check_write_pointer(sbi); ret = err; } From patchwork Mon Dec 4 18:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13478863 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 BFB72C4167B for ; Mon, 4 Dec 2023 18:05:45 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rADKD-0008Ht-1X; Mon, 04 Dec 2023 18:05:45 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rADK1-0008Hl-0C for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bHgvlR7opcdsXndy/cEVWyidzHDwr/pEoNe0B44Z2W0=; b=JOKL5pGWSbVcEuZ7fZqOwvpAVe HyN2KdyyR0wlfSRtwTi2b3y5bK8BUSyxxJg8sTGFvc7sWbZvTUK7WbGx07WD98LVL9aUA0HkEM8BB 7SfYtk2iin+DBJ4oHcugmZVjYoheEpczwUBodl35qAoy4BfG/0j+aoKop/GsQdHFSnyM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bHgvlR7opcdsXndy/cEVWyidzHDwr/pEoNe0B44Z2W0=; b=OyRG6DnZB7siensKmoLcUg99Ua c37oqNaID5a0M8bs5nQYoPp8mcRfT/GEWC7mNE+BIakDGWAAwqHFikc3NCdNmlEgtBQIMiAvQvwkh NnoiROHmp/daIllVNEdoTWdyMaZZ7DMHoV/1I6JsqVFO+ppUv/ybdqk35HvdsuGPqNk0=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rADJl-0003Tz-P5 for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E1D6DCE127D for ; Mon, 4 Dec 2023 18:04:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D72FC433C8; Mon, 4 Dec 2023 18:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701713073; bh=0phZvSzPedzW6aghBJdL/2EodTWmVUATApogRYUPDL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJUpsYKjhndUIiQOWhL/JnuOSKRB4lZI+bnPJji3zxHnVVmcPDhoE/U0MgdbyqWrs zgqIk78WA38WbHWv8Xn/2rJyK5Aeh7aF4VWtrnadkOBuzDx1IJPFp91pgOS1pZPnX5 4fjfBp8Z4ioemkmo0f5iq/aQ8ngMnYp+fdDEZaBU2uDlTvf35o8taW9N0hE4jcuFjE nQv9bB/Mb8Zb/2tCyrBPTCrNs0QKiKi06ePBjMHppvd/tY00JhKNmm3CS2Axk0AMSu 4iKlvZcfK8Opeqt44AlZe+tmTLGnOZSwiRBaHcX/aEgLNdSvCgggjf/WVmcHTjf9Rf 2UDGeWImdFb3A== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Mon, 4 Dec 2023 10:04:27 -0800 Message-ID: <20231204180428.925779-3-jaegeuk@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231204180428.925779-1-jaegeuk@kernel.org> References: <20231204180428.925779-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rADJl-0003Tz-P5 Subject: [f2fs-dev] [PATCH 3/4] f2fs: check write pointers when checkpoint=disable 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Even if f2fs was rebooted as staying checkpoint=disable, let's match the write pointers all the time. Signed-off-by: Jaegeuk Kim --- fs/f2fs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 617340e9ea7f..9a874b4d1501 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4741,7 +4741,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) #ifdef CONFIG_QUOTA f2fs_recover_quota_end(sbi, quota_enabled); #endif - +reset_checkpoint: /* * If the f2fs is not readonly and fsync data recovery succeeds, * check zoned block devices' write pointer consistency. @@ -4752,7 +4752,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_meta; } -reset_checkpoint: f2fs_init_inmem_curseg(sbi); /* f2fs_recover_fsync_data() cleared this already */ From patchwork Mon Dec 4 18:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13478861 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 B2CDCC4167B for ; Mon, 4 Dec 2023 18:05:32 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rADJz-0006eh-T6; Mon, 04 Dec 2023 18:05:31 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rADJp-0006eb-0D for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Qu2RYnE4w04GzUb84LXo4r2mK/f+/R1xC48mOPscul4=; b=Ig/VjqQeGRDczVHTvogHFC86As k+x12NCisV2d31mQA68hXNvYVyfZusnHeGd53U25tbNLdZDE+EGgptu6OnT2ylV7I+c0uud8L89rR 87HhHy5oyGeOsuVN8j5vG16jS09aQsXMA2+OMT9ywLBVRk6RXOqPhaiGm4dMg2exE+f4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Qu2RYnE4w04GzUb84LXo4r2mK/f+/R1xC48mOPscul4=; b=XSrlWsgnaIdFY01R51dti/vzTO PRPSWyijumMcIwvHEath/Z6gAXY55MbFzw/Q/ygTqvIAzPj6V2IFC6HY62Pi7TunlzSkOcelBDQ9I +SxCpVvsxu0B7+PsqkZQb6tr6s3YnS21NFO5jtVLlBV1C+tWnxINYXzHBLzsKOQTej8k=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rADJl-0003U2-Ny for linux-f2fs-devel@lists.sourceforge.net; Mon, 04 Dec 2023 18:05:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 400F9612AF for ; Mon, 4 Dec 2023 18:04:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63F04C433C7; Mon, 4 Dec 2023 18:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701713074; bh=PwUOwNlOAh2R10G7w1lvJbSsW8uLBZf2Vd4s/Pbn7C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9AVu69ZIryiI3PhsohcgkW8Ue+YPlthWMUoLAFbugh0wVR0eRz52wYTvFetN7lLM Ayvhjb1AWpSA7eXj0iPh/lPKVtfQ3okc92q0NVjScrt7EMybF59PIyaL5i35o0omPk DH8fpVlcfLJ4GzcsktlKTHNrd63uPfr43VSxb/Pynleq5c4BKvZb84za+YKO9bfMeM Mt+umIlYcJw42krd+AtLNbJoAf8tJFx9dO67tOcW6slFzyRPyq9IGL97O05PvCp1n4 ZHL1k3iv8Nja/QL8IBtFLS/Zc+tYm7QMtuZx9aANQUksIkTr5LhjWKdecJnoTvl91L ucNJDY53woRnQ== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Mon, 4 Dec 2023 10:04:28 -0800 Message-ID: <20231204180428.925779-4-jaegeuk@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231204180428.925779-1-jaegeuk@kernel.org> References: <20231204180428.925779-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rADJl-0003U2-Ny Subject: [f2fs-dev] [PATCH 4/4] f2fs: let's finish or reset zones all the time 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In order to limit # of open zones, let's finish or reset zones given # of valid blocks per section and its zone condition. Signed-off-by: Jaegeuk Kim Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.c | 74 +++++++++++------------------------------------ 1 file changed, 17 insertions(+), 57 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9081c9af977a..5696a4d381ff 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4870,82 +4870,44 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi, struct f2fs_dev_info *fdev, struct blk_zone *zone) { - unsigned int wp_segno, wp_blkoff, zone_secno, zone_segno, segno; - block_t zone_block, wp_block, last_valid_block; + unsigned int zone_segno; + block_t zone_block, wp_block, valid_block_cnt; unsigned int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT; - int i, s, b, ret; - struct seg_entry *se; + int ret; if (zone->type != BLK_ZONE_TYPE_SEQWRITE_REQ) return 0; wp_block = fdev->start_blk + (zone->wp >> log_sectors_per_block); - wp_segno = GET_SEGNO(sbi, wp_block); - wp_blkoff = wp_block - START_BLOCK(sbi, wp_segno); zone_block = fdev->start_blk + (zone->start >> log_sectors_per_block); zone_segno = GET_SEGNO(sbi, zone_block); - zone_secno = GET_SEC_FROM_SEG(sbi, zone_segno); - - if (zone_segno >= MAIN_SEGS(sbi)) - return 0; /* * Skip check of zones cursegs point to, since * fix_curseg_write_pointer() checks them. */ - for (i = 0; i < NO_CHECK_TYPE; i++) - if (zone_secno == GET_SEC_FROM_SEG(sbi, - CURSEG_I(sbi, i)->segno)) - return 0; + if (zone_segno >= MAIN_SEGS(sbi) || + IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno))) + return 0; /* - * Get last valid block of the zone. + * Get # of valid block of the zone. */ - last_valid_block = zone_block - 1; - for (s = sbi->segs_per_sec - 1; s >= 0; s--) { - segno = zone_segno + s; - se = get_seg_entry(sbi, segno); - for (b = sbi->blocks_per_seg - 1; b >= 0; b--) - if (f2fs_test_bit(b, se->cur_valid_map)) { - last_valid_block = START_BLOCK(sbi, segno) + b; - break; - } - if (last_valid_block >= zone_block) - break; - } + valid_block_cnt = get_valid_blocks(sbi, zone_segno, true); - /* - * When safely unmounted in the previous mount, we can trust write - * pointers. Otherwise, finish zones. - */ - if (is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { - /* - * The write pointer matches with the valid blocks or - * already points to the end of the zone. - */ - if ((last_valid_block + 1 == wp_block) || - (zone->wp == zone->start + zone->len)) - return 0; - } + if ((!valid_block_cnt && zone->cond == BLK_ZONE_COND_EMPTY) || + (valid_block_cnt && zone->cond == BLK_ZONE_COND_FULL)) + return 0; - if (last_valid_block + 1 == zone_block) { - if (is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { - /* - * If there is no valid block in the zone and if write - * pointer is not at zone start, reset the write - * pointer. - */ - f2fs_notice(sbi, - "Zone without valid block has non-zero write " - "pointer. Reset the write pointer: wp[0x%x,0x%x]", - wp_segno, wp_blkoff); - } + if (!valid_block_cnt) { + f2fs_notice(sbi, "Zone without valid block has non-zero write " + "pointer. Reset the write pointer: cond[0x%x]", + zone->cond); ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block, zone->len >> log_sectors_per_block); if (ret) f2fs_err(sbi, "Discard zone failed: %s (errno=%d)", fdev->path, ret); - return ret; } @@ -4957,10 +4919,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi, * selected for write operation until it get discarded. */ f2fs_notice(sbi, "Valid blocks are not aligned with write " - "pointer: valid block[0x%x,0x%x] wp[0x%x,0x%x]", - GET_SEGNO(sbi, last_valid_block), - GET_BLKOFF_FROM_SEG0(sbi, last_valid_block), - wp_segno, wp_blkoff); + "pointer: valid block[0x%x,0x%x] cond[0x%x]", + zone_segno, valid_block_cnt, zone->cond); ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH, zone->start, zone->len, GFP_NOFS);