From: Nikola Ciprich <nikola.ciprich@linuxbox.cz>
To: "Ted Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org,
Radovan Mzik <radovan.mzik@linuxbox.cz>,
Nikola Ciprich <nikola.ciprich@linuxbox.cz>
Subject: Re: running mkfs.ext4 causes very high system load
Date: Thu, 22 Mar 2012 20:15:18 +0100 [thread overview]
Message-ID: <20120322191518.GA2049@nik-comp.lan> (raw)
In-Reply-To: <20120322153500.GE25897@thunk.org>
[-- Attachment #1: Type: text/plain, Size: 4212 bytes --]
hi Ted!
> Mke2fs generates a large number of writes, and with LVM, if you are
> writing a lot to an LV which uses physical disks shared by other LV's,
> ultimately you are going to run into disk contention. It sounds like
> from your description that your system is pretty busy, and other
> applications are using the disks pretty heavily.
>
> The other potential thing that could be happening is that mke2fs is
> dirtying a lot of memory blocks when it writes to the disk, and so
> your system is thrashing due memory pressure.
You're pretty right! After applying Your patch (+ one more small
fix to build on centos5) and using -D parameter, mkfs really got slower,
bud didn't affect system load almost at all!
> If it is caused by memory pressure it may be that using direct I/O
> will help make mke2fs be more "polite" at the expensive of taking a bit longer.
>
> Here are patches versus the latest e2fsprogs (1.42.1) that might be
> helpful. After you apply them, run mke2fs with the -D option to force
> the use of direct I/O. Let me know if it makes a difference for you.
so it really made the difference.
Thanks a lot!
with regards
nik
>
> Regards,
>
> - Ted
>
> diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
> index a63ea18..b06371c 100644
> --- a/lib/ext2fs/initialize.c
> +++ b/lib/ext2fs/initialize.c
> @@ -119,6 +119,8 @@ errcode_t ext2fs_initialize(const char *name, int flags,
> io_flags = IO_FLAG_RW;
> if (flags & EXT2_FLAG_EXCLUSIVE)
> io_flags |= IO_FLAG_EXCLUSIVE;
> + if (flags & EXT2_FLAG_DIRECT_IO)
> + io_flags |= IO_FLAG_DIRECT_IO;
> retval = manager->open(name, io_flags, &fs->io);
> if (retval)
> goto cleanup;
> diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
> index 8e78249..9f1fa29 100644
> --- a/misc/mke2fs.8.in
> +++ b/misc/mke2fs.8.in
> @@ -18,6 +18,9 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
> .I block-size
> ]
> [
> +.B \-D
> +]
> +[
> .B \-f
> .I fragment-size
> ]
> @@ -184,6 +187,11 @@ Check the device for bad blocks before creating the file system. If
> this option is specified twice, then a slower read-write
> test is used instead of a fast read-only test.
> .TP
> +.B \-D
> +Use direct I/O when writing to the disk. This avoids mke2fs dirtying a
> +lot of buffer cache memory which may impact other applications running
> +on a busy server, at the expense of causing mke2fs to run much more slowly.
> +.TP
> .BI \-E " extended-options"
> Set extended options for the filesystem. Extended options are comma
> separated, and may take an argument using the equals ('=') sign. The
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index 51435d2..b8ff19b 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -88,6 +88,7 @@ int verbose;
> int quiet;
> int super_only;
> int discard = 1; /* attempt to discard device before fs creation */
> +int direct_io;
> int force;
> int noaction;
> int journal_size;
> @@ -1321,7 +1322,7 @@ profile_error:
> }
>
> while ((c = getopt (argc, argv,
> - "b:cg:i:jl:m:no:qr:s:t:vC:E:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
> + "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
> switch (c) {
> case 'b':
> blocksize = strtol(optarg, &tmp, 0);
> @@ -1354,6 +1355,9 @@ profile_error:
> exit(1);
> }
> break;
> + case 'D':
> + direct_io = 1;
> + break;
> case 'g':
> fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
> if (*tmp) {
> @@ -2257,6 +2261,8 @@ int main (int argc, char *argv[])
> * Initialize the superblock....
> */
> flags = EXT2_FLAG_EXCLUSIVE;
> + if (direct_io)
> + flags |= EXT2_FLAG_DIRECT_IO;
> profile_get_boolean(profile, "options", "old_bitmaps", 0, 0,
> &old_bitmaps);
> if (!old_bitmaps)
>
--
-------------------------------------
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28. rijna 168, 709 01 Ostrava
tel.: +420 596 603 142
fax: +420 596 621 273
mobil: +420 777 093 799
www.linuxbox.cz
mobil servis: +420 737 238 656
email servis: servis@linuxbox.cz
-------------------------------------
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
prev parent reply other threads:[~2012-03-22 19:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 14:05 running mkfs.ext4 causes very high system load Nikola Ciprich
2012-03-22 15:35 ` Ted Ts'o
2012-03-22 19:15 ` Nikola Ciprich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120322191518.GA2049@nik-comp.lan \
--to=nikola.ciprich@linuxbox.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=radovan.mzik@linuxbox.cz \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).