From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>,
Christoph Anton Mitterer <calestyo@scientia.org>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: btrfs thinks fs is full, though 11GB should be still free
Date: Sat, 6 Jan 2024 11:12:37 +0300 [thread overview]
Message-ID: <f7211b06-085d-445a-9934-ebaacf280821@gmail.com> (raw)
In-Reply-To: <b849c107-c3d5-4dae-a03f-c7575eee157b@gmx.com>
On 06.01.2024 08:40, Qu Wenruo wrote:
>
>
> On 2024/1/6 11:12, Christoph Anton Mitterer wrote:
>> On Fri, 2024-01-05 at 17:37 +1030, Qu Wenruo wrote:
>>> but pretty hard to find a
>>> good way to improve:
>>
>> I guess it would not be an alternative to do the work on truncate (i.e.
>> check whether a lot is wasted and if so, create a new extent with just
>> the right size), because that would need a full re-write of the
>> extent... or would it?
>
> I'm not sure if it's a valid idea to do all these on truncation.
> It would involve doing all the backref walk to determine if it's needed
> to do the COW.
>
>>
>> Also, a while ago in one of my mails I saw that:
>> $ cat affected-file > new-file
>> would also cause new-file to be affected... which I found pretty
>> strange.
>>
>> Any idea why that happens?
>
> Initially I thought that's impossible, until I tired it:
>
> mkfs.btrfs -f $dev1
> mount $dev1 $mnt
> xfs_io -f -c "pwrite 0 128m" $mnt/file
> sync
> truncate -s 4k $mnt/file
> sync
> cat $mnt/file > $mnt/new
> sync
>
> Then dump tree indeed show the new file is sharing the same large extent:
>
>
> item 6 key (257 INODE_ITEM 0) itemoff 15817 itemsize 160
> generation 7 transid 8 size 4096 nbytes 4096
> block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0
> sequence 32770 flags 0x0(none)
> item 7 key (257 INODE_REF 256) itemoff 15803 itemsize 14
> index 2 namelen 4 name: file
> item 8 key (257 EXTENT_DATA 0) itemoff 15750 itemsize 53
> generation 7 type 1 (regular)
> extent data disk byte 298844160 nr 134217728 <<<
> extent data offset 0 nr 4096 ram 134217728
> extent compression 0 (none)
> item 9 key (258 INODE_ITEM 0) itemoff 15590 itemsize 160
> generation 9 transid 9 size 4096 nbytes 4096
> block group 0 mode 100644 links 1 uid 0 gid 0 rdev 0
> sequence 1 flags 0x0(none)
> item 10 key (258 INODE_REF 256) itemoff 15577 itemsize 13
> index 3 namelen 3 name: new
> item 11 key (258 EXTENT_DATA 0) itemoff 15524 itemsize 53
> generation 7 type 1 (regular)
> extent data disk byte 298844160 nr 134217728 <<<
> extent data offset 0 nr 4096 ram 134217728
> extent compression 0 (none)
>
> My guess is bash is doing something weird thus making the whole cat +
> redirection into reflink.
>
It is not bash (which just opens file and dup's it). It is cat from GNU
coreutils which defaults to using copy_file_range
10393 openat(AT_FDCWD, "/mnt/file", O_RDONLY) = 3
10393 fstat(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
10393 fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
10393 uname({sysname="Linux", nodename="tw", ...}) = 0
10393 copy_file_range(3, NULL, 1, NULL, 9223372035781033984, 0) = 4096
10393 copy_file_range(3, NULL, 1, NULL, 9223372035781033984, 0) = 0
In case of btrfs this ends in btrfs_remap_file_range(). So it is more or
less self inflicted wound. May be btrfs should not reflink partial
extents in such cases.
> But at least dd works as expected by creating a new extent.
>
>>
>>
>>
>>> My previous guess is totally wrong, it has nothing to do with
>>> NODATACOW/PREALLOC flags at all.
>>>
>>> It's a defrag only problem.
>>
>> Sure, but I meant, if a file is NODATACOW and would be prealloced to a
>> large size and then truncated - would it also loose the extra space?
>
> That would be the same.
>
>>
>>
>> And do you think that other CoW fs would be affected, too? IIRC XFS is
>> also about to get CoW features... so may it's simply an IO pattern that
>> developers need to avoid with modern filesystems.
>
> Not sure, maybe XFS would do extra extent split to solve the problem.
>
> Thanks,
> Qu
>
>>
>>
>> Cheers,
>> Chris-
>>
>
next prev parent reply other threads:[~2024-01-06 8:12 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 20:26 btrfs thinks fs is full, though 11GB should be still free Christoph Anton Mitterer
2023-12-11 20:57 ` Qu Wenruo
2023-12-11 22:23 ` Christoph Anton Mitterer
2023-12-11 22:26 ` Christoph Anton Mitterer
2023-12-11 23:20 ` Qu Wenruo
2023-12-11 23:38 ` Christoph Anton Mitterer
2023-12-11 23:54 ` Qu Wenruo
2023-12-12 0:12 ` Christoph Anton Mitterer
2023-12-12 0:58 ` Qu Wenruo
2023-12-12 2:30 ` Qu Wenruo
2023-12-12 3:27 ` Christoph Anton Mitterer
2023-12-12 3:40 ` Christoph Anton Mitterer
2023-12-12 4:13 ` Qu Wenruo
2023-12-15 2:33 ` Chris Murphy
2023-12-15 3:12 ` Qu Wenruo
2023-12-18 16:24 ` Christoph Anton Mitterer
2023-12-18 19:18 ` Goffredo Baroncelli
2023-12-18 20:04 ` Goffredo Baroncelli
2023-12-18 22:38 ` Christoph Anton Mitterer
2023-12-19 8:22 ` Andrei Borzenkov
2023-12-19 19:09 ` Goffredo Baroncelli
2023-12-21 13:53 ` Christoph Anton Mitterer
2023-12-21 18:03 ` Goffredo Baroncelli
2023-12-21 22:06 ` Christoph Anton Mitterer
2023-12-21 13:46 ` Christoph Anton Mitterer
2023-12-21 20:41 ` Qu Wenruo
2023-12-21 22:15 ` Christoph Anton Mitterer
2023-12-21 22:41 ` Qu Wenruo
2023-12-21 22:54 ` Christoph Anton Mitterer
2023-12-22 0:53 ` Qu Wenruo
2023-12-22 0:56 ` Christoph Anton Mitterer
2023-12-22 1:13 ` Qu Wenruo
2023-12-22 1:23 ` Christoph Anton Mitterer
2024-01-05 3:30 ` Christoph Anton Mitterer
2024-01-05 7:07 ` Qu Wenruo
2024-01-06 0:42 ` Christoph Anton Mitterer
2024-01-06 5:40 ` Qu Wenruo
2024-01-06 8:12 ` Andrei Borzenkov [this message]
2024-12-14 19:09 ` Christoph Anton Mitterer
2023-12-18 19:54 ` Qu Wenruo
2023-12-18 22:30 ` Christoph Anton Mitterer
2023-12-13 1:49 ` Remi Gauvin
2023-12-13 8:29 ` Andrea Gelmini
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=f7211b06-085d-445a-9934-ebaacf280821@gmail.com \
--to=arvidjaar@gmail.com \
--cc=calestyo@scientia.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.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.