Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
7f16ce0fd6
!248 [sync] PR-247: mke2fs: batch zeroing inode table
From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-11-04 06:10:03 +00:00
liuh
83de92e15e mke2fs: batch zeroing inode table
(cherry picked from commit 2c674faf72f00c56384f71648fe529553c48d909)
2024-10-16 14:24:05 +08:00
openeuler-ci-bot
e82b1cdedd
!241 [sync] PR-235: fsck: fix memory leak on an error exit
From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-07-08 02:01:15 +00:00
cenhuilin
89ceeccb76 fsck: fix memory leak on an error exit
(cherry picked from commit e308b3ebb368db37733653199feb8488a669a1c0)
2024-07-05 10:42:36 +08:00
openeuler-ci-bot
e2a0bd4c11
!233 [sync] PR-232: e2fsck: update quota when deallocating a bad inode
From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-06-24 02:46:37 +00:00
liuh
dba37e07d1 e2fsck: update quota when deallocating a bad inode
(cherry picked from commit b0ae794398a139d0c0e376f931f76f089a3b6d15)
2024-06-22 14:48:56 +08:00
openeuler-ci-bot
a7a590f8a2
!230 [sync] PR-228: e2fsck: update quota accounting after directory optimization
From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-06-22 06:44:37 +00:00
liuh
5306a56874 e2fsck: update quota accounting after directory optimization
(cherry picked from commit 27ba442b09c6ac5edfc4310ee73e814220fbabe8)
2024-06-17 09:30:08 +08:00
openeuler-ci-bot
7f111e060f
!226 [sync] PR-225: e4crypt: fix spurious "Success" error message
From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-06-14 03:23:18 +00:00
liuh
9e8674e737 e4crypt: fix spurious Success error message
(cherry picked from commit 5f5dd8e368d10910b7485760be828cdb5de52552)
2024-06-05 19:39:37 +08:00
6 changed files with 409 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From 1275bbaaea7ffd42346789f945c2f4dcddbfbbc8 Mon Sep 17 00:00:00 2001
From: Jakub Wilk <jwilk@jwilk.net>
Date: Wed, 27 Dec 2023 09:08:05 +0100
Subject: [PATCH] e4crypt: fix spurious "Success" error message
Before:
# e4crypt set_policy 0000000000000000 /dev/null
/dev/null is not a directory
/dev/null: Success
After:
# e4crypt set_policy 0000000000000000 /dev/null
/dev/null: Not a directory
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Link: https://lore.kernel.org/r/20231227080805.6801-1-jwilk@jwilk.net
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/e4crypt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/e4crypt.c b/misc/e4crypt.c
index 67d25d8..af90704 100644
--- a/misc/e4crypt.c
+++ b/misc/e4crypt.c
@@ -144,7 +144,7 @@ static void validate_paths(int argc, char *argv[], int path_start_index)
if (ret < 0)
goto invalid;
if (!S_ISDIR(st.st_mode)) {
- fprintf(stderr, "%s is not a directory\n", argv[x]);
+ errno = ENOTDIR;
goto invalid;
}
}
--
2.43.0

View File

