From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH 7/7] Btrfs: kill BUG_ON()'s in btrfs_mark_extent_written
Date: Fri, 2 Sep 2016 15:40:06 -0400 [thread overview]
Message-ID: <1472845206-22870-8-git-send-email-jbacik@fb.com> (raw)
In-Reply-To: <1472845206-22870-1-git-send-email-jbacik@fb.com>
No reason to bug on in here, fs corruption could easily cause these things to
happen.
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
fs/btrfs/file.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f060b08..85bf035 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1110,13 +1110,25 @@ again:
leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
- BUG_ON(key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY);
+ if (key.objectid != ino ||
+ key.type != BTRFS_EXTENT_DATA_KEY) {
+ ret = -EINVAL;
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
fi = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_file_extent_item);
- BUG_ON(btrfs_file_extent_type(leaf, fi) !=
- BTRFS_FILE_EXTENT_PREALLOC);
+ if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_PREALLOC) {
+ ret = -EINVAL;
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi);
- BUG_ON(key.offset > start || extent_end < end);
+ if (key.offset > start || extent_end < end) {
+ ret = -EINVAL;
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
@@ -1213,12 +1225,19 @@ again:
ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
root->root_key.objectid,
ino, orig_offset);
- BUG_ON(ret); /* -ENOMEM */
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
if (split == start) {
key.offset = start;
} else {
- BUG_ON(start != key.offset);
+ if (start != key.offset) {
+ ret = -EINVAL;
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
path->slots[0]--;
extent_end = end;
}
@@ -1240,7 +1259,10 @@ again:
ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
0, root->root_key.objectid,
ino, orig_offset);
- BUG_ON(ret); /* -ENOMEM */
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
}
other_start = 0;
other_end = start;
@@ -1257,7 +1279,10 @@ again:
ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
0, root->root_key.objectid,
ino, orig_offset);
- BUG_ON(ret); /* -ENOMEM */
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
}
if (del_nr == 0) {
fi = btrfs_item_ptr(leaf, path->slots[0],
--
2.7.4
next prev parent reply other threads:[~2016-09-02 19:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 19:39 [PATCH 0/7] Kill the btree inode Josef Bacik
2016-09-02 19:40 ` [PATCH 1/7] Btrfs: replace tree->mapping with tree->private_data Josef Bacik
2016-09-02 19:40 ` [PATCH 2/7] btrfs: remove inode argument from repair_io_failure Josef Bacik
2016-09-02 19:40 ` [PATCH 3/7] Btrfs: add a flags field to btrfs_fs_info Josef Bacik
2016-09-08 17:01 ` David Sterba
2016-09-02 19:40 ` [PATCH 4/7] Btrfs: kill the start argument to read_extent_buffer_pages Josef Bacik
2016-09-08 17:01 ` David Sterba
2016-09-02 19:40 ` [PATCH 5/7] Btrfs: don't pass the inode through clean_io_failure Josef Bacik
2016-09-02 19:40 ` [PATCH 6/7] Btrfs: kill the btree_inode Josef Bacik
2016-09-08 5:17 ` Chandan Rajendra
2016-09-08 14:12 ` Josef Bacik
2016-09-09 17:40 ` [PATCH 6/7][V2] " Josef Bacik
2016-09-02 19:40 ` Josef Bacik [this message]
2016-09-08 17:07 ` [PATCH 7/7] Btrfs: kill BUG_ON()'s in btrfs_mark_extent_written David Sterba
2016-09-05 16:31 ` [PATCH 0/7] Kill the btree inode David Sterba
2016-09-06 13:03 ` Josef Bacik
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=1472845206-22870-8-git-send-email-jbacik@fb.com \
--to=jbacik@fb.com \
--cc=kernel-team@fb.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;
as well as URLs for NNTP newsgroup(s).