Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Julian Sun" <sunjunchao@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v3 1/3] ext4: fix a race between partial writeback and truncation
Date: Mon, 16 Nov 2026 07:02:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-216366@kernel.org> (raw)
In-Reply-To: <20261116064404.189911-2-sunjunchao@bytedance.com>

> After a retryable mapping error, mpage_submit_partial_folio() submits the
> mapped buffers, advances start_pos into the folio and unlocks it.
> mpage_release_unused_pages() subsequently looks up the remaining range
> and skips the partial folio by comparing its position with start_pos.
> 
> Once unlocked, the folio can be truncated and replaced by smaller folios.
> A replacement at or beyond start_pos passes the position check even
> though writeback does not own its lock. Cleanup can then hit the locked
> folio assertion or unlock a folio held by another task.
> 
> The race was reproduced reliably using local code instrumentation to
> widen the race window, triggering BUG_ON(!folio_test_locked(folio)) in
> mpage_release_unused_pages().
> The issue could no longer be reproduced after applying this patch.
> 
> On this retryable error path, cleanup only needs to unlock unused folios.
> The partial folio has already been unlocked. Its buffers still needing
> mapping remain dirty, and ext4_bio_write_folio() redirties the folio for a
> later writeback attempt. The existing code therefore intends to leave
> it alone. Any new folios inserted into the same range were not locked by
> this writeback operation and must also be excluded. The following unused
> folios still need their locks released.
> 
> Record the end of the partially submitted folio before unlocking it,
> and start cleanup at that offset.
> 
> Fixes: ded2d726a304 ("ext4: fix stale data if it bail out of the extents mapping loop")
> Cc: stable@vger.kernel.org
> Signed-off-by: Julian Sun <sunjunchao@bytedance.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116064404.189911-1-sunjunchao@bytedance.com?part=1


  reply	other threads:[~2026-11-16  7:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  6:44 [PATCH v3 0/3] ext4: fix buffered writeback error handling Julian Sun
2026-11-16  6:44 ` [PATCH v3 1/3] ext4: fix a race between partial writeback and truncation Julian Sun
2026-11-16  7:02   ` sashiko-bot [this message]
2026-11-16  6:47 ` [PATCH v3 2/3] ext4: submit mapped buffers after fatal mapping errors Julian Sun
2026-11-16  7:24   ` sashiko-bot
2026-11-16  6:47 ` [PATCH v3 3/3] ext4: use atomic bitops for io_end flags Julian Sun
2026-11-16  6:59   ` sashiko-bot

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=sashiko-outbox-216366@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sunjunchao@bytedance.com \
    --cc=tytso@mit.edu \
    /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