@ -0,0 +1,88 @@
From eb782652045e67a5379dd319613b0d3d924901dd Mon Sep 17 00:00:00 2001
From: "Luis Henriques (SUSE)" <luis.henriques@linux.dev>
Date: Fri, 5 Apr 2024 15:24:02 +0100
Subject: [PATCH] e2fsck: update quota accounting after directory optimization
In "Pass 3A: Optimizing directories", a directory may have it's size reduced.
If that happens and quota is enabled in the filesystem, the quota information
will be incorrect because it doesn't take the rehash into account. This issue
was detected by running fstest ext4/014.
This patch simply updates the quota data accordingly, after the directory is
written and it's size has been updated.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218626
Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20240405142405.12312-2-luis.henriques@linux.dev
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/rehash.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index c1da7d5..04d543b 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -987,14 +987,18 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino,
{
ext2_filsys fs = ctx->fs;
errcode_t retval;
- struct ext2_inode inode;
+ struct ext2_inode_large inode;
char *dir_buf = 0;
struct fill_dir_struct fd = { NULL, NULL, 0, 0, 0, NULL,
0, 0, 0, 0, 0, 0 };
struct out_dir outdir = { 0, 0, 0, 0 };
- struct name_cmp_ctx name_cmp_ctx = {0, NULL};
+ struct name_cmp_ctx name_cmp_ctx = {0, NULL};
+ __u64 osize;
- e2fsck_read_inode(ctx, ino, &inode, "rehash_dir");
+ e2fsck_read_inode_full(ctx, ino, EXT2_INODE(&inode),
+ sizeof(inode), "rehash_dir");
+
+ osize = EXT2_I_SIZE(&inode);
if (ext2fs_has_feature_inline_data(fs->super) &&
(inode.i_flags & EXT4_INLINE_DATA_FL))
@@ -1013,7 +1017,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino,
fd.ino = ino;
fd.ctx = ctx;
fd.buf = dir_buf;
- fd.inode = &inode;
+ fd.inode = EXT2_INODE(&inode);
fd.dir = ino;
if (!ext2fs_has_feature_dir_index(fs->super) ||
(inode.i_size / fs->blocksize) < 2)
@@ -1092,14 +1096,25 @@ resort:
goto errout;
}
- retval = write_directory(ctx, fs, &outdir, ino, &inode, fd.compress);
+ retval = write_directory(ctx, fs, &outdir, ino, EXT2_INODE(&inode),
+ fd.compress);
if (retval)
goto errout;
+ if ((osize > EXT2_I_SIZE(&inode)) &&
+ (ino != quota_type2inum(PRJQUOTA, fs->super)) &&
+ (ino != fs->super->s_orphan_file_inum) &&
+ (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) &&
+ !(inode.i_flags & EXT4_EA_INODE_FL)) {
+ quota_data_sub(ctx->qctx, &inode,
+ ino, osize - EXT2_I_SIZE(&inode));
+ }
+
if (ctx->options & E2F_OPT_CONVERT_BMAP)
retval = e2fsck_rebuild_extents_later(ctx, ino);
else
- retval = e2fsck_check_rebuild_extents(ctx, ino, &inode, pctx);
+ retval = e2fsck_check_rebuild_extents(ctx, ino,
+ EXT2_INODE(&inode), pctx);
errout:
ext2fs_free_mem(&dir_buf);
ext2fs_free_mem(&fd.harray);
--
2.43.0

View File

