From: Jan Schmidt <list.btrfs@jan-o-sch.net>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, dustymabe@gmail.com
Subject: [PATCH] Btrfs: fix negative qgroup tracking from owner accounting (bug #61951)
Date: Thu, 24 Oct 2013 15:22:06 +0200 [thread overview]
Message-ID: <1382620926-8513-1-git-send-email-list.btrfs@jan-o-sch.net> (raw)
btrfs_dec_ref() queued a delayed ref for owner of a tree block. The qgroup
tracking is based on delayed refs. The owner of a tree block is set when a
tree block is allocated, it is never updated.
When you allocate a tree block and then remove the subvolume that did the
allocation, the qgroup accounting for that removal is correct. However, the
removal was accounted again for each subvolume deletion that also referenced
the tree block, because accounting was erroneously based on the owner.
Instead of queueing delayed refs for the non-existent owner, we now
queue delayed refs for the root being removed. This fixes the qgroup
accounting.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Tested-by: <dustymabe@gmail.com>
---
fs/btrfs/extent-tree.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d58bef1..7846cae 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3004,12 +3004,11 @@ out:
static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_buffer *buf,
- int full_backref, int inc, int for_cow)
+ int full_backref, u64 ref_root, int inc, int for_cow)
{
u64 bytenr;
u64 num_bytes;
u64 parent;
- u64 ref_root;
u32 nritems;
struct btrfs_key key;
struct btrfs_file_extent_item *fi;
@@ -3019,7 +3018,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
u64, u64, u64, u64, u64, u64, int);
- ref_root = btrfs_header_owner(buf);
nritems = btrfs_header_nritems(buf);
level = btrfs_header_level(buf);
@@ -3075,13 +3073,19 @@ fail:
int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct extent_buffer *buf, int full_backref, int for_cow)
{
- return __btrfs_mod_ref(trans, root, buf, full_backref, 1, for_cow);
+ u64 ref_root;
+
+ ref_root = btrfs_header_owner(buf);
+
+ return __btrfs_mod_ref(trans, root, buf, full_backref, ref_root,
+ 1, for_cow);
}
int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct extent_buffer *buf, int full_backref, int for_cow)
{
- return __btrfs_mod_ref(trans, root, buf, full_backref, 0, for_cow);
+ return __btrfs_mod_ref(trans, root, buf, full_backref, root->objectid,
+ 0, for_cow);
}
static int write_one_cache_group(struct btrfs_trans_handle *trans,
--
1.7.2.2
next reply other threads:[~2013-10-24 13:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 13:22 Jan Schmidt [this message]
2013-10-24 14:49 ` [PATCH] Btrfs: fix negative qgroup tracking from owner accounting (bug #61951) Wang Shilong
2013-10-24 15:36 ` Jan Schmidt
2013-10-25 4:08 ` Wang Shilong
2013-11-01 9:16 ` Jan Schmidt
2013-11-01 12:42 ` Josef Bacik
2013-11-02 4:35 ` Wang Shilong
2013-11-01 9:19 ` Jan Schmidt
2013-11-01 15:07 ` Josef Bacik
2013-11-04 17:42 ` Josef Bacik
2013-11-06 17:20 ` Jan Schmidt
2013-11-06 17:34 ` Josef Bacik
2013-11-07 1:33 ` Wang Shilong
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=1382620926-8513-1-git-send-email-list.btrfs@jan-o-sch.net \
--to=list.btrfs@jan-o-sch.net \
--cc=dsterba@suse.cz \
--cc=dustymabe@gmail.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).