Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp386119rwl; Fri, 4 Nov 2022 01:23:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SVWE6nxSlUSDQOb0k9QCPPGUU/DnYfuMSay7dxn2xWyB2l7URu1Q3+LI9gN0y3i8QC5LC X-Received: by 2002:a17:903:1245:b0:178:9234:3768 with SMTP id u5-20020a170903124500b0017892343768mr34578145plh.146.1667550201049; Fri, 04 Nov 2022 01:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667550201; cv=none; d=google.com; s=arc-20160816; b=vup6WeKSBp6JLmnzuSTD6y+SyVCBYT15RvrAno20kRoL615woe7rGlVYNmQAs+M+oU Herdd4UXlZRW+g89pF2DtpsJY6K7NNeV64Jg1eM08eE+Rt317PwXBnDtiU4gOioH3NKd hSzY+vJOwQlLg5DbXaI8ihQuq5T5wwC3cyC7IdN9bNbUqNA43QkZrL9DbY0DZcfo4KtK Iuz8vLk2y4ZpgpT7gr9uzUEgIdb6UhknIh/Gl0u4/R9NSStvrB4ED5cqP0E0NecqDwzA h3jLM2JGDn0wiF2shbvyhPxXhhrQox9EZVPHgM7MbAddEZq/py8b7wHrvXetup/U3HBz h9xw== 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=AihrJqgoVd3c0h3fHGKr/hWXiMuYzumF5CStDRHPXeo=; b=Hioo/Ry7WqZAeBWnV0aqgg828wiH42TVqfM2hAag8SA9ECykt+0c3IvmgxQlzA7B3B pQ2DpofrwOatJ0QRZ5X5xvCVCSw9UU3Hn4ThGervLn09JJxABOR26CTzccGpyxRlsGWI P9F2kQeJ3DvAiGO3vWgdPG9s9knXpAf27mYh6lbCL4XYVYQazFmBMJqOnXf1eh+ysEj0 cWAqs2jZ54T3Xtr0PnApIZhzDHNMY7YWhkxCI+2uvYzwHgmnXjErfvUwudE5go3QrUu6 /yMrasVTKjQ/5ToPaVN4w0I3MvJFGt/IEJrCsFGP7ThJPK4fehM5VERpP3KOCAeYvOYc gmmw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a63dd56000000b0045a5d846af1si4023519pgj.134.2022.11.04.01.23.08; Fri, 04 Nov 2022 01:23:21 -0700 (PDT) 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 S231331AbiKDHl6 (ORCPT + 96 others); Fri, 4 Nov 2022 03:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiKDHl4 (ORCPT ); Fri, 4 Nov 2022 03:41:56 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33217286E4 for ; Fri, 4 Nov 2022 00:41:53 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by SHSQR01.spreadtrum.com with ESMTPS id 2A47epYA004466 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 4 Nov 2022 15:40:51 +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; Fri, 4 Nov 2022 15:40:51 +0800 From: "zhiguo.niu" To: , , , CC: , Subject: [PATCH] f2fs: fix atgc bug on issue in 32bits platform Date: Fri, 4 Nov 2022 15:40:21 +0800 Message-ID: <1667547621-26175-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain 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 2A47epYA004466 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 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 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; }; } struct victim_entry { [0] struct rb_node rb_node; union { struct {...}; [16] struct victim_info vi; }; [32] struct list_head list; } This patch fix this inconsistence layout of 64bits key between struct rb_entry and struct victim_entry. Signed-off-by: Zhiguo Niu --- 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..9a03c6502b39 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -68,7 +68,7 @@ struct victim_entry { unsigned int segno; /* segment No. */ }; struct victim_info vi; /* victim info */ - }; + } __packed; struct list_head list; }; -- 2.17.1