!172 Upgrade to latest release [e2fsprogs: 1.46.5 2021/12/30 -> 1.47.0 2023/02/05]
From: @hifi521 Reviewed-by: @liuzhiqiang26 Signed-off-by: @liuzhiqiang26
This commit is contained in:
commit
397704e73f
@ -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,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,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
|
|
||||||
|
|
||||||
@ -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,35 +0,0 @@
|
|||||||
From 3d967e53033c85ad5d3af1a42efb2c4f7501c356 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lijinlin3@huawei.com
|
|
||||||
Date: Fri, 16 Sep 2022 18:15:02 +0200
|
|
||||||
Subject: [PATCH] tune2fs: exit directly when fs freed in ext2fs_run_ext3_journal
|
|
||||||
|
|
||||||
In ext2fs_run_ext3_journal(), fs will be free and reallocate. But
|
|
||||||
reallocating by ext2fs_open() may fail in some cases, such as device
|
|
||||||
being offline at the same time. In these cases, goto closefs will
|
|
||||||
cause segfault, fix it by exiting directly.
|
|
||||||
|
|
||||||
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
|
||||||
---
|
|
||||||
misc/tune2fs.c | 7 +++++--
|
|
||||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
|
|
||||||
index 088f87e5..ee57dc7c 100644
|
|
||||||
--- a/misc/tune2fs.c
|
|
||||||
+++ b/misc/tune2fs.c
|
|
||||||
@@ -3344,8 +3344,11 @@ _("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]);
|
|
||||||
- rc = 1;
|
|
||||||
- goto closefs;
|
|
||||||
+ if (fs) {
|
|
||||||
+ rc = 1;
|
|
||||||
+ goto closefs;
|
|
||||||
+ }
|
|
||||||
+ exit(1);
|
|
||||||
}
|
|
||||||
sb = fs->super;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.23.0
|
|
||||||
@ -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,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,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
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
Name: e2fsprogs
|
Name: e2fsprogs
|
||||||
Version: 1.46.5
|
Version: 1.47.0
|
||||||
Release: 6
|
Release: 1
|
||||||
Summary: Second extended file system management tools
|
Summary: Second extended file system management tools
|
||||||
License: GPLv2+ and LGPLv2 and MIT
|
License: GPLv2+ and LGPLv2 and MIT
|
||||||
URL: http://e2fsprogs.sourceforge.net/
|
URL: http://e2fsprogs.sourceforge.net/
|
||||||
@ -8,29 +8,15 @@ Source0: https://www.kernel.org/pub/linux/kernel/people/tytso/%{name}/v%{
|
|||||||
Source1: ext2_types-wrapper.h
|
Source1: ext2_types-wrapper.h
|
||||||
|
|
||||||
Patch1: 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch
|
Patch1: 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch
|
||||||
Patch2: 0002-resize2fs-resize2fs-disk-hardlinks-will-be-error.patch
|
Patch2: 0002-e2fsck-exit-journal-recovery-when-find-EIO-ENOMEM-er.patch
|
||||||
Patch3: 0003-e2fsck-exit-journal-recovery-when-find-EIO-ENOMEM-er.patch
|
Patch3: 0003-e2fsck-exit-journal-recovery-when-jounral-superblock.patch
|
||||||
Patch4: 0004-e2fsck-exit-journal-recovery-when-jounral-superblock.patch
|
Patch4: 0004-e2fsck-add-env-param-E2FS_UNRELIABLE_IO-to-fi.patch
|
||||||
Patch5: 0005-e2fsck-add-env-param-E2FS_UNRELIABLE_IO-to-fi.patch
|
Patch5: 0005-e2mmpstatus.8.in-detele-filesystem-can-be-UUID-or-LA.patch
|
||||||
Patch6: 0006-e2mmpstatus.8.in-detele-filesystem-can-be-UUID-or-LA.patch
|
Patch6: 0006-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch
|
||||||
Patch7: 0007-tests-fix-ACL-printing-tests.patch
|
Patch7: 0007-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch
|
||||||
Patch8: 0008-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch
|
Patch8: 0008-e2fsprogs-add-sw64.patch
|
||||||
Patch9: 0009-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch
|
Patch9: 0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch
|
||||||
Patch10: 0010-libext2fs-add-sanity-check-to-extent-manipulation.patch
|
Patch10: 0010-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
|
||||||
Patch11: 0011-e2fsprogs-add-sw64.patch
|
|
||||||
Patch12: 0012-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
|
|
||||||
Patch13: 0013-debugfs-teach-logdump-the-n-num_trans-option.patch
|
|
||||||
Patch14: 0014-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch
|
|
||||||
Patch15: 0015-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch
|
|
||||||
Patch16: 0016-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch
|
|
||||||
Patch17: 0017-unix_io.c-fix-deadlock-problem-in-unix_write_blk64.patch
|
|
||||||
Patch18: 0018-misc-fsck.c-Processes-may-kill-other-processes.patch
|
|
||||||
Patch19: 0019-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch
|
|
||||||
Patch20: 0020-tune2fs-check-return-value-of-ext2fs_mmp_update2-in-.patch
|
|
||||||
Patch21: 0021-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch
|
|
||||||
Patch22: 0022-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch
|
|
||||||
Patch23: 0023-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
|
|
||||||
|
|
||||||
|
|
||||||
BuildRequires: gcc pkgconfig texinfo
|
BuildRequires: gcc pkgconfig texinfo
|
||||||
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
||||||
@ -171,6 +157,9 @@ exit 0
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Jul 22 2023 zhanchengbin <zhanchengbin1@huawei.com> - 1.47.0-1
|
||||||
|
- update package to v1.47.0.
|
||||||
|
|
||||||
* Tue Jul 11 2023 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.5-6
|
* Tue Jul 11 2023 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.5-6
|
||||||
- e2fsprogs: avoid error information loss during journal replay
|
- e2fsprogs: avoid error information loss during journal replay
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user