All of lore.kernel.org
 help / color / mirror / Atom feed
From: jeffm@suse.com
To: btrfs list <linux-btrfs@vger.kernel.org>
Cc: Chris Mason <chris.mason@oracle.com>
Subject: [patch v3 10/23] btrfs: Push up non-looped btrfs_start_transaction failures
Date: Thu, 08 Sep 2011 20:22:50 -0400	[thread overview]
Message-ID: <20110909002731.618284636@suse.com> (raw)
In-Reply-To: 20110909002240.141223014@suse.com

 This patch handles btrfs_start_transaction failures that don't occur
 in a loop and are obvious to simply push up. In all cases except the
 mark_garbage_root case, the error is already handled by BUG_ON in the
 caller.

 Update v2: This version also checks the returns from btrfs_drop_snapshot.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/btrfs/extent-tree.c |    6 +++++-
 fs/btrfs/relocation.c  |    9 ++++++---
 fs/btrfs/transaction.c |    6 ++++--
 fs/btrfs/tree-log.c    |    5 ++++-
 fs/btrfs/volumes.c     |    3 ++-
 5 files changed, 21 insertions(+), 8 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6319,7 +6319,11 @@ int btrfs_drop_snapshot(struct btrfs_roo
 	}
 
 	trans = btrfs_start_transaction(tree_root, 0);
-	BUG_ON(IS_ERR(trans));
+	if (IS_ERR(trans)) {
+		kfree(wc);
+		btrfs_free_path(path);
+		return PTR_ERR(trans);
+	}
 
 	if (block_rsv)
 		trans->block_rsv = block_rsv;
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2251,7 +2251,8 @@ again:
 		} else {
 			list_del_init(&reloc_root->root_list);
 		}
-		btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0);
+		ret = btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0);
+		BUG_ON(ret);
 	}
 
 	if (found) {
@@ -4096,7 +4097,8 @@ static noinline_for_stack int mark_garba
 	int ret;
 
 	trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
-	BUG_ON(IS_ERR(trans));
+	if (IS_ERR(trans))
+		return PTR_ERR(trans);
 
 	memset(&root->root_item.drop_progress, 0,
 		sizeof(root->root_item.drop_progress));
@@ -4176,7 +4178,8 @@ int btrfs_recover_relocation(struct btrf
 					err = ret;
 					goto out;
 				}
-				mark_garbage_root(reloc_root);
+				ret = mark_garbage_root(reloc_root);
+				BUG_ON(ret);
 			}
 		}
 
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1400,6 +1400,7 @@ int btrfs_commit_transaction(struct btrf
  */
 int btrfs_clean_old_snapshots(struct btrfs_root *root)
 {
+	int ret;
 	LIST_HEAD(list);
 	struct btrfs_fs_info *fs_info = root->fs_info;
 
@@ -1415,9 +1416,10 @@ int btrfs_clean_old_snapshots(struct btr
 
 		if (btrfs_header_backref_rev(root->node) <
 		    BTRFS_MIXED_BACKREF_REV)
-			btrfs_drop_snapshot(root, NULL, 0);
+			ret = btrfs_drop_snapshot(root, NULL, 0);
 		else
-			btrfs_drop_snapshot(root, NULL, 1);
+			ret = btrfs_drop_snapshot(root, NULL, 1);
+		BUG_ON(ret);
 	}
 	return 0;
 }
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3151,7 +3151,10 @@ int btrfs_recover_log_trees(struct btrfs
 	fs_info->log_root_recovering = 1;
 
 	trans = btrfs_start_transaction(fs_info->tree_root, 0);
-	BUG_ON(IS_ERR(trans));
+	if (IS_ERR(trans)) {
+		btrfs_free_path(path);
+		return PTR_ERR(trans);
+	}
 
 	wc.trans = trans;
 	wc.pin = 1;
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1876,7 +1876,8 @@ static int btrfs_relocate_chunk(struct b
 		return ret;
 
 	trans = btrfs_start_transaction(root, 0);
-	BUG_ON(IS_ERR(trans));
+	if (IS_ERR(trans))
+		return PTR_ERR(trans);
 
 	lock_chunks(root);
 



  parent reply	other threads:[~2011-09-09  0:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-09  0:22 [patch v3 00/23] More error handling fixes jeffm
2011-09-09  0:22 ` [patch v3 01/23] btrfs: Add btrfs_panic() jeffm
2011-09-09  0:22 ` [patch v3 02/23] btrfs: Catch locking failures in {set,clear}_extent_bit jeffm
2011-09-09  0:22 ` [patch v3 03/23] btrfs: Push up set_extent_bit errors to callers jeffm
2011-09-09  0:22 ` [patch v3 04/23] btrfs: Push up lock_extent " jeffm
2011-09-09  0:22 ` [patch v3 05/23] btrfs: Push up clear_extent_bit " jeffm
2011-09-09  0:22 ` [patch v3 06/23] btrfs: Push up unlock_extent " jeffm
2011-09-09  0:22 ` [patch v3 07/23] btrfs: Make pin_down_extent return void jeffm
2011-09-09  0:22 ` [patch v3 08/23] btrfs: Push up btrfs_pin_extent failures jeffm
2011-09-09  0:22 ` [patch v3 09/23] btrfs: btrfs_drop_snapshot should return int jeffm
2011-09-09  0:22 ` jeffm [this message]
2011-09-09  0:22 ` [patch v3 11/23] btrfs: Make set_range_writeback return void jeffm
2011-09-09  0:22 ` [patch v3 12/23] btrfs: extent_io.c: Make functions with no error conditions " jeffm
2011-09-09  0:22 ` [patch v3 13/23] btrfs: volumes.c: " jeffm
2011-09-09  0:22 ` [patch v3 14/23] btrfs: async-thread.c: " jeffm
2011-09-09  0:22 ` [patch v3 15/23] btrfs: tree-log.c: " jeffm
2011-09-09  0:22 ` [patch v3 16/23] btrfs: Make btrfs_init_compress " jeffm
2011-09-09  0:22 ` [patch v3 17/23] btrfs: Make btrfs_invalidate_inodes " jeffm
2011-09-09  0:22 ` [patch v3 18/23] btrfs: disk-io.c: Make functions with no error conditions " jeffm
2011-09-09  0:22 ` [patch v3 19/23] btrfs: extent-tree.c: " jeffm
2011-09-09  0:23 ` [patch v3 20/23] btrfs: file.c: " jeffm
2011-09-09  0:23 ` [patch v3 21/23] btrfs: simplify btrfs_submit_bio_hook jeffm
2011-09-09  0:23 ` [patch v3 22/23] btrfs: Factor out tree->ops->merge_bio_hook call jeffm
2011-09-09  0:23 ` [patch v3 23/23] btrfs: Push up ->submit_bio_hook failures jeffm
2011-09-09  0:35 ` [patch v3 00/23] More error handling fixes Jeff Mahoney

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=20110909002731.618284636@suse.com \
    --to=jeffm@suse.com \
    --cc=chris.mason@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.