From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 3/5] btrfs: abort transaction on errors in btrfs_free_chunk()
Date: Wed, 19 Jun 2024 19:09:11 +0200 [thread overview]
Message-ID: <72fac19a7ad1c8fe469a05a721c6bf1b55130c19.1718816796.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1718816796.git.dsterba@suse.com>
The errors during removing a chunk item are fatal, we expect to have a
matching item in the chunk map from which the chunk_offset is taken.
Handle that by transaction abort.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/volumes.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ac6056072ee8..fcedc43ef291 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2989,16 +2989,19 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
if (ret < 0)
goto out;
else if (ret > 0) { /* Logic error or corruption */
- btrfs_handle_fs_error(fs_info, -ENOENT,
- "Failed lookup while freeing chunk.");
- ret = -ENOENT;
+ btrfs_err(fs_info, "failed to lookup chunk %llu when freeing",
+ chunk_offset);
+ btrfs_abort_transaction(trans, -ENOENT);
+ ret = -EUCLEAN;
goto out;
}
ret = btrfs_del_item(trans, root, path);
- if (ret < 0)
- btrfs_handle_fs_error(fs_info, ret,
- "Failed to delete chunk item.");
+ if (ret < 0) {
+ btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset);
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
out:
btrfs_free_path(path);
return ret;
--
2.45.0
next prev parent reply other threads:[~2024-06-19 17:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 17:08 [PATCH 0/5] Error handling fixes David Sterba
2024-06-19 17:08 ` [PATCH 1/5] btrfs: abort transaction if we don't find extref in btrfs_del_inode_extref() David Sterba
2024-06-19 17:09 ` [PATCH 2/5] btrfs: only print error message when checking item size in print_extent_item() David Sterba
2024-06-19 17:09 ` David Sterba [this message]
2024-06-19 17:09 ` [PATCH 4/5] btrfs: qgroup: preallocate memory before adding a relation David Sterba
2024-06-20 1:59 ` Qu Wenruo
2024-06-20 17:40 ` David Sterba
2024-06-20 17:46 ` [PATCH v2] " David Sterba
2024-06-20 22:22 ` Qu Wenruo
2024-06-19 17:09 ` [PATCH 5/5] btrfs: qgroup: warn about inconsistent qgroups when relation update fails David Sterba
2024-06-20 21:28 ` Boris Burkov
2024-06-20 22:34 ` Qu Wenruo
2024-06-19 23:21 ` [PATCH 0/5] Error handling fixes Qu Wenruo
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=72fac19a7ad1c8fe469a05a721c6bf1b55130c19.1718816796.git.dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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