All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: John Ettedgui <john.ettedgui@gmail.com>,
	Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: mount btrfs takes 30 minutes, btrfs check runs out of memory
Date: Mon, 18 Jul 2016 09:13:57 +0800	[thread overview]
Message-ID: <5cc93522-1bd2-bdc1-d5da-a11d5e4816a7@cn.fujitsu.com> (raw)
In-Reply-To: <CAJ3TwYTnMPVwkrZEU-=Q_Nq+9Bn0vM3z+EFC8RP=RTyaufSoqw@mail.gmail.com>



At 07/16/2016 07:17 PM, John Ettedgui wrote:
> On Thu, Jul 14, 2016 at 10:54 PM John Ettedgui <john.ettedgui@gmail.com
> <mailto:john.ettedgui@gmail.com>> wrote:
>
>     On Thu, Jul 14, 2016 at 10:26 PM Qu Wenruo <quwenruo@cn.fujitsu.com
>     <mailto:quwenruo@cn.fujitsu.com>> wrote:
>
>
>         > Would increasing the leaf size help as well?
>
>         > nodatacow seems unsafe
>
>
>         Nodatacow is not that unsafe, as btrfs will still do data cow if
>         it's
>         needed, like rewriting data of another subvolume/snapshot.
>
>     Alright.
>
>         That would be one of the most obvious method if you do a lot of
>         rewrite.
>
>         > as for defrag, all my partitions are already on
>         > autodefrag, so I assume that should be good. Or is manual once
>         in a
>         > while a good idea as well?
>         AFAIK autodefrag will only help if you're doing appending write.
>
>         Manual one will help more, but since btrfs has problem defraging
>         extents
>         shared by different subvolumes, I doubt the effect if you have a
>         lot of
>         subvolumes/snapshots.
>
>     I don't have any subvolume/snapshot for the big partitions, my usage
>     there is fairly simple. I'll have to add a regular defrag job then.
>
>
>         Another method is to disable compression.
>         For compression, file extent size up limit is 128K, while for
>         non-compress case, it's 128M.
>
>         So for the same 1G sized file, it would cause 8K extents using
>         compression, while only 8 extents without compression.
>
>     Now that might be something important, I do use LZO compression on
>     all of them.
>     Does this limit apply to only compressed files, or any file if the
>     fs is mounted using the compression option?
>     Would mounting these partitions without compression option and then
>     defragmenting them reverse the compression?
>
> I've tried this for the slowest to mount partition.
> I changed its mount option to compression=no, run defrag and balance.
> Not sure if the latter was needed but I thought to try... like in the
> past it worked fine up to dusage=99 but with 100% I get a crash, oh well.
> The result of defrag + nocompress (I don't know how much it actually
> decompressed, and if it changed the limit Qu mentioned before) is about
> 26% less time spent to mount the partition, and it's no more my slowerst
> partition to mount.!

Well, compression=no only affects any write after the mount option.
And balance won't help to convert compressed extent to non-compressed one.

But maybe the defrag will convert them to normal extents.

The best method to de-compress them is, to read them out and rewrite 
them with compression=no mount option.

>
> I'll try just defragmenting another partition but keeping the
> compression on and see what difference I get there the same changes.
>
> I've tried the patch, which applied fine to my kernel (4.6.4) but I
> don't see any difference in mounting time, maybe I made a mistake or my
> issue is not really the same?

Pretty possible that there is another problem causing the slow mount.

The best method to verify is to do a ftrace on the btrfs mount.
Here is the script I tested my patch:

------
#!/bin/bash

trace_dir=/sys/kernel/debug/tracing

init_trace () {
	echo 0 > $trace_dir/tracing_on
	echo > $trace_dir/trace
	echo function_graph > $trace_dir/current_tracer
	echo > $trace_dir/set_ftrace_filter

	echo open_ctree			>> $trace_dir/set_ftrace_filter
	echo btrfs_read_chunk_tree	>> $trace_dir/set_ftrace_filter
	echo btrfs_read_block_groups	>> $trace_dir/set_ftrace_filter

	# This will generate tons of trace, better to comment it out
	echo find_block_group		>> $trace_dir/set_ftrace_filter

	echo 1 > $trace_dir/tracing_on
}

end_trace () {
	cp $trace_dir/trace $(dirname $0)
	echo 0 > $trace_dir/tracing_on
	echo > $trace_dir/set_ftrace_filter
	echo > $trace_dir/trace
}

init_trace
echo start mounting
time mount /dev/sdb /mnt/test
echo mount done
end_trace
------

After executing the script, you got a file named "trace" at the same 
directory of the script.

The content will be like:
------
# tracer: function_graph
#
# CPU  DURATION                  FUNCTION CALLS
# |     |   |                     |   |   |   |
  1) $ 7670856 us  |  open_ctree [btrfs]();
  2) * 13533.45 us |    btrfs_read_chunk_tree [btrfs]();
  2) # 1320.981 us |    btrfs_init_space_info [btrfs]();
  2)               |    btrfs_read_block_groups [btrfs]() {
  2) * 10127.35 us |      find_block_group [btrfs]();
  2)   4.951 us    |      find_block_group [btrfs]();
  2) * 26225.17 us |      find_block_group [btrfs]();
......
  3) * 26450.28 us |      find_block_group [btrfs]();
  3) * 11590.29 us |      find_block_group [btrfs]();
  3) $ 7557210 us  |    } /* btrfs_read_block_groups [btrfs] */ <<<
------

And you can see open_ctree() function, the main part of btrfs mount, 
takes about 7.67 seconds to execute, while btrfs_read_block_groups() 
takes 7.56 seconds, about 98.6% of the open_ctree() executing time.

