Skip to contentSkip to conversation

btrfs: document where we use BUG_ON instead of error handling

PATCH New Mark Fasheh 1 participant 1 message Sep 3, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 btrfs: document where we use BUG_ON instead of error handling

Document those places in the btrfs code which are BUGing on non-fatal error conditions that should be handled by proper error paths. This makes it easier to distinguish between what needs fixing versus which BUG_ON's we might want to keep (to trap code bugs, unexpected inconsistencies, etc).

Do this with a trivial macro, 'btrfs_fixable_bug_on' which just defines to BUG_ON(). The rest of this patch is basically a manual search and replace for all the places where it was obvious to me we simply needed better handling of errors.

No code functionality has changed.

---
 fs/btrfs/btrfs_inode.h |    6 ++
 fs/btrfs/compression.c |   20 +++---
 fs/btrfs/ctree.c       |   24 ++++----
 fs/btrfs/delayed-ref.c |   16 +++---
 fs/btrfs/disk-io.c     |   20 +++---
 fs/btrfs/extent-tree.c |  156 ++++++++++++++++++++++++------------------------
 fs/btrfs/file-item.c   |   14 ++--
 fs/btrfs/file.c        |   24 ++++----
 fs/btrfs/inode.c       |  122 +++++++++++++++++++-------------------
 fs/btrfs/ioctl.c       |   30 +++++-----
 fs/btrfs/relocation.c  |   54 ++++++++--------
 fs/btrfs/transaction.c |   48 +++++++-------
 fs/btrfs/tree-log.c    |   84 +++++++++++++-------------
 fs/btrfs/volumes.c     |   64 ++++++++++----------
 fs/btrfs/xattr.c       |    6 +-
 15 files changed, 347 insertions(+), 341 deletions(-)
fs/btrfs/btrfs_inode.h +6 -0
index 6ad63f1..8a6a2d9 100644
@@ -173,4 +173,10 @@ static inline void btrfs_i_size_write(struct inode *inode, u64 size)
 	BTRFS_I(inode)->disk_i_size = size;
 }
 
+/*
+ * This macro documents all the places in the btrfs code where we're failing
+ * to correctly handle a recoverable error condition.
+ */
+#define btrfs_fixable_bug_on(_err) BUG_ON(_err)
+
 #endif
fs/btrfs/compression.c +10 -10
index 396039b..b06e1bf 100644
@@ -394,13 +394,13 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
 			 */
 			atomic_inc(&cb->pending_bios);
 			ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			bio_put(bio);
 
@@ -420,13 +420,13 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
 	bio_get(bio);
 
 	ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	bio_put(bio);
 	return 0;
@@ -646,7 +646,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 			bio_get(comp_bio);
 
 			ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			/*
 			 * inc the count before we submit the bio so
@@ -665,7 +665,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 
 			ret = btrfs_map_bio(root, READ, comp_bio,
 					    mirror_num, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			bio_put(comp_bio);
 
@@ -681,13 +681,13 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 	bio_get(comp_bio);
 
 	ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM))
 		btrfs_lookup_bio_sums(root, inode, comp_bio, sums);
 
 	ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	bio_put(comp_bio);
 	return 0;
fs/btrfs/ctree.c +12 -12
index c3df14c..781b4ae 100644
@@ -309,7 +309,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 	if (btrfs_block_can_be_shared(root, buf)) {
 		ret = btrfs_lookup_extent_info(trans, root, buf->start,
 					       buf->len, &refs, &flags);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 		BUG_ON(refs == 0);
 	} else {
 		refs = 1;
@@ -329,14 +329,14 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 		     root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) &&
 		    !(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) {
 			ret = btrfs_inc_ref(trans, root, buf, 1);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			if (root->root_key.objectid ==
 			    BTRFS_TREE_RELOC_OBJECTID) {
 				ret = btrfs_dec_ref(trans, root, buf, 0);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 				ret = btrfs_inc_ref(trans, root, cow, 1);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 			}
 			new_flags |= BTRFS_BLOCK_FLAG_FULL_BACKREF;
 		} else {
@@ -346,14 +346,14 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 				ret = btrfs_inc_ref(trans, root, cow, 1);
 			else
 				ret = btrfs_inc_ref(trans, root, cow, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		}
 		if (new_flags != 0) {
 			ret = btrfs_set_disk_extent_flags(trans, root,
 							  buf->start,
 							  buf->len,
 							  new_flags, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		}
 	} else {
 		if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
@@ -362,9 +362,9 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 				ret = btrfs_inc_ref(trans, root, cow, 1);
 			else
 				ret = btrfs_inc_ref(trans, root, cow, 0);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			ret = btrfs_dec_ref(trans, root, buf, 1);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		}
 		clean_tree_block(trans, root, buf);
 		*last_ref = 1;
@@ -3094,7 +3094,7 @@ again:
 	}
 
 	ret = copy_for_split(trans, root, path, l, right, slot, mid, nritems);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	if (split == 2) {
 		BUG_ON(num_doubles != 0);
@@ -3307,7 +3307,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
 	ret = setup_items_for_insert(trans, root, path, new_key, &item_size,
 				     item_size, item_size +
 				     sizeof(struct btrfs_item), 1);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	leaf = path->nodes[0];
 	memcpy_extent_buffer(leaf,
@@ -3982,7 +3982,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 			btrfs_set_path_blocking(path);
 			clean_tree_block(trans, root, leaf);
 			ret = btrfs_del_leaf(trans, root, path, leaf);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		}
 	} else {
 		int used = leaf_space_used(leaf, 0, nritems);
@@ -4022,7 +4022,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 			if (btrfs_header_nritems(leaf) == 0) {
 				path->slots[1] = slot;
 				ret = btrfs_del_leaf(trans, root, path, leaf);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 				free_extent_buffer(leaf);
 			} else {
 				/* if we're still in the path, make sure
fs/btrfs/delayed-ref.c +8 -8
index e807b14..ee1cf82 100644
@@ -644,11 +644,11 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
 	 */
 	ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
 				   action, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes,
 				   parent, ref_root, level, action);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	spin_unlock(&delayed_refs->lock);
 	return 0;
 }
