diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2015-10-13 04:53:10 +0300 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-10-22 04:41:10 +0300 |
commit | 56fa9d0762ed17153c1bdff3c0aeeecbe522b504 (patch) | |
tree | 8a71bc780898b0fd8a8504187dd78be09a3ff948 /fs/btrfs/qgroup.c | |
parent | 51773bec7ea352f3b9afa11ecfc72324c7977335 (diff) | |
download | linux-56fa9d0762ed17153c1bdff3c0aeeecbe522b504.tar.xz |
btrfs: qgroup: Check if qgroup reserved space leaked
Add check at btrfs_destroy_inode() time to detect qgroup reserved space
leak.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/qgroup.c')
-rw-r--r-- | fs/btrfs/qgroup.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 879343c959d9..158633c9bbd9 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2645,3 +2645,35 @@ void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes) atomic_sub(num_bytes, &root->qgroup_meta_rsv); qgroup_free(root, num_bytes); } + +/* + * Check qgroup reserved space leaking, normally at destory inode + * time + */ +void btrfs_qgroup_check_reserved_leak(struct inode *inode) +{ + struct extent_changeset changeset; + struct ulist_node *unode; + struct ulist_iterator iter; + int ret; + + changeset.bytes_changed = 0; + changeset.range_changed = ulist_alloc(GFP_NOFS); + if (WARN_ON(!changeset.range_changed)) + return; + + ret = clear_record_extent_bits(&BTRFS_I(inode)->io_tree, 0, (u64)-1, + EXTENT_QGROUP_RESERVED, GFP_NOFS, &changeset); + + WARN_ON(ret < 0); + if (WARN_ON(changeset.bytes_changed)) { + ULIST_ITER_INIT(&iter); + while ((unode = ulist_next(changeset.range_changed, &iter))) { + btrfs_warn(BTRFS_I(inode)->root->fs_info, + "leaking qgroup reserved space, ino: %lu, start: %llu, end: %llu", + inode->i_ino, unode->val, unode->aux); + } + qgroup_free(BTRFS_I(inode)->root, changeset.bytes_changed); + } + ulist_free(changeset.range_changed); +} |