mbox series

[v2,0/2] btrfs: zoned: fix EXTENT_BUFFER_ZONED_ZEROOUT handling

Message ID cover.1711416290.git.naohiro.aota@wdc.com (mailing list archive)
Headers show
Series btrfs: zoned: fix EXTENT_BUFFER_ZONED_ZEROOUT handling | expand

Message

Naohiro Aota March 26, 2024, 5:39 a.m. UTC
Btrfs clears the content of an extent buffer marked as
EXTENT_BUFFER_ZONED_ZEROOUT before the bio submission. This mechanism is
introduced to prevent a write hole of an extent buffer, which is once
allocated, marked dirty, but turns out unnecessary and cleaned up within
one transaction operation.

Currently, btrfs_clear_buffer_dirty() marks the extent buffer as
EXTENT_BUFFER_ZONED_ZEROOUT, and skip the enteri function. If this call
happens while the buffer is under IO (with the WRITEBACK flag set, without
the DIRTY flag), we can add the ZEROOUT flag and clear the buffer's content
just before a bio submission. As a result, 1) it can lead to adding faulty
delayed reference item which leads to a FS corrupted (EUCLEAN) error, and
2) it writes out cleared tree node on disk

Fix them by skipping a non-dirty extent buffer. Also, the second patch adds
ASSERT and WARN to catch invalid EXTENT_BUFFER_ZONED_ZEROOUT state.

Naohiro Aota (2):
  btrfs: zoned: do not flag ZEROOUT on non-dirty extent bufffer
  btrfs: zoned: add ASSERT and WARN for EXTENT_BUFFER_ZONED_ZEROOUT
    handling

 fs/btrfs/extent-tree.c | 8 ++++++++
 fs/btrfs/extent_io.c   | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn March 26, 2024, 4:50 p.m. UTC | #1
On 26.03.24 06:40, Naohiro Aota wrote:
> Btrfs clears the content of an extent buffer marked as
> EXTENT_BUFFER_ZONED_ZEROOUT before the bio submission. This mechanism is
> introduced to prevent a write hole of an extent buffer, which is once
> allocated, marked dirty, but turns out unnecessary and cleaned up within
> one transaction operation.
> 
> Currently, btrfs_clear_buffer_dirty() marks the extent buffer as
> EXTENT_BUFFER_ZONED_ZEROOUT, and skip the enteri function. If this call
> happens while the buffer is under IO (with the WRITEBACK flag set, without
> the DIRTY flag), we can add the ZEROOUT flag and clear the buffer's content
> just before a bio submission. As a result, 1) it can lead to adding faulty
> delayed reference item which leads to a FS corrupted (EUCLEAN) error, and
> 2) it writes out cleared tree node on disk
> 
> Fix them by skipping a non-dirty extent buffer. Also, the second patch adds
> ASSERT and WARN to catch invalid EXTENT_BUFFER_ZONED_ZEROOUT state.
> 
> Naohiro Aota (2):
>    btrfs: zoned: do not flag ZEROOUT on non-dirty extent bufffer
>    btrfs: zoned: add ASSERT and WARN for EXTENT_BUFFER_ZONED_ZEROOUT
>      handling
> 
>   fs/btrfs/extent-tree.c | 8 ++++++++
>   fs/btrfs/extent_io.c   | 3 ++-
>   2 files changed, 10 insertions(+), 1 deletion(-)
> 

Looks good, thanks

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

One minor nit, codespell flagged a typo, but I'm too blind to find it:

johannes@nuc:linux (review)$ b4 shazam 
cover.1711416290.git.naohiro.aota@wdc.com
Grabbing thread from 
lore.kernel.org/all/cover.1711416290.git.naohiro.aota@wdc.com/t.mbox.gz 
 

Checking for newer revisions
Grabbing search results from lore.kernel.org 

Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
   ✓ [PATCH v2 1/2] btrfs: zoned: do not flag ZEROOUT on non-dirty 
extent bufffer
   ✓ [PATCH v2 2/2] btrfs: zoned: add ASSERT and WARN for 
EXTENT_BUFFER_ZONED_ZEROOUT handling 

   ---
   ✓ Signed: DKIM/wdc.com
---
Total patches: 2
---
Applying: btrfs: zoned: do not flag ZEROOUT on non-dirty extent bufffer 

Applying: btrfs: zoned: add ASSERT and WARN for 
EXTENT_BUFFER_ZONED_ZEROOUT handling
/home/johannes/src/linux/.git/rebase-apply/final-commit:1: bufffer ==> 
buffer
David Sterba March 28, 2024, 7:49 p.m. UTC | #2
On Tue, Mar 26, 2024 at 04:50:46PM +0000, Johannes Thumshirn wrote:
> On 26.03.24 06:40, Naohiro Aota wrote:
> > Btrfs clears the content of an extent buffer marked as
> > EXTENT_BUFFER_ZONED_ZEROOUT before the bio submission. This mechanism is
> > introduced to prevent a write hole of an extent buffer, which is once
> > allocated, marked dirty, but turns out unnecessary and cleaned up within
> > one transaction operation.
> > 
> > Currently, btrfs_clear_buffer_dirty() marks the extent buffer as
> > EXTENT_BUFFER_ZONED_ZEROOUT, and skip the enteri function. If this call
                                              ^^^^^^

> One minor nit, codespell flagged a typo, but I'm too blind to find it:

There's the typo.