@@ -689,11 +689,11 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
 	 */
 	ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
 				   action, 1);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes,
 				   parent, ref_root, owner, offset, action);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	spin_unlock(&delayed_refs->lock);
 	return 0;
 }
@@ -718,7 +718,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,
 	ret = add_delayed_ref_head(trans, &head_ref->node, bytenr,
 				   num_bytes, BTRFS_UPDATE_DELAYED_HEAD,
 				   extent_op->is_data);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	spin_unlock(&delayed_refs->lock);
 	return 0;
@@ -801,18 +801,18 @@ int btrfs_update_delayed_ref(struct btrfs_trans_handle *trans,
 	ret = __btrfs_add_delayed_ref(trans, &head_ref->node, bytenr, num_bytes,
 				      (u64)-1, 0, 0, 0,
 				      BTRFS_UPDATE_DELAYED_HEAD, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = __btrfs_add_delayed_ref(trans, &ref->node, bytenr, num_bytes,
 				      parent, ref_root, ref_generation,
 				      owner_objectid, BTRFS_ADD_DELAYED_REF, 0);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = __btrfs_add_delayed_ref(trans, &old_ref->node, bytenr, num_bytes,
 				      orig_parent, orig_ref_root,
 				      orig_ref_generation, owner_objectid,
 				      BTRFS_DROP_DELAYED_REF, pin);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	spin_unlock(&delayed_refs->lock);
 	return 0;
 }
fs/btrfs/disk-io.c +10 -10
index 64f1008..b5440f5 100644
@@ -355,7 +355,7 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
 	eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
 	ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE,
 					     btrfs_header_generation(eb));
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	found_start = btrfs_header_bytenr(eb);
 	if (found_start != start) {
 		WARN_ON(1);
@@ -666,7 +666,7 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
 
 	ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info,
 					  bio, 1);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	if (!(rw & REQ_WRITE)) {
 		/*
@@ -974,7 +974,7 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
 				   &root->root_item, &root->root_key);
 	if (ret > 0)
 		return -ENOENT;
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	generation = btrfs_root_generation(&root->root_item);
 	blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
@@ -1501,7 +1501,7 @@ static int transaction_kthread(void *arg)
 		trans = btrfs_join_transaction(root, 1);
 		if (transid == trans->transid) {
 			ret = btrfs_commit_transaction(trans, root);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		} else {
 			btrfs_end_transaction(trans, root);
 		}
@@ -1954,20 +1954,20 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 						      blocksize,
 						      generation + 1);
 		ret = btrfs_recover_log_trees(log_tree_root);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 
 		if (sb->s_flags & MS_RDONLY) {
 			ret =  btrfs_commit_super(tree_root);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 		}
 	}
 
 	ret = btrfs_find_orphan_roots(tree_root);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	if (!(sb->s_flags & MS_RDONLY)) {
 		ret = btrfs_cleanup_fs_roots(fs_info);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 
 		ret = btrfs_recover_relocation(tree_root);
 		if (ret < 0) {
@@ -2402,12 +2402,12 @@ int btrfs_commit_super(struct btrfs_root *root)
 
 	trans = btrfs_join_transaction(root, 1);
 	ret = btrfs_commit_transaction(trans, root);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	/* run commit again to drop the original snapshot */
 	trans = btrfs_join_transaction(root, 1);
 	btrfs_commit_transaction(trans, root);
 	ret = btrfs_write_and_wait_transaction(NULL, root);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = write_ctree_super(NULL, root, 0);
 	return ret;
fs/btrfs/extent-tree.c +78 -78

589 lines not on this page · raw message

fs/btrfs/file-item.c +7 -7
index a562a25..0936d41 100644
@@ -58,7 +58,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
 				      sizeof(*item));
 	if (ret < 0)
 		goto out;
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	leaf = path->nodes[0];
 	item = btrfs_item_ptr(leaf, path->slots[0],
 			      struct btrfs_file_extent_item);
