linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
To: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org
Cc: jmwdev38@gmail.com, jbacik@fusionio.com, sensille@gmx.net
Subject: [PATCH] Btrfs: fix ENOSPC in qgroups (metadata)
Date: Mon, 28 Jan 2013 13:03:46 +0100	[thread overview]
Message-ID: <1359374626-14109-1-git-send-email-list.btrfs@jan-o-sch.net> (raw)

When start_transaction() returns ENOSPC after btrfs_qgroup_reserve(), we
must call btrfs_qgroup_free() to avoid the qgroup counters increasing when
there's actually no data being written.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
---

Josef: It looks like these places (except the first) are candidates for
btrfs_block_rsv_release, please check.

---
 fs/btrfs/transaction.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 87fac9a..f2430fd 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -332,13 +332,17 @@ start_transaction(struct btrfs_root *root, u64 num_items, int type,
 		ret = btrfs_block_rsv_add(root,
 					  &root->fs_info->trans_block_rsv,
 					  num_bytes, flush);
-		if (ret)
+		if (ret) {
+			btrfs_qgroup_free(root, qgroup_reserved);
 			return ERR_PTR(ret);
+		}
 	}
 again:
 	h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
-	if (!h)
+	if (!h) {
+		btrfs_qgroup_free(root, qgroup_reserved);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	/*
 	 * If we are JOIN_NOLOCK we're already committing a transaction and
@@ -369,6 +373,7 @@ again:
 		if (type < TRANS_JOIN_NOLOCK)
 			sb_end_intwrite(root->fs_info->sb);
 		kmem_cache_free(btrfs_trans_handle_cachep, h);
+		btrfs_qgroup_free(root, qgroup_reserved);
 		return ERR_PTR(ret);
 	}
 
-- 
1.7.1


             reply	other threads:[~2013-01-28 12:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-28 12:03 Jan Schmidt [this message]
2013-01-28 12:44 ` [PATCH] Btrfs: fix ENOSPC in qgroups (metadata) Miao Xie
2013-01-28 12:50   ` Jan Schmidt

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=1359374626-14109-1-git-send-email-list.btrfs@jan-o-sch.net \
    --to=list.btrfs@jan-o-sch.net \
    --cc=chris.mason@fusionio.com \
    --cc=jbacik@fusionio.com \
    --cc=jmwdev38@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sensille@gmx.net \
    /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).