From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Wang Jianjian <wangjianjian3@huawei.com>,
linux-nilfs <linux-nilfs@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Zheng Zheng <fengaojigui88@gmail.com>,
Joshua Crofts <joshua.crofts1@gmail.com>
Subject: Re: [PATCH 0/8] nilfs2: support GC error rollback and avoid infinite retry hangs
Date: Fri, 27 Nov 2026 10:13:23 -0800 [thread overview]
Message-ID: <5e9c9b70801f18beacdf30f9bfe78741cb1ce129.camel@dubeyko.com> (raw)
In-Reply-To: <20261127044231.37630-1-konishi.ryusuke@gmail.com>
On Fri, 2026-11-27 at 13:40 +0900, Ryusuke Konishi wrote:
> Hi Viacheslav,
>
> Please apply this series for the next cycle.
>
> This patch series rectifies an early design flaw in the garbage
> collection mechanism itself and fundamentally resolves the task hang
> issue seen in the GC ioctl (NILFS_IOCTL_CLEAN_SEGMENTS). To make GC
> safely abortable upon errors, this series strengthens the error-
> recovery
> and rollback logic for metadata updated during GC, specifically
> segment
> usage information (sufile) and virtual block address mappings (DAT).
>
> Historically, NILFS2 GC was designed around a point of no return:
> once
> the log writer started, it looped until a full-format log (including
> a
> checkpoint and a super root) was successfully written out. Because
> GC
> runs exclusively while holding ns_segctor_sem for writing, any
> persistent error during GC blocked the log writer thread and write
> operations indefinitely, causing filesystem hangs.
>
> An initial fix by Joshua Crofts (commit ce5a5ad1a833) took the right
> direction by introducing an escape path when the filesystem
> transitioned to read-only mode (-EROFS). However, two issues
> remained:
>
> 1. Cached GC inodes were leaked when GC exited on error, which Wang
> Jianjian addressed in the first patch of this series.
> 2. Persistent errors that do not trigger read-only remounts (such as
> -EIO or -ENOSPC) still caused infinite retry loops, as further
> reported by Zheng Zheng.
>
> Whenever GC aborts mid-way, however, an underlying issue arises:
> bailing out of the GC loop leaves irreversible inconsistencies in
> on-disk and in-memory metadata. While this was previously masked
> because the escape path was only taken during emergency read-only
> degradation, expanding error exits to general errors exposes this
> problem, breaking subsequent GC runs and causing userland tools such
> as "lssu -l" to fail permanently.
>
> To build upon commit ce5a5ad1a833 and make error exits safe, this
> series implements dedicated undo mechanisms for each metadata change
> performed during GC before allowing nilfs_clean_segments() to bail
> out on general errors:
>
> - Patch 1 (by Wang Jianjian) fixes the GC inode leak on error paths.
> - Patch 2 makes physical block location updates in the DAT for
> GC-relocated blocks (other than DAT blocks themselves) reversible
> by
> restoring them from the shadow mapping on error.
> - Patch 3 makes the removal of GC target segment usage entries in
> sufile reversible by saving and restoring them on abort.
> - Patch 4 fixes an issue where stale nilfs_redirected flags remain on
> primary DAT buffers when GC is aborted.
> - Patches 5-6 make the deletion of obsolete virtual block entries
> from
> the DAT during GC reversible by saving and restoring them on abort.
> - Patch 7 defers this virtual block deletion to a safe stage so that
> the
> freed entries cannot be reallocated while GC is in progress, which
> is
> required now that GC can abort mid-way.
> - Patch 8 updates nilfs_clean_segments() to bail out immediately on
> errors, retaining only a minimal bounded retry loop for transient
> cases.
>
> Thanks,
> Ryusuke Konishi
>
>
> Ryusuke Konishi (7):
> nilfs2: cancel the relocation of GC-targeted blocks if log writing
> fails
> nilfs2: restore segment usage from the save buffer when aborting GC
> nilfs2: drop redirected buffer flag from DAT when clearing shadow
> map
> nilfs2: save DAT entry blocks to shadow mapping before freeing
> nilfs2: restore removed DAT entries when aborting GC
> nilfs2: free virtual block numbers just before collecting DAT
> changes
> nilfs2: avoid infinite retry loop on GC failure
>
> Wang Jianjian (1):
> nilfs2: fix leak of gc inodes on error
>
> fs/nilfs2/alloc.c | 14 +++-
> fs/nilfs2/alloc.h | 3 +-
> fs/nilfs2/bmap.h | 23 ++++++
> fs/nilfs2/btree.c | 8 ++
> fs/nilfs2/dat.c | 181
> +++++++++++++++++++++++++++++++++++++++++++-
> fs/nilfs2/dat.h | 5 +-
> fs/nilfs2/direct.c | 1 +
> fs/nilfs2/ioctl.c | 36 +--------
> fs/nilfs2/mdt.c | 41 ++++++++--
> fs/nilfs2/segment.c | 108 +++++++++++++++++++++++---
> fs/nilfs2/segment.h | 7 ++
> fs/nilfs2/sufile.c | 27 ++++---
> fs/nilfs2/sufile.h | 37 ++++-----
> 13 files changed, 404 insertions(+), 87 deletions(-)
Applied.
Thanks,
Slava.
prev parent reply other threads:[~2026-11-27 18:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 4:40 Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 1/8] nilfs2: fix leak of gc inodes on error Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 2/8] nilfs2: cancel the relocation of GC-targeted blocks if log writing fails Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 3/8] nilfs2: restore segment usage from the save buffer when aborting GC Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 4/8] nilfs2: drop redirected buffer flag from DAT when clearing shadow map Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 5/8] nilfs2: save DAT entry blocks to shadow mapping before freeing Ryusuke Konishi
2026-11-27 4:40 ` [PATCH 6/8] nilfs2: restore removed DAT entries when aborting GC Ryusuke Konishi
2026-11-27 4:41 ` [PATCH 7/8] nilfs2: free virtual block numbers just before collecting DAT changes Ryusuke Konishi
2026-11-27 4:41 ` [PATCH 8/8] nilfs2: avoid infinite retry loop on GC failure Ryusuke Konishi
2026-11-27 18:13 ` Viacheslav Dubeyko [this message]
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=5e9c9b70801f18beacdf30f9bfe78741cb1ce129.camel@dubeyko.com \
--to=slava@dubeyko.com \
--cc=fengaojigui88@gmail.com \
--cc=joshua.crofts1@gmail.com \
--cc=konishi.ryusuke@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=wangjianjian3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®