@ -0,0 +1,121 @@
From eb0680deb908d7da399dd331b7aa35cc1a4dfa2d Mon Sep 17 00:00:00 2001
From: "Luis Henriques (SUSE)" <luis.henriques@linux.dev>
Date: Fri, 5 Apr 2024 15:24:03 +0100
Subject: [PATCH] e2fsck: update quota when deallocating a bad inode
If a bad inode is found it will be deallocated. However, if the filesystem has
quota enabled, the quota information isn't being updated accordingly. This
issue was detected by running fstest ext4/019.
This patch fixes the issue by decreasing the inode count from the
quota and, if blocks are also being released, also subtract them as well.
While there, and as suggested by Andreas Dilger, the deallocate_inode()
function documentation is also updated by this patch to make it clear what
that function really does.
Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev>
Link: https://lore.kernel.org/r/20240405142405.12312-3-luis.henriques@linux.dev
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/pass2.c | 43 ++++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 410edd1..9bb1e32 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1842,17 +1842,26 @@ static int deallocate_inode_block(ext2_filsys fs,
}
/*
- * This function deallocates an inode
+ * This function reverts various counters and bitmaps incremented in
+ * pass1 for the inode, blocks, and quotas before it was decided the
+ * inode was corrupt and needed to be cleared. This avoids the need
+ * to run e2fsck a second time (or have it restart itself) to repair
+ * these counters.
+ *
+ * It does not modify any on-disk state, so even if the inode is bad
+ * it _should_ reset in-memory state to before the inode was first
+ * processed.
*/
static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
{
ext2_filsys fs = ctx->fs;
- struct ext2_inode inode;
+ struct ext2_inode_large inode;
struct problem_context pctx;
__u32 count;
struct del_block del_block;
- e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode");
+ e2fsck_read_inode_full(ctx, ino, EXT2_INODE(&inode),
+ sizeof(inode), "deallocate_inode");
clear_problem_context(&pctx);
pctx.ino = ino;
@@ -1862,29 +1871,29 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
e2fsck_read_bitmaps(ctx);
ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(inode.i_mode));
- if (ext2fs_file_acl_block(fs, &inode) &&
+ if (ext2fs_file_acl_block(fs, EXT2_INODE(&inode)) &&
ext2fs_has_feature_xattr(fs->super)) {
pctx.errcode = ext2fs_adjust_ea_refcount3(fs,
- ext2fs_file_acl_block(fs, &inode),
+ ext2fs_file_acl_block(fs, EXT2_INODE(&inode)),
block_buf, -1, &count, ino);
if (pctx.errcode == EXT2_ET_BAD_EA_BLOCK_NUM) {
pctx.errcode = 0;
count = 1;
}
if (pctx.errcode) {
- pctx.blk = ext2fs_file_acl_block(fs, &inode);
+ pctx.blk = ext2fs_file_acl_block(fs, EXT2_INODE(&inode));
fix_problem(ctx, PR_2_ADJ_EA_REFCOUNT, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
if (count == 0) {
ext2fs_block_alloc_stats2(fs,
- ext2fs_file_acl_block(fs, &inode), -1);
+ ext2fs_file_acl_block(fs, EXT2_INODE(&inode)), -1);
}
- ext2fs_file_acl_block_set(fs, &inode, 0);
+ ext2fs_file_acl_block_set(fs, EXT2_INODE(&inode), 0);
}
- if (!ext2fs_inode_has_valid_blocks2(fs, &inode))
+ if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(&inode)))
goto clear_inode;
/* Inline data inodes don't have blocks to iterate */
@@ -1909,10 +1918,22 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
ctx->flags |= E2F_FLAG_ABORT;
return;
}
+
+ if ((ino != quota_type2inum(PRJQUOTA, fs->super)) &&
+ (ino != fs->super->s_orphan_file_inum) &&
+ (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) &&
+ !(inode.i_flags & EXT4_EA_INODE_FL)) {
+ if (del_block.num > 0)
+ quota_data_sub(ctx->qctx, &inode, ino,
+ del_block.num * EXT2_CLUSTER_SIZE(fs->super));
+ quota_data_inodes(ctx->qctx, (struct ext2_inode_large *)&inode,
+ ino, -1);
+ }
+
clear_inode:
/* Inode may have changed by block_iterate, so reread it */
- e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode");
- e2fsck_clear_inode(ctx, ino, &inode, 0, "deallocate_inode");
+ e2fsck_read_inode(ctx, ino, EXT2_INODE(&inode), "deallocate_inode");
+ e2fsck_clear_inode(ctx, ino, EXT2_INODE(&inode), 0, "deallocate_inode");
}
/*
--
2.43.0

View File

@ -0,0 +1,29 @@
From 7b76a84fd8f75fb53849a751db27d7dfd17bd8b6 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Tue, 2 Jul 2024 11:23:47 +0800
Subject: [PATCH] fsck: fix memory leak on an error exit
This reduces noise from a static analyzer.
https://github.com/tytso/e2fsprogs/issues/160
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/fsck.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/misc/fsck.c b/misc/fsck.c
index 1769a10..64d0e7c 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -806,6 +806,7 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp)
if ((negate && !cmp->negate) ||
(!negate && cmp->negate)) {
fputs(_(fs_type_syntax_error), stderr);
+ free(list);
exit(EXIT_USAGE);
}
}
--
2.33.0

View File

@ -0,0 +1,109 @@
From a192f4f344456c2390ce946b4a71db0b85ce5665 Mon Sep 17 00:00:00 2001
From: Li Dongyang <dongyangli@ddn.com>
Date: Mon, 4 Sep 2023 14:58:06 +1000
Subject: [PATCH] mke2fs: batch zeroing inode table
For flex_bg enabled fs, we could merge the
inode table blocks into a contiguous range,
this improves mke2fs time on large devices
when lazy_itable_init is disabled.
On a 977TB device, unpatched mke2fs was running
for 449m10s before getting terminated manually.
strace shows huge number of fallocate, given the
offset from fallocate it has done 41% of the inode
tables, the estimated time needed would be 1082m.
unpatched patched
real 449m10.954s 4m20.531s
user 0m18.217s 0m16.147s
sys 0m20.311s 0m8.944s
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Link: https://lore.kernel.org/r/20230904045806.827621-1-dongyangli@ddn.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/mke2fs.c | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 4a9c1b0..aebf050 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -415,9 +415,9 @@ static errcode_t packed_allocate_tables(ext2_filsys fs)
static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
{
errcode_t retval;
- blk64_t blk;
+ blk64_t start = 0;
dgrp_t i;
- int num;
+ int len = 0;
struct ext2fs_numeric_progress_struct progress;
ext2fs_numeric_progress_init(fs, &progress,
@@ -425,10 +425,10 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
fs->group_desc_count);
for (i = 0; i < fs->group_desc_count; i++) {
- ext2fs_numeric_progress_update(fs, &progress, i);
+ blk64_t blk = ext2fs_inode_table_loc(fs, i);
+ int num = fs->inode_blocks_per_group;
- blk = ext2fs_inode_table_loc(fs, i);
- num = fs->inode_blocks_per_group;
+ ext2fs_numeric_progress_update(fs, &progress, i);
if (lazy_flag)
num = ext2fs_div_ceil((fs->super->s_inodes_per_group -
@@ -441,14 +441,26 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
ext2fs_group_desc_csum_set(fs, i);
}
if (!itable_zeroed) {
- retval = ext2fs_zero_blocks2(fs, blk, num, &blk, &num);
+ if (len == 0) {
+ start = blk;
+ len = num;
+ continue;
+ }
+ /* 'len' must not overflow 2^31 blocks for ext2fs_zero_blocks2() */
+ if (start + len == blk && len + num >= len) {
+ len += num;
+ continue;
+ }
+ retval = ext2fs_zero_blocks2(fs, start, len, &start, &len);
if (retval) {
fprintf(stderr, _("\nCould not write %d "
"blocks in inode table starting at %llu: %s\n"),
- num, (unsigned long long) blk,
+ len, (unsigned long long) start,
error_message(retval));
exit(1);
}
+ start = blk;
+ len = num;
}
if (sync_kludge) {
if (sync_kludge == 1)
@@ -457,6 +469,18 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
io_channel_flush(fs->io);
}
}
+ if (len) {
+ retval = ext2fs_zero_blocks2(fs, start, len, &start, &len);
+ if (retval) {
+ fprintf(stderr, _("\nCould not write %d "
+ "blocks in inode table starting at %llu: %s\n"),
+ len, (unsigned long long) start,
+ error_message(retval));
+ exit(1);
+ }
+ if (sync_kludge)
+ io_channel_flush(fs->io);
+ }
ext2fs_numeric_progress_close(fs, &progress,
_("done \n"));
--
2.43.0

