From patchwork Fri May 5 10:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232379 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 E411AC77B75 for ; Fri, 5 May 2023 10:02: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 1pusGr-0004MR-OH; Fri, 05 May 2023 10:02:37 +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 1pusGp-0004ML-KV for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:35 +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=/nz6/Uadb7H7G3YFFP4OlF6i65bhIwfg4rk474BUYMk=; b=hXm9EcFlV1+877HEMTq7xUFGRz 91+dF+l9cEp6xinqCaKm/CDISNTahHOYZ8iS+fFlqmxRYBfn0zV+oGypvxZqBF1UlpQtjqRyNlpWU VzRmxeMuH1SAIpLnMnfbsTOr6GqIJK5c98kNeEZS/3YY4X5KWLRJEj/GGsdwpoNeFe18=; 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=/nz6/Uadb7H7G3YFFP4OlF6i65bhIwfg4rk474BUYMk=; b=C fN3lTUjeYFr32UhIrZpsBBu16DCqNURwwQ4umFcYa1ufrfcg1Zw0T1xx5MD4oSocthMipqyL5vQA7 w6ECIfli8ZPvIbeJQ29/PVCTkqwtTOdmtnDo0SifJ9HfyLOjDgOPBVrTgC6H5gYiZX5D2Lbt51nDP +V726oaAFvVmvS+4=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pusGk-00F8L9-Cv for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:35 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0763461281 for ; Fri, 5 May 2023 10:02:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70064C433D2; Fri, 5 May 2023 10:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280944; bh=lNBNV6B5y1MgXLhf8ZukLUZNk+SzXLYsXaOi78SS6OE=; h=From:To:Cc:Subject:Date:From; b=uVQeMVAMtU5PoPC+QRIEsLy+tdor6V3FjRFTn08t9ZGt6W4CWsxVVMlwDt2Eua1QP MeiXgti3Z4djnVOXmqinptycT7s1zrbnFO4w/2JkW8mUBjoySxbLrwv012ndxWOWxn qnGgRd7RkgRW64nHnZFkrLRilMKJIcKyh6BvWWt2TEmLJF4eOtV1AbdH2ExM2/sdQb /cGpqL/5fupseuY/tIYNV4AFc6XzxPKDYRsXtDzRjiZbdD71LUSj2h9QXsVesL5o4E GYzJu4JSFkP0XI+d4viWUmP3D2pb0wgdoX0EAkylJINW/VPVwzAbfJKs47mNCi2gJ4 owTjmzur0G8LQ== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:00 +0800 Message-Id: <20230505100205.1921708-1-chao@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Headers-End: 1pusGk-00F8L9-Cv Subject: [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Otherwise, it may trigger static assert below when the structure updates. static_assert(sizeof(struct f2fs_super_block) == 3072, "") Signed-off-by: Chao Yu --- include/f2fs_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 6948814..c71b59d 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -849,7 +849,7 @@ struct f2fs_super_block { __u8 s_errors[MAX_F2FS_ERRORS]; /* reason of image corrupts */ __u8 reserved[258]; /* valid reserved region */ __le32 crc; /* checksum of superblock */ -}; +} __attribute__((packed)); static_assert(sizeof(struct f2fs_super_block) == 3072, ""); From patchwork Fri May 5 10:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232378 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 6A68BC77B7D for ; Fri, 5 May 2023 10:02:39 +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 1pusGr-0004ga-Ic; Fri, 05 May 2023 10:02:37 +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 1pusGq-0004gR-Px for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:37 +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=6qumTK+NelXkhB5VDlu/80vlcehzrumCR0Z8roARkTo=; b=Rno1l0QzDuBPIE+l9HRvyr9Rp3 1q7eYvFFUjdLq+JhU96pNimsnMknNyWp0ACPGLGuR/BQdxKGfCMOFtSYJ38MUbFoRw9E1cVOgrlmx 9u3ZOP9uu63ZA5JnsWf4pkqMzbYr8YmzrRw6zIiYzMRCPjqB7EUnfGQyPrxiJWvkh26Y=; 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=6qumTK+NelXkhB5VDlu/80vlcehzrumCR0Z8roARkTo=; b=NCzF4u+6eeNYmkJ3lznGxI0t+s W878sWcqDBtBViS06wVroEfnPlWzyZBUK80+IFsG65mopKk/CHMAiysFfbrP47eCQo74ig0v+osqB oaOB1mdEGRxZWX/ym4OGylf2IU4zJA3ldlBm4AEPAFBfJpXqxDuUzTWK7DRswwzW0zqs=; 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 1pusGl-0007k4-Ss for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7FDC763D04 for ; Fri, 5 May 2023 10:02:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7672C4339E; Fri, 5 May 2023 10:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280945; bh=ZyVrUVlQjetosZr4whKO7s1Es2Z/Kb1syAKYglz/M1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhumQTJwgz15rJ8MWb+GX64ZZl3vOqHgmZr4DRKnaVGjkNFuEdshjQnF7DemzFbo6 N07vBPzeQqL0qBH0g9sfUbiR0oph9kiRPqgnDSjs/E4xydtQK10xWUCeK2hAzdsDTP QRuA+OD3k11j5kRQGnWH1dOfJprzoedlrLUN6NrGOrDCubOM3ueZPsSZWJn7zm19ni VjzefE3Y+TbJVEBY8XL08FJJ7dI2wQvz6VPg2G8W/+17cnVpmSxD21Z0qpNW2LmSk5 DKomY4GWGboFcGypWSprZYXYF+Ve7INYKLF16BM98E6GejlYaw3Ttq867vJDgXOp1l uIs7hzCHesZXw== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:01 +0800 Message-Id: <20230505100205.1921708-2-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230505100205.1921708-1-chao@kernel.org> References: <20230505100205.1921708-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1pusGl-0007k4-Ss Subject: [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Commit b28f047b28c5 ("f2fs: compress: support chksum") renames i_padding to i_compress_flag in struct f2fs_inode, adjust f2fs-tools' codes as well. Signed-off-by: Chao Yu --- fsck/mount.c | 2 +- include/f2fs_fs.h | 5 ++++- mkfs/f2fs_format.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index df0314d..2e1634f 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -304,7 +304,7 @@ void print_inode_info(struct f2fs_sb_info *sbi, DISP_u64(inode, i_compr_blocks); DISP_u32(inode, i_compress_algrithm); DISP_u32(inode, i_log_cluster_size); - DISP_u32(inode, i_padding); + DISP_u32(inode, i_compress_flag); } } diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index c71b59d..7ad1c40 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1076,7 +1076,10 @@ struct f2fs_inode { __le64 i_compr_blocks; /* # of compressed blocks */ __u8 i_compress_algrithm; /* compress algrithm */ __u8 i_log_cluster_size; /* log of cluster size */ - __le16 i_padding; /* padding */ + __le16 i_compress_flag; /* compress flag */ + /* 0 bit: chksum flag + * [8,15] bits: compress level + */ __le32 i_extra_end[0]; /* for attribute size calculation */ } __attribute__((packed)); __le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */ diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index d3bb622..11804eb 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -1289,7 +1289,7 @@ static int f2fs_write_root_inode(void) if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { raw_node->i.i_compress_algrithm = 0; raw_node->i.i_log_cluster_size = 0; - raw_node->i.i_padding = 0; + raw_node->i.i_compress_flag = 0; } data_blk_nor = get_sb(main_blkaddr) + @@ -1611,7 +1611,7 @@ static int f2fs_write_lpf_inode(void) if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { raw_node->i.i_compress_algrithm = 0; raw_node->i.i_log_cluster_size = 0; - raw_node->i.i_padding = 0; + raw_node->i.i_compress_flag = 0; } data_blk_nor = f2fs_add_default_dentry_lpf(); From patchwork Fri May 5 10:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232381 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 D8008C77B7F for ; Fri, 5 May 2023 10:02: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 1pusGw-0006d9-ER; Fri, 05 May 2023 10:02:42 +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 1pusGu-0006d2-Re for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:40 +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=QAlLXmyPGXS4i4+lrCKBZVlQU5pxGZ9Tqil/9eGDbhM=; b=Dx6zD81yYcEz0g/YOr/OVatS8V aKDTXLI4hxpPQV0E8BVpcQ0ScCxJexeH7qcF7XbT9YTkMrPQb0p8axkYi7UiEewANb2hnm/jlQPaX ezSYHM8L588ay2sU/d8xEPC4i9ZMbNJxytysC7KdAW/vbIJk1u7MsX3Pm7dvkhwKgkW0=; 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=QAlLXmyPGXS4i4+lrCKBZVlQU5pxGZ9Tqil/9eGDbhM=; b=PfLzgIrgKtwubPasa51gLYK7WE Mzb032nTt9Ujl0eocNj8qsIu9rgSdReaSh1SMPllYL955L+Mm2UnLz0YtWER8bHK4mtnJ6Z7S+yzM PQH6qh9/VsTao0faVX7Q5ilEr/qZEw+cuI2gs3jIOohJcKNulvLn9XAi72mHVt/npVsA=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pusGn-00F8LB-CN for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 000E263D07 for ; Fri, 5 May 2023 10:02:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6983BC4339C; Fri, 5 May 2023 10:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280947; bh=OljGVEJ85emXYstDa5DeLRblnvW4bDVk2devzBiCgxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUbvkKhmzEhWnYAS7CTHxkdnbhQLabDx6BtIQYe+zZdsHlS2JxTeDkxM18RSYTiib TaMjg5XmNHAtt5OkkXkVLT4rbWE4dQ7yXfwReA/EdoRF/yGcs25jYwBMwfqTnyaPOx yEHTxlZB3UOetUJsuNufy1vn8okO5UW43IsiDNVNQ3a0ECjPjr0lqtgpK8bNNDPj63 UehJPQo7S/XkSnuqwPhC2rkUtzxRhzOLXMONX5nlXWAYp4bzVaOu/UYd/fonHh2xtg RADeZJkd8D7P68jmuqQkk+aoaQd7IiIWsVvPiab3/GBGpAi1HjL822GhurRs15kiOM zY8/c+rWQWyzg== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:02 +0800 Message-Id: <20230505100205.1921708-3-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230505100205.1921708-1-chao@kernel.org> References: <20230505100205.1921708-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1pusGn-00F8LB-CN Subject: [f2fs-dev] [PATCH 3/6] f2fs-tools: fix typo in f2fs_inode structure 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net :%s/i_compress_algrithm/i_compress_algorithm/g Signed-off-by: Chao Yu --- fsck/mount.c | 2 +- fsck/segment.c | 2 +- include/f2fs_fs.h | 2 +- mkfs/f2fs_format.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index 2e1634f..b314756 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -302,7 +302,7 @@ void print_inode_info(struct f2fs_sb_info *sbi, } if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { DISP_u64(inode, i_compr_blocks); - DISP_u32(inode, i_compress_algrithm); + DISP_u32(inode, i_compress_algorithm); DISP_u32(inode, i_log_cluster_size); DISP_u32(inode, i_compress_flag); } diff --git a/fsck/segment.c b/fsck/segment.c index 0307bdd..0ca8b5a 100644 --- a/fsck/segment.c +++ b/fsck/segment.c @@ -633,7 +633,7 @@ int f2fs_build_file(struct f2fs_sb_info *sbi, struct dentry *de) get_node_info(sbi, de->ino, &ni); ASSERT(dev_read_block(node_blk, ni.blk_addr) >= 0); /* update inode meta */ - node_blk->i.i_compress_algrithm = c.compress.alg; + node_blk->i.i_compress_algorithm = c.compress.alg; node_blk->i.i_log_cluster_size = c.compress.cc.log_cluster_size; node_blk->i.i_flags = cpu_to_le32(F2FS_COMPR_FL); diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 7ad1c40..dca4cd8 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1074,7 +1074,7 @@ struct f2fs_inode { __le64 i_crtime; /* creation time */ __le32 i_crtime_nsec; /* creation time in nano scale */ __le64 i_compr_blocks; /* # of compressed blocks */ - __u8 i_compress_algrithm; /* compress algrithm */ + __u8 i_compress_algorithm; /* compress algorithm */ __u8 i_log_cluster_size; /* log of cluster size */ __le16 i_compress_flag; /* compress flag */ /* 0 bit: chksum flag diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 11804eb..e8c9675 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -1287,7 +1287,7 @@ static int f2fs_write_root_inode(void) } if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { - raw_node->i.i_compress_algrithm = 0; + raw_node->i.i_compress_algorithm = 0; raw_node->i.i_log_cluster_size = 0; raw_node->i.i_compress_flag = 0; } @@ -1609,7 +1609,7 @@ static int f2fs_write_lpf_inode(void) } if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { - raw_node->i.i_compress_algrithm = 0; + raw_node->i.i_compress_algorithm = 0; raw_node->i.i_log_cluster_size = 0; raw_node->i.i_compress_flag = 0; } From patchwork Fri May 5 10:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232380 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 77159C77B7D for ; Fri, 5 May 2023 10:02:42 +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 1pusGv-0007lW-43; Fri, 05 May 2023 10:02:41 +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 1pusGt-0007lH-W8 for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:40 +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=Hutm2pxCoF8V7ug5iQtrZEyTWM28MeQf9PAMUTJcEAA=; b=gNYVZRWMwgs6KPRR5undalqWD1 TrrrMhnMN/2ILUSTdvv1nTlUBPXlWmzV3Yp6RixNAyLqMW+K7bVeD+dkAgPaCZTtR018wFiRtkaip N8GyvAU5UQtvn0v3Cw+kit0jx2cYFtkuiQhHjpsMD7RUfpnjPlzx+wck90BRBqMCedpE=; 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=Hutm2pxCoF8V7ug5iQtrZEyTWM28MeQf9PAMUTJcEAA=; b=QUVdEdyUN4Yl+Ty5UT5R/dm1dB xobZ46rY48bhPZQokJ+Vz88f/pSGdnBFxQr42tqA9iKXjdpToPiHOKx50QAiiysxWgc9OaHrPyQqn vDujvw3LGbhq0+e0VpkqCyf9cny+gGHf+si6+lPWsjvePwSUqH2yooarNKqu9G07q0iY=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pusGo-00F8LD-SV for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B56763D0A for ; Fri, 5 May 2023 10:02:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD84C4339E; Fri, 5 May 2023 10:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280948; bh=cz3oRRmvG5okQd0cyNeoeQXKErnw2aTiRUPVOyqJuIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+GxmjOlCc6OSEZB8O7fmCI27uONLSuFagrLBRMOeub3BeoTdKN8PumYZUdl34uvM ZUt/VBBfh1F3xPIKm0LGMeqH+QTUQe48W4kfbWfLu76CWwiHRDOndDxYXCpeBexUM7 FcsvGQOCfgeqo9PpKWGRyEhlEZ2idtRGILZEdmH3HezXYkH//Df6PZYN2WCNBGHsbj lB85O1P3Ro6yStztEcCUB+mVx7BfbBJvQHtkEDlZsjuBVHKtym5ONkc4TjCf67uPDK VWqTHscz7ikKq/59SDvt7/F/1aEG4OmN+1y45uND5ljgUxIlv/ApVDBib97M2Urb65 u6hmz3EECwMHA== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:03 +0800 Message-Id: <20230505100205.1921708-4-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230505100205.1921708-1-chao@kernel.org> References: <20230505100205.1921708-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1pusGo-00F8LD-SV Subject: [f2fs-dev] [PATCH 4/6] f2fs-tools: add DISP_u8() macro 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Introduce DISP_u8(), and use DISP_u16() and DISP_u8() to print below fields: - i_compress_algorithm - i_log_cluster_size - i_compress_flag Signed-off-by: Chao Yu --- fsck/mount.c | 6 +++--- include/f2fs_fs.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index b314756..5e475a3 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -302,9 +302,9 @@ void print_inode_info(struct f2fs_sb_info *sbi, } if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { DISP_u64(inode, i_compr_blocks); - DISP_u32(inode, i_compress_algorithm); - DISP_u32(inode, i_log_cluster_size); - DISP_u32(inode, i_compress_flag); + DISP_u8(inode, i_compress_algorithm); + DISP_u8(inode, i_log_cluster_size); + DISP_u16(inode, i_compress_flag); } } diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index dca4cd8..e5d5d13 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -282,6 +282,17 @@ static inline uint64_t bswap_64(uint64_t val) printf("%-30s" fmt, #member, ((ptr)->member)); \ } while (0) +#define DISP_u8(ptr, member) \ + do { \ + assert(sizeof((ptr)->member) == 1); \ + if (c.layout) \ + printf("%-30s %u\n", \ + #member":", ((ptr)->member)); \ + else \ + printf("%-30s" "\t\t[0x%8x : %u]\n", \ + #member, ((ptr)->member), ((ptr)->member)); \ + } while (0) + #define DISP_u16(ptr, member) \ do { \ assert(sizeof((ptr)->member) == 2); \ From patchwork Fri May 5 10:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232382 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 4A742C7EE22 for ; Fri, 5 May 2023 10:02:44 +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 1pusGx-0004Ms-BQ; Fri, 05 May 2023 10:02:43 +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 1pusGv-0004Mk-Jz for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:41 +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=qY34rgbDrGVCDbTKJ3zE1V+AxjZ8M1zbP7ilag6p89k=; b=j4CPALWKjAC+b38aVIBVNdfIML FRRp9CrxxQF8e3jrYGblQnjONYWWlWFhiL+q8FtIOwAl6YxYIJFhgeIJ7LuO6DSvgnb1br8VN3QzA znTe7lxdlowDsbinsRDx4X+uAhmghfyqzpZg2cisDcK/nlejyf1UpbA3PsNqrnD7qvrA=; 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=qY34rgbDrGVCDbTKJ3zE1V+AxjZ8M1zbP7ilag6p89k=; b=e59n2YyzXPGfG6dd3BIsk8QVss tXy24P76jaK//PGyGWUnllVCMGg97Mrj8DlArjiw9CkPvva420hySOtYooS85/ngWlddOBYN6FyXf F2O7iaEVAMPnSmOqmScA030QQWs6pFYLW/6Tw70ua9MMxbVU1d9uXEZz0akW1JWD3jO8=; 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 1pusGq-0007k9-BL for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:41 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EE8E763CFF for ; Fri, 5 May 2023 10:02:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63BAFC433D2; Fri, 5 May 2023 10:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280950; bh=QFVk5Uiw/jMz9GfXgLtpnNnEncbAij3NbR0ptx866nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0/gC8MtMfGO/MdzsxK0xFfUiWiFYLivW/bQRYLnOLj22gPMxcxULZ5aiXUYCSTas INti+yjxHvzvCV791PJEDe1BWw6zkYuCAhKGAkwbYraRhbo7UTNDDFFPv0Za2uAZ4X TweIuiVres/91l1bNikX+xyl151+ubQ3YekEXKbmqW+A9xhCrcIW11aIS6yHxQ0Gts MchE3vbGzZrdjbvU6kBDaXkcvf8a97P24Da70sX6JuZAccSPRbd2QvZmJzv+fHjNvy 85YS+D0YdCieUCh3mRdKB4MPhSusx4zftCtO5BBU8o9Y8kt4PiPhn8zpmtmBKlfqK7 sQsp5LDbOCJFw== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:04 +0800 Message-Id: <20230505100205.1921708-5-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230505100205.1921708-1-chao@kernel.org> References: <20230505100205.1921708-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1pusGq-0007k9-BL Subject: [f2fs-dev] [PATCH 5/6] f2fs-tools: print more raw sb info 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Output is as below: magic [0xf2f52010 : 4076150800] major_ver [0x 1 : 1] minor_ver [0x 10 : 16] log_sectorsize [0x 9 : 9] log_sectors_per_block [0x 3 : 3] log_blocksize [0x c : 12] log_blocks_per_seg [0x 9 : 9] segs_per_sec [0x 1 : 1] secs_per_zone [0x 1 : 1] checksum_offset [0x 0 : 0] block_count [0x 300000 : 3145728] section_count [0x 17d3 : 6099] segment_count [0x 17ff : 6143] segment_count_ckpt [0x 2 : 2] segment_count_sit [0x 2 : 2] segment_count_nat [0x 1c : 28] segment_count_ssa [0x c : 12] segment_count_main [0x 17d3 : 6099] segment0_blkaddr [0x 200 : 512] cp_blkaddr [0x 200 : 512] sit_blkaddr [0x 600 : 1536] nat_blkaddr [0x a00 : 2560] ssa_blkaddr [0x 4200 : 16896] main_blkaddr [0x 5a00 : 23040] root_ino [0x 3 : 3] node_ino [0x 1 : 1] meta_ino [0x 2 : 2] uuid [f16856a6-8781-422b-adce-d51c0632c94e] volum_name [] extension_count [0x 24 : 36] cold file extentsions [mp wm og jp ] [avi m4v m4p mkv ] [mov webm wav m4a ] [3gp opus flac gif ] [png svg webp jar ] [deb iso gz xz ] [zst pdf pyc ttc ] [ttf exe apk cnt ] [exo odex vdex so ] hot_ext_count [0x 4 : 4] hot file extentsions [db vmdk vdi qcow2 ] cp_payload [0x 0 : 0] version [Linux version 6.3.0+ (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #143 SMP PREEMPT_DYNAMIC Thu May 4 09:50:08 HKT 2023] init_version [Linux version 6.3.0+ (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #143 SMP PREEMPT_DYNAMIC Thu May 4 09:50:08 HKT 2023] feature [0x 21f8 : 8696] encryption_level [0x 0 : 0] encrypt_pw_salt [00000000-0000-0000-0000-000000000000] qf_ino[USRQUOTA] [0x 4 : 4] qf_ino[GRPQUOTA] [0x 5 : 5] qf_ino[PRJQUOTA] [0x 6 : 6] s_encoding [0x 0 : 0] crc [0x 0 : 0] Signed-off-by: Chao Yu --- fsck/mount.c | 105 +++++++++++++++++++++++++++++++++++++++++++-- include/f2fs_fs.h | 19 ++++++++ mkfs/f2fs_format.c | 1 + 3 files changed, 122 insertions(+), 3 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index 5e475a3..93ad806 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -11,6 +11,7 @@ #include "fsck.h" #include "node.h" #include "xattr.h" +#include "quota.h" #include #include #include @@ -20,6 +21,9 @@ #ifdef HAVE_SYS_ACL_H #include #endif +#ifdef HAVE_UUID_UUID_H +#include +#endif #ifndef ACL_UNDEFINED_TAG #define ACL_UNDEFINED_TAG (0x00) @@ -365,6 +369,40 @@ void print_node_info(struct f2fs_sb_info *sbi, } } +void print_extention_list(struct f2fs_super_block *sb, int cold) +{ + int start, end, i; + + if (cold) { + DISP_u32(sb, extension_count); + + start = 0; + end = le32_to_cpu(sb->extension_count); + } else { + DISP_u8(sb, hot_ext_count); + + start = le32_to_cpu(sb->extension_count); + end = start + sb->hot_ext_count; + } + + printf("%s file extentsions\n", cold ? "cold" : "hot"); + + for (i = start; i < end; i++) { + if (c.layout) { + printf("%-30s %-8.8s\n", "extension_list", + sb->extension_list[i]); + } else { + if (i % 4 == 0) + printf("%-30s\t\t[", ""); + + printf("%-8.8s", sb->extension_list[i]); + + if (i % 4 == 4 - 1 || i == end - start - 1) + printf("]\n"); + } + } +} + static void DISP_label(uint16_t *name) { char buffer[MAX_VOLUME_NAME]; @@ -376,8 +414,14 @@ static void DISP_label(uint16_t *name) printf("%-30s" "\t\t[%s]\n", "volum_name", buffer); } +void print_sb_debug_info(struct f2fs_super_block *sb); void print_raw_sb_info(struct f2fs_super_block *sb) { +#ifdef HAVE_LIBUUID + char uuid[40]; + char encrypt_pw_salt[40]; +#endif + if (c.layout) goto printout; if (!c.dbg_lv) @@ -391,8 +435,6 @@ printout: DISP_u32(sb, magic); DISP_u32(sb, major_ver); - DISP_label(sb->volume_name); - DISP_u32(sb, minor_ver); DISP_u32(sb, log_sectorsize); DISP_u32(sb, log_sectors_per_block); @@ -423,9 +465,39 @@ printout: DISP_u32(sb, root_ino); DISP_u32(sb, node_ino); DISP_u32(sb, meta_ino); + +#ifdef HAVE_LIBUUID + uuid_unparse(sb->uuid, uuid); + DISP_raw_str("%-.36s", uuid); +#endif + + DISP_label(sb->volume_name); + + print_extention_list(sb, 1); + print_extention_list(sb, 0); + DISP_u32(sb, cp_payload); + + DISP_str("%-.252s", sb, version); + DISP_str("%-.252s", sb, init_version); + + DISP_u32(sb, feature); + DISP_u8(sb, encryption_level); + +#ifdef HAVE_LIBUUID + uuid_unparse(sb->encrypt_pw_salt, encrypt_pw_salt); + DISP_raw_str("%-.36s", encrypt_pw_salt); +#endif + + DISP_u32(sb, qf_ino[USRQUOTA]); + DISP_u32(sb, qf_ino[GRPQUOTA]); + DISP_u32(sb, qf_ino[PRJQUOTA]); + + DISP_u16(sb, s_encoding); DISP_u32(sb, crc); - DISP("%-.252s", sb, version); + + print_sb_debug_info(sb); + printf("\n"); } @@ -647,6 +719,33 @@ void print_sb_errors(struct f2fs_super_block *sb) MSG(0, "\n"); } +void print_sb_debug_info(struct f2fs_super_block *sb) +{ + u8 *reason = sb->s_stop_reason; + u8 *errors = sb->s_errors; + int i; + + for (i = 0; i < STOP_CP_REASON_MAX; i++) { + if (!reason[i]) + continue; + if (c.layout) + printf("%-30s %s(%s, %d)\n", "", "stop_reason", + stop_reason_str[i], reason[i]); + else + printf("%-30s\t\t[%-20s : %u]\n", "", + stop_reason_str[i], reason[i]); + } + + for (i = 0; i < ERROR_MAX; i++) { + if (!test_bit_le(i, errors)) + continue; + if (c.layout) + printf("%-30s %s(%s)\n", "", "errors", errors_str[i]); + else + printf("%-30s\t\t[%-20s]\n", "", errors_str[i]); + } +} + bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type) { diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index e5d5d13..4accade 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -282,6 +282,25 @@ static inline uint64_t bswap_64(uint64_t val) printf("%-30s" fmt, #member, ((ptr)->member)); \ } while (0) +#define DISP_raw_str(fmt, member) \ + do { \ + if (c.layout) \ + printf("%-30s " fmt "\n", #member":", member); \ + else \ + printf("%-30s" "\t\t[" fmt "]\n", \ + #member, member); \ + } while (0) + +#define DISP_str(fmt, ptr, member) \ + do { \ + if (c.layout) \ + printf("%-30s " fmt "\n", \ + #member":", ((ptr)->member)); \ + else \ + printf("%-30s" "\t\t[" fmt "]\n", \ + #member, ((ptr)->member)); \ + } while (0) + #define DISP_u8(ptr, member) \ do { \ assert(sizeof((ptr)->member) == 1); \ diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index e8c9675..666af45 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -29,6 +29,7 @@ #ifndef HAVE_LIBUUID #define uuid_parse(a, b) -1 #define uuid_generate(a) +#define uuid_unparse(a, b) -1 #endif #include "quota.h" From patchwork Fri May 5 10:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13232383 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 B7D90C77B7D for ; Fri, 5 May 2023 10:02:47 +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 1pusH0-0004hD-VL; Fri, 05 May 2023 10:02:47 +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 1pusH0-0004h6-09 for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:46 +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=JSz0ergeSkpgDw7Ev22N++XeMyQBokvk/GSgEqqbk4Q=; b=kvfGxdgdDcl+DGdb+/GO60l03o tu0fz++W/AVlH7PoSb8aviQyoxDQqDCBjsIh/R3QZc0aTyGtOwISV5qr55CUggnT8/bFkxZVAFSRr ItNQTp8JGn8DxJtw48MQ5/mYbVAaE+rak3KVA+NvSRNQbn8+GCpfKXWgXbh2ESHnEeuA=; 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=JSz0ergeSkpgDw7Ev22N++XeMyQBokvk/GSgEqqbk4Q=; b=N2+eBFOrKNxg4XTkwgoi+gzlCJ v1dWdzkIT9zQ4rovRapIGKa7ikYBlLe36HQRDdnZkhtiyzkaP64PUrawW9jI08BXrif8nxmoHOmuO Z1uKIOSl+Z9SDczh3eH+NVlugihwNHJROxdlOwDh1eP6pGm/ssPs91A7kSJdBuUczrMA=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pusGv-00F8Ld-3f for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 10:02:46 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 75E1963D0F for ; Fri, 5 May 2023 10:02:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DACA8C433A0; Fri, 5 May 2023 10:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683280951; bh=StyTTh30oTEgsBuYTW1V09GLVjgm15bu8Xjh1oHn1gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cMAnAwt05CXqTrQ7Gx8immCCabFe0KrqeWK+LUTfHxp9bW+/w8Igcckk+hvIZb1Zy ZU97j3VU4IDZRRLeIzWc2RvzrjoCONzbkWsBCBHMaDjgUnk/cFTxueS8YEaGwZ6lyD yY7SQnszibLtIY6QUN8NVfU7Gnpn8ucoDe4glZJ3EmvHqtPMaMm7P9misirfvEN8qU hUKBxAQxIWm3MQHSM2LmCUwCLA2yDxd5yD/W4RICytsR4/GCtQ17MGIXevRC5BI3Ge oAxugt037u88snL+eFDji85rQFVMbO8kdX2q1ITdZzzu395Yyj8f9ySjw3K0Ds4Tg9 WgIXXzVOaC1fw== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 5 May 2023 18:02:05 +0800 Message-Id: <20230505100205.1921708-6-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230505100205.1921708-1-chao@kernel.org> References: <20230505100205.1921708-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1pusGv-00F8Ld-3f Subject: [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes 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: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net No logic changes. Signed-off-by: Chao Yu --- fsck/node.c | 7 ++- include/f2fs_fs.h | 36 +++++++++----- mkfs/f2fs_format.c | 118 ++++++++------------------------------------- 3 files changed, 50 insertions(+), 111 deletions(-) diff --git a/fsck/node.c b/fsck/node.c index c3e383b..9ce8a72 100644 --- a/fsck/node.c +++ b/fsck/node.c @@ -57,7 +57,12 @@ int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype) MSG(1, "\tError: Calloc Failed for raw_node!!!\n"); return -ENOMEM; } - f2fs_init_qf_inode(sb, raw_node, qtype, time(NULL)); + f2fs_init_inode(sb, raw_node, + le32_to_cpu(sb->qf_ino[qtype]), time(NULL), 0x8180); + + raw_node->i.i_size = cpu_to_le64(1024 * 6); + raw_node->i.i_blocks = cpu_to_le64(1); + raw_node->i.i_flags = FS_IMMUTABLE_FL; if (is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) cp_ver |= (cur_cp_crc(ckpt) << 32); diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 4accade..cab452d 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1741,20 +1741,16 @@ static inline void show_version(const char *prog) #endif } -static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb, - struct f2fs_node *raw_node, int qtype, time_t mtime) +static inline void f2fs_init_inode(struct f2fs_super_block *sb, + struct f2fs_node *raw_node, nid_t ino, time_t mtime, mode_t mode) { - raw_node->footer.nid = sb->qf_ino[qtype]; - raw_node->footer.ino = sb->qf_ino[qtype]; + raw_node->footer.nid = cpu_to_le32(ino); + raw_node->footer.ino = cpu_to_le32(ino); raw_node->footer.cp_ver = cpu_to_le64(1); - raw_node->i.i_mode = cpu_to_le16(0x8180); - raw_node->i.i_links = cpu_to_le32(1); + raw_node->i.i_uid = cpu_to_le32(c.root_uid); raw_node->i.i_gid = cpu_to_le32(c.root_gid); - raw_node->i.i_size = cpu_to_le64(1024 * 6); /* Hard coded */ - raw_node->i.i_blocks = cpu_to_le64(1); - raw_node->i.i_atime = cpu_to_le32(mtime); raw_node->i.i_atime_nsec = 0; raw_node->i.i_ctime = cpu_to_le32(mtime); @@ -1763,9 +1759,15 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb, raw_node->i.i_mtime_nsec = 0; raw_node->i.i_generation = 0; raw_node->i.i_xattr_nid = 0; - raw_node->i.i_flags = FS_IMMUTABLE_FL; - raw_node->i.i_current_depth = cpu_to_le32(0); + raw_node->i.i_flags = 0; + raw_node->i.i_current_depth = cpu_to_le32(S_ISDIR(mode) ? 1 : 0); raw_node->i.i_dir_level = DEF_DIR_LEVEL; + raw_node->i.i_mode = cpu_to_le16(mode); + raw_node->i.i_links = cpu_to_le32(S_ISDIR(mode) ? 2 : 1); + + /* for dentry block in directory */ + raw_node->i.i_size = cpu_to_le64(1 << get_sb(log_blocksize)); + raw_node->i.i_blocks = cpu_to_le64(2); if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) { raw_node->i.i_inline = F2FS_EXTRA_ATTR; @@ -1775,6 +1777,18 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb, if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID); + if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) { + raw_node->i.i_crtime = cpu_to_le32(mtime); + raw_node->i.i_crtime_nsec = 0; + } + + if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { + raw_node->i.i_compr_blocks = 0; + raw_node->i.i_compress_algorithm = 0; + raw_node->i.i_log_cluster_size = 0; + raw_node->i.i_compress_flag = 0; + } + raw_node->i.i_ext.fofs = 0; raw_node->i.i_ext.blk_addr = 0; raw_node->i.i_ext.len = 0; diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 666af45..6d02a57 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -1233,7 +1233,7 @@ static int f2fs_discard_obsolete_dnode(void) static int f2fs_write_root_inode(void) { struct f2fs_node *raw_node = NULL; - uint64_t blk_size_bytes, data_blk_nor; + uint64_t data_blk_nor; uint64_t main_area_node_seg_blk_offset = 0; raw_node = calloc(F2FS_BLKSIZE, 1); @@ -1242,65 +1242,21 @@ static int f2fs_write_root_inode(void) return -1; } - raw_node->footer.nid = sb->root_ino; - raw_node->footer.ino = sb->root_ino; - raw_node->footer.cp_ver = cpu_to_le64(1); - raw_node->footer.next_blkaddr = cpu_to_le32( - get_sb(main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE] * - c.blks_per_seg + 1); + f2fs_init_inode(sb, raw_node, le32_to_cpu(sb->root_ino), + mkfs_time, 0x41ed); - raw_node->i.i_mode = cpu_to_le16(0x41ed); if (c.lpf_ino) raw_node->i.i_links = cpu_to_le32(3); - else - raw_node->i.i_links = cpu_to_le32(2); - raw_node->i.i_uid = cpu_to_le32(c.root_uid); - raw_node->i.i_gid = cpu_to_le32(c.root_gid); - - blk_size_bytes = 1 << get_sb(log_blocksize); - raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */ - raw_node->i.i_blocks = cpu_to_le64(2); - - raw_node->i.i_atime = cpu_to_le32(mkfs_time); - raw_node->i.i_atime_nsec = 0; - raw_node->i.i_ctime = cpu_to_le32(mkfs_time); - raw_node->i.i_ctime_nsec = 0; - raw_node->i.i_mtime = cpu_to_le32(mkfs_time); - raw_node->i.i_mtime_nsec = 0; - raw_node->i.i_generation = 0; - raw_node->i.i_xattr_nid = 0; - raw_node->i.i_flags = 0; - raw_node->i.i_current_depth = cpu_to_le32(1); - raw_node->i.i_dir_level = DEF_DIR_LEVEL; - - if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) { - raw_node->i.i_inline = F2FS_EXTRA_ATTR; - raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize()); - } - - if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) - raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID); - if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) { - raw_node->i.i_crtime = cpu_to_le32(mkfs_time); - raw_node->i.i_crtime_nsec = 0; - } - - if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { - raw_node->i.i_compress_algorithm = 0; - raw_node->i.i_log_cluster_size = 0; - raw_node->i.i_compress_flag = 0; - } + raw_node->footer.next_blkaddr = cpu_to_le32( + get_sb(main_blkaddr) + + c.cur_seg[CURSEG_HOT_NODE] * + c.blks_per_seg + 1); data_blk_nor = get_sb(main_blkaddr) + c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg; raw_node->i.i_addr[get_extra_isize(raw_node)] = cpu_to_le32(data_blk_nor); - raw_node->i.i_ext.fofs = 0; - raw_node->i.i_ext.blk_addr = 0; - raw_node->i.i_ext.len = 0; - main_area_node_seg_blk_offset = get_sb(main_blkaddr); main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg; @@ -1403,13 +1359,17 @@ static int f2fs_write_qf_inode(int qtype, int offset) MSG(1, "\tError: Calloc Failed for raw_node!!!\n"); return -1; } - f2fs_init_qf_inode(sb, raw_node, qtype, mkfs_time); + f2fs_init_inode(sb, raw_node, + le32_to_cpu(sb->qf_ino[qtype]), mkfs_time, 0x8180); + + raw_node->i.i_size = cpu_to_le64(1024 * 6); + raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype)); + raw_node->i.i_flags = FS_IMMUTABLE_FL; raw_node->footer.next_blkaddr = cpu_to_le32( get_sb(main_blkaddr) + c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + 1 + qtype + 1); - raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype)); data_blk_nor = get_sb(main_blkaddr) + c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg + 1 @@ -1552,7 +1512,7 @@ static block_t f2fs_add_default_dentry_lpf(void) static int f2fs_write_lpf_inode(void) { struct f2fs_node *raw_node; - uint64_t blk_size_bytes, main_area_node_seg_blk_offset; + uint64_t main_area_node_seg_blk_offset; block_t data_blk_nor; int err = 0; @@ -1564,56 +1524,16 @@ static int f2fs_write_lpf_inode(void) return -1; } - raw_node->footer.nid = cpu_to_le32(c.lpf_ino); - raw_node->footer.ino = raw_node->footer.nid; - raw_node->footer.cp_ver = cpu_to_le64(1); - raw_node->footer.next_blkaddr = cpu_to_le32( - get_sb(main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + - 1 + c.quota_inum + 1); - - raw_node->i.i_mode = cpu_to_le16(0x41c0); /* 0700 */ - raw_node->i.i_links = cpu_to_le32(2); - raw_node->i.i_uid = cpu_to_le32(c.root_uid); - raw_node->i.i_gid = cpu_to_le32(c.root_gid); + f2fs_init_inode(sb, raw_node, c.lpf_ino, mkfs_time, 0x41c0); - blk_size_bytes = 1 << get_sb(log_blocksize); - raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); - raw_node->i.i_blocks = cpu_to_le64(2); - - raw_node->i.i_atime = cpu_to_le32(mkfs_time); - raw_node->i.i_atime_nsec = 0; - raw_node->i.i_ctime = cpu_to_le32(mkfs_time); - raw_node->i.i_ctime_nsec = 0; - raw_node->i.i_mtime = cpu_to_le32(mkfs_time); - raw_node->i.i_mtime_nsec = 0; - raw_node->i.i_generation = 0; - raw_node->i.i_xattr_nid = 0; - raw_node->i.i_flags = 0; raw_node->i.i_pino = le32_to_cpu(sb->root_ino); raw_node->i.i_namelen = le32_to_cpu(strlen(LPF)); memcpy(raw_node->i.i_name, LPF, strlen(LPF)); - raw_node->i.i_current_depth = cpu_to_le32(1); - raw_node->i.i_dir_level = DEF_DIR_LEVEL; - if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) { - raw_node->i.i_inline = F2FS_EXTRA_ATTR; - raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize()); - } - - if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) - raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID); - - if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) { - raw_node->i.i_crtime = cpu_to_le32(mkfs_time); - raw_node->i.i_crtime_nsec = 0; - } - - if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) { - raw_node->i.i_compress_algorithm = 0; - raw_node->i.i_log_cluster_size = 0; - raw_node->i.i_compress_flag = 0; - } + raw_node->footer.next_blkaddr = cpu_to_le32( + get_sb(main_blkaddr) + + c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + + 1 + c.quota_inum + 1); data_blk_nor = f2fs_add_default_dentry_lpf(); if (data_blk_nor == 0) {