public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* Why does defragmenting break reflinks?
@ 2025-05-29 23:52 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
  2025-05-30  0:27 ` Qu Wenruo
  0 siblings, 1 reply; 7+ messages in thread
From: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 @ 2025-05-29 23:52 UTC (permalink / raw)
  To: linux-btrfs

BTRFS-FILESYSTEM(8) says "defragmenting  with  Linux kernel versions < 
3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 
3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data 
(for example files copied with cp --reflink, snapshots or de-duplicated 
data)." Why does defragmenting not preserve reflinks and why was it removed?

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
  2025-05-29 23:52 Why does defragmenting break reflinks? 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
@ 2025-05-30  0:27 ` Qu Wenruo
  2025-05-30 22:41   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qu Wenruo @ 2025-05-30  0:27 UTC (permalink / raw)
  To: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣,
	linux-btrfs



在 2025/5/30 09:22, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 写道:
> BTRFS-FILESYSTEM(8) says "defragmenting  with  Linux kernel versions < 
> 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 
> 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data 
> (for example files copied with cp --reflink, snapshots or de-duplicated 
> data)." Why does defragmenting not preserve reflinks and why was it 
> removed?
> 

Defrag means to re-dirty the data, and write them back again, which will 
cause COW.
And by nature this breaks reflinked data extents.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
  2025-05-30  0:27 ` Qu Wenruo
@ 2025-05-30 22:41   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
       [not found]   ` <3eabd123-e2a8-4554-b57b-0c84b713cd10@velocifyer.com>
  2025-06-04 21:36   ` Ferry Toth
  2 siblings, 0 replies; 7+ messages in thread
From: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 @ 2025-05-30 22:41 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs


[-- Attachment #1.1.1: Type: text/plain, Size: 1097 bytes --]

On 5/29/25 20:27, Qu Wenruo wrote:
>
>
> 在 2025/5/30 09:22, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 写道:
>> BTRFS-FILESYSTEM(8) says "defragmenting with  Linux kernel versions < 
>> 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 
>> 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data 
>> (for example files copied with cp --reflink, snapshots or 
>> de-duplicated data)." Why does defragmenting not preserve reflinks 
>> and why was it removed?
>>
>
> Defrag means to re-dirty the data, and write them back again, which 
> will cause COW.
> And by nature this breaks reflinked data extents.

But why did it previusly not break reflinks?

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 Improve your wifi reception for free 
<https://www.youtube.com/watch?v=LY8Wi7XRXCA>Home alone any% world 
<https://www.youtube.com/watch?v=IMstFIKZLpI>record set by 
𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 
<https://www.speedrun.com/home_alone_nes/runs/zpkq978y> This email does 
not constitute a legally binding contract

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 669 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
       [not found]   ` <3eabd123-e2a8-4554-b57b-0c84b713cd10@velocifyer.com>
@ 2025-05-30 22:53     ` Qu Wenruo
  0 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2025-05-30 22:53 UTC (permalink / raw)
  To: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣,
	linux-btrfs



在 2025/5/31 08:09, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 写道:
> On 5/29/25 20:27, Qu Wenruo wrote:
>>
>>
>> 在 2025/5/30 09:22, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 写道:
>>> BTRFS-FILESYSTEM(8) says "defragmenting with  Linux kernel versions < 
>>> 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 
>>> 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data 
>>> (for example files copied with cp --reflink, snapshots or de- 
>>> duplicated data)." Why does defragmenting not preserve reflinks and 
>>> why was it removed?
>>>
>>
>> Defrag means to re-dirty the data, and write them back again, which 
>> will cause COW.
>> And by nature this breaks reflinked data extents.
> 
> But why did it not break reflinks previusly?

It looks like it's technical difficulties.

The commit is 8101c8dbf624 ("Btrfs: disable snapshot aware defrag for now").

I do not have all the details, but at least a quick glance already shows 
that the old detection is not taking reflink into consideration.
It only considers snapshot, but reflink can happen within a single 
subvolume, or between subvolumes (not snapshot).

So the old method is not reliable in the first place.

Thanks,
Qu



> 
> -- 
> George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 Improve your wifi reception for free <https:// 
> www.youtube.com/watch?v=LY8Wi7XRXCA>Home alone any% world <https:// 
> www.youtube.com/watch?v=IMstFIKZLpI>record set by 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 <https:// 
> www.speedrun.com/home_alone_nes/runs/zpkq978y> This email does not 
> constitute a legally binding contract


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
  2025-05-30  0:27 ` Qu Wenruo
  2025-05-30 22:41   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
       [not found]   ` <3eabd123-e2a8-4554-b57b-0c84b713cd10@velocifyer.com>
@ 2025-06-04 21:36   ` Ferry Toth
  2025-06-04 21:54     ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
  2 siblings, 1 reply; 7+ messages in thread
