Update openEuler:e2fsprogs v1.46.4 to e2fsprogs v1.47.2

Change-Id: Ia36c7caa4e1e1c4cbbfd0fbbac64b924788551b0
Signed-off-by: zhang-daiyue <zhangdaiyue1@huawei.com>
This commit is contained in:
zhang-daiyue
2025-05-13 23:07:28 +08:00
parent f2a23ac678
commit ca4d4f129c
49 changed files with 38 additions and 2823 deletions
@@ -1,63 +0,0 @@
From 851e3f835614371ab4e21c36f2ddcb6f0312a8bb Mon Sep 17 00:00:00 2001
From: ZhiqiangLiu <lzhq28@mail.ustc.edu.cn>
Date: Wed, 15 Jul 2020 21:20:25 +0800
Subject: [PATCH] e2fsprogs: set hugefile from 4T to 1T in hugefile test
When execing make check, 4T is too large for CI,
so set hugefile from 4T to 1T in hugefile test.
Signed-off-by: Zhiqiang Liu <lzhq28@mail.ustc.edu.cn>
---
tests/m_hugefile/expect | 14 +++++++-------
tests/m_hugefile/script | 4 ++--
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/m_hugefile/expect b/tests/m_hugefile/expect
index ee33fe5..170387a 100644
--- a/tests/m_hugefile/expect
+++ b/tests/m_hugefile/expect
@@ -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 --git a/tests/m_hugefile/script b/tests/m_hugefile/script
index 1abdb7d..e576a21 100644
--- a/tests/m_hugefile/script
+++ b/tests/m_hugefile/script
@@ -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...
--
2.21.1 (Apple Git-122.3)
@@ -1,30 +0,0 @@
From 3d967e53033c85ad5d3af1a42efb2c4f7501c356 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Fri, 20 Aug 2021 18:15:02 +0200
Subject: [PATCH] libss: add newer libreadline.so.8 to dlopen path
OpenSUSE Tumbleweed now has libreadline.so.8. Add it to the list of libs
to look for.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ss/get_readline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ss/get_readline.c b/lib/ss/get_readline.c
index 11c72b3..aa16157 100644
--- a/lib/ss/get_readline.c
+++ b/lib/ss/get_readline.c
@@ -37,7 +37,7 @@ static void ss_release_readline(ss_data *info)
#endif
/* Libraries we will try to use for readline/editline functionality */
-#define DEFAULT_LIBPATH "libreadline.so.7:libreadline.so.6:libreadline.so.5:libreadline.so.4:libreadline.so:libedit.so.2:libedit.so:libeditline.so.0:libeditline.so"
+#define DEFAULT_LIBPATH "libreadline.so.8:libreadline.so.7:libreadline.so.6:libreadline.so.5:libreadline.so.4:libreadline.so:libedit.so.2:libedit.so:libeditline.so.0:libeditline.so"
#ifdef HAVE_DLOPEN
void ss_get_readline(int sci_idx)
--
2.14.3 (Apple Git-98)
@@ -1,41 +0,0 @@
From 8b2beb24819a976f575e8cec04e3fe6ca8851017 Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Tue, 24 Aug 2021 14:10:19 +0200
Subject: [PATCH] tests: update expect files for f_mmp_garbage
Update expect file for f_mmp_garbage test to work correctly with the
new default 256 inode size.
Fixes: d730be5ceeba ("tests: update mke2fs.conf to create 256 byte inodes by default")
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
tests/f_mmp_garbage/expect.1 | 2 +-
tests/f_mmp_garbage/expect.2 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/f_mmp_garbage/expect.1 b/tests/f_mmp_garbage/expect.1
index a8add10..4134eae 100644
--- a/tests/f_mmp_garbage/expect.1
+++ b/tests/f_mmp_garbage/expect.1
@@ -5,5 +5,5 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/64 files (0.0% non-contiguous), 13/100 blocks
+test_filesys: 11/64 files (0.0% non-contiguous), 15/100 blocks
Exit status is 0
diff --git a/tests/f_mmp_garbage/expect.2 b/tests/f_mmp_garbage/expect.2
index 6630002..3bca182 100644
--- a/tests/f_mmp_garbage/expect.2
+++ b/tests/f_mmp_garbage/expect.2
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/64 files (0.0% non-contiguous), 13/100 blocks
+test_filesys: 11/64 files (0.0% non-contiguous), 15/100 blocks
Exit status is 0
--
1.8.3.1
@@ -1,38 +0,0 @@
From da33289073de254ab4bacb80b1b83cf9d27c76ea Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Tue, 24 Aug 2021 14:10:20 +0200
Subject: [PATCH] tests: update expect files for f_large_dir and
f_large_dir_csum
Update expect files for f_large_dir and f_large_dir_csum tests to
include the warning about missing y2038 support with 128-byte inodes.
Fixes: a23b50cd ("mke2fs: warn about missing y2038 support when formatting fresh ext4 fs")
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
tests/f_large_dir/expect | 1 +
tests/f_large_dir_csum/expect | 1 +
2 files changed, 2 insertions(+)
diff --git a/tests/f_large_dir/expect b/tests/f_large_dir/expect
index 028234c..495ea85 100644
--- a/tests/f_large_dir/expect
+++ b/tests/f_large_dir/expect
@@ -1,3 +1,4 @@
+128-byte inodes cannot handle dates beyond 2038 and are deprecated
Creating filesystem with 108341 1k blocks and 65072 inodes
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
diff --git a/tests/f_large_dir_csum/expect b/tests/f_large_dir_csum/expect
index aa9f33f..44770f7 100644
--- a/tests/f_large_dir_csum/expect
+++ b/tests/f_large_dir_csum/expect
@@ -1,3 +1,4 @@
+128-byte inodes cannot handle dates beyond 2038 and are deprecated
Creating filesystem with 31002 1k blocks and 64 inodes
Superblock backups stored on blocks:
8193, 24577
--
1.8.3.1
@@ -1,59 +0,0 @@
From 228e9f0567eebd4597bd1771fc4bf3650190cf3e Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Thu, 24 Feb 2022 10:06:30 +0800
Subject: [PATCH] resize2fs: resize2fs disk hardlinks will be error
Resize2fs disk hardlinks which mounting after the same name as tmpfs
filesystem it will be error. The items in /proc/mounts are traversed,
when you get to tmpfs, file!=mnt->mnt_fsname, therefore, the
stat(mnt->mnt_fsname, &st_buf) branch is used, however, the values of
file_rdev and st_buf.st_rdev are the same, As a result, the system
mistakenly considers that disk is mounted to /root/tmp. As a result
, resize2fs fails.
example:
dev_name="/dev/sdc" (ps: a disk in you self)
mkdir /root/tmp
mkdir /root/mnt
mkfs.ext4 -F -b 1024 -E "resize=10000000" "${dev_name}" 32768
mount -t tmpfs "${dev_name}" /root/tmp
mount "${dev_name}" /root/tmp
ln "${dev_name}" "${dev_name}"-ln
resize2fs "${dev_name}"-ln 6G
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: guiyao <guiyao@huawei.com>
---
lib/ext2fs/ismounted.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index aee7d72..463a82a 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -98,6 +98,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
{
struct mntent *mnt;
struct stat st_buf;
+ struct stat dir_st_buf;
errcode_t retval = 0;
dev_t file_dev=0, file_rdev=0;
ino_t file_ino=0;
@@ -144,8 +145,12 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
if (stat(mnt->mnt_fsname, &st_buf) == 0) {
if (ext2fsP_is_disk_device(st_buf.st_mode)) {
#ifndef __GNU__
- if (file_rdev && (file_rdev == st_buf.st_rdev))
- break;
+ if (file_rdev && (file_rdev == st_buf.st_rdev)) {
+ if (stat(mnt->mnt_dir, &dir_st_buf) != 0)
+ continue;
+ if (file_rdev == dir_st_buf.st_dev)
+ break;
+ }
if (check_loop_mounted(mnt->mnt_fsname,
st_buf.st_rdev, file_dev,
file_ino) == 1)
--
1.8.3.1
@@ -1,51 +0,0 @@
From dc4c71c6192f9709a2d833f9aa63d3463da6155a Mon Sep 17 00:00:00 2001
From: lihaotian <lihaotian9@huawei.com>
Date: Tue, 15 Dec 2020 11:46:07 +0000
Subject: [PATCH] e2fsck: exit journal recovery when find EIO, ENOMEM
errors
jbd2_journal_revocer() may fail when some error occers
such as ENOMEM. However, jsb->s_start is still cleared
by func e2fsck_journal_release(). This may break
consistency between metadata and data in disk. Sometimes,
failure in jbd2_journal_revocer() is temporary but retry
e2fsck will skip the journal recovery when the temporary
problem is fixed.
To fix this case, we use "fatal_error" instead "goto errout"
when recover journal failed. If journal recovery fails, we
will send error message to user and reserve the recovery
flags to recover the journal when try e2fsck again.
Fix issue: https://gitee.com/src-openeuler/e2fsprogs/issues/I4RZUT?from=project-issue
conflict: journal_recover -> jbd2_journal_recover
Reported-by: Liangyun <liangyun2@huawei.com>
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
e2fsck/journal.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index e83f3a9..a5f7088 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -942,6 +942,13 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
goto errout;
retval = -jbd2_journal_recover(journal);
+ if (retval == EIO || retval == ENOMEM || retval == EXT2_ET_NO_MEMORY) {
+ ctx->fs->flags &= ~EXT2_FLAG_VALID;
+ com_err(ctx->program_name, 0,
+ _("Journal recovery failed "
+ "on %s, retval=%d \n"), ctx->device_name, retval);
+ fatal_error(ctx, 0);
+ }
if (retval)
goto errout;
--
2.21.1 (Apple Git-122.3)
@@ -1,98 +0,0 @@
From f923f6ddbd555801f1d6495904de4fefb363fa57 Mon Sep 17 00:00:00 2001
From: liangyun2 <liangyun2@huawei.com>
Date: Sat, 19 Dec 2020 12:05:37 +0800
Subject: [PATCH] e2fsck: exit journal recovery when jounral superblock fails
to update
Jounral superblock may be failed to update in e2fsck_journal_release.
But if needs_recovery flag is cleared, e2fsck_check_ext3_journal will be failed.
To fix this case, we use "fatal_error" when recover journal failed.
So we can reserve the recovery flag to recover the journal when try e2fsck again.
Fix issue: https://gitee.com/src-openeuler/e2fsprogs/issues/I4S0SD?from=project-issue
conflict: journal_destroy_revoke -> jbd2_journal_destroy_revoke
journal_destroy_revoke_caches -> jbd2_journal_destroy_revoke_record_cache
jbd2_journal_destroy_revoke_table_cache
JFS_BARRIER -> JBD2_BARRIER
blkdev_issue_flush(kdev, a, b) -> blkdev_issue_flush(kdev)
Reported-by: Liangyun <liangyun2@huawei.com>
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
e2fsck/journal.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 7081b6e..f4253c0 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -1444,10 +1444,12 @@ static errcode_t e2fsck_journal_fix_corrupt_super(e2fsck_t ctx,
return 0;
}
-static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
+static errcode_t e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
int reset, int drop)
{
journal_superblock_t *jsb;
+ errcode_t err = 0;
+ errcode_t err2;
if (drop)
mark_buffer_clean(journal->j_sb_buffer);
@@ -1461,6 +1463,16 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
}
brelse(journal->j_sb_buffer);
+ if(reset == 1 && drop == 0) {
+ err = sync_blockdev(journal->j_fs_dev);
+ /* Make sure all replayed data is on permanent storage */
+ if (journal->j_flags & JBD2_BARRIER) {
+ err2 = blkdev_issue_flush(journal->j_fs_dev);
+ if (!err)
+ err = err2;
+ }
+ }
+
if (ctx->journal_io) {
if (ctx->fs && ctx->fs->io != ctx->journal_io)
io_channel_close(ctx->journal_io);
@@ -1474,6 +1486,8 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
if (journal->j_fs_dev)
ext2fs_free_mem(&journal->j_fs_dev);
ext2fs_free_mem(&journal);
+
+ return err;
}
/*
@@ -1612,6 +1626,7 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
struct problem_context pctx;
journal_t *journal;
errcode_t retval;
+ errcode_t recover_retval;
clear_problem_context(&pctx);
@@ -1659,7 +1674,14 @@ errout:
jbd2_journal_destroy_revoke(journal);
jbd2_journal_destroy_revoke_record_cache();
jbd2_journal_destroy_revoke_table_cache();
- e2fsck_journal_release(ctx, journal, 1, 0);
+ recover_retval = e2fsck_journal_release(ctx, journal, 1, 0);
+ if(recover_retval == -EIO) {
+ ctx->fs->flags &= ~EXT2_FLAG_VALID;
+ com_err(ctx->program_name, 0,
+ _("e2fsck journal release failed "
+ "on %s, retval=%d \n"), ctx->device_name, recover_retval);
+ fatal_error(ctx, 0);
+ }
return retval;
}
--
1.8.3.1
@@ -1,41 +0,0 @@
From 491c2dea43a9c9f33c5feb9ccd9b91d04a24b6f7 Mon Sep 17 00:00:00 2001
From: Haotian <lihaotian9@huawei.com>
Date: Wed, 17 Mar 2021 17:34:14 +0800
Subject: [PATCH] e2fsck: add env param E2FS_UNRELIABLE_IO to fix
unreliable io case
Func write_primary_superblock() has two way to wirte disk. One is 1k block,
the other is byte by byte as default. On unreliable IO case such as flaky
network, the byte-by-byte method may lost some data of ext4-superblock.
Then, the superblock may lose consistency and the sb checksum error will
occur.
We provide the env param E2FS_UNRELIABLE_IO for users to choose if it's
necessary to take 1k block way on writing disk.
Fix issue:https://gitee.com/src-openeuler/e2fsprogs/issues/I4RZVX?from=project-issue
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
lib/ext2fs/closefs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 1d4d5b7..1893fb6 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -195,8 +195,9 @@ static errcode_t write_primary_superblock(ext2_filsys fs,
__u16 *old_super, *new_super;
int check_idx, write_idx, size;
errcode_t retval;
+ int is_unreliable_io = getenv("E2FS_UNRELIABLE_IO") ? 1 : 0;
- if (!fs->io->manager->write_byte || !fs->orig_super) {
+ if (!fs->io->manager->write_byte || !fs->orig_super || is_unreliable_io) {
fallback:
io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
retval = io_channel_write_blk64(fs->io, 1, -SUPERBLOCK_SIZE,
--
2.21.1 (Apple Git-122.3)
@@ -1,31 +0,0 @@
From 8178197e6c39b2a08c90bcd3685d694115ce9254 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Tue, 1 Mar 2022 21:46:55 +0800
Subject: [PATCH] e2mmpstatus.8.in: detele filesystem can be UUID or LABEL in
manpage
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
misc/e2mmpstatus.8.in | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/misc/e2mmpstatus.8.in b/misc/e2mmpstatus.8.in
index c7ed929..07a28ec 100644
--- a/misc/e2mmpstatus.8.in
+++ b/misc/e2mmpstatus.8.in
@@ -19,11 +19,7 @@ file system with the
feature enabled. The specified
.I file system
can be a device name (e.g.
-.IR /dev/hdc1 ", " /dev/sdb2 ),
-or an ext4 file system label or UUID, for example
-.B UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd
-or
-.BR LABEL=root .
+.IR /dev/hdc1 ", " /dev/sdb2 ).
By default, the
.B e2mmpstatus
program checks whether it is safe to mount the file system without taking
--
1.8.3.1
@@ -1,75 +0,0 @@
From 4cda25453f85f06371735b8f55d584e0d38a52bc Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Sun, 22 Aug 2021 10:07:15 -0400
Subject: [PATCH] tests: update expect file for u_direct_io
The u_direct_io test is normally not run (since it requires root
privileges); as a result, when the mke2fs.conf defaults were changed,
I didn't notice that the expected output for u_direct_io test needed
to be updated.
Fixes: d730be5ceeba ("tests: update mke2fs.conf to create 256 byte inodes by default"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
tests/u_direct_io/expect | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tests/u_direct_io/expect b/tests/u_direct_io/expect
index b0cdc73..830cbd7 100644
--- a/tests/u_direct_io/expect
+++ b/tests/u_direct_io/expect
@@ -19,8 +19,8 @@ Filesystem OS type: Linux
Inode count: 32768
Block count: 32768
Reserved block count: 1638
-Overhead clusters: 5131
-Free blocks: 27631
+Overhead clusters: 6155
+Free blocks: 26607
Free inodes: 32757
First block: 0
Block size: 4096
@@ -29,27 +29,29 @@ Reserved GDT blocks: 7
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 32768
-Inode blocks per group: 1024
+Inode blocks per group: 2048
Flex block group size: 16
Mount count: 0
Check interval: 15552000 (6 months)
Reserved blocks uid: 0
Reserved blocks gid: 0
First inode: 11
-Inode size: 128
+Inode size: 256
+Required extra isize: 32
+Desired extra isize: 32
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Directories: 2
Group 0: block bitmap at 9, inode bitmap at 25, inode table at 41
- 27631 free blocks, 32757 free inodes, 2 used directories
+ 26607 free blocks, 32757 free inodes, 2 used directories
e2fsck -fn -N test_filesys $LOOP
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: 11/32768 files (9.1% non-contiguous), 5137/32768 blocks
+test_filesys: 11/32768 files (9.1% non-contiguous), 6161/32768 blocks
Exit status is 0
e2fsck -fn -N test_filesys $TMPFILE
Pass 1: Checking inodes, blocks, and sizes
@@ -57,5 +59,5 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/32768 files (9.1% non-contiguous), 5137/32768 blocks
+test_filesys: 11/32768 files (9.1% non-contiguous), 6161/32768 blocks
Exit status is 0
--
1.8.3.1
@@ -1,106 +0,0 @@
From 699d448eee4b991acafaae4e4f8222be332d6837 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Thu, 9 Dec 2021 10:55:54 -0500
Subject: [PATCH] libext2fs: don't old the CACHE_MTX while doing I/O
A report a deadlock problem caused by I/O errors (caused by e2fsck's
error handler trying to write to a bad block to perform a forced
rewrite) uncovered that we were holding the CACHE_MTX while doing read
operations. This serialized read operations which destroyed the
performance benefits from doing parallel bitmap loading (or the
parallel e2fsck processing under development).
So restructure the code in unix_read_blk64() so that the read is
always done into the user-provided buffer, and then copied into the
cache afterwards.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/unix_io.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 50ac737..e53db33 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -977,8 +977,8 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
int count, void *buf)
{
struct unix_private_data *data;
- struct unix_cache *cache, *reuse[READ_DIRECT_SIZE];
- errcode_t retval = 0;
+ struct unix_cache *cache;
+ errcode_t retval;
char *cp;
int i, j;
@@ -1005,7 +1005,7 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
mutex_lock(data, CACHE_MTX);
while (count > 0) {
/* If it's in the cache, use it! */
- if ((cache = find_cached_block(data, block, &reuse[0]))) {
+ if ((cache = find_cached_block(data, block, NULL))) {
#ifdef DEBUG
printf("Using cached block %lu\n", block);
#endif
@@ -1015,47 +1015,35 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
cp += channel->block_size;
continue;
}
- if (count == 1) {
- /*
- * Special case where we read directly into the
- * cache buffer; important in the O_DIRECT case
- */
- cache = reuse[0];
- reuse_cache(channel, data, cache, block);
- if ((retval = raw_read_blk(channel, data, block, 1,
- cache->buf))) {
- cache->in_use = 0;
- break;
- }
- memcpy(cp, cache->buf, channel->block_size);
- retval = 0;
- break;
- }
/*
* Find the number of uncached blocks so we can do a
* single read request
*/
for (i=1; i < count; i++)
- if (find_cached_block(data, block+i, &reuse[i]))
+ if (find_cached_block(data, block+i, NULL))
break;
#ifdef DEBUG
printf("Reading %d blocks starting at %lu\n", i, block);
#endif
+ mutex_unlock(data, CACHE_MTX);
if ((retval = raw_read_blk(channel, data, block, i, cp)))
- break;
+ return retval;
+ mutex_lock(data, CACHE_MTX);
/* Save the results in the cache */
for (j=0; j < i; j++) {
+ if (!find_cached_block(data, block, &cache)) {
+ reuse_cache(channel, data, cache, block);
+ memcpy(cache->buf, cp, channel->block_size);
+ }
count--;
- cache = reuse[j];
- reuse_cache(channel, data, cache, block++);
- memcpy(cache->buf, cp, channel->block_size);
+ block++;
cp += channel->block_size;
}
}
mutex_unlock(data, CACHE_MTX);
- return retval;
+ return 0;
#endif /* NO_IO_CACHE */
}
--
1.8.3.1
-136
View File
@@ -1,136 +0,0 @@
From 13f1ce96046fba15d93a90733b791312284fbb62 Mon Sep 17 00:00:00 2001
From: Andreas Dilger <adilger@whamcloud.com>
Date: Mon, 28 Feb 2022 21:17:06 -0700
Subject: [PATCH] tests: fix ACL-printing tests
Fix the ACL-printing tests to be more flexible for different systems.
If the MKFS_DIR is on tmpfs, it will not list "system.posix_acl*"
xattrs, so they will not be copied. Create this on a real filesystem
or skip the test if that doesn't work.
Filter out the security.selinux xattr if it is printed, since this
depends on the selinux configuration of the host system. However,
this also spills xattrs for "acl_dir/file" into an external xattr
block, and causes it to fail due to different block allocations.
Increase the filesystem inode size so that the allocation is the same
regardless of whether selinux is enabled or not.
Fixes: 67e6ae0a35 ("mke2fs: fix a importing a directory with an ACL")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
tests/filter.sed | 1 +
tests/m_rootdir_acl/expect | 18 +++++++++---------
tests/m_rootdir_acl/script | 13 +++++++++----
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/tests/filter.sed b/tests/filter.sed
index 796186e..5fd68f3 100644
--- a/tests/filter.sed
+++ b/tests/filter.sed
@@ -20,6 +20,7 @@ s/\\015//g
/^Maximum mount count:/d
/^Next check after:/d
/^Suggestion:/d
+/security.selinux/d
/Reserved blocks uid:/s/ (user .*)//
/Reserved blocks gid:/s/ (group .*)//
/whichever comes first/d
diff --git a/tests/m_rootdir_acl/expect b/tests/m_rootdir_acl/expect
index babd802..57f03e5 100644
--- a/tests/m_rootdir_acl/expect
+++ b/tests/m_rootdir_acl/expect
@@ -10,8 +10,8 @@ Filesystem OS type: Linux
Inode count: 1024
Block count: 16384
Reserved block count: 819
-Overhead clusters: 1543
-Free blocks: 14788
+Overhead clusters: 1799
+Free blocks: 14533
Free inodes: 1003
First block: 1
Block size: 1024
@@ -21,14 +21,14 @@ Reserved GDT blocks: 127
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 512
-Inode blocks per group: 128
+Inode blocks per group: 256
Flex block group size: 16
Mount count: 0
Check interval: 15552000 (6 months)
Reserved blocks uid: 0
Reserved blocks gid: 0
First inode: 11
-Inode size: 256
+Inode size: 512
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
@@ -49,16 +49,16 @@ Group 0: (Blocks 1-8192)
Reserved GDT blocks at 3-129
Block bitmap at 130 (+129)
Inode bitmap at 132 (+131)
- Inode table at 134-261 (+133)
- 7750 free blocks, 491 free inodes, 5 directories, 491 unused inodes
- Free blocks: 443-8192
+ Inode table at 134-389 (+133)
+ 7495 free blocks, 491 free inodes, 5 directories, 491 unused inodes
+ Free blocks: 698-8192
Free inodes: 22-512
Group 1: (Blocks 8193-16383) [INODE_UNINIT]
Backup superblock at 8193, Group descriptors at 8194-8194
Reserved GDT blocks at 8195-8321
Block bitmap at 131 (bg #0 + 130)
Inode bitmap at 133 (bg #0 + 132)
- Inode table at 262-389 (bg #0 + 261)
+ Inode table at 390-645 (bg #0 + 389)
7038 free blocks, 512 free inodes, 0 directories, 512 unused inodes
Free blocks: 9346-16383
Free inodes: 513-1024
@@ -116,4 +116,4 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test.img: 21/1024 files (0.0% non-contiguous), 1596/16384 blocks
+test.img: 21/1024 files (0.0% non-contiguous), 1851/16384 blocks
diff --git a/tests/m_rootdir_acl/script b/tests/m_rootdir_acl/script
index e81c82c..a00e4c4 100644
--- a/tests/m_rootdir_acl/script
+++ b/tests/m_rootdir_acl/script
@@ -16,12 +16,10 @@ if [ "$os" = "GNU" ]; then
return 0
fi
-MKFS_DIR=$TMPFILE.dir
+MKFS_DIR=$(mktemp -d ./$test_name-XXXXXX.tmp)
OUT=$test_name.log
EXP=$test_dir/expect
-rm -rf $MKFS_DIR
-mkdir -p $MKFS_DIR
touch $MKFS_DIR/emptyfile
dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile
echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null
@@ -60,7 +58,14 @@ mask::r-x
other::r-x
EOF
-$MKE2FS -q -F -o Linux -T ext4 -O metadata_csum,inline_data,64bit -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT 2>&1
+if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
+ echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
+ rm -rf $MKFS_DIR
+ return 0
+fi
+
+# use 512-byte inodes so with/out security.selinux xattr doesn't fail
+$MKE2FS -q -F -o Linux -T ext4 -I 512 -O metadata_csum,inline_data,64bit -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT 2>&1
$DUMPE2FS $TMPFILE >> $OUT 2>&1
cat > $TMPFILE.cmd << ENDL
--
1.8.3.1
@@ -1,61 +0,0 @@
From 3dcbf460613413614684013a51279f1e65c32f9e Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Wed, 18 May 2022 15:16:25 +0800
Subject: [PATCH] e2fsck: do not clean up file acl if the inode is truncating
type
We got issue as follows:
[root@localhost ~]# e2fsck -a img
img: recovering journal
img: Truncating orphaned inode 188 (uid=0, gid=0, mode=0100666, size=0)
img: Truncating orphaned inode 174 (uid=0, gid=0, mode=0100666, size=0)
img: clean, 484/128016 files, 118274/512000 blocks
[root@localhost ~]# e2fsck -fn img
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Inode 174, i_blocks is 2, should be 0. Fix? no
Inode 188, i_blocks is 2, should be 0. Fix? no
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
img: ********** WARNING: Filesystem still has errors **********
img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks
File acl would be clean up in release_inode_blocks, whether the orphan
node is truncating or clearing type. If the inode is truncating type,
the file acl would be clean up, but the blocks count is not be
subtract acl blocks, and the inode is not unmark in bitmap, which causes
this issue.
To slove this issue, do not clean up file acl if the inode is truncating
type.
Signed-off-by: LiJinlin <lijinlin3@huawei.com>
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
e2fsck/super.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 31e2ffb..ec28426 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -235,6 +235,10 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
if (pb.truncated_blocks)
ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode),
pb.truncated_blocks);
+
+ /* do not clean up file acl if the inode is truncating type */
+ if (inode->i_links_count)
+ return 0;
blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode));
if (blk) {
--
1.8.3.1
@@ -1,74 +0,0 @@
From 508b1b57f73a49effc975731f8b76325d45b0e0f Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Fri, 18 Mar 2022 00:02:50 +0800
Subject: [PATCH] e2fsck: handle->level is overflow in ext2fs_extent_get.
In function check_blocks_extents, program call scan_extent_node recursively until
leaf extent is found, and if this leaf extent is the last one in this extent_idx,
it will delete the parent extent_idx of this leaf extent in ext2fs_extent_delete,
and do handle->level--. After scan_extent_node return, program allways to get up extent,
but level was already decreased.
So calling ext2fs_extent_get(EXT2_EXTENT_UP) again will return EXT2_ET_EXTENT_NO_UP,
and then print failed.
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
e2fsck/pass1.c | 7 +++++++
lib/ext2fs/ext2fs.h | 1 +
lib/ext2fs/extent.c | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 26b9ab71..3d698934 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -3074,11 +3074,18 @@ report_problem:
}
}
}
+
+ int level_bak = ext2fs_current_level_get(ehandle);
+
scan_extent_node(ctx, pctx, pb, extent.e_lblk,
last_lblk, eof_block, ehandle,
next_try_repairs);
if (pctx->errcode)
return;
+
+ if (level_bak != ext2fs_current_level_get(ehandle))
+ return;
+
pctx->errcode = ext2fs_extent_get(ehandle,
EXT2_EXTENT_UP, &extent);
if (pctx->errcode) {
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 68f9c1fe..d0468f11 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1333,6 +1333,7 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
+extern int ext2fs_current_level_get(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
struct ext2fs_extent *extent);
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index b324c7b0..07acd4e0 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -575,6 +575,11 @@ retry:
return 0;
}
+int ext2fs_current_level_get(ext2_extent_handle_t handle)
+{
+ return handle->level;
+}
+
static errcode_t update_path(ext2_extent_handle_t handle)
{
blk64_t blk;
--
2.27.0
@@ -1,55 +0,0 @@
From ab51d587bb9b229b1fade1afd02e1574c1ba5c76 Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Thu, 21 Apr 2022 19:31:48 +0200
Subject: [PATCH] libext2fs: add sanity check to extent manipulation
It is possible to have a corrupted extent tree in such a way that a leaf
node contains zero extents in it. Currently if that happens and we try
to traverse the tree we can end up accessing wrong data, or possibly
even uninitialized memory. Make sure we don't do that.
Additionally make sure that we have a sane number of bytes passed to
memmove() in ext2fs_extent_delete().
Note that e2fsck is currently unable to spot and fix such corruption in
pass1.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Nils Bars <nils_bars@t-online.de>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2068113
Addresses: CVE-2022-1304
Addresses-Debian-Bug: #1010263
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/extent.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index b324c7b..1a206a1 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -495,6 +495,10 @@ retry:
ext2fs_le16_to_cpu(eh->eh_entries);
newpath->max_entries = ext2fs_le16_to_cpu(eh->eh_max);
+ /* Make sure there is at least one extent present */
+ if (newpath->left <= 0)
+ return EXT2_ET_EXTENT_NO_DOWN;
+
if (path->left > 0) {
ix++;
newpath->end_blk = ext2fs_le32_to_cpu(ix->ei_block);
@@ -1630,6 +1634,10 @@ errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags)
cp = path->curr;
+ /* Sanity check before memmove() */
+ if (path->left < 0)
+ return EXT2_ET_EXTENT_LEAF_BAD;
+
if (path->left) {
memmove(cp, cp + sizeof(struct ext3_extent_idx),
path->left * sizeof(struct ext3_extent_idx));
--
1.8.3.1
-134
View File
@@ -1,134 +0,0 @@
From 862752ef988c637562196b802504ce5b3cafe9ea Mon Sep 17 00:00:00 2001
From: wuzx <wuzx1226@qq.com>
Date: Thu, 11 Aug 2022 14:58:42 +0000
Subject: [PATCH] e2fsprogs add sw64
Add code related to sw64 in file configure configure.ac aclocal.m4 lib/blkid/llseek.c lib/ext2fs/unix_io.c to support sw64 architecture.
Signed-off-by: wuzx <wuzx1226@qq.com>
---
aclocal.m4 | 13 +++++++++++--
configure | 6 +++---
configure.ac | 2 +-
lib/blkid/llseek.c | 2 +-
lib/ext2fs/unix_io.c | 2 +-
5 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 0f39d30..206d5b0 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -977,6 +977,12 @@ changequote([,])dnl
[gl_cv_host_cpu_c_abi=i386])
;;
+changequote(,)dnl
+ sw_64* )
+changequote([,])dnl
+ gl_cv_host_cpu_c_abi=sw_64
+ ;;
+
changequote(,)dnl
alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
changequote([,])dnl
@@ -1242,6 +1248,9 @@ EOF
#ifndef __x86_64__
#undef __x86_64__
#endif
+#ifndef __sw_64__
+#undef __sw_64__
+#endif
#ifndef __alpha__
#undef __alpha__
#endif
@@ -1355,7 +1364,7 @@ AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
case "$gl_cv_host_cpu_c_abi" in
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
gl_cv_host_cpu_c_abi_32bit=yes ;;
- x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
+ x86_64 | sw_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
gl_cv_host_cpu_c_abi_32bit=no ;;
*)
gl_cv_host_cpu_c_abi_32bit=unknown ;;
@@ -1385,7 +1394,7 @@ AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
# CPUs that only support a 64-bit ABI.
changequote(,)dnl
- alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
+ sw_64* | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
| mmix )
changequote([,])dnl
gl_cv_host_cpu_c_abi_32bit=no
diff --git a/configure b/configure
index 405b730..bc483dc 100755
--- a/configure
+++ b/configure
@@ -4462,7 +4462,7 @@ $as_echo_n "checking for additional special compiler flags... " >&6; }
if test "$GCC" = yes
then
case "$host_cpu" in
- alpha) addcflags="-mieee" ;;
+ alpha | sw_64) addcflags="-mieee" ;;
esac
fi
if test "x$addcflags" != x
@@ -7552,7 +7552,7 @@ else
case "$gl_cv_host_cpu_c_abi" in
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
gl_cv_host_cpu_c_abi_32bit=yes ;;
- x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
+ x86_64 | alpha | sw_64 | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
gl_cv_host_cpu_c_abi_32bit=no ;;
*)
gl_cv_host_cpu_c_abi_32bit=unknown ;;
@@ -7581,7 +7581,7 @@ else
;;
# CPUs that only support a 64-bit ABI.
- alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
+ sw_64* | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
| mmix )
gl_cv_host_cpu_c_abi_32bit=no
;;
diff --git a/configure.ac b/configure.ac
index 824a93d..6f39955 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,7 +113,7 @@ AC_MSG_CHECKING(for additional special compiler flags)
if test "$GCC" = yes
then
case "$host_cpu" in
- alpha) addcflags="-mieee" ;;
+ alpha | sw_64) addcflags="-mieee" ;;
esac
fi
if test "x$addcflags" != x
diff --git a/lib/blkid/llseek.c b/lib/blkid/llseek.c
index 5929864..25c613b 100644
--- a/lib/blkid/llseek.c
+++ b/lib/blkid/llseek.c
@@ -88,7 +88,7 @@ static blkid_loff_t my_llseek(int fd, blkid_loff_t offset, int origin)
return (retval == -1 ? (blkid_loff_t) retval : result);
}
-#endif /* __alpha__ || __ia64__ */
+#endif /* __alpha__ || __sw_64__ || __ia64__ */
#endif /* HAVE_LLSEEK */
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index d251c20..e7a2b4e 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -786,7 +786,7 @@ static errcode_t unix_open_channel(const char *name, int fd,
#ifdef __linux__
#undef RLIM_INFINITY
-#if (defined(__alpha__) || ((defined(__sparc__) || defined(__mips__)) && (SIZEOF_LONG == 4)))
+#if (defined(__alpha__) || defined(__sw_64__) || ((defined(__sparc__) || defined(__mips__)) && (SIZEOF_LONG == 4)))
#define RLIM_INFINITY ((unsigned long)(~0UL>>1))
#else
#define RLIM_INFINITY (~0UL)
--
2.33.0
@@ -1,38 +0,0 @@
From 003125b2f00aed8f0a1d8b5bd80fcbb1e8e2f13e Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Thu, 4 Aug 2022 18:33:39 +0800
Subject: [PATCH] tune2fs: do not change j_tail_sequence in journal superblock
The function recover_ext3_journal() in debugfs/journal.c, if the log
replay is over, the j_tail_sequence in journal superblock is not
changed to the value of the last transaction sequence. This will
cause subsequent log commitids to count from the commitid in last
time. After tune2fs -e, the log commitid is counted from the commitid
in last time, if the log ID of the current operation overlaps with
that of the last operation, this will cause logs that were previously
replayed by tune2fs to be replayed here.
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: liangyun <liangyun2@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
debugfs/journal.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/debugfs/journal.c b/debugfs/journal.c
index 095fff00..5bac0d3b 100644
--- a/debugfs/journal.c
+++ b/debugfs/journal.c
@@ -769,6 +769,8 @@ static errcode_t recover_ext3_journal(ext2_filsys fs)
mark_buffer_dirty(journal->j_sb_buffer);
}
+ journal->j_tail_sequence = journal->j_transaction_sequence;
+
errout:
jbd2_journal_destroy_revoke(journal);
jbd2_journal_destroy_revoke_record_cache();
--
2.37.1
@@ -1,165 +0,0 @@
From 6e4cc3d5eeb2dfaa055e652b5390beaa6c3d05da Mon Sep 17 00:00:00 2001
From: "lihaoxiang (F)" <lihaoxiang9@huawei.com>
Date: Thu, 14 Jul 2022 09:32:48 +0800
Subject: [PATCH] debugfs: teach logdump the -n <num_trans> option
The current version's debugfs possessed the function
logdump. Executing with option -O could output the log history. But
when it occurred the block which had no magic number in it's header,
the program would exit.
Sometimes we were locating problems, needed for more transactions that
had replayed instead of the latest batch of transactions and we
weren't hope to display all the history in the meanwhile. So we
introduced the option -n used for controlling the print of history
transactions. Specially, this parameter was depending on the option
-O otherwise it couldn't work.
So in this modification, we used logdump with -O -n <num_trans>. The
-n options causes logdump to continue past a block with a missing
magic nuber. Instead, it will terminate only when the entire log has
been printed or after <num_trans> transactions.
Link: https://lore.kernel.org/r/608df030-593f-8c69-cb65-632a34729d23@huawei.com
Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
debugfs/debugfs.8.in | 13 +++++++++++--
debugfs/logdump.c | 32 ++++++++++++++++++++++++++++----
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index aa6128a..a3227a8 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.8.in
@@ -505,7 +505,7 @@ which is a hard link to
.IR filespec .
Note this does not adjust the inode reference counts.
.TP
-.BI logdump " [-acsOS] [-b block] [-i filespec] [-f journal_file] [output_file]"
+.BI logdump " [-acsOS] [-b block] [-n num_trans ] [-i filespec] [-f journal_file] [output_file]"
Dump the contents of the ext3 journal. By default, dump the journal inode as
specified in the superblock. However, this can be overridden with the
.I \-i
@@ -528,7 +528,7 @@ The
.I \-a
option causes the
.B logdump
-program to print the contents of all of the descriptor blocks.
+to print the contents of all of the descriptor blocks.
The
.I \-b
option causes
@@ -548,6 +548,15 @@ The
option causes logdump to display old (checkpointed) journal entries.
This can be used to try to track down journal problems even after the
journal has been replayed.
+.IP
+The
+.I \-n
+option causes
+.B logdump
+to continue past a journal block which is missing a magic number.
+Instead, it will stop only when the entire log is printed or after
+.I num_trans
+transactions.
.TP
.BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
Print a listing of the files in the directory
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index 6b0133e..614414e 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -48,6 +48,7 @@ enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
#define ANY_BLOCK ((blk64_t) -1)
static int dump_all, dump_super, dump_old, dump_contents, dump_descriptors;
+static int64_t dump_counts;
static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
static unsigned int group_to_dump, inode_offset_to_dump;
static ext2_ino_t inode_to_dump;
@@ -113,9 +114,10 @@ void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
bitmap_to_dump = -1;
inode_block_to_dump = ANY_BLOCK;
inode_to_dump = -1;
+ dump_counts = -1;
reset_getopt();
- while ((c = getopt (argc, argv, "ab:ci:f:OsS")) != EOF) {
+ while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) {
switch (c) {
case 'a':
dump_all++;
@@ -148,6 +150,14 @@ void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
case 'S':
dump_super++;
break;
+ case 'n':
+ dump_counts = strtol(optarg, &tmp, 10);
+ if (*tmp) {
+ com_err(argv[0], 0,
+ "Bad log counts number - %s", optarg);
+ return;
+ }
+ break;
default:
goto print_usage;
}
@@ -289,7 +299,7 @@ cleanup:
return;
print_usage:
- fprintf(stderr, "%s: Usage: logdump [-acsOS] [-b<block>] [-i<filespec>]\n\t"
+ fprintf(stderr, "%s: Usage: logdump [-acsOS] [-n<num_trans>] [-b<block>] [-i<filespec>]\n\t"
"[-f<journal_file>] [output_file]\n", argv[0]);
}
@@ -369,6 +379,8 @@ static void dump_journal(char *cmdname, FILE *out_file,
int fc_done;
__u64 total_len;
__u32 maxlen;
+ int64_t cur_counts = 0;
+ bool exist_no_magic = false;
/* First, check to see if there's an ext2 superblock header */
retval = read_journal_block(cmdname, source, 0, buf, 2048);
@@ -459,6 +471,9 @@ static void dump_journal(char *cmdname, FILE *out_file,
}
while (1) {
+ if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
+ break;
+
retval = read_journal_block(cmdname, source,
((ext2_loff_t) blocknr) * blocksize,
buf, blocksize);
@@ -472,8 +487,16 @@ static void dump_journal(char *cmdname, FILE *out_file,
blocktype = be32_to_cpu(header->h_blocktype);
if (magic != JBD2_MAGIC_NUMBER) {
- fprintf (out_file, "No magic number at block %u: "
- "end of journal.\n", blocknr);
+ if (exist_no_magic == false) {
+ exist_no_magic = true;
+ fprintf(out_file, "No magic number at block %u: "
+ "end of journal.\n", blocknr);
+ }
+ if (dump_old && (dump_counts != -1)) {
+ blocknr++;
+ WRAP(jsb, blocknr, maxlen);
+ continue;
+ }
break;
}
@@ -500,6 +523,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
continue;
case JBD2_COMMIT_BLOCK:
+ cur_counts++;
transaction++;
blocknr++;
WRAP(jsb, blocknr, maxlen);
--
1.8.3.1
@@ -1,57 +0,0 @@
From 66ecb6abe5d2c74191bb4bc24f3da036e5fa1213 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Mon, 5 Sep 2022 19:16:03 +0800
Subject: [PATCH] tune2fs: fix tune2fs segfault when ext2fs_run_ext3_journal()
fails
When ext2fs_run_ext3_journal() fails, tune2fs cmd will occur one
segfault problem as follows.
(gdb) bt
#0 0x00007fdadad69917 in ext2fs_mmp_stop (fs=0x0) at mmp.c:405
#1 0x0000558fa5a9365a in main (argc=<optimized out>, argv=<optimized out>) at tune2fs.c:3440
misc/tune2fs.c:
main()
-> ext2fs_open2(&fs)
-> ext2fs_mmp_start
......
-> retval = ext2fs_run_ext3_journal(&fs)
-> if (retval)
// if ext2fs_run_ext3_journal fails, close and free fs.
-> ext2fs_close_free(&fs)
-> rc = 1
-> goto closefs
......
closefs:
-> if (rc)
-> ext2fs_mmp_stop(fs) // fs has been set to NULL, boom!!
-> (ext2fs_close_free(&fs) ? 1 : 0); // close and free fs
In main() of tune2fs cmd, if ext2fs_run_ext3_journal() fails,
we should set rc=1 and goto closefs tag, in which will release fs
resource.
Fix: a2292f8a5108 ("tune2fs: reset MMP state on error exit")
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index a7ff16de..98e38983 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3106,8 +3106,6 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
com_err("tune2fs", retval,
"while recovering journal.\n");
printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
- if (fs)
- ext2fs_close_free(&fs);
rc = 1;
goto closefs;
}
--
2.33.0
@@ -1,39 +0,0 @@
From 77ac16dfba42e0d152b1e99359e01a933f8cc6f9 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Mon, 5 Sep 2022 23:40:01 +0800
Subject: [PATCH] tune2fs: tune2fs_main() should return rc when some error,
occurs
If some error occurs, tune2fs_main() will go to closefs tag for
releasing resource, and it should return correct value (rc) instead
of 0 when ext2fs_close_free(&fs) successes.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 98e38983..bed3d95b 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3243,6 +3243,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
fputs(_("Error in using clear_mmp. "
"It must be used with -f\n"),
stderr);
+ rc = 1;
goto closefs;
}
}
@@ -3447,5 +3448,5 @@ closefs:
if (feature_64bit)
convert_64bit(fs, feature_64bit);
- return (ext2fs_close_free(&fs) ? 1 : 0);
+ return (ext2fs_close_free(&fs) ? 1 : rc);
}
--
2.33.0
@@ -1,34 +0,0 @@
From 47ab1faccb228e10869898c8a02b06f5a91a9174 Mon Sep 17 00:00:00 2001
From: Li Jinlin <lijinlin3@huawei.com>
Date: Fri, 16 Sep 2022 15:42:23 +0800
Subject: tune2fs: exit directly when fs freed in ext2fs_run_ext3_journal
In ext2fs_run_ext3_journal(), fs will be freed and reallocated.
However, the reallocation by ext2fs_open() may fail in some cases ---
for example, when the device becomes offline. To avoid a segfault,
exit if fs is NULL.
[ Simplified the patch by by simply exiting if fs is NULL -TYT ]
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index bed3d95b..f566ed81 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3106,6 +3106,8 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
com_err("tune2fs", retval,
"while recovering journal.\n");
printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
+ if (!fs)
+ exit(1);
rc = 1;
goto closefs;
}
--
cgit
@@ -1,217 +0,0 @@
From 8625b843ab9e1327dcb83b025951f97c971175e0 Mon Sep 17 00:00:00 2001
From: Wenchao Hao <haowenchao@huawei.com>
Date: Fri, 11 Nov 2022 12:22:08 +0800
Subject: [PATCH] unix_io.c: fix deadlock problem in unix_write_blk64
We will release CACHE_MTX lock, when enter e2fsck_handle_write_error.
stack:
(gdb) bt
0 0x0000ffffa740bc34 in ?? () from /usr/lib64/libc.so.6
1 0x0000ffffa7412024 in pthread_mutex_lock () from /usr/lib64/libc.so.6
2 0x0000ffffa7654e54 in mutex_lock (kind=CACHE_MTX, data=0xaaaaf5c98f30) at unix_io.c:151
3 unix_write_blk64 (channel=0xaaaaf5c98e60, block=2, count=4, buf=0xaaaaf5c9d170) at unix_io.c:1092
4 0x0000ffffa762e610 in ext2fs_flush2 (flags=0, fs=0xaaaaf5c98cc0) at closefs.c:401
5 ext2fs_flush2 (fs=0xaaaaf5c98cc0, flags=0) at closefs.c:279
6 0x0000ffffa762eb14 in ext2fs_close2 (fs=fs@entry=0xaaaaf5c98cc0, flags=flags@entry=0) at closefs.c:510
7 0x0000ffffa762eba4 in ext2fs_close_free (fs_ptr=fs_ptr@entry=0xffffc8cbab30) at closefs.c:472
8 0x0000aaaadcc39bd8 in preenhalt (ctx=ctx@entry=0xaaaaf5c98460) at util.c:365
9 0x0000aaaadcc3bc5c in e2fsck_handle_write_error (channel=<optimized out>, block=262152, count=<optimized out>, data=<optimized out>, size=<optimized out>, actual=<optimized out>, error=5)
at ehandler.c:114
10 0x0000ffffa7655044 in reuse_cache (block=262206, cache=0xaaaaf5c98f80, data=0xaaaaf5c98f30, channel=0xaaaaf5c98e60) at unix_io.c:583
11 unix_write_blk64 (channel=0xaaaaf5c98e60, block=262206, count=<optimized out>, buf=<optimized out>) at unix_io.c:1097
12 0x0000aaaadcc3702c in ll_rw_block (rw=rw@entry=1, op_flags=op_flags@entry=0, nr=<optimized out>, nr@entry=1, bhp=0xffffc8cbac60, bhp@entry=0xffffc8cbac58) at journal.c:184
13 0x0000aaaadcc375e8 in brelse (bh=<optimized out>, bh@entry=0xaaaaf5cac4a0) at journal.c:217
14 0x0000aaaadcc3ebe0 in do_one_pass (journal=journal@entry=0xaaaaf5c9f590, info=info@entry=0xffffc8cbad60, pass=pass@entry=PASS_REPLAY) at recovery.c:693
15 0x0000aaaadcc3ee74 in jbd2_journal_recover (journal=0xaaaaf5c9f590) at recovery.c:310
16 0x0000aaaadcc386a8 in recover_ext3_journal (ctx=0xaaaaf5c98460) at journal.c:1653
17 e2fsck_run_ext3_journal (ctx=0xaaaaf5c98460) at journal.c:1706
18 0x0000aaaadcc207e0 in main (argc=<optimized out>, argv=<optimized out>) at unix.c:1791
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
lib/ext2fs/unix_io.c | 63 +++++++++++++++++++++++++++++++++++++---------------
1 file changed, 45 insertions(+), 18 deletions(-)
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index c326f57..a7ab772 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -210,7 +210,8 @@ static char *safe_getenv(const char *arg)
static errcode_t raw_read_blk(io_channel channel,
struct unix_private_data *data,
unsigned long long block,
- int count, void *bufv)
+ int count, void *bufv,
+ int cache_lock)
{
errcode_t retval;
ssize_t size;
@@ -331,16 +332,22 @@ error_unlock:
mutex_unlock(data, BOUNCE_MTX);
if (actual >= 0 && actual < size)
memset((char *) buf+actual, 0, size-actual);
- if (channel->read_error)
+ if (channel->read_error) {
+ if (cache_lock)
+ mutex_unlock(data, CACHE_MTX);
retval = (channel->read_error)(channel, block, count, buf,
size, actual, retval);
+ if (cache_lock)
+ mutex_lock(data, CACHE_MTX);
+ }
return retval;
}
static errcode_t raw_write_blk(io_channel channel,
struct unix_private_data *data,
unsigned long long block,
- int count, const void *bufv)
+ int count, const void *bufv,
+ int cache_lock)
{
ssize_t size;
ext2_loff_t location;
@@ -482,9 +489,14 @@ bounce_write:
error_unlock:
mutex_unlock(data, BOUNCE_MTX);
error_out:
- if (channel->write_error)
+ if (channel->write_error) {
+ if (cache_lock)
+ mutex_unlock(data, CACHE_MTX);
retval = (channel->write_error)(channel, block, count, buf,
size, actual, retval);
+ if (cache_lock)
+ mutex_lock(data, CACHE_MTX);
+ }
return retval;
}
@@ -576,16 +588,22 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data,
/*
* Reuse a particular cache entry for another block.
*/
-static void reuse_cache(io_channel channel, struct unix_private_data *data,
+static errcode_t reuse_cache(io_channel channel, struct unix_private_data *data,
struct unix_cache *cache, unsigned long long block)
{
- if (cache->dirty && cache->in_use)
- raw_write_blk(channel, data, cache->block, 1, cache->buf);
+ errcode_t retval = 0;
+ if (cache->dirty && cache->in_use) {
+ retval = raw_write_blk(channel, data, cache->block, 1, cache->buf, 1);
+ if (retval)
+ return retval;
+ }
cache->in_use = 1;
cache->dirty = 0;
cache->block = block;
cache->access_time = ++data->access_time;
+
+ return retval;
}
#define FLUSH_INVALIDATE 0x01
@@ -616,7 +634,8 @@ static errcode_t flush_cached_blocks(io_channel channel,
continue;
retval = raw_write_blk(channel, data,
- cache->block, 1, cache->buf);
+ cache->block, 1, cache->buf,
+ !(flags & FLUSH_NOLOCK));
if (retval)
retval2 = retval;
else
@@ -984,10 +1003,10 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
#ifdef NO_IO_CACHE
- return raw_read_blk(channel, data, block, count, buf);
+ return raw_read_blk(channel, data, block, count, buf, 0);
#else
if (data->flags & IO_FLAG_NOCACHE)
- return raw_read_blk(channel, data, block, count, buf);
+ return raw_read_blk(channel, data, block, count, buf, 0);
/*
* If we're doing an odd-sized read or a very large read,
* flush out the cache and then do a direct read.
@@ -995,7 +1014,7 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
if (count < 0 || count > WRITE_DIRECT_SIZE) {
if ((retval = flush_cached_blocks(channel, data, 0)))
return retval;
- return raw_read_blk(channel, data, block, count, buf);
+ return raw_read_blk(channel, data, block, count, buf, 0);
}
cp = buf;
@@ -1024,14 +1043,18 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
printf("Reading %d blocks starting at %lu\n", i, block);
#endif
mutex_unlock(data, CACHE_MTX);
- if ((retval = raw_read_blk(channel, data, block, i, cp)))
+ if ((retval = raw_read_blk(channel, data, block, i, cp, 0)))
return retval;
mutex_lock(data, CACHE_MTX);
/* Save the results in the cache */
for (j=0; j < i; j++) {
if (!find_cached_block(data, block, &cache)) {
- reuse_cache(channel, data, cache, block);
+ retval = reuse_cache(channel, data, cache, block);
+ if (retval) {
+ mutex_unlock(data, CACHE_MTX);
+ return retval;
+ }
memcpy(cache->buf, cp, channel->block_size);
}
count--;
@@ -1064,10 +1087,10 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
#ifdef NO_IO_CACHE
- return raw_write_blk(channel, data, block, count, buf);
+ return raw_write_blk(channel, data, block, count, buf, 0);
#else
if (data->flags & IO_FLAG_NOCACHE)
- return raw_write_blk(channel, data, block, count, buf);
+ return raw_write_blk(channel, data, block, count, buf, 0);
/*
* If we're doing an odd-sized write or a very large write,
* flush out the cache completely and then do a direct write.
@@ -1076,7 +1099,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
if ((retval = flush_cached_blocks(channel, data,
FLUSH_INVALIDATE)))
return retval;
- return raw_write_blk(channel, data, block, count, buf);
+ return raw_write_blk(channel, data, block, count, buf, 0);
}
/*
@@ -1086,7 +1109,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
*/
writethrough = channel->flags & CHANNEL_FLAGS_WRITETHROUGH;
if (writethrough)
- retval = raw_write_blk(channel, data, block, count, buf);
+ retval = raw_write_blk(channel, data, block, count, buf, 0);
cp = buf;
mutex_lock(data, CACHE_MTX);
@@ -1094,7 +1117,11 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
cache = find_cached_block(data, block, &reuse);
if (!cache) {
cache = reuse;
- reuse_cache(channel, data, cache, block);
+ retval = reuse_cache(channel, data, cache, block);
+ if (retval) {
+ mutex_unlock(data, CACHE_MTX);
+ return retval;
+ }
}
if (cache->buf != cp)
memcpy(cache->buf, cp, channel->block_size);
--
1.8.3.1
@@ -1,76 +0,0 @@
From d37a9f1818fa04fc91a497b3541ed205804720af Mon Sep 17 00:00:00 2001
From: "lihaoxiang (F)" <lihaoxiang9@huawei.com>
Date: Tue, 15 Nov 2022 16:29:55 +0800
Subject: [PATCH] debugfs: fix repeated output problem with `logdump -O -n
<num_trans>`
Previously, patch 6e4cc3d5eeb2dfaa055e652b5390beaa6c3d05da introduces
the function of printing the specified number of logs. But there exists
a shortage when n is larger than the total number of logs, it dumped the
duplicated records circulately.
For example, the disk sda only has three records, but using instruction logdump
-On5, it would output the result as follow:
----------------------------------------------------------------------
Journal starts at block 1, transaction 6
Found expected sequence 6, type 1 (descriptor block) at block 1
Found expected sequence 6, type 2 (commit block) at block 4
No magic number at block 5: end of journal.
Found sequence 2 (not 7) at block 7: end of journal.
Found expected sequence 2, type 2 (commit block) at block 7
Found sequence 3 (not 8) at block 8: end of journal.
Found expected sequence 3, type 1 (descriptor block) at block 8
Found sequence 3 (not 8) at block 15: end of journal.
Found expected sequence 3, type 2 (commit block) at block 15
Found sequence 6 (not 9) at block 1: end of journal. <---------begin loop
Found expected sequence 6, type 1 (descriptor block) at block 1
Found sequence 6 (not 9) at block 4: end of journal.
Found expected sequence 6, type 2 (commit block) at block 4
Found sequence 2 (not 10) at block 7: end of journal.
Found expected sequence 2, type 2 (commit block) at block 7
logdump: short read (read 0, expected 1024) while reading journal
In this commit, we solve the problem above by exiting dumping if the
blocknr had already encountered, displayed the total number of logs
that the disk only possessed.
Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
debugfs/logdump.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index 614414e..036b50b 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -376,6 +376,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
journal_header_t *header;
tid_t transaction;
unsigned int blocknr = 0;
+ unsigned int first_transaction_blocknr;
int fc_done;
__u64 total_len;
__u32 maxlen;
@@ -470,10 +471,18 @@ static void dump_journal(char *cmdname, FILE *out_file,
blocknr = 1;
}
+ first_transaction_blocknr = blocknr;
+
while (1) {
if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
break;
+ if ((blocknr == first_transaction_blocknr) &&
+ (cur_counts != 0) && dump_old && (dump_counts != -1)) {
+ fprintf(out_file, "Dump all %lld journal records.\n", cur_counts);
+ break;
+ }
+
retval = read_journal_block(cmdname, source,
((ext2_loff_t) blocknr) * blocksize,
buf, blocksize);
--
1.8.3.1
@@ -1,73 +0,0 @@
From f7c9598655420102353ff87946f5bf77ebf465bc Mon Sep 17 00:00:00 2001
From: "lihaoxiang (F)" <lihaoxiang9@huawei.com>
Date: Tue, 29 Nov 2022 14:58:12 +0800
Subject: [PATCH] tune2fs: check return value of ext2fs_mmp_update2 in
rewrite_metadata_checksums
Tune2fs hasn't consider about the result of executing ext2fs_mmp_update2
when it try to rewrite_metadata_checksums. If the ext2fs_mmp_update2
failed, multi-mount protection couldn't guard there has the only node
(i.e. this program) accessing this device in the meantime.
We solve this problem to verify the return value of ext2fs_mmp_update2.
It terminate rewrite_metadata_checksums and exit immediately if the
wrong error code returned.
Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index b1e49b3..cb5f575 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -930,7 +930,7 @@ static void rewrite_inodes(ext2_filsys fs, unsigned int flags)
ext2fs_free_mem(&ctx.ea_buf);
}
-static void rewrite_metadata_checksums(ext2_filsys fs, unsigned int flags)
+static errcode_t rewrite_metadata_checksums(ext2_filsys fs, unsigned int flags)
{
errcode_t retval;
dgrp_t i;
@@ -945,7 +945,9 @@ static void rewrite_metadata_checksums(ext2_filsys fs, unsigned int flags)
rewrite_inodes(fs, flags);
ext2fs_mark_ib_dirty(fs);
ext2fs_mark_bb_dirty(fs);
- ext2fs_mmp_update2(fs, 1);
+ retval = ext2fs_mmp_update2(fs, 1);
+ if (retval)
+ return retval;
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
if (ext2fs_has_feature_metadata_csum(fs->super))
@@ -953,6 +955,7 @@ static void rewrite_metadata_checksums(ext2_filsys fs, unsigned int flags)
else
fs->super->s_checksum_type = 0;
ext2fs_mark_super_dirty(fs);
+ return 0;
}
static void enable_uninit_bg(ext2_filsys fs)
@@ -3412,8 +3415,14 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
}
}
- if (rewrite_checksums)
- rewrite_metadata_checksums(fs, rewrite_checksums);
+ if (rewrite_checksums) {
+ retval = rewrite_metadata_checksums(fs, rewrite_checksums);
+ if (retval != 0) {
+ printf("Failed to rewrite metadata checksums\n");
+ rc = 1;
+ goto closefs;
+ }
+ }
if (l_flag)
list_super(sb);
--
1.8.3.1
@@ -1,43 +0,0 @@
From ffa6de1e3da4216a2ed6ec2890e16b22dc2ca40f Mon Sep 17 00:00:00 2001
From: "lihaoxiang (F)" <lihaoxiang9@huawei.com>
Date: Tue, 29 Nov 2022 15:02:39 +0800
Subject: [PATCH] mmp: fix wrong comparison in ext2fs_mmp_stop
In our knowledge, ext2fs_mmp_stop use to process the rest of work
when mmp will finish. Critically, it must check if the mmp block is
not changed. But there exist an error in comparing the mmp and mmp_cmp.
Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the
superblock of disk and it copy to mmp_buf if mmp_buf is not none
and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop
pass the no NULL pointer fs->mmp_buf which has possed the mmp info to
ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf
by fs->mmp_cmp so that loss the meaning of comparing themselves
after that and worse yet, couldn't judge whether the struct of mmp
has changed.
In fact, we only need to modify the parameter to NULL pointer for
solving this problem.
Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/mmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 7970aac..1428970 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
(fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
goto mmp_error;
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
+ retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
if (retval)
goto mmp_error;
--
1.8.3.1
@@ -1,39 +0,0 @@
From d08ef863feae14e4710bf2026404e6c6e06db2be Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Mon, 10 Oct 2022 16:56:58 +0800
Subject: [PATCH] misc/fsck.c: Processes may kill other processes.
I find a error in misc/fsck.c, if run the fsck -N command, processes
don't execute, just show what would be done. However, the pid whose
value is -1 is added to the instance_list list in the execute
function,if the kill_all function is called later, kill(-1, signum)
is executed, Signals are sent to all processes except the number one
process and itself. Other processes will be killed if they use the
default signal processing function.
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/fsck.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/misc/fsck.c b/misc/fsck.c
index 1f6ec7d9..1769a106 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -547,6 +547,8 @@ static int kill_all(int signum)
for (inst = instance_list; inst; inst = inst->next) {
if (inst->flags & FLAG_DONE)
continue;
+ if (inst->pid <= 0)
+ continue;
kill(inst->pid, signum);
n++;
}
--
2.38.1
@@ -1,46 +0,0 @@
From ba18f6efec62a1706b4bcf8fffd27611022260b8 Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Fri, 31 Dec 2021 15:42:40 +0800
Subject: dumpe2fs, resize2fs: avoid memory leak on error path
Link: https://lore.kernel.org/r/cbfd9852-bc89-1e83-f101-36fd29a0e70e@huawei.com
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/dumpe2fs.c | 1 +
resize/resize2fs.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 3f4fc4ed..ef6d1cb8 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -338,6 +338,7 @@ static void list_bad_blocks(ext2_filsys fs, int dump)
if (retval) {
com_err("ext2fs_badblocks_list_iterate_begin", retval,
"%s", _("while printing bad block list"));
+ ext2fs_badblocks_list_free(bb_list);
return;
}
if (dump) {
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index d69cb01e..916b1f4b 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1781,11 +1781,11 @@ static errcode_t block_mover(ext2_resize_t rfs)
fs->inode_blocks_per_group,
&rfs->itable_buf);
if (retval)
- return retval;
+ goto errout;
}
retval = ext2fs_create_extent_table(&rfs->bmap, 0);
if (retval)
- return retval;
+ goto errout;
/*
* The first step is to figure out where all of the blocks
--
cgit
@@ -1,43 +0,0 @@
From 1c966c9dffef7e823a020a2f3982e9b9b1953e8b Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Fri, 31 Dec 2021 15:43:36 +0800
Subject: libext2fs: fix memory leak in error path while opening test_io
manager
Link: https://lore.kernel.org/r/d0632bbc-9713-38a9-c914-137b702f6ae1@huawei.com
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/test_io.c | 2 ++
lib/ext2fs/undo_io.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index 480e68fc..6843edbc 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -248,6 +248,8 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
return 0;
cleanup:
+ if (io && io->name)
+ ext2fs_free_mem(&io->name);
if (io)
ext2fs_free_mem(&io);
if (data)
diff --git a/lib/ext2fs/undo_io.c b/lib/ext2fs/undo_io.c
index eb56f53d..f4a6d526 100644
--- a/lib/ext2fs/undo_io.c
+++ b/lib/ext2fs/undo_io.c
@@ -790,6 +790,8 @@ cleanup:
io_channel_close(data->real);
if (data)
ext2fs_free_mem(&data);
+ if (io && io->name)
+ ext2fs_free_mem(&io->name);
if (io)
ext2fs_free_mem(&io);
return retval;
--
cgit
@@ -1,42 +0,0 @@
From fdec633fd661e79b7b81e848b5699775328d70ae Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Fri, 31 Dec 2021 15:43:10 +0800
Subject: e2fsck: avoid theoretical null dereference in end_problem_latch()
This should only happen if there is a programming bug, but better safe
than sorry.
Link: https://lore.kernel.org/r/9a9c6658-a8b3-794a-85df-c3bdf0470111@huawei.com
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/problem.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 46a74273..95f0ace8 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -2321,6 +2321,8 @@ int end_problem_latch(e2fsck_t ctx, int mask)
int answer = -1;
ldesc = find_latch(mask);
+ if (!ldesc)
+ return answer;
if (ldesc->end_message && (ldesc->flags & PRL_LATCHED)) {
clear_problem_context(&pctx);
answer = fix_problem(ctx, ldesc->end_message, &pctx);
@@ -2467,8 +2469,8 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
* Do special latch processing. This is where we ask the
* latch question, if it exists
*/
- if (ptr->flags & PR_LATCH_MASK) {
- ldesc = find_latch(ptr->flags & PR_LATCH_MASK);
+ if (ptr->flags & PR_LATCH_MASK &&
+ (ldesc = find_latch(ptr->flags & PR_LATCH_MASK)) != NULL) {
if (ldesc->question && !(ldesc->flags & PRL_LATCHED)) {
ans = fix_problem(ctx, ldesc->question, pctx);
if (ans == 1)
--
cgit
@@ -1,56 +0,0 @@
From 1052048fb8f4ddcc0160eb670ef746ef7ee505a4 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Mon, 6 Jun 2022 11:39:23 -0400
Subject: e2fsck: fix potential out-of-bounds read in inc_ea_inode_refs()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If there isn't enough space for a full extended attribute entry,
inc_ea_inode_refs() might end up reading beyond the allocated memory
buffer.
Reported-by: Nils Bars <nils.bars@rub.de>
Reported-by: Moritz Schlögel <moritz.schloegel@rub.de>
Reported-by: Nico Schiller <nico.schiller@rub.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/pass1.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index dde862a8..2a17bb8a 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -389,13 +389,13 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx,
struct ext2_ext_attr_entry *first, void *end)
{
- struct ext2_ext_attr_entry *entry;
+ struct ext2_ext_attr_entry *entry = first;
+ struct ext2_ext_attr_entry *np = EXT2_EXT_ATTR_NEXT(entry);
- for (entry = first;
- (void *)entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry);
- entry = EXT2_EXT_ATTR_NEXT(entry)) {
+ while ((void *) entry < end && (void *) np < end &&
+ !EXT2_EXT_IS_LAST_ENTRY(entry)) {
if (!entry->e_value_inum)
- continue;
+ goto next;
if (!ctx->ea_inode_refs) {
pctx->errcode = ea_refcount_create(0,
&ctx->ea_inode_refs);
@@ -408,6 +408,9 @@ static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx,
}
ea_refcount_increment(ctx->ea_inode_refs, entry->e_value_inum,
0);
+ next:
+ entry = np;
+ np = EXT2_EXT_ATTR_NEXT(entry);
}
}
--
cgit
@@ -1,71 +0,0 @@
From 8d66e7e9316002ca9f9d558069bd56ccba9cece8 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Mon, 6 Jun 2022 22:44:35 -0400
Subject: e2fsck: avoid out-of-bounds write for very deep extent trees
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The kernel doesn't support extent trees deeper than 5
(EXT4_MAX_EXTENT_DEPTH). For this reason we only maintain the extent
tree statistics for 5 levels. Avoid out-of-bounds writes and reads if
the extent tree is deeper than this.
We keep these statistics to determine whether we should rebuild the
extent tree. If the extent tree is too deep, we don't need the
statistics because we should always rebuild the it.
Reported-by: Nils Bars <nils.bars@rub.de>
Reported-by: Moritz Schlögel <moritz.schloegel@rub.de>
Reported-by: Nico Schiller <nico.schiller@rub.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/extents.c | 10 +++++++++-
e2fsck/pass1.c | 3 ++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/e2fsck/extents.c b/e2fsck/extents.c
index 01879f56..86fe00e7 100644
--- a/e2fsck/extents.c
+++ b/e2fsck/extents.c
@@ -526,7 +526,8 @@ errcode_t e2fsck_check_rebuild_extents(e2fsck_t ctx, ext2_ino_t ino,
*/
if (info.curr_entry == 1 &&
!(extent.e_flags & EXT2_EXTENT_FLAGS_SECOND_VISIT) &&
- !eti.force_rebuild) {
+ !eti.force_rebuild &&
+ info.curr_level < MAX_EXTENT_DEPTH_COUNT) {
struct extent_tree_level *etl;
etl = eti.ext_info + info.curr_level;
@@ -580,6 +581,13 @@ errcode_t e2fsck_should_rebuild_extents(e2fsck_t ctx,
extents_per_block = (ctx->fs->blocksize -
sizeof(struct ext3_extent_header)) /
sizeof(struct ext3_extent);
+
+ /* If the extent tree is too deep, then rebuild it. */
+ if (info->max_depth > MAX_EXTENT_DEPTH_COUNT) {
+ pctx->blk = info->max_depth;
+ op = PR_1E_CAN_COLLAPSE_EXTENT_TREE;
+ goto rebuild;
+ }
/*
* If we can consolidate a level or shorten the tree, schedule the
* extent tree to be rebuilt.
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 11d7ce93..43972e7c 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2842,7 +2842,8 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
if (pctx->errcode)
return;
if (!(ctx->options & E2F_OPT_FIXES_ONLY) &&
- !pb->eti.force_rebuild) {
+ !pb->eti.force_rebuild &&
+ info.curr_level < MAX_EXTENT_DEPTH_COUNT) {
struct extent_tree_level *etl;
etl = pb->eti.ext_info + info.curr_level;
--
cgit
@@ -1,55 +0,0 @@
From 7464397a0c5df0416a7ef3436747045b36fb7882 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Tue, 9 Aug 2022 10:52:57 -0400
Subject: e2fsck: fix potential fencepost error in
e2fsck_should_rebuild_extents()
The ext2_extent_info.max_depth is zero-based (e.g., it is zero when
the entire extent tree fits in the inode). Hence, if it is equal to
MAX_EXTENT_DEPTH_COUNT we should always rebuild the extent tree to
shorten it.
Also, for 1k block file systems, it's possible for the worst-case
extent tree in its most compact form to have a maximum depth of 6, not
5. So set MAX_EXTENT_DEPTH_COUNT to 8 just to be sure we have plenty
of headroom. (The kernel supports an extent depth up to 2**16, but
e2fsck only keeps statistics up to MAX_EXTENT_DEPTH_COUNT, and if it's
deeper than that, we know that it will be profitable to rebuild the
extent tree in any case.)
Addresses-Coverity-Bug: 1507761
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/e2fsck.h | 2 +-
e2fsck/extents.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 00b20919..75baf2cd 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -233,7 +233,7 @@ typedef struct ea_refcount *ext2_refcount_t;
*/
typedef struct e2fsck_struct *e2fsck_t;
-#define MAX_EXTENT_DEPTH_COUNT 5
+#define MAX_EXTENT_DEPTH_COUNT 8
/*
* This strucutre is used to manage the list of extents in a file. Placing
diff --git a/e2fsck/extents.c b/e2fsck/extents.c
index 86fe00e7..70798f34 100644
--- a/e2fsck/extents.c
+++ b/e2fsck/extents.c
@@ -583,7 +583,7 @@ errcode_t e2fsck_should_rebuild_extents(e2fsck_t ctx,
sizeof(struct ext3_extent);
/* If the extent tree is too deep, then rebuild it. */
- if (info->max_depth > MAX_EXTENT_DEPTH_COUNT) {
+ if (info->max_depth > MAX_EXTENT_DEPTH_COUNT-1) {
pctx->blk = info->max_depth;
op = PR_1E_CAN_COLLAPSE_EXTENT_TREE;
goto rebuild;
--
cgit
@@ -1,53 +0,0 @@
From 27504bcf89193d47d7632cde922a65e0c051be01 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Tue, 9 Aug 2022 11:16:47 -0400
Subject: libext2fs: fix potential integer overflow in bitmap accessors
bmap->cluster_bits has a maximum value of 19, but Coverity doesn't
know that. To make it happy, and just in case there is a bug where
somehow the cluster size does get set to an invalid value and the rest
of the library doesn't check it, use 1ULL instead of 1 to avoid the
integer overflow.
Addresses-Coverity-Bug: 1500759
Addresses-Coverity-Bug: 1500764
Addresses-Coverity-Bug: 1500771
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/gen_bitmap64.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index d9809084..c860c10e 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -684,7 +684,7 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
/* convert to clusters if necessary */
block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
+ end += (1ULL << bmap->cluster_bits) - 1;
end >>= bmap->cluster_bits;
num = end - block;
@@ -725,7 +725,7 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
/* convert to clusters if necessary */
block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
+ end += (1ULL << bmap->cluster_bits) - 1;
end >>= bmap->cluster_bits;
num = end - block;
@@ -766,7 +766,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
/* convert to clusters if necessary */
block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
+ end += (1ULL << bmap->cluster_bits) - 1;
end >>= bmap->cluster_bits;
num = end - block;
--
cgit
-36
View File
@@ -1,36 +0,0 @@
From 6695555e50a374f897965300568253f242a0b13b Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Fri, 23 Sep 2022 15:25:48 +0200
Subject: tune2fs: fix an error message
$ tune2fs -O ^has_journal -ff /dev/sdh2
Recovering journal. tune2fs: Unknown code ____ 251 while recovering journal.
Before: Please run e2fsck -fy -O.
After: Please run e2fsck -fy /dev/sdh2.
Note this doesn't fix the "Unknown code" message, just the "Please run
e2fsck" one.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index f566ed81..f3ce443c 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3105,7 +3105,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
if (retval) {
com_err("tune2fs", retval,
"while recovering journal.\n");
- printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
+ printf(_("Please run e2fsck -fy %s.\n"), device_name);
if (!fs)
exit(1);
rc = 1;
--
cgit
@@ -1,113 +0,0 @@
From b0cd09e5b65373fc9f89048958c093bb1e6a1ecb Mon Sep 17 00:00:00 2001
From: Eric Biggers <ebiggers@google.com>
Date: Wed, 2 Nov 2022 15:05:51 -0700
Subject: e2fsck: don't allow journal inode to have encrypt flag
Since the kernel is being fixed to consider journal inodes with the
'encrypt' flag set to be invalid, also update e2fsck accordingly.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/journal.c | 3 ++-
tests/f_badjour_encrypted/expect.1 | 30 ++++++++++++++++++++++++++++++
tests/f_badjour_encrypted/expect.2 | 7 +++++++
tests/f_badjour_encrypted/name | 1 +
tests/f_badjour_encrypted/script | 11 +++++++++++
5 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 tests/f_badjour_encrypted/expect.1
create mode 100644 tests/f_badjour_encrypted/expect.2
create mode 100644 tests/f_badjour_encrypted/name
create mode 100644 tests/f_badjour_encrypted/script
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 1646b479..1bfabb02 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -1039,7 +1039,8 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
tried_backup_jnl++;
}
if (!j_inode->i_ext2.i_links_count ||
- !LINUX_S_ISREG(j_inode->i_ext2.i_mode)) {
+ !LINUX_S_ISREG(j_inode->i_ext2.i_mode) ||
+ (j_inode->i_ext2.i_flags & EXT4_ENCRYPT_FL)) {
retval = EXT2_ET_NO_JOURNAL;
goto try_backup_journal;
}
diff --git a/tests/f_badjour_encrypted/expect.1 b/tests/f_badjour_encrypted/expect.1
new file mode 100644
index 00000000..0b13b9eb
--- /dev/null
+++ b/tests/f_badjour_encrypted/expect.1
@@ -0,0 +1,30 @@
+Superblock has an invalid journal (inode 8).
+Clear? yes
+
+*** journal has been deleted ***
+
+Pass 1: Checking inodes, blocks, and sizes
+Journal inode is not in use, but contains data. Clear? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences: -(24--25) -(27--41) -(107--1113)
+Fix? yes
+
+Free blocks count wrong for group #0 (934, counted=1958).
+Fix? yes
+
+Free blocks count wrong (934, counted=1958).
+Fix? yes
+
+Recreate journal? yes
+
+Creating journal (1024 blocks): Done.
+
+*** journal has been regenerated ***
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/256 files (0.0% non-contiguous), 1114/2048 blocks
+Exit status is 1
diff --git a/tests/f_badjour_encrypted/expect.2 b/tests/f_badjour_encrypted/expect.2
new file mode 100644
index 00000000..76934be2
--- /dev/null
+++ b/tests/f_badjour_encrypted/expect.2
@@ -0,0 +1,7 @@
+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: 11/256 files (9.1% non-contiguous), 1114/2048 blocks
+Exit status is 0
diff --git a/tests/f_badjour_encrypted/name b/tests/f_badjour_encrypted/name
new file mode 100644
index 00000000..e8f4c04f
--- /dev/null
+++ b/tests/f_badjour_encrypted/name
@@ -0,0 +1 @@
+journal inode has encrypt flag
diff --git a/tests/f_badjour_encrypted/script b/tests/f_badjour_encrypted/script
new file mode 100644
index 00000000..e6778f1d
--- /dev/null
+++ b/tests/f_badjour_encrypted/script
@@ -0,0 +1,11 @@
+if ! test -x $DEBUGFS_EXE; then
+ echo "$test_name: $test_description: skipped (no debugfs)"
+ return 0
+fi
+
+touch $TMPFILE
+$MKE2FS -t ext4 -b 1024 $TMPFILE 2M
+$DEBUGFS -w -R 'set_inode_field <8> flags 0x80800' $TMPFILE
+
+SKIP_GUNZIP="true"
+. $cmd_dir/run_e2fsck
--
cgit
@@ -1,31 +0,0 @@
From c640cf1f3a9a7ac6ecbf82c27539c8e158f8ea24 Mon Sep 17 00:00:00 2001
From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Date: Mon, 7 Nov 2022 17:50:49 +0530
Subject: lib/ext2fs: fix unbalanced mutex unlock for BOUNCE_MTX in unix_io
f_crashdisk test failed with UNIX_IO_FORCE_BOUNCE=yes due to unbalanced
mutex unlock in below path.
This patch fixes it.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/unix_io.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index e53db333..5b894826 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -305,7 +305,6 @@ bounce_read:
while (size > 0) {
actual = read(data->dev, data->bounce, align_size);
if (actual != align_size) {
- mutex_unlock(data, BOUNCE_MTX);
actual = really_read;
buf -= really_read;
size += really_read;
--
cgit
@@ -1,41 +0,0 @@
From b795c06d8a44f42cdffdf5aa9561ff8de20d78cc Mon Sep 17 00:00:00 2001
From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Date: Mon, 7 Nov 2022 17:50:50 +0530
Subject: libext2fs: fix ext2fs_compare_generic_bmap logic
Currently this function was not correctly comparing against the right
length of the bitmap. Also when we compare bitarray v/s rbtree bitmap
the value returned by ext2fs_test_generic_bmap() could be different in
these two implementations. Hence only check against boolean value.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/gen_bitmap64.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index c860c10e..f7710afd 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -629,10 +629,14 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
(bm1->end != bm2->end))
return neq;
- for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
- if (ext2fs_test_generic_bmap(gen_bm1, i) !=
- ext2fs_test_generic_bmap(gen_bm2, i))
+ for (i = bm1->start; i < bm1->end; i++) {
+ int ret1, ret2;
+ ret1 = !!ext2fs_test_generic_bmap(gen_bm1, i);
+ ret2 = !!ext2fs_test_generic_bmap(gen_bm2, i);
+ if (ret1 != ret2) {
return neq;
+ }
+ }
return 0;
}
--
cgit
-72
View File
@@ -1,72 +0,0 @@
From 9d8b56b3b5d59691f16a8b8ae5fb763bc6be3d15 Mon Sep 17 00:00:00 2001
From: Andreas Dilger <adilger@dilger.ca>
Date: Thu, 4 Aug 2022 11:18:32 -0600
Subject: Quiet unused variable warnings
Quiet various compiler warnings about unreferenced or unset variables.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/journal.c | 15 +++++++--------
lib/ext2fs/swapfs.c | 2 +-
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 12487e3d..571de83e 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -620,7 +620,6 @@ static inline int tl_to_darg(struct dentry_info_args *darg,
struct ext4_fc_tl *tl, __u8 *val)
{
struct ext4_fc_dentry_info fcd;
- int tag = le16_to_cpu(tl->fc_tag);
memcpy(&fcd, val, sizeof(fcd));
@@ -636,10 +635,10 @@ static inline int tl_to_darg(struct dentry_info_args *darg,
darg->dname_len);
darg->dname[darg->dname_len] = 0;
jbd_debug(1, "%s: %s, ino %lu, parent %lu\n",
- tag == EXT4_FC_TAG_CREAT ? "create" :
- (tag == EXT4_FC_TAG_LINK ? "link" :
- (tag == EXT4_FC_TAG_UNLINK ? "unlink" : "error")),
- darg->dname, darg->ino, darg->parent_ino);
+ le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_CREAT ? "create" :
+ (le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_LINK ? "link" :
+ (le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_UNLINK ? "unlink" :
+ "error")), darg->dname, darg->ino, darg->parent_ino);
return 0;
}
@@ -652,11 +651,11 @@ static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl, __u8 *val)
if (ret)
return ret;
ext4_fc_flush_extents(ctx, darg.ino);
- ret = errcode_to_errno(
- ext2fs_unlink(ctx->fs, darg.parent_ino,
- darg.dname, darg.ino, 0));
+ ret = errcode_to_errno(ext2fs_unlink(ctx->fs, darg.parent_ino,
+ darg.dname, darg.ino, 0));
/* It's okay if the above call fails */
free(darg.dname);
+
return ret;
}
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 1006b2d2..cd160b31 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -244,7 +244,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
int bufsize)
{
unsigned i, extra_isize, attr_magic;
- int has_extents, has_inline_data, islnk, fast_symlink;
+ int has_extents = 0, has_inline_data = 0, islnk = 0, fast_symlink = 0;
unsigned int inode_size;
__u32 *eaf, *eat;
--
cgit
@@ -1,40 +0,0 @@
From 674d844c52cba11a5a80cb864161b97f1529fe5c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 14 Dec 2022 20:56:44 -0800
Subject: ext2fs: Use 64bit lseek when _FILE_OFFSET_BITS is 64
Use lseek() with 64bit off_t when _FILE_OFFSET_BITS is 64
this fixes build with musl where there is no _llseek but lseek
is using off_t which is 64bit on musl
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/ext2fs/llseek.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index 922a0d56..45f21d09 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -51,7 +51,7 @@ extern long long llseek (int fd, long long offset, int origin);
#else /* ! HAVE_LLSEEK */
-#if SIZEOF_LONG == SIZEOF_LONG_LONG
+#if SIZEOF_LONG == SIZEOF_LONG_LONG || _FILE_OFFSET_BITS+0 == 64
#define my_llseek lseek
@@ -69,7 +69,7 @@ static int _llseek (unsigned int, unsigned long,
static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
unsigned long, offset_low,ext2_loff_t *,result,
- unsigned int, origin)
+ unsigned int, origin);
#endif
static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
--
cgit
@@ -1,60 +0,0 @@
From 79a7b5e1f387caf907ec88460cdb39b8364bfb0b Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Thu, 16 Mar 2023 22:57:10 -0400
Subject: e2fsck: fix bad htree checksums in preen mode
We attempt to fix directories which have a bad/corrupted htree index
node by completely rebuilding the directory htree nodes. Since this
is a very safe thing to do and has no risk of losing directory
entries, we've enabled this for preen mode. Unfortunately, subsequent
index nodes look like empty directory entries that fill the entire
block --- without a checksum at the end of the directory. So these
nodes will be treated as a completely corrupted directory block, and
this will *not* be fixed while in preen mode.
So add code to treat an empty directory entry which covers the entire
block as valid if the directory is already on the list of inodes to be
rebuilt.
Addresses-Gooogle-Bug: 178607853
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/pass2.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 287360943..2700e3409 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1341,7 +1341,18 @@ skip_checksum:
(rec_len < min_dir_len) ||
((rec_len % 4) != 0) ||
((ext2fs_dir_rec_len(ext2fs_dirent_name_len(dirent),
- extended)) > rec_len)) {
+ extended)) > rec_len))
+ problem = PR_2_DIR_CORRUPTED;
+ if (problem) {
+ if ((offset == 0) &&
+ (rec_len == fs->blocksize) &&
+ (dirent->inode == 0) &&
+ e2fsck_dir_will_be_rehashed(ctx, ino)) {
+ problem = 0;
+ max_block_size = fs->blocksize;
+ }
+ }
+ if (problem) {
if (fix_problem(ctx, PR_2_DIR_CORRUPTED,
&cd->pctx)) {
#ifdef WORDS_BIGENDIAN
@@ -1573,7 +1584,8 @@ skip_checksum:
*/
if (!(ctx->flags & E2F_FLAG_RESTART_LATER) &&
!(ext2fs_test_inode_bitmap2(ctx->inode_used_map,
- dirent->inode)))
+ dirent->inode))
+ )
problem = PR_2_UNUSED_INODE;
if (problem) {
--
cgit
@@ -1,70 +0,0 @@
From a1530ed61778e99da315cb10cea2c46d215b096f Mon Sep 17 00:00:00 2001
From: Wenchao Hao <haowenchao2@huawei.com>
Date: Tue, 19 Dec 2023 17:23:57 +0800
Subject: [PATCH] debugfs: Fix infinite loop when dump log
There are 2 scenarios which would trigger infinite loop:
1. None log is recorded, then dumplog with "-n", for example:
debugfs -R "logdump -O -n 10" /dev/xxx
while /dev/xxx has no valid log recorded.
2. The log area is full and cycle write is triggered, then dumplog with
debugfs -R "logdump -aOS" /dev/xxx
This patch add a new flag "reverse_flag" to mark if logdump has reached
to tail of logarea, it is default false, and set in macro WRAP().
If reverse_flag is true, and we comes to first_transaction_blocknr
again, just break the logdump loop.
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
---
debugfs/logdump.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index 853be41..c4686ae 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -45,6 +45,7 @@ static int64_t dump_counts;
static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
static unsigned int group_to_dump, inode_offset_to_dump;
static ext2_ino_t inode_to_dump;
+static bool reverse_flag;
struct journal_source
{
@@ -73,8 +74,10 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize,
static void do_hexdump (FILE *, char *, int);
#define WRAP(jsb, blocknr, maxlen) \
- if (blocknr >= (maxlen)) \
- blocknr -= (maxlen - be32_to_cpu((jsb)->s_first));
+ if (blocknr >= (maxlen)) { \
+ blocknr -= (maxlen - be32_to_cpu((jsb)->s_first)); \
+ reverse_flag = true; \
+ }
void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
void *infop EXT2FS_ATTR((unused)))
@@ -108,6 +111,7 @@ void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
inode_block_to_dump = ANY_BLOCK;
inode_to_dump = -1;
dump_counts = -1;
+ reverse_flag = false;
reset_getopt();
while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) {
@@ -470,8 +474,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
break;
- if ((blocknr == first_transaction_blocknr) &&
- (cur_counts != 0) && dump_old && (dump_counts != -1)) {
+ if ((blocknr == first_transaction_blocknr) && dump_old && reverse_flag) {
fprintf(out_file, "Dump all %lld journal records.\n", cur_counts);
break;
}
--
2.32.0
@@ -299,7 +299,7 @@ new file mode 100644
index 0000000000000000000000000000000000000000..f9e9ad81a4669d62108a39a86c3a7c8fdb8fbcad
--- /dev/null
+++ b/lib/config.h
@@ -0,0 +1,909 @@
@@ -0,0 +1,906 @@
+/* lib/config.h. Generated from config.h.in by configure. */
+/* lib/config.h.in. Generated from configure.ac by autoheader. */
+
@@ -315,9 +315,6 @@ index 0000000000000000000000000000000000000000..f9e9ad81a4669d62108a39a86c3a7c8f
+/* Define to 1 if debugging ext3/4 journal code */
+/* #undef CONFIG_JBD_DEBUG */
+
+/* The internal ext2_filsys data structure appears to be corrupted */
+#define EXT2_FILSYS_CORRUPTED 1
+
+/* Define to 1 to enable mmp support */
+#define CONFIG_MMP 1
+
@@ -873,7 +870,7 @@ index 0000000000000000000000000000000000000000..f9e9ad81a4669d62108a39a86c3a7c8f
+#define HAVE_TERMIOS_H 1
+
+/* Define to 1 if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 1
+#undef HAVE_TERMIO_H
+
+/* Define to 1 if you have the `tsearch' function. */
+#define HAVE_TSEARCH 1
@@ -1221,10 +1218,10 @@ index 0000000000000000000000000000000000000000..14e2da62e4afd9aedd59f83e9a4c08fb
+ */
+
+/* Where to put the messages file for internationalization support */
+#define LOCALEDIR "/home/sunfan/OHOS_OTA2/hos/third_party/e2fsprogs-1.45.6/out/share/locale"
+#define LOCALEDIR "/home/sunfan/OHOS_OTA2/hos/third_party/e2fsprogs-1.47.2/out/share/locale"
+
+/* Where to find the mke2fs.conf and e2fsck.conf files */
+#define ROOT_SYSCONFDIR "/home/sunfan/OHOS_OTA2/hos/third_party/e2fsprogs-1.45.6/out/etc"
+#define ROOT_SYSCONFDIR "/home/sunfan/OHOS_OTA2/hos/third_party/e2fsprogs-1.47.2/out/etc"
diff --git a/lib/ext2fs/crc32c_table.h b/lib/ext2fs/crc32c_table.h
new file mode 100644
index 0000000000000000000000000000000000000000..07b56d4db7e045e9e0438678a496c61306b76441
@@ -2280,7 +2277,7 @@ new file mode 100644
index 0000000000000000000000000000000000000000..6b88d5f1e2ac3ccd6f7d6481204284439986f420
--- /dev/null
+++ b/lib/ext2fs/ext2_err.c
@@ -0,0 +1,234 @@
@@ -0,0 +1,237 @@
+/*
+ * ext2_err.c:
+ * This file is automatically generated; please do not edit it.
@@ -2291,7 +2288,7 @@ index 0000000000000000000000000000000000000000..6b88d5f1e2ac3ccd6f7d648120428443
+#define N_(a) a
+
+static const char * const text[] = {
+ N_( "EXT2FS Library version 1.45.6"),
+ N_( "EXT2FS Library version 1.47.2"),
+ N_( "Wrong magic number for ext2_filsys structure"),
+ N_( "Wrong magic number for badblocks_list structure"),
+ N_( "Wrong magic number for badblocks_iterate structure"),
@@ -2471,6 +2468,9 @@ index 0000000000000000000000000000000000000000..6b88d5f1e2ac3ccd6f7d648120428443
+ N_( "Inode is corrupted"),
+ N_( "Inode containing extended attribute value is corrupted"),
+ N_( "Group descriptors not loaded"),
+ N_( "The internal ext2_filsys data structure appears to be corrupted"),
+ N_( "Found cyclic loop in extent tree"),
+ N_( "Operation not supported on an external journal"),
+ 0
+};
+
@@ -2485,7 +2485,7 @@ index 0000000000000000000000000000000000000000..6b88d5f1e2ac3ccd6f7d648120428443
+};
+extern struct et_list *_et_list;
+
+const struct error_table et_ext2_error_table = { text, 2133571328L, 180 };
+const struct error_table et_ext2_error_table = { text, 2133571328L, 183 };
+
+static struct et_list link = { 0, 0 };
+
@@ -2520,7 +2520,7 @@ new file mode 100644
index 0000000000000000000000000000000000000000..8a107f9f67aa8a315d8e3435c65ecbf526183feb
--- /dev/null
+++ b/lib/ext2fs/ext2_err.h
@@ -0,0 +1,198 @@
@@ -0,0 +1,201 @@
+/*
+ * ext2_err.h:
+ * This file is automatically generated; please do not edit it.
@@ -2708,6 +2708,9 @@ index 0000000000000000000000000000000000000000..8a107f9f67aa8a315d8e3435c65ecbf5
+#define EXT2_ET_INODE_CORRUPTED (2133571505L)
+#define EXT2_ET_EA_INODE_CORRUPTED (2133571506L)
+#define EXT2_ET_NO_GDESC (2133571507L)
+#define EXT2_FILSYS_CORRUPTED (2133571508L)
+#define EXT2_ET_EXTENT_CYCLE (2133571509L)
+#define EXT2_ET_EXTERNAL_JOURNAL_NOSUPP (2133571510L)
+extern const struct error_table et_ext2_error_table;
+extern void initialize_ext2_error_table(void);
+
+4 -17
View File
@@ -17,30 +17,17 @@ index 1beb1e25bee8f1d4d33f1bf1b0e36064c567d544..622ad570f2eabc201e0e69cae4dc4ca8
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include "config.h"
#include <stdio.h>
#include <getopt.h>
diff --git a/contrib/android/perms.c b/contrib/android/perms.c
index 680d348e38e9374c2352dc66633132b95fe867fd..bfe06ca365682d4a508dd1634860a9abcf2c6c4b 100644
--- a/contrib/android/perms.c
+++ b/contrib/android/perms.c
@@ -3,6 +3,7 @@
#endif
@@ -4,6 +4,7 @@
#include "config.h"
#include "perms.h"
#include "support/nls-enable.h"
+#include <linux/capability.h>
#include <time.h>
#include <sys/stat.h>
diff --git a/misc/blkid.c b/misc/blkid.c
index 472f0179ee99ba28c51c2ce48561394482da753b..e46efc707daaf5867bea6cd415b9637e6c5bba61 100644
--- a/misc/blkid.c
+++ b/misc/blkid.c
@@ -17,6 +17,7 @@
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
+#undef HAVE_TERMIO_H
#ifdef HAVE_TERMIO_H
#include <termio.h>
#endif
+11 -2
View File
@@ -352,6 +352,7 @@ ohos_shared_library("libext2fs") {
"e2fsprogs/lib/ext2fs/gen_bitmap64.c",
"e2fsprogs/lib/ext2fs/get_num_dirs.c",
"e2fsprogs/lib/ext2fs/get_pathname.c",
"e2fsprogs/lib/ext2fs/getenv.c",
"e2fsprogs/lib/ext2fs/getsectsize.c",
"e2fsprogs/lib/ext2fs/getsize.c",
"e2fsprogs/lib/ext2fs/hashmap.c",
@@ -376,6 +377,7 @@ ohos_shared_library("libext2fs") {
"e2fsprogs/lib/ext2fs/newdir.c",
"e2fsprogs/lib/ext2fs/nls_utf8.c",
"e2fsprogs/lib/ext2fs/openfs.c",
"e2fsprogs/lib/ext2fs/orphan.c",
"e2fsprogs/lib/ext2fs/progress.c",
"e2fsprogs/lib/ext2fs/punch.c",
"e2fsprogs/lib/ext2fs/qcow2.c",
@@ -457,6 +459,7 @@ config("libext2_support-defaults") {
ohos_shared_library("libext2_quota") {
sources = [
"e2fsprogs/lib/support/devname.c",
"e2fsprogs/lib/support/dict.c",
"e2fsprogs/lib/support/mkquota.c",
"e2fsprogs/lib/support/parse_qtype.c",
@@ -564,12 +567,18 @@ config("libext2_misc-defaults") {
ohos_shared_library("libext2_misc") {
configs = [ ":libext2_misc-defaults" ]
sources = [ "e2fsprogs/misc/create_inode.c" ]
sources = [
"e2fsprogs/misc/create_inode.c",
"e2fsprogs/misc/create_inode_libarchive.c"
]
include_dirs = [
"//third_party/e2fsprogs/e2fsprogs/misc",
"//third_party/e2fsprogs/e2fsprogs/lib",
]
cflags = [ "-Wno-error=format-extra-args" ]
cflags = [
"-Wno-error=format-extra-args",
"-Wno-c2x-extensions"
]
deps = [
":libext2_com_err",
+1 -1
View File
@@ -1,4 +1,4 @@
This is the new version (1.46.4) of the second extended file
This is the new version (1.47.2) of the second extended file
system management programs.
From time to time, I release new versions of e2fsprogs, to fix
+4 -4
View File
@@ -1,11 +1,11 @@
[
{
"Name" : "openEuler:e2fsprogs",
"Name" : "e2fsprogs",
"License" : "LGPL V2.0, BSD 3-Clause License, GPL V2.0, MIT License",
"License File" : "e2fsprogs/NOTICE",
"Version Number" : "1.46.4-24.oe2203sp3",
"Owner" : "liuzhiqiang26@huawei.com",
"Upstream URL" : "https://repo.openeuler.org/openEuler-22.03-LTS-SP3/source/Packages/e2fsprogs-1.46.4-24.oe2203sp3.src.rpm",
"Version Number" : "1.47.2",
"Owner" : "zhangdaiyue1@huawei.com",
"Upstream URL" : "https://web.git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-1.47.2.tar.gz",
"Description" : "The E2fsprogs package contains the utilities for handling the ext2 file system. It also supports the ext3 and ext4 journaling file systems"
}
]
+4 -44
View File
@@ -1,54 +1,12 @@
Name: e2fsprogs
Version: 1.46.4
Release: 24
Version: 1.47.2
Release: 1
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
Source1: ext2_types-wrapper.h
Patch1: 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch
Patch2: 0002-libss-add-newer-libreadline.so.8-to-dlopen-path.patch
Patch3: 0003-tests-update-expect-files-for-f_mmp_garbage.patch
Patch4: 0004-tests-update-expect-files-for-f_large_dir-and-f_larg.patch
Patch5: 0005-resize2fs-resize2fs-disk-hardlinks-will-be-error.patch
Patch6: 0006-e2fsck-exit-journal-recovery-when-find-EIO-ENOMEM-er.patch
Patch7: 0007-e2fsck-exit-journal-recovery-when-jounral-superblock.patch
Patch8: 0008-e2fsck-add-env-param-E2FS_UNRELIABLE_IO-to-fi.patch
Patch9: 0009-e2mmpstatus.8.in-detele-filesystem-can-be-UUID-or-LA.patch
Patch10: 0010-tests-update-expect-file-for-u_direct_io.patch
Patch11: 0011-libext2fs-don-t-old-the-CACHE_MTX-while-doing-I-O.patch
Patch12: 0012-tests-fix-ACL-printing-tests.patch
Patch13: 0013-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch
Patch14: 0014-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch
Patch15: 0015-libext2fs-add-sanity-check-to-extent-manipulation.patch
Patch16: 0016-e2fsprogs-add-sw64.patch
Patch17: 0017-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
Patch18: 0018-debugfs-teach-logdump-the-n-num_trans-option.patch
Patch19: 0019-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch
Patch20: 0020-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch
Patch21: 0021-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch
Patch22: 0022-unix_io.c-fix-deadlock-problem-in-unix_write_blk64.patch
Patch23: 0023-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch
Patch24: 0024-tune2fs-check-return-value-of-ext2fs_mmp_update2-in-.patch
Patch25: 0025-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch
Patch26: 0026-misc-fsck.c-Processes-may-kill-other-processes.patch
Patch27: 0027-dumpe2fs-resize2fs-avoid-memory-leak-on-error-path.patch
Patch28: 0028-libext2fs-fix-memory-leak-in-error-path-while-openin.patch
Patch29: 0029-e2fsck-avoid-theoretical-null-dereference-in-end_pro.patch
Patch30: 0030-e2fsck-fix-potential-out-of-bounds-read-in-inc_ea_in.patch
Patch31: 0031-e2fsck-avoid-out-of-bounds-write-for-very-deep-exten.patch
Patch32: 0032-e2fsck-fix-potential-fencepost-error-in-e2fsck_shoul.patch
Patch33: 0033-libext2fs-fix-potential-integer-overflow-in-bitmap-a.patch
Patch34: 0034-tune2fs-fix-an-error-message.patch
Patch35: 0035-e2fsck-don-t-allow-journal-inode-to-have-encrypt-fla.patch
Patch36: 0036-lib-ext2fs-fix-unbalanced-mutex-unlock-for-BOUNCE_MT.patch
Patch37: 0037-libext2fs-fix-ext2fs_compare_generic_bmap-logic.patch
Patch38: 0038-Quiet-unused-variable-warnings.patch
Patch39: 0039-ext2fs-Use-64bit-lseek-when-_FILE_OFFSET_BITS-is-64.patch
Patch40: 0040-e2fsck-fix-bad-htree-checksums-in-preen-mode.patch
Patch41: 0041-debugfs-Fix-infinite-loop-when-dump-log.patch
BuildRequires: gcc pkgconfig texinfo
BuildRequires: fuse-devel libblkid-devel libuuid-devel
BuildRequires: audit
@@ -187,6 +145,8 @@ exit 0
%{_mandir}/man8/*
%changelog
* Sun May 11 2025 zhangdaiyue <zhangdaiyue1@huawei.com> - 1.47.2-1
- Switch openEuler:e2fsprogs to e2fsprogs, and update package to v1.47.2
* Tue Dec 19 2023 haowenchao <haowenchao2@huawei.com> - 1.46.4-24
- debugfs: Fix infinite loop when dump log
BIN
View File
Binary file not shown.
-41
View File
@@ -16,47 +16,6 @@ if [ -d "e2fsprogs" ];then
fi
tar xvf e2fsprogs.tar.xz
cd $1/e2fsprogs
patch -p1 < $1/0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0002-libss-add-newer-libreadline.so.8-to-dlopen-path.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0003-tests-update-expect-files-for-f_mmp_garbage.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0004-tests-update-expect-files-for-f_large_dir-and-f_larg.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0005-resize2fs-resize2fs-disk-hardlinks-will-be-error.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0006-e2fsck-exit-journal-recovery-when-find-EIO-ENOMEM-er.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0007-e2fsck-exit-journal-recovery-when-jounral-superblock.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0008-e2fsck-add-env-param-E2FS_UNRELIABLE_IO-to-fi.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0009-e2mmpstatus.8.in-detele-filesystem-can-be-UUID-or-LA.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0010-tests-update-expect-file-for-u_direct_io.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0011-libext2fs-don-t-old-the-CACHE_MTX-while-doing-I-O.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0012-tests-fix-ACL-printing-tests.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0013-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0014-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0015-libext2fs-add-sanity-check-to-extent-manipulation.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0016-e2fsprogs-add-sw64.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0017-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0018-debugfs-teach-logdump-the-n-num_trans-option.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0019-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0020-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0021-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0022-unix_io.c-fix-deadlock-problem-in-unix_write_blk64.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0023-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0024-tune2fs-check-return-value-of-ext2fs_mmp_update2-in-.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0025-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0026-misc-fsck.c-Processes-may-kill-other-processes.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0027-dumpe2fs-resize2fs-avoid-memory-leak-on-error-path.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0028-libext2fs-fix-memory-leak-in-error-path-while-openin.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0029-e2fsck-avoid-theoretical-null-dereference-in-end_pro.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0030-e2fsck-fix-potential-out-of-bounds-read-in-inc_ea_in.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0031-e2fsck-avoid-out-of-bounds-write-for-very-deep-exten.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0032-e2fsck-fix-potential-fencepost-error-in-e2fsck_shoul.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0033-libext2fs-fix-potential-integer-overflow-in-bitmap-a.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0034-tune2fs-fix-an-error-message.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0035-e2fsck-don-t-allow-journal-inode-to-have-encrypt-fla.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0036-lib-ext2fs-fix-unbalanced-mutex-unlock-for-BOUNCE_MT.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0037-libext2fs-fix-ext2fs_compare_generic_bmap-logic.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0038-Quiet-unused-variable-warnings.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0039-ext2fs-Use-64bit-lseek-when-_FILE_OFFSET_BITS-is-64.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0040-e2fsck-fix-bad-htree-checksums-in-preen-mode.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/0041-debugfs-Fix-infinite-loop-when-dump-log.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/1001-image-make.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/1002-add-header-file-to-musl-compile-mk2efs.patch --fuzz=0 --no-backup-if-mismatch
patch -p1 < $1/1003-add-dac-config.patch --fuzz=0 --no-backup-if-mismatch