mkfs.ext3: backport upstream to speed up mkfs.ext3
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
This commit is contained in:
parent
2cd449da19
commit
ecd554ac8b
75
0055-libext2fs-batch-calls-to-ext2fs_zero_blocks2.patch
Normal file
75
0055-libext2fs-batch-calls-to-ext2fs_zero_blocks2.patch
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
From 86d6153417ddaccbe3d1f4466a374716006581f4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Date: Sat, 25 Apr 2020 11:41:24 -0400
|
||||||
|
Subject: [PATCH] libext2fs: batch calls to ext2fs_zero_blocks2()
|
||||||
|
|
||||||
|
When allocating blocks for an indirect block mapped file, accumulate
|
||||||
|
blocks to be zero'ed and then call ext2fs_zero_blocks2() to zero them
|
||||||
|
in large chunks instead of block by block.
|
||||||
|
|
||||||
|
This significantly speeds up mkfs.ext3 since we don't send a large
|
||||||
|
number of ZERO_RANGE requests to the kernel, and while the kernel does
|
||||||
|
batch write requests, it is not batching ZERO_RANGE requests. It's
|
||||||
|
more efficient to batch in userspace in any case, since it avoids
|
||||||
|
unnecessary system calls.
|
||||||
|
|
||||||
|
Reported-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
lib/ext2fs/fallocate.c | 28 +++++++++++++++++++++++-----
|
||||||
|
1 file changed, 23 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/ext2fs/fallocate.c b/lib/ext2fs/fallocate.c
|
||||||
|
index 31e47f8d..5cde7d5c 100644
|
||||||
|
--- a/lib/ext2fs/fallocate.c
|
||||||
|
+++ b/lib/ext2fs/fallocate.c
|
||||||
|
@@ -805,7 +805,8 @@ errcode_t ext2fs_fallocate(ext2_filsys fs, int flags, ext2_ino_t ino,
|
||||||
|
blk64_t start, blk64_t len)
|
||||||
|
{
|
||||||
|
struct ext2_inode inode_buf;
|
||||||
|
- blk64_t blk, x;
|
||||||
|
+ blk64_t blk, x, zero_blk, last = 0;
|
||||||
|
+ int zero_len = 0;
|
||||||
|
errcode_t err;
|
||||||
|
|
||||||
|
if (((flags & EXT2_FALLOCATE_FORCE_INIT) &&
|
||||||
|
@@ -841,15 +842,32 @@ errcode_t ext2fs_fallocate(ext2_filsys fs, int flags, ext2_ino_t ino,
|
||||||
|
if (x)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
- err = ext2fs_bmap2(fs, ino, inode, NULL,
|
||||||
|
- BMAP_ALLOC | BMAP_UNINIT | BMAP_ZERO, blk,
|
||||||
|
- 0, &x);
|
||||||
|
+ err = ext2fs_bmap2(fs, ino, inode, NULL, BMAP_ALLOC,
|
||||||
|
+ blk, 0, &x);
|
||||||
|
if (err)
|
||||||
|
- return err;
|
||||||
|
+ goto errout;
|
||||||
|
+ if ((zero_len && (x != last+1)) ||
|
||||||
|
+ (zero_len >= 65536)) {
|
||||||
|
+ err = ext2fs_zero_blocks2(fs, zero_blk, zero_len,
|
||||||
|
+ NULL, NULL);
|
||||||
|
+ zero_len = 0;
|
||||||
|
+ if (err)
|
||||||
|
+ goto errout;
|
||||||
|
+ }
|
||||||
|
+ if (zero_len == 0) {
|
||||||
|
+ zero_blk = x;
|
||||||
|
+ zero_len = 1;
|
||||||
|
+ } else {
|
||||||
|
+ zero_len++;
|
||||||
|
+ }
|
||||||
|
+ last = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (inode == &inode_buf)
|
||||||
|
ext2fs_write_inode(fs, ino, inode);
|
||||||
|
+errout:
|
||||||
|
+ if (zero_len)
|
||||||
|
+ ext2fs_zero_blocks2(fs, zero_blk, zero_len, NULL, NULL);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.23.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: e2fsprogs
|
Name: e2fsprogs
|
||||||
Version: 1.45.6
|
Version: 1.45.6
|
||||||
Release: 19
|
Release: 20
|
||||||
Summary: Second extended file system management tools
|
Summary: Second extended file system management tools
|
||||||
License: GPLv2 and LGPLv2 and GPLv2+
|
License: GPLv2 and LGPLv2 and GPLv2+
|
||||||
URL: http://e2fsprogs.sourceforge.net/
|
URL: http://e2fsprogs.sourceforge.net/
|
||||||
@ -61,6 +61,7 @@ Patch51: 0051-misc-fsck.c-Processes-may-kill-other-processes.patch
|
|||||||
Patch52: 0052-append_pathname-check-the-value-returned-by-realloc.patch
|
Patch52: 0052-append_pathname-check-the-value-returned-by-realloc.patch
|
||||||
Patch53: 0053-argv_parse-check-return-value-of-malloc-in-argv_pars.patch
|
Patch53: 0053-argv_parse-check-return-value-of-malloc-in-argv_pars.patch
|
||||||
Patch54: 0054-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch
|
Patch54: 0054-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch
|
||||||
|
Patch55: 0055-libext2fs-batch-calls-to-ext2fs_zero_blocks2.patch
|
||||||
|
|
||||||
BuildRequires: gcc pkgconfig texinfo
|
BuildRequires: gcc pkgconfig texinfo
|
||||||
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
||||||
@ -182,6 +183,9 @@ exit 0
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 28 2023 haowenchao <haowenchao2@huawei.com> - 1.45.6-20
|
||||||
|
- backport upstream to speed up mkfs.ext3
|
||||||
|
|
||||||
* Mon Apr 17 tangyuchen <tangyuchen5@huawei.com> - 1.45.6-19
|
* Mon Apr 17 tangyuchen <tangyuchen5@huawei.com> - 1.45.6-19
|
||||||
- backport 1 patch, improving error-handling in POSIX-ACL
|
- backport 1 patch, improving error-handling in POSIX-ACL
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user