From patchwork Fri Mar 22 08:33:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=A9bastien_Szymanski?= X-Patchwork-Id: 1060976 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=armadeus.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44QcPt1TZYz9sR4 for ; Fri, 22 Mar 2019 19:33:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D22A6C22149; Fri, 22 Mar 2019 08:33:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0F896C2208B; Fri, 22 Mar 2019 08:33:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20E9EC2208B; Fri, 22 Mar 2019 08:33:48 +0000 (UTC) Received: from 4.mo1.mail-out.ovh.net (4.mo1.mail-out.ovh.net [46.105.76.26]) by lists.denx.de (Postfix) with ESMTPS id B16FBC21C4A for ; Fri, 22 Mar 2019 08:33:47 +0000 (UTC) Received: from player699.ha.ovh.net (unknown [10.109.143.24]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 3B5EE1634FF for ; Fri, 22 Mar 2019 09:33:46 +0100 (CET) Received: from armadeus.com (aputeaux-683-1-59-211.w90-86.abo.wanadoo.fr [90.86.46.211]) (Authenticated sender: sebastien.szymanski@armadeus.com) by player699.ha.ovh.net (Postfix) with ESMTPSA id EBA5C3EF5E90; Fri, 22 Mar 2019 08:33:44 +0000 (UTC) From: =?utf-8?q?S=C3=A9bastien_Szymanski?= To: u-boot@lists.denx.de Date: Fri, 22 Mar 2019 09:33:52 +0100 Message-Id: <20190322083352.24443-1-sebastien.szymanski@armadeus.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Ovh-Tracer-Id: 11378907408979022873 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrjedtgdduvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenuc Subject: [U-Boot] [PATCH 1/1] fs: ext4: do not write on filesystem with metadata_csum feature X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" U-Boot doesn't support metadata_csum feature. Writing to filesystem with metadata_csum feature makes the filesystem corrupted and unbootable by Linux: [ 2.527495] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 0 failed (52188!=0) [ 2.537421] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 1 failed (5262!=0) ... [ 2.653308] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 14 failed (42611!=0) [ 2.662179] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 15 failed (21527!=0) [ 2.687920] JBD2: journal checksum error [ 2.691982] EXT4-fs (mmcblk0p2): error loading journal [ 2.698292] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -74 Don't write to filesystem with meatadata_csum feature to not corrupt the filesystem. Signed-off-by: Sébastien Szymanski --- fs/ext4/ext4_write.c | 6 ++++++ include/ext4fs.h | 1 + 2 files changed, 7 insertions(+) diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index a7f543f7df..4eb77c327e 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -864,6 +864,12 @@ int ext4fs_write(const char *fname, unsigned char *buffer, printf("error in File System init\n"); return -1; } + + if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { + printf("Unsupported feature metadata_csum found, not writing.\n"); + return -1; + } + inodes_per_block = fs->blksz / fs->inodesz; parent_inodeno = ext4fs_get_parent_inode_num(fname, filename, F_FILE); if (parent_inodeno == -1) diff --git a/include/ext4fs.h b/include/ext4fs.h index bb55639107..2421011341 100644 --- a/include/ext4fs.h +++ b/include/ext4fs.h @@ -32,6 +32,7 @@ #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ #define EXT4_EXT_MAGIC 0xf30a #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 +#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 #define EXT4_INDIRECT_BLOCKS 12