View File

@ -1,6 +1,6 @@
Name: e2fsprogs
Version: 1.47.0
Release: 3
Release: 8
Summary: Second extended file system management tools
License: GPLv2+ and LGPLv2 and MIT
URL: http://e2fsprogs.sourceforge.net/
@ -19,6 +19,11 @@ Patch9: 0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch
Patch10: 0010-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
Patch11: 0011-mke2fs.conf-remove-metadata_csum_seed-and-orphan_fil.patch
Patch12: 0012-debugfs-fix-infinite-loop-while-dumping-the-journal.patch
Patch13: 0013-e4crypt-fix-spurious-Success-error-message.patch
Patch14: 0014-e2fsck-update-quota-accounting-after-directory-optim.patch
Patch15: 0015-e2fsck-update-quota-when-deallocating-a-bad-inode.patch
Patch16: 0016-fsck-fix-memory-leak-on-an-error-exit.patch
Patch17: 0017-mke2fs-batch-zeroing-inode-table.patch
BuildRequires: gcc pkgconfig texinfo
BuildRequires: fuse-devel libblkid-devel libuuid-devel
@ -159,6 +164,23 @@ exit 0
%{_mandir}/man8/*
%changelog
* Fri Sep 20 2024 liuh <liuhuan01@kylinos.cn> - 1.47.0-8
- mke2fs: batch zeroing inode table
* Tue Jul 2 2024 cenhuilin <cenhuilin@kylinos.cn> - 1.47.0-7
- fsck: fix memory leak on an error exit
* Fri Jun 21 2024 liuh <liuhuan01@kylinos.cn> - 1.47.0-6
- sync patch from community
e2fsck: update quota when deallocating a bad inode
* Wed Jun 12 2024 liuh <liuhuan01@kylinos.cn> - 1.47.0-5
- sync patch from community
fix e2fsck: update quota accounting after directory optimization
* Wed Jun 5 2024 liuh <liuhuan01@kylinos.cn> - 1.47.0-4
- sync patch from community
* Thu Apr 18 2024 jinzhiguang <jinzhiguang@kylinos.cn> - 1.47.0-3
- Upstream patches regress for debugfs.
Fix infinite loop while dumping the journal.