From patchwork Wed Mar 5 11:05:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 14002456 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 D1F88C282E3 for ; Wed, 5 Mar 2025 11:05:31 +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 1tpmZ7-000819-4E; Wed, 05 Mar 2025 11:05:28 +0000 Received: from [172.30.29.66] (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 1tpmZ6-000813-47 for linux-f2fs-devel@lists.sourceforge.net; Wed, 05 Mar 2025 11:05:27 +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=696eTfI3wzHBFDS8ulpC+SspCgRAhIWnHtJ7HkvI+gE=; b=mJwObgQ0MOWjPb2B8+SPwONxUM HlLMXgfgp0kBjMXWiSMoqTriHd+zHesPhV+vWVEO62z+uGqrgXPP4QbE8YbwIfNIFXP5qszrPFHeP 3PZc23QgN9M4Jq25pOQjadAaeF1M+DNDxXaJ3ImsmrIP25c4piMeBENcvBBVAp1qg6KY=; 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=696eTfI3wzHBFDS8ulpC+SspCgRAhIWnHtJ7HkvI+gE=; b=c 4bMD0r/0jDTcdEPoLYIG3pHwEagSP9tH1AFya72P9IqYSF/j4k6InuowYicUOBYXdKt1o4r9Phage vbud49lm+wwhtggfYrKmY23wjRu2/pgOCAO79WYdOeUm23iwScCPHaDktNlZjHdH0DDqMmxmFPTbo LMjm1lPakqr8vVmM=; 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 1tpmZ4-0000Ys-Qm for linux-f2fs-devel@lists.sourceforge.net; Wed, 05 Mar 2025 11:05:27 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 99F605C4BED for ; Wed, 5 Mar 2025 11:03:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CCBAC4AF09; Wed, 5 Mar 2025 11:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741172721; bh=cbnf2Wz08VaaoY4VPV3r2qQqn0Gxg/9gzwltBcOCobA=; h=From:To:Cc:Subject:Date:From; b=m8C1e4GNyzUgelI2wn1alWkJFohLIZsLgxbMSEQBcmmJLLng3GiL9C5yHaMlDSHmr NWQECINZOSYvD9aicpNP+Dxbh3RFnCKdv6Fs+NtVVDE8y8jF9bliUYkQ0/gEAedcW7 GOdp0GFy7vtmaPf4TJCTbnIrfaXVEEVKjKBZ5+FS+Lynhb7Qy9pF7wLjlRyLl2YZhM lHXT6TqAPawlA+l5s3yO/9bKGpXAV2VvkOiCoRMJ++6V7GPu0nAy4czg6VWPjkfZT3 EwycHJ4MtW3gJA1jpkJuGYJ3NI38k/6GbdxxReAa0SNkzkvPH6vqMqvpRDFHYHXoRW LrBQXNNClDF5w== To: jaegeuk@kernel.org Date: Wed, 5 Mar 2025 19:05:05 +0800 Message-ID: <20250305110506.2113560-1-chao@kernel.org> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog MIME-Version: 1.0 X-Headers-End: 1tpmZ4-0000Ys-Qm Subject: [f2fs-dev] [PATCH] f2fs-tools: disable nat_bits by default in Android 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: , X-Patchwork-Original-From: Chao Yu via Linux-f2fs-devel From: Chao Yu Reply-To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch turns off nat_bits feature by default in Android, for other scenario, keep it on and keep an eye on it. Signed-off-by: Chao Yu --- fsck/mount.c | 3 ++- include/f2fs_fs.h | 6 ++++++ mkfs/f2fs_format.c | 3 ++- mkfs/f2fs_format_main.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index a189ba7..2f4c631 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -1708,7 +1708,8 @@ u32 update_nat_bits_flags(struct f2fs_super_block *sb, nat_bits_bytes = get_sb(segment_count_nat) << 5; nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) + 8 + F2FS_BLKSIZE - 1); - if (get_cp(cp_pack_total_block_count) <= + if (!(c.disabled_feature & F2FS_FEATURE_NAT_BITS) && + get_cp(cp_pack_total_block_count) <= (1 << get_sb(log_blocks_per_seg)) - nat_bits_blocks) flags |= CP_NAT_BITS_FLAG; else diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 0cb9228..bb40adc 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1471,6 +1471,11 @@ enum { #define MAX_CACHE_SUMS 8 +/* feature list in Android */ +enum { + F2FS_FEATURE_NAT_BITS = 0x0001, +}; + struct f2fs_configuration { uint32_t conf_reserved_sections; uint32_t reserved_segments; @@ -1537,6 +1542,7 @@ struct f2fs_configuration { int large_nat_bitmap; int fix_chksum; /* fix old cp.chksum position */ unsigned int feature; /* defined features */ + unsigned int disabled_feature; /* disabled feature, used for Android only */ unsigned int quota_bits; /* quota bits */ time_t fixed_time; int roll_forward; diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 6635eed..c28ebb0 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -893,7 +893,8 @@ static int f2fs_write_check_point_pack(void) /* cp page (2), data summaries (1), node summaries (3) */ set_cp(cp_pack_total_block_count, 6 + get_sb(cp_payload)); flags = CP_UMOUNT_FLAG | CP_COMPACT_SUM_FLAG; - if (get_cp(cp_pack_total_block_count) <= + if (!(c.disabled_feature & F2FS_FEATURE_NAT_BITS) && + get_cp(cp_pack_total_block_count) <= (1 << get_sb(log_blocks_per_seg)) - nat_bits_blocks) flags |= CP_NAT_BITS_FLAG; diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 9407f5b..5b4569d 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -143,6 +143,7 @@ static void add_default_options(void) force_overwrite = 1; c.wanted_sector_size = F2FS_BLKSIZE; c.root_uid = c.root_gid = 0; + c.disabled_feature |= F2FS_FEATURE_NAT_BITS; /* RO doesn't need any other features */ if (c.feature & F2FS_FEATURE_RO)