From: Ferry Toth @ 2025-06-04 21:36 UTC (permalink / raw)
  To: Qu Wenruo,
	𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣,
	linux-btrfs

Op 30-05-2025 om 02:27 schreef Qu Wenruo:
> 
> 
> 在 2025/5/30 09:22, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 写道:
>> BTRFS-FILESYSTEM(8) says "defragmenting  with  Linux kernel versions < 
>> 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 
>> 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data 
>> (for example files copied with cp --reflink, snapshots or de- 
>> duplicated data)." Why does defragmenting not preserve reflinks and 
>> why was it removed?
>>
> 
> Defrag means to re-dirty the data, and write them back again, which will 
> cause COW.

That sounds like an implementation choice.

> And by nature this breaks reflinked data extents.

With a different implementation this would not by nature be the case.

Actually this makes defrag a very dangerous operation on disks with many 
snapshots (> 20). When you would defrag each snapshot suddenly your 5% 
full disk would be 100%.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
  2025-06-04 21:36   ` Ferry Toth
@ 2025-06-04 21:54     ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
  2025-06-05  8:17       ` Christopher Snowhill
  0 siblings, 1 reply; 7+ messages in thread
From: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 @ 2025-06-04 21:54 UTC (permalink / raw)
  To: Ferry Toth, Qu Wenruo, linux-btrfs

On 6/4/25 17:36, Ferry Toth wrote:
> Actually this makes defrag a very dangerous operation on disks with 
> many snapshots (> 20). When you would defrag each snapshot suddenly 
> your 5% full disk would be 100%.

This actualy happend to me once because i forgot i had snapshots.

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why does defragmenting break reflinks?
  2025-06-04 21:54     ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
@ 2025-06-05  8:17       ` Christopher Snowhill
  0 siblings, 0 replies; 7+ messages in thread
From: Christopher Snowhill @ 2025-06-05  8:17 UTC (permalink / raw)
  To: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣,
	Ferry Toth, Qu Wenruo, linux-btrfs

On Wed Jun 4, 2025 at 2:54 PM PDT, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 wrote:
> On 6/4/25 17:36, Ferry Toth wrote:
>> Actually this makes defrag a very dangerous operation on disks with 
>> many snapshots (> 20). When you would defrag each snapshot suddenly 
>> your 5% full disk would be 100%.
>
> This actualy happend to me once because i forgot i had snapshots.

Greater than 20 is a lot of snapshots? I guess I should stop using
things like Snapper on my systems, then. It *defaults* to hourly
snapshots of every subvolume you activate it on, pruned to the last 24
hours, so that's 24 alone. Then it keeps midnight for every day going
back several weeks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-05  8:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 23:52 Why does defragmenting break reflinks? 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-05-30  0:27 ` Qu Wenruo
2025-05-30 22:41   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
     [not found]   ` <3eabd123-e2a8-4554-b57b-0c84b713cd10@velocifyer.com>
2025-05-30 22:53     ` Qu Wenruo
2025-06-04 21:36   ` Ferry Toth
2025-06-04 21:54     ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-06-05  8:17       ` Christopher Snowhill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox