Skip to contentSkip to conversation

Mixed inline and regular extents caused by btrfs/062

DISCUSSION Qu Wenruo 3 participants 5 messages Aug 10, 2021 – Aug 23, 2021 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

Hi,

Although I understand current kernel can handle mixed inline extent with regular extent without problem, but the idea of mixing them is still making me quite unease.

Thus I still go testing with modify btrfs-progs to detect such problem, and find out btrfs/062 can cause such mixed extents.

Since it's not really causing any on-disk data corruption, but just an inconsistent behavior, I'm wondering do we really need to fix it. (This is also the only reason why subpage has disabled inline extent creation completely, just to prevent such problem).

Any idea on whether we should "fix" the behavior?

Thanks,
Qu

#1 lore raw
Quoted 9 lines · Qu Wenruo

Hi,

Although I understand current kernel can handle mixed inline extent with regular extent without problem, but the idea of mixing them is still making me quite unease.

Thus I still go testing with modify btrfs-progs to detect such problem, and find out btrfs/062 can cause such mixed extents.

Quoted 6 lines

Since it's not really causing any on-disk data corruption, but just an inconsistent behavior, I'm wondering do we really need to fix it. (This is also the only reason why subpage has disabled inline extent creation completely, just to prevent such problem).

Any idea on whether we should "fix" the behavior?

What do you mean by mixed inline and regular extents? AFAICS inline extents are created when you write at the beginning of the file and the size of the write is less than the inline extent threshold? All subsequent writes are going to be regular extents.

Quoted 4 lines

Thanks,
Qu

author
#2 lore raw
Quoted 12 lines · Nikolay Borisov
Quoted 9 lines · Qu Wenruo

Hi,

Although I understand current kernel can handle mixed inline extent with regular extent without problem, but the idea of mixing them is still making me quite unease.

Thus I still go testing with modify btrfs-progs to detect such problem, and find out btrfs/062 can cause such mixed extents.

Quoted 8 lines
Quoted 6 lines

Since it's not really causing any on-disk data corruption, but just an inconsistent behavior, I'm wondering do we really need to fix it. (This is also the only reason why subpage has disabled inline extent creation completely, just to prevent such problem).

Any idea on whether we should "fix" the behavior?

What do you mean by mixed inline and regular extents?

I mean, one inode has both inlined extent and regular extent.

There is an old btrfs-progs patch to detect such problems:

https://patchwork.kernel.org/project/linux-btrfs/patch/[email protected]/

Quoted 4 lines

AFAICS inline
extents are created when you write at the beginning of the file and the size of the write is less than the inline extent threshold? All subsequent writes are going to be regular extents.

But with above patch, the following test cases can cause btrfs-check to report such mixed inline and regular extents:

btrfs/004
btrfs/192
btrfs/195
btrfs/205
generic/269

(Haven't yet to check the reproducibility)

Currently it won't hurt anyone, but I still don't think the mixed behavior is expected.

Thanks,
Qu

Quoted 5 lines
Quoted 5 lines

Thanks,
Qu

author
#3 lore raw
Quoted 40 lines · Qu Wenruo
Quoted 12 lines · Nikolay Borisov
Quoted 9 lines · Qu Wenruo

Hi,

Although I understand current kernel can handle mixed inline extent with regular extent without problem, but the idea of mixing them is still making me quite unease.

Thus I still go testing with modify btrfs-progs to detect such problem, and find out btrfs/062 can cause such mixed extents.

Quoted 8 lines
Quoted 6 lines

Since it's not really causing any on-disk data corruption, but just an inconsistent behavior, I'm wondering do we really need to fix it. (This is also the only reason why subpage has disabled inline extent creation completely, just to prevent such problem).

Any idea on whether we should "fix" the behavior?

What do you mean by mixed inline and regular extents?

I mean, one inode has both inlined extent and regular extent.

There is an old btrfs-progs patch to detect such problems:

https://patchwork.kernel.org/project/linux-btrfs/patch/[email protected]/

Quoted 4 lines

AFAICS inline
extents are created when you write at the beginning of the file and the size of the write is less than the inline extent threshold? All subsequent writes are going to be regular extents.

But with above patch, the following test cases can cause btrfs-check to report such mixed inline and regular extents:

Quoted 6 lines

btrfs/004
btrfs/192
btrfs/195

btrfs/205
generic/269

Above two tests are almost 100% reproducible of such mixed extents, especially btrfs/205 is pretty short tests.

I guess a fix would be easier to understand the problem.

Thanks,
Qu

Quoted 13 lines

(Haven't yet to check the reproducibility)

Currently it won't hurt anyone, but I still don't think the mixed behavior is expected.

Thanks,
Qu

Quoted 5 lines
Quoted 5 lines

Thanks,
Qu

#4 lore raw
In reply to Qu Wenruo
Quoted 10 lines · Qu Wenruo

Hi,

Although I understand current kernel can handle mixed inline extent with regular extent without problem, but the idea of mixing them is still making me quite unease.

Thus I still go testing with modify btrfs-progs to detect such problem, and find out btrfs/062 can cause such mixed extents.

Quoted 6 lines

Since it's not really causing any on-disk data corruption, but just an inconsistent behavior, I'm wondering do we really need to fix it. (This is also the only reason why subpage has disabled inline extent creation completely, just to prevent such problem).

Any idea on whether we should "fix" the behavior?

We had a discussion about this not long ago:

https://lore.kernel.org/linux-btrfs/[email protected]/

And yes, as you found out, it's quite easy to trigger scenarios of an inline extent followed by non-inline extents.
Both fsstress and fsx can trigger it often, plus I remember writing test cases that explicitly exercise those scenarios to verify that either extent cloning works as expected or send/receive, like in btrfs/205 for example.

Yes, there's the case triggered by fallocate, but also the case triggered by a compressed inline extent, representing PAGE_SIZE bytes of data, followed by other extents. This case was discussed in the past too:

https://lore.kernel.org/linux-btrfs/[email protected]/

Currently this one isn't triggered anymore, but that's due to a temporary regression in 5.14-rcs reported yesterday by Zygo, that results in never having compressed inline extents.

I still don't consider it a problem. The code paths have been exercised for years, reads, writes, cloning, send/receive, etc, all work as expected as far as I know.
Having the inline extent always brings a performance benefit when reading its data, so I don't see any advantage in changing the behaviour - doesn't make the code faster, shorter or easy to read/maintain.

Thanks.

Quoted 3 lines

Thanks,
Qu

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”