From patchwork Tue Nov 8 06:40:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Niu X-Patchwork-Id: 16886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2526536wru; Mon, 7 Nov 2022 22:50:19 -0800 (PST) X-Google-Smtp-Source: AMsMyM6X72h6Aubv2KIxXZ0zVgrwVVRdy9xnBE6cZiG7PvSeop5YSP/X3n1sQXEKHK67Ld8JshDw X-Received: by 2002:a17:902:e891:b0:186:c544:8b1e with SMTP id w17-20020a170902e89100b00186c5448b1emr53726578plg.163.1667890219042; Mon, 07 Nov 2022 22:50:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667890219; cv=none; d=google.com; s=arc-20160816; b=t4tn2vgI2e4AOUiq1URTD+19sRLqN+2bsqb1f7yldGmKZYMdfIF/Nw2RCza7KIVU5a JO7uyRM8h3dkjw7l3WktOwgaJxKDhmNVYyGC405Ehw6tcvKE2sApjAgnNb5KX+8W8O9/ hSZ78zLG7Fz/m+J/R6/glZvCecoU860HDBiaOCNifpcUXlmYwv9qGWsO87/CaLaE+66X DxnllEe60HXTeOozuGWcpZ5AO/3dbxpwNPUhAnyu9Icy2VxjdwdZMQ8n0KXNXKYLBJ4X b054nk52wQzu3hpPMm1pSnqxa5FAFkfNKRIK6mic1othoKypPzNTBIiKQMd4vDyp6/jM alZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=xej/uiqvvb0hcKS+hjJM61rEgXeY8fzcIZnGcVhjrks=; b=Jz3Ldv2gsYVCsS1JEy6OJXdqh5KRCJvKD93Y+H7XuDQ8sIXB3DKQ9A7EagQDmIJI6j /E0wDuMmrkqiDw+tuIEtAV3dIds8dTRsl+xOR3G6HTe4XmH4JREOvpc6a8umr8FXogwA qyQBAxrEZhMnUgTqq94m2XSbrSFI+6R7X/uGIpuCYgAiv3h7J/F4K57QmzXf+mDHORWm MYVgYUOlohg2LMk+HQdj7REkMWSKMkpoE+yYPe62hMnJAdrr3mWFgYawiXnL7Jt1v60D i4pliKpEzFTLAK2NuxbB1PZfPkxCDJnkLrorZ7hY0ThWBPYCBwKa2Vxd7L3xVhNlpDmx YH4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170903018900b00186f1a1fb83si13430281plg.352.2022.11.07.22.50.06; Mon, 07 Nov 2022 22:50:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233240AbiKHGly (ORCPT + 99 others); Tue, 8 Nov 2022 01:41:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232798AbiKHGlx (ORCPT ); Tue, 8 Nov 2022 01:41:53 -0500 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 502101EAD2 for ; Mon, 7 Nov 2022 22:41:50 -0800 (PST) Received: from SHSend.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by SHSQR01.spreadtrum.com with ESMTPS id 2A86erVb051782 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Tue, 8 Nov 2022 14:40:53 +0800 (CST) (envelope-from Zhiguo.Niu@unisoc.com) Received: from bj08434pcu.spreadtrum.com (10.0.74.109) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 8 Nov 2022 14:40:53 +0800 From: "zhiguo.niu" To: , , , CC: , Subject: [PATCH V2] f2fs: fix atgc bug on issue in 32bits platform Date: Tue, 8 Nov 2022 14:40:38 +0800 Message-ID: <1667889638-9106-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.109] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 2A86erVb051782 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748909654701386245?= X-GMAIL-MSGID: =?utf-8?q?1748909654701386245?= From: Zhiguo Niu There is bug on issue after atgc feature is enabled in 32bits platform as the following log: F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808) ------------[ cut here ]------------ kernel BUG at fs/f2fs/gc.c:602! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM PC is at get_victim_by_default+0x13c0/0x1498 LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4 .... [] (get_victim_by_default) from [] (f2fs_gc+0x220/0x6cc) [] (f2fs_gc) from [] (gc_thread_func+0x2ac/0x708) [] (gc_thread_func) from [] (kthread+0x1a8/0x1b4) [] (kthread) from [] (ret_from_fork+0x14/0x20) the reason is the 64bits key in struct rb_entry has __packed attibute but has not in struct victim_entry, so the wrong key value got by struct rb_entry in f2fs_check_rb_tree_consistence, the following are the memory layouts of struct rb_entry and struct victim_entry in 32bits platform: struct rb_entry { [0] struct rb_node rb_node; union { struct {...}; [12] unsigned long long key; }; } SIZE: 20 struct victim_entry { [0] struct rb_node rb_node; union { struct {...}; [16] struct victim_info vi; }; [32] struct list_head list; } SIZE: 40 This patch fix the inconsistence layout of 64bits key between struct rb_entry and struct victim_entry. Fixes: 093749e296e2 ("f2fs: support age threshold based garbage collection") Signed-off-by: Zhiguo Niu --- changes of v2: update patch according to Chao's suggestion. --- --- fs/f2fs/gc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 19b956c2d697..37e1142edf2c 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -70,7 +70,7 @@ struct victim_entry { struct victim_info vi; /* victim info */ }; struct list_head list; -}; +} __packed; /* * inline functions