[31/36] btrfs: cleanup pending bgs on transaction abort
diff mbox series

Message ID 20180911175807.26181-32-josef@toxicpanda.com
State New
Headers show
  • My current patch queue
Related show

Commit Message

Josef Bacik Sept. 11, 2018, 5:58 p.m. UTC
We may abort the transaction during a commit and not have a chance to
run the pending bgs stuff, which will leave block groups on our list and
cause us accounting issues and leaked memory.  Fix this by running the
pending bgs when we cleanup a transaction.

Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
 fs/btrfs/transaction.c | 4 ++++
 1 file changed, 4 insertions(+)

diff mbox series

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 46ca775a709e..9168efaca37e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2280,6 +2280,10 @@  int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
+	/* This cleans up the pending block groups list properly. */
+	if (!trans->aborted)
+		trans->aborted = ret;
+	btrfs_create_pending_block_groups(trans);
 	trans->block_rsv = NULL;
 	btrfs_warn(fs_info, "Skipping commit of aborted transaction.");