If your result are much the same as mine, then that's the same problem.

And after applying my patch, please try to compare the executing time of 
btrfs_read_block_groups() to see if there is any obvious(>5%) change.

Thanks,
Qu

>
> Thank you,
> John



  parent reply	other threads:[~2016-07-18  1:14 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJ3TwYQXqUZiKhYc5rciTmvGX1RLkHnkQb5SSYAJ7AD+kbudag@mail.gmail.com>
2015-07-31  2:34 ` mount btrfs takes 30 minutes, btrfs check runs out of memory Qu Wenruo
2015-07-31  4:10   ` John Ettedgui
2015-08-02  5:44     ` Georgi Georgiev
     [not found]   ` <CAJ3TwYRN+1tJY+paz=qZT0_XP=r9CcTKbBgX_kZRFOWj8vSK=w@mail.gmail.com>
2015-07-31  4:52     ` Qu Wenruo
     [not found]       ` <CAJ3TwYR5g-JhjmGnZUXqLXc7qV1_=AN5_6sj54JQODbtgG9Aag@mail.gmail.com>
2015-07-31  5:40         ` Qu Wenruo
2015-07-31  5:45           ` John Ettedgui
2015-08-01  4:35             ` John Ettedgui
2015-08-01 10:05               ` Russell Coker
2015-08-04  1:39               ` Qu Wenruo
2015-08-04  1:55                 ` John Ettedgui
2015-08-04  2:31                   ` John Ettedgui
2015-08-04  3:01                   ` Qu Wenruo
2015-08-04  4:58                     ` John Ettedgui
2015-08-04  6:47                       ` Duncan
2015-08-04 11:28                       ` Austin S Hemmelgarn
2015-08-04 17:36                         ` John Ettedgui
2015-08-05 11:30                           ` Austin S Hemmelgarn
2015-08-13 22:38                             ` Vincent Olivier
2015-08-13 23:19                               ` Chris Murphy
2015-08-14  0:30                                 ` Duncan
2015-08-14  2:42                                   ` Vincent Olivier
2015-08-18 17:36                                     ` Vincent Olivier
2015-08-14  2:39                                 ` Vincent Olivier
     [not found]                             ` <CAJ3TwYSW+SvbBrh1u_x+c3HTRx03qSR6BoH5cj_VzCXxZYv6EA@mail.gmail.com>
2016-07-15  3:56                               ` Qu Wenruo
     [not found]                                 ` <CAJ3TwYRXwDVVfT0TRRiM9dEw-7TvY8qG=WvMYKczZOv6wkFWAQ@mail.gmail.com>
2016-07-15  5:24                                   ` Qu Wenruo
2016-07-15  6:56                                     ` Kai Krakow
     [not found]                                     ` <CAJ3TwYSTnQfj=qmBLtnmtXQKexMMD4x=9Gk3p3anf4uF+G26kw@mail.gmail.com>
     [not found]                                       ` <CAJ3TwYTnMPVwkrZEU-=Q_Nq+9Bn0vM3z+EFC8RP=RTyaufSoqw@mail.gmail.com>
2016-07-18  1:13                                         ` Qu Wenruo [this message]
     [not found]                                           ` <CAJ3TwYRpc_R-wVur0T6+Uy_aPVXTGpvp_ag1Ar9K2HoB0H1ySQ@mail.gmail.com>
2016-07-18  8:41                                             ` Qu Wenruo
     [not found]                                               ` <CAJ3TwYRH8JVkuv2Hu7FYb+BSwKGrq1spx079zwOF_FO1y=9NFA@mail.gmail.com>
2016-07-18  9:07                                                 ` Qu Wenruo
2016-07-18 15:31                                                   ` Duncan
     [not found]                                                   ` <CAJ3TwYS6UTkWf=PNku3RG7hPrXMKz3yhk2WqCRLix4v_VwgrmA@mail.gmail.com>
2016-07-21  8:10                                                     ` Qu Wenruo
     [not found]                                                       ` <CAJ3TwYQ47SVpbO1Pb-TWjhaTCCpMFFmijwTgmV8=7+1_a6_3Ww@mail.gmail.com>
2016-07-21  8:19                                                         ` Qu Wenruo
2016-07-21 15:47                                                           ` Graham Cobb
2017-04-10  0:52                                                             ` Qu Wenruo
2018-02-13 10:21                                                           ` John Ettedgui
2018-02-13 11:04                                                             ` Qu Wenruo
2018-02-13 11:25                                                               ` John Ettedgui
2018-02-13 11:40                                                                 ` Qu Wenruo
2018-02-13 12:06                                                                   ` John Ettedgui
2018-02-13 12:46                                                                     ` Qu Wenruo
2018-02-13 12:52                                                                       ` John Ettedgui
2018-02-13 12:26                                                                   ` Holger Hoffstätte
2018-02-13 12:54                                                                     ` Qu Wenruo
2018-02-13 16:24                                                                       ` Holger Hoffstätte
2018-02-14  0:43                                                                         ` Qu Wenruo
2016-07-15 11:29                                 ` Christian Rohmann
2016-07-16 23:53                                   ` Qu Wenruo
2016-07-18 13:42                                     ` Josef Bacik
2016-07-19  0:35                                       ` Qu Wenruo
2016-07-25 13:01                                       ` David Sterba
2016-07-25 13:38                                         ` Josef Bacik
2015-08-04 14:38                     ` Chris Murphy
2015-07-29  5:46 Georgi Georgiev
2015-07-29  6:19 ` Qu Wenruo

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=5cc93522-1bd2-bdc1-d5da-a11d5e4816a7@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=ahferroin7@gmail.com \
    --cc=john.ettedgui@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.