!11 e2fsprogs: backport upstream patches to fix some problem-epoch2

From: @liuzhiqiang26
Reviewed-by: @shijieluo,@lixiaokeng,@wubo009
Signed-off-by: @wubo009,@wubo009
This commit is contained in:
openeuler-ci-bot 2020-11-02 10:44:43 +08:00 committed by Gitee
commit 85b05a580d
4 changed files with 117 additions and 45 deletions

View File

@ -0,0 +1,29 @@
From 2f6fd5da81a78aa45d750d8248b25171b8ad9dcd Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Fri, 10 Apr 2020 00:30:52 -0400
Subject: [PATCH 13/26] e2fsck: fix off-by-one check when validating depth of
an htree
Fixes: 3f0cf6475399 ("e2fsprogs: add support for 3-level htree")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/pass1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index c9e8bf8..38afda4 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2685,7 +2685,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
return 1;
pctx->num = root->indirect_levels;
- if ((root->indirect_levels > ext2_dir_htree_level(fs)) &&
+ if ((root->indirect_levels >= ext2_dir_htree_level(fs)) &&
fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
return 1;
--
1.8.3.1

View File

@ -1,44 +0,0 @@
diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/expect e2fsprogs-1.44.4-hzq/tests/m_hugefile/expect
--- e2fsprogs-1.44.4/tests/m_hugefile/expect 2018-08-19 10:26:58.000000000 +0800
+++ e2fsprogs-1.44.4-hzq/tests/m_hugefile/expect 2018-11-30 06:04:12.000000000 +0800
@@ -1,19 +1,19 @@
-mke2fs -F -T hugefile test.img 4T
-Creating filesystem with 1073741824 4k blocks and 1048576 inodes
+mke2fs -F -T hugefile test.img 1T
+Creating filesystem with 268435456 4k blocks and 262144 inodes
Superblock backups stored on blocks:
Allocating group tables: done
-Writing inode tables: done
+Writing inode tables: done
Creating 1 huge file(s) : done
-Writing superblocks and filesystem accounting information: done
+Writing superblocks and filesystem accounting information: done
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 13/1048576 files (0.0% non-contiguous), 1073709417/1073741824 blocks
+test_filesys: 13/262144 files (0.0% non-contiguous), 268394593/268435456 blocks
Exit status is 0
debugfs -R "extents /store/big-data" test.img
-Last logical block: 1073610751
-Last physical block: 1073741823
+Last logical block: 268369919
+Last physical block: 268435455
diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/script e2fsprogs-1.44.4-hzq/tests/m_hugefile/script
--- e2fsprogs-1.44.4/tests/m_hugefile/script 2018-08-19 10:26:58.000000000 +0800
+++ e2fsprogs-1.44.4-hzq/tests/m_hugefile/script 2018-11-30 05:52:17.000000000 +0800
@@ -35,8 +35,8 @@ cat > $CONF << ENDL
}
ENDL
-echo "mke2fs -F -T hugefile test.img 4T" > $OUT
-MKE2FS_CONFIG=$CONF $MKE2FS -F -T hugefile $TMPFILE 4T >> $OUT 2>&1
+echo "mke2fs -F -T hugefile test.img 1T" > $OUT
+MKE2FS_CONFIG=$CONF $MKE2FS -F -T hugefile $TMPFILE 1T >> $OUT 2>&1
rm -f $CONF
# check the file system if we get this far, we succeeded...

View File

@ -0,0 +1,82 @@
From 4baaa1fcada10669af9c267d8c436383e0bffb07 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 21 Jul 2020 18:25:03 -0700
Subject: [PATCH 25/26] mke2fs: fix up check for hardlinks always false if
inode > 0xFFFFFFFF
While file has a large inode number (> 0xFFFFFFFF), mkfs.ext4 could
not parse hardlink correctly.
Prepare three hardlink files for mkfs.ext4
$ ls -il rootfs_ota/a rootfs_ota/boot/b rootfs_ota/boot/c
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/a
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/b
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/c
$ truncate -s 1M rootfs_ota.ext4
$ mkfs.ext4 -F -i 8192 rootfs_ota.ext4 -L otaroot -U fd5f8768-c779-4dc9-adde-165a3d863349 -d rootfs_ota
$ mkdir mnt && sudo mount rootfs_ota.ext4 mnt
$ ls -il mnt/a mnt/boot/b mnt/boot/c
12 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/a
14 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/b
15 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/c
After applying this fix
$ ls -il mnt/a mnt/boot/b mnt/boot/c
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/a
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/b
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/c
Since commit [382ed4a1 e2fsck: use proper types for variables][1]
applied, it used ext2_ino_t instead of ino_t for referencing inode
numbers, but the type of is_hardlink's `ino' should not be instead,
The ext2_ino_t is 32bit, if inode > 0xFFFFFFFF, its value will be
truncated.
Add a debug printf to show the value of inode, when it check for hardlink
files, it will always return false if inode > 0xFFFFFFFF
|--- a/misc/create_inode.c
|+++ b/misc/create_inode.c
|@@ -605,6 +605,7 @@ static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
| {
| int i;
|
|+ printf("%s %d, %lX, %lX\n", __FUNCTION__, __LINE__, hdlinks->hdl[i].src_ino, ino);
| for (i = 0; i < hdlinks->count; i++) {
| if (hdlinks->hdl[i].src_dev == dev &&
| hdlinks->hdl[i].src_ino == ino)
Here is debug message:
is_hardlink 608, 2913DB886, 913DB886
The length of ext2_ino_t is 32bit (typedef __u32 __bitwise ext2_ino_t;),
and ino_t is 64bit on 64bit system (such as x86-64), recover `ino' to ino_t.
[1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=382ed4a1c2b60acb9db7631e86dda207bde6076e
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/create_inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/create_inode.c b/misc/create_inode.c
index e8d1df6..837f387 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -601,7 +601,7 @@ out:
return err;
}
-static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
+static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ino_t ino)
{
int i;
--
1.8.3.1

View File

@ -1,12 +1,14 @@
Name: e2fsprogs
Version: 1.45.6
Release: 1
Release: 2
Summary: Second extended file system management tools
License: GPLv2 and LGPLv2 and MIT
URL: http://e2fsprogs.sourceforge.net/
Source0: https://www.kernel.org/pub/linux/kernel/people/tytso/%{name}/v%{version}/%{name}-%{version}.tar.xz
Patch1: 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch
Patch2: 0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch
Patch3: 0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch
BuildRequires: gcc git pkgconfig texinfo
BuildRequires: fuse-devel libblkid-devel libuuid-devel
@ -126,6 +128,9 @@ exit 0
%{_mandir}/man8/*
%changelog
* Fri Oct 30 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 1.45.6-2
- backport upstream patches-epoch2 to fix some problems
* Wed Jul 15 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 1.45.6-1
- rebuild package