Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org,
	Christoph Anton Mitterer <calestyo@scientia.org>
Subject: Re: [PATCH] btrfs: defrag: add under utilized extent to defrag target list
Date: Wed, 10 Jan 2024 18:09:41 +0100	[thread overview]
Message-ID: <20240110170941.GA31555@twin.jikos.cz> (raw)
In-Reply-To: <2c2fac36b67c97c9955eb24a97c6f3c09d21c7ff.1704440000.git.wqu@suse.com>

On Fri, Jan 05, 2024 at 06:03:40PM +1030, Qu Wenruo wrote:
> [BUG]
> The following script can lead to a very under utilized extent and we
> have no way to use defrag to properly reclaim its wasted space:
> 
>   # mkfs.btrfs -f $dev
>   # mount $dev $mnt
>   # xfs_io -f -c "pwrite 0 128M" $mnt/foobar
>   # sync
>   # btrfs filesystem defrag $mnt/foobar
>   # sync

I don't see what's wrong with this example, as Filipe noted there's a
truncate missing, but still this should be explained better.

Is this the problem when an overwritten and shared extent is partially
overwritten but still occupying the whole range, aka. bookend extent?
If yes, defrag was never meant to deal with that, though we could use
the interface for that.

As Andrei pointed out, this is more like a garbage collection, get rid
of extent that is partially unreachable. Detecting such extent requires
looking for the unreferenced part of the extent while defragmentation
deals with live data. This could be a new ioctl entirely too. But first
I'd like to know if we're talking about the same thing.

  parent reply	other threads:[~2024-01-10 17:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05  7:33 [PATCH] btrfs: defrag: add under utilized extent to defrag target list Qu Wenruo
2024-01-05 16:45 ` Andrei Borzenkov
2024-01-05 20:11   ` Qu Wenruo
2024-01-09 14:55 ` Filipe Manana
2024-01-09 16:12   ` Filipe Manana
2024-01-09 21:04   ` Qu Wenruo
2024-01-09 21:57     ` Christoph Anton Mitterer
2024-01-09 22:17       ` Qu Wenruo
2024-01-10 17:09 ` David Sterba [this message]
2024-01-11  6:24   ` Qu Wenruo
2024-01-12 15:58     ` David Sterba
2024-01-13  3:17       ` Qu Wenruo
2024-01-13  8:05         ` Andrei Borzenkov
2024-01-13  8:32           ` Qu Wenruo
2024-01-13  3:47       ` Christoph Anton Mitterer
2024-02-05  5:39 ` Christoph Anton Mitterer
2024-02-05  5:42   ` Qu Wenruo
2024-04-20  4:30     ` Skirnir Torvaldsson

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=20240110170941.GA31555@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=calestyo@scientia.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox