From: Luca Stefani via B4 Relay <devnull+luca.stefani.ge1.gmail.com@kernel.org>
To: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
Luca Stefani <luca.stefani.ge1@gmail.com>
Cc: Robbie Ko <robbieko@synology.com>,
Filipe Manana <fdmanana@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhiwei Liang <zhiwei.liang@zliang.me>, Qu Wenruo <wqu@suse.com>
Subject: [PATCH 2/2] btrfs: don't report failure when trim is interrupted
Date: Wed, 28 Oct 2026 18:55:50 +0100 [thread overview]
Message-ID: <20261028-b4-btrfs-fitrim-interruption-v1-2-bf5c53738b3a@gmail.com> (raw)
In-Reply-To: <20261028-b4-btrfs-fitrim-interruption-v1-0-bf5c53738b3a@gmail.com>
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Treat cancellation as a successful partial trim as ext4 and XFS do.
Reported-by: Zhiwei Liang <zhiwei.liang@zliang.me>
Closes: https://lore.kernel.org/20261028-btrfs-fitrim-freezer-v1-1-0ad1d58aa94d@zliang.me/
Suggested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
---
fs/btrfs/extent-tree.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 242db255cf1c..90e581c29609 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6926,7 +6926,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
bg_failed, ERR_PTR(bg_ret));
if (ret == -ERESTARTSYS || ret == -EINTR)
- return ret;
+ goto out;
ret = btrfs_trim_free_extents(fs_info, &group_trimmed, &dev_failed, &dev_ret);
trimmed += group_trimmed;
@@ -6935,9 +6935,8 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
btrfs_warn(fs_info,
"failed to trim %llu device(s), first error %pe",
dev_failed, ERR_PTR(dev_ret));
+out:
range->len = trimmed;
- if (ret == -ERESTARTSYS || ret == -EINTR)
- return ret;
if (bg_ret)
return bg_ret;
return dev_ret;
--
2.56.0
next prev parent reply other threads:[~2026-10-28 17:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 17:55 [PATCH 0/2] btrfs: don't expose ERESTARTSYS to userspace Luca Stefani via B4 Relay
2026-10-28 17:55 ` [PATCH 1/2] btrfs: account partially completed discards Luca Stefani via B4 Relay
2026-10-28 21:02 ` Qu Wenruo
2026-10-28 17:55 ` Luca Stefani via B4 Relay [this message]
2026-10-28 21:06 ` [PATCH 2/2] btrfs: don't report failure when trim is interrupted Qu Wenruo
2026-10-28 20:13 ` [PATCH 0/2] btrfs: don't expose ERESTARTSYS to userspace zhiwei.liang
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=20261028-b4-btrfs-fitrim-interruption-v1-2-bf5c53738b3a@gmail.com \
--to=devnull+luca.stefani.ge1.gmail.com@kernel.org \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.stefani.ge1@gmail.com \
--cc=mason@kernel.org \
--cc=robbieko@synology.com \
--cc=wqu@suse.com \
--cc=zhiwei.liang@zliang.me \
/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®