@@ -492,7 +492,7 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
 		u32 new_size = (bytenr - key->offset) >> blocksize_bits;
 		new_size *= csum_size;
 		ret = btrfs_truncate_item(trans, root, path, new_size, 1);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	} else if (key->offset >= bytenr && csum_end > end_byte &&
 		   end_byte > key->offset) {
 		/*
@@ -505,11 +505,11 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
 		new_size *= csum_size;
 
 		ret = btrfs_truncate_item(trans, root, path, new_size, 0);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 
 		key->offset = end_byte;
 		ret = btrfs_set_item_key_safe(trans, root, path, key);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	} else {
 		BUG();
 	}
@@ -571,7 +571,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
 		/* delete the entire item, it is inside our range */
 		if (key.offset >= bytenr && csum_end <= end_byte) {
 			ret = btrfs_del_item(trans, root, path);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			if (key.offset == bytenr)
 				break;
 		} else if (key.offset < bytenr && csum_end > end_byte) {
@@ -619,7 +619,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
 		} else {
 			ret = truncate_one_csum(trans, root, path,
 						&key, bytenr, len);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			if (key.offset < bytenr)
 				break;
 		}
@@ -753,7 +753,7 @@ again:
 			goto insert;
 
 		ret = btrfs_extend_item(trans, root, path, diff);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 		goto csum;
 	}
 
fs/btrfs/file.c +12 -12
index e354c33..0f32ed8 100644
@@ -221,7 +221,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
 			split->bdev = em->bdev;
 			split->flags = flags;
 			ret = add_extent_mapping(em_tree, split);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			free_extent_map(split);
 			split = split2;
 			split2 = NULL;
@@ -246,7 +246,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
 			}
 
 			ret = add_extent_mapping(em_tree, split);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			free_extent_map(split);
 			split = NULL;
 		}
@@ -404,7 +404,7 @@ next_slot:
 						root->root_key.objectid,
 						new_key.objectid,
 						start - extent_offset);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 				*hint_byte = disk_bytenr;
 			}
 			key.offset = start;
@@ -479,7 +479,7 @@ next_slot:
 						root->root_key.objectid,
 						key.objectid, key.offset -
 						extent_offset);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 				inode_sub_bytes(inode,
 						extent_end - key.offset);
 				*hint_byte = disk_bytenr;
@@ -495,7 +495,7 @@ next_slot:
 
 			ret = btrfs_del_items(trans, root, path, del_slot,
 					      del_nr);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 
 			del_nr = 0;
 			del_slot = 0;
@@ -509,7 +509,7 @@ next_slot:
 
 	if (del_nr > 0) {
 		ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	}
 
 	btrfs_free_path(path);
@@ -685,7 +685,7 @@ again:
 		ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
 					   root->root_key.objectid,
 					   inode->i_ino, orig_offset);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 
 		if (split == start) {
 			key.offset = start;
@@ -712,7 +712,7 @@ again:
 		ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
 					0, root->root_key.objectid,
 					inode->i_ino, orig_offset);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	}
 	other_start = 0;
 	other_end = start;
