All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: dsterba@suse.cz, Remi Gauvin <remi@georgianit.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Does btrfs filesystem defragment -r also include the trees?
Date: Fri, 21 Apr 2023 15:57:14 +0800	[thread overview]
Message-ID: <6f795670-eae6-6aef-3fd0-dad81bb89700@suse.com> (raw)
In-Reply-To: <20230420224242.GZ19619@twin.jikos.cz>



On 2023/4/21 06:42, David Sterba wrote:
> On Thu, Apr 20, 2023 at 08:37:07AM -0400, Remi Gauvin wrote:
>> I have recently experienced that btrfs defragment (by itself, without
>> -r) of a subvolume can dramatically improve performance when accessing
>> very large directories.  I would go so far as to call it critical
>> maintenance when working with gtk3 based file managers.
>>
>> What I am not clear on, however, does adding the -r *also* defragment
>> the subvolume extent tree, or do the two commands needs to be run
>> separately to get the full effect?
> 
> No, -r does not defragment the extent tree, so if you really want to
> defragment the extent tree, then you need to run it separately and
> without -r.

I did a quick glance, btrfs_defrag_root() only defrags the target 
subvolume, thus there is no way to defrag internal trees.

> 
> Originally there was only the extent tree defragmentation which was
> confusing when defrag got a directory as an argument, then it always
> defragmented the extent tree but did not descend recursively. Then the
> -r was added and the bare directory path discouraged. It still works
> though.

My another concern is, does metadata "defrag" make any sense?

Btree itself is never designed for sequential read anyway, and even we 
can pack all metadata into a sequential bytenr, what's the proper order? 
Breadth-first? Depth-first?

Thanks,
Qu

> 
> I've checked if this is documented, it seems to (btrfs-filesystem,
> section defrag):
> 
> "NOTE: Directory  arguments  without -r do not defragment files
> recursively but will defragment certain internal trees (extent tree and
> the subvolume tree). This has been confusing and could be re- moved in
> the future."
> 
> but if you think it's not clear enough please suggest in what way it
> could be extended or what's missing.

  reply	other threads:[~2023-04-21  7:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 12:37 Does btrfs filesystem defragment -r also include the trees? Remi Gauvin
2023-04-20 22:42 ` David Sterba
2023-04-21  7:57   ` Qu Wenruo [this message]
2023-04-21 12:21     ` Remi Gauvin
2023-04-21 17:41       ` waxhead
2023-04-21 21:00         ` Forza
2023-04-21 21:27         ` Remi Gauvin
2023-04-21 21:40         ` joshua
2023-04-21 22:55           ` Qu Wenruo
2023-04-21 23:25             ` joshua
2023-04-22  0:42               ` Qu Wenruo
2023-04-23  9:34                 ` waxhead
2023-04-23 10:50                   ` 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=6f795670-eae6-6aef-3fd0-dad81bb89700@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=remi@georgianit.com \
    /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.