@@ -729,7 +729,7 @@ again:
 		ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
 					0, root->root_key.objectid,
 					inode->i_ino, orig_offset);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	}
 	if (del_nr == 0) {
 		fi = btrfs_item_ptr(leaf, path->slots[0],
@@ -747,7 +747,7 @@ again:
 		btrfs_mark_buffer_dirty(leaf);
 
 		ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	}
 out:
 	btrfs_free_path(path);
@@ -942,7 +942,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 		pinned[0] = grab_cache_page(inode->i_mapping, first_index);
 		if (!PageUptodate(pinned[0])) {
 			ret = btrfs_readpage(NULL, pinned[0]);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			wait_on_page_locked(pinned[0]);
 		} else {
 			unlock_page(pinned[0]);
@@ -952,7 +952,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 		pinned[1] = grab_cache_page(inode->i_mapping, last_index);
 		if (!PageUptodate(pinned[1])) {
 			ret = btrfs_readpage(NULL, pinned[1]);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			wait_on_page_locked(pinned[1]);
 		} else {
 			unlock_page(pinned[1]);
fs/btrfs/inode.c +61 -61

463 lines not on this page · raw message

fs/btrfs/ioctl.c +15 -15
index 9254b3d..18ba85b 100644
@@ -203,7 +203,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 	BUG_ON(!trans);
 
 	ret = btrfs_update_inode(trans, root, inode);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	btrfs_update_iflags(inode);
 	inode->i_ctime = CURRENT_TIME;
@@ -318,7 +318,7 @@ static noinline int create_subvol(struct btrfs_root *root,
 	 * insert the directory item
 	 */
 	ret = btrfs_set_inode_index(dir, &index);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = btrfs_insert_dir_item(trans, root,
 				    name, namelen, dir->i_ino, &key,
@@ -328,13 +328,13 @@ static noinline int create_subvol(struct btrfs_root *root,
 
 	btrfs_i_size_write(dir, dir->i_size + namelen * 2);
 	ret = btrfs_update_inode(trans, root, dir);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
 				 objectid, root->root_key.objectid,
 				 dir->i_ino, index, name, namelen);
 
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry));
 fail:
@@ -369,12 +369,12 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry)
 	}
 
 	ret = btrfs_snap_reserve_metadata(trans, pending_snapshot);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	list_add(&pending_snapshot->list,
 		 &trans->transaction->pending_snapshots);
 	ret = btrfs_commit_transaction(trans, root->fs_info->extent_root);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	ret = pending_snapshot->error;
 	if (ret)
@@ -1288,7 +1288,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 				dest->root_key.objectid,
 				dentry->d_name.name,
 				dentry->d_name.len);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 
 	btrfs_record_root_in_trans(trans, dest);
 
@@ -1301,11 +1301,11 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 		ret = btrfs_insert_orphan_item(trans,
 					root->fs_info->tree_root,
 					dest->root_key.objectid);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 	}
 
 	ret = btrfs_commit_transaction(trans, root);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 	inode->i_flags |= S_DEAD;
 out_up_write:
 	up_write(&root->fs_info->subvol_sem);
@@ -1633,11 +1633,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 							 new_key.offset,
 							 new_key.offset + datal,
 							 &hint_byte, 1);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 
 				ret = btrfs_insert_empty_item(trans, root, path,
 							      &new_key, size);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 
 				leaf = path->nodes[0];
 				slot = path->slots[0];
@@ -1663,7 +1663,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 							root->root_key.objectid,
 							inode->i_ino,
 							new_key.offset - datao);
-					BUG_ON(ret);
+					btrfs_fixable_bug_on(ret);
 				}
 			} else if (type == BTRFS_FILE_EXTENT_INLINE) {
 				u64 skip = 0;
@@ -1688,11 +1688,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 							 new_key.offset,
 							 new_key.offset + datal,
 							 &hint_byte, 1);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 
 				ret = btrfs_insert_empty_item(trans, root, path,
 							      &new_key, size);
-				BUG_ON(ret);
+				btrfs_fixable_bug_on(ret);
 
 				if (skip) {
 					u32 start =
@@ -1727,7 +1727,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 
 			BTRFS_I(inode)->flags = BTRFS_I(src)->flags;
 			ret = btrfs_update_inode(trans, root, inode);
-			BUG_ON(ret);
+			btrfs_fixable_bug_on(ret);
 			btrfs_end_transaction(trans, root);
 		}
 next:
fs/btrfs/relocation.c +27 -27

198 lines not on this page · raw message

fs/btrfs/transaction.c +24 -24

172 lines not on this page · raw message

fs/btrfs/tree-log.c +42 -42

316 lines not on this page · raw message

fs/btrfs/volumes.c +32 -32

225 lines not on this page · raw message

fs/btrfs/xattr.c +3 -3
index 88ecbb2..0b4f7e6 100644
@@ -119,7 +119,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
 		}
 
 		ret = btrfs_delete_one_dir_name(trans, root, path, di);
-		BUG_ON(ret);
+		btrfs_fixable_bug_on(ret);
 		btrfs_release_path(root, path);
 
 		/* if we don't have a value then we are removing the xattr */
@@ -138,7 +138,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
 	/* ok we have to create a completely new xattr */
 	ret = btrfs_insert_xattr_item(trans, root, path, inode->i_ino,
 				      name, name_len, value, size);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 out:
 	btrfs_free_path(path);
 	return ret;
@@ -166,7 +166,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans,
 
 	inode->i_ctime = CURRENT_TIME;
 	ret = btrfs_update_inode(trans, root, inode);
-	BUG_ON(ret);
+	btrfs_fixable_bug_on(ret);
 out:
 	btrfs_end_transaction_throttle(trans, root);
 	return ret;
Signature · 1 line
1.6.4.2